diff --git a/core/org.eclipse.cdt.core/model/org/eclipse/cdt/core/model/IDeclaration.java b/core/org.eclipse.cdt.core/model/org/eclipse/cdt/core/model/IDeclaration.java index 981d3798872..063e34765dc 100644 --- a/core/org.eclipse.cdt.core/model/org/eclipse/cdt/core/model/IDeclaration.java +++ b/core/org.eclipse.cdt.core/model/org/eclipse/cdt/core/model/IDeclaration.java @@ -11,35 +11,33 @@ package org.eclipse.cdt.core.model; /** - * IDeclaration is a base interface for any C Model element that could be - * considered a declaration. - * + * Base interface for any C Model element that could be considered a declaration. + * * @noextend This interface is not intended to be extended by clients. * @noimplement This interface is not intended to be implemented by clients. */ public interface IDeclaration extends ICElement, ISourceManipulation, ISourceReference { - /** - * Checks if the declaration is static + * Checks if the declaration is static * Returns true if the declaration is static, false otherwise. * @return boolean * @throws CModelException */ boolean isStatic() throws CModelException; - + /** * Checks if the declaration is constant. - * Returns true if the decalration is constant, false otherwise. + * Returns true if the declaration is constant, false otherwise. * @return boolean * @throws CModelException */ boolean isConst() throws CModelException; - + /** * Checks if the declaration is volatile. * Returns true if the declaration is volatile, false otherwise. * @return boolean * @throws CModelException */ - boolean isVolatile() throws CModelException; + boolean isVolatile() throws CModelException; } diff --git a/core/org.eclipse.cdt.core/model/org/eclipse/cdt/core/model/IFunctionDeclaration.java b/core/org.eclipse.cdt.core/model/org/eclipse/cdt/core/model/IFunctionDeclaration.java index ac10bd01950..c85ea3d39d4 100644 --- a/core/org.eclipse.cdt.core/model/org/eclipse/cdt/core/model/IFunctionDeclaration.java +++ b/core/org.eclipse.cdt.core/model/org/eclipse/cdt/core/model/IFunctionDeclaration.java @@ -10,15 +10,13 @@ *******************************************************************************/ package org.eclipse.cdt.core.model; - /** * Represents a function - * + * * @noextend This interface is not intended to be extended by clients. * @noimplement This interface is not intended to be implemented by clients. */ public interface IFunctionDeclaration extends IDeclaration { - /** * Returns the type signatures of the exceptions this method throws, * in the order declared in the source. Returns an empty array @@ -54,12 +52,12 @@ public interface IFunctionDeclaration extends IDeclaration { String[] getParameterTypes(); /** - * Returns the return value of this method. + * Returns the return value of this method. */ String getReturnType(); - + /** - * Returns the signature of the method. - */ + * Returns the signature of the method. + */ String getSignature() throws CModelException; } diff --git a/core/org.eclipse.cdt.core/model/org/eclipse/cdt/core/model/IMethod.java b/core/org.eclipse.cdt.core/model/org/eclipse/cdt/core/model/IMethod.java index 778ac88b8bf..2b03050204d 100644 --- a/core/org.eclipse.cdt.core/model/org/eclipse/cdt/core/model/IMethod.java +++ b/core/org.eclipse.cdt.core/model/org/eclipse/cdt/core/model/IMethod.java @@ -12,10 +12,9 @@ package org.eclipse.cdt.core.model; /** * Represents the definition method of a class. - * + * * @noextend This interface is not intended to be extended by clients. * @noimplement This interface is not intended to be implemented by clients. */ public interface IMethod extends IMethodDeclaration { - } diff --git a/core/org.eclipse.cdt.core/model/org/eclipse/cdt/core/model/IMethodDeclaration.java b/core/org.eclipse.cdt.core/model/org/eclipse/cdt/core/model/IMethodDeclaration.java index cb927bb4d2a..9cc2d29bed4 100644 --- a/core/org.eclipse.cdt.core/model/org/eclipse/cdt/core/model/IMethodDeclaration.java +++ b/core/org.eclipse.cdt.core/model/org/eclipse/cdt/core/model/IMethodDeclaration.java @@ -10,7 +10,6 @@ *******************************************************************************/ package org.eclipse.cdt.core.model; - /** * Represents the declaration method of a class * @@ -18,7 +17,6 @@ package org.eclipse.cdt.core.model; * @noimplement This interface is not intended to be implemented by clients. */ public interface IMethodDeclaration extends IMember, IFunctionDeclaration { - /** * Returns whether this method is a constructor. * @@ -78,5 +76,4 @@ public interface IMethodDeclaration extends IMember, IFunctionDeclaration { * return true if the member is a friend. */ public boolean isFriend() throws CModelException; - } diff --git a/core/org.eclipse.cdt.core/parser/org/eclipse/cdt/core/dom/ast/ASTGenericVisitor.java b/core/org.eclipse.cdt.core/parser/org/eclipse/cdt/core/dom/ast/ASTGenericVisitor.java index b211f38f70b..6cd05720d50 100644 --- a/core/org.eclipse.cdt.core/parser/org/eclipse/cdt/core/dom/ast/ASTGenericVisitor.java +++ b/core/org.eclipse.cdt.core/parser/org/eclipse/cdt/core/dom/ast/ASTGenericVisitor.java @@ -6,8 +6,8 @@ * http://www.eclipse.org/legal/epl-v10.html * * Contributors: - * Markus Schorn - initial API and implementation - *******************************************************************************/ + * Markus Schorn - initial API and implementation + *******************************************************************************/ package org.eclipse.cdt.core.dom.ast; import org.eclipse.cdt.core.dom.ast.IASTEnumerationSpecifier.IASTEnumerator; @@ -20,11 +20,12 @@ import org.eclipse.cdt.core.dom.ast.cpp.ICPPASTTemplateParameter; import org.eclipse.cdt.core.dom.ast.cpp.ICPPASTVisitor; /** - * Generic visitor for ast-nodes. - *

Clients may subclass.

+ * Generic visitor for AST nodes. + *

Clients may subclass.

