diff --git a/editor/src/main/java/com/itsaky/androidide/editor/language/IDELanguage.java b/editor/src/main/java/com/itsaky/androidide/editor/language/IDELanguage.java index 6b7f58b10..47e273d4f 100644 --- a/editor/src/main/java/com/itsaky/androidide/editor/language/IDELanguage.java +++ b/editor/src/main/java/com/itsaky/androidide/editor/language/IDELanguage.java @@ -19,6 +19,7 @@ package com.itsaky.androidide.editor.language; import android.os.Bundle; import androidx.annotation.NonNull; import com.itsaky.androidide.editor.api.IEditor; +import com.itsaky.androidide.editor.ui.IDECompletionPublisher; import com.itsaky.androidide.lookup.Lookup; import com.itsaky.androidide.lsp.api.ILanguageServer; import com.itsaky.androidide.preferences.internal.EditorPreferencesKt; @@ -84,7 +85,8 @@ public abstract class IDELanguage implements Language { completionProvider.complete(content, file, position, this::checkIsCompletionChar); publisher.setUpdateThreshold(1); - publisher.addItems(new ArrayList<>(completionItems)); + + ((IDECompletionPublisher) publisher).addLSPItems(completionItems); } protected ILanguageServer getLanguageServer() { diff --git a/editor/src/main/java/com/itsaky/androidide/editor/ui/EditorCompletionWindow.kt b/editor/src/main/java/com/itsaky/androidide/editor/ui/EditorCompletionWindow.kt index 6837ed752..fbecab441 100644 --- a/editor/src/main/java/com/itsaky/androidide/editor/ui/EditorCompletionWindow.kt +++ b/editor/src/main/java/com/itsaky/androidide/editor/ui/EditorCompletionWindow.kt @@ -123,7 +123,7 @@ class EditorCompletionWindow(val editor: IDEEditor) : EditorAutoCompletion(edito currentSelection = -1 publisher = - CompletionPublisher( + IDECompletionPublisher( editor.handler, { val items = publisher.items diff --git a/editor/src/main/java/com/itsaky/androidide/editor/ui/IDECompletionPublisher.kt b/editor/src/main/java/com/itsaky/androidide/editor/ui/IDECompletionPublisher.kt new file mode 100644 index 000000000..21bc6437c --- /dev/null +++ b/editor/src/main/java/com/itsaky/androidide/editor/ui/IDECompletionPublisher.kt @@ -0,0 +1,45 @@ +/* + * This file is part of AndroidIDE. + * + * AndroidIDE is free software: you can redistribute it and/or modify + * it under the terms of the GNU General Public License as published by + * the Free Software Foundation, either version 3 of the License, or + * (at your option) any later version. + * + * AndroidIDE 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 for more details. + * + * You should have received a copy of the GNU General Public License + * along with AndroidIDE. If not, see . + */ + +package com.itsaky.androidide.editor.ui + +import android.os.Handler +import io.github.rosemoe.sora.lang.completion.CompletionItem +import io.github.rosemoe.sora.lang.completion.CompletionPublisher + +/** + * [CompletionPublisher] implementation for AndroidIDE. + * + * @author Akash Yadav + */ +class IDECompletionPublisher( + handler: Handler, + callback: Runnable, + languageInterruptionLevel: Int +) : CompletionPublisher(handler, callback, languageInterruptionLevel) { + + init { + setUpdateThreshold(1) + } + + /** + * Adds the given [completion items][items] to the completion list. + */ + fun addLSPItems(items: Collection) { + super.addItems(items) + } +} \ No newline at end of file