You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
First of all, I'm not sure if it's a bug, or it's just the way LSON works (because I cannot really find a spec for it)
Now to the issue. Say we have the following code:
If I have code style that sets spaces after : (or before, or both) character, reformatting the code inserts spaces inside strings (respecting the current code style) which in turn looks like this :
The third case is formatted properly, because in context of object, colon is a separator between property name and value.
The second should remain string:string, because in context of array colon means nothing.
The first one should probably remain as it is. But it is interesting what should it look like, if it was originally written case1:string:string. Probably the most correct answer is it should be considered just as LibGDX JsonReader() considers it (cannot check it at the moment). But currently the plugin highlights case1:string:string as case1 - property string:string - string value.
Also it looks like { } [ ] , characters cause similar issues. Formatter does not consider context the character is written in.
The text was updated successfully, but these errors were encountered:
And one final note. In case1 and case2 after space inserted around colon, editor still considers string: string as a whole string
acanthite1855
changed the title
Reformatting code inserts spaces around ':' in string without qoutes
Reformatting LibGDX JSON code inserts spaces around ':' in string without qoutes
Dec 8, 2020
That is a bug: the plugin should ideally parse all JSON exactly as JsonReader does, but it currently can't handle :]} etc characters in unquoted value strings.
I have no idea how to fix that because JsonReader-tokens are context-sensitive. For example a : is allowed in unquoted value strings but not in unquoted keyword strings and a , is allowed in keys but not in unquoted value strings.
I can't reuse JsonReader in my plugin because IntelliJ needs the lexer and parser to be seperate (JsonReader mixes parsing and lexing) and it also needs an incremental lexer.
BTW my current lexer specification (Jflex) is here and the parser specification here.
First of all, I'm not sure if it's a bug, or it's just the way LSON works (because I cannot really find a spec for it)
Now to the issue. Say we have the following code:
If I have code style that sets spaces after
:
(or before, or both) character, reformatting the code inserts spaces inside strings (respecting the current code style) which in turn looks like this :The third case is formatted properly, because in context of object, colon is a separator between property name and value.
The second should remain
string:string
, because in context of array colon means nothing.The first one should probably remain as it is. But it is interesting what should it look like, if it was originally written
case1:string:string
. Probably the most correct answer is it should be considered just as LibGDX JsonReader() considers it (cannot check it at the moment). But currently the plugin highlightscase1:string:string
ascase1
- propertystring:string
- string value.Also it looks like
{ } [ ] ,
characters cause similar issues. Formatter does not consider context the character is written in.The text was updated successfully, but these errors were encountered: