Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
@@ -1,8 +1,14 @@
package com.emberjs.glint

import com.emberjs.gts.GjsLanguage
import com.emberjs.gts.GtsFileViewProvider
import com.emberjs.gts.GtsLanguage
import com.intellij.codeInsight.daemon.impl.analysis.FileHighlightingSetting
import com.intellij.codeInsight.daemon.impl.analysis.HighlightingSettingsPerFile
import com.intellij.openapi.fileEditor.FileEditorManager
import com.intellij.openapi.fileEditor.FileEditorManagerListener
import com.intellij.openapi.vfs.VirtualFile
import com.intellij.psi.PsiManager

class GlintLanguageServiceFileEditorListener : FileEditorManagerListener {
override fun fileOpened(source: FileEditorManager, file: VirtualFile) {
Expand Down
10 changes: 5 additions & 5 deletions src/main/kotlin/com/emberjs/gts/GtsSupport.kt
Original file line number Diff line number Diff line change
Expand Up @@ -47,9 +47,7 @@ import com.intellij.lang.xml.XmlFormattingModel
import com.intellij.lexer.HtmlLexer
import com.intellij.lexer.Lexer
import com.intellij.lexer.LookAheadLexer
import com.intellij.openapi.editor.Document
import com.intellij.openapi.editor.Editor
import com.intellij.openapi.editor.actions.lists.TrailingComma
import com.intellij.openapi.editor.colors.EditorColorsScheme
import com.intellij.openapi.editor.ex.util.LayerDescriptor
import com.intellij.openapi.editor.ex.util.LayeredLexerEditorHighlighter
Expand Down Expand Up @@ -99,6 +97,7 @@ val JS: JSLanguageDialect = JavaScriptSupportLoader.ECMA_SCRIPT_6

open class GtsLanguage(val lang: JSLanguageDialect = TS, id: String ="Gts") : Language(lang, id) {
public var fileElementType: JSFileElementType? = null

override fun <T : Any?> getUserData(key: Key<T>): T? {
if (key.toString() == "js.file.element.type") {
return fileElementType as T?
Expand All @@ -114,7 +113,7 @@ open class GtsLanguage(val lang: JSLanguageDialect = TS, id: String ="Gts") : La
}

companion object {
val INSTANCE = GtsLanguage()
val INSTANCE = GtsLanguage(TS)
}
}

Expand All @@ -135,8 +134,6 @@ class GtsFile(viewProvider: FileViewProvider?, val isJS: Boolean =false)
override fun toString(): String {
return "GTS File"
}


}


Expand Down Expand Up @@ -397,6 +394,9 @@ class GtsFileType : LanguageFileType(GtsLanguage.INSTANCE) {
if (other == TypeScriptFileType) {
return true
}
if (other == JavaScriptFileType) {
return true
}
return super.equals(other)
}

Expand Down
26 changes: 26 additions & 0 deletions src/test/kotlin/com/emberjs/gts/GtsFileTest.kt
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,10 @@ package com.emberjs.hbs
import com.emberjs.gts.GjsFileType
import com.emberjs.gts.GtsFileType
import com.intellij.codeInsight.daemon.impl.HighlightInfo
import com.intellij.lang.javascript.BasicDialectDetector
import com.intellij.lang.javascript.JavaScriptSupportLoader
import com.intellij.lang.javascript.inspections.ES6UnusedImportsInspection
import com.intellij.lang.javascript.inspections.JSLastCommaInObjectLiteralInspection
import com.intellij.lang.javascript.inspections.JSUnusedGlobalSymbolsInspection
import com.intellij.lang.javascript.inspections.JSUnusedLocalSymbolsInspection
import com.intellij.lang.javascript.psi.impl.JSFileImpl
Expand Down Expand Up @@ -121,4 +124,27 @@ class GtsFileTest : BasePlatformTestCase() {
TestCase.assertTrue(highlightInfos.first().description.contains("quux"))
TestCase.assertTrue(highlightInfos.last().description.contains("qux"))
}

@Test
fun testGtsTrailingCommaAllowed() {
val gts = """
const a = {
a: 1,
b: 2,
}
""".trimIndent()
myFixture.addFileToProject("main.gts", gts)
myFixture.configureByFile("main.gts")
myFixture.enableInspections(JSLastCommaInObjectLiteralInspection())
try {
CodeInsightTestFixtureImpl.ensureIndexesUpToDate(project)
} catch (exception: Exception) {

}

val highlighting = myFixture.doHighlighting()
System.out.println(highlighting)
val noCommaAllowed = highlighting.filter { it.description?.contains("comma") == true }
TestCase.assertEquals(noCommaAllowed.toString(), 0, noCommaAllowed.size)
}
}
Loading