@openrewrite/rewrite 8.53.0 → 8.53.1
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/src/java/visitor.d.ts.map +1 -1
- package/dist/src/java/visitor.js +10 -0
- package/dist/src/java/visitor.js.map +1 -1
- package/dist/src/javascript/assertions.d.ts +2 -0
- package/dist/src/javascript/assertions.d.ts.map +1 -1
- package/dist/src/javascript/assertions.js +20 -0
- package/dist/src/javascript/assertions.js.map +1 -1
- package/dist/src/javascript/format.d.ts +62 -44
- package/dist/src/javascript/format.d.ts.map +1 -1
- package/dist/src/javascript/format.js +244 -12
- package/dist/src/javascript/format.js.map +1 -1
- package/dist/src/javascript/parser.d.ts +11 -15
- package/dist/src/javascript/parser.d.ts.map +1 -1
- package/dist/src/javascript/parser.js +136 -56
- package/dist/src/javascript/parser.js.map +1 -1
- package/dist/src/javascript/print.d.ts +7 -3
- package/dist/src/javascript/print.d.ts.map +1 -1
- package/dist/src/javascript/print.js +93 -35
- package/dist/src/javascript/print.js.map +1 -1
- package/dist/src/javascript/rpc.js +83 -0
- package/dist/src/javascript/rpc.js.map +1 -1
- package/dist/src/javascript/style.d.ts +19 -6
- package/dist/src/javascript/style.d.ts.map +1 -1
- package/dist/src/javascript/style.js +31 -4
- package/dist/src/javascript/style.js.map +1 -1
- package/dist/src/javascript/tree.d.ts +48 -4
- package/dist/src/javascript/tree.d.ts.map +1 -1
- package/dist/src/javascript/tree.js +1 -1
- package/dist/src/javascript/tree.js.map +1 -1
- package/dist/src/javascript/visitor.d.ts +6 -1
- package/dist/src/javascript/visitor.d.ts.map +1 -1
- package/dist/src/javascript/visitor.js +59 -0
- package/dist/src/javascript/visitor.js.map +1 -1
- package/dist/src/tree.d.ts +1 -0
- package/dist/src/tree.d.ts.map +1 -1
- package/dist/src/tree.js +4 -0
- package/dist/src/tree.js.map +1 -1
- package/package.json +1 -1
- package/src/java/visitor.ts +12 -0
- package/src/javascript/assertions.ts +20 -0
- package/src/javascript/format.ts +254 -71
- package/src/javascript/parser.ts +195 -76
- package/src/javascript/print.ts +90 -39
- package/src/javascript/rpc.ts +78 -1
- package/src/javascript/style.ts +47 -9
- package/src/javascript/tree.ts +75 -4
- package/src/javascript/visitor.ts +56 -1
- package/src/tree.ts +5 -0
|
@@ -18,7 +18,7 @@
|
|
|
18
18
|
import {mapAsync, SourceFile, ValidImmerRecipeReturnType} from "../";
|
|
19
19
|
import {Expression, J, JavaType, JavaVisitor, NameTree, Statement, TypedTree} from "../java";
|
|
20
20
|
import {createDraft, Draft, finishDraft} from "immer";
|
|
21
|
-
import {isJavaScript, JS} from "./tree";
|
|
21
|
+
import {isJavaScript, JS, JSX} from "./tree";
|
|
22
22
|
import ComputedPropertyName = JS.ComputedPropertyName;
|
|
23
23
|
|
|
24
24
|
export class JavaScriptVisitor<P> extends JavaVisitor<P> {
|
|
@@ -116,6 +116,45 @@ export class JavaScriptVisitor<P> extends JavaVisitor<P> {
|
|
|
116
116
|
});
|
|
117
117
|
}
|
|
118
118
|
|
|
119
|
+
protected async visitJsxTag(element: JSX.Tag, p: P): Promise<J | undefined> {
|
|
120
|
+
return this.produceJavaScript<JSX.Tag>(element, p, async draft => {
|
|
121
|
+
draft.openName = await this.visitLeftPadded(element.openName, p);
|
|
122
|
+
draft.afterName = await this.visitSpace(element.afterName, p);
|
|
123
|
+
draft.attributes = await mapAsync(element.attributes, attr => this.visitRightPadded(attr, p));
|
|
124
|
+
draft.selfClosing = element.selfClosing && await this.visitSpace(element.selfClosing, p);
|
|
125
|
+
draft.children = element.children && await mapAsync(element.children, child => this.visitRightPadded(child, p));
|
|
126
|
+
draft.closingName = element.closingName && await this.visitLeftPadded(element.closingName, p);
|
|
127
|
+
draft.afterClosingName = element.afterClosingName && await this.visitSpace(element.afterClosingName, p);
|
|
128
|
+
});
|
|
129
|
+
}
|
|
130
|
+
|
|
131
|
+
protected async visitJsxAttribute(attribute: JSX.Attribute, p: P): Promise<J | undefined> {
|
|
132
|
+
return this.produceJavaScript<JSX.Attribute>(attribute, p, async draft => {
|
|
133
|
+
draft.key = await this.visitDefined<J.Identifier | JSX.NamespacedName>(attribute.key, p);
|
|
134
|
+
draft.value = attribute.value && await this.visitLeftPadded(attribute.value, p);
|
|
135
|
+
});
|
|
136
|
+
}
|
|
137
|
+
|
|
138
|
+
protected async visitJsxSpreadAttribute(spread: JSX.SpreadAttribute, p: P): Promise<J | undefined> {
|
|
139
|
+
return this.produceJavaScript<JSX.SpreadAttribute>(spread, p, async draft => {
|
|
140
|
+
draft.dots = await this.visitSpace(spread.dots, p);
|
|
141
|
+
draft.expression = await this.visitRightPadded(spread.expression, p);
|
|
142
|
+
});
|
|
143
|
+
}
|
|
144
|
+
|
|
145
|
+
protected async visitJsxExpression(expr: JSX.EmbeddedExpression, p: P): Promise<J | undefined> {
|
|
146
|
+
return this.produceJavaScript<JSX.EmbeddedExpression>(expr, p, async draft => {
|
|
147
|
+
draft.expression = await this.visitRightPadded(expr.expression, p);
|
|
148
|
+
});
|
|
149
|
+
}
|
|
150
|
+
|
|
151
|
+
protected async visitJsxNamespacedName(ns: JSX.NamespacedName, p: P): Promise<J | undefined> {
|
|
152
|
+
return this.produceJavaScript<JSX.NamespacedName>(ns, p, async draft => {
|
|
153
|
+
draft.namespace = await this.visitDefined<J.Identifier>(ns.namespace, p);
|
|
154
|
+
draft.name = await this.visitLeftPadded(ns.name, p);
|
|
155
|
+
});
|
|
156
|
+
}
|
|
157
|
+
|
|
119
158
|
protected async visitJsCompilationUnit(compilationUnit: JS.CompilationUnit, p: P): Promise<J | undefined> {
|
|
120
159
|
return this.produceJavaScript<JS.CompilationUnit>(compilationUnit, p, async draft => {
|
|
121
160
|
draft.statements = await mapAsync(compilationUnit.statements, stmt => this.visitRightPadded(stmt, p));
|
|
@@ -232,6 +271,12 @@ export class JavaScriptVisitor<P> extends JavaVisitor<P> {
|
|
|
232
271
|
}
|
|
233
272
|
|
|
234
273
|
protected async visitImportDeclaration(jsImport: JS.Import, p: P): Promise<J | undefined> {
|
|
274
|
+
const statement = await this.visitStatement(jsImport, p);
|
|
275
|
+
if (!statement?.kind || statement.kind !== JS.Kind.Import) {
|
|
276
|
+
return statement;
|
|
277
|
+
}
|
|
278
|
+
jsImport = statement as JS.Import;
|
|
279
|
+
|
|
235
280
|
return this.produceJavaScript<JS.Import>(jsImport, p, async draft => {
|
|
236
281
|
draft.importClause = jsImport.importClause && await this.visitDefined<JS.ImportClause>(jsImport.importClause, p);
|
|
237
282
|
draft.moduleSpecifier = await this.visitLeftPadded(jsImport.moduleSpecifier, p);
|
|
@@ -872,6 +917,16 @@ export class JavaScriptVisitor<P> extends JavaVisitor<P> {
|
|
|
872
917
|
return this.visitImportTypeAttributes(tree as unknown as JS.ImportTypeAttributes, p);
|
|
873
918
|
case JS.Kind.ImportAttribute:
|
|
874
919
|
return this.visitImportAttribute(tree as unknown as JS.ImportAttribute, p);
|
|
920
|
+
case JS.Kind.JsxAttribute:
|
|
921
|
+
return this.visitJsxAttribute(tree as unknown as JSX.Attribute, p);
|
|
922
|
+
case JS.Kind.JsxSpreadAttribute:
|
|
923
|
+
return this.visitJsxSpreadAttribute(tree as unknown as JSX.SpreadAttribute, p);
|
|
924
|
+
case JS.Kind.JsxEmbeddedExpression:
|
|
925
|
+
return this.visitJsxExpression(tree as unknown as JSX.EmbeddedExpression, p);
|
|
926
|
+
case JS.Kind.JsxNamespacedName:
|
|
927
|
+
return this.visitJsxNamespacedName(tree as unknown as JSX.NamespacedName, p);
|
|
928
|
+
case JS.Kind.JsxTag:
|
|
929
|
+
return this.visitJsxTag(tree as unknown as JSX.Tag, p);
|
|
875
930
|
case JS.Kind.Binary:
|
|
876
931
|
return this.visitBinaryExtensions(tree as unknown as JS.Binary, p);
|
|
877
932
|
case JS.Kind.LiteralType:
|
package/src/tree.ts
CHANGED
|
@@ -56,6 +56,11 @@ export class Cursor {
|
|
|
56
56
|
return this._messages;
|
|
57
57
|
}
|
|
58
58
|
|
|
59
|
+
getNearestMessage<T>(key: string): any {
|
|
60
|
+
const t = this._messages == undefined ? undefined : this._messages.get(key);
|
|
61
|
+
return t == null && this.parent != null ? this.parent.getNearestMessage<T>(key) : t;
|
|
62
|
+
}
|
|
63
|
+
|
|
59
64
|
asArray(): any[] {
|
|
60
65
|
const path: any[] = [];
|
|
61
66
|
let current: Cursor | undefined = this;
|