mirror of
https://github.com/eclipse-cdt/cdt
synced 2025-04-29 19:45:01 +02:00
patch from Devin Steffler for bug 100568
- also remove references to implementations of IASTName and use interfaces instead
This commit is contained in:
parent
7ab54e4dad
commit
fb5cd0f157
3 changed files with 37 additions and 84 deletions
|
@ -37,6 +37,7 @@ import org.eclipse.cdt.core.dom.ast.IVariable;
|
|||
import org.eclipse.cdt.core.dom.ast.c.CASTVisitor;
|
||||
import org.eclipse.cdt.core.dom.ast.cpp.CPPASTVisitor;
|
||||
import org.eclipse.cdt.core.dom.ast.cpp.ICPPASTNamespaceDefinition;
|
||||
import org.eclipse.cdt.core.dom.ast.cpp.ICPPASTQualifiedName;
|
||||
import org.eclipse.cdt.core.dom.ast.cpp.ICPPBinding;
|
||||
import org.eclipse.cdt.core.dom.ast.cpp.ICPPClassScope;
|
||||
import org.eclipse.cdt.core.dom.ast.cpp.ICPPClassType;
|
||||
|
@ -50,8 +51,6 @@ import org.eclipse.cdt.core.parser.ParserLanguage;
|
|||
import org.eclipse.cdt.core.parser.util.ArrayUtil;
|
||||
import org.eclipse.cdt.core.search.ICSearchConstants.LimitTo;
|
||||
import org.eclipse.cdt.core.search.ICSearchConstants.SearchFor;
|
||||
import org.eclipse.cdt.internal.core.dom.parser.cpp.CPPASTName;
|
||||
import org.eclipse.cdt.internal.core.dom.parser.cpp.CPPASTQualifiedName;
|
||||
import org.eclipse.cdt.internal.core.index.domsourceindexer.IndexVisitorUtil;
|
||||
import org.eclipse.cdt.internal.core.search.matching.CSearchPattern;
|
||||
import org.eclipse.core.resources.IFile;
|
||||
|
@ -459,6 +458,8 @@ public class DOMSearchUtil {
|
|||
} catch (DOMException e) {
|
||||
buffer.append(name.toString());
|
||||
}
|
||||
} else {
|
||||
buffer.append(name.toString()); // if it's not an ICPPBinding then just use the name
|
||||
}
|
||||
}
|
||||
// second option - traverse the tree
|
||||
|
@ -483,8 +484,8 @@ public class DOMSearchUtil {
|
|||
}
|
||||
}
|
||||
|
||||
if (name instanceof CPPASTName && name.getParent() instanceof CPPASTQualifiedName) {
|
||||
IASTName[] names = ((CPPASTQualifiedName)name.getParent()).getNames();
|
||||
if (name.getParent() instanceof ICPPASTQualifiedName) {
|
||||
IASTName[] names = ((ICPPASTQualifiedName)name.getParent()).getNames();
|
||||
for(int i=0; i<names.length; i++) {
|
||||
if (i != 0) buffer.append("::"); //$NON-NLS-1$
|
||||
buffer.append(names[i].toString());
|
||||
|
|
|
@ -142,15 +142,11 @@ public class CSelectionTestsCTagsIndexer extends BaseSelectionTestsIndexer
|
|||
assertEquals(((TextSelection)def).getOffset(), header.indexOf("int x() { return 1; }\n"));
|
||||
assertEquals(((TextSelection)def).getLength(), "int x() { return 1; }\n".length());
|
||||
}
|
||||
try {
|
||||
// TODO raised bug 97079
|
||||
ISelection decl = testF3Selection(file, offset);
|
||||
if (decl instanceof TextSelection) {
|
||||
assertEquals(((TextSelection)decl).getOffset(), header.indexOf("int x() { return 1; }\n"));
|
||||
assertEquals(((TextSelection)decl).getLength(), "int x() { return 1; }\n".length());
|
||||
}
|
||||
assertFalse(true); // when this fails then the test is passing correctly
|
||||
} catch (AssertionFailedError afe) {}
|
||||
ISelection decl = testF3Selection(file, offset);
|
||||
if (decl instanceof TextSelection) {
|
||||
assertEquals(((TextSelection)decl).getOffset(), header.indexOf("int x() { return 1; }\n"));
|
||||
assertEquals(((TextSelection)decl).getLength(), "int x() { return 1; }\n".length());
|
||||
}
|
||||
}
|
||||
|
||||
public void testSimpleOpenDeclaration2() throws Exception {
|
||||
|
@ -165,15 +161,11 @@ public class CSelectionTestsCTagsIndexer extends BaseSelectionTestsIndexer
|
|||
assertEquals(((TextSelection)def).getOffset(), header.indexOf("int y() { return 1; }\r\n"));
|
||||
assertEquals(((TextSelection)def).getLength(), "int y() { return 1; }\r\n".length());
|
||||
}
|
||||
try {
|
||||
// TODO raised bug 97079
|
||||
ISelection decl = testF3Selection(file, offset);
|
||||
if (decl instanceof TextSelection) {
|
||||
assertEquals(((TextSelection)decl).getOffset(), header.indexOf("int y() { return 1; }\r\n"));
|
||||
assertEquals(((TextSelection)decl).getLength(), "int y() { return 1; }\r\n".length());
|
||||
}
|
||||
assertFalse(true); // when this fails then the test is passing correctly
|
||||
} catch (AssertionFailedError afe) {}
|
||||
ISelection decl = testF3Selection(file, offset);
|
||||
if (decl instanceof TextSelection) {
|
||||
assertEquals(((TextSelection)decl).getOffset(), header.indexOf("int y() { return 1; }\r\n"));
|
||||
assertEquals(((TextSelection)decl).getLength(), "int y() { return 1; }\r\n".length());
|
||||
}
|
||||
}
|
||||
|
||||
// perform the tests from CSelectionTestsNoIndexer and make sure they work with an indexer as well:
|
||||
|
@ -549,10 +541,7 @@ public class CSelectionTestsCTagsIndexer extends BaseSelectionTestsIndexer
|
|||
offset = code.indexOf("anotherX; // declares anotherX"); //$NON-NLS-1$
|
||||
def = testF2(file, offset);
|
||||
decl = testF3(file, offset);
|
||||
try {
|
||||
assertNull(def); // TODO raised bug 96689
|
||||
assertTrue(false); // try/catch/assertTrue(false) added to alert the tester when this test passes!
|
||||
} catch (AssertionFailedError e) {}
|
||||
assertNull(def);
|
||||
|
||||
assertTrue(decl instanceof IASTName);
|
||||
assertEquals(((IASTName)decl).toString(), "anotherX"); //$NON-NLS-1$
|
||||
|
@ -574,10 +563,7 @@ public class CSelectionTestsCTagsIndexer extends BaseSelectionTestsIndexer
|
|||
int offset = code.indexOf("a1; // declares a"); //$NON-NLS-1$
|
||||
IASTNode def = testF2(file, offset);
|
||||
IASTNode decl = testF3(file, offset);
|
||||
try {
|
||||
assertNull(def); // TODO raised bug 96689
|
||||
assertTrue(false); // try/catch/assertTrue(false) added to alert the tester when this test passes!
|
||||
} catch (AssertionFailedError e) {}
|
||||
assertNull(def);
|
||||
|
||||
assertTrue(decl instanceof IASTName);
|
||||
assertEquals(((IASTName)decl).toString(), "a1"); //$NON-NLS-1$
|
||||
|
@ -587,10 +573,7 @@ public class CSelectionTestsCTagsIndexer extends BaseSelectionTestsIndexer
|
|||
offset = code.indexOf("c1; // declares c"); //$NON-NLS-1$
|
||||
def = testF2(file, offset);
|
||||
decl = testF3(file, offset);
|
||||
try {
|
||||
assertNull(def); // TODO raised bug 96689
|
||||
assertTrue(false); // try/catch/assertTrue(false) added to alert the tester when this test passes!
|
||||
} catch (AssertionFailedError e) {}
|
||||
assertNull(def);
|
||||
assertTrue(decl instanceof IASTName);
|
||||
assertEquals(((IASTName)decl).toString(), "c1"); //$NON-NLS-1$
|
||||
assertEquals(((ASTNode)decl).getOffset(), 46);
|
||||
|
@ -608,10 +591,7 @@ public class CSelectionTestsCTagsIndexer extends BaseSelectionTestsIndexer
|
|||
offset = code.indexOf("S1; // declares S"); //$NON-NLS-1$
|
||||
def = testF2(file, offset);
|
||||
decl = testF3(file, offset);
|
||||
try {
|
||||
assertNull(def); // TODO raised bug 96690
|
||||
assertTrue(false); // try/catch/assertTrue(false) added to alert the tester when this test passes!
|
||||
} catch (AssertionFailedError e) {}
|
||||
assertNull(def);
|
||||
assertTrue(decl instanceof IASTName);
|
||||
assertEquals(((IASTName)decl).toString(), "S1"); //$NON-NLS-1$
|
||||
assertEquals(((ASTNode)decl).getOffset(), 98);
|
||||
|
@ -643,15 +623,11 @@ public class CSelectionTestsCTagsIndexer extends BaseSelectionTestsIndexer
|
|||
assertEquals(((TextSelection)def).getOffset(), header.indexOf(" int y() { return 1; } /* comment */ \r\n")); //$NON-NLS-1$
|
||||
assertEquals(((TextSelection)def).getLength(), " int y() { return 1; } /* comment */ \r\n".length()); //$NON-NLS-1$
|
||||
}
|
||||
try {
|
||||
// TODO raised bug 97079
|
||||
ISelection decl = testF3Selection(file, offset);
|
||||
if (decl instanceof TextSelection) {
|
||||
assertEquals(((TextSelection)decl).getOffset(), header.indexOf(" int y() { return 1; } /* comment */ \r\n"));
|
||||
assertEquals(((TextSelection)decl).getLength(), " int y() { return 1; } /* comment */ \r\n".length());
|
||||
}
|
||||
assertFalse(true); // when this fails then the test is passing correctly
|
||||
} catch (AssertionFailedError afe) {}
|
||||
ISelection decl = testF3Selection(file, offset);
|
||||
if (decl instanceof TextSelection) {
|
||||
assertEquals(((TextSelection)decl).getOffset(), header.indexOf(" int y() { return 1; } /* comment */ \r\n"));
|
||||
assertEquals(((TextSelection)decl).getLength(), " int y() { return 1; } /* comment */ \r\n".length());
|
||||
}
|
||||
}
|
||||
|
||||
// REMINDER: see CSelectionTestsCTagsIndexer#suite() when appending new tests to this suite
|
||||
|
|
|
@ -132,13 +132,9 @@ public class CSelectionTestsDOMIndexer extends BaseSelectionTestsIndexer impleme
|
|||
|
||||
int offset = code.indexOf("x();\n}\n");
|
||||
IASTNode def = testF2(file, offset);
|
||||
try {
|
||||
// TODO raised bug 97079
|
||||
assertTrue(def instanceof IASTName);
|
||||
assertEquals(((ASTNode)def).getOffset(), header.indexOf("x")); //$NON-NLS-1$
|
||||
assertEquals(((ASTNode)def).getLength(), "x".length()); //$NON-NLS-1$
|
||||
assertTrue(false); // when this fails then the test is passing correctly
|
||||
} catch (AssertionFailedError afe) {}
|
||||
assertTrue(def instanceof IASTName);
|
||||
assertEquals(((ASTNode)def).getOffset(), header.indexOf("x")); //$NON-NLS-1$
|
||||
assertEquals(((ASTNode)def).getLength(), "x".length()); //$NON-NLS-1$
|
||||
IASTNode decl = testF3(file, offset);
|
||||
assertTrue(decl instanceof IASTName);
|
||||
assertEquals(((ASTNode)decl).getOffset(), header.indexOf("x")); //$NON-NLS-1$
|
||||
|
@ -154,13 +150,9 @@ public class CSelectionTestsDOMIndexer extends BaseSelectionTestsIndexer impleme
|
|||
|
||||
int offset = code.indexOf("y();\n}\n");
|
||||
IASTNode def = testF2(file, offset);
|
||||
try {
|
||||
// TODO raised bug 97079
|
||||
assertTrue(def instanceof IASTName);
|
||||
assertEquals(((ASTNode)def).getOffset(), header.indexOf("y")); //$NON-NLS-1$
|
||||
assertEquals(((ASTNode)def).getLength(), "y".length()); //$NON-NLS-1$
|
||||
assertTrue(false); // when this fails then the test is passing correctly
|
||||
} catch (AssertionFailedError afe) {}
|
||||
assertTrue(def instanceof IASTName);
|
||||
assertEquals(((ASTNode)def).getOffset(), header.indexOf("y")); //$NON-NLS-1$
|
||||
assertEquals(((ASTNode)def).getLength(), "y".length()); //$NON-NLS-1$
|
||||
IASTNode decl = testF3(file, offset);
|
||||
assertTrue(decl instanceof IASTName);
|
||||
assertEquals(((ASTNode)decl).getOffset(), header.indexOf("y")); //$NON-NLS-1$
|
||||
|
@ -541,10 +533,7 @@ public class CSelectionTestsDOMIndexer extends BaseSelectionTestsIndexer impleme
|
|||
offset = code.indexOf("anotherX; // declares anotherX"); //$NON-NLS-1$
|
||||
def = testF2(file, offset);
|
||||
decl = testF3(file, offset);
|
||||
try {
|
||||
assertNull(def); // TODO raised bug 96689
|
||||
assertTrue(false); // try/catch/assertTrue(false) added to alert the tester when this test passes!
|
||||
} catch (AssertionFailedError e) {}
|
||||
assertNull(def);
|
||||
|
||||
assertTrue(decl instanceof IASTName);
|
||||
assertEquals(((IASTName)decl).toString(), "anotherX"); //$NON-NLS-1$
|
||||
|
@ -566,10 +555,7 @@ public class CSelectionTestsDOMIndexer extends BaseSelectionTestsIndexer impleme
|
|||
int offset = code.indexOf("a1; // declares a"); //$NON-NLS-1$
|
||||
IASTNode def = testF2(file, offset);
|
||||
IASTNode decl = testF3(file, offset);
|
||||
try {
|
||||
assertNull(def); // TODO raised bug 96689
|
||||
assertTrue(false); // try/catch/assertTrue(false) added to alert the tester when this test passes!
|
||||
} catch (AssertionFailedError e) {}
|
||||
assertNull(def);
|
||||
|
||||
assertTrue(decl instanceof IASTName);
|
||||
assertEquals(((IASTName)decl).toString(), "a1"); //$NON-NLS-1$
|
||||
|
@ -579,10 +565,7 @@ public class CSelectionTestsDOMIndexer extends BaseSelectionTestsIndexer impleme
|
|||
offset = code.indexOf("c1; // declares c"); //$NON-NLS-1$
|
||||
def = testF2(file, offset);
|
||||
decl = testF3(file, offset);
|
||||
try {
|
||||
assertNull(def); // TODO raised bug 96689
|
||||
assertTrue(false); // try/catch/assertTrue(false) added to alert the tester when this test passes!
|
||||
} catch (AssertionFailedError e) {}
|
||||
assertNull(def);
|
||||
assertTrue(decl instanceof IASTName);
|
||||
assertEquals(((IASTName)decl).toString(), "c1"); //$NON-NLS-1$
|
||||
assertEquals(((ASTNode)decl).getOffset(), 46);
|
||||
|
@ -600,10 +583,7 @@ public class CSelectionTestsDOMIndexer extends BaseSelectionTestsIndexer impleme
|
|||
offset = code.indexOf("S1; // declares S"); //$NON-NLS-1$
|
||||
def = testF2(file, offset);
|
||||
decl = testF3(file, offset);
|
||||
try {
|
||||
assertNull(def); // TODO raised bug 96690
|
||||
assertTrue(false); // try/catch/assertTrue(false) added to alert the tester when this test passes!
|
||||
} catch (AssertionFailedError e) {}
|
||||
assertNull(def);
|
||||
assertTrue(decl instanceof IASTName);
|
||||
assertEquals(((IASTName)decl).toString(), "S1"); //$NON-NLS-1$
|
||||
assertEquals(((ASTNode)decl).getOffset(), 98);
|
||||
|
@ -631,13 +611,9 @@ public class CSelectionTestsDOMIndexer extends BaseSelectionTestsIndexer impleme
|
|||
|
||||
int offset = code.indexOf("y();\n}\n");
|
||||
IASTNode def = testF2(file, offset);
|
||||
try {
|
||||
// TODO raised bug 97079
|
||||
assertTrue(def instanceof IASTName);
|
||||
assertEquals(((ASTNode)def).getOffset(), header.indexOf("y")); //$NON-NLS-1$
|
||||
assertEquals(((ASTNode)def).getLength(), "y".length()); //$NON-NLS-1$
|
||||
assertTrue(false); // when this fails then the test is passing correctly
|
||||
} catch (AssertionFailedError afe) {}
|
||||
assertTrue(def instanceof IASTName);
|
||||
assertEquals(((ASTNode)def).getOffset(), header.indexOf("y")); //$NON-NLS-1$
|
||||
assertEquals(((ASTNode)def).getLength(), "y".length()); //$NON-NLS-1$
|
||||
IASTNode decl = testF3(file, offset);
|
||||
assertTrue(decl instanceof IASTName);
|
||||
assertEquals(((ASTNode)decl).getOffset(), header.indexOf("y")); //$NON-NLS-1$
|
||||
|
|
Loading…
Add table
Reference in a new issue