mirror of
https://github.com/eclipse-cdt/cdt
synced 2025-08-12 10:45:37 +02:00
Cosmetics.
This commit is contained in:
parent
73175131ff
commit
1012380fa8
1 changed files with 23 additions and 28 deletions
|
@ -40,37 +40,36 @@ public class CPPASTDeclarator extends ASTNode implements ICPPASTDeclarator {
|
||||||
private IASTName name;
|
private IASTName name;
|
||||||
private IASTDeclarator nested;
|
private IASTDeclarator nested;
|
||||||
private IASTPointerOperator[] pointerOps = null;
|
private IASTPointerOperator[] pointerOps = null;
|
||||||
private boolean isPackExpansion;
|
private boolean isPackExpansion;
|
||||||
|
|
||||||
public CPPASTDeclarator() {
|
public CPPASTDeclarator() {
|
||||||
}
|
}
|
||||||
|
|
||||||
public CPPASTDeclarator(IASTName name) {
|
public CPPASTDeclarator(IASTName name) {
|
||||||
setName(name);
|
setName(name);
|
||||||
}
|
}
|
||||||
|
|
||||||
public CPPASTDeclarator(IASTName name, IASTInitializer initializer) {
|
public CPPASTDeclarator(IASTName name, IASTInitializer initializer) {
|
||||||
this(name);
|
this(name);
|
||||||
setInitializer(initializer);
|
setInitializer(initializer);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
public CPPASTDeclarator copy() {
|
public CPPASTDeclarator copy() {
|
||||||
CPPASTDeclarator copy = new CPPASTDeclarator();
|
CPPASTDeclarator copy = new CPPASTDeclarator();
|
||||||
copyBaseDeclarator(copy);
|
copyBaseDeclarator(copy);
|
||||||
return copy;
|
return copy;
|
||||||
}
|
}
|
||||||
|
|
||||||
protected void copyBaseDeclarator(CPPASTDeclarator copy) {
|
protected void copyBaseDeclarator(CPPASTDeclarator copy) {
|
||||||
copy.setName(name == null ? null : name.copy());
|
copy.setName(name == null ? null : name.copy());
|
||||||
copy.setInitializer(initializer == null ? null : initializer.copy());
|
copy.setInitializer(initializer == null ? null : initializer.copy());
|
||||||
copy.setNestedDeclarator(nested == null ? null : nested.copy());
|
copy.setNestedDeclarator(nested == null ? null : nested.copy());
|
||||||
copy.isPackExpansion= isPackExpansion;
|
copy.isPackExpansion= isPackExpansion;
|
||||||
for(IASTPointerOperator pointer : getPointerOperators())
|
for (IASTPointerOperator pointer : getPointerOperators())
|
||||||
copy.addPointerOperator(pointer == null ? null : pointer.copy());
|
copy.addPointerOperator(pointer == null ? null : pointer.copy());
|
||||||
copy.setOffsetAndLength(this);
|
copy.setOffsetAndLength(this);
|
||||||
}
|
}
|
||||||
|
|
||||||
public boolean declaresParameterPack() {
|
public boolean declaresParameterPack() {
|
||||||
return isPackExpansion;
|
return isPackExpansion;
|
||||||
}
|
}
|
||||||
|
@ -128,7 +127,7 @@ public class CPPASTDeclarator extends ASTNode implements ICPPASTDeclarator {
|
||||||
name.setPropertyInParent(DECLARATOR_NAME);
|
name.setPropertyInParent(DECLARATOR_NAME);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
public void setDeclaresParameterPack(boolean val) {
|
public void setDeclaresParameterPack(boolean val) {
|
||||||
assertNotFrozen();
|
assertNotFrozen();
|
||||||
isPackExpansion= val;
|
isPackExpansion= val;
|
||||||
|
@ -137,13 +136,13 @@ public class CPPASTDeclarator extends ASTNode implements ICPPASTDeclarator {
|
||||||
@Override
|
@Override
|
||||||
public boolean accept(ASTVisitor action) {
|
public boolean accept(ASTVisitor action) {
|
||||||
if (action.shouldVisitDeclarators) {
|
if (action.shouldVisitDeclarators) {
|
||||||
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 (pointerOps != null) {
|
if (pointerOps != null) {
|
||||||
for (IASTPointerOperator op : pointerOps) {
|
for (IASTPointerOperator op : pointerOps) {
|
||||||
if (op == null)
|
if (op == null)
|
||||||
|
@ -152,34 +151,30 @@ public class CPPASTDeclarator extends ASTNode implements ICPPASTDeclarator {
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
if (nested == null && name != null) {
|
if (nested == null && name != null) {
|
||||||
IASTDeclarator outermost= ASTQueries.findOutermostDeclarator(this);
|
IASTDeclarator outermost= ASTQueries.findOutermostDeclarator(this);
|
||||||
if (outermost.getPropertyInParent() != IASTTypeId.ABSTRACT_DECLARATOR) {
|
if (outermost.getPropertyInParent() != IASTTypeId.ABSTRACT_DECLARATOR) {
|
||||||
if (!name.accept(action)) return false;
|
if (!name.accept(action)) return false;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
if (nested != null) {
|
if (nested != null) {
|
||||||
if (!nested.accept(action)) return false;
|
if (!nested.accept(action)) return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (!postAccept(action))
|
if (!postAccept(action))
|
||||||
return false;
|
return false;
|
||||||
|
|
||||||
if (action.shouldVisitDeclarators && action.leave(this) == ASTVisitor.PROCESS_ABORT)
|
if (action.shouldVisitDeclarators && action.leave(this) == ASTVisitor.PROCESS_ABORT)
|
||||||
return false;
|
return false;
|
||||||
|
|
||||||
return true;
|
return true;
|
||||||
}
|
|
||||||
|
|
||||||
protected boolean postAccept(ASTVisitor action) {
|
|
||||||
if (initializer != null && !initializer.accept(action))
|
|
||||||
return false;
|
|
||||||
|
|
||||||
return true;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
protected boolean postAccept(ASTVisitor action) {
|
||||||
|
return initializer == null || initializer.accept(action);
|
||||||
|
}
|
||||||
|
|
||||||
public int getRoleForName(IASTName n) {
|
public int getRoleForName(IASTName n) {
|
||||||
// 3.1.2
|
// 3.1.2
|
||||||
|
@ -188,7 +183,7 @@ public class CPPASTDeclarator extends ASTNode implements ICPPASTDeclarator {
|
||||||
// a declaration is a definition unless ...
|
// a declaration is a definition unless ...
|
||||||
if (parent instanceof IASTFunctionDefinition)
|
if (parent instanceof IASTFunctionDefinition)
|
||||||
return r_definition;
|
return r_definition;
|
||||||
|
|
||||||
if (parent instanceof IASTSimpleDeclaration) {
|
if (parent instanceof IASTSimpleDeclaration) {
|
||||||
final IASTSimpleDeclaration sdecl = (IASTSimpleDeclaration) parent;
|
final IASTSimpleDeclaration sdecl = (IASTSimpleDeclaration) parent;
|
||||||
|
|
||||||
|
@ -206,24 +201,24 @@ public class CPPASTDeclarator extends ASTNode implements ICPPASTDeclarator {
|
||||||
if (storage == IASTDeclSpecifier.sc_static && CPPVisitor.getContainingScope(parent) instanceof ICPPClassScope) {
|
if (storage == IASTDeclSpecifier.sc_static && CPPVisitor.getContainingScope(parent) instanceof ICPPClassScope) {
|
||||||
return r_declaration;
|
return r_declaration;
|
||||||
}
|
}
|
||||||
// unless it is a class name declaration: no declarator in this case
|
// unless it is a class name declaration: no declarator in this case
|
||||||
// unless it is a typedef declaration
|
// unless it is a typedef declaration
|
||||||
if (storage == IASTDeclSpecifier.sc_typedef)
|
if (storage == IASTDeclSpecifier.sc_typedef)
|
||||||
return r_definition; // should actually be a declaration
|
return r_definition; // should actually be a declaration
|
||||||
|
|
||||||
// unless it is a using-declaration or using-directive: no declarator in this case
|
// unless it is a using-declaration or using-directive: no declarator in this case
|
||||||
}
|
}
|
||||||
|
|
||||||
// all other cases
|
// all other cases
|
||||||
return r_definition;
|
return r_definition;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (parent instanceof IASTTypeId)
|
if (parent instanceof IASTTypeId)
|
||||||
return r_reference;
|
return r_reference;
|
||||||
|
|
||||||
if (parent instanceof IASTParameterDeclaration)
|
if (parent instanceof IASTParameterDeclaration)
|
||||||
return (n.getLookupKey().length > 0) ? r_definition : r_declaration;
|
return (n.getLookupKey().length > 0) ? r_definition : r_declaration;
|
||||||
|
|
||||||
return r_unclear;
|
return r_unclear;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
Loading…
Add table
Reference in a new issue