(expression: lua.BinaryExpression)
| 743 | } |
| 744 | |
| 745 | public printBinaryExpression(expression: lua.BinaryExpression): SourceNode { |
| 746 | const chunks: SourceChunk[] = []; |
| 747 | const isRightAssociative = LuaPrinter.rightAssociativeOperators.has(expression.operator); |
| 748 | const precedence = LuaPrinter.operatorPrecedence[expression.operator]; |
| 749 | chunks.push( |
| 750 | this.printExpressionInParenthesesIfNeeded(expression.left, isRightAssociative ? precedence + 1 : precedence) |
| 751 | ); |
| 752 | chunks.push(" ", this.printOperator(expression.operator), " "); |
| 753 | chunks.push( |
| 754 | this.printExpressionInParenthesesIfNeeded( |
| 755 | expression.right, |
| 756 | isRightAssociative ? precedence : precedence + 1 |
| 757 | ) |
| 758 | ); |
| 759 | |
| 760 | return this.createSourceNode(expression, chunks); |
| 761 | } |
| 762 | |
| 763 | private printExpressionInParenthesesIfNeeded(expression: lua.Expression, minPrecedenceToOmit?: number): SourceNode { |
| 764 | return this.needsParenthesis(expression, minPrecedenceToOmit) |
no test coverage detected