Skip to content

Commit 1dc1fa2

Browse files
committed
feat(completion): replace DevInsCompletionProvider with DevInsSymbolProvider #101
This commit replaces all instances of `DevInsCompletionProvider` with `DevInsSymbolProvider`.
1 parent d00d5a0 commit 1dc1fa2

File tree

5 files changed

+19
-10
lines changed

5 files changed

+19
-10
lines changed

exts/devins-lang/src/main/kotlin/cc/unitmesh/devti/language/completion/SymbolReferenceLanguageProvider.kt

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
package cc.unitmesh.devti.language.completion
22

3-
import cc.unitmesh.devti.provider.devins.DevInsCompletionProvider
3+
import cc.unitmesh.devti.provider.devins.DevInsSymbolProvider
44
import com.intellij.codeInsight.completion.CompletionParameters
55
import com.intellij.codeInsight.completion.CompletionProvider
66
import com.intellij.codeInsight.completion.CompletionResultSet
@@ -12,7 +12,7 @@ class SymbolReferenceLanguageProvider : CompletionProvider<CompletionParameters>
1212
context: ProcessingContext,
1313
result: CompletionResultSet
1414
) {
15-
DevInsCompletionProvider.all().forEach { completionProvider ->
15+
DevInsSymbolProvider.all().forEach { completionProvider ->
1616
val elements = completionProvider.lookupSymbol(parameters.editor.project!!, parameters, result)
1717
elements.forEach {
1818
result.addElement(it)

java/src/main/kotlin/cc/unitmesh/idea/provider/JavaCustomDevInsCompletionProvider.kt renamed to java/src/main/kotlin/cc/unitmesh/idea/provider/JavaCustomDevInsSymbolProvider.kt

Lines changed: 2 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
package cc.unitmesh.idea.provider
22

3-
import cc.unitmesh.devti.provider.devins.DevInsCompletionProvider
3+
import cc.unitmesh.devti.provider.devins.DevInsSymbolProvider
44
import com.intellij.codeInsight.completion.*
55
import com.intellij.codeInsight.lookup.LookupElement
66
import com.intellij.codeInsight.lookup.LookupElementBuilder
@@ -13,8 +13,7 @@ import com.intellij.psi.search.ProjectScope
1313
import com.intellij.psi.util.PsiTreeUtil
1414
import com.intellij.util.SmartList
1515

16-
class JavaCustomDevInsCompletionProvider : DevInsCompletionProvider {
17-
16+
class JavaCustomDevInsSymbolProvider : DevInsSymbolProvider {
1817
override fun lookupSymbol(
1918
project: Project,
2019
parameters: CompletionParameters,

java/src/main/resources/cc.unitmesh.idea.xml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -62,7 +62,7 @@
6262
</autoDevIntention>
6363

6464
<customDevInsCompletionProvider
65-
implementation="cc.unitmesh.idea.provider.JavaCustomDevInsCompletionProvider"/>
65+
implementation="cc.unitmesh.idea.provider.JavaCustomDevInsSymbolProvider"/>
6666
</extensions>
6767

6868
<extensions defaultExtensionNs="com.intellij">

src/233/main/resources/META-INF/autodev-core.xml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -165,7 +165,7 @@
165165
dynamic="true"/>
166166

167167
<extensionPoint qualifiedName="cc.unitmesh.customDevInsCompletionProvider"
168-
interface="cc.unitmesh.devti.provider.devins.DevInsCompletionProvider"
168+
interface="cc.unitmesh.devti.provider.devins.DevInsSymbolProvider"
169169
dynamic="true"/>
170170
</extensionPoints>
171171

src/main/kotlin/cc/unitmesh/devti/provider/devins/DevInsCompletionProvider.kt renamed to src/main/kotlin/cc/unitmesh/devti/provider/devins/DevInsSymbolProvider.kt

Lines changed: 13 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,17 @@ import com.intellij.codeInsight.lookup.LookupElement
66
import com.intellij.openapi.extensions.ExtensionPointName
77
import com.intellij.openapi.project.Project
88

9-
interface DevInsCompletionProvider {
9+
/**
10+
* The symbol provider for DevIns completion and execution
11+
* - Completion will be triggered by like `/symbol:`, and the symbol provider will provide the completion for the symbol.
12+
* - Execution will be triggered by like `/symbol:java.lang.String`, all load children level elements, like `java.lang.String#length()`
13+
*
14+
* For execution:
15+
* - If parent is Root, the children will be packages
16+
* - If parent is Package, the children will be classes
17+
* - If parent is Class, the children will be methods and fields
18+
*/
19+
interface DevInsSymbolProvider {
1020

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

2030
companion object {
21-
private val EP_NAME: ExtensionPointName<DevInsCompletionProvider> =
31+
private val EP_NAME: ExtensionPointName<DevInsSymbolProvider> =
2232
ExtensionPointName("cc.unitmesh.customDevInsCompletionProvider")
2333

24-
fun all(): List<DevInsCompletionProvider> {
34+
fun all(): List<DevInsSymbolProvider> {
2535
return EP_NAME.extensionList
2636
}
2737
}

0 commit comments

Comments
 (0)