Turn on many more Eclipse warnings, and fix them

- Warn on empty statements, e.g. "for (;;);". These may be
   typos and are easily replaced by "for (;;) {}" which is more
   explicit.
 - Warn on field hiding. This allows cleanup of many acceptance test
   members, at the cost of a couple of renames and the occasional
   suppression (when the field is in a public nested enum that shadows
   a public constant).
 - Warn on unnecessary casts.
 - Warn on unused declared thrown exceptions. In addition to reducing
   method signature length and number of imports, this also eliminated
   some impossible catch blocks.
 - Warn on missing @Override annotations.
 - Warn on unused parameters. This is likely the most controversial,
   as a few relatively common patterns require unused parameters in a
   way that Eclipse can't ignore. However, it also resulted in cleanup
   of a lot of unnecessary injections and method parameters, so I
   think the cost was worth it.

Change-Id: I7224be8b1c798613a127c88507e8cce400679e5d
This commit is contained in:
Dave Borowitz
2014-10-28 12:09:55 -07:00
parent 2e82f2f8a2
commit 8b42ec5bd5
305 changed files with 932 additions and 699 deletions

View File

@@ -14,11 +14,11 @@ org.eclipse.jdt.core.compiler.problem.deprecation=warning
org.eclipse.jdt.core.compiler.problem.deprecationInDeprecatedCode=disabled org.eclipse.jdt.core.compiler.problem.deprecationInDeprecatedCode=disabled
org.eclipse.jdt.core.compiler.problem.deprecationWhenOverridingDeprecatedMethod=disabled org.eclipse.jdt.core.compiler.problem.deprecationWhenOverridingDeprecatedMethod=disabled
org.eclipse.jdt.core.compiler.problem.discouragedReference=warning org.eclipse.jdt.core.compiler.problem.discouragedReference=warning
org.eclipse.jdt.core.compiler.problem.emptyStatement=ignore org.eclipse.jdt.core.compiler.problem.emptyStatement=warning
org.eclipse.jdt.core.compiler.problem.explicitlyClosedAutoCloseable=ignore org.eclipse.jdt.core.compiler.problem.explicitlyClosedAutoCloseable=ignore
org.eclipse.jdt.core.compiler.problem.fallthroughCase=ignore org.eclipse.jdt.core.compiler.problem.fallthroughCase=ignore
org.eclipse.jdt.core.compiler.problem.fatalOptionalError=disabled org.eclipse.jdt.core.compiler.problem.fatalOptionalError=disabled
org.eclipse.jdt.core.compiler.problem.fieldHiding=ignore org.eclipse.jdt.core.compiler.problem.fieldHiding=warning
org.eclipse.jdt.core.compiler.problem.finalParameterBound=warning org.eclipse.jdt.core.compiler.problem.finalParameterBound=warning
org.eclipse.jdt.core.compiler.problem.finallyBlockNotCompletingNormally=warning org.eclipse.jdt.core.compiler.problem.finallyBlockNotCompletingNormally=warning
org.eclipse.jdt.core.compiler.problem.forbiddenReference=warning org.eclipse.jdt.core.compiler.problem.forbiddenReference=warning
@@ -68,9 +68,9 @@ org.eclipse.jdt.core.compiler.problem.unclosedCloseable=warning
org.eclipse.jdt.core.compiler.problem.undocumentedEmptyBlock=ignore org.eclipse.jdt.core.compiler.problem.undocumentedEmptyBlock=ignore
org.eclipse.jdt.core.compiler.problem.unhandledWarningToken=warning org.eclipse.jdt.core.compiler.problem.unhandledWarningToken=warning
org.eclipse.jdt.core.compiler.problem.unnecessaryElse=ignore org.eclipse.jdt.core.compiler.problem.unnecessaryElse=ignore
org.eclipse.jdt.core.compiler.problem.unnecessaryTypeCheck=ignore org.eclipse.jdt.core.compiler.problem.unnecessaryTypeCheck=warning
org.eclipse.jdt.core.compiler.problem.unqualifiedFieldAccess=ignore org.eclipse.jdt.core.compiler.problem.unqualifiedFieldAccess=ignore
org.eclipse.jdt.core.compiler.problem.unusedDeclaredThrownException=ignore org.eclipse.jdt.core.compiler.problem.unusedDeclaredThrownException=warning
org.eclipse.jdt.core.compiler.problem.unusedDeclaredThrownExceptionExemptExceptionAndThrowable=enabled org.eclipse.jdt.core.compiler.problem.unusedDeclaredThrownExceptionExemptExceptionAndThrowable=enabled
org.eclipse.jdt.core.compiler.problem.unusedDeclaredThrownExceptionIncludeDocCommentReference=enabled org.eclipse.jdt.core.compiler.problem.unusedDeclaredThrownExceptionIncludeDocCommentReference=enabled
org.eclipse.jdt.core.compiler.problem.unusedDeclaredThrownExceptionWhenOverriding=disabled org.eclipse.jdt.core.compiler.problem.unusedDeclaredThrownExceptionWhenOverriding=disabled
@@ -78,7 +78,7 @@ org.eclipse.jdt.core.compiler.problem.unusedImport=warning
org.eclipse.jdt.core.compiler.problem.unusedLabel=warning org.eclipse.jdt.core.compiler.problem.unusedLabel=warning
org.eclipse.jdt.core.compiler.problem.unusedLocal=warning org.eclipse.jdt.core.compiler.problem.unusedLocal=warning
org.eclipse.jdt.core.compiler.problem.unusedObjectAllocation=ignore org.eclipse.jdt.core.compiler.problem.unusedObjectAllocation=ignore
org.eclipse.jdt.core.compiler.problem.unusedParameter=ignore org.eclipse.jdt.core.compiler.problem.unusedParameter=warning
org.eclipse.jdt.core.compiler.problem.unusedParameterIncludeDocCommentReference=enabled org.eclipse.jdt.core.compiler.problem.unusedParameterIncludeDocCommentReference=enabled
org.eclipse.jdt.core.compiler.problem.unusedParameterWhenImplementingAbstract=disabled org.eclipse.jdt.core.compiler.problem.unusedParameterWhenImplementingAbstract=disabled
org.eclipse.jdt.core.compiler.problem.unusedParameterWhenOverridingConcrete=disabled org.eclipse.jdt.core.compiler.problem.unusedParameterWhenOverridingConcrete=disabled

View File

