Skip to content

Commit f3a7182

Browse files
committed
fix bad inspections like trailing comma
1 parent 0b50e51 commit f3a7182

File tree

2 files changed

+34
-1
lines changed

2 files changed

+34
-1
lines changed

src/main/kotlin/com/emberjs/glint/GlintLanguageServiceFileEditorListener.kt

Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,11 +1,24 @@
11
package com.emberjs.glint
22

3+
import com.emberjs.gts.GjsLanguage
4+
import com.emberjs.gts.GtsFileViewProvider
5+
import com.emberjs.gts.GtsLanguage
6+
import com.intellij.codeInsight.daemon.impl.analysis.FileHighlightingSetting
7+
import com.intellij.codeInsight.daemon.impl.analysis.HighlightingSettingsPerFile
38
import com.intellij.openapi.fileEditor.FileEditorManager
49
import com.intellij.openapi.fileEditor.FileEditorManagerListener
510
import com.intellij.openapi.vfs.VirtualFile
11+
import com.intellij.psi.PsiManager
612

713
class GlintLanguageServiceFileEditorListener : FileEditorManagerListener {
814
override fun fileOpened(source: FileEditorManager, file: VirtualFile) {
15+
val highlighter = HighlightingSettingsPerFile.getInstance(source.project)
16+
val fileManager = PsiManager.getInstance(source.project)
17+
val f = fileManager.findFile(file) ?: return
18+
if (f.viewProvider is GtsFileViewProvider) {
19+
val root = f.viewProvider.getPsi(GtsLanguage.INSTANCE) ?: f.viewProvider.getPsi(GjsLanguage.INSTANCE)
20+
highlighter.setHighlightingSettingForRoot(root, FileHighlightingSetting.SKIP_INSPECTION)
21+
}
922
val project = source.project
1023
val provider = GlintLanguageServiceProvider(project)
1124
openEditorIfFileRelevant(file, provider)

src/main/kotlin/com/emberjs/gts/GtsSupport.kt

Lines changed: 21 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -13,6 +13,7 @@ import com.emberjs.index.EmberNameIndex
1313
import com.emberjs.resolver.EmberName
1414
import com.emberjs.utils.EmberUtils
1515
import com.emberjs.utils.ifTrue
16+
import com.intellij.extapi.psi.PsiFileBase
1617
import com.intellij.formatting.*
1718
import com.intellij.formatting.templateLanguages.DataLanguageBlockWrapper
1819
import com.intellij.lang.*
@@ -25,9 +26,11 @@ import com.intellij.lang.javascript.*
2526
import com.intellij.lang.javascript.config.JSImportResolveContext
2627
import com.intellij.lang.javascript.dialects.ECMA6ParserDefinition
2728
import com.intellij.lang.javascript.dialects.TypeScriptParserDefinition
29+
import com.intellij.lang.javascript.ecmascript6.TypeScriptAnnotatingVisitor
2830
import com.intellij.lang.javascript.editing.JavascriptCommenter
2931
import com.intellij.lang.javascript.formatter.JavascriptFormattingModelBuilder
3032
import com.intellij.lang.javascript.highlighting.JSHighlighter
33+
import com.intellij.lang.javascript.highlighting.JSSemanticHighlightingVisitor
3134
import com.intellij.lang.javascript.index.IndexedFileTypeProvider
3235
import com.intellij.lang.javascript.modules.JSImportCandidateDescriptor
3336
import com.intellij.lang.javascript.modules.JSImportPlaceInfo
@@ -41,6 +44,9 @@ import com.intellij.lang.javascript.psi.*
4144
import com.intellij.lang.javascript.psi.ecmal4.JSClass
4245
import com.intellij.lang.javascript.psi.impl.JSFileImpl
4346
import com.intellij.lang.javascript.types.JSFileElementType
47+
import com.intellij.lang.javascript.validation.JSAnnotatingVisitor
48+
import com.intellij.lang.javascript.validation.JSAnnotator
49+
import com.intellij.lang.javascript.validation.TypeScriptKeywordHighlighterVisitor
4450
import com.intellij.lang.typescript.tsconfig.*
4551
import com.intellij.lang.xml.XMLLanguage
4652
import com.intellij.lang.xml.XmlFormattingModel
@@ -49,7 +55,6 @@ import com.intellij.lexer.Lexer
4955
import com.intellij.lexer.LookAheadLexer
5056
import com.intellij.openapi.editor.Document
5157
import com.intellij.openapi.editor.Editor
52-
import com.intellij.openapi.editor.actions.lists.TrailingComma
5358
import com.intellij.openapi.editor.colors.EditorColorsScheme
5459
import com.intellij.openapi.editor.ex.util.LayerDescriptor
5560
import com.intellij.openapi.editor.ex.util.LayeredLexerEditorHighlighter
@@ -137,6 +142,21 @@ class GtsFile(viewProvider: FileViewProvider?, val isJS: Boolean =false)
137142
}
138143

139144

145+
override fun accept(visitor: PsiElementVisitor) {
146+
if (visitor is JSSemanticHighlightingVisitor) {
147+
return
148+
}
149+
if (visitor is TypeScriptAnnotatingVisitor) {
150+
return
151+
}
152+
if (visitor is TypeScriptKeywordHighlighterVisitor) {
153+
return
154+
}
155+
if (visitor is JSAnnotatingVisitor) {
156+
return
157+
}
158+
super.accept(visitor)
159+
}
140160
}
141161

142162

0 commit comments

Comments
 (0)