@putout/printer 2.47.0 → 2.49.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/ChangeLog +10 -0
- package/lib/tokenize/expressions/class/class.js +26 -28
- package/lib/tokenize/expressions/class/static-block.js +16 -0
- package/lib/tokenize/expressions/index.js +1 -1
- package/lib/tokenize/expressions/new-expression.js +4 -0
- package/lib/tokenize/statements/program.js +1 -1
- package/lib/tokenize/typescript/index.js +3 -16
- package/lib/tokenize/typescript/interface/ts-interface-body.js +19 -0
- package/lib/tokenize/typescript/{ts-interface-declaration.js → interface/ts-interface-declaration.js} +1 -1
- package/package.json +1 -1
package/ChangeLog
CHANGED
|
@@ -4,37 +4,35 @@ const {isNext} = require('../../is');
|
|
|
4
4
|
const {markAfter} = require('../../mark');
|
|
5
5
|
const {maybeDecorators} = require('../../maybe-get');
|
|
6
6
|
|
|
7
|
-
|
|
7
|
+
const isInsideExport = ({parentPath}) => parentPath.isExportDeclaration();
|
|
8
8
|
|
|
9
|
-
module.exports.
|
|
10
|
-
print('static ');
|
|
11
|
-
print('{');
|
|
12
|
-
print.breakline();
|
|
13
|
-
|
|
14
|
-
for (const child of path.get('body')) {
|
|
15
|
-
traverse(child);
|
|
16
|
-
}
|
|
17
|
-
|
|
18
|
-
print.indent();
|
|
19
|
-
print('}');
|
|
20
|
-
print.newline();
|
|
21
|
-
};
|
|
9
|
+
module.exports.ClassExpression = classVisitor;
|
|
22
10
|
|
|
23
|
-
module.exports.ClassDeclaration =
|
|
24
|
-
indent
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
|
|
11
|
+
module.exports.ClassDeclaration = {
|
|
12
|
+
print(path, {print, indent, maybe, traverse}) {
|
|
13
|
+
indent();
|
|
14
|
+
|
|
15
|
+
classVisitor(path, {
|
|
16
|
+
print,
|
|
17
|
+
indent,
|
|
18
|
+
maybe,
|
|
19
|
+
traverse,
|
|
20
|
+
});
|
|
21
|
+
},
|
|
22
|
+
afterIf(path) {
|
|
23
|
+
if (!isNext(path))
|
|
24
|
+
return false;
|
|
25
|
+
|
|
26
|
+
return !isInsideExport(path);
|
|
27
|
+
},
|
|
28
|
+
after(path, {write}) {
|
|
34
29
|
write.newline();
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
|
|
30
|
+
|
|
31
|
+
if (path.node.body.body.length) {
|
|
32
|
+
write.newline();
|
|
33
|
+
markAfter(path);
|
|
34
|
+
}
|
|
35
|
+
},
|
|
38
36
|
};
|
|
39
37
|
|
|
40
38
|
function classVisitor(path, {print, indent, maybe, traverse}) {
|
|
@@ -0,0 +1,16 @@
|
|
|
1
|
+
'use strict';
|
|
2
|
+
|
|
3
|
+
module.exports.StaticBlock = (path, {print, traverse}) => {
|
|
4
|
+
print('static ');
|
|
5
|
+
print('{');
|
|
6
|
+
print.breakline();
|
|
7
|
+
|
|
8
|
+
for (const child of path.get('body')) {
|
|
9
|
+
traverse(child);
|
|
10
|
+
}
|
|
11
|
+
|
|
12
|
+
print.indent();
|
|
13
|
+
print('}');
|
|
14
|
+
print.newline();
|
|
15
|
+
};
|
|
16
|
+
|
|
@@ -7,7 +7,6 @@ const memberExpressions = require('./member-expressions/member-expressions');
|
|
|
7
7
|
const {
|
|
8
8
|
ClassExpression,
|
|
9
9
|
ClassDeclaration,
|
|
10
|
-
StaticBlock,
|
|
11
10
|
} = require('./class/class');
|
|
12
11
|
|
|
13
12
|
const {
|
|
@@ -42,6 +41,7 @@ const {
|
|
|
42
41
|
} = require('./binary-expression/binary-expression');
|
|
43
42
|
|
|
44
43
|
const {ConditionalExpression} = require('./conditional-expression');
|
|
44
|
+
const {StaticBlock} = require('./class/static-block');
|
|
45
45
|
|
|
46
46
|
module.exports = {
|
|
47
47
|
...functions,
|
|
@@ -1,6 +1,7 @@
|
|
|
1
1
|
'use strict';
|
|
2
2
|
|
|
3
3
|
const {exists} = require('../is');
|
|
4
|
+
const {isMarkedAfter} = require('../mark');
|
|
4
5
|
const isInsideExpressionStatement = ({parentPath}) => parentPath.isExpressionStatement();
|
|
5
6
|
const notFirst = ({parentPath}) => exists(parentPath.getPrevSibling());
|
|
6
7
|
|
|
@@ -23,6 +24,9 @@ module.exports.NewExpression = {
|
|
|
23
24
|
if (!exists)
|
|
24
25
|
return false;
|
|
25
26
|
|
|
27
|
+
if (isMarkedAfter(prev))
|
|
28
|
+
return false;
|
|
29
|
+
|
|
26
30
|
if (prev.isExpressionStatement())
|
|
27
31
|
return false;
|
|
28
32
|
|
|
@@ -1,6 +1,7 @@
|
|
|
1
1
|
'use strict';
|
|
2
2
|
|
|
3
3
|
const {parseComments} = require('../comments/comments');
|
|
4
|
+
|
|
4
5
|
module.exports.Program = (path, {print, write}, semantics) => {
|
|
5
6
|
print('__interpreter');
|
|
6
7
|
parseComments(path, {write}, semantics);
|
|
@@ -11,4 +12,3 @@ module.exports.Program = (path, {print, write}, semantics) => {
|
|
|
11
12
|
|
|
12
13
|
print.newline();
|
|
13
14
|
};
|
|
14
|
-
|
|
@@ -13,8 +13,9 @@ const {
|
|
|
13
13
|
TSModuleBlock,
|
|
14
14
|
} = require('./ts-module-declaration');
|
|
15
15
|
|
|
16
|
-
const {TSInterfaceDeclaration} = require('./ts-interface-declaration');
|
|
16
|
+
const {TSInterfaceDeclaration} = require('./interface/ts-interface-declaration');
|
|
17
17
|
const {TSAsExpression} = require('./ts-as-expression');
|
|
18
|
+
const {TSInterfaceBody} = require('./interface/ts-interface-body');
|
|
18
19
|
|
|
19
20
|
module.exports = {
|
|
20
21
|
TSAsExpression,
|
|
@@ -104,21 +105,7 @@ module.exports = {
|
|
|
104
105
|
print('__typeAnnotation');
|
|
105
106
|
},
|
|
106
107
|
TSInterfaceDeclaration,
|
|
107
|
-
TSInterfaceBody
|
|
108
|
-
write(' {');
|
|
109
|
-
write.newline();
|
|
110
|
-
indent.inc();
|
|
111
|
-
|
|
112
|
-
for (const item of path.get('body')) {
|
|
113
|
-
indent();
|
|
114
|
-
traverse(item);
|
|
115
|
-
write(';');
|
|
116
|
-
write.newline();
|
|
117
|
-
}
|
|
118
|
-
|
|
119
|
-
indent.dec();
|
|
120
|
-
write('}');
|
|
121
|
-
},
|
|
108
|
+
TSInterfaceBody,
|
|
122
109
|
TSTypeAssertion(path, {print}) {
|
|
123
110
|
print('<');
|
|
124
111
|
print('__typeAnnotation');
|
|
@@ -0,0 +1,19 @@
|
|
|
1
|
+
'use strict';
|
|
2
|
+
|
|
3
|
+
module.exports.TSInterfaceBody = (path, {traverse, write, indent, maybe}) => {
|
|
4
|
+
const body = path.get('body');
|
|
5
|
+
write.space();
|
|
6
|
+
write('{');
|
|
7
|
+
maybe.write.newline(body.length);
|
|
8
|
+
indent.inc();
|
|
9
|
+
|
|
10
|
+
for (const item of body) {
|
|
11
|
+
indent();
|
|
12
|
+
traverse(item);
|
|
13
|
+
write(';');
|
|
14
|
+
write.newline();
|
|
15
|
+
}
|
|
16
|
+
|
|
17
|
+
indent.dec();
|
|
18
|
+
write('}');
|
|
19
|
+
};
|
package/package.json
CHANGED