Skip to content

Commit

Permalink
Reformat with the latest google-java-format changes
Browse files Browse the repository at this point in the history
Including some improvements for JSpecify type annotations, blank lines between
declarations, and parameter comments.

PiperOrigin-RevId: 575866598
  • Loading branch information
cushon authored and Javac Team committed Oct 23, 2023
1 parent a79e7af commit 5584bf5
Show file tree
Hide file tree
Showing 20 changed files with 37 additions and 57 deletions.
3 changes: 1 addition & 2 deletions java/com/google/turbine/binder/ClassPath.java
Original file line number Diff line number Diff line change
Expand Up @@ -39,6 +39,5 @@ public interface ClassPath {
/** The classpath's top level index. */
TopLevelIndex index();

@Nullable
Supplier<byte[]> resource(String path);
@Nullable Supplier<byte[]> resource(String path);
}
6 changes: 2 additions & 4 deletions java/com/google/turbine/binder/ConstEvaluator.java
Original file line number Diff line number Diff line change
Expand Up @@ -234,8 +234,7 @@ private ClassSymbol resolveNext(int position, ClassSymbol sym, Ident bit) {
}

/** Evaluates a reference to another constant variable. */
@Nullable
Const evalConstVar(ConstVarName t) {
@Nullable Const evalConstVar(ConstVarName t) {
FieldInfo field = resolveField(t);
if (field == null) {
return null;
Expand Down Expand Up @@ -1312,8 +1311,7 @@ AnnoInfo evaluateAnnotation(AnnoInfo info) {
return new Const.ArrayInitValue(elements.build());
}

@Nullable
Const evalAnnotationValue(Tree tree, Type ty) {
@Nullable Const evalAnnotationValue(Tree tree, Type ty) {
if (ty == null) {
throw error(tree.position(), ErrorKind.EXPRESSION_ERROR);
}
Expand Down
6 changes: 2 additions & 4 deletions java/com/google/turbine/binder/JimageClassBinder.java
Original file line number Diff line number Diff line change
Expand Up @@ -105,14 +105,12 @@ public JimageClassBinder(ImmutableMultimap<String, String> packageMap, Path modu
this.modulesRoot = modules;
}

@Nullable
Path modulePath(String moduleName) {
@Nullable Path modulePath(String moduleName) {
Path path = modulesRoot.resolve(moduleName);
return Files.exists(path) ? path : null;
}

@Nullable
ModuleInfo module(String moduleName) {
@Nullable ModuleInfo module(String moduleName) {
ModuleInfo result = moduleMap.get(moduleName);
if (result == null) {
Path path = modulePath(moduleName);
Expand Down
3 changes: 1 addition & 2 deletions java/com/google/turbine/binder/bound/BoundClass.java
Original file line number Diff line number Diff line change
Expand Up @@ -32,8 +32,7 @@ public interface BoundClass {
TurbineTyKind kind();

/** The enclosing declaration for member types, or {@code null} for top-level declarations. */
@Nullable
ClassSymbol owner();
@Nullable ClassSymbol owner();

/** Class access bits (see JVMS table 4.1). */
int access();
Expand Down
3 changes: 1 addition & 2 deletions java/com/google/turbine/binder/bound/HeaderBoundClass.java
Original file line number Diff line number Diff line change
Expand Up @@ -25,8 +25,7 @@
/** A bound node that augments {@link BoundClass} with superclasses and interfaces. */
public interface HeaderBoundClass extends BoundClass {
/** The superclass of the declaration. */
@Nullable
ClassSymbol superclass();
@Nullable ClassSymbol superclass();

/** The interfaces of the declaration. */
ImmutableList<ClassSymbol> interfaces();
Expand Down
6 changes: 2 additions & 4 deletions java/com/google/turbine/binder/bound/TypeBoundClass.java
Original file line number Diff line number Diff line change
Expand Up @@ -38,8 +38,7 @@
public interface TypeBoundClass extends HeaderBoundClass {

/** The super-class type. */
@Nullable
Type superClassType();
@Nullable Type superClassType();

/** Implemented interface types. */
ImmutableList<Type> interfaceTypes();
Expand All @@ -62,8 +61,7 @@ public interface TypeBoundClass extends HeaderBoundClass {
* Annotation metadata, e.g. from {@link java.lang.annotation.Target}, {@link
* java.lang.annotation.Retention}, and {@link java.lang.annotation.Repeatable}.
*/
@Nullable
AnnotationMetadata annotationMetadata();
@Nullable AnnotationMetadata annotationMetadata();

/** Declaration annotations. */
ImmutableList<AnnoInfo> annotations();
Expand Down
3 changes: 1 addition & 2 deletions java/com/google/turbine/binder/env/Env.java
Original file line number Diff line number Diff line change
Expand Up @@ -35,8 +35,7 @@
*/
public interface Env<S extends Symbol, V> {
/** Returns the information associated with the given symbol in this environment. */
@Nullable
V get(S sym);
@Nullable V get(S sym);

default V getNonNull(S sym) {
V result = get(sym);
Expand Down
3 changes: 1 addition & 2 deletions java/com/google/turbine/binder/env/LazyEnv.java
Original file line number Diff line number Diff line change
Expand Up @@ -81,8 +81,7 @@ public LazyEnv(ImmutableMap<S, Completer<S, T, V>> completers, Env<S, ? extends
/** A lazy value provider which is given access to the current environment. */
public interface Completer<S extends Symbol, T, V extends T> {
/** Provides the value for the given symbol in the current environment. */
@Nullable
V complete(Env<S, T> env, S k);
@Nullable V complete(Env<S, T> env, S k);
}

/** Indicates that a completer tried to complete itself, possibly transitively. */
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -24,8 +24,7 @@
public interface CanonicalSymbolResolver extends ImportScope.ResolveFunction {
/** Resolves a single member type of the given symbol by canonical name. */
@Override
@Nullable
ClassSymbol resolveOne(ClassSymbol sym, Tree.Ident bit);
@Nullable ClassSymbol resolveOne(ClassSymbol sym, Tree.Ident bit);

/** Returns true if the given symbol is visible from the current package. */
boolean visible(ClassSymbol sym);
Expand Down
6 changes: 2 additions & 4 deletions java/com/google/turbine/binder/lookup/ImportScope.java
Original file line number Diff line number Diff line change
Expand Up @@ -33,13 +33,11 @@ public interface ImportScope {
*/
@FunctionalInterface
interface ResolveFunction {
@Nullable
ClassSymbol resolveOne(ClassSymbol base, Tree.Ident name);
@Nullable ClassSymbol resolveOne(ClassSymbol base, Tree.Ident name);
}

/** See {@link Scope#lookup(LookupKey)}. */
@Nullable
LookupResult lookup(LookupKey lookupKey, ResolveFunction resolve);
@Nullable LookupResult lookup(LookupKey lookupKey, ResolveFunction resolve);

/** Adds a scope to the chain, in the manner of {@link CompoundScope#append(Scope)}. */
default ImportScope append(ImportScope next) {
Expand Down
3 changes: 1 addition & 2 deletions java/com/google/turbine/binder/lookup/Scope.java
Original file line number Diff line number Diff line change
Expand Up @@ -24,6 +24,5 @@ public interface Scope {
* Performs qualified name lookup on the given {@link LookupKey}, and returns either a {@link
* LookupResult} or else {@code null} indicating that the name could not be resolved.
*/
@Nullable
LookupResult lookup(LookupKey lookupKey);
@Nullable LookupResult lookup(LookupKey lookupKey);
}
3 changes: 1 addition & 2 deletions java/com/google/turbine/binder/lookup/TopLevelIndex.java
Original file line number Diff line number Diff line change
Expand Up @@ -36,6 +36,5 @@ public interface TopLevelIndex {
Scope scope();

/** Returns a scope to look up members of the given package. */
@Nullable
PackageScope lookupPackage(Iterable<String> packagename);
@Nullable PackageScope lookupPackage(Iterable<String> packagename);
}
1 change: 0 additions & 1 deletion java/com/google/turbine/bytecode/ClassReader.java
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,6 @@

package com.google.turbine.bytecode;


import com.google.common.collect.ImmutableList;
import com.google.common.collect.ImmutableMap;
import com.google.errorprone.annotations.CheckReturnValue;
Expand Down
2 changes: 1 addition & 1 deletion java/com/google/turbine/deps/Transitive.java
Original file line number Diff line number Diff line change
Expand Up @@ -110,7 +110,7 @@ public static ClassFile trimClass(ClassFile cf, @Nullable String jarFile) {
/* nestHost= */ null,
/* nestMembers= */ ImmutableList.of(),
/* record= */ null,
/* transitiveJar = */ transitiveJar);
/* transitiveJar= */ transitiveJar);
}

private static Set<ClassSymbol> superClosure(BindingResult bound) {
Expand Down
15 changes: 5 additions & 10 deletions java/com/google/turbine/processing/TurbineElement.java
Original file line number Diff line number Diff line change
Expand Up @@ -209,8 +209,7 @@ public TypeBoundClass get() {
});
}

@Nullable
TypeBoundClass info() {
@Nullable TypeBoundClass info() {
return info.get();
}

Expand Down Expand Up @@ -677,8 +676,7 @@ public MethodInfo get() {
}
});

@Nullable
MethodInfo info() {
@Nullable MethodInfo info() {
return info.get();
}

Expand Down Expand Up @@ -883,8 +881,7 @@ public FieldInfo get() {
}
});

@Nullable
FieldInfo info() {
@Nullable FieldInfo info() {
return info.get();
}

Expand Down Expand Up @@ -1147,8 +1144,7 @@ public ParamInfo get() {
}
});

@Nullable
ParamInfo info() {
@Nullable ParamInfo info() {
return info.get();
}

Expand Down Expand Up @@ -1252,8 +1248,7 @@ public RecordComponentInfo get() {
}
});

@Nullable
RecordComponentInfo info() {
@Nullable RecordComponentInfo info() {
return info.get();
}

Expand Down
2 changes: 2 additions & 0 deletions java/com/google/turbine/tree/Tree.java
Original file line number Diff line number Diff line change
Expand Up @@ -856,6 +856,7 @@ public ImmutableList<ClassTy> exntys() {
public Optional<Tree> defaultValue() {
return defaultValue;
}

/**
* A javadoc comment, excluding the opening and closing delimiters but including all interior
* characters and whitespace.
Expand Down Expand Up @@ -1017,6 +1018,7 @@ public ImmutableList<VarDecl> components() {
public TurbineTyKind tykind() {
return tykind;
}

/**
* A javadoc comment, excluding the opening and closing delimiters but including all interior
* characters and whitespace.
Expand Down
6 changes: 3 additions & 3 deletions java/com/google/turbine/zip/Zip.java
Original file line number Diff line number Diff line change
Expand Up @@ -281,14 +281,14 @@ public byte[] data() {
nameLength,
extLength,
UnsignedInts.toLong(cd.getInt(cdindex + CENSIZ)),
/*deflate=*/ true);
/* deflate= */ true);
case 0x0:
return getBytes(
offset,
nameLength,
extLength,
UnsignedInts.toLong(cd.getInt(cdindex + CENLEN)),
/*deflate=*/ false);
/* deflate= */ false);
default:
throw new AssertionError(
String.format("unsupported compression mode: 0x%x", compression));
Expand Down Expand Up @@ -332,7 +332,7 @@ private byte[] getBytes(
if (deflate) {
bytes =
new InflaterInputStream(
new ByteArrayInputStream(bytes), new Inflater(/*nowrap=*/ true))
new ByteArrayInputStream(bytes), new Inflater(/* nowrap= */ true))
.readAllBytes();
}
return bytes;
Expand Down
4 changes: 2 additions & 2 deletions javatests/com/google/turbine/binder/BinderErrorTest.java
Original file line number Diff line number Diff line change
Expand Up @@ -1030,7 +1030,7 @@ public void test() throws Exception {
ImmutableList.of(parseLines(source)),
ClassPathBinder.bindClasspath(ImmutableList.of()),
TURBINE_BOOTCLASSPATH,
/* moduleVersion=*/ Optional.empty())
/* moduleVersion= */ Optional.empty())
.units());
assertThat(e).hasMessageThat().isEqualTo(lines(expected));
}
Expand Down Expand Up @@ -1066,7 +1066,7 @@ public void testWithProcessors() throws Exception {
/* options= */ ImmutableMap.of(),
SourceVersion.latestSupported()),
TURBINE_BOOTCLASSPATH,
/* moduleVersion=*/ Optional.empty())
/* moduleVersion= */ Optional.empty())
.units());
assertThat(e).hasMessageThat().isEqualTo(lines(expected));
}
Expand Down
14 changes: 7 additions & 7 deletions javatests/com/google/turbine/binder/BinderTest.java
Original file line number Diff line number Diff line change
Expand Up @@ -73,7 +73,7 @@ public void hello() throws Exception {
units,
ClassPathBinder.bindClasspath(ImmutableList.of()),
TURBINE_BOOTCLASSPATH,
/* moduleVersion=*/ Optional.empty())
/* moduleVersion= */ Optional.empty())
.units();

assertThat(bound.keySet())
Expand Down Expand Up @@ -117,7 +117,7 @@ public void interfaces() throws Exception {
units,
ClassPathBinder.bindClasspath(ImmutableList.of()),
TURBINE_BOOTCLASSPATH,
/* moduleVersion=*/ Optional.empty())
/* moduleVersion= */ Optional.empty())
.units();

assertThat(bound.keySet())
Expand Down Expand Up @@ -156,7 +156,7 @@ public void imports() throws Exception {
units,
ClassPathBinder.bindClasspath(ImmutableList.of()),
TURBINE_BOOTCLASSPATH,
/* moduleVersion=*/ Optional.empty())
/* moduleVersion= */ Optional.empty())
.units();

assertThat(getBoundClass(bound, "other/Foo").superclass())
Expand Down Expand Up @@ -188,7 +188,7 @@ public void cycle() throws Exception {
units,
ClassPathBinder.bindClasspath(ImmutableList.of()),
TURBINE_BOOTCLASSPATH,
/* moduleVersion=*/ Optional.empty()));
/* moduleVersion= */ Optional.empty()));
assertThat(e).hasMessageThat().contains("cycle in class hierarchy: a.A -> b.B -> a.A");
}