@@ -40,6 +40,7 @@ import com.google.gerrit.server.OutputFormat;
import com.google.gerrit.server.account.GroupCache; import com.google.gerrit.server.account.GroupCache;
import com.google.gerrit.server.change.ChangeJson; import com.google.gerrit.server.change.ChangeJson;
import com.google.gerrit.server.config.AllProjectsName; import com.google.gerrit.server.config.AllProjectsName;
import com.google.gerrit.server.git.GitRepositoryManager;
import com.google.gerrit.server.git.MetaDataUpdate; import com.google.gerrit.server.git.MetaDataUpdate;
import com.google.gerrit.server.git.ProjectConfig; import com.google.gerrit.server.git.ProjectConfig;
import com.google.gerrit.server.project.ProjectCache; import com.google.gerrit.server.project.ProjectCache;
@@ -104,6 +105,9 @@ public abstract class AbstractDaemonTest {
@Inject @Inject
protected GroupCache groupCache; protected GroupCache groupCache;
@Inject
protected GitRepositoryManager repoManager;
protected Git git; protected Git git;
protected GerritServer server; protected GerritServer server;
protected TestAccount admin; protected TestAccount admin;

View File

@@ -164,8 +164,10 @@ public class AcceptanceTestRequestScope {
/** Returns exactly one instance per command executed. */ /** Returns exactly one instance per command executed. */
static final Scope REQUEST = new Scope() { static final Scope REQUEST = new Scope() {
@Override
public <T> Provider<T> scope(final Key<T> key, final Provider<T> creator) { public <T> Provider<T> scope(final Key<T> key, final Provider<T> creator) {
return new Provider<T>() { return new Provider<T>() {
@Override
public T get() { public T get() {
return requireContext().get(key, creator); return requireContext().get(key, creator);
} }

View File

@@ -27,18 +27,15 @@ import com.google.inject.Injector;
import com.google.inject.Key; import com.google.inject.Key;
import com.google.inject.Module; import com.google.inject.Module;
import org.eclipse.jgit.errors.ConfigInvalidException;
import org.eclipse.jgit.lib.Config; import org.eclipse.jgit.lib.Config;
import org.eclipse.jgit.lib.RepositoryCache; import org.eclipse.jgit.lib.RepositoryCache;
import org.eclipse.jgit.util.FS; import org.eclipse.jgit.util.FS;
import java.io.File; import java.io.File;
import java.io.IOException;
import java.lang.reflect.Field; import java.lang.reflect.Field;
import java.net.InetAddress; import java.net.InetAddress;
import java.net.InetSocketAddress; import java.net.InetSocketAddress;
import java.net.URI; import java.net.URI;
import java.net.UnknownHostException;
import java.util.concurrent.BrokenBarrierException; import java.util.concurrent.BrokenBarrierException;
import java.util.concurrent.Callable; import java.util.concurrent.Callable;
import java.util.concurrent.CyclicBarrier; import java.util.concurrent.CyclicBarrier;
@@ -53,6 +50,7 @@ public class GerritServer {
throws Exception { throws Exception {
final CyclicBarrier serverStarted = new CyclicBarrier(2); final CyclicBarrier serverStarted = new CyclicBarrier(2);
final Daemon daemon = new Daemon(new Runnable() { final Daemon daemon = new Daemon(new Runnable() {
@Override
public void run() { public void run() {
try { try {
serverStarted.await(); serverStarted.await();
@@ -84,6 +82,7 @@ public class GerritServer {
site = initSite(cfg); site = initSite(cfg);
daemonService = Executors.newSingleThreadExecutor(); daemonService = Executors.newSingleThreadExecutor();
daemonService.submit(new Callable<Void>() { daemonService.submit(new Callable<Void>() {
@Override
public Void call() throws Exception { public Void call() throws Exception {
int rc = daemon.main(new String[] {"-d", site.getPath(), "--headless" }); int rc = daemon.main(new String[] {"-d", site.getPath(), "--headless" });
if (rc != 0) { if (rc != 0) {
@@ -122,8 +121,7 @@ public class GerritServer {
return tmp; return tmp;
} }
private static void mergeTestConfig(Config cfg) private static void mergeTestConfig(Config cfg) {
throws IOException {
String forceEphemeralPort = String.format("%s:0", String forceEphemeralPort = String.format("%s:0",
getLocalHost().getHostName()); getLocalHost().getHostName());
String url = "http://" + forceEphemeralPort + "/"; String url = "http://" + forceEphemeralPort + "/";
@@ -157,7 +155,7 @@ public class GerritServer {
return (T) f.get(obj); return (T) f.get(obj);
} }
private static InetAddress getLocalHost() throws UnknownHostException { private static InetAddress getLocalHost() {
return InetAddress.getLoopbackAddress(); return InetAddress.getLoopbackAddress();
} }
@@ -169,7 +167,7 @@ public class GerritServer {
private InetSocketAddress httpAddress; private InetSocketAddress httpAddress;
private GerritServer(Injector testInjector, Daemon daemon, private GerritServer(Injector testInjector, Daemon daemon,
ExecutorService daemonService) throws IOException, ConfigInvalidException { ExecutorService daemonService) {
this.testInjector = testInjector; this.testInjector = testInjector;
this.daemon = daemon; this.daemon = daemon;
this.daemonService = daemonService; this.daemonService = daemonService;

View File

@@ -141,7 +141,7 @@ public class GitUtil {
} }
public static void rm(Git gApi, String path) public static void rm(Git gApi, String path)
throws GitAPIException, IOException { throws GitAPIException {
gApi.rm() gApi.rm()
.addFilepattern(path) .addFilepattern(path)
.call(); .call();

View File

@@ -43,7 +43,7 @@ public class HttpResponse {
public void consume() throws IllegalStateException, IOException { public void consume() throws IllegalStateException, IOException {
Reader reader = getReader(); Reader reader = getReader();
if (reader != null) { if (reader != null) {
while (reader.read() != -1); while (reader.read() != -1) {}
} }
} }

View File

@@ -194,14 +194,14 @@ public class PushOneCommit {
private final String ref; private final String ref;
private final PushResult result; private final PushResult result;
private final Commit commit; private final Commit commit;
private final String subject; private final String resSubj;
private Result(String ref, PushResult result, Commit commit, private Result(String ref, PushResult resSubj, Commit commit,
String subject) { String subject) {
this.ref = ref; this.ref = ref;
this.result = result; this.result = resSubj;
this.commit = commit; this.commit = commit;
this.subject = subject; this.resSubj = subject;
} }
public PatchSet.Id getPatchSetId() throws OrmException { public PatchSet.Id getPatchSetId() throws OrmException {
@@ -226,7 +226,7 @@ public class PushOneCommit {
throws OrmException { throws OrmException {
Change c = Change c =
Iterables.getOnlyElement(db.changes().byKey(new Change.Key(commit.getChangeId())).toList()); Iterables.getOnlyElement(db.changes().byKey(new Change.Key(commit.getChangeId())).toList());
assertEquals(subject, c.getSubject()); assertEquals(resSubj, c.getSubject());
assertEquals(expectedStatus, c.getStatus()); assertEquals(expectedStatus, c.getStatus());
assertEquals(expectedTopic, Strings.emptyToNull(c.getTopic())); assertEquals(expectedTopic, Strings.emptyToNull(c.getTopic()));
assertReviewers(c, expectedReviewers); assertReviewers(c, expectedReviewers);

View File

@@ -92,11 +92,11 @@ public class RestSession extends HttpSession {
} }
public static RawInput newRawInput(String content) throws IOException { public static RawInput newRawInput(String content) {
return newRawInput(content.getBytes(StandardCharsets.UTF_8)); return newRawInput(content.getBytes(StandardCharsets.UTF_8));
} }
public static RawInput newRawInput(final byte[] bytes) throws IOException { public static RawInput newRawInput(final byte[] bytes) {
Preconditions.checkNotNull(bytes); Preconditions.checkNotNull(bytes);
Preconditions.checkArgument(bytes.length > 0); Preconditions.checkArgument(bytes.length > 0);
return new RawInput() { return new RawInput() {

View File

@@ -78,9 +78,6 @@ public class ChangeEditIT extends AbstractDaemonTest {
@Inject @Inject
private SchemaFactory<ReviewDb> reviewDbProvider; private SchemaFactory<ReviewDb> reviewDbProvider;
@Inject
private PushOneCommit.Factory pushFactory;
@Inject @Inject
ChangeEditUtil editUtil; ChangeEditUtil editUtil;
@@ -90,7 +87,6 @@ public class ChangeEditIT extends AbstractDaemonTest {
@Inject @Inject
private FileContentUtil fileUtil; private FileContentUtil fileUtil;
private ReviewDb db;
private Change change; private Change change;
private String changeId; private String changeId;
private Change change2; private Change change2;

View File

@@ -195,14 +195,14 @@ public abstract class AbstractPushForReview extends AbstractDaemonTest {
@Test @Test
public void testPushForMasterWithApprovals_ValueOutOfRange() throws GitAPIException, public void testPushForMasterWithApprovals_ValueOutOfRange() throws GitAPIException,
IOException, RestApiException { IOException {
PushOneCommit.Result r = pushTo("refs/for/master/%l=Code-Review-3"); PushOneCommit.Result r = pushTo("refs/for/master/%l=Code-Review-3");
r.assertErrorStatus("label \"Code-Review\": -3 is not a valid value"); r.assertErrorStatus("label \"Code-Review\": -3 is not a valid value");
} }
@Test @Test
public void testPushForNonExistingBranch() throws GitAPIException, public void testPushForNonExistingBranch() throws GitAPIException,
OrmException, IOException { IOException {
String branchName = "non-existing"; String branchName = "non-existing";
PushOneCommit.Result r = pushTo("refs/for/" + branchName); PushOneCommit.Result r = pushTo("refs/for/" + branchName);
r.assertErrorStatus("branch " + branchName + " not found"); r.assertErrorStatus("branch " + branchName + " not found");

View File

@@ -30,7 +30,6 @@ import com.google.gerrit.reviewdb.client.Project;
import com.google.gerrit.server.ApprovalsUtil; import com.google.gerrit.server.ApprovalsUtil;
import com.google.gerrit.server.GerritPersonIdent; import com.google.gerrit.server.GerritPersonIdent;
import com.google.gerrit.server.git.CommitMergeStatus; import com.google.gerrit.server.git.CommitMergeStatus;
import com.google.gerrit.server.git.GitRepositoryManager;
import com.google.gerrit.server.notedb.ChangeNotes; import com.google.gerrit.server.notedb.ChangeNotes;
import com.google.gwtorm.server.OrmException; import com.google.gwtorm.server.OrmException;
import com.google.inject.Inject; import com.google.inject.Inject;
@@ -51,9 +50,6 @@ import java.io.IOException;
@NoHttpd @NoHttpd
public class SubmitOnPushIT extends AbstractDaemonTest { public class SubmitOnPushIT extends AbstractDaemonTest {
@Inject
private GitRepositoryManager repoManager;
@Inject @Inject
private ApprovalsUtil approvalsUtil; private ApprovalsUtil approvalsUtil;
@@ -63,9 +59,6 @@ public class SubmitOnPushIT extends AbstractDaemonTest {
@Inject @Inject
private @GerritPersonIdent PersonIdent serverIdent; private @GerritPersonIdent PersonIdent serverIdent;
@Inject
private PushOneCommit.Factory pushFactory;
@Test @Test
public void submitOnPush() throws Exception { public void submitOnPush() throws Exception {
grant(Permission.SUBMIT, project, "refs/for/refs/heads/master"); grant(Permission.SUBMIT, project, "refs/for/refs/heads/master");

View File

@@ -32,9 +32,7 @@ import com.google.gerrit.reviewdb.client.AccountGroup;
import com.google.gerrit.reviewdb.client.Change; import com.google.gerrit.reviewdb.client.Change;
import com.google.gerrit.reviewdb.client.PatchSet; import com.google.gerrit.reviewdb.client.PatchSet;
import com.google.gerrit.reviewdb.client.RefNames; import com.google.gerrit.reviewdb.client.RefNames;
import com.google.gerrit.server.account.GroupCache;
import com.google.gerrit.server.edit.ChangeEditModifier; import com.google.gerrit.server.edit.ChangeEditModifier;
import com.google.gerrit.server.git.GitRepositoryManager;
import com.google.gerrit.server.git.ProjectConfig; import com.google.gerrit.server.git.ProjectConfig;
import com.google.gerrit.server.notedb.NotesMigration; import com.google.gerrit.server.notedb.NotesMigration;
import com.google.gerrit.server.project.Util; import com.google.gerrit.server.project.Util;
@@ -65,12 +63,6 @@ public class VisibleRefFilterIT extends AbstractDaemonTest {
@Inject @Inject
private NotesMigration notesMigration; private NotesMigration notesMigration;
@Inject
private GitRepositoryManager repoManager;
@Inject
private GroupCache groupCache;
@Inject @Inject
private ChangeEditModifier editModifier; private ChangeEditModifier editModifier;

View File

@@ -39,7 +39,6 @@ import com.google.gerrit.reviewdb.client.Project;
import com.google.gerrit.server.ApprovalsUtil; import com.google.gerrit.server.ApprovalsUtil;
import com.google.gerrit.server.change.ChangeJson.ChangeInfo; import com.google.gerrit.server.change.ChangeJson.ChangeInfo;
import com.google.gerrit.server.change.ChangeJson.LabelInfo; import com.google.gerrit.server.change.ChangeJson.LabelInfo;
import com.google.gerrit.server.git.GitRepositoryManager;
import com.google.gerrit.server.notedb.ChangeNotes; import com.google.gerrit.server.notedb.ChangeNotes;
import com.google.gerrit.server.project.PutConfig; import com.google.gerrit.server.project.PutConfig;
import com.google.gson.reflect.TypeToken; import com.google.gson.reflect.TypeToken;
@@ -67,10 +66,6 @@ import java.util.Collections;
import java.util.List; import java.util.List;
public abstract class AbstractSubmit extends AbstractDaemonTest { public abstract class AbstractSubmit extends AbstractDaemonTest {
@Inject
private GitRepositoryManager repoManager;
@Inject @Inject
private ChangeNotes.Factory notesFactory; private ChangeNotes.Factory notesFactory;
@@ -212,7 +207,7 @@ public abstract class AbstractSubmit extends AbstractDaemonTest {
} }
protected void assertSubmitter(String changeId, int psId) protected void assertSubmitter(String changeId, int psId)
throws OrmException, IOException { throws OrmException {
ChangeNotes cn = notesFactory.create( ChangeNotes cn = notesFactory.create(
Iterables.getOnlyElement(db.changes().byKey(new Change.Key(changeId)))); Iterables.getOnlyElement(db.changes().byKey(new Change.Key(changeId))));
PatchSetApproval submitter = approvalsUtil.getSubmitter( PatchSetApproval submitter = approvalsUtil.getSubmitter(

View File

@@ -31,9 +31,7 @@ import com.google.gerrit.reviewdb.client.Account;
import com.google.gerrit.reviewdb.client.AccountGroup; import com.google.gerrit.reviewdb.client.AccountGroup;
import com.google.gerrit.reviewdb.client.AccountGroupById; import com.google.gerrit.reviewdb.client.AccountGroupById;
import com.google.gerrit.reviewdb.client.AccountGroupMember; import com.google.gerrit.reviewdb.client.AccountGroupMember;
import com.google.gerrit.reviewdb.server.ReviewDb;
import com.google.gerrit.server.account.AccountInfo; import com.google.gerrit.server.account.AccountInfo;
import com.google.gerrit.server.account.GroupCache;
import com.google.gerrit.server.group.AddIncludedGroups; import com.google.gerrit.server.group.AddIncludedGroups;
import com.google.gerrit.server.group.AddMembers; import com.google.gerrit.server.group.AddMembers;
import com.google.gerrit.server.group.CreateGroup; import com.google.gerrit.server.group.CreateGroup;
@@ -41,12 +39,8 @@ import com.google.gerrit.server.group.GroupJson.GroupInfo;
import com.google.gson.reflect.TypeToken; import com.google.gson.reflect.TypeToken;
import com.google.gwtorm.server.OrmException; import com.google.gwtorm.server.OrmException;
import com.google.gwtorm.server.ResultSet; import com.google.gwtorm.server.ResultSet;
import com.google.gwtorm.server.SchemaFactory;
import com.google.inject.Inject;
import org.apache.http.HttpStatus; import org.apache.http.HttpStatus;
import org.junit.After;
import org.junit.Before;
import org.junit.Test; import org.junit.Test;
import java.io.IOException; import java.io.IOException;
@@ -56,25 +50,6 @@ import java.util.Map;
import java.util.Set; import java.util.Set;
public class AddRemoveGroupMembersIT extends AbstractDaemonTest { public class AddRemoveGroupMembersIT extends AbstractDaemonTest {
@Inject
private SchemaFactory<ReviewDb> reviewDbProvider;
@Inject
private GroupCache groupCache;
private ReviewDb db;
@Before
public void setUp() throws Exception {
db = reviewDbProvider.open();
}
@After
public void tearDown() {
db.close();
}
@Test @Test
public void addToNonExistingGroup_NotFound() throws Exception { public void addToNonExistingGroup_NotFound() throws Exception {
assertEquals(HttpStatus.SC_NOT_FOUND, assertEquals(HttpStatus.SC_NOT_FOUND,

View File

@@ -22,19 +22,13 @@ import com.google.gerrit.acceptance.AbstractDaemonTest;
import com.google.gerrit.acceptance.RestResponse; import com.google.gerrit.acceptance.RestResponse;
import com.google.gerrit.acceptance.RestSession; import com.google.gerrit.acceptance.RestSession;
import com.google.gerrit.reviewdb.client.AccountGroup; import com.google.gerrit.reviewdb.client.AccountGroup;
import com.google.gerrit.server.account.GroupCache;
import com.google.gerrit.server.group.CreateGroup; import com.google.gerrit.server.group.CreateGroup;
import com.google.gerrit.server.group.GroupJson.GroupInfo; import com.google.gerrit.server.group.GroupJson.GroupInfo;
import com.google.inject.Inject;
import org.apache.http.HttpStatus; import org.apache.http.HttpStatus;
import org.junit.Test; import org.junit.Test;
public class CreateGroupIT extends AbstractDaemonTest { public class CreateGroupIT extends AbstractDaemonTest {
@Inject
private GroupCache groupCache;
@Test @Test
public void testCreateGroup() throws Exception { public void testCreateGroup() throws Exception {
final String newGroupName = "newGroup"; final String newGroupName = "newGroup";

View File

@@ -19,19 +19,13 @@ import static com.google.gerrit.acceptance.rest.group.GroupAssert.assertGroupInf
import com.google.gerrit.acceptance.AbstractDaemonTest; import com.google.gerrit.acceptance.AbstractDaemonTest;
import com.google.gerrit.acceptance.RestResponse; import com.google.gerrit.acceptance.RestResponse;
import com.google.gerrit.reviewdb.client.AccountGroup; import com.google.gerrit.reviewdb.client.AccountGroup;
import com.google.gerrit.server.account.GroupCache;
import com.google.gerrit.server.group.GroupJson.GroupInfo; import com.google.gerrit.server.group.GroupJson.GroupInfo;
import com.google.inject.Inject;
import org.junit.Test; import org.junit.Test;
import java.io.IOException; import java.io.IOException;
public class GetGroupIT extends AbstractDaemonTest { public class GetGroupIT extends AbstractDaemonTest {
@Inject
private GroupCache groupCache;
@Test @Test
public void testGetGroup() throws Exception { public void testGetGroup() throws Exception {
AccountGroup adminGroup = groupCache.get(new AccountGroup.NameKey("Administrators")); AccountGroup adminGroup = groupCache.get(new AccountGroup.NameKey("Administrators"));

View File

@@ -24,7 +24,6 @@ import com.google.gerrit.acceptance.AbstractDaemonTest;
import com.google.gerrit.acceptance.RestResponse; import com.google.gerrit.acceptance.RestResponse;
import com.google.gerrit.extensions.restapi.Url; import com.google.gerrit.extensions.restapi.Url;
import com.google.gerrit.reviewdb.client.AccountGroup; import com.google.gerrit.reviewdb.client.AccountGroup;
import com.google.gerrit.server.account.GroupCache;
import com.google.gerrit.server.group.GroupJson.GroupInfo; import com.google.gerrit.server.group.GroupJson.GroupInfo;
import com.google.gerrit.server.group.GroupOptionsInfo; import com.google.gerrit.server.group.GroupOptionsInfo;
import com.google.gerrit.server.group.PutDescription; import com.google.gerrit.server.group.PutDescription;
@@ -32,16 +31,11 @@ import com.google.gerrit.server.group.PutName;
import com.google.gerrit.server.group.PutOptions; import com.google.gerrit.server.group.PutOptions;
import com.google.gerrit.server.group.PutOwner; import com.google.gerrit.server.group.PutOwner;
import com.google.gerrit.server.group.SystemGroupBackend; import com.google.gerrit.server.group.SystemGroupBackend;
import com.google.inject.Inject;
import org.apache.http.HttpStatus; import org.apache.http.HttpStatus;
import org.junit.Test; import org.junit.Test;
public class GroupPropertiesIT extends AbstractDaemonTest { public class GroupPropertiesIT extends AbstractDaemonTest {
@Inject
private GroupCache groupCache;
@Test @Test
public void testGroupName() throws Exception { public void testGroupName() throws Exception {
AccountGroup.NameKey adminGroupName = new AccountGroup.NameKey("Administrators"); AccountGroup.NameKey adminGroupName = new AccountGroup.NameKey("Administrators");

View File

@@ -26,11 +26,9 @@ import com.google.gerrit.acceptance.AbstractDaemonTest;
import com.google.gerrit.acceptance.RestResponse; import com.google.gerrit.acceptance.RestResponse;
import com.google.gerrit.common.Nullable; import com.google.gerrit.common.Nullable;
import com.google.gerrit.reviewdb.client.AccountGroup; import com.google.gerrit.reviewdb.client.AccountGroup;
import com.google.gerrit.server.account.GroupCache;
import com.google.gerrit.server.group.CreateGroup; import com.google.gerrit.server.group.CreateGroup;
import com.google.gerrit.server.group.GroupJson.GroupInfo; import com.google.gerrit.server.group.GroupJson.GroupInfo;
import com.google.gson.reflect.TypeToken; import com.google.gson.reflect.TypeToken;
import com.google.inject.Inject;
import org.apache.http.HttpStatus; import org.apache.http.HttpStatus;
import org.junit.Test; import org.junit.Test;
@@ -39,10 +37,6 @@ import java.util.Map;
import java.util.Set; import java.util.Set;
public class ListGroupsIT extends AbstractDaemonTest { public class ListGroupsIT extends AbstractDaemonTest {
@Inject
private GroupCache groupCache;
@Test @Test
public void testListAllGroups() throws Exception { public void testListAllGroups() throws Exception {
Iterable<String> expectedGroups = Iterables.transform(groupCache.all(), Iterable<String> expectedGroups = Iterables.transform(groupCache.all(),

View File

@@ -31,11 +31,8 @@ import com.google.gerrit.extensions.common.SubmitType;
import com.google.gerrit.reviewdb.client.AccountGroup; import com.google.gerrit.reviewdb.client.AccountGroup;
import com.google.gerrit.reviewdb.client.Project; import com.google.gerrit.reviewdb.client.Project;
import com.google.gerrit.reviewdb.client.RefNames; import com.google.gerrit.reviewdb.client.RefNames;
import com.google.gerrit.server.account.GroupCache;
import com.google.gerrit.server.git.GitRepositoryManager;
import com.google.gerrit.server.group.SystemGroupBackend; import com.google.gerrit.server.group.SystemGroupBackend;
import com.google.gerrit.server.project.ProjectState; import com.google.gerrit.server.project.ProjectState;
import com.google.inject.Inject;
import org.apache.http.HttpStatus; import org.apache.http.HttpStatus;
import org.eclipse.jgit.errors.RepositoryNotFoundException; import org.eclipse.jgit.errors.RepositoryNotFoundException;
@@ -51,13 +48,6 @@ import java.util.Collections;
import java.util.Set; import java.util.Set;
public class CreateProjectIT extends AbstractDaemonTest { public class CreateProjectIT extends AbstractDaemonTest {
@Inject
private GroupCache groupCache;
@Inject
private GitRepositoryManager git;
@Test @Test
public void testCreateProjectApi() throws Exception { public void testCreateProjectApi() throws Exception {
final String newProjectName = "newProject"; final String newProjectName = "newProject";
@@ -214,7 +204,8 @@ public class CreateProjectIT extends AbstractDaemonTest {
private void assertHead(String projectName, String expectedRef) private void assertHead(String projectName, String expectedRef)
throws RepositoryNotFoundException, IOException { throws RepositoryNotFoundException, IOException {
Repository repo = git.openRepository(new Project.NameKey(projectName)); Repository repo =
repoManager.openRepository(new Project.NameKey(projectName));
try { try {
assertEquals(expectedRef, repo.getRef(Constants.HEAD).getTarget() assertEquals(expectedRef, repo.getRef(Constants.HEAD).getTarget()
.getName()); .getName());
@@ -225,7 +216,8 @@ public class CreateProjectIT extends AbstractDaemonTest {
private void assertEmptyCommit(String projectName, String... refs) private void assertEmptyCommit(String projectName, String... refs)
throws RepositoryNotFoundException, IOException { throws RepositoryNotFoundException, IOException {
Repository repo = git.openRepository(new Project.NameKey(projectName)); Repository repo =
repoManager.openRepository(new Project.NameKey(projectName));
RevWalk rw = new RevWalk(repo); RevWalk rw = new RevWalk(repo);
TreeWalk tw = new TreeWalk(repo); TreeWalk tw = new TreeWalk(repo);
try { try {

View File

@@ -25,9 +25,7 @@ import com.google.gerrit.acceptance.RestResponse;
import com.google.gerrit.common.data.AccessSection; import com.google.gerrit.common.data.AccessSection;
import com.google.gerrit.common.data.Permission; import com.google.gerrit.common.data.Permission;
import com.google.gerrit.extensions.common.CommitInfo; import com.google.gerrit.extensions.common.CommitInfo;
import com.google.gerrit.server.git.GitRepositoryManager;
import com.google.gerrit.server.git.ProjectConfig; import com.google.gerrit.server.git.ProjectConfig;
import com.google.inject.Inject;
import org.apache.http.HttpStatus; import org.apache.http.HttpStatus;
import org.eclipse.jgit.junit.TestRepository; import org.eclipse.jgit.junit.TestRepository;
@@ -39,9 +37,6 @@ import org.junit.Before;
import org.junit.Test; import org.junit.Test;
public class GetCommitIT extends AbstractDaemonTest { public class GetCommitIT extends AbstractDaemonTest {
@Inject
private GitRepositoryManager repoManager;
private TestRepository<Repository> repo; private TestRepository<Repository> repo;
@Before @Before

View File

@@ -22,9 +22,7 @@ import static org.junit.Assert.assertEquals;
import com.google.gerrit.acceptance.AbstractDaemonTest; import com.google.gerrit.acceptance.AbstractDaemonTest;
import com.google.gerrit.acceptance.PushOneCommit; import com.google.gerrit.acceptance.PushOneCommit;
import com.google.gerrit.reviewdb.client.RefNames; import com.google.gerrit.reviewdb.client.RefNames;
import com.google.gerrit.server.config.AllProjectsNameProvider;
import com.google.gerrit.server.project.ProjectState; import com.google.gerrit.server.project.ProjectState;
import com.google.inject.Inject;
import org.eclipse.jgit.api.Git; import org.eclipse.jgit.api.Git;
import org.eclipse.jgit.lib.Config; import org.eclipse.jgit.lib.Config;
@@ -32,13 +30,6 @@ import org.junit.Before;
import org.junit.Test; import org.junit.Test;
public class ProjectLevelConfigIT extends AbstractDaemonTest { public class ProjectLevelConfigIT extends AbstractDaemonTest {
@Inject
private AllProjectsNameProvider allProjects;
@Inject
private PushOneCommit.Factory pushFactory;
@Before @Before
public void setUp() throws Exception { public void setUp() throws Exception {
fetch(git, RefNames.REFS_CONFIG + ":refs/heads/config"); fetch(git, RefNames.REFS_CONFIG + ":refs/heads/config");
@@ -77,7 +68,7 @@ public class ProjectLevelConfigIT extends AbstractDaemonTest {
parentCfg.setString("s2", "ss", "k4", "parentValue4"); parentCfg.setString("s2", "ss", "k4", "parentValue4");
Git parentGit = Git parentGit =
cloneProject(sshSession.getUrl() + "/" + allProjects.get().get(), false); cloneProject(sshSession.getUrl() + "/" + allProjects.get(), false);
fetch(parentGit, RefNames.REFS_CONFIG + ":refs/heads/config"); fetch(parentGit, RefNames.REFS_CONFIG + ":refs/heads/config");
checkout(parentGit, "refs/heads/config"); checkout(parentGit, "refs/heads/config");
PushOneCommit push = PushOneCommit push =

View File

@@ -20,18 +20,12 @@ import static org.junit.Assert.assertEquals;
import com.google.gerrit.acceptance.AbstractDaemonTest; import com.google.gerrit.acceptance.AbstractDaemonTest;
import com.google.gerrit.acceptance.RestResponse; import com.google.gerrit.acceptance.RestResponse;
import com.google.gerrit.reviewdb.client.Project; import com.google.gerrit.reviewdb.client.Project;
import com.google.gerrit.server.config.AllProjectsNameProvider;
import com.google.gerrit.server.project.SetParent; import com.google.gerrit.server.project.SetParent;
import com.google.inject.Inject;
import org.apache.http.HttpStatus; import org.apache.http.HttpStatus;
import org.junit.Test; import org.junit.Test;
public class SetParentIT extends AbstractDaemonTest { public class SetParentIT extends AbstractDaemonTest {
@Inject
private AllProjectsNameProvider allProjects;
@Test @Test
public void setParent_Forbidden() throws Exception { public void setParent_Forbidden() throws Exception {
String parent = "parent"; String parent = "parent";

View File

@@ -33,7 +33,6 @@ import com.google.gerrit.server.patch.PatchListCache;
import com.google.gerrit.server.patch.PatchListEntry; import com.google.gerrit.server.patch.PatchListEntry;
import com.google.gerrit.server.patch.PatchListKey; import com.google.gerrit.server.patch.PatchListKey;
import com.google.gerrit.server.patch.PatchListNotAvailableException; import com.google.gerrit.server.patch.PatchListNotAvailableException;
import com.google.gwtorm.server.OrmException;
import com.google.inject.Inject; import com.google.inject.Inject;
import org.eclipse.jgit.api.ResetCommand.ResetType; import org.eclipse.jgit.api.ResetCommand.ResetType;
@@ -205,16 +204,16 @@ public class PatchListCacheIT extends AbstractDaemonTest {
} }
private List<PatchListEntry> getCurrentPatches(String changeId) private List<PatchListEntry> getCurrentPatches(String changeId)
throws PatchListNotAvailableException, OrmException, RestApiException { throws PatchListNotAvailableException, RestApiException {
return patchListCache.get(getKey(null, getCurrentRevisionId(changeId))).getPatches(); return patchListCache.get(getKey(null, getCurrentRevisionId(changeId))).getPatches();
} }
private List<PatchListEntry> getPatches(ObjectId revisionIdA, ObjectId revisionIdB) private List<PatchListEntry> getPatches(ObjectId revisionIdA, ObjectId revisionIdB)
throws PatchListNotAvailableException, OrmException { throws PatchListNotAvailableException {
return patchListCache.get(getKey(revisionIdA, revisionIdB)).getPatches(); return patchListCache.get(getKey(revisionIdA, revisionIdB)).getPatches();
} }
private PatchListKey getKey(ObjectId revisionIdA, ObjectId revisionIdB) throws OrmException { private PatchListKey getKey(ObjectId revisionIdA, ObjectId revisionIdB) {
return new PatchListKey(project, revisionIdA, revisionIdB, Whitespace.IGNORE_NONE); return new PatchListKey(project, revisionIdA, revisionIdB, Whitespace.IGNORE_NONE);
} }

View File

@@ -25,12 +25,10 @@ import com.google.gerrit.extensions.api.changes.CherryPickInput;
import com.google.gerrit.extensions.api.changes.ReviewInput; import com.google.gerrit.extensions.api.changes.ReviewInput;
import com.google.gerrit.extensions.common.ChangeInfo; import com.google.gerrit.extensions.common.ChangeInfo;
import com.google.gerrit.extensions.common.LabelInfo; import com.google.gerrit.extensions.common.LabelInfo;
import com.google.gerrit.server.git.GitRepositoryManager;
import com.google.gerrit.server.git.MetaDataUpdate; import com.google.gerrit.server.git.MetaDataUpdate;
import com.google.gerrit.server.git.ProjectConfig; import com.google.gerrit.server.git.ProjectConfig;
import com.google.gerrit.server.notedb.NotesMigration; import com.google.gerrit.server.notedb.NotesMigration;
import com.google.gerrit.testutil.ConfigSuite; import com.google.gerrit.testutil.ConfigSuite;
import com.google.inject.Inject;
import org.eclipse.jgit.lib.Config; import org.eclipse.jgit.lib.Config;
import org.eclipse.jgit.lib.Repository; import org.eclipse.jgit.lib.Repository;
@@ -44,9 +42,6 @@ public class LabelTypeIT extends AbstractDaemonTest {
return NotesMigration.allEnabledConfig(); return NotesMigration.allEnabledConfig();
} }
@Inject
private GitRepositoryManager repoManager;
private LabelType codeReview; private LabelType codeReview;
@Before @Before

View File

@@ -32,6 +32,7 @@ public class ApprovalDetail {
final int owner) { final int owner) {
List<ApprovalDetail> sorted = new ArrayList<>(ads); List<ApprovalDetail> sorted = new ArrayList<>(ads);
Collections.sort(sorted, new Comparator<ApprovalDetail>() { Collections.sort(sorted, new Comparator<ApprovalDetail>() {
@Override
public int compare(ApprovalDetail o1, ApprovalDetail o2) { public int compare(ApprovalDetail o1, ApprovalDetail o2) {
int byOwner = (o2.account.get() == owner ? 1 : 0) int byOwner = (o2.account.get() == owner ? 1 : 0)
- (o1.account.get() == owner ? 1 : 0); - (o1.account.get() == owner ? 1 : 0);

View File

@@ -66,6 +66,7 @@ public class LabelType {
return Collections.unmodifiableList(values); return Collections.unmodifiableList(values);
} }
Collections.sort(values, new Comparator<LabelValue>() { Collections.sort(values, new Comparator<LabelValue>() {
@Override
public int compare(LabelValue o1, LabelValue o2) { public int compare(LabelValue o1, LabelValue o2) {
return o1.getValue() - o2.getValue(); return o1.getValue() - o2.getValue();
} }

View File

@@ -42,6 +42,7 @@ public class SubmitTypeRecord {
public SubmitType type; public SubmitType type;
public String errorMessage; public String errorMessage;
@Override
public String toString() { public String toString() {
StringBuilder sb = new StringBuilder(); StringBuilder sb = new StringBuilder();
sb.append(status); sb.append(status);

View File

@@ -194,19 +194,20 @@ public class DynamicItem<T> {
} }
private class ReloadableHandle implements ReloadableRegistrationHandle<T> { private class ReloadableHandle implements ReloadableRegistrationHandle<T> {
private final Key<T> key; private final Key<T> handleKey;
private final NamedProvider<T> item; private final NamedProvider<T> item;
private final NamedProvider<T> defaultItem; private final NamedProvider<T> defaultItem;
ReloadableHandle(Key<T> key, NamedProvider<T> item, NamedProvider<T> defaultItem) { ReloadableHandle(Key<T> handleKey, NamedProvider<T> item,
this.key = key; NamedProvider<T> defaultItem) {
this.handleKey = handleKey;
this.item = item; this.item = item;
this.defaultItem = defaultItem; this.defaultItem = defaultItem;
} }
@Override @Override
public Key<T> getKey() { public Key<T> getKey() {
return key; return handleKey;
} }
@Override @Override

View File

@@ -36,6 +36,7 @@ class DynamicItemProvider<T> implements Provider<DynamicItem<T>> {
this.key = key; this.key = key;
} }
@Override
public DynamicItem<T> get() { public DynamicItem<T> get() {
return new DynamicItem<>(key, find(injector, type), "gerrit"); return new DynamicItem<>(key, find(injector, type), "gerrit");
} }

View File

@@ -139,6 +139,7 @@ public abstract class DynamicMap<T> implements Iterable<DynamicMap.Entry<T>> {
} }
/** Iterate through all entries in an undefined order. */ /** Iterate through all entries in an undefined order. */
@Override
public Iterator<Entry<T>> iterator() { public Iterator<Entry<T>> iterator() {
final Iterator<Map.Entry<NamePair, Provider<T>>> i = final Iterator<Map.Entry<NamePair, Provider<T>>> i =
items.entrySet().iterator(); items.entrySet().iterator();

View File

@@ -32,6 +32,7 @@ class DynamicMapProvider<T> implements Provider<DynamicMap<T>> {
this.type = type; this.type = type;
} }
@Override
public DynamicMap<T> get() { public DynamicMap<T> get() {
PrivateInternals_DynamicMapImpl<T> m = PrivateInternals_DynamicMapImpl<T> m =
new PrivateInternals_DynamicMapImpl<>(); new PrivateInternals_DynamicMapImpl<>();

View File

@@ -35,6 +35,7 @@ class DynamicSetProvider<T> implements Provider<DynamicSet<T>> {
this.type = type; this.type = type;
} }
@Override
public DynamicSet<T> get() { public DynamicSet<T> get() {
return new DynamicSet<>(find(injector, type)); return new DynamicSet<>(find(injector, type));
} }

View File

@@ -145,6 +145,7 @@ public abstract class BinaryResult implements Closeable {
public abstract void writeTo(OutputStream os) throws IOException; public abstract void writeTo(OutputStream os) throws IOException;
/** Close the result and release any resources it holds. */ /** Close the result and release any resources it holds. */
@Override
public void close() throws IOException { public void close() throws IOException {
} }

View File

@@ -19,6 +19,7 @@ import java.util.concurrent.TimeUnit;
public class CacheControl { public class CacheControl {
public enum Type { public enum Type {
@SuppressWarnings("hiding")
NONE, PUBLIC, PRIVATE NONE, PUBLIC, PRIVATE
} }

View File

@@ -52,6 +52,7 @@ public abstract class Response<T> {
public abstract T value(); public abstract T value();
public abstract CacheControl caching(); public abstract CacheControl caching();
public abstract Response<T> caching(CacheControl c); public abstract Response<T> caching(CacheControl c);
@Override
public abstract String toString(); public abstract String toString();
private static final class Impl<T> extends Response<T> { private static final class Impl<T> extends Response<T> {
@@ -100,6 +101,7 @@ public abstract class Response<T> {
return 204; return 204;
} }
@Override
public Object value() { public Object value() {
throw new UnsupportedOperationException(); throw new UnsupportedOperationException();
} }

View File

@@ -160,10 +160,12 @@ public class CopyableLabel extends Composite implements HasText {
} }
} }
@Override
public String getText() { public String getText() {
return text; return text;
} }
@Override
public void setText(final String newText) { public void setText(final String newText) {
text = newText; text = newText;
visibleLen = newText.length(); visibleLen = newText.length();
@@ -195,6 +197,7 @@ public class CopyableLabel extends Composite implements HasText {
@Override @Override
public void onKeyUp(final KeyUpEvent event) { public void onKeyUp(final KeyUpEvent event) {
Scheduler.get().scheduleDeferred(new Command() { Scheduler.get().scheduleDeferred(new Command() {
@Override
public void execute() { public void execute() {
hideTextBox(); hideTextBox();
} }

View File

@@ -107,11 +107,13 @@ class AttMap {
} }
private static class AnyTag implements Tag { private static class AnyTag implements Tag {
@Override
public void assertSafe(String name, String value) { public void assertSafe(String name, String value) {
} }
} }
private static class AnchorTag implements Tag { private static class AnchorTag implements Tag {
@Override
public void assertSafe(String name, String value) { public void assertSafe(String name, String value) {
if ("href".equals(name)) { if ("href".equals(name)) {
assertNotJavascriptUrl(value); assertNotJavascriptUrl(value);
@@ -120,6 +122,7 @@ class AttMap {
} }
private static class FormTag implements Tag { private static class FormTag implements Tag {
@Override
public void assertSafe(String name, String value) { public void assertSafe(String name, String value) {
if ("action".equals(name)) { if ("action".equals(name)) {
assertNotJavascriptUrl(value); assertNotJavascriptUrl(value);
@@ -128,6 +131,7 @@ class AttMap {
} }
private static class SrcTag implements Tag { private static class SrcTag implements Tag {
@Override
public void assertSafe(String name, String value) { public void assertSafe(String name, String value) {
if ("src".equals(name)) { if ("src".equals(name)) {
assertNotJavascriptUrl(value); assertNotJavascriptUrl(value);

View File

@@ -29,5 +29,6 @@ interface Buffer {
void append(String v); void append(String v);
@Override
String toString(); String toString();
} }

View File

@@ -21,30 +21,37 @@ final class BufferDirect implements Buffer {
return strbuf.length() == 0; return strbuf.length() == 0;
} }
@Override
public void append(final boolean v) { public void append(final boolean v) {
strbuf.append(v); strbuf.append(v);
} }
@Override
public void append(final char v) { public void append(final char v) {
strbuf.append(v); strbuf.append(v);
} }
@Override
public void append(final int v) { public void append(final int v) {
strbuf.append(v); strbuf.append(v);
} }
@Override
public void append(final long v) { public void append(final long v) {
strbuf.append(v); strbuf.append(v);
} }
@Override
public void append(final float v) { public void append(final float v) {
strbuf.append(v); strbuf.append(v);
} }
@Override
public void append(final double v) { public void append(final double v) {
strbuf.append(v); strbuf.append(v);
} }
@Override
public void append(final String v) { public void append(final String v) {
strbuf.append(v); strbuf.append(v);
} }

View File

@@ -21,30 +21,37 @@ final class BufferSealElement implements Buffer {
shb = safeHtmlBuilder; shb = safeHtmlBuilder;
} }
@Override
public void append(final boolean v) { public void append(final boolean v) {
shb.sealElement().append(v); shb.sealElement().append(v);
} }
@Override
public void append(final char v) { public void append(final char v) {
shb.sealElement().append(v); shb.sealElement().append(v);
} }
@Override
public void append(final double v) { public void append(final double v) {
shb.sealElement().append(v); shb.sealElement().append(v);
} }
@Override
public void append(final float v) { public void append(final float v) {
shb.sealElement().append(v); shb.sealElement().append(v);
} }
@Override
public void append(final int v) { public void append(final int v) {
shb.sealElement().append(v); shb.sealElement().append(v);
} }
@Override
public void append(final long v) { public void append(final long v) {
shb.sealElement().append(v); shb.sealElement().append(v);
} }
@Override
public void append(final String v) { public void append(final String v) {
shb.sealElement().append(v); shb.sealElement().append(v);
} }

View File

@@ -41,6 +41,7 @@ public abstract class HighlightSuggestOracle extends SuggestOracle {
@Override @Override
public final void requestSuggestions(final Request request, final Callback cb) { public final void requestSuggestions(final Request request, final Callback cb) {
onRequestSuggestions(request, new Callback() { onRequestSuggestions(request, new Callback() {
@Override
public void onSuggestionsReady(final Request request, public void onSuggestionsReady(final Request request,
final Response response) { final Response response) {
final String qpat = getQueryPattern(request.getQuery()); final String qpat = getQueryPattern(request.getQuery());
@@ -99,10 +100,12 @@ public abstract class HighlightSuggestOracle extends SuggestOracle {
private static native String sgi(String inString, String pat, String newHtml) private static native String sgi(String inString, String pat, String newHtml)
/*-{ return inString.replace(RegExp(pat, 'gi'), newHtml); }-*/; /*-{ return inString.replace(RegExp(pat, 'gi'), newHtml); }-*/;
@Override
public String getDisplayString() { public String getDisplayString() {
return displayString; return displayString;
} }
@Override
public String getReplacementString() { public String getReplacementString() {
return suggestion.getReplacementString(); return suggestion.getReplacementString();
} }

View File

@@ -44,26 +44,32 @@ public abstract class SafeHtml
@Override @Override
public SafeHtmlCss css() { public SafeHtmlCss css() {
return new SafeHtmlCss() { return new SafeHtmlCss() {
@Override
public String wikiList() { public String wikiList() {
return "wikiList"; return "wikiList";
} }
@Override
public String wikiPreFormat() { public String wikiPreFormat() {
return "wikiPreFormat"; return "wikiPreFormat";
} }
@Override
public String wikiQuote() { public String wikiQuote() {
return "wikiQuote"; return "wikiQuote";
} }
@Override
public boolean ensureInjected() { public boolean ensureInjected() {
return false; return false;
} }
@Override
public String getName() { public String getName() {
return null; return null;
} }
@Override
public String getText() { public String getText() {
return null; return null;
} }
@@ -335,5 +341,6 @@ public abstract class SafeHtml
} }
/** @return a clean HTML string safe for inclusion in any context. */ /** @return a clean HTML string safe for inclusion in any context. */
@Override
public abstract String asString(); public abstract String asString();
} }

View File

@@ -49,12 +49,15 @@ import javax.servlet.http.HttpServletResponse;
* </pre> * </pre>
*/ */
public class CacheControlFilter implements Filter { public class CacheControlFilter implements Filter {
@Override
public void init(final FilterConfig config) { public void init(final FilterConfig config) {
} }
@Override
public void destroy() { public void destroy() {
} }
@Override
public void doFilter(final ServletRequest sreq, final ServletResponse srsp, public void doFilter(final ServletRequest sreq, final ServletResponse srsp,
final FilterChain chain) throws IOException, ServletException { final FilterChain chain) throws IOException, ServletException {
final HttpServletRequest req = (HttpServletRequest) sreq; final HttpServletRequest req = (HttpServletRequest) sreq;

View File

@@ -240,7 +240,7 @@ public class Dispatcher {
if (defaultScreenToken != null && !MINE.equals(defaultScreenToken)) { if (defaultScreenToken != null && !MINE.equals(defaultScreenToken)) {
select(defaultScreenToken); select(defaultScreenToken);
} else { } else {
Gerrit.display(token, mine(token)); Gerrit.display(token, mine());
} }
} else if (matchPrefix("/dashboard/", token)) { } else if (matchPrefix("/dashboard/", token)) {
@@ -433,7 +433,7 @@ public class Dispatcher {
Gerrit.display(token, screen); Gerrit.display(token, screen);
} }
private static Screen mine(final String token) { private static Screen mine() {
if (Gerrit.isSignedIn()) { if (Gerrit.isSignedIn()) {
return new AccountDashboardScreen(Gerrit.getUserAccount().getId()); return new AccountDashboardScreen(Gerrit.getUserAccount().getId());
@@ -644,6 +644,7 @@ public class Dispatcher {
private static void publish(final PatchSet.Id ps) { private static void publish(final PatchSet.Id ps) {
String token = toPublish(ps); String token = toPublish(ps);
new AsyncSplit(token) { new AsyncSplit(token) {
@Override
public void onSuccess() { public void onSuccess() {
Gerrit.display(token, select()); Gerrit.display(token, select());
} }
@@ -670,6 +671,7 @@ public class Dispatcher {
Gerrit.getPatchScreenTopView() : topView; Gerrit.getPatchScreenTopView() : topView;
GWT.runAsync(new AsyncSplit(token) { GWT.runAsync(new AsyncSplit(token) {
@Override
public void onSuccess() { public void onSuccess() {
Gerrit.display(token, select()); Gerrit.display(token, select());
} }
@@ -743,6 +745,7 @@ public class Dispatcher {
private static void settings(String token) { private static void settings(String token) {
GWT.runAsync(new AsyncSplit(token) { GWT.runAsync(new AsyncSplit(token) {
@Override
public void onSuccess() { public void onSuccess() {
Gerrit.display(token, select()); Gerrit.display(token, select());
} }
@@ -810,6 +813,7 @@ public class Dispatcher {
private static void admin(String token) { private static void admin(String token) {
GWT.runAsync(new AsyncSplit(token) { GWT.runAsync(new AsyncSplit(token) {
@Override
public void onSuccess() { public void onSuccess() {
if (matchExact(ADMIN_GROUPS, token) if (matchExact(ADMIN_GROUPS, token)
|| matchExact("/admin/groups", token)) { || matchExact("/admin/groups", token)) {
@@ -983,6 +987,7 @@ public class Dispatcher {
this.token = token; this.token = token;
} }
@Override
public final void onFailure(Throwable reason) { public final void onFailure(Throwable reason) {
if (!isReloadUi if (!isReloadUi
&& "HTTP download failed with status 404".equals(reason.getMessage())) { && "HTTP download failed with status 404".equals(reason.getMessage())) {
@@ -999,6 +1004,7 @@ public class Dispatcher {
private static void docSearch(final String token) { private static void docSearch(final String token) {
GWT.runAsync(new AsyncSplit(token) { GWT.runAsync(new AsyncSplit(token) {
@Override
public void onSuccess() { public void onSuccess() {
Gerrit.display(token, new DocScreen(skip(token))); Gerrit.display(token, new DocScreen(skip(token)));
} }

View File

@@ -657,6 +657,7 @@ public class Gerrit implements EntryPoint {
final LinkMenuItem dashboardsMenuItem = final LinkMenuItem dashboardsMenuItem =
new ProjectLinkMenuItem(C.menuProjectsDashboards(), new ProjectLinkMenuItem(C.menuProjectsDashboards(),
ProjectScreen.DASHBOARDS) { ProjectScreen.DASHBOARDS) {
@Override
protected boolean match(String token) { protected boolean match(String token) {
return super.match(token) || return super.match(token) ||
(!getTargetHistoryToken().isEmpty() && ("/admin" + token).startsWith(getTargetHistoryToken())); (!getTargetHistoryToken().isEmpty() && ("/admin" + token).startsWith(getTargetHistoryToken()));
@@ -718,6 +719,7 @@ public class Gerrit implements EntryPoint {
case OPENID: case OPENID:
menuRight.addItem(C.menuRegister(), new Command() { menuRight.addItem(C.menuRegister(), new Command() {
@Override
public void execute() { public void execute() {
String t = History.getToken(); String t = History.getToken();
if (t == null) { if (t == null) {
@@ -727,6 +729,7 @@ public class Gerrit implements EntryPoint {
} }
}); });
menuRight.addItem(C.menuSignIn(), new Command() { menuRight.addItem(C.menuSignIn(), new Command() {
@Override
public void execute() { public void execute() {
doSignIn(History.getToken()); doSignIn(History.getToken());
} }
@@ -735,6 +738,7 @@ public class Gerrit implements EntryPoint {
case OPENID_SSO: case OPENID_SSO:
menuRight.addItem(C.menuSignIn(), new Command() { menuRight.addItem(C.menuSignIn(), new Command() {
@Override
public void execute() { public void execute() {
doSignIn(History.getToken()); doSignIn(History.getToken());
} }
@@ -757,6 +761,7 @@ public class Gerrit implements EntryPoint {
menuRight.add(anchor(registerText, cfg.getRegisterUrl())); menuRight.add(anchor(registerText, cfg.getRegisterUrl()));
} }
menuRight.addItem(C.menuSignIn(), new Command() { menuRight.addItem(C.menuSignIn(), new Command() {
@Override
public void execute() { public void execute() {
doSignIn(History.getToken()); doSignIn(History.getToken());
} }
@@ -769,6 +774,7 @@ public class Gerrit implements EntryPoint {
} }
} }
ConfigServerApi.topMenus(new GerritCallback<TopMenuList>() { ConfigServerApi.topMenus(new GerritCallback<TopMenuList>() {
@Override
public void onSuccess(TopMenuList result) { public void onSuccess(TopMenuList result) {
List<TopMenu> topMenuExtensions = Natives.asList(result); List<TopMenu> topMenuExtensions = Natives.asList(result);
for (TopMenu menu : topMenuExtensions) { for (TopMenu menu : topMenuExtensions) {

View File

@@ -194,6 +194,7 @@ class ContactPanelShort extends Composite {
haveEmails = false; haveEmails = false;
Util.ACCOUNT_SVC.myAccount(new GerritCallback<Account>() { Util.ACCOUNT_SVC.myAccount(new GerritCallback<Account>() {
@Override
public void onSuccess(final Account result) { public void onSuccess(final Account result) {
if (!isAttached()) { if (!isAttached()) {
return; return;
@@ -359,6 +360,7 @@ class ContactPanelShort extends Composite {
Util.ACCOUNT_SEC.updateContact(newName, newEmail, info, Util.ACCOUNT_SEC.updateContact(newName, newEmail, info,
new GerritCallback<Account>() { new GerritCallback<Account>() {
@Override
public void onSuccess(final Account result) { public void onSuccess(final Account result) {
registerNewEmail.setEnabled(true); registerNewEmail.setEnabled(true);
onSaveSuccess(result); onSaveSuccess(result);

View File

@@ -40,6 +40,7 @@ public class MyAgreementsScreen extends SettingsScreen {
protected void onLoad() { protected void onLoad() {
super.onLoad(); super.onLoad();
Util.ACCOUNT_SVC.myAgreements(new ScreenLoadCallback<AgreementInfo>(this) { Util.ACCOUNT_SVC.myAgreements(new ScreenLoadCallback<AgreementInfo>(this) {
@Override
public void preDisplay(final AgreementInfo result) { public void preDisplay(final AgreementInfo result) {
agreements.display(result); agreements.display(result);
} }

View File

@@ -76,6 +76,7 @@ public class MyIdentitiesScreen extends SettingsScreen {
super.onLoad(); super.onLoad();
Util.ACCOUNT_SEC Util.ACCOUNT_SEC
.myExternalIds(new ScreenLoadCallback<List<AccountExternalId>>(this) { .myExternalIds(new ScreenLoadCallback<List<AccountExternalId>>(this) {
@Override
public void preDisplay(final List<AccountExternalId> result) { public void preDisplay(final List<AccountExternalId> result) {
identites.display(result); identites.display(result);
} }
@@ -126,6 +127,7 @@ public class MyIdentitiesScreen extends SettingsScreen {
deleteIdentity.setEnabled(false); deleteIdentity.setEnabled(false);
Util.ACCOUNT_SEC.deleteExternalIds(keys, Util.ACCOUNT_SEC.deleteExternalIds(keys,
new GerritCallback<Set<AccountExternalId.Key>>() { new GerritCallback<Set<AccountExternalId.Key>>() {
@Override
public void onSuccess(final Set<AccountExternalId.Key> removed) { public void onSuccess(final Set<AccountExternalId.Key> removed) {
for (int row = 1; row < table.getRowCount();) { for (int row = 1; row < table.getRowCount();) {
final AccountExternalId k = getRowItem(row); final AccountExternalId k = getRowItem(row);

View File

@@ -213,6 +213,7 @@ public class MyWatchedProjectsScreen extends SettingsScreen {
Util.ACCOUNT_SVC.addProjectWatch(projectName, filter, Util.ACCOUNT_SVC.addProjectWatch(projectName, filter,
new GerritCallback<AccountProjectWatchInfo>() { new GerritCallback<AccountProjectWatchInfo>() {
@Override
public void onSuccess(final AccountProjectWatchInfo result) { public void onSuccess(final AccountProjectWatchInfo result) {
addNew.setEnabled(true); addNew.setEnabled(true);
nameBox.setEnabled(true); nameBox.setEnabled(true);

View File

@@ -67,6 +67,7 @@ public class MyWatchesTable extends FancyFlexTable<AccountProjectWatchInfo> {
if (!ids.isEmpty()) { if (!ids.isEmpty()) {
Util.ACCOUNT_SVC.deleteProjectWatches(ids, Util.ACCOUNT_SVC.deleteProjectWatches(ids,
new GerritCallback<VoidResult>() { new GerritCallback<VoidResult>() {
@Override
public void onSuccess(final VoidResult result) { public void onSuccess(final VoidResult result) {
remove(ids); remove(ids);
} }
@@ -165,6 +166,7 @@ public class MyWatchesTable extends FancyFlexTable<AccountProjectWatchInfo> {
cbox.setEnabled(false); cbox.setEnabled(false);
Util.ACCOUNT_SVC.updateProjectWatch(info.getWatch(), Util.ACCOUNT_SVC.updateProjectWatch(info.getWatch(),
new GerritCallback<VoidResult>() { new GerritCallback<VoidResult>() {
@Override
public void onSuccess(final VoidResult result) { public void onSuccess(final VoidResult result) {
cbox.setEnabled(true); cbox.setEnabled(true);
} }

View File

@@ -79,6 +79,7 @@ public class NewAgreementScreen extends AccountScreen {
protected void onLoad() { protected void onLoad() {
super.onLoad(); super.onLoad();
Util.ACCOUNT_SVC.myAgreements(new GerritCallback<AgreementInfo>() { Util.ACCOUNT_SVC.myAgreements(new GerritCallback<AgreementInfo>() {
@Override
public void onSuccess(AgreementInfo result) { public void onSuccess(AgreementInfo result) {
if (isAttached()) { if (isAttached()) {
mySigned = new HashSet<>(result.accepted); mySigned = new HashSet<>(result.accepted);
@@ -88,6 +89,7 @@ public class NewAgreementScreen extends AccountScreen {
}); });
Gerrit.SYSTEM_SVC Gerrit.SYSTEM_SVC
.contributorAgreements(new GerritCallback<List<ContributorAgreement>>() { .contributorAgreements(new GerritCallback<List<ContributorAgreement>>() {
@Override
public void onSuccess(final List<ContributorAgreement> result) { public void onSuccess(final List<ContributorAgreement> result) {
if (isAttached()) { if (isAttached()) {
available = result; available = result;
@@ -224,6 +226,7 @@ public class NewAgreementScreen extends AccountScreen {
private void doEnterAgreement() { private void doEnterAgreement() {
Util.ACCOUNT_SEC.enterAgreement(current.getName(), Util.ACCOUNT_SEC.enterAgreement(current.getName(),
new GerritCallback<VoidResult>() { new GerritCallback<VoidResult>() {
@Override
public void onSuccess(final VoidResult result) { public void onSuccess(final VoidResult result) {
Gerrit.display(nextToken); Gerrit.display(nextToken);
} }
@@ -247,10 +250,12 @@ public class NewAgreementScreen extends AccountScreen {
} }
final RequestBuilder rb = new RequestBuilder(RequestBuilder.GET, url); final RequestBuilder rb = new RequestBuilder(RequestBuilder.GET, url);
rb.setCallback(new RequestCallback() { rb.setCallback(new RequestCallback() {
@Override
public void onError(Request request, Throwable exception) { public void onError(Request request, Throwable exception) {
new ErrorDialog(exception).center(); new ErrorDialog(exception).center();
} }
@Override
public void onResponseReceived(Request request, Response response) { public void onResponseReceived(Request request, Response response) {
final String ct = response.getHeader("Content-Type"); final String ct = response.getHeader("Content-Type");
if (response.getStatusCode() == 200 && ct != null if (response.getStatusCode() == 200 && ct != null

View File

@@ -159,6 +159,7 @@ class SshPanel extends Composite {
if (txt != null && txt.length() > 0) { if (txt != null && txt.length() > 0) {
addNew.setEnabled(false); addNew.setEnabled(false);
AccountApi.addSshKey("self", txt, new GerritCallback<SshKeyInfo>() { AccountApi.addSshKey("self", txt, new GerritCallback<SshKeyInfo>() {
@Override
public void onSuccess(final SshKeyInfo k) { public void onSuccess(final SshKeyInfo k) {
addNew.setEnabled(true); addNew.setEnabled(true);
addTxt.setText(""); addTxt.setText("");
@@ -198,6 +199,7 @@ class SshPanel extends Composite {
super.onLoad(); super.onLoad();
refreshSshKeys(); refreshSshKeys();
Gerrit.SYSTEM_SVC.daemonHostKeys(new GerritCallback<List<SshHostKey>>() { Gerrit.SYSTEM_SVC.daemonHostKeys(new GerritCallback<List<SshHostKey>>() {
@Override
public void onSuccess(final List<SshHostKey> result) { public void onSuccess(final List<SshHostKey> result) {
serverKeys.clear(); serverKeys.clear();
for (final SshHostKey keyInfo : result) { for (final SshHostKey keyInfo : result) {
@@ -272,6 +274,7 @@ class SshPanel extends Composite {
deleteKey.setEnabled(false); deleteKey.setEnabled(false);
AccountApi.deleteSshKeys("self", sequenceNumbers, AccountApi.deleteSshKeys("self", sequenceNumbers,
new GerritCallback<VoidResult>() { new GerritCallback<VoidResult>() {
@Override
public void onSuccess(VoidResult result) { public void onSuccess(VoidResult result) {
for (int row = 1; row < table.getRowCount();) { for (int row = 1; row < table.getRowCount();) {
final SshKeyInfo k = getRowItem(row); final SshKeyInfo k = getRowItem(row);

View File

@@ -116,6 +116,7 @@ class UsernameField extends Composite {
Util.ACCOUNT_SEC.changeUserName(newUserName, Util.ACCOUNT_SEC.changeUserName(newUserName,
new GerritCallback<VoidResult>() { new GerritCallback<VoidResult>() {
@Override
public void onSuccess(final VoidResult result) { public void onSuccess(final VoidResult result) {
Gerrit.getUserAccount().setUserName(newUserName); Gerrit.getUserAccount().setUserName(newUserName);
userNameLbl.setText(newUserName); userNameLbl.setText(newUserName);

View File

@@ -96,6 +96,7 @@ public class AccountGroupInfoScreen extends AccountGroupScreen {
final String newName = groupNameTxt.getText().trim(); final String newName = groupNameTxt.getText().trim();
GroupApi.renameGroup(getGroupUUID(), newName, GroupApi.renameGroup(getGroupUUID(), newName,
new GerritCallback<com.google.gerrit.client.VoidResult>() { new GerritCallback<com.google.gerrit.client.VoidResult>() {
@Override
public void onSuccess(final com.google.gerrit.client.VoidResult result) { public void onSuccess(final com.google.gerrit.client.VoidResult result) {
saveName.setEnabled(false); saveName.setEnabled(false);
setPageTitle(Util.M.group(newName)); setPageTitle(Util.M.group(newName));
@@ -135,6 +136,7 @@ public class AccountGroupInfoScreen extends AccountGroupScreen {
String ownerId = ownerUuid != null ? ownerUuid.get() : newOwner; String ownerId = ownerUuid != null ? ownerUuid.get() : newOwner;
GroupApi.setGroupOwner(getGroupUUID(), ownerId, GroupApi.setGroupOwner(getGroupUUID(), ownerId,
new GerritCallback<GroupInfo>() { new GerritCallback<GroupInfo>() {
@Override
public void onSuccess(final GroupInfo result) { public void onSuccess(final GroupInfo result) {
updateOwnerGroup(result); updateOwnerGroup(result);
saveOwner.setEnabled(false); saveOwner.setEnabled(false);
@@ -165,6 +167,7 @@ public class AccountGroupInfoScreen extends AccountGroupScreen {
final String txt = descTxt.getText().trim(); final String txt = descTxt.getText().trim();
GroupApi.setGroupDescription(getGroupUUID(), txt, GroupApi.setGroupDescription(getGroupUUID(), txt,
new GerritCallback<VoidResult>() { new GerritCallback<VoidResult>() {
@Override
public void onSuccess(final VoidResult result) { public void onSuccess(final VoidResult result) {
saveDesc.setEnabled(false); saveDesc.setEnabled(false);
} }
@@ -193,6 +196,7 @@ public class AccountGroupInfoScreen extends AccountGroupScreen {
public void onClick(final ClickEvent event) { public void onClick(final ClickEvent event) {
GroupApi.setGroupOptions(getGroupUUID(), GroupApi.setGroupOptions(getGroupUUID(),
visibleToAllCheckBox.getValue(), new GerritCallback<VoidResult>() { visibleToAllCheckBox.getValue(), new GerritCallback<VoidResult>() {
@Override
public void onSuccess(final VoidResult result) { public void onSuccess(final VoidResult result) {
saveGroupOptions.setEnabled(false); saveGroupOptions.setEnabled(false);
} }

View File

@@ -172,6 +172,7 @@ public class AccountGroupMembersScreen extends AccountGroupScreen {
addMemberBox.setEnabled(false); addMemberBox.setEnabled(false);
GroupApi.addMember(getGroupUUID(), nameEmail, GroupApi.addMember(getGroupUUID(), nameEmail,
new GerritCallback<AccountInfo>() { new GerritCallback<AccountInfo>() {
@Override
public void onSuccess(final AccountInfo memberInfo) { public void onSuccess(final AccountInfo memberInfo) {
addMemberBox.setEnabled(true); addMemberBox.setEnabled(true);
addMemberBox.setText(""); addMemberBox.setText("");
@@ -200,6 +201,7 @@ public class AccountGroupMembersScreen extends AccountGroupScreen {
addIncludeBox.setEnabled(false); addIncludeBox.setEnabled(false);
GroupApi.addIncludedGroup(getGroupUUID(), uuid.get(), GroupApi.addIncludedGroup(getGroupUUID(), uuid.get(),
new GerritCallback<GroupInfo>() { new GerritCallback<GroupInfo>() {
@Override
public void onSuccess(final GroupInfo result) { public void onSuccess(final GroupInfo result) {
addIncludeBox.setEnabled(true); addIncludeBox.setEnabled(true);
addIncludeBox.setText(""); addIncludeBox.setText("");
@@ -248,6 +250,7 @@ public class AccountGroupMembersScreen extends AccountGroupScreen {
if (!ids.isEmpty()) { if (!ids.isEmpty()) {
GroupApi.removeMembers(getGroupUUID(), ids, GroupApi.removeMembers(getGroupUUID(), ids,
new GerritCallback<VoidResult>() { new GerritCallback<VoidResult>() {
@Override
public void onSuccess(final VoidResult result) { public void onSuccess(final VoidResult result) {
for (int row = 1; row < table.getRowCount();) { for (int row = 1; row < table.getRowCount();) {
final AccountInfo i = getRowItem(row); final AccountInfo i = getRowItem(row);
@@ -353,6 +356,7 @@ public class AccountGroupMembersScreen extends AccountGroupScreen {
if (!ids.isEmpty()) { if (!ids.isEmpty()) {
GroupApi.removeIncludedGroups(getGroupUUID(), ids, GroupApi.removeIncludedGroups(getGroupUUID(), ids,
new GerritCallback<VoidResult>() { new GerritCallback<VoidResult>() {
@Override
public void onSuccess(final VoidResult result) { public void onSuccess(final VoidResult result) {
for (int row = 1; row < table.getRowCount();) { for (int row = 1; row < table.getRowCount();) {
final GroupInfo i = getRowItem(row); final GroupInfo i = getRowItem(row);

View File

@@ -128,6 +128,7 @@ public class CreateGroupScreen extends Screen {
addNew.setEnabled(false); addNew.setEnabled(false);
GroupApi.createGroup(newName, new GerritCallback<GroupInfo>() { GroupApi.createGroup(newName, new GerritCallback<GroupInfo>() {
@Override
public void onSuccess(final GroupInfo result) { public void onSuccess(final GroupInfo result) {
History.newItem(Dispatcher.toGroup(result.getGroupId(), History.newItem(Dispatcher.toGroup(result.getGroupId(),
AccountGroupScreen.MEMBERS)); AccountGroupScreen.MEMBERS));

View File

@@ -133,6 +133,7 @@ public class GroupReferenceBox extends Composite implements
suggestBox.setTabIndex(index); suggestBox.setTabIndex(index);
} }
@Override
public void setFocus(boolean focused) { public void setFocus(boolean focused) {
suggestBox.setFocus(focused); suggestBox.setFocus(focused);
} }

View File

@@ -316,6 +316,7 @@ public class ProjectBranchesScreen extends ProjectScreen {
private void deleteBranches(final Set<String> branches) { private void deleteBranches(final Set<String> branches) {
ProjectApi.deleteBranches(getProjectKey(), branches, ProjectApi.deleteBranches(getProjectKey(), branches,
new GerritCallback<VoidResult>() { new GerritCallback<VoidResult>() {
@Override
public void onSuccess(VoidResult result) { public void onSuccess(VoidResult result) {
for (int row = 1; row < table.getRowCount();) { for (int row = 1; row < table.getRowCount();) {
BranchInfo k = getRowItem(row); BranchInfo k = getRowItem(row);

View File

@@ -27,16 +27,19 @@ import java.text.ParseException;
public class RefPatternBox extends ValueBox<String> { public class RefPatternBox extends ValueBox<String> {
private static final Renderer<String> RENDERER = new Renderer<String>() { private static final Renderer<String> RENDERER = new Renderer<String>() {
@Override
public String render(String ref) { public String render(String ref) {
return ref; return ref;
} }
@Override
public void render(String ref, Appendable dst) throws IOException { public void render(String ref, Appendable dst) throws IOException {
dst.append(render(ref)); dst.append(render(ref));
} }
}; };
private static final Parser<String> PARSER = new Parser<String>() { private static final Parser<String> PARSER = new Parser<String>() {
@Override
public String parse(CharSequence text) throws ParseException { public String parse(CharSequence text) throws ParseException {
String ref = text.toString(); String ref = text.toString();

View File

@@ -86,6 +86,7 @@ public class ValueEditor<T> extends Composite implements HasEditorErrors<T>,
editPanel.setVisible(true); editPanel.setVisible(true);
} }
@Override
public ValueBoxEditor<T> asEditor() { public ValueBoxEditor<T> asEditor() {
if (editProxy == null) { if (editProxy == null) {
editProxy = new EditorProxy(); editProxy = new EditorProxy();
@@ -133,6 +134,7 @@ public class ValueEditor<T> extends Composite implements HasEditorErrors<T>,
startHandlers.enabled = enabled; startHandlers.enabled = enabled;
} }
@Override
public void showErrors(List<EditorError> errors) { public void showErrors(List<EditorError> errors) {
StringBuilder buf = new StringBuilder(); StringBuilder buf = new StringBuilder();
for (EditorError error : errors) { for (EditorError error : errors) {

View File

@@ -81,6 +81,7 @@ class PluginName {
/** Extracts URL from the stack frame. */ /** Extracts URL from the stack frame. */
static class PluginNameMoz extends PluginName { static class PluginNameMoz extends PluginName {
@Override
String findCallerUrl() { String findCallerUrl() {
return getUrl(makeException()); return getUrl(makeException());
} }

View File

@@ -30,6 +30,7 @@ class AbandonAction extends ActionMessageBox {
this.id = id; this.id = id;
} }
@Override
void send(String message) { void send(String message) {
ChangeApi.abandon(id.get(), message, new GerritCallback<ChangeInfo>() { ChangeApi.abandon(id.get(), message, new GerritCallback<ChangeInfo>() {
@Override @Override

View File

@@ -256,7 +256,7 @@ class Actions extends Composite {
@UiHandler("revert") @UiHandler("revert")
void onRevert(ClickEvent e) { void onRevert(ClickEvent e) {
RevertAction.call(revert, changeId, revision, project, subject); RevertAction.call(revert, changeId, revision, subject);
} }
private static void a2b(NativeMap<ActionInfo> actions, String a, Button b) { private static void a2b(NativeMap<ActionInfo> actions, String a, Button b) {

View File

@@ -1077,6 +1077,7 @@ public class ChangeScreen2 extends Screen {
Gerrit.display(PageLinks.toChange(changeId)); Gerrit.display(PageLinks.toChange(changeId));
} }
@Override
void onIgnore(Timestamp newTime) { void onIgnore(Timestamp newTime) {
lastDisplayedUpdate = newTime; lastDisplayedUpdate = newTime;
} }

View File

@@ -34,6 +34,7 @@ class DownloadAction extends RightSidePopdownAction {
info.revision(revision)._number())); info.revision(revision)._number()));
} }
@Override
Widget getWidget() { Widget getWidget() {
return downloadBox; return downloadBox;
} }

View File

@@ -40,10 +40,12 @@ public class DraftActions {
public static GerritCallback<JavaScriptObject> cs( public static GerritCallback<JavaScriptObject> cs(
final Change.Id id) { final Change.Id id) {
return new GerritCallback<JavaScriptObject>() { return new GerritCallback<JavaScriptObject>() {
@Override
public void onSuccess(JavaScriptObject result) { public void onSuccess(JavaScriptObject result) {
Gerrit.display(PageLinks.toChange(id)); Gerrit.display(PageLinks.toChange(id));
} }
@Override
public void onFailure(Throwable err) { public void onFailure(Throwable err) {
if (SubmitFailureDialog.isConflict(err)) { if (SubmitFailureDialog.isConflict(err)) {
new SubmitFailureDialog(err.getMessage()).center(); new SubmitFailureDialog(err.getMessage()).center();
@@ -57,10 +59,12 @@ public class DraftActions {
private static AsyncCallback<JavaScriptObject> mine() { private static AsyncCallback<JavaScriptObject> mine() {
return new GerritCallback<JavaScriptObject>() { return new GerritCallback<JavaScriptObject>() {
@Override
public void onSuccess(JavaScriptObject result) { public void onSuccess(JavaScriptObject result) {
Gerrit.display(PageLinks.MINE); Gerrit.display(PageLinks.MINE);
} }
@Override
public void onFailure(Throwable err) { public void onFailure(Throwable err) {
if (SubmitFailureDialog.isConflict(err)) { if (SubmitFailureDialog.isConflict(err)) {
new SubmitFailureDialog(err.getMessage()).center(); new SubmitFailureDialog(err.getMessage()).center();

View File

@@ -39,10 +39,12 @@ public class EditActions {
public static GerritCallback<JavaScriptObject> cs( public static GerritCallback<JavaScriptObject> cs(
final Change.Id id) { final Change.Id id) {
return new GerritCallback<JavaScriptObject>() { return new GerritCallback<JavaScriptObject>() {
@Override
public void onSuccess(JavaScriptObject result) { public void onSuccess(JavaScriptObject result) {
Gerrit.display(PageLinks.toChange(id)); Gerrit.display(PageLinks.toChange(id));
} }
@Override
public void onFailure(Throwable err) { public void onFailure(Throwable err) {
if (SubmitFailureDialog.isConflict(err)) { if (SubmitFailureDialog.isConflict(err)) {
new SubmitFailureDialog(err.getMessage()).center(); new SubmitFailureDialog(err.getMessage()).center();

View File

@@ -58,6 +58,7 @@ class EditMessageBox extends Composite {
message.getElement().setAttribute("wrap", "off"); message.getElement().setAttribute("wrap", "off");
message.setText(""); message.setText("");
new TextBoxChangeListener(message) { new TextBoxChangeListener(message) {
@Override
public void onTextChanged(String newText) { public void onTextChanged(String newText) {
save.setEnabled(!newText.trim() save.setEnabled(!newText.trim()
.equals(originalMessage)); .equals(originalMessage));

View File

@@ -93,6 +93,7 @@ public class FileTable extends FlowPanel {
public static enum Mode { public static enum Mode {
REVIEW, REVIEW,
@SuppressWarnings("hiding")
EDIT EDIT
} }
@@ -460,7 +461,7 @@ public class FileTable extends FlowPanel {
private final class DisplayCommand implements RepeatingCommand { private final class DisplayCommand implements RepeatingCommand {
private final SafeHtmlBuilder sb = new SafeHtmlBuilder(); private final SafeHtmlBuilder sb = new SafeHtmlBuilder();
private final MyTable table; private final MyTable myTable;
private final JsArray<FileInfo> list; private final JsArray<FileInfo> list;
private final Timestamp myLastReply; private final Timestamp myLastReply;
private final NativeMap<JsArray<CommentInfo>> comments; private final NativeMap<JsArray<CommentInfo>> comments;
@@ -482,16 +483,17 @@ public class FileTable extends FlowPanel {
NativeMap<JsArray<CommentInfo>> comments, NativeMap<JsArray<CommentInfo>> comments,
NativeMap<JsArray<CommentInfo>> drafts, NativeMap<JsArray<CommentInfo>> drafts,
Mode mode) { Mode mode) {
this.table = new MyTable(map, list); this.myTable = new MyTable(map, list);
this.list = list; this.list = list;
this.myLastReply = myLastReply; this.myLastReply = myLastReply;
this.comments = comments; this.comments = comments;
this.drafts = drafts; this.drafts = drafts;
this.hasUser = Gerrit.isSignedIn(); this.hasUser = Gerrit.isSignedIn();
this.mode = mode; this.mode = mode;
table.addStyleName(R.css().table()); myTable.addStyleName(R.css().table());
} }
@Override
public boolean execute() { public boolean execute() {
boolean attachedNow = isAttached(); boolean attachedNow = isAttached();
if (!attached && attachedNow) { if (!attached && attachedNow) {
@@ -519,9 +521,9 @@ public class FileTable extends FlowPanel {
} }
} }
footer(sb); footer(sb);
table.resetHtml(sb); myTable.resetHtml(sb);
table.finishDisplay(); myTable.finishDisplay();
setTable(table); setTable(myTable);
return false; return false;
} }

View File

@@ -33,6 +33,7 @@ class FollowUpAction extends ActionMessageBox {
this.base = project + "~" + branch + "~" + key; this.base = project + "~" + branch + "~" + key;
} }
@Override
void send(String message) { void send(String message) {
ChangeApi.createChange(project, branch, message, base, ChangeApi.createChange(project, branch, message, base,
new GerritCallback<ChangeInfo>() { new GerritCallback<ChangeInfo>() {

View File

@@ -200,6 +200,7 @@ public class Hashtags extends Composite {
ChangeApi.hashtags(changeId.get()).post( ChangeApi.hashtags(changeId.get()).post(
PostInput.create(hashtags, null), PostInput.create(hashtags, null),
new GerritCallback<JsArrayString>() { new GerritCallback<JsArrayString>() {
@Override
public void onSuccess(JsArrayString result) { public void onSuccess(JsArrayString result) {
hashtagTextBox.setEnabled(true); hashtagTextBox.setEnabled(true);
UIObject.setVisible(error, false); UIObject.setVisible(error, false);

View File

@@ -30,6 +30,7 @@ class IncludedInAction extends RightSidePopdownAction {
this.includedInBox = new IncludedInBox(changeId); this.includedInBox = new IncludedInBox(changeId);
} }
@Override
Widget getWidget() { Widget getWidget() {
return includedInBox; return includedInBox;
} }

View File

@@ -31,6 +31,7 @@ class PatchSetsAction extends RightSidePopdownAction {
this.revisionBox = new PatchSetsBox(changeId, revision); this.revisionBox = new PatchSetsBox(changeId, revision);
} }
@Override
Widget getWidget() { Widget getWidget() {
return revisionBox; return revisionBox;
} }

View File

@@ -25,6 +25,7 @@ class RebaseAction {
static void call(final Change.Id id, String revision) { static void call(final Change.Id id, String revision) {
ChangeApi.rebase(id.get(), revision, ChangeApi.rebase(id.get(), revision,
new GerritCallback<ChangeInfo>() { new GerritCallback<ChangeInfo>() {
@Override
public void onSuccess(ChangeInfo result) { public void onSuccess(ChangeInfo result) {
Gerrit.display(PageLinks.toChange(id)); Gerrit.display(PageLinks.toChange(id));
} }

View File

@@ -200,6 +200,7 @@ class RelatedChangesTab implements IsWidget {
return false; return false;
} }
@Override
public boolean execute() { public boolean execute() {
if (navList != view || !panel.isAttached()) { if (navList != view || !panel.isAttached()) {
// If the user navigated away, we aren't in the DOM anymore. // If the user navigated away, we aren't in the DOM anymore.

View File

@@ -62,6 +62,7 @@ public class RestReviewerSuggestOracle extends SuggestAfterTypingNCharsOracle {
this.reviewer = reviewer; this.reviewer = reviewer;
} }
@Override
public String getDisplayString() { public String getDisplayString() {
if (reviewer.account() != null) { if (reviewer.account() != null) {
return FormatUtil.nameEmail(reviewer.account()); return FormatUtil.nameEmail(reviewer.account());
@@ -72,6 +73,7 @@ public class RestReviewerSuggestOracle extends SuggestAfterTypingNCharsOracle {
+ ")"; + ")";
} }
@Override
public String getReplacementString() { public String getReplacementString() {
if (reviewer.account() != null) { if (reviewer.account() != null) {
return FormatUtil.nameEmail(reviewer.account()); return FormatUtil.nameEmail(reviewer.account());

View File

@@ -30,6 +30,7 @@ class RestoreAction extends ActionMessageBox {
this.id = id; this.id = id;
} }
@Override
void send(String message) { void send(String message) {
ChangeApi.restore(id.get(), message, new GerritCallback<ChangeInfo>() { ChangeApi.restore(id.get(), message, new GerritCallback<ChangeInfo>() {
@Override @Override

View File

@@ -26,7 +26,7 @@ import com.google.gwt.user.client.ui.Button;
class RevertAction { class RevertAction {
static void call(Button b, final Change.Id id, final String revision, static void call(Button b, final Change.Id id, final String revision,
String project, final String commitSubject) { final String commitSubject) {
// TODO Replace ActionDialog with a nicer looking display. // TODO Replace ActionDialog with a nicer looking display.
b.setEnabled(false); b.setEnabled(false);
new ActionDialog(b, false, new ActionDialog(b, false,

View File

@@ -163,6 +163,7 @@ public class Reviewers extends Composite {
ChangeApi.reviewers(changeId.get()).post( ChangeApi.reviewers(changeId.get()).post(
PostInput.create(reviewer, confirmed), PostInput.create(reviewer, confirmed),
new GerritCallback<PostResult>() { new GerritCallback<PostResult>() {
@Override
public void onSuccess(PostResult result) { public void onSuccess(PostResult result) {
nameTxtBox.setEnabled(true); nameTxtBox.setEnabled(true);

View File

@@ -32,10 +32,12 @@ class SubmitAction {
ChangeApi.submit( ChangeApi.submit(
changeId.get(), revisionInfo.name(), changeId.get(), revisionInfo.name(),
new GerritCallback<SubmitInfo>() { new GerritCallback<SubmitInfo>() {
@Override
public void onSuccess(SubmitInfo result) { public void onSuccess(SubmitInfo result) {
redisplay(); redisplay();
} }
@Override
public void onFailure(Throwable err) { public void onFailure(Throwable err) {
if (SubmitFailureDialog.isConflict(err)) { if (SubmitFailureDialog.isConflict(err)) {
new SubmitFailureDialog(err.getMessage()).center(); new SubmitFailureDialog(err.getMessage()).center();

View File

@@ -254,6 +254,7 @@ public class ApprovalTable extends Composite {
ChangeApi.reviewers(lastChange.legacy_id().get()).post( ChangeApi.reviewers(lastChange.legacy_id().get()).post(
PostInput.create(reviewer, confirmed), PostInput.create(reviewer, confirmed),
new GerritCallback<PostResult>() { new GerritCallback<PostResult>() {
@Override
public void onSuccess(PostResult result) { public void onSuccess(PostResult result) {
addMemberBox.setEnabled(true); addMemberBox.setEnabled(true);
addMemberBox.setText(""); addMemberBox.setText("");

View File

@@ -313,6 +313,7 @@ public class ChangeScreen extends Screen
event.getValue().setSubmitTypeRecord(SubmitTypeRecord.OK( event.getValue().setSubmitTypeRecord(SubmitTypeRecord.OK(
SubmitType.valueOf(result.asString()))); SubmitType.valueOf(result.asString())));
} }
@Override
public void onFailure(Throwable caught) {} public void onFailure(Throwable caught) {}
})); }));
} }
@@ -388,7 +389,9 @@ public class ChangeScreen extends Screen
ListChangesOption.CURRENT_REVISION)); ListChangesOption.CURRENT_REVISION));
call.get(cbs2.add(new AsyncCallback< call.get(cbs2.add(new AsyncCallback<
com.google.gerrit.client.changes.ChangeInfo>() { com.google.gerrit.client.changes.ChangeInfo>() {
@Override
public void onFailure(Throwable caught) {} public void onFailure(Throwable caught) {}
@Override
public void onSuccess( public void onSuccess(
com.google.gerrit.client.changes.ChangeInfo result) { com.google.gerrit.client.changes.ChangeInfo result) {
i.set(ChangeDetailCache.toChange(result), i.set(ChangeDetailCache.toChange(result),
@@ -398,6 +401,7 @@ public class ChangeScreen extends Screen
.merge(ChangeDetailCache.users(result)); .merge(ChangeDetailCache.users(result));
}})); }}));
} }
@Override
public void onFailure(Throwable caught) {} public void onFailure(Throwable caught) {}
})); }));
ChangeApi.revision(changeId.get(), revId) ChangeApi.revision(changeId.get(), revId)
@@ -416,6 +420,7 @@ public class ChangeScreen extends Screen
p.setReviewedByCurrentUser(true); p.setReviewedByCurrentUser(true);
} }
} }
@Override
public void onFailure(Throwable caught) {} public void onFailure(Throwable caught) {}
})); }));
final Set<PatchSet.Id> withDrafts = new HashSet<>(); final Set<PatchSet.Id> withDrafts = new HashSet<>();
@@ -432,6 +437,7 @@ public class ChangeScreen extends Screen
withDrafts.add(id); withDrafts.add(id);
} }
} }
@Override
public void onFailure(Throwable caught) {} public void onFailure(Throwable caught) {}
})); }));
} }
@@ -453,6 +459,7 @@ public class ChangeScreen extends Screen
withDrafts.add(psId); withDrafts.add(psId);
} }
} }
@Override
public void onFailure(Throwable caught) {} public void onFailure(Throwable caught) {}
})); }));
} }
@@ -470,6 +477,7 @@ public class ChangeScreen extends Screen
p.setCommentCount(result.get(path).length()); p.setCommentCount(result.get(path).length());
} }
} }
@Override
public void onFailure(Throwable caught) {} public void onFailure(Throwable caught) {}
})); }));
DiffApi.list(changeId.get(), null, revId, DiffApi.list(changeId.get(), null, revId,
@@ -497,6 +505,7 @@ public class ChangeScreen extends Screen
} }
event.getValue().getCurrentPatchSetDetail().setPatches(list); event.getValue().getCurrentPatchSetDetail().setPatches(list);
} }
@Override
public void onFailure(Throwable caught) {} public void onFailure(Throwable caught) {}
}); });
ConfigInfoCache.get( ConfigInfoCache.get(
@@ -524,6 +533,7 @@ public class ChangeScreen extends Screen
public void onSuccess(Void result) { public void onSuccess(Void result) {
display(event.getValue()); display(event.getValue());
} }
@Override
public void onFailure(Throwable caught) {} public void onFailure(Throwable caught) {}
}).onSuccess(null); }).onSuccess(null);
} }

View File

@@ -87,6 +87,7 @@ public class CommitMessageBlock extends Composite {
sendButton.setEnabled(false); sendButton.setEnabled(false);
new TextBoxChangeListener(message) { new TextBoxChangeListener(message) {
@Override
public void onTextChanged(String newText) { public void onTextChanged(String newText) {
// Trim the new text so we don't consider trailing // Trim the new text so we don't consider trailing
// newlines as changes // newlines as changes
@@ -95,6 +96,7 @@ public class CommitMessageBlock extends Composite {
}; };
} }
@Override
public String getMessageText() { public String getMessageText() {
// As we rely on commit message lines ending in LF, we convert CRLF to // As we rely on commit message lines ending in LF, we convert CRLF to
// LF. Additionally, the commit message should be trimmed to remove any // LF. Additionally, the commit message should be trimmed to remove any

View File

@@ -96,6 +96,7 @@ public class DashboardTable extends ChangeTable2 {
return unlimitedQuery.toString().trim(); return unlimitedQuery.toString().trim();
} }
@Override
public String getTitle() { public String getTitle() {
return title; return title;
} }

View File

@@ -319,10 +319,12 @@ class PatchSetComplexDisclosurePanel extends ComplexDisclosurePanel
patchSet.getId().getParentKey().get(), patchSet.getId().getParentKey().get(),
patchSet.getRevision().get(), patchSet.getRevision().get(),
new GerritCallback<SubmitInfo>() { new GerritCallback<SubmitInfo>() {
@Override
public void onSuccess(SubmitInfo result) { public void onSuccess(SubmitInfo result) {
redisplay(); redisplay();
} }
@Override
public void onFailure(Throwable err) { public void onFailure(Throwable err) {
if (SubmitFailureDialog.isConflict(err)) { if (SubmitFailureDialog.isConflict(err)) {
new SubmitFailureDialog(err.getMessage()).center(); new SubmitFailureDialog(err.getMessage()).center();
@@ -480,10 +482,12 @@ class PatchSetComplexDisclosurePanel extends ComplexDisclosurePanel
b.setEnabled(false); b.setEnabled(false);
ChangeApi.deleteChange(patchSet.getId().getParentKey().get(), ChangeApi.deleteChange(patchSet.getId().getParentKey().get(),
new GerritCallback<JavaScriptObject>() { new GerritCallback<JavaScriptObject>() {
@Override
public void onSuccess(JavaScriptObject result) { public void onSuccess(JavaScriptObject result) {
Gerrit.display(PageLinks.MINE); Gerrit.display(PageLinks.MINE);
} }
@Override
public void onFailure(Throwable err) { public void onFailure(Throwable err) {
if (SubmitFailureDialog.isConflict(err)) { if (SubmitFailureDialog.isConflict(err)) {
new SubmitFailureDialog(err.getMessage()).center(); new SubmitFailureDialog(err.getMessage()).center();
@@ -545,6 +549,7 @@ class PatchSetComplexDisclosurePanel extends ComplexDisclosurePanel
final Change.Id id = patchSet.getId().getParentKey(); final Change.Id id = patchSet.getId().getParentKey();
ChangeApi.rebase(id.get(), patchSet.getRevision().get(), ChangeApi.rebase(id.get(), patchSet.getRevision().get(),
new GerritCallback<ChangeInfo>() { new GerritCallback<ChangeInfo>() {
@Override
public void onSuccess(ChangeInfo result) { public void onSuccess(ChangeInfo result) {
Gerrit.display(PageLinks.toChange(id)); Gerrit.display(PageLinks.toChange(id));
} }
@@ -691,6 +696,7 @@ class PatchSetComplexDisclosurePanel extends ComplexDisclosurePanel
Util.DETAIL_SVC.patchSetDetail2(diffBaseId, patchSet.getId(), diffPrefs, Util.DETAIL_SVC.patchSetDetail2(diffBaseId, patchSet.getId(), diffPrefs,
new GerritCallback<PatchSetDetail>() { new GerritCallback<PatchSetDetail>() {
@Override
public void onSuccess(final PatchSetDetail result) { public void onSuccess(final PatchSetDetail result) {
loadInfoTable(result); loadInfoTable(result);
loadActionPanel(result); loadActionPanel(result);

View File

@@ -455,6 +455,7 @@ public class PatchTable extends Composite {
int C_UNIFIED = C_SIDEBYSIDE - 2 + 1; int C_UNIFIED = C_SIDEBYSIDE - 2 + 1;
Anchor unified = new Anchor(Util.C.diffAllUnified()); Anchor unified = new Anchor(Util.C.diffAllUnified());
unified.addClickHandler(new ClickHandler() { unified.addClickHandler(new ClickHandler() {
@Override
public void onClick(ClickEvent event) { public void onClick(ClickEvent event) {
for (Patch p : detail.getPatches()) { for (Patch p : detail.getPatches()) {
openWindow(Dispatcher.toPatchUnified(base, p.getKey())); openWindow(Dispatcher.toPatchUnified(base, p.getKey()));
@@ -742,6 +743,7 @@ public class PatchTable extends Composite {
/** /**
* Add the files contained in the list of patches to the table, one per row. * Add the files contained in the list of patches to the table, one per row.
*/ */
@Override
@SuppressWarnings("fallthrough") @SuppressWarnings("fallthrough")
public boolean execute() { public boolean execute() {
final boolean attachedNow = isAttached(); final boolean attachedNow = isAttached();

View File

@@ -171,6 +171,7 @@ public class PublishCommentScreen extends AccountScreen implements
submitTypeRecord = SubmitTypeRecord.OK( submitTypeRecord = SubmitTypeRecord.OK(
SubmitType.valueOf(result.asString())); SubmitType.valueOf(result.asString()));
} }
@Override
public void onFailure(Throwable caught) {} public void onFailure(Throwable caught) {}
})); }));
ChangeApi.revision(patchSetId.getParentKey().get(), "" + patchSetId.get()) ChangeApi.revision(patchSetId.getParentKey().get(), "" + patchSetId.get())
@@ -180,6 +181,7 @@ public class PublishCommentScreen extends AccountScreen implements
public void onSuccess(NativeMap<JsArray<CommentInfo>> result) { public void onSuccess(NativeMap<JsArray<CommentInfo>> result) {
drafts = result; drafts = result;
} }
@Override
public void onFailure(Throwable caught) {} public void onFailure(Throwable caught) {}
})); }));
ChangeApi.revision(patchSetId).view("review") ChangeApi.revision(patchSetId).view("review")
@@ -445,6 +447,7 @@ public class PublishCommentScreen extends AccountScreen implements
patchSetId.getParentKey().get(), patchSetId.getParentKey().get(),
"" + patchSetId.get(), "" + patchSetId.get(),
new GerritCallback<SubmitInfo>() { new GerritCallback<SubmitInfo>() {
@Override
public void onSuccess(SubmitInfo result) { public void onSuccess(SubmitInfo result) {
saveStateOnUnload = false; saveStateOnUnload = false;
goChange(); goChange();

View File

@@ -65,7 +65,7 @@ class ChunkManager {
event.stopPropagation(); event.stopPropagation();
} }
} }
}; }
static void focusOnClick(Element e, DisplaySide side) { static void focusOnClick(Element e, DisplaySide side) {
onClick(e, side == A ? focusA : focusB); onClick(e, side == A ? focusA : focusB);
@@ -165,10 +165,10 @@ class ChunkManager {
int endA = mapper.getLineA() - 1; int endA = mapper.getLineA() - 1;
int endB = mapper.getLineB() - 1; int endB = mapper.getLineB() - 1;
if (aLen > 0) { if (aLen > 0) {
addDiffChunk(cmB, endB, endA, aLen, bLen > 0); addDiffChunk(cmB, endA, aLen, bLen > 0);
} }
if (bLen > 0) { if (bLen > 0) {
addDiffChunk(cmA, endA, endB, bLen, aLen > 0); addDiffChunk(cmA, endB, bLen, aLen > 0);
} }
} }
@@ -264,8 +264,8 @@ class ChunkManager {
} }
} }
private void addDiffChunk(CodeMirror cmToPad, int lineToPad, private void addDiffChunk(CodeMirror cmToPad, int lineOnOther,
int lineOnOther, int chunkSize, boolean edit) { int chunkSize, boolean edit) {
chunks.add(new DiffChunkInfo(host.otherCm(cmToPad).side(), chunks.add(new DiffChunkInfo(host.otherCm(cmToPad).side(),
lineOnOther - chunkSize + 1, lineOnOther, edit)); lineOnOther - chunkSize + 1, lineOnOther, edit));
} }

View File

@@ -295,6 +295,7 @@ class CommentManager {
Runnable toggleOpenBox(final CodeMirror cm) { Runnable toggleOpenBox(final CodeMirror cm) {
return new Runnable() { return new Runnable() {
@Override
public void run() { public void run() {
if (cm.hasActiveLine()) { if (cm.hasActiveLine()) {
CommentGroup w = map(cm.side()).get( CommentGroup w = map(cm.side()).get(
@@ -339,6 +340,7 @@ class CommentManager {
} }
return new Runnable() { return new Runnable() {
@Override
public void run() { public void run() {
if (cm.hasActiveLine()) { if (cm.hasActiveLine()) {
newDraft(cm); newDraft(cm);

View File

@@ -281,6 +281,7 @@ class Header extends Composite {
Runnable toggleReviewed() { Runnable toggleReviewed() {
return new Runnable() { return new Runnable() {
@Override
public void run() { public void run() {
reviewed.setValue(!reviewed.getValue(), true); reviewed.setValue(!reviewed.getValue(), true);
} }

View File

@@ -109,6 +109,7 @@ class PublishedBox extends CommentBox {
return UIObject.isVisible(message); return UIObject.isVisible(message);
} }
@Override
void setOpen(boolean open) { void setOpen(boolean open) {
UIObject.setVisible(summary, !open); UIObject.setVisible(summary, !open);
UIObject.setVisible(message, open); UIObject.setVisible(message, open);

View File

@@ -363,6 +363,7 @@ public class SideBySide2 extends Screen {
.on("Shift-Left", moveCursorToSide(cm, DisplaySide.A)) .on("Shift-Left", moveCursorToSide(cm, DisplaySide.A))
.on("Shift-Right", moveCursorToSide(cm, DisplaySide.B)) .on("Shift-Right", moveCursorToSide(cm, DisplaySide.B))
.on("I", new Runnable() { .on("I", new Runnable() {
@Override
public void run() { public void run() {
switch (getIntraLineStatus()) { switch (getIntraLineStatus()) {
case OFF: case OFF:
@@ -594,6 +595,7 @@ public class SideBySide2 extends Screen {
} }
operation(new Runnable() { operation(new Runnable() {
@Override
public void run() { public void run() {
// Estimate initial CM3 height, fixed up in onShowView. // Estimate initial CM3 height, fixed up in onShowView.
int height = Window.getClientHeight() int height = Window.getClientHeight()
@@ -783,6 +785,7 @@ public class SideBySide2 extends Screen {
private Runnable updateActiveLine(final CodeMirror cm) { private Runnable updateActiveLine(final CodeMirror cm) {
final CodeMirror other = otherCm(cm); final CodeMirror other = otherCm(cm);
return new Runnable() { return new Runnable() {
@Override
public void run() { public void run() {
// The rendering of active lines has to be deferred. Reflow // The rendering of active lines has to be deferred. Reflow
// caused by adding and removing styles chokes Firefox when arrow // caused by adding and removing styles chokes Firefox when arrow
@@ -793,6 +796,7 @@ public class SideBySide2 extends Screen {
@Override @Override
public void execute() { public void execute() {
operation(new Runnable() { operation(new Runnable() {
@Override
public void run() { public void run() {
LineHandle handle = cm.getLineHandleVisualStart( LineHandle handle = cm.getLineHandleVisualStart(
cm.getCursor("end").getLine()); cm.getCursor("end").getLine());
@@ -848,6 +852,7 @@ public class SideBySide2 extends Screen {
private Runnable upToChange(final boolean openReplyBox) { private Runnable upToChange(final boolean openReplyBox) {
return new Runnable() { return new Runnable() {
@Override
public void run() { public void run() {
CallbackGroup group = new CallbackGroup(); CallbackGroup group = new CallbackGroup();
commentManager.saveAllDrafts(group); commentManager.saveAllDrafts(group);
@@ -879,6 +884,7 @@ public class SideBySide2 extends Screen {
final DisplaySide sideSrc = cmSrc.side(); final DisplaySide sideSrc = cmSrc.side();
return new Runnable() { return new Runnable() {
@Override
public void run() { public void run() {
if (cmSrc.hasActiveLine()) { if (cmSrc.hasActiveLine()) {
cmDst.setCursor(LineCharacter.create(lineOnOther( cmDst.setCursor(LineCharacter.create(lineOnOther(

View File

@@ -541,6 +541,11 @@ public abstract class AbstractPatchContentTable extends NavigationTable<Object>
} }
} }
/**
* Update cursor after selecting a comment.
*
* @param newComment comment that was selected.
*/
protected void updateCursor(final PatchLineComment newComment) { protected void updateCursor(final PatchLineComment newComment) {
} }
@@ -724,7 +729,7 @@ public abstract class AbstractPatchContentTable extends NavigationTable<Object>
} }
protected void bindComment(final int row, final int col, protected void bindComment(final int row, final int col,
final PatchLineComment line, final boolean isLast, boolean expandComment) { final PatchLineComment line, boolean expandComment) {
if (line.getStatus() == PatchLineComment.Status.DRAFT) { if (line.getStatus() == PatchLineComment.Status.DRAFT) {
final CommentEditorPanel plc = final CommentEditorPanel plc =
new CommentEditorPanel(line, commentLinkProcessor); new CommentEditorPanel(line, commentLinkProcessor);

View File

@@ -245,6 +245,7 @@ public class CommentEditorPanel extends CommentPanel implements ClickHandler,
final PatchSet.Id psId = comment.getKey().getParentKey().getParentKey(); final PatchSet.Id psId = comment.getKey().getParentKey().getParentKey();
final boolean wasNew = isNew(); final boolean wasNew = isNew();
GerritCallback<CommentInfo> cb = new GerritCallback<CommentInfo>() { GerritCallback<CommentInfo> cb = new GerritCallback<CommentInfo>() {
@Override
public void onSuccess(CommentInfo result) { public void onSuccess(CommentInfo result) {
notifyDraftDelta(wasNew ? 1 : 0); notifyDraftDelta(wasNew ? 1 : 0);
comment = toComment(psId, comment.getKey().getParentKey().get(), result); comment = toComment(psId, comment.getKey().getParentKey().get(), result);
@@ -300,6 +301,7 @@ public class CommentEditorPanel extends CommentPanel implements ClickHandler,
comment.getKey().getParentKey().getParentKey(), comment.getKey().getParentKey().getParentKey(),
comment.getKey().get(), comment.getKey().get(),
new GerritCallback<JavaScriptObject>() { new GerritCallback<JavaScriptObject>() {
@Override
public void onSuccess(JavaScriptObject result) { public void onSuccess(JavaScriptObject result) {
notifyDraftDelta(-1); notifyDraftDelta(-1);
removeUI(); removeUI();

View File

@@ -564,6 +564,7 @@ public abstract class PatchScreen extends Screen implements
fileList.setSavePointerId("PatchTable " + psid); fileList.setSavePointerId("PatchTable " + psid);
Util.DETAIL_SVC.patchSetDetail(psid, Util.DETAIL_SVC.patchSetDetail(psid,
new GerritCallback<PatchSetDetail>() { new GerritCallback<PatchSetDetail>() {
@Override
public void onSuccess(final PatchSetDetail result) { public void onSuccess(final PatchSetDetail result) {
fileList.display(idSideA, result); fileList.display(idSideA, result);
} }

View File

@@ -135,6 +135,7 @@ public class ReviewedPanels {
private InlineHyperlink createReviewedLink(final int patchIndex, private InlineHyperlink createReviewedLink(final int patchIndex,
final PatchScreen.Type patchScreenType) { final PatchScreen.Type patchScreenType) {
final PatchValidator unreviewedValidator = new PatchValidator() { final PatchValidator unreviewedValidator = new PatchValidator() {
@Override
public boolean isValid(Patch patch) { public boolean isValid(Patch patch) {
return !patch.isReviewedByCurrentUser(); return !patch.isReviewedByCurrentUser();
} }

View File

@@ -57,10 +57,12 @@ public class SideBySideTable extends AbstractPatchContentTable {
private boolean isHugeFile; private boolean isHugeFile;
protected boolean isFileCommentBorderRowExist; protected boolean isFileCommentBorderRowExist;
@Override
protected void createFileCommentEditorOnSideA() { protected void createFileCommentEditorOnSideA() {
createCommentEditor(R_HEAD + 1, A, R_HEAD, FILE_SIDE_A); createCommentEditor(R_HEAD + 1, A, R_HEAD, FILE_SIDE_A);
} }
@Override
protected void createFileCommentEditorOnSideB() { protected void createFileCommentEditorOnSideB() {
createCommentEditor(R_HEAD + 1, B, R_HEAD, FILE_SIDE_B); createCommentEditor(R_HEAD + 1, B, R_HEAD, FILE_SIDE_B);
} }
@@ -96,7 +98,7 @@ public class SideBySideTable extends AbstractPatchContentTable {
final ArrayList<Object> lines = new ArrayList<>(); final ArrayList<Object> lines = new ArrayList<>();
final SafeHtmlBuilder nc = new SafeHtmlBuilder(); final SafeHtmlBuilder nc = new SafeHtmlBuilder();
isHugeFile = script.isHugeFile(); isHugeFile = script.isHugeFile();
allocateTableHeader(script, nc); allocateTableHeader(nc);
lines.add(null); lines.add(null);
if (!isDisplayBinary) { if (!isDisplayBinary) {
if (script.getFileModeA() != FileMode.FILE if (script.getFileModeA() != FileMode.FILE
@@ -119,7 +121,7 @@ public class SideBySideTable extends AbstractPatchContentTable {
&& script.hasIntralineDifference(); && script.hasIntralineDifference();
for (final EditList.Hunk hunk : script.getHunks()) { for (final EditList.Hunk hunk : script.getHunks()) {
if (!hunk.isStartOfFile()) { if (!hunk.isStartOfFile()) {
appendSkipLine(nc, hunk.getCurB() - lastB); appendSkipLine(nc);
lines.add(new SkippedLine(lastA, lastB, hunk.getCurB() - lastB)); lines.add(new SkippedLine(lastA, lastB, hunk.getCurB() - lastB));
} }
@@ -185,7 +187,7 @@ public class SideBySideTable extends AbstractPatchContentTable {
lastB = hunk.getCurB(); lastB = hunk.getCurB();
} }
if (lastB != b.size()) { if (lastB != b.size()) {
appendSkipLine(nc, b.size() - lastB); appendSkipLine(nc);
lines.add(new SkippedLine(lastA, lastB, b.size() - lastB)); lines.add(new SkippedLine(lastA, lastB, b.size() - lastB));
} }
} }
@@ -329,13 +331,13 @@ public class SideBySideTable extends AbstractPatchContentTable {
} else { } else {
insertRow(row); insertRow(row);
} }
bindComment(row, A, ac, !ai.hasNext(), expandComments); bindComment(row, A, ac, !ai.hasNext());
bindComment(row, B, bc, !bi.hasNext(), expandComments); bindComment(row, B, bc, !bi.hasNext());
row++; row++;
} }
row = finish(ai, row, A, expandComments); row = finish(ai, row, A);
row = finish(bi, row, B, expandComments); row = finish(bi, row, B);
} }
} }
@@ -390,7 +392,7 @@ public class SideBySideTable extends AbstractPatchContentTable {
} }
} }
private int finish(final Iterator<PatchLineComment> i, int row, final int col, boolean expandComment) { private int finish(final Iterator<PatchLineComment> i, int row, final int col) {
while (i.hasNext()) { while (i.hasNext()) {
final PatchLineComment c = i.next(); final PatchLineComment c = i.next();
if (c.getLine() == R_HEAD) { if (c.getLine() == R_HEAD) {
@@ -398,13 +400,13 @@ public class SideBySideTable extends AbstractPatchContentTable {
} else { } else {
insertRow(row); insertRow(row);
} }
bindComment(row, col, c, !i.hasNext(), expandComment); bindComment(row, col, c, !i.hasNext());
row++; row++;
} }
return row; return row;
} }
private void allocateTableHeader(PatchScript script, final SafeHtmlBuilder m) { private void allocateTableHeader(final SafeHtmlBuilder m) {
m.openTr(); m.openTr();
m.openTd(); m.openTd();
@@ -457,7 +459,7 @@ public class SideBySideTable extends AbstractPatchContentTable {
m.closeTr(); m.closeTr();
} }
private void appendSkipLine(final SafeHtmlBuilder m, final int skipCnt) { private void appendSkipLine(final SafeHtmlBuilder m) {
m.openTr(); m.openTr();
m.openTd(); m.openTd();

View File

@@ -46,6 +46,7 @@ public class UnifiedDiffTable extends AbstractPatchContentTable {
private static final int PC = 3; private static final int PC = 3;
private static final Comparator<PatchLineComment> BY_DATE = private static final Comparator<PatchLineComment> BY_DATE =
new Comparator<PatchLineComment>() { new Comparator<PatchLineComment>() {
@Override
public int compare(final PatchLineComment o1, final PatchLineComment o2) { public int compare(final PatchLineComment o1, final PatchLineComment o2) {
return o1.getWrittenOn().compareTo(o2.getWrittenOn()); return o1.getWrittenOn().compareTo(o2.getWrittenOn());
} }
@@ -164,10 +165,12 @@ public class UnifiedDiffTable extends AbstractPatchContentTable {
nc.closeElement("img"); nc.closeElement("img");
} }
@Override
protected void createFileCommentEditorOnSideA() { protected void createFileCommentEditorOnSideA() {
createCommentEditor(R_HEAD + 1, PC, R_HEAD, FILE_SIDE_A); createCommentEditor(R_HEAD + 1, PC, R_HEAD, FILE_SIDE_A);
} }
@Override
protected void createFileCommentEditorOnSideB() { protected void createFileCommentEditorOnSideB() {
createCommentEditor(rowOfTableHeaderB + 1, PC, R_HEAD, FILE_SIDE_B); createCommentEditor(rowOfTableHeaderB + 1, PC, R_HEAD, FILE_SIDE_B);
createFileCommentBorderRow(); createFileCommentBorderRow();
@@ -367,13 +370,13 @@ public class UnifiedDiffTable extends AbstractPatchContentTable {
row++; row++;
if (!fora.isEmpty()) { if (!fora.isEmpty()) {
row = insert(fora, row, expandComments); row = insert(fora, row);
} }
rowOfTableHeaderB = row; rowOfTableHeaderB = row;
borderRowOfFileComment = row + 1; borderRowOfFileComment = row + 1;
if (!forb.isEmpty()) { if (!forb.isEmpty()) {
row++;// Skip the Header of sideB. row++;// Skip the Header of sideB.
row = insert(forb, row, expandComments); row = insert(forb, row);
borderRowOfFileComment = row; borderRowOfFileComment = row;
createFileCommentBorderRow(); createFileCommentBorderRow();
} }
@@ -388,13 +391,13 @@ public class UnifiedDiffTable extends AbstractPatchContentTable {
all.addAll(fora); all.addAll(fora);
all.addAll(forb); all.addAll(forb);
Collections.sort(all, BY_DATE); Collections.sort(all, BY_DATE);
row = insert(all, row, expandComments); row = insert(all, row);
} else if (!fora.isEmpty()) { } else if (!fora.isEmpty()) {
row = insert(fora, row, expandComments); row = insert(fora, row);
} else if (!forb.isEmpty()) { } else if (!forb.isEmpty()) {
row = insert(forb, row, expandComments); row = insert(forb, row);
} }
} else { } else {
row++; row++;
@@ -422,7 +425,7 @@ public class UnifiedDiffTable extends AbstractPatchContentTable {
return PatchScreen.Type.UNIFIED; return PatchScreen.Type.UNIFIED;
} }
private int insert(final List<PatchLineComment> in, int row, boolean expandComment) { private int insert(final List<PatchLineComment> in, int row) {
for (Iterator<PatchLineComment> ci = in.iterator(); ci.hasNext();) { for (Iterator<PatchLineComment> ci = in.iterator(); ci.hasNext();) {
final PatchLineComment c = ci.next(); final PatchLineComment c = ci.next();
if (c.getLine() == R_HEAD) { if (c.getLine() == R_HEAD) {
@@ -430,7 +433,7 @@ public class UnifiedDiffTable extends AbstractPatchContentTable {
} else { } else {
insertRow(row); insertRow(row);
} }
bindComment(row, PC, c, !ci.hasNext(), expandComment); bindComment(row, PC, c, !ci.hasNext());
row++; row++;
} }
return row; return row;

View File

@@ -33,6 +33,7 @@ import com.google.gwtjsonrpc.common.JsonConstants;
public abstract class GerritCallback<T> implements public abstract class GerritCallback<T> implements
com.google.gwtjsonrpc.common.AsyncCallback<T>, com.google.gwtjsonrpc.common.AsyncCallback<T>,
com.google.gwt.user.client.rpc.AsyncCallback<T> { com.google.gwt.user.client.rpc.AsyncCallback<T> {
@Override
public void onFailure(final Throwable caught) { public void onFailure(final Throwable caught) {
if (isNotSignedIn(caught) || isInvalidXSRF(caught)) { if (isNotSignedIn(caught) || isInvalidXSRF(caught)) {
new NotSignedInDialog().center(); new NotSignedInDialog().center();

View File

@@ -28,6 +28,7 @@ public abstract class ScreenLoadCallback<T> extends GerritCallback<T> {
screen = s; screen = s;
} }
@Override
public final void onSuccess(final T result) { public final void onSuccess(final T result) {
if (screen.isAttached()) { if (screen.isAttached()) {
preDisplay(result); preDisplay(result);

Some files were not shown because too many files have changed in this diff Show More