Simplify lambda expressions
When lambda expression consists of only one statement, curly brackets can be omitted. Change-Id: Ibeced168aef9ecd511a2872d40e707912e05ec50
This commit is contained in:
parent
eca086a537
commit
00b0bcfb3d
@ -369,42 +369,14 @@ abstract class DiffScreen extends Screen {
|
||||
}
|
||||
})
|
||||
.on("','", prefsAction::show)
|
||||
.on(
|
||||
"Shift-/",
|
||||
() -> {
|
||||
new ShowHelpCommand().onKeyPress(null);
|
||||
})
|
||||
.on(
|
||||
"Space",
|
||||
() -> {
|
||||
cm.vim().handleKey("<C-d>");
|
||||
})
|
||||
.on(
|
||||
"Shift-Space",
|
||||
() -> {
|
||||
cm.vim().handleKey("<C-u>");
|
||||
})
|
||||
.on(
|
||||
"Ctrl-F",
|
||||
() -> {
|
||||
cm.execCommand("find");
|
||||
})
|
||||
.on(
|
||||
"Ctrl-G",
|
||||
() -> {
|
||||
cm.execCommand("findNext");
|
||||
})
|
||||
.on("Shift-/", () -> new ShowHelpCommand().onKeyPress(null))
|
||||
.on("Space", () -> cm.vim().handleKey("<C-d>"))
|
||||
.on("Shift-Space", () -> cm.vim().handleKey("<C-u>"))
|
||||
.on("Ctrl-F", () -> cm.execCommand("find"))
|
||||
.on("Ctrl-G", () -> cm.execCommand("findNext"))
|
||||
.on("Enter", maybeNextCmSearch(cm))
|
||||
.on(
|
||||
"Shift-Ctrl-G",
|
||||
() -> {
|
||||
cm.execCommand("findPrev");
|
||||
})
|
||||
.on(
|
||||
"Shift-Enter",
|
||||
() -> {
|
||||
cm.execCommand("findPrev");
|
||||
})
|
||||
.on("Shift-Ctrl-G", () -> cm.execCommand("findPrev"))
|
||||
.on("Shift-Enter", () -> cm.execCommand("findPrev"))
|
||||
.on(
|
||||
"Esc",
|
||||
() -> {
|
||||
@ -412,53 +384,17 @@ abstract class DiffScreen extends Screen {
|
||||
cm.execCommand("clearSearch");
|
||||
cm.vim().handleEx("nohlsearch");
|
||||
})
|
||||
.on(
|
||||
"Ctrl-A",
|
||||
() -> {
|
||||
cm.execCommand("selectAll");
|
||||
})
|
||||
.on(
|
||||
"G O",
|
||||
() -> {
|
||||
Gerrit.display(PageLinks.toChangeQuery("status:open"));
|
||||
})
|
||||
.on(
|
||||
"G M",
|
||||
() -> {
|
||||
Gerrit.display(PageLinks.toChangeQuery("status:merged"));
|
||||
})
|
||||
.on(
|
||||
"G A",
|
||||
() -> {
|
||||
Gerrit.display(PageLinks.toChangeQuery("status:abandoned"));
|
||||
});
|
||||
.on("Ctrl-A", () -> cm.execCommand("selectAll"))
|
||||
.on("G O", () -> Gerrit.display(PageLinks.toChangeQuery("status:open")))
|
||||
.on("G M", () -> Gerrit.display(PageLinks.toChangeQuery("status:merged")))
|
||||
.on("G A", () -> Gerrit.display(PageLinks.toChangeQuery("status:abandoned")));
|
||||
if (Gerrit.isSignedIn()) {
|
||||
keyMap
|
||||
.on(
|
||||
"G I",
|
||||
() -> {
|
||||
Gerrit.display(PageLinks.MINE);
|
||||
})
|
||||
.on(
|
||||
"G D",
|
||||
() -> {
|
||||
Gerrit.display(PageLinks.toChangeQuery("owner:self is:draft"));
|
||||
})
|
||||
.on(
|
||||
"G C",
|
||||
() -> {
|
||||
Gerrit.display(PageLinks.toChangeQuery("has:draft"));
|
||||
})
|
||||
.on(
|
||||
"G W",
|
||||
() -> {
|
||||
Gerrit.display(PageLinks.toChangeQuery("is:watched status:open"));
|
||||
})
|
||||
.on(
|
||||
"G S",
|
||||
() -> {
|
||||
Gerrit.display(PageLinks.toChangeQuery("is:starred"));
|
||||
});
|
||||
.on("G I", () -> Gerrit.display(PageLinks.MINE))
|
||||
.on("G D", () -> Gerrit.display(PageLinks.toChangeQuery("owner:self is:draft")))
|
||||
.on("G C", () -> Gerrit.display(PageLinks.toChangeQuery("has:draft")))
|
||||
.on("G W", () -> Gerrit.display(PageLinks.toChangeQuery("is:watched status:open")))
|
||||
.on("G S", () -> Gerrit.display(PageLinks.toChangeQuery("is:starred")));
|
||||
}
|
||||
|
||||
if (revision.get() != 0) {
|
||||
|
@ -318,21 +318,15 @@ public class Header extends Composite {
|
||||
}
|
||||
|
||||
Runnable toggleReviewed() {
|
||||
return () -> {
|
||||
reviewed.setValue(!reviewed.getValue(), true);
|
||||
};
|
||||
return () -> reviewed.setValue(!reviewed.getValue(), true);
|
||||
}
|
||||
|
||||
Runnable navigate(Direction dir) {
|
||||
switch (dir) {
|
||||
case PREV:
|
||||
return () -> {
|
||||
(hasPrev ? prev : up).go();
|
||||
};
|
||||
return () -> (hasPrev ? prev : up).go();
|
||||
case NEXT:
|
||||
return () -> {
|
||||
(hasNext ? next : up).go();
|
||||
};
|
||||
return () -> (hasNext ? next : up).go();
|
||||
default:
|
||||
return () -> {};
|
||||
}
|
||||
|
@ -338,10 +338,7 @@ public class PreferencesBox extends Composite {
|
||||
if (v != null && v.length() > 0) {
|
||||
prefs.lineLength(Math.max(1, Integer.parseInt(v)));
|
||||
if (view != null) {
|
||||
view.operation(
|
||||
() -> {
|
||||
view.setLineLength(prefs.lineLength());
|
||||
});
|
||||
view.operation(() -> view.setLineLength(prefs.lineLength()));
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@ -370,10 +370,7 @@ public class SideBySide extends DiffScreen {
|
||||
|
||||
@Override
|
||||
void operation(Runnable apply) {
|
||||
cmA.operation(
|
||||
() -> {
|
||||
cmB.operation(apply::run);
|
||||
});
|
||||
cmA.operation(() -> cmB.operation(apply::run));
|
||||
}
|
||||
|
||||
@Override
|
||||
|
@ -75,9 +75,7 @@ class SideBySideTable extends DiffTable {
|
||||
}
|
||||
|
||||
Runnable toggleA() {
|
||||
return () -> {
|
||||
setVisibleA(!isVisibleA());
|
||||
};
|
||||
return () -> setVisibleA(!isVisibleA());
|
||||
}
|
||||
|
||||
void setVisibleB(boolean show) {
|
||||
|
@ -317,9 +317,7 @@ public class EditScreen extends Screen {
|
||||
}
|
||||
|
||||
private Runnable gotoLine() {
|
||||
return () -> {
|
||||
cmEdit.execCommand("jumpToLine");
|
||||
};
|
||||
return () -> cmEdit.execCommand("jumpToLine");
|
||||
}
|
||||
|
||||
@Override
|
||||
@ -469,14 +467,8 @@ public class EditScreen extends Screen {
|
||||
}
|
||||
|
||||
void setTheme(Theme newTheme) {
|
||||
cmBase.operation(
|
||||
() -> {
|
||||
cmBase.setOption("theme", newTheme.name().toLowerCase());
|
||||
});
|
||||
cmEdit.operation(
|
||||
() -> {
|
||||
cmEdit.setOption("theme", newTheme.name().toLowerCase());
|
||||
});
|
||||
cmBase.operation(() -> cmBase.setOption("theme", newTheme.name().toLowerCase()));
|
||||
cmEdit.operation(() -> cmEdit.setOption("theme", newTheme.name().toLowerCase()));
|
||||
}
|
||||
|
||||
void setLineLength(int length) {
|
||||
@ -495,14 +487,8 @@ public class EditScreen extends Screen {
|
||||
}
|
||||
|
||||
void setShowWhitespaceErrors(boolean show) {
|
||||
cmBase.operation(
|
||||
() -> {
|
||||
cmBase.setOption("showTrailingSpace", show);
|
||||
});
|
||||
cmEdit.operation(
|
||||
() -> {
|
||||
cmEdit.setOption("showTrailingSpace", show);
|
||||
});
|
||||
cmBase.operation(() -> cmBase.setOption("showTrailingSpace", show));
|
||||
cmEdit.operation(() -> cmEdit.setOption("showTrailingSpace", show));
|
||||
}
|
||||
|
||||
void setShowTabs(boolean show) {
|
||||
@ -633,11 +619,7 @@ public class EditScreen extends Screen {
|
||||
// key (or j/k) is held down. Performance on Chrome is fine
|
||||
// without the deferral.
|
||||
//
|
||||
Scheduler.get()
|
||||
.scheduleDeferred(
|
||||
() -> {
|
||||
cmEdit.operation(this::updateActiveLine);
|
||||
});
|
||||
Scheduler.get().scheduleDeferred(() -> cmEdit.operation(this::updateActiveLine));
|
||||
};
|
||||
}
|
||||
|
||||
|
@ -85,11 +85,7 @@ public abstract class MetricMaker {
|
||||
@SuppressWarnings("unchecked")
|
||||
Class<V> type = (Class<V>) value.getClass();
|
||||
CallbackMetric0<V> metric = newCallbackMetric(name, type, desc);
|
||||
newTrigger(
|
||||
metric,
|
||||
() -> {
|
||||
metric.set(value);
|
||||
});
|
||||
newTrigger(metric, () -> metric.set(value));
|
||||
}
|
||||
|
||||
/**
|
||||
@ -115,11 +111,7 @@ public abstract class MetricMaker {
|
||||
public <V> void newCallbackMetric(
|
||||
String name, Class<V> valueClass, Description desc, Supplier<V> trigger) {
|
||||
CallbackMetric0<V> metric = newCallbackMetric(name, valueClass, desc);
|
||||
newTrigger(
|
||||
metric,
|
||||
() -> {
|
||||
metric.set(trigger.get());
|
||||
});
|
||||
newTrigger(metric, () -> metric.set(trigger.get()));
|
||||
}
|
||||
|
||||
/**
|
||||
|
@ -201,16 +201,12 @@ public class RepoSequenceTest {
|
||||
@Test
|
||||
public void failAfterRetryerGivesUp() throws Exception {
|
||||
AtomicInteger bgCounter = new AtomicInteger(1234);
|
||||
Runnable bgUpdate =
|
||||
() -> {
|
||||
writeBlob("id", Integer.toString(bgCounter.getAndAdd(1000)));
|
||||
};
|
||||
RepoSequence s =
|
||||
newSequence(
|
||||
"id",
|
||||
1,
|
||||
10,
|
||||
bgUpdate,
|
||||
() -> writeBlob("id", Integer.toString(bgCounter.getAndAdd(1000))),
|
||||
RetryerBuilder.<RefUpdate.Result>newBuilder()
|
||||
.withStopStrategy(StopStrategies.stopAfterAttempt(3))
|
||||
.build());
|
||||
|
Loading…
Reference in New Issue
Block a user