mirror of
https://gitflic.ru/project/openide/openide.git
synced 2026-09-27 10:03:11 +07:00
IDEA-160599 (False positive "Java | Code style issues | Control flow statement without braces" for "else if")
This commit is contained in:
+1
-1
@@ -140,7 +140,7 @@ public abstract class ControlFlowStatementVisitorBase extends BaseInspectionVisi
|
||||
}
|
||||
}
|
||||
|
||||
private boolean isHighlightOnlyKeyword(PsiElement element) {
|
||||
protected boolean isHighlightOnlyKeyword(@NotNull PsiElement element) {
|
||||
if (!isOnTheFly()) {
|
||||
return true;
|
||||
}
|
||||
|
||||
+10
-1
@@ -1,5 +1,5 @@
|
||||
/*
|
||||
* Copyright 2003-2010 Dave Griffith, Bas Leijdekkers
|
||||
* Copyright 2003-2016 Dave Griffith, Bas Leijdekkers
|
||||
*
|
||||
* Licensed under the Apache License, Version 2.0 (the "License");
|
||||
* you may not use this file except in compliance with the License.
|
||||
@@ -140,6 +140,15 @@ public class ControlFlowStatementWithoutBracesInspection
|
||||
@Contract("null->false")
|
||||
@Override
|
||||
protected boolean isApplicable(PsiStatement body) {
|
||||
if (body instanceof PsiIfStatement && isHighlightOnlyKeyword(body)) {
|
||||
final PsiElement parent = body.getParent();
|
||||
if (parent instanceof PsiIfStatement) {
|
||||
final PsiIfStatement ifStatement = (PsiIfStatement)parent;
|
||||
if (ifStatement.getElseBranch() == body) {
|
||||
return false;
|
||||
}
|
||||
}
|
||||
}
|
||||
return body != null && !(body instanceof PsiBlockStatement);
|
||||
}
|
||||
|
||||
|
||||
+9
@@ -36,4 +36,13 @@ class T {
|
||||
else System.out.println(0);
|
||||
else System.out.println("no");
|
||||
}
|
||||
|
||||
void fff(String[] a) {
|
||||
if (a.length == 0) {
|
||||
System.out.println();
|
||||
}
|
||||
else if (a.length > 10) {
|
||||
System.out.println();
|
||||
}
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user