mirror of
https://github.com/eclipse-cdt/cdt
synced 2025-07-19 15:05:36 +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:
parent
d15eba065f
commit
4ab007930b
7 changed files with 64 additions and 27 deletions
|
@ -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;
|
||||
}
|
|
@ -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();
|
||||
|
|
|
@ -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);
|
||||
}
|
||||
|
|
|
@ -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)
|
||||
|
|
|
@ -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();
|
||||
|
||||
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 (binding != null && !(binding instanceof IProblemBinding))
|
||||
proposals.add(createBindingCompletionProposal(binding, repOffset, repLength));
|
||||
}
|
||||
|
||||
List proposals = null;
|
||||
|
||||
if (completionNode != null) {
|
||||
int repLength = completionNode.getLength();
|
||||
int repOffset = offset - repLength;
|
||||
proposals = new ArrayList();
|
||||
|
||||
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) {
|
||||
}
|
||||
|
|
|
@ -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>
|
||||
|
|
|
@ -17,6 +17,7 @@
|
|||
</buildCommand>
|
||||
<buildCommand>
|
||||
<name>org.eclipse.ui.externaltools.ExternalToolBuilder</name>
|
||||
<triggers>full,incremental,</triggers>
|
||||
<arguments>
|
||||
<dictionary>
|
||||
<key>LaunchConfigHandle</key>
|
||||
|
|
Loading…
Add table
Reference in a new issue