mirror of
https://gitflic.ru/project/openide/openide.git
synced 2026-09-27 10:03:11 +07:00
[java-highlighting] Avoid highlighting outside of PsiField psi element
Fixes IDEA-368916 IAE in error highlighting when several fields are declared with shared modifier list GitOrigin-RevId: 012b6564f9ca1a775894a3fc2b003c4feb2477e6
This commit is contained in:
committed by
intellij-monorepo-bot
parent
f3ac3c8925
commit
830860950b
+2
-1
@@ -158,7 +158,8 @@ final class JavaErrorFormatUtil {
|
||||
static @NotNull TextRange getFieldDeclarationTextRange(@NotNull PsiField field) {
|
||||
PsiModifierList modifierList = field.getModifierList();
|
||||
TextRange range = field.getTextRange();
|
||||
int start = modifierList == null ? range.getStartOffset() : stripAnnotationsFromModifierList(modifierList);
|
||||
int start = modifierList == null || modifierList.getParent() != field ?
|
||||
range.getStartOffset() : stripAnnotationsFromModifierList(modifierList);
|
||||
int end = field.getNameIdentifier().getTextRange().getEndOffset();
|
||||
return new TextRange(start, end).shiftLeft(range.getStartOffset());
|
||||
}
|
||||
|
||||
+3
@@ -0,0 +1,3 @@
|
||||
public final class A {
|
||||
<error descr="Field 'x' might not have been initialized">private final int x</error>, <error descr="Field 'y' might not have been initialized">y</error>;
|
||||
}
|
||||
+2
@@ -469,4 +469,6 @@ public class LightAdvHighlightingTest extends LightDaemonAnalyzerTestCase {
|
||||
public void testReferenceToImplicitClass() {
|
||||
IdeaTestUtil.withLevel(getModule(), LanguageLevel.JDK_22_PREVIEW, () -> doTest(false));
|
||||
}
|
||||
|
||||
public void testUninitializedFields() { doTest(false); }
|
||||
}
|
||||
Reference in New Issue
Block a user