Skip to content

Commit

Permalink
#779 DiamondOperator complains when instantiating/assigning inner typ…
Browse files Browse the repository at this point in the history
…es (add test)
  • Loading branch information
dskalenko committed Jul 6, 2016
1 parent fccf32c commit 404b361
Show file tree
Hide file tree
Showing 4 changed files with 38 additions and 11 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -109,6 +109,9 @@ private static DetailAST getFirstChildNodeOfType(
.getFirstChildNodeOfType(result, type);
if (child == null) {
result = result.getNextSibling();
if(result != null && result.getType() != type) {
result = null;
}
}
}
return result;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -679,16 +679,19 @@ public void allowsUppercaseAbbreviationExceptions() throws Exception {
* @throws Exception If error
*/
@Test
@SuppressWarnings("unchecked")
public void rejectsNonDiamondOperatorUsage() throws Exception {
final String file = "InvalidDiamondsUsage.java";
final String name = "DiamondOperatorCheck";
final String message = "Use diamond operator";
MatcherAssert.assertThat(
this.runValidation(file, false),
Matchers.contains(
new CheckstyleValidatorTest.ViolationMatcher(
// @checkstyle MultipleStringLiterals (1 line)
"Use diamond operator", file, "21", "DiamondOperatorCheck"
this.runValidation(file, false),
Matchers.hasItems(
new ViolationMatcher(
message, file, "21", name),
new ViolationMatcher(
message, file, "30", name)
)
)
);
}

Expand All @@ -699,7 +702,6 @@ public void rejectsNonDiamondOperatorUsage() throws Exception {
* {@code return new ArrayList<String>();}
*/
@Test
@Ignore
public void allowsDiamondOperatorUsage() throws Exception {
this.runValidation("ValidDiamondsUsage.java", true);
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -22,4 +22,25 @@ public List<String> firstTen(final String... args) {
list.addAll(Arrays.asList(args));
return list;
}

/**
* Act.
*/
public static void act() {
final RqForm.Smart<String> smart = new RqForm.Smart<String>();
}

/**
* RqForm.
*/
interface RqForm {

/**
* Smart.
* @param <E> generic parament
*/
final class Smart<E> implements RqForm {

}
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -27,16 +27,17 @@ public List<String> firstTen(final String... args) {
return list;
}

@Override
public Response act(final Request req) throws IOException {
/**
* Act.
*/
public static void act() {
final RqForm.Smart smart = new RqForm.Smart();
return smart;
}

/**
* RqForm.
*/
interface RqForm extends Request {
interface RqForm {

/**
* Smart.
Expand Down

0 comments on commit 404b361

Please sign in to comment.