prettier-plugin-solidity 2.0.0-beta.7 → 2.0.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/README.md +61 -57
- package/dist/591f276013d241f7a687.wasm +0 -0
- package/dist/comments/handlers/handleContractDefinitionComments.js +7 -2
- package/dist/comments/handlers/handleContractDefinitionComments.js.map +1 -1
- package/dist/e5a84a17f0f9e01763d3.wasm +0 -0
- package/dist/ea6945b7193921081ced.wasm +0 -0
- package/dist/index.js +5 -5
- package/dist/index.js.map +1 -1
- package/dist/nodes/ContractDefinition.js +30 -10
- package/dist/nodes/ContractDefinition.js.map +1 -1
- package/dist/printer.js +1 -1
- package/dist/printer.js.map +1 -1
- package/dist/slang-comments/handlers/handle-contract-definition-comments.js +18 -8
- package/dist/slang-comments/handlers/handle-contract-definition-comments.js.map +1 -1
- package/dist/slang-comments/handlers/handle-contract-specifiers-comments.js +22 -0
- package/dist/slang-comments/handlers/handle-contract-specifiers-comments.js.map +1 -0
- package/dist/slang-comments/handlers/handle-storage-layout-specifier-comments.js +14 -0
- package/dist/slang-comments/handlers/handle-storage-layout-specifier-comments.js.map +1 -0
- package/dist/slang-comments/handlers/index.js +4 -0
- package/dist/slang-comments/handlers/index.js.map +1 -1
- package/dist/slang-nodes/ConditionalExpression.js +6 -12
- package/dist/slang-nodes/ConditionalExpression.js.map +1 -1
- package/dist/slang-nodes/ContractDefinition.js +5 -6
- package/dist/slang-nodes/ContractDefinition.js.map +1 -1
- package/dist/slang-nodes/ContractSpecifier.js +27 -0
- package/dist/slang-nodes/ContractSpecifier.js.map +1 -0
- package/dist/slang-nodes/ContractSpecifiers.js +31 -0
- package/dist/slang-nodes/ContractSpecifiers.js.map +1 -0
- package/dist/slang-nodes/Expression.js +3 -3
- package/dist/slang-nodes/FunctionCallExpression.js +3 -4
- package/dist/slang-nodes/FunctionCallExpression.js.map +1 -1
- package/dist/slang-nodes/IndexAccessExpression.js +3 -4
- package/dist/slang-nodes/IndexAccessExpression.js.map +1 -1
- package/dist/slang-nodes/{ComparisonExpression.js → InequalityExpression.js} +3 -3
- package/dist/slang-nodes/{ComparisonExpression.js.map → InequalityExpression.js.map} +1 -1
- package/dist/slang-nodes/ReturnStatement.js +3 -5
- package/dist/slang-nodes/ReturnStatement.js.map +1 -1
- package/dist/slang-nodes/StateVariableDefinition.js +3 -6
- package/dist/slang-nodes/StateVariableDefinition.js.map +1 -1
- package/dist/slang-nodes/StateVariableDefinitionValue.js +1 -2
- package/dist/slang-nodes/StateVariableDefinitionValue.js.map +1 -1
- package/dist/slang-nodes/StorageLayoutSpecifier.js +25 -0
- package/dist/slang-nodes/StorageLayoutSpecifier.js.map +1 -0
- package/dist/slang-nodes/TupleDeconstructionStatement.js +3 -4
- package/dist/slang-nodes/TupleDeconstructionStatement.js.map +1 -1
- package/dist/slang-nodes/VariableDeclarationStatement.js +3 -2
- package/dist/slang-nodes/VariableDeclarationStatement.js.map +1 -1
- package/dist/slang-nodes/YulExpression.js +0 -4
- package/dist/slang-nodes/YulExpression.js.map +1 -1
- package/dist/slang-utils/is-binary-operation.js +1 -1
- package/dist/slang-utils/is-binary-operation.js.map +1 -1
- package/dist/slang-utils/sort-contract-specifiers.js +14 -0
- package/dist/slang-utils/sort-contract-specifiers.js.map +1 -0
- package/dist/slangPrinter.js +2 -3
- package/dist/slangPrinter.js.map +1 -1
- package/dist/standalone.js +1 -1
- package/dist/standalone.js.map +1 -1
- package/package.json +18 -15
- package/src/comments/handlers/handleContractDefinitionComments.js +11 -2
- package/src/index.ts +5 -5
- package/src/nodes/ContractDefinition.js +31 -11
- package/src/printer.js +1 -1
- package/src/slang-comments/handlers/handle-contract-definition-comments.ts +21 -13
- package/src/slang-comments/handlers/handle-contract-specifiers-comments.ts +33 -0
- package/src/slang-comments/handlers/handle-storage-layout-specifier-comments.ts +23 -0
- package/src/slang-comments/handlers/index.ts +4 -0
- package/src/slang-nodes/ConditionalExpression.ts +4 -10
- package/src/slang-nodes/ContractDefinition.ts +6 -7
- package/src/slang-nodes/ContractSpecifier.ts +48 -0
- package/src/slang-nodes/ContractSpecifiers.ts +52 -0
- package/src/slang-nodes/Expression.ts +5 -5
- package/src/slang-nodes/FunctionCallExpression.ts +3 -4
- package/src/slang-nodes/IndexAccessExpression.ts +3 -4
- package/src/slang-nodes/{ComparisonExpression.ts → InequalityExpression.ts} +4 -4
- package/src/slang-nodes/ReturnStatement.ts +3 -5
- package/src/slang-nodes/StateVariableDefinition.ts +3 -6
- package/src/slang-nodes/StateVariableDefinitionValue.ts +1 -2
- package/src/slang-nodes/StorageLayoutSpecifier.ts +45 -0
- package/src/slang-nodes/TupleDeconstructionStatement.ts +3 -4
- package/src/slang-nodes/VariableDeclarationStatement.ts +3 -2
- package/src/slang-nodes/YulExpression.ts +1 -11
- package/src/slang-nodes/types.d.ts +8 -4
- package/src/slang-printers/print-binary-operation.ts +2 -2
- package/src/slang-utils/is-binary-operation.ts +1 -1
- package/src/slang-utils/sort-contract-specifiers.ts +25 -0
- package/src/slangPrinter.ts +2 -3
- package/src/types.d.ts +7 -220
- package/dist/28d7fb838862acf337c8.wasm +0 -0
- package/dist/80ab9aab2ee473939a05.wasm +0 -0
- package/dist/e0ce19302a589ebeaa6d.wasm +0 -0
- package/dist/slang-nodes/YulBuiltInFunction.js +0 -15
- package/dist/slang-nodes/YulBuiltInFunction.js.map +0 -1
- package/dist/slang-utils/prettier-version-satisfies.js +0 -6
- package/dist/slang-utils/prettier-version-satisfies.js.map +0 -1
- package/dist/slang-utils/print-warning.js +0 -12
- package/dist/slang-utils/print-warning.js.map +0 -1
- package/src/slang-nodes/YulBuiltInFunction.ts +0 -29
- package/src/slang-utils/prettier-version-satisfies.ts +0 -8
- package/src/slang-utils/print-warning.ts +0 -12
|
@@ -0,0 +1,45 @@
|
|
|
1
|
+
import { doc } from 'prettier';
|
|
2
|
+
import { NonterminalKind } from '@nomicfoundation/slang/cst';
|
|
3
|
+
import { printSeparatedItem } from '../slang-printers/print-separated-item.js';
|
|
4
|
+
import { getNodeMetadata, updateMetadata } from '../slang-utils/metadata.js';
|
|
5
|
+
import { Expression } from './Expression.js';
|
|
6
|
+
|
|
7
|
+
import type * as ast from '@nomicfoundation/slang/ast';
|
|
8
|
+
import type { AstPath, Doc, ParserOptions } from 'prettier';
|
|
9
|
+
import type { AstNode } from './types.js';
|
|
10
|
+
import type { PrintFunction, SlangNode } from '../types.js';
|
|
11
|
+
|
|
12
|
+
const { line } = doc.builders;
|
|
13
|
+
|
|
14
|
+
export class StorageLayoutSpecifier implements SlangNode {
|
|
15
|
+
readonly kind = NonterminalKind.StorageLayoutSpecifier;
|
|
16
|
+
|
|
17
|
+
comments;
|
|
18
|
+
|
|
19
|
+
loc;
|
|
20
|
+
|
|
21
|
+
expression: Expression;
|
|
22
|
+
|
|
23
|
+
constructor(
|
|
24
|
+
ast: ast.StorageLayoutSpecifier,
|
|
25
|
+
options: ParserOptions<AstNode>
|
|
26
|
+
) {
|
|
27
|
+
let metadata = getNodeMetadata(ast);
|
|
28
|
+
|
|
29
|
+
this.expression = new Expression(ast.expression, options);
|
|
30
|
+
|
|
31
|
+
metadata = updateMetadata(metadata, [this.expression]);
|
|
32
|
+
|
|
33
|
+
this.comments = metadata.comments;
|
|
34
|
+
this.loc = metadata.loc;
|
|
35
|
+
}
|
|
36
|
+
|
|
37
|
+
print(path: AstPath<StorageLayoutSpecifier>, print: PrintFunction): Doc {
|
|
38
|
+
return [
|
|
39
|
+
'layout at',
|
|
40
|
+
printSeparatedItem(path.call(print, 'expression'), {
|
|
41
|
+
firstSeparator: line
|
|
42
|
+
})
|
|
43
|
+
];
|
|
44
|
+
}
|
|
45
|
+
}
|
|
@@ -44,16 +44,15 @@ export class TupleDeconstructionStatement implements SlangNode {
|
|
|
44
44
|
path: AstPath<TupleDeconstructionStatement>,
|
|
45
45
|
print: PrintFunction
|
|
46
46
|
): Doc {
|
|
47
|
+
const groupId = Symbol('Slang.VariableDeclarationStatement.variables');
|
|
47
48
|
const declarationDoc = group(
|
|
48
49
|
[this.varKeyword ? 'var (' : '(', path.call(print, 'elements'), ')'],
|
|
49
|
-
{ id:
|
|
50
|
+
{ id: groupId }
|
|
50
51
|
);
|
|
51
52
|
|
|
52
53
|
return [
|
|
53
54
|
declarationDoc,
|
|
54
|
-
indentIfBreak([' = ', path.call(print, 'expression'), ';'], {
|
|
55
|
-
groupId: declarationDoc.id!
|
|
56
|
-
})
|
|
55
|
+
indentIfBreak([' = ', path.call(print, 'expression'), ';'], { groupId })
|
|
57
56
|
];
|
|
58
57
|
}
|
|
59
58
|
}
|
|
@@ -57,6 +57,7 @@ export class VariableDeclarationStatement implements SlangNode {
|
|
|
57
57
|
path: AstPath<VariableDeclarationStatement>,
|
|
58
58
|
print: PrintFunction
|
|
59
59
|
): Doc {
|
|
60
|
+
const groupId = Symbol('Slang.VariableDeclarationStatement.variables');
|
|
60
61
|
const declarationDoc = group(
|
|
61
62
|
[
|
|
62
63
|
path.call(print, 'variableType'),
|
|
@@ -68,12 +69,12 @@ export class VariableDeclarationStatement implements SlangNode {
|
|
|
68
69
|
path.call(print, 'name')
|
|
69
70
|
])
|
|
70
71
|
],
|
|
71
|
-
{ id:
|
|
72
|
+
{ id: groupId }
|
|
72
73
|
);
|
|
73
74
|
|
|
74
75
|
return [
|
|
75
76
|
declarationDoc,
|
|
76
|
-
indentIfBreak(path.call(print, 'value'), { groupId
|
|
77
|
+
indentIfBreak(path.call(print, 'value'), { groupId }),
|
|
77
78
|
';'
|
|
78
79
|
];
|
|
79
80
|
}
|
|
@@ -2,7 +2,6 @@ import { NonterminalKind } from '@nomicfoundation/slang/cst';
|
|
|
2
2
|
import { getNodeMetadata, updateMetadata } from '../slang-utils/metadata.js';
|
|
3
3
|
import { YulFunctionCallExpression } from './YulFunctionCallExpression.js';
|
|
4
4
|
import { YulLiteral } from './YulLiteral.js';
|
|
5
|
-
import { YulBuiltInFunction } from './YulBuiltInFunction.js';
|
|
6
5
|
import { YulPath } from './YulPath.js';
|
|
7
6
|
|
|
8
7
|
import type * as ast from '@nomicfoundation/slang/ast';
|
|
@@ -17,11 +16,7 @@ export class YulExpression implements SlangNode {
|
|
|
17
16
|
|
|
18
17
|
loc;
|
|
19
18
|
|
|
20
|
-
variant:
|
|
21
|
-
| YulFunctionCallExpression
|
|
22
|
-
| YulLiteral
|
|
23
|
-
| YulBuiltInFunction
|
|
24
|
-
| YulPath;
|
|
19
|
+
variant: YulFunctionCallExpression | YulLiteral | YulPath;
|
|
25
20
|
|
|
26
21
|
constructor(ast: ast.YulExpression, options: ParserOptions<AstNode>) {
|
|
27
22
|
let metadata = getNodeMetadata(ast);
|
|
@@ -36,11 +31,6 @@ export class YulExpression implements SlangNode {
|
|
|
36
31
|
case NonterminalKind.YulLiteral:
|
|
37
32
|
this.variant = new YulLiteral(ast.variant as ast.YulLiteral, options);
|
|
38
33
|
break;
|
|
39
|
-
case NonterminalKind.YulBuiltInFunction:
|
|
40
|
-
this.variant = new YulBuiltInFunction(
|
|
41
|
-
ast.variant as ast.YulBuiltInFunction
|
|
42
|
-
);
|
|
43
|
-
break;
|
|
44
34
|
case NonterminalKind.YulPath:
|
|
45
35
|
this.variant = new YulPath(ast.variant as ast.YulPath);
|
|
46
36
|
break;
|
|
@@ -20,7 +20,6 @@ import type { CallOptionsExpression } from './CallOptionsExpression.ts';
|
|
|
20
20
|
import type { CatchClause } from './CatchClause.ts';
|
|
21
21
|
import type { CatchClauseError } from './CatchClauseError.ts';
|
|
22
22
|
import type { CatchClauses } from './CatchClauses.ts';
|
|
23
|
-
import type { ComparisonExpression } from './ComparisonExpression.ts';
|
|
24
23
|
import type { ConditionalExpression } from './ConditionalExpression.ts';
|
|
25
24
|
import type { ConstantDefinition } from './ConstantDefinition.ts';
|
|
26
25
|
import type { ConstructorAttribute } from './ConstructorAttribute.ts';
|
|
@@ -30,6 +29,8 @@ import type { ContinueStatement } from './ContinueStatement.ts';
|
|
|
30
29
|
import type { ContractDefinition } from './ContractDefinition.ts';
|
|
31
30
|
import type { ContractMember } from './ContractMember.ts';
|
|
32
31
|
import type { ContractMembers } from './ContractMembers.ts';
|
|
32
|
+
import type { ContractSpecifier } from './ContractSpecifier.ts';
|
|
33
|
+
import type { ContractSpecifiers } from './ContractSpecifiers.ts';
|
|
33
34
|
import type { DecimalNumberExpression } from './DecimalNumberExpression.ts';
|
|
34
35
|
import type { DoWhileStatement } from './DoWhileStatement.ts';
|
|
35
36
|
import type { ElementaryType } from './ElementaryType.ts';
|
|
@@ -80,6 +81,7 @@ import type { ImportDeconstructionSymbols } from './ImportDeconstructionSymbols.
|
|
|
80
81
|
import type { ImportDirective } from './ImportDirective.ts';
|
|
81
82
|
import type { IndexAccessEnd } from './IndexAccessEnd.ts';
|
|
82
83
|
import type { IndexAccessExpression } from './IndexAccessExpression.ts';
|
|
84
|
+
import type { InequalityExpression } from './InequalityExpression.ts';
|
|
83
85
|
import type { InheritanceSpecifier } from './InheritanceSpecifier.ts';
|
|
84
86
|
import type { InheritanceType } from './InheritanceType.ts';
|
|
85
87
|
import type { InheritanceTypes } from './InheritanceTypes.ts';
|
|
@@ -139,6 +141,7 @@ import type { StateVariableAttribute } from './StateVariableAttribute.ts';
|
|
|
139
141
|
import type { StateVariableAttributes } from './StateVariableAttributes.ts';
|
|
140
142
|
import type { StateVariableDefinition } from './StateVariableDefinition.ts';
|
|
141
143
|
import type { StateVariableDefinitionValue } from './StateVariableDefinitionValue.ts';
|
|
144
|
+
import type { StorageLayoutSpecifier } from './StorageLayoutSpecifier.ts';
|
|
142
145
|
import type { StorageLocation } from './StorageLocation.ts';
|
|
143
146
|
import type { StringExpression } from './StringExpression.ts';
|
|
144
147
|
import type { StringLiteral } from './StringLiteral.ts';
|
|
@@ -190,7 +193,6 @@ import type { YulArguments } from './YulArguments.ts';
|
|
|
190
193
|
import type { YulAssignmentOperator } from './YulAssignmentOperator.ts';
|
|
191
194
|
import type { YulBlock } from './YulBlock.ts';
|
|
192
195
|
import type { YulBreakStatement } from './YulBreakStatement.ts';
|
|
193
|
-
import type { YulBuiltInFunction } from './YulBuiltInFunction.ts';
|
|
194
196
|
import type { YulColonAndEqual } from './YulColonAndEqual.ts';
|
|
195
197
|
import type { YulContinueStatement } from './YulContinueStatement.ts';
|
|
196
198
|
import type { YulDefaultCase } from './YulDefaultCase.ts';
|
|
@@ -258,6 +260,7 @@ export type StrictAstNode =
|
|
|
258
260
|
| ContractDefinition
|
|
259
261
|
| InheritanceSpecifier
|
|
260
262
|
| InheritanceType
|
|
263
|
+
| StorageLayoutSpecifier
|
|
261
264
|
| InterfaceDefinition
|
|
262
265
|
| LibraryDefinition
|
|
263
266
|
| StructDefinition
|
|
@@ -321,7 +324,7 @@ export type StrictAstNode =
|
|
|
321
324
|
| OrExpression
|
|
322
325
|
| AndExpression
|
|
323
326
|
| EqualityExpression
|
|
324
|
-
|
|
|
327
|
+
| InequalityExpression
|
|
325
328
|
| BitwiseOrExpression
|
|
326
329
|
| BitwiseXorExpression
|
|
327
330
|
| BitwiseAndExpression
|
|
@@ -409,10 +412,11 @@ export type StrictAstNode =
|
|
|
409
412
|
| YulAssignmentOperator
|
|
410
413
|
| YulSwitchCase
|
|
411
414
|
| YulExpression
|
|
412
|
-
| YulBuiltInFunction
|
|
413
415
|
| YulLiteral
|
|
414
416
|
| SourceUnitMembers
|
|
415
417
|
| VersionExpressionSet
|
|
418
|
+
| ContractSpecifier
|
|
419
|
+
| ContractSpecifiers
|
|
416
420
|
| ContractMembers
|
|
417
421
|
| InterfaceMembers
|
|
418
422
|
| LibraryMembers
|
|
@@ -5,8 +5,8 @@ import { createKindCheckFunction } from '../slang-utils/create-kind-check-functi
|
|
|
5
5
|
|
|
6
6
|
import type { AstPath, Doc } from 'prettier';
|
|
7
7
|
import type { BinaryOperation, StrictAstNode } from '../slang-nodes/types.d.ts';
|
|
8
|
-
import type { ComparisonExpression } from '../slang-nodes/ComparisonExpression.ts';
|
|
9
8
|
import type { EqualityExpression } from '../slang-nodes/EqualityExpression.ts';
|
|
9
|
+
import type { InequalityExpression } from '../slang-nodes/InequalityExpression.ts';
|
|
10
10
|
|
|
11
11
|
const { group, indent } = doc.builders;
|
|
12
12
|
|
|
@@ -25,7 +25,7 @@ const isBinaryOperationWithoutComparison = createKindCheckFunction([
|
|
|
25
25
|
node: StrictAstNode
|
|
26
26
|
) => node is Exclude<
|
|
27
27
|
BinaryOperation,
|
|
28
|
-
|
|
28
|
+
EqualityExpression | InequalityExpression
|
|
29
29
|
>;
|
|
30
30
|
|
|
31
31
|
const binaryGroupRulesBuilder =
|
|
@@ -11,8 +11,8 @@ export const isBinaryOperation = createKindCheckFunction([
|
|
|
11
11
|
NonterminalKind.BitwiseAndExpression,
|
|
12
12
|
NonterminalKind.BitwiseOrExpression,
|
|
13
13
|
NonterminalKind.BitwiseXorExpression,
|
|
14
|
-
NonterminalKind.ComparisonExpression,
|
|
15
14
|
NonterminalKind.EqualityExpression,
|
|
15
|
+
NonterminalKind.InequalityExpression,
|
|
16
16
|
NonterminalKind.AndExpression,
|
|
17
17
|
NonterminalKind.OrExpression,
|
|
18
18
|
NonterminalKind.ShiftExpression
|
|
@@ -0,0 +1,25 @@
|
|
|
1
|
+
import { NonterminalKind } from '@nomicfoundation/slang/cst';
|
|
2
|
+
|
|
3
|
+
import type { ContractSpecifier } from '../slang-nodes/ContractSpecifier.js';
|
|
4
|
+
|
|
5
|
+
export function sortContractSpecifiers(
|
|
6
|
+
a: ContractSpecifier,
|
|
7
|
+
b: ContractSpecifier
|
|
8
|
+
): number {
|
|
9
|
+
const aVariant = a.variant;
|
|
10
|
+
const bVariant = b.variant;
|
|
11
|
+
|
|
12
|
+
// OverrideSpecifiers before ModifierInvocation
|
|
13
|
+
if (
|
|
14
|
+
aVariant.kind === NonterminalKind.InheritanceSpecifier &&
|
|
15
|
+
bVariant.kind === NonterminalKind.StorageLayoutSpecifier
|
|
16
|
+
)
|
|
17
|
+
return -1;
|
|
18
|
+
if (
|
|
19
|
+
bVariant.kind === NonterminalKind.InheritanceSpecifier &&
|
|
20
|
+
aVariant.kind === NonterminalKind.StorageLayoutSpecifier
|
|
21
|
+
)
|
|
22
|
+
return 1;
|
|
23
|
+
|
|
24
|
+
return 0;
|
|
25
|
+
}
|
package/src/slangPrinter.ts
CHANGED
|
@@ -20,10 +20,9 @@ function hasNodeIgnoreComment(node: StrictAstNode): boolean {
|
|
|
20
20
|
}
|
|
21
21
|
|
|
22
22
|
function ignoreComments(path: AstPath<AstNode>): void {
|
|
23
|
-
// TODO: remove undefined once we stop supporting prettier 2
|
|
24
23
|
const node = path.getNode();
|
|
25
24
|
// We ignore anything that is not an object
|
|
26
|
-
if (node === null ||
|
|
25
|
+
if (node === null || typeof node !== 'object') return;
|
|
27
26
|
|
|
28
27
|
const keys = Object.keys(node) as (keyof StrictAstNode)[];
|
|
29
28
|
for (const key of keys) {
|
|
@@ -64,7 +63,7 @@ function genericPrint(
|
|
|
64
63
|
): Doc {
|
|
65
64
|
const node = path.getNode();
|
|
66
65
|
|
|
67
|
-
if (
|
|
66
|
+
if (node === null) {
|
|
68
67
|
return '';
|
|
69
68
|
}
|
|
70
69
|
|
package/src/types.d.ts
CHANGED
|
@@ -7,7 +7,6 @@ import type { AstNode, Comment, StrictAstNode } from './slang-nodes/types.d.ts';
|
|
|
7
7
|
declare module 'prettier' {
|
|
8
8
|
interface ParserOptions {
|
|
9
9
|
compiler: string;
|
|
10
|
-
experimentalTernaries: boolean;
|
|
11
10
|
}
|
|
12
11
|
}
|
|
13
12
|
|
|
@@ -40,7 +39,7 @@ interface Metadata {
|
|
|
40
39
|
|
|
41
40
|
interface SlangNode {
|
|
42
41
|
kind:
|
|
43
|
-
|
|
|
42
|
+
| NonterminalKind
|
|
44
43
|
| typeof TerminalKind.Identifier
|
|
45
44
|
| typeof TerminalKind.YulIdentifier
|
|
46
45
|
| typeof TerminalKind.MultiLineComment
|
|
@@ -58,221 +57,9 @@ interface SlangNode {
|
|
|
58
57
|
|
|
59
58
|
type PrintFunction = (path: AstPath<AstNode>) => Doc;
|
|
60
59
|
|
|
61
|
-
|
|
62
|
-
|
|
63
|
-
|
|
64
|
-
|
|
65
|
-
|
|
66
|
-
|
|
67
|
-
| ast.VersionRange
|
|
68
|
-
| ast.VersionTerm
|
|
69
|
-
| ast.ImportDirective
|
|
70
|
-
| ast.PathImport
|
|
71
|
-
| ast.NamedImport
|
|
72
|
-
| ast.ImportDeconstruction
|
|
73
|
-
| ast.ImportDeconstructionSymbol
|
|
74
|
-
| ast.ImportAlias
|
|
75
|
-
| ast.UsingDirective
|
|
76
|
-
| ast.UsingDeconstruction
|
|
77
|
-
| ast.UsingDeconstructionSymbol
|
|
78
|
-
| ast.UsingAlias
|
|
79
|
-
| ast.ContractDefinition
|
|
80
|
-
| ast.InheritanceSpecifier
|
|
81
|
-
| ast.InheritanceType
|
|
82
|
-
| ast.InterfaceDefinition
|
|
83
|
-
| ast.LibraryDefinition
|
|
84
|
-
| ast.StructDefinition
|
|
85
|
-
| ast.StructMember
|
|
86
|
-
| ast.EnumDefinition
|
|
87
|
-
| ast.ConstantDefinition
|
|
88
|
-
| ast.StateVariableDefinition
|
|
89
|
-
| ast.StateVariableDefinitionValue
|
|
90
|
-
| ast.FunctionDefinition
|
|
91
|
-
| ast.ParametersDeclaration
|
|
92
|
-
| ast.Parameter
|
|
93
|
-
| ast.OverrideSpecifier
|
|
94
|
-
| ast.OverridePathsDeclaration
|
|
95
|
-
| ast.ReturnsDeclaration
|
|
96
|
-
| ast.ConstructorDefinition
|
|
97
|
-
| ast.UnnamedFunctionDefinition
|
|
98
|
-
| ast.FallbackFunctionDefinition
|
|
99
|
-
| ast.ReceiveFunctionDefinition
|
|
100
|
-
| ast.ModifierDefinition
|
|
101
|
-
| ast.ModifierInvocation
|
|
102
|
-
| ast.EventDefinition
|
|
103
|
-
| ast.EventParametersDeclaration
|
|
104
|
-
| ast.EventParameter
|
|
105
|
-
| ast.UserDefinedValueTypeDefinition
|
|
106
|
-
| ast.ErrorDefinition
|
|
107
|
-
| ast.ErrorParametersDeclaration
|
|
108
|
-
| ast.ErrorParameter
|
|
109
|
-
| ast.ArrayTypeName
|
|
110
|
-
| ast.FunctionType
|
|
111
|
-
| ast.MappingType
|
|
112
|
-
| ast.MappingKey
|
|
113
|
-
| ast.MappingValue
|
|
114
|
-
| ast.AddressType
|
|
115
|
-
| ast.Block
|
|
116
|
-
| ast.UncheckedBlock
|
|
117
|
-
| ast.ExpressionStatement
|
|
118
|
-
| ast.AssemblyStatement
|
|
119
|
-
| ast.AssemblyFlagsDeclaration
|
|
120
|
-
| ast.TupleDeconstructionStatement
|
|
121
|
-
| ast.TupleDeconstructionElement
|
|
122
|
-
| ast.TypedTupleMember
|
|
123
|
-
| ast.UntypedTupleMember
|
|
124
|
-
| ast.VariableDeclarationStatement
|
|
125
|
-
| ast.VariableDeclarationValue
|
|
126
|
-
| ast.IfStatement
|
|
127
|
-
| ast.ElseBranch
|
|
128
|
-
| ast.ForStatement
|
|
129
|
-
| ast.WhileStatement
|
|
130
|
-
| ast.DoWhileStatement
|
|
131
|
-
| ast.ContinueStatement
|
|
132
|
-
| ast.BreakStatement
|
|
133
|
-
| ast.ReturnStatement
|
|
134
|
-
| ast.EmitStatement
|
|
135
|
-
| ast.TryStatement
|
|
136
|
-
| ast.CatchClause
|
|
137
|
-
| ast.CatchClauseError
|
|
138
|
-
| ast.RevertStatement
|
|
139
|
-
| ast.ThrowStatement
|
|
140
|
-
| ast.AssignmentExpression
|
|
141
|
-
| ast.ConditionalExpression
|
|
142
|
-
| ast.OrExpression
|
|
143
|
-
| ast.AndExpression
|
|
144
|
-
| ast.EqualityExpression
|
|
145
|
-
| ast.ComparisonExpression
|
|
146
|
-
| ast.BitwiseOrExpression
|
|
147
|
-
| ast.BitwiseXorExpression
|
|
148
|
-
| ast.BitwiseAndExpression
|
|
149
|
-
| ast.ShiftExpression
|
|
150
|
-
| ast.AdditiveExpression
|
|
151
|
-
| ast.MultiplicativeExpression
|
|
152
|
-
| ast.ExponentiationExpression
|
|
153
|
-
| ast.PostfixExpression
|
|
154
|
-
| ast.PrefixExpression
|
|
155
|
-
| ast.FunctionCallExpression
|
|
156
|
-
| ast.CallOptionsExpression
|
|
157
|
-
| ast.MemberAccessExpression
|
|
158
|
-
| ast.IndexAccessExpression
|
|
159
|
-
| ast.IndexAccessEnd
|
|
160
|
-
| ast.PositionalArgumentsDeclaration
|
|
161
|
-
| ast.NamedArgumentsDeclaration
|
|
162
|
-
| ast.NamedArgumentGroup
|
|
163
|
-
| ast.NamedArgument
|
|
164
|
-
| ast.TypeExpression
|
|
165
|
-
| ast.NewExpression
|
|
166
|
-
| ast.TupleExpression
|
|
167
|
-
| ast.TupleValue
|
|
168
|
-
| ast.ArrayExpression
|
|
169
|
-
| ast.HexNumberExpression
|
|
170
|
-
| ast.DecimalNumberExpression
|
|
171
|
-
| ast.YulBlock
|
|
172
|
-
| ast.YulFunctionDefinition
|
|
173
|
-
| ast.YulParametersDeclaration
|
|
174
|
-
| ast.YulReturnsDeclaration
|
|
175
|
-
| ast.YulVariableDeclarationStatement
|
|
176
|
-
| ast.YulVariableDeclarationValue
|
|
177
|
-
| ast.YulVariableAssignmentStatement
|
|
178
|
-
| ast.YulStackAssignmentStatement
|
|
179
|
-
| ast.YulStackAssignmentOperator
|
|
180
|
-
| ast.YulColonAndEqual
|
|
181
|
-
| ast.YulEqualAndColon
|
|
182
|
-
| ast.YulIfStatement
|
|
183
|
-
| ast.YulForStatement
|
|
184
|
-
| ast.YulSwitchStatement
|
|
185
|
-
| ast.YulDefaultCase
|
|
186
|
-
| ast.YulValueCase
|
|
187
|
-
| ast.YulLeaveStatement
|
|
188
|
-
| ast.YulBreakStatement
|
|
189
|
-
| ast.YulContinueStatement
|
|
190
|
-
| ast.YulLabel
|
|
191
|
-
| ast.YulFunctionCallExpression
|
|
192
|
-
| ast.SourceUnitMember
|
|
193
|
-
| ast.Pragma
|
|
194
|
-
| ast.ExperimentalFeature
|
|
195
|
-
| ast.VersionExpression
|
|
196
|
-
| ast.VersionOperator
|
|
197
|
-
| ast.VersionLiteral
|
|
198
|
-
| ast.ImportClause
|
|
199
|
-
| ast.UsingClause
|
|
200
|
-
| ast.UsingOperator
|
|
201
|
-
| ast.UsingTarget
|
|
202
|
-
| ast.ContractMember
|
|
203
|
-
| ast.StateVariableAttribute
|
|
204
|
-
| ast.FunctionName
|
|
205
|
-
| ast.FunctionAttribute
|
|
206
|
-
| ast.FunctionBody
|
|
207
|
-
| ast.ConstructorAttribute
|
|
208
|
-
| ast.UnnamedFunctionAttribute
|
|
209
|
-
| ast.FallbackFunctionAttribute
|
|
210
|
-
| ast.ReceiveFunctionAttribute
|
|
211
|
-
| ast.ModifierAttribute
|
|
212
|
-
| ast.TypeName
|
|
213
|
-
| ast.FunctionTypeAttribute
|
|
214
|
-
| ast.MappingKeyType
|
|
215
|
-
| ast.ElementaryType
|
|
216
|
-
| ast.Statement
|
|
217
|
-
| ast.TupleMember
|
|
218
|
-
| ast.VariableDeclarationType
|
|
219
|
-
| ast.StorageLocation
|
|
220
|
-
| ast.ForStatementInitialization
|
|
221
|
-
| ast.ForStatementCondition
|
|
222
|
-
| ast.Expression
|
|
223
|
-
| ast.ArgumentsDeclaration
|
|
224
|
-
| ast.NumberUnit
|
|
225
|
-
| ast.StringExpression
|
|
226
|
-
| ast.StringLiteral
|
|
227
|
-
| ast.HexStringLiteral
|
|
228
|
-
| ast.UnicodeStringLiteral
|
|
229
|
-
| ast.YulStatement
|
|
230
|
-
| ast.YulAssignmentOperator
|
|
231
|
-
| ast.YulSwitchCase
|
|
232
|
-
| ast.YulExpression
|
|
233
|
-
| ast.YulBuiltInFunction
|
|
234
|
-
| ast.YulLiteral
|
|
235
|
-
| ast.SourceUnitMembers
|
|
236
|
-
| ast.VersionExpressionSet
|
|
237
|
-
| ast.ContractMembers
|
|
238
|
-
| ast.InterfaceMembers
|
|
239
|
-
| ast.LibraryMembers
|
|
240
|
-
| ast.StructMembers
|
|
241
|
-
| ast.StateVariableAttributes
|
|
242
|
-
| ast.FunctionAttributes
|
|
243
|
-
| ast.ConstructorAttributes
|
|
244
|
-
| ast.UnnamedFunctionAttributes
|
|
245
|
-
| ast.FallbackFunctionAttributes
|
|
246
|
-
| ast.ReceiveFunctionAttributes
|
|
247
|
-
| ast.ModifierAttributes
|
|
248
|
-
| ast.FunctionTypeAttributes
|
|
249
|
-
| ast.Statements
|
|
250
|
-
| ast.CatchClauses
|
|
251
|
-
| ast.StringLiterals
|
|
252
|
-
| ast.HexStringLiterals
|
|
253
|
-
| ast.UnicodeStringLiterals
|
|
254
|
-
| ast.YulStatements
|
|
255
|
-
| ast.YulSwitchCases
|
|
256
|
-
| ast.VersionExpressionSets
|
|
257
|
-
| ast.SimpleVersionLiteral
|
|
258
|
-
| ast.ImportDeconstructionSymbols
|
|
259
|
-
| ast.UsingDeconstructionSymbols
|
|
260
|
-
| ast.InheritanceTypes
|
|
261
|
-
| ast.EnumMembers
|
|
262
|
-
| ast.Parameters
|
|
263
|
-
| ast.OverridePaths
|
|
264
|
-
| ast.EventParameters
|
|
265
|
-
| ast.ErrorParameters
|
|
266
|
-
| ast.AssemblyFlags
|
|
267
|
-
| ast.TupleDeconstructionElements
|
|
268
|
-
| ast.PositionalArguments
|
|
269
|
-
| ast.NamedArguments
|
|
270
|
-
| ast.CallOptions
|
|
271
|
-
| ast.TupleValues
|
|
272
|
-
| ast.ArrayValues
|
|
273
|
-
| ast.IdentifierPath
|
|
274
|
-
| ast.YulParameters
|
|
275
|
-
| ast.YulVariableNames
|
|
276
|
-
| ast.YulArguments
|
|
277
|
-
| ast.YulPaths
|
|
278
|
-
| ast.YulPath;
|
|
60
|
+
// This the union of all the types in the namespace `ast`.
|
|
61
|
+
type TypeOfAst = typeof ast;
|
|
62
|
+
type KeyOfAst = keyof TypeOfAst;
|
|
63
|
+
type ValuesOf<E> = E[keyof E];
|
|
64
|
+
|
|
65
|
+
type SlangAstNode = { [k in KeyOfAst]: ValuesOf<TypeOfAst[k]> }[KeyOfAst];
|
|
Binary file
|
|
Binary file
|
|
Binary file
|
|
@@ -1,15 +0,0 @@
|
|
|
1
|
-
import { NonterminalKind } from '@nomicfoundation/slang/cst';
|
|
2
|
-
import { getNodeMetadata } from '../slang-utils/metadata.js';
|
|
3
|
-
export class YulBuiltInFunction {
|
|
4
|
-
constructor(ast) {
|
|
5
|
-
this.kind = NonterminalKind.YulBuiltInFunction;
|
|
6
|
-
const metadata = getNodeMetadata(ast);
|
|
7
|
-
this.variant = ast.variant.unparse();
|
|
8
|
-
this.comments = metadata.comments;
|
|
9
|
-
this.loc = metadata.loc;
|
|
10
|
-
}
|
|
11
|
-
print() {
|
|
12
|
-
return this.variant;
|
|
13
|
-
}
|
|
14
|
-
}
|
|
15
|
-
//# sourceMappingURL=YulBuiltInFunction.js.map
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"YulBuiltInFunction.js","sourceRoot":"","sources":["../../src/slang-nodes/YulBuiltInFunction.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,eAAe,EAAE,MAAM,4BAA4B,CAAC;AAC7D,OAAO,EAAE,eAAe,EAAE,MAAM,4BAA4B,CAAC;AAM7D,MAAM,OAAO,kBAAkB;IAS7B,YAAY,GAA2B;QAR9B,SAAI,GAAG,eAAe,CAAC,kBAAkB,CAAC;QASjD,MAAM,QAAQ,GAAG,eAAe,CAAC,GAAG,CAAC,CAAC;QAEtC,IAAI,CAAC,OAAO,GAAG,GAAG,CAAC,OAAO,CAAC,OAAO,EAAE,CAAC;QAErC,IAAI,CAAC,QAAQ,GAAG,QAAQ,CAAC,QAAQ,CAAC;QAClC,IAAI,CAAC,GAAG,GAAG,QAAQ,CAAC,GAAG,CAAC;IAC1B,CAAC;IAED,KAAK;QACH,OAAO,IAAI,CAAC,OAAO,CAAC;IACtB,CAAC;CACF"}
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"prettier-version-satisfies.js","sourceRoot":"","sources":["../../src/slang-utils/prettier-version-satisfies.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,OAAO,EAAE,MAAM,UAAU,CAAC;AACnC,OAAO,SAAS,MAAM,+BAA+B,CAAC;AAItD,MAAM,UAAU,wBAAwB,CAAC,KAAqB;IAC5D,OAAO,SAAS,CAAC,OAAO,EAAE,KAAK,CAAC,CAAC;AACnC,CAAC"}
|
|
@@ -1,12 +0,0 @@
|
|
|
1
|
-
export function printWarning(message) {
|
|
2
|
-
// Prettier prints some temporary messages while formatting, and this warning
|
|
3
|
-
// can mess with that output. We clear the line and move the cursor to the
|
|
4
|
-
// beginning of the line to avoid this.
|
|
5
|
-
//
|
|
6
|
-
// \x1b: Escape character
|
|
7
|
-
// [2K: Escape code to clear the entire line
|
|
8
|
-
// \r: Carriage return
|
|
9
|
-
const clearLine = '\x1b[2K\r';
|
|
10
|
-
console.warn(`${clearLine}[prettier-solidity] ${message}`);
|
|
11
|
-
}
|
|
12
|
-
//# sourceMappingURL=print-warning.js.map
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"print-warning.js","sourceRoot":"","sources":["../../src/slang-utils/print-warning.ts"],"names":[],"mappings":"AAAA,MAAM,UAAU,YAAY,CAAC,OAAe;IAC1C,6EAA6E;IAC7E,0EAA0E;IAC1E,uCAAuC;IACvC,EAAE;IACF,yBAAyB;IACzB,6CAA6C;IAC7C,wBAAwB;IACxB,MAAM,SAAS,GAAG,WAAW,CAAC;IAE9B,OAAO,CAAC,IAAI,CAAC,GAAG,SAAS,uBAAuB,OAAO,EAAE,CAAC,CAAC;AAC7D,CAAC"}
|
|
@@ -1,29 +0,0 @@
|
|
|
1
|
-
import { NonterminalKind } from '@nomicfoundation/slang/cst';
|
|
2
|
-
import { getNodeMetadata } from '../slang-utils/metadata.js';
|
|
3
|
-
|
|
4
|
-
import type * as ast from '@nomicfoundation/slang/ast';
|
|
5
|
-
import type { Doc } from 'prettier';
|
|
6
|
-
import type { SlangNode } from '../types.d.ts';
|
|
7
|
-
|
|
8
|
-
export class YulBuiltInFunction implements SlangNode {
|
|
9
|
-
readonly kind = NonterminalKind.YulBuiltInFunction;
|
|
10
|
-
|
|
11
|
-
comments;
|
|
12
|
-
|
|
13
|
-
loc;
|
|
14
|
-
|
|
15
|
-
variant: string;
|
|
16
|
-
|
|
17
|
-
constructor(ast: ast.YulBuiltInFunction) {
|
|
18
|
-
const metadata = getNodeMetadata(ast);
|
|
19
|
-
|
|
20
|
-
this.variant = ast.variant.unparse();
|
|
21
|
-
|
|
22
|
-
this.comments = metadata.comments;
|
|
23
|
-
this.loc = metadata.loc;
|
|
24
|
-
}
|
|
25
|
-
|
|
26
|
-
print(): Doc {
|
|
27
|
-
return this.variant;
|
|
28
|
-
}
|
|
29
|
-
}
|
|
@@ -1,12 +0,0 @@
|
|
|
1
|
-
export function printWarning(message: string): void {
|
|
2
|
-
// Prettier prints some temporary messages while formatting, and this warning
|
|
3
|
-
// can mess with that output. We clear the line and move the cursor to the
|
|
4
|
-
// beginning of the line to avoid this.
|
|
5
|
-
//
|
|
6
|
-
// \x1b: Escape character
|
|
7
|
-
// [2K: Escape code to clear the entire line
|
|
8
|
-
// \r: Carriage return
|
|
9
|
-
const clearLine = '\x1b[2K\r';
|
|
10
|
-
|
|
11
|
-
console.warn(`${clearLine}[prettier-solidity] ${message}`);
|
|
12
|
-
}
|