Format all Java files with google-java-format
Having a standard tool for formatting saves reviewers' valuable time. google-java-format is Google's standard formatter and is somewhat inspired by gofmt[1]. This commit formats everything using google-java-format version 1.2. The downside of this one-off formatting is breaking blame. This can be somewhat hacked around with a tool like git-hyper-blame[2], but it's definitely not optimal until/unless this kind of feature makes its way to git core. Not in this change: * Tool support, e.g. Eclipse. The command must be run manually [3]. * Documentation of best practice, e.g. new 100-column default. [1] https://talks.golang.org/2015/gofmt-en.slide#3 [2] https://commondatastorage.googleapis.com/chrome-infra-docs/flat/depot_tools/docs/html/git-hyper-blame.html [3] git ls-files | grep java$ | xargs google-java-format -i Change-Id: Id5f3c6de95ce0b68b41f0a478b5c99a93675aaa3 Signed-off-by: David Pursehouse <dpursehouse@collab.net>
This commit is contained in:
committed by
David Pursehouse
parent
6723b6d0fa
commit
292fa154c1
@@ -18,7 +18,6 @@ import com.google.gerrit.reviewdb.client.AccountGroup;
|
||||
import com.google.gerrit.server.account.GroupCache;
|
||||
import com.google.inject.Inject;
|
||||
import com.google.inject.assistedinject.Assisted;
|
||||
|
||||
import org.kohsuke.args4j.CmdLineException;
|
||||
import org.kohsuke.args4j.CmdLineParser;
|
||||
import org.kohsuke.args4j.OptionDef;
|
||||
@@ -30,16 +29,17 @@ public class AccountGroupIdHandler extends OptionHandler<AccountGroup.Id> {
|
||||
private final GroupCache groupCache;
|
||||
|
||||
@Inject
|
||||
public AccountGroupIdHandler(final GroupCache groupCache,
|
||||
@Assisted final CmdLineParser parser, @Assisted final OptionDef option,
|
||||
public AccountGroupIdHandler(
|
||||
final GroupCache groupCache,
|
||||
@Assisted final CmdLineParser parser,
|
||||
@Assisted final OptionDef option,
|
||||
@Assisted final Setter<AccountGroup.Id> setter) {
|
||||
super(parser, option, setter);
|
||||
this.groupCache = groupCache;
|
||||
}
|
||||
|
||||
@Override
|
||||
public final int parseArguments(final Parameters params)
|
||||
throws CmdLineException {
|
||||
public final int parseArguments(final Parameters params) throws CmdLineException {
|
||||
final String n = params.getParameter(0);
|
||||
final AccountGroup group = groupCache.get(new AccountGroup.NameKey(n));
|
||||
if (group == null) {
|
||||
|
||||
@@ -20,7 +20,6 @@ import com.google.gerrit.server.account.GroupBackend;
|
||||
import com.google.gerrit.server.account.GroupBackends;
|
||||
import com.google.inject.Inject;
|
||||
import com.google.inject.assistedinject.Assisted;
|
||||
|
||||
import org.kohsuke.args4j.CmdLineException;
|
||||
import org.kohsuke.args4j.CmdLineParser;
|
||||
import org.kohsuke.args4j.OptionDef;
|
||||
@@ -32,16 +31,17 @@ public class AccountGroupUUIDHandler extends OptionHandler<AccountGroup.UUID> {
|
||||
private final GroupBackend groupBackend;
|
||||
|
||||
@Inject
|
||||
public AccountGroupUUIDHandler(final GroupBackend groupBackend,
|
||||
@Assisted final CmdLineParser parser, @Assisted final OptionDef option,
|
||||
public AccountGroupUUIDHandler(
|
||||
final GroupBackend groupBackend,
|
||||
@Assisted final CmdLineParser parser,
|
||||
@Assisted final OptionDef option,
|
||||
@Assisted final Setter<AccountGroup.UUID> setter) {
|
||||
super(parser, option, setter);
|
||||
this.groupBackend = groupBackend;
|
||||
}
|
||||
|
||||
@Override
|
||||
public final int parseArguments(final Parameters params)
|
||||
throws CmdLineException {
|
||||
public final int parseArguments(final Parameters params) throws CmdLineException {
|
||||
final String n = params.getParameter(0);
|
||||
GroupReference group = GroupBackends.findExactSuggestion(groupBackend, n);
|
||||
if (group == null) {
|
||||
|
||||
@@ -26,7 +26,7 @@ import com.google.gwtorm.server.OrmException;
|
||||
import com.google.inject.Inject;
|
||||
import com.google.inject.Provider;
|
||||
import com.google.inject.assistedinject.Assisted;
|
||||
|
||||
import java.io.IOException;
|
||||
import org.kohsuke.args4j.CmdLineException;
|
||||
import org.kohsuke.args4j.CmdLineParser;
|
||||
import org.kohsuke.args4j.OptionDef;
|
||||
@@ -34,8 +34,6 @@ import org.kohsuke.args4j.spi.OptionHandler;
|
||||
import org.kohsuke.args4j.spi.Parameters;
|
||||
import org.kohsuke.args4j.spi.Setter;
|
||||
|
||||
import java.io.IOException;
|
||||
|
||||
public class AccountIdHandler extends OptionHandler<Account.Id> {
|
||||
private final Provider<ReviewDb> db;
|
||||
private final AccountResolver accountResolver;
|
||||
@@ -59,8 +57,7 @@ public class AccountIdHandler extends OptionHandler<Account.Id> {
|
||||
}
|
||||
|
||||
@Override
|
||||
public int parseArguments(Parameters params)
|
||||
throws CmdLineException {
|
||||
public int parseArguments(Parameters params) throws CmdLineException {
|
||||
String token = params.getParameter(0);
|
||||
Account.Id accountId;
|
||||
try {
|
||||
@@ -92,8 +89,7 @@ public class AccountIdHandler extends OptionHandler<Account.Id> {
|
||||
return 1;
|
||||
}
|
||||
|
||||
private Account.Id createAccountByLdap(String user)
|
||||
throws CmdLineException, IOException {
|
||||
private Account.Id createAccountByLdap(String user) throws CmdLineException, IOException {
|
||||
if (!user.matches(Account.USER_NAME_PATTERN)) {
|
||||
throw new CmdLineException(owner, "user \"" + user + "\" not found");
|
||||
}
|
||||
|
||||
@@ -23,7 +23,6 @@ import com.google.gwtorm.server.OrmException;
|
||||
import com.google.inject.Inject;
|
||||
import com.google.inject.Provider;
|
||||
import com.google.inject.assistedinject.Assisted;
|
||||
|
||||
import org.kohsuke.args4j.CmdLineException;
|
||||
import org.kohsuke.args4j.CmdLineParser;
|
||||
import org.kohsuke.args4j.OptionDef;
|
||||
@@ -38,20 +37,20 @@ public class ChangeIdHandler extends OptionHandler<Change.Id> {
|
||||
public ChangeIdHandler(
|
||||
// TODO(dborowitz): Not sure whether this is injectable here.
|
||||
Provider<InternalChangeQuery> queryProvider,
|
||||
@Assisted final CmdLineParser parser, @Assisted final OptionDef option,
|
||||
@Assisted final CmdLineParser parser,
|
||||
@Assisted final OptionDef option,
|
||||
@Assisted final Setter<Change.Id> setter) {
|
||||
super(parser, option, setter);
|
||||
this.queryProvider = queryProvider;
|
||||
}
|
||||
|
||||
@Override
|
||||
public final int parseArguments(final Parameters params)
|
||||
throws CmdLineException {
|
||||
public final int parseArguments(final Parameters params) throws CmdLineException {
|
||||
final String token = params.getParameter(0);
|
||||
final String[] tokens = token.split(",");
|
||||
if (tokens.length != 3) {
|
||||
throw new CmdLineException(owner, "change should be specified as "
|
||||
+ "<project>,<branch>,<change-id>");
|
||||
throw new CmdLineException(
|
||||
owner, "change should be specified as " + "<project>,<branch>,<change-id>");
|
||||
}
|
||||
|
||||
try {
|
||||
|
||||
@@ -16,7 +16,6 @@ package com.google.gerrit.server.args4j;
|
||||
|
||||
import com.google.inject.Inject;
|
||||
import com.google.inject.assistedinject.Assisted;
|
||||
|
||||
import org.eclipse.jgit.lib.ObjectId;
|
||||
import org.kohsuke.args4j.CmdLineException;
|
||||
import org.kohsuke.args4j.CmdLineParser;
|
||||
@@ -28,8 +27,10 @@ import org.kohsuke.args4j.spi.Setter;
|
||||
public class ObjectIdHandler extends OptionHandler<ObjectId> {
|
||||
|
||||
@Inject
|
||||
public ObjectIdHandler(@Assisted final CmdLineParser parser,
|
||||
@Assisted final OptionDef option, @Assisted final Setter<ObjectId> setter) {
|
||||
public ObjectIdHandler(
|
||||
@Assisted final CmdLineParser parser,
|
||||
@Assisted final OptionDef option,
|
||||
@Assisted final Setter<ObjectId> setter) {
|
||||
super(parser, option, setter);
|
||||
}
|
||||
|
||||
|
||||
@@ -17,7 +17,6 @@ package com.google.gerrit.server.args4j;
|
||||
import com.google.gerrit.reviewdb.client.PatchSet;
|
||||
import com.google.inject.Inject;
|
||||
import com.google.inject.assistedinject.Assisted;
|
||||
|
||||
import org.kohsuke.args4j.CmdLineException;
|
||||
import org.kohsuke.args4j.CmdLineParser;
|
||||
import org.kohsuke.args4j.OptionDef;
|
||||
@@ -28,21 +27,21 @@ import org.kohsuke.args4j.spi.Setter;
|
||||
public class PatchSetIdHandler extends OptionHandler<PatchSet.Id> {
|
||||
|
||||
@Inject
|
||||
public PatchSetIdHandler(@Assisted final CmdLineParser parser,
|
||||
@Assisted final OptionDef option, @Assisted final Setter<PatchSet.Id> setter) {
|
||||
public PatchSetIdHandler(
|
||||
@Assisted final CmdLineParser parser,
|
||||
@Assisted final OptionDef option,
|
||||
@Assisted final Setter<PatchSet.Id> setter) {
|
||||
super(parser, option, setter);
|
||||
}
|
||||
|
||||
@Override
|
||||
public final int parseArguments(final Parameters params)
|
||||
throws CmdLineException {
|
||||
public final int parseArguments(final Parameters params) throws CmdLineException {
|
||||
final String token = params.getParameter(0);
|
||||
final PatchSet.Id id;
|
||||
try {
|
||||
id = PatchSet.Id.parse(token);
|
||||
} catch (IllegalArgumentException e) {
|
||||
throw new CmdLineException(owner, "\"" + token
|
||||
+ "\" is not a valid patch set");
|
||||
throw new CmdLineException(owner, "\"" + token + "\" is not a valid patch set");
|
||||
}
|
||||
|
||||
setter.addValue(id);
|
||||
|
||||
@@ -22,7 +22,7 @@ import com.google.gerrit.server.project.ProjectControl;
|
||||
import com.google.inject.Inject;
|
||||
import com.google.inject.Provider;
|
||||
import com.google.inject.assistedinject.Assisted;
|
||||
|
||||
import java.io.IOException;
|
||||
import org.kohsuke.args4j.CmdLineException;
|
||||
import org.kohsuke.args4j.CmdLineParser;
|
||||
import org.kohsuke.args4j.OptionDef;
|
||||
@@ -32,11 +32,8 @@ import org.kohsuke.args4j.spi.Setter;
|
||||
import org.slf4j.Logger;
|
||||
import org.slf4j.LoggerFactory;
|
||||
|
||||
import java.io.IOException;
|
||||
|
||||
public class ProjectControlHandler extends OptionHandler<ProjectControl> {
|
||||
private static final Logger log = LoggerFactory
|
||||
.getLogger(ProjectControlHandler.class);
|
||||
private static final Logger log = LoggerFactory.getLogger(ProjectControlHandler.class);
|
||||
private final ProjectControl.GenericFactory projectControlFactory;
|
||||
private final Provider<CurrentUser> user;
|
||||
|
||||
@@ -44,7 +41,8 @@ public class ProjectControlHandler extends OptionHandler<ProjectControl> {
|
||||
public ProjectControlHandler(
|
||||
final ProjectControl.GenericFactory projectControlFactory,
|
||||
Provider<CurrentUser> user,
|
||||
@Assisted final CmdLineParser parser, @Assisted final OptionDef option,
|
||||
@Assisted final CmdLineParser parser,
|
||||
@Assisted final OptionDef option,
|
||||
@Assisted final Setter<ProjectControl> setter) {
|
||||
super(parser, option, setter);
|
||||
this.projectControlFactory = projectControlFactory;
|
||||
@@ -52,8 +50,7 @@ public class ProjectControlHandler extends OptionHandler<ProjectControl> {
|
||||
}
|
||||
|
||||
@Override
|
||||
public final int parseArguments(final Parameters params)
|
||||
throws CmdLineException {
|
||||
public final int parseArguments(final Parameters params) throws CmdLineException {
|
||||
String projectName = params.getParameter(0);
|
||||
|
||||
while (projectName.endsWith("/")) {
|
||||
@@ -74,17 +71,14 @@ public class ProjectControlHandler extends OptionHandler<ProjectControl> {
|
||||
|
||||
final ProjectControl control;
|
||||
try {
|
||||
control = projectControlFactory.validateFor(
|
||||
nameKey,
|
||||
ProjectControl.OWNER | ProjectControl.VISIBLE,
|
||||
user.get());
|
||||
control =
|
||||
projectControlFactory.validateFor(
|
||||
nameKey, ProjectControl.OWNER | ProjectControl.VISIBLE, user.get());
|
||||
} catch (NoSuchProjectException e) {
|
||||
throw new CmdLineException(owner, e.getMessage());
|
||||
} catch (IOException e) {
|
||||
log.warn("Cannot load project " + nameWithoutSuffix, e);
|
||||
throw new CmdLineException(
|
||||
owner,
|
||||
new NoSuchProjectException(nameKey).getMessage());
|
||||
throw new CmdLineException(owner, new NoSuchProjectException(nameKey).getMessage());
|
||||
}
|
||||
|
||||
setter.addValue(control);
|
||||
|
||||
@@ -17,7 +17,7 @@ package com.google.gerrit.server.args4j;
|
||||
import com.google.gerrit.server.util.SocketUtil;
|
||||
import com.google.inject.Inject;
|
||||
import com.google.inject.assistedinject.Assisted;
|
||||
|
||||
import java.net.SocketAddress;
|
||||
import org.kohsuke.args4j.CmdLineException;
|
||||
import org.kohsuke.args4j.CmdLineParser;
|
||||
import org.kohsuke.args4j.OptionDef;
|
||||
@@ -25,19 +25,18 @@ import org.kohsuke.args4j.spi.OptionHandler;
|
||||
import org.kohsuke.args4j.spi.Parameters;
|
||||
import org.kohsuke.args4j.spi.Setter;
|
||||
|
||||
import java.net.SocketAddress;
|
||||
|
||||
public class SocketAddressHandler extends OptionHandler<SocketAddress> {
|
||||
|
||||
@Inject
|
||||
public SocketAddressHandler(@Assisted final CmdLineParser parser,
|
||||
@Assisted final OptionDef option, @Assisted final Setter<SocketAddress> setter) {
|
||||
public SocketAddressHandler(
|
||||
@Assisted final CmdLineParser parser,
|
||||
@Assisted final OptionDef option,
|
||||
@Assisted final Setter<SocketAddress> setter) {
|
||||
super(parser, option, setter);
|
||||
}
|
||||
|
||||
@Override
|
||||
public final int parseArguments(final Parameters params)
|
||||
throws CmdLineException {
|
||||
public final int parseArguments(final Parameters params) throws CmdLineException {
|
||||
final String token = params.getParameter(0);
|
||||
try {
|
||||
setter.addValue(SocketUtil.parse(token, 0));
|
||||
|
||||
@@ -16,7 +16,6 @@ package com.google.gerrit.server.args4j;
|
||||
|
||||
import com.google.inject.Inject;
|
||||
import com.google.inject.assistedinject.Assisted;
|
||||
|
||||
import org.kohsuke.args4j.CmdLineException;
|
||||
import org.kohsuke.args4j.CmdLineParser;
|
||||
import org.kohsuke.args4j.OptionDef;
|
||||
@@ -27,14 +26,15 @@ import org.kohsuke.args4j.spi.Setter;
|
||||
public class SubcommandHandler extends OptionHandler<String> {
|
||||
|
||||
@Inject
|
||||
public SubcommandHandler(@Assisted final CmdLineParser parser,
|
||||
@Assisted final OptionDef option, @Assisted final Setter<String> setter) {
|
||||
public SubcommandHandler(
|
||||
@Assisted final CmdLineParser parser,
|
||||
@Assisted final OptionDef option,
|
||||
@Assisted final Setter<String> setter) {
|
||||
super(parser, option, setter);
|
||||
}
|
||||
|
||||
@Override
|
||||
public final int parseArguments(final Parameters params)
|
||||
throws CmdLineException {
|
||||
public final int parseArguments(final Parameters params) throws CmdLineException {
|
||||
setter.addValue(params.getParameter(0));
|
||||
owner.stopOptionParsing();
|
||||
return 1;
|
||||
|
||||
@@ -16,7 +16,11 @@ package com.google.gerrit.server.args4j;
|
||||
|
||||
import com.google.inject.Inject;
|
||||
import com.google.inject.assistedinject.Assisted;
|
||||
|
||||
import java.sql.Timestamp;
|
||||
import java.text.DateFormat;
|
||||
import java.text.ParseException;
|
||||
import java.text.SimpleDateFormat;
|
||||
import java.util.TimeZone;
|
||||
import org.kohsuke.args4j.CmdLineException;
|
||||
import org.kohsuke.args4j.CmdLineParser;
|
||||
import org.kohsuke.args4j.OptionDef;
|
||||
@@ -24,18 +28,14 @@ import org.kohsuke.args4j.spi.OptionHandler;
|
||||
import org.kohsuke.args4j.spi.Parameters;
|
||||
import org.kohsuke.args4j.spi.Setter;
|
||||
|
||||
import java.sql.Timestamp;
|
||||
import java.text.DateFormat;
|
||||
import java.text.ParseException;
|
||||
import java.text.SimpleDateFormat;
|
||||
import java.util.TimeZone;
|
||||
|
||||
public class TimestampHandler extends OptionHandler<Timestamp> {
|
||||
public static final String TIMESTAMP_FORMAT = "yyyyMMdd_HHmm";
|
||||
|
||||
@Inject
|
||||
public TimestampHandler(@Assisted CmdLineParser parser,
|
||||
@Assisted OptionDef option, @Assisted Setter<Timestamp> setter) {
|
||||
public TimestampHandler(
|
||||
@Assisted CmdLineParser parser,
|
||||
@Assisted OptionDef option,
|
||||
@Assisted Setter<Timestamp> setter) {
|
||||
super(parser, option, setter);
|
||||
}
|
||||
|
||||
@@ -48,9 +48,10 @@ public class TimestampHandler extends OptionHandler<Timestamp> {
|
||||
setter.addValue(new Timestamp(fmt.parse(timestamp).getTime()));
|
||||
return 1;
|
||||
} catch (ParseException e) {
|
||||
throw new CmdLineException(owner,
|
||||
String.format("Invalid timestamp: %s; expected format: %s",
|
||||
timestamp, TIMESTAMP_FORMAT), e);
|
||||
throw new CmdLineException(
|
||||
owner,
|
||||
String.format("Invalid timestamp: %s; expected format: %s", timestamp, TIMESTAMP_FORMAT),
|
||||
e);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user