prettier-plugin-solidity 1.1.1 → 1.1.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/dist/standalone.js +1 -1
- package/dist/standalone.js.map +1 -1
- package/package.json +4 -4
- package/src/common/printer-helpers.js +116 -0
- package/src/nodes/AssemblyBlock.js +5 -3
- package/src/nodes/AssemblyCall.js +1 -1
- package/src/nodes/AssemblyFunctionDefinition.js +4 -2
- package/src/nodes/AssemblyLocalDefinition.js +1 -1
- package/src/nodes/Block.js +4 -2
- package/src/nodes/CatchClause.js +1 -1
- package/src/nodes/ContractDefinition.js +6 -4
- package/src/nodes/CustomErrorDefinition.js +1 -1
- package/src/nodes/DoWhileStatement.js +1 -1
- package/src/nodes/EnumDefinition.js +1 -1
- package/src/nodes/EventDefinition.js +1 -1
- package/src/nodes/ExpressionStatement.js +1 -1
- package/src/nodes/ForStatement.js +1 -1
- package/src/nodes/FunctionCall.js +1 -1
- package/src/nodes/FunctionDefinition.js +6 -6
- package/src/nodes/FunctionTypeName.js +1 -1
- package/src/nodes/IfStatement.js +4 -2
- package/src/nodes/ImportDirective.js +1 -1
- package/src/nodes/InheritanceSpecifier.js +1 -1
- package/src/nodes/InlineAssemblyStatement.js +1 -1
- package/src/nodes/Mapping.js +15 -7
- package/src/nodes/ModifierDefinition.js +1 -1
- package/src/nodes/ModifierInvocation.js +4 -2
- package/src/nodes/NameValueList.js +1 -1
- package/src/nodes/SourceUnit.js +1 -1
- package/src/nodes/StructDefinition.js +18 -12
- package/src/nodes/TryStatement.js +4 -2
- package/src/nodes/TupleExpression.js +1 -1
- package/src/nodes/UsingForDeclaration.js +34 -16
- package/src/nodes/VariableDeclaration.js +1 -1
- package/src/nodes/VariableDeclarationStatement.js +1 -1
- package/src/nodes/WhileStatement.js +1 -1
- package/src/nodes/print-comments.js +0 -37
- package/src/nodes/print-preserving-empty-lines.js +0 -53
- package/src/nodes/print-separated-item.js +0 -21
- package/src/nodes/print-separated-list.js +0 -23
|
@@ -1,53 +0,0 @@
|
|
|
1
|
-
const {
|
|
2
|
-
doc: {
|
|
3
|
-
builders: { hardline }
|
|
4
|
-
},
|
|
5
|
-
util: { isNextLineEmptyAfterIndex }
|
|
6
|
-
} = require('prettier');
|
|
7
|
-
|
|
8
|
-
function printPreservingEmptyLines(path, key, options, print) {
|
|
9
|
-
const parts = [];
|
|
10
|
-
path.each((childPath) => {
|
|
11
|
-
const node = childPath.getValue();
|
|
12
|
-
const nodeType = node.type;
|
|
13
|
-
|
|
14
|
-
if (
|
|
15
|
-
// Avoid adding a hardline at the beginning of the document.
|
|
16
|
-
parts.length !== 0 &&
|
|
17
|
-
// LabelDefinition adds a dedented line so we don't have to prepend a
|
|
18
|
-
// hardline.
|
|
19
|
-
nodeType !== 'LabelDefinition'
|
|
20
|
-
) {
|
|
21
|
-
parts.push(hardline);
|
|
22
|
-
}
|
|
23
|
-
|
|
24
|
-
if (childPath.getName() > 0) {
|
|
25
|
-
if (
|
|
26
|
-
['ContractDefinition', 'FunctionDefinition'].includes(nodeType) &&
|
|
27
|
-
parts[parts.length - 2] !== hardline
|
|
28
|
-
) {
|
|
29
|
-
parts.push(hardline);
|
|
30
|
-
}
|
|
31
|
-
}
|
|
32
|
-
|
|
33
|
-
parts.push(print(childPath));
|
|
34
|
-
|
|
35
|
-
if (
|
|
36
|
-
isNextLineEmptyAfterIndex(
|
|
37
|
-
options.originalText,
|
|
38
|
-
options.locEnd(node) + 1
|
|
39
|
-
) ||
|
|
40
|
-
nodeType === 'FunctionDefinition'
|
|
41
|
-
) {
|
|
42
|
-
parts.push(hardline);
|
|
43
|
-
}
|
|
44
|
-
}, key);
|
|
45
|
-
|
|
46
|
-
if (parts.length > 1 && parts[parts.length - 1] === hardline) {
|
|
47
|
-
parts.pop();
|
|
48
|
-
}
|
|
49
|
-
|
|
50
|
-
return parts;
|
|
51
|
-
}
|
|
52
|
-
|
|
53
|
-
module.exports = printPreservingEmptyLines;
|
|
@@ -1,21 +0,0 @@
|
|
|
1
|
-
const {
|
|
2
|
-
doc: {
|
|
3
|
-
builders: { group, indent, softline }
|
|
4
|
-
}
|
|
5
|
-
} = require('prettier');
|
|
6
|
-
|
|
7
|
-
// This function will add an indentation to the `item` and separate it from the
|
|
8
|
-
// rest of the `doc` in most cases by a `softline`.
|
|
9
|
-
const printSeparatedItem = (
|
|
10
|
-
item,
|
|
11
|
-
{
|
|
12
|
-
firstSeparator = softline,
|
|
13
|
-
lastSeparator = firstSeparator,
|
|
14
|
-
grouped = true
|
|
15
|
-
} = {}
|
|
16
|
-
) => {
|
|
17
|
-
const doc = [indent([firstSeparator, item]), lastSeparator];
|
|
18
|
-
return grouped ? group(doc) : doc;
|
|
19
|
-
};
|
|
20
|
-
|
|
21
|
-
module.exports = printSeparatedItem;
|
|
@@ -1,23 +0,0 @@
|
|
|
1
|
-
const {
|
|
2
|
-
doc: {
|
|
3
|
-
builders: { group, indent, join, line, softline }
|
|
4
|
-
}
|
|
5
|
-
} = require('prettier');
|
|
6
|
-
|
|
7
|
-
// This function will add an indentation to the `list` and separate it from the
|
|
8
|
-
// rest of the `doc` in most cases by a `softline`.
|
|
9
|
-
// the list itself will be printed with a separator that in most cases is a
|
|
10
|
-
// comma (,) and a `line`
|
|
11
|
-
const printSeparatedList = (
|
|
12
|
-
list,
|
|
13
|
-
{
|
|
14
|
-
firstSeparator = softline,
|
|
15
|
-
separator = [',', line],
|
|
16
|
-
lastSeparator = firstSeparator,
|
|
17
|
-
grouped = true
|
|
18
|
-
} = {}
|
|
19
|
-
) => {
|
|
20
|
-
const doc = [indent([firstSeparator, join(separator, list)]), lastSeparator];
|
|
21
|
-
return grouped ? group(doc) : doc;
|
|
22
|
-
};
|
|
23
|
-
module.exports = printSeparatedList;
|