From c98fbbdcd5a042b84382e2fd04be865188b8184d Mon Sep 17 00:00:00 2001 From: Akash Yadav Date: Fri, 20 Oct 2023 22:29:31 +0530 Subject: [PATCH] fix: add base patches for Android --- .idea/compiler.xml | 10 + .../google-java-format/build.gradle.kts | 4 +- .../collect/CollectSpliteratorUtils.java | 185 ++++++++++++++ .../common/collect/ImmutableListUtils.java | 72 ++++++ .../com/google/common/collect/Streams.java | 234 ++++++++++++++++++ .../java/DimensionHelpers.java | 10 +- .../googlejavaformat/java/Formatter.java | 26 +- .../java/FormatterException.java | 4 +- .../googlejavaformat/java/ImportOrderer.java | 2 +- .../googlejavaformat/java/JavaInput.java | 28 +-- .../java/JavaInputAstVisitor.java | 165 ++++++------ .../googlejavaformat/java/JavacTokens.java | 18 +- .../google/googlejavaformat/java/Main.java | 3 +- .../java/ModifierOrderer.java | 6 +- .../java/RemoveUnusedImports.java | 60 ++--- .../java/SnippetFormatter.java | 2 +- .../googlejavaformat/java/StringWrapper.java | 42 ++-- .../google/googlejavaformat/java/Trees.java | 26 +- .../java/filer/FormattingFiler.java | 12 +- .../java/filer/FormattingJavaFileObject.java | 8 +- .../java/java17/Java17InputAstVisitor.java | 40 +-- 21 files changed, 731 insertions(+), 226 deletions(-) create mode 100644 subprojects/google-java-format/src/main/java/com/google/common/collect/CollectSpliteratorUtils.java create mode 100644 subprojects/google-java-format/src/main/java/com/google/common/collect/ImmutableListUtils.java create mode 100644 subprojects/google-java-format/src/main/java/com/google/common/collect/Streams.java diff --git a/.idea/compiler.xml b/.idea/compiler.xml index 2220768a0..4bb4b09a3 100644 --- a/.idea/compiler.xml +++ b/.idea/compiler.xml @@ -24,6 +24,16 @@ + + + + + + + + + + diff --git a/subprojects/google-java-format/build.gradle.kts b/subprojects/google-java-format/build.gradle.kts index 63791dd77..4817c1a7e 100644 --- a/subprojects/google-java-format/build.gradle.kts +++ b/subprojects/google-java-format/build.gradle.kts @@ -23,7 +23,9 @@ plugins { dependencies { implementation(libs.google.guava) implementation(libs.google.auto.value.annotations) + implementation(libs.google.auto.service.annotations) implementation(projects.subprojects.javac) - + annotationProcessor(libs.google.auto.value.ap) + annotationProcessor(libs.google.auto.service) } \ No newline at end of file diff --git a/subprojects/google-java-format/src/main/java/com/google/common/collect/CollectSpliteratorUtils.java b/subprojects/google-java-format/src/main/java/com/google/common/collect/CollectSpliteratorUtils.java new file mode 100644 index 000000000..75c5ee966 --- /dev/null +++ b/subprojects/google-java-format/src/main/java/com/google/common/collect/CollectSpliteratorUtils.java @@ -0,0 +1,185 @@ +/* + * This file is part of AndroidIDE. + * + * AndroidIDE is free software: you can redistribute it and/or modify + * it under the terms of the GNU General Public License as published by + * the Free Software Foundation, either version 3 of the License, or + * (at your option) any later version. + * + * AndroidIDE is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with AndroidIDE. If not, see . + */ + +package com.google.common.collect; + +import static com.google.common.base.Preconditions.checkArgument; +import static com.google.common.base.Preconditions.checkNotNull; +import static java.lang.Math.max; + +import java.util.Spliterator; +import java.util.function.Consumer; +import java.util.function.Function; + +/** + * @author Akash Yadav + */ +public class CollectSpliteratorUtils { + + /** + * Returns a {@code Spliterator} that iterates over the elements of the spliterators generated by + * applying {@code function} to the elements of {@code fromSpliterator}. + */ + static + Spliterator flatMap( + Spliterator fromSpliterator, + Function> function, + int topCharacteristics, + long topSize) { + checkArgument( + (topCharacteristics & Spliterator.SUBSIZED) == 0, + "flatMap does not support SUBSIZED characteristic"); + checkArgument( + (topCharacteristics & Spliterator.SORTED) == 0, + "flatMap does not support SORTED characteristic"); + checkNotNull(fromSpliterator); + checkNotNull(function); + return new FlatMapSpliteratorOfObject<>( + null, fromSpliterator, function, topCharacteristics, topSize); + } + + static final class FlatMapSpliteratorOfObject< + InElementT extends Object, OutElementT extends Object> + extends FlatMapSpliterator> { + FlatMapSpliteratorOfObject( + Spliterator prefix, + Spliterator from, + Function> function, + int characteristics, + long estimatedSize) { + super( + prefix, from, function, FlatMapSpliteratorOfObject::new, characteristics, estimatedSize); + } + } + + abstract static class FlatMapSpliterator< + InElementT extends Object, + OutElementT extends Object, + OutSpliteratorT extends Spliterator> + implements Spliterator { + /** Factory for constructing {@link FlatMapSpliterator} instances. */ + @FunctionalInterface + interface Factory> { + OutSpliteratorT newFlatMapSpliterator( + OutSpliteratorT prefix, + Spliterator fromSplit, + Function function, + int splitCharacteristics, + long estSplitSize); + } + + OutSpliteratorT prefix; + final Spliterator from; + final Function function; + final Factory factory; + int characteristics; + long estimatedSize; + + FlatMapSpliterator( + OutSpliteratorT prefix, + Spliterator from, + Function function, + Factory factory, + int characteristics, + long estimatedSize) { + this.prefix = prefix; + this.from = from; + this.function = function; + this.factory = factory; + this.characteristics = characteristics; + this.estimatedSize = estimatedSize; + } + + /* + * The tryAdvance and forEachRemaining in FlatMapSpliteratorOfPrimitive are overloads of these + * methods, not overrides. They are annotated @Override because they implement methods from + * Spliterator.OfPrimitive (and override default implementations from Spliterator.OfPrimitive or + * a subtype like Spliterator.OfInt). + */ + + @Override + public final boolean tryAdvance(Consumer action) { + while (true) { + if (prefix != null && prefix.tryAdvance(action)) { + if (estimatedSize != Long.MAX_VALUE) { + estimatedSize--; + } + return true; + } else { + prefix = null; + } + if (!from.tryAdvance(fromElement -> prefix = function.apply(fromElement))) { + return false; + } + } + } + + @Override + public final void forEachRemaining(Consumer action) { + if (prefix != null) { + prefix.forEachRemaining(action); + prefix = null; + } + from.forEachRemaining( + fromElement -> { + Spliterator elements = function.apply(fromElement); + if (elements != null) { + elements.forEachRemaining(action); + } + }); + estimatedSize = 0; + } + + @Override + public final OutSpliteratorT trySplit() { + Spliterator fromSplit = from.trySplit(); + if (fromSplit != null) { + int splitCharacteristics = characteristics & ~Spliterator.SIZED; + long estSplitSize = estimateSize(); + if (estSplitSize < Long.MAX_VALUE) { + estSplitSize /= 2; + this.estimatedSize -= estSplitSize; + this.characteristics = splitCharacteristics; + } + OutSpliteratorT result = + factory.newFlatMapSpliterator( + this.prefix, fromSplit, function, splitCharacteristics, estSplitSize); + this.prefix = null; + return result; + } else if (prefix != null) { + OutSpliteratorT result = prefix; + this.prefix = null; + return result; + } else { + return null; + } + } + + @Override + public final long estimateSize() { + if (prefix != null) { + estimatedSize = max(estimatedSize, prefix.estimateSize()); + } + return max(estimatedSize, 0); + } + + @Override + public final int characteristics() { + return characteristics; + } + } +} diff --git a/subprojects/google-java-format/src/main/java/com/google/common/collect/ImmutableListUtils.java b/subprojects/google-java-format/src/main/java/com/google/common/collect/ImmutableListUtils.java new file mode 100644 index 000000000..a8023a30d --- /dev/null +++ b/subprojects/google-java-format/src/main/java/com/google/common/collect/ImmutableListUtils.java @@ -0,0 +1,72 @@ +/* + * This file is part of AndroidIDE. + * + * AndroidIDE is free software: you can redistribute it and/or modify + * it under the terms of the GNU General Public License as published by + * the Free Software Foundation, either version 3 of the License, or + * (at your option) any later version. + * + * AndroidIDE is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with AndroidIDE. If not, see . + */ + + +package com.google.common.collect; + +import java.util.Iterator; +import java.util.stream.Collector; + +/** + * @author Akash Yadav + */ +public class ImmutableListUtils { + + private static final Collector> TO_IMMUTABLE_LIST = + Collector.of( + ImmutableList::builder, + ImmutableList.Builder::add, + ImmutableList.Builder::combine, + ImmutableList.Builder::build); + + private static final Collector> TO_IMMUTABLE_SET = + Collector.of( + ImmutableSet::builder, + ImmutableSet.Builder::add, + ImmutableSet.Builder::combine, + ImmutableSet.Builder::build); + + @SuppressWarnings({"rawtypes", "unchecked"}) + public static Collector> toImmutableList() { + return (Collector) TO_IMMUTABLE_LIST; + } + + // Sets + + @SuppressWarnings({"rawtypes", "unchecked"}) + public static Collector> toImmutableSet() { + return (Collector) TO_IMMUTABLE_SET; + } + + /** + * Returns an immutable list containing the given elements, in order. + * + * @throws NullPointerException if {@code elements} contains a null element + */ + public static ImmutableList copyOf(Iterator elements) { + // We special-case for 0 or 1 elements, but going further is madness. + if (!elements.hasNext()) { + return ImmutableList.of(); + } + E first = elements.next(); + if (!elements.hasNext()) { + return ImmutableList.of(first); + } else { + return new ImmutableList.Builder().add(first).addAll(elements).build(); + } + } +} diff --git a/subprojects/google-java-format/src/main/java/com/google/common/collect/Streams.java b/subprojects/google-java-format/src/main/java/com/google/common/collect/Streams.java new file mode 100644 index 000000000..73751cecd --- /dev/null +++ b/subprojects/google-java-format/src/main/java/com/google/common/collect/Streams.java @@ -0,0 +1,234 @@ +/* + * This file is part of AndroidIDE. + * + * AndroidIDE is free software: you can redistribute it and/or modify + * it under the terms of the GNU General Public License as published by + * the Free Software Foundation, either version 3 of the License, or + * (at your option) any later version. + * + * AndroidIDE is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with AndroidIDE. If not, see . + */ + +/* + * Copyright (C) 2015 The Guava Authors + * + * 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.google.common.collect; + +import static com.google.common.base.Preconditions.checkNotNull; + +import com.google.common.math.LongMath; +import java.util.Iterator; +import java.util.Spliterator; +import java.util.Spliterators; +import java.util.Spliterators.AbstractSpliterator; +import java.util.function.Consumer; +import java.util.stream.BaseStream; +import java.util.stream.Stream; +import java.util.stream.StreamSupport; + +/** + * @author Akash Yadav + * @see Streams.java + */ +public class Streams { + + public static Stream concat(Stream... streams) { + // TODO(lowasser): consider an implementation that can support SUBSIZED + boolean isParallel = false; + int characteristics = Spliterator.ORDERED | Spliterator.SIZED | Spliterator.NONNULL; + long estimatedSize = 0L; + ImmutableList.Builder> splitrsBuilder = + new ImmutableList.Builder<>(streams.length); + for (Stream stream : streams) { + isParallel |= stream.isParallel(); + Spliterator splitr = stream.spliterator(); + splitrsBuilder.add(splitr); + characteristics &= splitr.characteristics(); + estimatedSize = LongMath.saturatedAdd(estimatedSize, splitr.estimateSize()); + } + return StreamSupport.stream( + CollectSpliteratorUtils.flatMap( + splitrsBuilder.build().spliterator(), + splitr -> (Spliterator) splitr, + characteristics, + estimatedSize), + isParallel) + .onClose(() -> closeAll(streams)); + } + + private static void closeAll(BaseStream[] toClose) { + // If one of the streams throws a RuntimeException, continue closing the others, then throw the + // exception later. If more than one stream throws an exception, the later ones are added to the + // first as suppressed exceptions. We don't catch Error on the grounds that it should be allowed + // to propagate immediately. + RuntimeException exception = null; + for (BaseStream stream : toClose) { + try { + stream.close(); + } catch (RuntimeException e) { + if (exception == null) { + exception = e; + } else { + exception.addSuppressed(e); + } + } + } + if (exception != null) { + throw exception; + } + } + + /** + * Returns a stream consisting of the results of applying the given function to the elements of + * {@code stream} and their indices in the stream. For example, + * + *
{@code
+   * mapWithIndex(
+   *     Stream.of("a", "b", "c"),
+   *     (e, index) -> index + ":" + e)
+   * }
+ * + *

would return {@code Stream.of("0:a", "1:b", "2:c")}. + * + *

The resulting stream is efficiently splittable + * if and only if {@code stream} was efficiently splittable and its underlying spliterator + * reported {@link Spliterator#SUBSIZED}. This is generally the case if the underlying stream + * comes from a data structure supporting efficient indexed random access, typically an array or + * list. + * + *

The order of the resulting stream is defined if and only if the order of the original + * stream was defined. + */ + public static Stream mapWithIndex( + Stream stream, FunctionWithIndex function) { + checkNotNull(stream); + checkNotNull(function); + boolean isParallel = stream.isParallel(); + Spliterator fromSpliterator = stream.spliterator(); + + if (!fromSpliterator.hasCharacteristics(Spliterator.SUBSIZED)) { + Iterator fromIterator = Spliterators.iterator(fromSpliterator); + return StreamSupport.stream( + new AbstractSpliterator( + fromSpliterator.estimateSize(), + fromSpliterator.characteristics() & (Spliterator.ORDERED | Spliterator.SIZED)) { + long index = 0; + + @Override + public boolean tryAdvance(Consumer action) { + if (fromIterator.hasNext()) { + action.accept(function.apply(fromIterator.next(), index++)); + return true; + } + return false; + } + }, + isParallel) + .onClose(stream::close); + } + class Splitr extends MapWithIndexSpliterator, R, Splitr> implements Consumer { + + T holder; + + Splitr(Spliterator splitr, long index) { + super(splitr, index); + } + + @Override + public void accept(@ParametricNullness T t) { + this.holder = t; + } + + @Override + public boolean tryAdvance(Consumer action) { + if (fromSpliterator.tryAdvance(this)) { + try { + // The cast is safe because tryAdvance puts a T into `holder`. + action.accept(function.apply((T) holder, index++)); + return true; + } finally { + holder = null; + } + } + return false; + } + + @Override + Splitr createSplit(Spliterator from, long i) { + return new Splitr(from, i); + } + } + return StreamSupport.stream(new Splitr(fromSpliterator, 0), isParallel).onClose(stream::close); + } + + private abstract static class MapWithIndexSpliterator< + F extends Spliterator, + R extends Object, + S extends MapWithIndexSpliterator> + implements Spliterator { + + final F fromSpliterator; + long index; + + MapWithIndexSpliterator(F fromSpliterator, long index) { + this.fromSpliterator = fromSpliterator; + this.index = index; + } + + abstract S createSplit(F from, long i); + + @Override + public S trySplit() { + Spliterator splitOrNull = fromSpliterator.trySplit(); + if (splitOrNull == null) { + return null; + } + @SuppressWarnings("unchecked") + F split = (F) splitOrNull; + S result = createSplit(split, index); + this.index += split.getExactSizeIfKnown(); + return result; + } + + @Override + public long estimateSize() { + return fromSpliterator.estimateSize(); + } + + @Override + public int characteristics() { + return fromSpliterator.characteristics() + & (Spliterator.ORDERED | Spliterator.SIZED | Spliterator.SUBSIZED); + } + } + + public interface FunctionWithIndex { + + /** + * Applies this function to the given argument and its index within a stream. + */ + @ParametricNullness + R apply(@ParametricNullness T from, long index); + } +} diff --git a/subprojects/google-java-format/src/main/java/com/google/googlejavaformat/java/DimensionHelpers.java b/subprojects/google-java-format/src/main/java/com/google/googlejavaformat/java/DimensionHelpers.java index 4bd19bee3..363acc9a2 100644 --- a/subprojects/google-java-format/src/main/java/com/google/googlejavaformat/java/DimensionHelpers.java +++ b/subprojects/google-java-format/src/main/java/com/google/googlejavaformat/java/DimensionHelpers.java @@ -15,11 +15,11 @@ package com.google.googlejavaformat.java; import com.google.common.collect.ImmutableList; -import com.sun.source.tree.AnnotatedTypeTree; -import com.sun.source.tree.AnnotationTree; -import com.sun.source.tree.ArrayTypeTree; -import com.sun.source.tree.Tree; -import com.sun.tools.javac.tree.JCTree; +import openjdk.source.tree.AnnotatedTypeTree; +import openjdk.source.tree.AnnotationTree; +import openjdk.source.tree.ArrayTypeTree; +import openjdk.source.tree.Tree; +import openjdk.tools.javac.tree.JCTree; import java.util.ArrayDeque; import java.util.ArrayList; import java.util.Collections; diff --git a/subprojects/google-java-format/src/main/java/com/google/googlejavaformat/java/Formatter.java b/subprojects/google-java-format/src/main/java/com/google/googlejavaformat/java/Formatter.java index 9ff702d5a..7831b414d 100644 --- a/subprojects/google-java-format/src/main/java/com/google/googlejavaformat/java/Formatter.java +++ b/subprojects/google-java-format/src/main/java/com/google/googlejavaformat/java/Formatter.java @@ -31,25 +31,25 @@ import com.google.googlejavaformat.FormattingError; import com.google.googlejavaformat.Newlines; import com.google.googlejavaformat.Op; import com.google.googlejavaformat.OpsBuilder; -import com.sun.tools.javac.file.JavacFileManager; -import com.sun.tools.javac.parser.JavacParser; -import com.sun.tools.javac.parser.ParserFactory; -import com.sun.tools.javac.tree.JCTree.JCCompilationUnit; -import com.sun.tools.javac.util.Context; -import com.sun.tools.javac.util.Log; -import com.sun.tools.javac.util.Options; +import openjdk.tools.javac.file.JavacFileManager; +import openjdk.tools.javac.parser.JavacParser; +import openjdk.tools.javac.parser.ParserFactory; +import openjdk.tools.javac.tree.JCTree.JCCompilationUnit; +import openjdk.tools.javac.util.Context; +import openjdk.tools.javac.util.Log; +import openjdk.tools.javac.util.Options; import java.io.IOError; import java.io.IOException; import java.net.URI; import java.util.ArrayList; import java.util.Collection; import java.util.List; -import javax.tools.Diagnostic; -import javax.tools.DiagnosticCollector; -import javax.tools.DiagnosticListener; -import javax.tools.JavaFileObject; -import javax.tools.SimpleJavaFileObject; -import javax.tools.StandardLocation; +import jdkx.tools.Diagnostic; +import jdkx.tools.DiagnosticCollector; +import jdkx.tools.DiagnosticListener; +import jdkx.tools.JavaFileObject; +import jdkx.tools.SimpleJavaFileObject; +import jdkx.tools.StandardLocation; /** * This is google-java-format, a new Java formatter that follows the Google Java Style Guide quite diff --git a/subprojects/google-java-format/src/main/java/com/google/googlejavaformat/java/FormatterException.java b/subprojects/google-java-format/src/main/java/com/google/googlejavaformat/java/FormatterException.java index 808916c2c..8ce1c8fb7 100644 --- a/subprojects/google-java-format/src/main/java/com/google/googlejavaformat/java/FormatterException.java +++ b/subprojects/google-java-format/src/main/java/com/google/googlejavaformat/java/FormatterException.java @@ -20,8 +20,8 @@ import com.google.common.collect.ImmutableList; import com.google.common.collect.Iterables; import com.google.googlejavaformat.FormatterDiagnostic; import java.util.List; -import javax.tools.Diagnostic; -import javax.tools.JavaFileObject; +import jdkx.tools.Diagnostic; +import jdkx.tools.JavaFileObject; /** Checked exception class for formatter errors. */ public final class FormatterException extends Exception { diff --git a/subprojects/google-java-format/src/main/java/com/google/googlejavaformat/java/ImportOrderer.java b/subprojects/google-java-format/src/main/java/com/google/googlejavaformat/java/ImportOrderer.java index dcbaea172..c0aabb6dd 100644 --- a/subprojects/google-java-format/src/main/java/com/google/googlejavaformat/java/ImportOrderer.java +++ b/subprojects/google-java-format/src/main/java/com/google/googlejavaformat/java/ImportOrderer.java @@ -25,7 +25,7 @@ import com.google.common.collect.ImmutableSortedSet; import com.google.googlejavaformat.Newlines; import com.google.googlejavaformat.java.JavaFormatterOptions.Style; import com.google.googlejavaformat.java.JavaInput.Tok; -import com.sun.tools.javac.parser.Tokens.TokenKind; +import openjdk.tools.javac.parser.Tokens.TokenKind; import java.util.ArrayList; import java.util.Comparator; import java.util.List; diff --git a/subprojects/google-java-format/src/main/java/com/google/googlejavaformat/java/JavaInput.java b/subprojects/google-java-format/src/main/java/com/google/googlejavaformat/java/JavaInput.java index eee210e20..ed0ae5350 100644 --- a/subprojects/google-java-format/src/main/java/com/google/googlejavaformat/java/JavaInput.java +++ b/subprojects/google-java-format/src/main/java/com/google/googlejavaformat/java/JavaInput.java @@ -33,26 +33,26 @@ import com.google.common.collect.TreeRangeSet; import com.google.googlejavaformat.Input; import com.google.googlejavaformat.Newlines; import com.google.googlejavaformat.java.JavacTokens.RawTok; -import com.sun.tools.javac.file.JavacFileManager; -import com.sun.tools.javac.parser.Tokens.TokenKind; -import com.sun.tools.javac.tree.JCTree.JCCompilationUnit; -import com.sun.tools.javac.util.Context; -import com.sun.tools.javac.util.Log; -import com.sun.tools.javac.util.Log.DeferredDiagnosticHandler; -import com.sun.tools.javac.util.Options; +import openjdk.tools.javac.file.JavacFileManager; +import openjdk.tools.javac.parser.Tokens.TokenKind; +import openjdk.tools.javac.tree.JCTree.JCCompilationUnit; +import openjdk.tools.javac.util.Context; +import openjdk.tools.javac.util.Log; +import openjdk.tools.javac.util.Log.DeferredDiagnosticHandler; +import openjdk.tools.javac.util.Options; import java.io.IOException; import java.net.URI; import java.util.ArrayList; import java.util.Collection; import java.util.Iterator; import java.util.List; -import javax.tools.Diagnostic; -import javax.tools.DiagnosticCollector; -import javax.tools.DiagnosticListener; -import javax.tools.JavaFileManager; -import javax.tools.JavaFileObject; -import javax.tools.JavaFileObject.Kind; -import javax.tools.SimpleJavaFileObject; +import jdkx.tools.Diagnostic; +import jdkx.tools.DiagnosticCollector; +import jdkx.tools.DiagnosticListener; +import jdkx.tools.JavaFileManager; +import jdkx.tools.JavaFileObject; +import jdkx.tools.JavaFileObject.Kind; +import jdkx.tools.SimpleJavaFileObject; /** {@code JavaInput} extends {@link Input} to represent a Java input document. */ public final class JavaInput extends Input { diff --git a/subprojects/google-java-format/src/main/java/com/google/googlejavaformat/java/JavaInputAstVisitor.java b/subprojects/google-java-format/src/main/java/com/google/googlejavaformat/java/JavaInputAstVisitor.java index 89c944c5b..a373e7325 100644 --- a/subprojects/google-java-format/src/main/java/com/google/googlejavaformat/java/JavaInputAstVisitor.java +++ b/subprojects/google-java-format/src/main/java/com/google/googlejavaformat/java/JavaInputAstVisitor.java @@ -29,18 +29,18 @@ import static com.google.googlejavaformat.java.Trees.getStartPosition; import static com.google.googlejavaformat.java.Trees.operatorName; import static com.google.googlejavaformat.java.Trees.precedence; import static com.google.googlejavaformat.java.Trees.skipParen; -import static com.sun.source.tree.Tree.Kind.ANNOTATION; -import static com.sun.source.tree.Tree.Kind.ARRAY_ACCESS; -import static com.sun.source.tree.Tree.Kind.ASSIGNMENT; -import static com.sun.source.tree.Tree.Kind.BLOCK; -import static com.sun.source.tree.Tree.Kind.EXTENDS_WILDCARD; -import static com.sun.source.tree.Tree.Kind.IF; -import static com.sun.source.tree.Tree.Kind.METHOD_INVOCATION; -import static com.sun.source.tree.Tree.Kind.NEW_ARRAY; -import static com.sun.source.tree.Tree.Kind.NEW_CLASS; -import static com.sun.source.tree.Tree.Kind.STRING_LITERAL; -import static com.sun.source.tree.Tree.Kind.UNION_TYPE; -import static com.sun.source.tree.Tree.Kind.VARIABLE; +import static openjdk.source.tree.Tree.Kind.ANNOTATION; +import static openjdk.source.tree.Tree.Kind.ARRAY_ACCESS; +import static openjdk.source.tree.Tree.Kind.ASSIGNMENT; +import static openjdk.source.tree.Tree.Kind.BLOCK; +import static openjdk.source.tree.Tree.Kind.EXTENDS_WILDCARD; +import static openjdk.source.tree.Tree.Kind.IF; +import static openjdk.source.tree.Tree.Kind.METHOD_INVOCATION; +import static openjdk.source.tree.Tree.Kind.NEW_ARRAY; +import static openjdk.source.tree.Tree.Kind.NEW_CLASS; +import static openjdk.source.tree.Tree.Kind.STRING_LITERAL; +import static openjdk.source.tree.Tree.Kind.UNION_TYPE; +import static openjdk.source.tree.Tree.Kind.VARIABLE; import static java.util.stream.Collectors.toList; import com.google.auto.value.AutoOneOf; @@ -51,6 +51,7 @@ import com.google.common.base.Throwables; import com.google.common.base.Verify; import com.google.common.collect.HashMultiset; import com.google.common.collect.ImmutableList; +import com.google.common.collect.ImmutableListUtils; import com.google.common.collect.ImmutableMultimap; import com.google.common.collect.ImmutableSet; import com.google.common.collect.ImmutableSetMultimap; @@ -77,73 +78,73 @@ import com.google.googlejavaformat.OpsBuilder.BlankLineWanted; import com.google.googlejavaformat.Output.BreakTag; import com.google.googlejavaformat.java.DimensionHelpers.SortedDims; import com.google.googlejavaformat.java.DimensionHelpers.TypeWithDims; -import com.sun.source.tree.AnnotatedTypeTree; -import com.sun.source.tree.AnnotationTree; -import com.sun.source.tree.ArrayAccessTree; -import com.sun.source.tree.ArrayTypeTree; -import com.sun.source.tree.AssertTree; -import com.sun.source.tree.AssignmentTree; -import com.sun.source.tree.BinaryTree; -import com.sun.source.tree.BlockTree; -import com.sun.source.tree.BreakTree; -import com.sun.source.tree.CaseTree; -import com.sun.source.tree.CatchTree; -import com.sun.source.tree.ClassTree; -import com.sun.source.tree.CompilationUnitTree; -import com.sun.source.tree.CompoundAssignmentTree; -import com.sun.source.tree.ConditionalExpressionTree; -import com.sun.source.tree.ContinueTree; -import com.sun.source.tree.DirectiveTree; -import com.sun.source.tree.DoWhileLoopTree; -import com.sun.source.tree.EmptyStatementTree; -import com.sun.source.tree.EnhancedForLoopTree; -import com.sun.source.tree.ExportsTree; -import com.sun.source.tree.ExpressionStatementTree; -import com.sun.source.tree.ExpressionTree; -import com.sun.source.tree.ForLoopTree; -import com.sun.source.tree.IdentifierTree; -import com.sun.source.tree.IfTree; -import com.sun.source.tree.ImportTree; -import com.sun.source.tree.InstanceOfTree; -import com.sun.source.tree.IntersectionTypeTree; -import com.sun.source.tree.LabeledStatementTree; -import com.sun.source.tree.LambdaExpressionTree; -import com.sun.source.tree.LiteralTree; -import com.sun.source.tree.MemberReferenceTree; -import com.sun.source.tree.MemberSelectTree; -import com.sun.source.tree.MethodInvocationTree; -import com.sun.source.tree.MethodTree; -import com.sun.source.tree.ModifiersTree; -import com.sun.source.tree.ModuleTree; -import com.sun.source.tree.NewArrayTree; -import com.sun.source.tree.NewClassTree; -import com.sun.source.tree.OpensTree; -import com.sun.source.tree.ParameterizedTypeTree; -import com.sun.source.tree.ParenthesizedTree; -import com.sun.source.tree.PrimitiveTypeTree; -import com.sun.source.tree.ProvidesTree; -import com.sun.source.tree.RequiresTree; -import com.sun.source.tree.ReturnTree; -import com.sun.source.tree.StatementTree; -import com.sun.source.tree.SwitchTree; -import com.sun.source.tree.SynchronizedTree; -import com.sun.source.tree.ThrowTree; -import com.sun.source.tree.Tree; -import com.sun.source.tree.TryTree; -import com.sun.source.tree.TypeCastTree; -import com.sun.source.tree.TypeParameterTree; -import com.sun.source.tree.UnaryTree; -import com.sun.source.tree.UnionTypeTree; -import com.sun.source.tree.UsesTree; -import com.sun.source.tree.VariableTree; -import com.sun.source.tree.WhileLoopTree; -import com.sun.source.tree.WildcardTree; -import com.sun.source.util.TreePath; -import com.sun.source.util.TreePathScanner; -import com.sun.tools.javac.code.Flags; -import com.sun.tools.javac.tree.JCTree; -import com.sun.tools.javac.tree.JCTree.JCMethodDecl; -import com.sun.tools.javac.tree.TreeScanner; +import openjdk.source.tree.AnnotatedTypeTree; +import openjdk.source.tree.AnnotationTree; +import openjdk.source.tree.ArrayAccessTree; +import openjdk.source.tree.ArrayTypeTree; +import openjdk.source.tree.AssertTree; +import openjdk.source.tree.AssignmentTree; +import openjdk.source.tree.BinaryTree; +import openjdk.source.tree.BlockTree; +import openjdk.source.tree.BreakTree; +import openjdk.source.tree.CaseTree; +import openjdk.source.tree.CatchTree; +import openjdk.source.tree.ClassTree; +import openjdk.source.tree.CompilationUnitTree; +import openjdk.source.tree.CompoundAssignmentTree; +import openjdk.source.tree.ConditionalExpressionTree; +import openjdk.source.tree.ContinueTree; +import openjdk.source.tree.DirectiveTree; +import openjdk.source.tree.DoWhileLoopTree; +import openjdk.source.tree.EmptyStatementTree; +import openjdk.source.tree.EnhancedForLoopTree; +import openjdk.source.tree.ExportsTree; +import openjdk.source.tree.ExpressionStatementTree; +import openjdk.source.tree.ExpressionTree; +import openjdk.source.tree.ForLoopTree; +import openjdk.source.tree.IdentifierTree; +import openjdk.source.tree.IfTree; +import openjdk.source.tree.ImportTree; +import openjdk.source.tree.InstanceOfTree; +import openjdk.source.tree.IntersectionTypeTree; +import openjdk.source.tree.LabeledStatementTree; +import openjdk.source.tree.LambdaExpressionTree; +import openjdk.source.tree.LiteralTree; +import openjdk.source.tree.MemberReferenceTree; +import openjdk.source.tree.MemberSelectTree; +import openjdk.source.tree.MethodInvocationTree; +import openjdk.source.tree.MethodTree; +import openjdk.source.tree.ModifiersTree; +import openjdk.source.tree.ModuleTree; +import openjdk.source.tree.NewArrayTree; +import openjdk.source.tree.NewClassTree; +import openjdk.source.tree.OpensTree; +import openjdk.source.tree.ParameterizedTypeTree; +import openjdk.source.tree.ParenthesizedTree; +import openjdk.source.tree.PrimitiveTypeTree; +import openjdk.source.tree.ProvidesTree; +import openjdk.source.tree.RequiresTree; +import openjdk.source.tree.ReturnTree; +import openjdk.source.tree.StatementTree; +import openjdk.source.tree.SwitchTree; +import openjdk.source.tree.SynchronizedTree; +import openjdk.source.tree.ThrowTree; +import openjdk.source.tree.Tree; +import openjdk.source.tree.TryTree; +import openjdk.source.tree.TypeCastTree; +import openjdk.source.tree.TypeParameterTree; +import openjdk.source.tree.UnaryTree; +import openjdk.source.tree.UnionTypeTree; +import openjdk.source.tree.UsesTree; +import openjdk.source.tree.VariableTree; +import openjdk.source.tree.WhileLoopTree; +import openjdk.source.tree.WildcardTree; +import openjdk.source.util.TreePath; +import openjdk.source.util.TreePathScanner; +import openjdk.tools.javac.code.Flags; +import openjdk.tools.javac.tree.JCTree; +import openjdk.tools.javac.tree.JCTree.JCMethodDecl; +import openjdk.tools.javac.tree.TreeScanner; import java.util.ArrayDeque; import java.util.ArrayList; import java.util.Collection; @@ -157,7 +158,7 @@ import java.util.Optional; import java.util.Set; import java.util.regex.Pattern; import java.util.stream.Stream; -import javax.lang.model.element.Name; +import jdkx.lang.model.element.Name; import org.checkerframework.checker.nullness.qual.Nullable; /** @@ -2433,7 +2434,7 @@ public class JavaInputAstVisitor extends TreePathScanner { // we're seeing annotations or modifiers annotationRanges.contains(tok.getPosition()) || isModifier(tok.getText())); ImmutableList modifiers = - ImmutableList.copyOf( + ImmutableListUtils.copyOf( Streams.concat( toks.stream() // reject tokens from inside AnnotationTrees, we only want modifiers @@ -2441,7 +2442,7 @@ public class JavaInputAstVisitor extends TreePathScanner { .map(AnnotationOrModifier::ofModifier), annotations.stream().map(AnnotationOrModifier::ofAnnotation)) .sorted() - .collect(toList())); + .iterator()); // Take a suffix of annotations that are well-known type annotations, and which appear after any // declaration annotations or modifiers ImmutableList.Builder typeAnnotations = ImmutableList.builder(); diff --git a/subprojects/google-java-format/src/main/java/com/google/googlejavaformat/java/JavacTokens.java b/subprojects/google-java-format/src/main/java/com/google/googlejavaformat/java/JavacTokens.java index ba7e3b774..3228c04f4 100644 --- a/subprojects/google-java-format/src/main/java/com/google/googlejavaformat/java/JavacTokens.java +++ b/subprojects/google-java-format/src/main/java/com/google/googlejavaformat/java/JavacTokens.java @@ -18,15 +18,15 @@ import static com.google.common.base.Preconditions.checkArgument; import com.google.common.collect.ImmutableList; import com.google.common.collect.Lists; -import com.sun.tools.javac.parser.JavaTokenizer; -import com.sun.tools.javac.parser.Scanner; -import com.sun.tools.javac.parser.ScannerFactory; -import com.sun.tools.javac.parser.Tokens.Comment; -import com.sun.tools.javac.parser.Tokens.Comment.CommentStyle; -import com.sun.tools.javac.parser.Tokens.Token; -import com.sun.tools.javac.parser.Tokens.TokenKind; -import com.sun.tools.javac.parser.UnicodeReader; -import com.sun.tools.javac.util.Context; +import openjdk.tools.javac.parser.JavaTokenizer; +import openjdk.tools.javac.parser.Scanner; +import openjdk.tools.javac.parser.ScannerFactory; +import openjdk.tools.javac.parser.Tokens.Comment; +import openjdk.tools.javac.parser.Tokens.Comment.CommentStyle; +import openjdk.tools.javac.parser.Tokens.Token; +import openjdk.tools.javac.parser.Tokens.TokenKind; +import openjdk.tools.javac.parser.UnicodeReader; +import openjdk.tools.javac.util.Context; import java.util.Set; /** A wrapper around javac's lexer. */ diff --git a/subprojects/google-java-format/src/main/java/com/google/googlejavaformat/java/Main.java b/subprojects/google-java-format/src/main/java/com/google/googlejavaformat/java/Main.java index 62423f226..0d71f99ce 100644 --- a/subprojects/google-java-format/src/main/java/com/google/googlejavaformat/java/Main.java +++ b/subprojects/google-java-format/src/main/java/com/google/googlejavaformat/java/Main.java @@ -39,6 +39,7 @@ import java.util.concurrent.ExecutionException; import java.util.concurrent.ExecutorCompletionService; import java.util.concurrent.ExecutorService; import java.util.concurrent.Executors; +import java.util.concurrent.TimeUnit; /** The main class for the Java formatter CLI. */ public final class Main { @@ -196,7 +197,7 @@ public final class Main { outWriter.write(formatted); } } - if (!MoreExecutors.shutdownAndAwaitTermination(executorService, Duration.ofSeconds(5))) { + if (!MoreExecutors.shutdownAndAwaitTermination(executorService, 5, TimeUnit.SECONDS)) { errWriter.println("Failed to shut down ExecutorService"); allOk = false; } diff --git a/subprojects/google-java-format/src/main/java/com/google/googlejavaformat/java/ModifierOrderer.java b/subprojects/google-java-format/src/main/java/com/google/googlejavaformat/java/ModifierOrderer.java index e14b29036..9d7e00dfc 100644 --- a/subprojects/google-java-format/src/main/java/com/google/googlejavaformat/java/ModifierOrderer.java +++ b/subprojects/google-java-format/src/main/java/com/google/googlejavaformat/java/ModifierOrderer.java @@ -23,7 +23,7 @@ import com.google.common.collect.RangeSet; import com.google.common.collect.TreeRangeMap; import com.google.googlejavaformat.Input.Tok; import com.google.googlejavaformat.Input.Token; -import com.sun.tools.javac.parser.Tokens.TokenKind; +import openjdk.tools.javac.parser.Tokens.TokenKind; import java.util.ArrayList; import java.util.Collection; import java.util.Collections; @@ -31,7 +31,7 @@ import java.util.Iterator; import java.util.List; import java.util.Map; import java.util.Map.Entry; -import javax.lang.model.element.Modifier; +import jdkx.lang.model.element.Modifier; /** Fixes sequences of modifiers to be in JLS order. */ final class ModifierOrderer { @@ -110,7 +110,7 @@ final class ModifierOrderer { } /** - * Returns the given token as a {@link javax.lang.model.element.Modifier}, or {@code null} if it + * Returns the given token as a {@link jdkx.lang.model.element.Modifier}, or {@code null} if it * is not a modifier. */ private static Modifier asModifier(Token token) { diff --git a/subprojects/google-java-format/src/main/java/com/google/googlejavaformat/java/RemoveUnusedImports.java b/subprojects/google-java-format/src/main/java/com/google/googlejavaformat/java/RemoveUnusedImports.java index a0fc2f54a..79f9fe55e 100644 --- a/subprojects/google-java-format/src/main/java/com/google/googlejavaformat/java/RemoveUnusedImports.java +++ b/subprojects/google-java-format/src/main/java/com/google/googlejavaformat/java/RemoveUnusedImports.java @@ -30,29 +30,29 @@ import com.google.common.collect.RangeSet; import com.google.common.collect.TreeRangeMap; import com.google.common.collect.TreeRangeSet; import com.google.googlejavaformat.Newlines; -import com.sun.source.doctree.DocCommentTree; -import com.sun.source.doctree.ReferenceTree; -import com.sun.source.tree.CaseTree; -import com.sun.source.tree.IdentifierTree; -import com.sun.source.tree.ImportTree; -import com.sun.source.tree.Tree; -import com.sun.source.util.DocTreePath; -import com.sun.source.util.DocTreePathScanner; -import com.sun.source.util.TreePathScanner; -import com.sun.source.util.TreeScanner; -import com.sun.tools.javac.api.JavacTrees; -import com.sun.tools.javac.file.JavacFileManager; -import com.sun.tools.javac.parser.JavacParser; -import com.sun.tools.javac.parser.ParserFactory; -import com.sun.tools.javac.tree.DCTree; -import com.sun.tools.javac.tree.DCTree.DCReference; -import com.sun.tools.javac.tree.JCTree; -import com.sun.tools.javac.tree.JCTree.JCCompilationUnit; -import com.sun.tools.javac.tree.JCTree.JCFieldAccess; -import com.sun.tools.javac.tree.JCTree.JCImport; -import com.sun.tools.javac.util.Context; -import com.sun.tools.javac.util.Log; -import com.sun.tools.javac.util.Options; +import openjdk.source.doctree.DocCommentTree; +import openjdk.source.doctree.ReferenceTree; +import openjdk.source.tree.CaseTree; +import openjdk.source.tree.IdentifierTree; +import openjdk.source.tree.ImportTree; +import openjdk.source.tree.Tree; +import openjdk.source.util.DocTreePath; +import openjdk.source.util.DocTreePathScanner; +import openjdk.source.util.TreePathScanner; +import openjdk.source.util.TreeScanner; +import openjdk.tools.javac.api.JavacTrees; +import openjdk.tools.javac.file.JavacFileManager; +import openjdk.tools.javac.parser.JavacParser; +import openjdk.tools.javac.parser.ParserFactory; +import openjdk.tools.javac.tree.DCTree; +import openjdk.tools.javac.tree.DCTree.DCReference; +import openjdk.tools.javac.tree.JCTree; +import openjdk.tools.javac.tree.JCTree.JCCompilationUnit; +import openjdk.tools.javac.tree.JCTree.JCFieldAccess; +import openjdk.tools.javac.tree.JCTree.JCImport; +import openjdk.tools.javac.util.Context; +import openjdk.tools.javac.util.Log; +import openjdk.tools.javac.util.Options; import java.io.IOError; import java.io.IOException; import java.lang.reflect.Method; @@ -61,12 +61,12 @@ import java.util.LinkedHashSet; import java.util.List; import java.util.Map; import java.util.Set; -import javax.tools.Diagnostic; -import javax.tools.DiagnosticCollector; -import javax.tools.DiagnosticListener; -import javax.tools.JavaFileObject; -import javax.tools.SimpleJavaFileObject; -import javax.tools.StandardLocation; +import jdkx.tools.Diagnostic; +import jdkx.tools.DiagnosticCollector; +import jdkx.tools.DiagnosticListener; +import jdkx.tools.JavaFileObject; +import jdkx.tools.SimpleJavaFileObject; +import jdkx.tools.StandardLocation; /** * Removes unused imports from a source file. Imports that are only used in javadoc are also @@ -165,7 +165,7 @@ public class RemoveUnusedImports { // scan javadoc comments, checking for references to imported types class DocTreeScanner extends DocTreePathScanner { @Override - public Void visitIdentifier(com.sun.source.doctree.IdentifierTree node, Void aVoid) { + public Void visitIdentifier(openjdk.source.doctree.IdentifierTree node, Void aVoid) { return null; } diff --git a/subprojects/google-java-format/src/main/java/com/google/googlejavaformat/java/SnippetFormatter.java b/subprojects/google-java-format/src/main/java/com/google/googlejavaformat/java/SnippetFormatter.java index 8d426b65d..2362af641 100644 --- a/subprojects/google-java-format/src/main/java/com/google/googlejavaformat/java/SnippetFormatter.java +++ b/subprojects/google-java-format/src/main/java/com/google/googlejavaformat/java/SnippetFormatter.java @@ -14,7 +14,7 @@ package com.google.googlejavaformat.java; -import static com.google.common.collect.ImmutableList.toImmutableList; +import static com.google.common.collect.ImmutableListUtils.toImmutableList; import com.google.common.base.CharMatcher; import com.google.common.base.Preconditions; diff --git a/subprojects/google-java-format/src/main/java/com/google/googlejavaformat/java/StringWrapper.java b/subprojects/google-java-format/src/main/java/com/google/googlejavaformat/java/StringWrapper.java index d801c9b86..876978a9d 100644 --- a/subprojects/google-java-format/src/main/java/com/google/googlejavaformat/java/StringWrapper.java +++ b/subprojects/google-java-format/src/main/java/com/google/googlejavaformat/java/StringWrapper.java @@ -26,21 +26,21 @@ import com.google.common.collect.Iterables; import com.google.common.collect.Range; import com.google.common.collect.TreeRangeMap; import com.google.googlejavaformat.Newlines; -import com.sun.source.tree.BinaryTree; -import com.sun.source.tree.LiteralTree; -import com.sun.source.tree.MemberSelectTree; -import com.sun.source.tree.Tree; -import com.sun.source.tree.Tree.Kind; -import com.sun.source.util.TreePath; -import com.sun.source.util.TreePathScanner; -import com.sun.tools.javac.file.JavacFileManager; -import com.sun.tools.javac.parser.JavacParser; -import com.sun.tools.javac.parser.ParserFactory; -import com.sun.tools.javac.tree.JCTree; -import com.sun.tools.javac.util.Context; -import com.sun.tools.javac.util.Log; -import com.sun.tools.javac.util.Options; -import com.sun.tools.javac.util.Position; +import openjdk.source.tree.BinaryTree; +import openjdk.source.tree.LiteralTree; +import openjdk.source.tree.MemberSelectTree; +import openjdk.source.tree.Tree; +import openjdk.source.tree.Tree.Kind; +import openjdk.source.util.TreePath; +import openjdk.source.util.TreePathScanner; +import openjdk.tools.javac.file.JavacFileManager; +import openjdk.tools.javac.parser.JavacParser; +import openjdk.tools.javac.parser.ParserFactory; +import openjdk.tools.javac.tree.JCTree; +import openjdk.tools.javac.util.Context; +import openjdk.tools.javac.util.Log; +import openjdk.tools.javac.util.Options; +import openjdk.tools.javac.util.Position; import java.io.IOException; import java.io.UncheckedIOException; import java.net.URI; @@ -52,12 +52,12 @@ import java.util.List; import java.util.Map; import java.util.concurrent.atomic.AtomicBoolean; import java.util.stream.Stream; -import javax.tools.Diagnostic; -import javax.tools.DiagnosticCollector; -import javax.tools.DiagnosticListener; -import javax.tools.JavaFileObject; -import javax.tools.SimpleJavaFileObject; -import javax.tools.StandardLocation; +import jdkx.tools.Diagnostic; +import jdkx.tools.DiagnosticCollector; +import jdkx.tools.DiagnosticListener; +import jdkx.tools.JavaFileObject; +import jdkx.tools.SimpleJavaFileObject; +import jdkx.tools.StandardLocation; /** Wraps string literals that exceed the column limit. */ public final class StringWrapper { diff --git a/subprojects/google-java-format/src/main/java/com/google/googlejavaformat/java/Trees.java b/subprojects/google-java-format/src/main/java/com/google/googlejavaformat/java/Trees.java index 397dacae6..83f302dc3 100644 --- a/subprojects/google-java-format/src/main/java/com/google/googlejavaformat/java/Trees.java +++ b/subprojects/google-java-format/src/main/java/com/google/googlejavaformat/java/Trees.java @@ -14,21 +14,21 @@ package com.google.googlejavaformat.java; -import com.sun.source.tree.ClassTree; -import com.sun.source.tree.CompoundAssignmentTree; -import com.sun.source.tree.ExpressionTree; -import com.sun.source.tree.IdentifierTree; -import com.sun.source.tree.MemberSelectTree; -import com.sun.source.tree.MethodInvocationTree; -import com.sun.source.tree.ParenthesizedTree; -import com.sun.source.tree.Tree; -import com.sun.source.util.TreePath; -import com.sun.tools.javac.tree.JCTree; -import com.sun.tools.javac.tree.Pretty; -import com.sun.tools.javac.tree.TreeInfo; +import openjdk.source.tree.ClassTree; +import openjdk.source.tree.CompoundAssignmentTree; +import openjdk.source.tree.ExpressionTree; +import openjdk.source.tree.IdentifierTree; +import openjdk.source.tree.MemberSelectTree; +import openjdk.source.tree.MethodInvocationTree; +import openjdk.source.tree.ParenthesizedTree; +import openjdk.source.tree.Tree; +import openjdk.source.util.TreePath; +import openjdk.tools.javac.tree.JCTree; +import openjdk.tools.javac.tree.Pretty; +import openjdk.tools.javac.tree.TreeInfo; import java.io.IOError; import java.io.IOException; -import javax.lang.model.element.Name; +import jdkx.lang.model.element.Name; /** Utilities for working with {@link Tree}s. */ class Trees { diff --git a/subprojects/google-java-format/src/main/java/com/google/googlejavaformat/java/filer/FormattingFiler.java b/subprojects/google-java-format/src/main/java/com/google/googlejavaformat/java/filer/FormattingFiler.java index d38d84eca..846e5f217 100644 --- a/subprojects/google-java-format/src/main/java/com/google/googlejavaformat/java/filer/FormattingFiler.java +++ b/subprojects/google-java-format/src/main/java/com/google/googlejavaformat/java/filer/FormattingFiler.java @@ -18,12 +18,12 @@ import static com.google.common.base.Preconditions.checkNotNull; import com.google.googlejavaformat.java.Formatter; import java.io.IOException; -import javax.annotation.processing.Filer; -import javax.annotation.processing.Messager; -import javax.lang.model.element.Element; -import javax.tools.FileObject; -import javax.tools.JavaFileManager; -import javax.tools.JavaFileObject; +import jdkx.annotation.processing.Filer; +import jdkx.annotation.processing.Messager; +import jdkx.lang.model.element.Element; +import jdkx.tools.FileObject; +import jdkx.tools.JavaFileManager; +import jdkx.tools.JavaFileObject; import org.checkerframework.checker.nullness.qual.Nullable; /** diff --git a/subprojects/google-java-format/src/main/java/com/google/googlejavaformat/java/filer/FormattingJavaFileObject.java b/subprojects/google-java-format/src/main/java/com/google/googlejavaformat/java/filer/FormattingJavaFileObject.java index c8ae80769..420d11227 100644 --- a/subprojects/google-java-format/src/main/java/com/google/googlejavaformat/java/filer/FormattingJavaFileObject.java +++ b/subprojects/google-java-format/src/main/java/com/google/googlejavaformat/java/filer/FormattingJavaFileObject.java @@ -22,10 +22,10 @@ import com.google.googlejavaformat.java.Formatter; import com.google.googlejavaformat.java.FormatterException; import java.io.IOException; import java.io.Writer; -import javax.annotation.processing.Messager; -import javax.tools.Diagnostic; -import javax.tools.ForwardingJavaFileObject; -import javax.tools.JavaFileObject; +import jdkx.annotation.processing.Messager; +import jdkx.tools.Diagnostic; +import jdkx.tools.ForwardingJavaFileObject; +import jdkx.tools.JavaFileObject; import org.checkerframework.checker.nullness.qual.Nullable; /** A {@link JavaFileObject} decorator which {@linkplain Formatter formats} source code. */ diff --git a/subprojects/google-java-format/src/main/java/com/google/googlejavaformat/java/java17/Java17InputAstVisitor.java b/subprojects/google-java-format/src/main/java/com/google/googlejavaformat/java/java17/Java17InputAstVisitor.java index a0561e2fe..a40937fb5 100644 --- a/subprojects/google-java-format/src/main/java/com/google/googlejavaformat/java/java17/Java17InputAstVisitor.java +++ b/subprojects/google-java-format/src/main/java/com/google/googlejavaformat/java/java17/Java17InputAstVisitor.java @@ -14,7 +14,7 @@ package com.google.googlejavaformat.java.java17; -import static com.google.common.collect.ImmutableList.toImmutableList; +import static com.google.common.collect.ImmutableListUtils.toImmutableList; import static com.google.common.collect.Iterables.getOnlyElement; import com.google.common.base.Verify; @@ -22,27 +22,27 @@ import com.google.common.collect.ImmutableList; import com.google.googlejavaformat.OpsBuilder; import com.google.googlejavaformat.OpsBuilder.BlankLineWanted; import com.google.googlejavaformat.java.JavaInputAstVisitor; -import com.sun.source.tree.AnnotationTree; -import com.sun.source.tree.BindingPatternTree; -import com.sun.source.tree.BlockTree; -import com.sun.source.tree.CaseLabelTree; -import com.sun.source.tree.CaseTree; -import com.sun.source.tree.ClassTree; -import com.sun.source.tree.CompilationUnitTree; -import com.sun.source.tree.InstanceOfTree; -import com.sun.source.tree.ModifiersTree; -import com.sun.source.tree.ModuleTree; -import com.sun.source.tree.SwitchExpressionTree; -import com.sun.source.tree.Tree; -import com.sun.source.tree.VariableTree; -import com.sun.source.tree.YieldTree; -import com.sun.tools.javac.code.Flags; -import com.sun.tools.javac.tree.JCTree; -import com.sun.tools.javac.tree.JCTree.JCVariableDecl; -import com.sun.tools.javac.tree.TreeInfo; import java.util.List; import java.util.Optional; -import javax.lang.model.element.Name; +import jdkx.lang.model.element.Name; +import openjdk.source.tree.AnnotationTree; +import openjdk.source.tree.BindingPatternTree; +import openjdk.source.tree.BlockTree; +import openjdk.source.tree.CaseLabelTree; +import openjdk.source.tree.CaseTree; +import openjdk.source.tree.ClassTree; +import openjdk.source.tree.CompilationUnitTree; +import openjdk.source.tree.InstanceOfTree; +import openjdk.source.tree.ModifiersTree; +import openjdk.source.tree.ModuleTree; +import openjdk.source.tree.SwitchExpressionTree; +import openjdk.source.tree.Tree; +import openjdk.source.tree.VariableTree; +import openjdk.source.tree.YieldTree; +import openjdk.tools.javac.code.Flags; +import openjdk.tools.javac.tree.JCTree; +import openjdk.tools.javac.tree.JCTree.JCVariableDecl; +import openjdk.tools.javac.tree.TreeInfo; /** * Extends {@link JavaInputAstVisitor} with support for AST nodes that were added or modified in