1
0
Fork 0
mirror of https://github.com/eclipse-cdt/cdt synced 2025-04-29 19:45:01 +02:00

Code streamlining.

This commit is contained in:
Sergey Prigogin 2008-05-26 21:08:35 +00:00
parent d3477152cd
commit 79c2c87814
3 changed files with 33 additions and 41 deletions

View file

@ -145,7 +145,6 @@ public class CPPASTQualifiedName extends CPPASTNode implements
public void setSignature(String signature) { public void setSignature(String signature) {
this.signature = signature; this.signature = signature;
} }
@Override @Override

View file

@ -10,6 +10,7 @@
* Markus Schorn (Wind River Systems) * Markus Schorn (Wind River Systems)
* Bryan Wilkinson (QNX) * Bryan Wilkinson (QNX)
* Andrew Ferguson (Symbian) * Andrew Ferguson (Symbian)
* Sergey Prigogin (Google)
*******************************************************************************/ *******************************************************************************/
package org.eclipse.cdt.internal.core.dom.parser.cpp; package org.eclipse.cdt.internal.core.dom.parser.cpp;
@ -78,8 +79,7 @@ public class CPPClassScope extends CPPScope implements ICPPClassScope {
IASTName name = compTypeSpec.getName(); IASTName name = compTypeSpec.getName();
if (name instanceof ICPPASTQualifiedName) { if (name instanceof ICPPASTQualifiedName) {
IASTName[] ns = ((ICPPASTQualifiedName) name).getNames(); name = ((ICPPASTQualifiedName) name).getLastName();
name = ns[ns.length - 1];
} }
IBinding binding = name.resolveBinding(); IBinding binding = name.resolveBinding();
@ -142,8 +142,7 @@ public class CPPClassScope extends CPPScope implements ICPPClassScope {
ICPPASTCompositeTypeSpecifier compType = (ICPPASTCompositeTypeSpecifier) getPhysicalNode(); ICPPASTCompositeTypeSpecifier compType = (ICPPASTCompositeTypeSpecifier) getPhysicalNode();
IASTName compName = compType.getName(); IASTName compName = compType.getName();
if (compName instanceof ICPPASTQualifiedName) { if (compName instanceof ICPPASTQualifiedName) {
IASTName[] ns = ((ICPPASTQualifiedName)compName).getNames(); compName = ((ICPPASTQualifiedName) compName).getLastName();
compName = ns[ns.length - 1];
} }
return CPPVisitor.getContainingScope(compName); return CPPVisitor.getContainingScope(compName);
} }
@ -162,14 +161,13 @@ public class CPPClassScope extends CPPScope implements ICPPClassScope {
@Override @Override
public void addName(IASTName name) throws DOMException { public void addName(IASTName name) throws DOMException {
IASTNode parent = name.getParent();
if (name instanceof ICPPASTQualifiedName) { if (name instanceof ICPPASTQualifiedName) {
final IASTName[] qn= ((ICPPASTQualifiedName) name).getNames(); IASTName ln= ((ICPPASTQualifiedName) name).getLastName();
final IASTName ln= qn[qn.length-1];
if (CPPVisitor.getContainingScope(name) != CPPVisitor.getContainingScope(ln)) { if (CPPVisitor.getContainingScope(name) != CPPVisitor.getContainingScope(ln)) {
return; return;
} }
} }
IASTNode parent = name.getParent();
if (parent instanceof IASTDeclarator) { if (parent instanceof IASTDeclarator) {
if (CPPVisitor.isConstructor(this, (IASTDeclarator) parent)) { if (CPPVisitor.isConstructor(this, (IASTDeclarator) parent)) {
addConstructor(name); addConstructor(name);
@ -208,8 +206,7 @@ public class CPPClassScope extends CPPScope implements ICPPClassScope {
ICPPASTCompositeTypeSpecifier compType = (ICPPASTCompositeTypeSpecifier) getPhysicalNode(); ICPPASTCompositeTypeSpecifier compType = (ICPPASTCompositeTypeSpecifier) getPhysicalNode();
IASTName compName = compType.getName(); IASTName compName = compType.getName();
if (compName instanceof ICPPASTQualifiedName) { if (compName instanceof ICPPASTQualifiedName) {
IASTName[] ns = ((ICPPASTQualifiedName)compName).getNames(); compName = ((ICPPASTQualifiedName) compName).getLastName();
compName = ns[ns.length - 1];
} }
if (CharArrayUtils.equals(c, compName.toCharArray())) { if (CharArrayUtils.equals(c, compName.toCharArray())) {
if (isConstructorReference(name)) { if (isConstructorReference(name)) {
@ -228,8 +225,7 @@ public class CPPClassScope extends CPPScope implements ICPPClassScope {
ICPPASTCompositeTypeSpecifier compType = (ICPPASTCompositeTypeSpecifier) getPhysicalNode(); ICPPASTCompositeTypeSpecifier compType = (ICPPASTCompositeTypeSpecifier) getPhysicalNode();
IASTName compName = compType.getName(); IASTName compName = compType.getName();
if (compName instanceof ICPPASTQualifiedName) { if (compName instanceof ICPPASTQualifiedName) {
IASTName[] ns = ((ICPPASTQualifiedName)compName).getNames(); compName = ((ICPPASTQualifiedName) compName).getLastName();
compName = ns[ns.length - 1];
} }
IBinding[] result = null; IBinding[] result = null;
if ((!prefixLookup && CharArrayUtils.equals(c, compName.toCharArray())) if ((!prefixLookup && CharArrayUtils.equals(c, compName.toCharArray()))
@ -313,8 +309,7 @@ public class CPPClassScope extends CPPScope implements ICPPClassScope {
ICPPASTCompositeTypeSpecifier compType = (ICPPASTCompositeTypeSpecifier) getPhysicalNode(); ICPPASTCompositeTypeSpecifier compType = (ICPPASTCompositeTypeSpecifier) getPhysicalNode();
IASTName compName = compType.getName(); IASTName compName = compType.getName();
if (compName instanceof ICPPASTQualifiedName) { if (compName instanceof ICPPASTQualifiedName) {
IASTName[] ns = ((ICPPASTQualifiedName)compName).getNames(); compName = ((ICPPASTQualifiedName) compName).getLastName();
compName = ns[ns.length - 1];
} }
if (CharArrayUtils.equals(compName.toCharArray(), n)) { if (CharArrayUtils.equals(compName.toCharArray(), n)) {
@ -330,8 +325,7 @@ public class CPPClassScope extends CPPScope implements ICPPClassScope {
if (node instanceof ICPPASTTemplateId) if (node instanceof ICPPASTTemplateId)
node = node.getParent(); node = node.getParent();
if (node instanceof ICPPASTQualifiedName) { if (node instanceof ICPPASTQualifiedName) {
IASTName[] ns = ((ICPPASTQualifiedName)node).getNames(); if (((ICPPASTQualifiedName) node).getLastName() == name)
if (ns[ns.length - 1] == name)
node = node.getParent(); node = node.getParent();
else else
return false; return false;
@ -494,8 +488,7 @@ class ImplicitsAnalysis {
dcltor = ((IASTFunctionDefinition)member).getDeclarator(); dcltor = ((IASTFunctionDefinition)member).getDeclarator();
} }
if (!(dcltor instanceof ICPPASTFunctionDeclarator) || if (!(dcltor instanceof ICPPASTFunctionDeclarator) ||
!CharArrayUtils.equals(dcltor.getName().toCharArray(), OverloadableOperator.ASSIGN.toCharArray())) !CharArrayUtils.equals(dcltor.getName().toCharArray(), OverloadableOperator.ASSIGN.toCharArray())) {
{
continue; continue;
} }
@ -517,14 +510,14 @@ class ImplicitsAnalysis {
private static boolean paramHasTypeReferenceToTheAssociatedClassType(IASTParameterDeclaration dec, String name) { private static boolean paramHasTypeReferenceToTheAssociatedClassType(IASTParameterDeclaration dec, String name) {
boolean result= false; boolean result= false;
IASTDeclarator pdtor= dec.getDeclarator(); IASTDeclarator pdtor= dec.getDeclarator();
if (pdtor.getPointerOperators().length == 1 && pdtor.getPointerOperators()[0] instanceof ICPPASTReferenceOperator) { if (pdtor.getPointerOperators().length == 1 &&
if (dec.getDeclSpecifier() instanceof ICPPASTNamedTypeSpecifier) { pdtor.getPointerOperators()[0] instanceof ICPPASTReferenceOperator &&
dec.getDeclSpecifier() instanceof ICPPASTNamedTypeSpecifier) {
ICPPASTNamedTypeSpecifier nts= (ICPPASTNamedTypeSpecifier) dec.getDeclSpecifier(); ICPPASTNamedTypeSpecifier nts= (ICPPASTNamedTypeSpecifier) dec.getDeclSpecifier();
if (name == null || name.equals(nts.getName().getRawSignature())) { if (name == null || name.equals(nts.getName().getRawSignature())) {
result= true; result= true;
} }
} }
}
return result; return result;
} }