mirror of
https://github.com/eclipse-cdt/cdt
synced 2025-04-29 19:45:01 +02:00
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>
This commit is contained in:
parent
d7e2618b8f
commit
ff7056130e
2 changed files with 9 additions and 1 deletions
|
@ -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;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
|
@ -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.
|
||||
|
|
Loading…
Add table
Reference in a new issue