mirror of
https://github.com/eclipse-cdt/cdt
synced 2025-04-23 14:42:11 +02:00
Patch from Devin Steffler: fix bug 102258
This commit is contained in:
parent
66495196b7
commit
d94e967724
2 changed files with 34 additions and 2 deletions
|
@ -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;
|
||||
|
|
|
@ -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
|
||||
}
|
||||
|
|
Loading…
Add table
Reference in a new issue