From 147ff5a482906be5aa3446c9b5275300a5fe58f9 Mon Sep 17 00:00:00 2001 From: Alexander Fedorov Date: Sat, 22 Aug 2020 08:57:08 +0300 Subject: [PATCH] Bug 566093 - CDT LSP: null-free functions to retrieve URL from IDocument Rework usages of Java 11 Optional#isEmpty() to Java 8 Optional#isPresent() Change-Id: I9c0788414e7752efe87bf50eafadb6f3ab9a76be Signed-off-by: Alexander Fedorov --- .../cdt/lsp/text/tests/ResolveDocumentUriTest.java | 8 ++++---- .../internal/cquery/ui/PublishSemanticHighlighting.java | 2 +- .../cdt/lsp/internal/ui/text/SetInactiveRegions.java | 2 +- 3 files changed, 6 insertions(+), 6 deletions(-) diff --git a/lsp/org.eclipse.cdt.lsp.core.tests/src/org/eclipse/cdt/lsp/text/tests/ResolveDocumentUriTest.java b/lsp/org.eclipse.cdt.lsp.core.tests/src/org/eclipse/cdt/lsp/text/tests/ResolveDocumentUriTest.java index 6fbc7dbad42..b86f2ff590b 100644 --- a/lsp/org.eclipse.cdt.lsp.core.tests/src/org/eclipse/cdt/lsp/text/tests/ResolveDocumentUriTest.java +++ b/lsp/org.eclipse.cdt.lsp.core.tests/src/org/eclipse/cdt/lsp/text/tests/ResolveDocumentUriTest.java @@ -13,7 +13,7 @@ *******************************************************************************/ package org.eclipse.cdt.lsp.text.tests; -import static org.junit.Assert.assertTrue; +import static org.junit.Assert.assertFalse; import org.eclipse.cdt.lsp.internal.text.ResolveDocumentUri; import org.eclipse.core.filebuffers.FileBuffers; @@ -32,14 +32,14 @@ public class ResolveDocumentUriTest { @Test public void emptyDocument() { - assertTrue(uri.apply(new Document()).isEmpty()); + assertFalse(uri.apply(new Document()).isPresent()); } @Test public void externalDocument() { Document document = new Document(); FileBuffers.createTextFileBufferManager().createEmptyDocument(new Path("some.c"), LocationKind.LOCATION); - assertTrue(uri.apply(document).isEmpty()); + assertFalse(uri.apply(document).isPresent()); } @Test @@ -47,7 +47,7 @@ public class ResolveDocumentUriTest { Document document = new Document(); FileBuffers.createTextFileBufferManager().createEmptyDocument(new Path("some.c"), LocationKind.LOCATION); //it's a pity! see https://bugs.eclipse.org/bugs/show_bug.cgi?id=566044 - assertTrue(uri.apply(document).isEmpty()); + assertFalse(uri.apply(document).isPresent()); } } diff --git a/lsp/org.eclipse.cdt.lsp.cquery/src/org/eclipse/cdt/lsp/internal/cquery/ui/PublishSemanticHighlighting.java b/lsp/org.eclipse.cdt.lsp.cquery/src/org/eclipse/cdt/lsp/internal/cquery/ui/PublishSemanticHighlighting.java index 54412edbcf0..83c72f1f3e3 100644 --- a/lsp/org.eclipse.cdt.lsp.cquery/src/org/eclipse/cdt/lsp/internal/cquery/ui/PublishSemanticHighlighting.java +++ b/lsp/org.eclipse.cdt.lsp.cquery/src/org/eclipse/cdt/lsp/internal/cquery/ui/PublishSemanticHighlighting.java @@ -57,7 +57,7 @@ public class PublishSemanticHighlighting implements Consumer currentReconcilerUri = uri.apply(currentReconcilerDoc); - if (currentReconcilerUri.isEmpty()) { + if (!currentReconcilerUri.isPresent()) { continue; } diff --git a/lsp/org.eclipse.cdt.lsp.ui/src/org/eclipse/cdt/lsp/internal/ui/text/SetInactiveRegions.java b/lsp/org.eclipse.cdt.lsp.ui/src/org/eclipse/cdt/lsp/internal/ui/text/SetInactiveRegions.java index 0912f7ed754..898dd031781 100644 --- a/lsp/org.eclipse.cdt.lsp.ui/src/org/eclipse/cdt/lsp/internal/ui/text/SetInactiveRegions.java +++ b/lsp/org.eclipse.cdt.lsp.ui/src/org/eclipse/cdt/lsp/internal/ui/text/SetInactiveRegions.java @@ -42,7 +42,7 @@ public final class SetInactiveRegions implements BiConsumer, Suppl for (PresentationReconcilerCPP eachReconciler : PresentationReconcilerCPP.presentationReconcilers) { IDocument currentReconcilerDoc = eachReconciler.getTextViewer().getDocument(); Optional currentReconcilerUri = resolve.apply(currentReconcilerDoc); - if (currentReconcilerUri.isEmpty()) { + if (!currentReconcilerUri.isPresent()) { continue; } if (uriReceived.equals(currentReconcilerUri.get())) {