Resolve in resource list tuned to not look forward

This commit is contained in:
Roman Shevchenko
2011-02-25 20:59:19 +01:00
parent b2ec3c9263
commit a469762b6d
2 changed files with 14 additions and 4 deletions
@@ -198,9 +198,14 @@ public class PsiImplUtil {
@NotNull final PsiScopeProcessor processor,
@NotNull final ResolveState state,
final PsiElement lastParent) {
final ElementClassHint hint = processor.getHint(ElementClassHint.KEY);
if (hint != null && !hint.shouldProcess(ElementClassHint.DeclaractionKind.VARIABLE)) return true;
final List<PsiResourceVariable> resources = resourceList.getResourceVariables();
for (PsiResourceVariable resource : resources) {
if (!resource.equals(lastParent) && !processor.execute(resource, state)) return false;
@SuppressWarnings({"SuspiciousMethodCalls"})
final int lastIdx = lastParent instanceof PsiResourceVariable ? resources.indexOf(lastParent) : resources.size();
for (int i = 0; i < lastIdx; i++) {
if (!processor.execute(resources.get(i), state)) return false;
}
return true;
@@ -46,11 +46,11 @@ class C {
}
<error descr="Cannot resolve symbol 'r'">r</error> = null;
try (MyResource <error descr="Variable 'r' is already defined in the scope">r</error> = new MyResource(); MyResource <error descr="Variable 'r' is already defined in the scope">r</error> = new MyResource()) { }
try (MyResource r = new MyResource(); MyResource <error descr="Variable 'r' is already defined in the scope">r</error> = new MyResource()) { }
try (MyResource r1 = new MyResource(); MyResource r2 = r1) { }
/* todo: try (MyResource r1 = < error descr="Cannot resolve symbol 'r'">r2</error >; MyResource r2 = r1) { }*/
try (MyResource r1 = <error descr="Cannot resolve symbol 'r2'">r2</error>; MyResource r2 = r1) { }
MyResource r = null;
try (MyResource <error descr="Variable 'r' is already defined in the scope">r</error> = new MyResource()) { }
@@ -64,4 +64,9 @@ class C {
}
}.run();
}
void m4() throws Exception {
MyResource r;
try (MyResource r1 = <error descr="Variable 'r' might not have been initialized">r</error>) { }
}
}