diff options
author | rnveach <rveach02@gmail.com> | 2015-10-10 22:25:09 -0400 |
---|---|---|
committer | Roman Ivanov <ivanov-jr@mail.ru> | 2015-10-12 06:53:34 -0700 |
commit | 3ad60e5742797c5db87de1c8325b001c13543553 (patch) | |
tree | 36682216e60d036160aa57d78923ca93bf791131 /src/test/resources/com/puppycrawl/tools/checkstyle/checks/annotation | |
parent | 3c11c78c126d1cbc0e5efa213ce555467616f091 (diff) | |
download | checkstyle-3ad60e5742797c5db87de1c8325b001c13543553.tar.gz |
Issue #2161: unify test input locations
Diffstat (limited to 'src/test/resources/com/puppycrawl/tools/checkstyle/checks/annotation')
9 files changed, 437 insertions, 0 deletions
diff --git a/src/test/resources/com/puppycrawl/tools/checkstyle/checks/annotation/AnnotationUseNoTrailingComma.java b/src/test/resources/com/puppycrawl/tools/checkstyle/checks/annotation/AnnotationUseNoTrailingComma.java new file mode 100644 index 000000000..3a6e8310f --- /dev/null +++ b/src/test/resources/com/puppycrawl/tools/checkstyle/checks/annotation/AnnotationUseNoTrailingComma.java @@ -0,0 +1,47 @@ +package com.puppycrawl.tools.checkstyle.checks.annotation; +// suppress +@SuppressWarnings({}) +public class AnnotationUseNoTrailingComma +{ + @SuppressWarnings({"common"}) + public void foo() { + + /** Suppress warnings */ + @SuppressWarnings({"common","foo"}) + Object o = new Object() { + + @SuppressWarnings(value={"common"}) + public String toString() { + + @SuppressWarnings(value={"leo","herbie"}) + final String pooches = "leo.herbie"; + + return pooches; + } + }; + } + + @Test2(value={(false) ? "" : "foo"}, more={(true) ? "" : "bar"}) + + @Pooches2(tokens={},other={}) + enum P { + + @Pooches2(tokens={Pooches2.class},other={1}) + L, // annotation in enum + + @Test2(value={}, more={(false) ? "" : "unchecked"}) + Y; + } + +} + +@interface Test2 { + String[] value(); + String[] more() default {}; +} + +@interface Pooches2 { + + Class<?>[] tokens(); + int[] other(); +} diff --git a/src/test/resources/com/puppycrawl/tools/checkstyle/checks/annotation/AnnotationUseWithTrailingComma.java b/src/test/resources/com/puppycrawl/tools/checkstyle/checks/annotation/AnnotationUseWithTrailingComma.java new file mode 100644 index 000000000..13ba48999 --- /dev/null +++ b/src/test/resources/com/puppycrawl/tools/checkstyle/checks/annotation/AnnotationUseWithTrailingComma.java @@ -0,0 +1,56 @@ +package com.puppycrawl.tools.checkstyle.checks.annotation; +//this file compiles in eclipse 3.4 but not with Sun's JDK 1.6.0.11 + +/** + +*/ +public class AnnotationUseWithTrailingComma +{ + @SuppressWarnings({"common",}) + public void foo() { + + + @SuppressWarnings({"common","foo",}) + Object o = new Object() { + + @SuppressWarnings(value={"common",}) + public String toString() { + + @SuppressWarnings(value={"leo","herbie",}) + final String pooches = "leo.herbie"; + + return pooches; + } + }; + } + + @Test(value={(false) ? "" : "foo",}, more={(true) ? "" : "bar",}) + /** + + */ + enum P { + + @Pooches(tokens={Pooches.class,},other={1,}) + L, + + /** + + */ + Y; + } + +} + +@interface Test { + String[] value(); + String[] more() default {}; + /** + + */ +} + +@interface Pooches { + + Class<?>[] tokens(); + int[] other(); +} diff --git a/src/test/resources/com/puppycrawl/tools/checkstyle/checks/annotation/AnnotationsUseStyleParams.java b/src/test/resources/com/puppycrawl/tools/checkstyle/checks/annotation/AnnotationsUseStyleParams.java new file mode 100644 index 000000000..87c01ed71 --- /dev/null +++ b/src/test/resources/com/puppycrawl/tools/checkstyle/checks/annotation/AnnotationsUseStyleParams.java @@ -0,0 +1,12 @@ +package com.puppycrawl.tools.checkstyle.checks.annotation; + +import java.lang.annotation.Retention; +import java.lang.annotation.Target; + +public class AnnotationsUseStyleParams +{ + @Target({}) + public @interface myAnn { + + } +} diff --git a/src/test/resources/com/puppycrawl/tools/checkstyle/checks/annotation/DifferentUseStyles.java b/src/test/resources/com/puppycrawl/tools/checkstyle/checks/annotation/DifferentUseStyles.java new file mode 100644 index 000000000..2d4b1435e --- /dev/null +++ b/src/test/resources/com/puppycrawl/tools/checkstyle/checks/annotation/DifferentUseStyles.java @@ -0,0 +1,65 @@ +package com.puppycrawl.tools.checkstyle.checks.annotation; + +@Deprecated +@SomeArrays(pooches={DOGS.LEO}) +@SuppressWarnings({""}) +public class DifferentUseStyles +{ + +} + +@SomeArrays(pooches={DOGS.LEO}, um={}, duh={"bleh"}) +@SuppressWarnings("") //compact_no_array +@Deprecated() +class Dep { + +} + +@Deprecated +@SomeArrays(pooches={DOGS.LEO}) +@SuppressWarnings({""}) +enum SON { + + @Deprecated + @SomeArrays(pooches={DOGS.LEO}, um={""}, duh={"bleh"}) + @APooch(dog=DOGS.HERBIE) + @Another("") //compact_no_array + ETHAN +} + +@MyAnnotation13() +enum DOGS { + + @Deprecated() + LEO, + HERBIE +} + +@interface SomeArrays { + @Another("") //compact + String[] um() default {}; + @Another({""}) //compact + String[] duh() default {}; + @Another(value={""}) //expanded + DOGS[] pooches(); +} + +@Another(value={""}) //expanded +enum E { + +} + +@interface APooch { + DOGS dog(); +} + +@interface Another { + String[] value(); + @Another({"foo", "bar"}) //compact style + String value1() default ""; +} + +@SomeArrays(pooches = {}) +@Another({}) +class Closing { +}
\ No newline at end of file diff --git a/src/test/resources/com/puppycrawl/tools/checkstyle/checks/annotation/InputAnnotationLocationCheckTest1.java b/src/test/resources/com/puppycrawl/tools/checkstyle/checks/annotation/InputAnnotationLocationCheckTest1.java new file mode 100644 index 000000000..ee72b54a2 --- /dev/null +++ b/src/test/resources/com/puppycrawl/tools/checkstyle/checks/annotation/InputAnnotationLocationCheckTest1.java @@ -0,0 +1,5 @@ +package com.puppycrawl.tools.checkstyle.checks.annotation; + +public class InputAnnotationLocationCheckTest1 { + +}
\ No newline at end of file diff --git a/src/test/resources/com/puppycrawl/tools/checkstyle/checks/annotation/InputAnnotationLocationCheckTest2.java b/src/test/resources/com/puppycrawl/tools/checkstyle/checks/annotation/InputAnnotationLocationCheckTest2.java new file mode 100644 index 000000000..299ff5bf0 --- /dev/null +++ b/src/test/resources/com/puppycrawl/tools/checkstyle/checks/annotation/InputAnnotationLocationCheckTest2.java @@ -0,0 +1,26 @@ +package com.puppycrawl.tools.checkstyle.checks.annotation; + +@MyAnnotation11 @MyAnnotation12 @MyAnnotation13 +public class InputAnnotationLocationCheckTest2 { + + @MyAnnotation13 + void method() { + + } + + @MyAnnotation13 + @MyAnnotation12 + void method2() { + + } + +} + +@interface MyAnnotation11 { +} + +@interface MyAnnotation12 { +} + +@interface MyAnnotation13 { +}
\ No newline at end of file diff --git a/src/test/resources/com/puppycrawl/tools/checkstyle/checks/annotation/InputAnnotationUseStyleCheckTest.java b/src/test/resources/com/puppycrawl/tools/checkstyle/checks/annotation/InputAnnotationUseStyleCheckTest.java new file mode 100644 index 000000000..9ea5b2449 --- /dev/null +++ b/src/test/resources/com/puppycrawl/tools/checkstyle/checks/annotation/InputAnnotationUseStyleCheckTest.java @@ -0,0 +1,12 @@ +package com.puppycrawl.tools.checkstyle.checks.annotation; + + +@interface SomeArrays32 { + @Another32(value={"foo", "bar"}) //expanded + DOGS[] pooches(); +} + + +@interface Another32 { + String[] value(); +} diff --git a/src/test/resources/com/puppycrawl/tools/checkstyle/checks/annotation/InputCorrectAnnotationLocation.java b/src/test/resources/com/puppycrawl/tools/checkstyle/checks/annotation/InputCorrectAnnotationLocation.java new file mode 100644 index 000000000..f3d8fe4dc --- /dev/null +++ b/src/test/resources/com/puppycrawl/tools/checkstyle/checks/annotation/InputCorrectAnnotationLocation.java @@ -0,0 +1,105 @@ +package com.puppycrawl.tools.checkstyle.checks.annotation; + + + + +@MyAnnotation6 +@MyAnnotation5 +class InputCorrectAnnotationLocation +{ + + @MyAnnotation6 + @MyAnnotation5 + public int a; + + @MyAnnotation5 + public int b; + + @MyAnnotation6 + @MyAnnotation5 + public int c; + + @MyAnnotation5 + public int d; + + @MyAnnotation6 + @MyAnnotation5 + public InputCorrectAnnotationLocation() + { + //comment + } + @MyAnnotation5 + @MyAnnotation6 + void foo1() {} + + @MyAnnotation5 + @MyAnnotation6 + void foo2() {} + + @MyAnnotation5 + @MyAnnotation6 + @MyAnnotation3 + @MyAnnotation4 + class InnerClass + { + @MyAnnotation6 + @MyAnnotation5 + public int a; + + @MyAnnotation5 + public int b; + + @MyAnnotation6 + @MyAnnotation5 + public int c; + + @MyAnnotation5 + public int d; + + @MyAnnotation6 + public InnerClass() + { + // comment + } + @MyAnnotation5 + @MyAnnotation6 void foo1(int a) {} + + @MyAnnotation5 + @MyAnnotation6 + void foo2() {} + } + + @MyAnnotation5 + @MyAnnotation6 + InnerClass anon = new InnerClass() + { + @MyAnnotation6 + @MyAnnotation5 + public int a; + + @MyAnnotation5 public int b; + + @MyAnnotation6 + @MyAnnotation5 + public int c; + + @MyAnnotation5 + public int d; + + @MyAnnotation5 + @MyAnnotation6 void foo1() {} + + @MyAnnotation5 + @MyAnnotation6 + void foo2() {} + }; + +} + +@MyAnnotation5 +@MyAnnotation6 +class _Foo {} + +@interface MyAnnotation5 {} + +@interface MyAnnotation6 {} diff --git a/src/test/resources/com/puppycrawl/tools/checkstyle/checks/annotation/InputIncorrectAnnotationLocation.java b/src/test/resources/com/puppycrawl/tools/checkstyle/checks/annotation/InputIncorrectAnnotationLocation.java new file mode 100644 index 000000000..abb2f517b --- /dev/null +++ b/src/test/resources/com/puppycrawl/tools/checkstyle/checks/annotation/InputIncorrectAnnotationLocation.java @@ -0,0 +1,109 @@ +package com.puppycrawl.tools.checkstyle.checks.annotation; + + + + +@MyAnnotation2 @com.puppycrawl.tools.checkstyle.checks.annotation.MyAnnotation1 //warn +(value = "") +class InputIncorrectAnnotationLocation +{ + + @MyAnnotation2 @MyAnnotation1(value = "") + public int a; + + @MyAnnotation1(value = "") public int b; + + @MyAnnotation2 + @MyAnnotation1 //warn +(value = "") + public int c; + + @MyAnnotation1(value = "") + public int d; + + @MyAnnotation2 + @MyAnnotation1 //warn +(value = "") + public InputIncorrectAnnotationLocation() {} + + @MyAnnotation1("foo") @MyAnnotation2 void foo1() {} //warn + + @MyAnnotation1(value = "") + @MyAnnotation2 //warn + void foo2() {} + + @MyAnnotation1(value = "") + @MyAnnotation2 //warn + @MyAnnotation3 //warn + @MyAnnotation4 //warn + class InnerClass + { + @MyAnnotation2 @MyAnnotation1 //warn +(value = "") + public int a; + + @MyAnnotation1(value = "") public int b; + + @MyAnnotation2 + @MyAnnotation1 //warn +(value = "") + public int c; + + @MyAnnotation1(value = "") + public int d; + + @MyAnnotation2 + @MyAnnotation1(value = "") public InnerClass() + { + // comment + } + @MyAnnotation1(value = "") + @MyAnnotation2 //warn + void foo1() {} + + @MyAnnotation1(value = "") + @MyAnnotation2 //warn + void foo2() {} + } + + @MyAnnotation1(value = "") + @MyAnnotation2 //warn + InnerClass anon = new InnerClass() + { + @MyAnnotation2 @MyAnnotation1(value = "") public int a; + + @MyAnnotation1(value = "") public int b; + + @MyAnnotation2 + @MyAnnotation1(value = "") + public int c; + + @MyAnnotation1(value = "") + public int d; + + @MyAnnotation1(value = "") + @MyAnnotation2 void foo1() {} //warn + + @MyAnnotation1(value = "") + @MyAnnotation2 //warn + void foo2() {} + + @MyAnnotation1(value = "") void foo42() {} + }; + +} + + @MyAnnotation1 //warn +(value = "") +@MyAnnotation2 +class Foo {} + +@interface MyAnnotation1 { + + String value();} + +@interface MyAnnotation2 {} + +@interface MyAnnotation3 {} + +@interface MyAnnotation4 {} |