Skip to main content
aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorJohn Camelon2003-09-02 20:05:20 +0000
committerJohn Camelon2003-09-02 20:05:20 +0000
commit7ce8f5c91e399eee6671f83c4638ae8116a79d9e (patch)
treed2889bea714f60dc3d619814a1954436c78b4d31 /core/org.eclipse.cdt.core.tests
parent08ceac730e802e75155f443bebdc9e709a02d297 (diff)
downloadorg.eclipse.cdt-7ce8f5c91e399eee6671f83c4638ae8116a79d9e.tar.gz
org.eclipse.cdt-7ce8f5c91e399eee6671f83c4638ae8116a79d9e.tar.xz
org.eclipse.cdt-7ce8f5c91e399eee6671f83c4638ae8116a79d9e.zip
Patch for Andrew Niefer.
Added support to the parser symbol table for namespace aliases. tests: added ParserSymbolTableTest.testNamespaceAlias() added ParserSymbolTableTest.testUsingNamespaceAlias()
Diffstat (limited to 'core/org.eclipse.cdt.core.tests')
-rw-r--r--core/org.eclipse.cdt.core.tests/ChangeLog4
-rw-r--r--core/org.eclipse.cdt.core.tests/parser/org/eclipse/cdt/core/parser/tests/ParserSymbolTableTest.java74
2 files changed, 78 insertions, 0 deletions
diff --git a/core/org.eclipse.cdt.core.tests/ChangeLog b/core/org.eclipse.cdt.core.tests/ChangeLog
index 095b6259e35..75e757623e5 100644
--- a/core/org.eclipse.cdt.core.tests/ChangeLog
+++ b/core/org.eclipse.cdt.core.tests/ChangeLog
@@ -2,6 +2,10 @@
Modified CCompletionProposalsTest to complete on a body file
that includes a header file.
+2003-09-02 Andrew Niefer
+ added ParserSymbolTableTest.testNamespaceAlias()
+ added ParserSymbolTableTest.testUsingNamespaceAlias()
+
2003-08-28 Andrew Niefer
Modified BaseSearchTest.setup to properly include the "include.h" file
diff --git a/core/org.eclipse.cdt.core.tests/parser/org/eclipse/cdt/core/parser/tests/ParserSymbolTableTest.java b/core/org.eclipse.cdt.core.tests/parser/org/eclipse/cdt/core/parser/tests/ParserSymbolTableTest.java
index a82ffcec3e7..249b6b65244 100644
--- a/core/org.eclipse.cdt.core.tests/parser/org/eclipse/cdt/core/parser/tests/ParserSymbolTableTest.java
+++ b/core/org.eclipse.cdt.core.tests/parser/org/eclipse/cdt/core/parser/tests/ParserSymbolTableTest.java
@@ -2204,6 +2204,7 @@ public class ParserSymbolTableTest extends TestCase {
*
* @throws Exception
*/
+ //TODO
public void incompletetestTemplateSpecialization() throws Exception{
newTable();
@@ -2502,5 +2503,78 @@ public class ParserSymbolTableTest extends TestCase {
assertEquals( lookup, constructor2 );
}
+
+ /**
+ *
+ * @throws Exception
+ *
+ * namespace A
+ * {
+ * int x;
+ * }
+ * namespace B = A;
+ *
+ * ++B::x;
+ */
+ public void testNamespaceAlias() throws Exception{
+ newTable();
+
+ IContainerSymbol NSA = table.newContainerSymbol( "A", TypeInfo.t_namespace );
+ table.getCompilationUnit().addSymbol( NSA );
+
+ ISymbol x = table.newSymbol( "x", TypeInfo.t_int );
+ NSA.addSymbol( x );
+
+ IContainerSymbol NSB = table.newContainerSymbol( "B", TypeInfo.t_namespace );
+ NSB.setTypeSymbol( NSA ); //alias B to A
+
+ table.getCompilationUnit().addSymbol( NSB );
+
+ ISymbol lookup = table.getCompilationUnit().lookup( "B" );
+ assertEquals( lookup, NSB );
+
+ lookup = NSB.lookup( "x" );
+ assertEquals( lookup, x );
+ }
+
+ /**
+ *
+ * @throws Exception
+ * namespace A
+ * {
+ * void f( );
+ * }
+ * namespace B = A;
+ *
+ * B::f();
+ *
+ * using namespace B;
+ * f();
+ */
+ public void testUsingNamespaceAlias() throws Exception{
+ newTable();
+
+ IContainerSymbol NSA = table.newContainerSymbol( "A", TypeInfo.t_namespace );
+ table.getCompilationUnit().addSymbol( NSA );
+
+ IParameterizedSymbol f = table.newParameterizedSymbol( "f", TypeInfo.t_function );
+ f.setReturnType( table.newSymbol( "", TypeInfo.t_void ) );
+
+ NSA.addSymbol( f );
+
+ IContainerSymbol NSB = table.newContainerSymbol( "B", TypeInfo.t_namespace );
+ NSB.setTypeSymbol( NSA );
+ table.getCompilationUnit().addSymbol( NSB );
+
+ //look for function that has no parameters
+ LinkedList paramList = new LinkedList();
+ ISymbol look = NSB.qualifiedFunctionLookup( "f", paramList );
+ assertEquals( look, f );
+
+ table.getCompilationUnit().addUsingDirective( NSB );
+
+ look = table.getCompilationUnit().unqualifiedFunctionLookup( "f", paramList );
+ assertEquals( look, f );
+ }
}

Back to the top