* @since 5.1 */ public abstract class ASTGenericVisitor extends ASTVisitor implements ICPPASTVisitor, ICASTVisitor { + public ASTGenericVisitor(boolean visitNodes) { super(visitNodes); } @@ -32,7 +33,7 @@ public abstract class ASTGenericVisitor extends ASTVisitor implements ICPPASTVis protected int genericVisit(IASTNode node) { return PROCESS_CONTINUE; } - + protected int genericLeave(IASTNode node) { return PROCESS_CONTINUE; } @@ -51,7 +52,7 @@ public abstract class ASTGenericVisitor extends ASTVisitor implements ICPPASTVis public int visit(ICPPASTTemplateParameter templateParameter) { return genericVisit(templateParameter); } - + @Override public int visit(ICPPASTCapture capture) { return genericVisit(capture); @@ -61,7 +62,7 @@ public abstract class ASTGenericVisitor extends ASTVisitor implements ICPPASTVis public int visit(IASTArrayModifier arrayModifier) { return genericVisit(arrayModifier); } - + @Override public int visit(IASTPointerOperator ptrOperator) { return genericVisit(ptrOperator); @@ -161,7 +162,7 @@ public abstract class ASTGenericVisitor extends ASTVisitor implements ICPPASTVis public int leave(IASTArrayModifier arrayModifier) { return genericLeave(arrayModifier); } - + @Override public int leave(IASTPointerOperator ptrOperator) { return genericLeave(ptrOperator); diff --git a/core/org.eclipse.cdt.core/parser/org/eclipse/cdt/core/dom/ast/ASTVisitor.java b/core/org.eclipse.cdt.core/parser/org/eclipse/cdt/core/dom/ast/ASTVisitor.java index fd84a29e921..2fe1ab4ef25 100644 --- a/core/org.eclipse.cdt.core/parser/org/eclipse/cdt/core/dom/ast/ASTVisitor.java +++ b/core/org.eclipse.cdt.core/parser/org/eclipse/cdt/core/dom/ast/ASTVisitor.java @@ -22,15 +22,15 @@ import org.eclipse.cdt.core.dom.ast.cpp.ICPPASTTemplateParameter; import org.eclipse.cdt.internal.core.dom.parser.ASTAmbiguousNode; /** - * Abstract base class for all visitors to traverse ast nodes.
+ * Abstract base class for all visitors to traverse AST nodes.
* visit() methods implement a top-down traversal, and
* leave() methods implement a bottom-up traversal.
- * + * *

Clients may subclass.

*/ public abstract class ASTVisitor { /** - * Skip the traversal of children of this node, don't call leave on this node. + * Skip the traversal of children of this node, don't call leave on this node. */ public final static int PROCESS_SKIP = 1; /** @@ -105,7 +105,7 @@ public abstract class ASTVisitor { * Set this flag to visit designators of initializers. */ public boolean shouldVisitDesignators = false; - + /** * Set this flag to visit base specifiers off composite types. */ @@ -120,20 +120,20 @@ public abstract class ASTVisitor { * Set this flag to visit template parameters. */ public boolean shouldVisitTemplateParameters = false; - + /** * Set this flag to visit captures * @since 5.3 */ public boolean shouldVisitCaptures= false; - + /** * Per default inactive nodes are not visited. You can change that by setting * this flag to true. * @since 5.1 */ public boolean includeInactiveNodes= false; - + /** * Normally neither ambiguous nodes nor their children are visited. By setting * this flag to true ambiguous nodes are visited, their children @@ -141,31 +141,28 @@ public abstract class ASTVisitor { * @noreference This field is not intended to be referenced by clients. */ public boolean shouldVisitAmbiguousNodes = false; - - + /** * Implicit names are created to allow implicit bindings to be resolved, * normally they are not visited, set this flag to true to visit them. * @since 5.1 */ public boolean shouldVisitImplicitNames = false; - - + /** * Sometimes more than one implicit name is created for a binding, * set this flag to true to visit more than one name for an implicit binding. * @since 5.1 */ public boolean shouldVisitImplicitNameAlternates = false; - - + /** * Creates a visitor that does not visit any kind of node per default. */ public ASTVisitor() { this(false); } - + /** * Creates a visitor. * @param visitNodes whether visitor is setup to visit all nodes per default, except @@ -254,11 +251,11 @@ public abstract class ASTVisitor { public int visit(IASTEnumerator enumerator) { return PROCESS_CONTINUE; } - + public int visit( IASTProblem problem ){ return PROCESS_CONTINUE; } - + /** * @since 5.3 */ @@ -329,6 +326,7 @@ public abstract class ASTVisitor { public int leave(IASTArrayModifier arrayModifier) { return PROCESS_CONTINUE; } + /** * @since 5.1 */ @@ -351,11 +349,11 @@ public abstract class ASTVisitor { public int leave(IASTEnumerator enumerator) { return PROCESS_CONTINUE; } - + public int leave(IASTProblem problem){ return PROCESS_CONTINUE; } - + /** * @since 5.3 */ @@ -398,6 +396,7 @@ public abstract class ASTVisitor { public int visit( IASTComment comment){ return PROCESS_CONTINUE; } + /** * @deprecated use {@link IASTTranslationUnit#getComments()}, instead. */ @@ -409,7 +408,7 @@ public abstract class ASTVisitor { /** * For internal use, only. When {@link ASTVisitor#shouldVisitAmbiguousNodes} is set to true, the * visitor will be called for ambiguous nodes. However, the children of an ambiguous will not be - * traversed. + * traversed. * @nooverride This method is not intended to be re-implemented or extended by clients. * @noreference This method is not intended to be referenced by clients. */ diff --git a/core/org.eclipse.cdt.core/parser/org/eclipse/cdt/core/dom/ast/IASTBreakStatement.java b/core/org.eclipse.cdt.core/parser/org/eclipse/cdt/core/dom/ast/IASTBreakStatement.java index 280e7d185f2..24a502fe79d 100644 --- a/core/org.eclipse.cdt.core/parser/org/eclipse/cdt/core/dom/ast/IASTBreakStatement.java +++ b/core/org.eclipse.cdt.core/parser/org/eclipse/cdt/core/dom/ast/IASTBreakStatement.java @@ -6,18 +6,17 @@ * http://www.eclipse.org/legal/epl-v10.html * * Contributors: - * Doug Schaefer (IBM) - Initial API and implementation + * Doug Schaefer (IBM) - Initial API and implementation *******************************************************************************/ package org.eclipse.cdt.core.dom.ast; /** * This is the break clause in a loop. - * + * * @noextend This interface is not intended to be extended by clients. * @noimplement This interface is not intended to be implemented by clients. */ public interface IASTBreakStatement extends IASTStatement { - /** * @since 5.1 */ diff --git a/core/org.eclipse.cdt.core/parser/org/eclipse/cdt/core/dom/ast/IASTCaseStatement.java b/core/org.eclipse.cdt.core/parser/org/eclipse/cdt/core/dom/ast/IASTCaseStatement.java index bc2a47204ea..152a0c7984f 100644 --- a/core/org.eclipse.cdt.core/parser/org/eclipse/cdt/core/dom/ast/IASTCaseStatement.java +++ b/core/org.eclipse.cdt.core/parser/org/eclipse/cdt/core/dom/ast/IASTCaseStatement.java @@ -6,7 +6,7 @@ * http://www.eclipse.org/legal/epl-v10.html * * Contributors: - * Doug Schaefer (IBM) - Initial API and implementation + * Doug Schaefer (IBM) - Initial API and implementation *******************************************************************************/ package org.eclipse.cdt.core.dom.ast; @@ -20,7 +20,6 @@ package org.eclipse.cdt.core.dom.ast; * @noimplement This interface is not intended to be implemented by clients. */ public interface IASTCaseStatement extends IASTStatement { - /** * ASTNodeProperty that represents the relationship between a * case statement and the expression it contains. @@ -30,7 +29,6 @@ public interface IASTCaseStatement extends IASTStatement { /** * The expression that determines whether this case should be taken. - * */ public IASTExpression getExpression(); diff --git a/core/org.eclipse.cdt.core/parser/org/eclipse/cdt/core/dom/ast/IASTContinueStatement.java b/core/org.eclipse.cdt.core/parser/org/eclipse/cdt/core/dom/ast/IASTContinueStatement.java index 68ca0313abb..0171cbc44dd 100644 --- a/core/org.eclipse.cdt.core/parser/org/eclipse/cdt/core/dom/ast/IASTContinueStatement.java +++ b/core/org.eclipse.cdt.core/parser/org/eclipse/cdt/core/dom/ast/IASTContinueStatement.java @@ -6,18 +6,17 @@ * http://www.eclipse.org/legal/epl-v10.html * * Contributors: - * Doug Schaefer (IBM) - Initial API and implementation + * Doug Schaefer (IBM) - Initial API and implementation *******************************************************************************/ package org.eclipse.cdt.core.dom.ast; /** * This is the continue clause in a loop. - * + * * @noextend This interface is not intended to be extended by clients. * @noimplement This interface is not intended to be implemented by clients. */ public interface IASTContinueStatement extends IASTStatement { - /** * @since 5.1 */ diff --git a/core/org.eclipse.cdt.core/parser/org/eclipse/cdt/core/dom/ast/IASTDeclarationStatement.java b/core/org.eclipse.cdt.core/parser/org/eclipse/cdt/core/dom/ast/IASTDeclarationStatement.java index 3646c7b0e0f..4b925c93e80 100644 --- a/core/org.eclipse.cdt.core/parser/org/eclipse/cdt/core/dom/ast/IASTDeclarationStatement.java +++ b/core/org.eclipse.cdt.core/parser/org/eclipse/cdt/core/dom/ast/IASTDeclarationStatement.java @@ -6,18 +6,17 @@ * http://www.eclipse.org/legal/epl-v10.html * * Contributors: - * Doug Schaefer (IBM) - Initial API and implementation + * Doug Schaefer (IBM) - Initial API and implementation *******************************************************************************/ package org.eclipse.cdt.core.dom.ast; /** * A declaration statement that introduces a declaration. - * + * * @noextend This interface is not intended to be extended by clients. * @noimplement This interface is not intended to be implemented by clients. */ public interface IASTDeclarationStatement extends IASTStatement { - /** * DECLARATION represents the relationship between a * declaration statement and the declaration it wraps. @@ -27,18 +26,18 @@ public interface IASTDeclarationStatement extends IASTStatement { /** * Gets the declaration introduced by this statement. - * + * * @return the declaration */ public IASTDeclaration getDeclaration(); /** * Set the declaration for this statement. - * + * * @param declaration */ public void setDeclaration(IASTDeclaration declaration); - + /** * @since 5.1 */ @@ -50,5 +49,4 @@ public interface IASTDeclarationStatement extends IASTStatement { */ @Override public IASTDeclarationStatement copy(CopyStyle style); - } diff --git a/core/org.eclipse.cdt.core/parser/org/eclipse/cdt/core/dom/ast/IASTDefaultStatement.java b/core/org.eclipse.cdt.core/parser/org/eclipse/cdt/core/dom/ast/IASTDefaultStatement.java index c58c80f80f0..ebf5e25cfb3 100644 --- a/core/org.eclipse.cdt.core/parser/org/eclipse/cdt/core/dom/ast/IASTDefaultStatement.java +++ b/core/org.eclipse.cdt.core/parser/org/eclipse/cdt/core/dom/ast/IASTDefaultStatement.java @@ -6,7 +6,7 @@ * http://www.eclipse.org/legal/epl-v10.html * * Contributors: - * Doug Schaefer (IBM) - Initial API and implementation + * Doug Schaefer (IBM) - Initial API and implementation *******************************************************************************/ package org.eclipse.cdt.core.dom.ast; @@ -20,7 +20,6 @@ package org.eclipse.cdt.core.dom.ast; * @noimplement This interface is not intended to be implemented by clients. */ public interface IASTDefaultStatement extends IASTStatement { - /** * @since 5.1 */ diff --git a/core/org.eclipse.cdt.core/parser/org/eclipse/cdt/core/dom/ast/IASTDoStatement.java b/core/org.eclipse.cdt.core/parser/org/eclipse/cdt/core/dom/ast/IASTDoStatement.java index 2cfc7582a46..c7f0ba6daa7 100644 --- a/core/org.eclipse.cdt.core/parser/org/eclipse/cdt/core/dom/ast/IASTDoStatement.java +++ b/core/org.eclipse.cdt.core/parser/org/eclipse/cdt/core/dom/ast/IASTDoStatement.java @@ -6,24 +6,24 @@ * http://www.eclipse.org/legal/epl-v10.html * * Contributors: - * Doug Schaefer (IBM) - Initial API and implementation + * Doug Schaefer (IBM) - Initial API and implementation *******************************************************************************/ package org.eclipse.cdt.core.dom.ast; /** * Ye ol' do statement. - * + * * @noextend This interface is not intended to be extended by clients. * @noimplement This interface is not intended to be implemented by clients. */ public interface IASTDoStatement extends IASTStatement { - /** * BODY represents the relationship between a * IASTDoStatement and its nested body * IASTStatement. */ - public static final ASTNodeProperty BODY = new ASTNodeProperty("IASTDoStatement.BODY - nested body for IASTDoStatement"); //$NON-NLS-1$ + public static final ASTNodeProperty BODY = + new ASTNodeProperty("IASTDoStatement.BODY - nested body for IASTDoStatement"); //$NON-NLS-1$ /** * CONDITION represents the relationship between a @@ -35,14 +35,14 @@ public interface IASTDoStatement extends IASTStatement { /** * Get the body of the loop. - * + * * @return IASTStatement loop code body */ public IASTStatement getBody(); /** * Set the body of the loop. - * + * * @param body * an IASTStatement */ @@ -50,19 +50,19 @@ public interface IASTDoStatement extends IASTStatement { /** * The condition on the loop. - * + * * @return the expression for the condition */ public IASTExpression getCondition(); /** * Set the condition for the loop. - * + * * @param condition * an IASTExpression */ public void setCondition(IASTExpression condition); - + /** * @since 5.1 */ @@ -74,5 +74,4 @@ public interface IASTDoStatement extends IASTStatement { */ @Override public IASTDoStatement copy(CopyStyle style); - } diff --git a/core/org.eclipse.cdt.core/parser/org/eclipse/cdt/core/dom/ast/IASTNameOwner.java b/core/org.eclipse.cdt.core/parser/org/eclipse/cdt/core/dom/ast/IASTNameOwner.java index f535fc805fa..16e60500a17 100644 --- a/core/org.eclipse.cdt.core/parser/org/eclipse/cdt/core/dom/ast/IASTNameOwner.java +++ b/core/org.eclipse.cdt.core/parser/org/eclipse/cdt/core/dom/ast/IASTNameOwner.java @@ -14,12 +14,11 @@ package org.eclipse.cdt.core.dom.ast; /** * This interface represents a mechanism for a name to discover more information about it's parent. * All interfaces that claim ownership/residence of a name should extend this interface. - * + * * @noextend This interface is not intended to be extended by clients. * @noimplement This interface is not intended to be implemented by clients. */ public interface IASTNameOwner { - /** * Role of name in this context is a declaration. */ @@ -28,22 +27,21 @@ public interface IASTNameOwner { * Role of name in this construct is a reference. */ public static final int r_reference = 1; - + /** - * Role of name in this construct is a definition. + * Role of name in this construct is a definition. */ public static final int r_definition = 2; /** * Role is unclear. */ - public static final int r_unclear = 3; - + public static final int r_unclear = 3; + /** - * Get the role for the name. - * + * Get the role for the name. + * * @param name the name to determine the role for. * @return r_definition, r_declaration, r_reference or r_unclear. */ public int getRoleForName(IASTName name); - } diff --git a/core/org.eclipse.cdt.core/parser/org/eclipse/cdt/core/dom/ast/IASTStatement.java b/core/org.eclipse.cdt.core/parser/org/eclipse/cdt/core/dom/ast/IASTStatement.java index e1ed40c0af9..9b4b64a3acb 100644 --- a/core/org.eclipse.cdt.core/parser/org/eclipse/cdt/core/dom/ast/IASTStatement.java +++ b/core/org.eclipse.cdt.core/parser/org/eclipse/cdt/core/dom/ast/IASTStatement.java @@ -6,7 +6,7 @@ * http://www.eclipse.org/legal/epl-v10.html * * Contributors: - * Doug Schaefer (IBM) - Initial API and implementation + * Doug Schaefer (IBM) - Initial API and implementation *******************************************************************************/ package org.eclipse.cdt.core.dom.ast; @@ -33,5 +33,4 @@ public interface IASTStatement extends IASTNode { */ @Override public IASTStatement copy(CopyStyle style); - } diff --git a/core/org.eclipse.cdt.core/parser/org/eclipse/cdt/core/dom/ast/IASTSwitchStatement.java b/core/org.eclipse.cdt.core/parser/org/eclipse/cdt/core/dom/ast/IASTSwitchStatement.java index d98fbf5b7ed..dcc3c226944 100644 --- a/core/org.eclipse.cdt.core/parser/org/eclipse/cdt/core/dom/ast/IASTSwitchStatement.java +++ b/core/org.eclipse.cdt.core/parser/org/eclipse/cdt/core/dom/ast/IASTSwitchStatement.java @@ -6,7 +6,7 @@ * http://www.eclipse.org/legal/epl-v10.html * * Contributors: - * Doug Schaefer (IBM) - Initial API and implementation + * Doug Schaefer (IBM) - Initial API and implementation *******************************************************************************/ package org.eclipse.cdt.core.dom.ast; @@ -17,7 +17,6 @@ package org.eclipse.cdt.core.dom.ast; * @noimplement This interface is not intended to be implemented by clients. */ public interface IASTSwitchStatement extends IASTStatement { - /** * CONTROLLER_EXP represents the relationship between an * IASTSwitchStatement and it's nested diff --git a/core/org.eclipse.cdt.core/parser/org/eclipse/cdt/core/dom/ast/IBinding.java b/core/org.eclipse.cdt.core/parser/org/eclipse/cdt/core/dom/ast/IBinding.java index 6f32a398fbb..99ccc8589c1 100644 --- a/core/org.eclipse.cdt.core/parser/org/eclipse/cdt/core/dom/ast/IBinding.java +++ b/core/org.eclipse.cdt.core/parser/org/eclipse/cdt/core/dom/ast/IBinding.java @@ -6,8 +6,8 @@ * http://www.eclipse.org/legal/epl-v10.html * * Contributors: - * IBM - Initial API and implementation - * Markus Schorn (Wind River Systems) + * IBM - Initial API and implementation + * Markus Schorn (Wind River Systems) *******************************************************************************/ package org.eclipse.cdt.core.dom.ast; @@ -21,7 +21,7 @@ import org.eclipse.core.runtime.IAdaptable; /** * Represents the semantics of a name found in the AST or the index. - * + * * @noextend This interface is not intended to be extended by clients. * @noimplement This interface is not intended to be implemented by clients. */ @@ -32,33 +32,33 @@ public interface IBinding extends IAdaptable { * Returns the unqualified name of the binding as a string. */ public String getName(); - + /** * Returns the unqualified name of the binding as an array of characters. */ public char[] getNameCharArray(); - + /** * Returns the linkage the binding belongs to. C++-declarations declared as * extern "C" will still return c++-linkage. */ public ILinkage getLinkage(); - + /** * Returns the binding that owns this binding, or null if there is no owner. *

* The owner is determined as follows: - *
{@link ICPPUsingDeclaration}: The owner depends on where the declaration is found, within a - * function or method, a class-type, a namespace or on global scope. + *
{@link ICPPUsingDeclaration}: The owner depends on where the declaration is found, within a + * function or method, a class-type, a namespace or on global scope. *
{@link ICPPTemplateParameter}: The owner is the {@link ICPPTemplateDefinition}. - *
{@link IEnumerator}: The owner is the {@link IEnumeration}, independent of whether they are scoped or not. + *
{@link IEnumerator}: The owner is the {@link IEnumeration}, independent of whether they are scoped or not. *
For all other bindings: The owner depends on where the binding can be defined (it could be - * declared else where). + * declared else where). *

Possible owners are: *
{@link IFunction}: for parameters, local types, variables, enumerators, labels and using declarations; - *
{@link ICPPClassType}: for class-, struct- and union-members, even if the composite type is anonymous; + *
{@link ICPPClassType}: for class-, struct- and union-members, even if the composite type is anonymous; * also for enumerators and using declarations; - *
{@link ICompositeType}: for struct- and union-members, even if the composite type is anonymous; + *
{@link ICompositeType}: for struct- and union-members, even if the composite type is anonymous; * also for anonymous structs or unions found within another struct; *
{@link ICPPNamespace}: for global types, functions, variables, enumerators, namespaces and using declarations; *
{@link IEnumeration}: for enumerators. @@ -66,10 +66,10 @@ public interface IBinding extends IAdaptable { * @since 5.1 */ public IBinding getOwner(); - + /** * Returns the parent scope for this binding. A binding may have declarations in multiple scopes, - * this method returns the scope where the binding would potentially be defined. + * this method returns the scope where the binding would potentially be defined. */ public IScope getScope() throws DOMException; } diff --git a/core/org.eclipse.cdt.core/parser/org/eclipse/cdt/core/dom/ast/cpp/ICPPASTQualifiedName.java b/core/org.eclipse.cdt.core/parser/org/eclipse/cdt/core/dom/ast/cpp/ICPPASTQualifiedName.java index d5c72f49e73..103b8c65d9d 100644 --- a/core/org.eclipse.cdt.core/parser/org/eclipse/cdt/core/dom/ast/cpp/ICPPASTQualifiedName.java +++ b/core/org.eclipse.cdt.core/parser/org/eclipse/cdt/core/dom/ast/cpp/ICPPASTQualifiedName.java @@ -6,7 +6,7 @@ * http://www.eclipse.org/legal/epl-v10.html * * Contributors: - * John Camelon (IBM) - Initial API and implementation + * John Camelon (IBM) - Initial API and implementation *******************************************************************************/ package org.eclipse.cdt.core.dom.ast.cpp; @@ -16,12 +16,11 @@ import org.eclipse.cdt.core.dom.ast.IASTNameOwner; /** * This interface is a qualified name in C++. - * + * * @noextend This interface is not intended to be extended by clients. * @noimplement This interface is not intended to be implemented by clients. */ public interface ICPPASTQualifiedName extends IASTName, IASTNameOwner { - /** * Each IASTName segment has property being SEGMENT_NAME. */ @@ -30,48 +29,44 @@ public interface ICPPASTQualifiedName extends IASTName, IASTNameOwner { /** * Add a subname. - * - * @param name - * IASTName + * + * @param name IASTName */ public void addName(IASTName name); /** * Get all subnames. - * + * * @return IASTName [] */ public IASTName[] getNames(); /** * The last name is often semantically significant. - * */ @Override public IASTName getLastName(); - + /** * Is this name fully qualified? - * + * * @return boolean */ public boolean isFullyQualified(); /** * Set this name to be fully qualified or not (true/false). - * - * @param value - * boolean + * + * @param value boolean */ public void setFullyQualified(boolean value); - + /** * This is used to check if the ICPPASTQualifiedName's last segment is * an ICPPASTConversionName or an ICPPASTOperatorName. - * */ public boolean isConversionOrOperator(); - + /** * @since 5.1 */ diff --git a/core/org.eclipse.cdt.core/parser/org/eclipse/cdt/core/dom/ast/cpp/ICPPASTRangeBasedForStatement.java b/core/org.eclipse.cdt.core/parser/org/eclipse/cdt/core/dom/ast/cpp/ICPPASTRangeBasedForStatement.java index 7a47c036c27..d5b85eb9663 100644 --- a/core/org.eclipse.cdt.core/parser/org/eclipse/cdt/core/dom/ast/cpp/ICPPASTRangeBasedForStatement.java +++ b/core/org.eclipse.cdt.core/parser/org/eclipse/cdt/core/dom/ast/cpp/ICPPASTRangeBasedForStatement.java @@ -6,9 +6,8 @@ * http://www.eclipse.org/legal/epl-v10.html * * Contributors: - * Markus Schorn - initial API and implementation - *******************************************************************************/ - + * Markus Schorn - initial API and implementation + *******************************************************************************/ package org.eclipse.cdt.core.dom.ast.cpp; import org.eclipse.cdt.core.dom.ast.ASTNodeProperty; @@ -20,7 +19,7 @@ import org.eclipse.cdt.core.dom.ast.IScope; /** * Represents a range-based for loop. - * + * * @noextend This interface is not intended to be extended by clients. * @noimplement This interface is not intended to be implemented by clients. * @since 5.3 @@ -33,17 +32,16 @@ public interface ICPPASTRangeBasedForStatement extends IASTStatement, IASTImplic public static final ASTNodeProperty BODY = new ASTNodeProperty( "ICPPASTRangeBasedForStatement.BODY [IASTStatement]"); //$NON-NLS-1$ - /** - * Returns the for-range-declaration + * Returns the for-range-declaration */ IASTDeclaration getDeclaration(); - + /** * Returns the for-range-initializer. */ IASTInitializerClause getInitializerClause(); - + /** * Returns the statement of this for-loop. */ @@ -60,7 +58,6 @@ public interface ICPPASTRangeBasedForStatement extends IASTStatement, IASTImplic @Override public ICPPASTRangeBasedForStatement copy(CopyStyle style); - /** * Not allowed on frozen AST. */ @@ -70,7 +67,7 @@ public interface ICPPASTRangeBasedForStatement extends IASTStatement, IASTImplic * Not allowed on frozen AST. */ void setInitializerClause(IASTInitializerClause statement); - + /** * Not allowed on frozen AST. */ diff --git a/core/org.eclipse.cdt.core/parser/org/eclipse/cdt/internal/core/dom/parser/ASTNode.java b/core/org.eclipse.cdt.core/parser/org/eclipse/cdt/internal/core/dom/parser/ASTNode.java index a5ed9162714..fb53f0d45c8 100644 --- a/core/org.eclipse.cdt.core/parser/org/eclipse/cdt/internal/core/dom/parser/ASTNode.java +++ b/core/org.eclipse.cdt.core/parser/org/eclipse/cdt/internal/core/dom/parser/ASTNode.java @@ -8,7 +8,7 @@ * Contributors: * John Camelon - Initial API and implementation * Markus Schorn (Wind River Systems) - * Sergey Prigoin (Google) + * Sergey Prigogin (Google) *******************************************************************************/ package org.eclipse.cdt.internal.core.dom.parser; @@ -51,60 +51,60 @@ public abstract class ASTNode implements IASTNode { private boolean frozen = false; private boolean active = true; - + @Override public IASTNode getParent() { return parent; } - + @Override public IASTNode[] getChildren() { ChildCollector collector= new ChildCollector(this); return collector.getChildren(); } - + @Override public boolean isFrozen() { return frozen; } - + @Override public boolean isActive() { return active; } - + void setIsFrozen() { frozen = true; } - + public void setInactive() { if (frozen) throw new IllegalStateException("attempt to modify frozen AST node"); //$NON-NLS-1$ active= false; } - + protected void assertNotFrozen() throws IllegalStateException { if (frozen) throw new IllegalStateException("attempt to modify frozen AST node"); //$NON-NLS-1$ } - + @Override public void setParent(IASTNode node) { assertNotFrozen(); this.parent = node; } - + @Override public ASTNodeProperty getPropertyInParent() { return property; } - + @Override public void setPropertyInParent(ASTNodeProperty property) { assertNotFrozen(); this.property = property; } - + public int getOffset() { return offset; } @@ -219,7 +219,7 @@ public abstract class ASTNode implements IASTNode { } return fileLocation; } - + @Override public boolean isPartOfTranslationUnitFile() { IASTTranslationUnit ast = getTranslationUnit(); @@ -231,7 +231,7 @@ public abstract class ASTNode implements IASTNode { } return false; } - + public boolean isPartOfSourceFile() { IASTTranslationUnit ast = getTranslationUnit(); if (ast != null) { @@ -242,7 +242,7 @@ public abstract class ASTNode implements IASTNode { } return false; } - + @Override public IASTTranslationUnit getTranslationUnit() { return parent != null ? parent.getTranslationUnit() : null; @@ -252,7 +252,7 @@ public abstract class ASTNode implements IASTNode { public boolean accept(ASTVisitor visitor) { return true; } - + @Override public boolean contains(IASTNode node) { if (node instanceof ASTNode) { @@ -281,7 +281,7 @@ public abstract class ASTNode implements IASTNode { int right= getBoundary(1); return getSyntax(getOffset() + length, right, 1); } - + /** * Compute the sequence number of the boundary of the leading/trailing syntax. */ @@ -306,45 +306,45 @@ public abstract class ASTNode implements IASTNode { private IToken getSyntax(int fromSequenceNumber, int nextSequenceNumber, int direction) throws ExpansionOverlapsBoundaryException { final IASTTranslationUnit tu= getTranslationUnit(); - if (!(tu instanceof ASTNode)) - throw new UnsupportedOperationException(); - - ILocationResolver lr= (ILocationResolver) tu.getAdapter(ILocationResolver.class); - if (lr == null) + if (!(tu instanceof ASTNode)) throw new UnsupportedOperationException(); - int endSequenceNumber= lr.convertToSequenceEndNumber(nextSequenceNumber); + ILocationResolver lr= (ILocationResolver) tu.getAdapter(ILocationResolver.class); + if (lr == null) + throw new UnsupportedOperationException(); + + int endSequenceNumber= lr.convertToSequenceEndNumber(nextSequenceNumber); IASTFileLocation total= lr.getMappedFileLocation(fromSequenceNumber, endSequenceNumber - fromSequenceNumber); IASTFileLocation myfloc= getFileLocation(); if (total == null || myfloc == null) throw new UnsupportedOperationException(); - + if (!total.getFileName().equals(myfloc.getFileName())) throw new ExpansionOverlapsBoundaryException(); if (fromSequenceNumber > 0) { IASTFileLocation fl= lr.getMappedFileLocation(fromSequenceNumber-1, endSequenceNumber - fromSequenceNumber + 1); - if (fl.getFileName().equals(total.getFileName()) && fl.getNodeOffset() == total.getNodeOffset()) + if (fl.getFileName().equals(total.getFileName()) && fl.getNodeOffset() == total.getNodeOffset()) throw new ExpansionOverlapsBoundaryException(); } - + if (endSequenceNumber < ((ASTNode) tu).getOffset() + ((ASTNode) tu).getLength()) { IASTFileLocation fl= lr.getMappedFileLocation(fromSequenceNumber, nextSequenceNumber - fromSequenceNumber + 1); - if (fl.getFileName().equals(total.getFileName()) && fl.getNodeLength() == total.getNodeLength()) + if (fl.getFileName().equals(total.getFileName()) && fl.getNodeLength() == total.getNodeLength()) throw new ExpansionOverlapsBoundaryException(); } - + int adjustment= total.getNodeOffset() - myfloc.getNodeOffset(); if (direction > 0) { adjustment-= myfloc.getNodeLength(); - } + } char[] txt= lr.getUnpreprocessedSignature(total); Lexer lex= new Lexer(txt, (LexerOptions) tu.getAdapter(LexerOptions.class), ILexerLog.NULL, null); try { - Token result= null; + Token result= null; Token last= null; - while (true) { + while (true) { Token t= lex.nextToken(); switch (t.getType()) { case IToken.tEND_OF_INPUT: diff --git a/core/org.eclipse.cdt.core/parser/org/eclipse/cdt/internal/core/dom/parser/ASTNodeSpecification.java b/core/org.eclipse.cdt.core/parser/org/eclipse/cdt/internal/core/dom/parser/ASTNodeSpecification.java index b3f438cd6b9..e36614cb2a6 100644 --- a/core/org.eclipse.cdt.core/parser/org/eclipse/cdt/internal/core/dom/parser/ASTNodeSpecification.java +++ b/core/org.eclipse.cdt.core/parser/org/eclipse/cdt/internal/core/dom/parser/ASTNodeSpecification.java @@ -7,7 +7,7 @@ * * Contributors: * Markus Schorn - initial API and implementation - *******************************************************************************/ + *******************************************************************************/ package org.eclipse.cdt.internal.core.dom.parser; import org.eclipse.cdt.core.dom.ast.IASTFileLocation; @@ -17,13 +17,13 @@ import org.eclipse.cdt.core.dom.ast.IASTNode; import org.eclipse.cdt.core.dom.ast.IASTPreprocessorMacroExpansion; /** - * For searching ast-nodes by offset and length, instances of this class can be used to + * For searching ast-nodes by offset and length, instances of this class can be used to * determine whether a node matches or not. * * @since 5.0 */ public class ASTNodeSpecification { - public enum Relation {FIRST_CONTAINED, EXACT_MATCH, ENCLOSING, STRICTLY_ENCLOSING} + public enum Relation { FIRST_CONTAINED, EXACT_MATCH, ENCLOSING, STRICTLY_ENCLOSING } private final Class fClass; private final Relation fRelation; @@ -36,7 +36,7 @@ public class ASTNodeSpecification { private T fBestNode; private boolean fSearchInExpansion; private boolean fZeroToLeft= false; - + public ASTNodeSpecification(Relation relation, Class clazz, int fileOffset, int fileLength) { fRelation= relation; fClass= clazz; @@ -53,7 +53,7 @@ public class ASTNodeSpecification { setRangeInSequence(offsetInSeq, lengthInSeq); fZeroToLeft= zeroRangeToLeft; } - + public void setSearchInExpansion(boolean searchInExpansion) { fSearchInExpansion= searchInExpansion; } @@ -77,7 +77,7 @@ public class ASTNodeSpecification { public boolean requiresClass(Class clazz) { return clazz.isAssignableFrom(fClass); } - + @SuppressWarnings("unchecked") public void visit(ASTNode astNode) { if (isAcceptableNode(astNode) && isMatchingRange(astNode.getOffset(), astNode.getLength(), fSeqNumber, fSeqEndNumber)) { @@ -87,6 +87,7 @@ public class ASTNodeSpecification { } } } + @SuppressWarnings("unchecked") public void visit(ASTNode astNode, IASTImageLocation imageLocation) { if (isAcceptableNode(astNode) && imageLocation != null) { @@ -109,16 +110,16 @@ public class ASTNodeSpecification { if (offset <= selOffset && selEndOffset <= endOffset) { return offset != selOffset || selEndOffset != endOffset; } - return false; + return false; } assert false; return false; } public boolean isAcceptableNode(IASTNode astNode) { - if (astNode == null || !fClass.isAssignableFrom(astNode.getClass())) + if (astNode == null || !fClass.isAssignableFrom(astNode.getClass())) return false; - + if (fSearchInExpansion) { IASTNode check= astNode instanceof IASTName ? astNode.getParent() : astNode; if (check instanceof IASTPreprocessorMacroExpansion) { @@ -129,7 +130,7 @@ public class ASTNodeSpecification { } /** - * Returns whether the node can contain matches in its range. + * Returns whether the node can contain matches in its range. */ public boolean canContainMatches(ASTNode node) { final int offset= node.getOffset(); @@ -142,7 +143,7 @@ public class ASTNodeSpecification { if (offset <= fSeqNumber && fSeqEndNumber <= endOffset) { return offset != fSeqNumber || fSeqEndNumber != endOffset; } - return false; + return false; case FIRST_CONTAINED: return offset <= fSeqEndNumber && fSeqNumber <= endOffset; } @@ -163,14 +164,14 @@ public class ASTNodeSpecification { } /** - * Assuming that the given range matches, this method returns whether the match is better + * Assuming that the given range matches, this method returns whether the match is better * than the best match stored. */ private boolean isBetterMatch(int offset, int length, IASTNode cand) { if (fBestNode == null) { return true; } - + final int endOffset= offset+length; switch(fRelation) { case EXACT_MATCH: @@ -186,8 +187,8 @@ public class ASTNodeSpecification { return endOffset == fBestEndOffset && isParent(fBestNode, cand); } return false; - case ENCLOSING: - case STRICTLY_ENCLOSING: + case ENCLOSING: + case STRICTLY_ENCLOSING: final int bestLength= fBestEndOffset-fBestOffset; if (length < bestLength) { return true; @@ -213,7 +214,7 @@ public class ASTNodeSpecification { IASTPreprocessorMacroExpansion exp= nodeSelector.findEnclosingMacroExpansion(fZeroToLeft ? fFileOffset-1 : fFileOffset, 1); if (fRelation == Relation.ENCLOSING || fRelation == Relation.STRICTLY_ENCLOSING) return exp; - + if (exp != null) { IASTFileLocation loc= exp.getFileLocation(); if (loc != null) { @@ -230,7 +231,7 @@ public class ASTNodeSpecification { IASTPreprocessorMacroExpansion exp= nodeSelector.findEnclosingMacroExpansion(fFileEndOffset==fFileOffset && !fZeroToLeft ? fFileEndOffset : fFileEndOffset-1, 1); if (fRelation == Relation.ENCLOSING || fRelation == Relation.STRICTLY_ENCLOSING) return exp; - + if (exp != null) { IASTFileLocation loc= exp.getFileLocation(); if (loc != null) { diff --git a/core/org.eclipse.cdt.core/parser/org/eclipse/cdt/internal/core/dom/parser/cpp/CPPASTBreakStatement.java b/core/org.eclipse.cdt.core/parser/org/eclipse/cdt/internal/core/dom/parser/cpp/CPPASTBreakStatement.java index f498af4e8ec..00f026ed1a5 100644 --- a/core/org.eclipse.cdt.core/parser/org/eclipse/cdt/internal/core/dom/parser/cpp/CPPASTBreakStatement.java +++ b/core/org.eclipse.cdt.core/parser/org/eclipse/cdt/internal/core/dom/parser/cpp/CPPASTBreakStatement.java @@ -6,7 +6,7 @@ * http://www.eclipse.org/legal/epl-v10.html * * Contributors: - * IBM - Initial API and implementation + * IBM - Initial API and implementation *******************************************************************************/ package org.eclipse.cdt.internal.core.dom.parser.cpp; @@ -18,24 +18,22 @@ import org.eclipse.cdt.internal.core.dom.parser.ASTNode; * @author jcamelon */ public class CPPASTBreakStatement extends ASTNode implements IASTBreakStatement { - @Override - public boolean accept( ASTVisitor action ){ - if( action.shouldVisitStatements ){ - 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.shouldVisitStatements) { + switch (action.visit(this)) { + case ASTVisitor.PROCESS_ABORT: return false; + case ASTVisitor.PROCESS_SKIP: return true; + default: break; } } - if( action.shouldVisitStatements ){ - switch( action.leave( this ) ){ - case ASTVisitor.PROCESS_ABORT : return false; - case ASTVisitor.PROCESS_SKIP : return true; - default : break; + if (action.shouldVisitStatements) { + switch (action.leave(this)) { + case ASTVisitor.PROCESS_ABORT: return false; + case ASTVisitor.PROCESS_SKIP: return true; + default: break; } } - return true; } diff --git a/core/org.eclipse.cdt.core/parser/org/eclipse/cdt/internal/core/dom/parser/cpp/CPPASTReturnStatement.java b/core/org.eclipse.cdt.core/parser/org/eclipse/cdt/internal/core/dom/parser/cpp/CPPASTReturnStatement.java index b4865d47f60..192e9624a0f 100644 --- a/core/org.eclipse.cdt.core/parser/org/eclipse/cdt/internal/core/dom/parser/cpp/CPPASTReturnStatement.java +++ b/core/org.eclipse.cdt.core/parser/org/eclipse/cdt/internal/core/dom/parser/cpp/CPPASTReturnStatement.java @@ -6,8 +6,8 @@ * http://www.eclipse.org/legal/epl-v10.html * * Contributors: - * John Camelon (IBM) - Initial API and implementation - * Markus Schorn (Wind River Systems) + * John Camelon (IBM) - Initial API and implementation + * Markus Schorn (Wind River Systems) *******************************************************************************/ package org.eclipse.cdt.internal.core.dom.parser.cpp; @@ -20,9 +20,8 @@ import org.eclipse.cdt.internal.core.dom.parser.ASTNode; import org.eclipse.cdt.internal.core.dom.parser.IASTAmbiguityParent; public class CPPASTReturnStatement extends ASTNode implements IASTReturnStatement, IASTAmbiguityParent { - private IASTInitializerClause retValue; - + public CPPASTReturnStatement() { } @@ -34,11 +33,11 @@ public class CPPASTReturnStatement extends ASTNode implements IASTReturnStatemen public CPPASTReturnStatement copy() { return copy(CopyStyle.withoutLocations); } - + @Override public CPPASTReturnStatement copy(CopyStyle style) { - CPPASTReturnStatement copy = new CPPASTReturnStatement(retValue == null ? null - : retValue.copy(style)); + CPPASTReturnStatement copy = + new CPPASTReturnStatement(retValue == null ? null : retValue.copy(style)); copy.setOffsetAndLength(this); if (style == CopyStyle.withLocations) { copy.setCopyLocation(this); @@ -50,7 +49,7 @@ public class CPPASTReturnStatement extends ASTNode implements IASTReturnStatemen public IASTInitializerClause getReturnArgument() { return retValue; } - + @Override public IASTExpression getReturnValue() { if (retValue instanceof IASTExpression) { @@ -59,12 +58,11 @@ public class CPPASTReturnStatement extends ASTNode implements IASTReturnStatemen return null; } - @Override public void setReturnValue(IASTExpression returnValue) { setReturnArgument(returnValue); } - + @Override public void setReturnArgument(IASTInitializerClause arg) { assertNotFrozen(); @@ -89,12 +87,12 @@ public class CPPASTReturnStatement extends ASTNode implements IASTReturnStatemen } if (retValue != null && !retValue.accept(action)) return false; - - if( action.shouldVisitStatements ){ - switch( action.leave( this ) ){ - case ASTVisitor.PROCESS_ABORT : return false; - case ASTVisitor.PROCESS_SKIP : return true; - default : break; + + if (action.shouldVisitStatements) { + switch (action.leave(this)) { + case ASTVisitor.PROCESS_ABORT: return false; + case ASTVisitor.PROCESS_SKIP: return true; + default: break; } } return true; diff --git a/core/org.eclipse.cdt.core/parser/org/eclipse/cdt/internal/core/dom/parser/cpp/semantics/CPPVisitor.java b/core/org.eclipse.cdt.core/parser/org/eclipse/cdt/internal/core/dom/parser/cpp/semantics/CPPVisitor.java index d186b557474..c878789dff1 100644 --- a/core/org.eclipse.cdt.core/parser/org/eclipse/cdt/internal/core/dom/parser/cpp/semantics/CPPVisitor.java +++ b/core/org.eclipse.cdt.core/parser/org/eclipse/cdt/internal/core/dom/parser/cpp/semantics/CPPVisitor.java @@ -19,13 +19,6 @@ import static org.eclipse.cdt.internal.core.dom.parser.cpp.semantics.SemanticUti import static org.eclipse.cdt.internal.core.dom.parser.cpp.semantics.SemanticUtil.getNestedType; import static org.eclipse.cdt.internal.core.dom.parser.cpp.semantics.SemanticUtil.getUltimateTypeUptoPointers; -import java.util.ArrayList; -import java.util.Arrays; -import java.util.Collections; -import java.util.HashSet; -import java.util.List; -import java.util.Set; - import org.eclipse.cdt.core.dom.ast.ASTGenericVisitor; import org.eclipse.cdt.core.dom.ast.ASTNodeProperty; import org.eclipse.cdt.core.dom.ast.ASTVisitor; @@ -199,6 +192,13 @@ import org.eclipse.cdt.internal.core.dom.parser.cpp.ICPPInternalBinding; import org.eclipse.cdt.internal.core.dom.parser.cpp.ICPPUnknownBinding; import org.eclipse.cdt.internal.core.index.IIndexScope; +import java.util.ArrayList; +import java.util.Arrays; +import java.util.Collections; +import java.util.HashSet; +import java.util.List; +import java.util.Set; + /** * Collection of methods to extract information from a C++ translation unit. */ @@ -207,7 +207,7 @@ public class CPPVisitor extends ASTQueries { private static final CPPBasicType INT_TYPE = new CPPBasicType(Kind.eInt, 0); public static final String BEGIN_STR = "begin"; //$NON-NLS-1$ - public static final char[] BEGIN = BEGIN_STR.toCharArray(); + public static final char[] BEGIN = BEGIN_STR.toCharArray(); public static final char[] END = "end".toCharArray(); //$NON-NLS-1$ static final String STD = "std"; //$NON-NLS-1$ private static final char[] SIZE_T = "size_t".toCharArray(); //$NON-NLS-1$ @@ -227,7 +227,7 @@ public class CPPVisitor extends ASTQueries { return new HashSet(); } }; - + public static IBinding createBinding(IASTName name) { IASTNode parent = name.getParent(); IBinding binding = null; @@ -237,8 +237,8 @@ public class CPPVisitor extends ASTQueries { name.getPropertyInParent() == ICPPASTNamespaceAlias.MAPPING_NAME) { if (name.getLookupKey().length == 0) return null; - - return CPPSemantics.resolveBinding(name); + + return CPPSemantics.resolveBinding(name); } else if (parent instanceof ICPPASTQualifiedName) { if (name.getLookupKey().length == 0) return null; @@ -246,7 +246,7 @@ public class CPPVisitor extends ASTQueries { final ICPPASTQualifiedName qname = (ICPPASTQualifiedName) parent; if (name != qname.getLastName()) return CPPSemantics.resolveBinding(name); - + parent = parent.getParent(); if (!declaresMemberInClassOrNamespace(qname)) { binding = CPPSemantics.resolveBinding(name); @@ -264,8 +264,8 @@ public class CPPVisitor extends ASTQueries { } else if (parent instanceof ICPPASTTemplateId) { final ICPPASTTemplateId id = (ICPPASTTemplateId) parent; if (CPPTemplates.isClassTemplate(id)) - return CPPSemantics.resolveBinding(name); - + return CPPSemantics.resolveBinding(name); + // function templates/instances/specializations must be resolved via the id id.resolveBinding(); return name.getBinding(); @@ -293,21 +293,21 @@ public class CPPVisitor extends ASTQueries { } else if (parent instanceof ICPPASTTemplateParameter) { return CPPTemplates.createBinding((ICPPASTTemplateParameter) parent); } - + if (name.getLookupKey().length > 0) return binding; return null; } - + private static boolean declaresMemberInClassOrNamespace(ICPPASTQualifiedName qname) { IASTName[] names= qname.getNames(); if (names.length < 2) return false; - + IBinding pb= names[names.length-2].resolvePreBinding(); - if (pb instanceof IProblemBinding) + if (pb instanceof IProblemBinding) return false; - + IScope scope= null; if (pb instanceof IType) { IType t= SemanticUtil.getNestedType((IType) pb, TDEF); @@ -316,7 +316,7 @@ public class CPPVisitor extends ASTQueries { } } else if (pb instanceof ICPPNamespace) { scope= ((ICPPNamespace)pb).getNamespaceScope(); - } + } if (scope == null) return false; @@ -331,17 +331,17 @@ public class CPPVisitor extends ASTQueries { ASTNodeProperty prop = decl.getPropertyInParent(); if (prop == IASTCompositeTypeSpecifier.MEMBER_DECLARATION) { return scope == ((ICPPASTCompositeTypeSpecifier) decl.getParent()).getScope(); - } + } if (prop == ICPPASTNamespaceDefinition.OWNED_DECLARATION) { return scope == ((ICPPASTNamespaceDefinition) decl.getParent()).getScope(); - } - - if (prop == ICPPASTTemplateDeclaration.OWNED_DECLARATION) { + } + + if (prop == ICPPASTTemplateDeclaration.OWNED_DECLARATION) { decl= decl.getParent(); } else { return false; - } - } + } + } return false; } @@ -354,10 +354,10 @@ public class CPPVisitor extends ASTQueries { binding = new CPPLabel(name); ASTInternal.addName(functionScope, name); } - + return binding; } - + private static IBinding createBinding(IASTLabelStatement labelStatement) { ICPPFunctionScope functionScope = (ICPPFunctionScope) getContainingScope(labelStatement.getName()); IASTName name = labelStatement.getName(); @@ -369,10 +369,10 @@ public class CPPVisitor extends ASTQueries { } else { ((CPPLabel) binding).setLabelStatement(name); } - + return binding; } - + private static IBinding createBinding(IASTEnumerator enumerator) { ICPPScope scope = (ICPPScope) getContainingScope(enumerator); IBinding enumtor; @@ -380,7 +380,7 @@ public class CPPVisitor extends ASTQueries { if (enumtor == null || !(enumtor instanceof IEnumerator)) { enumtor = new CPPEnumerator(enumerator.getName()); } - + return enumtor; } @@ -405,7 +405,7 @@ public class CPPVisitor extends ASTQueries { } } return new ProblemBinding(name, IProblemBinding.SEMANTIC_INVALID_REDECLARATION); - } + } return new CPPEnumeration(specifier, fixedType); } @@ -443,7 +443,7 @@ public class CPPVisitor extends ASTQueries { } else { mustBeSimple = false; } - } else if (parent instanceof IASTParameterDeclaration || + } else if (parent instanceof IASTParameterDeclaration || parent instanceof IASTDeclaration || parent instanceof IASTTypeId) { binding = CPPSemantics.resolveBinding(elabType.getName()); @@ -452,27 +452,27 @@ public class CPPVisitor extends ASTQueries { binding= ((CPPASTTranslationUnit) elabType.getTranslationUnit()).mapToAST((ICPPClassType) binding); ASTInternal.addDeclaration(binding, elabType); } - - if (binding != null && + + if (binding != null && (!(binding instanceof IProblemBinding) || ((IProblemBinding) binding).getID() != IProblemBinding.SEMANTIC_NAME_NOT_FOUND)) { return binding; } - + // 7.1.5.3-2 ... If name lookup does not find a declaration for the name, the elaborated-type-specifier is ill-formed // unless it is of the simple form class-key identifier - if (mustBeSimple && + if (mustBeSimple && (elabType.getName() instanceof ICPPASTQualifiedName || elabType.getKind() == IASTElaboratedTypeSpecifier.k_enum)) { return binding; } - + try { ICPPASTTemplateDeclaration templateDecl = CPPTemplates.getTemplateDeclaration(name); ICPPScope scope = (ICPPScope) getContainingScope(name); while (scope instanceof ICPPTemplateScope) { scope= (ICPPScope) scope.getParent(); } - + if (mustBeSimple) { // 3.3.1-5 ... the identifier is declared in the smallest non-class non-function-prototype scope that contains // the declaration @@ -496,7 +496,7 @@ public class CPPVisitor extends ASTQueries { if (binding instanceof ICPPInternalBinding) { if (!name.isActive()) return binding; - + if (binding instanceof ICPPClassType) { final ICPPInternalBinding ib = (ICPPInternalBinding) binding; if (templateParametersMatch((ICPPClassType) binding, templateDecl)) { @@ -508,9 +508,9 @@ public class CPPVisitor extends ASTQueries { return new ProblemBinding(name, IProblemBinding.SEMANTIC_INVALID_REDECLARATION); } markRedeclaration(ib); - } + } } - + // Create a binding if (elabType.getKind() != IASTElaboratedTypeSpecifier.k_enum) { if (templateDecl != null) @@ -523,7 +523,7 @@ public class CPPVisitor extends ASTQueries { } catch (DOMException e) { binding = e.getProblem(); } - + return binding; } @@ -555,10 +555,10 @@ public class CPPVisitor extends ASTQueries { return !isTemplate; if (!isTemplate) return false; - + ICPPTemplateParameter[] pars1 = ((ICPPClassTemplate) binding).getTemplateParameters(); ICPPASTTemplateParameter[] pars2 = templateDecl.getTemplateParameters(); - + int i=0; for (ICPPASTTemplateParameter p2 : pars2) { if (i >= pars1.length) @@ -576,9 +576,9 @@ public class CPPVisitor extends ASTQueries { IASTName[] ns = ((ICPPASTQualifiedName) name).getNames(); name = ns[ns.length - 1]; } - if (name instanceof ICPPASTTemplateId) + if (name instanceof ICPPASTTemplateId) return CPPTemplates.createBinding((ICPPASTTemplateId) name); - + ICPPScope scope = (ICPPScope) getContainingScope(name); try { while (scope instanceof ICPPTemplateScope) { @@ -587,40 +587,40 @@ public class CPPVisitor extends ASTQueries { } catch (DOMException e) { return e.getProblem(); } - + // Can't lookup anonymous names IBinding binding= null; ICPPASTTemplateDeclaration templateDecl = CPPTemplates.getTemplateDeclaration(name); - if (name.getLookupKey().length > 0 && scope != null) { + if (name.getLookupKey().length > 0 && scope != null) { binding = scope.getBinding(name, false); - if (binding instanceof ICPPInternalBinding + if (binding instanceof ICPPInternalBinding && binding instanceof ICPPClassType && name.isActive()) { ICPPInternalBinding ib = (ICPPInternalBinding) binding; - if (ib.getDefinition() == null + if (ib.getDefinition() == null && templateParametersMatch((ICPPClassType) binding, templateDecl)) { ASTInternal.addDefinition(ib, compType); return binding; - } + } if (CPPSemantics.declaredBefore(ib, name, false)) { return new ProblemBinding(name, IProblemBinding.SEMANTIC_INVALID_REDEFINITION); } markRedeclaration(ib); } } - if (templateDecl != null) + if (templateDecl != null) return new CPPClassTemplate(name); return new CPPClassType(name, binding); } - + private static IBinding createBinding(IASTDeclaration declaration) { if (declaration instanceof ICPPASTNamespaceDefinition) { ICPPASTNamespaceDefinition namespaceDef = (ICPPASTNamespaceDefinition) declaration; ICPPScope scope = (ICPPScope) getContainingScope(namespaceDef); IBinding binding; binding = scope.getBinding(namespaceDef.getName(), false); - if (!(binding instanceof ICPPInternalBinding) || binding instanceof IProblemBinding + if (!(binding instanceof ICPPInternalBinding) || binding instanceof IProblemBinding || !(binding instanceof ICPPNamespace)) { binding = new CPPNamespace(namespaceDef); } @@ -639,36 +639,36 @@ public class CPPVisitor extends ASTQueries { namespace = new CPPNamespace.CPPNamespaceProblem(problem.getASTNode(), problem.getID(), alias.getMappingName().toCharArray()); } - if (namespace instanceof ICPPNamespace) { + if (namespace instanceof ICPPNamespace) { binding = new CPPNamespaceAlias(alias.getAlias(), (ICPPNamespace) namespace); } else { binding = new ProblemBinding(alias.getAlias(), IProblemBinding.SEMANTIC_NAME_NOT_FOUND); } } - + return binding; } return null; } - + private static IBinding createBinding(IASTDeclarator declarator) { IASTNode parent = findOutermostDeclarator(declarator).getParent(); declarator= findInnermostDeclarator(declarator); final IASTDeclarator typeRelevantDtor= findTypeRelevantDeclarator(declarator); - + IASTName name= declarator.getName(); if (name instanceof ICPPASTQualifiedName) { name= ((ICPPASTQualifiedName) name).getLastName(); } - + // in case the binding was created starting from another name within the declarator. IBinding candidate= name.getBinding(); if (candidate != null) { return candidate; } - + // function type if (parent instanceof IASTTypeId) return CPPSemantics.resolveBinding(name); @@ -680,20 +680,20 @@ public class CPPVisitor extends ASTQueries { } // explicit instantiations - if (prop == ICPPASTExplicitTemplateInstantiation.OWNED_DECLARATION) + if (prop == ICPPASTExplicitTemplateInstantiation.OWNED_DECLARATION) return CPPSemantics.resolveBinding(name); - + // explicit specializations ICPPASTTemplateDeclaration tmplDecl= CPPTemplates.getTemplateDeclaration(name); if (tmplDecl instanceof ICPPASTTemplateSpecialization) { IBinding b= CPPSemantics.resolveBinding(name); if (parent instanceof ICPPASTFunctionDefinition) { ASTInternal.addDefinition(b, name); - } else { + } else { ASTInternal.addDeclaration(b, name); } return b; - } + } // parameter declarations if (parent instanceof ICPPASTParameterDeclaration) { @@ -701,7 +701,7 @@ public class CPPVisitor extends ASTQueries { parent = param.getParent(); if (parent instanceof IASTStandardFunctionDeclarator) { IASTStandardFunctionDeclarator fdtor = (IASTStandardFunctionDeclarator) param.getParent(); - // Create parameter bindings only if the declarator declares a function + // Create parameter bindings only if the declarator declares a function if (findTypeRelevantDeclarator(fdtor) != fdtor) return null; @@ -709,7 +709,7 @@ public class CPPVisitor extends ASTQueries { if (dtorParent instanceof ICPPASTLambdaExpression) { return new CPPLambdaExpressionParameter(name); } - + if (dtorParent instanceof IASTDeclaration) { IASTParameterDeclaration[] params = fdtor.getParameters(); int i= 0; @@ -746,7 +746,7 @@ public class CPPVisitor extends ASTQueries { if (name.getLookupKey().length != 0 && scope != null) { binding = scope.getBinding(name, forceResolve); } - + boolean isFunction= false; if (parent instanceof ICPPASTFunctionDefinition) { isFunction= true; @@ -794,14 +794,14 @@ public class CPPVisitor extends ASTQueries { binding = new ProblemBinding(name, IProblemBinding.SEMANTIC_INVALID_REDECLARATION); } } else if (simpleDecl.getParent() instanceof ICPPASTCompositeTypeSpecifier) { - binding = new CPPField(name); + binding = new CPPField(name); } else { binding = new CPPVariable(name); } } } - } - + } + if (isFunction) { if (binding instanceof ICPPInternalBinding && binding instanceof ICPPFunction && name.isActive()) { ICPPFunction function = (ICPPFunction) binding; @@ -823,11 +823,11 @@ public class CPPVisitor extends ASTQueries { return new ProblemBinding(name, IProblemBinding.SEMANTIC_INVALID_REDEFINITION); } } - + return function; } - } - + } + if (scope instanceof ICPPClassScope) { if (isConstructor(scope, typeRelevantDtor)) { binding = template ? (ICPPConstructor) new CPPConstructorTemplate(name) @@ -842,7 +842,7 @@ public class CPPVisitor extends ASTQueries { } binding= CPPSemantics.checkDeclSpecifier(binding, name, parent); } - + return binding; } @@ -900,7 +900,7 @@ public class CPPVisitor extends ASTQueries { } } return false; - } + } while (parent != null) { if (parent instanceof ICPPASTCompositeTypeSpecifier) { final char[] className= ((ICPPASTCompositeTypeSpecifier) parent).getName().getLastName().getLookupKey(); @@ -913,11 +913,11 @@ public class CPPVisitor extends ASTQueries { } return false; } - + private static boolean isConstructorDtor(IASTDeclarator declarator) { if (declarator == null || !(declarator instanceof IASTFunctionDeclarator)) return false; - + IASTDeclSpecifier declSpec = null; IASTNode parent = findOutermostDeclarator(declarator).getParent(); if (parent instanceof IASTSimpleDeclaration) { @@ -926,12 +926,12 @@ public class CPPVisitor extends ASTQueries { declSpec = ((IASTFunctionDefinition) parent).getDeclSpecifier(); } if (declSpec != null && declSpec instanceof IASTSimpleDeclSpecifier) { - return (((IASTSimpleDeclSpecifier) declSpec).getType() == IASTSimpleDeclSpecifier.t_unspecified); + return (((IASTSimpleDeclSpecifier) declSpec).getType() == IASTSimpleDeclSpecifier.t_unspecified); } - + return false; } - + public static IScope getContainingNonTemplateScope(final IASTNode inputNode) { IScope scope= getContainingScope(inputNode); while (scope instanceof ICPPTemplateScope) { @@ -939,7 +939,7 @@ public class CPPVisitor extends ASTQueries { } return scope; } - + public static IScope getContainingScope(final IASTNode inputNode) { if (inputNode == null || inputNode instanceof IASTTranslationUnit) return null; @@ -974,12 +974,12 @@ public class CPPVisitor extends ASTQueries { return ((ICPPASTCatchHandler) parent).getScope(); } } else if (node instanceof IASTStatement) { - return getContainingScope((IASTStatement) node); + return getContainingScope((IASTStatement) node); } else if (node instanceof IASTTypeId) { ASTNodeProperty prop = node.getPropertyInParent(); if (prop == ICPPASTTemplateId.TEMPLATE_ID_ARGUMENT || prop == ICPPASTConversionName.TYPE_ID) { node= node.getParent(); // template-id or conversion name - while (node instanceof IASTName) { + while (node instanceof IASTName) { node= node.getParent(); } continue; @@ -1009,7 +1009,7 @@ public class CPPVisitor extends ASTQueries { return binding.getScope(); } catch (DOMException e) { } - } else { + } else { IASTNode parent = node.getParent(); if (parent instanceof IASTDeclarator) { IASTDeclarator dtor = (IASTDeclarator) parent; @@ -1061,7 +1061,7 @@ public class CPPVisitor extends ASTQueries { } else if (parent instanceof ICPPASTTemplateId && node.getPropertyInParent() == ICPPASTTemplateId.TEMPLATE_ID_ARGUMENT) { node= parent; // template-id - while (node instanceof IASTName) { + while (node instanceof IASTName) { node= node.getParent(); } continue; @@ -1081,7 +1081,7 @@ public class CPPVisitor extends ASTQueries { IASTName[] ns = ((ICPPASTQualifiedName) n).getNames(); n = ns[ns.length - 1]; } - + return getContainingScope(n); } else if (node instanceof IASTEnumerator) { node= node.getParent(); @@ -1098,7 +1098,7 @@ public class CPPVisitor extends ASTQueries { } node = node.getParent(); } - return new CPPScope.CPPScopeProblem(inputNode, IProblemBinding.SEMANTIC_BAD_SCOPE, + return new CPPScope.CPPScopeProblem(inputNode, IProblemBinding.SEMANTIC_BAD_SCOPE, inputNode.getRawSignature().toCharArray()); } @@ -1114,21 +1114,21 @@ public class CPPVisitor extends ASTQueries { if (body != null) return body.getScope(); return dtor.getFunctionScope(); - } + } if (prop == ICPPASTLambdaExpression.DECLARATOR) { final IASTCompoundStatement body = ((ICPPASTLambdaExpression) outerDtor.getParent()).getBody(); if (body != null) return body.getScope(); return dtor.getFunctionScope(); - } + } } return null; } - + public static IScope getContainingScope(IASTName name) { return getContainingScope(name, null); } - + public static IScope getContainingScope(IASTName name, LookupData data) { IScope scope= getContainingScopeOrNull(name, data); if (scope == null) { @@ -1137,7 +1137,7 @@ public class CPPVisitor extends ASTQueries { return scope; } - + private static IScope getContainingScopeOrNull(IASTName name, LookupData data) { if (name == null) { return null; @@ -1148,7 +1148,7 @@ public class CPPVisitor extends ASTQueries { name = (IASTName) parent; parent = name.getParent(); } - + if (parent instanceof ICPPASTQualifiedName) { final ICPPASTQualifiedName qname= (ICPPASTQualifiedName) parent; final IASTName[] names = qname.getNames(); @@ -1162,7 +1162,7 @@ public class CPPVisitor extends ASTQueries { if (tu == null) return null; return tu.getScope(); - } + } if (qname.getParent() instanceof ICPPASTFieldReference) { name= qname; parent= name.getParent(); @@ -1174,7 +1174,7 @@ public class CPPVisitor extends ASTQueries { // For template functions we may need to resolve a template parameter // as a parent of an unknown type used as parameter type. IBinding binding = names[i - 1].resolvePreBinding(); - + // 7.1.3-7 Unwrap typedefs, delete cv-qualifiers. if (binding instanceof ITypedef) { IType type= getNestedType((ITypedef) binding, TDEF | CVTYPE); @@ -1207,9 +1207,9 @@ public class CPPVisitor extends ASTQueries { } return scope; } - } - } - + } + } + if (parent instanceof ICPPASTFieldReference) { if (data != null) { data.usesEnclosingScope= false; @@ -1224,7 +1224,7 @@ public class CPPVisitor extends ASTQueries { return ((ICPPUnknownBinding) type).asScope(); } else { // mstodo introduce problem category - return new CPPScope.CPPScopeProblem(name, ISemanticProblem.TYPE_UNKNOWN_FOR_EXPRESSION); + return new CPPScope.CPPScopeProblem(name, ISemanticProblem.TYPE_UNKNOWN_FOR_EXPRESSION); } } else if (parent instanceof IASTGotoStatement || parent instanceof IASTLabelStatement) { while (!(parent instanceof IASTFunctionDefinition)) { @@ -1237,7 +1237,7 @@ public class CPPVisitor extends ASTQueries { IProblemBinding problem = e.getProblem(); if (problem instanceof ICPPScope) return problem; - return new CPPScope.CPPScopeProblem(problem.getASTNode(), problem.getID(), problem.getNameCharArray()); + return new CPPScope.CPPScopeProblem(problem.getASTNode(), problem.getID(), problem.getNameCharArray()); } return getContainingScope(parent); } @@ -1269,12 +1269,12 @@ public class CPPVisitor extends ASTQueries { } return getContainingScope(name); } - + if (scope == null) return getContainingScope(parent); return scope; } - + public static IASTNode getContainingBlockItem(IASTNode node) { if (node == null) return null; if (node.getPropertyInParent() == CPPSemantics.STRING_LOOKUP_PROPERTY) return null; @@ -1307,7 +1307,7 @@ public class CPPVisitor extends ASTQueries { } return null; } - + static private IBinding resolveBinding(IASTNode node) { IASTName name = null; while (node != null) { @@ -1344,7 +1344,7 @@ public class CPPVisitor extends ASTQueries { private static class CollectProblemsAction extends ASTGenericVisitor { private List fProblems = null; - + CollectProblemsAction() { super(true); } @@ -1355,14 +1355,14 @@ public class CPPVisitor extends ASTQueries { } fProblems.add(problem); } - + public IASTProblem[] getProblems() { if (fProblems == null) return new IASTProblem[0]; - + return fProblems.toArray(new IASTProblem[fProblems.size()]); } - + @Override public int genericVisit(IASTNode node) { if (node instanceof IASTProblemHolder) @@ -1392,12 +1392,12 @@ public class CPPVisitor extends ASTQueries { shouldVisitTranslationUnit = true; shouldVisitNames = true; this.decls = new IASTName[DEFAULT_LIST_SIZE]; - + final String bname= binding.getName(); if (bname.length() > 0 && !bname.startsWith("operator")) { //$NON-NLS-1$ requiredName= bname.toCharArray(); } - this.bindings = new IBinding[] {binding}; + this.bindings = new IBinding[] { binding }; if (binding instanceof ICPPUsingDeclaration) { this.bindings= ((ICPPUsingDeclaration) binding).getDelegates(); kind= KIND_COMPOSITE; @@ -1405,8 +1405,8 @@ public class CPPVisitor extends ASTQueries { kind = KIND_LABEL; } else if (binding instanceof ICPPTemplateParameter) { kind = KIND_TEMPLATE_PARAMETER; - } else if (binding instanceof ICompositeType || - binding instanceof ITypedef || + } else if (binding instanceof ICompositeType || + binding instanceof ITypedef || binding instanceof IEnumeration) { kind = KIND_TYPE; } else if (binding instanceof ICPPNamespace) { @@ -1431,11 +1431,11 @@ public class CPPVisitor extends ASTQueries { if (requiredName != null && !CharArrayUtils.equals(name.getLookupKey(), requiredName)) { return PROCESS_CONTINUE; } - + ASTNodeProperty prop = name.getPropertyInParent(); if (prop == ICPPASTQualifiedName.SEGMENT_NAME) prop = name.getParent().getPropertyInParent(); - + switch (kind) { case KIND_TEMPLATE_PARAMETER: if (prop == ICPPASTSimpleTypeTemplateParameter.PARAMETER_NAME || @@ -1479,7 +1479,7 @@ public class CPPVisitor extends ASTQueries { break; } } - + if (kind == KIND_TYPE) return PROCESS_CONTINUE; // $FALL-THROUGH$ @@ -1496,17 +1496,17 @@ public class CPPVisitor extends ASTQueries { if (prop == ICPPASTNamespaceDefinition.NAMESPACE_NAME || prop == ICPPASTNamespaceAlias.ALIAS_NAME) { break; - } + } return PROCESS_CONTINUE; } - + if (bindings != null) { if (isDeclarationBinding(name.resolveBinding())) { if (decls.length == idx) { decls = Arrays.copyOf(decls, decls.length * 2); } decls[idx++] = name; - } + } } return PROCESS_CONTINUE; } @@ -1574,7 +1574,7 @@ public class CPPVisitor extends ASTQueries { private int idx = 0; private int kind; private IIndex index; - + private static final int KIND_LABEL = 1; private static final int KIND_OBJ_FN = 2; private static final int KIND_TYPE = 3; @@ -1588,21 +1588,21 @@ public class CPPVisitor extends ASTQueries { binding = unwindBinding(binding); this.bindings = new IBinding[] { binding }; - + if (binding instanceof ICPPUsingDeclaration) { this.bindings= ((ICPPUsingDeclaration) binding).getDelegates(); kind= KIND_COMPOSITE; } else if (binding instanceof ILabel) { kind = KIND_LABEL; - } else if (binding instanceof ICompositeType || - binding instanceof ITypedef || + } else if (binding instanceof ICompositeType || + binding instanceof ITypedef || binding instanceof IEnumeration) { kind = KIND_TYPE; } else if (binding instanceof ICPPNamespace) { kind = KIND_NAMESPACE; } else if (binding instanceof ICPPTemplateParameter) { kind = KIND_COMPOSITE; - } else { + } else { kind = KIND_OBJ_FN; } } @@ -1617,14 +1617,14 @@ public class CPPVisitor extends ASTQueries { public int visit(IASTName name) { if (name instanceof ICPPASTQualifiedName || name instanceof ICPPASTTemplateId) return PROCESS_CONTINUE; - + ASTNodeProperty prop = name.getPropertyInParent(); ASTNodeProperty p2 = null; if (prop == ICPPASTQualifiedName.SEGMENT_NAME) { p2 = prop; prop = name.getParent().getPropertyInParent(); } - + switch (kind) { case KIND_LABEL: if (prop == IASTGotoStatement.NAME) @@ -1633,7 +1633,7 @@ public class CPPVisitor extends ASTQueries { case KIND_TYPE: case KIND_COMPOSITE: - if (prop == IASTNamedTypeSpecifier.NAME || + if (prop == IASTNamedTypeSpecifier.NAME || prop == ICPPASTPointerToMember.NAME || prop == ICPPASTUsingDeclaration.NAME || prop == ICPPASTCompositeTypeSpecifier.ICPPASTBaseSpecifier.NAME || @@ -1651,8 +1651,8 @@ public class CPPVisitor extends ASTQueries { return PROCESS_CONTINUE; //$FALL-THROUGH$ case KIND_OBJ_FN: - if (prop == IASTIdExpression.ID_NAME || - prop == IASTFieldReference.FIELD_NAME || + if (prop == IASTIdExpression.ID_NAME || + prop == IASTFieldReference.FIELD_NAME || prop == ICPPASTUsingDirective.QUALIFIED_NAME || prop == ICPPASTUsingDeclaration.NAME || prop == IASTFunctionCallExpression.FUNCTION_NAME || @@ -1674,7 +1674,7 @@ public class CPPVisitor extends ASTQueries { } return PROCESS_CONTINUE; } - + if (bindings != null) { if (isReferenceBinding(name.resolveBinding())) { if (refs.length == idx) { @@ -1705,7 +1705,7 @@ public class CPPVisitor extends ASTQueries { } return false; } - + public IASTName[] getReferences() { if (idx < refs.length) { refs = Arrays.copyOf(refs, idx); @@ -1721,10 +1721,10 @@ public class CPPVisitor extends ASTQueries { public static ICPPFunctionType createImplicitFunctionType(IType returnType, IParameter[] parameters, boolean isConst, boolean isVolatile) { IType[] pTypes = new IType[parameters.length]; IType pt = null; - + for (int i = 0; i < parameters.length; i++) { pt = parameters[i].getType(); - + // remove qualifiers if (pt instanceof IQualifierType) { pt= ((IQualifierType) pt).getType(); @@ -1735,10 +1735,10 @@ public class CPPVisitor extends ASTQueries { } else if (pt instanceof IFunctionType) { pt = new CPPPointerType(pt); } - - pTypes[i] = pt; + + pTypes[i] = pt; } - + return new CPPFunctionType(returnType, pTypes, isConst, isVolatile, false); } @@ -1761,7 +1761,7 @@ public class CPPVisitor extends ASTQueries { pt = createType(pt, pDtor); } pt= adjustParameterType(pt, forFuncType); - + if (pDtor != null && CPPVisitor.findInnermostDeclarator(pDtor).declaresParameterPack()) { pt= new CPPParameterPackType(pt); } @@ -1770,7 +1770,7 @@ public class CPPVisitor extends ASTQueries { private static IType createType(IType returnType, ICPPASTFunctionDeclarator fnDtor) { IType[] pTypes = createParameterTypes(fnDtor); - + IASTName name = fnDtor.getName(); if (name instanceof ICPPASTQualifiedName) { IASTName[] ns = ((ICPPASTQualifiedName) name).getNames(); @@ -1781,7 +1781,7 @@ public class CPPVisitor extends ASTQueries { } else { returnType = getPointerTypes(returnType, fnDtor); } - + CPPFunctionType type = new CPPFunctionType(returnType, pTypes, fnDtor.isConst(), fnDtor.isVolatile(), fnDtor.takesVarArgs()); final IASTDeclarator nested = fnDtor.getNestedDeclarator(); @@ -1803,7 +1803,7 @@ public class CPPVisitor extends ASTQueries { return pTypes; } - + /** * Adjusts the parameter type according to 8.3.5-3: * cv-qualifiers are deleted, arrays and function types are converted to pointers. @@ -1819,7 +1819,7 @@ public class CPPVisitor extends ASTQueries { return new CPPPointerType(pt); } - // 8.3.5-3 + // 8.3.5-3 // Any cv-qualifier modifying a parameter type is deleted. The parameter type remains // to be qualified. if (forFunctionType && SemanticUtil.getCVQualifier(t) != CVQualifier.NONE) { @@ -1827,7 +1827,7 @@ public class CPPVisitor extends ASTQueries { } return pt; } - + private static IType getPointerTypes(IType type, IASTDeclarator declarator) { IASTPointerOperator[] ptrOps = declarator.getPointerOperators(); for (IASTPointerOperator ptrOp : ptrOps) { @@ -1851,14 +1851,14 @@ public class CPPVisitor extends ASTQueries { } return type; } - + public static IType createType(IASTDeclarator declarator) { - if (declarator == null) + if (declarator == null) return new ProblemType(ISemanticProblem.TYPE_NO_NAME); - + declarator= findOutermostDeclarator(declarator); IASTNode parent = declarator.getParent(); - + IASTDeclSpecifier declSpec = null; boolean isPackExpansion= false; if (parent instanceof IASTSimpleDeclaration) { @@ -1879,7 +1879,7 @@ public class CPPVisitor extends ASTQueries { ((ICPPASTSimpleDeclSpecifier) declSpec).getType() == IASTSimpleDeclSpecifier.t_auto) { return createAutoType(declSpec, declarator); } - + IType type = createType(declSpec); type = createType(type, declarator); @@ -1916,7 +1916,7 @@ public class CPPVisitor extends ASTQueries { IASTInitializerClause[] arguments = ((ICPPASTConstructorInitializer) initializer).getArguments(); if (arguments.length == 1) { autoInitClause = arguments[0]; - } + } } } else if (parent instanceof ICPPASTRangeBasedForStatement) { // See 6.5.4 The range-based for statement [stmt.ranged] @@ -1928,7 +1928,7 @@ public class CPPVisitor extends ASTQueries { IType type= SemanticUtil.getNestedType(expr.getExpressionType(), TDEF|CVTYPE); if (type instanceof IArrayType) { beginExpr= expr.copy(); - } + } } if (beginExpr == null) { IASTImplicitName[] implicits= forStmt.getImplicitNames(); @@ -1988,7 +1988,7 @@ public class CPPVisitor extends ASTQueries { } } type = decorateType(type, declSpec, declarator); - + if (initClause instanceof IASTExpression) { final IASTExpression expression = (IASTExpression) initClause; initType = expression.getExpressionType(); @@ -2025,7 +2025,7 @@ public class CPPVisitor extends ASTQueries { IASTTypeId id= declarator.getTrailingReturnType(); if (id == null) return new ProblemType(ISemanticProblem.TYPE_NO_NAME); - + IType t= createType(id.getAbstractDeclarator()); t= qualifyType(t, declSpec); return createType(t, declarator); @@ -2061,10 +2061,10 @@ public class CPPVisitor extends ASTQueries { IBinding binding = name.resolvePreBinding(); if (!(binding instanceof IProblemBinding)) { - if (binding instanceof ICPPConstructor) + if (binding instanceof ICPPConstructor) return ((ICPPConstructor) binding).getClassOwner(); - if (binding instanceof IType) + if (binding instanceof IType) return (IType) binding; } return new ProblemType(ISemanticProblem.TYPE_UNRESOLVED_NAME); @@ -2082,7 +2082,7 @@ public class CPPVisitor extends ASTQueries { private static IType createType(IType baseType, IASTDeclarator declarator) { if (declarator instanceof ICPPASTFunctionDeclarator) return createType(baseType, (ICPPASTFunctionDeclarator) declarator); - + IType type = baseType; type = getPointerTypes(type, declarator); if (declarator instanceof IASTArrayDeclarator) @@ -2100,9 +2100,9 @@ public class CPPVisitor extends ASTQueries { */ private static IType getDeclType(ICPPASTSimpleDeclSpecifier spec) { IASTExpression expr = spec.getDeclTypeExpression(); - if (expr == null) + if (expr == null) return null; - + if (spec.getType() == IASTSimpleDeclSpecifier.t_decltype) { IASTName namedEntity= null; if (expr instanceof IASTIdExpression) { @@ -2135,7 +2135,7 @@ public class CPPVisitor extends ASTQueries { case PRVALUE: break; } - } + } return type; } @@ -2183,7 +2183,7 @@ public class CPPVisitor extends ASTQueries { } return null; } - + public static IType getPointerDiffType(final IASTBinaryExpression binary) { IType t= getStdType(binary, PTRDIFF_T); return t != null ? t : INT_TYPE; @@ -2235,30 +2235,30 @@ public class CPPVisitor extends ASTQueries { tu.accept(action); return action.getReferences(); } - + public static IASTName[] getImplicitReferences(IASTTranslationUnit tu, IBinding binding) { CollectReferencesAction action = new CollectReferencesAction(binding) { - { + { shouldVisitNames = false; - shouldVisitImplicitNames = true; - shouldVisitImplicitNameAlternates = true; + shouldVisitImplicitNames = true; + shouldVisitImplicitNameAlternates = true; } }; tu.accept(action); return action.getReferences(); } - + public static IASTName[] getDeclarations(IASTTranslationUnit tu, IBinding binding) { CollectDeclarationsAction action = new CollectDeclarationsAction(binding); tu.accept(action); - + IASTName[] found = action.getDeclarations(); if (found.length == 0 && binding instanceof ICPPSpecialization && binding instanceof ICPPInternalBinding) { IASTNode node = ((ICPPInternalBinding) binding).getDefinition(); if (node == null) { IASTNode[] nds = ((ICPPInternalBinding) binding).getDeclarations(); if (nds != null && nds.length > 0) - node = nds[0]; + node = nds[0]; } if (node != null) { IASTName name = null; @@ -2271,10 +2271,10 @@ public class CPPVisitor extends ASTQueries { found = new IASTName[] { name }; } } - + return found; } - + public static String[] getQualifiedName(IBinding binding) { String[] ns = null; for (IBinding owner= binding.getOwner(); owner != null; owner= owner.getOwner()) { @@ -2284,13 +2284,13 @@ public class CPPVisitor extends ASTQueries { String n= owner.getName(); if (n == null) break; - if (owner instanceof ICPPFunction) + if (owner instanceof ICPPFunction) break; if (owner instanceof ICPPNamespace && n.length() == 0) { // TODO(sprigogin): Do not ignore anonymous namespaces. continue; } - + ns = ArrayUtil.append(String.class, ns, n); } ns = ArrayUtil.trim(String.class, ns); @@ -2301,7 +2301,7 @@ public class CPPVisitor extends ASTQueries { result[ns.length]= binding.getName(); return result; } - + public static char[][] getQualifiedNameCharArray(IBinding binding) { char[][] ns = EMPTY_CHAR_ARRAY_ARRAY; ns = ArrayUtil.append(ns, binding.getNameCharArray()); @@ -2309,11 +2309,11 @@ public class CPPVisitor extends ASTQueries { char[] n= owner.getNameCharArray(); if (n == null) break; - if (owner instanceof ICPPFunction) + if (owner instanceof ICPPFunction) break; if (owner instanceof ICPPNamespace && n.length == 0) continue; - + ns = ArrayUtil.append(ns, n); } ns = ArrayUtil.trim(ns); @@ -2347,7 +2347,7 @@ public class CPPVisitor extends ASTQueries { t= SemanticUtil.getNestedType(t, TDEF); return t instanceof ICPPReferenceType && !((ICPPReferenceType) t).isRValueReference(); } - + /** * Searches for the function enclosing the given node. May return null. */ @@ -2357,7 +2357,7 @@ public class CPPVisitor extends ASTQueries { } if (node == null) return null; - + IASTDeclarator dtor= findInnermostDeclarator(((IASTFunctionDefinition) node).getDeclarator()); if (dtor != null) { IASTName name= dtor.getName(); @@ -2380,15 +2380,15 @@ public class CPPVisitor extends ASTQueries { name= dtor.getName(); } break; - } + } if (node instanceof IASTCompositeTypeSpecifier) { name= ((IASTCompositeTypeSpecifier) node).getName(); break; } } - if (name == null) + if (name == null) return null; - + return name.resolveBinding(); } @@ -2403,7 +2403,7 @@ public class CPPVisitor extends ASTQueries { break; } } - if (--i < 0) + if (--i < 0) break; return bindingToOwner(qn[i].resolveBinding()); } @@ -2416,9 +2416,9 @@ public class CPPVisitor extends ASTQueries { private static IBinding bindingToOwner(IBinding b) { if (b instanceof ITypedef) { IType t= SemanticUtil.getNestedType((IType) b, TDEF); - if (t instanceof IBinding) + if (t instanceof IBinding) return (IBinding) t; - + return b; } while (b instanceof ICPPNamespaceAlias) { @@ -2455,13 +2455,13 @@ public class CPPVisitor extends ASTQueries { } boolean isFriend= isFriendDeclaration(node); - + // Search for enclosing binding IASTName name= null; node= node.getParent(); for (; node != null; node= node.getParent()) { if (node instanceof IASTFunctionDefinition) { - if (!allowFunction) + if (!allowFunction) continue; IASTDeclarator dtor= findInnermostDeclarator(((IASTFunctionDefinition) node).getDeclarator()); @@ -2469,7 +2469,7 @@ public class CPPVisitor extends ASTQueries { name= dtor.getName(); } break; - } + } if (node instanceof IASTCompositeTypeSpecifier) { if (isFriend || isNonSimpleElabDecl) continue; @@ -2485,9 +2485,9 @@ public class CPPVisitor extends ASTQueries { break; } } - if (name == null) + if (name == null) return null; - + return name.resolveBinding(); } @@ -2503,7 +2503,7 @@ public class CPPVisitor extends ASTQueries { } return false; } - + public static ICPPASTDeclarator findInnermostDeclarator(ICPPASTDeclarator dtor) { return (ICPPASTDeclarator) ASTQueries.findInnermostDeclarator(dtor); } diff --git a/core/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/refactoring/NodeContainer.java b/core/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/refactoring/NodeContainer.java index 0d544788747..38ce30f0dd0 100644 --- a/core/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/refactoring/NodeContainer.java +++ b/core/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/refactoring/NodeContainer.java @@ -1,12 +1,12 @@ /******************************************************************************* - * Copyright (c) 2008, 2012 Institute for Software, HSR Hochschule fuer Technik + * Copyright (c) 2008, 2012 Institute for Software, HSR Hochschule fuer Technik * Rapperswil, University of applied sciences 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: + * 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: * Institute for Software - initial API and implementation * Sergey Prigogin (Google) *******************************************************************************/ @@ -19,7 +19,6 @@ import java.util.List; import java.util.Set; import org.eclipse.core.resources.IProject; -import org.eclipse.core.runtime.ILog; import org.eclipse.core.runtime.IStatus; import org.eclipse.core.runtime.Platform; import org.eclipse.core.runtime.Status; @@ -92,7 +91,7 @@ public class NodeContainer { public int visit(IASTName name) { if (name.getPropertyInParent() != IASTFieldReference.FIELD_NAME) { IBinding binding = name.resolveBinding(); - + if (binding instanceof ICPPBinding && !(binding instanceof ICPPTemplateTypeParameter)) { ICPPBinding cppBinding = (ICPPBinding) binding; try { @@ -106,14 +105,13 @@ public class NodeContainer { names.add(nameInfo); } } catch (DOMException e) { - ILog logger = CUIPlugin.getDefault().getLog(); IStatus status = new Status(IStatus.WARNING, CUIPlugin.PLUGIN_ID, e.getMessage(), e); - logger.log(status); + CUIPlugin.log(status); } } else if (binding instanceof IVariable) { NameInformation nameInformation = new NameInformation(name); - + IASTName[] refs = name.getTranslationUnit().getReferences(binding); for (IASTName ref : refs) { nameInformation.addReference(ref, startOffset, endOffset); @@ -129,8 +127,8 @@ public class NodeContainer { for (NameInformation nameInfo : names) { IASTName name = nameInfo.getName(); - IASTTranslationUnit unit = name.getTranslationUnit(); - IASTName[] nameDeclarations = unit.getDeclarationsInAST(name.resolveBinding()); + IASTTranslationUnit ast = name.getTranslationUnit(); + IASTName[] nameDeclarations = ast.getDeclarationsInAST(name.resolveBinding()); if (nameDeclarations.length != 0) { nameInfo.setDeclarationName(nameDeclarations[nameDeclarations.length - 1]); } @@ -153,10 +151,10 @@ public class NodeContainer { private List getInterfaceNames() { if (interfaceNames == null) { findAllNames(); - + Set declarations = new HashSet(); interfaceNames = new ArrayList(); - + for (NameInformation nameInfo : names) { IASTName declarationName = nameInfo.getDeclarationName(); if (declarations.add(declarationName)) { @@ -227,7 +225,7 @@ public class NodeContainer { public List getParameterCandidates() { return getInterfaceNames(false); } - + /** * Returns names that are candidates for being used as the function return value. Multiple * return value candidates mean that the function cannot be extracted. @@ -235,7 +233,7 @@ public class NodeContainer { public List getReturnValueCandidates() { return getInterfaceNames(true); } - + public List getNodesToWrite() { return nodes; } @@ -282,7 +280,7 @@ public class NodeContainer { public int getEndOffset() { return getEndOffset(false); } - + public int getEndOffsetIncludingComments() { return getEndOffset(true); } diff --git a/core/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/refactoring/utils/EclipseObjects.java b/core/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/refactoring/utils/EclipseObjects.java index b86378707fc..b1323657c42 100644 --- a/core/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/refactoring/utils/EclipseObjects.java +++ b/core/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/refactoring/utils/EclipseObjects.java @@ -1,12 +1,12 @@ /******************************************************************************* - * Copyright (c) 2008 Institute for Software, HSR Hochschule fuer Technik + * Copyright (c) 2008 Institute for Software, HSR Hochschule fuer Technik * Rapperswil, University of applied sciences 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: + * 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: * Institute for Software - initial API and implementation *******************************************************************************/ package org.eclipse.cdt.internal.ui.refactoring.utils; @@ -30,7 +30,6 @@ import org.eclipse.ui.editors.text.TextEditor; import org.eclipse.ui.texteditor.IDocumentProvider; import org.eclipse.ui.texteditor.ITextEditor; -import org.eclipse.cdt.core.dom.ast.IASTNode; import org.eclipse.cdt.core.model.ICElement; import org.eclipse.cdt.internal.ui.editor.CEditor; @@ -39,29 +38,27 @@ import org.eclipse.cdt.internal.ui.editor.CEditor; * A collection of helper methods to interact with the workbench's IDocuments and IFiles */ public class EclipseObjects { + static public IWorkbenchPage getActivePage() { return getActiveWindow().getActivePage(); } - + /** * @return the active, visible TextEditor */ static public IEditorPart getActiveEditor() { - IEditorPart editor = null; - IWorkbenchPage page = getActivePage(); - - if (page.isEditorAreaVisible() - && page.getActiveEditor() != null - && page.getActiveEditor() instanceof TextEditor) { - editor = page.getActiveEditor(); + + IEditorPart activeEditor = page.getActiveEditor(); + if (page.isEditorAreaVisible() && activeEditor instanceof TextEditor) { + return activeEditor; } - return editor; + return null; } - + /** - * Goes through all open editors to find the one with the specified file. - * + * Goes through all open editors to find the one with the specified file. + * * @param file to search for * @return the editor or null */ @@ -71,45 +68,44 @@ public class EclipseObjects { for (IEditorReference editor2 : editors) { IEditorPart editor = editor2.getEditor(false); if (editor instanceof CEditor) { - CEditor edi = ((CEditor)editor); + CEditor edi = ((CEditor) editor); IResource resource = edi.getInputCElement().getResource(); if (resource instanceof IFile) { - if( (( IFile )resource).equals(file) ){ + if (((IFile) resource).equals(file)) { return editor; - } + } } - + } } return null; } - + /** * @return the file from the active editor */ - static public IFile getActiveFile(){ + static public IFile getActiveFile() { IEditorInput editorInput = getActiveEditor().getEditorInput(); - IFile aFile = null; - if(editorInput instanceof IFileEditorInput){ - aFile = ((IFileEditorInput)editorInput).getFile(); + if (editorInput instanceof IFileEditorInput) { + return ((IFileEditorInput) editorInput).getFile(); } - - return aFile; + + return null; } - + /** * @return the document from the currently active editor */ static public IDocument getActiveDocument() { - return getDocument( getActiveEditor() ); + return getDocument(getActiveEditor()); } - + /** - * @return the document opened in the editor + * @return the document opened in the editor */ static public IDocument getDocument(IEditorPart editor) { - ITextEditor txtEditor = ((ITextEditor)editor); + ITextEditor txtEditor = ((ITextEditor) editor); IDocumentProvider prov = txtEditor.getDocumentProvider(); return prov.getDocument(txtEditor.getEditorInput()); } @@ -125,48 +121,38 @@ public class EclipseObjects { IEditorPart editor = getEditorForFile(file); return getDocument(editor); } - + /** - * @return return the file that contains the selection or the + * @return return the file that contains the selection or the * active file if there is no present selection */ static public IFile getFile(ISelection selection) { if (selection instanceof IStructuredSelection && !selection.isEmpty()) { - IFile file = getFile((IStructuredSelection)selection); + IFile file = getFile((IStructuredSelection) selection); return file; } - return EclipseObjects.getActiveFile(); + return getActiveFile(); } static private IFile getFile(IStructuredSelection selection) { - IFile file = null; Object o = selection.getFirstElement(); - + if (o instanceof ICElement) { ICElement e= (ICElement) o; IResource r= e.getUnderlyingResource(); if (r instanceof IFile) { - file= (IFile) r; + return (IFile) r; } - } - - return file; + } + + return null; } - + /** * @return the file at the specified path string */ - public static IFile getFileForPathString(String path) { - IPath ipath = new Path(path); - return ResourcesPlugin.getWorkspace().getRoot().getFileForLocation(ipath); - } - - /** - * @return the file containing the node - */ - public static IFile getFile(IASTNode node){ - if(node == null) - return null; - return getFileForPathString(node.getFileLocation().getFileName()); + public static IFile getFileForPathString(String filePath) { + IPath path = new Path(filePath); + return ResourcesPlugin.getWorkspace().getRoot().getFileForLocation(path); } }