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

Cosmetics.

This commit is contained in:
Sergey Prigogin 2014-04-24 18:36:01 -07:00
parent ab445bbf47
commit 300a9b0807
9 changed files with 50 additions and 108 deletions

View file

@ -25,20 +25,20 @@ public interface ICPPTemplateParameterMap {
public ICPPTemplateArgument getArgument(int paramID); public ICPPTemplateArgument getArgument(int paramID);
/** /**
* Returns the value for the template parameter in the map, or <code>null</code> if * Returns the value for the template parameter in the map, or {@code null} if
* the parameter is not mapped or the parameter is a parameter pack. * the parameter is not mapped or the parameter is a parameter pack.
*/ */
public ICPPTemplateArgument getArgument(ICPPTemplateParameter param); public ICPPTemplateArgument getArgument(ICPPTemplateParameter param);
/** /**
* Returns the values for the template parameter pack with the given id in the map, * Returns the values for the template parameter pack with the given id in the map,
* or <code>null</code> if the parameter is not mapped or is not a parameter pack. * or {@code null} if the parameter is not mapped or is not a parameter pack.
* @since 5.2 * @since 5.2
*/ */
public ICPPTemplateArgument[] getPackExpansion(int paramID); public ICPPTemplateArgument[] getPackExpansion(int paramID);
/** /**
* Returns the values for the template parameter pack in the map, or <code>null</code> if the * Returns the values for the template parameter pack in the map, or {@code null} if the
* parameter is not mapped or is no parameter pack. * parameter is not mapped or is no parameter pack.
* @since 5.2 * @since 5.2
*/ */
@ -46,9 +46,9 @@ public interface ICPPTemplateParameterMap {
/** /**
* If 'param' is not a parameter pack, returns the value for 'param' in the map. * If 'param' is not a parameter pack, returns the value for 'param' in the map.
* If 'param' is a parmameter pack, returns the value at position 'packOffset' * If 'param' is a parameter pack, returns the value at position 'packOffset'
* in the pack of values for 'param' in the map. * in the pack of values for 'param' in the map.
* Returns <code>null</code> is 'param' is not mapped. * Returns {@code null} is 'param' is not mapped.
* @since 5.5 * @since 5.5
*/ */
public ICPPTemplateArgument getArgument(ICPPTemplateParameter param, int packOffset); public ICPPTemplateArgument getArgument(ICPPTemplateParameter param, int packOffset);

View file

@ -146,9 +146,10 @@ public class CPPClassScope extends CPPScope implements ICPPClassScope {
inheritedConstructorsSources, ia.getParametersOfNontrivialUserDeclaredConstructors(), inheritedConstructorsSources, ia.getParametersOfNontrivialUserDeclaredConstructors(),
compTypeSpec); compTypeSpec);
implicits = addAll(implicits, inheritedConstructors); implicits = addAll(implicits, inheritedConstructors);
for (ICPPMethod ctor : inheritedConstructors) for (ICPPMethod ctor : inheritedConstructors) {
addBinding(ctor); addBinding(ctor);
} }
}
private ICPPBase[] findInheritedConstructorsSourceBases( private ICPPBase[] findInheritedConstructorsSourceBases(
ICPPASTCompositeTypeSpecifier compositeTypeSpec) { ICPPASTCompositeTypeSpecifier compositeTypeSpec) {

View file

@ -156,7 +156,7 @@ public class CPPFunctionTemplate extends CPPTemplateDefinition
} else if (t instanceof ISemanticProblem){ } else if (t instanceof ISemanticProblem){
type= new ProblemFunctionType(((ISemanticProblem) t).getID()); type= new ProblemFunctionType(((ISemanticProblem) t).getID());
} else { } else {
// This case is unexpected // This case is unexpected.
type= new ProblemFunctionType(ISemanticProblem.TYPE_UNRESOLVED_NAME); type= new ProblemFunctionType(ISemanticProblem.TYPE_UNRESOLVED_NAME);
} }
} }
@ -392,19 +392,19 @@ public class CPPFunctionTemplate extends CPPTemplateDefinition
public IType[] getExceptionSpecification() { public IType[] getExceptionSpecification() {
ICPPASTFunctionDeclarator declarator = getFirstFunctionDtor(); ICPPASTFunctionDeclarator declarator = getFirstFunctionDtor();
if (declarator != null) { if (declarator != null) {
IASTTypeId[] astTypeIds = declarator.getExceptionSpecification(); IASTTypeId[] typeIds = declarator.getExceptionSpecification();
if (astTypeIds.equals(ICPPASTFunctionDeclarator.NO_EXCEPTION_SPECIFICATION)) { if (typeIds.equals(ICPPASTFunctionDeclarator.NO_EXCEPTION_SPECIFICATION)) {
return null; return null;
} }
if (astTypeIds.equals(IASTTypeId.EMPTY_TYPEID_ARRAY)) { if (typeIds.equals(IASTTypeId.EMPTY_TYPEID_ARRAY)) {
return IType.EMPTY_TYPE_ARRAY; return IType.EMPTY_TYPE_ARRAY;
} }
IType[] typeIds = new IType[astTypeIds.length]; IType[] types = new IType[typeIds.length];
for (int i = 0; i < astTypeIds.length; ++i) { for (int i = 0; i < typeIds.length; ++i) {
typeIds[i] = CPPVisitor.createType(astTypeIds[i]); types[i] = CPPVisitor.createType(typeIds[i]);
} }
return typeIds; return types;
} }
return null; return null;
} }

