1
0
Fork 0
mirror of https://github.com/eclipse-cdt/cdt synced 2025-06-06 09:16:02 +02:00

Cosmetics.

This commit is contained in:
Sergey Prigogin 2009-10-06 05:58:08 +00:00
parent dbec91987b
commit 1c2270f0cb
5 changed files with 34 additions and 42 deletions

View file

@ -26,20 +26,18 @@ import org.eclipse.cdt.internal.core.dom.parser.IASTAmbiguityParent;
/** /**
* @author jcamelon * @author jcamelon
*/ */
public class CASTFunctionDefinition extends ASTNode implements public class CASTFunctionDefinition extends ASTNode implements IASTFunctionDefinition, IASTAmbiguityParent {
IASTFunctionDefinition, IASTAmbiguityParent {
private IASTDeclSpecifier declSpecifier; private IASTDeclSpecifier declSpecifier;
private IASTFunctionDeclarator declarator; private IASTFunctionDeclarator declarator;
private IASTStatement bodyStatement; private IASTStatement bodyStatement;
private ICFunctionScope scope; private ICFunctionScope scope;
public CASTFunctionDefinition() { public CASTFunctionDefinition() {
} }
public CASTFunctionDefinition(IASTDeclSpecifier declSpecifier, public CASTFunctionDefinition(IASTDeclSpecifier declSpecifier, IASTFunctionDeclarator declarator,
IASTFunctionDeclarator declarator, IASTStatement bodyStatement) { IASTStatement bodyStatement) {
setDeclSpecifier(declSpecifier); setDeclSpecifier(declSpecifier);
setDeclarator(declarator); setDeclarator(declarator);
setBody(bodyStatement); setBody(bodyStatement);
@ -49,10 +47,10 @@ public class CASTFunctionDefinition extends ASTNode implements
CASTFunctionDefinition copy = new CASTFunctionDefinition(); CASTFunctionDefinition copy = new CASTFunctionDefinition();
copy.setDeclSpecifier(declSpecifier == null ? null : declSpecifier.copy()); copy.setDeclSpecifier(declSpecifier == null ? null : declSpecifier.copy());
if(declarator != null) { if (declarator != null) {
IASTDeclarator outer = CVisitor.findOutermostDeclarator(declarator); IASTDeclarator outer = CVisitor.findOutermostDeclarator(declarator);
outer = outer.copy(); outer = outer.copy();
copy.setDeclarator((IASTFunctionDeclarator)CVisitor.findTypeRelevantDeclarator(outer)); copy.setDeclarator((IASTFunctionDeclarator) CVisitor.findTypeRelevantDeclarator(outer));
} }
copy.setBody(bodyStatement == null ? null : bodyStatement.copy()); copy.setBody(bodyStatement == null ? null : bodyStatement.copy());
@ -101,41 +99,40 @@ public class CASTFunctionDefinition extends ASTNode implements
} }
public IScope getScope() { public IScope getScope() {
if( scope == null ) if (scope == null)
scope = new CFunctionScope( this ); scope = new CFunctionScope(this);
return scope; return scope;
} }
@Override @Override
public boolean accept( ASTVisitor action ){ public boolean accept(ASTVisitor action) {
if( action.shouldVisitDeclarations ){ if (action.shouldVisitDeclarations) {
switch( action.visit( this ) ){ switch (action.visit(this)) {
case ASTVisitor.PROCESS_ABORT : return false; case ASTVisitor.PROCESS_ABORT: return false;
case ASTVisitor.PROCESS_SKIP : return true; case ASTVisitor.PROCESS_SKIP: return true;
default : break; default: break;
} }
} }
if( declSpecifier != null ) if( !declSpecifier.accept( action ) ) return false; if (declSpecifier != null && !declSpecifier.accept(action)) return false;
final IASTDeclarator outerDtor= CVisitor.findOutermostDeclarator(declarator); final IASTDeclarator outerDtor= CVisitor.findOutermostDeclarator(declarator);
if( outerDtor != null ) if( !outerDtor.accept( action ) ) return false; if (outerDtor != null && !outerDtor.accept(action)) return false;
if( bodyStatement != null ) if( !bodyStatement.accept( action ) ) return false; if (bodyStatement != null && !bodyStatement.accept(action)) return false;
if( action.shouldVisitDeclarations ){ if (action.shouldVisitDeclarations) {
switch( action.leave( this ) ){ switch (action.leave(this)) {
case ASTVisitor.PROCESS_ABORT : return false; case ASTVisitor.PROCESS_ABORT: return false;
case ASTVisitor.PROCESS_SKIP : return true; case ASTVisitor.PROCESS_SKIP: return true;
default : break; default: break;
} }
} }
return true; return true;
} }
public void replace(IASTNode child, IASTNode other) { public void replace(IASTNode child, IASTNode other) {
if( bodyStatement == child ) if (bodyStatement == child) {
{ other.setPropertyInParent(bodyStatement.getPropertyInParent());
other.setPropertyInParent( bodyStatement.getPropertyInParent() ); other.setParent(bodyStatement.getParent());
other.setParent( bodyStatement.getParent() );
bodyStatement = (IASTStatement) other; bodyStatement = (IASTStatement) other;
} }
} }

View file

@ -207,15 +207,15 @@ public class CPPASTFieldReference extends ASTNode implements
public IBinding[] findBindings(IASTName n, boolean isPrefix) { public IBinding[] findBindings(IASTName n, boolean isPrefix) {
IBinding[] bindings = CPPSemantics.findBindingsForContentAssist(n, isPrefix); IBinding[] bindings = CPPSemantics.findBindingsForContentAssist(n, isPrefix);
List<IBinding> filtered = new ArrayList<IBinding>(); List<IBinding> filtered = new ArrayList<IBinding>();
for (int i = 0; i < bindings.length; i++) { for (IBinding binding : bindings) {
if (bindings[i] instanceof ICPPMethod) { if (binding instanceof ICPPMethod) {
ICPPMethod method = (ICPPMethod) bindings[i]; ICPPMethod method = (ICPPMethod) binding;
if (method.isImplicit()) { if (method.isImplicit()) {
continue; continue;
} }
} }
filtered.add(bindings[i]); filtered.add(binding);
} }
return filtered.toArray(new IBinding[filtered.size()]); return filtered.toArray(new IBinding[filtered.size()]);

View file

@ -243,7 +243,7 @@ public class CPPClassScope extends CPPScope implements ICPPClassScope {
} }
IBinding[] result = null; IBinding[] result = null;
if ((!prefixLookup && CharArrayUtils.equals(c, compName.getLookupKey())) if ((!prefixLookup && CharArrayUtils.equals(c, compName.getLookupKey()))
|| (prefixLookup && CharArrayUtils.equals(compName.getLookupKey(), 0, c.length, c, true))) { || (prefixLookup && CharArrayUtils.equals(compName.getLookupKey(), 0, c.length, c, true))) {
if (isConstructorReference(name)) { if (isConstructorReference(name)) {
result = (IBinding[]) ArrayUtil.addAll(IBinding.class, result, getConstructors(name, resolve)); result = (IBinding[]) ArrayUtil.addAll(IBinding.class, result, getConstructors(name, resolve));
} }

View file

@ -217,8 +217,7 @@ public class CPPFunction extends PlatformObject implements ICPPFunction, ICPPInt
final IBinding binding= name.resolveBinding(); final IBinding binding= name.resolveBinding();
if (binding instanceof IParameter) { if (binding instanceof IParameter) {
result[i]= (IParameter) binding; result[i]= (IParameter) binding;
} } else {
else {
result[i] = new CPPParameter.CPPParameterProblem(p, IProblemBinding.SEMANTIC_INVALID_TYPE, result[i] = new CPPParameter.CPPParameterProblem(p, IProblemBinding.SEMANTIC_INVALID_TYPE,
name.toCharArray()); name.toCharArray());
} }

View file

@ -99,7 +99,7 @@ public class DOMCompletionProposalComputer extends ParsingBasedProposalComputer
List<ICompletionProposal> proposals = new ArrayList<ICompletionProposal>(); List<ICompletionProposal> proposals = new ArrayList<ICompletionProposal>();
if(inPreprocessorDirective(context)) { if (inPreprocessorDirective(context)) {
if (!inPreprocessorKeyword(context)) { if (!inPreprocessorKeyword(context)) {
// add only macros // add only macros
if (prefix.length() == 0) { if (prefix.length() == 0) {
@ -278,12 +278,8 @@ public class DOMCompletionProposalComputer extends ParsingBasedProposalComputer
} }
} }
protected void handleBinding(IBinding binding, protected void handleBinding(IBinding binding, CContentAssistInvocationContext cContext, String prefix,
CContentAssistInvocationContext cContext, IASTCompletionContext astContext, List<ICompletionProposal> proposals) {
String prefix,
IASTCompletionContext astContext,
List<ICompletionProposal> proposals) {
if ((binding instanceof CPPImplicitFunction if ((binding instanceof CPPImplicitFunction
|| binding instanceof CPPImplicitFunctionTemplate || binding instanceof CPPImplicitFunctionTemplate
|| binding instanceof CPPImplicitTypedef || binding instanceof CPPImplicitTypedef