mirror of
https://github.com/eclipse-cdt/cdt
synced 2025-04-23 06:32:10 +02:00
Cosmetics.
This commit is contained in:
parent
1ae15f57fa
commit
b88109c7f4
5 changed files with 40 additions and 58 deletions
|
@ -6,22 +6,23 @@
|
|||
* 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;
|
||||
|
||||
/**
|
||||
* This interface represent a preprocessor function-style macro definition. e.g.
|
||||
* #define ABC( def ) GHI
|
||||
*
|
||||
* Note: macros that are expanded as parameters to function style macros are not captured in this abstraction.
|
||||
* <pre>
|
||||
* #define ABC(def) GHI
|
||||
* </pre>
|
||||
* Note: macros that are expanded as parameters to function style macros are not captured in this
|
||||
* abstraction.
|
||||
*
|
||||
* @noextend This interface is not intended to be extended by clients.
|
||||
* @noimplement This interface is not intended to be implemented by clients.
|
||||
*/
|
||||
public interface IASTPreprocessorFunctionStyleMacroDefinition extends
|
||||
IASTPreprocessorMacroDefinition {
|
||||
|
||||
/**
|
||||
* This property represents the relationship between a function style macro
|
||||
* definition and one of its parameters.
|
||||
|
@ -30,18 +31,16 @@ public interface IASTPreprocessorFunctionStyleMacroDefinition extends
|
|||
"IASTPreprocessorFunctionStyleMacroDefinition.PARAMETER - Function Macro Parameter"); //$NON-NLS-1$
|
||||
|
||||
/**
|
||||
* Get the macro parameters.
|
||||
* Returns the macro parameters.
|
||||
*
|
||||
* @return <code>IASTFunctionStyleMacroParameter[]</code> parameters
|
||||
*/
|
||||
public IASTFunctionStyleMacroParameter[] getParameters();
|
||||
|
||||
/**
|
||||
* Add a function-style macro parameter.
|
||||
* Adds a function-style macro parameter.
|
||||
*
|
||||
* @param parm
|
||||
* <code>IASTFunctionStyleMacroParameter</code>
|
||||
* @param parm the parameter to add
|
||||
*/
|
||||
public void addParameter(IASTFunctionStyleMacroParameter parm);
|
||||
|
||||
}
|
||||
|
|
|
@ -6,18 +6,18 @@
|
|||
* 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;
|
||||
|
||||
/**
|
||||
* This interface represents an object-style macro definition. e.g. #define
|
||||
* ONE_TWO_THREE 123
|
||||
* This interface represents an object-style macro definition. e.g.
|
||||
* <pre>
|
||||
* #define ONE_TWO_THREE 123
|
||||
* </pre>
|
||||
*
|
||||
* @noextend This interface is not intended to be extended by clients.
|
||||
* @noimplement This interface is not intended to be implemented by clients.
|
||||
*/
|
||||
public interface IASTPreprocessorObjectStyleMacroDefinition extends
|
||||
IASTPreprocessorMacroDefinition {
|
||||
|
||||
public interface IASTPreprocessorObjectStyleMacroDefinition extends IASTPreprocessorMacroDefinition {
|
||||
}
|
||||
|
|
|
@ -125,7 +125,7 @@ class ASTComment extends ASTPreprocessorNode implements IASTComment {
|
|||
@Override
|
||||
public int getOffset() {
|
||||
if (fFilePath != null) {
|
||||
// Perform lazy conversion to sequence number
|
||||
// Perform lazy conversion to sequence number.
|
||||
ILocationResolver lr= (ILocationResolver) getTranslationUnit().getAdapter(ILocationResolver.class);
|
||||
if (lr != null) {
|
||||
setOffset(lr.getSequenceNumberForFileOffset(fFilePath, super.getOffset()));
|
||||
|
@ -192,6 +192,7 @@ class ASTElse extends ASTPreprocessorNode implements IASTPreprocessorElseStateme
|
|||
super(parent, IASTTranslationUnit.PREPROCESSOR_STATEMENT, startNumber, endNumber);
|
||||
fTaken= taken;
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean taken() {
|
||||
return fTaken;
|
||||
|
@ -207,9 +208,7 @@ class ASTIfndef extends ASTDirectiveWithCondition implements IASTPreprocessorIfn
|
|||
fMacroRef= new ASTMacroReferenceName(this, IASTPreprocessorStatement.MACRO_NAME, condNumber, condEndNumber, macro, null);
|
||||
}
|
||||
}
|
||||
/* (non-Javadoc)
|
||||
* @see org.eclipse.cdt.core.dom.ast.IASTPreprocessorIfdefStatement#getMacroReference()
|
||||
*/
|
||||
|
||||
@Override
|
||||
public ASTPreprocessorName getMacroReference() {
|
||||
return fMacroRef;
|
||||
|
@ -224,9 +223,7 @@ class ASTIfdef extends ASTDirectiveWithCondition implements IASTPreprocessorIfde
|
|||
fMacroRef= new ASTMacroReferenceName(this, IASTPreprocessorStatement.MACRO_NAME, condNumber, condEndNumber, macro, null);
|
||||
}
|
||||
}
|
||||
/* (non-Javadoc)
|
||||
* @see org.eclipse.cdt.core.dom.ast.IASTPreprocessorIfdefStatement#getMacroReference()
|
||||
*/
|
||||
|
||||
@Override
|
||||
public ASTPreprocessorName getMacroReference() {
|
||||
return fMacroRef;
|
||||
|
@ -816,25 +813,16 @@ class ASTMacroExpansion extends ASTPreprocessorNode implements IASTPreprocessorM
|
|||
fContext= expansionCtx;
|
||||
}
|
||||
|
||||
/* (non-Javadoc)
|
||||
* @see org.eclipse.cdt.core.dom.ast.IASTPreprocessorMacroExpansion#getName()
|
||||
*/
|
||||
@Override
|
||||
public ASTMacroReferenceName getMacroReference() {
|
||||
return fContext.getMacroReference();
|
||||
}
|
||||
|
||||
/* (non-Javadoc)
|
||||
* @see org.eclipse.cdt.core.dom.ast.IASTPreprocessorMacroExpansion#getMacroDefinition()
|
||||
*/
|
||||
@Override
|
||||
public IASTPreprocessorMacroDefinition getMacroDefinition() {
|
||||
return fContext.getMacroDefinition();
|
||||
}
|
||||
|
||||
/* (non-Javadoc)
|
||||
* @see org.eclipse.cdt.core.dom.ast.IASTPreprocessorMacroExpansion#getNestedExpansions()
|
||||
*/
|
||||
@Override
|
||||
public ASTPreprocessorName[] getNestedMacroReferences() {
|
||||
return fContext.getNestedMacroReferences();
|
||||
|
@ -857,9 +845,6 @@ class ASTMacroExpansionLocation implements IASTMacroExpansionLocation, org.eclip
|
|||
fLength= length;
|
||||
}
|
||||
|
||||
/* (non-Javadoc)
|
||||
* @see org.eclipse.cdt.core.dom.ast.IASTMacroExpansionLocation#getExpansion()
|
||||
*/
|
||||
@Override
|
||||
public IASTPreprocessorMacroExpansion getExpansion() {
|
||||
return fContext.getExpansion();
|
||||
|
|
|
@ -6,7 +6,7 @@
|
|||
* 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.internal.ui.refactoring.rename;
|
||||
|
||||
|
@ -22,9 +22,9 @@ import org.eclipse.cdt.core.dom.ast.cpp.ICPPASTQualifiedName;
|
|||
* Visitor to prefer simple ASTNames over the qualified ones. This is different
|
||||
* to the strategy used within the dom-package.
|
||||
*/
|
||||
abstract public class ASTNameVisitor extends ASTVisitor {
|
||||
private int fOffset= -1;
|
||||
private String fFileName;
|
||||
public abstract class ASTNameVisitor extends ASTVisitor {
|
||||
private final int fOffset;
|
||||
private final String fFileName;
|
||||
|
||||
public ASTNameVisitor(String fileName) {
|
||||
this(fileName, -1);
|
||||
|
@ -33,20 +33,21 @@ abstract public class ASTNameVisitor extends ASTVisitor {
|
|||
public ASTNameVisitor(String fileName, int offset) {
|
||||
fFileName= fileName;
|
||||
fOffset= offset;
|
||||
shouldVisitNames=true;
|
||||
shouldVisitNames = true;
|
||||
}
|
||||
|
||||
abstract protected int visitName(IASTName name);
|
||||
|
||||
@Override
|
||||
final public int visit(IASTName name) {
|
||||
public final int visit(IASTName name) {
|
||||
if (name instanceof ICPPASTQualifiedName) {
|
||||
ICPPASTQualifiedName qn= (ICPPASTQualifiedName) name;
|
||||
ICPPASTNameSpecifier[] segments= qn.getAllSegments();
|
||||
ICPPASTNameSpecifier[] segments= qn.getQualifier();
|
||||
boolean visited= false;
|
||||
for (int i = 0; i < segments.length; i++) {
|
||||
if (segments[i] instanceof IASTName && checkLocation(segments[i])) {
|
||||
if (visitName((IASTName) segments[i]) == PROCESS_ABORT) {
|
||||
for (int i = 0; i <= segments.length; i++) {
|
||||
IASTNode segment = i < segments.length ? segments[i] : qn.getLastName();
|
||||
if (segment instanceof IASTName && checkLocation(segment)) {
|
||||
if (visitName((IASTName) segment) == PROCESS_ABORT) {
|
||||
return PROCESS_ABORT;
|
||||
}
|
||||
visited= true;
|
||||
|
@ -57,15 +58,14 @@ abstract public class ASTNameVisitor extends ASTVisitor {
|
|||
return visitName(name.getLastName());
|
||||
}
|
||||
}
|
||||
}
|
||||
else if (checkLocation(name)) {
|
||||
} else if (checkLocation(name)) {
|
||||
return visitName(name);
|
||||
}
|
||||
return PROCESS_CONTINUE;
|
||||
}
|
||||
|
||||
private boolean checkLocation(IASTNode node) {
|
||||
if (fFileName==null) {
|
||||
if (fFileName == null) {
|
||||
return true;
|
||||
}
|
||||
if (!fFileName.equals(node.getContainingFilename())) {
|
||||
|
@ -74,23 +74,22 @@ abstract public class ASTNameVisitor extends ASTVisitor {
|
|||
IASTFileLocation loc= null;
|
||||
if (node instanceof IASTName) {
|
||||
loc= ASTManager.getImageFileLocation((IASTName) node);
|
||||
}
|
||||
else {
|
||||
} else {
|
||||
IASTNodeLocation[] locs= node.getNodeLocations();
|
||||
if (locs!=null && locs.length==1) {
|
||||
if (locs != null && locs.length == 1) {
|
||||
if (locs[0] instanceof IASTFileLocation) {
|
||||
loc= (IASTFileLocation) locs[0];
|
||||
}
|
||||
}
|
||||
}
|
||||
if (loc==null) {
|
||||
if (loc == null) {
|
||||
return false;
|
||||
}
|
||||
if (fOffset==-1) {
|
||||
if (fOffset == -1) {
|
||||
return true;
|
||||
}
|
||||
int off= loc.getNodeOffset();
|
||||
int len = loc.getNodeLength();
|
||||
return off <= fOffset && fOffset < off+len;
|
||||
return off <= fOffset && fOffset < off + len;
|
||||
}
|
||||
}
|
||||
|
|
|
@ -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.internal.ui.refactoring.rename;
|
||||
|
||||
import org.eclipse.cdt.core.dom.ast.ASTVisitor;
|
||||
|
@ -17,7 +16,7 @@ import org.eclipse.cdt.core.dom.ast.cpp.ICPPASTQualifiedName;
|
|||
import org.eclipse.cdt.core.dom.ast.cpp.ICPPASTTemplateId;
|
||||
|
||||
public abstract class ASTSpecificNameVisitor extends ASTNameVisitor {
|
||||
private String fSearchForName;
|
||||
private final String fSearchForName;
|
||||
|
||||
public ASTSpecificNameVisitor(String name) {
|
||||
super(null);
|
||||
|
@ -25,7 +24,7 @@ public abstract class ASTSpecificNameVisitor extends ASTNameVisitor {
|
|||
}
|
||||
|
||||
@Override
|
||||
final public int visitName(IASTName name) {
|
||||
public final int visitName(IASTName name) {
|
||||
if (name instanceof ICPPASTTemplateId || name instanceof ICPPASTQualifiedName)
|
||||
return PROCESS_CONTINUE;
|
||||
|
||||
|
|
Loading…
Add table
Reference in a new issue