Skip to main content
aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorMichi2015-01-03 17:38:25 +0000
committerSergey Prigogin2015-01-04 07:34:22 +0000
commitff7056130e0df32328d56ab9af95412fbb2d0eca (patch)
tree368270315e1e3cbc1d2394104b67b8f2d155f0a2
parentd7e2618b8f8f5363dcb9834b0da2fd3e4190e20a (diff)
downloadorg.eclipse.cdt-ff7056130e0df32328d56ab9af95412fbb2d0eca.tar.gz
org.eclipse.cdt-ff7056130e0df32328d56ab9af95412fbb2d0eca.tar.xz
org.eclipse.cdt-ff7056130e0df32328d56ab9af95412fbb2d0eca.zip
Bug 456579 - Improve CSourceHover and OpenDeclaration for TemplateIds
When the nodeSelector detects an IASTNode that has a TemplateId parent we use that instead of the original. The benefit is that we also get the template parameters so we can find template specialization matches. Change-Id: I3751efdb15e868b4aa6688ad338227e0d0c5bcd8 Signed-off-by: Michi <woskimi@yahoo.de> Reviewed-on: https://git.eclipse.org/r/38923 Tested-by: Hudson CI Reviewed-by: Sergey Prigogin <eclipse.sprigogin@gmail.com> Tested-by: Sergey Prigogin <eclipse.sprigogin@gmail.com>
-rw-r--r--core/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/search/actions/OpenDeclarationsJob.java5
-rw-r--r--core/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/text/c/hover/CSourceHover.java5
2 files changed, 9 insertions, 1 deletions
diff --git a/core/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/search/actions/OpenDeclarationsJob.java b/core/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/search/actions/OpenDeclarationsJob.java
index aaedd0596bd..a3d1ca5f520 100644
--- a/core/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/search/actions/OpenDeclarationsJob.java
+++ b/core/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/search/actions/OpenDeclarationsJob.java
@@ -59,6 +59,7 @@ import org.eclipse.cdt.core.dom.ast.IParameter;
import org.eclipse.cdt.core.dom.ast.IProblemBinding;
import org.eclipse.cdt.core.dom.ast.IType;
import org.eclipse.cdt.core.dom.ast.cpp.ICPPASTTemplateDeclaration;
+import org.eclipse.cdt.core.dom.ast.cpp.ICPPASTTemplateId;
import org.eclipse.cdt.core.dom.ast.cpp.ICPPASTTranslationUnit;
import org.eclipse.cdt.core.dom.ast.cpp.ICPPASTUsingDeclaration;
import org.eclipse.cdt.core.dom.ast.cpp.ICPPAliasTemplateInstance;
@@ -176,6 +177,8 @@ class OpenDeclarationsJob extends Job implements ASTRunnable {
if (parent instanceof IASTPreprocessorIncludeStatement) {
openInclude(((IASTPreprocessorIncludeStatement) parent));
return Status.OK_STATUS;
+ } else if (parent instanceof ICPPASTTemplateId) {
+ sourceName = (IASTName) parent;
}
NameKind kind = getNameKind(sourceName);
IBinding b = sourceName.resolveBinding();
@@ -799,4 +802,4 @@ class OpenDeclarationsJob extends Job implements ASTRunnable {
return result;
}
-} \ No newline at end of file
+}
diff --git a/core/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/text/c/hover/CSourceHover.java b/core/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/text/c/hover/CSourceHover.java
index cbb883aea81..a6f68e769f4 100644
--- a/core/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/text/c/hover/CSourceHover.java
+++ b/core/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/text/c/hover/CSourceHover.java
@@ -79,6 +79,7 @@ import org.eclipse.cdt.core.dom.ast.IVariable;
import org.eclipse.cdt.core.dom.ast.cpp.ICPPASTDeclSpecifier;
import org.eclipse.cdt.core.dom.ast.cpp.ICPPASTDeclarator;
import org.eclipse.cdt.core.dom.ast.cpp.ICPPASTSimpleDeclSpecifier;
+import org.eclipse.cdt.core.dom.ast.cpp.ICPPASTTemplateId;
import org.eclipse.cdt.core.dom.ast.cpp.ICPPASTTypeId;
import org.eclipse.cdt.core.dom.ast.cpp.ICPPAliasTemplateInstance;
import org.eclipse.cdt.core.dom.ast.cpp.ICPPConstructor;
@@ -187,6 +188,10 @@ public class CSourceHover extends AbstractCEditorTextHover {
} else {
IASTName name= nodeSelector.findEnclosingName(fTextRegion.getOffset(), fTextRegion.getLength());
if (name != null) {
+ IASTNode parent = name.getParent();
+ if (parent instanceof ICPPASTTemplateId) {
+ name = (IASTName) parent;
+ }
IBinding binding= name.resolveBinding();
if (binding != null) {
// Check for implicit names first, could be an implicit constructor call.

Back to the top