Skip to content

Commit

Permalink
Issue checkstyle#3033: added more support for openjdk 8 and 9
Browse files Browse the repository at this point in the history
  • Loading branch information
rnveach committed May 29, 2016
1 parent 2438c5a commit d4fdab5
Show file tree
Hide file tree
Showing 6 changed files with 500 additions and 360 deletions.
13 changes: 10 additions & 3 deletions src/main/resources/com/puppycrawl/tools/checkstyle/grammars/java.g
Expand Up @@ -262,6 +262,7 @@ typeSpec[boolean addImagNode]
// - generic type arguments after
classTypeSpec[boolean addImagNode]
: classOrInterfaceType[addImagNode]
({LA(1) == AT}? annotations | )
(options{greedy=true; }:
({LA(1) == AT}? annotations
| )
Expand Down Expand Up @@ -606,6 +607,7 @@ typeParameters
typeParameter
:
// I'm pretty sure Antlr generates the right thing here:
({LA(1) == AT}? annotations | )
(id:IDENT) ( options{generateAmbigWarnings=false;}: typeParameterBounds )?
{#typeParameter = #(#[TYPE_PARAMETER,"TYPE_PARAMETER"], #typeParameter);}
;
Expand Down Expand Up @@ -944,7 +946,7 @@ ctorHead
// This is a list of exception classes that the method is declared to throw
throwsClause
: "throws"^ ({LA(1) == AT}? annotations
| ) identifier ( COMMA identifier )*
| ) identifier ( COMMA ({LA(1) == AT}? annotations | ) identifier )*
;
Expand Down Expand Up @@ -983,11 +985,16 @@ parameterModifier
// A formal parameter.
parameterDeclaration!
: pm:parameterModifier (t:typeSpec[false])? id:IDENT
pd:declaratorBrackets[#t]
: pm:parameterModifier (t:typeSpec[false])?
id:parameterIdent pd:declaratorBrackets[#t]
{#parameterDeclaration = #(#[PARAMETER_DEF,"PARAMETER_DEF"],
pm, #([TYPE,"TYPE"],pd), id);}
;
parameterIdent
: LITERAL_this | (IDENT (DOT^ LITERAL_this)?)
;
//Added for support Java7's "multi-catch", several types separated by '|'
catchParameterDeclaration!
: pm:parameterModifier mct:multiCatchTypes id:IDENT
Expand Down
Expand Up @@ -142,4 +142,13 @@ public void testAnnotationInCatchParameters()

}

@Test
public void testAnnotationInTypeParameters()
throws Exception {
final DefaultConfiguration checkConfig =
createCheckConfig(MemberNameCheck.class);
final String[] expected = CommonUtils.EMPTY_STRING_ARRAY;
verify(checkConfig, getNonCompilablePath("InputAnnotations11.java"), expected);

}
}
Expand Up @@ -22,6 +22,10 @@ public void m() {}
public static void sm() {}
void m1() throws @Nullable Exception {}
public static <T> void m2(T @Nullable [] array) {}
public void m3() throws NullPointerException, @Nullable ArrayIndexOutOfBoundsException {}
public void m4(InputRegressionJava8Class1 this) {}
public void m5(@Nullable InputRegressionJava8Class1 this, @Nullable String @Nullable ... vararg) {}
public Object @Nullable [][] @Nullable [] m6() { return null; }

{
List<String> vlist = new ArrayList<String>();
Expand Down Expand Up @@ -56,8 +60,14 @@ public void instructions() {
}

static final Comparator<?> f = (Comparator<?>) (dateTime1, dateTime2) -> { return 0; };

private class Inner {
public Inner(InputRegressionJava8Class1 InputRegressionJava8Class1.this) {}
}
}
;
class InputRegressionJava8TypeParam <@Nullable T> {
}
@Retention(RetentionPolicy.CLASS)
@Target({ ElementType.TYPE_USE })
@interface Nullable {
Expand Down

0 comments on commit d4fdab5

Please sign in to comment.