From df404bb8136b5f3c63293240b3907a34563e0d1f Mon Sep 17 00:00:00 2001 From: "Gregory.Shrago" Date: Wed, 17 Jun 2015 18:57:20 +0300 Subject: [PATCH] IDEA-CR-3132 honor exact selection; some javadoc with HTML warnings --- .../com/intellij/lang/ExpressionTypeProvider.java | 12 ++++++++++++ .../codeInsight/hint/ShowExpressionTypeHandler.java | 5 ++++- 2 files changed, 16 insertions(+), 1 deletion(-) diff --git a/platform/lang-api/src/com/intellij/lang/ExpressionTypeProvider.java b/platform/lang-api/src/com/intellij/lang/ExpressionTypeProvider.java index 163dc3f4d0c0..781db2cf703a 100644 --- a/platform/lang-api/src/com/intellij/lang/ExpressionTypeProvider.java +++ b/platform/lang-api/src/com/intellij/lang/ExpressionTypeProvider.java @@ -21,15 +21,27 @@ import org.jetbrains.annotations.NotNull; import java.util.List; /** + * @see com.intellij.codeInsight.hint.actions.ShowExpressionTypeAction + * * @author gregsh */ public abstract class ExpressionTypeProvider { + /** + * Returns HTML string for type info hint. + * @see com.intellij.openapi.util.text.StringUtil#escapeXml(String) + */ @NotNull public abstract String getInformationHint(@NotNull T element); + /** + * Returns HTML string if no target found at position. + */ @NotNull public abstract String getErrorHint(); + /** + * Returns the list of all possible targets at specified position. + */ @NotNull public abstract List getExpressionsAt(@NotNull PsiElement elementAt); } diff --git a/platform/lang-impl/src/com/intellij/codeInsight/hint/ShowExpressionTypeHandler.java b/platform/lang-impl/src/com/intellij/codeInsight/hint/ShowExpressionTypeHandler.java index 2eaeb0509595..cd914811b30a 100644 --- a/platform/lang-impl/src/com/intellij/codeInsight/hint/ShowExpressionTypeHandler.java +++ b/platform/lang-impl/src/com/intellij/codeInsight/hint/ShowExpressionTypeHandler.java @@ -60,11 +60,14 @@ public class ShowExpressionTypeHandler implements CodeInsightActionHandler { final Set handlers = getHandlers(project, language, file.getViewProvider().getBaseLanguage()); if (handlers.isEmpty()) return; + boolean exactRange = false; TextRange range = EditorUtil.getSelectionInAnyMode(editor); final Map map = ContainerUtil.newLinkedHashMap(); for (ExpressionTypeProvider handler : handlers) { for (PsiElement element : ((ExpressionTypeProvider)handler).getExpressionsAt(elementAt)) { - if (!element.getTextRange().contains(range)) continue; + TextRange r = element.getTextRange(); + if (exactRange && !r.equals(range) || !r.contains(range)) continue; + if (!exactRange) exactRange = r.equals(range); map.put(element, handler); } }