Skip to content

Commit

Permalink
Automated rollback of commit 1a87579.
Browse files Browse the repository at this point in the history
*** Reason for rollback ***

TAP shows this is broke Voice Access (and perhaps other projects)

[]

*** Original change description ***

Format type annotation as part of the type, not part of the modifiers list

Given e.g. `@Deprecated @nullable Object foo() {}`, prefer this:

```
@deprecated
@nullable Object foo() {}
```

instead of:

```
@deprecated
@nullable
Object foo() {}
```

The implementation is complicated by the fact that the AST doesn't store
source position information for modifiers, and there's no requirement that
declaration annotations, modifiers, and type annotations appear in any
particular order in source.

To...

***

PiperOrigin-RevId: 392785771
  • Loading branch information
java-team-github-bot authored and google-java-format Team committed Aug 25, 2021
1 parent 1a87579 commit 37f716a
Show file tree
Hide file tree
Showing 7 changed files with 68 additions and 398 deletions.
6 changes: 1 addition & 5 deletions core/pom.xml
Expand Up @@ -51,11 +51,7 @@
<artifactId>error_prone_annotations</artifactId>
<optional>true</optional>
</dependency>
<dependency>
<groupId>com.google.auto.value</groupId>
<artifactId>auto-value-annotations</artifactId>
<optional>true</optional>
</dependency>


<!-- Test dependencies -->
<dependency>
Expand Down
24 changes: 0 additions & 24 deletions core/src/main/java/com/google/googlejavaformat/OpsBuilder.java
Expand Up @@ -18,8 +18,6 @@
import static java.lang.Math.min;

import com.google.common.base.MoreObjects;
import com.google.common.base.Preconditions;
import com.google.common.base.Predicate;
import com.google.common.collect.ArrayListMultimap;
import com.google.common.collect.ImmutableList;
import com.google.common.collect.Iterables;
Expand Down Expand Up @@ -283,28 +281,6 @@ public final Optional<String> peekToken(int skip) {
: Optional.empty();
}

/**
* Returns the {@link Input.Tok}s starting at the current source position, which are satisfied by
* the given predicate.
*/
public ImmutableList<Tok> peekTokens(int startPosition, Predicate<Input.Tok> predicate) {
ImmutableList<? extends Input.Token> tokens = input.getTokens();
Preconditions.checkState(
tokens.get(tokenI).getTok().getPosition() == startPosition,
"Expected the current token to be at position %s, found: %s",
startPosition,
tokens.get(tokenI));
ImmutableList.Builder<Tok> result = ImmutableList.builder();
for (int idx = tokenI; idx < tokens.size(); idx++) {
Tok tok = tokens.get(idx).getTok();
if (!predicate.apply(tok)) {
break;
}
result.add(tok);
}
return result.build();
}

/**
* Emit an optional token iff it exists on the input. This is used to emit tokens whose existence
* has been lost in the AST.
Expand Down

0 comments on commit 37f716a

Please sign in to comment.