Expand All @@ -206,7 +206,7 @@ public void annotationDeclaration() throws Exception {
units,
ClassPathBinder.bindClasspath(ImmutableList.of()),
TURBINE_BOOTCLASSPATH,
/* moduleVersion=*/ Optional.empty())
/* moduleVersion= */ Optional.empty())
.units();

SourceTypeBoundClass a = getBoundClass(bound, "com/test/Annotation");
Expand Down Expand Up @@ -235,7 +235,7 @@ public void helloBytecode() throws Exception {
units,
ClassPathBinder.bindClasspath(ImmutableList.of()),
TURBINE_BOOTCLASSPATH,
/* moduleVersion=*/ Optional.empty())
/* moduleVersion= */ Optional.empty())
.units();

SourceTypeBoundClass a = getBoundClass(bound, "a/A");
Expand Down Expand Up @@ -275,7 +275,7 @@ public void incompleteClasspath() throws Exception {
units,
ClassPathBinder.bindClasspath(ImmutableList.of(libJar)),
TURBINE_BOOTCLASSPATH,
/* moduleVersion=*/ Optional.empty())
/* moduleVersion= */ Optional.empty())
.units();

SourceTypeBoundClass a = getBoundClass(bound, "C$A");
Expand Down
2 changes: 1 addition & 1 deletion javatests/com/google/turbine/parse/JavacLexer.java
Original file line number Diff line number Diff line change
Expand Up @@ -32,7 +32,7 @@ public final class JavacLexer {
static List<String> javacLex(final String input) {
Context context = new Context();
Scanner scanner =
ScannerFactory.instance(context).newScanner(input, /*keepDocComments=*/ false);
ScannerFactory.instance(context).newScanner(input, /* keepDocComments= */ false);
List<Tokens.Token> tokens = new ArrayList<>();
do {
scanner.nextToken();
Expand Down

0 comments on commit 5584bf5

Please sign in to comment.