1
0
Fork 0
mirror of https://github.com/eclipse-cdt/cdt synced 2025-07-23 17:05:26 +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);
/**
* 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.
*/
public ICPPTemplateArgument getArgument(ICPPTemplateParameter param);
/**
* 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
*/
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.
* @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 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.
* Returns <code>null</code> is 'param' is not mapped.
* Returns {@code null} is 'param' is not mapped.
* @since 5.5
*/
public ICPPTemplateArgument getArgument(ICPPTemplateParameter param, int packOffset);

View file

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

View file

@ -6,7 +6,7 @@
* http://www.eclipse.org/legal/epl-v10.html
*
* Contributors:
* Andrew Niefer (IBM Corporation) - Initial API and implementation
* Andrew Niefer (IBM Corporation) - Initial API and implementation
*******************************************************************************/
package org.eclipse.cdt.internal.core.dom.parser.cpp;

View file

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

View file

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

View file

@ -45,7 +45,7 @@ public class CPPMethodTemplate extends CPPFunctionTemplate implements ICPPMethod
}
public IASTDeclaration getPrimaryDeclaration() {
//first check if we already know it
// First check if we already know it.
if (declarations != null) {
for (IASTName declaration : declarations) {
IASTNode parent = declaration.getParent();
@ -104,10 +104,11 @@ public class CPPMethodTemplate extends CPPFunctionTemplate implements ICPPMethod
@Override
public int getVisibility() {
IASTDeclaration decl = getPrimaryDeclaration();
if( decl == null ){
if (decl == null) {
ICPPClassType cls = getClassOwner();
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;
}
@ -115,14 +116,15 @@ public class CPPMethodTemplate extends CPPFunctionTemplate implements ICPPMethod
IASTDeclaration [] members = cls.getMembers();
ICPPASTVisibilityLabel vis = null;
for (IASTDeclaration member : members) {
if( member instanceof ICPPASTVisibilityLabel )
if (member instanceof ICPPASTVisibilityLabel) {
vis = (ICPPASTVisibilityLabel) member;
else if( member == decl )
} else if (member == decl) {
break;
}
}
if( vis != null ){
if (vis != null) {
return vis.getVisibility();
} else if( cls.getKey() == ICPPASTCompositeTypeSpecifier.k_class ){
} else if (cls.getKey() == ICPPASTCompositeTypeSpecifier.k_class) {
return ICPPASTVisibilityLabel.v_private;
}
return ICPPASTVisibilityLabel.v_public;
@ -138,8 +140,8 @@ public class CPPMethodTemplate extends CPPFunctionTemplate implements ICPPMethod
return null;
}
}
if( scope instanceof ICPPClassScope ){
return ((ICPPClassScope)scope).getClassType();
if (scope instanceof ICPPClassScope) {
return ((ICPPClassScope) scope).getClassType();
}
return null;
}
@ -196,7 +198,8 @@ public class CPPMethodTemplate extends CPPFunctionTemplate implements ICPPMethod
public boolean isExplicit() {
IASTDeclaration decl = getPrimaryDeclaration();
if (decl instanceof ICPPASTTemplateDeclaration) {
ICPPASTDeclSpecifier declSpec= getDeclSpecifier(((ICPPASTTemplateDeclaration) decl).getDeclaration());
ICPPASTDeclSpecifier declSpec=
getDeclSpecifier(((ICPPASTTemplateDeclaration) decl).getDeclaration());
if (declSpec != null) {
return declSpec.isExplicit();
}
@ -207,7 +210,7 @@ public class CPPMethodTemplate extends CPPFunctionTemplate implements ICPPMethod
@Override
public boolean isPureVirtual() {
ICPPASTFunctionDeclarator functionDeclarator = findFunctionDeclarator();
if(functionDeclarator != null){
if (functionDeclarator != null) {
return functionDeclarator.isPureVirtual();
}
return false;
@ -216,7 +219,7 @@ public class CPPMethodTemplate extends CPPFunctionTemplate implements ICPPMethod
@Override
public boolean isOverride() {
ICPPASTFunctionDeclarator functionDeclarator = findFunctionDeclarator();
if(functionDeclarator != null){
if (functionDeclarator != null) {
return functionDeclarator.isOverride();
}
return false;
@ -225,7 +228,7 @@ public class CPPMethodTemplate extends CPPFunctionTemplate implements ICPPMethod
@Override
public boolean isFinal() {
ICPPASTFunctionDeclarator functionDeclarator = findFunctionDeclarator();
if(functionDeclarator != null){
if (functionDeclarator != null) {
return functionDeclarator.isFinal();
}
return false;
@ -244,8 +247,7 @@ public class CPPMethodTemplate extends CPPFunctionTemplate implements ICPPMethod
parent = parent.getParent();
if (parent instanceof IASTDeclarator) {
IASTDeclarator dtor = ASTQueries
.findTypeRelevantDeclarator((IASTDeclarator) parent);
IASTDeclarator dtor = ASTQueries.findTypeRelevantDeclarator((IASTDeclarator) parent);
if (dtor instanceof ICPPASTFunctionDeclarator) {
return (ICPPASTFunctionDeclarator) dtor;
}

View file

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

View file

@ -6,8 +6,8 @@
* http://www.eclipse.org/legal/epl-v10.html
*
* Contributors:
* Andrew Niefer (IBM) - Initial API and implementation
* Markus Schorn (Wind River Systems)
* Andrew Niefer (IBM) - Initial API and implementation
* Markus Schorn (Wind River Systems)
*******************************************************************************/
package org.eclipse.cdt.internal.core.dom.parser.cpp;
@ -53,7 +53,7 @@ public abstract class CPPTemplateParameter extends PlatformObject
tp= (ICPPASTTemplateParameter) node;
} else if (node instanceof ICPPASTInternalTemplateDeclaration) {
final ICPPASTInternalTemplateDeclaration tdecl= (ICPPASTInternalTemplateDeclaration) node;
nesting+= tdecl.getNestingLevel();
nesting += tdecl.getNestingLevel();
if (tps == null) {
tps= tdecl.getTemplateParameters();
}
@ -84,22 +84,16 @@ public abstract class CPPTemplateParameter extends PlatformObject
try {
t = (IType) super.clone();
} catch (CloneNotSupportedException e) {
//not going to happen
// Not going to happen.
}
return t;
}
/* (non-Javadoc)
* @see org.eclipse.cdt.core.dom.ast.IBinding#getName()
*/
@Override
public final String getName() {
return new String(getNameCharArray());
}
/* (non-Javadoc)
* @see org.eclipse.cdt.core.dom.ast.IBinding#getNameCharArray()
*/
@Override
public final char[] getNameCharArray() {
// Search for the first declaration that has a name.
@ -141,49 +135,31 @@ public abstract class CPPTemplateParameter extends PlatformObject
return (ICPPASTTemplateParameter) node;
}
/* (non-Javadoc)
* @see org.eclipse.cdt.core.dom.ast.IBinding#getScope()
*/
@Override
public IScope getScope() {
return CPPVisitor.getContainingScope(getPrimaryDeclaration());
}
/* (non-Javadoc)
* @see org.eclipse.cdt.core.dom.ast.cpp.ICPPBinding#getQualifiedName()
*/
@Override
public String[] getQualifiedName() {
return new String[] { getName() };
}
/* (non-Javadoc)
* @see org.eclipse.cdt.core.dom.ast.cpp.ICPPBinding#getQualifiedNameCharArray()
*/
@Override
public char[][] getQualifiedNameCharArray() {
return new char[][] {getNameCharArray() };
return new char[][] { getNameCharArray() };
}
/* (non-Javadoc)
* @see org.eclipse.cdt.core.dom.ast.cpp.ICPPBinding#isGloballyQualified()
*/
@Override
public boolean isGloballyQualified() {
return false;
}
/* (non-Javadoc)
* @see org.eclipse.cdt.internal.core.dom.parser.cpp.ICPPInternalBinding#getDeclarations()
*/
@Override
public IASTName[] getDeclarations() {
return declarations;
}
/* (non-Javadoc)
* @see org.eclipse.cdt.internal.core.dom.parser.cpp.ICPPInternalBinding#getDefinition()
*/
@Override
public IASTNode getDefinition() {
if (declarations != null && declarations.length > 0)
@ -191,17 +167,11 @@ public abstract class CPPTemplateParameter extends PlatformObject
return null;
}
/* (non-Javadoc)
* @see org.eclipse.cdt.internal.core.dom.parser.cpp.ICPPInternalBinding#addDefinition(org.eclipse.cdt.core.dom.ast.IASTNode)
*/
@Override
public void addDefinition(IASTNode node) {
addDeclaration(node);
}
/* (non-Javadoc)
* @see org.eclipse.cdt.internal.core.dom.parser.cpp.ICPPInternalBinding#addDeclaration(org.eclipse.cdt.core.dom.ast.IASTNode)
*/
@Override
public void addDeclaration(IASTNode node) {
if (!(node instanceof IASTName))
@ -212,7 +182,7 @@ public abstract class CPPTemplateParameter extends PlatformObject
} else {
if (declarations.length > 0 && declarations[0] == node)
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()) {
declarations = ArrayUtil.prepend(IASTName.class, declarations, name);
} else {
@ -249,7 +219,7 @@ public abstract class CPPTemplateParameter extends PlatformObject
@Override
public IBinding resolveFinalBinding(CPPASTNameBase name) {
// check if the binding has been updated.
// Check if the binding has been updated.
IBinding current= name.getPreBinding();
if (current != this)
return current;
@ -259,7 +229,7 @@ public abstract class CPPTemplateParameter extends PlatformObject
return ((ICPPTemplateParameterOwner) template).resolveTemplateParameter(this);
}
// problem finding the containing template
// Problem finding the containing template.
if (template == null) {
return this;
}

View file

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