Skip to content

Commit

Permalink
Merge pull request #344 from BalticAmadeus/342-negative-integer-is-pa…
Browse files Browse the repository at this point in the history
…rsed-as-unary-expression

unary expression fix
  • Loading branch information
PauliusKu authored Mar 5, 2025
2 parents 59638be + f7b1aa4 commit b8bc76c
Show file tree
Hide file tree
Showing 4 changed files with 11 additions and 1 deletion.
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
/* formatterSettingsOverride */
/* { "AblFormatter.expressionFormatting": true}*/

a = -c.
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
/* formatterSettingsOverride */
/* { "AblFormatter.expressionFormatting": true}*/

a = -c.
3 changes: 2 additions & 1 deletion src/formatters/expression/ExpressionFormatter.ts
Original file line number Diff line number Diff line change
Expand Up @@ -33,7 +33,8 @@ export class ExpressionFormatter extends AFormatter implements IFormatter {
node.type === SyntaxNodeType.ParenthesizedExpression ||
node.type === SyntaxNodeType.AdditiveExpression ||
node.type === SyntaxNodeType.MultiplicativeExpression ||
node.type === SyntaxNodeType.UnaryExpression
(node.type === SyntaxNodeType.UnaryExpression &&
node.child(0)?.type === SyntaxNodeType.Not)
) {
if (this.hasWhilePhraseParent(node)) {
return false;
Expand Down
1 change: 1 addition & 0 deletions src/model/SyntaxNodeType.ts
Original file line number Diff line number Diff line change
Expand Up @@ -93,6 +93,7 @@ export enum SyntaxNodeType {
Divide = "/",
Modulus = "%",
EqualsSign = "=",
Not = "NOT",
// comparison operators
EqualTo = "EQ",
NotEqualTo = "NE",
Expand Down

0 comments on commit b8bc76c

Please sign in to comment.