mirror of
https://github.com/eclipse-cdt/cdt
synced 2025-07-24 01:15:29 +02:00
Hooked up the PDOM to content assist. Addes a getExpressionType to IASTExpression to help out the cause.
This commit is contained in:
parent
3ca3b2bdcc
commit
0c03c9be25
42 changed files with 395 additions and 639 deletions
|
@ -66,7 +66,7 @@ public class ASTCompletionNode {
|
|||
* @return the prefix text up to the point of completion
|
||||
*/
|
||||
public String getPrefix() {
|
||||
return completionToken.getImage();
|
||||
return completionToken.getType() != IToken.tEOC ? completionToken.getImage() : "";
|
||||
}
|
||||
|
||||
/**
|
||||
|
|
|
@ -20,4 +20,7 @@ public interface IASTExpression extends IASTNode {
|
|||
* Empty expression array.
|
||||
*/
|
||||
public static final IASTExpression[] EMPTY_EXPRESSION_ARRAY = new IASTExpression[0];
|
||||
|
||||
public IType getExpressionType();
|
||||
|
||||
}
|
||||
|
|
|
@ -95,7 +95,7 @@ public class GCCLanguage extends PlatformObject implements ILanguage {
|
|||
IFile rfile = (IFile)file.getResource();
|
||||
if (file instanceof IWorkingCopy) {
|
||||
// get the working copy contents
|
||||
reader = new CodeReader(rfile.getLocation().toOSString(), file.getContents());
|
||||
reader = new CodeReader(((IWorkingCopy)file).getOriginalElement().getPath().toOSString(), file.getContents());
|
||||
} else {
|
||||
String path
|
||||
= rfile != null
|
||||
|
@ -125,7 +125,48 @@ public class GCCLanguage extends PlatformObject implements ILanguage {
|
|||
}
|
||||
|
||||
public ASTCompletionNode getCompletionNode(IWorkingCopy workingCopy, int offset) {
|
||||
return null;
|
||||
IResource resource = workingCopy.getResource();
|
||||
ICProject project = workingCopy.getCProject();
|
||||
IProject rproject = project.getProject();
|
||||
|
||||
IScannerInfo scanInfo = null;
|
||||
IScannerInfoProvider provider = CCorePlugin.getDefault().getScannerInfoProvider(rproject);
|
||||
if (provider != null){
|
||||
IResource infoResource = resource != null ? resource : rproject;
|
||||
IScannerInfo buildScanInfo = provider.getScannerInformation(infoResource);
|
||||
if (buildScanInfo != null)
|
||||
scanInfo = buildScanInfo;
|
||||
else
|
||||
scanInfo = new ScannerInfo();
|
||||
}
|
||||
|
||||
PDOM pdom = (PDOM)CCorePlugin.getPDOMManager().getPDOM(project).getAdapter(PDOM.class);
|
||||
ICodeReaderFactory fileCreator = new PDOMCodeReaderFactory(pdom);
|
||||
|
||||
String path
|
||||
= resource != null
|
||||
? resource.getLocation().toOSString()
|
||||
: workingCopy.getOriginalElement().getPath().toOSString();
|
||||
CodeReader reader = new CodeReader(path, workingCopy.getContents());
|
||||
IScannerExtensionConfiguration scannerExtensionConfiguration
|
||||
= C_GNU_SCANNER_EXTENSION;
|
||||
IScanner scanner = new DOMScanner(reader, scanInfo, ParserMode.COMPLETE_PARSE,
|
||||
ParserLanguage.C, ParserFactory.createDefaultLogService(), scannerExtensionConfiguration, fileCreator );
|
||||
scanner.setContentAssistMode(offset);
|
||||
|
||||
ISourceCodeParser parser = new GNUCSourceParser(
|
||||
scanner,
|
||||
ParserMode.COMPLETION_PARSE,
|
||||
ParserUtil.getParserLogService(),
|
||||
new GCCParserExtensionConfiguration());
|
||||
|
||||
// Run the parse and return the completion node
|
||||
parser.parse();
|
||||
ASTCompletionNode node = parser.getCompletionNode();
|
||||
if (node != null) {
|
||||
node.count = scanner.getCount();
|
||||
}
|
||||
return node;
|
||||
}
|
||||
|
||||
public IContributedModelBuilder createModelBuilder(ITranslationUnit tu) {
|
||||
|
|
|
@ -94,7 +94,7 @@ public class GPPLanguage extends PlatformObject implements ILanguage {
|
|||
IFile rfile = (IFile)file.getResource();
|
||||
if (file instanceof IWorkingCopy) {
|
||||
// get the working copy contents
|
||||
reader = new CodeReader(rfile.getLocation().toOSString(), file.getContents());
|
||||
reader = new CodeReader(((IWorkingCopy)file).getOriginalElement().getPath().toOSString(), file.getContents());
|
||||
} else {
|
||||
String path
|
||||
= rfile != null
|
||||
|
@ -123,9 +123,45 @@ public class GPPLanguage extends PlatformObject implements ILanguage {
|
|||
return ast;
|
||||
}
|
||||
|
||||
public ASTCompletionNode getCompletionNode(IWorkingCopy workingCopy,
|
||||
int offset) {
|
||||
return null;
|
||||
public ASTCompletionNode getCompletionNode(IWorkingCopy workingCopy, int offset) {
|
||||
IResource resource = workingCopy.getResource();
|
||||
ICProject project = workingCopy.getCProject();
|
||||
IProject rproject = project.getProject();
|
||||
|
||||
IScannerInfo scanInfo = null;
|
||||
IScannerInfoProvider provider = CCorePlugin.getDefault().getScannerInfoProvider(rproject);
|
||||
if (provider != null){
|
||||
IResource infoResource = resource != null ? resource : rproject;
|
||||
IScannerInfo buildScanInfo = provider.getScannerInformation(infoResource);
|
||||
if (buildScanInfo != null)
|
||||
scanInfo = buildScanInfo;
|
||||
else
|
||||
scanInfo = new ScannerInfo();
|
||||
}
|
||||
|
||||
PDOM pdom = (PDOM)CCorePlugin.getPDOMManager().getPDOM(project).getAdapter(PDOM.class);
|
||||
ICodeReaderFactory fileCreator = new PDOMCodeReaderFactory(pdom);
|
||||
|
||||
CodeReader reader = new CodeReader(resource.getLocation().toOSString(), workingCopy.getContents());
|
||||
IScannerExtensionConfiguration scannerExtensionConfiguration
|
||||
= CPP_GNU_SCANNER_EXTENSION;
|
||||
IScanner scanner = new DOMScanner(reader, scanInfo, ParserMode.COMPLETE_PARSE,
|
||||
ParserLanguage.CPP, ParserFactory.createDefaultLogService(), scannerExtensionConfiguration, fileCreator );
|
||||
scanner.setContentAssistMode(offset);
|
||||
|
||||
ISourceCodeParser parser = new GNUCPPSourceParser(
|
||||
scanner,
|
||||
ParserMode.COMPLETION_PARSE,
|
||||
ParserUtil.getParserLogService(),
|
||||
new GPPParserExtensionConfiguration());
|
||||
|
||||
// Run the parse and return the completion node
|
||||
parser.parse();
|
||||
ASTCompletionNode node = parser.getCompletionNode();
|
||||
if (node != null) {
|
||||
node.count = scanner.getCount();
|
||||
}
|
||||
return node;
|
||||
}
|
||||
|
||||
|
||||
|
|
|
@ -12,6 +12,7 @@ package org.eclipse.cdt.internal.core.dom.parser.c;
|
|||
|
||||
import org.eclipse.cdt.core.dom.ast.IASTExpression;
|
||||
import org.eclipse.cdt.core.dom.ast.IASTNode;
|
||||
import org.eclipse.cdt.core.dom.ast.IType;
|
||||
import org.eclipse.cdt.core.parser.util.ArrayUtil;
|
||||
import org.eclipse.cdt.internal.core.dom.parser.IASTAmbiguousExpression;
|
||||
|
||||
|
@ -37,5 +38,8 @@ public class CASTAmbiguousExpression extends CASTAmbiguity implements
|
|||
return getExpressions();
|
||||
}
|
||||
|
||||
|
||||
public IType getExpressionType() {
|
||||
return CVisitor.getExpressionType(this);
|
||||
}
|
||||
|
||||
}
|
||||
|
|
|
@ -14,6 +14,7 @@ import org.eclipse.cdt.core.dom.ast.ASTVisitor;
|
|||
import org.eclipse.cdt.core.dom.ast.IASTArraySubscriptExpression;
|
||||
import org.eclipse.cdt.core.dom.ast.IASTExpression;
|
||||
import org.eclipse.cdt.core.dom.ast.IASTNode;
|
||||
import org.eclipse.cdt.core.dom.ast.IType;
|
||||
import org.eclipse.cdt.internal.core.dom.parser.IASTAmbiguityParent;
|
||||
|
||||
/**
|
||||
|
@ -25,30 +26,18 @@ public class CASTArraySubscriptExpression extends CASTNode implements
|
|||
private IASTExpression array;
|
||||
private IASTExpression subscript;
|
||||
|
||||
/* (non-Javadoc)
|
||||
* @see org.eclipse.cdt.core.dom.ast.IASTArraySubscriptExpression#getArrayExpression()
|
||||
*/
|
||||
public IASTExpression getArrayExpression() {
|
||||
return array;
|
||||
}
|
||||
|
||||
/* (non-Javadoc)
|
||||
* @see org.eclipse.cdt.core.dom.ast.IASTArraySubscriptExpression#setArrayExpression(org.eclipse.cdt.core.dom.ast.IASTExpression)
|
||||
*/
|
||||
public void setArrayExpression(IASTExpression expression) {
|
||||
array = expression;
|
||||
}
|
||||
|
||||
/* (non-Javadoc)
|
||||
* @see org.eclipse.cdt.core.dom.ast.IASTArraySubscriptExpression#getSubscriptExpression()
|
||||
*/
|
||||
public IASTExpression getSubscriptExpression() {
|
||||
return subscript;
|
||||
}
|
||||
|
||||
/* (non-Javadoc)
|
||||
* @see org.eclipse.cdt.core.dom.ast.IASTArraySubscriptExpression#setSubscriptExpression(org.eclipse.cdt.core.dom.ast.IASTExpression)
|
||||
*/
|
||||
public void setSubscriptExpression(IASTExpression expression) {
|
||||
this.subscript = expression;
|
||||
}
|
||||
|
@ -81,4 +70,9 @@ public class CASTArraySubscriptExpression extends CASTNode implements
|
|||
subscript = (IASTExpression) other;
|
||||
}
|
||||
}
|
||||
|
||||
public IType getExpressionType() {
|
||||
return CVisitor.getExpressionType(this);
|
||||
}
|
||||
|
||||
}
|
||||
|
|
|
@ -14,6 +14,7 @@ import org.eclipse.cdt.core.dom.ast.ASTVisitor;
|
|||
import org.eclipse.cdt.core.dom.ast.IASTBinaryExpression;
|
||||
import org.eclipse.cdt.core.dom.ast.IASTExpression;
|
||||
import org.eclipse.cdt.core.dom.ast.IASTNode;
|
||||
import org.eclipse.cdt.core.dom.ast.IType;
|
||||
import org.eclipse.cdt.internal.core.dom.parser.IASTAmbiguityParent;
|
||||
|
||||
/**
|
||||
|
@ -26,44 +27,26 @@ public class CASTBinaryExpression extends CASTNode implements
|
|||
private IASTExpression operand1;
|
||||
private IASTExpression operand2;
|
||||
|
||||
/* (non-Javadoc)
|
||||
* @see org.eclipse.cdt.core.dom.ast.IASTBinaryExpression#getOperator()
|
||||
*/
|
||||
public int getOperator() {
|
||||
return op;
|
||||
}
|
||||
|
||||
/* (non-Javadoc)
|
||||
* @see org.eclipse.cdt.core.dom.ast.IASTBinaryExpression#getOperand1()
|
||||
*/
|
||||
public IASTExpression getOperand1() {
|
||||
return operand1;
|
||||
}
|
||||
|
||||
/* (non-Javadoc)
|
||||
* @see org.eclipse.cdt.core.dom.ast.IASTBinaryExpression#getOperand2()
|
||||
*/
|
||||
public IASTExpression getOperand2() {
|
||||
return operand2;
|
||||
}
|
||||
|
||||
/* (non-Javadoc)
|
||||
* @see org.eclipse.cdt.core.dom.ast.IASTBinaryExpression#setOperator(int)
|
||||
*/
|
||||
public void setOperator(int op) {
|
||||
this.op = op;
|
||||
}
|
||||
|
||||
/* (non-Javadoc)
|
||||
* @see org.eclipse.cdt.core.dom.ast.IASTBinaryExpression#setOperand1(org.eclipse.cdt.core.dom.ast.IASTExpression)
|
||||
*/
|
||||
public void setOperand1(IASTExpression expression) {
|
||||
operand1 = expression;
|
||||
}
|
||||
|
||||
/* (non-Javadoc)
|
||||
* @see org.eclipse.cdt.core.dom.ast.IASTBinaryExpression#setOperand2(org.eclipse.cdt.core.dom.ast.IASTExpression)
|
||||
*/
|
||||
public void setOperand2(IASTExpression expression) {
|
||||
operand2 = expression;
|
||||
}
|
||||
|
@ -96,4 +79,9 @@ public class CASTBinaryExpression extends CASTNode implements
|
|||
operand2 = (IASTExpression) other;
|
||||
}
|
||||
}
|
||||
|
||||
public IType getExpressionType() {
|
||||
return CVisitor.getExpressionType(this);
|
||||
}
|
||||
|
||||
}
|
||||
|
|
|
@ -12,6 +12,7 @@ package org.eclipse.cdt.internal.core.dom.parser.c;
|
|||
|
||||
import org.eclipse.cdt.core.dom.ast.ASTVisitor;
|
||||
import org.eclipse.cdt.core.dom.ast.IASTCompoundStatement;
|
||||
import org.eclipse.cdt.core.dom.ast.IType;
|
||||
import org.eclipse.cdt.core.dom.ast.gnu.IGNUASTCompoundStatementExpression;
|
||||
|
||||
/**
|
||||
|
@ -22,16 +23,10 @@ public class CASTCompoundStatementExpression extends CASTNode implements
|
|||
|
||||
private IASTCompoundStatement statement;
|
||||
|
||||
/* (non-Javadoc)
|
||||
* @see org.eclipse.cdt.core.dom.ast.c.gcc.IGCCASTCompoundStatementExpression#getCompoundStatement()
|
||||
*/
|
||||
public IASTCompoundStatement getCompoundStatement() {
|
||||
return statement;
|
||||
}
|
||||
|
||||
/* (non-Javadoc)
|
||||
* @see org.eclipse.cdt.core.dom.ast.c.gcc.IGCCASTCompoundStatementExpression#setCompoundStatement(org.eclipse.cdt.core.dom.ast.IASTCompoundStatement)
|
||||
*/
|
||||
public void setCompoundStatement(IASTCompoundStatement statement) {
|
||||
this.statement = statement;
|
||||
}
|
||||
|
@ -48,4 +43,9 @@ public class CASTCompoundStatementExpression extends CASTNode implements
|
|||
if( statement != null ) if( !statement.accept( action ) ) return false;
|
||||
return true;
|
||||
}
|
||||
|
||||
public IType getExpressionType() {
|
||||
return CVisitor.getExpressionType(this);
|
||||
}
|
||||
|
||||
}
|
||||
|
|
|
@ -14,6 +14,7 @@ import org.eclipse.cdt.core.dom.ast.ASTVisitor;
|
|||
import org.eclipse.cdt.core.dom.ast.IASTConditionalExpression;
|
||||
import org.eclipse.cdt.core.dom.ast.IASTExpression;
|
||||
import org.eclipse.cdt.core.dom.ast.IASTNode;
|
||||
import org.eclipse.cdt.core.dom.ast.IType;
|
||||
import org.eclipse.cdt.internal.core.dom.parser.IASTAmbiguityParent;
|
||||
|
||||
/**
|
||||
|
@ -26,44 +27,26 @@ public class CASTConditionalExpression extends CASTNode implements
|
|||
private IASTExpression negative;
|
||||
private IASTExpression positive;
|
||||
|
||||
/* (non-Javadoc)
|
||||
* @see org.eclipse.cdt.core.dom.ast.IASTConditionalExpression#getLogicalConditionExpression()
|
||||
*/
|
||||
public IASTExpression getLogicalConditionExpression() {
|
||||
return condition;
|
||||
}
|
||||
|
||||
/* (non-Javadoc)
|
||||
* @see org.eclipse.cdt.core.dom.ast.IASTConditionalExpression#setLogicalConditionExpression(org.eclipse.cdt.core.dom.ast.IASTExpression)
|
||||
*/
|
||||
public void setLogicalConditionExpression(IASTExpression expression) {
|
||||
condition = expression;
|
||||
}
|
||||
|
||||
/* (non-Javadoc)
|
||||
* @see org.eclipse.cdt.core.dom.ast.IASTConditionalExpression#getPositiveResultExpression()
|
||||
*/
|
||||
public IASTExpression getPositiveResultExpression() {
|
||||
return positive;
|
||||
}
|
||||
|
||||
/* (non-Javadoc)
|
||||
* @see org.eclipse.cdt.core.dom.ast.IASTConditionalExpression#setPositiveResultExpression(org.eclipse.cdt.core.dom.ast.IASTExpression)
|
||||
*/
|
||||
public void setPositiveResultExpression(IASTExpression expression) {
|
||||
this.positive = expression;
|
||||
}
|
||||
|
||||
/* (non-Javadoc)
|
||||
* @see org.eclipse.cdt.core.dom.ast.IASTConditionalExpression#getNegativeResultExpression()
|
||||
*/
|
||||
public IASTExpression getNegativeResultExpression() {
|
||||
return negative;
|
||||
}
|
||||
|
||||
/* (non-Javadoc)
|
||||
* @see org.eclipse.cdt.core.dom.ast.IASTConditionalExpression#setNegativeResultExpression(org.eclipse.cdt.core.dom.ast.IASTExpression)
|
||||
*/
|
||||
public void setNegativeResultExpression(IASTExpression expression) {
|
||||
this.negative = expression;
|
||||
}
|
||||
|
@ -103,4 +86,9 @@ public class CASTConditionalExpression extends CASTNode implements
|
|||
negative= (IASTExpression) other;
|
||||
}
|
||||
}
|
||||
|
||||
public IType getExpressionType() {
|
||||
return CVisitor.getExpressionType(this);
|
||||
}
|
||||
|
||||
}
|
||||
|
|
|
@ -14,6 +14,7 @@ import org.eclipse.cdt.core.dom.ast.ASTVisitor;
|
|||
import org.eclipse.cdt.core.dom.ast.IASTExpression;
|
||||
import org.eclipse.cdt.core.dom.ast.IASTExpressionList;
|
||||
import org.eclipse.cdt.core.dom.ast.IASTNode;
|
||||
import org.eclipse.cdt.core.dom.ast.IType;
|
||||
import org.eclipse.cdt.core.parser.util.ArrayUtil;
|
||||
import org.eclipse.cdt.internal.core.dom.parser.IASTAmbiguityParent;
|
||||
|
||||
|
@ -23,27 +24,16 @@ import org.eclipse.cdt.internal.core.dom.parser.IASTAmbiguityParent;
|
|||
public class CASTExpressionList extends CASTNode implements IASTExpressionList,
|
||||
IASTAmbiguityParent {
|
||||
|
||||
/*
|
||||
* (non-Javadoc)
|
||||
*
|
||||
* @see org.eclipse.cdt.core.dom.ast.IASTExpressionList#getExpressions()
|
||||
*/
|
||||
public IASTExpression[] getExpressions() {
|
||||
if (expressions == null)
|
||||
return IASTExpression.EMPTY_EXPRESSION_ARRAY;
|
||||
return (IASTExpression[]) ArrayUtil.removeNulls( IASTExpression.class, expressions );
|
||||
}
|
||||
|
||||
/*
|
||||
* (non-Javadoc)
|
||||
*
|
||||
* @see org.eclipse.cdt.core.dom.ast.IASTExpressionList#addExpression(org.eclipse.cdt.core.dom.ast.IASTExpression)
|
||||
*/
|
||||
public void addExpression(IASTExpression expression) {
|
||||
expressions = (IASTExpression[]) ArrayUtil.append( IASTExpression.class, expressions, expression );
|
||||
}
|
||||
|
||||
|
||||
private IASTExpression [] expressions = new IASTExpression[2];
|
||||
|
||||
public boolean accept(ASTVisitor action) {
|
||||
|
@ -76,4 +66,9 @@ public class CASTExpressionList extends CASTNode implements IASTExpressionList,
|
|||
}
|
||||
}
|
||||
}
|
||||
|
||||
public IType getExpressionType() {
|
||||
return CVisitor.getExpressionType(this);
|
||||
}
|
||||
|
||||
}
|
||||
|
|
|
@ -15,6 +15,7 @@ import org.eclipse.cdt.core.dom.ast.IASTExpression;
|
|||
import org.eclipse.cdt.core.dom.ast.IASTFieldReference;
|
||||
import org.eclipse.cdt.core.dom.ast.IASTName;
|
||||
import org.eclipse.cdt.core.dom.ast.IASTNode;
|
||||
import org.eclipse.cdt.core.dom.ast.IType;
|
||||
import org.eclipse.cdt.internal.core.dom.parser.IASTAmbiguityParent;
|
||||
|
||||
/**
|
||||
|
@ -26,44 +27,26 @@ public class CASTFieldReference extends CASTNode implements IASTFieldReference,
|
|||
private IASTName name;
|
||||
private boolean ptr;
|
||||
|
||||
/* (non-Javadoc)
|
||||
* @see org.eclipse.cdt.core.dom.ast.IASTFieldReference#getFieldOwner()
|
||||
*/
|
||||
public IASTExpression getFieldOwner() {
|
||||
return owner;
|
||||
}
|
||||
|
||||
/* (non-Javadoc)
|
||||
* @see org.eclipse.cdt.core.dom.ast.IASTFieldReference#setFieldOwner(org.eclipse.cdt.core.dom.ast.IASTExpression)
|
||||
*/
|
||||
public void setFieldOwner(IASTExpression expression) {
|
||||
this.owner = expression;
|
||||
}
|
||||
|
||||
/* (non-Javadoc)
|
||||
* @see org.eclipse.cdt.core.dom.ast.IASTFieldReference#getFieldName()
|
||||
*/
|
||||
public IASTName getFieldName() {
|
||||
return name;
|
||||
}
|
||||
|
||||
/* (non-Javadoc)
|
||||
* @see org.eclipse.cdt.core.dom.ast.IASTFieldReference#setFieldName(org.eclipse.cdt.core.dom.ast.IASTName)
|
||||
*/
|
||||
public void setFieldName(IASTName name) {
|
||||
this.name = name;
|
||||
}
|
||||
|
||||
/* (non-Javadoc)
|
||||
* @see org.eclipse.cdt.core.dom.ast.IASTFieldReference#isPointerDereference()
|
||||
*/
|
||||
public boolean isPointerDereference() {
|
||||
return ptr;
|
||||
}
|
||||
|
||||
/* (non-Javadoc)
|
||||
* @see org.eclipse.cdt.core.dom.ast.IASTFieldReference#setIsPointerDereference(boolean)
|
||||
*/
|
||||
public void setIsPointerDereference(boolean value) {
|
||||
ptr = value;
|
||||
}
|
||||
|
@ -82,9 +65,6 @@ public class CASTFieldReference extends CASTNode implements IASTFieldReference,
|
|||
return true;
|
||||
}
|
||||
|
||||
/* (non-Javadoc)
|
||||
* @see org.eclipse.cdt.core.dom.ast.IASTNameOwner#getRoleForName(org.eclipse.cdt.core.dom.ast.IASTName)
|
||||
*/
|
||||
public int getRoleForName(IASTName n ) {
|
||||
if( n == this.name )
|
||||
return r_reference;
|
||||
|
@ -100,5 +80,8 @@ public class CASTFieldReference extends CASTNode implements IASTFieldReference,
|
|||
}
|
||||
}
|
||||
|
||||
public IType getExpressionType() {
|
||||
return CVisitor.getExpressionType(this);
|
||||
}
|
||||
|
||||
}
|
||||
|
|
|
@ -14,6 +14,7 @@ import org.eclipse.cdt.core.dom.ast.ASTVisitor;
|
|||
import org.eclipse.cdt.core.dom.ast.IASTExpression;
|
||||
import org.eclipse.cdt.core.dom.ast.IASTFunctionCallExpression;
|
||||
import org.eclipse.cdt.core.dom.ast.IASTNode;
|
||||
import org.eclipse.cdt.core.dom.ast.IType;
|
||||
import org.eclipse.cdt.internal.core.dom.parser.IASTAmbiguityParent;
|
||||
|
||||
/**
|
||||
|
@ -25,30 +26,18 @@ public class CASTFunctionCallExpression extends CASTNode implements
|
|||
private IASTExpression functionName;
|
||||
private IASTExpression parameter;
|
||||
|
||||
/* (non-Javadoc)
|
||||
* @see org.eclipse.cdt.core.dom.ast.IASTFunctionCallExpression#setFunctionNameExpression(org.eclipse.cdt.core.dom.ast.IASTExpression)
|
||||
*/
|
||||
public void setFunctionNameExpression(IASTExpression expression) {
|
||||
this.functionName = expression;
|
||||
}
|
||||
|
||||
/* (non-Javadoc)
|
||||
* @see org.eclipse.cdt.core.dom.ast.IASTFunctionCallExpression#getFunctionNameExpression()
|
||||
*/
|
||||
public IASTExpression getFunctionNameExpression() {
|
||||
return functionName;
|
||||
}
|
||||
|
||||
/* (non-Javadoc)
|
||||
* @see org.eclipse.cdt.core.dom.ast.IASTFunctionCallExpression#setParameterExpression(org.eclipse.cdt.core.dom.ast.IASTExpression)
|
||||
*/
|
||||
public void setParameterExpression(IASTExpression expression) {
|
||||
this.parameter = expression;
|
||||
}
|
||||
|
||||
/* (non-Javadoc)
|
||||
* @see org.eclipse.cdt.core.dom.ast.IASTFunctionCallExpression#getParameterExpression()
|
||||
*/
|
||||
public IASTExpression getParameterExpression() {
|
||||
return parameter;
|
||||
}
|
||||
|
@ -82,4 +71,8 @@ public class CASTFunctionCallExpression extends CASTNode implements
|
|||
}
|
||||
}
|
||||
|
||||
public IType getExpressionType() {
|
||||
return CVisitor.getExpressionType(this);
|
||||
}
|
||||
|
||||
}
|
||||
|
|
|
@ -13,6 +13,7 @@ package org.eclipse.cdt.internal.core.dom.parser.c;
|
|||
import org.eclipse.cdt.core.dom.ast.ASTVisitor;
|
||||
import org.eclipse.cdt.core.dom.ast.IASTIdExpression;
|
||||
import org.eclipse.cdt.core.dom.ast.IASTName;
|
||||
import org.eclipse.cdt.core.dom.ast.IType;
|
||||
|
||||
/**
|
||||
* @author jcamelon
|
||||
|
@ -21,16 +22,10 @@ public class CASTIdExpression extends CASTNode implements IASTIdExpression {
|
|||
|
||||
private IASTName name;
|
||||
|
||||
/* (non-Javadoc)
|
||||
* @see org.eclipse.cdt.core.dom.ast.IASTIdExpression#getName()
|
||||
*/
|
||||
public IASTName getName() {
|
||||
return name;
|
||||
}
|
||||
|
||||
/* (non-Javadoc)
|
||||
* @see org.eclipse.cdt.core.dom.ast.IASTIdExpression#setName(org.eclipse.cdt.core.dom.ast.IASTName)
|
||||
*/
|
||||
public void setName(IASTName name) {
|
||||
this.name = name;
|
||||
}
|
||||
|
@ -48,11 +43,13 @@ public class CASTIdExpression extends CASTNode implements IASTIdExpression {
|
|||
return true;
|
||||
}
|
||||
|
||||
/* (non-Javadoc)
|
||||
* @see org.eclipse.cdt.core.dom.ast.IASTNameOwner#getRoleForName(org.eclipse.cdt.core.dom.ast.IASTName)
|
||||
*/
|
||||
public int getRoleForName(IASTName n) {
|
||||
if( n == name ) return r_reference;
|
||||
return r_unclear;
|
||||
}
|
||||
|
||||
public IType getExpressionType() {
|
||||
return CVisitor.getExpressionType(this);
|
||||
}
|
||||
|
||||
}
|
||||
|
|
|
@ -12,6 +12,7 @@ package org.eclipse.cdt.internal.core.dom.parser.c;
|
|||
|
||||
import org.eclipse.cdt.core.dom.ast.ASTVisitor;
|
||||
import org.eclipse.cdt.core.dom.ast.IASTLiteralExpression;
|
||||
import org.eclipse.cdt.core.dom.ast.IType;
|
||||
|
||||
/**
|
||||
* @author jcamelon
|
||||
|
@ -22,30 +23,18 @@ public class CASTLiteralExpression extends CASTNode implements
|
|||
private int kind;
|
||||
private String value = ""; //$NON-NLS-1$
|
||||
|
||||
/* (non-Javadoc)
|
||||
* @see org.eclipse.cdt.core.dom.ast.IASTLiteralExpression#getKind()
|
||||
*/
|
||||
public int getKind() {
|
||||
return kind;
|
||||
}
|
||||
|
||||
/* (non-Javadoc)
|
||||
* @see org.eclipse.cdt.core.dom.ast.IASTLiteralExpression#setKind(int)
|
||||
*/
|
||||
public void setKind(int value) {
|
||||
kind = value;
|
||||
}
|
||||
|
||||
/* (non-Javadoc)
|
||||
* @see org.eclipse.cdt.core.dom.ast.IASTLiteralExpression#setValue(java.lang.String)
|
||||
*/
|
||||
public void setValue(String value) {
|
||||
this.value = value;
|
||||
}
|
||||
|
||||
/* (non-Javadoc)
|
||||
* @see java.lang.Object#toString()
|
||||
*/
|
||||
public String toString() {
|
||||
return value;
|
||||
}
|
||||
|
@ -60,4 +49,9 @@ public class CASTLiteralExpression extends CASTNode implements
|
|||
}
|
||||
return true;
|
||||
}
|
||||
|
||||
public IType getExpressionType() {
|
||||
return CVisitor.getExpressionType(this);
|
||||
}
|
||||
|
||||
}
|
||||
|
|
|
@ -12,6 +12,7 @@ package org.eclipse.cdt.internal.core.dom.parser.c;
|
|||
|
||||
import org.eclipse.cdt.core.dom.ast.ASTVisitor;
|
||||
import org.eclipse.cdt.core.dom.ast.IASTProblemExpression;
|
||||
import org.eclipse.cdt.core.dom.ast.IType;
|
||||
|
||||
/**
|
||||
* @author jcamelon
|
||||
|
@ -29,4 +30,9 @@ public class CASTProblemExpression extends CASTProblemOwner implements
|
|||
}
|
||||
return true;
|
||||
}
|
||||
|
||||
public IType getExpressionType() {
|
||||
return null;
|
||||
}
|
||||
|
||||
}
|
||||
|
|
|
@ -13,6 +13,7 @@ package org.eclipse.cdt.internal.core.dom.parser.c;
|
|||
import org.eclipse.cdt.core.dom.ast.ASTVisitor;
|
||||
import org.eclipse.cdt.core.dom.ast.IASTTypeId;
|
||||
import org.eclipse.cdt.core.dom.ast.IASTTypeIdExpression;
|
||||
import org.eclipse.cdt.core.dom.ast.IType;
|
||||
|
||||
/**
|
||||
* @author jcamelon
|
||||
|
@ -23,30 +24,18 @@ public class CASTTypeIdExpression extends CASTNode implements
|
|||
private int op;
|
||||
private IASTTypeId typeId;
|
||||
|
||||
/* (non-Javadoc)
|
||||
* @see org.eclipse.cdt.core.dom.ast.IASTTypeIdExpression#getOperator()
|
||||
*/
|
||||
public int getOperator() {
|
||||
return op;
|
||||
}
|
||||
|
||||
/* (non-Javadoc)
|
||||
* @see org.eclipse.cdt.core.dom.ast.IASTTypeIdExpression#setOperator(int)
|
||||
*/
|
||||
public void setOperator(int value) {
|
||||
this.op = value;
|
||||
}
|
||||
|
||||
/* (non-Javadoc)
|
||||
* @see org.eclipse.cdt.core.dom.ast.IASTTypeIdExpression#setTypeId(org.eclipse.cdt.core.dom.ast.IASTTypeId)
|
||||
*/
|
||||
public void setTypeId(IASTTypeId typeId) {
|
||||
this.typeId = typeId;
|
||||
}
|
||||
|
||||
/* (non-Javadoc)
|
||||
* @see org.eclipse.cdt.core.dom.ast.IASTTypeIdExpression#getTypeId()
|
||||
*/
|
||||
public IASTTypeId getTypeId() {
|
||||
return typeId;
|
||||
}
|
||||
|
@ -63,4 +52,9 @@ public class CASTTypeIdExpression extends CASTNode implements
|
|||
if( typeId != null ) if( !typeId.accept( action ) ) return false;
|
||||
return true;
|
||||
}
|
||||
|
||||
public IType getExpressionType() {
|
||||
return CVisitor.getExpressionType(this);
|
||||
}
|
||||
|
||||
}
|
||||
|
|
|
@ -13,6 +13,7 @@ package org.eclipse.cdt.internal.core.dom.parser.c;
|
|||
import org.eclipse.cdt.core.dom.ast.ASTVisitor;
|
||||
import org.eclipse.cdt.core.dom.ast.IASTInitializer;
|
||||
import org.eclipse.cdt.core.dom.ast.IASTTypeId;
|
||||
import org.eclipse.cdt.core.dom.ast.IType;
|
||||
import org.eclipse.cdt.core.dom.ast.c.ICASTTypeIdInitializerExpression;
|
||||
|
||||
/**
|
||||
|
@ -24,30 +25,18 @@ public class CASTTypeIdInitializerExpression extends CASTNode implements
|
|||
private IASTTypeId t;
|
||||
private IASTInitializer i;
|
||||
|
||||
/* (non-Javadoc)
|
||||
* @see org.eclipse.cdt.core.dom.ast.c.ICASTTypeIdInitializerExpression#getTypeId()
|
||||
*/
|
||||
public IASTTypeId getTypeId() {
|
||||
return t;
|
||||
}
|
||||
|
||||
/* (non-Javadoc)
|
||||
* @see org.eclipse.cdt.core.dom.ast.c.ICASTTypeIdInitializerExpression#setTypeId(org.eclipse.cdt.core.dom.ast.IASTTypeId)
|
||||
*/
|
||||
public void setTypeId(IASTTypeId typeId) {
|
||||
t = typeId;
|
||||
}
|
||||
|
||||
/* (non-Javadoc)
|
||||
* @see org.eclipse.cdt.core.dom.ast.c.ICASTTypeIdInitializerExpression#getInitializer()
|
||||
*/
|
||||
public IASTInitializer getInitializer() {
|
||||
return i;
|
||||
}
|
||||
|
||||
/* (non-Javadoc)
|
||||
* @see org.eclipse.cdt.core.dom.ast.c.ICASTTypeIdInitializerExpression#setInitializer(org.eclipse.cdt.core.dom.ast.IASTInitializer)
|
||||
*/
|
||||
public void setInitializer(IASTInitializer initializer) {
|
||||
i = initializer;
|
||||
}
|
||||
|
@ -65,4 +54,9 @@ public class CASTTypeIdInitializerExpression extends CASTNode implements
|
|||
if( i != null ) if( !i.accept( action ) ) return false;
|
||||
return true;
|
||||
}
|
||||
|
||||
public IType getExpressionType() {
|
||||
return CVisitor.getExpressionType(this);
|
||||
}
|
||||
|
||||
}
|
||||
|
|
|
@ -14,6 +14,7 @@ import org.eclipse.cdt.core.dom.ast.ASTVisitor;
|
|||
import org.eclipse.cdt.core.dom.ast.IASTExpression;
|
||||
import org.eclipse.cdt.core.dom.ast.IASTNode;
|
||||
import org.eclipse.cdt.core.dom.ast.IASTUnaryExpression;
|
||||
import org.eclipse.cdt.core.dom.ast.IType;
|
||||
import org.eclipse.cdt.internal.core.dom.parser.IASTAmbiguityParent;
|
||||
|
||||
/**
|
||||
|
@ -25,30 +26,18 @@ public class CASTUnaryExpression extends CASTNode implements
|
|||
private int operator;
|
||||
private IASTExpression operand;
|
||||
|
||||
/* (non-Javadoc)
|
||||
* @see org.eclipse.cdt.core.dom.ast.IASTUnaryExpression#getOperator()
|
||||
*/
|
||||
public int getOperator() {
|
||||
return operator;
|
||||
}
|
||||
|
||||
/* (non-Javadoc)
|
||||
* @see org.eclipse.cdt.core.dom.ast.IASTUnaryExpression#setOperator(int)
|
||||
*/
|
||||
public void setOperator(int value) {
|
||||
this.operator = value;
|
||||
}
|
||||
|
||||
/* (non-Javadoc)
|
||||
* @see org.eclipse.cdt.core.dom.ast.IASTUnaryExpression#getOperand()
|
||||
*/
|
||||
public IASTExpression getOperand() {
|
||||
return operand;
|
||||
}
|
||||
|
||||
/* (non-Javadoc)
|
||||
* @see org.eclipse.cdt.core.dom.ast.IASTUnaryExpression#setOperand(org.eclipse.cdt.core.dom.ast.IASTExpression)
|
||||
*/
|
||||
public void setOperand(IASTExpression expression) {
|
||||
operand = expression;
|
||||
}
|
||||
|
@ -74,4 +63,9 @@ public class CASTUnaryExpression extends CASTNode implements
|
|||
operand = (IASTExpression) other;
|
||||
}
|
||||
}
|
||||
|
||||
public IType getExpressionType() {
|
||||
return CVisitor.getExpressionType(this);
|
||||
}
|
||||
|
||||
}
|
||||
|
|
|
@ -12,6 +12,7 @@ package org.eclipse.cdt.internal.core.dom.parser.cpp;
|
|||
|
||||
import org.eclipse.cdt.core.dom.ast.IASTExpression;
|
||||
import org.eclipse.cdt.core.dom.ast.IASTNode;
|
||||
import org.eclipse.cdt.core.dom.ast.IType;
|
||||
import org.eclipse.cdt.core.parser.util.ArrayUtil;
|
||||
import org.eclipse.cdt.internal.core.dom.parser.IASTAmbiguousExpression;
|
||||
|
||||
|
@ -36,5 +37,9 @@ public class CPPASTAmbiguousExpression extends CPPASTAmbiguity implements
|
|||
protected IASTNode[] getNodes() {
|
||||
return getExpressions();
|
||||
}
|
||||
|
||||
public IType getExpressionType() {
|
||||
return CPPVisitor.getExpressionType(this);
|
||||
}
|
||||
|
||||
}
|
||||
|
|
|
@ -14,6 +14,7 @@ import org.eclipse.cdt.core.dom.ast.ASTVisitor;
|
|||
import org.eclipse.cdt.core.dom.ast.IASTArraySubscriptExpression;
|
||||
import org.eclipse.cdt.core.dom.ast.IASTExpression;
|
||||
import org.eclipse.cdt.core.dom.ast.IASTNode;
|
||||
import org.eclipse.cdt.core.dom.ast.IType;
|
||||
import org.eclipse.cdt.internal.core.dom.parser.IASTAmbiguityParent;
|
||||
|
||||
/**
|
||||
|
@ -25,30 +26,18 @@ public class CPPASTArraySubscriptExpression extends CPPASTNode implements
|
|||
private IASTExpression subscriptExp;
|
||||
private IASTExpression arrayExpression;
|
||||
|
||||
/* (non-Javadoc)
|
||||
* @see org.eclipse.cdt.core.dom.ast.IASTArraySubscriptExpression#getArrayExpression()
|
||||
*/
|
||||
public IASTExpression getArrayExpression() {
|
||||
return arrayExpression;
|
||||
}
|
||||
|
||||
/* (non-Javadoc)
|
||||
* @see org.eclipse.cdt.core.dom.ast.IASTArraySubscriptExpression#setArrayExpression(org.eclipse.cdt.core.dom.ast.IASTExpression)
|
||||
*/
|
||||
public void setArrayExpression(IASTExpression expression) {
|
||||
arrayExpression = expression;
|
||||
}
|
||||
|
||||
/* (non-Javadoc)
|
||||
* @see org.eclipse.cdt.core.dom.ast.IASTArraySubscriptExpression#getSubscriptExpression()
|
||||
*/
|
||||
public IASTExpression getSubscriptExpression() {
|
||||
return subscriptExp;
|
||||
}
|
||||
|
||||
/* (non-Javadoc)
|
||||
* @see org.eclipse.cdt.core.dom.ast.IASTArraySubscriptExpression#setSubscriptExpression(org.eclipse.cdt.core.dom.ast.IASTExpression)
|
||||
*/
|
||||
public void setSubscriptExpression(IASTExpression expression) {
|
||||
subscriptExp = expression;
|
||||
}
|
||||
|
@ -83,4 +72,8 @@ public class CPPASTArraySubscriptExpression extends CPPASTNode implements
|
|||
}
|
||||
}
|
||||
|
||||
public IType getExpressionType() {
|
||||
return CPPVisitor.getExpressionType(this);
|
||||
}
|
||||
|
||||
}
|
||||
|
|
|
@ -13,6 +13,7 @@ package org.eclipse.cdt.internal.core.dom.parser.cpp;
|
|||
import org.eclipse.cdt.core.dom.ast.ASTVisitor;
|
||||
import org.eclipse.cdt.core.dom.ast.IASTExpression;
|
||||
import org.eclipse.cdt.core.dom.ast.IASTNode;
|
||||
import org.eclipse.cdt.core.dom.ast.IType;
|
||||
import org.eclipse.cdt.core.dom.ast.cpp.ICPPASTBinaryExpression;
|
||||
import org.eclipse.cdt.internal.core.dom.parser.IASTAmbiguityParent;
|
||||
|
||||
|
@ -26,44 +27,26 @@ public class CPPASTBinaryExpression extends CPPASTNode implements
|
|||
private IASTExpression operand1;
|
||||
private IASTExpression operand2;
|
||||
|
||||
/* (non-Javadoc)
|
||||
* @see org.eclipse.cdt.core.dom.ast.IASTBinaryExpression#getOperator()
|
||||
*/
|
||||
public int getOperator() {
|
||||
return op;
|
||||
}
|
||||
|
||||
/* (non-Javadoc)
|
||||
* @see org.eclipse.cdt.core.dom.ast.IASTBinaryExpression#getOperand1()
|
||||
*/
|
||||
public IASTExpression getOperand1() {
|
||||
return operand1;
|
||||
}
|
||||
|
||||
/* (non-Javadoc)
|
||||
* @see org.eclipse.cdt.core.dom.ast.IASTBinaryExpression#getOperand2()
|
||||
*/
|
||||
public IASTExpression getOperand2() {
|
||||
return operand2;
|
||||
}
|
||||
|
||||
/* (non-Javadoc)
|
||||
* @see org.eclipse.cdt.core.dom.ast.IASTBinaryExpression#setOperator(int)
|
||||
*/
|
||||
public void setOperator(int op) {
|
||||
this.op = op;
|
||||
}
|
||||
|
||||
/* (non-Javadoc)
|
||||
* @see org.eclipse.cdt.core.dom.ast.IASTBinaryExpression#setOperand1(org.eclipse.cdt.core.dom.ast.IASTExpression)
|
||||
*/
|
||||
public void setOperand1(IASTExpression expression) {
|
||||
operand1 = expression;
|
||||
}
|
||||
|
||||
/* (non-Javadoc)
|
||||
* @see org.eclipse.cdt.core.dom.ast.IASTBinaryExpression#setOperand2(org.eclipse.cdt.core.dom.ast.IASTExpression)
|
||||
*/
|
||||
public void setOperand2(IASTExpression expression) {
|
||||
operand2 = expression;
|
||||
}
|
||||
|
@ -97,4 +80,8 @@ public class CPPASTBinaryExpression extends CPPASTNode implements
|
|||
}
|
||||
}
|
||||
|
||||
public IType getExpressionType() {
|
||||
return CPPVisitor.getExpressionType(this);
|
||||
}
|
||||
|
||||
}
|
||||
|
|
|
@ -12,6 +12,7 @@ package org.eclipse.cdt.internal.core.dom.parser.cpp;
|
|||
|
||||
import org.eclipse.cdt.core.dom.ast.ASTVisitor;
|
||||
import org.eclipse.cdt.core.dom.ast.IASTCompoundStatement;
|
||||
import org.eclipse.cdt.core.dom.ast.IType;
|
||||
import org.eclipse.cdt.core.dom.ast.gnu.IGNUASTCompoundStatementExpression;
|
||||
|
||||
/**
|
||||
|
@ -21,16 +22,10 @@ public class CPPASTCompoundStatementExpression extends CPPASTNode implements
|
|||
IGNUASTCompoundStatementExpression {
|
||||
private IASTCompoundStatement statement;
|
||||
|
||||
/* (non-Javadoc)
|
||||
* @see org.eclipse.cdt.core.dom.ast.c.gcc.IGCCASTCompoundStatementExpression#getCompoundStatement()
|
||||
*/
|
||||
public IASTCompoundStatement getCompoundStatement() {
|
||||
return statement;
|
||||
}
|
||||
|
||||
/* (non-Javadoc)
|
||||
* @see org.eclipse.cdt.core.dom.ast.c.gcc.IGCCASTCompoundStatementExpression#setCompoundStatement(org.eclipse.cdt.core.dom.ast.IASTCompoundStatement)
|
||||
*/
|
||||
public void setCompoundStatement(IASTCompoundStatement statement) {
|
||||
this.statement = statement;
|
||||
}
|
||||
|
@ -47,4 +42,9 @@ public class CPPASTCompoundStatementExpression extends CPPASTNode implements
|
|||
if( statement != null ) if( !statement.accept( action ) ) return false;
|
||||
return true;
|
||||
}
|
||||
|
||||
public IType getExpressionType() {
|
||||
return CPPVisitor.getExpressionType(this);
|
||||
}
|
||||
|
||||
}
|
||||
|
|
|
@ -14,6 +14,7 @@ import org.eclipse.cdt.core.dom.ast.ASTVisitor;
|
|||
import org.eclipse.cdt.core.dom.ast.IASTConditionalExpression;
|
||||
import org.eclipse.cdt.core.dom.ast.IASTExpression;
|
||||
import org.eclipse.cdt.core.dom.ast.IASTNode;
|
||||
import org.eclipse.cdt.core.dom.ast.IType;
|
||||
import org.eclipse.cdt.internal.core.dom.parser.IASTAmbiguityParent;
|
||||
|
||||
/**
|
||||
|
@ -25,44 +26,26 @@ public class CPPASTConditionalExpression extends CPPASTNode implements
|
|||
private IASTExpression negative;
|
||||
private IASTExpression postive;
|
||||
|
||||
/* (non-Javadoc)
|
||||
* @see org.eclipse.cdt.core.dom.ast.IASTConditionalExpression#getLogicalConditionExpression()
|
||||
*/
|
||||
public IASTExpression getLogicalConditionExpression() {
|
||||
return condition;
|
||||
}
|
||||
|
||||
/* (non-Javadoc)
|
||||
* @see org.eclipse.cdt.core.dom.ast.IASTConditionalExpression#setLogicalConditionExpression(org.eclipse.cdt.core.dom.ast.IASTExpression)
|
||||
*/
|
||||
public void setLogicalConditionExpression(IASTExpression expression) {
|
||||
condition = expression;
|
||||
}
|
||||
|
||||
/* (non-Javadoc)
|
||||
* @see org.eclipse.cdt.core.dom.ast.IASTConditionalExpression#getPositiveResultExpression()
|
||||
*/
|
||||
public IASTExpression getPositiveResultExpression() {
|
||||
return postive;
|
||||
}
|
||||
|
||||
/* (non-Javadoc)
|
||||
* @see org.eclipse.cdt.core.dom.ast.IASTConditionalExpression#setPositiveResultExpression(org.eclipse.cdt.core.dom.ast.IASTExpression)
|
||||
*/
|
||||
public void setPositiveResultExpression(IASTExpression expression) {
|
||||
this.postive = expression;
|
||||
}
|
||||
|
||||
/* (non-Javadoc)
|
||||
* @see org.eclipse.cdt.core.dom.ast.IASTConditionalExpression#getNegativeResultExpression()
|
||||
*/
|
||||
public IASTExpression getNegativeResultExpression() {
|
||||
return negative;
|
||||
}
|
||||
|
||||
/* (non-Javadoc)
|
||||
* @see org.eclipse.cdt.core.dom.ast.IASTConditionalExpression#setNegativeResultExpression(org.eclipse.cdt.core.dom.ast.IASTExpression)
|
||||
*/
|
||||
public void setNegativeResultExpression(IASTExpression expression) {
|
||||
this.negative = expression;
|
||||
}
|
||||
|
@ -102,4 +85,9 @@ public class CPPASTConditionalExpression extends CPPASTNode implements
|
|||
negative = (IASTExpression) other;
|
||||
}
|
||||
}
|
||||
|
||||
public IType getExpressionType() {
|
||||
return CPPVisitor.getExpressionType(this);
|
||||
}
|
||||
|
||||
}
|
||||
|
|
|
@ -12,6 +12,7 @@ package org.eclipse.cdt.internal.core.dom.parser.cpp;
|
|||
|
||||
import org.eclipse.cdt.core.dom.ast.ASTVisitor;
|
||||
import org.eclipse.cdt.core.dom.ast.IASTExpression;
|
||||
import org.eclipse.cdt.core.dom.ast.IType;
|
||||
import org.eclipse.cdt.core.dom.ast.cpp.ICPPASTDeleteExpression;
|
||||
|
||||
/**
|
||||
|
@ -24,44 +25,26 @@ public class CPPASTDeleteExpression extends CPPASTNode implements
|
|||
private boolean isGlobal;
|
||||
private boolean isVectored;
|
||||
|
||||
/* (non-Javadoc)
|
||||
* @see org.eclipse.cdt.core.dom.ast.cpp.ICPPASTDeleteExpression#getOperand()
|
||||
*/
|
||||
public IASTExpression getOperand() {
|
||||
return operand;
|
||||
}
|
||||
|
||||
/* (non-Javadoc)
|
||||
* @see org.eclipse.cdt.core.dom.ast.cpp.ICPPASTDeleteExpression#setOperand(org.eclipse.cdt.core.dom.ast.IASTExpression)
|
||||
*/
|
||||
public void setOperand(IASTExpression expression) {
|
||||
operand = expression;
|
||||
}
|
||||
|
||||
/* (non-Javadoc)
|
||||
* @see org.eclipse.cdt.core.dom.ast.cpp.ICPPASTDeleteExpression#setIsGlobal(boolean)
|
||||
*/
|
||||
public void setIsGlobal(boolean global) {
|
||||
isGlobal = global;
|
||||
}
|
||||
|
||||
/* (non-Javadoc)
|
||||
* @see org.eclipse.cdt.core.dom.ast.cpp.ICPPASTDeleteExpression#isGlobal()
|
||||
*/
|
||||
public boolean isGlobal() {
|
||||
return isGlobal;
|
||||
}
|
||||
|
||||
/* (non-Javadoc)
|
||||
* @see org.eclipse.cdt.core.dom.ast.cpp.ICPPASTDeleteExpression#setIsVectored(boolean)
|
||||
*/
|
||||
public void setIsVectored(boolean vectored) {
|
||||
isVectored = vectored;
|
||||
}
|
||||
|
||||
/* (non-Javadoc)
|
||||
* @see org.eclipse.cdt.core.dom.ast.cpp.ICPPASTDeleteExpression#isVectored()
|
||||
*/
|
||||
public boolean isVectored() {
|
||||
return isVectored;
|
||||
}
|
||||
|
@ -78,4 +61,9 @@ public class CPPASTDeleteExpression extends CPPASTNode implements
|
|||
if( operand != null ) if( !operand.accept( action ) ) return false;
|
||||
return true;
|
||||
}
|
||||
|
||||
public IType getExpressionType() {
|
||||
return CPPVisitor.getExpressionType(this);
|
||||
}
|
||||
|
||||
}
|
||||
|
|
|
@ -14,6 +14,7 @@ import org.eclipse.cdt.core.dom.ast.ASTVisitor;
|
|||
import org.eclipse.cdt.core.dom.ast.IASTExpression;
|
||||
import org.eclipse.cdt.core.dom.ast.IASTExpressionList;
|
||||
import org.eclipse.cdt.core.dom.ast.IASTNode;
|
||||
import org.eclipse.cdt.core.dom.ast.IType;
|
||||
import org.eclipse.cdt.core.parser.util.ArrayUtil;
|
||||
import org.eclipse.cdt.internal.core.dom.parser.IASTAmbiguityParent;
|
||||
|
||||
|
@ -22,22 +23,18 @@ import org.eclipse.cdt.internal.core.dom.parser.IASTAmbiguityParent;
|
|||
*/
|
||||
public class CPPASTExpressionList extends CPPASTNode implements
|
||||
IASTExpressionList, IASTAmbiguityParent {
|
||||
/* (non-Javadoc)
|
||||
* @see org.eclipse.cdt.core.dom.ast.IASTExpressionList#getExpressions()
|
||||
*/
|
||||
public IASTExpression [] getExpressions() {
|
||||
|
||||
public IASTExpression [] getExpressions() {
|
||||
if( expressions == null ) return IASTExpression.EMPTY_EXPRESSION_ARRAY;
|
||||
return (IASTExpression[]) ArrayUtil.removeNulls( IASTExpression.class, expressions );
|
||||
}
|
||||
|
||||
/* (non-Javadoc)
|
||||
* @see org.eclipse.cdt.core.dom.ast.IASTExpressionList#addExpression(org.eclipse.cdt.core.dom.ast.IASTExpression)
|
||||
*/
|
||||
public void addExpression(IASTExpression expression) {
|
||||
expressions = (IASTExpression [])ArrayUtil.append( IASTExpression.class, expressions, expression );
|
||||
}
|
||||
|
||||
private IASTExpression [] expressions = new IASTExpression[2];
|
||||
|
||||
public boolean accept( ASTVisitor action ){
|
||||
if( action.shouldVisitExpressions ){
|
||||
switch( action.visit( this ) ){
|
||||
|
@ -64,4 +61,9 @@ public class CPPASTExpressionList extends CPPASTNode implements
|
|||
}
|
||||
}
|
||||
}
|
||||
|
||||
public IType getExpressionType() {
|
||||
return CPPVisitor.getExpressionType(this);
|
||||
}
|
||||
|
||||
}
|
||||
|
|
|
@ -14,6 +14,7 @@ import org.eclipse.cdt.core.dom.ast.ASTVisitor;
|
|||
import org.eclipse.cdt.core.dom.ast.IASTExpression;
|
||||
import org.eclipse.cdt.core.dom.ast.IASTName;
|
||||
import org.eclipse.cdt.core.dom.ast.IASTNode;
|
||||
import org.eclipse.cdt.core.dom.ast.IType;
|
||||
import org.eclipse.cdt.core.dom.ast.cpp.ICPPASTFieldReference;
|
||||
import org.eclipse.cdt.internal.core.dom.parser.IASTAmbiguityParent;
|
||||
|
||||
|
@ -28,58 +29,34 @@ public class CPPASTFieldReference extends CPPASTNode implements
|
|||
private IASTName name;
|
||||
private boolean isDeref;
|
||||
|
||||
/* (non-Javadoc)
|
||||
* @see org.eclipse.cdt.core.dom.ast.cpp.ICPPASTFieldReference#isTemplate()
|
||||
*/
|
||||
public boolean isTemplate() {
|
||||
return isTemplate;
|
||||
}
|
||||
|
||||
/* (non-Javadoc)
|
||||
* @see org.eclipse.cdt.core.dom.ast.cpp.ICPPASTFieldReference#setIsTemplate(boolean)
|
||||
*/
|
||||
public void setIsTemplate(boolean value) {
|
||||
isTemplate = value;
|
||||
}
|
||||
|
||||
/* (non-Javadoc)
|
||||
* @see org.eclipse.cdt.core.dom.ast.IASTFieldReference#getFieldOwner()
|
||||
*/
|
||||
public IASTExpression getFieldOwner() {
|
||||
return owner;
|
||||
}
|
||||
|
||||
/* (non-Javadoc)
|
||||
* @see org.eclipse.cdt.core.dom.ast.IASTFieldReference#setFieldOwner(org.eclipse.cdt.core.dom.ast.IASTExpression)
|
||||
*/
|
||||
public void setFieldOwner(IASTExpression expression) {
|
||||
owner = expression;
|
||||
}
|
||||
|
||||
/* (non-Javadoc)
|
||||
* @see org.eclipse.cdt.core.dom.ast.IASTFieldReference#getFieldName()
|
||||
*/
|
||||
public IASTName getFieldName() {
|
||||
return name;
|
||||
}
|
||||
|
||||
/* (non-Javadoc)
|
||||
* @see org.eclipse.cdt.core.dom.ast.IASTFieldReference#setFieldName(org.eclipse.cdt.core.dom.ast.IASTName)
|
||||
*/
|
||||
public void setFieldName(IASTName name) {
|
||||
this.name =name;
|
||||
}
|
||||
|
||||
/* (non-Javadoc)
|
||||
* @see org.eclipse.cdt.core.dom.ast.IASTFieldReference#isPointerDereference()
|
||||
*/
|
||||
public boolean isPointerDereference() {
|
||||
return isDeref;
|
||||
}
|
||||
|
||||
/* (non-Javadoc)
|
||||
* @see org.eclipse.cdt.core.dom.ast.IASTFieldReference#setIsPointerDereference(boolean)
|
||||
*/
|
||||
public void setIsPointerDereference(boolean value) {
|
||||
isDeref = value;
|
||||
}
|
||||
|
@ -98,9 +75,6 @@ public class CPPASTFieldReference extends CPPASTNode implements
|
|||
return true;
|
||||
}
|
||||
|
||||
/* (non-Javadoc)
|
||||
* @see org.eclipse.cdt.core.dom.ast.IASTNameOwner#getRoleForName(org.eclipse.cdt.core.dom.ast.IASTName)
|
||||
*/
|
||||
public int getRoleForName(IASTName n) {
|
||||
if( n == name )
|
||||
return r_reference;
|
||||
|
@ -116,5 +90,8 @@ public class CPPASTFieldReference extends CPPASTNode implements
|
|||
}
|
||||
}
|
||||
|
||||
|
||||
public IType getExpressionType() {
|
||||
return CPPVisitor.getExpressionType(this);
|
||||
}
|
||||
|
||||
}
|
||||
|
|
|
@ -14,6 +14,7 @@ import org.eclipse.cdt.core.dom.ast.ASTVisitor;
|
|||
import org.eclipse.cdt.core.dom.ast.IASTExpression;
|
||||
import org.eclipse.cdt.core.dom.ast.IASTFunctionCallExpression;
|
||||
import org.eclipse.cdt.core.dom.ast.IASTNode;
|
||||
import org.eclipse.cdt.core.dom.ast.IType;
|
||||
import org.eclipse.cdt.internal.core.dom.parser.IASTAmbiguityParent;
|
||||
|
||||
/**
|
||||
|
@ -24,30 +25,18 @@ public class CPPASTFunctionCallExpression extends CPPASTNode implements
|
|||
private IASTExpression functionName;
|
||||
private IASTExpression parameter;
|
||||
|
||||
/* (non-Javadoc)
|
||||
* @see org.eclipse.cdt.core.dom.ast.IASTFunctionCallExpression#setFunctionNameExpression(org.eclipse.cdt.core.dom.ast.IASTExpression)
|
||||
*/
|
||||
public void setFunctionNameExpression(IASTExpression expression) {
|
||||
this.functionName = expression;
|
||||
}
|
||||
|
||||
/* (non-Javadoc)
|
||||
* @see org.eclipse.cdt.core.dom.ast.IASTFunctionCallExpression#getFunctionNameExpression()
|
||||
*/
|
||||
public IASTExpression getFunctionNameExpression() {
|
||||
return functionName;
|
||||
}
|
||||
|
||||
/* (non-Javadoc)
|
||||
* @see org.eclipse.cdt.core.dom.ast.IASTFunctionCallExpression#setParameterExpression(org.eclipse.cdt.core.dom.ast.IASTExpression)
|
||||
*/
|
||||
public void setParameterExpression(IASTExpression expression) {
|
||||
this.parameter = expression;
|
||||
}
|
||||
|
||||
/* (non-Javadoc)
|
||||
* @see org.eclipse.cdt.core.dom.ast.IASTFunctionCallExpression#getParameterExpression()
|
||||
*/
|
||||
public IASTExpression getParameterExpression() {
|
||||
return parameter;
|
||||
}
|
||||
|
@ -79,6 +68,10 @@ public class CPPASTFunctionCallExpression extends CPPASTNode implements
|
|||
other.setParent( child.getParent() );
|
||||
parameter = (IASTExpression) other;
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
public IType getExpressionType() {
|
||||
return CPPVisitor.getExpressionType(this);
|
||||
}
|
||||
|
||||
}
|
||||
|
|
|
@ -13,6 +13,7 @@ package org.eclipse.cdt.internal.core.dom.parser.cpp;
|
|||
import org.eclipse.cdt.core.dom.ast.ASTVisitor;
|
||||
import org.eclipse.cdt.core.dom.ast.IASTIdExpression;
|
||||
import org.eclipse.cdt.core.dom.ast.IASTName;
|
||||
import org.eclipse.cdt.core.dom.ast.IType;
|
||||
|
||||
/**
|
||||
* @author jcamelon
|
||||
|
@ -20,16 +21,10 @@ import org.eclipse.cdt.core.dom.ast.IASTName;
|
|||
public class CPPASTIdExpression extends CPPASTNode implements IASTIdExpression {
|
||||
private IASTName name;
|
||||
|
||||
/* (non-Javadoc)
|
||||
* @see org.eclipse.cdt.core.dom.ast.IASTIdExpression#getName()
|
||||
*/
|
||||
public IASTName getName() {
|
||||
return name;
|
||||
}
|
||||
|
||||
/* (non-Javadoc)
|
||||
* @see org.eclipse.cdt.core.dom.ast.IASTIdExpression#setName(org.eclipse.cdt.core.dom.ast.IASTName)
|
||||
*/
|
||||
public void setName(IASTName name) {
|
||||
this.name = name;
|
||||
}
|
||||
|
@ -47,11 +42,13 @@ public class CPPASTIdExpression extends CPPASTNode implements IASTIdExpression {
|
|||
return true;
|
||||
}
|
||||
|
||||
/* (non-Javadoc)
|
||||
* @see org.eclipse.cdt.core.dom.ast.IASTNameOwner#getRoleForName(org.eclipse.cdt.core.dom.ast.IASTName)
|
||||
*/
|
||||
public int getRoleForName(IASTName n) {
|
||||
if( name == n )return r_reference;
|
||||
return r_unclear;
|
||||
}
|
||||
|
||||
public IType getExpressionType() {
|
||||
return CPPVisitor.getExpressionType(this);
|
||||
}
|
||||
|
||||
}
|
||||
|
|
|
@ -11,6 +11,7 @@
|
|||
package org.eclipse.cdt.internal.core.dom.parser.cpp;
|
||||
|
||||
import org.eclipse.cdt.core.dom.ast.ASTVisitor;
|
||||
import org.eclipse.cdt.core.dom.ast.IType;
|
||||
import org.eclipse.cdt.core.dom.ast.cpp.ICPPASTLiteralExpression;
|
||||
|
||||
|
||||
|
@ -23,30 +24,18 @@ public class CPPASTLiteralExpression extends CPPASTNode implements
|
|||
private int kind;
|
||||
private String value = ""; //$NON-NLS-1$
|
||||
|
||||
/* (non-Javadoc)
|
||||
* @see org.eclipse.cdt.core.dom.ast.IASTLiteralExpression#getKind()
|
||||
*/
|
||||
public int getKind() {
|
||||
return kind;
|
||||
}
|
||||
|
||||
/* (non-Javadoc)
|
||||
* @see org.eclipse.cdt.core.dom.ast.IASTLiteralExpression#setKind(int)
|
||||
*/
|
||||
public void setKind(int value) {
|
||||
this.kind = value;
|
||||
}
|
||||
|
||||
/* (non-Javadoc)
|
||||
* @see org.eclipse.cdt.core.dom.ast.IASTLiteralExpression#setValue(java.lang.String)
|
||||
*/
|
||||
public void setValue(String value) {
|
||||
this.value = value;
|
||||
}
|
||||
|
||||
/* (non-Javadoc)
|
||||
* @see java.lang.Object#toString()
|
||||
*/
|
||||
public String toString() {
|
||||
return value;
|
||||
}
|
||||
|
@ -61,4 +50,9 @@ public class CPPASTLiteralExpression extends CPPASTNode implements
|
|||
}
|
||||
return true;
|
||||
}
|
||||
|
||||
public IType getExpressionType() {
|
||||
return CPPVisitor.getExpressionType(this);
|
||||
}
|
||||
|
||||
}
|
||||
|
|
|
@ -14,6 +14,7 @@ import org.eclipse.cdt.core.dom.ast.ASTVisitor;
|
|||
import org.eclipse.cdt.core.dom.ast.IASTExpression;
|
||||
import org.eclipse.cdt.core.dom.ast.IASTNode;
|
||||
import org.eclipse.cdt.core.dom.ast.IASTTypeId;
|
||||
import org.eclipse.cdt.core.dom.ast.IType;
|
||||
import org.eclipse.cdt.core.dom.ast.cpp.ICPPASTNewExpression;
|
||||
import org.eclipse.cdt.core.parser.util.ArrayUtil;
|
||||
import org.eclipse.cdt.internal.core.dom.parser.IASTAmbiguityParent;
|
||||
|
@ -30,87 +31,51 @@ public class CPPASTNewExpression extends CPPASTNode implements
|
|||
private IASTTypeId typeId;
|
||||
private boolean isNewTypeId;
|
||||
|
||||
/* (non-Javadoc)
|
||||
* @see org.eclipse.cdt.core.dom.ast.cpp.ICPPASTNewExpression#isGlobal()
|
||||
*/
|
||||
public boolean isGlobal() {
|
||||
return global;
|
||||
}
|
||||
|
||||
/* (non-Javadoc)
|
||||
* @see org.eclipse.cdt.core.dom.ast.cpp.ICPPASTNewExpression#setIsGlobal(boolean)
|
||||
*/
|
||||
public void setIsGlobal(boolean value) {
|
||||
global = value;
|
||||
}
|
||||
|
||||
/* (non-Javadoc)
|
||||
* @see org.eclipse.cdt.core.dom.ast.cpp.ICPPASTNewExpression#getNewPlacement()
|
||||
*/
|
||||
public IASTExpression getNewPlacement() {
|
||||
return placement;
|
||||
}
|
||||
|
||||
/* (non-Javadoc)
|
||||
* @see org.eclipse.cdt.core.dom.ast.cpp.ICPPASTNewExpression#setNewPlacement(org.eclipse.cdt.core.dom.ast.IASTExpression)
|
||||
*/
|
||||
public void setNewPlacement(IASTExpression expression) {
|
||||
placement = expression;
|
||||
}
|
||||
|
||||
/* (non-Javadoc)
|
||||
* @see org.eclipse.cdt.core.dom.ast.cpp.ICPPASTNewExpression#getNewInitializer()
|
||||
*/
|
||||
public IASTExpression getNewInitializer() {
|
||||
return initializer;
|
||||
}
|
||||
|
||||
/* (non-Javadoc)
|
||||
* @see org.eclipse.cdt.core.dom.ast.cpp.ICPPASTNewExpression#setNewInitializer(org.eclipse.cdt.core.dom.ast.IASTExpression)
|
||||
*/
|
||||
public void setNewInitializer(IASTExpression expression) {
|
||||
initializer = expression;
|
||||
}
|
||||
|
||||
/* (non-Javadoc)
|
||||
* @see org.eclipse.cdt.core.dom.ast.cpp.ICPPASTNewExpression#getTypeId()
|
||||
*/
|
||||
public IASTTypeId getTypeId() {
|
||||
return typeId;
|
||||
}
|
||||
|
||||
/* (non-Javadoc)
|
||||
* @see org.eclipse.cdt.core.dom.ast.cpp.ICPPASTNewExpression#setTypeId(org.eclipse.cdt.core.dom.ast.IASTTypeId)
|
||||
*/
|
||||
public void setTypeId(IASTTypeId typeId) {
|
||||
this.typeId = typeId;
|
||||
}
|
||||
|
||||
/* (non-Javadoc)
|
||||
* @see org.eclipse.cdt.core.dom.ast.cpp.ICPPASTNewExpression#isNewTypeId()
|
||||
*/
|
||||
public boolean isNewTypeId() {
|
||||
return isNewTypeId;
|
||||
}
|
||||
|
||||
/* (non-Javadoc)
|
||||
* @see org.eclipse.cdt.core.dom.ast.cpp.ICPPASTNewExpression#setIsNewTypeId(boolean)
|
||||
*/
|
||||
public void setIsNewTypeId(boolean value) {
|
||||
isNewTypeId = value;
|
||||
}
|
||||
|
||||
/* (non-Javadoc)
|
||||
* @see org.eclipse.cdt.core.dom.ast.cpp.ICPPASTNewExpression#getNewTypeIdArrayExpressions()
|
||||
*/
|
||||
public IASTExpression [] getNewTypeIdArrayExpressions() {
|
||||
if( arrayExpressions == null ) return IASTExpression.EMPTY_EXPRESSION_ARRAY;
|
||||
return (IASTExpression[]) ArrayUtil.removeNulls( IASTExpression.class, arrayExpressions );
|
||||
}
|
||||
|
||||
/* (non-Javadoc)
|
||||
* @see org.eclipse.cdt.core.dom.ast.cpp.ICPPASTNewExpression#addNewTypeIdArrayExpression(org.eclipse.cdt.core.dom.ast.IASTExpression)
|
||||
*/
|
||||
public void addNewTypeIdArrayExpression(IASTExpression expression) {
|
||||
arrayExpressions = (IASTExpression[]) ArrayUtil.append( IASTExpression.class, arrayExpressions, expression );
|
||||
}
|
||||
|
@ -159,4 +124,9 @@ public class CPPASTNewExpression extends CPPASTNode implements
|
|||
arrayExpressions[i] = (IASTExpression) other;
|
||||
}
|
||||
}
|
||||
|
||||
public IType getExpressionType() {
|
||||
return CPPVisitor.getExpressionType(this);
|
||||
}
|
||||
|
||||
}
|
||||
|
|
|
@ -12,6 +12,7 @@ package org.eclipse.cdt.internal.core.dom.parser.cpp;
|
|||
|
||||
import org.eclipse.cdt.core.dom.ast.ASTVisitor;
|
||||
import org.eclipse.cdt.core.dom.ast.IASTProblemExpression;
|
||||
import org.eclipse.cdt.core.dom.ast.IType;
|
||||
|
||||
/**
|
||||
* @author jcamelon
|
||||
|
@ -29,4 +30,9 @@ public class CPPASTProblemExpression extends CPPASTProblemOwner implements
|
|||
}
|
||||
return true;
|
||||
}
|
||||
|
||||
public IType getExpressionType() {
|
||||
return null;
|
||||
}
|
||||
|
||||
}
|
||||
|
|
|
@ -13,6 +13,7 @@ package org.eclipse.cdt.internal.core.dom.parser.cpp;
|
|||
import org.eclipse.cdt.core.dom.ast.ASTVisitor;
|
||||
import org.eclipse.cdt.core.dom.ast.IASTExpression;
|
||||
import org.eclipse.cdt.core.dom.ast.IASTNode;
|
||||
import org.eclipse.cdt.core.dom.ast.IType;
|
||||
import org.eclipse.cdt.core.dom.ast.cpp.ICPPASTSimpleTypeConstructorExpression;
|
||||
import org.eclipse.cdt.internal.core.dom.parser.IASTAmbiguityParent;
|
||||
|
||||
|
@ -25,30 +26,18 @@ public class CPPASTSimpleTypeConstructorExpression extends CPPASTNode implements
|
|||
private int st;
|
||||
private IASTExpression init;
|
||||
|
||||
/* (non-Javadoc)
|
||||
* @see org.eclipse.cdt.core.dom.ast.cpp.ICPPASTSimpleTypeConstructorExpression#getSimpleType()
|
||||
*/
|
||||
public int getSimpleType() {
|
||||
return st;
|
||||
}
|
||||
|
||||
/* (non-Javadoc)
|
||||
* @see org.eclipse.cdt.core.dom.ast.cpp.ICPPASTSimpleTypeConstructorExpression#setSimpleType(int)
|
||||
*/
|
||||
public void setSimpleType(int value) {
|
||||
st = value;
|
||||
}
|
||||
|
||||
/* (non-Javadoc)
|
||||
* @see org.eclipse.cdt.core.dom.ast.cpp.ICPPASTSimpleTypeConstructorExpression#getInitialValue()
|
||||
*/
|
||||
public IASTExpression getInitialValue() {
|
||||
return init;
|
||||
}
|
||||
|
||||
/* (non-Javadoc)
|
||||
* @see org.eclipse.cdt.core.dom.ast.cpp.ICPPASTSimpleTypeConstructorExpression#setInitialValue(org.eclipse.cdt.core.dom.ast.IASTExpression)
|
||||
*/
|
||||
public void setInitialValue(IASTExpression expression) {
|
||||
init = expression;
|
||||
}
|
||||
|
@ -74,4 +63,9 @@ public class CPPASTSimpleTypeConstructorExpression extends CPPASTNode implements
|
|||
init = (IASTExpression) other;
|
||||
}
|
||||
}
|
||||
|
||||
public IType getExpressionType() {
|
||||
return CPPVisitor.getExpressionType(this);
|
||||
}
|
||||
|
||||
}
|
||||
|
|
|
@ -12,6 +12,7 @@ package org.eclipse.cdt.internal.core.dom.parser.cpp;
|
|||
|
||||
import org.eclipse.cdt.core.dom.ast.ASTVisitor;
|
||||
import org.eclipse.cdt.core.dom.ast.IASTTypeId;
|
||||
import org.eclipse.cdt.core.dom.ast.IType;
|
||||
import org.eclipse.cdt.core.dom.ast.cpp.ICPPASTTypeIdExpression;
|
||||
|
||||
/**
|
||||
|
@ -23,30 +24,18 @@ public class CPPASTTypeIdExpression extends CPPASTNode implements
|
|||
private int op;
|
||||
private IASTTypeId typeId;
|
||||
|
||||
/* (non-Javadoc)
|
||||
* @see org.eclipse.cdt.core.dom.ast.IASTTypeIdExpression#getOperator()
|
||||
*/
|
||||
public int getOperator() {
|
||||
return op;
|
||||
}
|
||||
|
||||
/* (non-Javadoc)
|
||||
* @see org.eclipse.cdt.core.dom.ast.IASTTypeIdExpression#setOperator(int)
|
||||
*/
|
||||
public void setOperator(int value) {
|
||||
this.op = value;
|
||||
}
|
||||
|
||||
/* (non-Javadoc)
|
||||
* @see org.eclipse.cdt.core.dom.ast.IASTTypeIdExpression#setTypeId(org.eclipse.cdt.core.dom.ast.IASTTypeId)
|
||||
*/
|
||||
public void setTypeId(IASTTypeId typeId) {
|
||||
this.typeId = typeId;
|
||||
}
|
||||
|
||||
/* (non-Javadoc)
|
||||
* @see org.eclipse.cdt.core.dom.ast.IASTTypeIdExpression#getTypeId()
|
||||
*/
|
||||
public IASTTypeId getTypeId() {
|
||||
return typeId;
|
||||
}
|
||||
|
@ -63,4 +52,9 @@ public class CPPASTTypeIdExpression extends CPPASTNode implements
|
|||
if( typeId != null ) if( !typeId.accept( action ) ) return false;
|
||||
return true;
|
||||
}
|
||||
|
||||
public IType getExpressionType() {
|
||||
return CPPVisitor.getExpressionType(this);
|
||||
}
|
||||
|
||||
}
|
||||
|
|
|
@ -14,6 +14,7 @@ import org.eclipse.cdt.core.dom.ast.ASTVisitor;
|
|||
import org.eclipse.cdt.core.dom.ast.IASTExpression;
|
||||
import org.eclipse.cdt.core.dom.ast.IASTName;
|
||||
import org.eclipse.cdt.core.dom.ast.IASTNode;
|
||||
import org.eclipse.cdt.core.dom.ast.IType;
|
||||
import org.eclipse.cdt.core.dom.ast.cpp.ICPPASTTypenameExpression;
|
||||
import org.eclipse.cdt.internal.core.dom.parser.IASTAmbiguityParent;
|
||||
|
||||
|
@ -27,44 +28,26 @@ public class CPPASTTypenameExpression extends CPPASTNode implements
|
|||
private IASTName name;
|
||||
private IASTExpression init;
|
||||
|
||||
/* (non-Javadoc)
|
||||
* @see org.eclipse.cdt.core.dom.ast.cpp.ICPPASTTypenameExpression#setIsTemplate(boolean)
|
||||
*/
|
||||
public void setIsTemplate(boolean templateTokenConsumed) {
|
||||
isTemplate = templateTokenConsumed;
|
||||
}
|
||||
|
||||
/* (non-Javadoc)
|
||||
* @see org.eclipse.cdt.core.dom.ast.cpp.ICPPASTTypenameExpression#isTemplate()
|
||||
*/
|
||||
public boolean isTemplate() {
|
||||
return isTemplate;
|
||||
}
|
||||
|
||||
/* (non-Javadoc)
|
||||
* @see org.eclipse.cdt.core.dom.ast.cpp.ICPPASTTypenameExpression#setName(org.eclipse.cdt.core.dom.ast.IASTName)
|
||||
*/
|
||||
public void setName(IASTName name) {
|
||||
this.name = name;
|
||||
}
|
||||
|
||||
/* (non-Javadoc)
|
||||
* @see org.eclipse.cdt.core.dom.ast.cpp.ICPPASTTypenameExpression#getName()
|
||||
*/
|
||||
public IASTName getName() {
|
||||
return name;
|
||||
}
|
||||
|
||||
/* (non-Javadoc)
|
||||
* @see org.eclipse.cdt.core.dom.ast.cpp.ICPPASTTypenameExpression#setInitialValue(org.eclipse.cdt.core.dom.ast.IASTExpression)
|
||||
*/
|
||||
public void setInitialValue(IASTExpression expressionList) {
|
||||
init = expressionList;
|
||||
}
|
||||
|
||||
/* (non-Javadoc)
|
||||
* @see org.eclipse.cdt.core.dom.ast.cpp.ICPPASTTypenameExpression#getInitialValue()
|
||||
*/
|
||||
public IASTExpression getInitialValue() {
|
||||
return init;
|
||||
}
|
||||
|
@ -83,9 +66,6 @@ public class CPPASTTypenameExpression extends CPPASTNode implements
|
|||
return true;
|
||||
}
|
||||
|
||||
/* (non-Javadoc)
|
||||
* @see org.eclipse.cdt.core.dom.ast.IASTNameOwner#getRoleForName(org.eclipse.cdt.core.dom.ast.IASTName)
|
||||
*/
|
||||
public int getRoleForName(IASTName n) {
|
||||
if( n == name )
|
||||
return r_reference;
|
||||
|
@ -101,4 +81,9 @@ public class CPPASTTypenameExpression extends CPPASTNode implements
|
|||
}
|
||||
|
||||
}
|
||||
|
||||
public IType getExpressionType() {
|
||||
return CPPVisitor.getExpressionType(this);
|
||||
}
|
||||
|
||||
}
|
||||
|
|
|
@ -14,6 +14,7 @@ import org.eclipse.cdt.core.dom.ast.ASTVisitor;
|
|||
import org.eclipse.cdt.core.dom.ast.IASTExpression;
|
||||
import org.eclipse.cdt.core.dom.ast.IASTNode;
|
||||
import org.eclipse.cdt.core.dom.ast.IASTUnaryExpression;
|
||||
import org.eclipse.cdt.core.dom.ast.IType;
|
||||
import org.eclipse.cdt.internal.core.dom.parser.IASTAmbiguityParent;
|
||||
|
||||
/**
|
||||
|
@ -25,30 +26,18 @@ public class CPPASTUnaryExpression extends CPPASTNode implements
|
|||
private int operator;
|
||||
private IASTExpression operand;
|
||||
|
||||
/* (non-Javadoc)
|
||||
* @see org.eclipse.cdt.core.dom.ast.IASTUnaryExpression#getOperator()
|
||||
*/
|
||||
public int getOperator() {
|
||||
return operator;
|
||||
}
|
||||
|
||||
/* (non-Javadoc)
|
||||
* @see org.eclipse.cdt.core.dom.ast.IASTUnaryExpression#setOperator(int)
|
||||
*/
|
||||
public void setOperator(int value) {
|
||||
this.operator = value;
|
||||
}
|
||||
|
||||
/* (non-Javadoc)
|
||||
* @see org.eclipse.cdt.core.dom.ast.IASTUnaryExpression#getOperand()
|
||||
*/
|
||||
public IASTExpression getOperand() {
|
||||
return operand;
|
||||
}
|
||||
|
||||
/* (non-Javadoc)
|
||||
* @see org.eclipse.cdt.core.dom.ast.IASTUnaryExpression#setOperand(org.eclipse.cdt.core.dom.ast.IASTExpression)
|
||||
*/
|
||||
public void setOperand(IASTExpression expression) {
|
||||
operand = expression;
|
||||
}
|
||||
|
@ -75,4 +64,9 @@ public class CPPASTUnaryExpression extends CPPASTNode implements
|
|||
}
|
||||
|
||||
}
|
||||
|
||||
public IType getExpressionType() {
|
||||
return CPPVisitor.getExpressionType(this);
|
||||
}
|
||||
|
||||
}
|
||||
|
|
|
@ -112,7 +112,8 @@ public class PDOMCPPClassType extends PDOMMemberOwner implements ICPPClassType,
|
|||
}
|
||||
|
||||
public int getKey() throws DOMException {
|
||||
throw new PDOMNotImplementedError();
|
||||
// TODO
|
||||
return ICPPClassType.k_class;
|
||||
}
|
||||
|
||||
public String[] getQualifiedName() throws DOMException {
|
||||
|
|
|
@ -55,7 +55,8 @@ public class PDOMCPPFunction extends PDOMBinding implements ICPPFunction {
|
|||
}
|
||||
|
||||
public IParameter[] getParameters() throws DOMException {
|
||||
throw new PDOMNotImplementedError();
|
||||
// TODO
|
||||
return new IParameter[0];
|
||||
}
|
||||
|
||||
public IFunctionType getType() throws DOMException {
|
||||
|
@ -80,7 +81,8 @@ public class PDOMCPPFunction extends PDOMBinding implements ICPPFunction {
|
|||
}
|
||||
|
||||
public boolean takesVarArgs() throws DOMException {
|
||||
throw new PDOMNotImplementedError();
|
||||
// TODO
|
||||
return false;
|
||||
}
|
||||
|
||||
public String[] getQualifiedName() throws DOMException {
|
||||
|
|
|
@ -1375,10 +1375,6 @@
|
|||
class="org.eclipse.cdt.internal.ui.text.template.TemplateEngine"
|
||||
id="CodeTemplates"
|
||||
priority="2"/>
|
||||
<contributor
|
||||
class="org.eclipse.cdt.internal.ui.text.contentassist.SearchCompletionContributor"
|
||||
id="Search"
|
||||
priority="3"/>
|
||||
<contributor
|
||||
class="org.eclipse.cdt.internal.ui.text.contentassist.KeywordCompletionContributor"
|
||||
id="Keywords"
|
||||
|
@ -1387,6 +1383,10 @@
|
|||
class="org.eclipse.cdt.internal.ui.text.contentassist.HelpCompletionContributor"
|
||||
id="Help"
|
||||
priority="99"/>
|
||||
<contributor
|
||||
class="org.eclipse.cdt.internal.ui.text.contentassist.PDOMCompletionContributor"
|
||||
id="PDOM"
|
||||
priority="3"/>
|
||||
</extension>
|
||||
|
||||
</plugin>
|
||||
|
|
|
@ -13,31 +13,21 @@ package org.eclipse.cdt.internal.ui.text.contentassist;
|
|||
import java.util.ArrayList;
|
||||
import java.util.List;
|
||||
|
||||
import org.eclipse.cdt.core.CCorePlugin;
|
||||
import org.eclipse.cdt.core.dom.CDOM;
|
||||
import org.eclipse.cdt.core.dom.ICodeReaderFactory;
|
||||
import org.eclipse.cdt.core.dom.IPDOM;
|
||||
import org.eclipse.cdt.core.dom.IASTServiceProvider.UnsupportedDialectException;
|
||||
import org.eclipse.cdt.core.dom.ast.ASTCompletionNode;
|
||||
import org.eclipse.cdt.core.model.IWorkingCopy;
|
||||
import org.eclipse.cdt.internal.ui.CUIMessages;
|
||||
import org.eclipse.cdt.internal.ui.preferences.ProposalFilterPreferencesUtil;
|
||||
import org.eclipse.cdt.internal.ui.text.CParameterListValidator;
|
||||
import org.eclipse.cdt.internal.ui.util.ExternalEditorInput;
|
||||
import org.eclipse.cdt.ui.CUIPlugin;
|
||||
import org.eclipse.cdt.ui.text.ICCompletionProposal;
|
||||
import org.eclipse.cdt.ui.text.contentassist.ICompletionContributor;
|
||||
import org.eclipse.cdt.ui.text.contentassist.IProposalFilter;
|
||||
import org.eclipse.core.resources.IFile;
|
||||
import org.eclipse.core.resources.IProject;
|
||||
import org.eclipse.core.resources.IStorage;
|
||||
import org.eclipse.core.runtime.CoreException;
|
||||
import org.eclipse.core.runtime.IConfigurationElement;
|
||||
import org.eclipse.core.runtime.IExtension;
|
||||
import org.eclipse.core.runtime.IExtensionPoint;
|
||||
import org.eclipse.core.runtime.InvalidRegistryObjectException;
|
||||
import org.eclipse.core.runtime.Platform;
|
||||
import org.eclipse.jface.preference.IPreferenceStore;
|
||||
import org.eclipse.jface.text.BadLocationException;
|
||||
import org.eclipse.jface.text.IDocument;
|
||||
import org.eclipse.jface.text.ITextViewer;
|
||||
|
@ -60,8 +50,6 @@ public class CCompletionProcessor2 implements IContentAssistProcessor {
|
|||
// Property names
|
||||
private String assistPrefix = "CEditor.contentassist"; //$NON-NLS-1$
|
||||
private String noCompletions = assistPrefix + ".noCompletions"; //$NON-NLS-1$
|
||||
private String parseError = assistPrefix + ".parseError"; //$NON-NLS-1$
|
||||
private String dialectError = assistPrefix + ".badDialect"; //$NON-NLS-1$
|
||||
private ASTCompletionNode fCurrentCompletionNode;
|
||||
|
||||
public CCompletionProcessor2(IEditorPart editor) {
|
||||
|
@ -73,37 +61,12 @@ public class CCompletionProcessor2 implements IContentAssistProcessor {
|
|||
try {
|
||||
IWorkingCopy workingCopy = CUIPlugin.getDefault().getWorkingCopyManager().getWorkingCopy(editor.getEditorInput());
|
||||
String prefix = null;
|
||||
|
||||
IPreferenceStore store = CUIPlugin.getDefault().getPreferenceStore();
|
||||
boolean fileScope = store.getBoolean(ContentAssistPreference.CURRENT_FILE_SEARCH_SCOPE);
|
||||
boolean projectScope = store.getBoolean(ContentAssistPreference.PROJECT_SEARCH_SCOPE);
|
||||
|
||||
if (fileScope && workingCopy != null) { // do a full parse
|
||||
if (workingCopy != null) {
|
||||
fCurrentCompletionNode = workingCopy.getLanguage().getCompletionNode(workingCopy, offset);
|
||||
|
||||
IFile file = (IFile)workingCopy.getResource();
|
||||
if (file != null) {
|
||||
IPDOM pdom = null; //CCorePlugin.getPDOMManager().getPDOM(workingCopy.getCProject());
|
||||
ICodeReaderFactory readerFactory;
|
||||
if (pdom != null)
|
||||
readerFactory = pdom.getCodeReaderFactory(workingCopy);
|
||||
else
|
||||
readerFactory = CDOM.getInstance().getCodeReaderFactory(CDOM.PARSE_WORKING_COPY_WHENEVER_POSSIBLE);
|
||||
fCurrentCompletionNode = CDOM.getInstance().getCompletionNode(file, offset, readerFactory);
|
||||
} else if (editor.getEditorInput() instanceof ExternalEditorInput) {
|
||||
IStorage storage = ((ExternalEditorInput)(editor.getEditorInput())).getStorage();
|
||||
IProject project = workingCopy.getCProject().getProject();
|
||||
IPDOM pdom = CCorePlugin.getPDOMManager().getPDOM(workingCopy.getCProject());
|
||||
ICodeReaderFactory readerFactory;
|
||||
if (pdom != null)
|
||||
readerFactory = pdom.getCodeReaderFactory(workingCopy);
|
||||
else
|
||||
readerFactory = CDOM.getInstance().getCodeReaderFactory(CDOM.PARSE_WORKING_COPY_WHENEVER_POSSIBLE);
|
||||
fCurrentCompletionNode = CDOM.getInstance().getCompletionNode(storage, project, offset, readerFactory);
|
||||
}
|
||||
|
||||
if (fCurrentCompletionNode != null)
|
||||
prefix = fCurrentCompletionNode.getPrefix();
|
||||
|
||||
}
|
||||
|
||||
if (prefix == null)
|
||||
|
@ -133,13 +96,10 @@ public class CCompletionProcessor2 implements IContentAssistProcessor {
|
|||
|
||||
IProposalFilter filter = getCompletionFilter();
|
||||
ICCompletionProposal[] proposalsInput = (ICCompletionProposal[]) proposals.toArray(new ICCompletionProposal[proposals.size()]) ;
|
||||
|
||||
ICCompletionProposal[] proposalsFiltered = filter.filterProposals(proposalsInput);
|
||||
|
||||
return proposalsFiltered;
|
||||
|
||||
} catch (UnsupportedDialectException e) {
|
||||
errorMessage = CUIMessages.getString(dialectError);
|
||||
} catch (Throwable e) {
|
||||
errorMessage = e.toString();
|
||||
}
|
||||
|
|
|
@ -25,6 +25,7 @@ import org.eclipse.cdt.core.dom.ast.IBinding;
|
|||
import org.eclipse.cdt.core.dom.ast.ICompositeType;
|
||||
import org.eclipse.cdt.core.dom.ast.IEnumerator;
|
||||
import org.eclipse.cdt.core.dom.ast.IFunction;
|
||||
import org.eclipse.cdt.core.dom.ast.IFunctionType;
|
||||
import org.eclipse.cdt.core.dom.ast.IParameter;
|
||||
import org.eclipse.cdt.core.dom.ast.IType;
|
||||
import org.eclipse.cdt.core.dom.ast.ITypedef;
|
||||
|
@ -93,7 +94,7 @@ public class DOMCompletionContributor implements ICompletionContributor {
|
|||
}
|
||||
}
|
||||
|
||||
private void handleBinding(IBinding binding, ASTCompletionNode completionNode, int offset, ITextViewer viewer, List proposals) {
|
||||
protected void handleBinding(IBinding binding, ASTCompletionNode completionNode, int offset, ITextViewer viewer, List proposals) {
|
||||
if (binding instanceof IFunction) {
|
||||
handleFunction((IFunction)binding, completionNode, offset, viewer, proposals);
|
||||
} else if (binding instanceof IVariable) {
|
||||
|
@ -144,9 +145,12 @@ public class DOMCompletionContributor implements ICompletionContributor {
|
|||
idargs.append("void"); //$NON-NLS-1$
|
||||
}
|
||||
|
||||
IType returnType = function.getType().getReturnType();
|
||||
if (returnType != null)
|
||||
returnTypeStr = ASTTypeUtil.getType(returnType);
|
||||
IFunctionType functionType = function.getType();
|
||||
if (functionType != null) {
|
||||
IType returnType = functionType.getReturnType();
|
||||
if (returnType != null)
|
||||
returnTypeStr = ASTTypeUtil.getType(returnType);
|
||||
}
|
||||
} catch (DOMException e) {
|
||||
}
|
||||
|
||||
|
|
|
@ -0,0 +1,107 @@
|
|||
/*******************************************************************************
|
||||
* Copyright (c) 2006 QNX Software Systems and others.
|
||||
* All rights reserved. This program and the accompanying materials
|
||||
* are made available under the terms of the Eclipse Public License v1.0
|
||||
* which accompanies this distribution, and is available at
|
||||
* http://www.eclipse.org/legal/epl-v10.html
|
||||
*
|
||||
* Contributors:
|
||||
* QNX - Initial API and implementation
|
||||
*******************************************************************************/
|
||||
|
||||
package org.eclipse.cdt.internal.ui.text.contentassist;
|
||||
|
||||
import java.util.List;
|
||||
|
||||
import org.eclipse.cdt.core.CCorePlugin;
|
||||
import org.eclipse.cdt.core.dom.IPDOM;
|
||||
import org.eclipse.cdt.core.dom.IPDOMNode;
|
||||
import org.eclipse.cdt.core.dom.IPDOMVisitor;
|
||||
import org.eclipse.cdt.core.dom.ast.ASTCompletionNode;
|
||||
import org.eclipse.cdt.core.dom.ast.IASTExpression;
|
||||
import org.eclipse.cdt.core.dom.ast.IASTFieldReference;
|
||||
import org.eclipse.cdt.core.dom.ast.IASTIdExpression;
|
||||
import org.eclipse.cdt.core.dom.ast.IASTName;
|
||||
import org.eclipse.cdt.core.dom.ast.IASTNamedTypeSpecifier;
|
||||
import org.eclipse.cdt.core.dom.ast.IASTNode;
|
||||
import org.eclipse.cdt.core.dom.ast.IBinding;
|
||||
import org.eclipse.cdt.core.dom.ast.IField;
|
||||
import org.eclipse.cdt.core.dom.ast.IType;
|
||||
import org.eclipse.cdt.core.model.IWorkingCopy;
|
||||
import org.eclipse.cdt.internal.core.pdom.PDOM;
|
||||
import org.eclipse.cdt.internal.core.pdom.dom.PDOMBinding;
|
||||
import org.eclipse.cdt.internal.core.pdom.dom.PDOMLinkage;
|
||||
import org.eclipse.cdt.ui.CUIPlugin;
|
||||
import org.eclipse.cdt.ui.text.contentassist.ICompletionContributor;
|
||||
import org.eclipse.core.runtime.CoreException;
|
||||
import org.eclipse.jface.text.ITextViewer;
|
||||
|
||||
/**
|
||||
* @author Doug Schaefer
|
||||
*
|
||||
* Completion contributor that looks up prefixes in the PDOM.
|
||||
*/
|
||||
public class PDOMCompletionContributor extends DOMCompletionContributor implements ICompletionContributor {
|
||||
|
||||
public void contributeCompletionProposals(
|
||||
final ITextViewer viewer,
|
||||
final int offset,
|
||||
final IWorkingCopy workingCopy,
|
||||
final ASTCompletionNode completionNode,
|
||||
final String prefix,
|
||||
final List proposals) {
|
||||
|
||||
if (completionNode == null)
|
||||
return;
|
||||
|
||||
try {
|
||||
IPDOM pdom = CCorePlugin.getPDOMManager().getPDOM(workingCopy.getCProject());
|
||||
IASTName[] names = completionNode.getNames();
|
||||
for (int i = 0; i < names.length; ++i) {
|
||||
IASTName name = names[i];
|
||||
IASTNode parent = name.getParent();
|
||||
if (parent instanceof IASTIdExpression || parent instanceof IASTNamedTypeSpecifier) {
|
||||
pdom.accept(new IPDOMVisitor() {
|
||||
public boolean visit(IPDOMNode node) throws CoreException {
|
||||
if (node instanceof PDOMLinkage)
|
||||
return true;
|
||||
|
||||
if (node instanceof PDOMBinding) {
|
||||
PDOMBinding binding = (PDOMBinding)node;
|
||||
if (binding.getName().startsWith(prefix)) {
|
||||
handleBinding(binding, completionNode, offset, viewer, proposals);
|
||||
}
|
||||
}
|
||||
return false;
|
||||
}
|
||||
});
|
||||
} else if (parent instanceof IASTFieldReference) {
|
||||
// Find the type the look at the fields
|
||||
IASTFieldReference fieldRef = (IASTFieldReference)parent;
|
||||
IASTExpression expression = fieldRef.getFieldOwner();
|
||||
IType type = expression.getExpressionType();
|
||||
if (type != null && type instanceof IBinding) {
|
||||
IBinding binding = (IBinding)type;
|
||||
PDOMLinkage linkage = ((PDOM)pdom).getLinkage(workingCopy.getLanguage());
|
||||
PDOMBinding pdomBinding = linkage.adaptBinding(binding);
|
||||
if (pdomBinding != null) {
|
||||
pdomBinding.accept(new IPDOMVisitor() {
|
||||
public boolean visit(IPDOMNode node) throws CoreException {
|
||||
if (node instanceof IField) {
|
||||
PDOMBinding binding = (PDOMBinding)node;
|
||||
if (binding.getName().startsWith(prefix))
|
||||
handleBinding(binding, completionNode, offset, viewer, proposals);
|
||||
}
|
||||
return false;
|
||||
};
|
||||
});
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
} catch (CoreException e) {
|
||||
CUIPlugin.getDefault().log(e);
|
||||
}
|
||||
}
|
||||
|
||||
}
|
|
@ -1,189 +0,0 @@
|
|||
/**********************************************************************
|
||||
* Copyright (c) 2004, 2005 IBM Corporation and others.
|
||||
* All rights reserved. This program and the accompanying materials
|
||||
* are made available under the terms of the Eclipse Public License v1.0
|
||||
* which accompanies this distribution, and is available at
|
||||
* http://www.eclipse.org/legal/epl-v10.html
|
||||
*
|
||||
* Contributors:
|
||||
* IBM Corporation - initial API and implementation
|
||||
*******************************************************************************/
|
||||
package org.eclipse.cdt.internal.ui.text.contentassist;
|
||||
|
||||
import java.util.Iterator;
|
||||
import java.util.List;
|
||||
import java.util.Set;
|
||||
|
||||
import org.eclipse.cdt.core.dom.ast.ASTCompletionNode;
|
||||
import org.eclipse.cdt.core.dom.ast.IASTFieldReference;
|
||||
import org.eclipse.cdt.core.dom.ast.IASTName;
|
||||
import org.eclipse.cdt.core.model.ICElement;
|
||||
import org.eclipse.cdt.core.model.IWorkingCopy;
|
||||
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.IMatch;
|
||||
import org.eclipse.cdt.core.search.OrPattern;
|
||||
import org.eclipse.cdt.core.search.SearchEngine;
|
||||
import org.eclipse.cdt.core.search.SearchFor;
|
||||
import org.eclipse.cdt.internal.ui.viewsupport.CElementImageProvider;
|
||||
import org.eclipse.cdt.ui.CUIPlugin;
|
||||
import org.eclipse.cdt.ui.text.contentassist.ICompletionContributor;
|
||||
import org.eclipse.jface.text.ITextViewer;
|
||||
import org.eclipse.swt.graphics.Image;
|
||||
|
||||
public class SearchCompletionContributor implements ICompletionContributor {
|
||||
|
||||
// The completion search for list
|
||||
// Kind of like the All Elements but excluding METHODS and FIELDS
|
||||
private static SearchFor[] completionSearchFor = {
|
||||
ICSearchConstants.CLASS_STRUCT,
|
||||
ICSearchConstants.FUNCTION,
|
||||
ICSearchConstants.VAR,
|
||||
ICSearchConstants.UNION,
|
||||
ICSearchConstants.ENUM,
|
||||
ICSearchConstants.ENUMTOR,
|
||||
ICSearchConstants.NAMESPACE,
|
||||
ICSearchConstants.TYPEDEF,
|
||||
ICSearchConstants.MACRO
|
||||
};
|
||||
|
||||
public void contributeCompletionProposals(ITextViewer viewer, int offset,
|
||||
IWorkingCopy workingCopy, ASTCompletionNode completionNode, String prefix,
|
||||
List proposals)
|
||||
{
|
||||
if (!validContext(completionNode))
|
||||
return;
|
||||
|
||||
if (prefix == null || prefix.length() == 0)
|
||||
return;
|
||||
|
||||
// Create search engine
|
||||
SearchEngine searchEngine = new SearchEngine();
|
||||
searchEngine.setWaitingPolicy( ICSearchConstants.FORCE_IMMEDIATE_SEARCH );
|
||||
|
||||
// Create search scope
|
||||
ICSearchScope scope;
|
||||
if (workingCopy != null) {
|
||||
ICElement[] projects = new ICElement[] { workingCopy.getCProject() };
|
||||
scope = SearchEngine.createCSearchScope(projects, true);
|
||||
} else
|
||||
scope = SearchEngine.createWorkspaceScope();
|
||||
|
||||
// Create the pattern
|
||||
String patternString = prefix + "*"; //$NON-NLS-1$
|
||||
OrPattern pattern = new OrPattern();
|
||||
for (int i = 0; i < completionSearchFor.length; i++)
|
||||
pattern.addPattern( SearchEngine.createSearchPattern( patternString,
|
||||
completionSearchFor[i], ICSearchConstants.ALL_OCCURRENCES, true));
|
||||
|
||||
// Run the search
|
||||
BasicSearchResultCollector collector = new BasicSearchResultCollector();
|
||||
try {
|
||||
searchEngine.search(CUIPlugin.getWorkspace(), pattern, scope, collector, false);
|
||||
} catch (InterruptedException e) {
|
||||
return;
|
||||
}
|
||||
|
||||
Set results = collector.getSearchResults();
|
||||
Iterator iResults = results.iterator();
|
||||
while (iResults.hasNext()) {
|
||||
IMatch match = (IMatch)iResults.next();
|
||||
switch (match.getElementType()) {
|
||||
case ICElement.C_FUNCTION:
|
||||
case ICElement.C_FUNCTION_DECLARATION:
|
||||
case ICElement.C_METHOD:
|
||||
case ICElement.C_METHOD_DECLARATION:
|
||||
handleFunction(match, viewer, prefix, offset, proposals);
|
||||
break;
|
||||
default:
|
||||
handleMatch(match, viewer, prefix, offset, proposals);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
private boolean validContext(ASTCompletionNode completionNode) {
|
||||
if (completionNode == null)
|
||||
// No completion node, assume true
|
||||
return true;
|
||||
|
||||
boolean valid = true;
|
||||
IASTName[] names = completionNode.getNames();
|
||||
for (int i = 0; i < names.length; i++) {
|
||||
IASTName name = names[i];
|
||||
|
||||
// not hooked up, not a valid name, ignore
|
||||
if (name.getTranslationUnit() == null)
|
||||
continue;
|
||||
|
||||
// member access currently isn't valid
|
||||
if (name.getParent() instanceof IASTFieldReference) {
|
||||
valid = false;
|
||||
continue;
|
||||
}
|
||||
|
||||
// found one that was valid
|
||||
return true;
|
||||
}
|
||||
|
||||
// Couldn't find a valid context
|
||||
return valid;
|
||||
}
|
||||
|
||||
private void handleMatch(IMatch match, ITextViewer viewer, String prefix, int offset, List proposals) {
|
||||
int repLength = prefix.length();
|
||||
int repOffset = offset - repLength;
|
||||
Image image = CUIPlugin.getImageDescriptorRegistry().get(CElementImageProvider.getImageDescriptor(match.getElementType()));
|
||||
String repString = match.getName();
|
||||
CCompletionProposal proposal = new CCompletionProposal(repString, repOffset, repLength, image, repString, 1, viewer);
|
||||
proposals.add(proposal);
|
||||
}
|
||||
|
||||
private void handleFunction(IMatch match, ITextViewer viewer, String prefix, int offset, List proposals) {
|
||||
Image image = CUIPlugin.getImageDescriptorRegistry().get(CElementImageProvider.getImageDescriptor(match.getElementType()));
|
||||
|
||||
StringBuffer repStringBuff = new StringBuffer();
|
||||
repStringBuff.append(match.getName());
|
||||
repStringBuff.append('(');
|
||||
|
||||
StringBuffer args = new StringBuffer();
|
||||
String[] params = match.getParameters();
|
||||
if (params != null)
|
||||
for (int i = 0; i < params.length; ++i) {
|
||||
if (i > 0)
|
||||
args.append(',');
|
||||
args.append(params[i]);
|
||||
}
|
||||
|
||||
String returnType = match.getReturnType();
|
||||
String argString = args.toString();
|
||||
|
||||
StringBuffer dispStringBuff = new StringBuffer(repStringBuff.toString());
|
||||
dispStringBuff.append(argString);
|
||||
dispStringBuff.append(')');
|
||||
|
||||
repStringBuff.append(')');
|
||||
String repString = repStringBuff.toString();
|
||||
|
||||
String idString = null;
|
||||
if (returnType != null) {
|
||||
idString = dispStringBuff.toString();
|
||||
dispStringBuff.append(' ');
|
||||
dispStringBuff.append(returnType);
|
||||
}
|
||||
String dispString = dispStringBuff.toString();
|
||||
|
||||
int repLength = prefix.length();
|
||||
int repOffset = offset - repLength;
|
||||
CCompletionProposal proposal = new CCompletionProposal(repString, repOffset, repLength, image, dispString, idString, 1, viewer);
|
||||
proposal.setCursorPosition(repString.length() - 1);
|
||||
|
||||
if (argString.length() > 0) {
|
||||
CProposalContextInformation info = new CProposalContextInformation(repString, argString);
|
||||
info.setContextInformationPosition(offset);
|
||||
proposal.setContextInformation(info);
|
||||
}
|
||||
|
||||
proposals.add(proposal);
|
||||
}
|
||||
}
|
Loading…
Add table
Reference in a new issue