Skip to content

Commit 648a8c7

Browse files
committed
fix(exts/devin-lang): remove CustomVariable class and refactor VariableProvider to use findLanguage method for language injection #101
The CustomVariable class was deleted as it was deemed unnecessary and introduced unnecessary complexity. The VariableProvider class was modified to use the findLanguage method from the util.parser.Code utility class to determine the language for code injection, eliminating the need for the CustomVariable class. This refactoring simplifies the language injection logic and improves the maintainability of the codebase.
1 parent 01506ed commit 648a8c7

File tree

3 files changed

+3
-21
lines changed

3 files changed

+3
-21
lines changed

exts/devin-lang/src/main/kotlin/cc/unitmesh/language/DevInLanguageInjector.kt

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

3+
import cc.unitmesh.devti.util.parser.Code.Companion.findLanguage
34
import cc.unitmesh.language.parser.CodeBlockElement
45
import cc.unitmesh.language.psi.DevInTypes
56
import com.intellij.lang.Language
@@ -8,7 +9,6 @@ import com.intellij.psi.InjectedLanguagePlaces
89
import com.intellij.psi.LanguageInjector
910
import com.intellij.psi.PsiLanguageInjectionHost
1011
import com.intellij.psi.util.elementType
11-
import org.intellij.plugins.markdown.injection.aliases.CodeFenceLanguageGuesser
1212

1313
class DevInLanguageInjector : LanguageInjector {
1414
override fun getLanguagesToInject(host: PsiLanguageInjectionHost, registrar: InjectedLanguagePlaces) {
@@ -23,7 +23,7 @@ class DevInLanguageInjector : LanguageInjector {
2323

2424
val languageIdentifier = host.getLanguageId()
2525
val text = languageIdentifier?.text ?: return
26-
val language = CodeFenceLanguageGuesser.guessLanguageForInjection(text) ?: return
26+
val language = findLanguage(text) ?: return
2727

2828
val contentList = CodeBlockElement.obtainFenceContent(host) ?: return
2929
if (contentList.isEmpty()) {

exts/devin-lang/src/main/kotlin/cc/unitmesh/language/completion/CustomVariable.kt

Lines changed: 0 additions & 19 deletions
This file was deleted.

exts/devin-lang/src/main/kotlin/cc/unitmesh/language/completion/VariableProvider.kt

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

3+
import cc.unitmesh.devti.custom.compile.CustomVariable
34
import com.intellij.codeInsight.completion.CompletionParameters
45
import com.intellij.codeInsight.completion.CompletionProvider
56
import com.intellij.codeInsight.completion.CompletionResultSet

0 commit comments

Comments
 (0)