Skip to content

Commit

Permalink
Restore javadoc @code workarounds
Browse files Browse the repository at this point in the history
The release build still uses JDK 8, so we can't rely on:
https://bugs.openjdk.java.net/browse/JDK-8241780

PiperOrigin-RevId: 351857243
  • Loading branch information
cushon authored and Error Prone Team committed Jan 14, 2021
1 parent eee9fff commit 7409d46
Show file tree
Hide file tree
Showing 11 changed files with 104 additions and 104 deletions.
2 changes: 1 addition & 1 deletion .github/workflows/ci.yml
Original file line number Diff line number Diff line change
Expand Up @@ -42,7 +42,7 @@ jobs:
java-version: ${{ matrix.java }}
- name: 'Install'
shell: bash
run: mvn install -DskipTests=true -Dmaven.javadoc.skip=true -B -V
run: mvn install -DskipTests=true -B -V
- name: 'Test'
shell: bash
run: mvn test -B
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -27,16 +27,16 @@
* Annotation declaring that the target annotation is incompatible with any one of the provided
* modifiers. For example, an annotation declared as:
*
* <pre>{@code
* @IncompatibleModifiers(Modifier.PUBLIC)
* @interface MyAnnotation {}
* }</pre>
* <pre>
* {@literal @}IncompatibleModifiers(Modifier.PUBLIC)
* {@literal @}interface MyAnnotation {}
* </pre>
*
* <p>will be considered illegal when used as:
*
* <pre>{@code
* @MyAnnotation public void foo() {}
* }</pre>
* <pre>
* {@literal @}MyAnnotation public void foo() {}
* </pre>
*
* @author benyu@google.com (Jige Yu)
*/
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -27,16 +27,16 @@
* Annotation declaring that the target annotation requires all the specified modifiers. For
* example, an annotation declared as:
*
* <pre>{@code
* @RequiredModifiers(Modifier.PUBLIC)
* @interface MyAnnotation {}
* }</pre>
* <pre>
* {@literal @}RequiredModifiers(Modifier.PUBLIC)
* {@literal @}interface MyAnnotation {}
* </pre>
*
* <p>will be considered illegal when used on non-public elements such as:
*
* <pre>{@code
* @MyAnnotation void foo() {}
* }</pre>
* <pre>
* {@literal @}MyAnnotation void foo() {}
* </pre>
*
* @author benyu@google.com (Jige Yu)
*/
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -38,15 +38,15 @@
* example through code review, could be marked {@code @ReviewedFooBar}.
*
* <pre>{@code
* public @interface LegacyUnsafeFooBar{}
* public {@literal @}interface LegacyUnsafeFooBar{}
*
* public @interface ReviewedFooBar{
* public {@literal @}interface ReviewedFooBar{
* public string reviewer();
* public string comments();
* }
*
* public class Foo {
* @RestrictedApi(
* {@literal @}RestrictedApi(
* explanation="You could shoot yourself in the foot with Foo.bar if you aren't careful",
* link="http://edsger.dijkstra/foo_bar_consider_harmful.html",
* allowedOnPath="testsuite/.*", // Unsafe behavior in tests is ok.
Expand All @@ -61,7 +61,7 @@
* }
* boolean complicatedCondition = true;
*
* @ReviewedFooBar(
* {@literal @}ReviewedFooBar(
* reviewer="bangert",
* comments="Makes sure complicatedCondition isn't true, so bar is safe!"
* )
Expand All @@ -71,7 +71,7 @@
* }
* }
*
* @LegacyUnsafeFooBar
* {@literal @}LegacyUnsafeFooBar
* public void someOldCode() {
* // ...
* bar()
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -33,7 +33,7 @@
*
* <pre>{@code
* private final String source;
* @LazyInit private String data;
* {@literal @}LazyInit private String data;
*
* public String getData() {
* String local = data;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -37,10 +37,10 @@ public interface CodeTransformer {
* applied to it:
*
* <pre>{@code
* @MyCustomAnnotation("value")
* {@literal @}MyCustomAnnotation("value")
* public class AnnotatedRefasterRule {
* @BeforeTemplate void before(String x) {...}
* @AfterTemplate void after(String x) {...}
* {@literal @}BeforeTemplate void before(String x) {...}
* {@literal @}AfterTemplate void after(String x) {...}
* }
* }</pre>
*
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -686,11 +686,11 @@ && isThreadSafeType(
* <p>Usually only the immediately enclosing declaration is searched, but it's possible to have
* cases like:
*
* <pre>{@code
* @MarkerAnnotation(containerOf="T") class C<T> {
* class Inner extends ThreadSafeCollection<T> {}
* <pre>
* {@literal @}MarkerAnnotation(containerOf="T") class C&lt;T&gt; {
* class Inner extends ThreadSafeCollection&lt;T&gt; {}
* }
* }</pre>
* </pre>
*/
public Set<String> threadSafeTypeParametersInScope(Symbol sym) {
if (sym == null) {
Expand Down
104 changes: 52 additions & 52 deletions core/src/main/java/com/google/errorprone/refaster/Refaster.java
Original file line number Diff line number Diff line change
Expand Up @@ -30,11 +30,11 @@ private Refaster() {}
*
* <p>For example, you might write
*
* <pre>{@code
* @BeforeTemplate void something(@Repeated T arg) {
* Stream.of(asVarargs(arg)); // doesn't use the Stream.of(T) overload, but Stream.of(T...)
* }
* }</pre>
* <pre><code>
* {@literal @}BeforeTemplate void something(@Repeated T arg) {
* Stream.of(asVarargs(arg)); // doesn't use the Stream.of(T) overload, but Stream.of(T...)
* }
* </code></pre>
*/
public static <T> T[] asVarargs(T arg) {
throw new UnsupportedOperationException();
Expand All @@ -48,24 +48,24 @@ public static <T> T[] asVarargs(T arg) {
*
* <p>For example, instead of writing
*
* <pre>{@code
* @BeforeTemplate <E> List<E> copyOfSingleton(E element) {
* <pre><code>
* {@literal @}BeforeTemplate &lt;E&gt; List&lt;E&gt; copyOfSingleton(E element) {
* return ImmutableList.copyOf(Collections.singletonList(element));
* }
* @BeforeTemplate <E> List<E> copyOfArrayList(E element) {
* {@literal @}BeforeTemplate &lt;E&gt; List&lt;E&gt; copyOfArrayList(E element) {
* return ImmutableList.copyOf(Lists.newArrayList(element));
* }
* }</pre>
* </code></pre>
*
* <p>one could alternately write
*
* <pre>{@code
* @BeforeTemplate <E> List<E> singleton(E element) {
* <pre><code>
* {@literal @}BeforeTemplate &lt;E&gt; List&lt;E&gt; singleton(E element) {
* return ImmutableList.copyOf(Refaster.anyOf(
* Collections.singletonList(element),
* Lists.newArrayList(element)));
* }
* }</pre>
* </code></pre>
*/
@SafeVarargs
public static <T> T anyOf(T... expressions) {
Expand All @@ -79,19 +79,19 @@ public static <T> T anyOf(T... expressions) {
*
* <p>For example, instead of writing the broken
*
* <pre>{@code
* @AfterTemplate <T> boolean instanceOf(Object o) {
* <pre><code>
* {@literal @}AfterTemplate &lt;T&gt; boolean instanceOf(Object o) {
* return o instanceof T; // you want to match this, but it won't compile
* }
* }</pre>
* </code></pre>
*
* <p>you would instead write
*
* <pre>{@code
* @AfterTemplate <T> boolean instanceOf(Object o) {
* return Refaster.<T>isInstance(o); // generates the replacement "o instanceof T"
* <pre><code>
* {@literal @}AfterTemplate &lt;T&gt; boolean instanceOf(Object o) {
* return Refaster.&lt;T&gt;isInstance(o); // generates the replacement "o instanceof T"
* }
* }</pre>
* </code></pre>
*
* @throws IllegalArgumentException if T is not specified explicitly.
*/
Expand All @@ -106,19 +106,19 @@ public static <T> boolean isInstance(Object o) {
*
* <p>For example, instead of writing the broken
*
* <pre>{@code
* @AfterTemplate <T> T[] newTArray(int size) {
* <pre><code>
* {@literal @}AfterTemplate &lt;T&gt; T[] newTArray(int size) {
* return new T[size]; // you want to generate this code, but it won't compile
* }
* }</pre>
* </code></pre>
*
* <p>you would instead write
*
* <pre>{@code
* @AfterTemplate <T> T[] newTArray(int size) {
* return Refaster.<T>newArray(size);
* <pre><code>
* {@literal @}AfterTemplate &lt;T&gt; T[] newTArray(int size) {
* return Refaster.&lt;T&gt;newArray(size);
* }
* }</pre>
* </code></pre>
*
* @throws IllegalArgumentException if T is not specified explicitly.
*/
Expand All @@ -132,19 +132,19 @@ public static <T> T[] newArray(int size) {
*
* <p>For example, instead of writing the broken
*
* <pre>{@code
* @AfterTemplate <T> T[] getEnumConstants() {
* <pre><code>
* {@literal @}AfterTemplate &lt;T&gt; T[] getEnumConstants() {
* return T.class.getEnumConstants(); // you want to inline this, but it won't compile
* }
* }</pre>
* </code></pre>
*
* you would instead write
*
* <pre>{@code
* @AfterTemplate <T> T[] getEnumConstants() {
* return Refaster.<T>clazz().getEnumConstants();
* <pre><code>
* {@literal @}AfterTemplate &lt;T&gt; T[] getEnumConstants() {
* return Refaster.&lt;T&gt;clazz().getEnumConstants();
* }
* }</pre>
* </code></pre>
*
* @throws IllegalArgumentException if T is not specified explicitly.
*/
Expand All @@ -158,19 +158,19 @@ public static <T> Class<T> clazz() {
*
* <p>For example, instead of writing the broken
*
* <pre>{@code
* @BeforeTemplate <E extends Enum<E>> E valueOf(String str) {
* <pre><code>
* {@literal @}BeforeTemplate &lt;E extends Enum&lt;E&gt;&gt; E valueOf(String str) {
* return E.valueOf(str);
* }
* }</pre>
* </code></pre>
*
* <p>you would instead write
*
* <pre>{@code
* @BeforeTemplate <E extends Enum<E>> E valueOf(String str) {
* return Refaster.<E>enumValueOf(str);
* <pre><code>
* {@literal @}BeforeTemplate &lt;E extends Enum&lt;E&gt;&gt; E valueOf(String str) {
* return Refaster.&lt;E&gt;enumValueOf(str);
* }
* }</pre>
* </code></pre>
*
* @throws IllegalArgumentException if E is not specified explicitly.
*/
Expand All @@ -184,19 +184,19 @@ public static <E extends Enum<E>> E enumValueOf(String string) {
*
* <p>For example, instead of writing
*
* <pre>{@code
* @AfterTemplate int lengthWithComment(String str) {
* <pre><code>
* {@literal @}AfterTemplate int lengthWithComment(String str) {
* return /* comment \*\/ str.length();
* }
* }</pre>
* </code></pre>
*
* <p>you would instead write
*
* <pre>{@code
* @AfterTemplate int lengthWithComment(String str) {
* <pre><code>
* {@literal @}AfterTemplate int lengthWithComment(String str) {
* return Refaster.emitCommentBefore("comment", str.length());
* }
* }</pre>
* </code></pre>
*/
public static <T> T emitCommentBefore(String literal, T expression) {
throw new UnsupportedOperationException();
Expand All @@ -208,21 +208,21 @@ public static <T> T emitCommentBefore(String literal, T expression) {
*
* <p>For example, instead of writing
*
* <pre>{@code
* @AfterTemplate void printWithComment(String str) {
* <pre><code>
* {@literal @}AfterTemplate void printWithComment(String str) {
* // comment
* System.out.println(str);
* }
* }</pre>
* </code></pre>
*
* <p>you would instead write
*
* <pre>{@code
* @AfterTemplate void printWithComment(String str) {
* <pre><code>
* {@literal @}AfterTemplate void printWithComment(String str) {
* Refaster.emitComment("comment");
* System.out.println(str);
* }
* }</pre>
* </code></pre>
*/
public static void emitComment(String literal) {
throw new UnsupportedOperationException();
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -32,12 +32,12 @@
*
* <pre>{@code
* class SingletonList {
* @BeforeTemplate
* public <E> List<E> before(@Matches(IsNonNullMatcher.class) E e) {
* {@literal @}BeforeTemplate
* public <E> List<E> before({@literal @}Matches(IsNonNullMatcher.class) E e) {
* return Collections.singletonList(e);
* }
*
* @AfterTemplate
* {@literal @}AfterTemplate
* public <E> List<E> after(E e) {
* return ImmutableList.of(e);
* }
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -25,23 +25,23 @@
* Indicates that a parameter to a placeholder method is not required to be used in the
* placeholder's implementation. For example, the pattern
*
* <pre>{@code
* <pre><code>
* abstract class Utf8Bytes {
* @Placeholder abstract void handleException(
* @MayOptionallyUse UnsupportedEncodingException e);
* @Placeholder abstract void useString(String str);
* @BeforeTemplate void before(byte[] array) {
* {@literal @}Placeholder abstract void handleException(
* {@literal @}MayOptionallyUse UnsupportedEncodingException e);
* {@literal @}Placeholder abstract void useString(String str);
* {@literal @}BeforeTemplate void before(byte[] array) {
* try {
* useString(new String(array, "UTF_8"));
* } catch (UnsupportedEncodingException e) {
* handleException(e);
* }
* }
* @AfterTemplate void after(byte[] array) {
* {@literal @}AfterTemplate void after(byte[] array) {
* useString(new String(array, StandardCharsets.UTF_8));
* }
* }
* }</pre>
* </code></pre>
*
* would match even if the catch statement were empty, or didn't refer to e.
*/
Expand Down
Loading

0 comments on commit 7409d46

Please sign in to comment.