mirror of
https://github.com/eclipse-cdt/cdt
synced 2025-04-23 06:32:10 +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.ICPPASTPointerToMember;
|
||||||
import org.eclipse.cdt.core.dom.ast.cpp.ICPPASTQualifiedName;
|
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.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.ICPPBlockScope;
|
||||||
import org.eclipse.cdt.core.dom.ast.cpp.ICPPClassScope;
|
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.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.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.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.ICPPMethod;
|
||||||
import org.eclipse.cdt.core.dom.ast.cpp.ICPPNamespace;
|
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.ICPPPointerToMemberType;
|
||||||
import org.eclipse.cdt.core.dom.ast.cpp.ICPPReferenceType;
|
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.cpp.ICPPASTCompositeTypeSpecifier.ICPPASTBaseSpecifier;
|
||||||
import org.eclipse.cdt.core.dom.ast.gnu.cpp.IGPPPointerToMemberType;
|
import org.eclipse.cdt.core.dom.ast.gnu.cpp.IGPPPointerToMemberType;
|
||||||
import org.eclipse.cdt.core.dom.ast.gnu.cpp.IGPPPointerType;
|
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();
|
IFunction g = (IFunction) collector.getName(2).resolveBinding();
|
||||||
ICPPNamespace X = (ICPPNamespace) collector.getName(3).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, A, 2);
|
||||||
assertInstances(collector, X, 3);
|
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 {
|
public void testFunctionDeclarations() throws Exception {
|
||||||
|
@ -1055,8 +1067,12 @@ public class AST2CPPTests extends AST2BaseTest {
|
||||||
assertEquals(col.size(), 8);
|
assertEquals(col.size(), 8);
|
||||||
ICPPNamespace A = (ICPPNamespace) col.getName(0).resolveBinding();
|
ICPPNamespace A = (ICPPNamespace) col.getName(0).resolveBinding();
|
||||||
IVariable x = (IVariable) col.getName(1).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);
|
assertInstances(col, x, 3);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -1288,7 +1304,7 @@ public class AST2CPPTests extends AST2BaseTest {
|
||||||
|
|
||||||
assertEquals(col.size(), 11);
|
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();
|
IVariable a2 = (IVariable) col.getName(10).resolveBinding();
|
||||||
assertSame(a1, a2);
|
assertSame(a1, a2);
|
||||||
}
|
}
|
||||||
|
@ -2250,6 +2266,10 @@ public class AST2CPPTests extends AST2BaseTest {
|
||||||
IBinding x_ref = col.getName(4).resolveBinding();
|
IBinding x_ref = col.getName(4).resolveBinding();
|
||||||
IEnumerator RED = (IEnumerator) col.getName(6).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 );
|
IASTName [] decls = tu.getDeclarations( enum_x );
|
||||||
assertEquals( decls.length, 1 );
|
assertEquals( decls.length, 1 );
|
||||||
assertSame( decls[0], col.getName(3) );
|
assertSame( decls[0], col.getName(3) );
|
||||||
|
@ -2343,13 +2363,19 @@ public class AST2CPPTests extends AST2BaseTest {
|
||||||
tu.accept(col);
|
tu.accept(col);
|
||||||
|
|
||||||
IFunction f1 = (IFunction) col.getName(2).resolveBinding();
|
IFunction f1 = (IFunction) col.getName(2).resolveBinding();
|
||||||
IFunction f2 = (IFunction) col.getName(5).resolveBinding();
|
ICPPFunction f2 = (ICPPFunction) col.getName(5).resolveBinding();
|
||||||
assertSame( f1, f2 );
|
assertSame( f1, f2 );
|
||||||
|
|
||||||
IASTName [] decls = tu.getDeclarations( f2 );
|
IASTName [] decls = tu.getDeclarations( f2 );
|
||||||
assertEquals( decls.length, 2 );
|
assertEquals( decls.length, 2 );
|
||||||
assertSame( decls[0], col.getName(2) );
|
assertSame( decls[0], col.getName(2) );
|
||||||
assertSame( decls[1], col.getName(5) );
|
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 {
|
public void test86371() throws Exception {
|
||||||
|
@ -2368,17 +2394,28 @@ public class AST2CPPTests extends AST2BaseTest {
|
||||||
CPPNameCollector col = new CPPNameCollector();
|
CPPNameCollector col = new CPPNameCollector();
|
||||||
tu.accept(col);
|
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 g_ref = (IFunction) col.getName(15).resolveBinding();
|
||||||
|
|
||||||
IFunction f = (IFunction) col.getName(1).resolveBinding();
|
ICPPFunction f = (ICPPFunction) col.getName(1).resolveBinding();
|
||||||
assertSame( f_ref, f );
|
assertSame( ((ICPPDelegate)f_ref).getBinding(), f );
|
||||||
|
|
||||||
IFunction g = (IFunction) col.getName(13).resolveBinding();
|
IFunction g = (IFunction) col.getName(13).resolveBinding();
|
||||||
assertSame( g, g_ref );
|
assertSame( g, g_ref );
|
||||||
|
|
||||||
assertInstances( col, f_ref, 4 );
|
assertInstances( col, f_ref, 1 );
|
||||||
assertInstances( col, g_ref, 2 );
|
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 {
|
public void testBug86369() throws Exception {
|
||||||
|
@ -2393,17 +2430,34 @@ public class AST2CPPTests extends AST2BaseTest {
|
||||||
tu.accept(col);
|
tu.accept(col);
|
||||||
|
|
||||||
ICPPNamespace ns = (ICPPNamespace) col.getName(0).resolveBinding();
|
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 );
|
IASTName [] refs = tu.getReferences( ns );
|
||||||
assertEquals( refs.length, 3 );
|
assertEquals( refs.length, 2 );
|
||||||
assertSame( refs[0], col.getName(2) );
|
assertSame( refs[0], col.getName(2) );
|
||||||
assertSame( refs[1], col.getName(4) );
|
assertSame( refs[1], col.getName(4) );
|
||||||
assertSame( refs[2], col.getName(6) );
|
|
||||||
IASTName [] decls = tu.getDeclarations( ns );
|
IASTName [] decls = tu.getDeclarations( ns );
|
||||||
assertEquals( decls.length, 4 );
|
assertEquals( decls.length, 1 );
|
||||||
assertSame( decls[0], col.getName(0) );
|
assertSame( decls[0], col.getName(0) );
|
||||||
assertSame( decls[1], col.getName(1) );
|
|
||||||
assertSame( decls[2], col.getName(3) );
|
refs = tu.getReferences( alias );
|
||||||
assertSame( decls[3], col.getName(5) );
|
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 {
|
public void testBug86470_1() throws Exception {
|
||||||
|
@ -2418,11 +2472,23 @@ public class AST2CPPTests extends AST2BaseTest {
|
||||||
CPPNameCollector col = new CPPNameCollector();
|
CPPNameCollector col = new CPPNameCollector();
|
||||||
tu.accept(col);
|
tu.accept(col);
|
||||||
|
|
||||||
IBinding b = col.getName(7).resolveBinding();
|
ICPPUsingDeclaration u = (ICPPUsingDeclaration) col.getName(7).resolveBinding();
|
||||||
IASTName [] decls = tu.getDeclarations( b );
|
|
||||||
|
IASTName [] decls = tu.getDeclarations( u );
|
||||||
assertEquals( decls.length, 2 );
|
assertEquals( decls.length, 2 );
|
||||||
assertSame( decls[0], col.getName(1) );
|
assertSame( decls[0], col.getName(1) );
|
||||||
assertSame( decls[1], col.getName(3) );
|
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 {
|
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_decl = (IFunction) col.getName(10).resolveBinding();
|
||||||
IFunction f_ref = (IFunction) col.getName(19).resolveBinding();
|
IFunction f_ref = (IFunction) col.getName(19).resolveBinding();
|
||||||
|
assertTrue( f_ref instanceof ICPPDelegate );
|
||||||
assertSame( f_decl, f_ref );
|
assertSame( f_decl, ((ICPPDelegate)f_ref).getBinding() );
|
||||||
}
|
}
|
||||||
|
|
||||||
public void testBug86470_3() throws Exception {
|
public void testBug86470_3() throws Exception {
|
||||||
|
@ -2471,13 +2537,16 @@ public class AST2CPPTests extends AST2BaseTest {
|
||||||
IBinding ref1 = col.getName(8).resolveBinding();
|
IBinding ref1 = col.getName(8).resolveBinding();
|
||||||
IBinding ref2 = col.getName(9).resolveBinding();
|
IBinding ref2 = col.getName(9).resolveBinding();
|
||||||
|
|
||||||
|
assertTrue( ref1 instanceof ICPPDelegate );
|
||||||
|
assertTrue( ref2 instanceof ICPPDelegate );
|
||||||
|
|
||||||
ICPPClassType g_struct = (ICPPClassType) col.getName(1).resolveBinding();
|
ICPPClassType g_struct = (ICPPClassType) col.getName(1).resolveBinding();
|
||||||
IFunction g_func = (IFunction) col.getName(2).resolveBinding();
|
IFunction g_func = (IFunction) col.getName(2).resolveBinding();
|
||||||
|
|
||||||
assertSame( g_struct, ref2 );
|
assertSame( g_struct, ((ICPPDelegate)ref2).getBinding() );
|
||||||
assertSame( g_func, ref1 );
|
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);
|
IASTName [] decls = tu.getDeclarations(comp);
|
||||||
assertEquals( decls.length, 2 );
|
assertEquals( decls.length, 2 );
|
||||||
assertSame( decls[0], col.getName(1) );
|
assertSame( decls[0], col.getName(1) );
|
||||||
|
@ -2503,14 +2572,29 @@ public class AST2CPPTests extends AST2BaseTest {
|
||||||
CPPNameCollector col = new CPPNameCollector();
|
CPPNameCollector col = new CPPNameCollector();
|
||||||
tu.accept(col);
|
tu.accept(col);
|
||||||
|
|
||||||
IBinding ref1 = col.getName(11).resolveBinding();
|
ICPPBinding ref1 = (ICPPBinding) col.getName(11).resolveBinding();
|
||||||
IBinding ref2 = col.getName(12).resolveBinding();
|
ICPPBinding ref2 = (ICPPBinding) col.getName(12).resolveBinding();
|
||||||
|
|
||||||
ICPPClassType x_struct = (ICPPClassType) col.getName(3).resolveBinding();
|
ICPPClassType x_struct = (ICPPClassType) col.getName(3).resolveBinding();
|
||||||
IVariable x_var = (IVariable) col.getName(1).resolveBinding();
|
IVariable x_var = (IVariable) col.getName(1).resolveBinding();
|
||||||
|
|
||||||
assertSame( x_struct, ref2 );
|
assertTrue( ref1 instanceof ICPPDelegate );
|
||||||
assertSame( x_var, ref1 );
|
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 {
|
public void testBug86470_5() throws Exception {
|
||||||
|
@ -2529,9 +2613,20 @@ public class AST2CPPTests extends AST2BaseTest {
|
||||||
CPPNameCollector col = new CPPNameCollector();
|
CPPNameCollector col = new CPPNameCollector();
|
||||||
tu.accept(col);
|
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 {
|
public void testBug86678 () throws Exception {
|
||||||
|
@ -2592,6 +2687,10 @@ public class AST2CPPTests extends AST2BaseTest {
|
||||||
IParameter b = (IParameter) col.getName(2).resolveBinding();
|
IParameter b = (IParameter) col.getName(2).resolveBinding();
|
||||||
IParameter c = (IParameter) col.getName(3).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, m, 3 );
|
||||||
assertInstances( col, a, 3 );
|
assertInstances( col, a, 3 );
|
||||||
assertInstances( col, b, 3 );
|
assertInstances( col, b, 3 );
|
||||||
|
@ -2609,9 +2708,18 @@ public class AST2CPPTests extends AST2BaseTest {
|
||||||
CPPNameCollector col = new CPPNameCollector();
|
CPPNameCollector col = new CPPNameCollector();
|
||||||
tu.accept(col);
|
tu.accept(col);
|
||||||
|
|
||||||
IFunction g1 = (IFunction) col.getName(0).resolveBinding();
|
ICPPFunction g1 = (ICPPFunction) col.getName(0).resolveBinding();
|
||||||
ICPPMethod g2 = (ICPPMethod) col.getName(9).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, g1, 1 );
|
||||||
assertInstances( col, g2, 2 );
|
assertInstances( col, g2, 2 );
|
||||||
}
|
}
|
||||||
|
@ -2642,6 +2750,16 @@ public class AST2CPPTests extends AST2BaseTest {
|
||||||
ICPPField x = (ICPPField) col.getName(23).resolveBinding();
|
ICPPField x = (ICPPField) col.getName(23).resolveBinding();
|
||||||
ICPPMethod f = (ICPPMethod) col.getName(24).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 y = (IProblemBinding) col.getName(25).resolveBinding();
|
||||||
IProblemBinding g = (IProblemBinding) col.getName(26).resolveBinding();
|
IProblemBinding g = (IProblemBinding) col.getName(26).resolveBinding();
|
||||||
|
|
||||||
|
@ -2663,7 +2781,13 @@ public class AST2CPPTests extends AST2BaseTest {
|
||||||
CPPNameCollector col = new CPPNameCollector();
|
CPPNameCollector col = new CPPNameCollector();
|
||||||
tu.accept(col);
|
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 );
|
IASTName [] refs = tu.getReferences( c );
|
||||||
assertEquals( refs.length, 1 );
|
assertEquals( refs.length, 1 );
|
||||||
|
@ -2683,8 +2807,16 @@ public class AST2CPPTests extends AST2BaseTest {
|
||||||
CPPNameCollector col = new CPPNameCollector();
|
CPPNameCollector col = new CPPNameCollector();
|
||||||
tu.accept(col);
|
tu.accept(col);
|
||||||
|
|
||||||
IVariable v1 = (IVariable) col.getName(2).resolveBinding();
|
ICPPVariable v1 = (ICPPVariable) col.getName(2).resolveBinding();
|
||||||
IVariable v2 = (IVariable) col.getName(3).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();
|
ICPPBlockScope scope = (ICPPBlockScope) v2.getScope();
|
||||||
IBinding [] bs = scope.find( "v1" ); //$NON-NLS-1$
|
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$
|
IBinding [] bs = scope.find( "f" ); //$NON-NLS-1$
|
||||||
assertEquals( bs.length, 3 );
|
assertEquals( bs.length, 3 );
|
||||||
assertSame( bs[0], f3 );
|
assertSame( bs[0], f3 );
|
||||||
assertSame( bs[1], f1 );
|
assertSame( ((ICPPDelegate)bs[1]).getBinding(), f1 );
|
||||||
assertSame( bs[2], f2 );
|
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 {
|
public void testFind_4() throws Exception {
|
||||||
|
@ -2882,5 +3026,35 @@ public class AST2CPPTests extends AST2BaseTest {
|
||||||
IProblemBinding C = (IProblemBinding) col.getName(3).resolveBinding();
|
IProblemBinding C = (IProblemBinding) col.getName(3).resolveBinding();
|
||||||
assertEquals( C.getID(), IProblemBinding.SEMANTIC_BAD_SCOPE );
|
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.ICPPBase;
|
||||||
import org.eclipse.cdt.core.dom.ast.cpp.ICPPClassType;
|
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.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.ICPPField;
|
||||||
import org.eclipse.cdt.core.dom.ast.cpp.ICPPMember;
|
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.ICPPMethod;
|
||||||
import org.eclipse.cdt.core.dom.ast.cpp.ICPPNamespace;
|
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.ICPPReferenceType;
|
||||||
|
import org.eclipse.cdt.core.dom.ast.cpp.ICPPUsingDeclaration;
|
||||||
import org.eclipse.cdt.core.parser.CodeReader;
|
import org.eclipse.cdt.core.parser.CodeReader;
|
||||||
import org.eclipse.cdt.core.parser.IScanner;
|
import org.eclipse.cdt.core.parser.IScanner;
|
||||||
import org.eclipse.cdt.core.parser.NullLogService;
|
import org.eclipse.cdt.core.parser.NullLogService;
|
||||||
|
@ -380,7 +382,11 @@ public class CompleteParser2Tests extends TestCase {
|
||||||
|
|
||||||
public void testUsingClauses() throws Exception
|
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();
|
CPPNameCollector col = new CPPNameCollector();
|
||||||
tu.accept( col );
|
tu.accept( col );
|
||||||
|
|
||||||
|
@ -391,11 +397,20 @@ public class CompleteParser2Tests extends TestCase {
|
||||||
ICPPClassType C = (ICPPClassType) col.getName(3).resolveBinding();
|
ICPPClassType C = (ICPPClassType) col.getName(3).resolveBinding();
|
||||||
ICPPField y = (ICPPField) col.getName(4).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, A, 5 );
|
||||||
assertInstances( col, B, 6 );
|
assertInstances( col, B, 6 );
|
||||||
assertInstances( col, x, 3 );
|
assertInstances( col, x, 1 );
|
||||||
assertInstances( col, C, 4 );
|
assertInstances( col, C, 2 );
|
||||||
assertInstances( col, y, 3 );
|
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
|
public void testEnumerations() throws Exception
|
||||||
|
@ -506,10 +521,16 @@ public class CompleteParser2Tests extends TestCase {
|
||||||
ICPPClassType A = (ICPPClassType) col.getName(3).resolveBinding();
|
ICPPClassType A = (ICPPClassType) col.getName(3).resolveBinding();
|
||||||
ICPPMethod bar = (ICPPMethod) col.getName(4).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, N, 2 );
|
||||||
assertInstances( col, foo, 3 );
|
assertInstances( col, foo, 1 );
|
||||||
assertInstances( col, A, 2 );
|
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
|
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
|
* @author Doug Schaefer
|
||||||
*/
|
*/
|
||||||
public interface ICPPClassType extends ICompositeType {
|
public interface ICPPClassType extends ICompositeType, ICPPBinding {
|
||||||
|
|
||||||
public static final int k_class = ICPPASTCompositeTypeSpecifier.k_class;
|
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
|
* @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;
|
package org.eclipse.cdt.core.dom.ast.cpp;
|
||||||
|
|
||||||
import org.eclipse.cdt.core.dom.ast.IFunction;
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @author Doug Schaefer
|
* @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;
|
package org.eclipse.cdt.core.dom.ast.cpp;
|
||||||
|
|
||||||
import org.eclipse.cdt.core.dom.ast.DOMException;
|
import org.eclipse.cdt.core.dom.ast.DOMException;
|
||||||
import org.eclipse.cdt.core.dom.ast.IBinding;
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* This interface represents a C++ namespace
|
* This interface represents a C++ namespace
|
||||||
*
|
*
|
||||||
* @author aniefer
|
* @author aniefer
|
||||||
*/
|
*/
|
||||||
public interface ICPPNamespace extends IBinding {
|
public interface ICPPNamespace extends ICPPBinding {
|
||||||
/**
|
/**
|
||||||
* get the scope object associated with this namespace
|
* 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 {
|
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
|
* 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:
|
* Contributors:
|
||||||
* IBM Corporation - initial API and implementation
|
* IBM Corporation - initial API and implementation
|
||||||
*******************************************************************************/
|
*******************************************************************************/
|
||||||
|
|
||||||
/*
|
/*
|
||||||
* Created on Dec 16, 2004
|
* Created on Mar 15, 2005
|
||||||
*/
|
*/
|
||||||
package org.eclipse.cdt.core.dom.ast.cpp;
|
package org.eclipse.cdt.core.dom.ast.cpp;
|
||||||
|
|
||||||
import org.eclipse.cdt.core.dom.ast.DOMException;
|
import org.eclipse.cdt.core.dom.ast.IVariable;
|
||||||
import org.eclipse.cdt.core.dom.ast.IBinding;
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* 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
|
* @author aniefer
|
||||||
*/
|
*/
|
||||||
public interface ICPPCompositeBinding extends IBinding {
|
public interface ICPPVariable extends IVariable, ICPPBinding {
|
||||||
/**
|
|
||||||
* get the bindings
|
|
||||||
*
|
|
||||||
* @return
|
|
||||||
* @throws DOMException
|
|
||||||
*/
|
|
||||||
IBinding[] getBindings() throws DOMException;
|
|
||||||
}
|
}
|
|
@ -13,6 +13,10 @@
|
||||||
*/
|
*/
|
||||||
package org.eclipse.cdt.internal.core.dom.parser.cpp;
|
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.IASTNode;
|
||||||
import org.eclipse.cdt.core.dom.ast.cpp.ICPPBlockScope;
|
import org.eclipse.cdt.core.dom.ast.cpp.ICPPBlockScope;
|
||||||
|
|
||||||
|
@ -23,4 +27,12 @@ public class CPPBlockScope extends CPPNamespaceScope implements ICPPBlockScope {
|
||||||
public CPPBlockScope( IASTNode physicalNode ){
|
public CPPBlockScope( IASTNode physicalNode ){
|
||||||
super( 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 ) };
|
implicits = new ICPPMethod[] { new CPPMethod.CPPMethodProblem( IProblemBinding.SEMANTIC_INVALID_TYPE, CPPSemantics.EMPTY_NAME_ARRAY ) };
|
||||||
return implicits;
|
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.ICPPASTQualifiedName;
|
||||||
import org.eclipse.cdt.core.dom.ast.cpp.ICPPASTUsingDeclaration;
|
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.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.ICPPClassScope;
|
||||||
import org.eclipse.cdt.core.dom.ast.cpp.ICPPClassType;
|
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.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.ICPPField;
|
||||||
import org.eclipse.cdt.core.dom.ast.cpp.ICPPFunctionScope;
|
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.ICPPMethod;
|
||||||
import org.eclipse.cdt.core.dom.ast.cpp.ICPPScope;
|
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.cpp.ICPPASTCompositeTypeSpecifier.ICPPASTBaseSpecifier;
|
||||||
import org.eclipse.cdt.core.parser.util.ArrayUtil;
|
import org.eclipse.cdt.core.parser.util.ArrayUtil;
|
||||||
import org.eclipse.cdt.core.parser.util.CharArrayUtils;
|
import org.eclipse.cdt.core.parser.util.CharArrayUtils;
|
||||||
|
@ -53,7 +55,48 @@ import org.eclipse.cdt.internal.core.dom.parser.ProblemBinding;
|
||||||
/**
|
/**
|
||||||
* @author aniefer
|
* @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 static class CPPClassTypeProblem extends ProblemBinding implements ICPPClassType{
|
||||||
public CPPClassTypeProblem( int id, char[] arg ) {
|
public CPPClassTypeProblem( int id, char[] arg ) {
|
||||||
super( id, arg );
|
super( id, arg );
|
||||||
|
@ -98,6 +141,15 @@ public class CPPClassType implements ICPPClassType, ICPPBinding {
|
||||||
public IBinding[] getFriends() throws DOMException {
|
public IBinding[] getFriends() throws DOMException {
|
||||||
throw new DOMException( this );
|
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;
|
private IASTName definition;
|
||||||
|
@ -357,8 +409,8 @@ public class CPPClassType implements ICPPClassType, ICPPBinding {
|
||||||
} else if( decls[i] instanceof ICPPASTUsingDeclaration ){
|
} else if( decls[i] instanceof ICPPASTUsingDeclaration ){
|
||||||
IASTName n = ((ICPPASTUsingDeclaration)decls[i]).getName();
|
IASTName n = ((ICPPASTUsingDeclaration)decls[i]).getName();
|
||||||
binding = n.resolveBinding();
|
binding = n.resolveBinding();
|
||||||
if( binding instanceof ICPPCompositeBinding ){
|
if( binding instanceof ICPPUsingDeclaration ){
|
||||||
IBinding [] bs = ((ICPPCompositeBinding)binding).getBindings();
|
IBinding [] bs = ((ICPPUsingDeclaration)binding).getDelegates();
|
||||||
for ( int j = 0; j < bs.length; j++ ) {
|
for ( int j = 0; j < bs.length; j++ ) {
|
||||||
if( bs[j] instanceof ICPPField )
|
if( bs[j] instanceof ICPPField )
|
||||||
result = (ICPPField[]) ArrayUtil.append( ICPPField.class, result, bs[j] );
|
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 ){
|
} else if( decls[i] instanceof ICPPASTUsingDeclaration ){
|
||||||
IASTName n = ((ICPPASTUsingDeclaration)decls[i]).getName();
|
IASTName n = ((ICPPASTUsingDeclaration)decls[i]).getName();
|
||||||
binding = n.resolveBinding();
|
binding = n.resolveBinding();
|
||||||
if( binding instanceof ICPPCompositeBinding ){
|
if( binding instanceof ICPPUsingDeclaration ){
|
||||||
IBinding [] bs = ((ICPPCompositeBinding)binding).getBindings();
|
IBinding [] bs = ((ICPPUsingDeclaration)binding).getDelegates();
|
||||||
for ( int j = 0; j < bs.length; j++ ) {
|
for ( int j = 0; j < bs.length; j++ ) {
|
||||||
if( bs[j] instanceof ICPPMethod )
|
if( bs[j] instanceof ICPPMethod )
|
||||||
result = (ICPPMethod[]) ArrayUtil.append( ICPPMethod.class, result, bs[j] );
|
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 );
|
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.IASTNode;
|
||||||
import org.eclipse.cdt.core.dom.ast.IBinding;
|
import org.eclipse.cdt.core.dom.ast.IBinding;
|
||||||
import org.eclipse.cdt.core.dom.ast.IScope;
|
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;
|
import org.eclipse.cdt.core.parser.util.ArrayUtil;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @author aniefer
|
* @author aniefer
|
||||||
*/
|
*/
|
||||||
public class CPPCompositeBinding implements ICPPCompositeBinding {
|
public class CPPCompositeBinding implements IBinding {
|
||||||
|
|
||||||
IBinding [] bindings = null;
|
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;
|
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.IASTEnumerationSpecifier;
|
||||||
import org.eclipse.cdt.core.dom.ast.IASTName;
|
import org.eclipse.cdt.core.dom.ast.IASTName;
|
||||||
import org.eclipse.cdt.core.dom.ast.IASTNode;
|
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.IEnumerator;
|
||||||
import org.eclipse.cdt.core.dom.ast.IScope;
|
import org.eclipse.cdt.core.dom.ast.IScope;
|
||||||
import org.eclipse.cdt.core.dom.ast.IType;
|
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
|
* @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;
|
private IASTName enumName;
|
||||||
/**
|
/**
|
||||||
* @param specifier
|
* @param specifier
|
||||||
|
@ -100,4 +116,37 @@ public class CPPEnumeration implements IEnumeration, ICPPBinding {
|
||||||
return bindings;
|
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;
|
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.IASTEnumerationSpecifier;
|
||||||
import org.eclipse.cdt.core.dom.ast.IASTName;
|
import org.eclipse.cdt.core.dom.ast.IASTName;
|
||||||
import org.eclipse.cdt.core.dom.ast.IASTNode;
|
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.IScope;
|
||||||
import org.eclipse.cdt.core.dom.ast.IType;
|
import org.eclipse.cdt.core.dom.ast.IType;
|
||||||
import org.eclipse.cdt.core.dom.ast.IASTEnumerationSpecifier.IASTEnumerator;
|
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
|
* @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;
|
private IASTName enumName;
|
||||||
/**
|
/**
|
||||||
* @param enumerator
|
* @param enumerator
|
||||||
|
@ -87,4 +100,39 @@ public class CPPEnumerator implements IEnumerator, ICPPBinding {
|
||||||
IEnumeration enumeration = (IEnumeration) enumSpec.getName().resolveBinding();
|
IEnumeration enumeration = (IEnumeration) enumSpec.getName().resolveBinding();
|
||||||
return enumeration;
|
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.DOMException;
|
||||||
import org.eclipse.cdt.core.dom.ast.IASTName;
|
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;
|
import org.eclipse.cdt.core.dom.ast.cpp.ICPPField;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @author aniefer
|
* @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 {
|
public static class CPPFieldProblem extends CPPVariable.CPPVariableProblem implements ICPPField {
|
||||||
/**
|
/**
|
||||||
* @param id
|
* @param id
|
||||||
|
@ -49,4 +58,11 @@ public class CPPField extends CPPVariable implements ICPPField, ICPPBinding {
|
||||||
// TODO Auto-generated method stub
|
// TODO Auto-generated method stub
|
||||||
return 0;
|
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.IASTStandardFunctionDeclarator;
|
||||||
import org.eclipse.cdt.core.dom.ast.IASTTranslationUnit;
|
import org.eclipse.cdt.core.dom.ast.IASTTranslationUnit;
|
||||||
import org.eclipse.cdt.core.dom.ast.IBinding;
|
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.IFunctionType;
|
||||||
import org.eclipse.cdt.core.dom.ast.IParameter;
|
import org.eclipse.cdt.core.dom.ast.IParameter;
|
||||||
import org.eclipse.cdt.core.dom.ast.IScope;
|
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.ICPPASTDeclSpecifier;
|
||||||
import org.eclipse.cdt.core.dom.ast.cpp.ICPPASTFunctionDeclarator;
|
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.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.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.core.parser.util.ArrayUtil;
|
||||||
import org.eclipse.cdt.internal.core.dom.parser.ProblemBinding;
|
import org.eclipse.cdt.internal.core.dom.parser.ProblemBinding;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @author aniefer
|
* @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 ) {
|
public CPPFunctionProblem( int id, char[] arg ) {
|
||||||
super( id, arg );
|
super( id, arg );
|
||||||
}
|
}
|
||||||
|
@ -61,6 +81,15 @@ public class CPPFunction implements IFunction, ICPPBinding {
|
||||||
public boolean isStatic() throws DOMException {
|
public boolean isStatic() throws DOMException {
|
||||||
throw new DOMException( this );
|
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;
|
protected ICPPASTFunctionDeclarator [] declarations;
|
||||||
|
@ -214,29 +243,35 @@ public class CPPFunction implements IFunction, ICPPBinding {
|
||||||
* @see org.eclipse.cdt.core.dom.ast.IBinding#getScope()
|
* @see org.eclipse.cdt.core.dom.ast.IBinding#getScope()
|
||||||
*/
|
*/
|
||||||
public IScope getScope() {
|
public IScope getScope() {
|
||||||
ICPPASTDeclSpecifier declSpec = null;
|
IASTName n = definition != null ? definition.getName() : declarations[0].getName();
|
||||||
if( definition != null ){
|
if( n instanceof ICPPASTQualifiedName ){
|
||||||
IASTNode node = definition.getParent();
|
IASTName [] ns = ((ICPPASTQualifiedName)n).getNames();
|
||||||
while( node instanceof IASTDeclarator )
|
n = ns[ ns.length - 1 ];
|
||||||
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( n );
|
||||||
IScope scope = CPPVisitor.getContainingScope( definition != null ? definition : declarations[0] );
|
if( scope instanceof ICPPClassScope ){
|
||||||
if( declSpec.isFriend() && scope instanceof ICPPClassScope ){
|
ICPPASTDeclSpecifier declSpec = null;
|
||||||
try {
|
if( definition != null ){
|
||||||
while( scope instanceof ICPPClassScope ){
|
IASTNode node = definition.getParent();
|
||||||
scope = scope.getParent();
|
while( node instanceof IASTDeclarator )
|
||||||
}
|
node = node.getParent();
|
||||||
} catch ( DOMException e ) {
|
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;
|
return scope;
|
||||||
}
|
}
|
||||||
|
@ -337,4 +372,39 @@ public class CPPFunction implements IFunction, ICPPBinding {
|
||||||
bits |= 2 << 2;
|
bits |= 2 << 2;
|
||||||
return false;
|
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.IBinding;
|
||||||
import org.eclipse.cdt.core.dom.ast.ILabel;
|
import org.eclipse.cdt.core.dom.ast.ILabel;
|
||||||
import org.eclipse.cdt.core.dom.ast.IScope;
|
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.ICPPASTQualifiedName;
|
||||||
import org.eclipse.cdt.core.dom.ast.cpp.ICPPClassType;
|
import org.eclipse.cdt.core.dom.ast.cpp.ICPPClassType;
|
||||||
import org.eclipse.cdt.core.dom.ast.cpp.ICPPFunctionScope;
|
import org.eclipse.cdt.core.dom.ast.cpp.ICPPFunctionScope;
|
||||||
|
@ -111,4 +112,15 @@ public class CPPFunctionScope extends CPPScope implements ICPPFunctionScope {
|
||||||
return null;
|
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.IASTNode;
|
||||||
import org.eclipse.cdt.core.dom.ast.ILabel;
|
import org.eclipse.cdt.core.dom.ast.ILabel;
|
||||||
import org.eclipse.cdt.core.dom.ast.IScope;
|
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
|
* @author aniefer
|
||||||
*/
|
*/
|
||||||
public class CPPLabel implements ILabel, ICPPBinding {
|
public class CPPLabel implements ILabel, ICPPInternalBinding, ICPPBinding {
|
||||||
private IASTName statement;
|
private IASTName statement;
|
||||||
/**
|
/**
|
||||||
* @param gotoStatement
|
* @param gotoStatement
|
||||||
|
@ -93,4 +95,34 @@ public class CPPLabel implements ILabel, ICPPBinding {
|
||||||
statement = labelStatement;
|
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.ICPPASTQualifiedName;
|
||||||
import org.eclipse.cdt.core.dom.ast.cpp.ICPPASTVisiblityLabel;
|
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.ICPPClassScope;
|
||||||
|
import org.eclipse.cdt.core.dom.ast.cpp.ICPPDelegate;
|
||||||
import org.eclipse.cdt.core.dom.ast.cpp.ICPPMethod;
|
import org.eclipse.cdt.core.dom.ast.cpp.ICPPMethod;
|
||||||
import org.eclipse.cdt.core.parser.util.CharArrayUtils;
|
import org.eclipse.cdt.core.parser.util.CharArrayUtils;
|
||||||
|
|
||||||
|
@ -33,6 +34,14 @@ import org.eclipse.cdt.core.parser.util.CharArrayUtils;
|
||||||
* @author aniefer
|
* @author aniefer
|
||||||
*/
|
*/
|
||||||
public class CPPMethod extends CPPFunction implements ICPPMethod {
|
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 {
|
public static class CPPMethodProblem extends CPPFunctionProblem implements ICPPMethod {
|
||||||
/**
|
/**
|
||||||
|
@ -145,24 +154,11 @@ public class CPPMethod extends CPPFunction implements ICPPMethod {
|
||||||
return declarations[0].getName().toCharArray();
|
return declarations[0].getName().toCharArray();
|
||||||
}
|
}
|
||||||
|
|
||||||
// /* (non-Javadoc)
|
/* (non-Javadoc)
|
||||||
// * @see org.eclipse.cdt.core.dom.ast.cpp.ICPPMember#isStatic()
|
* @see org.eclipse.cdt.internal.core.dom.parser.cpp.ICPPInternalBinding#createDelegate(org.eclipse.cdt.core.dom.ast.IASTName)
|
||||||
// */
|
*/
|
||||||
// public boolean isStatic() throws DOMException {
|
public ICPPDelegate createDelegate( IASTName name ) {
|
||||||
// IASTDeclarator dtor = (IASTDeclarator) getPrimaryDeclaration();
|
return new CPPMethodDelegate( name, this );
|
||||||
// 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;
|
|
||||||
// }
|
|
||||||
}
|
}
|
||||||
|
|
|
@ -18,6 +18,7 @@ import java.util.Collections;
|
||||||
import java.util.List;
|
import java.util.List;
|
||||||
|
|
||||||
import org.eclipse.cdt.core.dom.ast.ASTVisitor;
|
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.IASTDeclaration;
|
||||||
import org.eclipse.cdt.core.dom.ast.IASTName;
|
import org.eclipse.cdt.core.dom.ast.IASTName;
|
||||||
import org.eclipse.cdt.core.dom.ast.IASTNode;
|
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.ICPPASTLinkageSpecification;
|
||||||
import org.eclipse.cdt.core.dom.ast.cpp.ICPPASTNamespaceDefinition;
|
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.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.ICPPNamespace;
|
||||||
import org.eclipse.cdt.core.dom.ast.cpp.ICPPNamespaceScope;
|
import org.eclipse.cdt.core.dom.ast.cpp.ICPPNamespaceScope;
|
||||||
import org.eclipse.cdt.core.parser.util.CharArrayUtils;
|
import org.eclipse.cdt.core.parser.util.CharArrayUtils;
|
||||||
|
@ -33,7 +35,15 @@ import org.eclipse.cdt.core.parser.util.CharArrayUtils;
|
||||||
/**
|
/**
|
||||||
* @author aniefer
|
* @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 = { };
|
private static final char[] EMPTY_CHAR_ARRAY = { };
|
||||||
|
|
||||||
IASTName [] namespaceDefinitions = null;
|
IASTName [] namespaceDefinitions = null;
|
||||||
|
@ -164,4 +174,46 @@ public class CPPNamespace implements ICPPNamespace, ICPPBinding {
|
||||||
return ( tu != null ? (IASTNode) tu : namespaceDefinitions[0] );
|
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;
|
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.IASTNode;
|
||||||
|
import org.eclipse.cdt.core.dom.ast.cpp.ICPPASTNamespaceDefinition;
|
||||||
import org.eclipse.cdt.core.dom.ast.cpp.ICPPNamespaceScope;
|
import org.eclipse.cdt.core.dom.ast.cpp.ICPPNamespaceScope;
|
||||||
import org.eclipse.cdt.core.parser.util.ArrayUtil;
|
import org.eclipse.cdt.core.parser.util.ArrayUtil;
|
||||||
|
|
||||||
|
@ -39,4 +42,15 @@ public class CPPNamespaceScope extends CPPScope implements ICPPNamespaceScope{
|
||||||
public void addUsingDirective(IASTNode directive) {
|
public void addUsingDirective(IASTNode directive) {
|
||||||
usings = (IASTNode[]) ArrayUtil.append( IASTNode.class, usings, 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;
|
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.IASTDeclaration;
|
||||||
import org.eclipse.cdt.core.dom.ast.IASTDeclarator;
|
import org.eclipse.cdt.core.dom.ast.IASTDeclarator;
|
||||||
import org.eclipse.cdt.core.dom.ast.IASTFunctionDefinition;
|
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.IParameter;
|
||||||
import org.eclipse.cdt.core.dom.ast.IScope;
|
import org.eclipse.cdt.core.dom.ast.IScope;
|
||||||
import org.eclipse.cdt.core.dom.ast.IType;
|
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
|
* @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 IType type = null;
|
||||||
private IASTName [] declarations = null;
|
private IASTName [] declarations = null;
|
||||||
|
|
||||||
|
@ -136,4 +151,32 @@ public class CPPParameter implements IParameter, ICPPBinding {
|
||||||
return false;
|
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.IBinding;
|
||||||
import org.eclipse.cdt.core.dom.ast.IScope;
|
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.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.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.ArrayUtil;
|
||||||
import org.eclipse.cdt.core.parser.util.CharArrayObjectMap;
|
import org.eclipse.cdt.core.parser.util.CharArrayObjectMap;
|
||||||
import org.eclipse.cdt.core.parser.util.ObjectSet;
|
import org.eclipse.cdt.core.parser.util.ObjectSet;
|
||||||
|
@ -54,6 +54,9 @@ abstract public class CPPScope implements ICPPScope{
|
||||||
public boolean isFullyCached() {
|
public boolean isFullyCached() {
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
public IASTName getScopeName() throws DOMException {
|
||||||
|
throw new DOMException( this );
|
||||||
|
}
|
||||||
}
|
}
|
||||||
public static class CPPTemplateProblem extends CPPScopeProblem {
|
public static class CPPTemplateProblem extends CPPScopeProblem {
|
||||||
public CPPTemplateProblem(int id, char[] arg) {
|
public CPPTemplateProblem(int id, char[] arg) {
|
||||||
|
@ -136,8 +139,8 @@ abstract public class CPPScope implements ICPPScope{
|
||||||
}
|
}
|
||||||
binding = ((CPPASTName)n).getBinding();
|
binding = ((CPPASTName)n).getBinding();
|
||||||
}
|
}
|
||||||
if( binding instanceof ICPPCompositeBinding ){
|
if( binding instanceof ICPPUsingDeclaration ){
|
||||||
return CPPSemantics.resolveAmbiguities( name, ((ICPPCompositeBinding)binding).getBindings() );
|
return CPPSemantics.resolveAmbiguities( name, ((ICPPUsingDeclaration)binding).getDelegates() );
|
||||||
}
|
}
|
||||||
return binding;
|
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.ICPPBasicType;
|
||||||
import org.eclipse.cdt.core.dom.ast.cpp.ICPPClassScope;
|
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.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.ICPPConstructor;
|
||||||
import org.eclipse.cdt.core.dom.ast.cpp.ICPPMember;
|
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.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.ICPPPointerToMemberType;
|
||||||
import org.eclipse.cdt.core.dom.ast.cpp.ICPPReferenceType;
|
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.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.cpp.ICPPASTCompositeTypeSpecifier.ICPPASTBaseSpecifier;
|
||||||
import org.eclipse.cdt.core.parser.ast.IASTNamespaceDefinition;
|
import org.eclipse.cdt.core.parser.ast.IASTNamespaceDefinition;
|
||||||
import org.eclipse.cdt.core.parser.util.ArrayUtil;
|
import org.eclipse.cdt.core.parser.util.ArrayUtil;
|
||||||
|
@ -1267,8 +1267,8 @@ public class CPPSemantics {
|
||||||
if( node.getPropertyInParent() == STRING_LOOKUP_PROPERTY ) return true;
|
if( node.getPropertyInParent() == STRING_LOOKUP_PROPERTY ) return true;
|
||||||
|
|
||||||
ASTNode nd = null;
|
ASTNode nd = null;
|
||||||
if( obj instanceof ICPPBinding ){
|
if( obj instanceof ICPPInternalBinding ){
|
||||||
ICPPBinding cpp = (ICPPBinding) obj;
|
ICPPInternalBinding cpp = (ICPPInternalBinding) obj;
|
||||||
IASTNode[] n = cpp.getDeclarations();
|
IASTNode[] n = cpp.getDeclarations();
|
||||||
|
|
||||||
if( n != null && n.length > 0 )
|
if( n != null && n.length > 0 )
|
||||||
|
@ -1332,8 +1332,8 @@ public class CPPSemantics {
|
||||||
|
|
||||||
if( !( temp instanceof ICPPMember ) && !declaredBefore )
|
if( !( temp instanceof ICPPMember ) && !declaredBefore )
|
||||||
continue;
|
continue;
|
||||||
if( temp instanceof ICPPCompositeBinding ){
|
if( temp instanceof ICPPUsingDeclaration ){
|
||||||
IBinding [] bindings = ((ICPPCompositeBinding) temp).getBindings();
|
IBinding [] bindings = ((ICPPUsingDeclaration) temp).getDelegates();
|
||||||
mergeResults( data, bindings, false );
|
mergeResults( data, bindings, false );
|
||||||
items = (Object[]) data.foundItems;
|
items = (Object[]) data.foundItems;
|
||||||
continue;
|
continue;
|
||||||
|
@ -1357,17 +1357,16 @@ public class CPPSemantics {
|
||||||
IBinding [] bindings = null;
|
IBinding [] bindings = null;
|
||||||
if( obj != null ){
|
if( obj != null ){
|
||||||
if( fns != null ) return new ProblemBinding( IProblemBinding.SEMANTIC_AMBIGUOUS_LOOKUP, data.name );
|
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, obj );
|
||||||
bindings = (IBinding[]) ArrayUtil.append( IBinding.class, bindings, type );
|
bindings = (IBinding[]) ArrayUtil.append( IBinding.class, bindings, type );
|
||||||
} else {
|
} else {
|
||||||
if( fns == null ) return type;
|
// if( fns == null ) return type;
|
||||||
bindings = (IBinding[]) ArrayUtil.addAll( IBinding.class, bindings, fns );
|
|
||||||
bindings = (IBinding[]) ArrayUtil.append( IBinding.class, bindings, type );
|
bindings = (IBinding[]) ArrayUtil.append( IBinding.class, bindings, type );
|
||||||
|
bindings = (IBinding[]) ArrayUtil.addAll( IBinding.class, bindings, fns );
|
||||||
}
|
}
|
||||||
bindings = (IBinding[]) ArrayUtil.trim( IBinding.class, bindings );
|
bindings = (IBinding[]) ArrayUtil.trim( IBinding.class, bindings );
|
||||||
if( bindings.length == 1 ) return bindings[0];
|
ICPPUsingDeclaration composite = new CPPUsingDeclaration( data.astName, bindings );
|
||||||
ICPPCompositeBinding composite = new CPPCompositeBinding( bindings );
|
|
||||||
return composite;
|
return composite;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -1412,9 +1411,9 @@ public class CPPSemantics {
|
||||||
int size = functions.length;
|
int size = functions.length;
|
||||||
for( int i = 0; i < size && functions[i] != null; i++ ){
|
for( int i = 0; i < size && functions[i] != null; i++ ){
|
||||||
fName = (IFunction) functions[i];
|
fName = (IFunction) functions[i];
|
||||||
function = (ICPPASTFunctionDeclarator) ((ICPPBinding)fName).getDefinition();
|
function = (ICPPASTFunctionDeclarator) ((ICPPInternalBinding)fName).getDefinition();
|
||||||
if( function == null ){
|
if( function == null ){
|
||||||
IASTNode [] nodes = ((ICPPBinding) fName).getDeclarations();
|
IASTNode [] nodes = ((ICPPInternalBinding) fName).getDeclarations();
|
||||||
if( nodes != null && nodes.length > 0 )
|
if( nodes != null && nodes.length > 0 )
|
||||||
function = (ICPPASTFunctionDeclarator) nodes[0];
|
function = (ICPPASTFunctionDeclarator) nodes[0];
|
||||||
}
|
}
|
||||||
|
@ -1500,9 +1499,7 @@ public class CPPSemantics {
|
||||||
return null;
|
return null;
|
||||||
|
|
||||||
if( data.forUsingDeclaration() ){
|
if( data.forUsingDeclaration() ){
|
||||||
if( fns.length == 1 )
|
return new CPPUsingDeclaration( data.astName, fns );
|
||||||
return fns[ 0 ];
|
|
||||||
return new CPPCompositeBinding( fns );
|
|
||||||
}
|
}
|
||||||
|
|
||||||
//we don't have any arguments with which to resolve the function
|
//we don't have any arguments with which to resolve the function
|
||||||
|
@ -1547,9 +1544,9 @@ public class CPPSemantics {
|
||||||
if( currFn == null || bestFn == currFn )
|
if( currFn == null || bestFn == currFn )
|
||||||
continue;
|
continue;
|
||||||
|
|
||||||
ICPPASTFunctionDeclarator currDtor = (ICPPASTFunctionDeclarator) ((ICPPBinding)currFn).getDefinition();
|
ICPPASTFunctionDeclarator currDtor = (ICPPASTFunctionDeclarator) ((ICPPInternalBinding)currFn).getDefinition();
|
||||||
if( currDtor == null ){
|
if( currDtor == null ){
|
||||||
IASTNode[] nodes = ((ICPPBinding) currFn).getDeclarations();
|
IASTNode[] nodes = ((ICPPInternalBinding) currFn).getDeclarations();
|
||||||
if( nodes != null && nodes.length > 0 )
|
if( nodes != null && nodes.length > 0 )
|
||||||
currDtor = (ICPPASTFunctionDeclarator) nodes[0];
|
currDtor = (ICPPASTFunctionDeclarator) nodes[0];
|
||||||
}
|
}
|
||||||
|
@ -2023,7 +2020,7 @@ public class CPPSemantics {
|
||||||
|
|
||||||
static private boolean isCompleteType( IType type ){
|
static private boolean isCompleteType( IType type ){
|
||||||
type = getUltimateType( type, false );
|
type = getUltimateType( type, false );
|
||||||
if( type instanceof ICPPClassType && ((ICPPBinding)type).getDefinition() == null ){
|
if( type instanceof ICPPClassType && ((ICPPInternalBinding)type).getDefinition() == null ){
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
return true;
|
return true;
|
||||||
|
@ -2305,14 +2302,10 @@ public class CPPSemantics {
|
||||||
binding = null;
|
binding = null;
|
||||||
|
|
||||||
if( binding != null )
|
if( binding != null )
|
||||||
if( binding instanceof ICPPCompositeBinding ){
|
if( binding instanceof ICPPUsingDeclaration ){
|
||||||
try {
|
set.addAll( ((ICPPUsingDeclaration)binding).getDelegates() );
|
||||||
IBinding [] bs = ((ICPPCompositeBinding)binding).getBindings();
|
} else if( binding instanceof CPPCompositeBinding ){
|
||||||
for( int j = 0; j < bs.length; j++ ){
|
set.addAll( ((CPPCompositeBinding)binding).getBindings() );
|
||||||
set.put( bs[j] );
|
|
||||||
}
|
|
||||||
} catch ( DOMException e1 ) {
|
|
||||||
}
|
|
||||||
} else {
|
} else {
|
||||||
set.put( binding );
|
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.IScope;
|
||||||
import org.eclipse.cdt.core.dom.ast.IType;
|
import org.eclipse.cdt.core.dom.ast.IType;
|
||||||
import org.eclipse.cdt.core.dom.ast.ITypedef;
|
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;
|
import org.eclipse.cdt.internal.core.dom.parser.ITypeContainer;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @author aniefer
|
* @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 IASTName typedefName = null;
|
||||||
private IType type = null;
|
private IType type = null;
|
||||||
|
|
||||||
|
@ -125,4 +143,38 @@ public class CPPTypedef implements ITypedef, ITypeContainer, ICPPBinding {
|
||||||
}
|
}
|
||||||
return t;
|
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.IASTSimpleDeclaration;
|
||||||
import org.eclipse.cdt.core.dom.ast.IScope;
|
import org.eclipse.cdt.core.dom.ast.IScope;
|
||||||
import org.eclipse.cdt.core.dom.ast.IType;
|
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.ICPPASTCompositeTypeSpecifier;
|
||||||
import org.eclipse.cdt.core.dom.ast.cpp.ICPPASTQualifiedName;
|
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.core.parser.util.ArrayUtil;
|
||||||
import org.eclipse.cdt.internal.core.dom.parser.ProblemBinding;
|
import org.eclipse.cdt.internal.core.dom.parser.ProblemBinding;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @author aniefer
|
* @author aniefer
|
||||||
*/
|
*/
|
||||||
public class CPPVariable implements IVariable, ICPPBinding {
|
public class CPPVariable implements ICPPVariable, ICPPInternalBinding {
|
||||||
public static class CPPVariableProblem extends ProblemBinding implements IVariable{
|
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 ) {
|
public CPPVariableProblem( int id, char[] arg ) {
|
||||||
super( id, arg );
|
super( id, arg );
|
||||||
}
|
}
|
||||||
|
@ -43,6 +56,15 @@ public class CPPVariable implements IVariable, ICPPBinding {
|
||||||
public boolean isStatic() throws DOMException {
|
public boolean isStatic() throws DOMException {
|
||||||
throw new DOMException( this );
|
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 declarations[] = null;
|
||||||
private IASTName definition = null;
|
private IASTName definition = null;
|
||||||
|
@ -185,4 +207,39 @@ public class CPPVariable implements IVariable, ICPPBinding {
|
||||||
}
|
}
|
||||||
return false;
|
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.ICPPBlockScope;
|
||||||
import org.eclipse.cdt.core.dom.ast.cpp.ICPPClassScope;
|
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.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.ICPPFunctionScope;
|
||||||
import org.eclipse.cdt.core.dom.ast.cpp.ICPPMethod;
|
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.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.ICPPPointerToMemberType;
|
||||||
import org.eclipse.cdt.core.dom.ast.cpp.ICPPScope;
|
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.cpp.ICPPASTCompositeTypeSpecifier.ICPPASTBaseSpecifier;
|
||||||
import org.eclipse.cdt.core.dom.ast.gnu.cpp.IGPPASTPointer;
|
import org.eclipse.cdt.core.dom.ast.gnu.cpp.IGPPASTPointer;
|
||||||
import org.eclipse.cdt.core.dom.ast.gnu.cpp.IGPPASTPointerToMember;
|
import org.eclipse.cdt.core.dom.ast.gnu.cpp.IGPPASTPointerToMember;
|
||||||
|
@ -123,7 +125,8 @@ public class CPPVisitor {
|
||||||
if( parent instanceof IASTNamedTypeSpecifier ||
|
if( parent instanceof IASTNamedTypeSpecifier ||
|
||||||
parent instanceof ICPPASTQualifiedName ||
|
parent instanceof ICPPASTQualifiedName ||
|
||||||
parent instanceof ICPPASTBaseSpecifier ||
|
parent instanceof ICPPASTBaseSpecifier ||
|
||||||
parent instanceof ICPPASTConstructorChainInitializer )
|
parent instanceof ICPPASTConstructorChainInitializer ||
|
||||||
|
name.getPropertyInParent() == ICPPASTNamespaceAlias.MAPPING_NAME )
|
||||||
{
|
{
|
||||||
binding = CPPSemantics.resolveBinding( name );
|
binding = CPPSemantics.resolveBinding( name );
|
||||||
if( binding instanceof IProblemBinding && parent instanceof ICPPASTQualifiedName ){
|
if( binding instanceof IProblemBinding && parent instanceof ICPPASTQualifiedName ){
|
||||||
|
@ -345,8 +348,25 @@ public class CPPVisitor {
|
||||||
} else if( declaration instanceof ICPPASTUsingDirective ){
|
} else if( declaration instanceof ICPPASTUsingDirective ){
|
||||||
return CPPSemantics.resolveBinding( ((ICPPASTUsingDirective) declaration).getQualifiedName() );
|
return CPPSemantics.resolveBinding( ((ICPPASTUsingDirective) declaration).getQualifiedName() );
|
||||||
} else if( declaration instanceof ICPPASTNamespaceAlias ) {
|
} else if( declaration instanceof ICPPASTNamespaceAlias ) {
|
||||||
ICPPASTNamespaceAlias alias = (ICPPASTNamespaceAlias) declaration;
|
ICPPASTNamespaceAlias alias = (ICPPASTNamespaceAlias) declaration;
|
||||||
return CPPSemantics.resolveBinding( alias.getMappingName() );
|
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) {
|
else if( binding instanceof ICPPNamespace) {
|
||||||
kind = KIND_NAMESPACE;
|
kind = KIND_NAMESPACE;
|
||||||
}
|
}
|
||||||
else if( binding instanceof ICPPCompositeBinding )
|
else if( binding instanceof ICPPUsingDeclaration )
|
||||||
kind = KIND_COMPOSITE;
|
kind = KIND_COMPOSITE;
|
||||||
else
|
else
|
||||||
kind = KIND_OBJ_FN;
|
kind = KIND_OBJ_FN;
|
||||||
|
@ -836,7 +856,8 @@ public class CPPVisitor {
|
||||||
case KIND_TYPE:
|
case KIND_TYPE:
|
||||||
case KIND_COMPOSITE:
|
case KIND_COMPOSITE:
|
||||||
if( prop == IASTCompositeTypeSpecifier.TYPE_NAME ||
|
if( prop == IASTCompositeTypeSpecifier.TYPE_NAME ||
|
||||||
prop == IASTEnumerationSpecifier.ENUMERATION_NAME )
|
prop == IASTEnumerationSpecifier.ENUMERATION_NAME ||
|
||||||
|
prop == ICPPASTUsingDeclaration.NAME )
|
||||||
{
|
{
|
||||||
break;
|
break;
|
||||||
} else if( prop == IASTElaboratedTypeSpecifier.TYPE_NAME ){
|
} else if( prop == IASTElaboratedTypeSpecifier.TYPE_NAME ){
|
||||||
|
@ -859,7 +880,8 @@ public class CPPVisitor {
|
||||||
return PROCESS_CONTINUE;
|
return PROCESS_CONTINUE;
|
||||||
case KIND_OBJ_FN:
|
case KIND_OBJ_FN:
|
||||||
if( prop == IASTDeclarator.DECLARATOR_NAME ||
|
if( prop == IASTDeclarator.DECLARATOR_NAME ||
|
||||||
prop == IASTEnumerationSpecifier.IASTEnumerator.ENUMERATOR_NAME )
|
prop == IASTEnumerationSpecifier.IASTEnumerator.ENUMERATOR_NAME ||
|
||||||
|
prop == ICPPASTUsingDeclaration.NAME )
|
||||||
{
|
{
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
|
@ -875,25 +897,55 @@ public class CPPVisitor {
|
||||||
|
|
||||||
if( binding != null )
|
if( binding != null )
|
||||||
{
|
{
|
||||||
IBinding candidate = name.resolveBinding();
|
IBinding potential = name.resolveBinding();
|
||||||
|
IBinding [] bs = null;
|
||||||
boolean found = false;
|
IBinding candidate = null;
|
||||||
if( binding instanceof ICPPCompositeBinding ){
|
int n = -1;
|
||||||
try {
|
if( potential instanceof ICPPUsingDeclaration ){
|
||||||
found = ArrayUtil.contains( ((ICPPCompositeBinding)binding).getBindings(), candidate );
|
try {
|
||||||
|
bs = ((ICPPUsingDeclaration)potential).getDelegates();
|
||||||
} catch ( DOMException e ) {
|
} catch ( DOMException e ) {
|
||||||
|
return PROCESS_CONTINUE;
|
||||||
}
|
}
|
||||||
|
candidate = bs[ ++n ];
|
||||||
} else {
|
} else {
|
||||||
found = ( binding == candidate );
|
candidate = potential;
|
||||||
}
|
}
|
||||||
|
|
||||||
if( found ){
|
while( candidate != null ) {
|
||||||
if( decls.length == idx ){
|
boolean found = false;
|
||||||
IASTName [] temp = new IASTName[ decls.length * 2 ];
|
if( binding instanceof ICPPUsingDeclaration ){
|
||||||
System.arraycopy( decls, 0, temp, 0, decls.length );
|
ICPPDelegate [] delegates = null;
|
||||||
decls = temp;
|
try {
|
||||||
}
|
delegates = ((ICPPUsingDeclaration)binding).getDelegates();
|
||||||
decls[idx++] = name;
|
} 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;
|
return PROCESS_CONTINUE;
|
||||||
|
@ -937,7 +989,7 @@ public class CPPVisitor {
|
||||||
}
|
}
|
||||||
else if( binding instanceof ICPPNamespace) {
|
else if( binding instanceof ICPPNamespace) {
|
||||||
kind = KIND_NAMESPACE;
|
kind = KIND_NAMESPACE;
|
||||||
} else if( binding instanceof ICPPCompositeBinding )
|
} else if( binding instanceof ICPPUsingDeclaration )
|
||||||
kind = KIND_COMPOSITE;
|
kind = KIND_COMPOSITE;
|
||||||
else
|
else
|
||||||
kind = KIND_OBJ_FN;
|
kind = KIND_OBJ_FN;
|
||||||
|
@ -1009,9 +1061,9 @@ public class CPPVisitor {
|
||||||
IBinding [] bs = null;
|
IBinding [] bs = null;
|
||||||
IBinding candidate = null;
|
IBinding candidate = null;
|
||||||
int n = -1;
|
int n = -1;
|
||||||
if( potential instanceof ICPPCompositeBinding ){
|
if( potential instanceof ICPPUsingDeclaration ){
|
||||||
try {
|
try {
|
||||||
bs = ((ICPPCompositeBinding)potential).getBindings();
|
bs = ((ICPPUsingDeclaration)potential).getDelegates();
|
||||||
} catch ( DOMException e ) {
|
} catch ( DOMException e ) {
|
||||||
return PROCESS_CONTINUE;
|
return PROCESS_CONTINUE;
|
||||||
}
|
}
|
||||||
|
@ -1022,13 +1074,15 @@ public class CPPVisitor {
|
||||||
|
|
||||||
while( candidate != null ) {
|
while( candidate != null ) {
|
||||||
boolean found = false;
|
boolean found = false;
|
||||||
if( binding instanceof ICPPCompositeBinding ){
|
if( binding instanceof ICPPUsingDeclaration ){
|
||||||
try {
|
try {
|
||||||
found = ArrayUtil.contains( ((ICPPCompositeBinding)binding).getBindings(), candidate );
|
found = ArrayUtil.contains( ((ICPPUsingDeclaration)binding).getDelegates(), candidate );
|
||||||
} catch ( DOMException e ) {
|
} catch ( DOMException e ) {
|
||||||
}
|
}
|
||||||
|
} else if( potential instanceof ICPPUsingDeclaration ){
|
||||||
|
found = ( binding == ((ICPPDelegate)candidate).getBinding() );
|
||||||
} else {
|
} else {
|
||||||
found = ( binding == candidate );
|
found = (binding == candidate );
|
||||||
}
|
}
|
||||||
|
|
||||||
if( found ){
|
if( found ){
|
||||||
|
@ -1457,4 +1511,52 @@ public class CPPVisitor {
|
||||||
tu.accept( action );
|
tu.accept( action );
|
||||||
return action.getDeclarations();
|
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;
|
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.IASTNode;
|
||||||
|
import org.eclipse.cdt.core.dom.ast.cpp.ICPPDelegate;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @author aniefer
|
* @author aniefer
|
||||||
*/
|
*/
|
||||||
public interface ICPPBinding {
|
public interface ICPPInternalBinding {
|
||||||
//methods required by the CPPVisitor but not meant for the public interface
|
//methods required by the CPPVisitor but not meant for the public interface
|
||||||
|
|
||||||
IASTNode [] getDeclarations();
|
IASTNode [] getDeclarations();
|
||||||
IASTNode getDefinition();
|
IASTNode getDefinition();
|
||||||
|
|
||||||
|
ICPPDelegate createDelegate( IASTName name );
|
||||||
}
|
}
|
Loading…
Add table
Reference in a new issue