1
0
Fork 0
mirror of https://github.com/eclipse-cdt/cdt synced 2025-07-24 01:15:29 +02:00

Hooked up to the prefix resolution. Added image for functions.

This commit is contained in:
Doug Schaefer 2005-02-22 19:27:18 +00:00
parent 74850e900b
commit 6924155bcb
10 changed files with 47 additions and 13 deletions

View file

@ -30,5 +30,13 @@ public interface IASTName extends IASTNode {
*/
public IBinding resolveBinding();
/**
* Return a list of bindings in the scope of the name that have the
* name as a prefix.
*
* @return bindings that start with this name
*/
public IBinding[] resolvePrefix();
public char[] toCharArray();
}

View file

@ -432,12 +432,15 @@ public abstract class AbstractGNUSourceCodeParser implements ISourceCodeParser {
case IToken.tRBRACE:
--depth;
break;
case IToken.tEOC:
throw new EndOfFileException();
}
if (depth < 0)
return;
consume();
}
// eat the SEMI/RBRACE as well
consume();
}
@ -1458,7 +1461,7 @@ public abstract class AbstractGNUSourceCodeParser implements ISourceCodeParser {
BacktrackException savedBt = null;
try {
IASTExpression expression = expression();
lastTokenOfExpression = consume(IToken.tSEMI);
lastTokenOfExpression = consume(); // SEMI or EOC
expressionStatement = createExpressionStatement();
expressionStatement.setExpression(expression);
((ASTNode) expressionStatement).setOffsetAndLength(

View file

@ -45,6 +45,11 @@ public class CASTName extends CASTNode implements IASTName {
return binding;
}
public IBinding[] resolvePrefix() {
// TODO hook this up to the CVisitor
return null;
}
protected boolean hasBinding(){
return ( binding != null );
}

View file

@ -46,6 +46,10 @@ public class CPPASTName extends CPPASTNode implements IASTName {
return binding;
}
public IBinding[] resolvePrefix() {
return CPPSemantics.prefixLookup(this);
}
protected void setBinding( IBinding binding ){
this.binding = binding;
}

View file

@ -37,6 +37,11 @@ public class CPPASTQualifiedName extends CPPASTNode implements
return names[names.length - 1].resolveBinding();
}
public IBinding[] resolvePrefix() {
removeNullNames();
return names[names.length - 1].resolvePrefix();
}
/*
* (non-Javadoc)
*

View file

@ -112,6 +112,11 @@ public class CPPASTTemplateId extends CPPASTNode implements ICPPASTTemplateId {
return null;
}
public IBinding[] resolvePrefix() {
// TODO Auto-generated method stub
return null;
}
/* (non-Javadoc)
* @see org.eclipse.cdt.core.dom.ast.IASTName#toCharArray()
*/

View file

@ -55,7 +55,7 @@ abstract class BaseScanner implements IScanner {
protected static final char[] VA_ARGS_CHARARRAY = "__VA_ARGS__".toCharArray(); //$NON-NLS-1$
protected static final IToken eocToken = new SimpleToken(IToken.tEOC, 0, null, 0);
protected final IToken eocToken = new SimpleToken(IToken.tEOC, 0, null, 0);
/**
* @author jcamelon
@ -1517,9 +1517,6 @@ abstract class BaseScanner implements IScanner {
if (finished) {
if (contentAssistMode) {
if (lastToken == eocToken)
throwEOF();
lastToken = nextToken;
nextToken = eocToken;
return lastToken;
@ -1554,6 +1551,7 @@ abstract class BaseScanner implements IScanner {
if (!exception)
finished = true;
} else if (nextToken.getType() == IToken.tCOMPLETION) {
lastToken.setNext(nextToken);
finished = true;
} else if (nextToken.getType() == IToken.tPOUNDPOUND) {
// time for a pasting

View file

@ -584,6 +584,11 @@ public class LocationMap implements ILocationResolver, IScannerPreprocessorLog {
return null;
}
public IBinding[] resolvePrefix() {
// TODO Auto-generated method stub
return null;
}
/*
* (non-Javadoc)
*

View file

@ -299,7 +299,8 @@ public class SimpleToken extends AbstractToken implements IToken {
return "#"; //$NON-NLS-1$
case IScanner.tPOUNDPOUND:
return "##"; //$NON-NLS-1$
case IToken.tEOC:
return "EOC"; //$NON-NLS-1$
default :
// we should never get here!
// assert false : getType();

View file

@ -22,7 +22,7 @@ import org.eclipse.cdt.core.dom.ast.DOMException;
import org.eclipse.cdt.core.dom.ast.IASTName;
import org.eclipse.cdt.core.dom.ast.IBinding;
import org.eclipse.cdt.core.dom.ast.ICompositeType;
import org.eclipse.cdt.core.dom.ast.IProblemBinding;
import org.eclipse.cdt.core.dom.ast.IFunction;
import org.eclipse.cdt.core.dom.ast.ITypedef;
import org.eclipse.cdt.core.dom.ast.IVariable;
import org.eclipse.cdt.core.dom.ast.cpp.ICPPClassType;
@ -88,12 +88,10 @@ public class CCompletionProcessor2 implements IContentAssistProcessor {
IASTName[] names = completionNode.getNames();
for (int i = 0; i < names.length; ++i) {
IBinding binding = names[i].resolveBinding();
if (binding != null && !(binding instanceof IProblemBinding)) {
proposals.add(createBindingCompletionProposal(binding, repOffset, repLength));
proposals.add(createBindingCompletionProposal(binding, repOffset, repLength));
}
IBinding [] bindings = names[i].resolvePrefix();
if (bindings != null)
for (int j = 0; j < bindings.length; ++j)
proposals.add(createBindingCompletionProposal(bindings[j], repOffset, repLength));
}
}
@ -170,6 +168,8 @@ public class CCompletionProcessor2 implements IContentAssistProcessor {
imageDescriptor = CElementImageProvider.getStructImageDescriptor();
else if (((ICompositeType)binding).getKey() == ICompositeType.k_union)
imageDescriptor = CElementImageProvider.getUnionImageDescriptor();
} else if (binding instanceof IFunction) {
imageDescriptor = CElementImageProvider.getFunctionImageDescriptor();
} else if (binding instanceof IVariable) {
imageDescriptor = CElementImageProvider.getVariableImageDescriptor();
}