diff --git a/core/org.eclipse.cdt.ui.tests/ui/org/eclipse/cdt/ui/tests/text/selectiontests/CPPSelectionTestsCTagsIndexer.java b/core/org.eclipse.cdt.ui.tests/ui/org/eclipse/cdt/ui/tests/text/selectiontests/CPPSelectionTestsCTagsIndexer.java index 69fd35752f3..97cfca96482 100644 --- a/core/org.eclipse.cdt.ui.tests/ui/org/eclipse/cdt/ui/tests/text/selectiontests/CPPSelectionTestsCTagsIndexer.java +++ b/core/org.eclipse.cdt.ui.tests/ui/org/eclipse/cdt/ui/tests/text/selectiontests/CPPSelectionTestsCTagsIndexer.java @@ -120,6 +120,7 @@ public class CPPSelectionTestsCTagsIndexer extends BaseSelectionTestsIndexer public static Test suite() { TestSuite suite = new TestSuite(CPPSelectionTestsCTagsIndexer.class.getName()); + suite.addTest(new CPPSelectionTestsCTagsIndexer("testBug78354")); //$NON-NLS-1$ suite.addTest(new CPPSelectionTestsCTagsIndexer("testSimpleOpenDeclaration")); //$NON-NLS-1$ suite.addTest(new CPPSelectionTestsCTagsIndexer("testSimpleOpenDeclaration2")); //$NON-NLS-1$ suite.addTest(new CPPSelectionTestsCTagsIndexer("testBasicDefinition")); //$NON-NLS-1$ @@ -664,6 +665,28 @@ public class CPPSelectionTestsCTagsIndexer extends BaseSelectionTestsIndexer } } + public void testBug78354() throws Exception { + StringBuffer buffer = new StringBuffer(); + buffer.append("typedef int TestTypeOne;\n"); //$NON-NLS-1$ + buffer.append("typedef int TestTypeTwo;\n"); //$NON-NLS-1$ + buffer.append("main()\n"); //$NON-NLS-1$ + buffer.append("{\n"); //$NON-NLS-1$ + buffer.append("TestTypeOne myFirstLink = 5;\n"); //$NON-NLS-1$ + buffer.append("TestTypeTwo mySecondLink = 6;\n"); //$NON-NLS-1$ + buffer.append("return 0;\n"); //$NON-NLS-1$ + buffer.append("}\n"); //$NON-NLS-1$ + + String code = buffer.toString(); + IFile file = importFileWithLink("testBug78354.cpp", code); //$NON-NLS-1$ + + int offset = code.indexOf("TestTypeOne myFirstLink = 5;"); //$NON-NLS-1$ //$NON-NLS-2$ + IASTNode decl = testF3(file, offset); + assertTrue(decl instanceof IASTName); + assertEquals(((IASTName)decl).toString(), "TestTypeOne"); //$NON-NLS-1$ + assertEquals(((ASTNode)decl).getOffset(), 12); + assertEquals(((ASTNode)decl).getLength(), 11); + } + public void testBug103697() throws Exception { StringBuffer buffer = new StringBuffer(); buffer.append("int x;\n"); //$NON-NLS-1$ diff --git a/core/org.eclipse.cdt.ui.tests/ui/org/eclipse/cdt/ui/tests/text/selectiontests/CPPSelectionTestsDOMIndexer.java b/core/org.eclipse.cdt.ui.tests/ui/org/eclipse/cdt/ui/tests/text/selectiontests/CPPSelectionTestsDOMIndexer.java index 105f2f73728..ccacb3f7613 100644 --- a/core/org.eclipse.cdt.ui.tests/ui/org/eclipse/cdt/ui/tests/text/selectiontests/CPPSelectionTestsDOMIndexer.java +++ b/core/org.eclipse.cdt.ui.tests/ui/org/eclipse/cdt/ui/tests/text/selectiontests/CPPSelectionTestsDOMIndexer.java @@ -113,6 +113,7 @@ public class CPPSelectionTestsDOMIndexer extends BaseSelectionTestsIndexer imple public static Test suite() { TestSuite suite = new TestSuite(CPPSelectionTestsDOMIndexer.class.getName()); + suite.addTest(new CPPSelectionTestsDOMIndexer("testBug78354")); //$NON-NLS-1$ suite.addTest(new CPPSelectionTestsDOMIndexer("testBug93281")); //$NON-NLS-1$ suite.addTest(new CPPSelectionTestsDOMIndexer("testBasicDefinition")); //$NON-NLS-1$ suite.addTest(new CPPSelectionTestsDOMIndexer("testBug95224")); //$NON-NLS-1$ @@ -1071,6 +1072,28 @@ public class CPPSelectionTestsDOMIndexer extends BaseSelectionTestsIndexer imple } + public void testBug78354() throws Exception { + StringBuffer buffer = new StringBuffer(); + buffer.append("typedef int TestTypeOne;\n"); //$NON-NLS-1$ + buffer.append("typedef int TestTypeTwo;\n"); //$NON-NLS-1$ + buffer.append("main()\n"); //$NON-NLS-1$ + buffer.append("{\n"); //$NON-NLS-1$ + buffer.append("TestTypeOne myFirstLink = 5;\n"); //$NON-NLS-1$ + buffer.append("TestTypeTwo mySecondLink = 6;\n"); //$NON-NLS-1$ + buffer.append("return 0;\n"); //$NON-NLS-1$ + buffer.append("}\n"); //$NON-NLS-1$ + + String code = buffer.toString(); + IFile file = importFileWithLink("testBug78354.cpp", code); //$NON-NLS-1$ + + int offset = code.indexOf("TestTypeOne myFirstLink = 5;"); //$NON-NLS-1$ //$NON-NLS-2$ + IASTNode decl = testF3(file, offset); + assertTrue(decl instanceof IASTName); + assertEquals(((IASTName)decl).toString(), "TestTypeOne"); //$NON-NLS-1$ + assertEquals(((ASTNode)decl).getOffset(), 12); + assertEquals(((ASTNode)decl).getLength(), 11); + } + public void testBug103697() throws Exception { StringBuffer buffer = new StringBuffer(); buffer.append("int x;\n"); //$NON-NLS-1$ diff --git a/core/org.eclipse.cdt.ui.tests/ui/org/eclipse/cdt/ui/tests/text/selectiontests/CPPSelectionTestsNoIndexer.java b/core/org.eclipse.cdt.ui.tests/ui/org/eclipse/cdt/ui/tests/text/selectiontests/CPPSelectionTestsNoIndexer.java index b12a063fa36..498a8b2e44e 100644 --- a/core/org.eclipse.cdt.ui.tests/ui/org/eclipse/cdt/ui/tests/text/selectiontests/CPPSelectionTestsNoIndexer.java +++ b/core/org.eclipse.cdt.ui.tests/ui/org/eclipse/cdt/ui/tests/text/selectiontests/CPPSelectionTestsNoIndexer.java @@ -1130,6 +1130,28 @@ public class CPPSelectionTestsNoIndexer extends TestCase { assertEquals(((ASTNode)decl).getOffset(), 11); assertEquals(((ASTNode)decl).getLength(), 14); } + + public void testBug78354() throws Exception { + StringBuffer buffer = new StringBuffer(); + buffer.append("typedef int TestTypeOne;\n"); //$NON-NLS-1$ + buffer.append("typedef int TestTypeTwo;\n"); //$NON-NLS-1$ + buffer.append("main()\n"); //$NON-NLS-1$ + buffer.append("{\n"); //$NON-NLS-1$ + buffer.append("TestTypeOne myFirstLink = 5;\n"); //$NON-NLS-1$ + buffer.append("TestTypeTwo mySecondLink = 6;\n"); //$NON-NLS-1$ + buffer.append("return 0;\n"); //$NON-NLS-1$ + buffer.append("}\n"); //$NON-NLS-1$ + + String code = buffer.toString(); + IFile file = importFileWithLink("testBug78354.cpp", code); //$NON-NLS-1$ + + int offset = code.indexOf("TestTypeOne myFirstLink = 5;"); //$NON-NLS-1$ //$NON-NLS-2$ + IASTNode decl = testF3(file, offset); + assertTrue(decl instanceof IASTName); + assertEquals(((IASTName)decl).toString(), "TestTypeOne"); //$NON-NLS-1$ + assertEquals(((ASTNode)decl).getOffset(), 12); + assertEquals(((ASTNode)decl).getLength(), 11); + } public void testBug103697() throws Exception { StringBuffer buffer = new StringBuffer(); diff --git a/core/org.eclipse.cdt.ui.tests/ui/org/eclipse/cdt/ui/tests/text/selectiontests/CSelectionTestsCTagsIndexer.java b/core/org.eclipse.cdt.ui.tests/ui/org/eclipse/cdt/ui/tests/text/selectiontests/CSelectionTestsCTagsIndexer.java index 76405ad295c..baf1323e46c 100644 --- a/core/org.eclipse.cdt.ui.tests/ui/org/eclipse/cdt/ui/tests/text/selectiontests/CSelectionTestsCTagsIndexer.java +++ b/core/org.eclipse.cdt.ui.tests/ui/org/eclipse/cdt/ui/tests/text/selectiontests/CSelectionTestsCTagsIndexer.java @@ -113,6 +113,7 @@ public class CSelectionTestsCTagsIndexer extends BaseSelectionTestsIndexer public static Test suite() { TestSuite suite = new TestSuite(CSelectionTestsCTagsIndexer.class.getName()); + suite.addTest(new CSelectionTestsCTagsIndexer("testBug78354")); //$NON-NLS-1$ suite.addTest(new CSelectionTestsCTagsIndexer("testSimpleOpenDeclaration")); //$NON-NLS-1$ suite.addTest(new CSelectionTestsCTagsIndexer("testSimpleOpenDeclaration2")); //$NON-NLS-1$ suite.addTest(new CSelectionTestsCTagsIndexer("testBasicDefinition")); //$NON-NLS-1$ @@ -649,7 +650,29 @@ public class CSelectionTestsCTagsIndexer extends BaseSelectionTestsIndexer assertEquals(((TextSelection)decl).getLength(), "int abc;\n".length()); } } - + + public void testBug78354() throws Exception { + StringBuffer buffer = new StringBuffer(); + buffer.append("typedef int TestTypeOne;\n"); //$NON-NLS-1$ + buffer.append("typedef int TestTypeTwo;\n"); //$NON-NLS-1$ + buffer.append("main()\n"); //$NON-NLS-1$ + buffer.append("{\n"); //$NON-NLS-1$ + buffer.append("TestTypeOne myFirstLink = 5;\n"); //$NON-NLS-1$ + buffer.append("TestTypeTwo mySecondLink = 6;\n"); //$NON-NLS-1$ + buffer.append("return 0;\n"); //$NON-NLS-1$ + buffer.append("}\n"); //$NON-NLS-1$ + + String code = buffer.toString(); + IFile file = importFileWithLink("testBug78354.cpp", code); //$NON-NLS-1$ + + int offset = code.indexOf("TestTypeOne myFirstLink = 5;"); //$NON-NLS-1$ //$NON-NLS-2$ + IASTNode decl = testF3(file, offset); + assertTrue(decl instanceof IASTName); + assertEquals(((IASTName)decl).toString(), "TestTypeOne"); //$NON-NLS-1$ + assertEquals(((ASTNode)decl).getOffset(), 12); + assertEquals(((ASTNode)decl).getLength(), 11); + } + public void testBug103697() throws Exception { StringBuffer buffer = new StringBuffer(); buffer.append("int x;\n"); //$NON-NLS-1$ diff --git a/core/org.eclipse.cdt.ui.tests/ui/org/eclipse/cdt/ui/tests/text/selectiontests/CSelectionTestsDOMIndexer.java b/core/org.eclipse.cdt.ui.tests/ui/org/eclipse/cdt/ui/tests/text/selectiontests/CSelectionTestsDOMIndexer.java index d350ecd1c0c..30d1feebb6e 100644 --- a/core/org.eclipse.cdt.ui.tests/ui/org/eclipse/cdt/ui/tests/text/selectiontests/CSelectionTestsDOMIndexer.java +++ b/core/org.eclipse.cdt.ui.tests/ui/org/eclipse/cdt/ui/tests/text/selectiontests/CSelectionTestsDOMIndexer.java @@ -108,6 +108,7 @@ public class CSelectionTestsDOMIndexer extends BaseSelectionTestsIndexer impleme public static Test suite() { TestSuite suite = new TestSuite(CSelectionTestsDOMIndexer.class.getName()); + suite.addTest(new CSelectionTestsDOMIndexer("testBug78354")); //$NON-NLS-1$ suite.addTest(new CSelectionTestsDOMIndexer("testSimpleOpenDeclaration")); //$NON-NLS-1$ suite.addTest(new CSelectionTestsDOMIndexer("testSimpleOpenDeclaration2")); //$NON-NLS-1$ suite.addTest(new CSelectionTestsDOMIndexer("testBasicDefinition")); //$NON-NLS-1$ @@ -694,5 +695,27 @@ public class CSelectionTestsDOMIndexer extends BaseSelectionTestsIndexer impleme assertEquals(((ASTNode)decl).getLength(), 1); } + public void testBug78354() throws Exception { + StringBuffer buffer = new StringBuffer(); + buffer.append("typedef int TestTypeOne;\n"); //$NON-NLS-1$ + buffer.append("typedef int TestTypeTwo;\n"); //$NON-NLS-1$ + buffer.append("main()\n"); //$NON-NLS-1$ + buffer.append("{\n"); //$NON-NLS-1$ + buffer.append("TestTypeOne myFirstLink = 5;\n"); //$NON-NLS-1$ + buffer.append("TestTypeTwo mySecondLink = 6;\n"); //$NON-NLS-1$ + buffer.append("return 0;\n"); //$NON-NLS-1$ + buffer.append("}\n"); //$NON-NLS-1$ + + String code = buffer.toString(); + IFile file = importFileWithLink("testBug78354.cpp", code); //$NON-NLS-1$ + + int offset = code.indexOf("TestTypeOne myFirstLink = 5;"); //$NON-NLS-1$ //$NON-NLS-2$ + IASTNode decl = testF3(file, offset); + assertTrue(decl instanceof IASTName); + assertEquals(((IASTName)decl).toString(), "TestTypeOne"); //$NON-NLS-1$ + assertEquals(((ASTNode)decl).getOffset(), 12); + assertEquals(((ASTNode)decl).getLength(), 11); + } + // REMINDER: see CSelectionTestsDomIndexer#suite() when appending new tests to this suite } diff --git a/core/org.eclipse.cdt.ui.tests/ui/org/eclipse/cdt/ui/tests/text/selectiontests/CSelectionTestsNoIndexer.java b/core/org.eclipse.cdt.ui.tests/ui/org/eclipse/cdt/ui/tests/text/selectiontests/CSelectionTestsNoIndexer.java index 8d45f1b5a21..8dd5b756f6f 100644 --- a/core/org.eclipse.cdt.ui.tests/ui/org/eclipse/cdt/ui/tests/text/selectiontests/CSelectionTestsNoIndexer.java +++ b/core/org.eclipse.cdt.ui.tests/ui/org/eclipse/cdt/ui/tests/text/selectiontests/CSelectionTestsNoIndexer.java @@ -824,4 +824,26 @@ public class CSelectionTestsNoIndexer extends TestCase { assertEquals(((ASTNode)decl).getLength(), 1); } + public void testBug78354() throws Exception { + StringBuffer buffer = new StringBuffer(); + buffer.append("typedef int TestTypeOne;\n"); //$NON-NLS-1$ + buffer.append("typedef int TestTypeTwo;\n"); //$NON-NLS-1$ + buffer.append("main()\n"); //$NON-NLS-1$ + buffer.append("{\n"); //$NON-NLS-1$ + buffer.append("TestTypeOne myFirstLink = 5;\n"); //$NON-NLS-1$ + buffer.append("TestTypeTwo mySecondLink = 6;\n"); //$NON-NLS-1$ + buffer.append("return 0;\n"); //$NON-NLS-1$ + buffer.append("}\n"); //$NON-NLS-1$ + + String code = buffer.toString(); + IFile file = importFileWithLink("testBug78354.cpp", code); //$NON-NLS-1$ + + int offset = code.indexOf("TestTypeOne myFirstLink = 5;"); //$NON-NLS-1$ //$NON-NLS-2$ + IASTNode decl = testF3(file, offset); + assertTrue(decl instanceof IASTName); + assertEquals(((IASTName)decl).toString(), "TestTypeOne"); //$NON-NLS-1$ + assertEquals(((ASTNode)decl).getOffset(), 12); + assertEquals(((ASTNode)decl).getLength(), 11); + } + }