1
0
Fork 0
mirror of https://github.com/eclipse-cdt/cdt synced 2025-08-11 02:05:39 +02:00

Cosmetics.

This commit is contained in:
sprigogin 2012-02-29 14:21:04 -08:00
parent 84e82daec5
commit 5337c7707b
25 changed files with 423 additions and 470 deletions

View file

@ -11,35 +11,33 @@
package org.eclipse.cdt.core.model; package org.eclipse.cdt.core.model;
/** /**
* IDeclaration is a base interface for any C Model element that could be * Base interface for any C Model element that could be considered a declaration.
* considered a declaration. *
*
* @noextend This interface is not intended to be extended by clients. * @noextend This interface is not intended to be extended by clients.
* @noimplement This interface is not intended to be implemented by clients. * @noimplement This interface is not intended to be implemented by clients.
*/ */
public interface IDeclaration extends ICElement, ISourceManipulation, ISourceReference { 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. * Returns true if the declaration is static, false otherwise.
* @return boolean * @return boolean
* @throws CModelException * @throws CModelException
*/ */
boolean isStatic() throws CModelException; boolean isStatic() throws CModelException;
/** /**
* Checks if the declaration is constant. * 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 * @return boolean
* @throws CModelException * @throws CModelException
*/ */
boolean isConst() throws CModelException; boolean isConst() throws CModelException;
/** /**
* Checks if the declaration is volatile. * Checks if the declaration is volatile.
* Returns true if the declaration is volatile, false otherwise. * Returns true if the declaration is volatile, false otherwise.
* @return boolean * @return boolean
* @throws CModelException * @throws CModelException
*/ */
boolean isVolatile() throws CModelException; boolean isVolatile() throws CModelException;
} }

View file

@ -10,15 +10,13 @@
*******************************************************************************/ *******************************************************************************/
package org.eclipse.cdt.core.model; package org.eclipse.cdt.core.model;
/** /**
* Represents a function * Represents a function
* *
* @noextend This interface is not intended to be extended by clients. * @noextend This interface is not intended to be extended by clients.
* @noimplement This interface is not intended to be implemented by clients. * @noimplement This interface is not intended to be implemented by clients.
*/ */
public interface IFunctionDeclaration extends IDeclaration { public interface IFunctionDeclaration extends IDeclaration {
/** /**
* Returns the type signatures of the exceptions this method throws, * Returns the type signatures of the exceptions this method throws,
* in the order declared in the source. Returns an empty array * in the order declared in the source. Returns an empty array
@ -54,12 +52,12 @@ public interface IFunctionDeclaration extends IDeclaration {
String[] getParameterTypes(); String[] getParameterTypes();
/** /**
* Returns the return value of this method. * Returns the return value of this method.
*/ */
String getReturnType(); String getReturnType();
/** /**
* Returns the signature of the method. * Returns the signature of the method.
*/ */
String getSignature() throws CModelException; String getSignature() throws CModelException;
} }

View file

@ -12,10 +12,9 @@ package org.eclipse.cdt.core.model;
/** /**
* Represents the definition method of a class. * Represents the definition method of a class.
* *
* @noextend This interface is not intended to be extended by clients. * @noextend This interface is not intended to be extended by clients.
* @noimplement This interface is not intended to be implemented by clients. * @noimplement This interface is not intended to be implemented by clients.
*/ */
public interface IMethod extends IMethodDeclaration { public interface IMethod extends IMethodDeclaration {
} }

View file

@ -10,7 +10,6 @@
*******************************************************************************/ *******************************************************************************/
package org.eclipse.cdt.core.model; package org.eclipse.cdt.core.model;
/** /**
* Represents the declaration method of a class * 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. * @noimplement This interface is not intended to be implemented by clients.
*/ */
public interface IMethodDeclaration extends IMember, IFunctionDeclaration { public interface IMethodDeclaration extends IMember, IFunctionDeclaration {
/** /**
* Returns whether this method is a constructor. * 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. * return true if the member is a friend.
*/ */
public boolean isFriend() throws CModelException; public boolean isFriend() throws CModelException;
} }

View file

