Skip to content

Commit

Permalink
Fix '@' character in javadoc code snippets
Browse files Browse the repository at this point in the history
See also unknown commit

PiperOrigin-RevId: 511523970
  • Loading branch information
cushon authored and Error Prone Team committed Feb 22, 2023
1 parent 9b4ea86 commit 7976d8f
Show file tree
Hide file tree
Showing 10 changed files with 99 additions and 99 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -26,16 +26,16 @@
* Annotation declaring that the target annotation is incompatible with any one of the provided
* modifiers. For example, an annotation declared as:
*
* <pre>
* {@literal @}IncompatibleModifiers(modifier = Modifier.PUBLIC)
* {@literal @}interface MyAnnotation {}
* <pre>{@code
* @IncompatibleModifiers(modifier = Modifier.PUBLIC)
* @interface MyAnnotation {}
* </pre>
*
* <p>will be considered illegal when used as:
*
* <pre>
* {@literal @}MyAnnotation public void foo() {}
* </pre>
* @MyAnnotation public void foo() {}
* }</pre>
*
* @author [email protected] (Jige Yu)
*/
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -26,16 +26,16 @@
* Annotation declaring that the target annotation requires all the specified modifiers. For
* example, an annotation declared as:
*
* <pre>
* {@literal @}RequiredModifiers(modifier = Modifier.PUBLIC)
* {@literal @}interface MyAnnotation {}
* </pre>
* <pre>{@code
* @RequiredModifiers(modifier = Modifier.PUBLIC)
* @interface MyAnnotation {}
* }</pre>
*
* <p>will be considered illegal when used on non-public elements such as:
*
* <pre>
* {@literal @}MyAnnotation void foo() {}
* </pre>
* <pre>{@code
* @MyAnnotation void foo() {}
* }</pre>
*
* @author [email protected] (Jige Yu)
*/
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -32,7 +32,7 @@
*
* <pre>{@code
* private final String source;
* {@literal @}LazyInit private String data;
* @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
* {@literal @}MyCustomAnnotation("value")
* @MyCustomAnnotation("value")
* public class AnnotatedRefasterRule {
* {@literal @}BeforeTemplate void before(String x) {...}
* {@literal @}AfterTemplate void after(String x) {...}
* @BeforeTemplate void before(String x) {...}
* @AfterTemplate void after(String x) {...}
* }
* }</pre>
*
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -481,16 +481,16 @@ public static final class ExpectedLockCalculator {
*
* <p>For example:
*
* <pre><code>
* <pre>{@code
* class MyClass {
* final Object mu = new Object();
* {@literal @}GuardedBy("mu")
* @GuardedBy("mu")
* int x;
* }
* void m(MyClass myClass) {
* myClass.x++;
* }
* </code></pre>
* }</pre>
*
* To determine the lock that must be held when accessing myClass.x, from is called with
* "myClass.x" and "mu", and returns "myClass.mu".
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -666,11 +666,11 @@ && isThreadSafeType(
* <p>Usually only the immediately enclosing declaration is searched, but it's possible to have
* cases like:
*
* <pre>
* {@literal @}MarkerAnnotation(containerOf="T") class C&lt;T&gt; {
* class Inner extends ThreadSafeCollection&lt;T&gt; {}
* <pre>{@code
* @MarkerAnnotation(containerOf="T") class C<T> {
* class Inner extends ThreadSafeCollection<T> {}
* }
* </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 @@ -32,11 +32,11 @@ private Refaster() {}
*
* <p>For example, you might write
*
* <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>
* <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>
*/
public static <T> T[] asVarargs(T arg) {
throw new UnsupportedOperationException();
Expand All @@ -50,24 +50,24 @@ public static <T> T[] asVarargs(T arg) {
*
* <p>For example, instead of writing
*
* <pre><code>
* {@literal @}BeforeTemplate &lt;E&gt; List&lt;E&gt; copyOfSingleton(E element) {
* <pre>{@code
* @BeforeTemplate <E> List<E> copyOfSingleton(E element) {
* return ImmutableList.copyOf(Collections.singletonList(element));
* }
* {@literal @}BeforeTemplate &lt;E&gt; List&lt;E&gt; copyOfArrayList(E element) {
* @BeforeTemplate <E> List<E> copyOfArrayList(E element) {
* return ImmutableList.copyOf(Lists.newArrayList(element));
* }
* </code></pre>
* }</pre>
*
* <p>one could alternately write
*
* <pre><code>
* {@literal @}BeforeTemplate &lt;E&gt; List&lt;E&gt; singleton(E element) {
* <pre>{@code
* @BeforeTemplate <E> List<E> singleton(E element) {
* return ImmutableList.copyOf(Refaster.anyOf(
* Collections.singletonList(element),
* Lists.newArrayList(element)));
* }
* </code></pre>
* }</pre>
*/
@SafeVarargs
@CanIgnoreReturnValue
Expand All @@ -82,19 +82,19 @@ public static <T> T anyOf(T... expressions) {
*
* <p>For example, instead of writing the broken
*
* <pre><code>
* {@literal @}AfterTemplate &lt;T&gt; boolean instanceOf(Object o) {
* <pre>{@code
* @AfterTemplate <T> boolean instanceOf(Object o) {
* return o instanceof T; // you want to match this, but it won't compile
* }
* </code></pre>
* }</pre>
*
* <p>you would instead write
*
* <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
* @AfterTemplate <T> boolean instanceOf(Object o) {
* return Refaster.<T>isInstance(o); // generates the replacement "o instanceof T"
* }
* </code></pre>
* }</pre>
*
* @throws IllegalArgumentException if T is not specified explicitly.
*/
Expand All @@ -109,19 +109,19 @@ public static <T> boolean isInstance(Object o) {
*
* <p>For example, instead of writing the broken
*
* <pre><code>
* {@literal @}AfterTemplate &lt;T&gt; T[] newTArray(int size) {
* <pre>{@code
* @AfterTemplate <T> T[] newTArray(int size) {
* return new T[size]; // you want to generate this code, but it won't compile
* }
* </code></pre>
* }</pre>
*
* <p>you would instead write
*
* <pre><code>
* {@literal @}AfterTemplate &lt;T&gt; T[] newTArray(int size) {
* return Refaster.&lt;T&gt;newArray(size);
* <pre>{@code
* @AfterTemplate <T> T[] newTArray(int size) {
* return Refaster.<T>newArray(size);
* }
* </code></pre>
* }</pre>
*
* @throws IllegalArgumentException if T is not specified explicitly.
*/
Expand All @@ -135,19 +135,19 @@ public static <T> T[] newArray(int size) {
*
* <p>For example, instead of writing the broken
*
* <pre><code>
* {@literal @}AfterTemplate &lt;T&gt; T[] getEnumConstants() {
* <pre>{@code
* @AfterTemplate <T> T[] getEnumConstants() {
* return T.class.getEnumConstants(); // you want to inline this, but it won't compile
* }
* </code></pre>
* }</pre>
*
* you would instead write
*
* <pre><code>
* {@literal @}AfterTemplate &lt;T&gt; T[] getEnumConstants() {
* return Refaster.&lt;T&gt;clazz().getEnumConstants();
* <pre>{@code
* @AfterTemplate <T> T[] getEnumConstants() {
* return Refaster.<T>clazz().getEnumConstants();
* }
* </code></pre>
* }</pre>
*
* @throws IllegalArgumentException if T is not specified explicitly.
*/
Expand All @@ -161,19 +161,19 @@ public static <T> Class<T> clazz() {
*
* <p>For example, instead of writing the broken
*
* <pre><code>
* {@literal @}BeforeTemplate &lt;E extends Enum&lt;E&gt;&gt; E valueOf(String str) {
* <pre>{@code
* @BeforeTemplate <E extends Enum<E>> E valueOf(String str) {
* return E.valueOf(str);
* }
* </code></pre>
* }</pre>
*
* <p>you would instead write
*
* <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
* @BeforeTemplate <E extends Enum<E>> E valueOf(String str) {
* return Refaster.<E>enumValueOf(str);
* }
* </code></pre>
* }</pre>
*
* @throws IllegalArgumentException if E is not specified explicitly.
*/
Expand All @@ -187,19 +187,19 @@ public static <E extends Enum<E>> E enumValueOf(String string) {
*
* <p>For example, instead of writing
*
* <pre><code>
* {@literal @}AfterTemplate int lengthWithComment(String str) {
* <pre>{@code
* @AfterTemplate int lengthWithComment(String str) {
* return /* comment \*\/ str.length();
* }
* </code></pre>
* }</pre>
*
* <p>you would instead write
*
* <pre><code>
* {@literal @}AfterTemplate int lengthWithComment(String str) {
* <pre>{@code
* @AfterTemplate int lengthWithComment(String str) {
* return Refaster.emitCommentBefore("comment", str.length());
* }
* </code></pre>
* }</pre>
*/
public static <T> T emitCommentBefore(String literal, T expression) {
throw new UnsupportedOperationException();
Expand All @@ -211,21 +211,21 @@ public static <T> T emitCommentBefore(String literal, T expression) {
*
* <p>For example, instead of writing
*
* <pre><code>
* {@literal @}AfterTemplate void printWithComment(String str) {
* <pre>{@code
* @AfterTemplate void printWithComment(String str) {
* // comment
* System.out.println(str);
* }
* </code></pre>
* }</pre>
*
* <p>you would instead write
*
* <pre><code>
* {@literal @}AfterTemplate void printWithComment(String str) {
* <pre>{@code
* @AfterTemplate void printWithComment(String str) {
* Refaster.emitComment("comment");
* System.out.println(str);
* }
* </code></pre>
* }</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 {
* {@literal @}BeforeTemplate
* public <E> List<E> before({@literal @}Matches(IsNonNullMatcher.class) E e) {
* @BeforeTemplate
* public <E> List<E> before(@Matches(IsNonNullMatcher.class) E e) {
* return Collections.singletonList(e);
* }
*
* {@literal @}AfterTemplate
* @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 {
* {@literal @}Placeholder abstract void handleException(
* {@literal @}MayOptionallyUse UnsupportedEncodingException e);
* {@literal @}Placeholder abstract void useString(String str);
* {@literal @}BeforeTemplate void before(byte[] array) {
* @Placeholder abstract void handleException(
* @MayOptionallyUse UnsupportedEncodingException e);
* @Placeholder abstract void useString(String str);
* @BeforeTemplate void before(byte[] array) {
* try {
* useString(new String(array, "UTF_8"));
* } catch (UnsupportedEncodingException e) {
* handleException(e);
* }
* }
* {@literal @}AfterTemplate void after(byte[] array) {
* @AfterTemplate void after(byte[] array) {
* useString(new String(array, StandardCharsets.UTF_8));
* }
* }
* </code></pre>
* }</pre>
*
* would match even if the catch statement were empty, or didn't refer to e.
*/
Expand Down
Loading

0 comments on commit 7976d8f

Please sign in to comment.