@haneullabs/prettier-plugin-move 0.3.3
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/CHANGELOG.md +67 -0
- package/CONTRIBUTING.md +31 -0
- package/README.md +96 -0
- package/bin/prettier-move.js +29 -0
- package/out/cst/annotation.js +64 -0
- package/out/cst/annotation.js.map +1 -0
- package/out/cst/common.js +376 -0
- package/out/cst/common.js.map +1 -0
- package/out/cst/constant.js +92 -0
- package/out/cst/constant.js.map +1 -0
- package/out/cst/enum_definition.js +69 -0
- package/out/cst/enum_definition.js.map +1 -0
- package/out/cst/expression/abort_expression.js +32 -0
- package/out/cst/expression/abort_expression.js.map +1 -0
- package/out/cst/expression/annotation_expression.js +35 -0
- package/out/cst/expression/annotation_expression.js.map +1 -0
- package/out/cst/expression/assign_expression.js +51 -0
- package/out/cst/expression/assign_expression.js.map +1 -0
- package/out/cst/expression/binary_expression.js +70 -0
- package/out/cst/expression/binary_expression.js.map +1 -0
- package/out/cst/expression/block.js +58 -0
- package/out/cst/expression/block.js.map +1 -0
- package/out/cst/expression/block_item.js +25 -0
- package/out/cst/expression/block_item.js.map +1 -0
- package/out/cst/expression/borrow_expression.js +26 -0
- package/out/cst/expression/borrow_expression.js.map +1 -0
- package/out/cst/expression/break_expression.js +27 -0
- package/out/cst/expression/break_expression.js.map +1 -0
- package/out/cst/expression/call_expression.js +25 -0
- package/out/cst/expression/call_expression.js.map +1 -0
- package/out/cst/expression/cast_expression.js +31 -0
- package/out/cst/expression/cast_expression.js.map +1 -0
- package/out/cst/expression/continue_expression.js +26 -0
- package/out/cst/expression/continue_expression.js.map +1 -0
- package/out/cst/expression/dereference_expression.js +27 -0
- package/out/cst/expression/dereference_expression.js.map +1 -0
- package/out/cst/expression/dot_expression.js +66 -0
- package/out/cst/expression/dot_expression.js.map +1 -0
- package/out/cst/expression/expression_list.js +26 -0
- package/out/cst/expression/expression_list.js.map +1 -0
- package/out/cst/expression/identified_expression.js +28 -0
- package/out/cst/expression/identified_expression.js.map +1 -0
- package/out/cst/expression/if_expression.js +133 -0
- package/out/cst/expression/if_expression.js.map +1 -0
- package/out/cst/expression/index.js +74 -0
- package/out/cst/expression/index.js.map +1 -0
- package/out/cst/expression/index_expression.js +28 -0
- package/out/cst/expression/index_expression.js.map +1 -0
- package/out/cst/expression/lambda_expression.js +72 -0
- package/out/cst/expression/lambda_expression.js.map +1 -0
- package/out/cst/expression/let_statement.js +59 -0
- package/out/cst/expression/let_statement.js.map +1 -0
- package/out/cst/expression/loop_expression.js +27 -0
- package/out/cst/expression/loop_expression.js.map +1 -0
- package/out/cst/expression/macro_call_expression.js +66 -0
- package/out/cst/expression/macro_call_expression.js.map +1 -0
- package/out/cst/expression/match_expression.js +86 -0
- package/out/cst/expression/match_expression.js.map +1 -0
- package/out/cst/expression/move_or_copy_expression.js +27 -0
- package/out/cst/expression/move_or_copy_expression.js.map +1 -0
- package/out/cst/expression/name_expression.js +26 -0
- package/out/cst/expression/name_expression.js.map +1 -0
- package/out/cst/expression/pack_expression.js +27 -0
- package/out/cst/expression/pack_expression.js.map +1 -0
- package/out/cst/expression/return_expression.js +44 -0
- package/out/cst/expression/return_expression.js.map +1 -0
- package/out/cst/expression/unary_expression.js +26 -0
- package/out/cst/expression/unary_expression.js.map +1 -0
- package/out/cst/expression/unit_expression.js +17 -0
- package/out/cst/expression/unit_expression.js.map +1 -0
- package/out/cst/expression/vector_expression.js +80 -0
- package/out/cst/expression/vector_expression.js.map +1 -0
- package/out/cst/expression/while_expression.js +42 -0
- package/out/cst/expression/while_expression.js.map +1 -0
- package/out/cst/formatting.js +100 -0
- package/out/cst/formatting.js.map +1 -0
- package/out/cst/function_definition.js +248 -0
- package/out/cst/function_definition.js.map +1 -0
- package/out/cst/literal.js +68 -0
- package/out/cst/literal.js.map +1 -0
- package/out/cst/module.js +158 -0
- package/out/cst/module.js.map +1 -0
- package/out/cst/source_file.js +38 -0
- package/out/cst/source_file.js.map +1 -0
- package/out/cst/struct_definition.js +209 -0
- package/out/cst/struct_definition.js.map +1 -0
- package/out/cst/use_declaration.js +212 -0
- package/out/cst/use_declaration.js.map +1 -0
- package/out/imports-grouping.js +259 -0
- package/out/imports-grouping.js.map +1 -0
- package/out/index.js +97 -0
- package/out/index.js.map +1 -0
- package/out/printer.js +69 -0
- package/out/printer.js.map +1 -0
- package/out/tree.js +371 -0
- package/out/tree.js.map +1 -0
- package/out/utilities.js +251 -0
- package/out/utilities.js.map +1 -0
- package/package.json +34 -0
- package/prettier.config.js +12 -0
- package/src/cst/annotation.ts +71 -0
- package/src/cst/common.ts +430 -0
- package/src/cst/constant.ts +110 -0
- package/src/cst/enum_definition.ts +73 -0
- package/src/cst/expression/abort_expression.ts +35 -0
- package/src/cst/expression/annotation_expression.ts +38 -0
- package/src/cst/expression/assign_expression.ts +66 -0
- package/src/cst/expression/binary_expression.ts +75 -0
- package/src/cst/expression/block.ts +72 -0
- package/src/cst/expression/block_item.ts +29 -0
- package/src/cst/expression/borrow_expression.ts +28 -0
- package/src/cst/expression/break_expression.ts +33 -0
- package/src/cst/expression/call_expression.ts +28 -0
- package/src/cst/expression/cast_expression.ts +35 -0
- package/src/cst/expression/continue_expression.ts +29 -0
- package/src/cst/expression/dereference_expression.ts +33 -0
- package/src/cst/expression/dot_expression.ts +89 -0
- package/src/cst/expression/expression_list.ts +28 -0
- package/src/cst/expression/identified_expression.ts +30 -0
- package/src/cst/expression/if_expression.ts +177 -0
- package/src/cst/expression/index.ts +85 -0
- package/src/cst/expression/index_expression.ts +37 -0
- package/src/cst/expression/lambda_expression.ts +84 -0
- package/src/cst/expression/let_statement.ts +73 -0
- package/src/cst/expression/loop_expression.ts +29 -0
- package/src/cst/expression/macro_call_expression.ts +79 -0
- package/src/cst/expression/match_expression.ts +102 -0
- package/src/cst/expression/move_or_copy_expression.ts +29 -0
- package/src/cst/expression/name_expression.ts +28 -0
- package/src/cst/expression/pack_expression.ts +29 -0
- package/src/cst/expression/return_expression.ts +50 -0
- package/src/cst/expression/unary_expression.ts +28 -0
- package/src/cst/expression/unit_expression.ts +18 -0
- package/src/cst/expression/vector_expression.ts +97 -0
- package/src/cst/expression/while_expression.ts +45 -0
- package/src/cst/formatting.ts +100 -0
- package/src/cst/function_definition.ts +300 -0
- package/src/cst/literal.ts +69 -0
- package/src/cst/module.ts +191 -0
- package/src/cst/source_file.ts +38 -0
- package/src/cst/struct_definition.ts +267 -0
- package/src/cst/use_declaration.ts +238 -0
- package/src/imports-grouping.ts +300 -0
- package/src/index.ts +119 -0
- package/src/printer.ts +93 -0
- package/src/tree.ts +438 -0
- package/src/utilities.ts +387 -0
- package/tree-sitter-move.wasm +0 -0
- package/tsconfig.json +26 -0
|
@@ -0,0 +1,27 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
// Copyright (c) The Move Contributors
|
|
3
|
+
// SPDX-License-Identifier: Apache-2.0
|
|
4
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
5
|
+
exports.NODE_TYPE = void 0;
|
|
6
|
+
exports.default = default_1;
|
|
7
|
+
const prettier_1 = require("prettier");
|
|
8
|
+
const {} = prettier_1.doc.builders;
|
|
9
|
+
/** The type of the node implemented in this file */
|
|
10
|
+
exports.NODE_TYPE = 'dereference_expression';
|
|
11
|
+
function default_1(path) {
|
|
12
|
+
if (path.node.type === exports.NODE_TYPE) {
|
|
13
|
+
return printDereferenceExpression;
|
|
14
|
+
}
|
|
15
|
+
return null;
|
|
16
|
+
}
|
|
17
|
+
/**
|
|
18
|
+
* Print `dereference_expression` node.
|
|
19
|
+
*
|
|
20
|
+
* Inside:
|
|
21
|
+
* - `*`
|
|
22
|
+
* - `_expression`
|
|
23
|
+
*/
|
|
24
|
+
function printDereferenceExpression(path, options, print) {
|
|
25
|
+
return ['*', path.call(print, 'nonFormattingChildren', 0)];
|
|
26
|
+
}
|
|
27
|
+
//# sourceMappingURL=dereference_expression.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"dereference_expression.js","sourceRoot":"","sources":["../../../src/cst/expression/dereference_expression.ts"],"names":[],"mappings":";AAAA,sCAAsC;AACtC,sCAAsC;;;AAUtC,4BAMC;AAZD,uCAA6C;AAC7C,MAAM,EAAE,GAAG,cAAG,CAAC,QAAQ,CAAC;AAExB,oDAAoD;AACvC,QAAA,SAAS,GAAG,wBAAwB,CAAC;AAElD,mBAAyB,IAAmB;IACxC,IAAI,IAAI,CAAC,IAAI,CAAC,IAAI,KAAK,iBAAS,EAAE,CAAC;QAC/B,OAAO,0BAA0B,CAAC;IACtC,CAAC;IAED,OAAO,IAAI,CAAC;AAChB,CAAC;AAED;;;;;;GAMG;AACH,SAAS,0BAA0B,CAC/B,IAAmB,EACnB,OAAoB,EACpB,KAAc;IAEd,OAAO,CAAC,GAAG,EAAE,IAAI,CAAC,IAAI,CAAC,KAAK,EAAE,uBAAuB,EAAE,CAAC,CAAC,CAAC,CAAC;AAC/D,CAAC"}
|
|
@@ -0,0 +1,66 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
// Copyright (c) The Move Contributors
|
|
3
|
+
// SPDX-License-Identifier: Apache-2.0
|
|
4
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
5
|
+
exports.NODE_TYPE = void 0;
|
|
6
|
+
exports.default = default_1;
|
|
7
|
+
const prettier_1 = require("prettier");
|
|
8
|
+
const utilities_1 = require("../../utilities");
|
|
9
|
+
const { group, indent, ifBreak, breakParent, lineSuffix, softline } = prettier_1.doc.builders;
|
|
10
|
+
/** The type of the node implemented in this file */
|
|
11
|
+
exports.NODE_TYPE = 'dot_expression';
|
|
12
|
+
function default_1(path) {
|
|
13
|
+
if (path.node.type === exports.NODE_TYPE) {
|
|
14
|
+
return printDotExpression;
|
|
15
|
+
}
|
|
16
|
+
return null;
|
|
17
|
+
}
|
|
18
|
+
/**
|
|
19
|
+
* Print `dot_expression` node.
|
|
20
|
+
*
|
|
21
|
+
* Note, that it's intentional, that the return value is not a `group`. For more info,
|
|
22
|
+
* @see [This Issue](https://github.com/prettier/prettier/issues/15710#issuecomment-1836701758)
|
|
23
|
+
*/
|
|
24
|
+
function printDotExpression(path, options, print) {
|
|
25
|
+
if (path.node.nonFormattingChildren.length < 2) {
|
|
26
|
+
throw new Error('`dot_expression` node should have at least 2 children');
|
|
27
|
+
}
|
|
28
|
+
// chain is a `dot_expression` that is a child of another `dot_expression`
|
|
29
|
+
// or which has a `dot_expression` as a child
|
|
30
|
+
const isChain = path.node.nonFormattingChildren[0].type === exports.NODE_TYPE ||
|
|
31
|
+
path.node.parent?.type === exports.NODE_TYPE;
|
|
32
|
+
const isParentList = path.node.parent?.isList;
|
|
33
|
+
// if dot expression has a trailing comment and it breaks, we need to
|
|
34
|
+
// print it manually after the rhs
|
|
35
|
+
const trailing = lineSuffix((0, utilities_1.printTrailingComment)(path));
|
|
36
|
+
const lhs = path.call((path) => printNode(path, options, print, false), 'nonFormattingChildren', 0);
|
|
37
|
+
const rhs = path.call((path) => printNode(path, options, print, true), 'nonFormattingChildren', 1);
|
|
38
|
+
// if it's a single expression, we don't need to group it
|
|
39
|
+
// and optionally no need to break it; no need to special
|
|
40
|
+
// print it in this case
|
|
41
|
+
if (!isChain) {
|
|
42
|
+
const right = path.node.nonFormattingChildren[1];
|
|
43
|
+
if (right.leadingComment.length > 0) {
|
|
44
|
+
path.node.disableTrailingComment();
|
|
45
|
+
return [lhs, indent(softline), indent(rhs), trailing];
|
|
46
|
+
}
|
|
47
|
+
return [lhs, rhs];
|
|
48
|
+
}
|
|
49
|
+
path.node.disableTrailingComment();
|
|
50
|
+
const parts = [lhs, ifBreak(indent(softline), ''), ifBreak(indent(rhs), rhs), trailing];
|
|
51
|
+
// group if parent is not `dot_expression`
|
|
52
|
+
if (isChain && path.node.parent?.type !== exports.NODE_TYPE) {
|
|
53
|
+
return group(parts);
|
|
54
|
+
}
|
|
55
|
+
return parts;
|
|
56
|
+
}
|
|
57
|
+
// In `dot_expression` we need to keep the `.` in the same line as the `rhs`,
|
|
58
|
+
// so we need to prevent automatic printing of comments in the `print` call, and
|
|
59
|
+
// perform it manually.
|
|
60
|
+
function printNode(path, options, print, insertDot = false) {
|
|
61
|
+
const leading = (0, utilities_1.printLeadingComment)(path, options);
|
|
62
|
+
const shouldBreak = path.node.leadingComment.length > 0 || path.node.trailingComment?.type === 'line_comment';
|
|
63
|
+
path.node.disableLeadingComment();
|
|
64
|
+
return [leading, shouldBreak ? breakParent : '', insertDot ? '.' : '', print(path)];
|
|
65
|
+
}
|
|
66
|
+
//# sourceMappingURL=dot_expression.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"dot_expression.js","sourceRoot":"","sources":["../../../src/cst/expression/dot_expression.ts"],"names":[],"mappings":";AAAA,sCAAsC;AACtC,sCAAsC;;;AAWtC,4BAMC;AAbD,uCAA6C;AAC7C,+CAA4E;AAC5E,MAAM,EAAE,KAAK,EAAE,MAAM,EAAE,OAAO,EAAE,WAAW,EAAE,UAAU,EAAE,QAAQ,EAAE,GAAG,cAAG,CAAC,QAAQ,CAAC;AAEnF,oDAAoD;AACvC,QAAA,SAAS,GAAG,gBAAgB,CAAC;AAE1C,mBAAyB,IAAmB;IACxC,IAAI,IAAI,CAAC,IAAI,CAAC,IAAI,KAAK,iBAAS,EAAE,CAAC;QAC/B,OAAO,kBAAkB,CAAC;IAC9B,CAAC;IAED,OAAO,IAAI,CAAC;AAChB,CAAC;AAED;;;;;GAKG;AACH,SAAS,kBAAkB,CAAC,IAAmB,EAAE,OAAoB,EAAE,KAAc;IACjF,IAAI,IAAI,CAAC,IAAI,CAAC,qBAAqB,CAAC,MAAM,GAAG,CAAC,EAAE,CAAC;QAC7C,MAAM,IAAI,KAAK,CAAC,uDAAuD,CAAC,CAAC;IAC7E,CAAC;IAED,0EAA0E;IAC1E,6CAA6C;IAC7C,MAAM,OAAO,GACT,IAAI,CAAC,IAAI,CAAC,qBAAqB,CAAC,CAAC,CAAE,CAAC,IAAI,KAAK,iBAAS;QACtD,IAA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GAAG,CAAC,EAAE,GAAG,CAAC,EAAE,QAAQ,CAAC,CAAC;IAExF,0CAA0C;IAC1C,IAAI,OAAO,IAAI,IAAI,CAAC,IAAI,CAAC,MAAM,EAAE,IAAI,KAAK,iBAAS,EAAE,CAAC;QAClD,OAAO,KAAK,CAAC,KAAK,CAAC,CAAC;IACxB,CAAC;IAED,OAAO,KAAK,CAAC;AACjB,CAAC;AAED,6EAA6E;AAC7E,gFAAgF;AAChF,uBAAuB;AACvB,SAAS,SAAS,CAAC,IAAmB,EAAE,OAAoB,EAAE,KAAc,EAAE,SAAS,GAAG,KAAK;IAC3F,MAAM,OAAO,GAAG,IAAA,+BAAmB,EAAC,IAAI,EAAE,OAAO,CAAC,CAAC;IACnD,MAAM,WAAW,GACb,IAAI,CAAC,IAAI,CAAC,cAAc,CAAC,MAAM,GAAG,CAAC,IAAI,IAAI,CAAC,IAAI,CAAC,eAAe,EAAE,IAAI,KAAK,cAAc,CAAC;IAE9F,IAAI,CAAC,IAAI,CAAC,qBAAqB,EAAE,CAAC;IAClC,OAAO,CAAC,OAAO,EAAE,WAAW,CAAC,CAAC,CAAC,WAAW,CAAC,CAAC,CAAC,EAAE,EAAE,SAAS,CAAC,CAAC,CAAC,GAAG,CAAC,CAAC,CAAC,EAAE,EAAE,KAAK,CAAC,IAAI,CAAC,CAAC,CAAC;AACxF,CAAC"}
|
|
@@ -0,0 +1,26 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
// Copyright (c) The Move Contributors
|
|
3
|
+
// SPDX-License-Identifier: Apache-2.0
|
|
4
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
5
|
+
exports.NODE_TYPE = void 0;
|
|
6
|
+
exports.default = default_1;
|
|
7
|
+
const prettier_1 = require("prettier");
|
|
8
|
+
const utilities_1 = require("../../utilities");
|
|
9
|
+
const { group } = prettier_1.doc.builders;
|
|
10
|
+
/** The type of the node implemented in this file */
|
|
11
|
+
exports.NODE_TYPE = 'expression_list';
|
|
12
|
+
function default_1(path) {
|
|
13
|
+
if (path.node.type === exports.NODE_TYPE) {
|
|
14
|
+
return printExpressionList;
|
|
15
|
+
}
|
|
16
|
+
return null;
|
|
17
|
+
}
|
|
18
|
+
/**
|
|
19
|
+
* Print `expression_list` node.
|
|
20
|
+
*/
|
|
21
|
+
function printExpressionList(path, options, print) {
|
|
22
|
+
return group((0, utilities_1.list)({ path, print, options, open: '(', close: ')' }), {
|
|
23
|
+
shouldBreak: false,
|
|
24
|
+
});
|
|
25
|
+
}
|
|
26
|
+
//# sourceMappingURL=expression_list.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"expression_list.js","sourceRoot":"","sources":["../../../src/cst/expression/expression_list.ts"],"names":[],"mappings":";AAAA,sCAAsC;AACtC,sCAAsC;;;AAWtC,4BAMC;AAbD,uCAA6C;AAC7C,+CAAuC;AACvC,MAAM,EAAE,KAAK,EAAE,GAAG,cAAG,CAAC,QAAQ,CAAC;AAE/B,oDAAoD;AACvC,QAAA,SAAS,GAAG,iBAAiB,CAAC;AAE3C,mBAAyB,IAAmB;IACxC,IAAI,IAAI,CAAC,IAAI,CAAC,IAAI,KAAK,iBAAS,EAAE,CAAC;QAC/B,OAAO,mBAAmB,CAAC;IAC/B,CAAC;IAED,OAAO,IAAI,CAAC;AAChB,CAAC;AAED;;GAEG;AACH,SAAS,mBAAmB,CAAC,IAAmB,EAAE,OAAoB,EAAE,KAAc;IAClF,OAAO,KAAK,CAAC,IAAA,gBAAI,EAAC,EAAE,IAAI,EAAE,KAAK,EAAE,OAAO,EAAE,IAAI,EAAE,GAAG,EAAE,KAAK,EAAE,GAAG,EAAE,CAAC,EAAE;QAChE,WAAW,EAAE,KAAK;KACrB,CAAC,CAAC;AACP,CAAC"}
|
|
@@ -0,0 +1,28 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
// Copyright (c) The Move Contributors
|
|
3
|
+
// SPDX-License-Identifier: Apache-2.0
|
|
4
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
5
|
+
exports.NODE_TYPE = void 0;
|
|
6
|
+
exports.default = default_1;
|
|
7
|
+
const prettier_1 = require("prettier");
|
|
8
|
+
const {} = prettier_1.doc.builders;
|
|
9
|
+
/** The type of the node implemented in this file */
|
|
10
|
+
exports.NODE_TYPE = 'identified_expression';
|
|
11
|
+
function default_1(path) {
|
|
12
|
+
if (path.node.type === exports.NODE_TYPE) {
|
|
13
|
+
return printIdentifiedExpression;
|
|
14
|
+
}
|
|
15
|
+
return null;
|
|
16
|
+
}
|
|
17
|
+
/**
|
|
18
|
+
* Print `identified_expression` node.
|
|
19
|
+
* Also known as `label` in the grammar or `labeled_expression`.
|
|
20
|
+
*/
|
|
21
|
+
function printIdentifiedExpression(path, options, print) {
|
|
22
|
+
return [
|
|
23
|
+
path.call(print, 'nonFormattingChildren', 0), // identifier
|
|
24
|
+
' ',
|
|
25
|
+
path.call(print, 'nonFormattingChildren', 1), // expression
|
|
26
|
+
];
|
|
27
|
+
}
|
|
28
|
+
//# sourceMappingURL=identified_expression.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"identified_expression.js","sourceRoot":"","sources":["../../../src/cst/expression/identified_expression.ts"],"names":[],"mappings":";AAAA,sCAAsC;AACtC,sCAAsC;;;AAUtC,4BAMC;AAZD,uCAA6C;AAC7C,MAAM,EAAE,GAAG,cAAG,CAAC,QAAQ,CAAC;AAExB,oDAAoD;AACvC,QAAA,SAAS,GAAG,uBAAuB,CAAC;AAEjD,mBAAyB,IAAmB;IACxC,IAAI,IAAI,CAAC,IAAI,CAAC,IAAI,KAAK,iBAAS,EAAE,CAAC;QAC/B,OAAO,yBAAyB,CAAC;IACrC,CAAC;IAED,OAAO,IAAI,CAAC;AAChB,CAAC;AAED;;;GAGG;AACH,SAAS,yBAAyB,CAAC,IAAmB,EAAE,OAAoB,EAAE,KAAc;IACxF,OAAO;QACH,IAAI,CAAC,IAAI,CAAC,KAAK,EAAE,uBAAuB,EAAE,CAAC,CAAC,EAAE,aAAa;QAC3D,GAAG;QACH,IAAI,CAAC,IAAI,CAAC,KAAK,EAAE,uBAAuB,EAAE,CAAC,CAAC,EAAE,aAAa;KAC9D,CAAC;AACN,CAAC"}
|
|
@@ -0,0 +1,133 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
// Copyright (c) The Move Contributors
|
|
3
|
+
// SPDX-License-Identifier: Apache-2.0
|
|
4
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
5
|
+
exports.NODE_TYPE = void 0;
|
|
6
|
+
exports.default = default_1;
|
|
7
|
+
const prettier_1 = require("prettier");
|
|
8
|
+
const utilities_1 = require("../../utilities");
|
|
9
|
+
const { group, softline, line, ifBreak, indent, lineSuffix, breakParent, hardlineWithoutBreakParent, } = prettier_1.doc.builders;
|
|
10
|
+
/** The type of the node implemented in this file */
|
|
11
|
+
exports.NODE_TYPE = 'if_expression';
|
|
12
|
+
function default_1(path) {
|
|
13
|
+
if (path.node.type === exports.NODE_TYPE) {
|
|
14
|
+
return printIfExpression;
|
|
15
|
+
}
|
|
16
|
+
return null;
|
|
17
|
+
}
|
|
18
|
+
/**
|
|
19
|
+
* Print `if_expression` node.
|
|
20
|
+
*
|
|
21
|
+
* ```
|
|
22
|
+
* // single line
|
|
23
|
+
* if (cond || cond) {}
|
|
24
|
+
*
|
|
25
|
+
* // multi line + block
|
|
26
|
+
* if (
|
|
27
|
+
* long_cond ||
|
|
28
|
+
* long_cond
|
|
29
|
+
* ) {
|
|
30
|
+
* long_expr;
|
|
31
|
+
* long_expr;
|
|
32
|
+
* }
|
|
33
|
+
*
|
|
34
|
+
* // multi line + single line
|
|
35
|
+
* if (cond) {
|
|
36
|
+
* return long_expr;
|
|
37
|
+
* }
|
|
38
|
+
*
|
|
39
|
+
* // multi line + single line + long expr
|
|
40
|
+
* if (
|
|
41
|
+
* long_cond ||
|
|
42
|
+
* long_cond
|
|
43
|
+
* ) {
|
|
44
|
+
* return long_expr &&
|
|
45
|
+
* long_expr;
|
|
46
|
+
* }
|
|
47
|
+
* ```
|
|
48
|
+
*/
|
|
49
|
+
function printIfExpression(path, options, print) {
|
|
50
|
+
if (path.node.nonFormattingChildren.length < 2) {
|
|
51
|
+
throw new Error('Invalid if_expression node');
|
|
52
|
+
}
|
|
53
|
+
const isChain = path.parent?.type == 'if_expression';
|
|
54
|
+
const hasElse = path.node.children.some((e) => e.type == 'else');
|
|
55
|
+
const condition = path.node.nonFormattingChildren[0];
|
|
56
|
+
const trueBranch = path.node.nonFormattingChildren[1];
|
|
57
|
+
const groupId = Symbol('if_expression_true');
|
|
58
|
+
const result = [];
|
|
59
|
+
const conditionPrinted = path.call((path) => {
|
|
60
|
+
let trailingComment = '';
|
|
61
|
+
if (path.node.trailingComment?.type == 'line_comment') {
|
|
62
|
+
trailingComment = lineSuffix((0, utilities_1.printTrailingComment)(path));
|
|
63
|
+
path.node.disableTrailingComment();
|
|
64
|
+
}
|
|
65
|
+
return [print(path), trailingComment ? [trailingComment, breakParent] : ''];
|
|
66
|
+
}, 'nonFormattingChildren', 0);
|
|
67
|
+
const conditionGroup = group([
|
|
68
|
+
'if (',
|
|
69
|
+
condition?.isList
|
|
70
|
+
? [indent(softline), conditionPrinted, softline]
|
|
71
|
+
: [indent(softline), indent(conditionPrinted), softline],
|
|
72
|
+
')',
|
|
73
|
+
]);
|
|
74
|
+
result.push(conditionGroup);
|
|
75
|
+
const isTrueList = trueBranch?.isList || false;
|
|
76
|
+
const trueHasComment = trueBranch.leadingComment.some((e) => e.type == 'line_comment') ||
|
|
77
|
+
trueBranch.trailingComment?.type == 'line_comment';
|
|
78
|
+
// true branch group
|
|
79
|
+
if (isTrueList) {
|
|
80
|
+
const truePrinted = path.call(print, 'nonFormattingChildren', 1);
|
|
81
|
+
result.push(group([' ', truePrinted], { shouldBreak: false }));
|
|
82
|
+
}
|
|
83
|
+
else {
|
|
84
|
+
const truePrinted = trueBranch.trailingComment?.type !== 'line_comment'
|
|
85
|
+
? path.call(print, 'nonFormattingChildren', 1)
|
|
86
|
+
: path.call((path) => {
|
|
87
|
+
const comment = lineSuffix((0, utilities_1.printTrailingComment)(path));
|
|
88
|
+
path.node.disableTrailingComment();
|
|
89
|
+
return [print(path), comment];
|
|
90
|
+
}, 'nonFormattingChildren', 1);
|
|
91
|
+
result.push(group([indent(line), indent(truePrinted)], {
|
|
92
|
+
id: groupId,
|
|
93
|
+
}));
|
|
94
|
+
}
|
|
95
|
+
// early return if there's no else block
|
|
96
|
+
if (!hasElse) {
|
|
97
|
+
return result;
|
|
98
|
+
}
|
|
99
|
+
const elseNode = path.node.nonFormattingChildren[2];
|
|
100
|
+
// modify the break condition for the else block
|
|
101
|
+
const elseShouldBreak = elseNode.leadingComment.some((e) => e.type == 'line_comment') ||
|
|
102
|
+
elseNode.trailingComment?.type == 'line_comment' ||
|
|
103
|
+
trueHasComment;
|
|
104
|
+
// if true branch is a list, and there's no line comment, we add a space,
|
|
105
|
+
// if there's a line comment, we add a line break
|
|
106
|
+
//
|
|
107
|
+
// also, if the else block is another `if_expression` we follow the same
|
|
108
|
+
// logic as above
|
|
109
|
+
if (isTrueList) {
|
|
110
|
+
result.push(group([line, 'else'], { shouldBreak: trueHasComment }));
|
|
111
|
+
result.push([' ', path.call(print, 'nonFormattingChildren', 2)]);
|
|
112
|
+
return result;
|
|
113
|
+
}
|
|
114
|
+
const elseBranchPrinted = path.call(print, 'nonFormattingChildren', 2);
|
|
115
|
+
// if true branch is not a list, and else is a list, we newline
|
|
116
|
+
if ((elseNode.isList && !isTrueList) || elseNode.type == 'if_expression' || isChain) {
|
|
117
|
+
result.push([hardlineWithoutBreakParent, 'else ', group(elseBranchPrinted)]);
|
|
118
|
+
return result;
|
|
119
|
+
}
|
|
120
|
+
result.push(group([
|
|
121
|
+
ifBreak([
|
|
122
|
+
hardlineWithoutBreakParent,
|
|
123
|
+
'else',
|
|
124
|
+
group([indent(line), indent(elseBranchPrinted)]),
|
|
125
|
+
], [
|
|
126
|
+
line,
|
|
127
|
+
'else',
|
|
128
|
+
group([indent(line), elseBranchPrinted], { shouldBreak: elseShouldBreak }),
|
|
129
|
+
]),
|
|
130
|
+
]));
|
|
131
|
+
return result;
|
|
132
|
+
}
|
|
133
|
+
//# sourceMappingURL=if_expression.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"if_expression.js","sourceRoot":"","sources":["../../../src/cst/expression/if_expression.ts"],"names":[],"mappings":";AAAA,sCAAsC;AACtC,sCAAsC;;;AAoBtC,4BAMC;AAtBD,uCAA6C;AAC7C,+CAAuD;AACvD,MAAM,EACF,KAAK,EACL,QAAQ,EACR,IAAI,EACJ,OAAO,EACP,MAAM,EACN,UAAU,EACV,WAAW,EACX,0BAA0B,GAC7B,GAAG,cAAG,CAAC,QAAQ,CAAC;AAEjB,oDAAoD;AACvC,QAAA,SAAS,GAAG,eAAe,CAAC;AAEzC,mBAAyB,IAAmB;IACxC,IAAI,IAAI,CAAC,IAAI,CAAC,IAAI,KAAK,iBAAS,EAAE,CAAC;QAC/B,OAAO,iBAAiB,CAAC;IAC7B,CAAC;IAED,OAAO,IAAI,CAAC;AAChB,CAAC;AAED;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;GA8BG;AACH,SAAS,iBAAiB,CAAC,IAAmB,EAAE,OAAoB,EAAE,KAAc;IAChF,IAAI,IAAI,CAAC,IAAI,CAAC,qBAAqB,CAAC,MAAM,GAAG,CAAC,EAAE,CAAC;QAC7C,MAAM,IAAI,KAAK,CAAC,4BAA4B,CAAC,CAAC;IAClD,CAAC;IAED,MAAM,OAAO,GAAG,IAAI,CAAC,MAAM,EAAE,IAAI,IAAI,eAAe,CAAC;IACrD,MAAM,OAAO,GAAG,IAAI,CAAC,IAAI,CAAC,QAAQ,CAAC,IAAI,CAAC,CAAC,CAAC,EAAE,EAAE,CAAC,CAAC,CAAC,IAAI,IAAI,MAAM,CAAC,CAAC;IACjE,MAAM,SAAS,GAAG,IAAI,CAAC,IAAI,CAAC,qBAAqB,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CACL,CAAC;IAEF,OAAO,MAAM,CAAC;AAClB,CAAC"}
|
|
@@ -0,0 +1,74 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
// Copyright (c) The Move Contributors
|
|
3
|
+
// SPDX-License-Identifier: Apache-2.0
|
|
4
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
5
|
+
exports.default = default_1;
|
|
6
|
+
// Folder imports:
|
|
7
|
+
const abort_expression_1 = require("./abort_expression");
|
|
8
|
+
const annotation_expression_1 = require("./annotation_expression");
|
|
9
|
+
const assign_expression_1 = require("./assign_expression");
|
|
10
|
+
const binary_expression_1 = require("./binary_expression");
|
|
11
|
+
const block_item_1 = require("./block_item");
|
|
12
|
+
const block_1 = require("./block");
|
|
13
|
+
const borrow_expression_1 = require("./borrow_expression");
|
|
14
|
+
const break_expression_1 = require("./break_expression");
|
|
15
|
+
const call_expression_1 = require("./call_expression");
|
|
16
|
+
const cast_expression_1 = require("./cast_expression");
|
|
17
|
+
const continue_expression_1 = require("./continue_expression");
|
|
18
|
+
const dereference_expression_1 = require("./dereference_expression");
|
|
19
|
+
const dot_expression_1 = require("./dot_expression");
|
|
20
|
+
const expression_list_1 = require("./expression_list");
|
|
21
|
+
const if_expression_1 = require("./if_expression");
|
|
22
|
+
const identified_expression_1 = require("./identified_expression");
|
|
23
|
+
const index_expression_1 = require("./index_expression");
|
|
24
|
+
const lambda_expression_1 = require("./lambda_expression");
|
|
25
|
+
const let_statement_1 = require("./let_statement");
|
|
26
|
+
const loop_expression_1 = require("./loop_expression");
|
|
27
|
+
const macro_call_expression_1 = require("./macro_call_expression");
|
|
28
|
+
const match_expression_1 = require("./match_expression");
|
|
29
|
+
const move_or_copy_expression_1 = require("./move_or_copy_expression");
|
|
30
|
+
const name_expression_1 = require("./name_expression");
|
|
31
|
+
const pack_expression_1 = require("./pack_expression");
|
|
32
|
+
const return_expression_1 = require("./return_expression");
|
|
33
|
+
const unary_expression_1 = require("./unary_expression");
|
|
34
|
+
const unit_expression_1 = require("./unit_expression");
|
|
35
|
+
const vector_expression_1 = require("./vector_expression");
|
|
36
|
+
const while_expression_1 = require("./while_expression");
|
|
37
|
+
function default_1(path) {
|
|
38
|
+
// route to separated functions
|
|
39
|
+
const result = (0, abort_expression_1.default)(path) ||
|
|
40
|
+
(0, annotation_expression_1.default)(path) ||
|
|
41
|
+
(0, assign_expression_1.default)(path) ||
|
|
42
|
+
(0, binary_expression_1.default)(path) ||
|
|
43
|
+
(0, block_item_1.default)(path) ||
|
|
44
|
+
(0, block_1.default)(path) ||
|
|
45
|
+
(0, borrow_expression_1.default)(path) ||
|
|
46
|
+
(0, break_expression_1.default)(path) ||
|
|
47
|
+
(0, call_expression_1.default)(path) ||
|
|
48
|
+
(0, cast_expression_1.default)(path) ||
|
|
49
|
+
(0, continue_expression_1.default)(path) ||
|
|
50
|
+
(0, dereference_expression_1.default)(path) ||
|
|
51
|
+
(0, dot_expression_1.default)(path) ||
|
|
52
|
+
(0, expression_list_1.default)(path) ||
|
|
53
|
+
(0, if_expression_1.default)(path) ||
|
|
54
|
+
(0, identified_expression_1.default)(path) ||
|
|
55
|
+
(0, index_expression_1.default)(path) ||
|
|
56
|
+
(0, lambda_expression_1.default)(path) ||
|
|
57
|
+
(0, let_statement_1.default)(path) ||
|
|
58
|
+
(0, loop_expression_1.default)(path) ||
|
|
59
|
+
(0, macro_call_expression_1.default)(path) ||
|
|
60
|
+
(0, match_expression_1.default)(path) ||
|
|
61
|
+
(0, move_or_copy_expression_1.default)(path) ||
|
|
62
|
+
(0, name_expression_1.default)(path) ||
|
|
63
|
+
(0, pack_expression_1.default)(path) ||
|
|
64
|
+
(0, return_expression_1.default)(path) ||
|
|
65
|
+
(0, unary_expression_1.default)(path) ||
|
|
66
|
+
(0, unit_expression_1.default)(path) ||
|
|
67
|
+
(0, vector_expression_1.default)(path) ||
|
|
68
|
+
(0, while_expression_1.default)(path);
|
|
69
|
+
if (result !== null) {
|
|
70
|
+
return result;
|
|
71
|
+
}
|
|
72
|
+
return null;
|
|
73
|
+
}
|
|
74
|
+
//# sourceMappingURL=index.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"index.js","sourceRoot":"","sources":["../../../src/cst/expression/index.ts"],"names":[],"mappings":";AAAA,sCAAsC;AACtC,sCAAsC;;AA4CtC,4BAuCC;AAvED,kBAAkB;AAClB,yDAAkD;AAClD,mEAA4D;AAC5D,2DAAoD;AACpD,2DAAoD;AACpD,6CAAsC;AACtC,mCAA4B;AAC5B,2DAAoD;AACpD,yDAAkD;AAClD,uDAAgD;AAChD,uDAAgD;AAChD,+DAAwD;AACxD,qEAA8D;AAC9D,qDAA8C;AAC9C,uDAAgD;AAChD,mDAA4C;AAC5C,mEAA4D;AAC5D,yDAAkD;AAClD,2DAAoD;AACpD,mDAA4C;AAC5C,uDAAgD;AAChD,mEAA4D;AAC5D,yDAAkD;AAClD,uEAAgE;AAChE,uDAAgD;AAChD,uDAAgD;AAChD,2DAAoD;AACpD,yDAAkD;AAClD,uDAAgD;AAChD,2DAAoD;AACpD,yDAAkD;AAElD,mBAAyB,IAAmB;IACxC,+BAA+B;IAC/B,MAAM,MAAM,GACR,IAAA,0BAAgB,EAAC,IAAI,CAAC;QACtB,IAAA,+BAAqB,EAAC,IAAI,CAAC;QAC3B,IAAA,2BAAiB,EAAC,IAAI,CAAC;QACvB,IAAA,2BAAiB,EAAC,IAAI,CAAC;QACvB,IAAA,oBAAU,EAAC,IAAI,CAAC;QAChB,IAAA,eAAK,EAAC,IAAI,CAAC;QACX,IAAA,2BAAiB,EAAC,IAAI,CAAC;QACvB,IAAA,0BAAgB,EAAC,IAAI,CAAC;QACtB,IAAA,yBAAe,EAAC,IAAI,CAAC;QACrB,IAAA,yBAAe,EAAC,IAAI,CAAC;QACrB,IAAA,6BAAmB,EAAC,IAAI,CAAC;QACzB,IAAA,gCAAsB,EAAC,IAAI,CAAC;QAC5B,IAAA,wBAAc,EAAC,IAAI,CAAC;QACpB,IAAA,yBAAe,EAAC,IAAI,CAAC;QACrB,IAAA,uBAAa,EAAC,IAAI,CAAC;QACnB,IAAA,+BAAqB,EAAC,IAAI,CAAC;QAC3B,IAAA,0BAAgB,EAAC,IAAI,CAAC;QACtB,IAAA,2BAAiB,EAAC,IAAI,CAAC;QACvB,IAAA,uBAAa,EAAC,IAAI,CAAC;QACnB,IAAA,yBAAe,EAAC,IAAI,CAAC;QACrB,IAAA,+BAAqB,EAAC,IAAI,CAAC;QAC3B,IAAA,0BAAgB,EAAC,IAAI,CAAC;QACtB,IAAA,iCAAuB,EAAC,IAAI,CAAC;QAC7B,IAAA,yBAAe,EAAC,IAAI,CAAC;QACrB,IAAA,yBAAe,EAAC,IAAI,CAAC;QACrB,IAAA,2BAAiB,EAAC,IAAI,CAAC;QACvB,IAAA,0BAAgB,EAAC,IAAI,CAAC;QACtB,IAAA,yBAAe,EAAC,IAAI,CAAC;QACrB,IAAA,2BAAiB,EAAC,IAAI,CAAC;QACvB,IAAA,0BAAgB,EAAC,IAAI,CAAC,CAAC;IAE3B,IAAI,MAAM,KAAK,IAAI,EAAE,CAAC;QAClB,OAAO,MAAM,CAAC;IAClB,CAAC;IAED,OAAO,IAAI,CAAC;AAChB,CAAC"}
|
|
@@ -0,0 +1,28 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
// Copyright (c) The Move Contributors
|
|
3
|
+
// SPDX-License-Identifier: Apache-2.0
|
|
4
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
5
|
+
exports.default = default_1;
|
|
6
|
+
exports.printIndexExpression = printIndexExpression;
|
|
7
|
+
const prettier_1 = require("prettier");
|
|
8
|
+
const utilities_1 = require("../../utilities");
|
|
9
|
+
const { group } = prettier_1.doc.builders;
|
|
10
|
+
/** The type of the node implemented in this file */
|
|
11
|
+
const NODE_TYPE = 'index_expression';
|
|
12
|
+
function default_1(path) {
|
|
13
|
+
switch (path.node.type) {
|
|
14
|
+
case NODE_TYPE:
|
|
15
|
+
return printIndexExpression;
|
|
16
|
+
}
|
|
17
|
+
return null;
|
|
18
|
+
}
|
|
19
|
+
/**
|
|
20
|
+
* Print `index_expression` node.
|
|
21
|
+
*/
|
|
22
|
+
function printIndexExpression(path, options, print) {
|
|
23
|
+
return group([
|
|
24
|
+
path.call(print, 'nonFormattingChildren', 0), // lhs
|
|
25
|
+
(0, utilities_1.list)({ path, options, open: '[', close: ']', print, skipChildren: 1 }),
|
|
26
|
+
], { shouldBreak: false });
|
|
27
|
+
}
|
|
28
|
+
//# sourceMappingURL=index_expression.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"index_expression.js","sourceRoot":"","sources":["../../../src/cst/expression/index_expression.ts"],"names":[],"mappings":";AAAA,sCAAsC;AACtC,sCAAsC;;AAWtC,4BAOC;AAKD,oDAYC;AA/BD,uCAA6C;AAC7C,+CAAuC;AACvC,MAAM,EAAE,KAAK,EAAE,GAAG,cAAG,CAAC,QAAQ,CAAC;AAE/B,oDAAoD;AACpD,MAAM,SAAS,GAAG,kBAAkB,CAAC;AAErC,mBAAyB,IAAmB;IACxC,QAAQ,IAAI,CAAC,IAAI,CAAC,IAAI,EAAE,CAAC;QACrB,KAAK,SAAS;YACV,OAAO,oBAAoB,CAAC;IACpC,CAAC;IAED,OAAO,IAAI,CAAC;AAChB,CAAC;AAED;;GAEG;AACH,SAAgB,oBAAoB,CAChC,IAAmB,EACnB,OAAoB,EACpB,KAAc;IAEd,OAAO,KAAK,CACR;QACI,IAAI,CAAC,IAAI,CAAC,KAAK,EAAE,uBAAuB,EAAE,CAAC,CAAC,EAAE,MAAM;QACpD,IAAA,gBAAI,EAAC,EAAE,IAAI,EAAE,OAAO,EAAE,IAAI,EAAE,GAAG,EAAE,KAAK,EAAE,GAAG,EAAE,KAAK,EAAE,YAAY,EAAE,CAAC,EAAE,CAAC;KACzE,EACD,EAAE,WAAW,EAAE,KAAK,EAAE,CACzB,CAAC;AACN,CAAC"}
|
|
@@ -0,0 +1,72 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
// Copyright (c) The Move Contributors
|
|
3
|
+
// SPDX-License-Identifier: Apache-2.0
|
|
4
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
5
|
+
exports.default = default_1;
|
|
6
|
+
const prettier_1 = require("prettier");
|
|
7
|
+
const utilities_1 = require("../../utilities");
|
|
8
|
+
const { group, join, conditionalGroup } = prettier_1.doc.builders;
|
|
9
|
+
/** The type of the node implemented in this file */
|
|
10
|
+
const NODE_TYPE = 'lambda_expression';
|
|
11
|
+
function default_1(path) {
|
|
12
|
+
switch (path.node.type) {
|
|
13
|
+
case NODE_TYPE:
|
|
14
|
+
return printLambdaExpression;
|
|
15
|
+
case 'lambda_bindings':
|
|
16
|
+
return printLambdaBindings;
|
|
17
|
+
case 'lambda_binding':
|
|
18
|
+
return printLambdaBinding;
|
|
19
|
+
}
|
|
20
|
+
return null;
|
|
21
|
+
}
|
|
22
|
+
/**
|
|
23
|
+
* Print `labda_expression` node.
|
|
24
|
+
* Inside:
|
|
25
|
+
* - `lambda_bindings`
|
|
26
|
+
* - `_bind`
|
|
27
|
+
*/
|
|
28
|
+
function printLambdaExpression(path, options, print) {
|
|
29
|
+
const children = path.node.nonFormattingChildren;
|
|
30
|
+
// just bindings
|
|
31
|
+
if (children.length === 1) {
|
|
32
|
+
return path.call(print, 'nonFormattingChildren', 0);
|
|
33
|
+
}
|
|
34
|
+
// bindings, expression or bindings, return type
|
|
35
|
+
if (children.length === 2) {
|
|
36
|
+
return join(' ', path.map(print, 'nonFormattingChildren'));
|
|
37
|
+
}
|
|
38
|
+
// bindings, return type, expression
|
|
39
|
+
if (children.length === 3) {
|
|
40
|
+
return [
|
|
41
|
+
path.call(print, 'nonFormattingChildren', 0), // bindings
|
|
42
|
+
' -> ',
|
|
43
|
+
path.call(print, 'nonFormattingChildren', 1), // return type
|
|
44
|
+
' ',
|
|
45
|
+
path.call(print, 'nonFormattingChildren', 2), // expression
|
|
46
|
+
];
|
|
47
|
+
}
|
|
48
|
+
throw new Error('`lambda_expression` node should have 1, 2 or 3 children');
|
|
49
|
+
}
|
|
50
|
+
/**
|
|
51
|
+
* Print `lambda_bindings` node, contains comma-separated list of `lambda_binding` nodes.
|
|
52
|
+
*/
|
|
53
|
+
function printLambdaBindings(path, options, print) {
|
|
54
|
+
return group((0, utilities_1.list)({ path, print, options, open: '|', close: '|' }));
|
|
55
|
+
}
|
|
56
|
+
/**
|
|
57
|
+
* Print `lambda_binding` node.
|
|
58
|
+
* It can be either type annotated or just a variable binding, we know it by the number
|
|
59
|
+
* of non-formatting children.
|
|
60
|
+
*/
|
|
61
|
+
function printLambdaBinding(path, options, print) {
|
|
62
|
+
// simple bind, will be handled by its function
|
|
63
|
+
if (path.node.nonFormattingChildren.length === 1) {
|
|
64
|
+
return path.call(print, 'nonFormattingChildren', 0);
|
|
65
|
+
}
|
|
66
|
+
// with type annotation
|
|
67
|
+
if (path.node.nonFormattingChildren.length === 2) {
|
|
68
|
+
return join(': ', path.map(print, 'nonFormattingChildren'));
|
|
69
|
+
}
|
|
70
|
+
throw new Error('`lambda_binding` node should have 1 or 2 children');
|
|
71
|
+
}
|
|
72
|
+
//# sourceMappingURL=lambda_expression.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"lambda_expression.js","sourceRoot":"","sources":["../../../src/cst/expression/lambda_expression.ts"],"names":[],"mappings":";AAAA,sCAAsC;AACtC,sCAAsC;;AAYtC,4BAWC;AAnBD,uCAA6C;AAE7C,+CAAuC;AACvC,MAAM,EAAE,KAAK,EAAE,IAAI,EAAE,gBAAgB,EAAE,GAAG,cAAG,CAAC,QAAQ,CAAC;AAEvD,oDAAoD;AACpD,MAAM,SAAS,GAAG,mBAAmB,CAAC;AAEtC,mBAAyB,IAAmB;IACxC,QAAQ,IAAI,CAAC,IAAI,CAAC,IAAI,EAAE,CAAC;QACrB,KAAK,SAAS;YACV,OAAO,qBAAqB,CAAC;QACjC,KAAK,iBAAiB;YAClB,OAAO,mBA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,CAAC;AACxE,CAAC;AAED;;;;GAIG;AACH,SAAS,kBAAkB,CAAC,IAAmB,EAAE,OAAoB,EAAE,KAAc;IACjF,+CAA+C;IAC/C,IAAI,IAAI,CAAC,IAAI,CAAC,qBAAqB,CAAC,MAAM,KAAK,CAAC,EAAE,CAAC;QAC/C,OAAO,IAAI,CAAC,IAAI,CAAC,KAAK,EAAE,uBAAuB,EAAE,CAAC,CAAC,CAAC;IACxD,CAAC;IAED,uBAAuB;IACvB,IAAI,IAAI,CAAC,IAAI,CAAC,qBAAqB,CAAC,MAAM,KAAK,CAAC,EAAE,CAAC;QAC/C,OAAO,IAAI,CAAC,IAAI,EAAE,IAAI,CAAC,GAAG,CAAC,KAAK,EAAE,uBAAuB,CAAC,CAAC,CAAC;IAChE,CAAC;IAED,MAAM,IAAI,KAAK,CAAC,mDAAmD,CAAC,CAAC;AACzE,CAAC"}
|
|
@@ -0,0 +1,59 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
// Copyright (c) The Move Contributors
|
|
3
|
+
// SPDX-License-Identifier: Apache-2.0
|
|
4
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
5
|
+
exports.default = default_1;
|
|
6
|
+
const prettier_1 = require("prettier");
|
|
7
|
+
const utilities_1 = require("../../utilities");
|
|
8
|
+
const { group, indent, line, indentIfBreak } = prettier_1.doc.builders;
|
|
9
|
+
/** The type of the node implemented in this file */
|
|
10
|
+
const NODE_TYPE = 'let_statement';
|
|
11
|
+
function default_1(path) {
|
|
12
|
+
if (path.node.type === NODE_TYPE) {
|
|
13
|
+
return printLetStatement;
|
|
14
|
+
}
|
|
15
|
+
return null;
|
|
16
|
+
}
|
|
17
|
+
/**
|
|
18
|
+
* Print `let_statement` node.
|
|
19
|
+
*/
|
|
20
|
+
function printLetStatement(path, options, print) {
|
|
21
|
+
const nodes = path.node.nonFormattingChildren;
|
|
22
|
+
if (nodes.length === 1) {
|
|
23
|
+
return group(['let', ' ', path.call(print, 'nonFormattingChildren', 0)]);
|
|
24
|
+
}
|
|
25
|
+
function printWithTrailing(path) {
|
|
26
|
+
let trailingComment = '';
|
|
27
|
+
if (path.node.trailingComment?.type == 'line_comment') {
|
|
28
|
+
trailingComment = (0, utilities_1.printTrailingComment)(path, true);
|
|
29
|
+
path.node.disableTrailingComment();
|
|
30
|
+
}
|
|
31
|
+
return [print(path), trailingComment];
|
|
32
|
+
}
|
|
33
|
+
const printed = path.map(printWithTrailing, 'nonFormattingChildren');
|
|
34
|
+
const rhsNode = path.node.nonFormattingChildren.slice(-1)[0];
|
|
35
|
+
if (nodes.length === 2 && nodes[1].isTypeParam) {
|
|
36
|
+
const [bind, type] = printed;
|
|
37
|
+
return group(['let ', bind, ': ', type]);
|
|
38
|
+
}
|
|
39
|
+
if (nodes.length === 2) {
|
|
40
|
+
const [bind, expr] = printed;
|
|
41
|
+
const result = rhsNode.isBreakableExpression || rhsNode.isFunctionCall || rhsNode.isControlFlow
|
|
42
|
+
? ['let ', bind, ' = ', expr]
|
|
43
|
+
: ['let ', bind, ' =', printLetExpression(expr, rhsNode)];
|
|
44
|
+
return group(result, { shouldBreak: false });
|
|
45
|
+
}
|
|
46
|
+
const [bind, type, expr] = printed;
|
|
47
|
+
const result = rhsNode.isBreakableExpression || rhsNode.isFunctionCall
|
|
48
|
+
? ['let ', bind, ': ', type, ' = ', expr]
|
|
49
|
+
: ['let ', bind, ': ', type, ' =', printLetExpression(expr, rhsNode)];
|
|
50
|
+
return result;
|
|
51
|
+
}
|
|
52
|
+
function printLetExpression(expression, node) {
|
|
53
|
+
const groupId = Symbol('let_expression');
|
|
54
|
+
return group([indentIfBreak(line, { groupId }), indentIfBreak(expression, { groupId })], {
|
|
55
|
+
shouldBreak: false,
|
|
56
|
+
id: groupId,
|
|
57
|
+
});
|
|
58
|
+
}
|
|
59
|
+
//# sourceMappingURL=let_statement.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"let_statement.js","sourceRoot":"","sources":["../../../src/cst/exp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ED,SAAS,kBAAkB,CAAC,UAAe,EAAE,IAAU;IACnD,MAAM,OAAO,GAAG,MAAM,CAAC,gBAAgB,CAAC,CAAC;IACzC,OAAO,KAAK,CAAC,CAAC,aAAa,CAAC,IAAI,EAAE,EAAE,OAAO,EAAE,CAAC,EAAE,aAAa,CAAC,UAAU,EAAE,EAAE,OAAO,EAAE,CAAC,CAAC,EAAE;QACrF,WAAW,EAAE,KAAK;QAClB,EAAE,EAAE,OAAO;KACd,CAAC,CAAC;AACP,CAAC"}
|
|
@@ -0,0 +1,27 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
// Copyright (c) The Move Contributors
|
|
3
|
+
// SPDX-License-Identifier: Apache-2.0
|
|
4
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
5
|
+
exports.NODE_TYPE = void 0;
|
|
6
|
+
exports.default = default_1;
|
|
7
|
+
const prettier_1 = require("prettier");
|
|
8
|
+
const {} = prettier_1.doc.builders;
|
|
9
|
+
/** The type of the node implemented in this file */
|
|
10
|
+
exports.NODE_TYPE = 'loop_expression';
|
|
11
|
+
function default_1(path) {
|
|
12
|
+
if (path.node.type === exports.NODE_TYPE) {
|
|
13
|
+
return printLoopExpression;
|
|
14
|
+
}
|
|
15
|
+
return null;
|
|
16
|
+
}
|
|
17
|
+
/**
|
|
18
|
+
* Print `loop_expression` node.
|
|
19
|
+
*
|
|
20
|
+
* ```
|
|
21
|
+
* loop `_expression`
|
|
22
|
+
* ```
|
|
23
|
+
*/
|
|
24
|
+
function printLoopExpression(path, options, print) {
|
|
25
|
+
return [`loop `, path.call(print, 'nonFormattingChildren', 0)];
|
|
26
|
+
}
|
|
27
|
+
//# sourceMappingURL=loop_expression.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"loop_expression.js","sourceRoot":"","sources":["../../../src/cst/expression/loop_expression.ts"],"names":[],"mappings":";AAAA,sCAAsC;AACtC,sCAAsC;;;AAUtC,4BAMC;AAZD,uCAA6C;AAC7C,MAAM,EAAE,GAAG,cAAG,CAAC,QAAQ,CAAC;AAExB,oDAAoD;AACvC,QAAA,SAAS,GAAG,iBAAiB,CAAC;AAE3C,mBAAyB,IAAmB;IACxC,IAAI,IAAI,CAAC,IAAI,CAAC,IAAI,KAAK,iBAAS,EAAE,CAAC;QAC/B,OAAO,mBAAmB,CAAC;IAC/B,CAAC;IAED,OAAO,IAAI,CAAC;AAChB,CAAC;AAED;;;;;;GAMG;AACH,SAAS,mBAAmB,CAAC,IAAmB,EAAE,OAAoB,EAAE,KAAc;IAClF,OAAO,CAAC,OAAO,EAAE,IAAI,CAAC,IAAI,CAAC,KAAK,EAAE,uBAAuB,EAAE,CAAC,CAAC,CAAC,CAAC;AACnE,CAAC"}
|