1
0
Fork 0
mirror of https://github.com/eclipse-cdt/cdt synced 2025-08-10 01:35: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;
/**
* 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;
}

View file

@ -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;
}

View file

@ -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 {
}

View file

@ -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;
}

View file

@ -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.
* <p> Clients may subclass. </p>
* Generic visitor for AST nodes.
* <p> Clients may subclass. </p>
* @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);

View file

@ -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. <br>
* Abstract base class for all visitors to traverse AST nodes. <br>
* visit() methods implement a top-down traversal, and <br>
* leave() methods implement a bottom-up traversal. <br>
*
*
* <p> Clients may subclass. </p>
*/
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 <code>true</code>.
* @since 5.1
*/
public boolean includeInactiveNodes= false;
/**
* Normally neither ambiguous nodes nor their children are visited. By setting
* 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.
*/
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.
*/

View file

@ -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
*/

View file

@ -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 {
/**
* <code>ASTNodeProperty</code> 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();

View file

@ -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
*/

View file

@ -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 {
/**
* <code>DECLARATION</code> 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);
}

View file

@ -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
*/

View file

@ -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 {
/**
* <code>BODY</code> represents the relationship between a
* <code>IASTDoStatement</code> and its nested body
* <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
@ -35,14 +35,14 @@ public interface IASTDoStatement extends IASTStatement {
/**
* Get the body of the loop.
*
*
* @return <code>IASTStatement</code> loop code body
*/
public IASTStatement getBody();
/**
* Set the body of the loop.
*
*
* @param body
* an <code>IASTStatement</code>
*/
@ -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);
}

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.
* 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);
}

View file

@ -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);
}

View file

@ -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 {
/**
* <code>CONTROLLER_EXP</code> represents the relationship between an
* <code>IASTSwitchStatement</code> and it's nested

View file

@ -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 <code>null</code> if there is no owner.
* <p>
* The owner is determined as follows:
* <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.
* <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.
* <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
* declared else where).
* declared else where).
* <p> Possible owners are:
* <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;
* <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;
* <br> {@link ICPPNamespace}: for global types, functions, variables, enumerators, namespaces and using declarations;
* <br> {@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;
}

View file

@ -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 <code>SEGMENT_NAME</code>.
*/
@ -30,48 +29,44 @@ public interface ICPPASTQualifiedName extends IASTName, IASTNameOwner {
/**
* Add a subname.
*
* @param name
* <code>IASTName</code>
*
* @param name <code>IASTName</code>
*/
public void addName(IASTName name);
/**
* Get all subnames.
*
*
* @return <code>IASTName []</code>
*/
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
*/

View file

@ -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.
*/

View file

@ -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:

View file

@ -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<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 Relation fRelation;
@ -36,7 +36,7 @@ public class ASTNodeSpecification<T extends IASTNode> {
private T fBestNode;
private boolean fSearchInExpansion;
private boolean fZeroToLeft= false;
public ASTNodeSpecification(Relation relation, Class<T> clazz, int fileOffset, int fileLength) {
fRelation= relation;
fClass= clazz;
@ -53,7 +53,7 @@ public class ASTNodeSpecification<T extends IASTNode> {
setRangeInSequence(offsetInSeq, lengthInSeq);
fZeroToLeft= zeroRangeToLeft;
}
public void setSearchInExpansion(boolean searchInExpansion) {
fSearchInExpansion= searchInExpansion;
}
@ -77,7 +77,7 @@ public class ASTNodeSpecification<T extends IASTNode> {
public boolean requiresClass(Class<? extends IASTNode> 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<T extends IASTNode> {
}
}
}
@SuppressWarnings("unchecked")
public void visit(ASTNode astNode, IASTImageLocation imageLocation) {
if (isAcceptableNode(astNode) && imageLocation != null) {
@ -109,16 +110,16 @@ public class ASTNodeSpecification<T extends IASTNode> {
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<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) {
final int offset= node.getOffset();
@ -142,7 +143,7 @@ public class ASTNodeSpecification<T extends IASTNode> {
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<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.
*/
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<T extends IASTNode> {
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<T extends IASTNode> {
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<T extends IASTNode> {
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) {

View file

@ -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;
}

View file

@ -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;

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
* 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<NameInformation> getInterfaceNames() {
if (interfaceNames == null) {
findAllNames();
Set<IASTName> declarations = new HashSet<IASTName>();
interfaceNames = new ArrayList<NameInformation>();
for (NameInformation nameInfo : names) {
IASTName declarationName = nameInfo.getDeclarationName();
if (declarations.add(declarationName)) {
@ -227,7 +225,7 @@ public class NodeContainer {
public List<NameInformation> 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<NameInformation> getReturnValueCandidates() {
return getInterfaceNames(true);
}
public List<IASTNode> getNodesToWrite() {
return nodes;
}
@ -282,7 +280,7 @@ public class NodeContainer {
public int getEndOffset() {
return getEndOffset(false);
}
public int getEndOffsetIncludingComments() {
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
* 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);
}
}