Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,7 @@
import java.util.List;
import java.util.Map;

/** This interface defines methods common to an {@link Input} or an {@link Output}. */
/** This class defines methods common to an {@link Input} or an {@link Output}. */
public abstract class InputOutput {
private ImmutableList<String> lines = ImmutableList.of();

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -56,7 +56,7 @@ static Result create(
private final CommandLineOptions parameters;
private final JavaFormatterOptions options;

public FormatFileCallable(
FormatFileCallable(
CommandLineOptions parameters, Path path, String input, JavaFormatterOptions options) {
this.path = path;
this.input = input;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -63,13 +63,12 @@ public static String reorderImports(String text) throws FormatterException {
}

private String reorderImports() throws FormatterException {
int firstImportStart;
Optional<Integer> maybeFirstImport = findIdentifier(0, IMPORT_OR_CLASS_START);
if (!maybeFirstImport.isPresent() || !tokenAt(maybeFirstImport.get()).equals("import")) {
// No imports, so nothing to do.
return text;
}
firstImportStart = maybeFirstImport.get();
int firstImportStart = maybeFirstImport.get();
int unindentedFirstImportStart = unindent(firstImportStart);

ImportsAndIndex imports = scanImports(firstImportStart);
Expand Down Expand Up @@ -189,7 +188,7 @@ private ImportOrderer(String text, ImmutableList<Tok> toks, Style style) {
}
}

enum ImportType {
private enum ImportType {
STATIC,
MODULE,
NORMAL
Expand All @@ -206,7 +205,8 @@ enum ImportType {
* @param importType the {@link ImportType} of the import.
* @param lineSeparator the line separator to use when formatting the import.
*/
record Import(String imported, String trailing, ImportType importType, String lineSeparator) {
private record Import(
String imported, String trailing, ImportType importType, String lineSeparator) {
/** The top-level package of the import. */
String topLevel() {
return DOT_SPLITTER.split(imported).iterator().next();
Expand All @@ -227,7 +227,7 @@ boolean isJava() {
}

/** True if this is a third-party import per AOSP style. */
public boolean isThirdParty() {
boolean isThirdParty() {
return !(isAndroid() || isJava());
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -27,12 +27,12 @@
import java.util.regex.Pattern;

/** {@code JavaCommentsHelper} extends {@link CommentsHelper} to rewrite Java comments. */
public final class JavaCommentsHelper implements CommentsHelper {
final class JavaCommentsHelper implements CommentsHelper {

private final String lineSeparator;
private final JavaFormatterOptions options;

public JavaCommentsHelper(String lineSeparator, JavaFormatterOptions options) {
JavaCommentsHelper(String lineSeparator, JavaFormatterOptions options) {
this.lineSeparator = lineSeparator;
this.options = options;
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -59,7 +59,7 @@
import org.jspecify.annotations.Nullable;

/** {@code JavaInput} extends {@link Input} to represent a Java input document. */
public final class JavaInput extends Input {
final class JavaInput extends Input {
/**
* A {@code JavaInput} is a sequence of {@link Tok}s that cover the Java input. A {@link Tok} is
* either a token (if {@code isToken()}), or a non-token, which is a comment (if {@code
Expand Down Expand Up @@ -275,7 +275,7 @@ public String toString() {
* @param text the input text
* @throws FormatterException if the input cannot be parsed
*/
public JavaInput(String text) throws FormatterException {
JavaInput(String text) throws FormatterException {
this.text = checkNotNull(text);
setLines(ImmutableList.copyOf(Newlines.lineIterator(text)));
ImmutableList<Tok> toks = buildToks(text);
Expand Down Expand Up @@ -608,7 +608,7 @@ private static boolean isParamComment(Tok tok) {
* @return the {@code 0}-based {@link Range} of tokens
* @throws FormatterException if the upper endpoint of the range is outside the file
*/
Range<Integer> characterRangeToTokenRange(Range<Integer> characterRange)
private Range<Integer> characterRangeToTokenRange(Range<Integer> characterRange)
throws FormatterException {
if (characterRange.upperEndpoint() > text.length()) {
throw new FormatterException(
Expand Down Expand Up @@ -699,11 +699,11 @@ public int getColumnNumber(int inputPosition) {

// TODO(cushon): refactor JavaInput so the CompilationUnit can be passed into
// the constructor.
public void setCompilationUnit(JCCompilationUnit unit) {
void setCompilationUnit(JCCompilationUnit unit) {
this.unit = unit;
}

public RangeSet<Integer> characterRangesToTokenRanges(Collection<Range<Integer>> characterRanges)
RangeSet<Integer> characterRangesToTokenRanges(Collection<Range<Integer>> characterRanges)
throws FormatterException {
RangeSet<Integer> tokenRangeSet = TreeRangeSet.create();
for (Range<Integer> characterRange : characterRanges) {
Expand Down
Loading
Loading