Skip to content

Commit 877faf7

Browse files
authored
[cq] Migrate code to Inspection-recommended Java syntax and APIs (#44)
1 parent a33bc0d commit 877faf7

File tree

13 files changed

+19
-38
lines changed

13 files changed

+19
-38
lines changed

third_party/src/main/java/com/jetbrains/lang/dart/analyzer/DartAnalysisServerService.java

Lines changed: 3 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -1220,12 +1220,9 @@ public boolean edit_isPostfixCompletionApplicable(VirtualFile file, int _offset,
12201220
final Ref<Boolean> resultRef = Ref.create(false);
12211221
final CountDownLatch latch = new CountDownLatch(1);
12221222
final int offset = getOriginalOffset(file, _offset);
1223-
server.edit_isPostfixCompletionApplicable(fileUri, key, offset, new IsPostfixCompletionApplicableConsumer() {
1224-
@Override
1225-
public void isPostfixCompletionApplicable(Boolean value) {
1226-
resultRef.set(value);
1227-
latch.countDown();
1228-
}
1223+
server.edit_isPostfixCompletionApplicable(fileUri, key, offset, value -> {
1224+
resultRef.set(value);
1225+
latch.countDown();
12291226
});
12301227

12311228
awaitForLatchCheckingCanceled(server, latch, POSTFIX_COMPLETION_TIMEOUT);

third_party/src/main/java/com/jetbrains/lang/dart/analyzer/DartServerData.java

Lines changed: 2 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -277,9 +277,7 @@ void textDocumentContentDidChange(@NotNull String fileUri) {
277277
file.setWritable(false);
278278

279279
VirtualFile finalFile = file;
280-
ApplicationManager.getApplication().invokeLater(() -> {
281-
FileDocumentManager.getInstance().reloadFiles(finalFile);
282-
}, ModalityState.nonModal(), myService.getDisposedCondition());
280+
ApplicationManager.getApplication().invokeLater(() -> FileDocumentManager.getInstance().reloadFiles(finalFile), ModalityState.nonModal(), myService.getDisposedCondition());
283281
});
284282
}
285283

@@ -405,9 +403,7 @@ private void forceFileAnnotation(final @Nullable VirtualFile file, final boolean
405403
// but it will cache RemoteAnalysisServerImpl$ServerResponseReaderThread in FileStatusMap.threads and as a result,
406404
// DartAnalysisServerService.myProject will be leaked in tests
407405
ApplicationManager.getApplication()
408-
.invokeLater(() -> {
409-
DaemonCodeAnalyzer.getInstance(project).restart();
410-
},
406+
.invokeLater(() -> DaemonCodeAnalyzer.getInstance(project).restart(),
411407
ModalityState.nonModal(),
412408
myService.getDisposedCondition());
413409
}

third_party/src/main/java/com/jetbrains/lang/dart/analyzer/DartServerRootsHandler.java

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -57,7 +57,7 @@ void onServerStarted() {
5757
}
5858

5959
void scheduleDartRootsUpdate(@Nullable Runnable onSuccess) {
60-
ReadAction.nonBlocking(() -> calcIncludedAndExcludedDartRootPaths())
60+
ReadAction.nonBlocking(this::calcIncludedAndExcludedDartRootPaths)
6161
.coalesceBy(this)
6262
.expireWith(DartAnalysisServerService.getInstance(myProject))
6363
.finishOnUiThread(ModalityState.nonModal(), includedAndExcludedRootPaths -> {

third_party/src/main/java/com/jetbrains/lang/dart/ide/errorTreeView/DartProblemsViewPanel.java

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -372,7 +372,7 @@ public void performCopy(@NotNull DataContext dataContext) {
372372
public void uiDataSnapshot(@NotNull DataSink sink) {
373373
super.uiDataSnapshot(sink);
374374
sink.set(PlatformDataKeys.COPY_PROVIDER, this);
375-
sink.lazy(CommonDataKeys.NAVIGATABLE, () -> createNavigatable());
375+
sink.lazy(CommonDataKeys.NAVIGATABLE, this::createNavigatable);
376376
}
377377

378378
private @Nullable Navigatable createNavigatable() {

third_party/src/main/java/com/jetbrains/lang/dart/ide/findUsages/DartComponentUsageGroup.java

Lines changed: 1 addition & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -60,9 +60,7 @@ public boolean equals(Object object) {
6060

6161
@Override
6262
public void uiDataSnapshot(@NotNull DataSink sink) {
63-
sink.lazy(CommonDataKeys.PSI_ELEMENT, () -> {
64-
return getNameElement();
65-
});
63+
sink.lazy(CommonDataKeys.PSI_ELEMENT, this::getNameElement);
6664
sink.lazy(UsageView.USAGE_INFO_KEY, () -> {
6765
final DartComponentName nameElement = getNameElement();
6866
return nameElement != null ? new UsageInfo(nameElement) : null;

third_party/src/main/java/com/jetbrains/lang/dart/ide/runner/server/vmService/frame/DartVmServiceValue.java

Lines changed: 3 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -29,15 +29,9 @@
2929
// See https://youtrack.jetbrains.com/issue/WEB-17629.
3030

3131
public final class DartVmServiceValue extends XNamedValue {
32-
private static final LayeredIcon FINAL_FIELD_ICON = LayeredIcon.layeredIcon(() -> {
33-
return new Icon[]{AllIcons.Nodes.Field, IconManager.getInstance().getPlatformIcon(PlatformIcons.FinalMark)};
34-
});
35-
private static final LayeredIcon STATIC_FIELD_ICON = LayeredIcon.layeredIcon(() -> {
36-
return new Icon[]{AllIcons.Nodes.Field, IconManager.getInstance().getPlatformIcon(PlatformIcons.StaticMark)};
37-
});
38-
private static final LayeredIcon STATIC_FINAL_FIELD_ICON = LayeredIcon.layeredIcon(() -> {
39-
return new Icon[]{AllIcons.Nodes.Field, IconManager.getInstance().getPlatformIcon(PlatformIcons.StaticMark), IconManager.getInstance().getPlatformIcon(PlatformIcons.FinalMark)};
40-
});
32+
private static final LayeredIcon FINAL_FIELD_ICON = LayeredIcon.layeredIcon(() -> new Icon[]{AllIcons.Nodes.Field, IconManager.getInstance().getPlatformIcon(PlatformIcons.FinalMark)});
33+
private static final LayeredIcon STATIC_FIELD_ICON = LayeredIcon.layeredIcon(() -> new Icon[]{AllIcons.Nodes.Field, IconManager.getInstance().getPlatformIcon(PlatformIcons.StaticMark)});
34+
private static final LayeredIcon STATIC_FINAL_FIELD_ICON = LayeredIcon.layeredIcon(() -> new Icon[]{AllIcons.Nodes.Field, IconManager.getInstance().getPlatformIcon(PlatformIcons.StaticMark), IconManager.getInstance().getPlatformIcon(PlatformIcons.FinalMark)});
4135

4236
private final @NotNull DartVmServiceDebugProcess myDebugProcess;
4337
private final @NotNull String myIsolateId;

third_party/src/main/java/com/jetbrains/lang/dart/util/DartPsiImplUtil.java

Lines changed: 1 addition & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -204,11 +204,7 @@ private static PsiElement doResolveTypeReference(final DartType dartType) {
204204
// find type parameter
205205
if (result.isEmpty()) {
206206
PsiTreeUtil.treeWalkUp(dartResolveProcessor, dartType, null, ResolveState.initial());
207-
for (Iterator<DartComponentName> iterator = result.iterator(); iterator.hasNext(); ) {
208-
if (!(iterator.next().getParent() instanceof DartTypeParameter)) {
209-
iterator.remove();
210-
}
211-
}
207+
result.removeIf(dartComponentName -> !(dartComponentName.getParent() instanceof DartTypeParameter));
212208
}
213209

214210
// global

third_party/src/test/java/com/jetbrains/dart/analysisServer/DartCallHierarchyTest.java

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -106,7 +106,7 @@ public void visitReferenceExpression(@NotNull DartReferenceExpression reference)
106106
List<PsiElement> results = new ArrayList<>();
107107
DartCallHierarchyTreeStructure.collectDeclarations(reference.resolve(), results);
108108
if (!results.isEmpty()) {
109-
result[0] = results.get(0);
109+
result[0] = results.getFirst();
110110
throw new ExitVisitor();
111111
}
112112
}

third_party/src/test/java/com/jetbrains/dart/analysisServer/DartServerHighlightingTest.java

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -269,14 +269,14 @@ public void testNavigationTargetOffsetUpdated() {
269269
TextRange.create(15, 16),
270270
TextRange.create(19, 20)};
271271
checkRegions(regions, ranges);
272-
assertEquals(4, regions.get(4).getTargets().get(0).getOffset(getProject(), file));
272+
assertEquals(4, regions.get(4).getTargets().getFirst().getOffset(getProject(), file));
273273

274274
getEditor().getCaretModel().moveToOffset(0);
275275
myFixture.type("foo \b");
276276
// Disable for pre-3.7.0 Dart SDK versions:
277277
if(StringUtil.compareVersionNumbers(service.getSdkVersion(), "3.7.0") >= 0) {
278278
checkRegions(regions, ContainerUtil.map2Array(ranges, TextRange.class, range -> range.shiftRight(3)));
279-
assertEquals(4 + 3, regions.get(4).getTargets().get(0).getOffset(getProject(), file));
279+
assertEquals(4 + 3, regions.get(4).getTargets().getFirst().getOffset(getProject(), file));
280280
}
281281
}
282282

third_party/src/test/java/com/jetbrains/dart/analysisServer/DartServerIntentionsTest.java

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -51,7 +51,7 @@ void f() {
5151
<selection><caret>var x = 3;</selection>
5252
}
5353
""");
54-
final List<String> intentions = ContainerUtil.map(myFixture.getAvailableIntentions(), intention -> intention.getText());
54+
final List<String> intentions = ContainerUtil.map(myFixture.getAvailableIntentions(), IntentionAction::getText);
5555
assertOrderedEquals(intentions,
5656
"Surround with block",
5757
"Edit intention settings",

0 commit comments

Comments
 (0)