summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorMarc-Andre Laperle2013-01-02 00:06:16 (EST)
committerMarc-Andre Laperle2013-01-03 01:34:42 (EST)
commit1644f4d640679483632e0e946c6f990250e6e5f9 (patch)
tree8bbc7a479623f64a6c1a52162d3bf95b438c6a42
parent2fcedcbffe01aff756f81c532aaa0ef0ed1d9df0 (diff)
downloadorg.eclipse.cdt-1644f4d640679483632e0e946c6f990250e6e5f9.zip
org.eclipse.cdt-1644f4d640679483632e0e946c6f990250e6e5f9.tar.gz
org.eclipse.cdt-1644f4d640679483632e0e946c6f990250e6e5f9.tar.bz2
Bug 397288 - typename keyword is not completed
Change-Id: I26d62f771b5bb08d1c5cab64929c765c025053b3 Reviewed-on: https://git.eclipse.org/r/9419 Reviewed-by: Marc-Andre Laperle <malaperle@gmail.com> IP-Clean: Marc-Andre Laperle <malaperle@gmail.com> Tested-by: Marc-Andre Laperle <malaperle@gmail.com>
-rw-r--r--core/org.eclipse.cdt.core/parser/org/eclipse/cdt/internal/core/dom/parser/cpp/GNUCPPSourceParser.java6
-rw-r--r--core/org.eclipse.cdt.ui.tests/ui/org/eclipse/cdt/ui/tests/text/contentassist2/AbstractContentAssistTest.java20
-rw-r--r--core/org.eclipse.cdt.ui.tests/ui/org/eclipse/cdt/ui/tests/text/contentassist2/CompletionTests.java8
3 files changed, 24 insertions, 10 deletions
diff --git a/core/org.eclipse.cdt.core/parser/org/eclipse/cdt/internal/core/dom/parser/cpp/GNUCPPSourceParser.java b/core/org.eclipse.cdt.core/parser/org/eclipse/cdt/internal/core/dom/parser/cpp/GNUCPPSourceParser.java
index c63322a..c3c6390 100644
--- a/core/org.eclipse.cdt.core/parser/org/eclipse/cdt/internal/core/dom/parser/cpp/GNUCPPSourceParser.java
+++ b/core/org.eclipse.cdt.core/parser/org/eclipse/cdt/internal/core/dom/parser/cpp/GNUCPPSourceParser.java
@@ -1,5 +1,5 @@
/*******************************************************************************
- * Copyright (c) 2002, 2012 IBM Corporation and others.
+ * Copyright (c) 2002, 2013 IBM Corporation and others.
* All rights reserved. This program and the accompanying materials
* are made available under the terms of the Eclipse Public License v1.0
* which accompanies this distribution, and is available at
@@ -2051,7 +2051,9 @@ public class GNUCPPSourceParser extends AbstractGNUSourceCodeParser {
}
List<ICPPASTTemplateParameter> parms= outerTemplateParameterList();
- consume(IToken.tGT, IToken.tGT_in_SHIFTR);
+ if (LT(1) != IToken.tEOC) {
+ consume(IToken.tGT, IToken.tGT_in_SHIFTR);
+ }
IASTDeclaration d = declaration(option);
ICPPASTTemplateDeclaration templateDecl = nodeFactory.newTemplateDeclaration(d);
setRange(templateDecl, offset, calculateEndOffset(d));
diff --git a/core/org.eclipse.cdt.ui.tests/ui/org/eclipse/cdt/ui/tests/text/contentassist2/AbstractContentAssistTest.java b/core/org.eclipse.cdt.ui.tests/ui/org/eclipse/cdt/ui/tests/text/contentassist2/AbstractContentAssistTest.java
index e39e48b..26db8a4 100644
--- a/core/org.eclipse.cdt.ui.tests/ui/org/eclipse/cdt/ui/tests/text/contentassist2/AbstractContentAssistTest.java
+++ b/core/org.eclipse.cdt.ui.tests/ui/org/eclipse/cdt/ui/tests/text/contentassist2/AbstractContentAssistTest.java
@@ -1,5 +1,5 @@
/*******************************************************************************
- * Copyright (c) 2004, 2012 IBM Corporation and others.
+ * Copyright (c) 2004, 2013 IBM Corporation and others.
* All rights reserved. This program and the accompanying materials
* are made available under the terms of the Eclipse Public License v1.0
* which accompanies this distribution, and is available at
@@ -96,8 +96,8 @@ public abstract class AbstractContentAssistTest extends BaseUITestCase {
fCFile= null;
super.tearDown();
}
-
- protected void assertContentAssistResults(int offset, int length, String[] expected, boolean isCompletion, boolean isTemplate, int compareType) throws Exception {
+
+ protected void assertContentAssistResults(int offset, int length, String[] expected, boolean isCompletion, boolean isTemplate, boolean filterResults, int compareType) throws Exception {
if (CTestPlugin.getDefault().isDebugging()) {
System.out.println("\n\n\n\n\nTesting "+this.getClass().getName());
}
@@ -116,10 +116,12 @@ public abstract class AbstractContentAssistTest extends BaseUITestCase {
long endTime= System.currentTimeMillis();
assertTrue(results != null);
- if(isTemplate) {
- results= filterResultsKeepTemplates(results);
- } else {
- results= filterResults(results, isCode);
+ if (filterResults) {
+ if (isTemplate) {
+ results= filterResultsKeepTemplates(results);
+ } else {
+ results= filterResults(results, isCode);
+ }
}
String[] resultStrings= toStringArray(results, compareType);
Arrays.sort(expected);
@@ -160,6 +162,10 @@ public abstract class AbstractContentAssistTest extends BaseUITestCase {
}
}
+
+ protected void assertContentAssistResults(int offset, int length, String[] expected, boolean isCompletion, boolean isTemplate, int compareType) throws Exception {
+ assertContentAssistResults(offset, length, expected, isCompletion, isTemplate, true, compareType);
+ }
protected void assertContentAssistResults(int offset, String[] expected, boolean isCompletion, int compareType) throws Exception {
assertContentAssistResults(offset, 0, expected, isCompletion, false, compareType);
diff --git a/core/org.eclipse.cdt.ui.tests/ui/org/eclipse/cdt/ui/tests/text/contentassist2/CompletionTests.java b/core/org.eclipse.cdt.ui.tests/ui/org/eclipse/cdt/ui/tests/text/contentassist2/CompletionTests.java
index da4abfe..2b25113 100644
--- a/core/org.eclipse.cdt.ui.tests/ui/org/eclipse/cdt/ui/tests/text/contentassist2/CompletionTests.java
+++ b/core/org.eclipse.cdt.ui.tests/ui/org/eclipse/cdt/ui/tests/text/contentassist2/CompletionTests.java
@@ -1,5 +1,5 @@
/*******************************************************************************
- * Copyright (c) 2006, 2012 Wind River Systems, Inc. and others.
+ * Copyright (c) 2006, 2013 Wind River Systems, Inc. and others.
* All rights reserved. This program and the accompanying materials
* are made available under the terms of the Eclipse Public License v1.0
* which accompanies this distribution, and is available at
@@ -1374,4 +1374,10 @@ public class CompletionTests extends AbstractContentAssistTest {
final String[] expected= { "foo;" };
assertCompletionResults(fCursorOffset, expected, COMPARE_REP_STRINGS);
}
+
+ // template <typen/*cursor*/
+ public void testTemplateDeclaration_Bug397288() throws Exception {
+ final String[] expected= { "typename" };
+ assertContentAssistResults(fCursorOffset, 0, expected, true, false, false, COMPARE_REP_STRINGS);
+ }
} \ No newline at end of file