1
0
Fork 0
mirror of https://github.com/eclipse-cdt/cdt synced 2025-06-08 02:06:01 +02:00

Fixed Bug 84371 - AST problems with ICPPASTQualifiedName ::f

This commit is contained in:
John Camelon 2005-02-08 14:56:05 +00:00
parent 30277a9b62
commit cc8d114f90
7 changed files with 1137 additions and 1055 deletions

View file

@ -22,6 +22,7 @@ import org.eclipse.cdt.core.dom.ast.IASTExpressionStatement;
import org.eclipse.cdt.core.dom.ast.IASTFunctionDeclarator;
import org.eclipse.cdt.core.dom.ast.IASTFunctionDefinition;
import org.eclipse.cdt.core.dom.ast.IASTIdExpression;
import org.eclipse.cdt.core.dom.ast.IASTInitializerExpression;
import org.eclipse.cdt.core.dom.ast.IASTName;
import org.eclipse.cdt.core.dom.ast.IASTNamedTypeSpecifier;
import org.eclipse.cdt.core.dom.ast.IASTSimpleDeclaration;
@ -65,7 +66,8 @@ public class AST2CPPTests extends AST2BaseTest {
IASTTranslationUnit tu = parse(buffer.toString(), ParserLanguage.CPP);
IASTSimpleDeclaration decl = (IASTSimpleDeclaration) tu.getDeclarations()[0];
IASTCompositeTypeSpecifier compTypeSpec = (IASTCompositeTypeSpecifier) decl.getDeclSpecifier();
IASTCompositeTypeSpecifier compTypeSpec = (IASTCompositeTypeSpecifier) decl
.getDeclSpecifier();
IASTName name_A = compTypeSpec.getName();
IASTDeclarator dtor = decl.getDeclarators()[0];
@ -86,12 +88,14 @@ public class AST2CPPTests extends AST2BaseTest {
IASTSimpleDeclaration decl = (IASTSimpleDeclaration) tu.getDeclarations()[0];
assertEquals(decl.getDeclarators().length, 0);
IASTElaboratedTypeSpecifier elabSpec = (IASTElaboratedTypeSpecifier) decl.getDeclSpecifier();
IASTElaboratedTypeSpecifier elabSpec = (IASTElaboratedTypeSpecifier) decl
.getDeclSpecifier();
IASTName name_elab = elabSpec.getName();
decl = (IASTSimpleDeclaration) tu.getDeclarations()[1];
assertEquals(decl.getDeclarators().length, 0);
IASTCompositeTypeSpecifier compSpec = (IASTCompositeTypeSpecifier) decl.getDeclSpecifier();
IASTCompositeTypeSpecifier compSpec = (IASTCompositeTypeSpecifier) decl
.getDeclSpecifier();
IASTName name_comp = compSpec.getName();
ICompositeType A = (ICompositeType) name_elab.resolveBinding();
@ -107,13 +111,15 @@ public class AST2CPPTests extends AST2BaseTest {
IASTSimpleDeclaration decl = (IASTSimpleDeclaration) tu.getDeclarations()[0];
assertEquals(decl.getDeclarators().length, 0);
IASTCompositeTypeSpecifier compType = (IASTCompositeTypeSpecifier) decl.getDeclSpecifier();
IASTCompositeTypeSpecifier compType = (IASTCompositeTypeSpecifier) decl
.getDeclSpecifier();
IASTName name_A = compType.getName();
decl = (IASTSimpleDeclaration) tu.getDeclarations()[1];
IASTDeclarator dtor = decl.getDeclarators()[0];
IASTName name_a = dtor.getName();
IASTNamedTypeSpecifier namedSpec = (IASTNamedTypeSpecifier) decl.getDeclSpecifier();
IASTNamedTypeSpecifier namedSpec = (IASTNamedTypeSpecifier) decl
.getDeclSpecifier();
IASTName name_A2 = namedSpec.getName();
IVariable a = (IVariable) name_a.resolveBinding();
@ -133,7 +139,8 @@ public class AST2CPPTests extends AST2BaseTest {
IASTSimpleDeclaration decl = (IASTSimpleDeclaration) tu.getDeclarations()[0];
assertEquals(decl.getDeclarators().length, 0);
ICPPASTCompositeTypeSpecifier comp = (ICPPASTCompositeTypeSpecifier) decl.getDeclSpecifier();
ICPPASTCompositeTypeSpecifier comp = (ICPPASTCompositeTypeSpecifier) decl
.getDeclSpecifier();
IASTName name_A = comp.getName();
decl = (IASTSimpleDeclaration) comp.getMembers()[0];
@ -154,7 +161,8 @@ public class AST2CPPTests extends AST2BaseTest {
IASTSimpleDeclaration decl = (IASTSimpleDeclaration) tu.getDeclarations()[0];
assertEquals(decl.getDeclarators().length, 0);
IASTCompositeTypeSpecifier comp = (IASTCompositeTypeSpecifier) decl.getDeclSpecifier();
IASTCompositeTypeSpecifier comp = (IASTCompositeTypeSpecifier) decl
.getDeclSpecifier();
IASTName name_A = comp.getName();
decl = (IASTSimpleDeclaration) comp.getMembers()[0];
@ -177,14 +185,16 @@ public class AST2CPPTests extends AST2BaseTest {
IASTSimpleDeclaration decl = (IASTSimpleDeclaration) tu.getDeclarations()[0];
assertEquals(decl.getDeclarators().length, 0);
IASTCompositeTypeSpecifier comp = (IASTCompositeTypeSpecifier) decl.getDeclSpecifier();
IASTCompositeTypeSpecifier comp = (IASTCompositeTypeSpecifier) decl
.getDeclSpecifier();
IASTName name_A = comp.getName();
decl = (IASTSimpleDeclaration) comp.getMembers()[0];
IASTDeclarator dtor = decl.getDeclarators()[0];
IASTName name_f1 = dtor.getName();
IASTFunctionDefinition def = (IASTFunctionDefinition) tu.getDeclarations()[1];
IASTFunctionDefinition def = (IASTFunctionDefinition) tu
.getDeclarations()[1];
IASTFunctionDeclarator fdtor = def.getDeclarator();
ICPPASTQualifiedName name_f2 = (ICPPASTQualifiedName) fdtor.getName();
@ -216,7 +226,8 @@ public class AST2CPPTests extends AST2BaseTest {
IASTSimpleDeclaration decl = (IASTSimpleDeclaration) tu.getDeclarations()[0];
assertEquals(decl.getDeclarators().length, 0);
IASTCompositeTypeSpecifier comp = (IASTCompositeTypeSpecifier) decl.getDeclSpecifier();
IASTCompositeTypeSpecifier comp = (IASTCompositeTypeSpecifier) decl
.getDeclSpecifier();
IASTName name_A = comp.getName();
decl = (IASTSimpleDeclaration) comp.getMembers()[0];
@ -227,12 +238,14 @@ public class AST2CPPTests extends AST2BaseTest {
dtor = decl.getDeclarators()[0];
IASTName name_i = dtor.getName();
IASTFunctionDefinition def = (IASTFunctionDefinition) tu.getDeclarations()[1];
IASTFunctionDefinition def = (IASTFunctionDefinition) tu
.getDeclarations()[1];
IASTFunctionDeclarator fdtor = def.getDeclarator();
ICPPASTQualifiedName name_f2 = (ICPPASTQualifiedName) fdtor.getName();
IASTCompoundStatement compound = (IASTCompoundStatement) def.getBody();
IASTExpressionStatement statement = (IASTExpressionStatement) compound.getStatements()[0];
IASTExpressionStatement statement = (IASTExpressionStatement) compound
.getStatements()[0];
IASTIdExpression idExp = (IASTIdExpression) statement.getExpression();
IASTName name_i2 = idExp.getName();
@ -268,7 +281,8 @@ public class AST2CPPTests extends AST2BaseTest {
IASTTranslationUnit tu = parse(buffer.toString(), ParserLanguage.CPP);
IASTSimpleDeclaration decl = (IASTSimpleDeclaration) tu.getDeclarations()[0];
ICPPASTCompositeTypeSpecifier comp = (ICPPASTCompositeTypeSpecifier) decl.getDeclSpecifier();
ICPPASTCompositeTypeSpecifier comp = (ICPPASTCompositeTypeSpecifier) decl
.getDeclSpecifier();
IASTName name_A1 = comp.getName();
decl = (IASTSimpleDeclaration) comp.getMembers()[0];
@ -284,13 +298,16 @@ public class AST2CPPTests extends AST2BaseTest {
decl = (IASTSimpleDeclaration) comp.getMembers()[0];
IASTName name_f1 = decl.getDeclarators()[0].getName();
IASTFunctionDefinition def = (IASTFunctionDefinition) tu.getDeclarations()[2];
ICPPASTQualifiedName name_f2 = (ICPPASTQualifiedName) def.getDeclarator().getName();
IASTFunctionDefinition def = (IASTFunctionDefinition) tu
.getDeclarations()[2];
ICPPASTQualifiedName name_f2 = (ICPPASTQualifiedName) def.getDeclarator()
.getName();
IASTName name_B2 = name_f2.getNames()[0];
IASTName name_f3 = name_f2.getNames()[1];
IASTCompoundStatement compound = (IASTCompoundStatement) def.getBody();
IASTExpressionStatement statement = (IASTExpressionStatement) compound.getStatements()[0];
IASTExpressionStatement statement = (IASTExpressionStatement) compound
.getStatements()[0];
IASTIdExpression idExp = (IASTIdExpression) statement.getExpression();
IASTName name_i2 = idExp.getName();
@ -373,7 +390,8 @@ public class AST2CPPTests extends AST2BaseTest {
assertEquals(collector.size(), 6);
IVariable vA = (IVariable) collector.getName(0).resolveBinding();
ICompositeType cA = (ICompositeType) collector.getName( 1 ).resolveBinding();
ICompositeType cA = (ICompositeType) collector.getName(1)
.resolveBinding();
IVariable a = (IVariable) collector.getName(5).resolveBinding();
assertSame(a.getType(), cA);
@ -441,7 +459,8 @@ public class AST2CPPTests extends AST2BaseTest {
IASTTranslationUnit tu = parse(buff.toString(), ParserLanguage.CPP);
CPPNameCollector collector = new CPPNameCollector();
CPPVisitor.visitTranslationUnit(tu, collector);
ICPPClassType anonStruct = (ICPPClassType) collector.getName( 0 ).resolveBinding();
ICPPClassType anonStruct = (ICPPClassType) collector.getName(0)
.resolveBinding();
ICPPField x = (ICPPField) collector.getName(1).resolveBinding();
ITypedef S = (ITypedef) collector.getName(2).resolveBinding();
IFunction f = (IFunction) collector.getName(3).resolveBinding();
@ -453,6 +472,7 @@ public class AST2CPPTests extends AST2BaseTest {
assertInstances(collector, f, 1);
assertInstances(collector, myS, 2);
}
public void testStructureTags_1() throws Exception {
StringBuffer buffer = new StringBuffer();
buffer.append("struct A; \n"); //$NON-NLS-1$
@ -554,6 +574,7 @@ public class AST2CPPTests extends AST2BaseTest {
assertInstances(collector, f, 2);
assertInstances(collector, a, 3);
}
public void testSimpleFunctionCall() throws Exception {
StringBuffer buffer = new StringBuffer();
buffer.append("void f(); \n"); //$NON-NLS-1$
@ -675,17 +696,21 @@ public class AST2CPPTests extends AST2BaseTest {
IASTTranslationUnit tu = parse(buffer.toString(), ParserLanguage.CPP);
IASTSimpleDeclaration decl = (IASTSimpleDeclaration) tu.getDeclarations()[0];
IASTElaboratedTypeSpecifier elabSpec = (IASTElaboratedTypeSpecifier) decl.getDeclSpecifier();
IASTElaboratedTypeSpecifier elabSpec = (IASTElaboratedTypeSpecifier) decl
.getDeclSpecifier();
ICompositeType A = (ICompositeType) elabSpec.getName().resolveBinding();
decl = (IASTSimpleDeclaration) tu.getDeclarations()[1];
IFunction f = (IFunction) decl.getDeclarators()[0].getName().resolveBinding();
IFunction f = (IFunction) decl.getDeclarators()[0].getName()
.resolveBinding();
decl = (IASTSimpleDeclaration) tu.getDeclarations()[2];
IVariable g = (IVariable) decl.getDeclarators()[0].getNestedDeclarator().getName().resolveBinding();
IVariable g = (IVariable) decl.getDeclarators()[0].getNestedDeclarator()
.getName().resolveBinding();
decl = (IASTSimpleDeclaration) tu.getDeclarations()[3];
IVariable h = (IVariable) decl.getDeclarators()[0].getNestedDeclarator().getNestedDeclarator().getName().resolveBinding();
IVariable h = (IVariable) decl.getDeclarators()[0].getNestedDeclarator()
.getNestedDeclarator().getName().resolveBinding();
IFunctionType t_f = f.getType();
IType t_f_return = t_f.getReturnType();
@ -696,7 +721,8 @@ public class AST2CPPTests extends AST2BaseTest {
assertTrue(t_f_params[0] instanceof IBasicType);
assertTrue(t_f_params[1] instanceof IBasicType);
//g is a pointer to a function that returns void and has 1 parameter struct A *
//g is a pointer to a function that returns void and has 1 parameter
// struct A *
IType t_g = g.getType();
assertTrue(t_g instanceof IPointerType);
assertTrue(((IPointerType) t_g).getType() instanceof IFunctionType);
@ -722,10 +748,12 @@ public class AST2CPPTests extends AST2BaseTest {
IType t_h_func_p1 = t_h_func_params[0];
assertTrue(t_h_func_p1 instanceof IPointerType);
assertTrue(((IPointerType) t_h_func_p1).getType() instanceof IPointerType);
assertSame( ((IPointerType) ((IPointerType)t_h_func_p1).getType() ).getType(), A );
assertSame(((IPointerType) ((IPointerType) t_h_func_p1).getType())
.getType(), A);
assertTrue(t_h_func_return instanceof IPointerType);
IFunctionType h_return = (IFunctionType) ((IPointerType) t_h_func_return).getType();
IFunctionType h_return = (IFunctionType) ((IPointerType) t_h_func_return)
.getType();
IType h_r = h_return.getReturnType();
IType[] h_ps = h_return.getParameterTypes();
assertTrue(h_r instanceof IBasicType);
@ -734,10 +762,13 @@ public class AST2CPPTests extends AST2BaseTest {
}
public void testFnReturningPtrToFn() throws Exception {
IASTTranslationUnit tu = parse( "void ( * f( int ) )(){}", ParserLanguage.CPP ); //$NON-NLS-1$
IASTTranslationUnit tu = parse(
"void ( * f( int ) )(){}", ParserLanguage.CPP); //$NON-NLS-1$
IASTFunctionDefinition def = (IASTFunctionDefinition) tu.getDeclarations()[0];
IFunction f = (IFunction) def.getDeclarator().getNestedDeclarator().getName().resolveBinding();
IASTFunctionDefinition def = (IASTFunctionDefinition) tu
.getDeclarations()[0];
IFunction f = (IFunction) def.getDeclarator().getNestedDeclarator()
.getName().resolveBinding();
IFunctionType ft = f.getType();
assertTrue(ft.getReturnType() instanceof IPointerType);
@ -813,7 +844,8 @@ public class AST2CPPTests extends AST2BaseTest {
CPPNameCollector collector = new CPPNameCollector();
CPPVisitor.visitTranslationUnit(tu, collector);
IProblemBinding x = (IProblemBinding) collector.getName( 12 ).resolveBinding();
IProblemBinding x = (IProblemBinding) collector.getName(12)
.resolveBinding();
assertEquals(x.getID(), IProblemBinding.SEMANTIC_AMBIGUOUS_LOOKUP);
}
@ -871,7 +903,8 @@ public class AST2CPPTests extends AST2BaseTest {
ICPPClassType B = (ICPPClassType) collector.getName(4).resolveBinding();
ICPPClassType A = (ICPPClassType) collector.getName(6).resolveBinding();
ICPPConstructor ctor = A.getConstructors()[0];
IProblemBinding x2 = (IProblemBinding) collector.getName( 14 ).resolveBinding();
IProblemBinding x2 = (IProblemBinding) collector.getName(14)
.resolveBinding();
assertEquals(x2.getID(), IProblemBinding.SEMANTIC_AMBIGUOUS_LOOKUP);
assertInstances(collector, D, 3);
@ -914,7 +947,8 @@ public class AST2CPPTests extends AST2BaseTest {
IASTTranslationUnit tu = parse(buffer.toString(), ParserLanguage.CPP);
IASTSimpleDeclaration decl = (IASTSimpleDeclaration) tu.getDeclarations()[0];
IASTCompositeTypeSpecifier compSpec = (IASTCompositeTypeSpecifier) decl.getDeclSpecifier();
IASTCompositeTypeSpecifier compSpec = (IASTCompositeTypeSpecifier) decl
.getDeclSpecifier();
ICPPClassType A = (ICPPClassType) compSpec.getName().resolveBinding();
ICPPConstructor[] ctors = A.getConstructors();
@ -939,7 +973,8 @@ public class AST2CPPTests extends AST2BaseTest {
IASTTranslationUnit tu = parse(buffer.toString(), ParserLanguage.CPP);
IASTSimpleDeclaration decl = (IASTSimpleDeclaration) tu.getDeclarations()[0];
IASTCompositeTypeSpecifier compSpec = (IASTCompositeTypeSpecifier) decl.getDeclSpecifier();
IASTCompositeTypeSpecifier compSpec = (IASTCompositeTypeSpecifier) decl
.getDeclSpecifier();
ICPPClassType A = (ICPPClassType) compSpec.getName().resolveBinding();
ICPPConstructor[] ctors = A.getConstructors();
@ -976,10 +1011,10 @@ public class AST2CPPTests extends AST2BaseTest {
}
public void testBug84250() throws Exception {
assertTrue( ((IASTDeclarationStatement) ((IASTCompoundStatement) ((IASTFunctionDefinition) parse( "void f() { int (*p) [2]; }", ParserLanguage.CPP ).getDeclarations()[0]).getBody()).getStatements()[0]).getDeclaration() instanceof IASTSimpleDeclaration ); //$NON-NLS-1$
assertTrue(((IASTDeclarationStatement) ((IASTCompoundStatement) ((IASTFunctionDefinition) parse(
"void f() { int (*p) [2]; }", ParserLanguage.CPP).getDeclarations()[0]).getBody()).getStatements()[0]).getDeclaration() instanceof IASTSimpleDeclaration); //$NON-NLS-1$
}
public void _testBug84250() throws Exception {
StringBuffer buffer = new StringBuffer();
buffer.append("void f() { \n"); //$NON-NLS-1$
@ -1000,6 +1035,7 @@ public class AST2CPPTests extends AST2BaseTest {
assertInstances(col, p, 2);
}
public void _testBug84250_2() throws Exception {
StringBuffer buffer = new StringBuffer();
buffer.append("void f() { \n"); //$NON-NLS-1$
@ -1107,7 +1143,20 @@ public class AST2CPPTests extends AST2BaseTest {
assertSame(A, Aref);
assertSame(n, nref);
assertNotNull(prob);
}
public void testBug84371() throws Exception {
String code = "int x = ::ABC::DEF::ghi;"; //$NON-NLS-1$
IASTTranslationUnit tu = parse( code, ParserLanguage.CPP );
IASTSimpleDeclaration x = (IASTSimpleDeclaration) tu.getDeclarations()[0];
IASTInitializerExpression e = (IASTInitializerExpression) x.getDeclarators()[0].getInitializer();
IASTIdExpression id = (IASTIdExpression) e.getExpression();
ICPPASTQualifiedName name = (ICPPASTQualifiedName) id.getName();
assertTrue( name.isFullyQualified() );
assertEquals( name.getNames().length, 3 );
assertEquals( name.getNames()[0].toString(), "ABC" ); //$NON-NLS-1$
assertEquals( name.getNames()[1].toString(), "DEF" ); //$NON-NLS-1$
assertEquals( name.getNames()[2].toString(), "ghi" ); //$NON-NLS-1$
}
}

View file

@ -498,7 +498,7 @@ public class CompleteParser2Tests extends TestCase {
CPPNameCollector col = new CPPNameCollector();
CPPVisitor.visitTranslationUnit( tu, col );
assertEquals( col.size(), 13 );
assertEquals( col.size(), 12 );
ICPPNamespace N = (ICPPNamespace) col.getName(0).resolveBinding();
IFunction foo = (IFunction) col.getName(1).resolveBinding();
ICPPClassType A = (ICPPClassType) col.getName(3).resolveBinding();
@ -1682,13 +1682,13 @@ public class CompleteParser2Tests extends TestCase {
CPPNameCollector col = new CPPNameCollector();
CPPVisitor.visitTranslationUnit( tu, col );
assertEquals( col.size(), 11 );
assertEquals( col.size(), 10 );
ICPPClassType s = (ICPPClassType) col.getName(0).resolveBinding();
ICPPClassType s2 = (ICPPClassType) col.getName(3).resolveBinding();
ICPPClassType ref1 = (ICPPClassType) col.getName(5).resolveBinding();
ICPPClassType ref2 = (ICPPClassType) col.getName( 9 ).resolveBinding();
ICPPClassType ref2 = (ICPPClassType) col.getName( 8 ).resolveBinding();
assertSame( s, ref2 );
assertSame( s2, ref1 );

View file

@ -21,4 +21,7 @@ public interface ICPPASTQualifiedName extends IASTName {
public static final ASTNodeProperty SEGMENT_NAME = new ASTNodeProperty( "Segment"); //$NON-NLS-1$
public void addName( IASTName name );
public IASTName [] getNames();
public boolean isFullyQualified();
public void setFullyQualified( boolean value );
}

View file

@ -95,6 +95,7 @@ public class CPPASTQualifiedName extends CPPASTNode implements ICPPASTQualifiedN
private int currentIndex = 0;
private IASTName [] names = null;
private static final int DEFAULT_NAMES_LIST_SIZE = 4;
private boolean value;
/* (non-Javadoc)
* @see org.eclipse.cdt.core.dom.ast.cpp.ICPPASTQualifiedName#getNames()
@ -138,5 +139,19 @@ public class CPPASTQualifiedName extends CPPASTNode implements ICPPASTQualifiedN
return nameArray;
}
/* (non-Javadoc)
* @see org.eclipse.cdt.core.dom.ast.cpp.ICPPASTQualifiedName#isFullyQualified()
*/
public boolean isFullyQualified() {
return value;
}
/* (non-Javadoc)
* @see org.eclipse.cdt.core.dom.ast.cpp.ICPPASTQualifiedName#setFullyQualified(boolean)
*/
public void setFullyQualified(boolean value) {
this.value = value;
}
}

View file

@ -79,7 +79,6 @@ import org.eclipse.cdt.core.dom.ast.cpp.ICPPNamespace;
import org.eclipse.cdt.core.dom.ast.cpp.ICPPReferenceType;
import org.eclipse.cdt.core.dom.ast.cpp.ICPPScope;
import org.eclipse.cdt.core.dom.ast.cpp.ICPPASTCompositeTypeSpecifier.ICPPASTBaseSpecifier;
import org.eclipse.cdt.core.parser.Keywords;
import org.eclipse.cdt.core.parser.ast.IASTNamespaceDefinition;
import org.eclipse.cdt.core.parser.util.CharArrayUtils;
import org.eclipse.cdt.core.parser.util.ObjectMap;
@ -316,17 +315,20 @@ public class CPPSemantics {
}
}
static protected IBinding resolveBinding( IASTName name ){
if( name.toCharArray().length == 2 && CharArrayUtils.equals( name.toCharArray(), Keywords.cpCOLONCOLON ) ){
IASTNode node = name.getParent();
if( node instanceof ICPPASTQualifiedName ){
ICPPASTQualifiedName qname = (ICPPASTQualifiedName) node;
if( qname.getNames()[0] == name ){
//translation unit
return ((ICPPASTTranslationUnit)node.getTranslationUnit()).resolveBinding();
}
}
return null;
}
if( name instanceof ICPPASTQualifiedName && ((ICPPASTQualifiedName)name).isFullyQualified() )
return ((ICPPASTTranslationUnit)name.getTranslationUnit()).resolveBinding();
// if( name.toCharArray().length == 2 && CharArrayUtils.equals( name.toCharArray(), Keywords.cpCOLONCOLON ) ){
// IASTNode node = name.getParent();
// if( node instanceof ICPPASTQualifiedName ){
// ICPPASTQualifiedName qname = (ICPPASTQualifiedName) node;
// if( qname.getNames()[0] == name ){
// //translation unit
// return ((ICPPASTTranslationUnit)node.getTranslationUnit()).resolveBinding();
// }
// }
// return null;
// }
//1: get some context info off of the name to figure out what kind of lookup we want
LookupData data = createLookupData( name );

View file

@ -519,6 +519,10 @@ public class CPPVisitor {
return ((ICPPNamespace)binding).getNamespaceScope();
}
}
else if( ((ICPPASTQualifiedName)parent).isFullyQualified() )
{
return parent.getTranslationUnit().getScope();
}
} else if( parent instanceof ICPPASTFieldReference ){
IASTExpression owner = ((ICPPASTFieldReference)parent).getFieldOwner();
IType type = CPPSemantics.getUltimateType( getExpressionType( owner ) );

View file

@ -2487,11 +2487,21 @@ public class GNUCPPSourceParser extends AbstractGNUSourceCodeParser {
result.setOffsetAndLength(duple.getStartOffset(), duple.getEndOffset()
- duple.getStartOffset());
ITokenDuple[] segments = duple.getSegments();
for (int i = 0; i < segments.length; ++i) {
int startingValue = 0;
if( segments.length > 0 &&
segments[0] instanceof IToken &&
((IToken)segments[0]).getType() == IToken.tCOLONCOLON )
{
++startingValue;
result.setFullyQualified(true);
}
for (int i = startingValue; i < segments.length; ++i) {
IASTName subName = null;
// take each name and add it to the result
if (segments[i] instanceof IToken)
{
subName = createName((IToken) segments[i]);
}
else if (segments[i].getTemplateIdArgLists() == null)
subName = createName(segments[i]);
else
@ -2503,7 +2513,6 @@ public class GNUCPPSourceParser extends AbstractGNUSourceCodeParser {
segments[i].getEndOffset() - segments[i].getStartOffset());
result.addName(subName);
}
return result;
}