prettier-plugin-solidity 2.0.0-beta.6 → 2.0.0-beta.7
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/28d7fb838862acf337c8.wasm +0 -0
- package/dist/80ab9aab2ee473939a05.wasm +0 -0
- package/dist/d6da904aec8bb797eac6.wasm +0 -0
- package/dist/e0ce19302a589ebeaa6d.wasm +0 -0
- package/dist/slang-nodes/YulPath.js +4 -5
- package/dist/slang-nodes/YulPath.js.map +1 -1
- package/dist/slang-utils/create-parser.js +11 -10
- package/dist/slang-utils/create-parser.js.map +1 -1
- package/dist/slang-utils/metadata.js +1 -1
- package/dist/slang-utils/metadata.js.map +1 -1
- package/dist/slangSolidityParser.js +2 -2
- package/dist/slangSolidityParser.js.map +1 -1
- package/dist/standalone.js +1 -1
- package/dist/standalone.js.map +1 -1
- package/package.json +9 -9
- package/src/slang-nodes/YulPath.ts +5 -7
- package/src/slang-nodes/types.d.ts +0 -2
- package/src/slang-utils/create-parser.ts +11 -10
- package/src/slang-utils/metadata.ts +1 -1
- package/src/slangSolidityParser.ts +3 -3
- package/src/types.d.ts +0 -1
- package/dist/31ca71009a37f38d3a02.wasm +0 -0
- package/dist/8c7945c354c0e90e3eea.wasm +0 -0
- package/dist/fe6fce76f8236b8b86c6.wasm +0 -0
- package/dist/ffc577b688b8d07825c1.wasm +0 -0
- package/dist/slang-nodes/YulPathComponent.js +0 -16
- package/dist/slang-nodes/YulPathComponent.js.map +0 -1
- package/src/slang-nodes/YulPathComponent.ts +0 -30
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "prettier-plugin-solidity",
|
|
3
|
-
"version": "2.0.0-beta.
|
|
3
|
+
"version": "2.0.0-beta.7",
|
|
4
4
|
"description": "A Prettier Plugin for automatically formatting your Solidity code.",
|
|
5
5
|
"type": "module",
|
|
6
6
|
"main": "./dist/index.js",
|
|
@@ -86,12 +86,12 @@
|
|
|
86
86
|
"@babel/code-frame": "^7.26.2",
|
|
87
87
|
"@types/jest": "^29.5.14",
|
|
88
88
|
"@types/semver": "^7.5.8",
|
|
89
|
-
"@typescript-eslint/eslint-plugin": "^8.
|
|
90
|
-
"@typescript-eslint/parser": "^8.
|
|
89
|
+
"@typescript-eslint/eslint-plugin": "^8.22.0",
|
|
90
|
+
"@typescript-eslint/parser": "^8.22.0",
|
|
91
91
|
"c8": "^10.1.3",
|
|
92
92
|
"cross-env": "^7.0.3",
|
|
93
|
-
"eslint": "^9.
|
|
94
|
-
"eslint-config-prettier": "
|
|
93
|
+
"eslint": "^9.19.0",
|
|
94
|
+
"eslint-config-prettier": "10.0.1",
|
|
95
95
|
"esm-utils": "^4.3.0",
|
|
96
96
|
"jest": "^29.7.0",
|
|
97
97
|
"jest-light-runner": "^0.6.0",
|
|
@@ -101,16 +101,16 @@
|
|
|
101
101
|
"lines-and-columns": "^2.0.4",
|
|
102
102
|
"prettier": "^3.4.2",
|
|
103
103
|
"solc": "^0.8.28",
|
|
104
|
-
"ts-loader": "^9.5.
|
|
104
|
+
"ts-loader": "^9.5.2",
|
|
105
105
|
"ts-node": "^10.9.2",
|
|
106
|
-
"typescript": "^5.7.
|
|
106
|
+
"typescript": "^5.7.3",
|
|
107
107
|
"webpack": "^5.97.1",
|
|
108
108
|
"webpack-cli": "^6.0.1"
|
|
109
109
|
},
|
|
110
110
|
"dependencies": {
|
|
111
|
-
"@nomicfoundation/slang": "0.
|
|
111
|
+
"@nomicfoundation/slang": "0.19.0",
|
|
112
112
|
"@solidity-parser/parser": "^0.19.0",
|
|
113
|
-
"semver": "^7.
|
|
113
|
+
"semver": "^7.7.0"
|
|
114
114
|
},
|
|
115
115
|
"peerDependencies": {
|
|
116
116
|
"prettier": ">=3.0.0"
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
import { NonterminalKind } from '@nomicfoundation/slang/cst';
|
|
2
|
-
import { getNodeMetadata
|
|
3
|
-
import {
|
|
2
|
+
import { getNodeMetadata } from '../slang-utils/metadata.js';
|
|
3
|
+
import { YulIdentifier } from './YulIdentifier.js';
|
|
4
4
|
|
|
5
5
|
import type * as ast from '@nomicfoundation/slang/ast';
|
|
6
6
|
import type { AstPath, Doc } from 'prettier';
|
|
@@ -13,18 +13,16 @@ export class YulPath implements SlangNode {
|
|
|
13
13
|
|
|
14
14
|
loc;
|
|
15
15
|
|
|
16
|
-
items:
|
|
16
|
+
items: YulIdentifier[];
|
|
17
17
|
|
|
18
18
|
separators: string[];
|
|
19
19
|
|
|
20
20
|
constructor(ast: ast.YulPath) {
|
|
21
|
-
|
|
21
|
+
const metadata = getNodeMetadata(ast, true);
|
|
22
22
|
|
|
23
|
-
this.items = ast.items.map((item) => new
|
|
23
|
+
this.items = ast.items.map((item) => new YulIdentifier(item));
|
|
24
24
|
this.separators = ast.separators.map((separator) => separator.unparse());
|
|
25
25
|
|
|
26
|
-
metadata = updateMetadata(metadata, [this.items]);
|
|
27
|
-
|
|
28
26
|
this.comments = metadata.comments;
|
|
29
27
|
this.loc = metadata.loc;
|
|
30
28
|
}
|
|
@@ -207,7 +207,6 @@ import type { YulLiteral } from './YulLiteral.ts';
|
|
|
207
207
|
import type { YulParameters } from './YulParameters.ts';
|
|
208
208
|
import type { YulParametersDeclaration } from './YulParametersDeclaration.ts';
|
|
209
209
|
import type { YulPath } from './YulPath.ts';
|
|
210
|
-
import type { YulPathComponent } from './YulPathComponent.ts';
|
|
211
210
|
import type { YulPaths } from './YulPaths.ts';
|
|
212
211
|
import type { YulReturnsDeclaration } from './YulReturnsDeclaration.ts';
|
|
213
212
|
import type { YulStackAssignmentOperator } from './YulStackAssignmentOperator.ts';
|
|
@@ -410,7 +409,6 @@ export type StrictAstNode =
|
|
|
410
409
|
| YulAssignmentOperator
|
|
411
410
|
| YulSwitchCase
|
|
412
411
|
| YulExpression
|
|
413
|
-
| YulPathComponent
|
|
414
412
|
| YulBuiltInFunction
|
|
415
413
|
| YulLiteral
|
|
416
414
|
| SourceUnitMembers
|
|
@@ -1,6 +1,7 @@
|
|
|
1
1
|
import { VersionExpressionSets as SlangVersionExpressionSets } from '@nomicfoundation/slang/ast';
|
|
2
2
|
import { NonterminalKind, Query } from '@nomicfoundation/slang/cst';
|
|
3
3
|
import { Parser } from '@nomicfoundation/slang/parser';
|
|
4
|
+
import { LanguageFacts } from '@nomicfoundation/slang/utils';
|
|
4
5
|
import {
|
|
5
6
|
maxSatisfying,
|
|
6
7
|
minSatisfying,
|
|
@@ -15,7 +16,7 @@ import type { ParseOutput } from '@nomicfoundation/slang/parser';
|
|
|
15
16
|
import type { ParserOptions } from 'prettier';
|
|
16
17
|
import type { AstNode } from '../slang-nodes/types.js';
|
|
17
18
|
|
|
18
|
-
const supportedVersions =
|
|
19
|
+
const supportedVersions = LanguageFacts.allVersions();
|
|
19
20
|
|
|
20
21
|
const milestoneVersions = Array.from(
|
|
21
22
|
supportedVersions.reduce((minorRanges, version) => {
|
|
@@ -31,7 +32,7 @@ const milestoneVersions = Array.from(
|
|
|
31
32
|
}, []);
|
|
32
33
|
|
|
33
34
|
const queries = [
|
|
34
|
-
Query.
|
|
35
|
+
Query.create('[VersionPragma @versionRanges [VersionExpressionSets]]')
|
|
35
36
|
];
|
|
36
37
|
|
|
37
38
|
let parser: Parser;
|
|
@@ -42,10 +43,10 @@ export function createParser(
|
|
|
42
43
|
): [Parser, ParseOutput] {
|
|
43
44
|
const compiler = maxSatisfying(supportedVersions, options.compiler);
|
|
44
45
|
if (compiler) {
|
|
45
|
-
if (!parser || parser.
|
|
46
|
+
if (!parser || parser.languageVersion !== compiler) {
|
|
46
47
|
parser = Parser.create(compiler);
|
|
47
48
|
}
|
|
48
|
-
return [parser, parser.
|
|
49
|
+
return [parser, parser.parseNonterminal(NonterminalKind.SourceUnit, text)];
|
|
49
50
|
}
|
|
50
51
|
|
|
51
52
|
let isCachedParser = false;
|
|
@@ -59,7 +60,7 @@ export function createParser(
|
|
|
59
60
|
let inferredRanges: string[] = [];
|
|
60
61
|
|
|
61
62
|
try {
|
|
62
|
-
parseOutput = parser.
|
|
63
|
+
parseOutput = parser.parseNonterminal(NonterminalKind.SourceUnit, text);
|
|
63
64
|
inferredRanges = tryToCollectPragmas(parseOutput, parser, isCachedParser);
|
|
64
65
|
} catch {
|
|
65
66
|
for (
|
|
@@ -70,7 +71,7 @@ export function createParser(
|
|
|
70
71
|
try {
|
|
71
72
|
const version = milestoneVersions[i];
|
|
72
73
|
parser = Parser.create(version);
|
|
73
|
-
parseOutput = parser.
|
|
74
|
+
parseOutput = parser.parseNonterminal(NonterminalKind.SourceUnit, text);
|
|
74
75
|
inferredRanges = tryToCollectPragmas(parseOutput, parser);
|
|
75
76
|
break;
|
|
76
77
|
} catch {
|
|
@@ -98,9 +99,9 @@ export function createParser(
|
|
|
98
99
|
? satisfyingVersions[satisfyingVersions.length - 1]
|
|
99
100
|
: supportedVersions[supportedVersions.length - 1];
|
|
100
101
|
|
|
101
|
-
if (inferredVersion !== parser.
|
|
102
|
+
if (inferredVersion !== parser.languageVersion) {
|
|
102
103
|
parser = Parser.create(inferredVersion);
|
|
103
|
-
parseOutput = parser.
|
|
104
|
+
parseOutput = parser.parseNonterminal(NonterminalKind.SourceUnit, text);
|
|
104
105
|
}
|
|
105
106
|
|
|
106
107
|
// eslint-disable-next-line @typescript-eslint/no-unnecessary-type-assertion
|
|
@@ -132,11 +133,11 @@ function tryToCollectPragmas(
|
|
|
132
133
|
if (ranges.length === 0) {
|
|
133
134
|
// If we didn't find pragmas but succeeded parsing the source we keep it.
|
|
134
135
|
if (!isCachedParser && parseOutput.isValid()) {
|
|
135
|
-
return [parser.
|
|
136
|
+
return [parser.languageVersion];
|
|
136
137
|
}
|
|
137
138
|
// Otherwise we throw.
|
|
138
139
|
throw new Error(
|
|
139
|
-
`Using version ${parser.
|
|
140
|
+
`Using version ${parser.languageVersion} did not find any pragma statement and does not parse without errors.`
|
|
140
141
|
);
|
|
141
142
|
}
|
|
142
143
|
|
|
@@ -15,13 +15,13 @@ export default function parse(
|
|
|
15
15
|
|
|
16
16
|
if (parseOutput.isValid()) {
|
|
17
17
|
// We update the compiler version by the inferred one.
|
|
18
|
-
options.compiler = parser.
|
|
18
|
+
options.compiler = parser.languageVersion;
|
|
19
19
|
const parsed = new SourceUnit(
|
|
20
|
-
new SlangSourceUnit(parseOutput.tree.asNonterminalNode()
|
|
20
|
+
new SlangSourceUnit(parseOutput.tree.asNonterminalNode()),
|
|
21
21
|
options
|
|
22
22
|
);
|
|
23
23
|
clearOffsets();
|
|
24
24
|
return parsed;
|
|
25
25
|
}
|
|
26
|
-
throw new Error(parseOutput.errors[0].message);
|
|
26
|
+
throw new Error(parseOutput.errors()[0].message);
|
|
27
27
|
}
|
package/src/types.d.ts
CHANGED
|
Binary file
|
|
Binary file
|
|
Binary file
|
|
Binary file
|
|
@@ -1,16 +0,0 @@
|
|
|
1
|
-
import { NonterminalKind } from '@nomicfoundation/slang/cst';
|
|
2
|
-
import { getNodeMetadata } from '../slang-utils/metadata.js';
|
|
3
|
-
import { YulIdentifier } from './YulIdentifier.js';
|
|
4
|
-
export class YulPathComponent {
|
|
5
|
-
constructor(ast) {
|
|
6
|
-
this.kind = NonterminalKind.YulPathComponent;
|
|
7
|
-
const metadata = getNodeMetadata(ast);
|
|
8
|
-
this.variant = new YulIdentifier(ast.variant);
|
|
9
|
-
this.comments = metadata.comments;
|
|
10
|
-
this.loc = metadata.loc;
|
|
11
|
-
}
|
|
12
|
-
print(path, print) {
|
|
13
|
-
return path.call(print, 'variant');
|
|
14
|
-
}
|
|
15
|
-
}
|
|
16
|
-
//# sourceMappingURL=YulPathComponent.js.map
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"YulPathComponent.js","sourceRoot":"","sources":["../../src/slang-nodes/YulPathComponent.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,eAAe,EAAE,MAAM,4BAA4B,CAAC;AAC7D,OAAO,EAAE,eAAe,EAAE,MAAM,4BAA4B,CAAC;AAC7D,OAAO,EAAE,aAAa,EAAE,MAAM,oBAAoB,CAAC;AAMnD,MAAM,OAAO,gBAAgB;IAS3B,YAAY,GAAyB;QAR5B,SAAI,GAAG,eAAe,CAAC,gBAAgB,CAAC;QAS/C,MAAM,QAAQ,GAAG,eAAe,CAAC,GAAG,CAAC,CAAC;QAEtC,IAAI,CAAC,OAAO,GAAG,IAAI,aAAa,CAAC,GAAG,CAAC,OAAO,CAAC,CAAC;QAE9C,IAAI,CAAC,QAAQ,GAAG,QAAQ,CAAC,QAAQ,CAAC;QAClC,IAAI,CAAC,GAAG,GAAG,QAAQ,CAAC,GAAG,CAAC;IAC1B,CAAC;IAED,KAAK,CAAC,IAA+B,EAAE,KAAoB;QACzD,OAAO,IAAI,CAAC,IAAI,CAAC,KAAK,EAAE,SAAS,CAAC,CAAC;IACrC,CAAC;CACF"}
|
|
@@ -1,30 +0,0 @@
|
|
|
1
|
-
import { NonterminalKind } from '@nomicfoundation/slang/cst';
|
|
2
|
-
import { getNodeMetadata } from '../slang-utils/metadata.js';
|
|
3
|
-
import { YulIdentifier } from './YulIdentifier.js';
|
|
4
|
-
|
|
5
|
-
import type * as ast from '@nomicfoundation/slang/ast';
|
|
6
|
-
import type { AstPath, Doc } from 'prettier';
|
|
7
|
-
import type { PrintFunction, SlangNode } from '../types.d.ts';
|
|
8
|
-
|
|
9
|
-
export class YulPathComponent implements SlangNode {
|
|
10
|
-
readonly kind = NonterminalKind.YulPathComponent;
|
|
11
|
-
|
|
12
|
-
comments;
|
|
13
|
-
|
|
14
|
-
loc;
|
|
15
|
-
|
|
16
|
-
variant: YulIdentifier;
|
|
17
|
-
|
|
18
|
-
constructor(ast: ast.YulPathComponent) {
|
|
19
|
-
const metadata = getNodeMetadata(ast);
|
|
20
|
-
|
|
21
|
-
this.variant = new YulIdentifier(ast.variant);
|
|
22
|
-
|
|
23
|
-
this.comments = metadata.comments;
|
|
24
|
-
this.loc = metadata.loc;
|
|
25
|
-
}
|
|
26
|
-
|
|
27
|
-
print(path: AstPath<YulPathComponent>, print: PrintFunction): Doc {
|
|
28
|
-
return path.call(print, 'variant');
|
|
29
|
-
}
|
|
30
|
-
}
|