Skip to main content
aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorAndrew Ferguson2007-10-26 10:16:39 +0000
committerAndrew Ferguson2007-10-26 10:16:39 +0000
commit4c5b83298095fb6f463d049f875ff747c8d22d1f (patch)
tree631d7392324abab3e5f4bf43cbbdfece735c5d30
parent75225aa7589076bba480a5403ccf8a18ecdc36d6 (diff)
downloadorg.eclipse.cdt-4c5b83298095fb6f463d049f875ff747c8d22d1f.tar.gz
org.eclipse.cdt-4c5b83298095fb6f463d049f875ff747c8d22d1f.tar.xz
org.eclipse.cdt-4c5b83298095fb6f463d049f875ff747c8d22d1f.zip
207320: apply fix, add regression tests
-rw-r--r--core/org.eclipse.cdt.core.tests/parser/org/eclipse/cdt/internal/index/tests/IndexCPPBindingResolutionBugs.java26
-rw-r--r--core/org.eclipse.cdt.ui.tests/ui/org/eclipse/cdt/ui/tests/text/selection/CPPSelectionTestsAnyIndexer.java37
-rw-r--r--core/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/search/actions/OpenDeclarationsAction.java11
3 files changed, 70 insertions, 4 deletions
diff --git a/core/org.eclipse.cdt.core.tests/parser/org/eclipse/cdt/internal/index/tests/IndexCPPBindingResolutionBugs.java b/core/org.eclipse.cdt.core.tests/parser/org/eclipse/cdt/internal/index/tests/IndexCPPBindingResolutionBugs.java
index bab75a8dff4..d56d3d89b12 100644
--- a/core/org.eclipse.cdt.core.tests/parser/org/eclipse/cdt/internal/index/tests/IndexCPPBindingResolutionBugs.java
+++ b/core/org.eclipse.cdt.core.tests/parser/org/eclipse/cdt/internal/index/tests/IndexCPPBindingResolutionBugs.java
@@ -27,10 +27,12 @@ import org.eclipse.cdt.core.dom.ast.cpp.ICPPBase;
import org.eclipse.cdt.core.dom.ast.cpp.ICPPClassTemplate;
import org.eclipse.cdt.core.dom.ast.cpp.ICPPClassType;
import org.eclipse.cdt.core.dom.ast.cpp.ICPPField;
+import org.eclipse.cdt.core.dom.ast.cpp.ICPPFunction;
import org.eclipse.cdt.core.dom.ast.cpp.ICPPMethod;
import org.eclipse.cdt.core.dom.ast.cpp.ICPPNamespace;
import org.eclipse.cdt.core.dom.ast.cpp.ICPPSpecialization;
import org.eclipse.cdt.core.dom.ast.cpp.ICPPTemplateDefinition;
+import org.eclipse.cdt.core.dom.ast.cpp.ICPPTemplateInstance;
import org.eclipse.cdt.core.dom.ast.cpp.ICPPTemplateParameter;
import org.eclipse.cdt.core.dom.ast.cpp.ICPPVariable;
import org.eclipse.cdt.core.index.IIndexBinding;
@@ -63,6 +65,30 @@ public class IndexCPPBindingResolutionBugs extends IndexBindingResolutionTestBas
setStrategy(new SinglePDOMTestStrategy(true));
}
+ // template <class T>
+ // inline void testTemplate(T& aRef);
+ //
+ // class Temp {
+ // };
+
+ // #include <stdio.h>
+ // #include <stdlib.h>
+ // #include "test.h"
+ // int main(void) {
+ // puts("Hello World!!!");
+ //
+ // Temp testFile;
+ // testTemplate(testFile);
+ //
+ // return EXIT_SUCCESS;
+ // }
+ public void testBug207320() {
+ IBinding b0= getBindingFromASTName("testTemplate(", 12);
+ assertInstance(b0, ICPPFunction.class);
+ assertInstance(b0, ICPPTemplateInstance.class);
+ }
+
+
// class testdef{
//
// public:
diff --git a/core/org.eclipse.cdt.ui.tests/ui/org/eclipse/cdt/ui/tests/text/selection/CPPSelectionTestsAnyIndexer.java b/core/org.eclipse.cdt.ui.tests/ui/org/eclipse/cdt/ui/tests/text/selection/CPPSelectionTestsAnyIndexer.java
index 0053447a138..7eebcafd318 100644
--- a/core/org.eclipse.cdt.ui.tests/ui/org/eclipse/cdt/ui/tests/text/selection/CPPSelectionTestsAnyIndexer.java
+++ b/core/org.eclipse.cdt.ui.tests/ui/org/eclipse/cdt/ui/tests/text/selection/CPPSelectionTestsAnyIndexer.java
@@ -132,6 +132,40 @@ public abstract class CPPSelectionTestsAnyIndexer extends BaseSelectionTestsInde
assertEquals(9, ((ASTNode)node).getLength());
}
+ // template <class T>
+ // inline void testTemplate(T& aRef);
+ //
+ // class Temp {
+ // };
+
+ // #include <stdio.h>
+ // #include <stdlib.h>
+ // #include "test.h"
+ // int main(void) {
+ // puts("Hello World!!!");
+ //
+ // Temp testFile;
+ // testTemplate(testFile);
+ //
+ // return EXIT_SUCCESS;
+ // }
+ public void testBug207320() throws Exception {
+ StringBuffer[] buffers= getContents(2);
+ String hcode= buffers[0].toString();
+ String scode= buffers[1].toString();
+ IFile hfile = importFile("test.h", hcode);
+ IFile file = importFile("test.cpp", scode);
+ TestSourceReader.waitUntilFileIsIndexed(index, file, MAX_WAIT_TIME);
+
+ int hoffset= hcode.indexOf("testTemplate");
+ int soffset = scode.indexOf("testTemplate");
+ IASTNode def = testF3(file, soffset+2);
+ assertTrue(def instanceof IASTName);
+ assertEquals(((IASTName)def).toString(), "testTemplate"); //$NON-NLS-1$
+ assertEquals(((ASTNode)def).getOffset(), hoffset);
+ assertEquals(((ASTNode)def).getLength(), 12);
+ }
+
// // the header
// extern int MyInt; // MyInt is in another file
// extern const int MyConst; // MyConst is in another file
@@ -227,7 +261,7 @@ public abstract class CPPSelectionTestsAnyIndexer extends BaseSelectionTestsInde
// #include "testBasicTemplateInstance.h"
// N::AAA<int> a;
- public void _testBasicTemplateInstance() throws Exception{
+ public void testBasicTemplateInstance_207320() throws Exception{
StringBuffer[] buffers= getContents(2);
String hcode= buffers[0].toString();
String scode= buffers[1].toString();
@@ -235,7 +269,6 @@ public abstract class CPPSelectionTestsAnyIndexer extends BaseSelectionTestsInde
IFile file = importFile("testBasicTemplateInstance.cpp", scode);
TestSourceReader.waitUntilFileIsIndexed(index, file, MAX_WAIT_TIME);
-
int hoffset= hcode.indexOf("AAA");
int soffset = scode.indexOf("AAA<int>"); //$NON-NLS-1$
IASTNode decl1 = testF3(file, soffset, 3);
diff --git a/core/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/search/actions/OpenDeclarationsAction.java b/core/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/search/actions/OpenDeclarationsAction.java
index 18665de3981..13467b81460 100644
--- a/core/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/search/actions/OpenDeclarationsAction.java
+++ b/core/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/search/actions/OpenDeclarationsAction.java
@@ -39,6 +39,7 @@ import org.eclipse.cdt.core.dom.ast.IASTTranslationUnit;
import org.eclipse.cdt.core.dom.ast.IBinding;
import org.eclipse.cdt.core.dom.ast.IProblemBinding;
import org.eclipse.cdt.core.dom.ast.cpp.ICPPMethod;
+import org.eclipse.cdt.core.dom.ast.cpp.ICPPTemplateInstance;
import org.eclipse.cdt.core.index.IIndex;
import org.eclipse.cdt.core.index.IIndexManager;
import org.eclipse.cdt.core.index.IIndexName;
@@ -130,8 +131,14 @@ public class OpenDeclarationsAction extends SelectionParseAction {
if (binding != null && !(binding instanceof IProblemBinding)) {
IName[] declNames = findNames(fIndex, ast, isDefinition, binding);
if (declNames.length == 0) {
- // bug 86829, handle implicit methods.
- if (binding instanceof ICPPMethod) {
+ if(binding instanceof ICPPTemplateInstance) {
+ // bug 207320, handle template instances
+ IBinding definition= ((ICPPTemplateInstance)binding).getTemplateDefinition();
+ if(definition != null && !(definition instanceof IProblemBinding)) {
+ declNames = findNames(fIndex, ast, true, definition);
+ }
+ } else if (binding instanceof ICPPMethod) {
+ // bug 86829, handle implicit methods.
ICPPMethod method= (ICPPMethod) binding;
if (method.isImplicit()) {
try {

Back to the top