Closed desaikd closed 3 months ago
Thanks for tackling this!
Regarding Removes treating first element as operator in SExp, there are some people who like to use lisp-style formatting for SExpressions in Ion. Could we keep it, but make it conditional based on some setting? Perhaps using something like this?
I don't understand the goal of this PR. While not ideal, the current format-file behavior is better than the proposed change.
S-expressions are intended to be used for code and should follow Lisp-like formatting by default. There's a lot one could say about the topic, but at minimum it should keep the first child element adjacent to the opening paren, and any line-breaks inside should have at least one level of indentation relative to the opening paren.
As per the review comments and the original implementation that used lisp style formatting, I am reverting the previous commit https://github.com/amazon-ion/ion-intellij-plugin/pull/65/commits/c489a4ed70fb6807c4ad3407efc1240caf2cb23e. This PR still fixes some of the indentation and line break issue as described in Before fix
example of the PR description. I have also created an issue to look into making an optional setting for sexpression formatting either Lisp style(default) or similar to list formatting.
As per the current implementation following is the After fix example:
{
foo: "This is Foo",
bar: (bar
{
bar: "This is bar"
}
"bar"
),
baz: [
(baz
"baz"
),
BAZ,
Baz
]
}
Issue #64
Description of changes: This PR fixes SExpression formatting
Example: Sample Ion data(without any formatting):
Before the fix(After running code formatter from IDE):
After the fix(After running code formatter from IDE):
List of changes:
VALUE
IonSExpressionBlock
to considerSEXPRESSION_ATOM
as children as per BNF grammarIonCodeBlockSpacing
to correctly considerSEXPRESSION_ATOM
as children as per BNF grammargenerate parser
based on BNF grmmarTest: Tested with gradle build task that runs all the tests. Also ran
buildPlugin
andrunIde
tasks.By submitting this pull request, I confirm that my contribution is made under the terms of the Apache 2.0 license.