@@ -2,45 +2,12 @@ import { isBlockComment } from './slang-utils/is-comment.js';
22import { locEnd , locStart } from './slang-utils/loc.js' ;
33
44import type { AstPath , Doc , ParserOptions } from 'prettier' ;
5- import type { AstNode , StrictAstNode } from './slang-nodes/types.d.ts' ;
5+ import type {
6+ AstNode ,
7+ StrictAstNode ,
8+ StrictPolymorphicNode
9+ } from './slang-nodes/types.d.ts' ;
610import type { PrintFunction } from './types.d.ts' ;
7- import type { ArgumentsDeclaration } from './slang-nodes/ArgumentsDeclaration.js' ;
8- import type { ConstructorAttribute } from './slang-nodes/ConstructorAttribute.js' ;
9- import type { FallbackFunctionAttribute } from './slang-nodes/FallbackFunctionAttribute.js' ;
10- import type { FunctionAttribute } from './slang-nodes/FunctionAttribute.js' ;
11- import type { FunctionTypeAttribute } from './slang-nodes/FunctionTypeAttribute.js' ;
12- import type { ModifierAttribute } from './slang-nodes/ModifierAttribute.js' ;
13- import type { ReceiveFunctionAttribute } from './slang-nodes/ReceiveFunctionAttribute.js' ;
14- import type { StateVariableAttribute } from './slang-nodes/StateVariableAttribute.js' ;
15- import type { UnnamedFunctionAttribute } from './slang-nodes/UnnamedFunctionAttribute.js' ;
16- import type { ContractMember } from './slang-nodes/ContractMember.js' ;
17- import type { SourceUnitMember } from './slang-nodes/SourceUnitMember.js' ;
18- import type { Statement } from './slang-nodes/Statement.js' ;
19- import type { YulStatement } from './slang-nodes/YulStatement.js' ;
20- import type { ContractSpecifier } from './slang-nodes/ContractSpecifier.js' ;
21- import type { ElementaryType } from './slang-nodes/ElementaryType.js' ;
22- import type { ExperimentalFeature } from './slang-nodes/ExperimentalFeature.js' ;
23- import type { Expression } from './slang-nodes/Expression.js' ;
24- import type { ForStatementInitialization } from './slang-nodes/ForStatementInitialization.js' ;
25- import type { ForStatementCondition } from './slang-nodes/ForStatementCondition.js' ;
26- import type { FunctionBody } from './slang-nodes/FunctionBody.js' ;
27- import type { FunctionName } from './slang-nodes/FunctionName.js' ;
28- import type { ImportClause } from './slang-nodes/ImportClause.js' ;
29- import type { MappingKeyType } from './slang-nodes/MappingKeyType.js' ;
30- import type { Pragma } from './slang-nodes/Pragma.js' ;
31- import type { StringExpression } from './slang-nodes/StringExpression.js' ;
32- import type { TupleMember } from './slang-nodes/TupleMember.js' ;
33- import type { TypeName } from './slang-nodes/TypeName.js' ;
34- import type { UsingClause } from './slang-nodes/UsingClause.js' ;
35- import type { UsingTarget } from './slang-nodes/UsingTarget.js' ;
36- import type { VariableDeclarationType } from './slang-nodes/VariableDeclarationType.js' ;
37- import type { VersionExpression } from './slang-nodes/VersionExpression.js' ;
38- import type { VersionLiteral } from './slang-nodes/VersionLiteral.js' ;
39- import type { YulAssignmentOperator } from './slang-nodes/YulAssignmentOperator.js' ;
40- import type { YulLiteral } from './slang-nodes/YulLiteral.js' ;
41- import type { YulStackAssignmentOperator } from './slang-nodes/YulStackAssignmentOperator.js' ;
42- import type { YulSwitchCase } from './slang-nodes/YulSwitchCase.js' ;
43- import type { YulExpression } from './slang-nodes/YulExpression.js' ;
4411
4512function hasNodeIgnoreComment ( { comments } : StrictAstNode ) : boolean {
4613 // Prettier sets SourceUnit's comments to undefined after assigning comments
@@ -90,48 +57,7 @@ function ignoreComments(path: AstPath<AstNode>): void {
9057// Nodes take care of undefined and string properties so we can restrict path
9158// to AstPath<StrictAstNode>
9259function genericPrint (
93- path : AstPath <
94- Exclude <
95- StrictAstNode ,
96- | ArgumentsDeclaration
97- | ConstructorAttribute
98- | FallbackFunctionAttribute
99- | FunctionAttribute
100- | FunctionTypeAttribute
101- | ModifierAttribute
102- | ReceiveFunctionAttribute
103- | StateVariableAttribute
104- | UnnamedFunctionAttribute
105- | ContractMember
106- | SourceUnitMember
107- | Statement
108- | YulStatement
109- | ContractSpecifier
110- | ElementaryType
111- | ExperimentalFeature
112- | Expression
113- | ForStatementInitialization
114- | ForStatementCondition
115- | FunctionBody
116- | FunctionName
117- | ImportClause
118- | MappingKeyType
119- | Pragma
120- | StringExpression
121- | TupleMember
122- | TypeName
123- | UsingClause
124- | UsingTarget
125- | VariableDeclarationType
126- | VersionExpression
127- | VersionLiteral
128- | YulAssignmentOperator
129- | YulLiteral
130- | YulStackAssignmentOperator
131- | YulSwitchCase
132- | YulExpression
133- >
134- > ,
60+ path : AstPath < Exclude < StrictAstNode , StrictPolymorphicNode > > ,
13561 options : ParserOptions < AstNode > ,
13662 print : PrintFunction
13763) : Doc {
0 commit comments