diff --git a/core/org.eclipse.cdt.core/parser/org/eclipse/cdt/internal/core/dom/parser/cpp/CPPASTFieldReference.java b/core/org.eclipse.cdt.core/parser/org/eclipse/cdt/internal/core/dom/parser/cpp/CPPASTFieldReference.java index 14b5a2c81bf..1b05fc18b54 100644 --- a/core/org.eclipse.cdt.core/parser/org/eclipse/cdt/internal/core/dom/parser/cpp/CPPASTFieldReference.java +++ b/core/org.eclipse.cdt.core/parser/org/eclipse/cdt/internal/core/dom/parser/cpp/CPPASTFieldReference.java @@ -40,7 +40,8 @@ public class CPPASTFieldReference extends CPPASTNode implements public CPPASTFieldReference() { } - public CPPASTFieldReference(IASTName name, IASTExpression owner, boolean isTemplate, boolean isDeref) { + public CPPASTFieldReference(IASTName name, IASTExpression owner, boolean isTemplate, + boolean isDeref) { setFieldName(name); setFieldOwner(owner); this.isTemplate = isTemplate; @@ -91,39 +92,38 @@ public class CPPASTFieldReference extends CPPASTNode implements isDeref = value; } - public boolean accept( ASTVisitor action ){ - if( action.shouldVisitExpressions ){ - switch( action.visit( this ) ){ - case ASTVisitor.PROCESS_ABORT : return false; - case ASTVisitor.PROCESS_SKIP : return true; - default : break; + public boolean accept(ASTVisitor action) { + if (action.shouldVisitExpressions) { + switch (action.visit(this)) { + case ASTVisitor.PROCESS_ABORT: return false; + case ASTVisitor.PROCESS_SKIP: return true; + default: break; } } - if( owner != null ) if( !owner.accept( action ) ) return false; - if( name != null ) if( !name.accept( action ) ) return false; + if (owner != null && !owner.accept(action)) return false; + if (name != null && !name.accept(action)) return false; - if( action.shouldVisitExpressions ){ - switch( action.leave( this ) ){ - case ASTVisitor.PROCESS_ABORT : return false; - case ASTVisitor.PROCESS_SKIP : return true; - default : break; + if (action.shouldVisitExpressions) { + switch (action.leave(this)) { + case ASTVisitor.PROCESS_ABORT: return false; + case ASTVisitor.PROCESS_SKIP: return true; + default: break; } } return true; } public int getRoleForName(IASTName n) { - if( n == name ) + if (n == name) return r_reference; return r_unclear; } public void replace(IASTNode child, IASTNode other) { - if( child == owner ) - { - other.setPropertyInParent( child.getPropertyInParent() ); - other.setParent( child.getParent() ); + if (child == owner) { + other.setPropertyInParent(child.getPropertyInParent()); + other.setParent(child.getParent()); owner = (IASTExpression) other; } } @@ -134,7 +134,7 @@ public class CPPASTFieldReference extends CPPASTNode implements public IBinding[] findBindings(IASTName n, boolean isPrefix) { IBinding[] bindings = CPPSemantics.findBindingsForContentAssist(n, isPrefix); - List filtered = new ArrayList(); + List filtered = new ArrayList(); for (int i = 0; i < bindings.length; i++) { if (bindings[i] instanceof ICPPMethod) { @@ -146,6 +146,6 @@ public class CPPASTFieldReference extends CPPASTNode implements filtered.add(bindings[i]); } - return (IBinding[]) filtered.toArray(new IBinding[filtered.size()]); + return filtered.toArray(new IBinding[filtered.size()]); } } diff --git a/core/org.eclipse.cdt.core/parser/org/eclipse/cdt/internal/core/dom/parser/cpp/CPPASTQualifiedName.java b/core/org.eclipse.cdt.core/parser/org/eclipse/cdt/internal/core/dom/parser/cpp/CPPASTQualifiedName.java index 85b19f1f726..108998da038 100644 --- a/core/org.eclipse.cdt.core/parser/org/eclipse/cdt/internal/core/dom/parser/cpp/CPPASTQualifiedName.java +++ b/core/org.eclipse.cdt.core/parser/org/eclipse/cdt/internal/core/dom/parser/cpp/CPPASTQualifiedName.java @@ -41,7 +41,6 @@ import org.eclipse.cdt.core.parser.util.CharArrayUtils; public class CPPASTQualifiedName extends CPPASTNode implements ICPPASTQualifiedName, IASTCompletionContext { - public CPPASTQualifiedName() { } @@ -64,7 +63,6 @@ public class CPPASTQualifiedName extends CPPASTNode implements return null; } - public String toString() { if (signature == null) return ""; //$NON-NLS-1$ @@ -79,7 +77,6 @@ public class CPPASTQualifiedName extends CPPASTNode implements } } - private void removeNullNames() { names = (IASTName[]) ArrayUtil.removeNullsAfter( IASTName.class, names, namesPos ); } @@ -183,7 +180,6 @@ public class CPPASTQualifiedName extends CPPASTNode implements return true; } - public boolean isDeclaration() { IASTNode parent = getParent(); if (parent instanceof IASTNameOwner) { @@ -233,12 +229,16 @@ public class CPPASTQualifiedName extends CPPASTNode implements IASTName[] nonNullNames = getNames(); // ensure no null names int len=nonNullNames.length; - if (nonNullNames[len-1] instanceof ICPPASTConversionName || nonNullNames[len-1] instanceof ICPPASTOperatorName) return true; + if (nonNullNames[len-1] instanceof ICPPASTConversionName || nonNullNames[len-1] instanceof ICPPASTOperatorName) { + return true; + } // check templateId's name if (nonNullNames[len-1] instanceof ICPPASTTemplateId) { IASTName tempName = ((ICPPASTTemplateId)nonNullNames[len-1]).getTemplateName(); - if (tempName instanceof ICPPASTConversionName || tempName instanceof ICPPASTOperatorName) return true; + if (tempName instanceof ICPPASTConversionName || tempName instanceof ICPPASTOperatorName) { + return true; + } } return false; @@ -262,10 +262,10 @@ public class CPPASTQualifiedName extends CPPASTNode implements if (binding instanceof ICPPClassType) { ICPPClassType classType = (ICPPClassType) binding; final boolean isDeclaration = getParent().getParent() instanceof IASTSimpleDeclaration; - List filtered = filterClassScopeBindings(classType, bindings, isDeclaration); + List filtered = filterClassScopeBindings(classType, bindings, isDeclaration); - if (isDeclaration && nameMatches(classType.getNameCharArray(), n - .toCharArray(), isPrefix)) { + if (isDeclaration && nameMatches(classType.getNameCharArray(), + n.toCharArray(), isPrefix)) { try { ICPPConstructor[] constructors = classType.getConstructors(); for (int i = 0; i < constructors.length; i++) { @@ -277,16 +277,16 @@ public class CPPASTQualifiedName extends CPPASTNode implements } } - return (IBinding[]) filtered.toArray(new IBinding[filtered.size()]); + return filtered.toArray(new IBinding[filtered.size()]); } } return bindings; } - private List filterClassScopeBindings(ICPPClassType classType, + private List filterClassScopeBindings(ICPPClassType classType, IBinding[] bindings, final boolean isDeclaration) { - List filtered = new ArrayList(); + List filtered = new ArrayList(); try { for (int i = 0; i < bindings.length; i++) { @@ -298,7 +298,9 @@ public class CPPASTQualifiedName extends CPPASTNode implements if (method.isImplicit()) continue; if (method.isDestructor() || method instanceof ICPPConstructor) { if (!isDeclaration) continue; - } else if (!method.isStatic() && !isDeclaration) continue; + } else if (!method.isStatic() && !isDeclaration) { + continue; + } } else if (bindings[i] instanceof ICPPClassType) { ICPPClassType type = (ICPPClassType) bindings[i]; if (type.isSameType(classType)) continue;