diff --git a/core/org.eclipse.cdt.core/parser/org/eclipse/cdt/internal/core/dom/parser/cpp/CPPASTQualifiedName.java b/core/org.eclipse.cdt.core/parser/org/eclipse/cdt/internal/core/dom/parser/cpp/CPPASTQualifiedName.java index 1935929cbfa..11558e19c62 100644 --- a/core/org.eclipse.cdt.core/parser/org/eclipse/cdt/internal/core/dom/parser/cpp/CPPASTQualifiedName.java +++ b/core/org.eclipse.cdt.core/parser/org/eclipse/cdt/internal/core/dom/parser/cpp/CPPASTQualifiedName.java @@ -74,18 +74,18 @@ public class CPPASTQualifiedName extends CPPASTNode implements public void addName(IASTName name) { if (name != null) { - names = (IASTName[]) ArrayUtil.append( IASTName.class, names, ++namesPos, name ); + names = (IASTName[]) ArrayUtil.append(IASTName.class, names, ++namesPos, name); name.setParent(this); name.setPropertyInParent(SEGMENT_NAME); } } private void removeNullNames() { - names = (IASTName[]) ArrayUtil.removeNullsAfter( IASTName.class, names, namesPos ); + names = (IASTName[]) ArrayUtil.removeNullsAfter(IASTName.class, names, namesPos); } private IASTName[] names = null; - private int namesPos=-1; + private int namesPos= -1; private boolean isFullyQualified; private String signature; @@ -145,7 +145,6 @@ public class CPPASTQualifiedName extends CPPASTNode implements public void setSignature(String signature) { this.signature = signature; - } @Override @@ -188,7 +187,7 @@ public class CPPASTQualifiedName extends CPPASTNode implements IASTNode parent = getParent(); if (parent instanceof IASTNameOwner) { int role = ((IASTNameOwner) parent).getRoleForName(this); - if( role == IASTNameOwner.r_reference ) return false; + if (role == IASTNameOwner.r_reference) return false; return true; } return false; @@ -198,21 +197,21 @@ public class CPPASTQualifiedName extends CPPASTNode implements IASTNode parent = getParent(); if (parent instanceof IASTNameOwner) { int role = ((IASTNameOwner) parent).getRoleForName(this); - if( role == IASTNameOwner.r_reference ) return true; + if (role == IASTNameOwner.r_reference) return true; return false; } return false; } public int getRoleForName(IASTName n) { - IASTName [] namez = getNames(); - for( int i = 0; i < names.length; ++i ) - if( namez[i] == n ) + IASTName[] namez = getNames(); + for(int i = 0; i < names.length; ++i) + if (namez[i] == n) { - if( i < names.length - 1 ) + if (i < names.length - 1) return r_reference; IASTNode p = getParent(); - if( i == names.length - 1 && p instanceof IASTNameOwner ) + if (i == names.length - 1 && p instanceof IASTNameOwner) return ((IASTNameOwner)p).getRoleForName(this); return r_unclear; } @@ -226,20 +225,20 @@ public class CPPASTQualifiedName extends CPPASTNode implements public void setBinding(IBinding binding) { removeNullNames(); - names[names.length - 1].setBinding( binding ); + names[names.length - 1].setBinding(binding); } public boolean isConversionOrOperator() { IASTName[] nonNullNames = getNames(); // ensure no null names int len=nonNullNames.length; - if (nonNullNames[len-1] instanceof ICPPASTConversionName || nonNullNames[len-1] instanceof ICPPASTOperatorName) { + if (nonNullNames[len - 1] instanceof ICPPASTConversionName || nonNullNames[len - 1] instanceof ICPPASTOperatorName) { return true; } // check templateId's name - if (nonNullNames[len-1] instanceof ICPPASTTemplateId) { - IASTName tempName = ((ICPPASTTemplateId)nonNullNames[len-1]).getTemplateName(); + if (nonNullNames[len - 1] instanceof ICPPASTTemplateId) { + IASTName tempName = ((ICPPASTTemplateId)nonNullNames[len - 1]).getTemplateName(); if (tempName instanceof ICPPASTConversionName || tempName instanceof ICPPASTOperatorName) { return true; } @@ -252,7 +251,7 @@ public class CPPASTQualifiedName extends CPPASTNode implements IASTNode parent = getParent(); if (parent instanceof IASTNameOwner) { int role = ((IASTNameOwner) parent).getRoleForName(this); - if( role == IASTNameOwner.r_definition ) return true; + if (role == IASTNameOwner.r_definition) return true; return false; } return false; diff --git a/core/org.eclipse.cdt.core/parser/org/eclipse/cdt/internal/core/dom/parser/cpp/CPPClassScope.java b/core/org.eclipse.cdt.core/parser/org/eclipse/cdt/internal/core/dom/parser/cpp/CPPClassScope.java index eb934145d58..9aa3af516dd 100644 --- a/core/org.eclipse.cdt.core/parser/org/eclipse/cdt/internal/core/dom/parser/cpp/CPPClassScope.java +++ b/core/org.eclipse.cdt.core/parser/org/eclipse/cdt/internal/core/dom/parser/cpp/CPPClassScope.java @@ -10,6 +10,7 @@ * Markus Schorn (Wind River Systems) * Bryan Wilkinson (QNX) * Andrew Ferguson (Symbian) + * Sergey Prigogin (Google) *******************************************************************************/ package org.eclipse.cdt.internal.core.dom.parser.cpp; @@ -78,8 +79,7 @@ public class CPPClassScope extends CPPScope implements ICPPClassScope { IASTName name = compTypeSpec.getName(); if (name instanceof ICPPASTQualifiedName) { - IASTName[] ns = ((ICPPASTQualifiedName) name).getNames(); - name = ns[ns.length - 1]; + name = ((ICPPASTQualifiedName) name).getLastName(); } IBinding binding = name.resolveBinding(); @@ -142,8 +142,7 @@ public class CPPClassScope extends CPPScope implements ICPPClassScope { ICPPASTCompositeTypeSpecifier compType = (ICPPASTCompositeTypeSpecifier) getPhysicalNode(); IASTName compName = compType.getName(); if (compName instanceof ICPPASTQualifiedName) { - IASTName[] ns = ((ICPPASTQualifiedName)compName).getNames(); - compName = ns[ns.length - 1]; + compName = ((ICPPASTQualifiedName) compName).getLastName(); } return CPPVisitor.getContainingScope(compName); } @@ -162,14 +161,13 @@ public class CPPClassScope extends CPPScope implements ICPPClassScope { @Override public void addName(IASTName name) throws DOMException { - IASTNode parent = name.getParent(); if (name instanceof ICPPASTQualifiedName) { - final IASTName[] qn= ((ICPPASTQualifiedName) name).getNames(); - final IASTName ln= qn[qn.length-1]; + IASTName ln= ((ICPPASTQualifiedName) name).getLastName(); if (CPPVisitor.getContainingScope(name) != CPPVisitor.getContainingScope(ln)) { return; } } + IASTNode parent = name.getParent(); if (parent instanceof IASTDeclarator) { if (CPPVisitor.isConstructor(this, (IASTDeclarator) parent)) { addConstructor(name); @@ -208,8 +206,7 @@ public class CPPClassScope extends CPPScope implements ICPPClassScope { ICPPASTCompositeTypeSpecifier compType = (ICPPASTCompositeTypeSpecifier) getPhysicalNode(); IASTName compName = compType.getName(); if (compName instanceof ICPPASTQualifiedName) { - IASTName[] ns = ((ICPPASTQualifiedName)compName).getNames(); - compName = ns[ns.length - 1]; + compName = ((ICPPASTQualifiedName) compName).getLastName(); } if (CharArrayUtils.equals(c, compName.toCharArray())) { if (isConstructorReference(name)) { @@ -228,8 +225,7 @@ public class CPPClassScope extends CPPScope implements ICPPClassScope { ICPPASTCompositeTypeSpecifier compType = (ICPPASTCompositeTypeSpecifier) getPhysicalNode(); IASTName compName = compType.getName(); if (compName instanceof ICPPASTQualifiedName) { - IASTName[] ns = ((ICPPASTQualifiedName)compName).getNames(); - compName = ns[ns.length - 1]; + compName = ((ICPPASTQualifiedName) compName).getLastName(); } IBinding[] result = null; if ((!prefixLookup && CharArrayUtils.equals(c, compName.toCharArray())) @@ -313,12 +309,11 @@ public class CPPClassScope extends CPPScope implements ICPPClassScope { ICPPASTCompositeTypeSpecifier compType = (ICPPASTCompositeTypeSpecifier) getPhysicalNode(); IASTName compName = compType.getName(); if (compName instanceof ICPPASTQualifiedName) { - IASTName[] ns = ((ICPPASTQualifiedName)compName).getNames(); - compName = ns[ns.length - 1]; + compName = ((ICPPASTQualifiedName) compName).getLastName(); } if (CharArrayUtils.equals(compName.toCharArray(), n)) { - return new IBinding[] {getClassType()}; + return new IBinding[] { getClassType() }; } return super.find(name); @@ -330,8 +325,7 @@ public class CPPClassScope extends CPPScope implements ICPPClassScope { if (node instanceof ICPPASTTemplateId) node = node.getParent(); if (node instanceof ICPPASTQualifiedName) { - IASTName[] ns = ((ICPPASTQualifiedName)node).getNames(); - if (ns[ns.length - 1] == name) + if (((ICPPASTQualifiedName) node).getLastName() == name) node = node.getParent(); else return false; @@ -494,8 +488,7 @@ class ImplicitsAnalysis { dcltor = ((IASTFunctionDefinition)member).getDeclarator(); } if (!(dcltor instanceof ICPPASTFunctionDeclarator) || - !CharArrayUtils.equals(dcltor.getName().toCharArray(), OverloadableOperator.ASSIGN.toCharArray())) - { + !CharArrayUtils.equals(dcltor.getName().toCharArray(), OverloadableOperator.ASSIGN.toCharArray())) { continue; } @@ -517,12 +510,12 @@ class ImplicitsAnalysis { private static boolean paramHasTypeReferenceToTheAssociatedClassType(IASTParameterDeclaration dec, String name) { boolean result= false; IASTDeclarator pdtor= dec.getDeclarator(); - if (pdtor.getPointerOperators().length == 1 && pdtor.getPointerOperators()[0] instanceof ICPPASTReferenceOperator) { - if (dec.getDeclSpecifier() instanceof ICPPASTNamedTypeSpecifier) { - ICPPASTNamedTypeSpecifier nts= (ICPPASTNamedTypeSpecifier) dec.getDeclSpecifier(); - if (name == null || name.equals(nts.getName().getRawSignature())) { - result= true; - } + if (pdtor.getPointerOperators().length == 1 && + pdtor.getPointerOperators()[0] instanceof ICPPASTReferenceOperator && + dec.getDeclSpecifier() instanceof ICPPASTNamedTypeSpecifier) { + ICPPASTNamedTypeSpecifier nts= (ICPPASTNamedTypeSpecifier) dec.getDeclSpecifier(); + if (name == null || name.equals(nts.getName().getRawSignature())) { + result= true; } } return result; diff --git a/core/org.eclipse.cdt.core/parser/org/eclipse/cdt/internal/core/dom/parser/cpp/semantics/LookupData.java b/core/org.eclipse.cdt.core/parser/org/eclipse/cdt/internal/core/dom/parser/cpp/semantics/LookupData.java index 0a6c241fefb..ade055945e7 100644 --- a/core/org.eclipse.cdt.core/parser/org/eclipse/cdt/internal/core/dom/parser/cpp/semantics/LookupData.java +++ b/core/org.eclipse.cdt.core/parser/org/eclipse/cdt/internal/core/dom/parser/cpp/semantics/LookupData.java @@ -114,7 +114,7 @@ class LookupData { astName = null; } - public final char[] name () { + public final char[] name() { if (astName != null) return astName.toCharArray(); return CPPSemantics.EMPTY_NAME_ARRAY;