View file

@ -23,7 +23,7 @@ import org.eclipse.cdt.core.dom.ast.cpp.ICPPParameter;
* An example is GCC built-in functions. * An example is GCC built-in functions.
*/ */
public class CPPImplicitFunction extends CPPFunction { public class CPPImplicitFunction extends CPPFunction {
private ICPPParameter[] parms; private ICPPParameter[] params;
private IScope scope; private IScope scope;
private ICPPFunctionType functionType; private ICPPFunctionType functionType;
private final boolean takesVarArgs; private final boolean takesVarArgs;
@ -31,18 +31,18 @@ public class CPPImplicitFunction extends CPPFunction {
private final char[] name; private final char[] name;
public CPPImplicitFunction(char[] name, IScope scope, ICPPFunctionType type, public CPPImplicitFunction(char[] name, IScope scope, ICPPFunctionType type,
ICPPParameter[] parms, boolean takesVarArgs) { ICPPParameter[] params, boolean takesVarArgs) {
super(null); super(null);
this.name= name; this.name= name;
this.scope= scope; this.scope= scope;
this.functionType= type; this.functionType= type;
this.parms= parms; this.params= params;
this.takesVarArgs= takesVarArgs; this.takesVarArgs= takesVarArgs;
} }
@Override @Override
public ICPPParameter[] getParameters() { public ICPPParameter[] getParameters() {
return parms; return params;
} }
@Override @Override

View file

@ -45,7 +45,7 @@ public class CPPMethodTemplate extends CPPFunctionTemplate implements ICPPMethod
} }
public IASTDeclaration getPrimaryDeclaration() { public IASTDeclaration getPrimaryDeclaration() {
//first check if we already know it // First check if we already know it.
if (declarations != null) { if (declarations != null) {
for (IASTName declaration : declarations) { for (IASTName declaration : declarations) {
IASTNode parent = declaration.getParent(); IASTNode parent = declaration.getParent();
@ -107,7 +107,8 @@ public class CPPMethodTemplate extends CPPFunctionTemplate implements ICPPMethod
if (decl == null) { if (decl == null) {
ICPPClassType cls = getClassOwner(); ICPPClassType cls = getClassOwner();
if (cls != null) { if (cls != null) {
return ( cls.getKey() == ICPPClassType.k_class ) ? ICPPASTVisibilityLabel.v_private : ICPPASTVisibilityLabel.v_public; return cls.getKey() == ICPPClassType.k_class ?
ICPPASTVisibilityLabel.v_private : ICPPASTVisibilityLabel.v_public;
} }
return ICPPASTVisibilityLabel.v_private; return ICPPASTVisibilityLabel.v_private;
} }
@ -115,11 +116,12 @@ public class CPPMethodTemplate extends CPPFunctionTemplate implements ICPPMethod
IASTDeclaration [] members = cls.getMembers(); IASTDeclaration [] members = cls.getMembers();
ICPPASTVisibilityLabel vis = null; ICPPASTVisibilityLabel vis = null;
for (IASTDeclaration member : members) { for (IASTDeclaration member : members) {
if( member instanceof ICPPASTVisibilityLabel ) if (member instanceof ICPPASTVisibilityLabel) {
vis = (ICPPASTVisibilityLabel) member; vis = (ICPPASTVisibilityLabel) member;
else if( member == decl ) } else if (member == decl) {
break; break;
} }
}
if (vis != null) { if (vis != null) {
return vis.getVisibility(); return vis.getVisibility();
} else if (cls.getKey() == ICPPASTCompositeTypeSpecifier.k_class) { } else if (cls.getKey() == ICPPASTCompositeTypeSpecifier.k_class) {
@ -196,7 +198,8 @@ public class CPPMethodTemplate extends CPPFunctionTemplate implements ICPPMethod
public boolean isExplicit() { public boolean isExplicit() {
IASTDeclaration decl = getPrimaryDeclaration(); IASTDeclaration decl = getPrimaryDeclaration();
if (decl instanceof ICPPASTTemplateDeclaration) { if (decl instanceof ICPPASTTemplateDeclaration) {
ICPPASTDeclSpecifier declSpec= getDeclSpecifier(((ICPPASTTemplateDeclaration) decl).getDeclaration()); ICPPASTDeclSpecifier declSpec=
getDeclSpecifier(((ICPPASTTemplateDeclaration) decl).getDeclaration());
if (declSpec != null) { if (declSpec != null) {
return declSpec.isExplicit(); return declSpec.isExplicit();
} }
@ -244,8 +247,7 @@ public class CPPMethodTemplate extends CPPFunctionTemplate implements ICPPMethod
parent = parent.getParent(); parent = parent.getParent();
if (parent instanceof IASTDeclarator) { if (parent instanceof IASTDeclarator) {
IASTDeclarator dtor = ASTQueries IASTDeclarator dtor = ASTQueries.findTypeRelevantDeclarator((IASTDeclarator) parent);
.findTypeRelevantDeclarator((IASTDeclarator) parent);
if (dtor instanceof ICPPASTFunctionDeclarator) { if (dtor instanceof ICPPASTFunctionDeclarator) {
return (ICPPASTFunctionDeclarator) dtor; return (ICPPASTFunctionDeclarator) dtor;
} }

View file

@ -67,8 +67,8 @@ public abstract class CPPTemplateDefinition extends PlatformObject implements IC
private ICPPTemplateParameter[] templateParameters; private ICPPTemplateParameter[] templateParameters;
private ObjectMap instances; private ObjectMap instances;
private ICPPClassTemplate indexBinding= null; private ICPPClassTemplate indexBinding;
private boolean checkedIndex= false; private boolean checkedIndex;
public CPPTemplateDefinition(IASTName name) { public CPPTemplateDefinition(IASTName name) {
@ -164,57 +164,36 @@ public abstract class CPPTemplateDefinition extends PlatformObject implements IC
return null; return null;
} }
/* (non-Javadoc)
* @see org.eclipse.cdt.core.dom.ast.IBinding#getName()
*/
@Override @Override
public String getName() { public String getName() {
return new String(getNameCharArray()); return new String(getNameCharArray());
} }
/* (non-Javadoc)
* @see org.eclipse.cdt.core.dom.ast.IBinding#getNameCharArray()
*/
@Override @Override
public char[] getNameCharArray() { public char[] getNameCharArray() {
return getTemplateName().getSimpleID(); return getTemplateName().getSimpleID();
} }
/* (non-Javadoc)
* @see org.eclipse.cdt.core.dom.ast.IBinding#getScope()
*/
@Override @Override
public IScope getScope() { public IScope getScope() {
return CPPVisitor.getContainingScope(getTemplateName()); return CPPVisitor.getContainingScope(getTemplateName());
} }
/* (non-Javadoc)
* @see org.eclipse.cdt.core.dom.ast.cpp.ICPPBinding#getQualifiedName()
*/
@Override @Override
public String[] getQualifiedName() { public String[] getQualifiedName() {
return CPPVisitor.getQualifiedName(this); return CPPVisitor.getQualifiedName(this);
} }
/* (non-Javadoc)
* @see org.eclipse.cdt.core.dom.ast.cpp.ICPPBinding#getQualifiedNameCharArray()
*/
@Override @Override
public char[][] getQualifiedNameCharArray() { public char[][] getQualifiedNameCharArray() {
return CPPVisitor.getQualifiedNameCharArray(this); return CPPVisitor.getQualifiedNameCharArray(this);
} }
/* (non-Javadoc)
* @see org.eclipse.cdt.core.dom.ast.cpp.ICPPBinding#isGloballyQualified()
*/
@Override @Override
public boolean isGloballyQualified() { public boolean isGloballyQualified() {
return true; return true;
} }
/* (non-Javadoc)
* @see org.eclipse.cdt.core.dom.ast.cpp.ICPPTemplateDefinition#getParameters()
*/
@Override @Override
public ICPPTemplateParameter[] getTemplateParameters() { public ICPPTemplateParameter[] getTemplateParameters() {
if (templateParameters == null) { if (templateParameters == null) {
@ -235,9 +214,6 @@ public abstract class CPPTemplateDefinition extends PlatformObject implements IC
return templateParameters; return templateParameters;
} }
/* (non-Javadoc)
* @see org.eclipse.cdt.internal.core.dom.parser.cpp.ICPPInternalBinding#addDefinition(org.eclipse.cdt.core.dom.ast.IASTNode)
*/
@Override @Override
public void addDefinition(IASTNode node) { public void addDefinition(IASTNode node) {
if (node instanceof ICPPASTCompositeTypeSpecifier) { if (node instanceof ICPPASTCompositeTypeSpecifier) {
@ -252,9 +228,6 @@ public abstract class CPPTemplateDefinition extends PlatformObject implements IC
definition = (IASTName) node; definition = (IASTName) node;
} }
/* (non-Javadoc)
* @see org.eclipse.cdt.internal.core.dom.parser.cpp.ICPPInternalBinding#addDeclaration(org.eclipse.cdt.core.dom.ast.IASTNode)
*/
@Override @Override
public void addDeclaration(IASTNode node) { public void addDeclaration(IASTNode node) {
if (node instanceof ICPPASTElaboratedTypeSpecifier) { if (node instanceof ICPPASTElaboratedTypeSpecifier) {
@ -270,7 +243,7 @@ public abstract class CPPTemplateDefinition extends PlatformObject implements IC
if (declarations == null) { if (declarations == null) {
declarations = new IASTName[] { declName }; declarations = new IASTName[] { declName };
} else { } else {
// keep the lowest offset declaration in[0] // Keep the lowest offset declaration in [0].
if (declarations.length > 0 && ((ASTNode) node).getOffset() < ((ASTNode) declarations[0]).getOffset()) { if (declarations.length > 0 && ((ASTNode) node).getOffset() < ((ASTNode) declarations[0]).getOffset()) {
declarations = ArrayUtil.prepend(IASTName.class, declarations, declName); declarations = ArrayUtil.prepend(IASTName.class, declarations, declName);
} else { } else {
@ -336,17 +309,12 @@ public abstract class CPPTemplateDefinition extends PlatformObject implements IC
} }
} }
} }
/* (non-Javadoc)
* @see org.eclipse.cdt.internal.core.dom.parser.cpp.ICPPInternalBinding#getDeclarations()
*/
@Override @Override
public IASTNode[] getDeclarations() { public IASTNode[] getDeclarations() {
return declarations; return declarations;
} }
/* (non-Javadoc)
* @see org.eclipse.cdt.internal.core.dom.parser.cpp.ICPPInternalBinding#getDefinition()
*/
@Override @Override
public IASTNode getDefinition() { public IASTNode getDefinition() {
return definition; return definition;

View file

@ -84,22 +84,16 @@ public abstract class CPPTemplateParameter extends PlatformObject
try { try {
t = (IType) super.clone(); t = (IType) super.clone();
} catch (CloneNotSupportedException e) { } catch (CloneNotSupportedException e) {
//not going to happen // Not going to happen.
} }
return t; return t;
} }
/* (non-Javadoc)
* @see org.eclipse.cdt.core.dom.ast.IBinding#getName()
*/
@Override @Override
public final String getName() { public final String getName() {
return new String(getNameCharArray()); return new String(getNameCharArray());
} }
/* (non-Javadoc)
* @see org.eclipse.cdt.core.dom.ast.IBinding#getNameCharArray()
*/
@Override @Override
public final char[] getNameCharArray() { public final char[] getNameCharArray() {
// Search for the first declaration that has a name. // Search for the first declaration that has a name.
@ -141,49 +135,31 @@ public abstract class CPPTemplateParameter extends PlatformObject
return (ICPPASTTemplateParameter) node; return (ICPPASTTemplateParameter) node;
} }
/* (non-Javadoc)
* @see org.eclipse.cdt.core.dom.ast.IBinding#getScope()
*/
@Override @Override
public IScope getScope() { public IScope getScope() {
return CPPVisitor.getContainingScope(getPrimaryDeclaration()); return CPPVisitor.getContainingScope(getPrimaryDeclaration());
} }
/* (non-Javadoc)
* @see org.eclipse.cdt.core.dom.ast.cpp.ICPPBinding#getQualifiedName()
*/
@Override @Override
public String[] getQualifiedName() { public String[] getQualifiedName() {
return new String[] { getName() }; return new String[] { getName() };
} }
/* (non-Javadoc)
* @see org.eclipse.cdt.core.dom.ast.cpp.ICPPBinding#getQualifiedNameCharArray()
*/
@Override @Override
public char[][] getQualifiedNameCharArray() { public char[][] getQualifiedNameCharArray() {
return new char[][] { getNameCharArray() }; return new char[][] { getNameCharArray() };
} }
/* (non-Javadoc)
* @see org.eclipse.cdt.core.dom.ast.cpp.ICPPBinding#isGloballyQualified()
*/
@Override @Override
public boolean isGloballyQualified() { public boolean isGloballyQualified() {
return false; return false;
} }
/* (non-Javadoc)
* @see org.eclipse.cdt.internal.core.dom.parser.cpp.ICPPInternalBinding#getDeclarations()
*/
@Override @Override
public IASTName[] getDeclarations() { public IASTName[] getDeclarations() {
return declarations; return declarations;
} }
/* (non-Javadoc)
* @see org.eclipse.cdt.internal.core.dom.parser.cpp.ICPPInternalBinding#getDefinition()
*/
@Override @Override
public IASTNode getDefinition() { public IASTNode getDefinition() {
if (declarations != null && declarations.length > 0) if (declarations != null && declarations.length > 0)
@ -191,17 +167,11 @@ public abstract class CPPTemplateParameter extends PlatformObject
return null; return null;
} }
/* (non-Javadoc)
* @see org.eclipse.cdt.internal.core.dom.parser.cpp.ICPPInternalBinding#addDefinition(org.eclipse.cdt.core.dom.ast.IASTNode)
*/
@Override @Override
public void addDefinition(IASTNode node) { public void addDefinition(IASTNode node) {
addDeclaration(node); addDeclaration(node);
} }
/* (non-Javadoc)
* @see org.eclipse.cdt.internal.core.dom.parser.cpp.ICPPInternalBinding#addDeclaration(org.eclipse.cdt.core.dom.ast.IASTNode)
*/
@Override @Override
public void addDeclaration(IASTNode node) { public void addDeclaration(IASTNode node) {
if (!(node instanceof IASTName)) if (!(node instanceof IASTName))
@ -212,7 +182,7 @@ public abstract class CPPTemplateParameter extends PlatformObject
} else { } else {
if (declarations.length > 0 && declarations[0] == node) if (declarations.length > 0 && declarations[0] == node)
return; return;
// keep the lowest offset declaration in [0] // Keep the lowest offset declaration in [0].
if (declarations.length > 0 && ((ASTNode)node).getOffset() < ((ASTNode)declarations[0]).getOffset()) { if (declarations.length > 0 && ((ASTNode)node).getOffset() < ((ASTNode)declarations[0]).getOffset()) {
declarations = ArrayUtil.prepend(IASTName.class, declarations, name); declarations = ArrayUtil.prepend(IASTName.class, declarations, name);
} else { } else {
@ -249,7 +219,7 @@ public abstract class CPPTemplateParameter extends PlatformObject
@Override @Override
public IBinding resolveFinalBinding(CPPASTNameBase name) { public IBinding resolveFinalBinding(CPPASTNameBase name) {
// check if the binding has been updated. // Check if the binding has been updated.
IBinding current= name.getPreBinding(); IBinding current= name.getPreBinding();
if (current != this) if (current != this)
return current; return current;
@ -259,7 +229,7 @@ public abstract class CPPTemplateParameter extends PlatformObject
return ((ICPPTemplateParameterOwner) template).resolveTemplateParameter(this); return ((ICPPTemplateParameterOwner) template).resolveTemplateParameter(this);
} }
// problem finding the containing template // Problem finding the containing template.
if (template == null) { if (template == null) {
return this; return this;
} }

View file

@ -89,6 +89,7 @@ public class EvalBinding extends CPPDependentEvaluation {
public EvalBinding(ICPPFunction parameterOwner, int parameterPosition, IType type, IASTNode pointOfDefinition) { public EvalBinding(ICPPFunction parameterOwner, int parameterPosition, IType type, IASTNode pointOfDefinition) {
this(parameterOwner, parameterPosition, type, findEnclosingTemplate(pointOfDefinition)); this(parameterOwner, parameterPosition, type, findEnclosingTemplate(pointOfDefinition));
} }
public EvalBinding(ICPPFunction parameterOwner, int parameterPosition, IType type, IBinding templateDefinition) { public EvalBinding(ICPPFunction parameterOwner, int parameterPosition, IType type, IBinding templateDefinition) {
super(templateDefinition); super(templateDefinition);
fParameterOwner = parameterOwner; fParameterOwner = parameterOwner;