diff --git a/app/build.gradle b/app/build.gradle index 113054a1f..5b98e2e27 100644 --- a/app/build.gradle +++ b/app/build.gradle @@ -145,9 +145,6 @@ dependencies { implementation project(':javapoet') implementation project(':lsp') - // LSP4J - implementation 'org.eclipse.lsp4j:org.eclipse.lsp4j:0.12.0' - implementation fileTree(dir: 'libs', include: ['*.jar']) coreLibraryDesugaring 'com.android.tools:desugar_jdk_libs:1.1.5' diff --git a/app/libs/android-retrostreams-and-retrofuture.jar b/app/libs/android-retrostreams-and-retrofuture.jar new file mode 100644 index 000000000..6eb00c60e Binary files /dev/null and b/app/libs/android-retrostreams-and-retrofuture.jar differ diff --git a/app/libs/lsp4j-android-desugared.jar b/app/libs/lsp4j-android-desugared.jar new file mode 100644 index 000000000..9f2352ae5 Binary files /dev/null and b/app/libs/lsp4j-android-desugared.jar differ diff --git a/app/src/main/java/com/itsaky/androidide/language/java/JavaAutoComplete.java b/app/src/main/java/com/itsaky/androidide/language/java/JavaAutoComplete.java index 9bedc33c7..6b03fb83c 100644 --- a/app/src/main/java/com/itsaky/androidide/language/java/JavaAutoComplete.java +++ b/app/src/main/java/com/itsaky/androidide/language/java/JavaAutoComplete.java @@ -9,7 +9,7 @@ import java.util.ArrayList; import java.util.Collections; import java.util.Comparator; import java.util.List; -import java.util.concurrent.CompletableFuture; +import java9.util.concurrent.CompletableFuture; import org.eclipse.lsp4j.CompletionItem; import org.eclipse.lsp4j.CompletionList; import org.eclipse.lsp4j.CompletionParams; diff --git a/app/src/main/java/com/itsaky/androidide/lsp/AbstractLanguageClient.java b/app/src/main/java/com/itsaky/androidide/lsp/AbstractLanguageClient.java index 291c6b15b..297f54665 100644 --- a/app/src/main/java/com/itsaky/androidide/lsp/AbstractLanguageClient.java +++ b/app/src/main/java/com/itsaky/androidide/lsp/AbstractLanguageClient.java @@ -35,7 +35,7 @@ import java.util.HashMap; import java.util.List; import java.util.Map; import java.util.stream.Collectors; -import java.util.concurrent.CompletableFuture; +import java9.util.concurrent.CompletableFuture; import org.eclipse.lsp4j.CodeAction; import org.eclipse.lsp4j.Command; import org.eclipse.lsp4j.Diagnostic; diff --git a/app/src/main/java/com/itsaky/androidide/lsp/LanguageServerWrapper.java b/app/src/main/java/com/itsaky/androidide/lsp/LanguageServerWrapper.java index ea93bef04..23f484861 100644 --- a/app/src/main/java/com/itsaky/androidide/lsp/LanguageServerWrapper.java +++ b/app/src/main/java/com/itsaky/androidide/lsp/LanguageServerWrapper.java @@ -7,7 +7,7 @@ import com.itsaky.lsp.services.IDETextDocumentService; import com.itsaky.lsp.services.IDEWorkspaceService; import java.util.Collections; import java.util.List; -import java.util.concurrent.CompletableFuture; +import java9.util.concurrent.CompletableFuture; import org.eclipse.lsp4j.CallHierarchyIncomingCall; import org.eclipse.lsp4j.CallHierarchyIncomingCallsParams; import org.eclipse.lsp4j.CallHierarchyItem; diff --git a/app/src/main/java/com/itsaky/androidide/lsp/client/java/JavaLanguageClient.java b/app/src/main/java/com/itsaky/androidide/lsp/client/java/JavaLanguageClient.java index 3a432fb87..12c59e864 100644 --- a/app/src/main/java/com/itsaky/androidide/lsp/client/java/JavaLanguageClient.java +++ b/app/src/main/java/com/itsaky/androidide/lsp/client/java/JavaLanguageClient.java @@ -2,7 +2,7 @@ package com.itsaky.androidide.lsp.client.java; import com.itsaky.androidide.lsp.AbstractLanguageClient; import java.util.List; -import java.util.concurrent.CompletableFuture; +import java9.util.concurrent.CompletableFuture; import org.eclipse.lsp4j.ApplyWorkspaceEditParams; import org.eclipse.lsp4j.ApplyWorkspaceEditResponse; import org.eclipse.lsp4j.ConfigurationParams; diff --git a/app/src/main/java/com/itsaky/androidide/lsp/handlers/JLSHandler.java b/app/src/main/java/com/itsaky/androidide/lsp/handlers/JLSHandler.java index 8da5894c7..e8d7bbb52 100644 --- a/app/src/main/java/com/itsaky/androidide/lsp/handlers/JLSHandler.java +++ b/app/src/main/java/com/itsaky/androidide/lsp/handlers/JLSHandler.java @@ -13,7 +13,7 @@ import java.io.File; import java.util.ArrayList; import java.util.List; import java.util.Optional; -import java.util.concurrent.CompletableFuture; +import java9.util.concurrent.CompletableFuture; import org.eclipse.lsp4j.InitializeParams; import org.eclipse.lsp4j.InitializeResult; import org.eclipse.lsp4j.InitializedParams; diff --git a/app/src/main/java/com/itsaky/androidide/lsp/providers/CodeActionProvider.java b/app/src/main/java/com/itsaky/androidide/lsp/providers/CodeActionProvider.java index 346e874d9..e6e2b70ea 100644 --- a/app/src/main/java/com/itsaky/androidide/lsp/providers/CodeActionProvider.java +++ b/app/src/main/java/com/itsaky/androidide/lsp/providers/CodeActionProvider.java @@ -3,7 +3,7 @@ package com.itsaky.androidide.lsp.providers; import com.itsaky.lsp.services.IDELanguageServer; import java.util.ArrayList; import java.util.List; -import java.util.concurrent.CompletableFuture; +import java9.util.concurrent.CompletableFuture; import org.eclipse.lsp4j.CodeAction; import org.eclipse.lsp4j.CodeActionContext; import org.eclipse.lsp4j.CodeActionParams; diff --git a/app/src/main/java/io/github/rosemoe/editor/widget/CodeEditor.java b/app/src/main/java/io/github/rosemoe/editor/widget/CodeEditor.java index a05c850c9..2a48376b6 100644 --- a/app/src/main/java/io/github/rosemoe/editor/widget/CodeEditor.java +++ b/app/src/main/java/io/github/rosemoe/editor/widget/CodeEditor.java @@ -103,7 +103,7 @@ import java.util.LinkedList; import java.util.List; import java.util.Map; import java.util.Set; -import java.util.concurrent.CompletableFuture; +import java9.util.concurrent.CompletableFuture; import org.eclipse.lsp4j.CodeAction; import org.eclipse.lsp4j.CodeActionOptions; import org.eclipse.lsp4j.Command; diff --git a/lsp/build.gradle b/lsp/build.gradle index 4bb21d874..d43d6259f 100644 --- a/lsp/build.gradle +++ b/lsp/build.gradle @@ -26,6 +26,4 @@ android { dependencies { implementation fileTree(dir: 'libs', include: ['*.jar']) implementation 'com.google.code.gson:gson:2.8.7' - implementation 'org.eclipse.lsp4j:org.eclipse.lsp4j:0.12.0' - implementation 'org.eclipse.lsp4j:org.eclipse.lsp4j.jsonrpc:0.12.0' } diff --git a/lsp/libs/android-retrostreams-and-retrofuture.jar b/lsp/libs/android-retrostreams-and-retrofuture.jar new file mode 100644 index 000000000..6eb00c60e Binary files /dev/null and b/lsp/libs/android-retrostreams-and-retrofuture.jar differ diff --git a/lsp/libs/lsp4j-android-desugared.jar b/lsp/libs/lsp4j-android-desugared.jar new file mode 100644 index 000000000..9f2352ae5 Binary files /dev/null and b/lsp/libs/lsp4j-android-desugared.jar differ diff --git a/lsp/src/main/java/com/itsaky/lsp/services/IDELanguageServer.java b/lsp/src/main/java/com/itsaky/lsp/services/IDELanguageServer.java index 71e9c89fc..0bb71e664 100644 --- a/lsp/src/main/java/com/itsaky/lsp/services/IDELanguageServer.java +++ b/lsp/src/main/java/com/itsaky/lsp/services/IDELanguageServer.java @@ -1,6 +1,6 @@ package com.itsaky.lsp.services; -import java.util.concurrent.CompletableFuture; +import java9.util.concurrent.CompletableFuture; import org.eclipse.lsp4j.InitializeParams; import org.eclipse.lsp4j.InitializeResult; diff --git a/lsp/src/main/java/com/itsaky/lsp/services/IDETextDocumentService.java b/lsp/src/main/java/com/itsaky/lsp/services/IDETextDocumentService.java index 998974dc6..5ba7dd690 100644 --- a/lsp/src/main/java/com/itsaky/lsp/services/IDETextDocumentService.java +++ b/lsp/src/main/java/com/itsaky/lsp/services/IDETextDocumentService.java @@ -1,7 +1,7 @@ package com.itsaky.lsp.services; import java.util.List; -import java.util.concurrent.CompletableFuture; +import java9.util.concurrent.CompletableFuture; import com.itsaky.lsp.SemanticHighlight; import com.itsaky.lsp.SemanticHighlightsParams; diff --git a/lsp/src/main/java/com/itsaky/lsp/services/IDEWorkspaceService.java b/lsp/src/main/java/com/itsaky/lsp/services/IDEWorkspaceService.java index edcc973f5..f2b4cc807 100644 --- a/lsp/src/main/java/com/itsaky/lsp/services/IDEWorkspaceService.java +++ b/lsp/src/main/java/com/itsaky/lsp/services/IDEWorkspaceService.java @@ -1,7 +1,7 @@ package com.itsaky.lsp.services; import java.util.List; -import java.util.concurrent.CompletableFuture; +import java9.util.concurrent.CompletableFuture; import org.eclipse.lsp4j.CreateFilesParams; import org.eclipse.lsp4j.DeleteFilesParams; diff --git a/lsp/src/main/java/java9/util/function/BiConsumer.java b/lsp/src/main/java/java9/util/function/BiConsumer.java new file mode 100644 index 000000000..b8d12fa42 --- /dev/null +++ b/lsp/src/main/java/java9/util/function/BiConsumer.java @@ -0,0 +1,75 @@ +/* + * Copyright (c) 2012, 2013, Oracle and/or its affiliates. All rights reserved. + * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. + * + * This code is free software; you can redistribute it and/or modify it + * under the terms of the GNU General Public License version 2 only, as + * published by the Free Software Foundation. Oracle designates this + * particular file as subject to the "Classpath" exception as provided + * by Oracle in the LICENSE file that accompanied this code. + * + * This code is distributed in the hope that it will be useful, but WITHOUT + * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or + * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License + * version 2 for more details (a copy is included in the LICENSE file that + * accompanied this code). + * + * You should have received a copy of the GNU General Public License version + * 2 along with this work; if not, write to the Free Software Foundation, + * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA. + * + * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA + * or visit www.oracle.com if you need additional information or have any + * questions. + */ +package java9.util.function; + +import java9.util.function.Consumer; +import java9.util.Objects; + +/** + * Represents an operation that accepts two input arguments and returns no + * result. This is the two-arity specialization of {@link Consumer}. + * Unlike most other functional interfaces, {@code BiConsumer} is expected + * to operate via side-effects. + * + *

This is a functional interface + * whose functional method is {@link #accept(Object, Object)}. + * + * @param the type of the first argument to the operation + * @param the type of the second argument to the operation + * + * @see Consumer + * @since 1.8 + */ +public interface BiConsumer { + + /** + * Performs this operation on the given arguments. + * + * @param t the first input argument + * @param u the second input argument + */ + void accept(T t, U u); + + /** + * Returns a composed {@code BiConsumer} that performs, in sequence, this + * operation followed by the {@code after} operation. If performing either + * operation throws an exception, it is relayed to the caller of the + * composed operation. If performing this operation throws an exception, + * the {@code after} operation will not be performed. + * + * @param after the operation to perform after this operation + * @return a composed {@code BiConsumer} that performs in sequence this + * operation followed by the {@code after} operation + * @throws NullPointerException if {@code after} is null + */ + default BiConsumer andThen(BiConsumer after) { + Objects.requireNonNull(after); + + return (l, r) -> { + accept(l, r); + after.accept(l, r); + }; + } +}