diff options
author | Andrew Niefer | 2005-07-05 19:14:55 +0000 |
---|---|---|
committer | Andrew Niefer | 2005-07-05 19:14:55 +0000 |
commit | d94e967724da65483d66ca78dd3ce835eca488bf (patch) | |
tree | c473dd1639b477c3751273d64ddfdd9ea5de23eb | |
parent | 66495196b78924bc088950b42e85a166a4a7360d (diff) | |
download | org.eclipse.cdt-d94e967724da65483d66ca78dd3ce835eca488bf.tar.gz org.eclipse.cdt-d94e967724da65483d66ca78dd3ce835eca488bf.tar.xz org.eclipse.cdt-d94e967724da65483d66ca78dd3ce835eca488bf.zip |
Patch from Devin Steffler: fix bug 102258
2 files changed, 34 insertions, 2 deletions
diff --git a/core/org.eclipse.cdt.core/search/org/eclipse/cdt/core/search/DOMSearchUtil.java b/core/org.eclipse.cdt.core/search/org/eclipse/cdt/core/search/DOMSearchUtil.java index 89213b36f13..f5300a638aa 100644 --- a/core/org.eclipse.cdt.core/search/org/eclipse/cdt/core/search/DOMSearchUtil.java +++ b/core/org.eclipse.cdt.core/search/org/eclipse/cdt/core/search/DOMSearchUtil.java @@ -147,17 +147,19 @@ public class DOMSearchUtil { searchFor = ICSearchConstants.TYPEDEF; } else if (binding instanceof IVariable) { searchFor = ICSearchConstants.VAR; - } else if (binding instanceof ICPPClassType) { - searchFor = ICSearchConstants.CLASS; } else if (binding instanceof ICompositeType) { try { switch(((ICompositeType)binding).getKey()) { case ICompositeType.k_struct: + case ICPPClassType.k_class: searchFor = ICSearchConstants.CLASS_STRUCT; break; case ICompositeType.k_union: searchFor = ICSearchConstants.UNION; break; + default: + searchFor = ICSearchConstants.TYPE; + break; } } catch (DOMException e) { searchFor = ICSearchConstants.UNKNOWN_SEARCH_FOR; 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 551f5c39f47..fc37c40b8ee 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 @@ -125,6 +125,7 @@ public class CPPSelectionTestsDOMIndexer extends BaseSelectionTestsIndexer imple suite.addTest(new CPPSelectionTestsDOMIndexer("testBug95202")); //$NON-NLS-1$ suite.addTest(new CPPSelectionTestsDOMIndexer("testBug95229")); //$NON-NLS-1$ suite.addTest(new CPPSelectionTestsDOMIndexer("testBug101287")); //$NON-NLS-1$ + suite.addTest(new CPPSelectionTestsDOMIndexer("testBug102258")); //$NON-NLS-1$ return suite; } @@ -1016,6 +1017,35 @@ public class CPPSelectionTestsDOMIndexer extends BaseSelectionTestsIndexer imple assertEquals(((ASTNode)decl).getOffset(), 4); assertEquals(((ASTNode)decl).getLength(), 3); } + + public void testBug102258() throws Exception { + StringBuffer buffer = new StringBuffer(); + buffer.append("struct RTBindingEnd\n"); //$NON-NLS-1$ + buffer.append("{\n"); //$NON-NLS-1$ + buffer.append("int index;\n"); //$NON-NLS-1$ + buffer.append("};\n"); //$NON-NLS-1$ + + importFile("testBug102258.h", buffer.toString()); //$NON-NLS-1$ + + buffer = new StringBuffer(); + buffer.append("#include \"testBug102258.h\"\n"); //$NON-NLS-1$ + buffer.append("void f(RTBindingEnd & end) {\n"); //$NON-NLS-1$ + buffer.append("}\n"); //$NON-NLS-1$ + String code = buffer.toString(); + IFile file = importFile("testBug102258.cpp", code); //$NON-NLS-1$ + + int offset = code.indexOf("RTBindingEnd"); //$NON-NLS-1$ + IASTNode def = testCtrl_F3(file, offset); + IASTNode decl = testF3(file, offset); + assertTrue(decl instanceof IASTName); + assertEquals(((IASTName)decl).toString(), "RTBindingEnd"); //$NON-NLS-1$ + assertEquals(((ASTNode)decl).getOffset(), 7); + assertEquals(((ASTNode)decl).getLength(), 12); + assertTrue(decl instanceof IASTName); + assertEquals(((IASTName)decl).toString(), "RTBindingEnd"); //$NON-NLS-1$ + assertEquals(((ASTNode)decl).getOffset(), 7); + assertEquals(((ASTNode)decl).getLength(), 12); + } // REMINDER: see CPPSelectionTestsDomIndexer#suite() when appending new tests to this suite } |