@ -6,8 +6,8 @@
* http://www.eclipse.org/legal/epl-v10.html * http://www.eclipse.org/legal/epl-v10.html
* *
* Contributors: * Contributors:
* Markus Schorn - initial API and implementation * Markus Schorn - initial API and implementation
*******************************************************************************/ *******************************************************************************/
package org.eclipse.cdt.core.dom.ast; package org.eclipse.cdt.core.dom.ast;
import org.eclipse.cdt.core.dom.ast.IASTEnumerationSpecifier.IASTEnumerator; 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; import org.eclipse.cdt.core.dom.ast.cpp.ICPPASTVisitor;
/** /**
* Generic visitor for ast-nodes. * Generic visitor for AST nodes.
* <p> Clients may subclass. </p> * <p> Clients may subclass. </p>
* @since 5.1 * @since 5.1
*/ */
public abstract class ASTGenericVisitor extends ASTVisitor implements ICPPASTVisitor, ICASTVisitor { public abstract class ASTGenericVisitor extends ASTVisitor implements ICPPASTVisitor, ICASTVisitor {
public ASTGenericVisitor(boolean visitNodes) { public ASTGenericVisitor(boolean visitNodes) {
super(visitNodes); super(visitNodes);
} }
@ -32,7 +33,7 @@ public abstract class ASTGenericVisitor extends ASTVisitor implements ICPPASTVis
protected int genericVisit(IASTNode node) { protected int genericVisit(IASTNode node) {
return PROCESS_CONTINUE; return PROCESS_CONTINUE;
} }
protected int genericLeave(IASTNode node) { protected int genericLeave(IASTNode node) {
return PROCESS_CONTINUE; return PROCESS_CONTINUE;
} }
@ -51,7 +52,7 @@ public abstract class ASTGenericVisitor extends ASTVisitor implements ICPPASTVis
public int visit(ICPPASTTemplateParameter templateParameter) { public int visit(ICPPASTTemplateParameter templateParameter) {
return genericVisit(templateParameter); return genericVisit(templateParameter);
} }
@Override @Override
public int visit(ICPPASTCapture capture) { public int visit(ICPPASTCapture capture) {
return genericVisit(capture); return genericVisit(capture);
@ -61,7 +62,7 @@ public abstract class ASTGenericVisitor extends ASTVisitor implements ICPPASTVis
public int visit(IASTArrayModifier arrayModifier) { public int visit(IASTArrayModifier arrayModifier) {
return genericVisit(arrayModifier); return genericVisit(arrayModifier);
} }
@Override @Override
public int visit(IASTPointerOperator ptrOperator) { public int visit(IASTPointerOperator ptrOperator) {
return genericVisit(ptrOperator); return genericVisit(ptrOperator);
@ -161,7 +162,7 @@ public abstract class ASTGenericVisitor extends ASTVisitor implements ICPPASTVis
public int leave(IASTArrayModifier arrayModifier) { public int leave(IASTArrayModifier arrayModifier) {
return genericLeave(arrayModifier); return genericLeave(arrayModifier);
} }
@Override @Override
public int leave(IASTPointerOperator ptrOperator) { public int leave(IASTPointerOperator ptrOperator) {
return genericLeave(ptrOperator); return genericLeave(ptrOperator);

View file

@ -22,15 +22,15 @@ import org.eclipse.cdt.core.dom.ast.cpp.ICPPASTTemplateParameter;
import org.eclipse.cdt.internal.core.dom.parser.ASTAmbiguousNode; import org.eclipse.cdt.internal.core.dom.parser.ASTAmbiguousNode;
/** /**
* Abstract base class for all visitors to traverse ast nodes. <br> * Abstract base class for all visitors to traverse AST nodes. <br>
* visit() methods implement a top-down traversal, and <br> * visit() methods implement a top-down traversal, and <br>
* leave() methods implement a bottom-up traversal. <br> * leave() methods implement a bottom-up traversal. <br>
* *
* <p> Clients may subclass. </p> * <p> Clients may subclass. </p>
*/ */
public abstract class ASTVisitor { 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; public final static int PROCESS_SKIP = 1;
/** /**
@ -105,7 +105,7 @@ public abstract class ASTVisitor {
* Set this flag to visit designators of initializers. * Set this flag to visit designators of initializers.
*/ */
public boolean shouldVisitDesignators = false; public boolean shouldVisitDesignators = false;
/** /**
* Set this flag to visit base specifiers off composite types. * 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. * Set this flag to visit template parameters.
*/ */
public boolean shouldVisitTemplateParameters = false; public boolean shouldVisitTemplateParameters = false;
/** /**
* Set this flag to visit captures * Set this flag to visit captures
* @since 5.3 * @since 5.3
*/ */
public boolean shouldVisitCaptures= false; public boolean shouldVisitCaptures= false;
/** /**
* Per default inactive nodes are not visited. You can change that by setting * Per default inactive nodes are not visited. You can change that by setting
* this flag to <code>true</code>. * this flag to <code>true</code>.
* @since 5.1 * @since 5.1
*/ */
public boolean includeInactiveNodes= false; public boolean includeInactiveNodes= false;
/** /**
* Normally neither ambiguous nodes nor their children are visited. By setting * Normally neither ambiguous nodes nor their children are visited. By setting
* this flag to <code>true</code> ambiguous nodes are visited, their children * this flag to <code>true</code> 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. * @noreference This field is not intended to be referenced by clients.
*/ */
public boolean shouldVisitAmbiguousNodes = false; public boolean shouldVisitAmbiguousNodes = false;
/** /**
* Implicit names are created to allow implicit bindings to be resolved, * Implicit names are created to allow implicit bindings to be resolved,
* normally they are not visited, set this flag to true to visit them. * normally they are not visited, set this flag to true to visit them.
* @since 5.1 * @since 5.1
*/ */
public boolean shouldVisitImplicitNames = false; public boolean shouldVisitImplicitNames = false;
/** /**
* Sometimes more than one implicit name is created for a binding, * 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. * set this flag to true to visit more than one name for an implicit binding.
* @since 5.1 * @since 5.1
*/ */
public boolean shouldVisitImplicitNameAlternates = false; public boolean shouldVisitImplicitNameAlternates = false;
/** /**
* Creates a visitor that does not visit any kind of node per default. * Creates a visitor that does not visit any kind of node per default.
*/ */
public ASTVisitor() { public ASTVisitor() {
this(false); this(false);
} }
/** /**
* Creates a visitor. * Creates a visitor.
* @param visitNodes whether visitor is setup to visit all nodes per default, except * @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) { public int visit(IASTEnumerator enumerator) {
return PROCESS_CONTINUE; return PROCESS_CONTINUE;
} }
public int visit( IASTProblem problem ){ public int visit( IASTProblem problem ){
return PROCESS_CONTINUE; return PROCESS_CONTINUE;
} }
/** /**
* @since 5.3 * @since 5.3
*/ */
@ -329,6 +326,7 @@ public abstract class ASTVisitor {
public int leave(IASTArrayModifier arrayModifier) { public int leave(IASTArrayModifier arrayModifier) {
return PROCESS_CONTINUE; return PROCESS_CONTINUE;
} }
/** /**
* @since 5.1 * @since 5.1
*/ */
@ -351,11 +349,11 @@ public abstract class ASTVisitor {
public int leave(IASTEnumerator enumerator) { public int leave(IASTEnumerator enumerator) {
return PROCESS_CONTINUE; return PROCESS_CONTINUE;
} }
public int leave(IASTProblem problem){ public int leave(IASTProblem problem){
return PROCESS_CONTINUE; return PROCESS_CONTINUE;
} }
/** /**
* @since 5.3 * @since 5.3
*/ */
@ -398,6 +396,7 @@ public abstract class ASTVisitor {
public int visit( IASTComment comment){ public int visit( IASTComment comment){
return PROCESS_CONTINUE; return PROCESS_CONTINUE;
} }
/** /**
* @deprecated use {@link IASTTranslationUnit#getComments()}, instead. * @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 * 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 * 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. * @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. * @noreference This method is not intended to be referenced by clients.
*/ */

View file

@ -6,18 +6,17 @@
* http://www.eclipse.org/legal/epl-v10.html * http://www.eclipse.org/legal/epl-v10.html
* *
* Contributors: * Contributors:
* Doug Schaefer (IBM) - Initial API and implementation * Doug Schaefer (IBM) - Initial API and implementation
*******************************************************************************/ *******************************************************************************/
package org.eclipse.cdt.core.dom.ast; package org.eclipse.cdt.core.dom.ast;
/** /**
* This is the break clause in a loop. * This is the break clause in a loop.
* *
* @noextend This interface is not intended to be extended by clients. * @noextend This interface is not intended to be extended by clients.
* @noimplement This interface is not intended to be implemented by clients. * @noimplement This interface is not intended to be implemented by clients.
*/ */
public interface IASTBreakStatement extends IASTStatement { public interface IASTBreakStatement extends IASTStatement {
/** /**
* @since 5.1 * @since 5.1
*/ */

View file

@ -6,7 +6,7 @@
* http://www.eclipse.org/legal/epl-v10.html * http://www.eclipse.org/legal/epl-v10.html
* *
* Contributors: * Contributors:
* Doug Schaefer (IBM) - Initial API and implementation * Doug Schaefer (IBM) - Initial API and implementation
*******************************************************************************/ *******************************************************************************/
package org.eclipse.cdt.core.dom.ast; 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. * @noimplement This interface is not intended to be implemented by clients.
*/ */
public interface IASTCaseStatement extends IASTStatement { public interface IASTCaseStatement extends IASTStatement {
/** /**
* <code>ASTNodeProperty</code> that represents the relationship between a * <code>ASTNodeProperty</code> that represents the relationship between a
* case statement and the expression it contains. * 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. * The expression that determines whether this case should be taken.
*
*/ */
public IASTExpression getExpression(); public IASTExpression getExpression();

View file

@ -6,18 +6,17 @@
* http://www.eclipse.org/legal/epl-v10.html * http://www.eclipse.org/legal/epl-v10.html
* *
* Contributors: * Contributors:
* Doug Schaefer (IBM) - Initial API and implementation * Doug Schaefer (IBM) - Initial API and implementation
*******************************************************************************/ *******************************************************************************/
package org.eclipse.cdt.core.dom.ast; package org.eclipse.cdt.core.dom.ast;
/** /**
* This is the continue clause in a loop. * This is the continue clause in a loop.
* *
* @noextend This interface is not intended to be extended by clients. * @noextend This interface is not intended to be extended by clients.
* @noimplement This interface is not intended to be implemented by clients. * @noimplement This interface is not intended to be implemented by clients.
*/ */
public interface IASTContinueStatement extends IASTStatement { public interface IASTContinueStatement extends IASTStatement {
/** /**
* @since 5.1 * @since 5.1
*/ */

View file

@ -6,18 +6,17 @@
* http://www.eclipse.org/legal/epl-v10.html * http://www.eclipse.org/legal/epl-v10.html
* *
* Contributors: * Contributors:
* Doug Schaefer (IBM) - Initial API and implementation * Doug Schaefer (IBM) - Initial API and implementation
*******************************************************************************/ *******************************************************************************/
package org.eclipse.cdt.core.dom.ast; package org.eclipse.cdt.core.dom.ast;
/** /**
* A declaration statement that introduces a declaration. * A declaration statement that introduces a declaration.
* *
* @noextend This interface is not intended to be extended by clients. * @noextend This interface is not intended to be extended by clients.
* @noimplement This interface is not intended to be implemented by clients. * @noimplement This interface is not intended to be implemented by clients.
*/ */
public interface IASTDeclarationStatement extends IASTStatement { public interface IASTDeclarationStatement extends IASTStatement {
/** /**
* <code>DECLARATION</code> represents the relationship between a * <code>DECLARATION</code> represents the relationship between a
* declaration statement and the declaration it wraps. * declaration statement and the declaration it wraps.
@ -27,18 +26,18 @@ public interface IASTDeclarationStatement extends IASTStatement {
/** /**
* Gets the declaration introduced by this statement. * Gets the declaration introduced by this statement.
* *
* @return the declaration * @return the declaration
*/ */
public IASTDeclaration getDeclaration(); public IASTDeclaration getDeclaration();
/** /**
* Set the declaration for this statement. * Set the declaration for this statement.
* *
* @param declaration * @param declaration
*/ */
public void setDeclaration(IASTDeclaration declaration); public void setDeclaration(IASTDeclaration declaration);
/** /**
* @since 5.1 * @since 5.1
*/ */
@ -50,5 +49,4 @@ public interface IASTDeclarationStatement extends IASTStatement {
*/ */
@Override @Override
public IASTDeclarationStatement copy(CopyStyle style); public IASTDeclarationStatement copy(CopyStyle style);
} }

View file

@ -6,7 +6,7 @@
* http://www.eclipse.org/legal/epl-v10.html * http://www.eclipse.org/legal/epl-v10.html
* *
* Contributors: * Contributors:
* Doug Schaefer (IBM) - Initial API and implementation * Doug Schaefer (IBM) - Initial API and implementation
*******************************************************************************/ *******************************************************************************/
package org.eclipse.cdt.core.dom.ast; 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. * @noimplement This interface is not intended to be implemented by clients.
*/ */
public interface IASTDefaultStatement extends IASTStatement { public interface IASTDefaultStatement extends IASTStatement {
/** /**
* @since 5.1 * @since 5.1
*/ */

View file

@ -6,24 +6,24 @@
* http://www.eclipse.org/legal/epl-v10.html * http://www.eclipse.org/legal/epl-v10.html
* *
* Contributors: * Contributors:
* Doug Schaefer (IBM) - Initial API and implementation * Doug Schaefer (IBM) - Initial API and implementation
*******************************************************************************/ *******************************************************************************/
package org.eclipse.cdt.core.dom.ast; package org.eclipse.cdt.core.dom.ast;
/** /**
* Ye ol' do statement. * Ye ol' do statement.
* *
* @noextend This interface is not intended to be extended by clients. * @noextend This interface is not intended to be extended by clients.
* @noimplement This interface is not intended to be implemented by clients. * @noimplement This interface is not intended to be implemented by clients.
*/ */
public interface IASTDoStatement extends IASTStatement { public interface IASTDoStatement extends IASTStatement {
/** /**
* <code>BODY</code> represents the relationship between a * <code>BODY</code> represents the relationship between a
* <code>IASTDoStatement</code> and its nested body * <code>IASTDoStatement</code> and its nested body
* <code>IASTStatement</code>. * <code>IASTStatement</code>.
*/ */
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$
/** /**
* <code>CONDITION</code> represents the relationship between a * <code>CONDITION</code> represents the relationship between a
@ -35,14 +35,14 @@ public interface IASTDoStatement extends IASTStatement {
/** /**
* Get the body of the loop. * Get the body of the loop.
* *
* @return <code>IASTStatement</code> loop code body * @return <code>IASTStatement</code> loop code body
*/ */
public IASTStatement getBody(); public IASTStatement getBody();
/** /**
* Set the body of the loop. * Set the body of the loop.
* *
* @param body * @param body
* an <code>IASTStatement</code> * an <code>IASTStatement</code>
*/ */
@ -50,19 +50,19 @@ public interface IASTDoStatement extends IASTStatement {
/** /**
* The condition on the loop. * The condition on the loop.
* *
* @return the expression for the condition * @return the expression for the condition
*/ */
public IASTExpression getCondition(); public IASTExpression getCondition();
/** /**
* Set the condition for the loop. * Set the condition for the loop.
* *
* @param condition * @param condition
* an IASTExpression * an IASTExpression
*/ */
public void setCondition(IASTExpression condition); public void setCondition(IASTExpression condition);
/** /**
* @since 5.1 * @since 5.1
*/ */
@ -74,5 +74,4 @@ public interface IASTDoStatement extends IASTStatement {
*/ */
@Override @Override
public IASTDoStatement copy(CopyStyle style); public IASTDoStatement copy(CopyStyle style);
} }

View file

@ -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. * 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. * All interfaces that claim ownership/residence of a name should extend this interface.
* *
* @noextend This interface is not intended to be extended by clients. * @noextend This interface is not intended to be extended by clients.
* @noimplement This interface is not intended to be implemented by clients. * @noimplement This interface is not intended to be implemented by clients.
*/ */
public interface IASTNameOwner { public interface IASTNameOwner {
/** /**
* Role of name in this context is a declaration. * 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. * Role of name in this construct is a reference.
*/ */
public static final int r_reference = 1; 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; public static final int r_definition = 2;
/** /**
* Role is unclear. * 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. * @param name the name to determine the role for.
* @return r_definition, r_declaration, r_reference or r_unclear. * @return r_definition, r_declaration, r_reference or r_unclear.
*/ */
public int getRoleForName(IASTName name); public int getRoleForName(IASTName name);
} }

View file

@ -6,7 +6,7 @@
* http://www.eclipse.org/legal/epl-v10.html * http://www.eclipse.org/legal/epl-v10.html
* *
* Contributors: * Contributors:
* Doug Schaefer (IBM) - Initial API and implementation * Doug Schaefer (IBM) - Initial API and implementation
*******************************************************************************/ *******************************************************************************/
package org.eclipse.cdt.core.dom.ast; package org.eclipse.cdt.core.dom.ast;
@ -33,5 +33,4 @@ public interface IASTStatement extends IASTNode {
*/ */
@Override @Override
public IASTStatement copy(CopyStyle style); public IASTStatement copy(CopyStyle style);
} }

View file

@ -6,7 +6,7 @@
* http://www.eclipse.org/legal/epl-v10.html * http://www.eclipse.org/legal/epl-v10.html
* *
* Contributors: * Contributors:
* Doug Schaefer (IBM) - Initial API and implementation * Doug Schaefer (IBM) - Initial API and implementation
*******************************************************************************/ *******************************************************************************/
package org.eclipse.cdt.core.dom.ast; 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. * @noimplement This interface is not intended to be implemented by clients.
*/ */
public interface IASTSwitchStatement extends IASTStatement { public interface IASTSwitchStatement extends IASTStatement {
/** /**
* <code>CONTROLLER_EXP</code> represents the relationship between an * <code>CONTROLLER_EXP</code> represents the relationship between an
* <code>IASTSwitchStatement</code> and it's nested * <code>IASTSwitchStatement</code> and it's nested

View file

@ -6,8 +6,8 @@
* http://www.eclipse.org/legal/epl-v10.html * http://www.eclipse.org/legal/epl-v10.html
* *
* Contributors: * Contributors:
* IBM - Initial API and implementation * IBM - Initial API and implementation
* Markus Schorn (Wind River Systems) * Markus Schorn (Wind River Systems)
*******************************************************************************/ *******************************************************************************/
package org.eclipse.cdt.core.dom.ast; 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. * Represents the semantics of a name found in the AST or the index.
* *
* @noextend This interface is not intended to be extended by clients. * @noextend This interface is not intended to be extended by clients.
* @noimplement This interface is not intended to be implemented 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. * Returns the unqualified name of the binding as a string.
*/ */
public String getName(); public String getName();
/** /**
* Returns the unqualified name of the binding as an array of characters. * Returns the unqualified name of the binding as an array of characters.
*/ */
public char[] getNameCharArray(); public char[] getNameCharArray();
/** /**
* Returns the linkage the binding belongs to. C++-declarations declared as * Returns the linkage the binding belongs to. C++-declarations declared as
* extern "C" will still return c++-linkage. * extern "C" will still return c++-linkage.
*/ */
public ILinkage getLinkage(); public ILinkage getLinkage();
/** /**
* Returns the binding that owns this binding, or <code>null</code> if there is no owner. * Returns the binding that owns this binding, or <code>null</code> if there is no owner.
* <p> * <p>
* The owner is determined as follows: * The owner is determined as follows:
* <br> {@link ICPPUsingDeclaration}: The owner depends on where the declaration is found, within a * <br> {@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. * function or method, a class-type, a namespace or on global scope.
* <br> {@link ICPPTemplateParameter}: The owner is the {@link ICPPTemplateDefinition}. * <br> {@link ICPPTemplateParameter}: The owner is the {@link ICPPTemplateDefinition}.
* <br> {@link IEnumerator}: The owner is the {@link IEnumeration}, independent of whether they are scoped or not. * <br> {@link IEnumerator}: The owner is the {@link IEnumeration}, independent of whether they are scoped or not.
* <br> For all other bindings: The owner depends on where the binding can be defined (it could be * <br> For all other bindings: The owner depends on where the binding can be defined (it could be
* declared else where). * declared else where).
* <p> Possible owners are: * <p> Possible owners are:
* <br> {@link IFunction}: for parameters, local types, variables, enumerators, labels and using declarations; * <br> {@link IFunction}: for parameters, local types, variables, enumerators, labels and using declarations;
* <br> {@link ICPPClassType}: for class-, struct- and union-members, even if the composite type is anonymous; * <br> {@link ICPPClassType}: for class-, struct- and union-members, even if the composite type is anonymous;
* also for enumerators and using declarations; * also for enumerators and using declarations;
* <br> {@link ICompositeType}: for struct- and union-members, even if the composite type is anonymous; * <br> {@link ICompositeType}: for struct- and union-members, even if the composite type is anonymous;
* also for anonymous structs or unions found within another struct; * also for anonymous structs or unions found within another struct;
* <br> {@link ICPPNamespace}: for global types, functions, variables, enumerators, namespaces and using declarations; * <br> {@link ICPPNamespace}: for global types, functions, variables, enumerators, namespaces and using declarations;
* <br> {@link IEnumeration}: for enumerators. * <br> {@link IEnumeration}: for enumerators.
@ -66,10 +66,10 @@ public interface IBinding extends IAdaptable {
* @since 5.1 * @since 5.1
*/ */
public IBinding getOwner(); public IBinding getOwner();
/** /**
* Returns the parent scope for this binding. A binding may have declarations in multiple scopes, * 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; public IScope getScope() throws DOMException;
} }

View file

@ -6,7 +6,7 @@
* http://www.eclipse.org/legal/epl-v10.html * http://www.eclipse.org/legal/epl-v10.html
* *
* Contributors: * Contributors:
* John Camelon (IBM) - Initial API and implementation * John Camelon (IBM) - Initial API and implementation
*******************************************************************************/ *******************************************************************************/
package org.eclipse.cdt.core.dom.ast.cpp; 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++. * This interface is a qualified name in C++.
* *
* @noextend This interface is not intended to be extended by clients. * @noextend This interface is not intended to be extended by clients.
* @noimplement This interface is not intended to be implemented by clients. * @noimplement This interface is not intended to be implemented by clients.
*/ */
public interface ICPPASTQualifiedName extends IASTName, IASTNameOwner { public interface ICPPASTQualifiedName extends IASTName, IASTNameOwner {
/** /**
* Each IASTName segment has property being <code>SEGMENT_NAME</code>. * Each IASTName segment has property being <code>SEGMENT_NAME</code>.
*/ */
@ -30,48 +29,44 @@ public interface ICPPASTQualifiedName extends IASTName, IASTNameOwner {
/** /**
* Add a subname. * Add a subname.
* *
* @param name * @param name <code>IASTName</code>
* <code>IASTName</code>
*/ */
public void addName(IASTName name); public void addName(IASTName name);
/** /**
* Get all subnames. * Get all subnames.
* *
* @return <code>IASTName []</code> * @return <code>IASTName []</code>
*/ */
public IASTName[] getNames(); public IASTName[] getNames();
/** /**
* The last name is often semantically significant. * The last name is often semantically significant.
*
*/ */
@Override @Override
public IASTName getLastName(); public IASTName getLastName();
/** /**
* Is this name fully qualified? * Is this name fully qualified?
* *
* @return boolean * @return boolean
*/ */
public boolean isFullyQualified(); public boolean isFullyQualified();
/** /**
* Set this name to be fully qualified or not (true/false). * Set this name to be fully qualified or not (true/false).
* *
* @param value * @param value boolean
* boolean
*/ */
public void setFullyQualified(boolean value); public void setFullyQualified(boolean value);
/** /**
* This is used to check if the ICPPASTQualifiedName's last segment is * This is used to check if the ICPPASTQualifiedName's last segment is
* an ICPPASTConversionName or an ICPPASTOperatorName. * an ICPPASTConversionName or an ICPPASTOperatorName.
*
*/ */
public boolean isConversionOrOperator(); public boolean isConversionOrOperator();
/** /**
* @since 5.1 * @since 5.1
*/ */

View file

@ -6,9 +6,8 @@
* http://www.eclipse.org/legal/epl-v10.html * http://www.eclipse.org/legal/epl-v10.html
* *
* Contributors: * Contributors:
* Markus Schorn - initial API and implementation * Markus Schorn - initial API and implementation
*******************************************************************************/ *******************************************************************************/
package org.eclipse.cdt.core.dom.ast.cpp; package org.eclipse.cdt.core.dom.ast.cpp;
import org.eclipse.cdt.core.dom.ast.ASTNodeProperty; 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. * Represents a range-based for loop.
* *
* @noextend This interface is not intended to be extended by clients. * @noextend This interface is not intended to be extended by clients.
* @noimplement This interface is not intended to be implemented by clients. * @noimplement This interface is not intended to be implemented by clients.
* @since 5.3 * @since 5.3
@ -33,17 +32,16 @@ public interface ICPPASTRangeBasedForStatement extends IASTStatement, IASTImplic
public static final ASTNodeProperty BODY = new ASTNodeProperty( public static final ASTNodeProperty BODY = new ASTNodeProperty(
"ICPPASTRangeBasedForStatement.BODY [IASTStatement]"); //$NON-NLS-1$ "ICPPASTRangeBasedForStatement.BODY [IASTStatement]"); //$NON-NLS-1$
/** /**
* Returns the for-range-declaration * Returns the for-range-declaration
*/ */
IASTDeclaration getDeclaration(); IASTDeclaration getDeclaration();
/** /**
* Returns the for-range-initializer. * Returns the for-range-initializer.
*/ */
IASTInitializerClause getInitializerClause(); IASTInitializerClause getInitializerClause();
/** /**
* Returns the statement of this for-loop. * Returns the statement of this for-loop.
*/ */
@ -60,7 +58,6 @@ public interface ICPPASTRangeBasedForStatement extends IASTStatement, IASTImplic
@Override @Override
public ICPPASTRangeBasedForStatement copy(CopyStyle style); public ICPPASTRangeBasedForStatement copy(CopyStyle style);
/** /**
* Not allowed on frozen AST. * Not allowed on frozen AST.
*/ */
@ -70,7 +67,7 @@ public interface ICPPASTRangeBasedForStatement extends IASTStatement, IASTImplic
* Not allowed on frozen AST. * Not allowed on frozen AST.
*/ */
void setInitializerClause(IASTInitializerClause statement); void setInitializerClause(IASTInitializerClause statement);
/** /**
* Not allowed on frozen AST. * Not allowed on frozen AST.
*/ */

View file

@ -8,7 +8,7 @@
* Contributors: * Contributors:
* John Camelon - Initial API and implementation * John Camelon - Initial API and implementation
* Markus Schorn (Wind River Systems) * Markus Schorn (Wind River Systems)
* Sergey Prigoin (Google) * Sergey Prigogin (Google)
*******************************************************************************/ *******************************************************************************/
package org.eclipse.cdt.internal.core.dom.parser; package org.eclipse.cdt.internal.core.dom.parser;
@ -51,60 +51,60 @@ public abstract class ASTNode implements IASTNode {
private boolean frozen = false; private boolean frozen = false;
private boolean active = true; private boolean active = true;
@Override @Override
public IASTNode getParent() { public IASTNode getParent() {
return parent; return parent;
} }
@Override @Override
public IASTNode[] getChildren() { public IASTNode[] getChildren() {
ChildCollector collector= new ChildCollector(this); ChildCollector collector= new ChildCollector(this);
return collector.getChildren(); return collector.getChildren();
} }
@Override @Override
public boolean isFrozen() { public boolean isFrozen() {
return frozen; return frozen;
} }
@Override @Override
public boolean isActive() { public boolean isActive() {
return active; return active;
} }
void setIsFrozen() { void setIsFrozen() {
frozen = true; frozen = true;
} }
public void setInactive() { public void setInactive() {
if (frozen) if (frozen)
throw new IllegalStateException("attempt to modify frozen AST node"); //$NON-NLS-1$ throw new IllegalStateException("attempt to modify frozen AST node"); //$NON-NLS-1$
active= false; active= false;
} }
protected void assertNotFrozen() throws IllegalStateException { protected void assertNotFrozen() throws IllegalStateException {
if (frozen) if (frozen)
throw new IllegalStateException("attempt to modify frozen AST node"); //$NON-NLS-1$ throw new IllegalStateException("attempt to modify frozen AST node"); //$NON-NLS-1$
} }
@Override @Override
public void setParent(IASTNode node) { public void setParent(IASTNode node) {
assertNotFrozen(); assertNotFrozen();
this.parent = node; this.parent = node;
} }
@Override @Override
public ASTNodeProperty getPropertyInParent() { public ASTNodeProperty getPropertyInParent() {
return property; return property;
} }
@Override @Override
public void setPropertyInParent(ASTNodeProperty property) { public void setPropertyInParent(ASTNodeProperty property) {
assertNotFrozen(); assertNotFrozen();
this.property = property; this.property = property;
} }
public int getOffset() { public int getOffset() {
return offset; return offset;
} }
@ -219,7 +219,7 @@ public abstract class ASTNode implements IASTNode {
} }
return fileLocation; return fileLocation;
} }
@Override @Override
public boolean isPartOfTranslationUnitFile() { public boolean isPartOfTranslationUnitFile() {
IASTTranslationUnit ast = getTranslationUnit(); IASTTranslationUnit ast = getTranslationUnit();
@ -231,7 +231,7 @@ public abstract class ASTNode implements IASTNode {
} }
return false; return false;
} }
public boolean isPartOfSourceFile() { public boolean isPartOfSourceFile() {
IASTTranslationUnit ast = getTranslationUnit(); IASTTranslationUnit ast = getTranslationUnit();
if (ast != null) { if (ast != null) {
@ -242,7 +242,7 @@ public abstract class ASTNode implements IASTNode {
} }
return false; return false;
} }
@Override @Override
public IASTTranslationUnit getTranslationUnit() { public IASTTranslationUnit getTranslationUnit() {
return parent != null ? parent.getTranslationUnit() : null; return parent != null ? parent.getTranslationUnit() : null;
@ -252,7 +252,7 @@ public abstract class ASTNode implements IASTNode {
public boolean accept(ASTVisitor visitor) { public boolean accept(ASTVisitor visitor) {
return true; return true;
} }
@Override @Override
public boolean contains(IASTNode node) { public boolean contains(IASTNode node) {
if (node instanceof ASTNode) { if (node instanceof ASTNode) {
@ -281,7 +281,7 @@ public abstract class ASTNode implements IASTNode {
int right= getBoundary(1); int right= getBoundary(1);
return getSyntax(getOffset() + length, right, 1); return getSyntax(getOffset() + length, right, 1);
} }
/** /**
* Compute the sequence number of the boundary of the leading/trailing syntax. * 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 { private IToken getSyntax(int fromSequenceNumber, int nextSequenceNumber, int direction) throws ExpansionOverlapsBoundaryException {
final IASTTranslationUnit tu= getTranslationUnit(); final IASTTranslationUnit tu= getTranslationUnit();
if (!(tu instanceof ASTNode)) if (!(tu instanceof ASTNode))
throw new UnsupportedOperationException();
ILocationResolver lr= (ILocationResolver) tu.getAdapter(ILocationResolver.class);
if (lr == null)
throw new UnsupportedOperationException(); 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 total= lr.getMappedFileLocation(fromSequenceNumber, endSequenceNumber - fromSequenceNumber);
IASTFileLocation myfloc= getFileLocation(); IASTFileLocation myfloc= getFileLocation();
if (total == null || myfloc == null) if (total == null || myfloc == null)
throw new UnsupportedOperationException(); throw new UnsupportedOperationException();
if (!total.getFileName().equals(myfloc.getFileName())) if (!total.getFileName().equals(myfloc.getFileName()))
throw new ExpansionOverlapsBoundaryException(); throw new ExpansionOverlapsBoundaryException();
if (fromSequenceNumber > 0) { if (fromSequenceNumber > 0) {
IASTFileLocation fl= lr.getMappedFileLocation(fromSequenceNumber-1, endSequenceNumber - fromSequenceNumber + 1); 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(); throw new ExpansionOverlapsBoundaryException();
} }
if (endSequenceNumber < ((ASTNode) tu).getOffset() + ((ASTNode) tu).getLength()) { if (endSequenceNumber < ((ASTNode) tu).getOffset() + ((ASTNode) tu).getLength()) {
IASTFileLocation fl= lr.getMappedFileLocation(fromSequenceNumber, nextSequenceNumber - fromSequenceNumber + 1); 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(); throw new ExpansionOverlapsBoundaryException();
} }
int adjustment= total.getNodeOffset() - myfloc.getNodeOffset(); int adjustment= total.getNodeOffset() - myfloc.getNodeOffset();
if (direction > 0) { if (direction > 0) {
adjustment-= myfloc.getNodeLength(); adjustment-= myfloc.getNodeLength();
} }
char[] txt= lr.getUnpreprocessedSignature(total); char[] txt= lr.getUnpreprocessedSignature(total);
Lexer lex= new Lexer(txt, (LexerOptions) tu.getAdapter(LexerOptions.class), ILexerLog.NULL, null); Lexer lex= new Lexer(txt, (LexerOptions) tu.getAdapter(LexerOptions.class), ILexerLog.NULL, null);
try { try {
Token result= null; Token result= null;
Token last= null; Token last= null;
while (true) { while (true) {
Token t= lex.nextToken(); Token t= lex.nextToken();
switch (t.getType()) { switch (t.getType()) {
case IToken.tEND_OF_INPUT: case IToken.tEND_OF_INPUT:

View file

@ -7,7 +7,7 @@
* *
* Contributors: * Contributors:
* Markus Schorn - initial API and implementation * Markus Schorn - initial API and implementation
*******************************************************************************/ *******************************************************************************/
package org.eclipse.cdt.internal.core.dom.parser; package org.eclipse.cdt.internal.core.dom.parser;
import org.eclipse.cdt.core.dom.ast.IASTFileLocation; 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; 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. * determine whether a node matches or not.
* *
* @since 5.0 * @since 5.0
*/ */
public class ASTNodeSpecification<T extends IASTNode> { public class ASTNodeSpecification<T extends IASTNode> {
public enum Relation {FIRST_CONTAINED, EXACT_MATCH, ENCLOSING, STRICTLY_ENCLOSING} public enum Relation { FIRST_CONTAINED, EXACT_MATCH, ENCLOSING, STRICTLY_ENCLOSING }
private final Class<T> fClass; private final Class<T> fClass;
private final Relation fRelation; private final Relation fRelation;
@ -36,7 +36,7 @@ public class ASTNodeSpecification<T extends IASTNode> {
private T fBestNode; private T fBestNode;
private boolean fSearchInExpansion; private boolean fSearchInExpansion;
private boolean fZeroToLeft= false; private boolean fZeroToLeft= false;
public ASTNodeSpecification(Relation relation, Class<T> clazz, int fileOffset, int fileLength) { public ASTNodeSpecification(Relation relation, Class<T> clazz, int fileOffset, int fileLength) {
fRelation= relation; fRelation= relation;
fClass= clazz; fClass= clazz;
@ -53,7 +53,7 @@ public class ASTNodeSpecification<T extends IASTNode> {
setRangeInSequence(offsetInSeq, lengthInSeq); setRangeInSequence(offsetInSeq, lengthInSeq);
fZeroToLeft= zeroRangeToLeft; fZeroToLeft= zeroRangeToLeft;
} }
public void setSearchInExpansion(boolean searchInExpansion) { public void setSearchInExpansion(boolean searchInExpansion) {
fSearchInExpansion= searchInExpansion; fSearchInExpansion= searchInExpansion;
} }
@ -77,7 +77,7 @@ public class ASTNodeSpecification<T extends IASTNode> {
public boolean requiresClass(Class<? extends IASTNode> clazz) { public boolean requiresClass(Class<? extends IASTNode> clazz) {
return clazz.isAssignableFrom(fClass); return clazz.isAssignableFrom(fClass);
} }
@SuppressWarnings("unchecked") @SuppressWarnings("unchecked")
public void visit(ASTNode astNode) { public void visit(ASTNode astNode) {
if (isAcceptableNode(astNode) && isMatchingRange(astNode.getOffset(), astNode.getLength(), fSeqNumber, fSeqEndNumber)) { if (isAcceptableNode(astNode) && isMatchingRange(astNode.getOffset(), astNode.getLength(), fSeqNumber, fSeqEndNumber)) {
@ -87,6 +87,7 @@ public class ASTNodeSpecification<T extends IASTNode> {
} }
} }
} }
@SuppressWarnings("unchecked") @SuppressWarnings("unchecked")
public void visit(ASTNode astNode, IASTImageLocation imageLocation) { public void visit(ASTNode astNode, IASTImageLocation imageLocation) {
if (isAcceptableNode(astNode) && imageLocation != null) { if (isAcceptableNode(astNode) && imageLocation != null) {
@ -109,16 +110,16 @@ public class ASTNodeSpecification<T extends IASTNode> {
if (offset <= selOffset && selEndOffset <= endOffset) { if (offset <= selOffset && selEndOffset <= endOffset) {
return offset != selOffset || selEndOffset != endOffset; return offset != selOffset || selEndOffset != endOffset;
} }
return false; return false;
} }
assert false; assert false;
return false; return false;
} }
public boolean isAcceptableNode(IASTNode astNode) { public boolean isAcceptableNode(IASTNode astNode) {
if (astNode == null || !fClass.isAssignableFrom(astNode.getClass())) if (astNode == null || !fClass.isAssignableFrom(astNode.getClass()))
return false; return false;
if (fSearchInExpansion) { if (fSearchInExpansion) {
IASTNode check= astNode instanceof IASTName ? astNode.getParent() : astNode; IASTNode check= astNode instanceof IASTName ? astNode.getParent() : astNode;
if (check instanceof IASTPreprocessorMacroExpansion) { if (check instanceof IASTPreprocessorMacroExpansion) {
@ -129,7 +130,7 @@ public class ASTNodeSpecification<T extends IASTNode> {
} }
/** /**
* 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) { public boolean canContainMatches(ASTNode node) {
final int offset= node.getOffset(); final int offset= node.getOffset();
@ -142,7 +143,7 @@ public class ASTNodeSpecification<T extends IASTNode> {
if (offset <= fSeqNumber && fSeqEndNumber <= endOffset) { if (offset <= fSeqNumber && fSeqEndNumber <= endOffset) {
return offset != fSeqNumber || fSeqEndNumber != endOffset; return offset != fSeqNumber || fSeqEndNumber != endOffset;
} }
return false; return false;
case FIRST_CONTAINED: case FIRST_CONTAINED:
return offset <= fSeqEndNumber && fSeqNumber <= endOffset; return offset <= fSeqEndNumber && fSeqNumber <= endOffset;
} }
@ -163,14 +164,14 @@ public class ASTNodeSpecification<T extends IASTNode> {
} }
/** /**
* 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. * than the best match stored.
*/ */
private boolean isBetterMatch(int offset, int length, IASTNode cand) { private boolean isBetterMatch(int offset, int length, IASTNode cand) {
if (fBestNode == null) { if (fBestNode == null) {
return true; return true;
} }
final int endOffset= offset+length; final int endOffset= offset+length;
switch(fRelation) { switch(fRelation) {
case EXACT_MATCH: case EXACT_MATCH:
@ -186,8 +187,8 @@ public class ASTNodeSpecification<T extends IASTNode> {
return endOffset == fBestEndOffset && isParent(fBestNode, cand); return endOffset == fBestEndOffset && isParent(fBestNode, cand);
} }
return false; return false;
case ENCLOSING: case ENCLOSING:
case STRICTLY_ENCLOSING: case STRICTLY_ENCLOSING:
final int bestLength= fBestEndOffset-fBestOffset; final int bestLength= fBestEndOffset-fBestOffset;
if (length < bestLength) { if (length < bestLength) {
return true; return true;
@ -213,7 +214,7 @@ public class ASTNodeSpecification<T extends IASTNode> {
IASTPreprocessorMacroExpansion exp= nodeSelector.findEnclosingMacroExpansion(fZeroToLeft ? fFileOffset-1 : fFileOffset, 1); IASTPreprocessorMacroExpansion exp= nodeSelector.findEnclosingMacroExpansion(fZeroToLeft ? fFileOffset-1 : fFileOffset, 1);
if (fRelation == Relation.ENCLOSING || fRelation == Relation.STRICTLY_ENCLOSING) if (fRelation == Relation.ENCLOSING || fRelation == Relation.STRICTLY_ENCLOSING)
return exp; return exp;
if (exp != null) { if (exp != null) {
IASTFileLocation loc= exp.getFileLocation(); IASTFileLocation loc= exp.getFileLocation();
if (loc != null) { if (loc != null) {
@ -230,7 +231,7 @@ public class ASTNodeSpecification<T extends IASTNode> {
IASTPreprocessorMacroExpansion exp= nodeSelector.findEnclosingMacroExpansion(fFileEndOffset==fFileOffset && !fZeroToLeft ? fFileEndOffset : fFileEndOffset-1, 1); IASTPreprocessorMacroExpansion exp= nodeSelector.findEnclosingMacroExpansion(fFileEndOffset==fFileOffset && !fZeroToLeft ? fFileEndOffset : fFileEndOffset-1, 1);
if (fRelation == Relation.ENCLOSING || fRelation == Relation.STRICTLY_ENCLOSING) if (fRelation == Relation.ENCLOSING || fRelation == Relation.STRICTLY_ENCLOSING)
return exp; return exp;
if (exp != null) { if (exp != null) {
IASTFileLocation loc= exp.getFileLocation(); IASTFileLocation loc= exp.getFileLocation();
if (loc != null) { if (loc != null) {

View file

@ -6,7 +6,7 @@
* http://www.eclipse.org/legal/epl-v10.html * http://www.eclipse.org/legal/epl-v10.html
* *
* Contributors: * Contributors:
* IBM - Initial API and implementation * IBM - Initial API and implementation
*******************************************************************************/ *******************************************************************************/
package org.eclipse.cdt.internal.core.dom.parser.cpp; package org.eclipse.cdt.internal.core.dom.parser.cpp;
@ -18,24 +18,22 @@ import org.eclipse.cdt.internal.core.dom.parser.ASTNode;
* @author jcamelon * @author jcamelon
*/ */
public class CPPASTBreakStatement extends ASTNode implements IASTBreakStatement { public class CPPASTBreakStatement extends ASTNode implements IASTBreakStatement {
@Override @Override
public boolean accept( ASTVisitor action ){ public boolean accept(ASTVisitor action) {
if( action.shouldVisitStatements ){ if (action.shouldVisitStatements) {
switch( action.visit( this ) ){ switch (action.visit(this)) {
case ASTVisitor.PROCESS_ABORT : return false; case ASTVisitor.PROCESS_ABORT: return false;
case ASTVisitor.PROCESS_SKIP : return true; case ASTVisitor.PROCESS_SKIP: return true;
default : break; default: break;
} }
} }
if( action.shouldVisitStatements ){ if (action.shouldVisitStatements) {
switch( action.leave( this ) ){ switch (action.leave(this)) {
case ASTVisitor.PROCESS_ABORT : return false; case ASTVisitor.PROCESS_ABORT: return false;
case ASTVisitor.PROCESS_SKIP : return true; case ASTVisitor.PROCESS_SKIP: return true;
default : break; default: break;
} }
} }
return true; return true;
} }

View file

@ -6,8 +6,8 @@
* http://www.eclipse.org/legal/epl-v10.html * http://www.eclipse.org/legal/epl-v10.html
* *
* Contributors: * Contributors:
* John Camelon (IBM) - Initial API and implementation * John Camelon (IBM) - Initial API and implementation
* Markus Schorn (Wind River Systems) * Markus Schorn (Wind River Systems)
*******************************************************************************/ *******************************************************************************/
package org.eclipse.cdt.internal.core.dom.parser.cpp; 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; import org.eclipse.cdt.internal.core.dom.parser.IASTAmbiguityParent;
public class CPPASTReturnStatement extends ASTNode implements IASTReturnStatement, IASTAmbiguityParent { public class CPPASTReturnStatement extends ASTNode implements IASTReturnStatement, IASTAmbiguityParent {
private IASTInitializerClause retValue; private IASTInitializerClause retValue;
public CPPASTReturnStatement() { public CPPASTReturnStatement() {
} }
@ -34,11 +33,11 @@ public class CPPASTReturnStatement extends ASTNode implements IASTReturnStatemen
public CPPASTReturnStatement copy() { public CPPASTReturnStatement copy() {
return copy(CopyStyle.withoutLocations); return copy(CopyStyle.withoutLocations);
} }
@Override @Override
public CPPASTReturnStatement copy(CopyStyle style) { public CPPASTReturnStatement copy(CopyStyle style) {
CPPASTReturnStatement copy = new CPPASTReturnStatement(retValue == null ? null CPPASTReturnStatement copy =
: retValue.copy(style)); new CPPASTReturnStatement(retValue == null ? null : retValue.copy(style));
copy.setOffsetAndLength(this); copy.setOffsetAndLength(this);
if (style == CopyStyle.withLocations) { if (style == CopyStyle.withLocations) {
copy.setCopyLocation(this); copy.setCopyLocation(this);
@ -50,7 +49,7 @@ public class CPPASTReturnStatement extends ASTNode implements IASTReturnStatemen
public IASTInitializerClause getReturnArgument() { public IASTInitializerClause getReturnArgument() {
return retValue; return retValue;
} }
@Override @Override
public IASTExpression getReturnValue() { public IASTExpression getReturnValue() {
if (retValue instanceof IASTExpression) { if (retValue instanceof IASTExpression) {
@ -59,12 +58,11 @@ public class CPPASTReturnStatement extends ASTNode implements IASTReturnStatemen
return null; return null;
} }
@Override @Override
public void setReturnValue(IASTExpression returnValue) { public void setReturnValue(IASTExpression returnValue) {
setReturnArgument(returnValue); setReturnArgument(returnValue);
} }
@Override @Override
public void setReturnArgument(IASTInitializerClause arg) { public void setReturnArgument(IASTInitializerClause arg) {
assertNotFrozen(); assertNotFrozen();
@ -89,12 +87,12 @@ public class CPPASTReturnStatement extends ASTNode implements IASTReturnStatemen
} }
if (retValue != null && !retValue.accept(action)) if (retValue != null && !retValue.accept(action))
return false; return false;
if( action.shouldVisitStatements ){ if (action.shouldVisitStatements) {
switch( action.leave( this ) ){ switch (action.leave(this)) {
case ASTVisitor.PROCESS_ABORT : return false; case ASTVisitor.PROCESS_ABORT: return false;
case ASTVisitor.PROCESS_SKIP : return true; case ASTVisitor.PROCESS_SKIP: return true;
default : break; default: break;
} }
} }
return true; return true;

View file

@ -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 * Rapperswil, University of applied sciences and others
* All rights reserved. This program and the accompanying materials * All rights reserved. This program and the accompanying materials
* are made available under the terms of the Eclipse Public License v1.0 * are made available under the terms of the Eclipse Public License v1.0
* which accompanies this distribution, and is available at * which accompanies this distribution, and is available at
* http://www.eclipse.org/legal/epl-v10.html * http://www.eclipse.org/legal/epl-v10.html
* *
* Contributors: * Contributors:
* Institute for Software - initial API and implementation * Institute for Software - initial API and implementation
* Sergey Prigogin (Google) * Sergey Prigogin (Google)
*******************************************************************************/ *******************************************************************************/
@ -19,7 +19,6 @@ import java.util.List;
import java.util.Set; import java.util.Set;
import org.eclipse.core.resources.IProject; import org.eclipse.core.resources.IProject;
import org.eclipse.core.runtime.ILog;
import org.eclipse.core.runtime.IStatus; import org.eclipse.core.runtime.IStatus;
import org.eclipse.core.runtime.Platform; import org.eclipse.core.runtime.Platform;
import org.eclipse.core.runtime.Status; import org.eclipse.core.runtime.Status;
@ -92,7 +91,7 @@ public class NodeContainer {
public int visit(IASTName name) { public int visit(IASTName name) {
if (name.getPropertyInParent() != IASTFieldReference.FIELD_NAME) { if (name.getPropertyInParent() != IASTFieldReference.FIELD_NAME) {
IBinding binding = name.resolveBinding(); IBinding binding = name.resolveBinding();
if (binding instanceof ICPPBinding && !(binding instanceof ICPPTemplateTypeParameter)) { if (binding instanceof ICPPBinding && !(binding instanceof ICPPTemplateTypeParameter)) {
ICPPBinding cppBinding = (ICPPBinding) binding; ICPPBinding cppBinding = (ICPPBinding) binding;
try { try {
@ -106,14 +105,13 @@ public class NodeContainer {
names.add(nameInfo); names.add(nameInfo);
} }
} catch (DOMException e) { } catch (DOMException e) {
ILog logger = CUIPlugin.getDefault().getLog();
IStatus status = new Status(IStatus.WARNING, CUIPlugin.PLUGIN_ID, IStatus status = new Status(IStatus.WARNING, CUIPlugin.PLUGIN_ID,
e.getMessage(), e); e.getMessage(), e);
logger.log(status); CUIPlugin.log(status);
} }
} else if (binding instanceof IVariable) { } else if (binding instanceof IVariable) {
NameInformation nameInformation = new NameInformation(name); NameInformation nameInformation = new NameInformation(name);
IASTName[] refs = name.getTranslationUnit().getReferences(binding); IASTName[] refs = name.getTranslationUnit().getReferences(binding);
for (IASTName ref : refs) { for (IASTName ref : refs) {
nameInformation.addReference(ref, startOffset, endOffset); nameInformation.addReference(ref, startOffset, endOffset);
@ -129,8 +127,8 @@ public class NodeContainer {
for (NameInformation nameInfo : names) { for (NameInformation nameInfo : names) {
IASTName name = nameInfo.getName(); IASTName name = nameInfo.getName();
IASTTranslationUnit unit = name.getTranslationUnit(); IASTTranslationUnit ast = name.getTranslationUnit();
IASTName[] nameDeclarations = unit.getDeclarationsInAST(name.resolveBinding()); IASTName[] nameDeclarations = ast.getDeclarationsInAST(name.resolveBinding());
if (nameDeclarations.length != 0) { if (nameDeclarations.length != 0) {
nameInfo.setDeclarationName(nameDeclarations[nameDeclarations.length - 1]); nameInfo.setDeclarationName(nameDeclarations[nameDeclarations.length - 1]);
} }
@ -153,10 +151,10 @@ public class NodeContainer {
private List<NameInformation> getInterfaceNames() { private List<NameInformation> getInterfaceNames() {
if (interfaceNames == null) { if (interfaceNames == null) {
findAllNames(); findAllNames();
Set<IASTName> declarations = new HashSet<IASTName>(); Set<IASTName> declarations = new HashSet<IASTName>();
interfaceNames = new ArrayList<NameInformation>(); interfaceNames = new ArrayList<NameInformation>();
for (NameInformation nameInfo : names) { for (NameInformation nameInfo : names) {
IASTName declarationName = nameInfo.getDeclarationName(); IASTName declarationName = nameInfo.getDeclarationName();
if (declarations.add(declarationName)) { if (declarations.add(declarationName)) {
@ -227,7 +225,7 @@ public class NodeContainer {
public List<NameInformation> getParameterCandidates() { public List<NameInformation> getParameterCandidates() {
return getInterfaceNames(false); return getInterfaceNames(false);
} }
/** /**
* Returns names that are candidates for being used as the function return value. Multiple * Returns names that are candidates for being used as the function return value. Multiple
* return value candidates mean that the function cannot be extracted. * return value candidates mean that the function cannot be extracted.
@ -235,7 +233,7 @@ public class NodeContainer {
public List<NameInformation> getReturnValueCandidates() { public List<NameInformation> getReturnValueCandidates() {
return getInterfaceNames(true); return getInterfaceNames(true);
} }
public List<IASTNode> getNodesToWrite() { public List<IASTNode> getNodesToWrite() {
return nodes; return nodes;
} }
@ -282,7 +280,7 @@ public class NodeContainer {
public int getEndOffset() { public int getEndOffset() {
return getEndOffset(false); return getEndOffset(false);
} }
public int getEndOffsetIncludingComments() { public int getEndOffsetIncludingComments() {
return getEndOffset(true); return getEndOffset(true);
} }

View file

@ -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 * Rapperswil, University of applied sciences and others
* All rights reserved. This program and the accompanying materials * All rights reserved. This program and the accompanying materials
* are made available under the terms of the Eclipse Public License v1.0 * are made available under the terms of the Eclipse Public License v1.0
* which accompanies this distribution, and is available at * which accompanies this distribution, and is available at
* http://www.eclipse.org/legal/epl-v10.html * http://www.eclipse.org/legal/epl-v10.html
* *
* Contributors: * Contributors:
* Institute for Software - initial API and implementation * Institute for Software - initial API and implementation
*******************************************************************************/ *******************************************************************************/
package org.eclipse.cdt.internal.ui.refactoring.utils; 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.IDocumentProvider;
import org.eclipse.ui.texteditor.ITextEditor; 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.core.model.ICElement;
import org.eclipse.cdt.internal.ui.editor.CEditor; 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 * A collection of helper methods to interact with the workbench's IDocuments and IFiles
*/ */
public class EclipseObjects { public class EclipseObjects {
static public IWorkbenchPage getActivePage() { static public IWorkbenchPage getActivePage() {
return getActiveWindow().getActivePage(); return getActiveWindow().getActivePage();
} }
/** /**
* @return the active, visible TextEditor * @return the active, visible TextEditor
*/ */
static public IEditorPart getActiveEditor() { static public IEditorPart getActiveEditor() {
IEditorPart editor = null;
IWorkbenchPage page = getActivePage(); IWorkbenchPage page = getActivePage();
if (page.isEditorAreaVisible() IEditorPart activeEditor = page.getActiveEditor();
&& page.getActiveEditor() != null if (page.isEditorAreaVisible() && activeEditor instanceof TextEditor) {
&& page.getActiveEditor() instanceof TextEditor) { return activeEditor;
editor = page.getActiveEditor();
} }
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 * @param file to search for
* @return the editor or null * @return the editor or null
*/ */
@ -71,45 +68,44 @@ public class EclipseObjects {
for (IEditorReference editor2 : editors) { for (IEditorReference editor2 : editors) {
IEditorPart editor = editor2.getEditor(false); IEditorPart editor = editor2.getEditor(false);
if (editor instanceof CEditor) { if (editor instanceof CEditor) {
CEditor edi = ((CEditor)editor); CEditor edi = ((CEditor) editor);
IResource resource = edi.getInputCElement().getResource(); IResource resource = edi.getInputCElement().getResource();
if (resource instanceof IFile) { if (resource instanceof IFile) {
if( (( IFile )resource).equals(file) ){ if (((IFile) resource).equals(file)) {
return editor; return editor;
} }
} }
} }
} }
return null; return null;
} }
/** /**
* @return the file from the active editor * @return the file from the active editor
*/ */
static public IFile getActiveFile(){ static public IFile getActiveFile() {
IEditorInput editorInput = getActiveEditor().getEditorInput(); IEditorInput editorInput = getActiveEditor().getEditorInput();
IFile aFile = null; if (editorInput instanceof IFileEditorInput) {
if(editorInput instanceof IFileEditorInput){ return ((IFileEditorInput) editorInput).getFile();
aFile = ((IFileEditorInput)editorInput).getFile();
} }
return aFile; return null;
} }
/** /**
* @return the document from the currently active editor * @return the document from the currently active editor
*/ */
static public IDocument getActiveDocument() { 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) { static public IDocument getDocument(IEditorPart editor) {
ITextEditor txtEditor = ((ITextEditor)editor); ITextEditor txtEditor = ((ITextEditor) editor);
IDocumentProvider prov = txtEditor.getDocumentProvider(); IDocumentProvider prov = txtEditor.getDocumentProvider();
return prov.getDocument(txtEditor.getEditorInput()); return prov.getDocument(txtEditor.getEditorInput());
} }
@ -125,48 +121,38 @@ public class EclipseObjects {
IEditorPart editor = getEditorForFile(file); IEditorPart editor = getEditorForFile(file);
return getDocument(editor); 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 * active file if there is no present selection
*/ */
static public IFile getFile(ISelection selection) { static public IFile getFile(ISelection selection) {
if (selection instanceof IStructuredSelection && !selection.isEmpty()) { if (selection instanceof IStructuredSelection && !selection.isEmpty()) {
IFile file = getFile((IStructuredSelection)selection); IFile file = getFile((IStructuredSelection) selection);
return file; return file;
} }
return EclipseObjects.getActiveFile(); return getActiveFile();
} }
static private IFile getFile(IStructuredSelection selection) { static private IFile getFile(IStructuredSelection selection) {
IFile file = null;
Object o = selection.getFirstElement(); Object o = selection.getFirstElement();
if (o instanceof ICElement) { if (o instanceof ICElement) {
ICElement e= (ICElement) o; ICElement e= (ICElement) o;
IResource r= e.getUnderlyingResource(); IResource r= e.getUnderlyingResource();
if (r instanceof IFile) { if (r instanceof IFile) {
file= (IFile) r; return (IFile) r;
} }
} }
return file; return null;
} }
/** /**
* @return the file at the specified path string * @return the file at the specified path string
*/ */
public static IFile getFileForPathString(String path) { public static IFile getFileForPathString(String filePath) {
IPath ipath = new Path(path); IPath path = new Path(filePath);
return ResourcesPlugin.getWorkspace().getRoot().getFileForLocation(ipath); return ResourcesPlugin.getWorkspace().getRoot().getFileForLocation(path);
}
/**
* @return the file containing the node
*/
public static IFile getFile(IASTNode node){
if(node == null)
return null;
return getFileForPathString(node.getFileLocation().getFileName());
} }
} }