Skip to content

Commit

Permalink
feat(completion): replace DevInsCompletionProvider with DevInsSymbolP…
Browse files Browse the repository at this point in the history
…rovider #101

This commit replaces all instances of `DevInsCompletionProvider` with `DevInsSymbolProvider`.
  • Loading branch information
phodal committed Mar 18, 2024
1 parent d00d5a0 commit 1dc1fa2
Show file tree
Hide file tree
Showing 5 changed files with 19 additions and 10 deletions.
@@ -1,6 +1,6 @@
package cc.unitmesh.devti.language.completion

import cc.unitmesh.devti.provider.devins.DevInsCompletionProvider
import cc.unitmesh.devti.provider.devins.DevInsSymbolProvider
import com.intellij.codeInsight.completion.CompletionParameters
import com.intellij.codeInsight.completion.CompletionProvider
import com.intellij.codeInsight.completion.CompletionResultSet
Expand All @@ -12,7 +12,7 @@ class SymbolReferenceLanguageProvider : CompletionProvider<CompletionParameters>
context: ProcessingContext,
result: CompletionResultSet
) {
DevInsCompletionProvider.all().forEach { completionProvider ->
DevInsSymbolProvider.all().forEach { completionProvider ->
val elements = completionProvider.lookupSymbol(parameters.editor.project!!, parameters, result)
elements.forEach {
result.addElement(it)
Expand Down
@@ -1,6 +1,6 @@
package cc.unitmesh.idea.provider

import cc.unitmesh.devti.provider.devins.DevInsCompletionProvider
import cc.unitmesh.devti.provider.devins.DevInsSymbolProvider
import com.intellij.codeInsight.completion.*
import com.intellij.codeInsight.lookup.LookupElement
import com.intellij.codeInsight.lookup.LookupElementBuilder
Expand All @@ -13,8 +13,7 @@ import com.intellij.psi.search.ProjectScope
import com.intellij.psi.util.PsiTreeUtil
import com.intellij.util.SmartList

class JavaCustomDevInsCompletionProvider : DevInsCompletionProvider {

class JavaCustomDevInsSymbolProvider : DevInsSymbolProvider {
override fun lookupSymbol(
project: Project,
parameters: CompletionParameters,
Expand Down
2 changes: 1 addition & 1 deletion java/src/main/resources/cc.unitmesh.idea.xml
Expand Up @@ -62,7 +62,7 @@
</autoDevIntention>

<customDevInsCompletionProvider
implementation="cc.unitmesh.idea.provider.JavaCustomDevInsCompletionProvider"/>
implementation="cc.unitmesh.idea.provider.JavaCustomDevInsSymbolProvider"/>
</extensions>

<extensions defaultExtensionNs="com.intellij">
Expand Down
2 changes: 1 addition & 1 deletion src/233/main/resources/META-INF/autodev-core.xml
Expand Up @@ -165,7 +165,7 @@
dynamic="true"/>

<extensionPoint qualifiedName="cc.unitmesh.customDevInsCompletionProvider"
interface="cc.unitmesh.devti.provider.devins.DevInsCompletionProvider"
interface="cc.unitmesh.devti.provider.devins.DevInsSymbolProvider"
dynamic="true"/>
</extensionPoints>

Expand Down
Expand Up @@ -6,7 +6,17 @@ import com.intellij.codeInsight.lookup.LookupElement
import com.intellij.openapi.extensions.ExtensionPointName
import com.intellij.openapi.project.Project

interface DevInsCompletionProvider {
/**
* The symbol provider for DevIns completion and execution
* - Completion will be triggered by like `/symbol:`, and the symbol provider will provide the completion for the symbol.
* - Execution will be triggered by like `/symbol:java.lang.String`, all load children level elements, like `java.lang.String#length()`
*
* For execution:
* - If parent is Root, the children will be packages
* - If parent is Package, the children will be classes
* - If parent is Class, the children will be methods and fields
*/
interface DevInsSymbolProvider {

/**
* Lookup canonical name for different language
Expand All @@ -18,10 +28,10 @@ interface DevInsCompletionProvider {
): Iterable<LookupElement>

companion object {
private val EP_NAME: ExtensionPointName<DevInsCompletionProvider> =
private val EP_NAME: ExtensionPointName<DevInsSymbolProvider> =
ExtensionPointName("cc.unitmesh.customDevInsCompletionProvider")

fun all(): List<DevInsCompletionProvider> {
fun all(): List<DevInsSymbolProvider> {
return EP_NAME.extensionList
}
}
Expand Down

0 comments on commit 1dc1fa2

Please sign in to comment.