From ff7056130e0df32328d56ab9af95412fbb2d0eca Mon Sep 17 00:00:00 2001 From: Michi Date: Sat, 3 Jan 2015 18:38:25 +0100 Subject: [PATCH] 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 Reviewed-on: https://git.eclipse.org/r/38923 Tested-by: Hudson CI Reviewed-by: Sergey Prigogin Tested-by: Sergey Prigogin --- .../cdt/internal/ui/search/actions/OpenDeclarationsJob.java | 5 ++++- .../eclipse/cdt/internal/ui/text/c/hover/CSourceHover.java | 5 +++++ 2 files changed, 9 insertions(+), 1 deletion(-) 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.