[java] exception highlighting in try-with-resources (IDEA-142066)

This commit is contained in:
Roman Shevchenko
2016-02-29 18:32:21 +01:00
parent 1cef8eae98
commit 7cb95f22b5
3 changed files with 76 additions and 13 deletions
@@ -1,5 +1,5 @@
/*
* Copyright 2000-2015 JetBrains s.r.o.
* Copyright 2000-2016 JetBrains s.r.o.
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
@@ -223,6 +223,32 @@ public class HighlightUsagesHandlerTest extends LightCodeInsightFixtureTestCase
}
}
public void testExceptionsInTryWithResources() {
myFixture.configureByText 'A.java', '''
import java.io.*;
class A {
void test() throws IOException {
try (InputStream in = new FileInputStream("file.name")) { }
<caret>catch (FileNotFoundException e) { throw new FileNotFoundException("no highlighting here"); }
}
}'''.stripIndent()
ctrlShiftF7()
assertRangeText 'FileInputStream', 'catch'
}
public void testExceptionsResourceCloser() {
myFixture.configureByText 'A.java', '''
import java.io.*;
class A {
void test() {
try (InputStream in = new FileInputStream("file.name")) { }
<caret>catch (IOException e) { }
}
}'''.stripIndent()
ctrlShiftF7()
assertRangeText 'in', 'FileInputStream', 'FileInputStream', 'catch'
}
private void configureFile() {
def testName = getTestName(false)
def file = myFixture.copyFileToProject "/codeInsight/highlightUsagesHandler/${testName}.java", "${testName}.java"