WEB-53334: useless filetype removed; jsonc compliance problems test added

GitOrigin-RevId: c8c46880e28686595db3249c375d0ffb8f89cd00
This commit is contained in:
Alex Bashkatov
2023-06-27 16:39:12 +00:00
committed by intellij-monorepo-bot
parent 62f4e8bf36
commit 635a04ce33
5 changed files with 17 additions and 19 deletions

View File

@@ -188,6 +188,8 @@
<bundleName>messages.JsonBundle</bundleName>
<categoryKey>json.intention.category.name</categoryKey>
</intentionAction>
<json.jsonStandardComplianceProvider implementation="com.intellij.json.jsonc.JsoncComplianceProvider"/>
</extensions>
<extensions defaultExtensionNs="JavaScript">

View File

@@ -3,10 +3,15 @@ package com.intellij.json.jsonc
import com.intellij.json.codeinsight.JsonStandardComplianceProvider
import com.intellij.psi.PsiComment
import com.intellij.psi.util.PsiUtilCore
class JsoncComplianceProvider : JsonStandardComplianceProvider() {
private val JSONC_DEFAULT_EXTENSION = "jsonc"
override fun isCommentAllowed(comment: PsiComment): Boolean {
if (comment.containingFile.virtualFile.nameSequence.endsWith(JsoncFileType.DEFAULT_EXTENSION)) {
val virtualFile = PsiUtilCore.getVirtualFile(comment)
if (virtualFile?.extension == JSONC_DEFAULT_EXTENSION) {
return true
}

View File

@@ -1,18 +0,0 @@
// Copyright 2000-2023 JetBrains s.r.o. and contributors. Use of this source code is governed by the Apache 2.0 license.
package com.intellij.json.jsonc
import com.intellij.json.JsonFileType
class JsoncFileType : JsonFileType() {
companion object {
val DEFAULT_EXTENSION = "jsonc"
}
override fun getName(): String {
return "JSONC"
}
override fun getDefaultExtension(): String {
return DEFAULT_EXTENSION
}
}

View File

@@ -12,4 +12,9 @@ class JsoncHighlightingTest : JsonHighlightingTestBase() {
myFixture.enableInspections(JsonStandardComplianceInspection())
doTestHighlighting(false, true, true)
}
fun testJsoncComplianceProblems() {
myFixture.enableInspections(JsonStandardComplianceInspection())
doTestHighlighting(false, true, true)
}
}

View File

@@ -0,0 +1,4 @@
{
"key1": "foo",
<error descr="JSON standard allows only double quoted string as property key"><error descr="JSON standard does not allow single quoted strings">'key2'</error></error>: null
}