Skip to content

Commit

Permalink
Fixes SExpression formatting (#65)
Browse files Browse the repository at this point in the history
* Changes SExpression children to use `SEXPRESSION_ATOM` instead of `VALUE`
* Adds changes in `IonSExpressionBlock` to consider `SEXPRESSION_ATOM`
as children as per BNF grammar
* Adds changes in `IonCodeBlockSpacing` to correctly consider
`SEXPRESSION_ATOM` as children as per BNF grammar
* Adds changes in tests for usign correct node names
* Adds changes for PR workflow to run Gradle Build task
  • Loading branch information
desaikd authored Jun 11, 2024
1 parent c2ebad3 commit 36f8093
Show file tree
Hide file tree
Showing 9 changed files with 53 additions and 44 deletions.
4 changes: 4 additions & 0 deletions .github/workflows/pr.yml
Original file line number Diff line number Diff line change
Expand Up @@ -81,6 +81,10 @@ jobs:
echo "::set-output name=name::$NAME"
echo "::set-output name=artifact::$ARTIFACT"
# Build artifact using build Gradle task
- name: Build
run: ./gradlew build

# Build artifact using buildPlugin Gradle task
- name: Build Plugin
run: ./gradlew buildPlugin
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,7 @@ class IonSExpressionBlock(
) : AbstractIonBlock(node, formatting = formatting, options = options) {

override val childIndentedTypes: Set<IElementType> = setOf(
IonTypes.VALUE,
IonTypes.SEXPRESSION_ATOM,
IonTypes.COMMENT
)

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,7 @@ class IonSExpressionBlock(
) : AbstractIonBlock(node, formatting = formatting, options = options) {

override val childIndentedTypes: Set<IElementType> = setOf(
IonTypes.VALUE,
IonTypes.SEXPRESSION_ATOM,
IonTypes.COMMENT
)

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,7 @@ class IonSExpressionBlock(
) : AbstractIonBlock(node, formatting = formatting, options = options) {

override val childIndentedTypes: Set<IElementType> = setOf(
IonTypes.VALUE,
IonTypes.SEXPRESSION_ATOM,
IonTypes.COMMENT
)

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,7 @@ class IonSExpressionBlock(
) : AbstractIonBlock(node, formatting = formatting, options = options) {

override val childIndentedTypes: Set<IElementType> = setOf(
IonTypes.VALUE,
IonTypes.SEXPRESSION_ATOM,
IonTypes.COMMENT
)

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,7 @@ class IonSExpressionBlock(
) : AbstractIonBlock(node, formatting = formatting, options = options) {

override val childIndentedTypes: Set<IElementType> = setOf(
IonTypes.VALUE,
IonTypes.SEXPRESSION_ATOM,
IonTypes.COMMENT
)

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -97,7 +97,7 @@ private fun createSpaceBuilder(settings: CodeStyleSettings) =

before(IonTypes.SEXPRESSION_OPERATOR).none()
before(IonTypes.RPAREN).lineBreakInCode()
beforeInside(IonTypes.VALUE, IonTypes.SEXPRESSION).lineBreakInCode()
beforeInside(IonTypes.SEXPRESSION_ATOM, IonTypes.SEXPRESSION).lineBreakInCode()

/**
* Separator spacing, by default no space before and one space after separator, like JSON.
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -67,7 +67,7 @@ class IonBasicParsingTest : IonParserTestCaseBase(dataPath = "basic") {
IonListImpl(LIST)
PsiElement(LBRACKET)('[')
PsiWhiteSpace(' ')
IonElementsImpl(ELEMENTS)
IonListElementsImpl(LIST_ELEMENTS)
IonValueImpl(VALUE)
IonSymbolImpl(SYMBOL)
PsiElement(IDENTIFIER)('key')
Expand All @@ -87,7 +87,7 @@ class IonBasicParsingTest : IonParserTestCaseBase(dataPath = "basic") {
IonListImpl(LIST)
PsiElement(LBRACKET)('[')
PsiWhiteSpace(' ')
IonElementsImpl(ELEMENTS)
IonListElementsImpl(LIST_ELEMENTS)
IonValueImpl(VALUE)
IonSymbolImpl(SYMBOL)
PsiElement(IDENTIFIER)('key')
Expand All @@ -107,28 +107,31 @@ class IonBasicParsingTest : IonParserTestCaseBase(dataPath = "basic") {
IonContainerImpl(CONTAINER)
IonSexpressionImpl(SEXPRESSION)
PsiElement(LPAREN)('(')
IonAtomsImpl(ATOMS)
IonValueImpl(VALUE)
IonStringImpl(STRING)
IonQqStringImpl(QQ_STRING)
PsiElement(QQ_START)('"')
PsiElement(QQ_VALUE)('first')
PsiElement(QQ_END)('"')
IonSexpressionElementsImpl(SEXPRESSION_ELEMENTS)
IonSexpressionAtomImpl(SEXPRESSION_ATOM)
IonValueImpl(VALUE)
IonStringImpl(STRING)
IonQqStringImpl(QQ_STRING)
PsiElement(QQ_START)('"')
PsiElement(QQ_VALUE)('first')
PsiElement(QQ_END)('"')
PsiWhiteSpace(' ')
IonValueImpl(VALUE)
IonStringImpl(STRING)
IonQqStringImpl(QQ_STRING)
PsiElement(QQ_START)('"')
PsiElement(QQ_VALUE)('second')
PsiElement(QQ_END)('"')
IonSexpressionAtomImpl(SEXPRESSION_ATOM)
IonValueImpl(VALUE)
IonStringImpl(STRING)
IonQqStringImpl(QQ_STRING)
PsiElement(QQ_START)('"')
PsiElement(QQ_VALUE)('second')
PsiElement(QQ_END)('"')
PsiWhiteSpace(' ')
IonValueImpl(VALUE)
IonContainerImpl(CONTAINER)
IonStructImpl(STRUCT)
PsiElement(LBRACE)('{')
IonMembersImpl(MEMBERS)
<empty list>
PsiElement(RBRACE)('}')
IonSexpressionAtomImpl(SEXPRESSION_ATOM)
IonValueImpl(VALUE)
IonContainerImpl(CONTAINER)
IonStructImpl(STRUCT)
PsiElement(LBRACE)('{')
IonMembersImpl(MEMBERS)
<empty list>
PsiElement(RBRACE)('}')
PsiElement(RPAREN)(')')
"""
)
Expand All @@ -143,14 +146,15 @@ class IonBasicParsingTest : IonParserTestCaseBase(dataPath = "basic") {
IonContainerImpl(CONTAINER)
IonSexpressionImpl(SEXPRESSION)
PsiElement(LPAREN)('(')
IonSexpressionOperatorImpl(SEXPRESSION_OPERATOR)
IonSymbolImpl(SYMBOL)
PsiElement(IDENTIFIER)('test')
PsiWhiteSpace(' ')
IonAtomsImpl(ATOMS)
IonValueImpl(VALUE)
IonSexpressionElementsImpl(SEXPRESSION_ELEMENTS)
IonSexpressionOperatorImpl(SEXPRESSION_OPERATOR)
IonSymbolImpl(SYMBOL)
PsiElement(IDENTIFIER)('element')
PsiElement(IDENTIFIER)('test')
PsiWhiteSpace(' ')
IonSexpressionAtomImpl(SEXPRESSION_ATOM)
IonValueImpl(VALUE)
IonSymbolImpl(SYMBOL)
PsiElement(IDENTIFIER)('element')
PsiElement(RPAREN)(')')
"""
)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@ class IonPartialParsingTest : IonParserTestCaseBase(dataPath = "partial") {
IonListImpl(LIST)
PsiElement(LBRACKET)('[')
PsiWhiteSpace(' ')
IonElementsImpl(ELEMENTS)
IonListElementsImpl(LIST_ELEMENTS)
IonValueImpl(VALUE)
IonSymbolImpl(SYMBOL)
PsiElement(IDENTIFIER)('element')
Expand Down Expand Up @@ -75,14 +75,15 @@ class IonPartialParsingTest : IonParserTestCaseBase(dataPath = "partial") {
IonSexpressionImpl(SEXPRESSION)
PsiElement(LPAREN)('(')
PsiWhiteSpace(' ')
IonAtomsImpl(ATOMS)
IonValueImpl(VALUE)
IonBlobImpl(BLOB)
PsiElement(LOB_START)('{{')
PsiWhiteSpace(' ')
PsiElement(BAD_CHARACTER)('abcde_not_valid_base64')
PsiWhiteSpace(' ')
PsiElement(LOB_END)('}}')
IonSexpressionElementsImpl(SEXPRESSION_ELEMENTS)
IonSexpressionAtomImpl(SEXPRESSION_ATOM)
IonValueImpl(VALUE)
IonBlobImpl(BLOB)
PsiElement(LOB_START)('{{')
PsiWhiteSpace(' ')
PsiElement(BAD_CHARACTER)('abcde_not_valid_base64')
PsiWhiteSpace(' ')
PsiElement(LOB_END)('}}')
PsiWhiteSpace(' ')
PsiElement(RPAREN)(')')
"""
Expand Down

0 comments on commit 36f8093

Please sign in to comment.