prettier-plugin-solidity 2.0.0 → 2.1.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/LICENSE +1 -1
- package/README.md +2 -2
- package/dist/3620299963220ca08ee1.wasm +0 -0
- package/dist/binary-operator-printers/addition.js +11 -0
- package/dist/binary-operator-printers/addition.js.map +1 -0
- package/dist/binary-operator-printers/bit.js +5 -2
- package/dist/binary-operator-printers/bit.js.map +1 -1
- package/dist/binary-operator-printers/equality.js +7 -0
- package/dist/binary-operator-printers/equality.js.map +1 -0
- package/dist/binary-operator-printers/exponentiation.js +20 -12
- package/dist/binary-operator-printers/exponentiation.js.map +1 -1
- package/dist/binary-operator-printers/index.js +4 -2
- package/dist/binary-operator-printers/index.js.map +1 -1
- package/dist/binary-operator-printers/inequality.js +8 -0
- package/dist/binary-operator-printers/inequality.js.map +1 -0
- package/dist/binary-operator-printers/logical.js +9 -24
- package/dist/binary-operator-printers/logical.js.map +1 -1
- package/dist/binary-operator-printers/multiplication.js +19 -0
- package/dist/binary-operator-printers/multiplication.js.map +1 -0
- package/dist/binary-operator-printers/printers/binary-operation-printer.js +5 -0
- package/dist/binary-operator-printers/printers/binary-operation-printer.js.map +1 -0
- package/dist/binary-operator-printers/printers/create-binary-operation-printer.js +24 -0
- package/dist/binary-operator-printers/printers/create-binary-operation-printer.js.map +1 -0
- package/dist/binary-operator-printers/printers/create-group-if-necessary-builder.js +10 -0
- package/dist/binary-operator-printers/printers/create-group-if-necessary-builder.js.map +1 -0
- package/dist/binary-operator-printers/printers/create-indent-if-necessary-builder.js +22 -0
- package/dist/binary-operator-printers/printers/create-indent-if-necessary-builder.js.map +1 -0
- package/dist/binary-operator-printers/shift.js +6 -2
- package/dist/binary-operator-printers/shift.js.map +1 -1
- package/dist/binary-operator-printers/utils/should-group-or-indent.js +3 -0
- package/dist/binary-operator-printers/utils/should-group-or-indent.js.map +1 -0
- package/dist/comments/handlers/handleContractDefinitionComments.js +2 -3
- package/dist/comments/handlers/handleContractDefinitionComments.js.map +1 -1
- package/dist/comments/handlers/handleModifierInvocationComments.js +2 -3
- package/dist/comments/handlers/handleModifierInvocationComments.js.map +1 -1
- package/dist/common/printer-helpers.js +4 -11
- package/dist/common/printer-helpers.js.map +1 -1
- package/dist/index.js +1 -3
- package/dist/index.js.map +1 -1
- package/dist/nodes/Conditional.js +2 -2
- package/dist/nodes/Conditional.js.map +1 -1
- package/dist/nodes/ExpressionStatement.js +1 -1
- package/dist/nodes/ExpressionStatement.js.map +1 -1
- package/dist/nodes/FunctionDefinition.js +3 -3
- package/dist/nodes/FunctionDefinition.js.map +1 -1
- package/dist/nodes/ImportDirective.js +3 -1
- package/dist/nodes/ImportDirective.js.map +1 -1
- package/dist/options.js +16 -0
- package/dist/options.js.map +1 -1
- package/dist/parser.js +4 -0
- package/dist/parser.js.map +1 -1
- package/dist/prettier-comments/language-js/comments.js +8 -9
- package/dist/prettier-comments/language-js/comments.js.map +1 -1
- package/dist/printer.js +1 -1
- package/dist/printer.js.map +1 -1
- package/dist/slang-comments/handlers/{add-collection-node-first-comment.js → add-collection-first-comment.js} +2 -2
- package/dist/slang-comments/handlers/add-collection-first-comment.js.map +1 -0
- package/dist/slang-comments/handlers/{add-collection-node-last-comment.js → add-collection-last-comment.js} +2 -2
- package/dist/slang-comments/handlers/add-collection-last-comment.js.map +1 -0
- package/dist/slang-comments/handlers/handle-block-comments.js +4 -4
- package/dist/slang-comments/handlers/handle-block-comments.js.map +1 -1
- package/dist/slang-comments/handlers/handle-contract-definition-comments.js +3 -3
- package/dist/slang-comments/handlers/handle-contract-definition-comments.js.map +1 -1
- package/dist/slang-comments/handlers/handle-contract-specifiers-comments.js +2 -2
- package/dist/slang-comments/handlers/handle-contract-specifiers-comments.js.map +1 -1
- package/dist/slang-comments/handlers/handle-else-branch-comments.js +2 -2
- package/dist/slang-comments/handlers/handle-else-branch-comments.js.map +1 -1
- package/dist/slang-comments/handlers/handle-if-statement-comments.js +3 -3
- package/dist/slang-comments/handlers/handle-if-statement-comments.js.map +1 -1
- package/dist/slang-comments/handlers/handle-interface-definition-comments.js +4 -4
- package/dist/slang-comments/handlers/handle-interface-definition-comments.js.map +1 -1
- package/dist/slang-comments/handlers/handle-library-definition-comments.js +4 -4
- package/dist/slang-comments/handlers/handle-library-definition-comments.js.map +1 -1
- package/dist/slang-comments/handlers/handle-modifier-invocation-comments.js +2 -2
- package/dist/slang-comments/handlers/handle-modifier-invocation-comments.js.map +1 -1
- package/dist/slang-comments/handlers/handle-parameters-declaration-comments.js +4 -4
- package/dist/slang-comments/handlers/handle-parameters-declaration-comments.js.map +1 -1
- package/dist/slang-comments/handlers/handle-positional-arguments-declaration-comments.js +4 -4
- package/dist/slang-comments/handlers/handle-positional-arguments-declaration-comments.js.map +1 -1
- package/dist/slang-comments/handlers/handle-struct-comments.js +22 -0
- package/dist/slang-comments/handlers/handle-struct-comments.js.map +1 -0
- package/dist/slang-comments/handlers/handle-while-statement-comments.js +2 -2
- package/dist/slang-comments/handlers/handle-while-statement-comments.js.map +1 -1
- package/dist/slang-comments/handlers/index.js +2 -0
- package/dist/slang-comments/handlers/index.js.map +1 -1
- package/dist/slang-comments/printer.js +1 -2
- package/dist/slang-comments/printer.js.map +1 -1
- package/dist/slang-nodes/AdditiveExpression.js +12 -1
- package/dist/slang-nodes/AdditiveExpression.js.map +1 -1
- package/dist/slang-nodes/BitwiseAndExpression.js +8 -1
- package/dist/slang-nodes/BitwiseAndExpression.js.map +1 -1
- package/dist/slang-nodes/BitwiseOrExpression.js +8 -1
- package/dist/slang-nodes/BitwiseOrExpression.js.map +1 -1
- package/dist/slang-nodes/BitwiseXorExpression.js +8 -1
- package/dist/slang-nodes/BitwiseXorExpression.js.map +1 -1
- package/dist/slang-nodes/ConditionalExpression.js +11 -10
- package/dist/slang-nodes/ConditionalExpression.js.map +1 -1
- package/dist/slang-nodes/ContractDefinition.js +4 -4
- package/dist/slang-nodes/ContractDefinition.js.map +1 -1
- package/dist/slang-nodes/EqualityExpression.js +10 -2
- package/dist/slang-nodes/EqualityExpression.js.map +1 -1
- package/dist/slang-nodes/ExponentiationExpression.js +16 -2
- package/dist/slang-nodes/ExponentiationExpression.js.map +1 -1
- package/dist/slang-nodes/FallbackFunctionDefinition.js +4 -4
- package/dist/slang-nodes/FallbackFunctionDefinition.js.map +1 -1
- package/dist/slang-nodes/FunctionCallExpression.js +6 -5
- package/dist/slang-nodes/FunctionCallExpression.js.map +1 -1
- package/dist/slang-nodes/FunctionDefinition.js +4 -4
- package/dist/slang-nodes/FunctionDefinition.js.map +1 -1
- package/dist/slang-nodes/IfStatement.js +5 -4
- package/dist/slang-nodes/IfStatement.js.map +1 -1
- package/dist/slang-nodes/ImportDeconstructionSymbols.js +1 -1
- package/dist/slang-nodes/ImportDeconstructionSymbols.js.map +1 -1
- package/dist/slang-nodes/IndexAccessExpression.js +10 -9
- package/dist/slang-nodes/IndexAccessExpression.js.map +1 -1
- package/dist/slang-nodes/InequalityExpression.js +8 -2
- package/dist/slang-nodes/InequalityExpression.js.map +1 -1
- package/dist/slang-nodes/MemberAccessExpression.js +11 -13
- package/dist/slang-nodes/MemberAccessExpression.js.map +1 -1
- package/dist/slang-nodes/MultiplicativeExpression.js +13 -1
- package/dist/slang-nodes/MultiplicativeExpression.js.map +1 -1
- package/dist/slang-nodes/ReceiveFunctionDefinition.js +4 -4
- package/dist/slang-nodes/ReceiveFunctionDefinition.js.map +1 -1
- package/dist/slang-nodes/ReturnStatement.js +5 -3
- package/dist/slang-nodes/ReturnStatement.js.map +1 -1
- package/dist/slang-nodes/ShiftExpression.js +11 -1
- package/dist/slang-nodes/ShiftExpression.js.map +1 -1
- package/dist/slang-nodes/StateVariableDefinition.js +1 -4
- package/dist/slang-nodes/StateVariableDefinition.js.map +1 -1
- package/dist/slang-nodes/TupleDeconstructionStatement.js +1 -2
- package/dist/slang-nodes/TupleDeconstructionStatement.js.map +1 -1
- package/dist/slang-nodes/UnnamedFunctionDefinition.js +3 -3
- package/dist/slang-nodes/UnnamedFunctionDefinition.js.map +1 -1
- package/dist/slang-nodes/VariableDeclarationStatement.js +10 -11
- package/dist/slang-nodes/VariableDeclarationStatement.js.map +1 -1
- package/dist/slang-printers/create-binary-operation-printer.js +14 -9
- package/dist/slang-printers/create-binary-operation-printer.js.map +1 -1
- package/dist/slang-printers/print-binary-operation.js +24 -25
- package/dist/slang-printers/print-binary-operation.js.map +1 -1
- package/dist/slang-printers/print-comments.js +1 -1
- package/dist/slang-printers/print-comments.js.map +1 -1
- package/dist/slang-printers/print-logical-operation.js +5 -13
- package/dist/slang-printers/print-logical-operation.js.map +1 -1
- package/dist/slang-printers/print-preserving-empty-lines.js +1 -1
- package/dist/slang-printers/print-preserving-empty-lines.js.map +1 -1
- package/dist/slang-utils/create-hug-function.js +5 -4
- package/dist/slang-utils/create-hug-function.js.map +1 -1
- package/dist/slang-utils/create-parser.js +31 -86
- package/dist/slang-utils/create-parser.js.map +1 -1
- package/dist/slang-utils/metadata.js +31 -35
- package/dist/slang-utils/metadata.js.map +1 -1
- package/dist/slang-utils/sort-contract-specifiers.js +5 -7
- package/dist/slang-utils/sort-contract-specifiers.js.map +1 -1
- package/dist/slang-utils/sort-function-attributes.js +1 -3
- package/dist/slang-utils/sort-function-attributes.js.map +1 -1
- package/dist/slangPrinter.js +9 -16
- package/dist/slangPrinter.js.map +1 -1
- package/dist/slangSolidityParser.js +6 -9
- package/dist/slangSolidityParser.js.map +1 -1
- package/dist/standalone.js +1 -1
- package/dist/standalone.js.map +1 -1
- package/package.json +19 -19
- package/src/binary-operator-printers/addition.js +11 -0
- package/src/binary-operator-printers/bit.js +5 -2
- package/src/binary-operator-printers/equality.js +7 -0
- package/src/binary-operator-printers/exponentiation.js +22 -13
- package/src/binary-operator-printers/index.js +4 -2
- package/src/binary-operator-printers/inequality.js +8 -0
- package/src/binary-operator-printers/logical.js +12 -26
- package/src/binary-operator-printers/multiplication.js +19 -0
- package/src/binary-operator-printers/printers/binary-operation-printer.js +9 -0
- package/src/binary-operator-printers/printers/create-binary-operation-printer.js +31 -0
- package/src/binary-operator-printers/printers/create-group-if-necessary-builder.js +12 -0
- package/src/binary-operator-printers/printers/create-indent-if-necessary-builder.js +23 -0
- package/src/binary-operator-printers/shift.js +6 -2
- package/src/binary-operator-printers/utils/should-group-or-indent.js +3 -0
- package/src/comments/handlers/handleContractDefinitionComments.js +7 -4
- package/src/comments/handlers/handleModifierInvocationComments.js +7 -4
- package/src/common/printer-helpers.js +4 -15
- package/src/index.ts +2 -4
- package/src/nodes/Conditional.js +2 -2
- package/src/nodes/ExpressionStatement.js +1 -1
- package/src/nodes/FunctionDefinition.js +3 -4
- package/src/nodes/ImportDirective.js +5 -1
- package/src/options.ts +16 -0
- package/src/parser.js +4 -0
- package/src/prettier-comments/language-js/comments.js +10 -16
- package/src/printer.js +1 -4
- package/src/slang-comments/handlers/{add-collection-node-first-comment.ts → add-collection-first-comment.ts} +3 -3
- package/src/slang-comments/handlers/{add-collection-node-last-comment.ts → add-collection-last-comment.ts} +3 -3
- package/src/slang-comments/handlers/handle-block-comments.ts +4 -4
- package/src/slang-comments/handlers/handle-contract-definition-comments.ts +3 -3
- package/src/slang-comments/handlers/handle-contract-specifiers-comments.ts +2 -2
- package/src/slang-comments/handlers/handle-else-branch-comments.ts +2 -2
- package/src/slang-comments/handlers/handle-if-statement-comments.ts +3 -6
- package/src/slang-comments/handlers/handle-interface-definition-comments.ts +4 -4
- package/src/slang-comments/handlers/handle-library-definition-comments.ts +4 -4
- package/src/slang-comments/handlers/handle-modifier-invocation-comments.ts +2 -2
- package/src/slang-comments/handlers/handle-parameters-declaration-comments.ts +4 -4
- package/src/slang-comments/handlers/handle-positional-arguments-declaration-comments.ts +4 -4
- package/src/slang-comments/handlers/handle-struct-comments.ts +39 -0
- package/src/slang-comments/handlers/handle-while-statement-comments.ts +2 -2
- package/src/slang-comments/handlers/index.ts +2 -0
- package/src/slang-comments/printer.ts +1 -3
- package/src/slang-nodes/AdditiveExpression.ts +15 -1
- package/src/slang-nodes/BitwiseAndExpression.ts +11 -1
- package/src/slang-nodes/BitwiseOrExpression.ts +14 -4
- package/src/slang-nodes/BitwiseXorExpression.ts +11 -1
- package/src/slang-nodes/ConditionalExpression.ts +10 -10
- package/src/slang-nodes/ContractDefinition.ts +4 -4
- package/src/slang-nodes/ContractSpecifier.ts +2 -2
- package/src/slang-nodes/ContractSpecifiers.ts +2 -2
- package/src/slang-nodes/EqualityExpression.ts +15 -2
- package/src/slang-nodes/ExponentiationExpression.ts +17 -4
- package/src/slang-nodes/FallbackFunctionDefinition.ts +4 -4
- package/src/slang-nodes/FunctionCallExpression.ts +6 -5
- package/src/slang-nodes/FunctionDefinition.ts +4 -4
- package/src/slang-nodes/IfStatement.ts +5 -4
- package/src/slang-nodes/ImportDeconstructionSymbols.ts +1 -1
- package/src/slang-nodes/IndexAccessExpression.ts +10 -10
- package/src/slang-nodes/InequalityExpression.ts +11 -2
- package/src/slang-nodes/MemberAccessExpression.ts +13 -17
- package/src/slang-nodes/MultiplicativeExpression.ts +16 -1
- package/src/slang-nodes/PositionalArguments.ts +2 -2
- package/src/slang-nodes/ReceiveFunctionDefinition.ts +4 -4
- package/src/slang-nodes/ReturnStatement.ts +4 -3
- package/src/slang-nodes/ShiftExpression.ts +14 -1
- package/src/slang-nodes/StateVariableDefinition.ts +1 -5
- package/src/slang-nodes/StorageLayoutSpecifier.ts +2 -2
- package/src/slang-nodes/StringLiteral.ts +1 -1
- package/src/slang-nodes/TupleDeconstructionStatement.ts +4 -6
- package/src/slang-nodes/UnnamedFunctionDefinition.ts +3 -3
- package/src/slang-nodes/VariableDeclarationStatement.ts +13 -15
- package/src/slang-nodes/types.d.ts +9 -1
- package/src/slang-printers/create-binary-operation-printer.ts +16 -11
- package/src/slang-printers/print-binary-operation.ts +48 -39
- package/src/slang-printers/print-comments.ts +1 -1
- package/src/slang-printers/print-logical-operation.ts +8 -17
- package/src/slang-printers/print-preserving-empty-lines.ts +3 -7
- package/src/slang-utils/create-hug-function.ts +5 -5
- package/src/slang-utils/create-parser.ts +56 -119
- package/src/slang-utils/metadata.ts +33 -37
- package/src/slang-utils/sort-contract-specifiers.ts +6 -9
- package/src/slang-utils/sort-function-attributes.ts +2 -5
- package/src/slangPrinter.ts +11 -21
- package/src/slangSolidityParser.ts +9 -12
- package/dist/binary-operator-printers/arithmetic.js +0 -44
- package/dist/binary-operator-printers/arithmetic.js.map +0 -1
- package/dist/binary-operator-printers/comparison.js +0 -38
- package/dist/binary-operator-printers/comparison.js.map +0 -1
- package/dist/common/backward-compatibility.js +0 -27
- package/dist/common/backward-compatibility.js.map +0 -1
- package/dist/ea6945b7193921081ced.wasm +0 -0
- package/dist/slang-comments/handlers/add-collection-node-first-comment.js.map +0 -1
- package/dist/slang-comments/handlers/add-collection-node-last-comment.js.map +0 -1
- package/dist/slang-printers/print-comparison-operation.js +0 -35
- package/dist/slang-printers/print-comparison-operation.js.map +0 -1
- package/src/binary-operator-printers/arithmetic.js +0 -51
- package/src/binary-operator-printers/comparison.js +0 -36
- package/src/common/backward-compatibility.js +0 -34
- package/src/slang-printers/print-comparison-operation.ts +0 -45
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "prettier-plugin-solidity",
|
|
3
|
-
"version": "2.
|
|
3
|
+
"version": "2.1.0",
|
|
4
4
|
"description": "A Prettier Plugin for automatically formatting your Solidity code.",
|
|
5
5
|
"type": "module",
|
|
6
6
|
"main": "./dist/index.js",
|
|
@@ -80,40 +80,40 @@
|
|
|
80
80
|
},
|
|
81
81
|
"homepage": "https://github.com/prettier-solidity/prettier-plugin-solidity#readme",
|
|
82
82
|
"engines": {
|
|
83
|
-
"node": ">=
|
|
83
|
+
"node": ">=20"
|
|
84
84
|
},
|
|
85
85
|
"devDependencies": {
|
|
86
|
-
"@babel/code-frame": "^7.
|
|
86
|
+
"@babel/code-frame": "^7.27.1",
|
|
87
87
|
"@eslint/eslintrc": "^3.3.1",
|
|
88
|
-
"@eslint/js": "^9.
|
|
89
|
-
"@types/jest": "^
|
|
88
|
+
"@eslint/js": "^9.30.1",
|
|
89
|
+
"@types/jest": "^30.0.0",
|
|
90
90
|
"@types/semver": "^7.7.0",
|
|
91
|
-
"@typescript-eslint/eslint-plugin": "^8.
|
|
92
|
-
"@typescript-eslint/parser": "^8.
|
|
91
|
+
"@typescript-eslint/eslint-plugin": "^8.36.0",
|
|
92
|
+
"@typescript-eslint/parser": "^8.36.0",
|
|
93
93
|
"c8": "^10.1.3",
|
|
94
94
|
"cross-env": "^7.0.3",
|
|
95
|
-
"eslint": "^9.
|
|
96
|
-
"eslint-config-prettier": "^10.1.
|
|
97
|
-
"esm-utils": "^4.
|
|
98
|
-
"globals": "^16.
|
|
99
|
-
"jest": "^
|
|
100
|
-
"jest-light-runner": "^0.7.
|
|
95
|
+
"eslint": "^9.30.1",
|
|
96
|
+
"eslint-config-prettier": "^10.1.5",
|
|
97
|
+
"esm-utils": "^4.4.2",
|
|
98
|
+
"globals": "^16.3.0",
|
|
99
|
+
"jest": "^30.0.4",
|
|
100
|
+
"jest-light-runner": "^0.7.9",
|
|
101
101
|
"jest-snapshot-serializer-ansi": "^2.2.1",
|
|
102
102
|
"jest-snapshot-serializer-raw": "^2.0.0",
|
|
103
|
-
"jest-watch-typeahead": "^
|
|
103
|
+
"jest-watch-typeahead": "^3.0.1",
|
|
104
104
|
"lines-and-columns": "^2.0.4",
|
|
105
|
-
"prettier": "^3.
|
|
106
|
-
"solc": "^0.8.
|
|
105
|
+
"prettier": "^3.6.2",
|
|
106
|
+
"solc": "^0.8.30",
|
|
107
107
|
"ts-loader": "^9.5.2",
|
|
108
108
|
"ts-node": "^10.9.2",
|
|
109
109
|
"typescript": "^5.8.3",
|
|
110
|
-
"webpack": "^5.
|
|
110
|
+
"webpack": "^5.100.0",
|
|
111
111
|
"webpack-cli": "^6.0.1"
|
|
112
112
|
},
|
|
113
113
|
"dependencies": {
|
|
114
|
-
"@nomicfoundation/slang": "1.
|
|
114
|
+
"@nomicfoundation/slang": "1.2.0",
|
|
115
115
|
"@solidity-parser/parser": "^0.20.1",
|
|
116
|
-
"semver": "^7.7.
|
|
116
|
+
"semver": "^7.7.2"
|
|
117
117
|
},
|
|
118
118
|
"peerDependencies": {
|
|
119
119
|
"prettier": ">=3.0.0"
|
|
@@ -0,0 +1,11 @@
|
|
|
1
|
+
import { binaryOperationPrinter } from './printers/binary-operation-printer.js';
|
|
2
|
+
import { bit } from './bit.js';
|
|
3
|
+
import { shift } from './shift.js';
|
|
4
|
+
import { inequality } from './inequality.js';
|
|
5
|
+
import { equality } from './equality.js';
|
|
6
|
+
import { logical } from './logical.js';
|
|
7
|
+
|
|
8
|
+
export const addition = {
|
|
9
|
+
match: (op) => ['+', '-'].includes(op),
|
|
10
|
+
print: binaryOperationPrinter([shift, bit, inequality, equality, logical])
|
|
11
|
+
};
|
|
@@ -1,6 +1,9 @@
|
|
|
1
|
-
import {
|
|
1
|
+
import { binaryOperationPrinter } from './printers/binary-operation-printer.js';
|
|
2
|
+
import { inequality } from './inequality.js';
|
|
3
|
+
import { equality } from './equality.js';
|
|
4
|
+
import { logical } from './logical.js';
|
|
2
5
|
|
|
3
6
|
export const bit = {
|
|
4
7
|
match: (op) => ['&', '|', '^'].includes(op),
|
|
5
|
-
print:
|
|
8
|
+
print: binaryOperationPrinter([inequality, equality, logical])
|
|
6
9
|
};
|
|
@@ -1,19 +1,28 @@
|
|
|
1
1
|
import { doc } from 'prettier';
|
|
2
|
+
import { createBinaryOperationPrinter } from './printers/create-binary-operation-printer.js';
|
|
3
|
+
import { createIndentIfNecessaryBuilder } from './printers/create-indent-if-necessary-builder.js';
|
|
4
|
+
import { multiplication } from './multiplication.js';
|
|
5
|
+
import { addition } from './addition.js';
|
|
6
|
+
import { shift } from './shift.js';
|
|
7
|
+
import { bit } from './bit.js';
|
|
8
|
+
import { inequality } from './inequality.js';
|
|
9
|
+
import { equality } from './equality.js';
|
|
10
|
+
import { logical } from './logical.js';
|
|
2
11
|
|
|
3
|
-
const { group
|
|
12
|
+
const { group } = doc.builders;
|
|
4
13
|
|
|
5
14
|
export const exponentiation = {
|
|
6
15
|
match: (op) => op === '**',
|
|
7
|
-
print: (
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
])
|
|
18
|
-
|
|
16
|
+
print: createBinaryOperationPrinter(
|
|
17
|
+
() => (document) => group(document), // always group
|
|
18
|
+
createIndentIfNecessaryBuilder([
|
|
19
|
+
multiplication,
|
|
20
|
+
addition,
|
|
21
|
+
shift,
|
|
22
|
+
bit,
|
|
23
|
+
inequality,
|
|
24
|
+
equality,
|
|
25
|
+
logical
|
|
26
|
+
])
|
|
27
|
+
)
|
|
19
28
|
};
|
|
@@ -1,7 +1,9 @@
|
|
|
1
|
-
export * from './
|
|
1
|
+
export * from './addition.js';
|
|
2
2
|
export * from './assignment.js';
|
|
3
3
|
export * from './bit.js';
|
|
4
|
-
export * from './
|
|
4
|
+
export * from './equality.js';
|
|
5
5
|
export * from './exponentiation.js';
|
|
6
|
+
export * from './inequality.js';
|
|
6
7
|
export * from './logical.js';
|
|
8
|
+
export * from './multiplication.js';
|
|
7
9
|
export * from './shift.js';
|
|
@@ -0,0 +1,8 @@
|
|
|
1
|
+
import { binaryOperationPrinter } from './printers/binary-operation-printer.js';
|
|
2
|
+
import { logical } from './logical.js';
|
|
3
|
+
import { equality } from './equality.js';
|
|
4
|
+
|
|
5
|
+
export const inequality = {
|
|
6
|
+
match: (op) => ['<', '>', '<=', '>='].includes(op),
|
|
7
|
+
print: binaryOperationPrinter([logical, equality])
|
|
8
|
+
};
|
|
@@ -1,24 +1,22 @@
|
|
|
1
1
|
import { doc } from 'prettier';
|
|
2
|
+
import { createBinaryOperationPrinter } from './printers/create-binary-operation-printer.js';
|
|
3
|
+
import { createGroupIfNecessaryBuilder } from './printers/create-group-if-necessary-builder.js';
|
|
4
|
+
import { notIndentParentTypes } from './printers/create-indent-if-necessary-builder.js';
|
|
5
|
+
import { shouldGroupOrIndent } from './utils/should-group-or-indent.js';
|
|
2
6
|
|
|
3
|
-
const {
|
|
4
|
-
|
|
5
|
-
const groupIfNecessaryBuilder = (path) => (document) =>
|
|
6
|
-
path.getParentNode().type === 'BinaryOperation' ? document : group(document);
|
|
7
|
+
const { indent } = doc.builders;
|
|
7
8
|
|
|
8
9
|
const indentIfNecessaryBuilder = (path, options) => (document) => {
|
|
9
|
-
let node = path
|
|
10
|
-
for (let i = 0; ; i += 1) {
|
|
10
|
+
for (let i = 0, { node } = path; ; i += 1) {
|
|
11
11
|
const parentNode = path.getParentNode(i);
|
|
12
|
-
if (parentNode.type
|
|
13
|
-
if (parentNode.type === 'IfStatement') return document;
|
|
14
|
-
if (parentNode.type === 'WhileStatement') return document;
|
|
12
|
+
if (notIndentParentTypes.includes(parentNode.type)) return document;
|
|
15
13
|
if (
|
|
16
14
|
options.experimentalTernaries &&
|
|
17
15
|
parentNode.type === 'Conditional' &&
|
|
18
16
|
parentNode.condition === node
|
|
19
17
|
)
|
|
20
18
|
return document;
|
|
21
|
-
if (parentNode
|
|
19
|
+
if (shouldGroupOrIndent(parentNode, [])) return indent(document);
|
|
22
20
|
if (node === parentNode.right) return document;
|
|
23
21
|
node = parentNode;
|
|
24
22
|
}
|
|
@@ -26,20 +24,8 @@ const indentIfNecessaryBuilder = (path, options) => (document) => {
|
|
|
26
24
|
|
|
27
25
|
export const logical = {
|
|
28
26
|
match: (op) => ['&&', '||'].includes(op),
|
|
29
|
-
print: (
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
const right = [node.operator, line, path.call(print, 'right')];
|
|
34
|
-
// If it's a single binary operation, avoid having a small right
|
|
35
|
-
// operand like - 1 on its own line
|
|
36
|
-
const shouldGroup =
|
|
37
|
-
node.left.type !== 'BinaryOperation' &&
|
|
38
|
-
path.getParentNode().type !== 'BinaryOperation';
|
|
39
|
-
return groupIfNecessary([
|
|
40
|
-
path.call(print, 'left'),
|
|
41
|
-
' ',
|
|
42
|
-
indentIfNecessary(shouldGroup ? group(right) : right)
|
|
43
|
-
]);
|
|
44
|
-
}
|
|
27
|
+
print: createBinaryOperationPrinter(
|
|
28
|
+
createGroupIfNecessaryBuilder([]),
|
|
29
|
+
indentIfNecessaryBuilder
|
|
30
|
+
)
|
|
45
31
|
};
|
|
@@ -0,0 +1,19 @@
|
|
|
1
|
+
import { binaryOperationPrinter } from './printers/binary-operation-printer.js';
|
|
2
|
+
import { addition } from './addition.js';
|
|
3
|
+
import { bit } from './bit.js';
|
|
4
|
+
import { equality } from './equality.js';
|
|
5
|
+
import { inequality } from './inequality.js';
|
|
6
|
+
import { shift } from './shift.js';
|
|
7
|
+
import { logical } from './logical.js';
|
|
8
|
+
|
|
9
|
+
export const multiplication = {
|
|
10
|
+
match: (op) => ['*', '/', '%'].includes(op),
|
|
11
|
+
print: binaryOperationPrinter([
|
|
12
|
+
addition,
|
|
13
|
+
shift,
|
|
14
|
+
bit,
|
|
15
|
+
inequality,
|
|
16
|
+
equality,
|
|
17
|
+
logical
|
|
18
|
+
])
|
|
19
|
+
};
|
|
@@ -0,0 +1,9 @@
|
|
|
1
|
+
import { createBinaryOperationPrinter } from './create-binary-operation-printer.js';
|
|
2
|
+
import { createGroupIfNecessaryBuilder } from './create-group-if-necessary-builder.js';
|
|
3
|
+
import { createIndentIfNecessaryBuilder } from './create-indent-if-necessary-builder.js';
|
|
4
|
+
|
|
5
|
+
export const binaryOperationPrinter = (shouldGroupAndIndentMatchers) =>
|
|
6
|
+
createBinaryOperationPrinter(
|
|
7
|
+
createGroupIfNecessaryBuilder(shouldGroupAndIndentMatchers),
|
|
8
|
+
createIndentIfNecessaryBuilder(shouldGroupAndIndentMatchers)
|
|
9
|
+
);
|
|
@@ -0,0 +1,31 @@
|
|
|
1
|
+
import { doc } from 'prettier';
|
|
2
|
+
import { assignment } from '../assignment.js';
|
|
3
|
+
|
|
4
|
+
const { group, line } = doc.builders;
|
|
5
|
+
|
|
6
|
+
const rightOperandPrinter = (node, path, print, options) => {
|
|
7
|
+
const right =
|
|
8
|
+
options.experimentalOperatorPosition === 'end'
|
|
9
|
+
? [' ', node.operator, line, path.call(print, 'right')]
|
|
10
|
+
: [line, node.operator, ' ', path.call(print, 'right')];
|
|
11
|
+
|
|
12
|
+
// If it's a single binary operation, avoid having a small right
|
|
13
|
+
// operand like - 1 on its own line
|
|
14
|
+
const { parent } = path;
|
|
15
|
+
return node.left.type !== 'BinaryOperation' &&
|
|
16
|
+
(parent.type !== 'BinaryOperation' || assignment.match(parent.operator))
|
|
17
|
+
? group(right)
|
|
18
|
+
: right;
|
|
19
|
+
};
|
|
20
|
+
|
|
21
|
+
export const createBinaryOperationPrinter =
|
|
22
|
+
(groupIfNecessaryBuilder, indentIfNecessaryBuilder) =>
|
|
23
|
+
(node, path, print, options) => {
|
|
24
|
+
const groupIfNecessary = groupIfNecessaryBuilder(path);
|
|
25
|
+
const indentIfNecessary = indentIfNecessaryBuilder(path, options);
|
|
26
|
+
|
|
27
|
+
return groupIfNecessary([
|
|
28
|
+
path.call(print, 'left'),
|
|
29
|
+
indentIfNecessary(rightOperandPrinter(node, path, print, options))
|
|
30
|
+
]);
|
|
31
|
+
};
|
|
@@ -0,0 +1,12 @@
|
|
|
1
|
+
import { doc } from 'prettier';
|
|
2
|
+
import { shouldGroupOrIndent } from '../utils/should-group-or-indent.js';
|
|
3
|
+
|
|
4
|
+
const { group } = doc.builders;
|
|
5
|
+
|
|
6
|
+
export const createGroupIfNecessaryBuilder =
|
|
7
|
+
(shouldIndentMatchers) => (path) => (document) => {
|
|
8
|
+
const { parent } = path;
|
|
9
|
+
if (shouldGroupOrIndent(parent, shouldIndentMatchers))
|
|
10
|
+
return group(document);
|
|
11
|
+
return document;
|
|
12
|
+
};
|
|
@@ -0,0 +1,23 @@
|
|
|
1
|
+
import { doc } from 'prettier';
|
|
2
|
+
import { shouldGroupOrIndent } from '../utils/should-group-or-indent.js';
|
|
3
|
+
|
|
4
|
+
const { indent } = doc.builders;
|
|
5
|
+
|
|
6
|
+
export const notIndentParentTypes = [
|
|
7
|
+
'ReturnStatement',
|
|
8
|
+
'IfStatement',
|
|
9
|
+
'ForStatement',
|
|
10
|
+
'WhileStatement'
|
|
11
|
+
];
|
|
12
|
+
|
|
13
|
+
export const createIndentIfNecessaryBuilder =
|
|
14
|
+
(shouldIndentMatchers) => (path) => (document) => {
|
|
15
|
+
for (let i = 0, { node } = path; ; i += 1) {
|
|
16
|
+
const parentNode = path.getParentNode(i);
|
|
17
|
+
if (notIndentParentTypes.includes(parentNode.type)) return document;
|
|
18
|
+
if (shouldGroupOrIndent(parentNode, shouldIndentMatchers))
|
|
19
|
+
return indent(document);
|
|
20
|
+
if (node === parentNode.right) return document;
|
|
21
|
+
node = parentNode;
|
|
22
|
+
}
|
|
23
|
+
};
|
|
@@ -1,6 +1,10 @@
|
|
|
1
|
-
import {
|
|
1
|
+
import { binaryOperationPrinter } from './printers/binary-operation-printer.js';
|
|
2
|
+
import { bit } from './bit.js';
|
|
3
|
+
import { inequality } from './inequality.js';
|
|
4
|
+
import { equality } from './equality.js';
|
|
5
|
+
import { logical } from './logical.js';
|
|
2
6
|
|
|
3
7
|
export const shift = {
|
|
4
8
|
match: (op) => ['<<', '>>'].includes(op),
|
|
5
|
-
print:
|
|
9
|
+
print: binaryOperationPrinter([bit, inequality, equality, logical])
|
|
6
10
|
};
|
|
@@ -1,7 +1,11 @@
|
|
|
1
1
|
import { util } from 'prettier';
|
|
2
|
-
import { getNextNonSpaceNonCommentCharacter } from '../../common/backward-compatibility.js';
|
|
3
2
|
|
|
4
|
-
const {
|
|
3
|
+
const {
|
|
4
|
+
addLeadingComment,
|
|
5
|
+
addTrailingComment,
|
|
6
|
+
addDanglingComment,
|
|
7
|
+
getNextNonSpaceNonCommentCharacter
|
|
8
|
+
} = util;
|
|
5
9
|
|
|
6
10
|
function handleContractDefinitionComments({
|
|
7
11
|
text,
|
|
@@ -22,8 +26,7 @@ function handleContractDefinitionComments({
|
|
|
22
26
|
// it is a {}.
|
|
23
27
|
const nextCharacter = getNextNonSpaceNonCommentCharacter(
|
|
24
28
|
text,
|
|
25
|
-
comment
|
|
26
|
-
options.locEnd
|
|
29
|
+
options.locEnd(comment)
|
|
27
30
|
);
|
|
28
31
|
|
|
29
32
|
// The comment is behind the start of the Block `{}` or behind a base contract
|
|
@@ -1,7 +1,11 @@
|
|
|
1
1
|
import { util } from 'prettier';
|
|
2
|
-
import { getNextNonSpaceNonCommentCharacter } from '../../common/backward-compatibility.js';
|
|
3
2
|
|
|
4
|
-
const {
|
|
3
|
+
const {
|
|
4
|
+
addLeadingComment,
|
|
5
|
+
addTrailingComment,
|
|
6
|
+
addDanglingComment,
|
|
7
|
+
getNextNonSpaceNonCommentCharacter
|
|
8
|
+
} = util;
|
|
5
9
|
|
|
6
10
|
function handleModifierInvocationComments({
|
|
7
11
|
text,
|
|
@@ -21,8 +25,7 @@ function handleModifierInvocationComments({
|
|
|
21
25
|
// it is a ().
|
|
22
26
|
const nextCharacter = getNextNonSpaceNonCommentCharacter(
|
|
23
27
|
text,
|
|
24
|
-
comment
|
|
25
|
-
options.locEnd
|
|
28
|
+
options.locEnd(comment)
|
|
26
29
|
);
|
|
27
30
|
|
|
28
31
|
// The comment is behind the start of the Parentheses `()`
|
|
@@ -1,11 +1,7 @@
|
|
|
1
|
-
import { doc } from 'prettier';
|
|
2
|
-
import {
|
|
3
|
-
isLast,
|
|
4
|
-
isNextLineEmpty,
|
|
5
|
-
isPrettier2
|
|
6
|
-
} from './backward-compatibility.js';
|
|
1
|
+
import { doc, util } from 'prettier';
|
|
7
2
|
|
|
8
3
|
const { group, indent, join, line, softline, hardline } = doc.builders;
|
|
4
|
+
const { isNextLineEmpty } = util;
|
|
9
5
|
|
|
10
6
|
export const printComments = (node, path, options, filter = () => true) => {
|
|
11
7
|
if (!node.comments) return '';
|
|
@@ -26,14 +22,7 @@ export const printComments = (node, path, options, filter = () => true) => {
|
|
|
26
22
|
.filter(Boolean)
|
|
27
23
|
);
|
|
28
24
|
|
|
29
|
-
|
|
30
|
-
// since it depends on the version of Prettier being used.
|
|
31
|
-
// Mocking the behaviour will introduce a lot of maintenance in the tests.
|
|
32
|
-
/* c8 ignore start */
|
|
33
|
-
return isPrettier2
|
|
34
|
-
? document.parts // Prettier V2
|
|
35
|
-
: document; // Prettier V3
|
|
36
|
-
/* c8 ignore stop */
|
|
25
|
+
return document;
|
|
37
26
|
};
|
|
38
27
|
|
|
39
28
|
export function printPreservingEmptyLines(path, key, options, print) {
|
|
@@ -56,7 +45,7 @@ export function printPreservingEmptyLines(path, key, options, print) {
|
|
|
56
45
|
|
|
57
46
|
// Only attempt to append an empty line if `node` is not the last item
|
|
58
47
|
if (
|
|
59
|
-
!isLast
|
|
48
|
+
!childPath.isLast &&
|
|
60
49
|
isNextLineEmpty(options.originalText, options.locEnd(node) + 1)
|
|
61
50
|
) {
|
|
62
51
|
// Append an empty line if the original text already had an one after
|
package/src/index.ts
CHANGED
|
@@ -51,10 +51,8 @@ const parsers = {
|
|
|
51
51
|
[antlrParserId]: antlrParser
|
|
52
52
|
};
|
|
53
53
|
|
|
54
|
-
const antlrCanAttachComment = (
|
|
55
|
-
typeof
|
|
56
|
-
node.type !== 'BlockComment' &&
|
|
57
|
-
node.type !== 'LineComment';
|
|
54
|
+
const antlrCanAttachComment = ({ type }: { type: string }): boolean =>
|
|
55
|
+
typeof type === 'string' && type !== 'BlockComment' && type !== 'LineComment';
|
|
58
56
|
const canAttachComment = (node: AstNode): boolean =>
|
|
59
57
|
typeof node !== 'string' &&
|
|
60
58
|
typeof node !== 'undefined' &&
|
package/src/nodes/Conditional.js
CHANGED
|
@@ -4,7 +4,7 @@ import { printSeparatedItem } from '../common/printer-helpers.js';
|
|
|
4
4
|
const { group, hardline, ifBreak, indent, line, softline } = doc.builders;
|
|
5
5
|
|
|
6
6
|
const experimentalTernaries = (node, path, print, options) => {
|
|
7
|
-
const parent = path
|
|
7
|
+
const { parent } = path;
|
|
8
8
|
const isNested = parent.type === 'Conditional';
|
|
9
9
|
const isNestedAsTrueExpression = isNested && parent.trueExpression === node;
|
|
10
10
|
const falseExpressionIsNested = node.falseExpression.type === 'Conditional';
|
|
@@ -68,7 +68,7 @@ const traditionalTernaries = (path, print) =>
|
|
|
68
68
|
indent([
|
|
69
69
|
// Nested trueExpression and falseExpression are always printed in a new
|
|
70
70
|
// line
|
|
71
|
-
path.
|
|
71
|
+
path.parent.type === 'Conditional' ? hardline : line,
|
|
72
72
|
'? ',
|
|
73
73
|
path.call(print, 'trueExpression'),
|
|
74
74
|
line,
|
|
@@ -1,5 +1,4 @@
|
|
|
1
|
-
import { doc } from 'prettier';
|
|
2
|
-
import { getNextNonSpaceNonCommentCharacter } from '../common/backward-compatibility.js';
|
|
1
|
+
import { doc, util } from 'prettier';
|
|
3
2
|
import {
|
|
4
3
|
printComments,
|
|
5
4
|
printSeparatedItem,
|
|
@@ -7,6 +6,7 @@ import {
|
|
|
7
6
|
} from '../common/printer-helpers.js';
|
|
8
7
|
|
|
9
8
|
const { dedent, group, indent, join, line } = doc.builders;
|
|
9
|
+
const { getNextNonSpaceNonCommentCharacter } = util;
|
|
10
10
|
|
|
11
11
|
const functionName = (node, options) => {
|
|
12
12
|
if (node.isConstructor && !node.name) return 'constructor';
|
|
@@ -40,8 +40,7 @@ const parameters = (parametersType, node, path, print, options) => {
|
|
|
40
40
|
(comment) =>
|
|
41
41
|
getNextNonSpaceNonCommentCharacter(
|
|
42
42
|
options.originalText,
|
|
43
|
-
comment
|
|
44
|
-
options.locEnd
|
|
43
|
+
options.locEnd(comment)
|
|
45
44
|
) === ')'
|
|
46
45
|
);
|
|
47
46
|
return parameterComments.length > 0
|
|
@@ -30,7 +30,11 @@ export const ImportDirective = {
|
|
|
30
30
|
let firstSeparator;
|
|
31
31
|
let separator;
|
|
32
32
|
|
|
33
|
-
if (
|
|
33
|
+
if (
|
|
34
|
+
compiler &&
|
|
35
|
+
satisfies(compiler, '>=0.7.4') &&
|
|
36
|
+
symbolAliases.length > 1
|
|
37
|
+
) {
|
|
34
38
|
// if the compiler exists and is greater than or equal to 0.7.4 we will
|
|
35
39
|
// split the ImportDirective.
|
|
36
40
|
firstSeparator = options.bracketSpacing ? line : softline;
|
package/src/options.ts
CHANGED
|
@@ -48,6 +48,22 @@ const options: SupportOptions = {
|
|
|
48
48
|
oppositeDescription:
|
|
49
49
|
'Default behavior of ternaries; keep question marks on the same line as the consequent.'
|
|
50
50
|
},
|
|
51
|
+
experimentalOperatorPosition: {
|
|
52
|
+
category: CATEGORY_JAVASCRIPT,
|
|
53
|
+
type: 'choice',
|
|
54
|
+
default: 'end',
|
|
55
|
+
description: 'Where to print operators when binary expressions wrap lines.',
|
|
56
|
+
choices: [
|
|
57
|
+
{
|
|
58
|
+
value: 'start',
|
|
59
|
+
description: 'Print operators at the start of new lines.'
|
|
60
|
+
},
|
|
61
|
+
{
|
|
62
|
+
value: 'end',
|
|
63
|
+
description: 'Print operators at the end of previous lines.'
|
|
64
|
+
}
|
|
65
|
+
]
|
|
66
|
+
},
|
|
51
67
|
compiler: {
|
|
52
68
|
category: CATEGORY_SOLIDITY,
|
|
53
69
|
type: 'string',
|
package/src/parser.js
CHANGED
|
@@ -176,6 +176,10 @@ function parse(text, _parsers, options = _parsers) {
|
|
|
176
176
|
'&'
|
|
177
177
|
]);
|
|
178
178
|
break;
|
|
179
|
+
case '==':
|
|
180
|
+
case '!=':
|
|
181
|
+
ctx.left = tryHug(ctx.left, ['==', '!=']);
|
|
182
|
+
break;
|
|
179
183
|
case '||':
|
|
180
184
|
ctx.left = tryHug(ctx.left, ['&&']);
|
|
181
185
|
ctx.right = tryHug(ctx.right, ['&&']);
|
|
@@ -1,12 +1,13 @@
|
|
|
1
1
|
import { util } from "prettier";
|
|
2
|
-
import { getNextNonSpaceNonCommentCharacter } from "../../common/backward-compatibility.js";
|
|
3
2
|
|
|
4
3
|
const {
|
|
5
4
|
addLeadingComment,
|
|
6
5
|
addTrailingComment,
|
|
7
6
|
addDanglingComment,
|
|
8
7
|
hasNewline,
|
|
9
|
-
hasNewlineInRange
|
|
8
|
+
hasNewlineInRange,
|
|
9
|
+
getNextNonSpaceNonCommentCharacter,
|
|
10
|
+
getNextNonSpaceNonCommentCharacterIndex
|
|
10
11
|
} = util
|
|
11
12
|
|
|
12
13
|
export function handleOwnLineComment(comment, text, options, ast, isLastComment) {
|
|
@@ -242,8 +243,7 @@ function handleIfStatementComments(
|
|
|
242
243
|
// it is a ).
|
|
243
244
|
const nextCharacter = getNextNonSpaceNonCommentCharacter(
|
|
244
245
|
text,
|
|
245
|
-
comment
|
|
246
|
-
options.locEnd
|
|
246
|
+
options.locEnd(comment)
|
|
247
247
|
);
|
|
248
248
|
if (nextCharacter === ")") {
|
|
249
249
|
addTrailingComment(precedingNode, comment);
|
|
@@ -311,8 +311,7 @@ function handleWhileComments(
|
|
|
311
311
|
// it is a ).
|
|
312
312
|
const nextCharacter = getNextNonSpaceNonCommentCharacter(
|
|
313
313
|
text,
|
|
314
|
-
comment
|
|
315
|
-
options.locEnd
|
|
314
|
+
options.locEnd(comment)
|
|
316
315
|
);
|
|
317
316
|
if (nextCharacter === ")") {
|
|
318
317
|
addTrailingComment(precedingNode, comment);
|
|
@@ -470,8 +469,7 @@ function handleMethodNameComments(
|
|
|
470
469
|
// comment should be attached to value instead of key
|
|
471
470
|
getNextNonSpaceNonCommentCharacter(
|
|
472
471
|
text,
|
|
473
|
-
precedingNode
|
|
474
|
-
options.locEnd
|
|
472
|
+
options.locEnd(precedingNode)
|
|
475
473
|
) !== ":"
|
|
476
474
|
) {
|
|
477
475
|
addTrailingComment(precedingNode, comment);
|
|
@@ -507,8 +505,7 @@ function handleFunctionNameComments(
|
|
|
507
505
|
if (
|
|
508
506
|
getNextNonSpaceNonCommentCharacter(
|
|
509
507
|
text,
|
|
510
|
-
comment
|
|
511
|
-
options.locEnd
|
|
508
|
+
options.locEnd(comment)
|
|
512
509
|
) !== "("
|
|
513
510
|
) {
|
|
514
511
|
return false;
|
|
@@ -536,8 +533,7 @@ function handleCommentAfterArrowParams(text, enclosingNode, comment, options) {
|
|
|
536
533
|
|
|
537
534
|
const index = getNextNonSpaceNonCommentCharacterIndex(
|
|
538
535
|
text,
|
|
539
|
-
comment
|
|
540
|
-
options
|
|
536
|
+
options.locEnd(comment)
|
|
541
537
|
);
|
|
542
538
|
if (text.substr(index, 2) === "=>") {
|
|
543
539
|
addDanglingComment(enclosingNode, comment);
|
|
@@ -551,8 +547,7 @@ function handleCommentInEmptyParens(text, enclosingNode, comment, options) {
|
|
|
551
547
|
if (
|
|
552
548
|
getNextNonSpaceNonCommentCharacter(
|
|
553
549
|
text,
|
|
554
|
-
comment
|
|
555
|
-
options.locEnd
|
|
550
|
+
options.locEnd(comment)
|
|
556
551
|
) !== ")"
|
|
557
552
|
) {
|
|
558
553
|
return false;
|
|
@@ -622,8 +617,7 @@ function handleLastFunctionArgComments(
|
|
|
622
617
|
enclosingNode.type === "ClassMethod") &&
|
|
623
618
|
getNextNonSpaceNonCommentCharacter(
|
|
624
619
|
text,
|
|
625
|
-
comment
|
|
626
|
-
options.locEnd
|
|
620
|
+
options.locEnd(comment)
|
|
627
621
|
) === ")"
|
|
628
622
|
) {
|
|
629
623
|
addTrailingComment(precedingNode, comment);
|
package/src/printer.js
CHANGED
|
@@ -1,9 +1,6 @@
|
|
|
1
1
|
import * as nodes from './nodes/index.js';
|
|
2
2
|
import { printWarning } from './common/print-warning.js';
|
|
3
|
-
import {
|
|
4
|
-
hasNodeIgnoreComment,
|
|
5
|
-
prettierVersionSatisfies
|
|
6
|
-
} from './common/util.js';
|
|
3
|
+
import { hasNodeIgnoreComment } from './common/util.js';
|
|
7
4
|
import ignoreComments from './comments/ignore.js';
|
|
8
5
|
|
|
9
6
|
function once(factory) {
|