mirror of
https://gitflic.ru/project/openide/openide.git
synced 2025-12-15 02:59:33 +07:00
json: allow empty .jsonl files (WEB-49403)
Also, allow empty .json files to make creating a new JSON file more pleasant. GitOrigin-RevId: 707361a11b025917c06758f5c058c144f18eee4f
This commit is contained in:
committed by
intellij-monorepo-bot
parent
626db253dc
commit
ec5f02f021
@@ -115,19 +115,15 @@ public class JsonParser implements PsiParser, LightPsiParser {
|
||||
}
|
||||
|
||||
/* ********************************************************** */
|
||||
// value+
|
||||
// value*
|
||||
static boolean json(PsiBuilder b, int l) {
|
||||
if (!recursion_guard_(b, l, "json")) return false;
|
||||
boolean r;
|
||||
Marker m = enter_section_(b);
|
||||
r = value(b, l + 1);
|
||||
while (r) {
|
||||
while (true) {
|
||||
int c = current_position_(b);
|
||||
if (!value(b, l + 1)) break;
|
||||
if (!empty_element_parsed_guard_(b, "json", c)) break;
|
||||
}
|
||||
exit_section_(b, m, null, r);
|
||||
return r;
|
||||
return true;
|
||||
}
|
||||
|
||||
/* ********************************************************** */
|
||||
|
||||
@@ -59,7 +59,8 @@
|
||||
}
|
||||
|
||||
// For compatibility we allow any value at root level (see JsonStandardComplianceAnnotator)
|
||||
json ::= value+
|
||||
// Empty file is also allowed
|
||||
json ::= value*
|
||||
|
||||
object ::= '{' object_element* '}' {
|
||||
pin=1
|
||||
|
||||
@@ -45,6 +45,16 @@ public class JsonHighlightingTest extends JsonHighlightingTestBase {
|
||||
doTestHighlightingForJsonLines(false, true, true);
|
||||
}
|
||||
|
||||
public void testJsonLinesEmptyFile() {
|
||||
enableStandardComplianceInspection(true, true);
|
||||
doTestHighlightingForJsonLines(false, true, true);
|
||||
}
|
||||
|
||||
public void testEmptyFile() {
|
||||
enableStandardComplianceInspection(true, true);
|
||||
doTestHighlighting(false, true, true);
|
||||
}
|
||||
|
||||
public void testDuplicatePropertyKeys() {
|
||||
myFixture.enableInspections(JsonDuplicatePropertyKeysInspection.class);
|
||||
doTestHighlighting(false, true, true);
|
||||
|
||||
0
json/tests/testData/highlighting/EmptyFile.json
Normal file
0
json/tests/testData/highlighting/EmptyFile.json
Normal file
Reference in New Issue
Block a user