From 9d3636bab75e4417185e532cd978edfe85c2ed60 Mon Sep 17 00:00:00 2001 From: Alexey Kudravtsev Date: Wed, 26 Apr 2017 18:49:14 +0300 Subject: [PATCH] when the .getNavigationElement() is implemented to lead to a wildly different element (e.g. PsiPuppetVarWrapperImpl for "$mod" leads to a leaf element for identifier "mod"), correct the passed startOffset/endOffset accordingly to fix RUBY-19327 Variables names are partially highlighted in the Find Usages results --- .../core-api/src/com/intellij/usageView/UsageInfo.java | 9 +++++++-- 1 file changed, 7 insertions(+), 2 deletions(-) diff --git a/platform/core-api/src/com/intellij/usageView/UsageInfo.java b/platform/core-api/src/com/intellij/usageView/UsageInfo.java index 78c1d854c196..e9e51bcf2501 100644 --- a/platform/core-api/src/com/intellij/usageView/UsageInfo.java +++ b/platform/core-api/src/com/intellij/usageView/UsageInfo.java @@ -35,8 +35,8 @@ public class UsageInfo { public final boolean isNonCodeUsage; protected boolean myDynamicUsage; - public UsageInfo(@NotNull PsiElement element, final int startOffset, final int endOffset, boolean isNonCodeUsage) { - element = element.getNavigationElement(); + public UsageInfo(@NotNull PsiElement originalElement, final int startOffset, final int endOffset, boolean isNonCodeUsage) { + PsiElement element = originalElement.getNavigationElement(); PsiFile file = element.getContainingFile(); PsiElement topElement = file == null ? element : file; LOG.assertTrue(topElement.isValid(), element); @@ -55,6 +55,11 @@ public class UsageInfo { else { effectiveStart = startOffset; effectiveEnd = endOffset; + if (element != originalElement && originalElement.getContainingFile() == file) { + int delta = originalElement.getTextRange().getStartOffset() - elementRange.getStartOffset(); + effectiveStart += delta; + effectiveEnd += delta; + } } if (effectiveStart < 0 || effectiveStart > effectiveEnd) {