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:
Dave Borowitz
2016-11-13 09:56:32 -08:00
committed by David Pursehouse
parent 6723b6d0fa
commit 292fa154c1
2443 changed files with 54816 additions and 57825 deletions

View File

@@ -32,7 +32,13 @@ import com.google.gwtorm.server.ResultSet;
import com.google.inject.Inject;
import com.google.inject.Provider;
import com.google.inject.assistedinject.Assisted;
import java.io.IOException;
import java.nio.file.Path;
import java.util.ArrayList;
import java.util.Collections;
import java.util.Iterator;
import java.util.List;
import java.util.concurrent.ExecutionException;
import org.apache.lucene.document.Document;
import org.apache.lucene.index.Term;
import org.apache.lucene.search.IndexSearcher;
@@ -49,18 +55,9 @@ import org.eclipse.jgit.lib.Config;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import java.io.IOException;
import java.nio.file.Path;
import java.util.ArrayList;
import java.util.Collections;
import java.util.Iterator;
import java.util.List;
import java.util.concurrent.ExecutionException;
public class LuceneGroupIndex extends
AbstractLuceneIndex<AccountGroup.UUID, AccountGroup> implements GroupIndex {
private static final Logger log =
LoggerFactory.getLogger(LuceneGroupIndex.class);
public class LuceneGroupIndex extends AbstractLuceneIndex<AccountGroup.UUID, AccountGroup>
implements GroupIndex {
private static final Logger log = LoggerFactory.getLogger(LuceneGroupIndex.class);
private static final String GROUPS = "groups";
@@ -78,13 +75,12 @@ public class LuceneGroupIndex extends
private final QueryBuilder<AccountGroup> queryBuilder;
private final Provider<GroupCache> groupCache;
private static Directory dir(Schema<AccountGroup> schema, Config cfg,
SitePaths sitePaths) throws IOException {
private static Directory dir(Schema<AccountGroup> schema, Config cfg, SitePaths sitePaths)
throws IOException {
if (LuceneIndexModule.isInMemoryTest(cfg)) {
return new RAMDirectory();
}
Path indexDir =
LuceneVersionManager.getDir(sitePaths, GROUPS + "_", schema);
Path indexDir = LuceneVersionManager.getDir(sitePaths, GROUPS + "_", schema);
return FSDirectory.open(indexDir);
}
@@ -93,13 +89,19 @@ public class LuceneGroupIndex extends
@GerritServerConfig Config cfg,
SitePaths sitePaths,
Provider<GroupCache> groupCache,
@Assisted Schema<AccountGroup> schema) throws IOException {
super(schema, sitePaths, dir(schema, cfg, sitePaths), GROUPS, null,
new GerritIndexWriterConfig(cfg, GROUPS), new SearcherFactory());
@Assisted Schema<AccountGroup> schema)
throws IOException {
super(
schema,
sitePaths,
dir(schema, cfg, sitePaths),
GROUPS,
null,
new GerritIndexWriterConfig(cfg, GROUPS),
new SearcherFactory());
this.groupCache = groupCache;
indexWriterConfig =
new GerritIndexWriterConfig(cfg, GROUPS);
indexWriterConfig = new GerritIndexWriterConfig(cfg, GROUPS);
queryBuilder = new QueryBuilder<>(schema, indexWriterConfig.getAnalyzer());
}
@@ -123,9 +125,11 @@ public class LuceneGroupIndex extends
}
@Override
public DataSource<AccountGroup> getSource(Predicate<AccountGroup> p,
QueryOptions opts) throws QueryParseException {
return new QuerySource(opts, queryBuilder.toQuery(p),
public DataSource<AccountGroup> getSource(Predicate<AccountGroup> p, QueryOptions opts)
throws QueryParseException {
return new QuerySource(
opts,
queryBuilder.toQuery(p),
new Sort(new SortField(UUID_SORT_FIELD, SortField.Type.STRING, false)));
}
@@ -190,8 +194,7 @@ public class LuceneGroupIndex extends
}
private AccountGroup toAccountGroup(Document doc) {
AccountGroup.UUID uuid =
new AccountGroup.UUID(doc.getField(UUID.getName()).stringValue());
AccountGroup.UUID uuid = new AccountGroup.UUID(doc.getField(UUID.getName()).stringValue());
// Use the GroupCache rather than depending on any stored fields in the
// document (of which there shouldn't be any).
return groupCache.get().get(uuid);