diff --git a/core/org.eclipse.cdt.core/parser/org/eclipse/cdt/core/dom/ast/cpp/ICPPClassType.java b/core/org.eclipse.cdt.core/parser/org/eclipse/cdt/core/dom/ast/cpp/ICPPClassType.java index 78ee19a42a6..3b78bf78d2c 100644 --- a/core/org.eclipse.cdt.core/parser/org/eclipse/cdt/core/dom/ast/cpp/ICPPClassType.java +++ b/core/org.eclipse.cdt.core/parser/org/eclipse/cdt/core/dom/ast/cpp/ICPPClassType.java @@ -21,7 +21,7 @@ import org.eclipse.cdt.core.dom.ast.IField; * @author Doug Schaefer */ public interface ICPPClassType extends ICompositeType, ICPPBinding { - public static final ICPPClassType [] EMPTY_CLASS_ARRAY = new ICPPClassType[0]; + public static final ICPPClassType[] EMPTY_CLASS_ARRAY = new ICPPClassType[0]; public static final int k_class = ICPPASTCompositeTypeSpecifier.k_class; /** @@ -103,5 +103,5 @@ public interface ICPPClassType extends ICompositeType, ICPPBinding { * return an array of nested classes/structures * @throws DOMException */ - public ICPPClassType [] getNestedClasses() throws DOMException; + public ICPPClassType[] getNestedClasses() throws DOMException; } diff --git a/core/org.eclipse.cdt.core/parser/org/eclipse/cdt/internal/core/dom/parser/c/CASTDeclarator.java b/core/org.eclipse.cdt.core/parser/org/eclipse/cdt/internal/core/dom/parser/c/CASTDeclarator.java index 876327593e8..4cf7612c959 100644 --- a/core/org.eclipse.cdt.core/parser/org/eclipse/cdt/internal/core/dom/parser/c/CASTDeclarator.java +++ b/core/org.eclipse.cdt.core/parser/org/eclipse/cdt/internal/core/dom/parser/c/CASTDeclarator.java @@ -33,13 +33,11 @@ import org.eclipse.cdt.internal.core.dom.parser.IASTAmbiguityParent; * @author jcamelon */ public class CASTDeclarator extends ASTNode implements IASTDeclarator, IASTAmbiguityParent { - private IASTInitializer initializer; private IASTName name; private IASTDeclarator nestedDeclarator; - private IASTPointerOperator [] pointerOps = null; - private int pointerOpsPos=-1; - + private IASTPointerOperator[] pointerOps = null; + private int pointerOpsPos= -1; public CASTDeclarator() { } @@ -54,8 +52,8 @@ public class CASTDeclarator extends ASTNode implements IASTDeclarator, IASTAmbig } public IASTPointerOperator[] getPointerOperators() { - if( pointerOps == null ) return IASTPointerOperator.EMPTY_ARRAY; - pointerOps = (IASTPointerOperator[]) ArrayUtil.removeNullsAfter( IASTPointerOperator.class, pointerOps, pointerOpsPos ); + if (pointerOps == null) return IASTPointerOperator.EMPTY_ARRAY; + pointerOps = (IASTPointerOperator[]) ArrayUtil.removeNullsAfter(IASTPointerOperator.class, pointerOps, pointerOpsPos); return pointerOps; } @@ -71,7 +69,6 @@ public class CASTDeclarator extends ASTNode implements IASTDeclarator, IASTAmbig return initializer; } - public void setInitializer(IASTInitializer initializer) { this.initializer = initializer; if (initializer != null) { @@ -84,7 +81,7 @@ public class CASTDeclarator extends ASTNode implements IASTDeclarator, IASTAmbig if (operator != null) { operator.setParent(this); operator.setPropertyInParent(POINTER_OPERATOR); - pointerOps = (IASTPointerOperator[]) ArrayUtil.append( IASTPointerOperator.class, pointerOps, ++pointerOpsPos, operator ); + pointerOps = (IASTPointerOperator[]) ArrayUtil.append(IASTPointerOperator.class, pointerOps, ++pointerOpsPos, operator); } } @@ -105,35 +102,36 @@ public class CASTDeclarator extends ASTNode implements IASTDeclarator, IASTAmbig } @Override - public boolean accept( ASTVisitor action ){ - if( action.shouldVisitDeclarators ){ - switch( action.visit( this ) ){ + public boolean accept(ASTVisitor action) { + if (action.shouldVisitDeclarators) { + switch(action.visit(this)) { case ASTVisitor.PROCESS_ABORT : return false; case ASTVisitor.PROCESS_SKIP : return true; default : break; } } - - if( getPropertyInParent() != IASTTypeId.ABSTRACT_DECLARATOR && - nestedDeclarator == null ) - { - if( getParent() instanceof IASTDeclarator ) - { + if (getPropertyInParent() != IASTTypeId.ABSTRACT_DECLARATOR && nestedDeclarator == null) { + if (getParent() instanceof IASTDeclarator) { IASTDeclarator outermostDeclarator = (IASTDeclarator) getParent(); - while( outermostDeclarator.getParent() instanceof IASTDeclarator ) + while (outermostDeclarator.getParent() instanceof IASTDeclarator) outermostDeclarator = (IASTDeclarator) outermostDeclarator.getParent(); - if( outermostDeclarator.getPropertyInParent() != IASTTypeId.ABSTRACT_DECLARATOR ) - if( name != null ) if( !name.accept( action ) ) return false; + if (outermostDeclarator.getPropertyInParent() != IASTTypeId.ABSTRACT_DECLARATOR && + name != null && !name.accept(action)) { + return false; + } + } else if (name != null && !name.accept(action)) { + return false; } - else - if( name != null ) if( !name.accept( action ) ) return false; } - if( nestedDeclarator != null ) if( !nestedDeclarator.accept( action ) ) return false; + if (nestedDeclarator != null && !nestedDeclarator.accept(action)) { + return false; + } - IASTPointerOperator [] ptrOps = getPointerOperators(); - for ( int i = 0; i < ptrOps.length; i++ ) { - if( !ptrOps[i].accept( action ) ) return false; + IASTPointerOperator[] ptrOps = getPointerOperators(); + for (int i = 0; i < ptrOps.length; i++) { + if (!ptrOps[i].accept(action)) + return false; } if (!postAccept(action)) @@ -145,67 +143,59 @@ public class CASTDeclarator extends ASTNode implements IASTDeclarator, IASTAmbig return true; } - protected boolean postAccept( ASTVisitor action ){ + protected boolean postAccept(ASTVisitor action) { if (initializer != null && !initializer.accept(action)) return false; return true; } - public int getRoleForName(IASTName n ) { - if( n == this.name ) - { + public int getRoleForName(IASTName n) { + if (n == this.name) { IASTNode getParent = getParent(); - boolean fnDtor = ( this instanceof IASTFunctionDeclarator ); - if( getParent instanceof IASTDeclaration ) - { - if( getParent instanceof IASTFunctionDefinition ) + boolean fnDtor = (this instanceof IASTFunctionDeclarator); + if (getParent instanceof IASTDeclaration) { + if (getParent instanceof IASTFunctionDefinition) return r_definition; - if( getParent instanceof IASTSimpleDeclaration ) - { + if (getParent instanceof IASTSimpleDeclaration) { IASTSimpleDeclaration sd = (IASTSimpleDeclaration) getParent; int storage = sd.getDeclSpecifier().getStorageClass(); - if( getInitializer() != null || storage == IASTDeclSpecifier.sc_typedef ) + if (getInitializer() != null || storage == IASTDeclSpecifier.sc_typedef) return r_definition; - if( storage == IASTDeclSpecifier.sc_extern || - storage == IASTDeclSpecifier.sc_static ) - { - return r_declaration; - } + if (storage == IASTDeclSpecifier.sc_extern || storage == IASTDeclSpecifier.sc_static) { + return r_declaration; + } return fnDtor ? r_declaration : r_definition; } } - if( getParent instanceof IASTTypeId ) + if (getParent instanceof IASTTypeId) return r_reference; - if( getParent instanceof IASTDeclarator ) - { + if (getParent instanceof IASTDeclarator) { IASTNode t = getParent; - while ( t instanceof IASTDeclarator ) + while (t instanceof IASTDeclarator) t = t.getParent(); - if( t instanceof IASTDeclaration ) - { - if( getParent instanceof IASTFunctionDefinition ) + if (t instanceof IASTDeclaration) { + if (getParent instanceof IASTFunctionDefinition) return r_definition; - if( getParent instanceof IASTSimpleDeclaration ) - { - if( getInitializer() != null ) + if (getParent instanceof IASTSimpleDeclaration) { + if (getInitializer() != null) return r_definition; IASTSimpleDeclaration sd = (IASTSimpleDeclaration) getParent; int storage = sd.getDeclSpecifier().getStorageClass(); - if( storage == IASTDeclSpecifier.sc_extern || - storage == IASTDeclSpecifier.sc_static) + if (storage == IASTDeclSpecifier.sc_extern || storage == IASTDeclSpecifier.sc_static) { return r_declaration; + } } return fnDtor ? r_declaration : r_definition; } - if( t instanceof IASTTypeId ) + if (t instanceof IASTTypeId) return r_reference; } - if( getParent instanceof IASTParameterDeclaration ) - return ( n.toCharArray().length > 0 ) ? r_definition : r_declaration; + if (getParent instanceof IASTParameterDeclaration) + return (n.toCharArray().length > 0) ? r_definition : r_declaration; } return r_unclear; } diff --git a/core/org.eclipse.cdt.core/parser/org/eclipse/cdt/internal/core/dom/parser/cpp/CPPASTDeclarator.java b/core/org.eclipse.cdt.core/parser/org/eclipse/cdt/internal/core/dom/parser/cpp/CPPASTDeclarator.java index b040c3bde02..76680129096 100644 --- a/core/org.eclipse.cdt.core/parser/org/eclipse/cdt/internal/core/dom/parser/cpp/CPPASTDeclarator.java +++ b/core/org.eclipse.cdt.core/parser/org/eclipse/cdt/internal/core/dom/parser/cpp/CPPASTDeclarator.java @@ -35,9 +35,8 @@ public class CPPASTDeclarator extends ASTNode implements IASTDeclarator { private IASTInitializer initializer; private IASTName name; private IASTDeclarator nestedDeclarator; - private IASTPointerOperator [] pointerOps = null; - private int pointerOpsPos=-1; - + private IASTPointerOperator[] pointerOps = null; + private int pointerOpsPos= -1; public CPPASTDeclarator() { } @@ -52,8 +51,8 @@ public class CPPASTDeclarator extends ASTNode implements IASTDeclarator { } public IASTPointerOperator[] getPointerOperators() { - if( pointerOps == null ) return IASTPointerOperator.EMPTY_ARRAY; - pointerOps = (IASTPointerOperator[]) ArrayUtil.removeNullsAfter( IASTPointerOperator.class, pointerOps, pointerOpsPos ); + if (pointerOps == null) return IASTPointerOperator.EMPTY_ARRAY; + pointerOps = (IASTPointerOperator[]) ArrayUtil.removeNullsAfter(IASTPointerOperator.class, pointerOps, pointerOpsPos); return pointerOps; } @@ -81,7 +80,7 @@ public class CPPASTDeclarator extends ASTNode implements IASTDeclarator { if (operator != null) { operator.setParent(this); operator.setPropertyInParent(POINTER_OPERATOR); - pointerOps = (IASTPointerOperator[]) ArrayUtil.append( IASTPointerOperator.class, pointerOps, ++pointerOpsPos, operator ); + pointerOps = (IASTPointerOperator[]) ArrayUtil.append(IASTPointerOperator.class, pointerOps, ++pointerOpsPos, operator); } } @@ -93,7 +92,6 @@ public class CPPASTDeclarator extends ASTNode implements IASTDeclarator { } } - public void setName(IASTName name) { this.name = name; if (name != null) { @@ -103,18 +101,18 @@ public class CPPASTDeclarator extends ASTNode implements IASTDeclarator { } @Override - public boolean accept( ASTVisitor action ){ - if( action.shouldVisitDeclarators ){ - switch( action.visit( this ) ){ - case ASTVisitor.PROCESS_ABORT : return false; - case ASTVisitor.PROCESS_SKIP : return true; + public boolean accept(ASTVisitor action) { + if (action.shouldVisitDeclarators) { + switch(action.visit(this)) { + case ASTVisitor.PROCESS_ABORT: return false; + case ASTVisitor.PROCESS_SKIP: return true; default : break; } } - IASTPointerOperator [] ptrOps = getPointerOperators(); - for ( int i = 0; i < ptrOps.length; i++ ) { - if( !ptrOps[i].accept( action ) ) return false; + IASTPointerOperator[] ptrOps = getPointerOperators(); + for (int i = 0; i < ptrOps.length; i++) { + if (!ptrOps[i].accept(action)) return false; } if (nestedDeclarator == null && name != null) { @@ -147,55 +145,47 @@ public class CPPASTDeclarator extends ASTNode implements IASTDeclarator { public int getRoleForName(IASTName n) { IASTNode getParent = getParent(); - boolean fnDtor = ( this instanceof IASTFunctionDeclarator ); - if( getParent instanceof IASTDeclaration ) - { - if( getParent instanceof IASTFunctionDefinition ) + boolean fnDtor = (this instanceof IASTFunctionDeclarator); + if (getParent instanceof IASTDeclaration) { + if (getParent instanceof IASTFunctionDefinition) return r_definition; - if( getParent instanceof IASTSimpleDeclaration ) { + if (getParent instanceof IASTSimpleDeclaration) { final int storage = ((IASTSimpleDeclaration) getParent).getDeclSpecifier().getStorageClass(); - if( getInitializer() != null || storage == IASTDeclSpecifier.sc_typedef) + if (getInitializer() != null || storage == IASTDeclSpecifier.sc_typedef) return r_definition; - if( storage == IASTDeclSpecifier.sc_extern || - storage == IASTDeclSpecifier.sc_static ) - { + if (storage == IASTDeclSpecifier.sc_extern || storage == IASTDeclSpecifier.sc_static) { return r_declaration; } } return fnDtor ? r_declaration : r_definition; } - if( getParent instanceof IASTTypeId ) + if (getParent instanceof IASTTypeId) return r_reference; - if( getParent instanceof IASTDeclarator ) - { + if (getParent instanceof IASTDeclarator) { IASTNode t = getParent; - while ( t instanceof IASTDeclarator ) + while (t instanceof IASTDeclarator) t = t.getParent(); - if( t instanceof IASTDeclaration ) - { - if( getParent instanceof IASTFunctionDefinition ) + if (t instanceof IASTDeclaration) { + if (getParent instanceof IASTFunctionDefinition) return r_definition; - if( getParent instanceof IASTSimpleDeclaration ) - { - if( getInitializer() != null ) + if (getParent instanceof IASTSimpleDeclaration) { + if (getInitializer() != null) return r_definition; IASTSimpleDeclaration sd = (IASTSimpleDeclaration) getParent; int storage = sd.getDeclSpecifier().getStorageClass(); - if( storage == IASTDeclSpecifier.sc_extern || - storage == IASTDeclSpecifier.sc_typedef || - storage == IASTDeclSpecifier.sc_static ) - { + if (storage == IASTDeclSpecifier.sc_extern || storage == IASTDeclSpecifier.sc_typedef || + storage == IASTDeclSpecifier.sc_static) { return r_declaration; } } return fnDtor ? r_declaration : r_definition; } - if( t instanceof IASTTypeId ) + if (t instanceof IASTTypeId) return r_reference; } - if( getParent instanceof IASTParameterDeclaration ) - return ( n.toCharArray().length > 0 ) ? r_definition : r_declaration; + if (getParent instanceof IASTParameterDeclaration) + return (n.toCharArray().length > 0) ? r_definition : r_declaration; return r_unclear; } diff --git a/core/org.eclipse.cdt.core/parser/org/eclipse/cdt/internal/core/dom/parser/cpp/CPPClassTemplate.java b/core/org.eclipse.cdt.core/parser/org/eclipse/cdt/internal/core/dom/parser/cpp/CPPClassTemplate.java index 12ed02c11d4..ae63ebca441 100644 --- a/core/org.eclipse.cdt.core/parser/org/eclipse/cdt/internal/core/dom/parser/cpp/CPPClassTemplate.java +++ b/core/org.eclipse.cdt.core/parser/org/eclipse/cdt/internal/core/dom/parser/cpp/CPPClassTemplate.java @@ -107,7 +107,7 @@ public class CPPClassTemplate extends CPPTemplateDefinition implements private ICPPClassTemplatePartialSpecialization[] partialSpecializations = null; - public CPPClassTemplate(IASTName name) { + public CPPClassTemplate(IASTName name) { super(name); } diff --git a/core/org.eclipse.cdt.core/parser/org/eclipse/cdt/internal/core/dom/parser/cpp/CPPTemplateDefinition.java b/core/org.eclipse.cdt.core/parser/org/eclipse/cdt/internal/core/dom/parser/cpp/CPPTemplateDefinition.java index 1f6f95e4012..2d81fe8c125 100644 --- a/core/org.eclipse.cdt.core/parser/org/eclipse/cdt/internal/core/dom/parser/cpp/CPPTemplateDefinition.java +++ b/core/org.eclipse.cdt.core/parser/org/eclipse/cdt/internal/core/dom/parser/cpp/CPPTemplateDefinition.java @@ -251,7 +251,7 @@ public abstract class CPPTemplateDefinition extends PlatformObject implements IC int pos= templateParameter.getParameterPosition() & 0xff; int tdeclLen= declarations == null ? 0 : declarations.length; - for (int i=-1; i