mirror of
https://gitflic.ru/project/openide/openide.git
synced 2026-09-27 10:03:11 +07:00
Highlight uninitialized resource variable
This commit is contained in:
+2
@@ -66,6 +66,8 @@ class C {
|
||||
}
|
||||
|
||||
void m4() throws Exception {
|
||||
try (MyResource r = <error descr="Variable 'r' might not have been initialized">r</error>) { }
|
||||
|
||||
MyResource r;
|
||||
try (MyResource r1 = <error descr="Variable 'r' might not have been initialized">r</error>) { }
|
||||
}
|
||||
|
||||
@@ -232,7 +232,7 @@ public final class PsiUtil extends PsiUtilBase {
|
||||
}
|
||||
|
||||
/**
|
||||
* @return codeblock topmost codeblock where variable makes sense
|
||||
* @return topmost code block where variable makes sense
|
||||
*/
|
||||
@Nullable
|
||||
public static PsiElement getVariableCodeBlock(PsiVariable variable, PsiElement context) {
|
||||
@@ -249,6 +249,10 @@ public final class PsiUtil extends PsiUtilBase {
|
||||
codeBlock = ((PsiMethod)declarationScope).getBody();
|
||||
}
|
||||
}
|
||||
else if (variable instanceof PsiResourceVariable) {
|
||||
final PsiElement resourceList = variable.getParent();
|
||||
return resourceList != null ? resourceList.getParent() : null; // use try statement as topmost
|
||||
}
|
||||
else if (variable instanceof PsiLocalVariable && variable.getParent() instanceof PsiForStatement) {
|
||||
return variable.getParent();
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user