1
0
Fork 0
mirror of https://github.com/eclipse-cdt/cdt synced 2025-07-20 23:45:23 +02:00

Added completions in initializers. This required a new token type for post completion LT's.

Also, the ISV doc builder wanted to update itself with Eclipse 3.1 M5 stuff.
This commit is contained in:
Doug Schaefer 2005-02-21 21:33:59 +00:00
parent d15eba065f
commit 4ab007930b
7 changed files with 64 additions and 27 deletions

View file

@ -318,5 +318,7 @@ public interface IToken {
static public final int tCOMPLETION = 140; static public final int tCOMPLETION = 140;
static public final int tLAST = 140; static public final int tEOC = 141; // End of Completion
static public final int tLAST = 141;
} }

View file

@ -474,7 +474,7 @@ public abstract class AbstractGNUSourceCodeParser implements ISourceCodeParser {
((ASTNode) result).setOffset(startingOffset); ((ASTNode) result).setOffset(startingOffset);
result.setParent(mostRelevantScopeNode); result.setParent(mostRelevantScopeNode);
result.setPropertyInParent(IASTFunctionDefinition.FUNCTION_BODY); result.setPropertyInParent(IASTFunctionDefinition.FUNCTION_BODY);
while (LT(1) != IToken.tRBRACE && LT(1) != IToken.tCOMPLETION) { while (LT(1) != IToken.tRBRACE && LT(1) != IToken.tCOMPLETION && LT(1) != IToken.tEOC) {
int checkToken = LA(1).hashCode(); int checkToken = LA(1).hashCode();
try { try {
IASTStatement s = statement(); IASTStatement s = statement();

View file

@ -14,6 +14,7 @@ import java.util.ArrayList;
import java.util.Collections; import java.util.Collections;
import java.util.List; import java.util.List;
import org.eclipse.cdt.core.dom.ast.ASTCompletionNode;
import org.eclipse.cdt.core.dom.ast.IASTASMDeclaration; import org.eclipse.cdt.core.dom.ast.IASTASMDeclaration;
import org.eclipse.cdt.core.dom.ast.IASTArrayDeclarator; import org.eclipse.cdt.core.dom.ast.IASTArrayDeclarator;
import org.eclipse.cdt.core.dom.ast.IASTArrayModifier; import org.eclipse.cdt.core.dom.ast.IASTArrayModifier;
@ -342,7 +343,7 @@ public class GNUCPPSourceParser extends AbstractGNUSourceCodeParser {
switch (LT(1)) { switch (LT(1)) {
case IToken.tIDENTIFIER: case IToken.tIDENTIFIER:
last = consume(IToken.tIDENTIFIER); last = consume();
last = consumeTemplateArguments(last, argumentList); last = consumeTemplateArguments(last, argumentList);
if (last.getType() == IToken.tGT) if (last.getType() == IToken.tGT)
hasTemplateId = true; hasTemplateId = true;
@ -1721,6 +1722,7 @@ public class GNUCPPSourceParser extends AbstractGNUSourceCodeParser {
case IToken.tCOLONCOLON: case IToken.tCOLONCOLON:
case IToken.t_operator: case IToken.t_operator:
case IToken.tCOMPL: case IToken.tCOMPL:
{
ITokenDuple duple = idExpression(); ITokenDuple duple = idExpression();
IASTName name = createName(duple); IASTName name = createName(duple);
IASTIdExpression idExpression = createIdExpression(); IASTIdExpression idExpression = createIdExpression();
@ -1730,6 +1732,20 @@ public class GNUCPPSourceParser extends AbstractGNUSourceCodeParser {
name.setParent(idExpression); name.setParent(idExpression);
name.setPropertyInParent(IASTIdExpression.ID_NAME); name.setPropertyInParent(IASTIdExpression.ID_NAME);
return idExpression; return idExpression;
}
case IToken.tCOMPLETION:
{
IToken token = consume();
IASTName name = createName(token);
IASTIdExpression idExpression = createIdExpression();
idExpression.setName(name);
name.setParent(idExpression);
name.setPropertyInParent(IASTIdExpression.ID_NAME);
if (completionNode == null)
completionNode = new ASTCompletionNode(token);
completionNode.addName(name);
return idExpression;
}
default: default:
IToken la = LA(1); IToken la = LA(1);
int startingOffset = la.getOffset(); int startingOffset = la.getOffset();
@ -2662,6 +2678,10 @@ public class GNUCPPSourceParser extends AbstractGNUSourceCodeParser {
if (!fromCatchHandler) if (!fromCatchHandler)
throwBacktrack(firstOffset, LA(1).getEndOffset() - firstOffset); throwBacktrack(firstOffset, LA(1).getEndOffset() - firstOffset);
break; break;
case IToken.tEOC:
// Pretend we consumed the semi
consumedSemi = true;
break;
default: default:
throwBacktrack(firstOffset, LA(1).getEndOffset() - firstOffset); throwBacktrack(firstOffset, LA(1).getEndOffset() - firstOffset);
} }

View file

@ -41,6 +41,7 @@ import org.eclipse.cdt.core.parser.util.CharArrayUtils;
import org.eclipse.cdt.internal.core.parser.ast.ASTCompletionNode; import org.eclipse.cdt.internal.core.parser.ast.ASTCompletionNode;
import org.eclipse.cdt.internal.core.parser.ast.EmptyIterator; import org.eclipse.cdt.internal.core.parser.ast.EmptyIterator;
import org.eclipse.cdt.internal.core.parser.token.KeywordSets; import org.eclipse.cdt.internal.core.parser.token.KeywordSets;
import org.eclipse.cdt.internal.core.parser.token.SimpleToken;
/** /**
* @author Doug Schaefer * @author Doug Schaefer
@ -54,6 +55,8 @@ abstract class BaseScanner implements IScanner {
protected static final char[] VA_ARGS_CHARARRAY = "__VA_ARGS__".toCharArray(); //$NON-NLS-1$ 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);
/** /**
* @author jcamelon * @author jcamelon
* *
@ -1514,11 +1517,11 @@ abstract class BaseScanner implements IScanner {
if (finished) { if (finished) {
if (contentAssistMode) { if (contentAssistMode) {
lastToken = nextToken; if (lastToken == eocToken)
nextToken = null;
if (lastToken == null)
throwEOF(); throwEOF();
else
lastToken = nextToken;
nextToken = eocToken;
return lastToken; return lastToken;
} }

View file

@ -24,6 +24,7 @@ import org.eclipse.cdt.core.dom.ast.IBinding;
import org.eclipse.cdt.core.dom.ast.ICompositeType; import org.eclipse.cdt.core.dom.ast.ICompositeType;
import org.eclipse.cdt.core.dom.ast.IProblemBinding; import org.eclipse.cdt.core.dom.ast.IProblemBinding;
import org.eclipse.cdt.core.dom.ast.ITypedef; 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; import org.eclipse.cdt.core.dom.ast.cpp.ICPPClassType;
import org.eclipse.cdt.core.model.IWorkingCopy; import org.eclipse.cdt.core.model.IWorkingCopy;
import org.eclipse.cdt.core.parser.CodeReader; import org.eclipse.cdt.core.parser.CodeReader;
@ -57,7 +58,6 @@ public class CCompletionProcessor2 implements IContentAssistProcessor {
*/ */
public ICompletionProposal[] computeCompletionProposals(final ITextViewer viewer, public ICompletionProposal[] computeCompletionProposals(final ITextViewer viewer,
int offset) { int offset) {
errorMessage = null;
try { try {
long startTime = System.currentTimeMillis(); long startTime = System.currentTimeMillis();
IWorkingCopy workingCopy = CUIPlugin.getDefault().getWorkingCopyManager().getWorkingCopy(editor.getEditorInput()); IWorkingCopy workingCopy = CUIPlugin.getDefault().getWorkingCopyManager().getWorkingCopy(editor.getEditorInput());
@ -79,16 +79,22 @@ public class CCompletionProcessor2 implements IContentAssistProcessor {
); );
long stopTime = System.currentTimeMillis(); long stopTime = System.currentTimeMillis();
List proposals = null;
if (completionNode != null) {
int repLength = completionNode.getLength(); int repLength = completionNode.getLength();
int repOffset = offset - repLength; int repOffset = offset - repLength;
List proposals = new ArrayList(); proposals = new ArrayList();
IASTName[] names = completionNode.getNames(); IASTName[] names = completionNode.getNames();
for (int i = 0; i < names.length; ++i) { for (int i = 0; i < names.length; ++i) {
IBinding binding = names[0].resolveBinding(); IBinding binding = names[i].resolveBinding();
if (binding != null && !(binding instanceof IProblemBinding)) if (binding != null && !(binding instanceof IProblemBinding)) {
proposals.add(createBindingCompletionProposal(binding, repOffset, repLength)); proposals.add(createBindingCompletionProposal(binding, repOffset, repLength));
proposals.add(createBindingCompletionProposal(binding, repOffset, repLength));
}
}
} }
long propTime = System.currentTimeMillis(); long propTime = System.currentTimeMillis();
@ -96,16 +102,18 @@ public class CCompletionProcessor2 implements IContentAssistProcessor {
+ (propTime - stopTime)); + (propTime - stopTime));
System.out.flush(); System.out.flush();
if (!proposals.isEmpty()) if (proposals != null && !proposals.isEmpty()) {
errorMessage = null;
return (ICompletionProposal[])proposals.toArray(new ICompletionProposal[proposals.size()]); return (ICompletionProposal[])proposals.toArray(new ICompletionProposal[proposals.size()]);
else }
// The rest are error conditions
errorMessage = "No completions found"; errorMessage = "No completions found";
} catch (UnsupportedDialectException e) { } catch (UnsupportedDialectException e) {
errorMessage = "Unsupported Dialect Exception"; errorMessage = "Unsupported Dialect Exception";
} catch (Throwable e) { } catch (Throwable e) {
errorMessage = e.toString(); errorMessage = e.toString();
} }
return null; return null;
} }
@ -153,15 +161,17 @@ public class CCompletionProcessor2 implements IContentAssistProcessor {
ImageDescriptor imageDescriptor = null; ImageDescriptor imageDescriptor = null;
try { try {
if (binding instanceof ITypedef) if (binding instanceof ITypedef) {
imageDescriptor = CElementImageProvider.getTypedefImageDescriptor(); imageDescriptor = CElementImageProvider.getTypedefImageDescriptor();
else if (binding instanceof ICompositeType) { } else if (binding instanceof ICompositeType) {
if (((ICompositeType)binding).getKey() == ICPPClassType.k_class) if (((ICompositeType)binding).getKey() == ICPPClassType.k_class)
imageDescriptor = CElementImageProvider.getClassImageDescriptor(); imageDescriptor = CElementImageProvider.getClassImageDescriptor();
else if (((ICompositeType)binding).getKey() == ICompositeType.k_struct) else if (((ICompositeType)binding).getKey() == ICompositeType.k_struct)
imageDescriptor = CElementImageProvider.getStructImageDescriptor(); imageDescriptor = CElementImageProvider.getStructImageDescriptor();
else if (((ICompositeType)binding).getKey() == ICompositeType.k_union) else if (((ICompositeType)binding).getKey() == ICompositeType.k_union)
imageDescriptor = CElementImageProvider.getUnionImageDescriptor(); imageDescriptor = CElementImageProvider.getUnionImageDescriptor();
} else if (binding instanceof IVariable) {
imageDescriptor = CElementImageProvider.getVariableImageDescriptor();
} }
} catch (DOMException e) { } catch (DOMException e) {
} }

View file

@ -6,6 +6,7 @@
<stringAttribute key="org.eclipse.debug.core.ATTR_REFRESH_SCOPE" value="${project}"/> <stringAttribute key="org.eclipse.debug.core.ATTR_REFRESH_SCOPE" value="${project}"/>
<stringAttribute key="org.eclipse.ui.externaltools.ATTR_WORKING_DIRECTORY" value="${workspace_loc:/org.eclipse.cdt.doc.isv}"/> <stringAttribute key="org.eclipse.ui.externaltools.ATTR_WORKING_DIRECTORY" value="${workspace_loc:/org.eclipse.cdt.doc.isv}"/>
<stringAttribute key="org.eclipse.ui.externaltools.ATTR_LOCATION" value="${workspace_loc:/org.eclipse.cdt.doc.isv/buildDoc.xml}"/> <stringAttribute key="org.eclipse.ui.externaltools.ATTR_LOCATION" value="${workspace_loc:/org.eclipse.cdt.doc.isv/buildDoc.xml}"/>
<booleanAttribute key="org.eclipse.ui.externaltools.ATTR_TRIGGERS_CONFIGURED" value="true"/>
<booleanAttribute key="org.eclipse.debug.core.appendEnvironmentVariables" value="true"/> <booleanAttribute key="org.eclipse.debug.core.appendEnvironmentVariables" value="true"/>
<stringAttribute key="org.eclipse.jdt.launching.CLASSPATH_PROVIDER" value="org.eclipse.ant.ui.AntClasspathProvider"/> <stringAttribute key="org.eclipse.jdt.launching.CLASSPATH_PROVIDER" value="org.eclipse.ant.ui.AntClasspathProvider"/>
</launchConfiguration> </launchConfiguration>

View file

@ -17,6 +17,7 @@
</buildCommand> </buildCommand>
<buildCommand> <buildCommand>
<name>org.eclipse.ui.externaltools.ExternalToolBuilder</name> <name>org.eclipse.ui.externaltools.ExternalToolBuilder</name>
<triggers>full,incremental,</triggers>
<arguments> <arguments>
<dictionary> <dictionary>
<key>LaunchConfigHandle</key> <key>LaunchConfigHandle</key>