mirror of
https://github.com/eclipse-cdt/cdt
synced 2025-04-22 22:22:11 +02:00
Interface for getting qualified names from bindings.
- new ICPPDelegate and ICPPUsingDeclaration, ICPPNamespaceAlias interfaces
This commit is contained in:
parent
0556c189a3
commit
3780016b4b
36 changed files with 1564 additions and 185 deletions
|
@ -52,16 +52,21 @@ import org.eclipse.cdt.core.dom.ast.cpp.ICPPASTCompositeTypeSpecifier;
|
|||
import org.eclipse.cdt.core.dom.ast.cpp.ICPPASTPointerToMember;
|
||||
import org.eclipse.cdt.core.dom.ast.cpp.ICPPASTQualifiedName;
|
||||
import org.eclipse.cdt.core.dom.ast.cpp.ICPPASTWhileStatement;
|
||||
import org.eclipse.cdt.core.dom.ast.cpp.ICPPBinding;
|
||||
import org.eclipse.cdt.core.dom.ast.cpp.ICPPBlockScope;
|
||||
import org.eclipse.cdt.core.dom.ast.cpp.ICPPClassScope;
|
||||
import org.eclipse.cdt.core.dom.ast.cpp.ICPPClassType;
|
||||
import org.eclipse.cdt.core.dom.ast.cpp.ICPPCompositeBinding;
|
||||
import org.eclipse.cdt.core.dom.ast.cpp.ICPPConstructor;
|
||||
import org.eclipse.cdt.core.dom.ast.cpp.ICPPDelegate;
|
||||
import org.eclipse.cdt.core.dom.ast.cpp.ICPPField;
|
||||
import org.eclipse.cdt.core.dom.ast.cpp.ICPPFunction;
|
||||
import org.eclipse.cdt.core.dom.ast.cpp.ICPPMethod;
|
||||
import org.eclipse.cdt.core.dom.ast.cpp.ICPPNamespace;
|
||||
import org.eclipse.cdt.core.dom.ast.cpp.ICPPNamespaceAlias;
|
||||
import org.eclipse.cdt.core.dom.ast.cpp.ICPPPointerToMemberType;
|
||||
import org.eclipse.cdt.core.dom.ast.cpp.ICPPReferenceType;
|
||||
import org.eclipse.cdt.core.dom.ast.cpp.ICPPUsingDeclaration;
|
||||
import org.eclipse.cdt.core.dom.ast.cpp.ICPPVariable;
|
||||
import org.eclipse.cdt.core.dom.ast.cpp.ICPPASTCompositeTypeSpecifier.ICPPASTBaseSpecifier;
|
||||
import org.eclipse.cdt.core.dom.ast.gnu.cpp.IGPPPointerToMemberType;
|
||||
import org.eclipse.cdt.core.dom.ast.gnu.cpp.IGPPPointerType;
|
||||
|
@ -848,10 +853,17 @@ public class AST2CPPTests extends AST2BaseTest {
|
|||
IFunction g = (IFunction) collector.getName(2).resolveBinding();
|
||||
ICPPNamespace X = (ICPPNamespace) collector.getName(3).resolveBinding();
|
||||
|
||||
assertInstances(collector, f, 5);
|
||||
ICPPUsingDeclaration using = (ICPPUsingDeclaration) collector.getName(5).resolveBinding();
|
||||
ICPPDelegate [] delegates = using.getDelegates();
|
||||
assertEquals( delegates.length, 1 );
|
||||
assertSame( delegates[0].getBinding(), f );
|
||||
assertInstances(collector, delegates[0], 2);
|
||||
assertInstances(collector, A, 2);
|
||||
assertInstances(collector, X, 3);
|
||||
assertInstances(collector, g, 5);
|
||||
|
||||
ICPPUsingDeclaration using_g = (ICPPUsingDeclaration) collector.getName(8).resolveBinding();
|
||||
assertSame( using_g.getDelegates()[0].getBinding(), g );
|
||||
assertInstances(collector, using_g.getDelegates()[0], 2);
|
||||
}
|
||||
|
||||
public void testFunctionDeclarations() throws Exception {
|
||||
|
@ -1055,8 +1067,12 @@ public class AST2CPPTests extends AST2BaseTest {
|
|||
assertEquals(col.size(), 8);
|
||||
ICPPNamespace A = (ICPPNamespace) col.getName(0).resolveBinding();
|
||||
IVariable x = (IVariable) col.getName(1).resolveBinding();
|
||||
ICPPNamespace B = (ICPPNamespace) col.getName(2).resolveBinding();
|
||||
assertTrue( B instanceof ICPPDelegate );
|
||||
assertSame( ((ICPPDelegate)B).getBinding(), A );
|
||||
|
||||
assertInstances(col, A, 4);
|
||||
assertInstances(col, A, 2);
|
||||
assertInstances(col, B, 2);
|
||||
assertInstances(col, x, 3);
|
||||
}
|
||||
|
||||
|
@ -1288,7 +1304,7 @@ public class AST2CPPTests extends AST2BaseTest {
|
|||
|
||||
assertEquals(col.size(), 11);
|
||||
|
||||
IVariable a1 = (IVariable) col.getName(4).resolveBinding();
|
||||
ICPPVariable a1 = (ICPPVariable) col.getName(4).resolveBinding();
|
||||
IVariable a2 = (IVariable) col.getName(10).resolveBinding();
|
||||
assertSame(a1, a2);
|
||||
}
|
||||
|
@ -2250,6 +2266,10 @@ public class AST2CPPTests extends AST2BaseTest {
|
|||
IBinding x_ref = col.getName(4).resolveBinding();
|
||||
IEnumerator RED = (IEnumerator) col.getName(6).resolveBinding();
|
||||
|
||||
String [] s = ((ICPPBinding)RED).getQualifiedName();
|
||||
assertEquals( s[0], "RED" ); //$NON-NLS-1$
|
||||
assertTrue( ((ICPPBinding)RED).isGloballyQualified() );
|
||||
|
||||
IASTName [] decls = tu.getDeclarations( enum_x );
|
||||
assertEquals( decls.length, 1 );
|
||||
assertSame( decls[0], col.getName(3) );
|
||||
|
@ -2343,13 +2363,19 @@ public class AST2CPPTests extends AST2BaseTest {
|
|||
tu.accept(col);
|
||||
|
||||
IFunction f1 = (IFunction) col.getName(2).resolveBinding();
|
||||
IFunction f2 = (IFunction) col.getName(5).resolveBinding();
|
||||
ICPPFunction f2 = (ICPPFunction) col.getName(5).resolveBinding();
|
||||
assertSame( f1, f2 );
|
||||
|
||||
IASTName [] decls = tu.getDeclarations( f2 );
|
||||
assertEquals( decls.length, 2 );
|
||||
assertSame( decls[0], col.getName(2) );
|
||||
assertSame( decls[1], col.getName(5) );
|
||||
|
||||
String [] s = f2.getQualifiedName();
|
||||
assertEquals( s[0], "Q" ); //$NON-NLS-1$
|
||||
assertEquals( s[1], "V" ); //$NON-NLS-1$
|
||||
assertEquals( s[2], "f" ); //$NON-NLS-1$
|
||||
assertTrue( f2.isGloballyQualified() );
|
||||
}
|
||||
|
||||
public void test86371() throws Exception {
|
||||
|
@ -2368,17 +2394,28 @@ public class AST2CPPTests extends AST2BaseTest {
|
|||
CPPNameCollector col = new CPPNameCollector();
|
||||
tu.accept(col);
|
||||
|
||||
IFunction f_ref = (IFunction) col.getName(12).resolveBinding();
|
||||
ICPPFunction f_ref = (ICPPFunction) col.getName(12).resolveBinding();
|
||||
assertTrue( f_ref instanceof ICPPDelegate );
|
||||
IFunction g_ref = (IFunction) col.getName(15).resolveBinding();
|
||||
|
||||
IFunction f = (IFunction) col.getName(1).resolveBinding();
|
||||
assertSame( f_ref, f );
|
||||
ICPPFunction f = (ICPPFunction) col.getName(1).resolveBinding();
|
||||
assertSame( ((ICPPDelegate)f_ref).getBinding(), f );
|
||||
|
||||
IFunction g = (IFunction) col.getName(13).resolveBinding();
|
||||
assertSame( g, g_ref );
|
||||
|
||||
assertInstances( col, f_ref, 4 );
|
||||
assertInstances( col, f_ref, 1 );
|
||||
assertInstances( col, g_ref, 2 );
|
||||
|
||||
String [] s = f_ref.getQualifiedName();
|
||||
assertEquals( s[0], "D" ); //$NON-NLS-1$
|
||||
assertEquals( s[1], "f" ); //$NON-NLS-1$
|
||||
assertTrue( f_ref.isGloballyQualified() );
|
||||
|
||||
s = f.getQualifiedName();
|
||||
assertEquals( s[0], "B" ); //$NON-NLS-1$
|
||||
assertEquals( s[1], "f" ); //$NON-NLS-1$
|
||||
assertTrue( f.isGloballyQualified() );
|
||||
}
|
||||
|
||||
public void testBug86369() throws Exception {
|
||||
|
@ -2393,17 +2430,34 @@ public class AST2CPPTests extends AST2BaseTest {
|
|||
tu.accept(col);
|
||||
|
||||
ICPPNamespace ns = (ICPPNamespace) col.getName(0).resolveBinding();
|
||||
ICPPNamespace alias = (ICPPNamespace) col.getName(1).resolveBinding();
|
||||
|
||||
String [] s = ns.getQualifiedName();
|
||||
assertEquals( s[0], "Company_with_veryblahblah" ); //$NON-NLS-1$
|
||||
s = alias.getQualifiedName();
|
||||
assertEquals( s[0], "CWVLN" ); //$NON-NLS-1$
|
||||
|
||||
assertTrue( alias instanceof ICPPDelegate );
|
||||
assertSame( ((ICPPDelegate)alias).getBinding(), ns );
|
||||
|
||||
IASTName [] refs = tu.getReferences( ns );
|
||||
assertEquals( refs.length, 3 );
|
||||
assertEquals( refs.length, 2 );
|
||||
assertSame( refs[0], col.getName(2) );
|
||||
assertSame( refs[1], col.getName(4) );
|
||||
assertSame( refs[2], col.getName(6) );
|
||||
|
||||
IASTName [] decls = tu.getDeclarations( ns );
|
||||
assertEquals( decls.length, 4 );
|
||||
assertEquals( decls.length, 1 );
|
||||
assertSame( decls[0], col.getName(0) );
|
||||
assertSame( decls[1], col.getName(1) );
|
||||
assertSame( decls[2], col.getName(3) );
|
||||
assertSame( decls[3], col.getName(5) );
|
||||
|
||||
refs = tu.getReferences( alias );
|
||||
assertEquals( refs.length, 1 );
|
||||
assertSame( refs[0], col.getName(6) );
|
||||
|
||||
decls = tu.getDeclarations( alias );
|
||||
assertEquals( decls.length, 3 );
|
||||
assertSame( decls[0], col.getName(1) );
|
||||
assertSame( decls[1], col.getName(3) );
|
||||
assertSame( decls[2], col.getName(5) );
|
||||
}
|
||||
|
||||
public void testBug86470_1() throws Exception {
|
||||
|
@ -2418,11 +2472,23 @@ public class AST2CPPTests extends AST2BaseTest {
|
|||
CPPNameCollector col = new CPPNameCollector();
|
||||
tu.accept(col);
|
||||
|
||||
IBinding b = col.getName(7).resolveBinding();
|
||||
IASTName [] decls = tu.getDeclarations( b );
|
||||
ICPPUsingDeclaration u = (ICPPUsingDeclaration) col.getName(7).resolveBinding();
|
||||
|
||||
IASTName [] decls = tu.getDeclarations( u );
|
||||
assertEquals( decls.length, 2 );
|
||||
assertSame( decls[0], col.getName(1) );
|
||||
assertSame( decls[1], col.getName(3) );
|
||||
|
||||
ICPPDelegate [] delegates = u.getDelegates();
|
||||
assertEquals( delegates.length, 2 );
|
||||
|
||||
decls = tu.getDeclarations( delegates[0] );
|
||||
assertEquals( decls.length, 1 );
|
||||
assertSame( decls[0], col.getName(7) );
|
||||
|
||||
decls = tu.getDeclarations( delegates[0].getBinding() );
|
||||
assertEquals( decls.length, 1 );
|
||||
assertSame( decls[0], col.getName(1) );
|
||||
}
|
||||
|
||||
public void testBug86470_2() throws Exception {
|
||||
|
@ -2448,8 +2514,8 @@ public class AST2CPPTests extends AST2BaseTest {
|
|||
|
||||
IFunction f_decl = (IFunction) col.getName(10).resolveBinding();
|
||||
IFunction f_ref = (IFunction) col.getName(19).resolveBinding();
|
||||
|
||||
assertSame( f_decl, f_ref );
|
||||
assertTrue( f_ref instanceof ICPPDelegate );
|
||||
assertSame( f_decl, ((ICPPDelegate)f_ref).getBinding() );
|
||||
}
|
||||
|
||||
public void testBug86470_3() throws Exception {
|
||||
|
@ -2471,13 +2537,16 @@ public class AST2CPPTests extends AST2BaseTest {
|
|||
IBinding ref1 = col.getName(8).resolveBinding();
|
||||
IBinding ref2 = col.getName(9).resolveBinding();
|
||||
|
||||
assertTrue( ref1 instanceof ICPPDelegate );
|
||||
assertTrue( ref2 instanceof ICPPDelegate );
|
||||
|
||||
ICPPClassType g_struct = (ICPPClassType) col.getName(1).resolveBinding();
|
||||
IFunction g_func = (IFunction) col.getName(2).resolveBinding();
|
||||
|
||||
assertSame( g_struct, ref2 );
|
||||
assertSame( g_func, ref1 );
|
||||
assertSame( g_struct, ((ICPPDelegate)ref2).getBinding() );
|
||||
assertSame( g_func, ((ICPPDelegate)ref1).getBinding() );
|
||||
|
||||
ICPPCompositeBinding comp = (ICPPCompositeBinding) col.getName(7).resolveBinding();
|
||||
ICPPUsingDeclaration comp = (ICPPUsingDeclaration) col.getName(7).resolveBinding();
|
||||
IASTName [] decls = tu.getDeclarations(comp);
|
||||
assertEquals( decls.length, 2 );
|
||||
assertSame( decls[0], col.getName(1) );
|
||||
|
@ -2503,14 +2572,29 @@ public class AST2CPPTests extends AST2BaseTest {
|
|||
CPPNameCollector col = new CPPNameCollector();
|
||||
tu.accept(col);
|
||||
|
||||
IBinding ref1 = col.getName(11).resolveBinding();
|
||||
IBinding ref2 = col.getName(12).resolveBinding();
|
||||
ICPPBinding ref1 = (ICPPBinding) col.getName(11).resolveBinding();
|
||||
ICPPBinding ref2 = (ICPPBinding) col.getName(12).resolveBinding();
|
||||
|
||||
ICPPClassType x_struct = (ICPPClassType) col.getName(3).resolveBinding();
|
||||
IVariable x_var = (IVariable) col.getName(1).resolveBinding();
|
||||
|
||||
assertSame( x_struct, ref2 );
|
||||
assertSame( x_var, ref1 );
|
||||
assertTrue( ref1 instanceof ICPPDelegate );
|
||||
assertTrue( ref2 instanceof ICPPDelegate );
|
||||
assertSame( x_struct, ((ICPPDelegate)ref2).getBinding() );
|
||||
assertSame( x_var, ((ICPPDelegate)ref1).getBinding() );
|
||||
|
||||
IASTName [] refs = tu.getReferences( x_struct );
|
||||
assertEquals( refs.length, 1 );
|
||||
assertSame( refs[0], col.getName(10) );
|
||||
|
||||
String [] s = ref2.getQualifiedName();
|
||||
assertEquals( s[0], "x" ); //$NON-NLS-1$
|
||||
assertFalse( ref2.isGloballyQualified() );
|
||||
|
||||
s = x_struct.getQualifiedName();
|
||||
assertEquals( s[0], "B" ); //$NON-NLS-1$
|
||||
assertEquals( s[1], "x" ); //$NON-NLS-1$
|
||||
assertTrue( x_struct.isGloballyQualified() );
|
||||
}
|
||||
|
||||
public void testBug86470_5() throws Exception {
|
||||
|
@ -2529,9 +2613,20 @@ public class AST2CPPTests extends AST2BaseTest {
|
|||
CPPNameCollector col = new CPPNameCollector();
|
||||
tu.accept(col);
|
||||
|
||||
IFunction f = (IFunction) col.getName(3).resolveBinding();
|
||||
ICPPFunction f = (ICPPFunction) col.getName(3).resolveBinding();
|
||||
|
||||
assertInstances( col, f, 2 );
|
||||
ICPPFunction f_ref = (ICPPFunction) col.getName(11).resolveBinding();
|
||||
assertTrue( f_ref instanceof ICPPDelegate );
|
||||
assertSame( ((ICPPDelegate)f_ref).getBinding(), f );
|
||||
|
||||
String [] s = f_ref.getQualifiedName();
|
||||
assertEquals( s[0], "f" ); //$NON-NLS-1$
|
||||
assertFalse( f_ref.isGloballyQualified() );
|
||||
|
||||
s = f.getQualifiedName();
|
||||
assertEquals( s[0], "A" ); //$NON-NLS-1$
|
||||
assertEquals( s[1], "f" ); //$NON-NLS-1$
|
||||
assertTrue( f.isGloballyQualified() );
|
||||
}
|
||||
|
||||
public void testBug86678 () throws Exception {
|
||||
|
@ -2592,6 +2687,10 @@ public class AST2CPPTests extends AST2BaseTest {
|
|||
IParameter b = (IParameter) col.getName(2).resolveBinding();
|
||||
IParameter c = (IParameter) col.getName(3).resolveBinding();
|
||||
|
||||
String [] s = ((ICPPBinding)a).getQualifiedName();
|
||||
assertEquals( s[0], "a" ); //$NON-NLS-1$
|
||||
assertFalse( ((ICPPBinding)a).isGloballyQualified() );
|
||||
|
||||
assertInstances( col, m, 3 );
|
||||
assertInstances( col, a, 3 );
|
||||
assertInstances( col, b, 3 );
|
||||
|
@ -2609,9 +2708,18 @@ public class AST2CPPTests extends AST2BaseTest {
|
|||
CPPNameCollector col = new CPPNameCollector();
|
||||
tu.accept(col);
|
||||
|
||||
IFunction g1 = (IFunction) col.getName(0).resolveBinding();
|
||||
ICPPFunction g1 = (ICPPFunction) col.getName(0).resolveBinding();
|
||||
ICPPMethod g2 = (ICPPMethod) col.getName(9).resolveBinding();
|
||||
|
||||
String [] s = g1.getQualifiedName();
|
||||
assertEquals( s[0], "g" ); //$NON-NLS-1$
|
||||
assertTrue( g1.isGloballyQualified() );
|
||||
|
||||
s = g2.getQualifiedName();
|
||||
assertEquals( s[0], "X" ); //$NON-NLS-1$
|
||||
assertEquals( s[1], "g" ); //$NON-NLS-1$
|
||||
assertTrue( g2.isGloballyQualified() );
|
||||
|
||||
assertInstances( col, g1, 1 );
|
||||
assertInstances( col, g2, 2 );
|
||||
}
|
||||
|
@ -2642,6 +2750,16 @@ public class AST2CPPTests extends AST2BaseTest {
|
|||
ICPPField x = (ICPPField) col.getName(23).resolveBinding();
|
||||
ICPPMethod f = (ICPPMethod) col.getName(24).resolveBinding();
|
||||
|
||||
String [] s= f.getQualifiedName();
|
||||
assertEquals( s[0], "B" ); //$NON-NLS-1$
|
||||
assertEquals( s[1], "f" ); //$NON-NLS-1$
|
||||
assertTrue( f.isGloballyQualified() );
|
||||
|
||||
s = x.getQualifiedName();
|
||||
assertEquals( s[0], "B" ); //$NON-NLS-1$
|
||||
assertEquals( s[1], "x" ); //$NON-NLS-1$
|
||||
assertTrue( x.isGloballyQualified() );
|
||||
|
||||
IProblemBinding y = (IProblemBinding) col.getName(25).resolveBinding();
|
||||
IProblemBinding g = (IProblemBinding) col.getName(26).resolveBinding();
|
||||
|
||||
|
@ -2663,7 +2781,13 @@ public class AST2CPPTests extends AST2BaseTest {
|
|||
CPPNameCollector col = new CPPNameCollector();
|
||||
tu.accept(col);
|
||||
|
||||
IVariable c = (IVariable) col.getName(1).resolveBinding();
|
||||
ICPPVariable c = (ICPPVariable) col.getName(1).resolveBinding();
|
||||
|
||||
String [] s = c.getQualifiedName();
|
||||
assertEquals( s.length, 2 );
|
||||
assertEquals( s[0], "C" ); //$NON-NLS-1$
|
||||
assertEquals( s[1], "c" ); //$NON-NLS-1$
|
||||
assertTrue( c.isGloballyQualified() );
|
||||
|
||||
IASTName [] refs = tu.getReferences( c );
|
||||
assertEquals( refs.length, 1 );
|
||||
|
@ -2683,8 +2807,16 @@ public class AST2CPPTests extends AST2BaseTest {
|
|||
CPPNameCollector col = new CPPNameCollector();
|
||||
tu.accept(col);
|
||||
|
||||
IVariable v1 = (IVariable) col.getName(2).resolveBinding();
|
||||
IVariable v2 = (IVariable) col.getName(3).resolveBinding();
|
||||
ICPPVariable v1 = (ICPPVariable) col.getName(2).resolveBinding();
|
||||
ICPPVariable v2 = (ICPPVariable) col.getName(3).resolveBinding();
|
||||
|
||||
String [] s = v1.getQualifiedName();
|
||||
assertEquals( s[0], "v1" ); //$NON-NLS-1$
|
||||
assertFalse( v1.isGloballyQualified() );
|
||||
|
||||
s = v2.getQualifiedName();
|
||||
assertEquals( s[0], "v2" ); //$NON-NLS-1$
|
||||
assertFalse( v2.isGloballyQualified() );
|
||||
|
||||
ICPPBlockScope scope = (ICPPBlockScope) v2.getScope();
|
||||
IBinding [] bs = scope.find( "v1" ); //$NON-NLS-1$
|
||||
|
@ -2746,8 +2878,20 @@ public class AST2CPPTests extends AST2BaseTest {
|
|||
IBinding [] bs = scope.find( "f" ); //$NON-NLS-1$
|
||||
assertEquals( bs.length, 3 );
|
||||
assertSame( bs[0], f3 );
|
||||
assertSame( bs[1], f1 );
|
||||
assertSame( bs[2], f2 );
|
||||
assertSame( ((ICPPDelegate)bs[1]).getBinding(), f1 );
|
||||
assertSame( ((ICPPDelegate)bs[2]).getBinding(), f2 );
|
||||
|
||||
String [] s = ((ICPPDelegate)bs[1]).getQualifiedName();
|
||||
assertEquals( s.length, 1 );
|
||||
assertEquals( s[0], "f" ); //$NON-NLS-1$
|
||||
assertFalse( ((ICPPDelegate)bs[1]).isGloballyQualified() );
|
||||
|
||||
s = ((ICPPBinding) ((ICPPDelegate)bs[1]).getBinding()).getQualifiedName();
|
||||
assertEquals( s.length, 2 );
|
||||
assertEquals( s[0], "A"); //$NON-NLS-1$
|
||||
assertEquals( s[1], "f" ); //$NON-NLS-1$
|
||||
assertTrue( ((ICPPBinding) ((ICPPDelegate)bs[1]).getBinding()).isGloballyQualified() );
|
||||
|
||||
}
|
||||
|
||||
public void testFind_4() throws Exception {
|
||||
|
@ -2882,5 +3026,35 @@ public class AST2CPPTests extends AST2BaseTest {
|
|||
IProblemBinding C = (IProblemBinding) col.getName(3).resolveBinding();
|
||||
assertEquals( C.getID(), IProblemBinding.SEMANTIC_BAD_SCOPE );
|
||||
}
|
||||
|
||||
public void testNamespaceAlias_2() throws Exception {
|
||||
StringBuffer buffer = new StringBuffer();
|
||||
buffer.append("namespace A { int i; } \n"); //$NON-NLS-1$
|
||||
buffer.append("namespace B = A; \n"); //$NON-NLS-1$
|
||||
buffer.append("void f() { \n"); //$NON-NLS-1$
|
||||
buffer.append(" B::i; \n"); //$NON-NLS-1$
|
||||
buffer.append("} \n"); //$NON-NLS-1$
|
||||
|
||||
IASTTranslationUnit tu = parse( buffer.toString(), ParserLanguage.CPP ); //$NON-NLS-1$
|
||||
CPPNameCollector col = new CPPNameCollector();
|
||||
tu.accept(col);
|
||||
|
||||
ICPPNamespace A = (ICPPNamespace) col.getName(0).resolveBinding();
|
||||
ICPPNamespaceAlias alias = (ICPPNamespaceAlias) col.getName(6).resolveBinding();
|
||||
ICPPVariable i = (ICPPVariable) col.getName(7).resolveBinding();
|
||||
|
||||
assertInstances( col, A, 2 );
|
||||
assertInstances( col, alias, 2 );
|
||||
assertInstances( col, i, 3 );
|
||||
|
||||
String [] s = i.getQualifiedName();
|
||||
assertEquals( s[0], "A" ); //$NON-NLS-1$
|
||||
assertEquals( s[1], "i" ); //$NON-NLS-1$
|
||||
assertTrue( i.isGloballyQualified() );
|
||||
|
||||
s = alias.getQualifiedName();
|
||||
assertEquals( s[0], "B" ); //$NON-NLS-1$
|
||||
assertTrue( alias.isGloballyQualified() );
|
||||
}
|
||||
}
|
||||
|
||||
|
|
|
@ -51,11 +51,13 @@ import org.eclipse.cdt.core.dom.ast.cpp.CPPASTVisitor;
|
|||
import org.eclipse.cdt.core.dom.ast.cpp.ICPPBase;
|
||||
import org.eclipse.cdt.core.dom.ast.cpp.ICPPClassType;
|
||||
import org.eclipse.cdt.core.dom.ast.cpp.ICPPConstructor;
|
||||
import org.eclipse.cdt.core.dom.ast.cpp.ICPPDelegate;
|
||||
import org.eclipse.cdt.core.dom.ast.cpp.ICPPField;
|
||||
import org.eclipse.cdt.core.dom.ast.cpp.ICPPMember;
|
||||
import org.eclipse.cdt.core.dom.ast.cpp.ICPPMethod;
|
||||
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.ICPPUsingDeclaration;
|
||||
import org.eclipse.cdt.core.parser.CodeReader;
|
||||
import org.eclipse.cdt.core.parser.IScanner;
|
||||
import org.eclipse.cdt.core.parser.NullLogService;
|
||||
|
@ -380,7 +382,11 @@ public class CompleteParser2Tests extends TestCase {
|
|||
|
||||
public void testUsingClauses() throws Exception
|
||||
{
|
||||
IASTTranslationUnit tu = parse( "namespace A { namespace B { int x; class C { static int y = 5; }; } } \n using namespace A::B;\n using A::B::x;using A::B::C;using A::B::C::y;"); //$NON-NLS-1$
|
||||
IASTTranslationUnit tu = parse( "namespace A { namespace B { int x; class C { static int y = 5; }; } } \n " + //$NON-NLS-1$
|
||||
"using namespace A::B;\n " + //$NON-NLS-1$
|
||||
"using A::B::x;" + //$NON-NLS-1$
|
||||
"using A::B::C;" + //$NON-NLS-1$
|
||||
"using A::B::C::y;"); //$NON-NLS-1$
|
||||
CPPNameCollector col = new CPPNameCollector();
|
||||
tu.accept( col );
|
||||
|
||||
|
@ -391,11 +397,20 @@ public class CompleteParser2Tests extends TestCase {
|
|||
ICPPClassType C = (ICPPClassType) col.getName(3).resolveBinding();
|
||||
ICPPField y = (ICPPField) col.getName(4).resolveBinding();
|
||||
|
||||
ICPPUsingDeclaration using_x = (ICPPUsingDeclaration) col.getName(11).resolveBinding();
|
||||
ICPPUsingDeclaration using_C = (ICPPUsingDeclaration) col.getName(15).resolveBinding();
|
||||
ICPPUsingDeclaration using_y = (ICPPUsingDeclaration) col.getName(20).resolveBinding();
|
||||
|
||||
assertInstances( col, A, 5 );
|
||||
assertInstances( col, B, 6 );
|
||||
assertInstances( col, x, 3 );
|
||||
assertInstances( col, C, 4 );
|
||||
assertInstances( col, y, 3 );
|
||||
assertInstances( col, x, 1 );
|
||||
assertInstances( col, C, 2 );
|
||||
assertInstances( col, y, 1 );
|
||||
|
||||
ICPPDelegate [] ds = using_x.getDelegates();
|
||||
assertSame( ds[0].getBinding(), x );
|
||||
assertSame( using_C.getDelegates()[0].getBinding(), C );
|
||||
assertSame( using_y.getDelegates()[0].getBinding(), y );
|
||||
}
|
||||
|
||||
public void testEnumerations() throws Exception
|
||||
|
@ -506,10 +521,16 @@ public class CompleteParser2Tests extends TestCase {
|
|||
ICPPClassType A = (ICPPClassType) col.getName(3).resolveBinding();
|
||||
ICPPMethod bar = (ICPPMethod) col.getName(4).resolveBinding();
|
||||
|
||||
ICPPUsingDeclaration using_foo = (ICPPUsingDeclaration) col.getName(8).resolveBinding();
|
||||
ICPPUsingDeclaration using_bar = (ICPPUsingDeclaration) col.getName(11).resolveBinding();
|
||||
|
||||
assertInstances( col, N, 2 );
|
||||
assertInstances( col, foo, 3 );
|
||||
assertInstances( col, foo, 1 );
|
||||
assertInstances( col, A, 2 );
|
||||
assertInstances( col, bar, 3 );
|
||||
assertInstances( col, bar, 1 );
|
||||
|
||||
assertSame( using_foo.getDelegates()[0].getBinding(), foo );
|
||||
assertSame( using_bar.getDelegates()[0].getBinding(), bar );
|
||||
}
|
||||
|
||||
public void testLinkageSpec() throws Exception
|
||||
|
|
|
@ -0,0 +1,40 @@
|
|||
/*******************************************************************************
|
||||
* Copyright (c) 2004 IBM Corporation and others.
|
||||
* All rights reserved. This program and the accompanying materials
|
||||
* are made available under the terms of the Common Public License v1.0
|
||||
* which accompanies this distribution, and is available at
|
||||
* http://www.eclipse.org/legal/cpl-v10.html
|
||||
*
|
||||
* Contributors:
|
||||
* IBM Corporation - initial API and implementation
|
||||
*******************************************************************************/
|
||||
|
||||
/*
|
||||
* Created on Mar 15, 2005
|
||||
*/
|
||||
package org.eclipse.cdt.core.dom.ast.cpp;
|
||||
|
||||
import org.eclipse.cdt.core.dom.ast.DOMException;
|
||||
import org.eclipse.cdt.core.dom.ast.IBinding;
|
||||
|
||||
/**
|
||||
* @author aniefer
|
||||
*/
|
||||
public interface ICPPBinding extends IBinding {
|
||||
/**
|
||||
* return an array of strings representing the qualified name of this binding
|
||||
* @return
|
||||
*/
|
||||
public String [] getQualifiedName() throws DOMException;
|
||||
public char [][] getQualifiedNameCharArray() throws DOMException;
|
||||
|
||||
/**
|
||||
* returns true if this binding is qualified wrt the translation unit
|
||||
* for example, local variables, function parameters and local classes will
|
||||
* all return false.
|
||||
* @return
|
||||
* @throws DOMException
|
||||
*/
|
||||
public boolean isGloballyQualified() throws DOMException;
|
||||
|
||||
}
|
|
@ -20,7 +20,7 @@ import org.eclipse.cdt.core.dom.ast.IField;
|
|||
*
|
||||
* @author Doug Schaefer
|
||||
*/
|
||||
public interface ICPPClassType extends ICompositeType {
|
||||
public interface ICPPClassType extends ICompositeType, ICPPBinding {
|
||||
|
||||
public static final int k_class = ICPPASTCompositeTypeSpecifier.k_class;
|
||||
|
||||
|
|
|
@ -0,0 +1,44 @@
|
|||
/*******************************************************************************
|
||||
* Copyright (c) 2004 IBM Corporation and others.
|
||||
* All rights reserved. This program and the accompanying materials
|
||||
* are made available under the terms of the Common Public License v1.0
|
||||
* which accompanies this distribution, and is available at
|
||||
* http://www.eclipse.org/legal/cpl-v10.html
|
||||
*
|
||||
* Contributors:
|
||||
* IBM Corporation - initial API and implementation
|
||||
*******************************************************************************/
|
||||
|
||||
/*
|
||||
* Created on Mar 15, 2005
|
||||
*/
|
||||
package org.eclipse.cdt.core.dom.ast.cpp;
|
||||
|
||||
import org.eclipse.cdt.core.dom.ast.IBinding;
|
||||
|
||||
/**
|
||||
* ICPPDelegate is meant to represent IBindings that are identical in most
|
||||
* ways to another binding. Namespace aliases and using declarations will both
|
||||
* be represented by delegates
|
||||
*
|
||||
* @author aniefer
|
||||
*/
|
||||
public interface ICPPDelegate extends ICPPBinding, Cloneable {
|
||||
/**
|
||||
* Kinds of things delegates can represent
|
||||
*/
|
||||
public static final int NAMESPACE_ALIAS = 1;
|
||||
public static final int USING_DECLARATION = 2;
|
||||
|
||||
/**
|
||||
* What type of delegate is this?
|
||||
* @return
|
||||
*/
|
||||
public int getDelegateType();
|
||||
|
||||
/**
|
||||
* get the original binding that we are a delegate of
|
||||
* @return
|
||||
*/
|
||||
public IBinding getBinding();
|
||||
}
|
|
@ -15,6 +15,6 @@ import org.eclipse.cdt.core.dom.ast.IField;
|
|||
/**
|
||||
* @author Doug Schaefer
|
||||
*/
|
||||
public interface ICPPField extends IField, ICPPMember {
|
||||
public interface ICPPField extends IField, ICPPMember, ICPPVariable {
|
||||
|
||||
}
|
||||
|
|
|
@ -0,0 +1,24 @@
|
|||
/*******************************************************************************
|
||||
* Copyright (c) 2004 IBM Corporation and others.
|
||||
* All rights reserved. This program and the accompanying materials
|
||||
* are made available under the terms of the Common Public License v1.0
|
||||
* which accompanies this distribution, and is available at
|
||||
* http://www.eclipse.org/legal/cpl-v10.html
|
||||
*
|
||||
* Contributors:
|
||||
* IBM Corporation - initial API and implementation
|
||||
*******************************************************************************/
|
||||
|
||||
/*
|
||||
* Created on Mar 15, 2005
|
||||
*/
|
||||
package org.eclipse.cdt.core.dom.ast.cpp;
|
||||
|
||||
import org.eclipse.cdt.core.dom.ast.IFunction;
|
||||
|
||||
/**
|
||||
* @author aniefer
|
||||
*/
|
||||
public interface ICPPFunction extends IFunction, ICPPBinding {
|
||||
|
||||
}
|
|
@ -10,11 +10,10 @@
|
|||
**********************************************************************/
|
||||
package org.eclipse.cdt.core.dom.ast.cpp;
|
||||
|
||||
import org.eclipse.cdt.core.dom.ast.IFunction;
|
||||
|
||||
/**
|
||||
* @author Doug Schaefer
|
||||
*/
|
||||
public interface ICPPMethod extends IFunction, ICPPMember {
|
||||
public interface ICPPMethod extends ICPPFunction, ICPPMember {
|
||||
|
||||
}
|
||||
|
|
|
@ -14,14 +14,13 @@
|
|||
package org.eclipse.cdt.core.dom.ast.cpp;
|
||||
|
||||
import org.eclipse.cdt.core.dom.ast.DOMException;
|
||||
import org.eclipse.cdt.core.dom.ast.IBinding;
|
||||
|
||||
/**
|
||||
* This interface represents a C++ namespace
|
||||
*
|
||||
* @author aniefer
|
||||
*/
|
||||
public interface ICPPNamespace extends IBinding {
|
||||
public interface ICPPNamespace extends ICPPBinding {
|
||||
/**
|
||||
* get the scope object associated with this namespace
|
||||
*
|
||||
|
|
|
@ -0,0 +1,21 @@
|
|||
/*******************************************************************************
|
||||
* Copyright (c) 2005 IBM Corporation and others.
|
||||
* All rights reserved. This program and the accompanying materials
|
||||
* are made available under the terms of the Common Public License v1.0
|
||||
* which accompanies this distribution, and is available at
|
||||
* http://www.eclipse.org/legal/cpl-v10.html
|
||||
*
|
||||
* Contributors:
|
||||
* IBM Corporation - initial API and implementation
|
||||
*******************************************************************************/
|
||||
/*
|
||||
* Created on Mar 17, 2005
|
||||
*/
|
||||
package org.eclipse.cdt.core.dom.ast.cpp;
|
||||
|
||||
/**
|
||||
* @author aniefer
|
||||
*/
|
||||
public interface ICPPNamespaceAlias extends ICPPNamespace, ICPPDelegate {
|
||||
|
||||
}
|
|
@ -26,6 +26,13 @@ import org.eclipse.cdt.core.dom.ast.IScope;
|
|||
*/
|
||||
public interface ICPPScope extends IScope {
|
||||
|
||||
/**
|
||||
* Get the name for this scope, may be null
|
||||
* @return
|
||||
* @throws DOMException
|
||||
*/
|
||||
public IASTName getScopeName() throws DOMException;
|
||||
|
||||
/**
|
||||
* Add an IASTName to be cached in this scope
|
||||
*
|
||||
|
|
|
@ -0,0 +1,35 @@
|
|||
/*******************************************************************************
|
||||
* Copyright (c) 2004 IBM Corporation and others.
|
||||
* All rights reserved. This program and the accompanying materials
|
||||
* are made available under the terms of the Common Public License v1.0
|
||||
* which accompanies this distribution, and is available at
|
||||
* http://www.eclipse.org/legal/cpl-v10.html
|
||||
*
|
||||
* Contributors:
|
||||
* IBM Corporation - initial API and implementation
|
||||
*******************************************************************************/
|
||||
|
||||
/*
|
||||
* Created on Mar 16, 2005
|
||||
*/
|
||||
package org.eclipse.cdt.core.dom.ast.cpp;
|
||||
|
||||
import org.eclipse.cdt.core.dom.ast.DOMException;
|
||||
|
||||
/**
|
||||
* A using declaration introduces a name into the declarative region in which
|
||||
* it appears, that name is a synonym of some entity declared elsewhere
|
||||
*
|
||||
* The using declaration is both a declaration of a new binding and a reference to a
|
||||
* previously declared binding
|
||||
* @author aniefer
|
||||
*/
|
||||
public interface ICPPUsingDeclaration extends ICPPBinding {
|
||||
/**
|
||||
* Return an array of bindings that were declared by this using declaration.
|
||||
* Each of these bindings delegates to some previously declared binding to which it
|
||||
* is a reference.
|
||||
* @return
|
||||
*/
|
||||
ICPPDelegate [] getDelegates() throws DOMException;
|
||||
}
|
|
@ -8,27 +8,17 @@
|
|||
* Contributors:
|
||||
* IBM Corporation - initial API and implementation
|
||||
*******************************************************************************/
|
||||
|
||||
/*
|
||||
* Created on Dec 16, 2004
|
||||
* Created on Mar 15, 2005
|
||||
*/
|
||||
package org.eclipse.cdt.core.dom.ast.cpp;
|
||||
|
||||
import org.eclipse.cdt.core.dom.ast.DOMException;
|
||||
import org.eclipse.cdt.core.dom.ast.IBinding;
|
||||
import org.eclipse.cdt.core.dom.ast.IVariable;
|
||||
|
||||
/**
|
||||
* This binding is a container for other bindings. It is used in instances where
|
||||
* an IASTName refers to more than one binding, for example a using declaration
|
||||
* refering to a set of overloaded functions.
|
||||
*
|
||||
* @author aniefer
|
||||
*/
|
||||
public interface ICPPCompositeBinding extends IBinding {
|
||||
/**
|
||||
* get the bindings
|
||||
*
|
||||
* @return
|
||||
* @throws DOMException
|
||||
*/
|
||||
IBinding[] getBindings() throws DOMException;
|
||||
public interface ICPPVariable extends IVariable, ICPPBinding {
|
||||
|
||||
}
|
|
@ -13,6 +13,10 @@
|
|||
*/
|
||||
package org.eclipse.cdt.internal.core.dom.parser.cpp;
|
||||
|
||||
import org.eclipse.cdt.core.dom.ast.DOMException;
|
||||
import org.eclipse.cdt.core.dom.ast.IASTCompoundStatement;
|
||||
import org.eclipse.cdt.core.dom.ast.IASTFunctionDefinition;
|
||||
import org.eclipse.cdt.core.dom.ast.IASTName;
|
||||
import org.eclipse.cdt.core.dom.ast.IASTNode;
|
||||
import org.eclipse.cdt.core.dom.ast.cpp.ICPPBlockScope;
|
||||
|
||||
|
@ -23,4 +27,12 @@ public class CPPBlockScope extends CPPNamespaceScope implements ICPPBlockScope {
|
|||
public CPPBlockScope( IASTNode physicalNode ){
|
||||
super( physicalNode );
|
||||
}
|
||||
|
||||
public IASTName getScopeName() throws DOMException{
|
||||
IASTNode node = getPhysicalNode();
|
||||
if( node instanceof IASTCompoundStatement && node.getParent() instanceof IASTFunctionDefinition ){
|
||||
return ((IASTFunctionDefinition)node.getParent()).getDeclarator().getName();
|
||||
}
|
||||
return null;
|
||||
}
|
||||
}
|
||||
|
|
|
@ -239,4 +239,15 @@ public class CPPClassScope extends CPPScope implements ICPPClassScope {
|
|||
implicits = new ICPPMethod[] { new CPPMethod.CPPMethodProblem( IProblemBinding.SEMANTIC_INVALID_TYPE, CPPSemantics.EMPTY_NAME_ARRAY ) };
|
||||
return implicits;
|
||||
}
|
||||
|
||||
/* (non-Javadoc)
|
||||
* @see org.eclipse.cdt.core.dom.ast.cpp.ICPPScope#getScopeName()
|
||||
*/
|
||||
public IASTName getScopeName() throws DOMException {
|
||||
IASTNode node = getPhysicalNode();
|
||||
if( node instanceof ICPPASTCompositeTypeSpecifier ){
|
||||
return ((ICPPASTCompositeTypeSpecifier)node).getName();
|
||||
}
|
||||
return null;
|
||||
}
|
||||
}
|
||||
|
|
|
@ -36,14 +36,16 @@ import org.eclipse.cdt.core.dom.ast.cpp.ICPPASTElaboratedTypeSpecifier;
|
|||
import org.eclipse.cdt.core.dom.ast.cpp.ICPPASTQualifiedName;
|
||||
import org.eclipse.cdt.core.dom.ast.cpp.ICPPASTUsingDeclaration;
|
||||
import org.eclipse.cdt.core.dom.ast.cpp.ICPPBase;
|
||||
import org.eclipse.cdt.core.dom.ast.cpp.ICPPBlockScope;
|
||||
import org.eclipse.cdt.core.dom.ast.cpp.ICPPClassScope;
|
||||
import org.eclipse.cdt.core.dom.ast.cpp.ICPPClassType;
|
||||
import org.eclipse.cdt.core.dom.ast.cpp.ICPPCompositeBinding;
|
||||
import org.eclipse.cdt.core.dom.ast.cpp.ICPPConstructor;
|
||||
import org.eclipse.cdt.core.dom.ast.cpp.ICPPDelegate;
|
||||
import org.eclipse.cdt.core.dom.ast.cpp.ICPPField;
|
||||
import org.eclipse.cdt.core.dom.ast.cpp.ICPPFunctionScope;
|
||||
import org.eclipse.cdt.core.dom.ast.cpp.ICPPMethod;
|
||||
import org.eclipse.cdt.core.dom.ast.cpp.ICPPScope;
|
||||
import org.eclipse.cdt.core.dom.ast.cpp.ICPPUsingDeclaration;
|
||||
import org.eclipse.cdt.core.dom.ast.cpp.ICPPASTCompositeTypeSpecifier.ICPPASTBaseSpecifier;
|
||||
import org.eclipse.cdt.core.parser.util.ArrayUtil;
|
||||
import org.eclipse.cdt.core.parser.util.CharArrayUtils;
|
||||
|
@ -53,7 +55,48 @@ import org.eclipse.cdt.internal.core.dom.parser.ProblemBinding;
|
|||
/**
|
||||
* @author aniefer
|
||||
*/
|
||||
public class CPPClassType implements ICPPClassType, ICPPBinding {
|
||||
public class CPPClassType implements ICPPClassType, ICPPInternalBinding {
|
||||
public static class CPPClassTypeDelegate extends CPPDelegate implements ICPPClassType {
|
||||
public CPPClassTypeDelegate( IASTName name, ICPPClassType cls ){
|
||||
super( name, cls );
|
||||
}
|
||||
public ICPPBase[] getBases() throws DOMException {
|
||||
return ((ICPPClassType)getBinding()).getBases();
|
||||
}
|
||||
public IField[] getFields() throws DOMException {
|
||||
return ((ICPPClassType)getBinding()).getFields();
|
||||
}
|
||||
public IField findField( String name ) throws DOMException {
|
||||
return ((ICPPClassType)getBinding()).findField( name );
|
||||
}
|
||||
public ICPPField[] getDeclaredFields() throws DOMException {
|
||||
return ((ICPPClassType)getBinding()).getDeclaredFields();
|
||||
}
|
||||
public ICPPMethod[] getMethods() throws DOMException {
|
||||
return ((ICPPClassType)getBinding()).getMethods();
|
||||
}
|
||||
public ICPPMethod[] getAllDeclaredMethods() throws DOMException {
|
||||
return ((ICPPClassType)getBinding()).getAllDeclaredMethods();
|
||||
}
|
||||
public ICPPMethod[] getDeclaredMethods() throws DOMException {
|
||||
return ((ICPPClassType)getBinding()).getDeclaredMethods();
|
||||
}
|
||||
public ICPPConstructor[] getConstructors() throws DOMException {
|
||||
return ((ICPPClassType)getBinding()).getConstructors();
|
||||
}
|
||||
public IBinding[] getFriends() throws DOMException {
|
||||
return ((ICPPClassType)getBinding()).getFriends();
|
||||
}
|
||||
public int getKey() throws DOMException {
|
||||
return ((ICPPClassType)getBinding()).getKey();
|
||||
}
|
||||
public IScope getCompositeScope() throws DOMException {
|
||||
return ((ICPPClassType)getBinding()).getCompositeScope();
|
||||
}
|
||||
public Object clone() {
|
||||
return ((ICPPClassType)getBinding()).clone();
|
||||
}
|
||||
}
|
||||
public static class CPPClassTypeProblem extends ProblemBinding implements ICPPClassType{
|
||||
public CPPClassTypeProblem( int id, char[] arg ) {
|
||||
super( id, arg );
|
||||
|
@ -98,6 +141,15 @@ public class CPPClassType implements ICPPClassType, ICPPBinding {
|
|||
public IBinding[] getFriends() throws DOMException {
|
||||
throw new DOMException( this );
|
||||
}
|
||||
public String[] getQualifiedName() throws DOMException {
|
||||
throw new DOMException( this );
|
||||
}
|
||||
public char[][] getQualifiedNameCharArray() throws DOMException {
|
||||
throw new DOMException( this );
|
||||
}
|
||||
public boolean isGloballyQualified() throws DOMException {
|
||||
throw new DOMException( this );
|
||||
}
|
||||
}
|
||||
|
||||
private IASTName definition;
|
||||
|
@ -357,8 +409,8 @@ public class CPPClassType implements ICPPClassType, ICPPBinding {
|
|||
} else if( decls[i] instanceof ICPPASTUsingDeclaration ){
|
||||
IASTName n = ((ICPPASTUsingDeclaration)decls[i]).getName();
|
||||
binding = n.resolveBinding();
|
||||
if( binding instanceof ICPPCompositeBinding ){
|
||||
IBinding [] bs = ((ICPPCompositeBinding)binding).getBindings();
|
||||
if( binding instanceof ICPPUsingDeclaration ){
|
||||
IBinding [] bs = ((ICPPUsingDeclaration)binding).getDelegates();
|
||||
for ( int j = 0; j < bs.length; j++ ) {
|
||||
if( bs[j] instanceof ICPPField )
|
||||
result = (ICPPField[]) ArrayUtil.append( ICPPField.class, result, bs[j] );
|
||||
|
@ -437,8 +489,8 @@ public class CPPClassType implements ICPPClassType, ICPPBinding {
|
|||
} else if( decls[i] instanceof ICPPASTUsingDeclaration ){
|
||||
IASTName n = ((ICPPASTUsingDeclaration)decls[i]).getName();
|
||||
binding = n.resolveBinding();
|
||||
if( binding instanceof ICPPCompositeBinding ){
|
||||
IBinding [] bs = ((ICPPCompositeBinding)binding).getBindings();
|
||||
if( binding instanceof ICPPUsingDeclaration ){
|
||||
IBinding [] bs = ((ICPPUsingDeclaration)binding).getDelegates();
|
||||
for ( int j = 0; j < bs.length; j++ ) {
|
||||
if( bs[j] instanceof ICPPMethod )
|
||||
result = (ICPPMethod[]) ArrayUtil.append( ICPPMethod.class, result, bs[j] );
|
||||
|
@ -531,4 +583,38 @@ public class CPPClassType implements ICPPClassType, ICPPBinding {
|
|||
|
||||
return (IBinding[]) ArrayUtil.trim( IBinding.class, resultSet.keyArray(), true );
|
||||
}
|
||||
|
||||
/* (non-Javadoc)
|
||||
* @see org.eclipse.cdt.core.dom.ast.cpp.ICPPBinding#getQualifiedName()
|
||||
*/
|
||||
public String[] getQualifiedName() {
|
||||
return CPPVisitor.getQualifiedName( this );
|
||||
}
|
||||
|
||||
/* (non-Javadoc)
|
||||
* @see org.eclipse.cdt.core.dom.ast.cpp.ICPPBinding#getQualifiedNameCharArray()
|
||||
*/
|
||||
public char[][] getQualifiedNameCharArray() {
|
||||
return CPPVisitor.getQualifiedNameCharArray( this );
|
||||
}
|
||||
|
||||
/* (non-Javadoc)
|
||||
* @see org.eclipse.cdt.core.dom.ast.cpp.ICPPBinding#isGloballyQualified()
|
||||
*/
|
||||
public boolean isGloballyQualified() throws DOMException {
|
||||
IScope scope = getScope();
|
||||
while( scope != null ){
|
||||
if( scope instanceof ICPPBlockScope )
|
||||
return false;
|
||||
scope = scope.getParent();
|
||||
}
|
||||
return true;
|
||||
}
|
||||
|
||||
/* (non-Javadoc)
|
||||
* @see org.eclipse.cdt.internal.core.dom.parser.cpp.ICPPInternalBinding#createDelegate(org.eclipse.cdt.core.dom.ast.IASTName)
|
||||
*/
|
||||
public ICPPDelegate createDelegate( IASTName name ) {
|
||||
return new CPPClassTypeDelegate( name, this );
|
||||
}
|
||||
}
|
||||
|
|
|
@ -17,13 +17,12 @@ import org.eclipse.cdt.core.dom.ast.DOMException;
|
|||
import org.eclipse.cdt.core.dom.ast.IASTNode;
|
||||
import org.eclipse.cdt.core.dom.ast.IBinding;
|
||||
import org.eclipse.cdt.core.dom.ast.IScope;
|
||||
import org.eclipse.cdt.core.dom.ast.cpp.ICPPCompositeBinding;
|
||||
import org.eclipse.cdt.core.parser.util.ArrayUtil;
|
||||
|
||||
/**
|
||||
* @author aniefer
|
||||
*/
|
||||
public class CPPCompositeBinding implements ICPPCompositeBinding {
|
||||
public class CPPCompositeBinding implements IBinding {
|
||||
|
||||
IBinding [] bindings = null;
|
||||
|
||||
|
|
|
@ -0,0 +1,137 @@
|
|||
/*******************************************************************************
|
||||
* Copyright (c) 2004 IBM Corporation and others.
|
||||
* All rights reserved. This program and the accompanying materials
|
||||
* are made available under the terms of the Common Public License v1.0
|
||||
* which accompanies this distribution, and is available at
|
||||
* http://www.eclipse.org/legal/cpl-v10.html
|
||||
*
|
||||
* Contributors:
|
||||
* IBM Corporation - initial API and implementation
|
||||
*******************************************************************************/
|
||||
|
||||
/*
|
||||
* Created on Mar 17, 2005
|
||||
*/
|
||||
package org.eclipse.cdt.internal.core.dom.parser.cpp;
|
||||
|
||||
import org.eclipse.cdt.core.dom.ast.DOMException;
|
||||
import org.eclipse.cdt.core.dom.ast.IASTName;
|
||||
import org.eclipse.cdt.core.dom.ast.IASTNode;
|
||||
import org.eclipse.cdt.core.dom.ast.IBinding;
|
||||
import org.eclipse.cdt.core.dom.ast.IScope;
|
||||
import org.eclipse.cdt.core.dom.ast.cpp.ICPPBlockScope;
|
||||
import org.eclipse.cdt.core.dom.ast.cpp.ICPPDelegate;
|
||||
|
||||
/**
|
||||
* @author aniefer
|
||||
*/
|
||||
public class CPPDelegate implements ICPPDelegate, ICPPInternalBinding {
|
||||
private IBinding binding = null;
|
||||
private int type = 0;
|
||||
private IASTName name = null;
|
||||
|
||||
/**
|
||||
*
|
||||
*/
|
||||
public CPPDelegate( IASTName name, IBinding binding ) {
|
||||
this.binding = binding;
|
||||
this.name = name;
|
||||
}
|
||||
|
||||
/* (non-Javadoc)
|
||||
* @see org.eclipse.cdt.core.dom.ast.cpp.ICPPDelegate#getDelegateType()
|
||||
*/
|
||||
public int getDelegateType() {
|
||||
return type;
|
||||
}
|
||||
|
||||
/* (non-Javadoc)
|
||||
* @see org.eclipse.cdt.core.dom.ast.cpp.ICPPDelegate#getBinding()
|
||||
*/
|
||||
public IBinding getBinding() {
|
||||
return binding;
|
||||
}
|
||||
|
||||
/* (non-Javadoc)
|
||||
* @see org.eclipse.cdt.core.dom.ast.cpp.ICPPBinding#getQualifiedName()
|
||||
*/
|
||||
public String[] getQualifiedName() {
|
||||
return CPPVisitor.getQualifiedName( this );
|
||||
}
|
||||
|
||||
/* (non-Javadoc)
|
||||
* @see org.eclipse.cdt.core.dom.ast.cpp.ICPPBinding#getQualifiedNameCharArray()
|
||||
*/
|
||||
public char[][] getQualifiedNameCharArray() {
|
||||
return CPPVisitor.getQualifiedNameCharArray( this );
|
||||
}
|
||||
|
||||
/* (non-Javadoc)
|
||||
* @see org.eclipse.cdt.core.dom.ast.cpp.ICPPBinding#isGloballyQualified()
|
||||
*/
|
||||
public boolean isGloballyQualified() throws DOMException {
|
||||
IScope scope = getScope();
|
||||
while( scope != null ){
|
||||
if( scope instanceof ICPPBlockScope )
|
||||
return false;
|
||||
scope = scope.getParent();
|
||||
}
|
||||
return true;
|
||||
}
|
||||
|
||||
/* (non-Javadoc)
|
||||
* @see org.eclipse.cdt.core.dom.ast.IBinding#getName()
|
||||
*/
|
||||
public String getName() {
|
||||
return name.toString();
|
||||
}
|
||||
|
||||
/* (non-Javadoc)
|
||||
* @see org.eclipse.cdt.core.dom.ast.IBinding#getNameCharArray()
|
||||
*/
|
||||
public char[] getNameCharArray() {
|
||||
return name.toCharArray();
|
||||
}
|
||||
|
||||
/* (non-Javadoc)
|
||||
* @see org.eclipse.cdt.core.dom.ast.IBinding#getScope()
|
||||
*/
|
||||
public IScope getScope() {
|
||||
return CPPVisitor.getContainingScope( name.getParent() );
|
||||
}
|
||||
|
||||
/* (non-Javadoc)
|
||||
* @see org.eclipse.cdt.internal.core.dom.parser.cpp.ICPPInternalBinding#getDeclarations()
|
||||
*/
|
||||
public IASTNode[] getDeclarations() {
|
||||
return null;
|
||||
}
|
||||
|
||||
/* (non-Javadoc)
|
||||
* @see org.eclipse.cdt.internal.core.dom.parser.cpp.ICPPInternalBinding#getDefinition()
|
||||
*/
|
||||
public IASTNode getDefinition() {
|
||||
if( binding instanceof ICPPInternalBinding )
|
||||
return ((ICPPInternalBinding)binding).getDefinition();
|
||||
return name;
|
||||
}
|
||||
|
||||
public void setName( IASTName name ){
|
||||
this.name = name;
|
||||
}
|
||||
|
||||
/* (non-Javadoc)
|
||||
* @see org.eclipse.cdt.internal.core.dom.parser.cpp.ICPPInternalBinding#createDelegate(org.eclipse.cdt.core.dom.ast.IASTName)
|
||||
*/
|
||||
public ICPPDelegate createDelegate( IASTName n ) {
|
||||
CPPDelegate delegate = null;
|
||||
try {
|
||||
delegate = (CPPDelegate) clone();
|
||||
} catch ( CloneNotSupportedException e ) {
|
||||
}
|
||||
|
||||
delegate.setName( n );
|
||||
return delegate;
|
||||
}
|
||||
|
||||
}
|
|
@ -14,6 +14,7 @@
|
|||
*/
|
||||
package org.eclipse.cdt.internal.core.dom.parser.cpp;
|
||||
|
||||
import org.eclipse.cdt.core.dom.ast.DOMException;
|
||||
import org.eclipse.cdt.core.dom.ast.IASTEnumerationSpecifier;
|
||||
import org.eclipse.cdt.core.dom.ast.IASTName;
|
||||
import org.eclipse.cdt.core.dom.ast.IASTNode;
|
||||
|
@ -21,11 +22,26 @@ import org.eclipse.cdt.core.dom.ast.IEnumeration;
|
|||
import org.eclipse.cdt.core.dom.ast.IEnumerator;
|
||||
import org.eclipse.cdt.core.dom.ast.IScope;
|
||||
import org.eclipse.cdt.core.dom.ast.IType;
|
||||
import org.eclipse.cdt.core.dom.ast.cpp.ICPPBinding;
|
||||
import org.eclipse.cdt.core.dom.ast.cpp.ICPPBlockScope;
|
||||
import org.eclipse.cdt.core.dom.ast.cpp.ICPPDelegate;
|
||||
|
||||
/**
|
||||
* @author aniefer
|
||||
*/
|
||||
public class CPPEnumeration implements IEnumeration, ICPPBinding {
|
||||
public class CPPEnumeration implements IEnumeration, ICPPInternalBinding, ICPPBinding {
|
||||
public static class CPPEnumerationDelegate extends CPPDelegate implements IEnumeration {
|
||||
public CPPEnumerationDelegate( IASTName name, IEnumeration binding ) {
|
||||
super( name, binding );
|
||||
}
|
||||
public IEnumerator[] getEnumerators() throws DOMException {
|
||||
return ((IEnumeration)getBinding()).getEnumerators();
|
||||
}
|
||||
public Object clone() {
|
||||
return ((IEnumeration)getBinding()).clone();
|
||||
}
|
||||
|
||||
}
|
||||
private IASTName enumName;
|
||||
/**
|
||||
* @param specifier
|
||||
|
@ -100,4 +116,37 @@ public class CPPEnumeration implements IEnumeration, ICPPBinding {
|
|||
return bindings;
|
||||
}
|
||||
|
||||
/* (non-Javadoc)
|
||||
* @see org.eclipse.cdt.core.dom.ast.IBinding#getFullyQualifiedName()
|
||||
*/
|
||||
public String[] getQualifiedName() {
|
||||
return CPPVisitor.getQualifiedName( this );
|
||||
}
|
||||
|
||||
/* (non-Javadoc)
|
||||
* @see org.eclipse.cdt.core.dom.ast.IBinding#getFullyQualifiedNameCharArray()
|
||||
*/
|
||||
public char[][] getQualifiedNameCharArray() {
|
||||
return CPPVisitor.getQualifiedNameCharArray( this );
|
||||
}
|
||||
|
||||
/* (non-Javadoc)
|
||||
* @see org.eclipse.cdt.core.dom.ast.cpp.ICPPBinding#isGloballyQualified()
|
||||
*/
|
||||
public boolean isGloballyQualified() throws DOMException {
|
||||
IScope scope = getScope();
|
||||
while( scope != null ){
|
||||
if( scope instanceof ICPPBlockScope )
|
||||
return false;
|
||||
scope = scope.getParent();
|
||||
}
|
||||
return true;
|
||||
}
|
||||
|
||||
/* (non-Javadoc)
|
||||
* @see org.eclipse.cdt.internal.core.dom.parser.cpp.ICPPInternalBinding#createDelegate(org.eclipse.cdt.core.dom.ast.IASTName)
|
||||
*/
|
||||
public ICPPDelegate createDelegate( IASTName name ) {
|
||||
return new CPPEnumerationDelegate( name, this );
|
||||
}
|
||||
}
|
||||
|
|
|
@ -14,6 +14,7 @@
|
|||
*/
|
||||
package org.eclipse.cdt.internal.core.dom.parser.cpp;
|
||||
|
||||
import org.eclipse.cdt.core.dom.ast.DOMException;
|
||||
import org.eclipse.cdt.core.dom.ast.IASTEnumerationSpecifier;
|
||||
import org.eclipse.cdt.core.dom.ast.IASTName;
|
||||
import org.eclipse.cdt.core.dom.ast.IASTNode;
|
||||
|
@ -22,11 +23,23 @@ import org.eclipse.cdt.core.dom.ast.IEnumerator;
|
|||
import org.eclipse.cdt.core.dom.ast.IScope;
|
||||
import org.eclipse.cdt.core.dom.ast.IType;
|
||||
import org.eclipse.cdt.core.dom.ast.IASTEnumerationSpecifier.IASTEnumerator;
|
||||
import org.eclipse.cdt.core.dom.ast.cpp.ICPPBinding;
|
||||
import org.eclipse.cdt.core.dom.ast.cpp.ICPPBlockScope;
|
||||
import org.eclipse.cdt.core.dom.ast.cpp.ICPPDelegate;
|
||||
|
||||
/**
|
||||
* @author aniefer
|
||||
*/
|
||||
public class CPPEnumerator implements IEnumerator, ICPPBinding {
|
||||
public class CPPEnumerator implements IEnumerator, ICPPInternalBinding, ICPPBinding {
|
||||
public static class CPPEnumeratorDelegate extends CPPDelegate implements IEnumerator {
|
||||
public CPPEnumeratorDelegate( IASTName name, IEnumerator binding ) {
|
||||
super( name, binding );
|
||||
}
|
||||
public IType getType() throws DOMException {
|
||||
return ((IEnumerator)getBinding()).getType();
|
||||
}
|
||||
}
|
||||
|
||||
private IASTName enumName;
|
||||
/**
|
||||
* @param enumerator
|
||||
|
@ -87,4 +100,39 @@ public class CPPEnumerator implements IEnumerator, ICPPBinding {
|
|||
IEnumeration enumeration = (IEnumeration) enumSpec.getName().resolveBinding();
|
||||
return enumeration;
|
||||
}
|
||||
|
||||
/* (non-Javadoc)
|
||||
* @see org.eclipse.cdt.core.dom.ast.IBinding#getFullyQualifiedName()
|
||||
*/
|
||||
public String[] getQualifiedName() {
|
||||
return CPPVisitor.getQualifiedName( this );
|
||||
}
|
||||
|
||||
/* (non-Javadoc)
|
||||
* @see org.eclipse.cdt.core.dom.ast.IBinding#getFullyQualifiedNameCharArray()
|
||||
*/
|
||||
public char[][] getQualifiedNameCharArray() {
|
||||
return CPPVisitor.getQualifiedNameCharArray( this );
|
||||
}
|
||||
|
||||
/* (non-Javadoc)
|
||||
* @see org.eclipse.cdt.core.dom.ast.cpp.ICPPBinding#isGloballyQualified()
|
||||
*/
|
||||
public boolean isGloballyQualified() throws DOMException {
|
||||
IScope scope = getScope();
|
||||
while( scope != null ){
|
||||
if( scope instanceof ICPPBlockScope )
|
||||
return false;
|
||||
scope = scope.getParent();
|
||||
}
|
||||
return true;
|
||||
}
|
||||
|
||||
/* (non-Javadoc)
|
||||
* @see org.eclipse.cdt.internal.core.dom.parser.cpp.ICPPInternalBinding#createDelegate(org.eclipse.cdt.core.dom.ast.IASTName)
|
||||
*/
|
||||
public ICPPDelegate createDelegate( IASTName name ) {
|
||||
return new CPPEnumeratorDelegate( name, this );
|
||||
}
|
||||
|
||||
}
|
||||
|
|
|
@ -15,12 +15,21 @@ package org.eclipse.cdt.internal.core.dom.parser.cpp;
|
|||
|
||||
import org.eclipse.cdt.core.dom.ast.DOMException;
|
||||
import org.eclipse.cdt.core.dom.ast.IASTName;
|
||||
import org.eclipse.cdt.core.dom.ast.cpp.ICPPDelegate;
|
||||
import org.eclipse.cdt.core.dom.ast.cpp.ICPPField;
|
||||
|
||||
/**
|
||||
* @author aniefer
|
||||
*/
|
||||
public class CPPField extends CPPVariable implements ICPPField, ICPPBinding {
|
||||
public class CPPField extends CPPVariable implements ICPPField, ICPPInternalBinding {
|
||||
public static class CPPFieldDelegate extends CPPVariable.CPPVariableDelegate implements ICPPField {
|
||||
public CPPFieldDelegate( IASTName name, ICPPField binding ) {
|
||||
super( name, binding );
|
||||
}
|
||||
public int getVisibility() throws DOMException {
|
||||
return ((ICPPField)getBinding()).getVisibility();
|
||||
}
|
||||
}
|
||||
public static class CPPFieldProblem extends CPPVariable.CPPVariableProblem implements ICPPField {
|
||||
/**
|
||||
* @param id
|
||||
|
@ -49,4 +58,11 @@ public class CPPField extends CPPVariable implements ICPPField, ICPPBinding {
|
|||
// TODO Auto-generated method stub
|
||||
return 0;
|
||||
}
|
||||
|
||||
/* (non-Javadoc)
|
||||
* @see org.eclipse.cdt.internal.core.dom.parser.cpp.ICPPInternalBinding#createDelegate(org.eclipse.cdt.core.dom.ast.IASTName)
|
||||
*/
|
||||
public ICPPDelegate createDelegate( IASTName name ) {
|
||||
return new CPPFieldDelegate( name, this );
|
||||
}
|
||||
}
|
||||
|
|
|
@ -25,23 +25,43 @@ import org.eclipse.cdt.core.dom.ast.IASTSimpleDeclaration;
|
|||
import org.eclipse.cdt.core.dom.ast.IASTStandardFunctionDeclarator;
|
||||
import org.eclipse.cdt.core.dom.ast.IASTTranslationUnit;
|
||||
import org.eclipse.cdt.core.dom.ast.IBinding;
|
||||
import org.eclipse.cdt.core.dom.ast.IFunction;
|
||||
import org.eclipse.cdt.core.dom.ast.IFunctionType;
|
||||
import org.eclipse.cdt.core.dom.ast.IParameter;
|
||||
import org.eclipse.cdt.core.dom.ast.IScope;
|
||||
import org.eclipse.cdt.core.dom.ast.cpp.ICPPASTDeclSpecifier;
|
||||
import org.eclipse.cdt.core.dom.ast.cpp.ICPPASTFunctionDeclarator;
|
||||
import org.eclipse.cdt.core.dom.ast.cpp.ICPPASTQualifiedName;
|
||||
import org.eclipse.cdt.core.dom.ast.cpp.ICPPBlockScope;
|
||||
import org.eclipse.cdt.core.dom.ast.cpp.ICPPClassScope;
|
||||
import org.eclipse.cdt.core.dom.ast.cpp.ICPPDelegate;
|
||||
import org.eclipse.cdt.core.dom.ast.cpp.ICPPFunction;
|
||||
import org.eclipse.cdt.core.parser.util.ArrayUtil;
|
||||
import org.eclipse.cdt.internal.core.dom.parser.ProblemBinding;
|
||||
|
||||
/**
|
||||
* @author aniefer
|
||||
*/
|
||||
public class CPPFunction implements IFunction, ICPPBinding {
|
||||
public class CPPFunction implements ICPPFunction, ICPPInternalBinding {
|
||||
|
||||
public static class CPPFunctionProblem extends ProblemBinding implements IFunction {
|
||||
public static class CPPFunctionDelegate extends CPPDelegate implements ICPPFunction {
|
||||
public CPPFunctionDelegate( IASTName name, ICPPFunction binding ) {
|
||||
super( name, binding );
|
||||
}
|
||||
|
||||
public IParameter[] getParameters() throws DOMException {
|
||||
return ((ICPPFunction)getBinding()).getParameters();
|
||||
}
|
||||
public IScope getFunctionScope() throws DOMException {
|
||||
return ((ICPPFunction)getBinding()).getFunctionScope();
|
||||
}
|
||||
public IFunctionType getType() throws DOMException {
|
||||
return ((ICPPFunction)getBinding()).getType();
|
||||
}
|
||||
public boolean isStatic() throws DOMException {
|
||||
return ((ICPPFunction)getBinding()).isStatic();
|
||||
}
|
||||
}
|
||||
public static class CPPFunctionProblem extends ProblemBinding implements ICPPFunction {
|
||||
public CPPFunctionProblem( int id, char[] arg ) {
|
||||
super( id, arg );
|
||||
}
|
||||
|
@ -61,6 +81,15 @@ public class CPPFunction implements IFunction, ICPPBinding {
|
|||
public boolean isStatic() throws DOMException {
|
||||
throw new DOMException( this );
|
||||
}
|
||||
public String[] getQualifiedName() throws DOMException {
|
||||
throw new DOMException( this );
|
||||
}
|
||||
public char[][] getQualifiedNameCharArray() throws DOMException {
|
||||
throw new DOMException( this );
|
||||
}
|
||||
public boolean isGloballyQualified() throws DOMException {
|
||||
throw new DOMException( this );
|
||||
}
|
||||
}
|
||||
|
||||
protected ICPPASTFunctionDeclarator [] declarations;
|
||||
|
@ -214,29 +243,35 @@ public class CPPFunction implements IFunction, ICPPBinding {
|
|||
* @see org.eclipse.cdt.core.dom.ast.IBinding#getScope()
|
||||
*/
|
||||
public IScope getScope() {
|
||||
ICPPASTDeclSpecifier declSpec = null;
|
||||
if( definition != null ){
|
||||
IASTNode node = definition.getParent();
|
||||
while( node instanceof IASTDeclarator )
|
||||
node = node.getParent();
|
||||
IASTFunctionDefinition def = (IASTFunctionDefinition) node;
|
||||
declSpec = (ICPPASTDeclSpecifier) def.getDeclSpecifier();
|
||||
} else {
|
||||
IASTNode node = declarations[0].getParent();
|
||||
while( node instanceof IASTDeclarator )
|
||||
node = node.getParent();
|
||||
IASTSimpleDeclaration decl = (IASTSimpleDeclaration)node;
|
||||
declSpec = (ICPPASTDeclSpecifier) decl.getDeclSpecifier();
|
||||
}
|
||||
|
||||
IScope scope = CPPVisitor.getContainingScope( definition != null ? definition : declarations[0] );
|
||||
if( declSpec.isFriend() && scope instanceof ICPPClassScope ){
|
||||
try {
|
||||
while( scope instanceof ICPPClassScope ){
|
||||
scope = scope.getParent();
|
||||
}
|
||||
} catch ( DOMException e ) {
|
||||
}
|
||||
IASTName n = definition != null ? definition.getName() : declarations[0].getName();
|
||||
if( n instanceof ICPPASTQualifiedName ){
|
||||
IASTName [] ns = ((ICPPASTQualifiedName)n).getNames();
|
||||
n = ns[ ns.length - 1 ];
|
||||
}
|
||||
IScope scope = CPPVisitor.getContainingScope( n );
|
||||
if( scope instanceof ICPPClassScope ){
|
||||
ICPPASTDeclSpecifier declSpec = null;
|
||||
if( definition != null ){
|
||||
IASTNode node = definition.getParent();
|
||||
while( node instanceof IASTDeclarator )
|
||||
node = node.getParent();
|
||||
IASTFunctionDefinition def = (IASTFunctionDefinition) node;
|
||||
declSpec = (ICPPASTDeclSpecifier) def.getDeclSpecifier();
|
||||
} else {
|
||||
IASTNode node = declarations[0].getParent();
|
||||
while( node instanceof IASTDeclarator )
|
||||
node = node.getParent();
|
||||
IASTSimpleDeclaration decl = (IASTSimpleDeclaration)node;
|
||||
declSpec = (ICPPASTDeclSpecifier) decl.getDeclSpecifier();
|
||||
}
|
||||
if( declSpec.isFriend() ) {
|
||||
try {
|
||||
while( scope instanceof ICPPClassScope ){
|
||||
scope = scope.getParent();
|
||||
}
|
||||
} catch ( DOMException e ) {
|
||||
}
|
||||
}
|
||||
}
|
||||
return scope;
|
||||
}
|
||||
|
@ -337,4 +372,39 @@ public class CPPFunction implements IFunction, ICPPBinding {
|
|||
bits |= 2 << 2;
|
||||
return false;
|
||||
}
|
||||
|
||||
/* (non-Javadoc)
|
||||
* @see org.eclipse.cdt.core.dom.ast.IBinding#getFullyQualifiedName()
|
||||
*/
|
||||
public String[] getQualifiedName() {
|
||||
return CPPVisitor.getQualifiedName( this );
|
||||
}
|
||||
|
||||
/* (non-Javadoc)
|
||||
* @see org.eclipse.cdt.core.dom.ast.IBinding#getFullyQualifiedNameCharArray()
|
||||
*/
|
||||
public char[][] getQualifiedNameCharArray() {
|
||||
return CPPVisitor.getQualifiedNameCharArray( this );
|
||||
}
|
||||
|
||||
/* (non-Javadoc)
|
||||
* @see org.eclipse.cdt.core.dom.ast.cpp.ICPPBinding#isGloballyQualified()
|
||||
*/
|
||||
public boolean isGloballyQualified() throws DOMException {
|
||||
IScope scope = getScope();
|
||||
while( scope != null ){
|
||||
if( scope instanceof ICPPBlockScope )
|
||||
return false;
|
||||
scope = scope.getParent();
|
||||
}
|
||||
return true;
|
||||
}
|
||||
|
||||
/* (non-Javadoc)
|
||||
* @see org.eclipse.cdt.internal.core.dom.parser.cpp.ICPPInternalBinding#createDelegate(org.eclipse.cdt.core.dom.ast.IASTName)
|
||||
*/
|
||||
public ICPPDelegate createDelegate( IASTName name ) {
|
||||
return new CPPFunctionDelegate( name, this );
|
||||
}
|
||||
|
||||
}
|
||||
|
|
|
@ -23,6 +23,7 @@ import org.eclipse.cdt.core.dom.ast.IASTStatement;
|
|||
import org.eclipse.cdt.core.dom.ast.IBinding;
|
||||
import org.eclipse.cdt.core.dom.ast.ILabel;
|
||||
import org.eclipse.cdt.core.dom.ast.IScope;
|
||||
import org.eclipse.cdt.core.dom.ast.cpp.ICPPASTFunctionDeclarator;
|
||||
import org.eclipse.cdt.core.dom.ast.cpp.ICPPASTQualifiedName;
|
||||
import org.eclipse.cdt.core.dom.ast.cpp.ICPPClassType;
|
||||
import org.eclipse.cdt.core.dom.ast.cpp.ICPPFunctionScope;
|
||||
|
@ -111,4 +112,15 @@ public class CPPFunctionScope extends CPPScope implements ICPPFunctionScope {
|
|||
return null;
|
||||
}
|
||||
|
||||
|
||||
/* (non-Javadoc)
|
||||
* @see org.eclipse.cdt.core.dom.ast.cpp.ICPPScope#getScopeName()
|
||||
*/
|
||||
public IASTName getScopeName() throws DOMException {
|
||||
IASTNode node = getPhysicalNode();
|
||||
if( node instanceof ICPPASTFunctionDeclarator ){
|
||||
return ((ICPPASTFunctionDeclarator)node).getName();
|
||||
}
|
||||
return null;
|
||||
}
|
||||
}
|
||||
|
|
|
@ -19,11 +19,13 @@ import org.eclipse.cdt.core.dom.ast.IASTName;
|
|||
import org.eclipse.cdt.core.dom.ast.IASTNode;
|
||||
import org.eclipse.cdt.core.dom.ast.ILabel;
|
||||
import org.eclipse.cdt.core.dom.ast.IScope;
|
||||
import org.eclipse.cdt.core.dom.ast.cpp.ICPPBinding;
|
||||
import org.eclipse.cdt.core.dom.ast.cpp.ICPPDelegate;
|
||||
|
||||
/**
|
||||
* @author aniefer
|
||||
*/
|
||||
public class CPPLabel implements ILabel, ICPPBinding {
|
||||
public class CPPLabel implements ILabel, ICPPInternalBinding, ICPPBinding {
|
||||
private IASTName statement;
|
||||
/**
|
||||
* @param gotoStatement
|
||||
|
@ -93,4 +95,34 @@ public class CPPLabel implements ILabel, ICPPBinding {
|
|||
statement = labelStatement;
|
||||
}
|
||||
|
||||
/* (non-Javadoc)
|
||||
* @see org.eclipse.cdt.core.dom.ast.IBinding#getFullyQualifiedName()
|
||||
*/
|
||||
public String[] getQualifiedName() {
|
||||
return new String[] { getName() };
|
||||
}
|
||||
|
||||
/* (non-Javadoc)
|
||||
* @see org.eclipse.cdt.core.dom.ast.IBinding#getFullyQualifiedNameCharArray()
|
||||
*/
|
||||
public char[][] getQualifiedNameCharArray() {
|
||||
return new char [] [] { getNameCharArray() };
|
||||
}
|
||||
|
||||
/* (non-Javadoc)
|
||||
* @see org.eclipse.cdt.core.dom.ast.cpp.ICPPBinding#isGloballyQualified()
|
||||
*/
|
||||
public boolean isGloballyQualified() {
|
||||
return false;
|
||||
}
|
||||
|
||||
/* (non-Javadoc)
|
||||
* @see org.eclipse.cdt.internal.core.dom.parser.cpp.ICPPInternalBinding#createDelegate(org.eclipse.cdt.core.dom.ast.IASTName)
|
||||
*/
|
||||
public ICPPDelegate createDelegate( IASTName name ) {
|
||||
// TODO Auto-generated method stub
|
||||
return null;
|
||||
}
|
||||
|
||||
|
||||
}
|
||||
|
|
|
@ -26,6 +26,7 @@ import org.eclipse.cdt.core.dom.ast.cpp.ICPPASTFunctionDeclarator;
|
|||
import org.eclipse.cdt.core.dom.ast.cpp.ICPPASTQualifiedName;
|
||||
import org.eclipse.cdt.core.dom.ast.cpp.ICPPASTVisiblityLabel;
|
||||
import org.eclipse.cdt.core.dom.ast.cpp.ICPPClassScope;
|
||||
import org.eclipse.cdt.core.dom.ast.cpp.ICPPDelegate;
|
||||
import org.eclipse.cdt.core.dom.ast.cpp.ICPPMethod;
|
||||
import org.eclipse.cdt.core.parser.util.CharArrayUtils;
|
||||
|
||||
|
@ -33,7 +34,15 @@ import org.eclipse.cdt.core.parser.util.CharArrayUtils;
|
|||
* @author aniefer
|
||||
*/
|
||||
public class CPPMethod extends CPPFunction implements ICPPMethod {
|
||||
|
||||
public static class CPPMethodDelegate extends CPPFunction.CPPFunctionDelegate implements ICPPMethod {
|
||||
public CPPMethodDelegate( IASTName name, ICPPMethod binding ) {
|
||||
super( name, binding );
|
||||
}
|
||||
public int getVisibility() throws DOMException {
|
||||
return ((ICPPMethod)getBinding()).getVisibility();
|
||||
}
|
||||
}
|
||||
|
||||
public static class CPPMethodProblem extends CPPFunctionProblem implements ICPPMethod {
|
||||
/**
|
||||
* @param id
|
||||
|
@ -145,24 +154,11 @@ public class CPPMethod extends CPPFunction implements ICPPMethod {
|
|||
return declarations[0].getName().toCharArray();
|
||||
}
|
||||
|
||||
// /* (non-Javadoc)
|
||||
// * @see org.eclipse.cdt.core.dom.ast.cpp.ICPPMember#isStatic()
|
||||
// */
|
||||
// public boolean isStatic() throws DOMException {
|
||||
// IASTDeclarator dtor = (IASTDeclarator) getPrimaryDeclaration();
|
||||
// if( dtor == null ) return false;
|
||||
//
|
||||
// while( dtor.getPropertyInParent() == IASTDeclarator.NESTED_DECLARATOR )
|
||||
// dtor = (IASTDeclarator) dtor.getParent();
|
||||
//
|
||||
// IASTNode node = dtor.getParent();
|
||||
// if( node instanceof IASTSimpleDeclaration ){
|
||||
// ICPPASTDeclSpecifier declSpec = (ICPPASTDeclSpecifier) ((IASTSimpleDeclaration)node).getDeclSpecifier();
|
||||
// return (declSpec.getStorageClass() == IASTDeclSpecifier.sc_static );
|
||||
// } else if( node instanceof IASTFunctionDefinition ){
|
||||
// ICPPASTDeclSpecifier declSpec = (ICPPASTDeclSpecifier) ((IASTFunctionDefinition)node).getDeclSpecifier();
|
||||
// return (declSpec.getStorageClass() == IASTDeclSpecifier.sc_static );
|
||||
// }
|
||||
// return false;
|
||||
// }
|
||||
/* (non-Javadoc)
|
||||
* @see org.eclipse.cdt.internal.core.dom.parser.cpp.ICPPInternalBinding#createDelegate(org.eclipse.cdt.core.dom.ast.IASTName)
|
||||
*/
|
||||
public ICPPDelegate createDelegate( IASTName name ) {
|
||||
return new CPPMethodDelegate( name, this );
|
||||
}
|
||||
|
||||
}
|
||||
|
|
|
@ -18,6 +18,7 @@ import java.util.Collections;
|
|||
import java.util.List;
|
||||
|
||||
import org.eclipse.cdt.core.dom.ast.ASTVisitor;
|
||||
import org.eclipse.cdt.core.dom.ast.DOMException;
|
||||
import org.eclipse.cdt.core.dom.ast.IASTDeclaration;
|
||||
import org.eclipse.cdt.core.dom.ast.IASTName;
|
||||
import org.eclipse.cdt.core.dom.ast.IASTNode;
|
||||
|
@ -26,6 +27,7 @@ import org.eclipse.cdt.core.dom.ast.cpp.CPPASTVisitor;
|
|||
import org.eclipse.cdt.core.dom.ast.cpp.ICPPASTLinkageSpecification;
|
||||
import org.eclipse.cdt.core.dom.ast.cpp.ICPPASTNamespaceDefinition;
|
||||
import org.eclipse.cdt.core.dom.ast.cpp.ICPPASTTranslationUnit;
|
||||
import org.eclipse.cdt.core.dom.ast.cpp.ICPPDelegate;
|
||||
import org.eclipse.cdt.core.dom.ast.cpp.ICPPNamespace;
|
||||
import org.eclipse.cdt.core.dom.ast.cpp.ICPPNamespaceScope;
|
||||
import org.eclipse.cdt.core.parser.util.CharArrayUtils;
|
||||
|
@ -33,7 +35,15 @@ import org.eclipse.cdt.core.parser.util.CharArrayUtils;
|
|||
/**
|
||||
* @author aniefer
|
||||
*/
|
||||
public class CPPNamespace implements ICPPNamespace, ICPPBinding {
|
||||
public class CPPNamespace implements ICPPNamespace, ICPPInternalBinding {
|
||||
public static class CPPNamespaceDelegate extends CPPDelegate implements ICPPNamespace {
|
||||
public CPPNamespaceDelegate( IASTName name, ICPPNamespace binding ) {
|
||||
super( name, binding );
|
||||
}
|
||||
public ICPPNamespaceScope getNamespaceScope() throws DOMException {
|
||||
return ((ICPPNamespace)getBinding()).getNamespaceScope();
|
||||
}
|
||||
}
|
||||
private static final char[] EMPTY_CHAR_ARRAY = { };
|
||||
|
||||
IASTName [] namespaceDefinitions = null;
|
||||
|
@ -164,4 +174,46 @@ public class CPPNamespace implements ICPPNamespace, ICPPBinding {
|
|||
return ( tu != null ? (IASTNode) tu : namespaceDefinitions[0] );
|
||||
}
|
||||
|
||||
/* (non-Javadoc)
|
||||
* @see org.eclipse.cdt.core.dom.ast.IBinding#getFullyQualifiedName()
|
||||
*/
|
||||
public String[] getFullyQualifiedName() {
|
||||
return CPPVisitor.getQualifiedName( this );
|
||||
}
|
||||
|
||||
/* (non-Javadoc)
|
||||
* @see org.eclipse.cdt.core.dom.ast.IBinding#getFullyQualifiedNameCharArray()
|
||||
*/
|
||||
public char[][] getFullyQualifiedNameCharArray() {
|
||||
return CPPVisitor.getQualifiedNameCharArray( this );
|
||||
}
|
||||
|
||||
/* (non-Javadoc)
|
||||
* @see org.eclipse.cdt.core.dom.ast.cpp.ICPPBinding#getQualifiedName()
|
||||
*/
|
||||
public String[] getQualifiedName() {
|
||||
return CPPVisitor.getQualifiedName( this );
|
||||
}
|
||||
|
||||
/* (non-Javadoc)
|
||||
* @see org.eclipse.cdt.core.dom.ast.cpp.ICPPBinding#getQualifiedNameCharArray()
|
||||
*/
|
||||
public char[][] getQualifiedNameCharArray() {
|
||||
return CPPVisitor.getQualifiedNameCharArray( this );
|
||||
}
|
||||
|
||||
/* (non-Javadoc)
|
||||
* @see org.eclipse.cdt.core.dom.ast.cpp.ICPPBinding#isGloballyQualified()
|
||||
*/
|
||||
public boolean isGloballyQualified() {
|
||||
return true;
|
||||
}
|
||||
|
||||
/* (non-Javadoc)
|
||||
* @see org.eclipse.cdt.internal.core.dom.parser.cpp.ICPPInternalBinding#createDelegate(org.eclipse.cdt.core.dom.ast.IASTName)
|
||||
*/
|
||||
public ICPPDelegate createDelegate( IASTName name ) {
|
||||
return new CPPNamespaceDelegate( name, this );
|
||||
}
|
||||
|
||||
}
|
||||
|
|
|
@ -0,0 +1,134 @@
|
|||
/*******************************************************************************
|
||||
* Copyright (c) 2004 IBM Corporation and others.
|
||||
* All rights reserved. This program and the accompanying materials
|
||||
* are made available under the terms of the Common Public License v1.0
|
||||
* which accompanies this distribution, and is available at
|
||||
* http://www.eclipse.org/legal/cpl-v10.html
|
||||
*
|
||||
* Contributors:
|
||||
* IBM Corporation - initial API and implementation
|
||||
*******************************************************************************/
|
||||
|
||||
/*
|
||||
* Created on Mar 15, 2005
|
||||
*/
|
||||
package org.eclipse.cdt.internal.core.dom.parser.cpp;
|
||||
|
||||
import org.eclipse.cdt.core.dom.ast.DOMException;
|
||||
import org.eclipse.cdt.core.dom.ast.IASTName;
|
||||
import org.eclipse.cdt.core.dom.ast.IASTNode;
|
||||
import org.eclipse.cdt.core.dom.ast.IBinding;
|
||||
import org.eclipse.cdt.core.dom.ast.IScope;
|
||||
import org.eclipse.cdt.core.dom.ast.cpp.ICPPBlockScope;
|
||||
import org.eclipse.cdt.core.dom.ast.cpp.ICPPDelegate;
|
||||
import org.eclipse.cdt.core.dom.ast.cpp.ICPPNamespace;
|
||||
import org.eclipse.cdt.core.dom.ast.cpp.ICPPNamespaceAlias;
|
||||
import org.eclipse.cdt.core.dom.ast.cpp.ICPPNamespaceScope;
|
||||
|
||||
/**
|
||||
* @author aniefer
|
||||
*/
|
||||
public class CPPNamespaceAlias implements ICPPNamespaceAlias, ICPPInternalBinding {
|
||||
|
||||
private ICPPNamespace namespace;
|
||||
private IASTName alias;
|
||||
/**
|
||||
*
|
||||
*/
|
||||
public CPPNamespaceAlias( IASTName aliasName, ICPPNamespace namespace ) {
|
||||
super();
|
||||
this.namespace = namespace;
|
||||
this.alias = aliasName;
|
||||
}
|
||||
|
||||
/* (non-Javadoc)
|
||||
* @see org.eclipse.cdt.core.dom.ast.cpp.ICPPNamespace#getNamespaceScope()
|
||||
*/
|
||||
public ICPPNamespaceScope getNamespaceScope() throws DOMException {
|
||||
return namespace.getNamespaceScope();
|
||||
}
|
||||
|
||||
/* (non-Javadoc)
|
||||
* @see org.eclipse.cdt.core.dom.ast.cpp.ICPPDelegate#getDelegateType()
|
||||
*/
|
||||
public int getDelegateType() {
|
||||
return ICPPDelegate.NAMESPACE_ALIAS;
|
||||
}
|
||||
|
||||
/* (non-Javadoc)
|
||||
* @see org.eclipse.cdt.core.dom.ast.cpp.ICPPDelegate#getBinding()
|
||||
*/
|
||||
public IBinding getBinding() {
|
||||
return namespace;
|
||||
}
|
||||
|
||||
/* (non-Javadoc)
|
||||
* @see org.eclipse.cdt.core.dom.ast.IBinding#getName()
|
||||
*/
|
||||
public String getName() {
|
||||
return alias.toString();
|
||||
}
|
||||
|
||||
/* (non-Javadoc)
|
||||
* @see org.eclipse.cdt.core.dom.ast.IBinding#getNameCharArray()
|
||||
*/
|
||||
public char[] getNameCharArray() {
|
||||
return alias.toCharArray();
|
||||
}
|
||||
|
||||
/* (non-Javadoc)
|
||||
* @see org.eclipse.cdt.core.dom.ast.IBinding#getFullyQualifiedName()
|
||||
*/
|
||||
public String[] getQualifiedName() {
|
||||
return CPPVisitor.getQualifiedName( this );
|
||||
}
|
||||
|
||||
/* (non-Javadoc)
|
||||
* @see org.eclipse.cdt.core.dom.ast.IBinding#getFullyQualifiedNameCharArray()
|
||||
*/
|
||||
public char[][] getQualifiedNameCharArray() {
|
||||
return CPPVisitor.getQualifiedNameCharArray( this );
|
||||
}
|
||||
|
||||
/* (non-Javadoc)
|
||||
* @see org.eclipse.cdt.core.dom.ast.IBinding#getScope()
|
||||
*/
|
||||
public IScope getScope() {
|
||||
return CPPVisitor.getContainingScope( alias );
|
||||
}
|
||||
|
||||
/* (non-Javadoc)
|
||||
* @see org.eclipse.cdt.core.dom.ast.cpp.ICPPBinding#isGloballyQualified()
|
||||
*/
|
||||
public boolean isGloballyQualified() throws DOMException {
|
||||
IScope scope = getScope();
|
||||
while( scope != null ){
|
||||
if( scope instanceof ICPPBlockScope )
|
||||
return false;
|
||||
scope = scope.getParent();
|
||||
}
|
||||
return true;
|
||||
}
|
||||
|
||||
/* (non-Javadoc)
|
||||
* @see org.eclipse.cdt.internal.core.dom.parser.cpp.ICPPInternalBinding#getDeclarations()
|
||||
*/
|
||||
public IASTNode[] getDeclarations() {
|
||||
return null;
|
||||
}
|
||||
|
||||
/* (non-Javadoc)
|
||||
* @see org.eclipse.cdt.internal.core.dom.parser.cpp.ICPPInternalBinding#getDefinition()
|
||||
*/
|
||||
public IASTNode getDefinition() {
|
||||
return alias;
|
||||
}
|
||||
|
||||
/* (non-Javadoc)
|
||||
* @see org.eclipse.cdt.internal.core.dom.parser.cpp.ICPPInternalBinding#createDelegate(org.eclipse.cdt.core.dom.ast.IASTName)
|
||||
*/
|
||||
public ICPPDelegate createDelegate( IASTName name ) {
|
||||
// TODO Auto-generated method stub
|
||||
return null;
|
||||
}
|
||||
}
|
|
@ -13,7 +13,10 @@
|
|||
*/
|
||||
package org.eclipse.cdt.internal.core.dom.parser.cpp;
|
||||
|
||||
import org.eclipse.cdt.core.dom.ast.DOMException;
|
||||
import org.eclipse.cdt.core.dom.ast.IASTName;
|
||||
import org.eclipse.cdt.core.dom.ast.IASTNode;
|
||||
import org.eclipse.cdt.core.dom.ast.cpp.ICPPASTNamespaceDefinition;
|
||||
import org.eclipse.cdt.core.dom.ast.cpp.ICPPNamespaceScope;
|
||||
import org.eclipse.cdt.core.parser.util.ArrayUtil;
|
||||
|
||||
|
@ -39,4 +42,15 @@ public class CPPNamespaceScope extends CPPScope implements ICPPNamespaceScope{
|
|||
public void addUsingDirective(IASTNode directive) {
|
||||
usings = (IASTNode[]) ArrayUtil.append( IASTNode.class, usings, directive );
|
||||
}
|
||||
|
||||
/* (non-Javadoc)
|
||||
* @see org.eclipse.cdt.core.dom.ast.cpp.ICPPScope#getScopeName()
|
||||
*/
|
||||
public IASTName getScopeName() throws DOMException {
|
||||
IASTNode node = getPhysicalNode();
|
||||
if( node instanceof ICPPASTNamespaceDefinition ){
|
||||
return ((ICPPASTNamespaceDefinition)node).getName();
|
||||
}
|
||||
return null;
|
||||
}
|
||||
}
|
||||
|
|
|
@ -13,6 +13,7 @@
|
|||
*/
|
||||
package org.eclipse.cdt.internal.core.dom.parser.cpp;
|
||||
|
||||
import org.eclipse.cdt.core.dom.ast.DOMException;
|
||||
import org.eclipse.cdt.core.dom.ast.IASTDeclaration;
|
||||
import org.eclipse.cdt.core.dom.ast.IASTDeclarator;
|
||||
import org.eclipse.cdt.core.dom.ast.IASTFunctionDefinition;
|
||||
|
@ -21,11 +22,25 @@ import org.eclipse.cdt.core.dom.ast.IASTNode;
|
|||
import org.eclipse.cdt.core.dom.ast.IParameter;
|
||||
import org.eclipse.cdt.core.dom.ast.IScope;
|
||||
import org.eclipse.cdt.core.dom.ast.IType;
|
||||
import org.eclipse.cdt.core.dom.ast.cpp.ICPPDelegate;
|
||||
import org.eclipse.cdt.core.dom.ast.cpp.ICPPVariable;
|
||||
|
||||
/**
|
||||
* @author aniefer
|
||||
*/
|
||||
public class CPPParameter implements IParameter, ICPPBinding {
|
||||
public class CPPParameter implements IParameter, ICPPInternalBinding, ICPPVariable {
|
||||
public static class CPPParameterDelegate extends CPPDelegate implements IParameter, ICPPVariable {
|
||||
public CPPParameterDelegate( IASTName name, IParameter binding ) {
|
||||
super( name, binding );
|
||||
}
|
||||
public IType getType() throws DOMException {
|
||||
return ((IParameter)getBinding()).getType();
|
||||
}
|
||||
public boolean isStatic() throws DOMException {
|
||||
return ((IParameter)getBinding()).isStatic();
|
||||
}
|
||||
}
|
||||
|
||||
private IType type = null;
|
||||
private IASTName [] declarations = null;
|
||||
|
||||
|
@ -136,4 +151,32 @@ public class CPPParameter implements IParameter, ICPPBinding {
|
|||
return false;
|
||||
}
|
||||
|
||||
/* (non-Javadoc)
|
||||
* @see org.eclipse.cdt.core.dom.ast.IBinding#getFullyQualifiedName()
|
||||
*/
|
||||
public String[] getQualifiedName() {
|
||||
return new String [] { getName() };
|
||||
}
|
||||
|
||||
/* (non-Javadoc)
|
||||
* @see org.eclipse.cdt.core.dom.ast.IBinding#getFullyQualifiedNameCharArray()
|
||||
*/
|
||||
public char[][] getQualifiedNameCharArray() {
|
||||
return new char[][]{ getNameCharArray() };
|
||||
}
|
||||
|
||||
/* (non-Javadoc)
|
||||
* @see org.eclipse.cdt.core.dom.ast.cpp.ICPPBinding#isGloballyQualified()
|
||||
*/
|
||||
public boolean isGloballyQualified() {
|
||||
return false;
|
||||
}
|
||||
|
||||
/* (non-Javadoc)
|
||||
* @see org.eclipse.cdt.internal.core.dom.parser.cpp.ICPPInternalBinding#createDelegate(org.eclipse.cdt.core.dom.ast.IASTName)
|
||||
*/
|
||||
public ICPPDelegate createDelegate( IASTName name ) {
|
||||
return new CPPParameterDelegate( name, this );
|
||||
}
|
||||
|
||||
}
|
||||
|
|
|
@ -19,8 +19,8 @@ import org.eclipse.cdt.core.dom.ast.IASTNode;
|
|||
import org.eclipse.cdt.core.dom.ast.IBinding;
|
||||
import org.eclipse.cdt.core.dom.ast.IScope;
|
||||
import org.eclipse.cdt.core.dom.ast.cpp.ICPPASTQualifiedName;
|
||||
import org.eclipse.cdt.core.dom.ast.cpp.ICPPCompositeBinding;
|
||||
import org.eclipse.cdt.core.dom.ast.cpp.ICPPScope;
|
||||
import org.eclipse.cdt.core.dom.ast.cpp.ICPPUsingDeclaration;
|
||||
import org.eclipse.cdt.core.parser.util.ArrayUtil;
|
||||
import org.eclipse.cdt.core.parser.util.CharArrayObjectMap;
|
||||
import org.eclipse.cdt.core.parser.util.ObjectSet;
|
||||
|
@ -54,6 +54,9 @@ abstract public class CPPScope implements ICPPScope{
|
|||
public boolean isFullyCached() {
|
||||
return false;
|
||||
}
|
||||
public IASTName getScopeName() throws DOMException {
|
||||
throw new DOMException( this );
|
||||
}
|
||||
}
|
||||
public static class CPPTemplateProblem extends CPPScopeProblem {
|
||||
public CPPTemplateProblem(int id, char[] arg) {
|
||||
|
@ -136,8 +139,8 @@ abstract public class CPPScope implements ICPPScope{
|
|||
}
|
||||
binding = ((CPPASTName)n).getBinding();
|
||||
}
|
||||
if( binding instanceof ICPPCompositeBinding ){
|
||||
return CPPSemantics.resolveAmbiguities( name, ((ICPPCompositeBinding)binding).getBindings() );
|
||||
if( binding instanceof ICPPUsingDeclaration ){
|
||||
return CPPSemantics.resolveAmbiguities( name, ((ICPPUsingDeclaration)binding).getDelegates() );
|
||||
}
|
||||
return binding;
|
||||
}
|
||||
|
|
|
@ -77,7 +77,6 @@ import org.eclipse.cdt.core.dom.ast.cpp.ICPPBase;
|
|||
import org.eclipse.cdt.core.dom.ast.cpp.ICPPBasicType;
|
||||
import org.eclipse.cdt.core.dom.ast.cpp.ICPPClassScope;
|
||||
import org.eclipse.cdt.core.dom.ast.cpp.ICPPClassType;
|
||||
import org.eclipse.cdt.core.dom.ast.cpp.ICPPCompositeBinding;
|
||||
import org.eclipse.cdt.core.dom.ast.cpp.ICPPConstructor;
|
||||
import org.eclipse.cdt.core.dom.ast.cpp.ICPPMember;
|
||||
import org.eclipse.cdt.core.dom.ast.cpp.ICPPMethod;
|
||||
|
@ -86,6 +85,7 @@ import org.eclipse.cdt.core.dom.ast.cpp.ICPPNamespaceScope;
|
|||
import org.eclipse.cdt.core.dom.ast.cpp.ICPPPointerToMemberType;
|
||||
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.ICPPUsingDeclaration;
|
||||
import org.eclipse.cdt.core.dom.ast.cpp.ICPPASTCompositeTypeSpecifier.ICPPASTBaseSpecifier;
|
||||
import org.eclipse.cdt.core.parser.ast.IASTNamespaceDefinition;
|
||||
import org.eclipse.cdt.core.parser.util.ArrayUtil;
|
||||
|
@ -1267,8 +1267,8 @@ public class CPPSemantics {
|
|||
if( node.getPropertyInParent() == STRING_LOOKUP_PROPERTY ) return true;
|
||||
|
||||
ASTNode nd = null;
|
||||
if( obj instanceof ICPPBinding ){
|
||||
ICPPBinding cpp = (ICPPBinding) obj;
|
||||
if( obj instanceof ICPPInternalBinding ){
|
||||
ICPPInternalBinding cpp = (ICPPInternalBinding) obj;
|
||||
IASTNode[] n = cpp.getDeclarations();
|
||||
|
||||
if( n != null && n.length > 0 )
|
||||
|
@ -1332,8 +1332,8 @@ public class CPPSemantics {
|
|||
|
||||
if( !( temp instanceof ICPPMember ) && !declaredBefore )
|
||||
continue;
|
||||
if( temp instanceof ICPPCompositeBinding ){
|
||||
IBinding [] bindings = ((ICPPCompositeBinding) temp).getBindings();
|
||||
if( temp instanceof ICPPUsingDeclaration ){
|
||||
IBinding [] bindings = ((ICPPUsingDeclaration) temp).getDelegates();
|
||||
mergeResults( data, bindings, false );
|
||||
items = (Object[]) data.foundItems;
|
||||
continue;
|
||||
|
@ -1357,17 +1357,16 @@ public class CPPSemantics {
|
|||
IBinding [] bindings = null;
|
||||
if( obj != null ){
|
||||
if( fns != null ) return new ProblemBinding( IProblemBinding.SEMANTIC_AMBIGUOUS_LOOKUP, data.name );
|
||||
if( type == null ) return obj;
|
||||
// if( type == null ) return obj;
|
||||
bindings = (IBinding[]) ArrayUtil.append( IBinding.class, bindings, obj );
|
||||
bindings = (IBinding[]) ArrayUtil.append( IBinding.class, bindings, type );
|
||||
} else {
|
||||
if( fns == null ) return type;
|
||||
bindings = (IBinding[]) ArrayUtil.addAll( IBinding.class, bindings, fns );
|
||||
// if( fns == null ) return type;
|
||||
bindings = (IBinding[]) ArrayUtil.append( IBinding.class, bindings, type );
|
||||
bindings = (IBinding[]) ArrayUtil.addAll( IBinding.class, bindings, fns );
|
||||
}
|
||||
bindings = (IBinding[]) ArrayUtil.trim( IBinding.class, bindings );
|
||||
if( bindings.length == 1 ) return bindings[0];
|
||||
ICPPCompositeBinding composite = new CPPCompositeBinding( bindings );
|
||||
ICPPUsingDeclaration composite = new CPPUsingDeclaration( data.astName, bindings );
|
||||
return composite;
|
||||
}
|
||||
|
||||
|
@ -1412,9 +1411,9 @@ public class CPPSemantics {
|
|||
int size = functions.length;
|
||||
for( int i = 0; i < size && functions[i] != null; i++ ){
|
||||
fName = (IFunction) functions[i];
|
||||
function = (ICPPASTFunctionDeclarator) ((ICPPBinding)fName).getDefinition();
|
||||
function = (ICPPASTFunctionDeclarator) ((ICPPInternalBinding)fName).getDefinition();
|
||||
if( function == null ){
|
||||
IASTNode [] nodes = ((ICPPBinding) fName).getDeclarations();
|
||||
IASTNode [] nodes = ((ICPPInternalBinding) fName).getDeclarations();
|
||||
if( nodes != null && nodes.length > 0 )
|
||||
function = (ICPPASTFunctionDeclarator) nodes[0];
|
||||
}
|
||||
|
@ -1500,9 +1499,7 @@ public class CPPSemantics {
|
|||
return null;
|
||||
|
||||
if( data.forUsingDeclaration() ){
|
||||
if( fns.length == 1 )
|
||||
return fns[ 0 ];
|
||||
return new CPPCompositeBinding( fns );
|
||||
return new CPPUsingDeclaration( data.astName, fns );
|
||||
}
|
||||
|
||||
//we don't have any arguments with which to resolve the function
|
||||
|
@ -1547,9 +1544,9 @@ public class CPPSemantics {
|
|||
if( currFn == null || bestFn == currFn )
|
||||
continue;
|
||||
|
||||
ICPPASTFunctionDeclarator currDtor = (ICPPASTFunctionDeclarator) ((ICPPBinding)currFn).getDefinition();
|
||||
ICPPASTFunctionDeclarator currDtor = (ICPPASTFunctionDeclarator) ((ICPPInternalBinding)currFn).getDefinition();
|
||||
if( currDtor == null ){
|
||||
IASTNode[] nodes = ((ICPPBinding) currFn).getDeclarations();
|
||||
IASTNode[] nodes = ((ICPPInternalBinding) currFn).getDeclarations();
|
||||
if( nodes != null && nodes.length > 0 )
|
||||
currDtor = (ICPPASTFunctionDeclarator) nodes[0];
|
||||
}
|
||||
|
@ -2023,7 +2020,7 @@ public class CPPSemantics {
|
|||
|
||||
static private boolean isCompleteType( IType type ){
|
||||
type = getUltimateType( type, false );
|
||||
if( type instanceof ICPPClassType && ((ICPPBinding)type).getDefinition() == null ){
|
||||
if( type instanceof ICPPClassType && ((ICPPInternalBinding)type).getDefinition() == null ){
|
||||
return false;
|
||||
}
|
||||
return true;
|
||||
|
@ -2305,14 +2302,10 @@ public class CPPSemantics {
|
|||
binding = null;
|
||||
|
||||
if( binding != null )
|
||||
if( binding instanceof ICPPCompositeBinding ){
|
||||
try {
|
||||
IBinding [] bs = ((ICPPCompositeBinding)binding).getBindings();
|
||||
for( int j = 0; j < bs.length; j++ ){
|
||||
set.put( bs[j] );
|
||||
}
|
||||
} catch ( DOMException e1 ) {
|
||||
}
|
||||
if( binding instanceof ICPPUsingDeclaration ){
|
||||
set.addAll( ((ICPPUsingDeclaration)binding).getDelegates() );
|
||||
} else if( binding instanceof CPPCompositeBinding ){
|
||||
set.addAll( ((CPPCompositeBinding)binding).getBindings() );
|
||||
} else {
|
||||
set.put( binding );
|
||||
}
|
||||
|
|
|
@ -20,12 +20,30 @@ import org.eclipse.cdt.core.dom.ast.IASTNode;
|
|||
import org.eclipse.cdt.core.dom.ast.IScope;
|
||||
import org.eclipse.cdt.core.dom.ast.IType;
|
||||
import org.eclipse.cdt.core.dom.ast.ITypedef;
|
||||
import org.eclipse.cdt.core.dom.ast.cpp.ICPPBinding;
|
||||
import org.eclipse.cdt.core.dom.ast.cpp.ICPPBlockScope;
|
||||
import org.eclipse.cdt.core.dom.ast.cpp.ICPPDelegate;
|
||||
import org.eclipse.cdt.internal.core.dom.parser.ITypeContainer;
|
||||
|
||||
/**
|
||||
* @author aniefer
|
||||
*/
|
||||
public class CPPTypedef implements ITypedef, ITypeContainer, ICPPBinding {
|
||||
public class CPPTypedef implements ITypedef, ITypeContainer, ICPPInternalBinding, ICPPBinding {
|
||||
public static class CPPTypedefDelegate extends CPPDelegate implements ITypedef {
|
||||
public CPPTypedefDelegate( IASTName name, ITypedef binding ) {
|
||||
super( name, binding );
|
||||
}
|
||||
public IType getType() throws DOMException {
|
||||
return ((ITypedef)getBinding()).getType();
|
||||
}
|
||||
public Object clone() {
|
||||
try {
|
||||
return super.clone();
|
||||
} catch ( CloneNotSupportedException e ) {
|
||||
}
|
||||
return null;
|
||||
}
|
||||
}
|
||||
private IASTName typedefName = null;
|
||||
private IType type = null;
|
||||
|
||||
|
@ -125,4 +143,38 @@ public class CPPTypedef implements ITypedef, ITypeContainer, ICPPBinding {
|
|||
}
|
||||
return t;
|
||||
}
|
||||
/* (non-Javadoc)
|
||||
* @see org.eclipse.cdt.core.dom.ast.IBinding#getFullyQualifiedName()
|
||||
*/
|
||||
public String[] getQualifiedName() {
|
||||
return CPPVisitor.getQualifiedName( this );
|
||||
}
|
||||
|
||||
/* (non-Javadoc)
|
||||
* @see org.eclipse.cdt.core.dom.ast.IBinding#getFullyQualifiedNameCharArray()
|
||||
*/
|
||||
public char[][] getQualifiedNameCharArray() {
|
||||
return CPPVisitor.getQualifiedNameCharArray( this );
|
||||
}
|
||||
|
||||
/* (non-Javadoc)
|
||||
* @see org.eclipse.cdt.core.dom.ast.cpp.ICPPBinding#isGloballyQualified()
|
||||
*/
|
||||
public boolean isGloballyQualified() throws DOMException {
|
||||
IScope scope = getScope();
|
||||
while( scope != null ){
|
||||
if( scope instanceof ICPPBlockScope )
|
||||
return false;
|
||||
scope = scope.getParent();
|
||||
}
|
||||
return true;
|
||||
}
|
||||
|
||||
/* (non-Javadoc)
|
||||
* @see org.eclipse.cdt.internal.core.dom.parser.cpp.ICPPInternalBinding#createDelegate(org.eclipse.cdt.core.dom.ast.IASTName)
|
||||
*/
|
||||
public ICPPDelegate createDelegate( IASTName name ) {
|
||||
return new CPPTypedefDelegate( name, this );
|
||||
}
|
||||
|
||||
}
|
||||
|
|
|
@ -0,0 +1,103 @@
|
|||
/*******************************************************************************
|
||||
* Copyright (c) 2004 IBM Corporation and others.
|
||||
* All rights reserved. This program and the accompanying materials
|
||||
* are made available under the terms of the Common Public License v1.0
|
||||
* which accompanies this distribution, and is available at
|
||||
* http://www.eclipse.org/legal/cpl-v10.html
|
||||
*
|
||||
* Contributors:
|
||||
* IBM Corporation - initial API and implementation
|
||||
*******************************************************************************/
|
||||
|
||||
/*
|
||||
* Created on Mar 16, 2005
|
||||
*/
|
||||
package org.eclipse.cdt.internal.core.dom.parser.cpp;
|
||||
|
||||
import org.eclipse.cdt.core.dom.ast.DOMException;
|
||||
import org.eclipse.cdt.core.dom.ast.IASTName;
|
||||
import org.eclipse.cdt.core.dom.ast.IBinding;
|
||||
import org.eclipse.cdt.core.dom.ast.IScope;
|
||||
import org.eclipse.cdt.core.dom.ast.cpp.ICPPBlockScope;
|
||||
import org.eclipse.cdt.core.dom.ast.cpp.ICPPDelegate;
|
||||
import org.eclipse.cdt.core.dom.ast.cpp.ICPPUsingDeclaration;
|
||||
import org.eclipse.cdt.core.parser.util.ArrayUtil;
|
||||
|
||||
/**
|
||||
* @author aniefer
|
||||
*/
|
||||
public class CPPUsingDeclaration implements ICPPUsingDeclaration {
|
||||
private IASTName name;
|
||||
private ICPPDelegate [] delegates;
|
||||
|
||||
public CPPUsingDeclaration( IASTName name, IBinding [] bindings ) {
|
||||
this.name = name;
|
||||
this.delegates = createDelegates( bindings );
|
||||
}
|
||||
|
||||
private ICPPDelegate [] createDelegates( IBinding [] bindings ){
|
||||
ICPPDelegate [] result = null;
|
||||
for( int i = 0; i < bindings.length; i++ ){
|
||||
if( bindings[i] instanceof ICPPInternalBinding ){
|
||||
ICPPDelegate delegate = ((ICPPInternalBinding)bindings[i]).createDelegate( name );
|
||||
result = (ICPPDelegate[]) ArrayUtil.append( ICPPDelegate.class, result, delegate );
|
||||
}
|
||||
}
|
||||
return (ICPPDelegate[]) ArrayUtil.trim( ICPPDelegate.class, result );
|
||||
}
|
||||
|
||||
/* (non-Javadoc)
|
||||
* @see org.eclipse.cdt.core.dom.ast.cpp.ICPPUsingDeclaration#getDelegates()
|
||||
*/
|
||||
public ICPPDelegate[] getDelegates() {
|
||||
return delegates;
|
||||
}
|
||||
|
||||
/* (non-Javadoc)
|
||||
* @see org.eclipse.cdt.core.dom.ast.cpp.ICPPBinding#getQualifiedName()
|
||||
*/
|
||||
public String[] getQualifiedName() throws DOMException {
|
||||
return delegates[0].getQualifiedName();
|
||||
}
|
||||
|
||||
/* (non-Javadoc)
|
||||
* @see org.eclipse.cdt.core.dom.ast.cpp.ICPPBinding#getQualifiedNameCharArray()
|
||||
*/
|
||||
public char[][] getQualifiedNameCharArray() throws DOMException {
|
||||
return delegates[0].getQualifiedNameCharArray();
|
||||
}
|
||||
|
||||
/* (non-Javadoc)
|
||||
* @see org.eclipse.cdt.core.dom.ast.cpp.ICPPBinding#isGloballyQualified()
|
||||
*/
|
||||
public boolean isGloballyQualified() throws DOMException {
|
||||
IScope scope = getScope();
|
||||
while( scope != null ){
|
||||
if( scope instanceof ICPPBlockScope )
|
||||
return false;
|
||||
scope = scope.getParent();
|
||||
}
|
||||
return true;
|
||||
}
|
||||
|
||||
/* (non-Javadoc)
|
||||
* @see org.eclipse.cdt.core.dom.ast.IBinding#getName()
|
||||
*/
|
||||
public String getName() {
|
||||
return delegates[0].getName();
|
||||
}
|
||||
|
||||
/* (non-Javadoc)
|
||||
* @see org.eclipse.cdt.core.dom.ast.IBinding#getNameCharArray()
|
||||
*/
|
||||
public char[] getNameCharArray() {
|
||||
return delegates[0].getNameCharArray(); }
|
||||
|
||||
/* (non-Javadoc)
|
||||
* @see org.eclipse.cdt.core.dom.ast.IBinding#getScope()
|
||||
*/
|
||||
public IScope getScope() {
|
||||
return CPPVisitor.getContainingScope( name.getParent() );
|
||||
}
|
||||
|
||||
}
|
|
@ -21,17 +21,30 @@ import org.eclipse.cdt.core.dom.ast.IASTNode;
|
|||
import org.eclipse.cdt.core.dom.ast.IASTSimpleDeclaration;
|
||||
import org.eclipse.cdt.core.dom.ast.IScope;
|
||||
import org.eclipse.cdt.core.dom.ast.IType;
|
||||
import org.eclipse.cdt.core.dom.ast.IVariable;
|
||||
import org.eclipse.cdt.core.dom.ast.cpp.ICPPASTCompositeTypeSpecifier;
|
||||
import org.eclipse.cdt.core.dom.ast.cpp.ICPPASTQualifiedName;
|
||||
import org.eclipse.cdt.core.dom.ast.cpp.ICPPBlockScope;
|
||||
import org.eclipse.cdt.core.dom.ast.cpp.ICPPDelegate;
|
||||
import org.eclipse.cdt.core.dom.ast.cpp.ICPPVariable;
|
||||
import org.eclipse.cdt.core.parser.util.ArrayUtil;
|
||||
import org.eclipse.cdt.internal.core.dom.parser.ProblemBinding;
|
||||
|
||||
/**
|
||||
* @author aniefer
|
||||
*/
|
||||
public class CPPVariable implements IVariable, ICPPBinding {
|
||||
public static class CPPVariableProblem extends ProblemBinding implements IVariable{
|
||||
public class CPPVariable implements ICPPVariable, ICPPInternalBinding {
|
||||
public static class CPPVariableDelegate extends CPPDelegate implements ICPPVariable {
|
||||
public CPPVariableDelegate( IASTName name, ICPPVariable binding ) {
|
||||
super( name, binding );
|
||||
}
|
||||
public IType getType() throws DOMException {
|
||||
return ((ICPPVariable)getBinding()).getType();
|
||||
}
|
||||
public boolean isStatic() throws DOMException {
|
||||
return ((ICPPVariable)getBinding()).isStatic();
|
||||
}
|
||||
}
|
||||
public static class CPPVariableProblem extends ProblemBinding implements ICPPVariable{
|
||||
public CPPVariableProblem( int id, char[] arg ) {
|
||||
super( id, arg );
|
||||
}
|
||||
|
@ -43,6 +56,15 @@ public class CPPVariable implements IVariable, ICPPBinding {
|
|||
public boolean isStatic() throws DOMException {
|
||||
throw new DOMException( this );
|
||||
}
|
||||
public String[] getQualifiedName() throws DOMException {
|
||||
throw new DOMException( this );
|
||||
}
|
||||
public char[][] getQualifiedNameCharArray() throws DOMException {
|
||||
throw new DOMException( this );
|
||||
}
|
||||
public boolean isGloballyQualified() throws DOMException {
|
||||
throw new DOMException( this );
|
||||
}
|
||||
}
|
||||
private IASTName declarations[] = null;
|
||||
private IASTName definition = null;
|
||||
|
@ -185,4 +207,39 @@ public class CPPVariable implements IVariable, ICPPBinding {
|
|||
}
|
||||
return false;
|
||||
}
|
||||
|
||||
/* (non-Javadoc)
|
||||
* @see org.eclipse.cdt.core.dom.ast.IBinding#getFullyQualifiedName()
|
||||
*/
|
||||
public String[] getQualifiedName() {
|
||||
return CPPVisitor.getQualifiedName( this );
|
||||
}
|
||||
|
||||
/* (non-Javadoc)
|
||||
* @see org.eclipse.cdt.core.dom.ast.IBinding#getFullyQualifiedNameCharArray()
|
||||
*/
|
||||
public char[][] getQualifiedNameCharArray() {
|
||||
return CPPVisitor.getQualifiedNameCharArray( this );
|
||||
}
|
||||
|
||||
/* (non-Javadoc)
|
||||
* @see org.eclipse.cdt.core.dom.ast.cpp.ICPPBinding#isGloballyQualified()
|
||||
*/
|
||||
public boolean isGloballyQualified() throws DOMException {
|
||||
IScope scope = getScope();
|
||||
while( scope != null ){
|
||||
if( scope instanceof ICPPBlockScope )
|
||||
return false;
|
||||
scope = scope.getParent();
|
||||
}
|
||||
return true;
|
||||
}
|
||||
|
||||
/* (non-Javadoc)
|
||||
* @see org.eclipse.cdt.internal.core.dom.parser.cpp.ICPPInternalBinding#createDelegate(org.eclipse.cdt.core.dom.ast.IASTName)
|
||||
*/
|
||||
public ICPPDelegate createDelegate( IASTName name ) {
|
||||
return new CPPVariableDelegate( name, this );
|
||||
}
|
||||
|
||||
}
|
||||
|
|
|
@ -94,12 +94,14 @@ import org.eclipse.cdt.core.dom.ast.cpp.ICPPBasicType;
|
|||
import org.eclipse.cdt.core.dom.ast.cpp.ICPPBlockScope;
|
||||
import org.eclipse.cdt.core.dom.ast.cpp.ICPPClassScope;
|
||||
import org.eclipse.cdt.core.dom.ast.cpp.ICPPClassType;
|
||||
import org.eclipse.cdt.core.dom.ast.cpp.ICPPCompositeBinding;
|
||||
import org.eclipse.cdt.core.dom.ast.cpp.ICPPDelegate;
|
||||
import org.eclipse.cdt.core.dom.ast.cpp.ICPPFunctionScope;
|
||||
import org.eclipse.cdt.core.dom.ast.cpp.ICPPMethod;
|
||||
import org.eclipse.cdt.core.dom.ast.cpp.ICPPNamespace;
|
||||
import org.eclipse.cdt.core.dom.ast.cpp.ICPPNamespaceScope;
|
||||
import org.eclipse.cdt.core.dom.ast.cpp.ICPPPointerToMemberType;
|
||||
import org.eclipse.cdt.core.dom.ast.cpp.ICPPScope;
|
||||
import org.eclipse.cdt.core.dom.ast.cpp.ICPPUsingDeclaration;
|
||||
import org.eclipse.cdt.core.dom.ast.cpp.ICPPASTCompositeTypeSpecifier.ICPPASTBaseSpecifier;
|
||||
import org.eclipse.cdt.core.dom.ast.gnu.cpp.IGPPASTPointer;
|
||||
import org.eclipse.cdt.core.dom.ast.gnu.cpp.IGPPASTPointerToMember;
|
||||
|
@ -123,7 +125,8 @@ public class CPPVisitor {
|
|||
if( parent instanceof IASTNamedTypeSpecifier ||
|
||||
parent instanceof ICPPASTQualifiedName ||
|
||||
parent instanceof ICPPASTBaseSpecifier ||
|
||||
parent instanceof ICPPASTConstructorChainInitializer )
|
||||
parent instanceof ICPPASTConstructorChainInitializer ||
|
||||
name.getPropertyInParent() == ICPPASTNamespaceAlias.MAPPING_NAME )
|
||||
{
|
||||
binding = CPPSemantics.resolveBinding( name );
|
||||
if( binding instanceof IProblemBinding && parent instanceof ICPPASTQualifiedName ){
|
||||
|
@ -345,8 +348,25 @@ public class CPPVisitor {
|
|||
} else if( declaration instanceof ICPPASTUsingDirective ){
|
||||
return CPPSemantics.resolveBinding( ((ICPPASTUsingDirective) declaration).getQualifiedName() );
|
||||
} else if( declaration instanceof ICPPASTNamespaceAlias ) {
|
||||
ICPPASTNamespaceAlias alias = (ICPPASTNamespaceAlias) declaration;
|
||||
return CPPSemantics.resolveBinding( alias.getMappingName() );
|
||||
ICPPASTNamespaceAlias alias = (ICPPASTNamespaceAlias) declaration;
|
||||
ICPPScope scope = (ICPPScope) getContainingScope( declaration );
|
||||
IBinding binding;
|
||||
try{
|
||||
binding = scope.getBinding( alias.getAlias(), false );
|
||||
if( binding == null ){
|
||||
IBinding namespace = alias.getMappingName().resolveBinding();
|
||||
if( namespace instanceof ICPPNamespace ){
|
||||
binding = new CPPNamespaceAlias( alias.getAlias(), (ICPPNamespace) namespace );
|
||||
scope.addName( alias.getAlias() );
|
||||
} else {
|
||||
binding = new ProblemBinding( IProblemBinding.SEMANTIC_NAME_NOT_FOUND, alias.getAlias().toCharArray() );
|
||||
}
|
||||
}
|
||||
} catch( DOMException e ){
|
||||
binding = e.getProblem();
|
||||
}
|
||||
|
||||
return binding;
|
||||
}
|
||||
|
||||
|
||||
|
@ -815,7 +835,7 @@ public class CPPVisitor {
|
|||
else if( binding instanceof ICPPNamespace) {
|
||||
kind = KIND_NAMESPACE;
|
||||
}
|
||||
else if( binding instanceof ICPPCompositeBinding )
|
||||
else if( binding instanceof ICPPUsingDeclaration )
|
||||
kind = KIND_COMPOSITE;
|
||||
else
|
||||
kind = KIND_OBJ_FN;
|
||||
|
@ -836,7 +856,8 @@ public class CPPVisitor {
|
|||
case KIND_TYPE:
|
||||
case KIND_COMPOSITE:
|
||||
if( prop == IASTCompositeTypeSpecifier.TYPE_NAME ||
|
||||
prop == IASTEnumerationSpecifier.ENUMERATION_NAME )
|
||||
prop == IASTEnumerationSpecifier.ENUMERATION_NAME ||
|
||||
prop == ICPPASTUsingDeclaration.NAME )
|
||||
{
|
||||
break;
|
||||
} else if( prop == IASTElaboratedTypeSpecifier.TYPE_NAME ){
|
||||
|
@ -859,7 +880,8 @@ public class CPPVisitor {
|
|||
return PROCESS_CONTINUE;
|
||||
case KIND_OBJ_FN:
|
||||
if( prop == IASTDeclarator.DECLARATOR_NAME ||
|
||||
prop == IASTEnumerationSpecifier.IASTEnumerator.ENUMERATOR_NAME )
|
||||
prop == IASTEnumerationSpecifier.IASTEnumerator.ENUMERATOR_NAME ||
|
||||
prop == ICPPASTUsingDeclaration.NAME )
|
||||
{
|
||||
break;
|
||||
}
|
||||
|
@ -875,26 +897,56 @@ public class CPPVisitor {
|
|||
|
||||
if( binding != null )
|
||||
{
|
||||
IBinding candidate = name.resolveBinding();
|
||||
|
||||
boolean found = false;
|
||||
if( binding instanceof ICPPCompositeBinding ){
|
||||
try {
|
||||
found = ArrayUtil.contains( ((ICPPCompositeBinding)binding).getBindings(), candidate );
|
||||
IBinding potential = name.resolveBinding();
|
||||
IBinding [] bs = null;
|
||||
IBinding candidate = null;
|
||||
int n = -1;
|
||||
if( potential instanceof ICPPUsingDeclaration ){
|
||||
try {
|
||||
bs = ((ICPPUsingDeclaration)potential).getDelegates();
|
||||
} catch ( DOMException e ) {
|
||||
return PROCESS_CONTINUE;
|
||||
}
|
||||
candidate = bs[ ++n ];
|
||||
} else {
|
||||
found = ( binding == candidate );
|
||||
candidate = potential;
|
||||
}
|
||||
|
||||
if( found ){
|
||||
if( decls.length == idx ){
|
||||
IASTName [] temp = new IASTName[ decls.length * 2 ];
|
||||
System.arraycopy( decls, 0, temp, 0, decls.length );
|
||||
decls = temp;
|
||||
}
|
||||
decls[idx++] = name;
|
||||
}
|
||||
while( candidate != null ) {
|
||||
boolean found = false;
|
||||
if( binding instanceof ICPPUsingDeclaration ){
|
||||
ICPPDelegate [] delegates = null;
|
||||
try {
|
||||
delegates = ((ICPPUsingDeclaration)binding).getDelegates();
|
||||
} catch (DOMException e1) {
|
||||
}
|
||||
if( delegates != null ){
|
||||
for (int i = 0; i < delegates.length; i++) {
|
||||
if( delegates[i].getBinding() == candidate ){
|
||||
found = true;
|
||||
break;
|
||||
}
|
||||
}
|
||||
}
|
||||
} else {
|
||||
// if( candidate instanceof ICPPDelegate )
|
||||
// found = ( ((ICPPDelegate)candidate).getBinding() == binding );
|
||||
// else
|
||||
found = ( binding == candidate );
|
||||
}
|
||||
|
||||
if( found ){
|
||||
if( decls.length == idx ){
|
||||
IASTName [] temp = new IASTName[ decls.length * 2 ];
|
||||
System.arraycopy( decls, 0, temp, 0, decls.length );
|
||||
decls = temp;
|
||||
}
|
||||
decls[idx++] = name;
|
||||
}
|
||||
if( n > -1 && ++n < bs.length ){
|
||||
candidate = bs[n];
|
||||
} else break;
|
||||
}
|
||||
}
|
||||
return PROCESS_CONTINUE;
|
||||
}
|
||||
|
@ -937,7 +989,7 @@ public class CPPVisitor {
|
|||
}
|
||||
else if( binding instanceof ICPPNamespace) {
|
||||
kind = KIND_NAMESPACE;
|
||||
} else if( binding instanceof ICPPCompositeBinding )
|
||||
} else if( binding instanceof ICPPUsingDeclaration )
|
||||
kind = KIND_COMPOSITE;
|
||||
else
|
||||
kind = KIND_OBJ_FN;
|
||||
|
@ -1009,9 +1061,9 @@ public class CPPVisitor {
|
|||
IBinding [] bs = null;
|
||||
IBinding candidate = null;
|
||||
int n = -1;
|
||||
if( potential instanceof ICPPCompositeBinding ){
|
||||
if( potential instanceof ICPPUsingDeclaration ){
|
||||
try {
|
||||
bs = ((ICPPCompositeBinding)potential).getBindings();
|
||||
bs = ((ICPPUsingDeclaration)potential).getDelegates();
|
||||
} catch ( DOMException e ) {
|
||||
return PROCESS_CONTINUE;
|
||||
}
|
||||
|
@ -1022,13 +1074,15 @@ public class CPPVisitor {
|
|||
|
||||
while( candidate != null ) {
|
||||
boolean found = false;
|
||||
if( binding instanceof ICPPCompositeBinding ){
|
||||
if( binding instanceof ICPPUsingDeclaration ){
|
||||
try {
|
||||
found = ArrayUtil.contains( ((ICPPCompositeBinding)binding).getBindings(), candidate );
|
||||
found = ArrayUtil.contains( ((ICPPUsingDeclaration)binding).getDelegates(), candidate );
|
||||
} catch ( DOMException e ) {
|
||||
}
|
||||
} else if( potential instanceof ICPPUsingDeclaration ){
|
||||
found = ( binding == ((ICPPDelegate)candidate).getBinding() );
|
||||
} else {
|
||||
found = ( binding == candidate );
|
||||
found = (binding == candidate );
|
||||
}
|
||||
|
||||
if( found ){
|
||||
|
@ -1457,4 +1511,52 @@ public class CPPVisitor {
|
|||
tu.accept( action );
|
||||
return action.getDeclarations();
|
||||
}
|
||||
|
||||
public static String [] getQualifiedName( IBinding binding ){
|
||||
IASTName [] ns = null;
|
||||
try {
|
||||
ICPPScope scope = (ICPPScope) binding.getScope();
|
||||
while( scope != null ){
|
||||
if( scope instanceof ICPPBlockScope || scope instanceof ICPPFunctionScope )
|
||||
break;
|
||||
|
||||
IASTName n = scope.getScopeName();
|
||||
ns = (IASTName[]) ArrayUtil.append( IASTName.class, ns, n );
|
||||
scope = (ICPPScope) scope.getParent();
|
||||
}
|
||||
} catch ( DOMException e ) {
|
||||
}
|
||||
ns = (IASTName[]) ArrayUtil.trim( IASTName.class, ns );
|
||||
String [] result = new String[ ns.length + 1 ];
|
||||
for( int i = ns.length - 1; i >= 0; i-- ){
|
||||
result[ ns.length - i - 1 ] = ns[i].toString();
|
||||
}
|
||||
result[ns.length] = binding.getName();
|
||||
return result;
|
||||
}
|
||||
|
||||
public static char [][] getQualifiedNameCharArray( IBinding binding ) {
|
||||
IASTName [] ns = null;
|
||||
try {
|
||||
ICPPScope scope = (ICPPScope) binding.getScope();
|
||||
while( scope != null ){
|
||||
if( scope instanceof ICPPBlockScope || scope instanceof ICPPFunctionScope )
|
||||
break;
|
||||
if( scope instanceof ICPPNamespaceScope && scope.getScopeName().toCharArray().length == 0 )
|
||||
break;
|
||||
IASTName n = scope.getScopeName();
|
||||
ns = (IASTName[]) ArrayUtil.append( IASTName.class, ns, n );
|
||||
scope = (ICPPScope) scope.getParent();
|
||||
}
|
||||
} catch ( DOMException e ) {
|
||||
}
|
||||
ns = (IASTName[]) ArrayUtil.trim( IASTName.class, ns );
|
||||
char[] [] result = new char[ ns.length + 1 ][];
|
||||
for( int i = ns.length - 1; i >= 0; i-- ){
|
||||
result[ ns.length - i - 1 ] = ns[i].toCharArray();
|
||||
}
|
||||
result[ns.length] = binding.getNameCharArray();
|
||||
return result;
|
||||
}
|
||||
|
||||
}
|
||||
|
|
|
@ -14,14 +14,18 @@
|
|||
*/
|
||||
package org.eclipse.cdt.internal.core.dom.parser.cpp;
|
||||
|
||||
import org.eclipse.cdt.core.dom.ast.IASTName;
|
||||
import org.eclipse.cdt.core.dom.ast.IASTNode;
|
||||
import org.eclipse.cdt.core.dom.ast.cpp.ICPPDelegate;
|
||||
|
||||
/**
|
||||
* @author aniefer
|
||||
*/
|
||||
public interface ICPPBinding {
|
||||
public interface ICPPInternalBinding {
|
||||
//methods required by the CPPVisitor but not meant for the public interface
|
||||
|
||||
IASTNode [] getDeclarations();
|
||||
IASTNode getDefinition();
|
||||
|
||||
ICPPDelegate createDelegate( IASTName name );
|
||||
}
|
Loading…
Add table
Reference in a new issue