-
-
Notifications
You must be signed in to change notification settings - Fork 352
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
fix(pretty-print): the annotation values are now pretty-printed in th…
- Loading branch information
Showing
5 changed files
with
152 additions
and
6 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
104 changes: 104 additions & 0 deletions
104
src/test/resources/printer-test/spoon/test/AnnotationSpecTest.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,104 @@ | ||
/* | ||
* Copyright (C) 2015 Square, Inc. | ||
* | ||
* Licensed under the Apache License, Version 2.0 (the "License"); | ||
* you may not use this file except in compliance with the License. | ||
* You may obtain a copy of the License at | ||
* | ||
* http://www.apache.org/licenses/LICENSE-2.0 | ||
* | ||
* Unless required by applicable law or agreed to in writing, software | ||
* distributed under the License is distributed on an "AS IS" BASIS, | ||
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. | ||
* See the License for the specific language governing permissions and | ||
* limitations under the License. | ||
*/ | ||
package com.squareup.javapoet; | ||
|
||
import com.google.testing.compile.CompilationRule; | ||
import java.lang.annotation.Annotation; | ||
import java.lang.annotation.Inherited; | ||
import java.lang.annotation.Retention; | ||
import java.lang.annotation.RetentionPolicy; | ||
import javax.lang.model.element.TypeElement; | ||
import org.junit.Rule; | ||
import org.junit.Test; | ||
|
||
import static com.google.common.truth.Truth.assertThat; | ||
|
||
public final class AnnotationSpecTest { | ||
|
||
@Retention(RetentionPolicy.RUNTIME) | ||
public @interface AnnotationA { | ||
} | ||
|
||
@Inherited | ||
@Retention(RetentionPolicy.RUNTIME) | ||
public @interface AnnotationB { | ||
} | ||
|
||
@Retention(RetentionPolicy.RUNTIME) | ||
public @interface AnnotationC { | ||
String value(); | ||
} | ||
|
||
public enum Breakfast { | ||
WAFFLES, PANCAKES; | ||
public String toString() { return name() + " with cherries!"; }; | ||
} | ||
|
||
@Retention(RetentionPolicy.RUNTIME) | ||
public @interface HasDefaultsAnnotation { | ||
|
||
byte a() default 5; | ||
|
||
short b() default 6; | ||
|
||
int c() default 7; | ||
|
||
long d() default 8; | ||
|
||
float e() default 9.0f; | ||
|
||
double f() default 10.0; | ||
|
||
char[] g() default {0, 0xCAFE, 'z', '€', 'ℕ', '"', '\'', '\t', '\n'}; | ||
|
||
boolean h() default true; | ||
|
||
Breakfast i() default Breakfast.WAFFLES; | ||
|
||
AnnotationA j() default @AnnotationA(); | ||
|
||
String k() default "maple"; | ||
|
||
Class<? extends Annotation> l() default AnnotationB.class; | ||
|
||
int[] m() default {1, 2, 3}; | ||
|
||
Breakfast[] n() default {Breakfast.WAFFLES, Breakfast.PANCAKES}; | ||
|
||
Breakfast o(); | ||
|
||
int p(); | ||
|
||
AnnotationC q() default @AnnotationC("foo"); | ||
|
||
Class<? extends Number>[] r() default {Byte.class, Short.class, Integer.class, Long.class}; | ||
|
||
} | ||
|
||
@HasDefaultsAnnotation( | ||
o = Breakfast.PANCAKES, | ||
p = 1701, | ||
f = 11.1, | ||
m = {9, 8, 1}, | ||
l = Override.class, | ||
j = @AnnotationA, | ||
q = @AnnotationC("bar"), | ||
r = {Float.class, Double.class}) | ||
public class IsAnnotated { | ||
// empty | ||
} | ||
|
||
} |