mirror of
https://gitflic.ru/project/openide/openide.git
synced 2026-09-13 09:19:13 +07:00
not a statement -> declaration not allowed here (IDEA-152090)
This commit is contained in:
+7
-1
@@ -1391,7 +1391,13 @@ public class HighlightUtil extends HighlightUtilBase {
|
||||
@Nullable
|
||||
static HighlightInfo checkNotAStatement(@NotNull PsiStatement statement) {
|
||||
if (!PsiUtil.isStatement(statement) && !PsiUtilCore.hasErrorElementChild(statement)) {
|
||||
String description = JavaErrorMessages.message("not.a.statement");
|
||||
boolean isDeclarationNotAllowed = false;
|
||||
if (statement instanceof PsiDeclarationStatement) {
|
||||
final PsiElement parent = statement.getParent();
|
||||
isDeclarationNotAllowed = parent instanceof PsiIfStatement || parent instanceof PsiLoopStatement;
|
||||
}
|
||||
|
||||
String description = JavaErrorMessages.message(isDeclarationNotAllowed ? "declaration.not.allowed" : "not.a.statement");
|
||||
return HighlightInfo.newHighlightInfo(HighlightInfoType.ERROR).range(statement).descriptionAndTooltip(description).create();
|
||||
}
|
||||
return null;
|
||||
|
||||
@@ -401,3 +401,4 @@ feature.type.annotations=Type annotations
|
||||
feature.type.receivers=Receiver parameters
|
||||
feature.try.with.resources.refs=Resource references
|
||||
insufficient.language.level={0} are not supported at this language level
|
||||
declaration.not.allowed=Declaration not allowed here
|
||||
|
||||
+2
-2
@@ -16,9 +16,9 @@ public class a12 {
|
||||
<error descr="Not a statement">new int[]{1};</error>
|
||||
<error descr="Not a statement">new String[]{new String()};</error>
|
||||
if (i==1)
|
||||
<error descr="Not a statement">String s00 = "";</error>
|
||||
<error descr="Declaration not allowed here">String s00 = "";</error>
|
||||
for (;;)
|
||||
<error descr="Not a statement">String s01 = "";</error>
|
||||
<error descr="Declaration not allowed here">String s01 = "";</error>
|
||||
|
||||
|
||||
for (<error descr="Not a statement">1==2,i=3;</error> i<3; <error descr="Not a statement">!(1==2)</error>);
|
||||
|
||||
Reference in New Issue
Block a user