From bceb7a9a1ca33cc4bdeb683c3100b6b3cc3fa0b9 Mon Sep 17 00:00:00 2001 From: "Anna.Kozlova" Date: Mon, 2 Oct 2017 10:33:19 +0200 Subject: [PATCH] LVTI: provide quick documentation with type info for var types --- .../actions/GotoVarTypeHandler.java | 27 +++++++++++++++++++ resources/src/META-INF/IdeaPlugin.xml | 1 + 2 files changed, 28 insertions(+) create mode 100644 java/java-impl/src/com/intellij/codeInsight/navigation/actions/GotoVarTypeHandler.java diff --git a/java/java-impl/src/com/intellij/codeInsight/navigation/actions/GotoVarTypeHandler.java b/java/java-impl/src/com/intellij/codeInsight/navigation/actions/GotoVarTypeHandler.java new file mode 100644 index 000000000000..f2858d22f7d3 --- /dev/null +++ b/java/java-impl/src/com/intellij/codeInsight/navigation/actions/GotoVarTypeHandler.java @@ -0,0 +1,27 @@ +// Copyright 2000-2017 JetBrains s.r.o. Use of this source code is governed by the Apache 2.0 license that can be found in the LICENSE file. +package com.intellij.codeInsight.navigation.actions; + +import com.intellij.openapi.editor.Editor; +import com.intellij.psi.PsiElement; +import com.intellij.psi.PsiIdentifier; +import com.intellij.psi.PsiTypeElement; +import com.intellij.psi.PsiVariable; +import org.jetbrains.annotations.Nullable; + +public class GotoVarTypeHandler extends GotoDeclarationHandlerBase { + @Override + @Nullable + public PsiElement getGotoDeclarationTarget(@Nullable PsiElement elementAt, Editor editor) { + if (elementAt instanceof PsiIdentifier) { + PsiElement parent = elementAt.getParent(); + if (parent instanceof PsiVariable) { + PsiTypeElement typeElement = ((PsiVariable)parent).getTypeElement(); + if (typeElement != null && typeElement.isInferredType()) { + return parent; + } + } + } + + return null; + } +} diff --git a/resources/src/META-INF/IdeaPlugin.xml b/resources/src/META-INF/IdeaPlugin.xml index 0540219ae376..326eeaa1d4c9 100644 --- a/resources/src/META-INF/IdeaPlugin.xml +++ b/resources/src/META-INF/IdeaPlugin.xml @@ -1952,6 +1952,7 @@ +