Skip to content

Commit

Permalink
feat(completion): add DevInCompletionContributor and remove deprecate…
Browse files Browse the repository at this point in the history
…d 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.
  • Loading branch information
phodal committed Mar 11, 2024
1 parent c3a7b94 commit c757888
Show file tree
Hide file tree
Showing 3 changed files with 36 additions and 1 deletion.
@@ -0,0 +1,13 @@
package cc.unitmesh.language

import cc.unitmesh.language.completion.VariableProvider
import cc.unitmesh.language.psi.DevInTypes
import com.intellij.codeInsight.completion.CompletionContributor
import com.intellij.codeInsight.completion.CompletionType
import com.intellij.patterns.PlatformPatterns.psiElement

class DevInCompletionContributor : CompletionContributor() {
init {
extend(CompletionType.BASIC, psiElement(DevInTypes.IDENTIFIER), VariableProvider())
}
}
@@ -0,0 +1,19 @@
package cc.unitmesh.language.completion

import com.intellij.codeInsight.completion.CompletionParameters
import com.intellij.codeInsight.completion.CompletionProvider
import com.intellij.codeInsight.completion.CompletionResultSet
import com.intellij.util.ProcessingContext

class VariableProvider: CompletionProvider<CompletionParameters>() {
override fun addCompletions(
parameters: CompletionParameters,
context: ProcessingContext,
result: CompletionResultSet,
) {
// CustomVariable.all.forEach {
// result.addElement(it.toLookupElement())
// }
}

}
5 changes: 4 additions & 1 deletion exts/devin-lang/src/main/resources/cc.unitmesh.language.xml
Expand Up @@ -11,6 +11,9 @@
<lang.ast.factory language="DevIn"
implementationClass="cc.unitmesh.language.DevInAstFactory"/>

<typedHandler implementation="cc.unitmesh.language.DevInTypedHandler"/>
<!-- <typedHandler implementation="cc.unitmesh.language.DevInTypedHandler"/>-->

<completion.contributor language="DevIn"
implementationClass="cc.unitmesh.language.DevInCompletionContributor"/>
</extensions>
</idea-plugin>

0 comments on commit c757888

Please sign in to comment.