flow-parser 0.317.0 → 0.319.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/oxidized/FlowParser.js +249 -0
- package/oxidized/FlowParser.js.flow +457 -0
- package/oxidized/FlowParserDeserializer.js +209 -0
- package/oxidized/FlowParserDeserializer.js.flow +323 -0
- package/oxidized/FlowParserNodeDeserializers.js +1767 -0
- package/oxidized/FlowParserNodeDeserializers.js.flow +18 -0
- package/oxidized/FlowParserWASM.js +1 -0
- package/oxidized/FlowParserWASM.js.flow +119 -0
- package/oxidized/HermesAST.js.flow +57 -0
- package/oxidized/HermesParserDecodeUTF8String.js +45 -0
- package/oxidized/HermesParserDecodeUTF8String.js.flow +65 -0
- package/oxidized/ParserOptions.js +8 -0
- package/oxidized/ParserOptions.js.flow +55 -0
- package/oxidized/babel/TransformESTreeToBabel.js +1055 -0
- package/oxidized/babel/TransformESTreeToBabel.js.flow +1349 -0
- package/oxidized/estree/StripFlowTypes.js +158 -0
- package/oxidized/estree/StripFlowTypes.js.flow +158 -0
- package/oxidized/estree/StripFlowTypesForBabel.js +176 -0
- package/oxidized/estree/StripFlowTypesForBabel.js.flow +216 -0
- package/oxidized/estree/TransformComponentSyntax.js +751 -0
- package/oxidized/estree/TransformComponentSyntax.js.flow +864 -0
- package/oxidized/estree/TransformEnumSyntax.js +92 -0
- package/oxidized/estree/TransformEnumSyntax.js.flow +125 -0
- package/oxidized/estree/TransformMatchSyntax.js +990 -0
- package/oxidized/estree/TransformMatchSyntax.js.flow +991 -0
- package/oxidized/estree/TransformRecordSyntax.js +283 -0
- package/oxidized/estree/TransformRecordSyntax.js.flow +310 -0
- package/oxidized/generated/ESTreeVisitorKeys.js +234 -0
- package/oxidized/generated/ESTreeVisitorKeys.js.flow +22 -0
- package/oxidized/getModuleDocblock.js +87 -0
- package/oxidized/getModuleDocblock.js.flow +119 -0
- package/oxidized/index.js +220 -0
- package/oxidized/index.js.flow +183 -0
- package/oxidized/oxidized-src/FlowParser.js +249 -0
- package/oxidized/oxidized-src/FlowParserDeserializer.js +209 -0
- package/oxidized/oxidized-src/FlowParserNodeDeserializers.js +1767 -0
- package/oxidized/oxidized-src/HermesParserDecodeUTF8String.js +45 -0
- package/oxidized/oxidized-src/ParserOptions.js +8 -0
- package/oxidized/oxidized-src/babel/TransformESTreeToBabel.js +1055 -0
- package/oxidized/oxidized-src/estree/StripFlowTypes.js +158 -0
- package/oxidized/oxidized-src/estree/StripFlowTypesForBabel.js +176 -0
- package/oxidized/oxidized-src/estree/TransformComponentSyntax.js +751 -0
- package/oxidized/oxidized-src/estree/TransformEnumSyntax.js +92 -0
- package/oxidized/oxidized-src/estree/TransformMatchSyntax.js +990 -0
- package/oxidized/oxidized-src/estree/TransformRecordSyntax.js +283 -0
- package/oxidized/oxidized-src/generated/ESTreeVisitorKeys.js +234 -0
- package/oxidized/oxidized-src/getModuleDocblock.js +87 -0
- package/oxidized/oxidized-src/index.js +220 -0
- package/oxidized/oxidized-src/transform/SimpleTransform.js +95 -0
- package/oxidized/oxidized-src/transform/astArrayMutationHelpers.js +52 -0
- package/oxidized/oxidized-src/transform/astNodeMutationHelpers.js +142 -0
- package/oxidized/oxidized-src/transform/print/comments/comments.js +245 -0
- package/oxidized/oxidized-src/transform/print/comments/prettier/common/util.js +235 -0
- package/oxidized/oxidized-src/transform/print/comments/prettier/language-js/comments.js +663 -0
- package/oxidized/oxidized-src/transform/print/comments/prettier/language-js/loc.js +30 -0
- package/oxidized/oxidized-src/transform/print/comments/prettier/language-js/printer-estree.js +23 -0
- package/oxidized/oxidized-src/transform/print/comments/prettier/language-js/utils.js +89 -0
- package/oxidized/oxidized-src/transform/print/comments/prettier/main/comments.js +374 -0
- package/oxidized/oxidized-src/transform/print/comments/prettier/utils/get-last.js +5 -0
- package/oxidized/oxidized-src/transform/print/detachedNodeTypes.js +1 -0
- package/oxidized/oxidized-src/transform/print/print.js +68 -0
- package/oxidized/oxidized-src/traverse/SimpleTraverser.js +90 -0
- package/oxidized/oxidized-src/traverse/getVisitorKeys.js +29 -0
- package/oxidized/oxidized-src/utils/Builders.js +181 -0
- package/oxidized/oxidized-src/utils/GenID.js +37 -0
- package/oxidized/oxidized-src/utils/createSyntaxError.js +15 -0
- package/oxidized/oxidized-src/utils/isReservedWord.js +53 -0
- package/oxidized/oxidized-src/utils/mutateESTreeASTForPrettier.js +85 -0
- package/oxidized/transform/SimpleTransform.js +95 -0
- package/oxidized/transform/SimpleTransform.js.flow +168 -0
- package/oxidized/transform/astArrayMutationHelpers.js +52 -0
- package/oxidized/transform/astArrayMutationHelpers.js.flow +71 -0
- package/oxidized/transform/astNodeMutationHelpers.js +142 -0
- package/oxidized/transform/astNodeMutationHelpers.js.flow +252 -0
- package/oxidized/transform/print/comments/comments.js +245 -0
- package/oxidized/transform/print/comments/comments.js.flow +330 -0
- package/oxidized/transform/print/comments/prettier/common/util.js +235 -0
- package/oxidized/transform/print/comments/prettier/language-js/comments.js +663 -0
- package/oxidized/transform/print/comments/prettier/language-js/loc.js +30 -0
- package/oxidized/transform/print/comments/prettier/language-js/printer-estree.js +23 -0
- package/oxidized/transform/print/comments/prettier/language-js/utils.js +89 -0
- package/oxidized/transform/print/comments/prettier/main/comments.js +374 -0
- package/oxidized/transform/print/comments/prettier/utils/get-last.js +5 -0
- package/oxidized/transform/print/detachedNodeTypes.js +1 -0
- package/oxidized/transform/print/detachedNodeTypes.js.flow +24 -0
- package/oxidized/transform/print/print.js +68 -0
- package/oxidized/transform/print/print.js.flow +87 -0
- package/oxidized/traverse/SimpleTraverser.js +90 -0
- package/oxidized/traverse/SimpleTraverser.js.flow +133 -0
- package/oxidized/traverse/getVisitorKeys.js +29 -0
- package/oxidized/traverse/getVisitorKeys.js.flow +36 -0
- package/oxidized/utils/Builders.js +181 -0
- package/oxidized/utils/Builders.js.flow +218 -0
- package/oxidized/utils/GenID.js +37 -0
- package/oxidized/utils/GenID.js.flow +39 -0
- package/oxidized/utils/createSyntaxError.js +15 -0
- package/oxidized/utils/createSyntaxError.js.flow +24 -0
- package/oxidized/utils/isReservedWord.js +53 -0
- package/oxidized/utils/isReservedWord.js.flow +57 -0
- package/oxidized/utils/mutateESTreeASTForPrettier.js +85 -0
- package/oxidized/utils/mutateESTreeASTForPrettier.js.flow +130 -0
- package/package.json +16 -6
|
@@ -0,0 +1,234 @@
|
|
|
1
|
+
'use strict';
|
|
2
|
+
|
|
3
|
+
module.exports = {
|
|
4
|
+
AbstractMethodDefinition: ['key', 'value'],
|
|
5
|
+
AbstractPropertyDefinition: ['key', 'value', 'variance'],
|
|
6
|
+
AnyTypeAnnotation: [],
|
|
7
|
+
ArrayExpression: ['elements'],
|
|
8
|
+
ArrayPattern: ['elements', 'typeAnnotation'],
|
|
9
|
+
ArrayTypeAnnotation: ['elementType'],
|
|
10
|
+
ArrowFunctionExpression: ['params', 'body', 'typeParameters', 'returnType', 'predicate'],
|
|
11
|
+
AsConstExpression: ['expression'],
|
|
12
|
+
AsExpression: ['expression', 'typeAnnotation'],
|
|
13
|
+
AssignmentExpression: ['left', 'right'],
|
|
14
|
+
AssignmentPattern: ['left', 'right'],
|
|
15
|
+
AwaitExpression: ['argument'],
|
|
16
|
+
BigIntLiteralTypeAnnotation: [],
|
|
17
|
+
BigIntTypeAnnotation: [],
|
|
18
|
+
BinaryExpression: ['left', 'right'],
|
|
19
|
+
BlockStatement: ['body'],
|
|
20
|
+
BooleanLiteralTypeAnnotation: [],
|
|
21
|
+
BooleanTypeAnnotation: [],
|
|
22
|
+
BreakStatement: ['label'],
|
|
23
|
+
CallExpression: ['callee', 'typeArguments', 'arguments'],
|
|
24
|
+
CatchClause: ['param', 'body'],
|
|
25
|
+
ChainExpression: ['expression'],
|
|
26
|
+
ClassBody: ['body'],
|
|
27
|
+
ClassDeclaration: ['id', 'typeParameters', 'superClass', 'superTypeArguments', 'implements', 'decorators', 'body'],
|
|
28
|
+
ClassExpression: ['id', 'typeParameters', 'superClass', 'superTypeArguments', 'implements', 'decorators', 'body'],
|
|
29
|
+
ClassImplements: ['id', 'typeParameters'],
|
|
30
|
+
ComponentDeclaration: ['id', 'params', 'body', 'typeParameters', 'rendersType'],
|
|
31
|
+
ComponentParameter: ['name', 'local'],
|
|
32
|
+
ComponentTypeAnnotation: ['params', 'rest', 'typeParameters', 'rendersType'],
|
|
33
|
+
ComponentTypeParameter: ['name', 'typeAnnotation'],
|
|
34
|
+
ConditionalExpression: ['test', 'consequent', 'alternate'],
|
|
35
|
+
ConditionalTypeAnnotation: ['checkType', 'extendsType', 'trueType', 'falseType'],
|
|
36
|
+
ConstructorTypeAnnotation: ['params', 'returnType', 'rest', 'typeParameters'],
|
|
37
|
+
ContinueStatement: ['label'],
|
|
38
|
+
DebuggerStatement: [],
|
|
39
|
+
DeclareClass: ['id', 'typeParameters', 'extends', 'implements', 'mixins', 'body'],
|
|
40
|
+
DeclareClassExtendsCall: ['callee', 'argument'],
|
|
41
|
+
DeclareComponent: ['id', 'params', 'rest', 'typeParameters', 'rendersType'],
|
|
42
|
+
DeclareEnum: ['id', 'body'],
|
|
43
|
+
DeclareExportAllDeclaration: ['source'],
|
|
44
|
+
DeclareExportDeclaration: ['declaration', 'specifiers', 'source'],
|
|
45
|
+
DeclareFunction: ['id', 'predicate'],
|
|
46
|
+
DeclareHook: ['id'],
|
|
47
|
+
DeclareInterface: ['id', 'typeParameters', 'extends', 'body'],
|
|
48
|
+
DeclareMethodDefinition: ['key', 'value'],
|
|
49
|
+
DeclareModule: ['id', 'body'],
|
|
50
|
+
DeclareModuleExports: ['typeAnnotation'],
|
|
51
|
+
DeclareNamespace: ['id', 'body'],
|
|
52
|
+
DeclareOpaqueType: ['id', 'typeParameters', 'impltype', 'lowerBound', 'upperBound', 'supertype'],
|
|
53
|
+
DeclareTypeAlias: ['id', 'typeParameters', 'right'],
|
|
54
|
+
DeclareVariable: ['id'],
|
|
55
|
+
DeclaredPredicate: ['value'],
|
|
56
|
+
Decorator: ['expression'],
|
|
57
|
+
DoWhileStatement: ['body', 'test'],
|
|
58
|
+
EmptyStatement: [],
|
|
59
|
+
EmptyTypeAnnotation: [],
|
|
60
|
+
EnumBigIntBody: ['members'],
|
|
61
|
+
EnumBigIntMember: ['id', 'init'],
|
|
62
|
+
EnumBody: ['members'],
|
|
63
|
+
EnumBooleanBody: ['members'],
|
|
64
|
+
EnumBooleanMember: ['id', 'init'],
|
|
65
|
+
EnumDeclaration: ['id', 'body'],
|
|
66
|
+
EnumDefaultedMember: ['id'],
|
|
67
|
+
EnumNumberBody: ['members'],
|
|
68
|
+
EnumNumberMember: ['id', 'init'],
|
|
69
|
+
EnumStringBody: ['members'],
|
|
70
|
+
EnumStringMember: ['id', 'init'],
|
|
71
|
+
EnumSymbolBody: ['members'],
|
|
72
|
+
ExistsTypeAnnotation: [],
|
|
73
|
+
ExportAllDeclaration: ['exported', 'source'],
|
|
74
|
+
ExportAssignment: ['expression'],
|
|
75
|
+
ExportDefaultDeclaration: ['declaration'],
|
|
76
|
+
ExportNamedDeclaration: ['declaration', 'specifiers', 'source'],
|
|
77
|
+
ExportNamespaceSpecifier: ['exported'],
|
|
78
|
+
ExportSpecifier: ['exported', 'local'],
|
|
79
|
+
ExpressionStatement: ['expression'],
|
|
80
|
+
ExternalModuleReference: ['expression'],
|
|
81
|
+
ForInStatement: ['left', 'right', 'body'],
|
|
82
|
+
ForOfStatement: ['left', 'right', 'body'],
|
|
83
|
+
ForStatement: ['init', 'test', 'update', 'body'],
|
|
84
|
+
FunctionDeclaration: ['id', 'params', 'body', 'typeParameters', 'returnType', 'predicate'],
|
|
85
|
+
FunctionExpression: ['id', 'params', 'body', 'typeParameters', 'returnType', 'predicate'],
|
|
86
|
+
FunctionTypeAnnotation: ['params', 'this', 'returnType', 'rest', 'typeParameters'],
|
|
87
|
+
FunctionTypeParam: ['name', 'typeAnnotation'],
|
|
88
|
+
GenericTypeAnnotation: ['id', 'typeParameters'],
|
|
89
|
+
HookDeclaration: ['id', 'params', 'body', 'typeParameters', 'returnType'],
|
|
90
|
+
HookTypeAnnotation: ['params', 'returnType', 'rest', 'typeParameters'],
|
|
91
|
+
Identifier: ['typeAnnotation'],
|
|
92
|
+
IfStatement: ['test', 'consequent', 'alternate'],
|
|
93
|
+
ImportAttribute: ['key', 'value'],
|
|
94
|
+
ImportDeclaration: ['specifiers', 'source', 'attributes'],
|
|
95
|
+
ImportDefaultSpecifier: ['local'],
|
|
96
|
+
ImportEqualsDeclaration: ['id', 'moduleReference'],
|
|
97
|
+
ImportExpression: ['source', 'options'],
|
|
98
|
+
ImportNamespaceSpecifier: ['local'],
|
|
99
|
+
ImportSpecifier: ['imported', 'local'],
|
|
100
|
+
ImportType: ['argument'],
|
|
101
|
+
IndexedAccessType: ['objectType', 'indexType'],
|
|
102
|
+
InferTypeAnnotation: ['typeParameter'],
|
|
103
|
+
InferredPredicate: [],
|
|
104
|
+
InterfaceDeclaration: ['id', 'typeParameters', 'extends', 'body'],
|
|
105
|
+
InterfaceExtends: ['id', 'typeParameters'],
|
|
106
|
+
InterfaceTypeAnnotation: ['extends', 'body'],
|
|
107
|
+
InterpreterDirective: [],
|
|
108
|
+
IntersectionTypeAnnotation: ['types'],
|
|
109
|
+
JSXAttribute: ['name', 'value'],
|
|
110
|
+
JSXClosingElement: ['name'],
|
|
111
|
+
JSXClosingFragment: [],
|
|
112
|
+
JSXElement: ['openingElement', 'children', 'closingElement'],
|
|
113
|
+
JSXEmptyExpression: [],
|
|
114
|
+
JSXExpressionContainer: ['expression'],
|
|
115
|
+
JSXFragment: ['openingFragment', 'children', 'closingFragment'],
|
|
116
|
+
JSXIdentifier: [],
|
|
117
|
+
JSXMemberExpression: ['object', 'property'],
|
|
118
|
+
JSXNamespacedName: ['namespace', 'name'],
|
|
119
|
+
JSXOpeningElement: ['name', 'attributes', 'typeArguments'],
|
|
120
|
+
JSXOpeningFragment: [],
|
|
121
|
+
JSXSpreadAttribute: ['argument'],
|
|
122
|
+
JSXSpreadChild: ['expression'],
|
|
123
|
+
JSXText: [],
|
|
124
|
+
KeyofTypeAnnotation: ['argument'],
|
|
125
|
+
LabeledStatement: ['label', 'body'],
|
|
126
|
+
LogicalExpression: ['left', 'right'],
|
|
127
|
+
MatchArrayPattern: ['elements', 'rest'],
|
|
128
|
+
MatchAsPattern: ['pattern', 'target'],
|
|
129
|
+
MatchBindingPattern: ['id'],
|
|
130
|
+
MatchExpression: ['argument', 'cases'],
|
|
131
|
+
MatchExpressionCase: ['pattern', 'body', 'guard'],
|
|
132
|
+
MatchIdentifierPattern: ['id'],
|
|
133
|
+
MatchInstanceObjectPattern: ['properties', 'rest'],
|
|
134
|
+
MatchInstancePattern: ['targetConstructor', 'properties'],
|
|
135
|
+
MatchLiteralPattern: ['literal'],
|
|
136
|
+
MatchMemberPattern: ['base', 'property'],
|
|
137
|
+
MatchObjectPattern: ['properties', 'rest'],
|
|
138
|
+
MatchObjectPatternProperty: ['key', 'pattern'],
|
|
139
|
+
MatchOrPattern: ['patterns'],
|
|
140
|
+
MatchRestPattern: ['argument'],
|
|
141
|
+
MatchStatement: ['argument', 'cases'],
|
|
142
|
+
MatchStatementCase: ['pattern', 'body', 'guard'],
|
|
143
|
+
MatchUnaryPattern: ['argument'],
|
|
144
|
+
MatchWildcardPattern: [],
|
|
145
|
+
MemberExpression: ['object', 'property'],
|
|
146
|
+
MetaProperty: ['meta', 'property'],
|
|
147
|
+
MethodDefinition: ['key', 'value', 'decorators'],
|
|
148
|
+
MixedTypeAnnotation: [],
|
|
149
|
+
NamespaceExportDeclaration: ['id'],
|
|
150
|
+
NeverTypeAnnotation: [],
|
|
151
|
+
NewExpression: ['callee', 'typeArguments', 'arguments'],
|
|
152
|
+
NonNullExpression: ['argument'],
|
|
153
|
+
NullLiteralTypeAnnotation: [],
|
|
154
|
+
NullableTypeAnnotation: ['typeAnnotation'],
|
|
155
|
+
NumberLiteralTypeAnnotation: [],
|
|
156
|
+
NumberTypeAnnotation: [],
|
|
157
|
+
ObjectExpression: ['properties'],
|
|
158
|
+
ObjectPattern: ['properties', 'typeAnnotation'],
|
|
159
|
+
ObjectTypeAnnotation: ['properties', 'indexers', 'callProperties', 'internalSlots'],
|
|
160
|
+
ObjectTypeCallProperty: ['value'],
|
|
161
|
+
ObjectTypeIndexer: ['id', 'key', 'value', 'variance'],
|
|
162
|
+
ObjectTypeInternalSlot: ['id', 'value'],
|
|
163
|
+
ObjectTypeMappedTypeProperty: ['keyTparam', 'propType', 'sourceType', 'variance'],
|
|
164
|
+
ObjectTypePrivateField: ['key'],
|
|
165
|
+
ObjectTypeProperty: ['key', 'value', 'variance'],
|
|
166
|
+
ObjectTypeSpreadProperty: ['argument'],
|
|
167
|
+
OpaqueType: ['id', 'typeParameters', 'impltype', 'lowerBound', 'upperBound', 'supertype'],
|
|
168
|
+
OptionalIndexedAccessType: ['objectType', 'indexType'],
|
|
169
|
+
ParameterProperty: ['key', 'value', 'typeAnnotation', 'variance', 'decorators'],
|
|
170
|
+
PrivateIdentifier: [],
|
|
171
|
+
Program: ['body'],
|
|
172
|
+
Property: ['key', 'value'],
|
|
173
|
+
PropertyDefinition: ['key', 'value', 'decorators', 'variance', 'typeAnnotation'],
|
|
174
|
+
QualifiedTypeIdentifier: ['qualification', 'id'],
|
|
175
|
+
QualifiedTypeofIdentifier: ['qualification', 'id'],
|
|
176
|
+
RecordDeclaration: ['id', 'typeParameters', 'implements', 'body'],
|
|
177
|
+
RecordDeclarationBody: ['elements'],
|
|
178
|
+
RecordDeclarationImplements: ['id', 'typeArguments'],
|
|
179
|
+
RecordDeclarationProperty: ['key', 'typeAnnotation', 'defaultValue'],
|
|
180
|
+
RecordDeclarationStaticProperty: ['key', 'typeAnnotation', 'value'],
|
|
181
|
+
RecordExpression: ['recordConstructor', 'typeArguments', 'properties'],
|
|
182
|
+
RecordExpressionProperties: ['properties'],
|
|
183
|
+
RendersMaybeType: ['argument'],
|
|
184
|
+
RendersStarType: ['argument'],
|
|
185
|
+
RendersType: ['argument'],
|
|
186
|
+
RestElement: ['argument'],
|
|
187
|
+
ReturnStatement: ['argument'],
|
|
188
|
+
SatisfiesExpression: ['expression', 'typeAnnotation'],
|
|
189
|
+
SequenceExpression: ['expressions'],
|
|
190
|
+
SpreadElement: ['argument'],
|
|
191
|
+
StaticBlock: ['body'],
|
|
192
|
+
StringLiteralTypeAnnotation: [],
|
|
193
|
+
StringTypeAnnotation: [],
|
|
194
|
+
Super: [],
|
|
195
|
+
SwitchCase: ['test', 'consequent'],
|
|
196
|
+
SwitchStatement: ['discriminant', 'cases'],
|
|
197
|
+
SymbolTypeAnnotation: [],
|
|
198
|
+
TaggedTemplateExpression: ['tag', 'quasi'],
|
|
199
|
+
TemplateElement: [],
|
|
200
|
+
TemplateLiteral: ['quasis', 'expressions'],
|
|
201
|
+
TemplateLiteralTypeAnnotation: ['quasis', 'types'],
|
|
202
|
+
ThisExpression: [],
|
|
203
|
+
ThisTypeAnnotation: [],
|
|
204
|
+
ThrowStatement: ['argument'],
|
|
205
|
+
TryStatement: ['block', 'handler', 'finalizer'],
|
|
206
|
+
TupleTypeAnnotation: ['elementTypes'],
|
|
207
|
+
TupleTypeElement: ['elementType'],
|
|
208
|
+
TupleTypeLabeledElement: ['label', 'elementType', 'variance'],
|
|
209
|
+
TupleTypeSpreadElement: ['label', 'typeAnnotation'],
|
|
210
|
+
TypeAlias: ['id', 'typeParameters', 'right'],
|
|
211
|
+
TypeAnnotation: ['typeAnnotation'],
|
|
212
|
+
TypeCastExpression: ['expression', 'typeAnnotation'],
|
|
213
|
+
TypeOperator: ['typeAnnotation'],
|
|
214
|
+
TypeParameter: ['bound', 'variance', 'default'],
|
|
215
|
+
TypeParameterDeclaration: ['params'],
|
|
216
|
+
TypeParameterInstantiation: ['params'],
|
|
217
|
+
TypePredicate: ['parameterName', 'typeAnnotation'],
|
|
218
|
+
TypeofTypeAnnotation: ['argument', 'typeArguments'],
|
|
219
|
+
UnaryExpression: ['argument'],
|
|
220
|
+
UndefinedTypeAnnotation: [],
|
|
221
|
+
UnionTypeAnnotation: ['types'],
|
|
222
|
+
UnknownTypeAnnotation: [],
|
|
223
|
+
UpdateExpression: ['argument'],
|
|
224
|
+
VariableDeclaration: ['declarations'],
|
|
225
|
+
VariableDeclarator: ['id', 'init'],
|
|
226
|
+
Variance: [],
|
|
227
|
+
VoidTypeAnnotation: [],
|
|
228
|
+
WhileStatement: ['test', 'body'],
|
|
229
|
+
WithStatement: ['object', 'body'],
|
|
230
|
+
YieldExpression: ['argument'],
|
|
231
|
+
OptionalMemberExpression: ['object', 'property'],
|
|
232
|
+
OptionalCallExpression: ['callee', 'typeArguments', 'arguments'],
|
|
233
|
+
Literal: []
|
|
234
|
+
};
|
|
@@ -0,0 +1,22 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Copyright (c) Meta Platforms, Inc. and affiliates.
|
|
3
|
+
*
|
|
4
|
+
* This source code is licensed under the MIT license found in the
|
|
5
|
+
* LICENSE file in the root directory of this source tree.
|
|
6
|
+
*
|
|
7
|
+
* @flow strict
|
|
8
|
+
* @format
|
|
9
|
+
* @generated
|
|
10
|
+
*/
|
|
11
|
+
|
|
12
|
+
/*
|
|
13
|
+
* !!! GENERATED FILE !!!
|
|
14
|
+
*
|
|
15
|
+
* Any manual changes to this file will be overwritten. To regenerate run `buck run fbcode//flow/rust_port/crates/flow_parser_wasm:codegen -- --estree-visitor-keys-flow`.
|
|
16
|
+
*/
|
|
17
|
+
|
|
18
|
+
'use strict';
|
|
19
|
+
|
|
20
|
+
export type VisitorKeys = Readonly<{[string]: ReadonlyArray<string>}>;
|
|
21
|
+
|
|
22
|
+
declare module.exports: VisitorKeys;
|
|
@@ -0,0 +1,87 @@
|
|
|
1
|
+
'use strict';
|
|
2
|
+
|
|
3
|
+
Object.defineProperty(exports, "__esModule", {
|
|
4
|
+
value: true
|
|
5
|
+
});
|
|
6
|
+
exports.getModuleDocblock = getModuleDocblock;
|
|
7
|
+
exports.parseDocblockString = parseDocblockString;
|
|
8
|
+
const DIRECTIVE_REGEX = /^\s*@([a-zA-Z0-9_-]+)( +.+)?$/;
|
|
9
|
+
|
|
10
|
+
function parseDocblockString(docblock) {
|
|
11
|
+
const directiveLines = docblock.split('\n').map(line => line.trimStart().replace(/^\* ?/, '').trim()).filter(line => line.startsWith('@'));
|
|
12
|
+
const directives = Object.create(null);
|
|
13
|
+
|
|
14
|
+
for (const line of directiveLines) {
|
|
15
|
+
var _match$;
|
|
16
|
+
|
|
17
|
+
const match = DIRECTIVE_REGEX.exec(line);
|
|
18
|
+
|
|
19
|
+
if (match == null) {
|
|
20
|
+
continue;
|
|
21
|
+
}
|
|
22
|
+
|
|
23
|
+
const name = match[1];
|
|
24
|
+
const value = ((_match$ = match[2]) != null ? _match$ : '').trim();
|
|
25
|
+
|
|
26
|
+
if (directives[name]) {
|
|
27
|
+
directives[name].push(value);
|
|
28
|
+
} else {
|
|
29
|
+
directives[name] = [value];
|
|
30
|
+
}
|
|
31
|
+
}
|
|
32
|
+
|
|
33
|
+
return directives;
|
|
34
|
+
}
|
|
35
|
+
|
|
36
|
+
function getModuleDocblock(hermesProgram) {
|
|
37
|
+
const docblockNode = (() => {
|
|
38
|
+
if (hermesProgram.type !== 'Program') {
|
|
39
|
+
return null;
|
|
40
|
+
}
|
|
41
|
+
|
|
42
|
+
const program = hermesProgram;
|
|
43
|
+
|
|
44
|
+
if (program.comments.length === 0) {
|
|
45
|
+
return null;
|
|
46
|
+
}
|
|
47
|
+
|
|
48
|
+
const firstComment = (() => {
|
|
49
|
+
const first = program.comments[0];
|
|
50
|
+
|
|
51
|
+
if (first.type === 'Block') {
|
|
52
|
+
return first;
|
|
53
|
+
}
|
|
54
|
+
|
|
55
|
+
if (program.comments.length === 1) {
|
|
56
|
+
return null;
|
|
57
|
+
}
|
|
58
|
+
|
|
59
|
+
const second = program.comments[1];
|
|
60
|
+
|
|
61
|
+
if (first.type === 'Line' && first.range[0] === 0 && second.type === 'Block') {
|
|
62
|
+
return second;
|
|
63
|
+
}
|
|
64
|
+
|
|
65
|
+
return null;
|
|
66
|
+
})();
|
|
67
|
+
|
|
68
|
+
if (firstComment == null) {
|
|
69
|
+
return null;
|
|
70
|
+
}
|
|
71
|
+
|
|
72
|
+
if (program.body.length > 0 && program.body[0].range[0] < firstComment.range[0]) {
|
|
73
|
+
return null;
|
|
74
|
+
}
|
|
75
|
+
|
|
76
|
+
return firstComment;
|
|
77
|
+
})();
|
|
78
|
+
|
|
79
|
+
if (docblockNode == null) {
|
|
80
|
+
return null;
|
|
81
|
+
}
|
|
82
|
+
|
|
83
|
+
return {
|
|
84
|
+
directives: parseDocblockString(docblockNode.value),
|
|
85
|
+
comment: docblockNode
|
|
86
|
+
};
|
|
87
|
+
}
|
|
@@ -0,0 +1,119 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Copyright (c) Meta Platforms, Inc. and affiliates.
|
|
3
|
+
*
|
|
4
|
+
* This source code is licensed under the MIT license found in the
|
|
5
|
+
* LICENSE file in the root directory of this source tree.
|
|
6
|
+
*
|
|
7
|
+
* @flow strict
|
|
8
|
+
* @format
|
|
9
|
+
*/
|
|
10
|
+
|
|
11
|
+
'use strict';
|
|
12
|
+
|
|
13
|
+
import type {HermesNode} from './HermesAST';
|
|
14
|
+
import type {FlowParserProgram} from './FlowParserDeserializer';
|
|
15
|
+
import type {DocblockDirectives, Program} from 'hermes-estree';
|
|
16
|
+
|
|
17
|
+
const DIRECTIVE_REGEX = /^\s*@([a-zA-Z0-9_-]+)( +.+)?$/;
|
|
18
|
+
|
|
19
|
+
export function parseDocblockString(docblock: string): DocblockDirectives {
|
|
20
|
+
const directiveLines = docblock
|
|
21
|
+
.split('\n')
|
|
22
|
+
// remove the leading " *" from each line
|
|
23
|
+
.map(line => line.trimStart().replace(/^\* ?/, '').trim())
|
|
24
|
+
.filter(line => line.startsWith('@'));
|
|
25
|
+
|
|
26
|
+
const directives: {
|
|
27
|
+
[string]: Array<string>,
|
|
28
|
+
} =
|
|
29
|
+
// $FlowExpectedError[incompatible-type] - flow types this return as {...}
|
|
30
|
+
Object.create(null);
|
|
31
|
+
|
|
32
|
+
for (const line of directiveLines) {
|
|
33
|
+
const match = DIRECTIVE_REGEX.exec(line);
|
|
34
|
+
if (match == null) {
|
|
35
|
+
continue;
|
|
36
|
+
}
|
|
37
|
+
const name = match[1];
|
|
38
|
+
// explicitly use an empty string if there's no value
|
|
39
|
+
// this way the array length tracks how many instances of the directive there was
|
|
40
|
+
const value = (match[2] ?? '').trim();
|
|
41
|
+
if (directives[name]) {
|
|
42
|
+
directives[name].push(value);
|
|
43
|
+
} else {
|
|
44
|
+
directives[name] = [value];
|
|
45
|
+
}
|
|
46
|
+
}
|
|
47
|
+
|
|
48
|
+
return directives;
|
|
49
|
+
}
|
|
50
|
+
|
|
51
|
+
export function getModuleDocblock(
|
|
52
|
+
hermesProgram: HermesNode | FlowParserProgram,
|
|
53
|
+
): Program['docblock'] {
|
|
54
|
+
const docblockNode = (() => {
|
|
55
|
+
if (hermesProgram.type !== 'Program') {
|
|
56
|
+
return null;
|
|
57
|
+
}
|
|
58
|
+
|
|
59
|
+
// $FlowExpectedError[incompatible-type] - escape out of the unsafe hermes types
|
|
60
|
+
const program: Program = hermesProgram;
|
|
61
|
+
|
|
62
|
+
if (program.comments.length === 0) {
|
|
63
|
+
return null;
|
|
64
|
+
}
|
|
65
|
+
|
|
66
|
+
const firstComment = (() => {
|
|
67
|
+
const first = program.comments[0];
|
|
68
|
+
if (first.type === 'Block') {
|
|
69
|
+
return first;
|
|
70
|
+
}
|
|
71
|
+
|
|
72
|
+
if (program.comments.length === 1) {
|
|
73
|
+
return null;
|
|
74
|
+
}
|
|
75
|
+
|
|
76
|
+
// ESLint will always strip out the shebang comment from the code before passing it to the parser
|
|
77
|
+
// https://github.com/eslint/eslint/blob/21d647904dc30f9484b22acdd9243a6d0ecfba38/lib/linter/linter.js#L779
|
|
78
|
+
// this means that we're forced to parse it as a line comment :(
|
|
79
|
+
// this hacks around it by selecting the second comment in this case
|
|
80
|
+
const second = program.comments[1];
|
|
81
|
+
if (
|
|
82
|
+
first.type === 'Line' &&
|
|
83
|
+
first.range[0] === 0 &&
|
|
84
|
+
second.type === 'Block'
|
|
85
|
+
) {
|
|
86
|
+
return second;
|
|
87
|
+
}
|
|
88
|
+
|
|
89
|
+
return null;
|
|
90
|
+
})();
|
|
91
|
+
if (firstComment == null) {
|
|
92
|
+
return null;
|
|
93
|
+
}
|
|
94
|
+
|
|
95
|
+
/*
|
|
96
|
+
Handle cases like this where the comment isn't actually the first thing in the code:
|
|
97
|
+
```
|
|
98
|
+
const x = 1; /* docblock *./
|
|
99
|
+
```
|
|
100
|
+
*/
|
|
101
|
+
if (
|
|
102
|
+
program.body.length > 0 &&
|
|
103
|
+
program.body[0].range[0] < firstComment.range[0]
|
|
104
|
+
) {
|
|
105
|
+
return null;
|
|
106
|
+
}
|
|
107
|
+
|
|
108
|
+
return firstComment;
|
|
109
|
+
})();
|
|
110
|
+
|
|
111
|
+
if (docblockNode == null) {
|
|
112
|
+
return null;
|
|
113
|
+
}
|
|
114
|
+
|
|
115
|
+
return {
|
|
116
|
+
directives: parseDocblockString(docblockNode.value),
|
|
117
|
+
comment: docblockNode,
|
|
118
|
+
};
|
|
119
|
+
}
|
|
@@ -0,0 +1,220 @@
|
|
|
1
|
+
'use strict';
|
|
2
|
+
|
|
3
|
+
Object.defineProperty(exports, "__esModule", {
|
|
4
|
+
value: true
|
|
5
|
+
});
|
|
6
|
+
var _exportNames = {
|
|
7
|
+
parse: true,
|
|
8
|
+
mutateESTreeASTForPrettier: true,
|
|
9
|
+
Transforms: true,
|
|
10
|
+
FlowVisitorKeys: true,
|
|
11
|
+
astArrayMutationHelpers: true,
|
|
12
|
+
astNodeMutationHelpers: true
|
|
13
|
+
};
|
|
14
|
+
exports.mutateESTreeASTForPrettier = exports.astNodeMutationHelpers = exports.astArrayMutationHelpers = exports.Transforms = void 0;
|
|
15
|
+
exports.parse = parse;
|
|
16
|
+
|
|
17
|
+
var FlowParser = _interopRequireWildcard(require("./FlowParser"));
|
|
18
|
+
|
|
19
|
+
var _ESTreeVisitorKeys = _interopRequireDefault(require("./generated/ESTreeVisitorKeys"));
|
|
20
|
+
|
|
21
|
+
exports.FlowVisitorKeys = _ESTreeVisitorKeys.default;
|
|
22
|
+
|
|
23
|
+
var TransformComponentSyntax = _interopRequireWildcard(require("./estree/TransformComponentSyntax"));
|
|
24
|
+
|
|
25
|
+
var TransformEnumSyntax = _interopRequireWildcard(require("./estree/TransformEnumSyntax"));
|
|
26
|
+
|
|
27
|
+
var TransformMatchSyntax = _interopRequireWildcard(require("./estree/TransformMatchSyntax"));
|
|
28
|
+
|
|
29
|
+
var TransformRecordSyntax = _interopRequireWildcard(require("./estree/TransformRecordSyntax"));
|
|
30
|
+
|
|
31
|
+
var StripFlowTypesForBabel = _interopRequireWildcard(require("./estree/StripFlowTypesForBabel"));
|
|
32
|
+
|
|
33
|
+
var TransformESTreeToBabel = _interopRequireWildcard(require("./babel/TransformESTreeToBabel"));
|
|
34
|
+
|
|
35
|
+
var StripFlowTypes = _interopRequireWildcard(require("./estree/StripFlowTypes"));
|
|
36
|
+
|
|
37
|
+
var _ParserOptions = require("./ParserOptions");
|
|
38
|
+
|
|
39
|
+
Object.keys(_ParserOptions).forEach(function (key) {
|
|
40
|
+
if (key === "default" || key === "__esModule") return;
|
|
41
|
+
if (Object.prototype.hasOwnProperty.call(_exportNames, key)) return;
|
|
42
|
+
if (key in exports && exports[key] === _ParserOptions[key]) return;
|
|
43
|
+
exports[key] = _ParserOptions[key];
|
|
44
|
+
});
|
|
45
|
+
|
|
46
|
+
var _SimpleTraverser = require("./traverse/SimpleTraverser");
|
|
47
|
+
|
|
48
|
+
Object.keys(_SimpleTraverser).forEach(function (key) {
|
|
49
|
+
if (key === "default" || key === "__esModule") return;
|
|
50
|
+
if (Object.prototype.hasOwnProperty.call(_exportNames, key)) return;
|
|
51
|
+
if (key in exports && exports[key] === _SimpleTraverser[key]) return;
|
|
52
|
+
exports[key] = _SimpleTraverser[key];
|
|
53
|
+
});
|
|
54
|
+
|
|
55
|
+
var _SimpleTransform = require("./transform/SimpleTransform");
|
|
56
|
+
|
|
57
|
+
Object.keys(_SimpleTransform).forEach(function (key) {
|
|
58
|
+
if (key === "default" || key === "__esModule") return;
|
|
59
|
+
if (Object.prototype.hasOwnProperty.call(_exportNames, key)) return;
|
|
60
|
+
if (key in exports && exports[key] === _SimpleTransform[key]) return;
|
|
61
|
+
exports[key] = _SimpleTransform[key];
|
|
62
|
+
});
|
|
63
|
+
|
|
64
|
+
var _getVisitorKeys = require("./traverse/getVisitorKeys");
|
|
65
|
+
|
|
66
|
+
Object.keys(_getVisitorKeys).forEach(function (key) {
|
|
67
|
+
if (key === "default" || key === "__esModule") return;
|
|
68
|
+
if (Object.prototype.hasOwnProperty.call(_exportNames, key)) return;
|
|
69
|
+
if (key in exports && exports[key] === _getVisitorKeys[key]) return;
|
|
70
|
+
exports[key] = _getVisitorKeys[key];
|
|
71
|
+
});
|
|
72
|
+
|
|
73
|
+
var _astArrayMutationHelpers = _interopRequireWildcard(require("./transform/astArrayMutationHelpers"));
|
|
74
|
+
|
|
75
|
+
exports.astArrayMutationHelpers = _astArrayMutationHelpers;
|
|
76
|
+
|
|
77
|
+
var _astNodeMutationHelpers = _interopRequireWildcard(require("./transform/astNodeMutationHelpers"));
|
|
78
|
+
|
|
79
|
+
exports.astNodeMutationHelpers = _astNodeMutationHelpers;
|
|
80
|
+
|
|
81
|
+
var _mutateESTreeASTForPrettier = _interopRequireDefault(require("./utils/mutateESTreeASTForPrettier"));
|
|
82
|
+
|
|
83
|
+
exports.mutateESTreeASTForPrettier = _mutateESTreeASTForPrettier.default;
|
|
84
|
+
|
|
85
|
+
function _interopRequireDefault(obj) {
|
|
86
|
+
return obj && obj.__esModule ? obj : {
|
|
87
|
+
default: obj
|
|
88
|
+
};
|
|
89
|
+
}
|
|
90
|
+
|
|
91
|
+
function _getRequireWildcardCache(nodeInterop) {
|
|
92
|
+
if (typeof WeakMap !== "function") return null;
|
|
93
|
+
var cacheBabelInterop = new WeakMap();
|
|
94
|
+
var cacheNodeInterop = new WeakMap();
|
|
95
|
+
return (_getRequireWildcardCache = function (nodeInterop) {
|
|
96
|
+
return nodeInterop ? cacheNodeInterop : cacheBabelInterop;
|
|
97
|
+
})(nodeInterop);
|
|
98
|
+
}
|
|
99
|
+
|
|
100
|
+
function _interopRequireWildcard(obj, nodeInterop) {
|
|
101
|
+
if (!nodeInterop && obj && obj.__esModule) {
|
|
102
|
+
return obj;
|
|
103
|
+
}
|
|
104
|
+
|
|
105
|
+
if (obj === null || typeof obj !== "object" && typeof obj !== "function") {
|
|
106
|
+
return {
|
|
107
|
+
default: obj
|
|
108
|
+
};
|
|
109
|
+
}
|
|
110
|
+
|
|
111
|
+
var cache = _getRequireWildcardCache(nodeInterop);
|
|
112
|
+
|
|
113
|
+
if (cache && cache.has(obj)) {
|
|
114
|
+
return cache.get(obj);
|
|
115
|
+
}
|
|
116
|
+
|
|
117
|
+
var newObj = {};
|
|
118
|
+
var hasPropertyDescriptor = Object.defineProperty && Object.getOwnPropertyDescriptor;
|
|
119
|
+
|
|
120
|
+
for (var key in obj) {
|
|
121
|
+
if (key !== "default" && Object.prototype.hasOwnProperty.call(obj, key)) {
|
|
122
|
+
var desc = hasPropertyDescriptor ? Object.getOwnPropertyDescriptor(obj, key) : null;
|
|
123
|
+
|
|
124
|
+
if (desc && (desc.get || desc.set)) {
|
|
125
|
+
Object.defineProperty(newObj, key, desc);
|
|
126
|
+
} else {
|
|
127
|
+
newObj[key] = obj[key];
|
|
128
|
+
}
|
|
129
|
+
}
|
|
130
|
+
}
|
|
131
|
+
|
|
132
|
+
newObj.default = obj;
|
|
133
|
+
|
|
134
|
+
if (cache) {
|
|
135
|
+
cache.set(obj, newObj);
|
|
136
|
+
}
|
|
137
|
+
|
|
138
|
+
return newObj;
|
|
139
|
+
}
|
|
140
|
+
|
|
141
|
+
const DEFAULTS = {
|
|
142
|
+
flow: 'detect'
|
|
143
|
+
};
|
|
144
|
+
|
|
145
|
+
function getOptions(opts) {
|
|
146
|
+
const options = { ...DEFAULTS,
|
|
147
|
+
...(opts != null ? opts : {})
|
|
148
|
+
};
|
|
149
|
+
|
|
150
|
+
if (options.flow !== 'all' && options.flow !== 'detect') {
|
|
151
|
+
throw new Error('flow option must be "all" or "detect"');
|
|
152
|
+
}
|
|
153
|
+
|
|
154
|
+
if (options.sourceType === 'unambiguous') {
|
|
155
|
+
delete options.sourceType;
|
|
156
|
+
} else if (options.sourceType != null && options.sourceType !== 'script' && options.sourceType !== 'module') {
|
|
157
|
+
throw new Error('sourceType option must be "script", "module", or "unambiguous" if set');
|
|
158
|
+
}
|
|
159
|
+
|
|
160
|
+
if (options.enableExperimentalComponentSyntax == null) {
|
|
161
|
+
options.enableExperimentalComponentSyntax = true;
|
|
162
|
+
}
|
|
163
|
+
|
|
164
|
+
if (options.enableExperimentalFlowMatchSyntax == null) {
|
|
165
|
+
options.enableExperimentalFlowMatchSyntax = true;
|
|
166
|
+
}
|
|
167
|
+
|
|
168
|
+
if (options.enableExperimentalFlowRecordSyntax == null) {
|
|
169
|
+
options.enableExperimentalFlowRecordSyntax = true;
|
|
170
|
+
}
|
|
171
|
+
|
|
172
|
+
options.enableRecords = options.enableExperimentalFlowRecordSyntax;
|
|
173
|
+
|
|
174
|
+
if (options.enableEnums == null) {
|
|
175
|
+
options.enableEnums = true;
|
|
176
|
+
}
|
|
177
|
+
|
|
178
|
+
if (options.enableExperimentalDecorators == null) {
|
|
179
|
+
options.enableExperimentalDecorators = true;
|
|
180
|
+
}
|
|
181
|
+
|
|
182
|
+
options.tokens = options.tokens === true;
|
|
183
|
+
options.allowReturnOutsideFunction = options.allowReturnOutsideFunction === true;
|
|
184
|
+
return options;
|
|
185
|
+
}
|
|
186
|
+
|
|
187
|
+
function parse(code, opts) {
|
|
188
|
+
var _options$transformOpt, _options$transformOpt2;
|
|
189
|
+
|
|
190
|
+
const options = getOptions(opts);
|
|
191
|
+
|
|
192
|
+
if (options.flow === 'all') {
|
|
193
|
+
options.enableTypes = true;
|
|
194
|
+
} else {
|
|
195
|
+
options.enableTypesPragmaDetection = true;
|
|
196
|
+
}
|
|
197
|
+
|
|
198
|
+
const estreeAST = FlowParser.parse(code, options);
|
|
199
|
+
|
|
200
|
+
if (options.babel !== true) {
|
|
201
|
+
return estreeAST;
|
|
202
|
+
}
|
|
203
|
+
|
|
204
|
+
const loweredESTreeAST = [(_options$transformOpt = options.transformOptions) != null && (_options$transformOpt2 = _options$transformOpt.TransformEnumSyntax) != null && _options$transformOpt2.enable ? TransformEnumSyntax.transformProgram : null, TransformMatchSyntax.transformProgram, TransformComponentSyntax.transformProgram, TransformRecordSyntax.transformProgram, StripFlowTypesForBabel.transformProgram].reduce((ast, transform) => {
|
|
205
|
+
var _transform;
|
|
206
|
+
|
|
207
|
+
return (_transform = transform == null ? void 0 : transform(ast, options)) != null ? _transform : ast;
|
|
208
|
+
}, estreeAST);
|
|
209
|
+
return TransformESTreeToBabel.transformProgram(loweredESTreeAST, options);
|
|
210
|
+
}
|
|
211
|
+
|
|
212
|
+
const Transforms = {
|
|
213
|
+
transformEnumSyntax: TransformEnumSyntax.transformProgram,
|
|
214
|
+
transformMatchSyntax: TransformMatchSyntax.transformProgram,
|
|
215
|
+
transformComponentSyntax: TransformComponentSyntax.transformProgram,
|
|
216
|
+
transformRecordSyntax: TransformRecordSyntax.transformProgram,
|
|
217
|
+
stripFlowTypesForBabel: StripFlowTypesForBabel.transformProgram,
|
|
218
|
+
stripFlowTypes: StripFlowTypes.transformProgram
|
|
219
|
+
};
|
|
220
|
+
exports.Transforms = Transforms;
|