Skip to content

Commit c757888

Browse files
committed
feat(completion): add DevInCompletionContributor and remove deprecated TypedHandler from plugin.xml #101
The `DevInCompletionContributor` class has been added to provide code completion functionality for the DevIn language. This includes the `VariableProvider` class to suggest variables during code completion. Additionally, the deprecated `TypedHandler` has been commented out and a new `completion.contributor` extension has been added to the plugin descriptor (`cc.unitmesh.language.xml`) to register the new completion contributor.
1 parent c3a7b94 commit c757888

File tree

3 files changed

+36
-1
lines changed

3 files changed

+36
-1
lines changed
Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,13 @@
1+
package cc.unitmesh.language
2+
3+
import cc.unitmesh.language.completion.VariableProvider
4+
import cc.unitmesh.language.psi.DevInTypes
5+
import com.intellij.codeInsight.completion.CompletionContributor
6+
import com.intellij.codeInsight.completion.CompletionType
7+
import com.intellij.patterns.PlatformPatterns.psiElement
8+
9+
class DevInCompletionContributor : CompletionContributor() {
10+
init {
11+
extend(CompletionType.BASIC, psiElement(DevInTypes.IDENTIFIER), VariableProvider())
12+
}
13+
}
Lines changed: 19 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,19 @@
1+
package cc.unitmesh.language.completion
2+
3+
import com.intellij.codeInsight.completion.CompletionParameters
4+
import com.intellij.codeInsight.completion.CompletionProvider
5+
import com.intellij.codeInsight.completion.CompletionResultSet
6+
import com.intellij.util.ProcessingContext
7+
8+
class VariableProvider: CompletionProvider<CompletionParameters>() {
9+
override fun addCompletions(
10+
parameters: CompletionParameters,
11+
context: ProcessingContext,
12+
result: CompletionResultSet,
13+
) {
14+
// CustomVariable.all.forEach {
15+
// result.addElement(it.toLookupElement())
16+
// }
17+
}
18+
19+
}

exts/devin-lang/src/main/resources/cc.unitmesh.language.xml

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -11,6 +11,9 @@
1111
<lang.ast.factory language="DevIn"
1212
implementationClass="cc.unitmesh.language.DevInAstFactory"/>
1313

14-
<typedHandler implementation="cc.unitmesh.language.DevInTypedHandler"/>
14+
<!-- <typedHandler implementation="cc.unitmesh.language.DevInTypedHandler"/>-->
15+
16+
<completion.contributor language="DevIn"
17+
implementationClass="cc.unitmesh.language.DevInCompletionContributor"/>
1518
</extensions>
1619
</idea-plugin>

0 commit comments

Comments
 (0)