mirror of
https://github.com/eclipse-cdt/cdt
synced 2025-04-22 06:02:11 +02:00
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 <alexander.fedorov@arsysop.ru>
This commit is contained in:
parent
e4e1f6780d
commit
147ff5a482
3 changed files with 6 additions and 6 deletions
|
@ -13,7 +13,7 @@
|
||||||
*******************************************************************************/
|
*******************************************************************************/
|
||||||
package org.eclipse.cdt.lsp.text.tests;
|
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.cdt.lsp.internal.text.ResolveDocumentUri;
|
||||||
import org.eclipse.core.filebuffers.FileBuffers;
|
import org.eclipse.core.filebuffers.FileBuffers;
|
||||||
|
@ -32,14 +32,14 @@ public class ResolveDocumentUriTest {
|
||||||
|
|
||||||
@Test
|
@Test
|
||||||
public void emptyDocument() {
|
public void emptyDocument() {
|
||||||
assertTrue(uri.apply(new Document()).isEmpty());
|
assertFalse(uri.apply(new Document()).isPresent());
|
||||||
}
|
}
|
||||||
|
|
||||||
@Test
|
@Test
|
||||||
public void externalDocument() {
|
public void externalDocument() {
|
||||||
Document document = new Document();
|
Document document = new Document();
|
||||||
FileBuffers.createTextFileBufferManager().createEmptyDocument(new Path("some.c"), LocationKind.LOCATION);
|
FileBuffers.createTextFileBufferManager().createEmptyDocument(new Path("some.c"), LocationKind.LOCATION);
|
||||||
assertTrue(uri.apply(document).isEmpty());
|
assertFalse(uri.apply(document).isPresent());
|
||||||
}
|
}
|
||||||
|
|
||||||
@Test
|
@Test
|
||||||
|
@ -47,7 +47,7 @@ public class ResolveDocumentUriTest {
|
||||||
Document document = new Document();
|
Document document = new Document();
|
||||||
FileBuffers.createTextFileBufferManager().createEmptyDocument(new Path("some.c"), LocationKind.LOCATION);
|
FileBuffers.createTextFileBufferManager().createEmptyDocument(new Path("some.c"), LocationKind.LOCATION);
|
||||||
//it's a pity! see https://bugs.eclipse.org/bugs/show_bug.cgi?id=566044
|
//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());
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
|
@ -57,7 +57,7 @@ public class PublishSemanticHighlighting implements Consumer<CquerySemanticHighl
|
||||||
for (PresentationReconcilerCPP eachReconciler : PresentationReconcilerCPP.presentationReconcilers) {
|
for (PresentationReconcilerCPP eachReconciler : PresentationReconcilerCPP.presentationReconcilers) {
|
||||||
IDocument currentReconcilerDoc = eachReconciler.getTextViewer().getDocument();
|
IDocument currentReconcilerDoc = eachReconciler.getTextViewer().getDocument();
|
||||||
Optional<URI> currentReconcilerUri = uri.apply(currentReconcilerDoc);
|
Optional<URI> currentReconcilerUri = uri.apply(currentReconcilerDoc);
|
||||||
if (currentReconcilerUri.isEmpty()) {
|
if (!currentReconcilerUri.isPresent()) {
|
||||||
continue;
|
continue;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -42,7 +42,7 @@ public final class SetInactiveRegions implements BiConsumer<Supplier<URI>, Suppl
|
||||||
for (PresentationReconcilerCPP eachReconciler : PresentationReconcilerCPP.presentationReconcilers) {
|
for (PresentationReconcilerCPP eachReconciler : PresentationReconcilerCPP.presentationReconcilers) {
|
||||||
IDocument currentReconcilerDoc = eachReconciler.getTextViewer().getDocument();
|
IDocument currentReconcilerDoc = eachReconciler.getTextViewer().getDocument();
|
||||||
Optional<URI> currentReconcilerUri = resolve.apply(currentReconcilerDoc);
|
Optional<URI> currentReconcilerUri = resolve.apply(currentReconcilerDoc);
|
||||||
if (currentReconcilerUri.isEmpty()) {
|
if (!currentReconcilerUri.isPresent()) {
|
||||||
continue;
|
continue;
|
||||||
}
|
}
|
||||||
if (uriReceived.equals(currentReconcilerUri.get())) {
|
if (uriReceived.equals(currentReconcilerUri.get())) {
|
||||||
|
|
Loading…
Add table
Reference in a new issue