1
0
Fork 0
mirror of https://github.com/eclipse-cdt/cdt synced 2025-06-05 16:56:04 +02:00

Cosmetics.

This commit is contained in:
Sergey Prigogin 2011-05-31 02:54:08 +00:00
parent bb1eb7f5f7
commit 013cb1036a

View file

@ -208,8 +208,7 @@ public class CVisitor extends ASTQueries {
boolean compositeTypeDeclared = false;
private void addName(IASTName name) {
if (declsFound.length == numFound) // if the found array is full, then double the array
{
if (declsFound.length == numFound) { // if the found array is full, then double the array
IASTName[] old = declsFound;
declsFound = new IASTName[old.length * 2];
for (int j = 0; j < old.length; ++j)
@ -251,8 +250,10 @@ public class CVisitor extends ASTQueries {
if (declarator == null || declarator.getName() == null || declarator.getName().toCharArray().length == 0) return PROCESS_CONTINUE;
//if the binding is something not declared in a declarator, continue
if (binding instanceof ICompositeType) return PROCESS_CONTINUE;
if (binding instanceof IEnumeration) return PROCESS_CONTINUE;
if (binding instanceof ICompositeType)
return PROCESS_CONTINUE;
if (binding instanceof IEnumeration)
return PROCESS_CONTINUE;
IASTNode parent = declarator.getParent();
while (parent != null && !(parent instanceof IASTDeclaration || parent instanceof IASTParameterDeclaration))
@ -357,22 +358,21 @@ public class CVisitor extends ASTQueries {
private static final int KIND_OBJ_FN = 2;
private static final int KIND_TYPE = 3;
public CollectReferencesAction(IBinding binding) {
this.binding = binding;
this.refs = new IASTName[DEFAULT_LIST_SIZE];
shouldVisitNames = true;
if (binding instanceof ILabel)
if (binding instanceof ILabel) {
kind = KIND_LABEL;
else if (binding instanceof ICompositeType ||
} else if (binding instanceof ICompositeType ||
binding instanceof ITypedef ||
binding instanceof IEnumeration)
{
binding instanceof IEnumeration) {
kind = KIND_TYPE;
} else
} else {
kind = KIND_OBJ_FN;
}
}
@Override
public int visit(IASTName name) {
@ -383,13 +383,12 @@ public class CVisitor extends ASTQueries {
break;
return PROCESS_CONTINUE;
case KIND_TYPE:
if (prop == IASTNamedTypeSpecifier.NAME)
if (prop == IASTNamedTypeSpecifier.NAME) {
break;
else if (prop == IASTElaboratedTypeSpecifier.TYPE_NAME) {
} else if (prop == IASTElaboratedTypeSpecifier.TYPE_NAME) {
IASTNode p = name.getParent().getParent();
if (!(p instanceof IASTSimpleDeclaration) ||
((IASTSimpleDeclaration)p).getDeclarators().length > 0)
{
((IASTSimpleDeclaration) p).getDeclarators().length > 0) {
break;
}
}
@ -397,14 +396,13 @@ public class CVisitor extends ASTQueries {
case KIND_OBJ_FN:
if (prop == IASTIdExpression.ID_NAME ||
prop == IASTFieldReference.FIELD_NAME ||
prop == ICASTFieldDesignator.FIELD_NAME)
{
prop == ICASTFieldDesignator.FIELD_NAME) {
break;
}
return PROCESS_CONTINUE;
}
if (CharArrayUtils.equals(name.toCharArray(), binding.getNameCharArray()))
if (CharArrayUtils.equals(name.toCharArray(), binding.getNameCharArray())) {
if (sameBinding(name.resolveBinding(), binding)) {
if (refs.length == idx) {
IASTName[] temp = new IASTName[refs.length * 2];
@ -413,6 +411,7 @@ public class CVisitor extends ASTQueries {
}
refs[idx++] = name;
}
}
return PROCESS_CONTINUE;
}
@ -441,7 +440,7 @@ public class CVisitor extends ASTQueries {
public static final String EMPTY_STRING = ""; //$NON-NLS-1$
public static final char[] EMPTY_CHAR_ARRAY = "".toCharArray(); //$NON-NLS-1$
//definition lookup start loc
// definition lookup start location
protected static final int AT_BEGINNING = 1;
protected static final int AT_NEXT = 2;
@ -497,6 +496,7 @@ public class CVisitor extends ASTQueries {
}
return binding;
}
private static IBinding createBinding(IASTEnumerator enumerator) {
IEnumerator binding = new CEnumerator(enumerator);
try {
@ -505,6 +505,7 @@ public class CVisitor extends ASTQueries {
}
return binding;
}
private static IBinding createBinding(IASTStatement statement) {
if (statement instanceof IASTGotoStatement) {
char[] gotoName = ((IASTGotoStatement) statement).getName().toCharArray();
@ -533,6 +534,7 @@ public class CVisitor extends ASTQueries {
}
return null;
}
private static IBinding createBinding(ICASTElaboratedTypeSpecifier elabTypeSpec) {
IASTNode parent = elabTypeSpec.getParent();
IASTName name = elabTypeSpec.getName();
@ -580,7 +582,6 @@ public class CVisitor extends ASTQueries {
ASTInternal.addName(insertIntoScope, name);
}
}
return binding;
} else if (parent instanceof IASTTypeId || parent instanceof IASTParameterDeclaration) {
return resolveBinding(elabTypeSpec);
@ -631,7 +632,7 @@ public class CVisitor extends ASTQueries {
IBinding[] bs = scope.find(PTRDIFF_T);
for (IBinding b : bs) {
if (b instanceof IType) {
if (b instanceof ICInternalBinding == false ||
if (!(b instanceof ICInternalBinding) ||
CVisitor.declaredBefore(((ICInternalBinding) b).getPhysicalNode(), expr)) {
return (IType) b;
}
@ -646,7 +647,7 @@ public class CVisitor extends ASTQueries {
IBinding[] bs = scope.find(SIZE_T);
for (IBinding b : bs) {
if (b instanceof IType) {
if (b instanceof ICInternalBinding == false ||
if (!(b instanceof ICInternalBinding) ||
CVisitor.declaredBefore(((ICInternalBinding) b).getPhysicalNode(), expr)) {
return (IType) b;
}
@ -673,10 +674,11 @@ public class CVisitor extends ASTQueries {
IScope scope= CVisitor.getContainingScope(declarator);
binding = scope.getBinding(name, false);
if (binding != null && !(binding instanceof IIndexBinding) && name.isActive()) {
if (binding instanceof ICInternalFunction)
if (binding instanceof ICInternalFunction) {
((ICInternalFunction) binding).addDeclarator(declarator);
else
} else {
binding = new ProblemBinding(name, IProblemBinding.SEMANTIC_INVALID_OVERLOAD, name.toCharArray());
}
} else {
binding = createBinding(declarator);
}
@ -777,7 +779,6 @@ public class CVisitor extends ASTQueries {
return binding;
}
private static IBinding createBinding(ICASTCompositeTypeSpecifier compositeTypeSpec) {
IScope scope = null;
IBinding binding = null;
@ -795,7 +796,7 @@ public class CVisitor extends ASTQueries {
return binding;
}
}
} catch (DOMException e2) {
} catch (DOMException e) {
}
return new CStructure(name);
}
@ -857,13 +858,13 @@ public class CVisitor extends ASTQueries {
if ((blockItem instanceof IASTSimpleDeclaration ||
(blockItem instanceof IASTDeclarationStatement && ((IASTDeclarationStatement) blockItem).getDeclaration() instanceof IASTSimpleDeclaration))) {
IASTSimpleDeclaration simpleDecl = null;
if (blockItem instanceof IASTDeclarationStatement &&
((IASTDeclarationStatement)blockItem).getDeclaration() instanceof IASTSimpleDeclaration)
((IASTDeclarationStatement) blockItem).getDeclaration() instanceof IASTSimpleDeclaration) {
simpleDecl = (IASTSimpleDeclaration)((IASTDeclarationStatement) blockItem).getDeclaration();
else if (blockItem instanceof IASTSimpleDeclaration)
} else if (blockItem instanceof IASTSimpleDeclaration) {
simpleDecl = (IASTSimpleDeclaration) blockItem;
}
if (simpleDecl != null) {
IBinding struct = null;
@ -883,7 +884,6 @@ public class CVisitor extends ASTQueries {
type = ((ITypeContainer) type).getType();
}
if (type instanceof CStructure)
return ((CStructure) type).findField(((ICASTFieldDesignator) node).getName().toString());
}
@ -1001,13 +1001,10 @@ public class CVisitor extends ASTQueries {
if (p instanceof IASTDeclarationStatement)
return p;
return parent;
}
//if parent is something that can contain a declaration
else if (parent instanceof IASTCompoundStatement ||
} else if (parent instanceof IASTCompoundStatement || // parent is something that can contain a declaration
parent instanceof IASTTranslationUnit ||
parent instanceof IASTForStatement ||
parent instanceof IASTFunctionDeclarator)
{
parent instanceof IASTFunctionDeclarator) {
return node;
}
@ -1101,8 +1098,7 @@ public class CVisitor extends ASTQueries {
//external function
external = new CExternalFunction(tu, name);
ASTInternal.addName(tu.getScope(), name);
}
else {
} else {
//external variable
//external = new CExternalVariable(tu, name);
//((CScope) tu.getScope()).addName(name);
@ -1213,7 +1209,6 @@ public class CVisitor extends ASTQueries {
IType type = createType((ICASTDeclSpecifier) declSpec);
type = createType(type, declarator);
if (isParameter) {
IType paramType = type;
// Remove typedefs ready for subsequent processing.
@ -1258,7 +1253,6 @@ public class CVisitor extends ASTQueries {
}
public static IType createType(IType returnType, IASTFunctionDeclarator declarator) {
IType[] pTypes = getParmTypes(declarator);
returnType = setupPointerChain(declarator.getPointerOperators(), returnType);
@ -1272,11 +1266,13 @@ public class CVisitor extends ASTQueries {
}
/**
* This is used to create a base IType corresponding to an IASTDeclarator and the IASTDeclSpecifier. This method doesn't have any recursive
* behaviour and is used as the foundation of the ITypes being created.
* The parameter isParm is used to specify whether the declarator is a parameter or not.
* This is used to create a base IType corresponding to an IASTDeclarator and
* the IASTDeclSpecifier. This method doesn't have any recursive behavior and is used as
* the foundation of the ITypes being created. The parameter isParm is used to specify whether
* the declarator is a parameter or not.
*
* @param declSpec the IASTDeclSpecifier used to determine if the base type is a CQualifierType or not
* @param declSpec the IASTDeclSpecifier used to determine if the base type is a CQualifierType
* or not
* @return the base IType
*/
public static IType createBaseType(IASTDeclSpecifier declSpec) {
@ -1575,7 +1571,7 @@ public class CVisitor extends ASTQueries {
pointOfDecl = nd.getOffset() + nd.getLength();
}
return (pointOfDecl < ((ASTNode)nodeB).getOffset());
return pointOfDecl < ((ASTNode) nodeB).getOffset();
}
return true;
@ -1608,7 +1604,7 @@ public class CVisitor extends ASTQueries {
*/
public static IBinding findDeclarationOwner(IASTNode node, boolean allowFunction) {
// search for declaration
while (node instanceof IASTDeclaration == false) {
while (!(node instanceof IASTDeclaration)) {
if (node == null)
return null;