diff --git a/src/checkstyle/com/puppycrawl/tools/checkstyle/grammars/java.g b/src/checkstyle/com/puppycrawl/tools/checkstyle/grammars/java.g index ad96679f4..c2a8cb6da 100755 --- a/src/checkstyle/com/puppycrawl/tools/checkstyle/grammars/java.g +++ b/src/checkstyle/com/puppycrawl/tools/checkstyle/grammars/java.g @@ -1146,9 +1146,14 @@ resources {#resources = #([RESOURCES, "RESOURCES"], #resources);} ; + resource - : modifiers typeSpec[true] IDENT ASSIGN expression + : modifiers typeSpec[true] IDENT resource_assign {#resource = #([RESOURCE, "RESOURCE"], #resource);} +; + +resource_assign + : ASSIGN^ expression ; // an exception handler diff --git a/src/testinputs/com/puppycrawl/tools/checkstyle/indentation/InputValidTryResourcesIndent.java b/src/testinputs/com/puppycrawl/tools/checkstyle/indentation/InputValidTryResourcesIndent.java index 07d99f053..5b5fd93da 100644 --- a/src/testinputs/com/puppycrawl/tools/checkstyle/indentation/InputValidTryResourcesIndent.java +++ b/src/testinputs/com/puppycrawl/tools/checkstyle/indentation/InputValidTryResourcesIndent.java @@ -11,7 +11,8 @@ class InputValidTryResourcesIndent // Taken from JDK7 java.lang.Package src code. private static Manifest loadManifest(String fn) { try (FileInputStream fis = new FileInputStream(fn); -JarInputStream jis = new JarInputStream(fis, false)) + // This should be an error + JarInputStream jis = new JarInputStream(fis, false)) { return jis.getManifest(); } catch (IOException e) diff --git a/src/tests/com/puppycrawl/tools/checkstyle/checks/indentation/IndentationCheckTest.java b/src/tests/com/puppycrawl/tools/checkstyle/checks/indentation/IndentationCheckTest.java index 5931b7484..164c3f7d4 100755 --- a/src/tests/com/puppycrawl/tools/checkstyle/checks/indentation/IndentationCheckTest.java +++ b/src/tests/com/puppycrawl/tools/checkstyle/checks/indentation/IndentationCheckTest.java @@ -734,13 +734,12 @@ public class IndentationCheckTest extends BaseCheckTestSupport } @Test - @Ignore public void testTryResources() throws Exception { final DefaultConfiguration checkConfig = createCheckConfig(IndentationCheck.class); final String[] expected = { - "something is expected, but there is a NullPointerException", + //"something is expected, but there is nothing", }; verify(checkConfig, getPath("indentation/InputValidTryResourcesIndent.java"), expected);