Skip to main content
aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorAndrew Niefer2005-06-17 14:28:49 +0000
committerAndrew Niefer2005-06-17 14:28:49 +0000
commitfb5cd0f1574353599faccca082d41381c5f24ef8 (patch)
treee886ff390e07ba645dbb8ddb7a4b0fb8f7b3ca63
parent7ab54e4dad4bb7c4bf5c2ed6057a2eac8435f38c (diff)
downloadorg.eclipse.cdt-fb5cd0f1574353599faccca082d41381c5f24ef8.tar.gz
org.eclipse.cdt-fb5cd0f1574353599faccca082d41381c5f24ef8.tar.xz
org.eclipse.cdt-fb5cd0f1574353599faccca082d41381c5f24ef8.zip
patch from Devin Steffler for bug 100568
- also remove references to implementations of IASTName and use interfaces instead
-rw-r--r--core/org.eclipse.cdt.core/search/org/eclipse/cdt/core/search/DOMSearchUtil.java9
-rw-r--r--core/org.eclipse.cdt.ui.tests/ui/org/eclipse/cdt/ui/tests/text/selectiontests/CSelectionTestsCTagsIndexer.java62
-rw-r--r--core/org.eclipse.cdt.ui.tests/ui/org/eclipse/cdt/ui/tests/text/selectiontests/CSelectionTestsDOMIndexer.java50
3 files changed, 37 insertions, 84 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 5f6a3830218..dff4c5d4290 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
@@ -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());
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 3a1b14a1dd4..fa69637d88f 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
@@ -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
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 77fbee2e05c..b26eff155e7 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
@@ -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$

Back to the top