mirror of
https://github.com/eclipse-cdt/cdt
synced 2025-04-29 19:45:01 +02:00
Content Assist work
This commit is contained in:
parent
c01adea573
commit
33f033599d
45 changed files with 285 additions and 562 deletions
|
@ -1,3 +1,6 @@
|
|||
2003-12-17 Hoda Amer
|
||||
Small modifications to cope with the new interfaces
|
||||
|
||||
2003-12-15 Andrew Niefer
|
||||
added ContextualParseTest.testCompletionLookup_Unqualified
|
||||
added ContextualParseTest.testCompletionLookup_Qualified
|
||||
|
|
|
@ -19,6 +19,7 @@ import org.eclipse.cdt.core.CCProjectNature;
|
|||
import org.eclipse.cdt.core.CCorePlugin;
|
||||
import org.eclipse.cdt.core.model.CModelException;
|
||||
import org.eclipse.cdt.core.model.ICProject;
|
||||
import org.eclipse.cdt.internal.core.model.IWorkingCopy;
|
||||
import org.eclipse.cdt.internal.core.model.TranslationUnit;
|
||||
import org.eclipse.cdt.internal.core.search.indexing.IndexManager;
|
||||
import org.eclipse.cdt.internal.ui.text.contentassist.CCompletionProcessor;
|
||||
|
@ -109,38 +110,44 @@ public class CompletionProposalsTest extends TestCase{
|
|||
String buffer = tu.getBuffer().getContents();
|
||||
Document document = new Document(buffer);
|
||||
int pos = buffer.indexOf(" a ") + 2;
|
||||
int length = 0;
|
||||
CCompletionProcessor completionProcessor = new CCompletionProcessor(null);
|
||||
ICompletionProposal[] results = completionProcessor.evalProposals(document, pos, length, tu);
|
||||
IWorkingCopy wc = null;
|
||||
try{
|
||||
wc = tu.getWorkingCopy();
|
||||
}catch (CModelException e){
|
||||
fail("Failed to get working copy");
|
||||
}
|
||||
ICompletionProposal[] results = completionProcessor.evalProposals(document, pos, wc);
|
||||
try {
|
||||
Thread.sleep(MAGIC_NUMBER);
|
||||
} catch (InterruptedException e1) {
|
||||
fail( "Bogdan's hack did not suffice");
|
||||
}
|
||||
assertEquals(results.length, 7);
|
||||
assertEquals(results.length, 8);
|
||||
for (int i = 0; i<results.length; i++){
|
||||
ICompletionProposal proposal = results[i];
|
||||
String displayString = proposal.getDisplayString();
|
||||
switch(i){
|
||||
case 0:
|
||||
// case 0 is a key word found by the parser "auto"
|
||||
case 1:
|
||||
assertEquals(displayString, "aVariable");
|
||||
break;
|
||||
case 1:
|
||||
case 2:
|
||||
assertEquals(displayString, "aFunction() bool");
|
||||
break;
|
||||
case 2:
|
||||
case 3:
|
||||
assertEquals(displayString, "aClass");
|
||||
break;
|
||||
case 3:
|
||||
case 4:
|
||||
assertEquals(displayString, "anotherClass");
|
||||
break;
|
||||
case 4:
|
||||
case 5:
|
||||
assertEquals(displayString, "anEnumeration");
|
||||
break;
|
||||
case 5:
|
||||
case 6:
|
||||
assertEquals(displayString, "AStruct");
|
||||
break;
|
||||
case 6:
|
||||
case 7:
|
||||
assertEquals(displayString, "AMacro");
|
||||
break;
|
||||
}
|
||||
|
|
|
@ -121,7 +121,7 @@ public class CompleteParseBaseTest extends TestCase
|
|||
/* (non-Javadoc)
|
||||
* @see org.eclipse.cdt.core.parser.ast.IASTNode#lookup(java.lang.String, org.eclipse.cdt.core.parser.ast.IASTNode.LookupKind, org.eclipse.cdt.core.parser.ast.IASTNode)
|
||||
*/
|
||||
public LookupResult lookup(String prefix, LookupKind kind, IASTNode context) throws LookupException {
|
||||
public LookupResult lookup(String prefix, LookupKind[] kind, IASTNode context) throws LookupException {
|
||||
// TODO Auto-generated method stub
|
||||
return null;
|
||||
}
|
||||
|
|
|
@ -133,10 +133,11 @@ public class ContextualParseTest extends CompleteParseBaseTest {
|
|||
assertNotNull( prefix );
|
||||
assertTrue( node.getCompletionScope() instanceof IASTFunction );
|
||||
assertEquals( prefix, "a" );
|
||||
assertEquals( node.getCompletionKind(), IASTCompletionNode.CompletionKind.VARIABLE_TYPE );
|
||||
assertEquals( node.getCompletionKind(), IASTCompletionNode.CompletionKind.SINGLE_NAME_REFERENCE );
|
||||
|
||||
|
||||
LookupResult result = node.getCompletionScope().lookup( prefix, IASTNode.LookupKind.ALL, node.getCompletionContext() );
|
||||
IASTNode.LookupKind[] kinds = new IASTNode.LookupKind[1];
|
||||
kinds[0] = IASTNode.LookupKind.ALL;
|
||||
LookupResult result = node.getCompletionScope().lookup( prefix, kinds, node.getCompletionContext() );
|
||||
assertEquals( result.getPrefix(), prefix );
|
||||
|
||||
Iterator iter = result.getNodes();
|
||||
|
@ -177,7 +178,9 @@ public class ContextualParseTest extends CompleteParseBaseTest {
|
|||
assertNotNull( node.getCompletionContext() );
|
||||
assertTrue( node.getCompletionContext() instanceof IASTClassSpecifier );
|
||||
|
||||
LookupResult result = node.getCompletionScope().lookup( prefix, IASTNode.LookupKind.ALL, node.getCompletionContext() );
|
||||
IASTNode.LookupKind[] kinds = new IASTNode.LookupKind[1];
|
||||
kinds[0] = IASTNode.LookupKind.ALL;
|
||||
LookupResult result = node.getCompletionScope().lookup( prefix, kinds, node.getCompletionContext() );
|
||||
assertEquals( result.getPrefix(), prefix );
|
||||
|
||||
Iterator iter = result.getNodes();
|
||||
|
@ -229,7 +232,9 @@ public class ContextualParseTest extends CompleteParseBaseTest {
|
|||
assertNotNull( node.getCompletionContext() );
|
||||
assertTrue( node.getCompletionContext() instanceof IASTClassSpecifier );
|
||||
|
||||
LookupResult result = node.getCompletionScope().lookup( prefix, IASTNode.LookupKind.METHODS, node.getCompletionContext() );
|
||||
IASTNode.LookupKind[] kinds = new IASTNode.LookupKind[1];
|
||||
kinds[0] = IASTNode.LookupKind.METHODS;
|
||||
LookupResult result = node.getCompletionScope().lookup( prefix, kinds, node.getCompletionContext() );
|
||||
assertEquals( result.getPrefix(), prefix );
|
||||
|
||||
Iterator iter = result.getNodes();
|
||||
|
|
|
@ -1,3 +1,6 @@
|
|||
2003-12-17 Hoda Amer
|
||||
Content Assist work : Integrated with Parser and Symbol table modifications
|
||||
|
||||
2003-12-15 Andrew Niefer
|
||||
Changed IASTNode.lookup to take the context as a parameter
|
||||
created ASTNode to implement IASTNode, ASTSymbolOwner extends it.
|
||||
|
|
|
@ -29,5 +29,4 @@ public class Enum
|
|||
{
|
||||
return enumValue;
|
||||
}
|
||||
|
||||
}
|
||||
|
|
|
@ -58,6 +58,6 @@ public interface IASTNode {
|
|||
public Iterator getNodes();
|
||||
}
|
||||
|
||||
public LookupResult lookup( String prefix, LookupKind kind, IASTNode context) throws LookupException;
|
||||
public LookupResult lookup( String prefix, LookupKind[] kind, IASTNode context) throws LookupException;
|
||||
}
|
||||
|
||||
|
|
|
@ -114,7 +114,7 @@ public class ContextualParser extends Parser implements IParser {
|
|||
/**
|
||||
* @return
|
||||
*/
|
||||
private IASTCompletionNode.CompletionKind getCompletionKind() {
|
||||
protected IASTCompletionNode.CompletionKind getCompletionKind() {
|
||||
return kind;
|
||||
}
|
||||
|
||||
|
|
|
@ -767,6 +767,8 @@ public abstract class Parser implements IParser
|
|||
|
||||
if( scope instanceof IASTClassSpecifier )
|
||||
setCompletionKind( CompletionKind.FIELD_TYPE );
|
||||
else if (scope instanceof IASTCodeScope)
|
||||
setCompletionKind( CompletionKind.SINGLE_NAME_REFERENCE);
|
||||
else
|
||||
setCompletionKind( CompletionKind.VARIABLE_TYPE );
|
||||
try
|
||||
|
|
|
@ -96,11 +96,4 @@ public class ASTASMDefinition extends ASTAnonymousDeclaration implements IASTASM
|
|||
public void exitScope(ISourceElementRequestor requestor)
|
||||
{
|
||||
}
|
||||
/* (non-Javadoc)
|
||||
* @see org.eclipse.cdt.core.parser.ast.IASTNode#lookup(java.lang.String, org.eclipse.cdt.core.parser.ast.IASTNode.LookupKind)
|
||||
*/
|
||||
public LookupResult lookup(String prefix, LookupKind kind, IASTNode context) {
|
||||
// TODO Auto-generated method stub
|
||||
return null;
|
||||
}
|
||||
}
|
||||
|
|
|
@ -118,12 +118,4 @@ public class ASTAbstractTypeSpecifierDeclaration
|
|||
{
|
||||
return offsets.getEndingOffset();
|
||||
}
|
||||
|
||||
/* (non-Javadoc)
|
||||
* @see org.eclipse.cdt.core.parser.ast.IASTNode#lookup(java.lang.String, org.eclipse.cdt.core.parser.ast.IASTNode.LookupKind)
|
||||
*/
|
||||
public LookupResult lookup(String prefix, LookupKind kind, IASTNode context) {
|
||||
// TODO Auto-generated method stub
|
||||
return null;
|
||||
}
|
||||
}
|
||||
|
|
|
@ -18,7 +18,7 @@ import org.eclipse.cdt.internal.core.parser.pst.IContainerSymbol;
|
|||
* @author jcamelon
|
||||
*
|
||||
*/
|
||||
public abstract class ASTAnonymousDeclaration implements IASTDeclaration
|
||||
public abstract class ASTAnonymousDeclaration extends ASTNode implements IASTDeclaration
|
||||
{
|
||||
private final IContainerSymbol ownerScope;
|
||||
/**
|
||||
|
|
|
@ -113,11 +113,4 @@ public class ASTLinkageSpecification extends ASTAnonymousDeclaration implements
|
|||
/* do nothing */
|
||||
}
|
||||
}
|
||||
/* (non-Javadoc)
|
||||
* @see org.eclipse.cdt.core.parser.ast.IASTNode#lookup(java.lang.String, org.eclipse.cdt.core.parser.ast.IASTNode.LookupKind)
|
||||
*/
|
||||
public LookupResult lookup(String prefix, LookupKind kind, IASTNode context) {
|
||||
// TODO Auto-generated method stub
|
||||
return null;
|
||||
}
|
||||
}
|
||||
|
|
|
@ -30,7 +30,7 @@ public class ASTNode implements IASTNode {
|
|||
/* (non-Javadoc)
|
||||
* @see org.eclipse.cdt.core.parser.ast.IASTNode#lookup(java.lang.String, org.eclipse.cdt.core.parser.ast.IASTNode.LookupKind, org.eclipse.cdt.core.parser.ast.IASTNode)
|
||||
*/
|
||||
public LookupResult lookup(String prefix, LookupKind kind, IASTNode context) throws LookupException {
|
||||
public LookupResult lookup(String prefix, LookupKind[] kind, IASTNode context) throws LookupException {
|
||||
if( ! ( this instanceof ISymbolOwner ) || ( context != null && !(context instanceof ISymbolOwner) ) ){
|
||||
return null;
|
||||
}
|
||||
|
@ -52,7 +52,16 @@ public class ASTNode implements IASTNode {
|
|||
throw new LookupException();
|
||||
}
|
||||
|
||||
TypeFilter filter = new TypeFilter( kind );
|
||||
TypeFilter filter = null;
|
||||
if( kind != null && kind.length > 0 ){
|
||||
filter = new TypeFilter( kind[0] );
|
||||
for( int i = 1; i < kind.length; i++ ){
|
||||
filter.addFilteredType( kind[i] );
|
||||
}
|
||||
} else {
|
||||
filter = new TypeFilter();
|
||||
}
|
||||
|
||||
List lookupResults = null;
|
||||
try {
|
||||
if( qualification != null ){
|
||||
|
@ -64,6 +73,9 @@ public class ASTNode implements IASTNode {
|
|||
throw new LookupException();
|
||||
}
|
||||
|
||||
if(lookupResults == null)
|
||||
return null;
|
||||
|
||||
ListIterator iter = lookupResults.listIterator();
|
||||
while( iter.hasNext() ){
|
||||
ISymbol s = (ISymbol) iter.next();
|
||||
|
|
|
@ -23,7 +23,7 @@ import org.eclipse.cdt.internal.core.parser.pst.TypeInfo;
|
|||
* @author jcamelon
|
||||
*
|
||||
*/
|
||||
public class ASTSimpleTypeSpecifier implements IASTSimpleTypeSpecifier
|
||||
public class ASTSimpleTypeSpecifier extends ASTNode implements IASTSimpleTypeSpecifier
|
||||
{
|
||||
private final List refs;
|
||||
private ISymbol symbol;
|
||||
|
@ -148,13 +148,4 @@ public class ASTSimpleTypeSpecifier implements IASTSimpleTypeSpecifier
|
|||
{
|
||||
return symbol.getTypeInfo().checkBit( TypeInfo.isImaginary );
|
||||
}
|
||||
|
||||
/* (non-Javadoc)
|
||||
* @see org.eclipse.cdt.core.parser.ast.IASTNode#lookup(java.lang.String, org.eclipse.cdt.core.parser.ast.IASTNode.LookupKind)
|
||||
*/
|
||||
public LookupResult lookup(String prefix, LookupKind kind, IASTNode context) {
|
||||
// TODO Auto-generated method stub
|
||||
return null;
|
||||
}
|
||||
|
||||
}
|
||||
|
|
|
@ -22,7 +22,7 @@ import org.eclipse.cdt.core.parser.ast.IASTTemplateDeclaration;
|
|||
* @author jcamelon
|
||||
*
|
||||
*/
|
||||
public class ASTTemplateDeclaration implements IASTTemplateDeclaration
|
||||
public class ASTTemplateDeclaration extends ASTNode implements IASTTemplateDeclaration
|
||||
{
|
||||
/**
|
||||
*
|
||||
|
@ -122,11 +122,4 @@ public class ASTTemplateDeclaration implements IASTTemplateDeclaration
|
|||
{
|
||||
// TODO Auto-generated method stub
|
||||
}
|
||||
/* (non-Javadoc)
|
||||
* @see org.eclipse.cdt.core.parser.ast.IASTNode#lookup(java.lang.String, org.eclipse.cdt.core.parser.ast.IASTNode.LookupKind)
|
||||
*/
|
||||
public LookupResult lookup(String prefix, LookupKind kind, IASTNode context) {
|
||||
// TODO Auto-generated method stub
|
||||
return null;
|
||||
}
|
||||
}
|
||||
|
|
|
@ -20,7 +20,7 @@ import org.eclipse.cdt.core.parser.ast.IASTTemplateInstantiation;
|
|||
* @author jcamelon
|
||||
*
|
||||
*/
|
||||
public class ASTTemplateInstantiation implements IASTTemplateInstantiation
|
||||
public class ASTTemplateInstantiation extends ASTNode implements IASTTemplateInstantiation
|
||||
{
|
||||
/**
|
||||
*
|
||||
|
@ -104,11 +104,4 @@ public class ASTTemplateInstantiation implements IASTTemplateInstantiation
|
|||
{
|
||||
// TODO Auto-generated method stub
|
||||
}
|
||||
/* (non-Javadoc)
|
||||
* @see org.eclipse.cdt.core.parser.ast.IASTNode#lookup(java.lang.String, org.eclipse.cdt.core.parser.ast.IASTNode.LookupKind)
|
||||
*/
|
||||
public LookupResult lookup(String prefix, LookupKind kind, IASTNode context) {
|
||||
// TODO Auto-generated method stub
|
||||
return null;
|
||||
}
|
||||
}
|
||||
|
|
|
@ -20,7 +20,7 @@ import org.eclipse.cdt.core.parser.ast.IASTTemplateSpecialization;
|
|||
* @author jcamelon
|
||||
*
|
||||
*/
|
||||
public class ASTTemplateSpecialization implements IASTTemplateSpecialization
|
||||
public class ASTTemplateSpecialization extends ASTNode implements IASTTemplateSpecialization
|
||||
{
|
||||
/**
|
||||
*
|
||||
|
@ -104,11 +104,4 @@ public class ASTTemplateSpecialization implements IASTTemplateSpecialization
|
|||
{
|
||||
// TODO Auto-generated method stub
|
||||
}
|
||||
/* (non-Javadoc)
|
||||
* @see org.eclipse.cdt.core.parser.ast.IASTNode#lookup(java.lang.String, org.eclipse.cdt.core.parser.ast.IASTNode.LookupKind)
|
||||
*/
|
||||
public LookupResult lookup(String prefix, LookupKind kind, IASTNode context) {
|
||||
// TODO Auto-generated method stub
|
||||
return null;
|
||||
}
|
||||
}
|
||||
|
|
|
@ -25,7 +25,7 @@ import org.eclipse.cdt.internal.core.parser.ast.Offsets;
|
|||
* @author jcamelon
|
||||
*
|
||||
*/
|
||||
public class ASTUsingDeclaration implements IASTUsingDeclaration
|
||||
public class ASTUsingDeclaration extends ASTNode implements IASTUsingDeclaration
|
||||
{
|
||||
private final IASTScope ownerScope;
|
||||
private final boolean isTypeName;
|
||||
|
@ -128,11 +128,4 @@ public class ASTUsingDeclaration implements IASTUsingDeclaration
|
|||
{
|
||||
return declaration;
|
||||
}
|
||||
/* (non-Javadoc)
|
||||
* @see org.eclipse.cdt.core.parser.ast.IASTNode#lookup(java.lang.String, org.eclipse.cdt.core.parser.ast.IASTNode.LookupKind)
|
||||
*/
|
||||
public LookupResult lookup(String prefix, LookupKind kind, IASTNode context) {
|
||||
// TODO Auto-generated method stub
|
||||
return null;
|
||||
}
|
||||
}
|
||||
|
|
|
@ -123,11 +123,4 @@ public class ASTUsingDirective extends ASTAnonymousDeclaration implements IASTUs
|
|||
return namespace;
|
||||
}
|
||||
|
||||
/* (non-Javadoc)
|
||||
* @see org.eclipse.cdt.core.parser.ast.IASTNode#lookup(java.lang.String, org.eclipse.cdt.core.parser.ast.IASTNode.LookupKind)
|
||||
*/
|
||||
public LookupResult lookup(String prefix, LookupKind kind, IASTNode context) {
|
||||
// TODO Auto-generated method stub
|
||||
return null;
|
||||
}
|
||||
}
|
||||
|
|
|
@ -97,13 +97,4 @@ public class ASTASMDefinition
|
|||
public void exitScope(ISourceElementRequestor requestor)
|
||||
{
|
||||
}
|
||||
|
||||
/* (non-Javadoc)
|
||||
* @see org.eclipse.cdt.core.parser.ast.IASTNode#lookup(java.lang.String, org.eclipse.cdt.core.parser.ast.IASTNode.LookupKind)
|
||||
*/
|
||||
public LookupResult lookup(String prefix, LookupKind kind, IASTNode context) {
|
||||
// TODO Auto-generated method stub
|
||||
return null;
|
||||
}
|
||||
|
||||
}
|
||||
|
|
|
@ -115,13 +115,4 @@ public class ASTAbstractTypeSpecifierDeclaration
|
|||
public void exitScope(ISourceElementRequestor requestor)
|
||||
{
|
||||
}
|
||||
|
||||
/* (non-Javadoc)
|
||||
* @see org.eclipse.cdt.core.parser.ast.IASTNode#lookup(java.lang.String, org.eclipse.cdt.core.parser.ast.IASTNode.LookupKind)
|
||||
*/
|
||||
public LookupResult lookup(String prefix, LookupKind kind, IASTNode context) {
|
||||
// TODO Auto-generated method stub
|
||||
return null;
|
||||
}
|
||||
|
||||
}
|
||||
|
|
|
@ -23,7 +23,7 @@ import org.eclipse.cdt.core.parser.ast.IASTNode;
|
|||
* @author jcamelon
|
||||
*
|
||||
*/
|
||||
public class ASTCompilationUnit implements IASTCompilationUnit, IASTQScope {
|
||||
public class ASTCompilationUnit extends ASTNode implements IASTCompilationUnit, IASTQScope {
|
||||
|
||||
private List declarations = new ArrayList();
|
||||
/* (non-Javadoc)
|
||||
|
@ -74,13 +74,4 @@ public class ASTCompilationUnit implements IASTCompilationUnit, IASTQScope {
|
|||
/* do nothing */
|
||||
}
|
||||
}
|
||||
|
||||
/* (non-Javadoc)
|
||||
* @see org.eclipse.cdt.core.parser.ast.IASTNode#lookup(java.lang.String, org.eclipse.cdt.core.parser.ast.IASTNode.LookupKind)
|
||||
*/
|
||||
public LookupResult lookup(String prefix, LookupKind kind, IASTNode context) {
|
||||
// TODO Auto-generated method stub
|
||||
return null;
|
||||
}
|
||||
|
||||
}
|
||||
|
|
|
@ -17,7 +17,7 @@ import org.eclipse.cdt.core.parser.ast.IASTScope;
|
|||
* @author jcamelon
|
||||
*
|
||||
*/
|
||||
public abstract class ASTDeclaration implements IASTDeclaration {
|
||||
public abstract class ASTDeclaration extends ASTNode implements IASTDeclaration {
|
||||
|
||||
private final IASTScope scope;
|
||||
public ASTDeclaration( IASTScope scope )
|
||||
|
|
|
@ -23,7 +23,7 @@ import org.eclipse.cdt.internal.core.parser.ast.NamedOffsets;
|
|||
* @author jcamelon
|
||||
*
|
||||
*/
|
||||
public class ASTElaboratedTypeSpecifier implements IASTElaboratedTypeSpecifier
|
||||
public class ASTElaboratedTypeSpecifier extends ASTNode implements IASTElaboratedTypeSpecifier
|
||||
{
|
||||
|
||||
private NamedOffsets offsets = new NamedOffsets();
|
||||
|
@ -156,11 +156,4 @@ public class ASTElaboratedTypeSpecifier implements IASTElaboratedTypeSpecifier
|
|||
{
|
||||
offsets.setNameEndOffset(o);
|
||||
}
|
||||
/* (non-Javadoc)
|
||||
* @see org.eclipse.cdt.core.parser.ast.IASTNode#lookup(java.lang.String, org.eclipse.cdt.core.parser.ast.IASTNode.LookupKind)
|
||||
*/
|
||||
public LookupResult lookup(String prefix, LookupKind kind, IASTNode context) {
|
||||
// TODO Auto-generated method stub
|
||||
return null;
|
||||
}
|
||||
}
|
||||
|
|
|
@ -281,13 +281,4 @@ public class ASTFunction extends ASTDeclaration implements IASTFunction
|
|||
{
|
||||
return hasFunctionTryBlock;
|
||||
}
|
||||
/* (non-Javadoc)
|
||||
* @see org.eclipse.cdt.core.parser.ast.IASTNode#lookup(java.lang.String, org.eclipse.cdt.core.parser.ast.IASTNode.LookupKind)
|
||||
*/
|
||||
public LookupResult lookup(String prefix, LookupKind kind, IASTNode context) {
|
||||
// TODO Auto-generated method stub
|
||||
return null;
|
||||
}
|
||||
|
||||
|
||||
}
|
||||
|
|
|
@ -126,13 +126,4 @@ public class ASTLinkageSpecification
|
|||
/* do nothing */
|
||||
}
|
||||
}
|
||||
|
||||
/* (non-Javadoc)
|
||||
* @see org.eclipse.cdt.core.parser.ast.IASTNode#lookup(java.lang.String, org.eclipse.cdt.core.parser.ast.IASTNode.LookupKind)
|
||||
*/
|
||||
public LookupResult lookup(String prefix, LookupKind kind, IASTNode context) {
|
||||
// TODO Auto-generated method stub
|
||||
return null;
|
||||
}
|
||||
|
||||
}
|
||||
|
|
|
@ -146,11 +146,4 @@ public class ASTNamespaceAlias extends ASTDeclaration implements IASTNamespaceAl
|
|||
{
|
||||
offsets.setNameEndOffset(o);
|
||||
}
|
||||
/* (non-Javadoc)
|
||||
* @see org.eclipse.cdt.core.parser.ast.IASTNode#lookup(java.lang.String, org.eclipse.cdt.core.parser.ast.IASTNode.LookupKind)
|
||||
*/
|
||||
public LookupResult lookup(String prefix, LookupKind kind, IASTNode context) {
|
||||
// TODO Auto-generated method stub
|
||||
return null;
|
||||
}
|
||||
}
|
||||
|
|
|
@ -160,11 +160,4 @@ public class ASTNamespaceDefinition extends ASTDeclaration implements IASTNamesp
|
|||
{
|
||||
offsets.setNameEndOffset(o);
|
||||
}
|
||||
/* (non-Javadoc)
|
||||
* @see org.eclipse.cdt.core.parser.ast.IASTNode#lookup(java.lang.String, org.eclipse.cdt.core.parser.ast.IASTNode.LookupKind)
|
||||
*/
|
||||
public LookupResult lookup(String prefix, LookupKind kind, IASTNode context) {
|
||||
// TODO Auto-generated method stub
|
||||
return null;
|
||||
}
|
||||
}
|
||||
|
|
|
@ -0,0 +1,34 @@
|
|||
/*
|
||||
* Created on 17/12/2003
|
||||
*
|
||||
* To change the template for this generated file go to
|
||||
* Window - Preferences - Java - Code Generation - Code and Comments
|
||||
*/
|
||||
package org.eclipse.cdt.internal.core.parser.ast.quick;
|
||||
|
||||
import org.eclipse.cdt.core.parser.ast.IASTNode;
|
||||
import org.eclipse.cdt.core.parser.ast.IASTNode.LookupException;
|
||||
import org.eclipse.cdt.core.parser.ast.IASTNode.LookupKind;
|
||||
import org.eclipse.cdt.core.parser.ast.IASTNode.LookupResult;
|
||||
|
||||
/**
|
||||
* @author hamer
|
||||
*
|
||||
* To change the template for this generated type comment go to
|
||||
* Window - Preferences - Java - Code Generation - Code and Comments
|
||||
*/
|
||||
public class ASTNode implements IASTNode {
|
||||
|
||||
/* (non-Javadoc)
|
||||
* @see org.eclipse.cdt.core.parser.ast.IASTNode#lookup(java.lang.String, org.eclipse.cdt.core.parser.ast.IASTNode.LookupKind[], org.eclipse.cdt.core.parser.ast.IASTNode)
|
||||
*/
|
||||
public LookupResult lookup(
|
||||
String prefix,
|
||||
LookupKind[] kind,
|
||||
IASTNode context)
|
||||
throws LookupException {
|
||||
// TODO Auto-generated method stub
|
||||
return null;
|
||||
}
|
||||
|
||||
}
|
|
@ -13,6 +13,9 @@ package org.eclipse.cdt.internal.core.parser.ast.quick;
|
|||
import org.eclipse.cdt.core.parser.ast.IASTNode;
|
||||
import org.eclipse.cdt.core.parser.ast.IASTScope;
|
||||
import org.eclipse.cdt.core.parser.ast.IASTScopedTypeSpecifier;
|
||||
import org.eclipse.cdt.core.parser.ast.IASTNode.LookupException;
|
||||
import org.eclipse.cdt.core.parser.ast.IASTNode.LookupKind;
|
||||
import org.eclipse.cdt.core.parser.ast.IASTNode.LookupResult;
|
||||
import org.eclipse.cdt.internal.core.parser.ast.ASTQualifiedNamedElement;
|
||||
|
||||
/**
|
||||
|
@ -36,9 +39,13 @@ public class ASTScopedTypeSpecifier extends ASTQualifiedNamedElement implements
|
|||
return scope;
|
||||
}
|
||||
/* (non-Javadoc)
|
||||
* @see org.eclipse.cdt.core.parser.ast.IASTNode#lookup(java.lang.String, org.eclipse.cdt.core.parser.ast.IASTNode.LookupKind)
|
||||
* @see org.eclipse.cdt.core.parser.ast.IASTNode#lookup(java.lang.String, org.eclipse.cdt.core.parser.ast.IASTNode.LookupKind[], org.eclipse.cdt.core.parser.ast.IASTNode)
|
||||
*/
|
||||
public LookupResult lookup(String prefix, LookupKind kind, IASTNode context) {
|
||||
public LookupResult lookup(
|
||||
String prefix,
|
||||
LookupKind[] kind,
|
||||
IASTNode context)
|
||||
throws LookupException {
|
||||
// TODO Auto-generated method stub
|
||||
return null;
|
||||
}
|
||||
|
|
|
@ -23,7 +23,7 @@ import org.eclipse.cdt.core.parser.ast.IASTTypeSpecifier;
|
|||
* @author jcamelon
|
||||
*
|
||||
*/
|
||||
public class ASTSimpleTypeSpecifier implements IASTSimpleTypeSpecifier
|
||||
public class ASTSimpleTypeSpecifier extends ASTNode implements IASTSimpleTypeSpecifier
|
||||
{
|
||||
private final boolean imaginary;
|
||||
private final boolean complex;
|
||||
|
@ -193,12 +193,4 @@ public class ASTSimpleTypeSpecifier implements IASTSimpleTypeSpecifier
|
|||
{
|
||||
return imaginary;
|
||||
}
|
||||
|
||||
/* (non-Javadoc)
|
||||
* @see org.eclipse.cdt.core.parser.ast.IASTNode#lookup(java.lang.String, org.eclipse.cdt.core.parser.ast.IASTNode.LookupKind)
|
||||
*/
|
||||
public LookupResult lookup(String prefix, LookupKind kind, IASTNode context) {
|
||||
// TODO Auto-generated method stub
|
||||
return null;
|
||||
}
|
||||
}
|
||||
|
|
|
@ -137,12 +137,4 @@ public class ASTTemplateDeclaration extends ASTDeclaration implements IASTTempla
|
|||
/* do nothing */
|
||||
}
|
||||
}
|
||||
|
||||
/* (non-Javadoc)
|
||||
* @see org.eclipse.cdt.core.parser.ast.IASTNode#lookup(java.lang.String, org.eclipse.cdt.core.parser.ast.IASTNode.LookupKind)
|
||||
*/
|
||||
public LookupResult lookup(String prefix, LookupKind kind, IASTNode context) {
|
||||
// TODO Auto-generated method stub
|
||||
return null;
|
||||
}
|
||||
}
|
||||
|
|
|
@ -120,12 +120,4 @@ public class ASTTemplateInstantiation extends ASTDeclaration implements IASTTemp
|
|||
/* do nothing */
|
||||
}
|
||||
}
|
||||
|
||||
/* (non-Javadoc)
|
||||
* @see org.eclipse.cdt.core.parser.ast.IASTNode#lookup(java.lang.String, org.eclipse.cdt.core.parser.ast.IASTNode.LookupKind)
|
||||
*/
|
||||
public LookupResult lookup(String prefix, LookupKind kind, IASTNode context) {
|
||||
// TODO Auto-generated method stub
|
||||
return null;
|
||||
}
|
||||
}
|
||||
|
|
|
@ -114,12 +114,4 @@ public class ASTTemplateSpecialization extends ASTDeclaration implements IASTTem
|
|||
/* do nothing */
|
||||
}
|
||||
}
|
||||
|
||||
/* (non-Javadoc)
|
||||
* @see org.eclipse.cdt.core.parser.ast.IASTNode#lookup(java.lang.String, org.eclipse.cdt.core.parser.ast.IASTNode.LookupKind)
|
||||
*/
|
||||
public LookupResult lookup(String prefix, LookupKind kind, IASTNode context) {
|
||||
// TODO Auto-generated method stub
|
||||
return null;
|
||||
}
|
||||
}
|
||||
|
|
|
@ -148,12 +148,4 @@ public class ASTTypedefDeclaration extends ASTDeclaration implements IASTTypedef
|
|||
{
|
||||
offsets.setNameEndOffset(o);
|
||||
}
|
||||
/* (non-Javadoc)
|
||||
* @see org.eclipse.cdt.core.parser.ast.IASTNode#lookup(java.lang.String, org.eclipse.cdt.core.parser.ast.IASTNode.LookupKind)
|
||||
*/
|
||||
public LookupResult lookup(String prefix, LookupKind kind, IASTNode context) {
|
||||
// TODO Auto-generated method stub
|
||||
return null;
|
||||
}
|
||||
|
||||
}
|
||||
|
|
|
@ -113,11 +113,4 @@ public class ASTUsingDeclaration
|
|||
{
|
||||
throw new ASTNotImplementedException();
|
||||
}
|
||||
/* (non-Javadoc)
|
||||
* @see org.eclipse.cdt.core.parser.ast.IASTNode#lookup(java.lang.String, org.eclipse.cdt.core.parser.ast.IASTNode.LookupKind)
|
||||
*/
|
||||
public LookupResult lookup(String prefix, LookupKind kind, IASTNode context) {
|
||||
// TODO Auto-generated method stub
|
||||
return null;
|
||||
}
|
||||
}
|
||||
|
|
|
@ -105,11 +105,4 @@ public class ASTUsingDirective
|
|||
{
|
||||
throw new ASTNotImplementedException();
|
||||
}
|
||||
/* (non-Javadoc)
|
||||
* @see org.eclipse.cdt.core.parser.ast.IASTNode#lookup(java.lang.String, org.eclipse.cdt.core.parser.ast.IASTNode.LookupKind)
|
||||
*/
|
||||
public LookupResult lookup(String prefix, LookupKind kind, IASTNode context) {
|
||||
// TODO Auto-generated method stub
|
||||
return null;
|
||||
}
|
||||
}
|
||||
|
|
|
@ -229,12 +229,4 @@ public class ASTVariable extends ASTDeclaration implements IASTVariable
|
|||
{
|
||||
offsets.setNameEndOffset(o);
|
||||
}
|
||||
/* (non-Javadoc)
|
||||
* @see org.eclipse.cdt.core.parser.ast.IASTNode#lookup(java.lang.String, org.eclipse.cdt.core.parser.ast.IASTNode.LookupKind)
|
||||
*/
|
||||
public LookupResult lookup(String prefix, LookupKind kind, IASTNode context) {
|
||||
// TODO Auto-generated method stub
|
||||
return null;
|
||||
}
|
||||
|
||||
}
|
||||
|
|
|
@ -1,3 +1,6 @@
|
|||
2003-12-17 Hoda Amer
|
||||
Content Assist work: Completion Engine calling new lookups
|
||||
|
||||
2003-12-15 Andrew Niefer
|
||||
Updated CompletionEngine to match new signature for IASTNode.lookup
|
||||
|
||||
|
|
|
@ -10,12 +10,9 @@ import java.util.Arrays;
|
|||
import java.util.Iterator;
|
||||
import java.util.LinkedList;
|
||||
import java.util.List;
|
||||
import java.util.Map;
|
||||
|
||||
import org.eclipse.cdt.core.model.CModelException;
|
||||
import org.eclipse.cdt.core.model.CoreModel;
|
||||
import org.eclipse.cdt.core.model.ICElement;
|
||||
import org.eclipse.cdt.core.model.ITranslationUnit;
|
||||
import org.eclipse.cdt.core.parser.ast.ASTAccessVisibility;
|
||||
import org.eclipse.cdt.core.parser.ast.IASTCompletionNode;
|
||||
import org.eclipse.cdt.core.search.BasicSearchMatch;
|
||||
|
@ -23,7 +20,6 @@ import org.eclipse.cdt.core.search.BasicSearchResultCollector;
|
|||
import org.eclipse.cdt.core.search.ICSearchConstants;
|
||||
import org.eclipse.cdt.core.search.ICSearchScope;
|
||||
import org.eclipse.cdt.core.search.SearchEngine;
|
||||
import org.eclipse.cdt.internal.core.model.CElement;
|
||||
import org.eclipse.cdt.internal.core.model.IWorkingCopy;
|
||||
import org.eclipse.cdt.internal.core.search.matching.OrPattern;
|
||||
import org.eclipse.cdt.internal.corext.template.ContextType;
|
||||
|
@ -32,7 +28,6 @@ import org.eclipse.cdt.internal.ui.CCompletionContributorManager;
|
|||
import org.eclipse.cdt.internal.ui.CPluginImages;
|
||||
import org.eclipse.cdt.internal.ui.editor.CEditor;
|
||||
import org.eclipse.cdt.internal.ui.text.CParameterListValidator;
|
||||
import org.eclipse.cdt.internal.ui.text.CWordFinder;
|
||||
import org.eclipse.cdt.internal.ui.text.template.TemplateEngine;
|
||||
import org.eclipse.cdt.ui.CSearchResultLabelProvider;
|
||||
import org.eclipse.cdt.ui.CUIPlugin;
|
||||
|
@ -42,16 +37,13 @@ import org.eclipse.cdt.ui.IWorkingCopyManager;
|
|||
import org.eclipse.cdt.ui.text.ICCompletionProposal;
|
||||
import org.eclipse.core.resources.IFile;
|
||||
import org.eclipse.jface.preference.IPreferenceStore;
|
||||
import org.eclipse.jface.text.BadLocationException;
|
||||
import org.eclipse.jface.text.IDocument;
|
||||
import org.eclipse.jface.text.IRegion;
|
||||
import org.eclipse.jface.text.ITextViewer;
|
||||
import org.eclipse.jface.text.contentassist.ContextInformation;
|
||||
import org.eclipse.jface.text.contentassist.ICompletionProposal;
|
||||
import org.eclipse.jface.text.contentassist.IContentAssistProcessor;
|
||||
import org.eclipse.jface.text.contentassist.IContextInformation;
|
||||
import org.eclipse.jface.text.contentassist.IContextInformationValidator;
|
||||
import org.eclipse.swt.graphics.Point;
|
||||
import org.eclipse.ui.IEditorPart;
|
||||
|
||||
/**
|
||||
|
@ -218,26 +210,23 @@ public class CCompletionProcessor implements IContentAssistProcessor {
|
|||
IWorkingCopy unit = fManager.getWorkingCopy(fEditor.getEditorInput());
|
||||
|
||||
IDocument document = viewer.getDocument();
|
||||
|
||||
currentOffset = documentOffset;
|
||||
currentSourceUnit = unit;
|
||||
|
||||
|
||||
ICCompletionProposal[] results = null;
|
||||
|
||||
try {
|
||||
if (document != null) {
|
||||
// if (document != null) {
|
||||
//
|
||||
// int offset = documentOffset;
|
||||
// int length = 0;
|
||||
//
|
||||
// Point selection = viewer.getSelectedRange();
|
||||
// if (selection.y > 0) {
|
||||
// offset = selection.x;
|
||||
// length = selection.y;
|
||||
// }
|
||||
|
||||
int offset = documentOffset;
|
||||
int length = 0;
|
||||
|
||||
Point selection = viewer.getSelectedRange();
|
||||
if (selection.y > 0) {
|
||||
offset = selection.x;
|
||||
length = selection.y;
|
||||
}
|
||||
|
||||
results = evalProposals(document, offset, length, unit);
|
||||
}
|
||||
results = evalProposals(document, documentOffset, unit);
|
||||
// }
|
||||
} catch (Exception e) {
|
||||
CUIPlugin.getDefault().log(e);
|
||||
}
|
||||
|
@ -276,37 +265,6 @@ public class CCompletionProcessor implements IContentAssistProcessor {
|
|||
return results;
|
||||
}
|
||||
|
||||
private ICElement getCurrentScope(ITranslationUnit unit, int documentOffset){
|
||||
// quick parse the unit
|
||||
Map elements = unit.parse();
|
||||
// figure out what element is the enclosing the current offset
|
||||
ICElement currentScope = unit;
|
||||
Iterator i = elements.keySet().iterator();
|
||||
while (i.hasNext()){
|
||||
CElement element = (CElement) i.next();
|
||||
|
||||
if ((element.getStartPos() < documentOffset )
|
||||
&& ( element.getStartPos() + element.getLength() > documentOffset)
|
||||
)
|
||||
{
|
||||
if(currentScope instanceof ITranslationUnit){
|
||||
currentScope = element;
|
||||
}else
|
||||
if (currentScope instanceof CElement){
|
||||
CElement currentScopeElement = (CElement) currentScope;
|
||||
if(
|
||||
(currentScopeElement.getStartPos() < element.getStartPos())
|
||||
&& (
|
||||
(currentScopeElement.getStartPos() + currentScopeElement.getLength() )
|
||||
> (element.getStartPos() + element.getLength()) )
|
||||
)
|
||||
currentScope = element;
|
||||
}
|
||||
}
|
||||
}
|
||||
return currentScope;
|
||||
}
|
||||
|
||||
/**
|
||||
* Order the given proposals.
|
||||
*/
|
||||
|
@ -319,114 +277,23 @@ public class CCompletionProcessor implements IContentAssistProcessor {
|
|||
/**
|
||||
* Evaluate the actual proposals for C
|
||||
*/
|
||||
public ICCompletionProposal[] evalProposals(IDocument document, int pos, int length, ITranslationUnit unit) {
|
||||
try{
|
||||
currentOffset = pos;
|
||||
currentSourceUnit = unit.getWorkingCopy();
|
||||
} catch (CModelException e){
|
||||
|
||||
}
|
||||
return order (evalProposals(document, pos, length, getCurrentScope (unit, pos)));
|
||||
}
|
||||
|
||||
private ICCompletionProposal[] evalProposals(IDocument document, int startPos, int length, ICElement currentScope) {
|
||||
boolean isDereference = false;
|
||||
IRegion region;
|
||||
String frag = "";
|
||||
int pos = startPos;
|
||||
|
||||
|
||||
// Move back the pos by one the position is 0-based
|
||||
if (pos > 0) {
|
||||
pos--;
|
||||
}
|
||||
|
||||
// TODO: Check to see if we are trying to open for a structure/class, then
|
||||
// provide that structure's completion instead of the function/variable
|
||||
// completions. This needs to be properly dealt with so that we can
|
||||
// offer completion proposals.
|
||||
if (pos > 1) {
|
||||
int struct_pos = pos;
|
||||
|
||||
try {
|
||||
//While we aren't on a space, then go back and look for
|
||||
// . or a -> then determine the structure variable type.
|
||||
while(document.getChar(struct_pos) == ' ') {
|
||||
struct_pos--;
|
||||
}
|
||||
|
||||
if (document.getChar(struct_pos) == '.') {
|
||||
isDereference = true;
|
||||
pos -= struct_pos - 1;
|
||||
} else if ((document.getChar(struct_pos) == '>') && (document.getChar(struct_pos - 1) == '-')) {
|
||||
isDereference = true;
|
||||
pos -= struct_pos - 2;
|
||||
} else {
|
||||
isDereference = false;
|
||||
}
|
||||
} catch (BadLocationException ex) {
|
||||
return null;
|
||||
}
|
||||
}
|
||||
|
||||
// Get the current "word", it might be a variable or another starter
|
||||
region = CWordFinder.findWord(document, pos);
|
||||
if(region == null) {
|
||||
return null; //Bail out on error
|
||||
}
|
||||
|
||||
//@@@ TODO: Implement the structure member completion
|
||||
if(isDereference) {
|
||||
return null;
|
||||
}
|
||||
|
||||
try {
|
||||
//frag = document.get(region.getOffset(), region.getLength());
|
||||
frag = document.get(region.getOffset(), startPos - region.getOffset());
|
||||
frag = frag.trim();
|
||||
} catch (BadLocationException ex) {
|
||||
return null; //Bail out on error
|
||||
}
|
||||
public ICCompletionProposal[] evalProposals(IDocument document, int documentOffset, IWorkingCopy unit) {
|
||||
|
||||
//If there is no fragment, then see if we are in a function
|
||||
if(frag.length() == 0) {
|
||||
IRegion funcregion;
|
||||
String funcfrag = "";
|
||||
|
||||
funcregion = CWordFinder.findFunction(document, pos + 1);
|
||||
if(funcregion != null) {
|
||||
try {
|
||||
funcfrag = document.get(funcregion.getOffset(), funcregion.getLength());
|
||||
funcfrag = funcfrag.trim();
|
||||
} catch(Exception ex) {
|
||||
funcfrag = "";
|
||||
}
|
||||
if(funcfrag.length() == 0) {
|
||||
return null;
|
||||
} else {
|
||||
//@@@ Add some marker here to indicate different path!
|
||||
region = funcregion;
|
||||
frag = funcfrag;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
// Based on the frag name, build a list of completion proposals
|
||||
currentOffset = documentOffset;
|
||||
currentSourceUnit = unit;
|
||||
ArrayList completions = new ArrayList();
|
||||
|
||||
// Look in index manager
|
||||
addProposalsFromModel(region, completions);
|
||||
addProposalsFromModel(completions);
|
||||
|
||||
// Loot in the contributed completions
|
||||
addProposalsFromCompletionContributors(region, frag, completions);
|
||||
|
||||
return (ICCompletionProposal[]) completions.toArray(new ICCompletionProposal[0]);
|
||||
return order ( (ICCompletionProposal[]) completions.toArray(new ICCompletionProposal[0]) );
|
||||
}
|
||||
|
||||
private void addProposalsFromCompletionContributors(IRegion region, String frag, ArrayList completions) {
|
||||
private void addProposalsFromCompletionContributors(String prefix, int offset, int length, List completions) {
|
||||
IFunctionSummary[] summary;
|
||||
|
||||
summary = CCompletionContributorManager.getDefault().getMatchingFunctions(frag);
|
||||
summary = CCompletionContributorManager.getDefault().getMatchingFunctions(prefix);
|
||||
if(summary == null) {
|
||||
return;
|
||||
}
|
||||
|
@ -439,8 +306,8 @@ public class CCompletionProcessor implements IContentAssistProcessor {
|
|||
|
||||
CCompletionProposal proposal;
|
||||
proposal = new CCompletionProposal(fname,
|
||||
region.getOffset(),
|
||||
region.getLength(),
|
||||
offset,
|
||||
length,
|
||||
CPluginImages.get(CPluginImages.IMG_OBJS_FUNCTION),
|
||||
fproto.getPrototypeString(true),
|
||||
2);
|
||||
|
@ -472,7 +339,7 @@ public class CCompletionProcessor implements IContentAssistProcessor {
|
|||
}
|
||||
|
||||
|
||||
private void addProposalsFromModel (IRegion region, ArrayList completions) {
|
||||
private void addProposalsFromModel (List completions) {
|
||||
|
||||
if (currentSourceUnit == null)
|
||||
return;
|
||||
|
@ -481,12 +348,15 @@ public class CCompletionProcessor implements IContentAssistProcessor {
|
|||
resultCollector.clearCompletions();
|
||||
|
||||
//invoke the completion engine
|
||||
IASTCompletionNode completionNode = completionEngine.complete(currentSourceUnit, currentOffset, completions);
|
||||
IASTCompletionNode completionNode = completionEngine.complete(currentSourceUnit, currentOffset);
|
||||
if(completionNode == null)
|
||||
return;
|
||||
String prefix = completionNode.getCompletionPrefix();
|
||||
int offset = currentOffset - prefix.length();
|
||||
int length = prefix.length();
|
||||
|
||||
String searchPrefix = prefix + "*";
|
||||
|
||||
|
||||
// figure out the search scope
|
||||
IPreferenceStore store = CUIPlugin.getDefault().getPreferenceStore();
|
||||
boolean fileScope = store.getBoolean(ContentAssistPreference.CURRENT_FILE_SEARCH_SCOPE);
|
||||
|
@ -496,8 +366,6 @@ public class CCompletionProcessor implements IContentAssistProcessor {
|
|||
|
||||
if ((projectScope) || (projectScopeAndDependency)){
|
||||
List elementsFound = new LinkedList();
|
||||
resultCollector.clearCompletions();
|
||||
//////////////////////
|
||||
|
||||
ICElement[] projectScopeElement = new ICElement[1];
|
||||
projectScopeElement[0] = (ICElement)currentSourceUnit.getCProject();
|
||||
|
@ -515,26 +383,14 @@ public class CCompletionProcessor implements IContentAssistProcessor {
|
|||
searchEngine.search(CUIPlugin.getWorkspace(), orPattern, scope, searchResultCollector, true);
|
||||
elementsFound.addAll(searchResultCollector.getSearchResults());
|
||||
|
||||
sendResultsToCollector(elementsFound.iterator(), region.getOffset(), region.getLength(), prefix );
|
||||
sendResultsToCollector(elementsFound.iterator(), offset, length, prefix );
|
||||
}
|
||||
else{
|
||||
/* //Try to get the file
|
||||
IResource actualFile = currentSourceUnit.getUnderlyingResource();
|
||||
IProject project = currentSourceUnit.getCProject().getProject();
|
||||
ArrayList dependencies = new ArrayList();
|
||||
if (actualFile != null){
|
||||
//Get file's dependencies
|
||||
try {
|
||||
IndexManager indexMan = CCorePlugin.getDefault().getCoreModel().getIndexManager();
|
||||
indexMan.performConcurrentJob(new DependencyQueryJob(project, (IFile)actualFile, indexMan, dependencies), ICSearchConstants.WAIT_UNTIL_READY_TO_SEARCH, null, null);
|
||||
} catch (Exception e) {
|
||||
}
|
||||
}
|
||||
//Create CFileSearchScope
|
||||
scope = SearchEngine.createCFileSearchScope((IFile) actualFile, dependencies);
|
||||
*/ }
|
||||
|
||||
completions.addAll(resultCollector.getCompletions());
|
||||
completions.addAll(resultCollector.getCompletions());
|
||||
|
||||
// Loot in the contributed completions
|
||||
addProposalsFromCompletionContributors(prefix, offset, length, completions);
|
||||
|
||||
}
|
||||
|
||||
private void sendResultsToCollector(Iterator results , int completionStart, int completionLength, String prefix){
|
||||
|
|
|
@ -373,5 +373,29 @@ public class CCompletionProposal implements ICCompletionProposal, ICompletionPro
|
|||
fRelevance= relevance;
|
||||
}
|
||||
|
||||
/* (non-Javadoc)
|
||||
* @see java.lang.Object#hashCode()
|
||||
*/
|
||||
public int hashCode() {
|
||||
return fDisplayString.hashCode()
|
||||
+ fReplacementString.hashCode()
|
||||
+ ((fAdditionalInfoString == null) ? 0 : fAdditionalInfoString.hashCode());
|
||||
}
|
||||
/* (non-Javadoc)
|
||||
* @see java.lang.Object#equals(java.lang.Object)
|
||||
*/
|
||||
public boolean equals(Object other) {
|
||||
if(!(other instanceof CCompletionProposal))
|
||||
return false;
|
||||
if(!(fDisplayString.equals(((CCompletionProposal)other).fDisplayString)))
|
||||
return false;
|
||||
if(!(fReplacementString.equals(((CCompletionProposal)other).fReplacementString)))
|
||||
return false;
|
||||
if((fAdditionalInfoString != null) && (((CCompletionProposal)other).fAdditionalInfoString != null) && (!(fAdditionalInfoString.equals(((CCompletionProposal)other).fAdditionalInfoString))))
|
||||
return false;
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
|
|
|
@ -42,8 +42,10 @@ import org.eclipse.cdt.core.parser.ast.IASTMacro;
|
|||
import org.eclipse.cdt.core.parser.ast.IASTMethod;
|
||||
import org.eclipse.cdt.core.parser.ast.IASTNamespaceDefinition;
|
||||
import org.eclipse.cdt.core.parser.ast.IASTNode;
|
||||
import org.eclipse.cdt.core.parser.ast.IASTScope;
|
||||
import org.eclipse.cdt.core.parser.ast.IASTVariable;
|
||||
import org.eclipse.cdt.core.parser.ast.IASTNode.LookupException;
|
||||
import org.eclipse.cdt.core.parser.ast.IASTCompletionNode.CompletionKind;
|
||||
import org.eclipse.cdt.core.parser.ast.IASTNode.LookupKind;
|
||||
import org.eclipse.cdt.core.parser.ast.IASTNode.LookupResult;
|
||||
import org.eclipse.cdt.internal.core.CharOperation;
|
||||
import org.eclipse.cdt.internal.core.model.IWorkingCopy;
|
||||
|
@ -63,7 +65,6 @@ import org.eclipse.jface.preference.IPreferenceStore;
|
|||
*
|
||||
*/
|
||||
public class CompletionEngine implements RelevanceConstants{
|
||||
List completions = new ArrayList();
|
||||
ICompletionRequestor requestor;
|
||||
int completionStart = 0;
|
||||
int completionLength = 0;
|
||||
|
@ -88,7 +89,6 @@ public class CompletionEngine implements RelevanceConstants{
|
|||
private static final String exceptionKeyword = "...";
|
||||
|
||||
public CompletionEngine(ICompletionRequestor completionRequestor){
|
||||
completions.clear();
|
||||
requestor = completionRequestor;
|
||||
}
|
||||
|
||||
|
@ -204,7 +204,8 @@ public class CompletionEngine implements RelevanceConstants{
|
|||
int relevance = computeRelevance(ICElement.C_METHOD, prefix, method.getName());
|
||||
String parameterString = ASTUtil.getParametersString(ASTUtil.getFunctionParameterTypes(method));
|
||||
requestor.acceptMethod(method.getName(),
|
||||
ASTUtil.getType(method.getReturnType()), parameterString,
|
||||
parameterString,
|
||||
ASTUtil.getType(method.getReturnType()),
|
||||
method.getVisiblity(), completionStart, completionLength, relevance);
|
||||
}
|
||||
else if(node instanceof IASTFunction){
|
||||
|
@ -212,7 +213,8 @@ public class CompletionEngine implements RelevanceConstants{
|
|||
int relevance = computeRelevance(ICElement.C_FUNCTION, prefix, function.getName());
|
||||
String parameterString = ASTUtil.getParametersString(ASTUtil.getFunctionParameterTypes(function));
|
||||
requestor.acceptFunction(function.getName(),
|
||||
ASTUtil.getType(function.getReturnType()), parameterString,
|
||||
parameterString,
|
||||
ASTUtil.getType(function.getReturnType()),
|
||||
completionStart, completionLength, relevance);
|
||||
}
|
||||
else if(node instanceof IASTClassSpecifier){
|
||||
|
@ -292,61 +294,60 @@ public class CompletionEngine implements RelevanceConstants{
|
|||
}
|
||||
return result;
|
||||
}
|
||||
|
||||
private LookupResult lookup(IASTScope searchNode, String prefix, LookupKind[] kinds, IASTNode context){
|
||||
try {
|
||||
LookupResult result = searchNode.lookup (prefix, kinds, context);
|
||||
return result ;
|
||||
} catch (IASTNode.LookupException ilk ){
|
||||
// do we want to do something here?
|
||||
ilk.printStackTrace();
|
||||
return null;
|
||||
}
|
||||
}
|
||||
private void completionOnMemberReference(IASTCompletionNode completionNode){
|
||||
// Completing after a dot
|
||||
// 1. Get the search scope node
|
||||
IASTNode searchNode = completionNode.getCompletionScope();
|
||||
IASTScope searchNode = completionNode.getCompletionScope();
|
||||
|
||||
LookupResult result = null;
|
||||
// 2. lookup fields & add to completion proposals
|
||||
try
|
||||
{
|
||||
result = searchNode.lookup (completionNode.getCompletionPrefix(), IASTNode.LookupKind.FIELDS, completionNode.getCompletionContext());
|
||||
addToCompletions (result);
|
||||
}
|
||||
catch( IASTNode.LookupException ilk )
|
||||
{
|
||||
|
||||
}
|
||||
|
||||
try
|
||||
{
|
||||
// 3. looup methods & add to completion proposals
|
||||
result = searchNode.lookup (completionNode.getCompletionPrefix(), IASTNode.LookupKind.METHODS, completionNode.getCompletionContext());
|
||||
addToCompletions (result);
|
||||
}
|
||||
catch( IASTNode.LookupException ilk )
|
||||
{
|
||||
|
||||
}
|
||||
|
||||
|
||||
try {
|
||||
// 4. lookup nested structures & add to completion proposals
|
||||
result = searchNode.lookup (completionNode.getCompletionPrefix(), IASTNode.LookupKind.STRUCTURES, completionNode.getCompletionContext());
|
||||
addToCompletions (result);
|
||||
} catch (LookupException e) {
|
||||
}
|
||||
// lookup fields and methods with the right visibility
|
||||
IASTNode.LookupKind[] kinds = new IASTNode.LookupKind[2];
|
||||
kinds[0] = IASTNode.LookupKind.FIELDS;
|
||||
kinds[1] = IASTNode.LookupKind.METHODS;
|
||||
result = lookup (searchNode, completionNode.getCompletionPrefix(), kinds, completionNode.getCompletionContext());
|
||||
addToCompletions (result);
|
||||
|
||||
}
|
||||
private void completionOnScopedReference(IASTCompletionNode completionNode){
|
||||
// 1. Get the search scope node
|
||||
// the search node is the name before the qualification
|
||||
IASTScope searchNode = completionNode.getCompletionScope();
|
||||
// here we have to look for anything that could be referenced within this scope
|
||||
// 1. lookup local variables, global variables, functions, methods, structures, enums, macros, and namespaces
|
||||
IASTNode.LookupKind[] kinds = new IASTNode.LookupKind[4];
|
||||
kinds[0] = IASTNode.LookupKind.VARIABLES;
|
||||
kinds[1] = IASTNode.LookupKind.STRUCTURES;
|
||||
kinds[2] = IASTNode.LookupKind.ENUMERATIONS;
|
||||
kinds[3] = IASTNode.LookupKind.NAMESPACES;
|
||||
LookupResult result = lookup(searchNode, completionNode.getCompletionPrefix(), kinds, completionNode.getCompletionContext());
|
||||
addToCompletions(result);
|
||||
// TODO
|
||||
// lookup static members (field / methods) in type
|
||||
}
|
||||
private void completionOnTypeReference(IASTCompletionNode completionNode){
|
||||
// completing on a type
|
||||
// 1. Get the search scope node
|
||||
IASTNode searchNode = completionNode.getCompletionScope();
|
||||
IASTScope searchNode = completionNode.getCompletionScope();
|
||||
// if the prefix is not empty
|
||||
if(completionNode.getCompletionPrefix().length() > 0 ) {
|
||||
// 2. Lookup all types that could be used here
|
||||
LookupResult result;
|
||||
try {
|
||||
result = searchNode.lookup(completionNode.getCompletionPrefix(), IASTNode.LookupKind.STRUCTURES, completionNode.getCompletionContext());
|
||||
addToCompletions(result);
|
||||
} catch (LookupException e) {
|
||||
}
|
||||
|
||||
// 3. Lookup keywords
|
||||
// basic types should be in the keyword list
|
||||
List keywords = lookupKeyword(completionNode.getCompletionPrefix(), BASIC_TYPES_KEYWORDS);
|
||||
addKeywordsToCompletions(keywords.iterator());
|
||||
IASTNode.LookupKind[] kinds = new IASTNode.LookupKind[2];
|
||||
kinds[0] = IASTNode.LookupKind.STRUCTURES;
|
||||
kinds[1] = IASTNode.LookupKind.ENUMERATIONS;
|
||||
result = lookup(searchNode, completionNode.getCompletionPrefix(), kinds, completionNode.getCompletionContext());
|
||||
addToCompletions(result);
|
||||
} else // prefix is empty, we can not look for everything
|
||||
{
|
||||
|
||||
|
@ -357,18 +358,17 @@ public class CompletionEngine implements RelevanceConstants{
|
|||
// 1. basic completion on all types
|
||||
completionOnTypeReference(completionNode);
|
||||
// 2. Get the search scope node
|
||||
IASTNode searchNode = completionNode.getCompletionScope();
|
||||
// 3. lookup methods
|
||||
IASTScope searchNode = completionNode.getCompletionScope();
|
||||
// TODO
|
||||
// 3. provide a template for constructor/ destructor
|
||||
// 4. lookup methods
|
||||
// we are at a field declaration place, the user could be trying to override a function.
|
||||
// We have to lookup functions that could be overridden here.
|
||||
LookupResult result;
|
||||
try {
|
||||
result = searchNode.lookup(completionNode.getCompletionPrefix(), IASTNode.LookupKind.METHODS, completionNode.getCompletionContext());
|
||||
addToCompletions(result);
|
||||
} catch (LookupException e) {
|
||||
// TODO Auto-generated catch block
|
||||
e.printStackTrace();
|
||||
}
|
||||
// LookupResult result;
|
||||
// IASTNode.LookupKind[] kinds = new IASTNode.LookupKind[1];
|
||||
// kinds[0] = IASTNode.LookupKind.METHODS;
|
||||
// result = lookup(searchNode, completionNode.getCompletionPrefix(), kinds, completionNode.getCompletionContext());
|
||||
// addToCompletions(result);
|
||||
|
||||
}
|
||||
private void completionOnVariableType(IASTCompletionNode completionNode){
|
||||
|
@ -378,79 +378,49 @@ public class CompletionEngine implements RelevanceConstants{
|
|||
private void completionOnSingleNameReference(IASTCompletionNode completionNode){
|
||||
// 1. Get the search scope node
|
||||
// the search node is the code scope inwhich completion is requested
|
||||
IASTNode searchNode = completionNode.getCompletionScope();
|
||||
IASTScope searchNode = completionNode.getCompletionScope();
|
||||
// if prefix is not empty
|
||||
if (completionNode.getCompletionPrefix().length() > 0){
|
||||
// here we have to look for anything that could be referenced within this scope
|
||||
// 1. lookup local variables, global variables, functions, methods, structures, enums, macros, and namespaces
|
||||
try
|
||||
{
|
||||
LookupResult result = searchNode.lookup(completionNode.getCompletionPrefix(), IASTNode.LookupKind.ALL, completionNode.getCompletionContext());
|
||||
addToCompletions(result);
|
||||
}
|
||||
catch( LookupException ilk )
|
||||
{
|
||||
|
||||
}
|
||||
IASTNode.LookupKind[] kinds = new IASTNode.LookupKind[7];
|
||||
kinds[0] = IASTNode.LookupKind.LOCAL_VARIABLES;
|
||||
kinds[1] = IASTNode.LookupKind.FIELDS;
|
||||
kinds[2] = IASTNode.LookupKind.VARIABLES;
|
||||
kinds[3] = IASTNode.LookupKind.STRUCTURES;
|
||||
kinds[4] = IASTNode.LookupKind.ENUMERATIONS;
|
||||
kinds[5] = IASTNode.LookupKind.METHODS;
|
||||
kinds[6] = IASTNode.LookupKind.FUNCTIONS;
|
||||
LookupResult result = lookup(searchNode, completionNode.getCompletionPrefix(), kinds, completionNode.getCompletionContext());
|
||||
addToCompletions(result);
|
||||
} else // prefix is empty
|
||||
{
|
||||
// 1. look only for local variables
|
||||
try
|
||||
{
|
||||
LookupResult result = searchNode.lookup(completionNode.getCompletionPrefix(), IASTNode.LookupKind.LOCAL_VARIABLES, completionNode.getCompletionContext());
|
||||
addToCompletions(result);
|
||||
}
|
||||
catch( LookupException ilk )
|
||||
{
|
||||
|
||||
}
|
||||
|
||||
// 2. and what can be accessed through the "this" pointer
|
||||
// TODO : complete the lookup call
|
||||
}
|
||||
}
|
||||
private void completionOnScopedReference(IASTCompletionNode completionNode){
|
||||
// 1. Get the search scope node
|
||||
// the search node is the name before the qualification
|
||||
IASTNode searchNode = completionNode.getCompletionScope();
|
||||
// here we have to look for anything that could be referenced within this scope
|
||||
// 1. lookup local variables, global variables, functions, methods, structures, enums, macros, and namespaces
|
||||
try
|
||||
{
|
||||
LookupResult result = searchNode.lookup(completionNode.getCompletionPrefix(), IASTNode.LookupKind.ALL, completionNode.getCompletionContext());
|
||||
IASTNode.LookupKind[] kinds = new IASTNode.LookupKind[3];
|
||||
kinds[0] = IASTNode.LookupKind.LOCAL_VARIABLES;
|
||||
kinds[1] = IASTNode.LookupKind.FIELDS;
|
||||
kinds[2] = IASTNode.LookupKind.METHODS;
|
||||
LookupResult result = lookup(searchNode, completionNode.getCompletionPrefix(), kinds, completionNode.getCompletionContext());
|
||||
addToCompletions(result);
|
||||
}
|
||||
catch( LookupException ilk )
|
||||
{
|
||||
|
||||
}
|
||||
}
|
||||
|
||||
private void completionOnClassReference(IASTCompletionNode completionNode){
|
||||
// 1. Get the search scope node
|
||||
IASTNode searchNode = completionNode.getCompletionScope();
|
||||
IASTScope searchNode = completionNode.getCompletionScope();
|
||||
// only look for classes
|
||||
try
|
||||
{
|
||||
LookupResult result = searchNode.lookup(completionNode.getCompletionPrefix(), IASTNode.LookupKind.CLASSES, completionNode.getCompletionContext());
|
||||
addToCompletions(result);
|
||||
}
|
||||
catch( LookupException ilk )
|
||||
{
|
||||
}
|
||||
IASTNode.LookupKind[] kinds = new IASTNode.LookupKind[1];
|
||||
kinds[0] = IASTNode.LookupKind.CLASSES;
|
||||
LookupResult result = lookup(searchNode, completionNode.getCompletionPrefix(), kinds, completionNode.getCompletionContext());
|
||||
addToCompletions(result);
|
||||
}
|
||||
private void completionOnNamespaceReference(IASTCompletionNode completionNode){
|
||||
// 1. Get the search scope node
|
||||
IASTNode searchNode = completionNode.getCompletionScope();
|
||||
// only look for classes
|
||||
try
|
||||
{
|
||||
LookupResult result = searchNode.lookup(completionNode.getCompletionPrefix(), IASTNode.LookupKind.NAMESPACES, completionNode.getCompletionContext());
|
||||
addToCompletions(result);
|
||||
}
|
||||
catch( LookupException ilk )
|
||||
{
|
||||
}
|
||||
IASTScope searchNode = completionNode.getCompletionScope();
|
||||
// only look for namespaces
|
||||
IASTNode.LookupKind[] kinds = new IASTNode.LookupKind[1];
|
||||
kinds[0] = IASTNode.LookupKind.NAMESPACES;
|
||||
LookupResult result = lookup(searchNode, completionNode.getCompletionPrefix(), kinds, completionNode.getCompletionContext());
|
||||
addToCompletions(result);
|
||||
}
|
||||
private void completionOnExceptionReference(IASTCompletionNode completionNode){
|
||||
// here we have to look for all types
|
||||
|
@ -462,32 +432,23 @@ public class CompletionEngine implements RelevanceConstants{
|
|||
}
|
||||
private void completionOnMacroReference(IASTCompletionNode completionNode){
|
||||
// 1. Get the search scope node
|
||||
IASTNode searchNode = completionNode.getCompletionScope();
|
||||
IASTScope searchNode = completionNode.getCompletionScope();
|
||||
// only look for macros
|
||||
try
|
||||
{
|
||||
LookupResult result = searchNode.lookup(completionNode.getCompletionPrefix(), IASTNode.LookupKind.MACROS, completionNode.getCompletionContext());
|
||||
addToCompletions(result);
|
||||
}
|
||||
catch( LookupException ilk )
|
||||
{
|
||||
}
|
||||
IASTNode.LookupKind[] kinds = new IASTNode.LookupKind[1];
|
||||
kinds[0] = IASTNode.LookupKind.MACROS;
|
||||
LookupResult result = lookup(searchNode, completionNode.getCompletionPrefix(), kinds, completionNode.getCompletionContext());
|
||||
addToCompletions(result);
|
||||
}
|
||||
private void completionOnFunctionReference(IASTCompletionNode completionNode){
|
||||
// TODO: complete the lookups
|
||||
}
|
||||
private void completionOnConstructorReference(IASTCompletionNode completionNode){
|
||||
// 1. Get the search scope node
|
||||
IASTNode searchNode = completionNode.getCompletionScope();
|
||||
IASTScope searchNode = completionNode.getCompletionScope();
|
||||
// only lookup constructors
|
||||
try
|
||||
{
|
||||
LookupResult result = searchNode.lookup(completionNode.getCompletionPrefix(), IASTNode.LookupKind.CONSTRUCTORS, completionNode.getCompletionContext());
|
||||
}
|
||||
catch( LookupException ilk )
|
||||
{
|
||||
}
|
||||
|
||||
IASTNode.LookupKind[] kinds = new IASTNode.LookupKind[1];
|
||||
kinds[0] = IASTNode.LookupKind.CONSTRUCTORS;
|
||||
LookupResult result = lookup(searchNode, completionNode.getCompletionPrefix(), kinds, completionNode.getCompletionContext());
|
||||
}
|
||||
private void completionOnKeyword(IASTCompletionNode completionNode){
|
||||
// lookup every type of keywords
|
||||
|
@ -496,7 +457,7 @@ public class CompletionEngine implements RelevanceConstants{
|
|||
addKeywordsToCompletions(result.iterator());
|
||||
}
|
||||
|
||||
public IASTCompletionNode complete(IWorkingCopy sourceUnit, int completionOffset, List completionList) {
|
||||
public IASTCompletionNode complete(IWorkingCopy sourceUnit, int completionOffset) {
|
||||
|
||||
// 1- Parse the translation unit
|
||||
IASTCompletionNode completionNode = parse(sourceUnit, completionOffset);
|
||||
|
@ -505,69 +466,69 @@ public class CompletionEngine implements RelevanceConstants{
|
|||
return null;
|
||||
|
||||
// set the completionStart and the completionLength
|
||||
completionStart = completionOffset;
|
||||
completionStart = completionOffset - completionNode.getCompletionPrefix().length();
|
||||
completionLength = completionNode.getCompletionPrefix().length();
|
||||
CompletionKind kind = completionNode.getCompletionKind();
|
||||
|
||||
// 2- Check the return value
|
||||
if(completionNode.getCompletionKind() == IASTCompletionNode.CompletionKind.MEMBER_REFERENCE){
|
||||
if(kind == IASTCompletionNode.CompletionKind.MEMBER_REFERENCE){
|
||||
// completionOnMemberReference
|
||||
completionOnMemberReference(completionNode);
|
||||
}
|
||||
else if(completionNode.getCompletionKind() == IASTCompletionNode.CompletionKind.SCOPED_REFERENCE){
|
||||
else if(kind == IASTCompletionNode.CompletionKind.SCOPED_REFERENCE){
|
||||
// completionOnMemberReference
|
||||
completionOnMemberReference(completionNode);
|
||||
completionOnScopedReference(completionNode);
|
||||
}
|
||||
else if(completionNode.getCompletionKind() == IASTCompletionNode.CompletionKind.FIELD_TYPE){
|
||||
else if(kind == IASTCompletionNode.CompletionKind.FIELD_TYPE){
|
||||
// CompletionOnFieldType
|
||||
completionOnFieldType(completionNode);
|
||||
}
|
||||
else if(completionNode.getCompletionKind() == IASTCompletionNode.CompletionKind.VARIABLE_TYPE){
|
||||
else if(kind == IASTCompletionNode.CompletionKind.VARIABLE_TYPE) {
|
||||
// CompletionOnVariableType
|
||||
completionOnTypeReference(completionNode);
|
||||
}
|
||||
else if(completionNode.getCompletionKind() == IASTCompletionNode.CompletionKind.ARGUMENT_TYPE){
|
||||
// CompletionOnArgumentType
|
||||
completionOnVariableType(completionNode);
|
||||
}
|
||||
else if(completionNode.getCompletionKind() == IASTCompletionNode.CompletionKind.SINGLE_NAME_REFERENCE){
|
||||
else if(kind == IASTCompletionNode.CompletionKind.ARGUMENT_TYPE){
|
||||
// CompletionOnArgumentType
|
||||
completionOnTypeReference(completionNode);
|
||||
}
|
||||
else if(kind == IASTCompletionNode.CompletionKind.SINGLE_NAME_REFERENCE){
|
||||
// CompletionOnSingleNameReference
|
||||
completionOnSingleNameReference(completionNode);
|
||||
}
|
||||
else if(completionNode.getCompletionKind() == IASTCompletionNode.CompletionKind.TYPE_REFERENCE){
|
||||
else if(kind == IASTCompletionNode.CompletionKind.TYPE_REFERENCE){
|
||||
// CompletionOnStructureReference
|
||||
completionOnTypeReference(completionNode);
|
||||
}
|
||||
else if(completionNode.getCompletionKind() == IASTCompletionNode.CompletionKind.CLASS_REFERENCE){
|
||||
else if(kind == IASTCompletionNode.CompletionKind.CLASS_REFERENCE){
|
||||
// CompletionOnClassReference
|
||||
completionOnClassReference(completionNode);
|
||||
}
|
||||
else if(completionNode.getCompletionKind() == IASTCompletionNode.CompletionKind.NAMESPACE_REFERENCE){
|
||||
else if(kind == IASTCompletionNode.CompletionKind.NAMESPACE_REFERENCE){
|
||||
// completionOnNamespaceReference
|
||||
completionOnNamespaceReference(completionNode);
|
||||
}
|
||||
else if(completionNode.getCompletionKind() == IASTCompletionNode.CompletionKind.EXCEPTION_REFERENCE){
|
||||
else if(kind == IASTCompletionNode.CompletionKind.EXCEPTION_REFERENCE){
|
||||
// CompletionOnExceptionReference
|
||||
completionOnExceptionReference(completionNode);
|
||||
}
|
||||
else if(completionNode.getCompletionKind() == IASTCompletionNode.CompletionKind.MACRO_REFERENCE){
|
||||
else if(kind == IASTCompletionNode.CompletionKind.MACRO_REFERENCE){
|
||||
// CompletionOnMacroReference
|
||||
completionOnMacroReference(completionNode);
|
||||
}
|
||||
else if(completionNode.getCompletionKind() == IASTCompletionNode.CompletionKind.FUNCTION_REFERENCE){
|
||||
else if(kind == IASTCompletionNode.CompletionKind.FUNCTION_REFERENCE){
|
||||
// completionOnFunctionReference
|
||||
completionOnFunctionReference(completionNode);
|
||||
}
|
||||
else if(completionNode.getCompletionKind() == IASTCompletionNode.CompletionKind.CONSTRUCTOR_REFERENCE){
|
||||
else if(kind == IASTCompletionNode.CompletionKind.CONSTRUCTOR_REFERENCE){
|
||||
// completionOnConstructorReference
|
||||
completionOnConstructorReference(completionNode);
|
||||
}
|
||||
else if(completionNode.getCompletionKind() == IASTCompletionNode.CompletionKind.KEYWORD){
|
||||
else if(kind == IASTCompletionNode.CompletionKind.KEYWORD){
|
||||
// CompletionOnKeyword
|
||||
completionOnKeyword(completionNode);
|
||||
}
|
||||
|
||||
addKeywordsToCompletions( completionNode.getKeywords());
|
||||
completionList.addAll(completions);
|
||||
return completionNode;
|
||||
|
||||
}
|
||||
|
|
|
@ -15,7 +15,7 @@ package org.eclipse.cdt.internal.ui.text.contentassist;
|
|||
*
|
||||
*/
|
||||
public interface RelevanceConstants {
|
||||
final int KEYWORD_TYPE_RELEVANCE = 13;
|
||||
final int KEYWORD_TYPE_RELEVANCE = 30;
|
||||
final int LOCAL_VARIABLE_TYPE_RELEVANCE = 12;
|
||||
final int FIELD_TYPE_RELEVANCE = 11;
|
||||
final int VARIABLE_TYPE_RELEVANCE = 10;
|
||||
|
@ -32,6 +32,6 @@ public interface RelevanceConstants {
|
|||
|
||||
final int CASE_MATCH_RELEVANCE = 10;
|
||||
final int EXACT_NAME_MATCH_RELEVANCE = 4;
|
||||
final int CASE_NOT_VALID_RELEVANCE = -100;
|
||||
|
||||
|
||||
}
|
||||
|
|
|
@ -10,8 +10,9 @@
|
|||
***********************************************************************/
|
||||
package org.eclipse.cdt.internal.ui.text.contentassist;
|
||||
|
||||
import java.util.ArrayList;
|
||||
import java.util.HashSet;
|
||||
import java.util.List;
|
||||
import java.util.Set;
|
||||
|
||||
import org.eclipse.cdt.core.parser.ast.ASTAccessVisibility;
|
||||
import org.eclipse.cdt.internal.ui.CElementImageProvider;
|
||||
|
@ -32,7 +33,7 @@ import org.eclipse.swt.graphics.Image;
|
|||
*
|
||||
*/
|
||||
public class ResultCollector extends CompletionRequestorAdaptor {
|
||||
private List completions = new ArrayList();
|
||||
private Set completions = new HashSet();
|
||||
private ImageDescriptorRegistry registry = CUIPlugin.getImageDescriptorRegistry();
|
||||
|
||||
public ResultCollector(){
|
||||
|
@ -42,7 +43,7 @@ public class ResultCollector extends CompletionRequestorAdaptor {
|
|||
/**
|
||||
* @return the completion list
|
||||
*/
|
||||
public List getCompletions() {
|
||||
public Set getCompletions() {
|
||||
return completions;
|
||||
}
|
||||
public void clearCompletions() {
|
||||
|
|
Loading…
Add table
Reference in a new issue