From cb5c6721aa6823cf6b54095ba2a11009c6926826 Mon Sep 17 00:00:00 2001 From: Sergey Prigogin Date: Sun, 12 Oct 2008 23:48:09 +0000 Subject: [PATCH] Code formatting. --- .../parser/cpp/semantics/CPPSemantics.java | 23 +++-- .../parser/cpp/semantics/SemanticUtil.java | 89 +++++++++---------- 2 files changed, 55 insertions(+), 57 deletions(-) diff --git a/core/org.eclipse.cdt.core/parser/org/eclipse/cdt/internal/core/dom/parser/cpp/semantics/CPPSemantics.java b/core/org.eclipse.cdt.core/parser/org/eclipse/cdt/internal/core/dom/parser/cpp/semantics/CPPSemantics.java index b719ee49a90..171472efc0d 100644 --- a/core/org.eclipse.cdt.core/parser/org/eclipse/cdt/internal/core/dom/parser/cpp/semantics/CPPSemantics.java +++ b/core/org.eclipse.cdt.core/parser/org/eclipse/cdt/internal/core/dom/parser/cpp/semantics/CPPSemantics.java @@ -274,8 +274,8 @@ public class CPPSemantics { */ if (binding instanceof ICPPClassTemplate) { IASTNode parent= data.astName.getParent(); - if(parent instanceof IASTNamedTypeSpecifier) { - if(parent.getParent() instanceof IASTSimpleDeclaration) { + if (parent instanceof IASTNamedTypeSpecifier) { + if (parent.getParent() instanceof IASTSimpleDeclaration) { binding = new ProblemBinding(data.astName, IProblemBinding.SEMANTIC_INVALID_TYPE, data.name()); } } @@ -356,7 +356,7 @@ public class CPPSemantics { if (name.getPropertyInParent() == IASTNamedTypeSpecifier.NAME && !(binding instanceof IType || binding instanceof ICPPConstructor)) { IASTNode parent = name.getParent().getParent(); if (parent instanceof IASTTypeId && parent.getPropertyInParent() == ICPPASTTemplateId.TEMPLATE_ID_ARGUMENT) { - if(!(binding instanceof IType)) { + if (!(binding instanceof IType)) { // a type id needs to hold a type binding = new ProblemBinding(data.astName, IProblemBinding.SEMANTIC_INVALID_TYPE, data.name()); } @@ -547,7 +547,7 @@ public class CPPSemantics { if (results instanceof IBinding) { data.foundItems = ArrayUtil.append(Object.class, (Object[]) data.foundItems, results); } else if (results instanceof Object[]) { - data.foundItems = ArrayUtil.addAll(Object.class, (Object[])data.foundItems, (Object[])results); + data.foundItems = ArrayUtil.addAll(Object.class, (Object[]) data.foundItems, (Object[]) results); } } else { data.foundItems = mergePrefixResults((CharArrayObjectMap) data.foundItems, results, scoped); @@ -831,8 +831,8 @@ public class CPPSemantics { return null; } - for(ICPPBase base : bases) { - if(base instanceof IProblemBinding) + for (ICPPBase base : bases) { + if (base instanceof IProblemBinding) continue; IBinding b = base.getBaseClass(); @@ -841,7 +841,7 @@ public class CPPSemantics { inherited = null; - final ICPPClassType cls= (ICPPClassType) b; + final ICPPClassType cls = (ICPPClassType) b; final ICPPScope parent = (ICPPScope) cls.getCompositeScope(); if (parent == null) @@ -2086,7 +2086,6 @@ public class CPPSemantics { currFnCost[j] = cost; } - hasWorse = false; hasBetter = false; // In order for this function to be better than the previous best, it must @@ -2412,14 +2411,14 @@ public class CPPSemantics { if (fieldReference.isPointerDereference()) { IType type= getUltimateTypeUptoPointers(result); boolean needCheckClassMemberAccessOperator= true; - if(type instanceof IPointerType) { + if (type instanceof IPointerType) { type= getUltimateTypeUptoPointers(((IPointerType) type).getType()); - if(type instanceof ICPPClassType) { + if (type instanceof ICPPClassType) { needCheckClassMemberAccessOperator= false; } } - if(needCheckClassMemberAccessOperator) { + if (needCheckClassMemberAccessOperator) { IType temp= result; result= null; @@ -2438,7 +2437,7 @@ public class CPPSemantics { CPPASTName x= new CPPASTName(); boolean isConst= false, isVolatile= false; - if(temp instanceof IQualifierType) { + if (temp instanceof IQualifierType) { isConst= ((IQualifierType)temp).isConst(); isVolatile= ((IQualifierType)temp).isVolatile(); } diff --git a/core/org.eclipse.cdt.core/parser/org/eclipse/cdt/internal/core/dom/parser/cpp/semantics/SemanticUtil.java b/core/org.eclipse.cdt.core/parser/org/eclipse/cdt/internal/core/dom/parser/cpp/semantics/SemanticUtil.java index 9981b3fd4f9..9c70b32be6f 100644 --- a/core/org.eclipse.cdt.core/parser/org/eclipse/cdt/internal/core/dom/parser/cpp/semantics/SemanticUtil.java +++ b/core/org.eclipse.cdt.core/parser/org/eclipse/cdt/internal/core/dom/parser/cpp/semantics/SemanticUtil.java @@ -42,25 +42,23 @@ import org.eclipse.cdt.internal.core.dom.parser.cpp.OverloadableOperator; */ public class SemanticUtil { private static final char[] OPERATOR_CHARS = Keywords.OPERATOR.toCharArray(); - /** - * Cache of overloadable operator names for fast lookup. Used by isConversionOperator. - */ + // Cache of overloadable operator names for fast lookup. Used by isConversionOperator. private static final CharArraySet cas= new CharArraySet(OverloadableOperator.values().length); static { final int OPERATOR_SPC= OPERATOR_CHARS.length + 1; - for(OverloadableOperator op : OverloadableOperator.values()) { + for (OverloadableOperator op : OverloadableOperator.values()) { char[] name= op.toCharArray(); cas.put(CharArrayUtils.subarray(name, OPERATOR_SPC, name.length)); } } /** - * Returns a list of ICPPMethod objects representing all conversion operators + * Returns an array of ICPPMethod objects representing all conversion operators * declared by the specified class. This does not include inherited methods. Conversion * operators cannot be implicit. * @param clazz - * @return List of ICPPMethod + * @return an array of conversion operators. */ public static final ICPPMethod[] getDeclaredConversionOperators(ICPPClassType clazz) throws DOMException { ICPPMethod[] methods= new ICPPMethod[0]; @@ -68,9 +66,9 @@ public class SemanticUtil { clazz= (ICPPClassType) ((ICPPDeferredClassInstance)clazz).getTemplateDefinition(); } ICPPMethod[] decs= clazz.getDeclaredMethods(); - if(decs != null) { - for(ICPPMethod method : decs) { - if(isConversionOperator(method)) { + if (decs != null) { + for (ICPPMethod method : decs) { + if (isConversionOperator(method)) { methods= (ICPPMethod[]) ArrayUtil.append(ICPPMethod.class, methods, method); } } @@ -79,16 +77,16 @@ public class SemanticUtil { } /** - * Returns a list of ICPPMethod objects representing all conversion operators + * Returns an array of ICPPMethod objects representing all conversion operators * declared by the specified class and its ancestors. This includes inherited * methods. Conversion operators cannot be implicit. * @param clazz - * @return List of ICPPMethod + * @return an array of conversion operators. */ public static ICPPMethod[] getConversionOperators(ICPPClassType clazz) throws DOMException { ICPPMethod[] methods= new ICPPMethod[0]; ObjectSet ancestry= inheritanceClosure(clazz); - for(int i=0; i current= new ObjectSet(2); current.put(root); - for(int count=0; count < CPPSemantics.MAX_INHERITANCE_DEPTH && !current.isEmpty(); count++) { + for (int count = 0; count < CPPSemantics.MAX_INHERITANCE_DEPTH && !current.isEmpty(); count++) { ObjectSet next= new ObjectSet(2); - for(int i=0; i OPERATOR_CHARS.length + 1 && CharArrayUtils.equals(name, 0, OPERATOR_CHARS.length, OPERATOR_CHARS)) { - if(name[OPERATOR_CHARS.length]==' ') { + if (name[OPERATOR_CHARS.length]==' ') { result= !cas.containsKey(name, OPERATOR_CHARS.length+1, name.length - (OPERATOR_CHARS.length+1)); } } @@ -167,28 +165,29 @@ public class SemanticUtil { */ static IType getUltimateType(IType type, IType[] lastPointerType, boolean stopAtPointerToMember) { try { - while( true ){ - if( type instanceof ITypedef ) { - IType tt= ((ITypedef)type).getType(); + while (true) { + if (type instanceof ITypedef) { + IType tt= ((ITypedef) type).getType(); if (tt == null) return type; type= tt; - } else if( type instanceof IQualifierType ) { - type= ((IQualifierType)type).getType(); - } else if( stopAtPointerToMember && type instanceof ICPPPointerToMemberType ) + } else if (type instanceof IQualifierType) { + type= ((IQualifierType) type).getType(); + } else if (stopAtPointerToMember && type instanceof ICPPPointerToMemberType) { return type; - else if( type instanceof IPointerType ) { - if(lastPointerType!=null) { + } else if (type instanceof IPointerType) { + if (lastPointerType!=null) { lastPointerType[0]= type; } type= ((IPointerType) type).getType(); - } else if( type instanceof ICPPReferenceType ) { - type= ((ICPPReferenceType)type).getType(); - } else + } else if (type instanceof ICPPReferenceType) { + type= ((ICPPReferenceType) type).getType(); + } else { return type; + } } - } catch ( DOMException e ) { + } catch (DOMException e) { return e.getProblem(); } } @@ -199,22 +198,23 @@ public class SemanticUtil { * @param type * @return the ultimate type contained inside the specified type */ - public static IType getUltimateTypeUptoPointers(IType type){ + public static IType getUltimateTypeUptoPointers(IType type) { try { - while( true ){ - if( type instanceof ITypedef ) { - IType tt= ((ITypedef)type).getType(); + while (true) { + if (type instanceof ITypedef) { + IType tt= ((ITypedef) type).getType(); if (tt == null) return type; type= tt; - } else if( type instanceof IQualifierType ) { - type = ((IQualifierType)type).getType(); - } else if( type instanceof ICPPReferenceType ) { - type = ((ICPPReferenceType)type).getType(); - } else + } else if (type instanceof IQualifierType) { + type = ((IQualifierType) type).getType(); + } else if (type instanceof ICPPReferenceType) { + type = ((ICPPReferenceType) type).getType(); + } else { return type; + } } - } catch ( DOMException e ) { + } catch (DOMException e) { return e.getProblem(); } } @@ -226,13 +226,13 @@ public class SemanticUtil { */ static IType getUltimateTypeViaTypedefs(IType type) { try { - while(type instanceof ITypedef) { - IType t= ((ITypedef)type).getType(); + while (type instanceof ITypedef) { + IType t= ((ITypedef) type).getType(); if (t == null) return type; type= t; } - } catch(DOMException e) { + } catch (DOMException e) { type= e.getProblem(); } return type; @@ -292,5 +292,4 @@ public class SemanticUtil { } return result; } - }