Skip to main content
summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorDoug Schaefer2005-02-21 16:33:59 -0500
committerDoug Schaefer2005-02-21 16:33:59 -0500
commit4ab007930b0b7bd29f65890f269cf898166d75f4 (patch)
treede916e995df462e8ded362ceaa5d57ec457a2315
parentd15eba065f54c8a0b4b3a07ccb1d23a5df2e9c99 (diff)
downloadorg.eclipse.cdt-4ab007930b0b7bd29f65890f269cf898166d75f4.tar.gz
org.eclipse.cdt-4ab007930b0b7bd29f65890f269cf898166d75f4.tar.xz
org.eclipse.cdt-4ab007930b0b7bd29f65890f269cf898166d75f4.zip
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.
-rw-r--r--core/org.eclipse.cdt.core/parser/org/eclipse/cdt/core/parser/IToken.java4
-rw-r--r--core/org.eclipse.cdt.core/parser/org/eclipse/cdt/internal/core/dom/parser/AbstractGNUSourceCodeParser.java2
-rw-r--r--core/org.eclipse.cdt.core/parser/org/eclipse/cdt/internal/core/dom/parser/cpp/GNUCPPSourceParser.java22
-rw-r--r--core/org.eclipse.cdt.core/parser/org/eclipse/cdt/internal/core/parser/scanner2/BaseScanner.java13
-rw-r--r--core/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/text/contentassist/CCompletionProcessor2.java44
-rw-r--r--doc/org.eclipse.cdt.doc.isv/.externalToolBuilders/cdt.doc.isv doc builder.launch1
-rw-r--r--doc/org.eclipse.cdt.doc.isv/.project1
7 files changed, 62 insertions, 25 deletions
diff --git a/core/org.eclipse.cdt.core/parser/org/eclipse/cdt/core/parser/IToken.java b/core/org.eclipse.cdt.core/parser/org/eclipse/cdt/core/parser/IToken.java
index 7c12e69c41..ee03f490b2 100644
--- a/core/org.eclipse.cdt.core/parser/org/eclipse/cdt/core/parser/IToken.java
+++ b/core/org.eclipse.cdt.core/parser/org/eclipse/cdt/core/parser/IToken.java
@@ -317,6 +317,8 @@ public interface IToken {
static public final int tPOUNDPOUND = 139;
static public final int tCOMPLETION = 140;
+
+ static public final int tEOC = 141; // End of Completion
- static public final int tLAST = 140;
+ static public final int tLAST = 141;
} \ No newline at end of file
diff --git a/core/org.eclipse.cdt.core/parser/org/eclipse/cdt/internal/core/dom/parser/AbstractGNUSourceCodeParser.java b/core/org.eclipse.cdt.core/parser/org/eclipse/cdt/internal/core/dom/parser/AbstractGNUSourceCodeParser.java
index 91711bf677..db646e024d 100644
--- a/core/org.eclipse.cdt.core/parser/org/eclipse/cdt/internal/core/dom/parser/AbstractGNUSourceCodeParser.java
+++ b/core/org.eclipse.cdt.core/parser/org/eclipse/cdt/internal/core/dom/parser/AbstractGNUSourceCodeParser.java
@@ -474,7 +474,7 @@ public abstract class AbstractGNUSourceCodeParser implements ISourceCodeParser {
((ASTNode) result).setOffset(startingOffset);
result.setParent(mostRelevantScopeNode);
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();
try {
IASTStatement s = statement();
diff --git a/core/org.eclipse.cdt.core/parser/org/eclipse/cdt/internal/core/dom/parser/cpp/GNUCPPSourceParser.java b/core/org.eclipse.cdt.core/parser/org/eclipse/cdt/internal/core/dom/parser/cpp/GNUCPPSourceParser.java
index 6e32b4e5e4..bafcbf90db 100644
--- a/core/org.eclipse.cdt.core/parser/org/eclipse/cdt/internal/core/dom/parser/cpp/GNUCPPSourceParser.java
+++ b/core/org.eclipse.cdt.core/parser/org/eclipse/cdt/internal/core/dom/parser/cpp/GNUCPPSourceParser.java
@@ -14,6 +14,7 @@ import java.util.ArrayList;
import java.util.Collections;
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.IASTArrayDeclarator;
import org.eclipse.cdt.core.dom.ast.IASTArrayModifier;
@@ -342,7 +343,7 @@ public class GNUCPPSourceParser extends AbstractGNUSourceCodeParser {
switch (LT(1)) {
case IToken.tIDENTIFIER:
- last = consume(IToken.tIDENTIFIER);
+ last = consume();
last = consumeTemplateArguments(last, argumentList);
if (last.getType() == IToken.tGT)
hasTemplateId = true;
@@ -1721,6 +1722,7 @@ public class GNUCPPSourceParser extends AbstractGNUSourceCodeParser {
case IToken.tCOLONCOLON:
case IToken.t_operator:
case IToken.tCOMPL:
+ {
ITokenDuple duple = idExpression();
IASTName name = createName(duple);
IASTIdExpression idExpression = createIdExpression();
@@ -1730,6 +1732,20 @@ public class GNUCPPSourceParser extends AbstractGNUSourceCodeParser {
name.setParent(idExpression);
name.setPropertyInParent(IASTIdExpression.ID_NAME);
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:
IToken la = LA(1);
int startingOffset = la.getOffset();
@@ -2662,6 +2678,10 @@ public class GNUCPPSourceParser extends AbstractGNUSourceCodeParser {
if (!fromCatchHandler)
throwBacktrack(firstOffset, LA(1).getEndOffset() - firstOffset);
break;
+ case IToken.tEOC:
+ // Pretend we consumed the semi
+ consumedSemi = true;
+ break;
default:
throwBacktrack(firstOffset, LA(1).getEndOffset() - firstOffset);
}
diff --git a/core/org.eclipse.cdt.core/parser/org/eclipse/cdt/internal/core/parser/scanner2/BaseScanner.java b/core/org.eclipse.cdt.core/parser/org/eclipse/cdt/internal/core/parser/scanner2/BaseScanner.java
index 90d3da860f..8b5e9a6c49 100644
--- a/core/org.eclipse.cdt.core/parser/org/eclipse/cdt/internal/core/parser/scanner2/BaseScanner.java
+++ b/core/org.eclipse.cdt.core/parser/org/eclipse/cdt/internal/core/parser/scanner2/BaseScanner.java
@@ -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.EmptyIterator;
import org.eclipse.cdt.internal.core.parser.token.KeywordSets;
+import org.eclipse.cdt.internal.core.parser.token.SimpleToken;
/**
* @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 IToken eocToken = new SimpleToken(IToken.tEOC, 0, null, 0);
+
/**
* @author jcamelon
*
@@ -1514,12 +1517,12 @@ abstract class BaseScanner implements IScanner {
if (finished) {
if (contentAssistMode) {
+ if (lastToken == eocToken)
+ throwEOF();
+
lastToken = nextToken;
- nextToken = null;
- if (lastToken == null)
- throwEOF();
- else
- return lastToken;
+ nextToken = eocToken;
+ return lastToken;
}
if (isCancelled == true)
diff --git a/core/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/text/contentassist/CCompletionProcessor2.java b/core/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/text/contentassist/CCompletionProcessor2.java
index 52fe396b19..80fde41e82 100644
--- a/core/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/text/contentassist/CCompletionProcessor2.java
+++ b/core/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/text/contentassist/CCompletionProcessor2.java
@@ -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.IProblemBinding;
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.model.IWorkingCopy;
import org.eclipse.cdt.core.parser.CodeReader;
@@ -57,7 +58,6 @@ public class CCompletionProcessor2 implements IContentAssistProcessor {
*/
public ICompletionProposal[] computeCompletionProposals(final ITextViewer viewer,
int offset) {
- errorMessage = null;
try {
long startTime = System.currentTimeMillis();
IWorkingCopy workingCopy = CUIPlugin.getDefault().getWorkingCopyManager().getWorkingCopy(editor.getEditorInput());
@@ -78,34 +78,42 @@ public class CCompletionProcessor2 implements IContentAssistProcessor {
}
);
long stopTime = System.currentTimeMillis();
+
+ List proposals = null;
- int repLength = completionNode.getLength();
- int repOffset = offset - repLength;
- List proposals = new ArrayList();
-
- IASTName[] names = completionNode.getNames();
- for (int i = 0; i < names.length; ++i) {
- IBinding binding = names[0].resolveBinding();
+ if (completionNode != null) {
+ int repLength = completionNode.getLength();
+ int repOffset = offset - repLength;
+ proposals = new ArrayList();
- if (binding != null && !(binding instanceof IProblemBinding))
- proposals.add(createBindingCompletionProposal(binding, repOffset, repLength));
+ 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));
+ }
+ }
}
-
+
long propTime = System.currentTimeMillis();
System.out.println("Completion Parse: " + (stopTime - startTime) + " + Resolve:"
+ (propTime - stopTime));
System.out.flush();
- if (!proposals.isEmpty())
+ if (proposals != null && !proposals.isEmpty()) {
+ errorMessage = null;
return (ICompletionProposal[])proposals.toArray(new ICompletionProposal[proposals.size()]);
- else
- errorMessage = "No completions found";
+ }
+
+ // The rest are error conditions
+ errorMessage = "No completions found";
} catch (UnsupportedDialectException e) {
errorMessage = "Unsupported Dialect Exception";
} catch (Throwable e) {
errorMessage = e.toString();
}
-
return null;
}
@@ -153,15 +161,17 @@ public class CCompletionProcessor2 implements IContentAssistProcessor {
ImageDescriptor imageDescriptor = null;
try {
- if (binding instanceof ITypedef)
+ if (binding instanceof ITypedef) {
imageDescriptor = CElementImageProvider.getTypedefImageDescriptor();
- else if (binding instanceof ICompositeType) {
+ } else if (binding instanceof ICompositeType) {
if (((ICompositeType)binding).getKey() == ICPPClassType.k_class)
imageDescriptor = CElementImageProvider.getClassImageDescriptor();
else if (((ICompositeType)binding).getKey() == ICompositeType.k_struct)
imageDescriptor = CElementImageProvider.getStructImageDescriptor();
else if (((ICompositeType)binding).getKey() == ICompositeType.k_union)
imageDescriptor = CElementImageProvider.getUnionImageDescriptor();
+ } else if (binding instanceof IVariable) {
+ imageDescriptor = CElementImageProvider.getVariableImageDescriptor();
}
} catch (DOMException e) {
}
diff --git a/doc/org.eclipse.cdt.doc.isv/.externalToolBuilders/cdt.doc.isv doc builder.launch b/doc/org.eclipse.cdt.doc.isv/.externalToolBuilders/cdt.doc.isv doc builder.launch
index 173126b076..f249cc0a5f 100644
--- a/doc/org.eclipse.cdt.doc.isv/.externalToolBuilders/cdt.doc.isv doc builder.launch
+++ b/doc/org.eclipse.cdt.doc.isv/.externalToolBuilders/cdt.doc.isv doc builder.launch
@@ -6,6 +6,7 @@
<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_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"/>
<stringAttribute key="org.eclipse.jdt.launching.CLASSPATH_PROVIDER" value="org.eclipse.ant.ui.AntClasspathProvider"/>
</launchConfiguration>
diff --git a/doc/org.eclipse.cdt.doc.isv/.project b/doc/org.eclipse.cdt.doc.isv/.project
index 4b4caffa1a..e22df7e00a 100644
--- a/doc/org.eclipse.cdt.doc.isv/.project
+++ b/doc/org.eclipse.cdt.doc.isv/.project
@@ -17,6 +17,7 @@
</buildCommand>
<buildCommand>
<name>org.eclipse.ui.externaltools.ExternalToolBuilder</name>
+ <triggers>full,incremental,</triggers>
<arguments>
<dictionary>
<key>LaunchConfigHandle</key>

Back to the top