From ec9a5882bca57b60d78598ce8c2e2c55ffcad4e4 Mon Sep 17 00:00:00 2001 From: OlegDokuka Date: Tue, 8 Oct 2024 22:20:38 +0300 Subject: [PATCH 1/7] add method declaration support --- openrewrite/package.json | 1 + openrewrite/src/javascript/parser.ts | 39 +++++- .../test/javascript/parser/method.test.ts | 124 ++++++++++++++++++ 3 files changed, 158 insertions(+), 6 deletions(-) create mode 100644 openrewrite/test/javascript/parser/method.test.ts diff --git a/openrewrite/package.json b/openrewrite/package.json index 3a51dacb..017f941b 100644 --- a/openrewrite/package.json +++ b/openrewrite/package.json @@ -44,6 +44,7 @@ "@types/diff": "^5.2.2", "@types/jest": "^29.5.13", "@types/uuid": "^10.0.0", + "@openrewrite/rewrite-remote" : "~0.3.0", "jest": "^29.7.0", "ts-jest": "^29.2.5", "ts-node": "^10.9.2" diff --git a/openrewrite/src/javascript/parser.ts b/openrewrite/src/javascript/parser.ts index dd055b46..35337f14 100644 --- a/openrewrite/src/javascript/parser.ts +++ b/openrewrite/src/javascript/parser.ts @@ -246,7 +246,7 @@ export class JavaScriptParserVisitor { ); } - private mapModifiers(node: ts.VariableDeclarationList | ts.VariableStatement | ts.ClassDeclaration | ts.PropertyDeclaration | ts.FunctionDeclaration | ts.ParameterDeclaration) { + private mapModifiers(node: ts.VariableDeclarationList | ts.VariableStatement | ts.ClassDeclaration | ts.PropertyDeclaration | ts.FunctionDeclaration | ts.ParameterDeclaration | ts.MethodDeclaration) { if (ts.isVariableStatement(node)) { return [new J.Modifier( randomId(), @@ -260,7 +260,7 @@ export class JavaScriptParserVisitor { return node.modifiers ? node.modifiers?.filter(ts.isModifier).map(this.mapModifier) : []; } else if (ts.isPropertyDeclaration(node)) { return []; // FIXME - } else if (ts.isFunctionDeclaration(node) || ts.isParameter(node)) { + } else if (ts.isFunctionDeclaration(node) || ts.isParameter(node) || ts.isMethodDeclaration(node)) { return node.modifiers ? node.modifiers?.filter(ts.isModifier).map(this.mapModifier) : []; } else if (ts.isVariableDeclarationList(node)) { let modifier: string | undefined; @@ -570,7 +570,15 @@ export class JavaScriptParserVisitor { } visitTypeParameter(node: ts.TypeParameterDeclaration) { - return this.visitUnknown(node); + return new J.TypeParameter( + randomId(), + this.prefix(node), + Markers.EMPTY, + [], + [], + this.visit(node.name), + null // fix me. this should support complex generics + ); } visitParameter(node: ts.ParameterDeclaration) { @@ -665,7 +673,26 @@ export class JavaScriptParserVisitor { } visitMethodDeclaration(node: ts.MethodDeclaration) { - return this.visitUnknown(node); + return new J.MethodDeclaration( + randomId(), + this.prefix(node), + Markers.EMPTY, + this.mapDecorators(node), + this.mapModifiers(node), + node.typeParameters + ? new J.TypeParameters(randomId(), this.suffix(node.name), Markers.EMPTY, [], node.typeParameters.map(tp => new JRightPadded(this.visit(tp), this.suffix(tp), Markers.EMPTY))) + : null, + node.type ? this.visit(node.type) : null, + new J.MethodDeclaration.IdentifierWithAnnotations( + node.name ? this.visit(node.name) : this.mapIdentifier(node, ""), + [] + ), + this.mapCommaSeparatedList(this.getParameterListNodes(node)), + null, + node.body ? this.convert(node.body) : null, + null, + this.mapMethodType(node) + ); } visitClassStaticBlockDeclaration(node: ts.ClassStaticBlockDeclaration) { @@ -1487,7 +1514,7 @@ export class JavaScriptParserVisitor { ); } - private getParameterListNodes(node: ts.FunctionDeclaration) { + private getParameterListNodes(node: ts.FunctionDeclaration | ts.MethodDeclaration) { const children = node.getChildren(this.sourceFile); for (let i = 0; i < children.length; i++) { if (children[i].kind == ts.SyntaxKind.OpenParenToken) { @@ -2011,7 +2038,7 @@ export class JavaScriptParserVisitor { return args; } - private mapDecorators(node: ts.ClassDeclaration | ts.FunctionDeclaration): J.Annotation[] { + private mapDecorators(node: ts.ClassDeclaration | ts.FunctionDeclaration | ts.MethodDeclaration): J.Annotation[] { return node.modifiers?.filter(ts.isDecorator)?.map(this.convert) ?? []; } diff --git a/openrewrite/test/javascript/parser/method.test.ts b/openrewrite/test/javascript/parser/method.test.ts new file mode 100644 index 00000000..375e7a3a --- /dev/null +++ b/openrewrite/test/javascript/parser/method.test.ts @@ -0,0 +1,124 @@ +import {connect, disconnect, rewriteRun, rewriteRunWithOptions, typeScript} from '../testHarness'; + +describe('function mapping', () => { + beforeAll(() => connect()); + afterAll(() => disconnect()); + + test('simple', () => { + rewriteRun( + //language=typescript + typeScript(` + class Handler { + test() { + // hello world comment + } + } + `) + ); + }); + + + test('single parameter', () => { + rewriteRun( + //language=typescript + typeScript(` + class Handler { + test(input) { + // hello world comment + } + } + `) + ); + }); + + test('single typed parameter', () => { + rewriteRun( + //language=typescript + typeScript(` + class Handler { + test(input: string) { + // hello world comment + } + } + `) + ); + }); + + test('single typed parameter with initializer', () => { + rewriteRun( + //language=typescript + typeScript(` + class Handler { + test(input /*asda*/: string = /*8asdas */ "hello world" ) { + // hello world comment + } + } + `) + ); + }); + + test('single parameter with initializer', () => { + rewriteRun( + //language=typescript + typeScript(` + class Handler { + test(input = 1) { + // hello world comment + } + } + `) + ); + }); + + test('multi parameters', () => { + rewriteRun( + //language=typescript + typeScript(` + class Handler { + test(input: string, a = 1, test: number) { + // hello world comment + } + } + `) + ); + }); + + test('parameter with trailing comma', () => { + rewriteRun( + //language=typescript + typeScript(` + class Handler { + test(input: string , ) { + // hello world comment + } + } + `) + ); + }); + + test('type parameters', () => { + rewriteRun( + //language=typescript + typeScript(` + class Handler { + test(input: T , ) { + // hello world comment + } + } + `) + ); + }); + + test('multiple type parameters', () => { + rewriteRun( + //language=typescript + typeScript(` + class Handler { + test(input: T , ) { + // hello world comment + } + } + `) + ); + }); +}); From 0aa661b637f2dc5c9572ee0ac2ea15da24acc00f Mon Sep 17 00:00:00 2001 From: Oleh Dokuka <5380167+OlegDokuka@users.noreply.github.com> Date: Thu, 10 Oct 2024 21:10:23 +0300 Subject: [PATCH 2/7] Update openrewrite/src/javascript/parser.ts Co-authored-by: Knut Wannheden --- openrewrite/src/javascript/parser.ts | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/openrewrite/src/javascript/parser.ts b/openrewrite/src/javascript/parser.ts index 35337f14..712d3af1 100644 --- a/openrewrite/src/javascript/parser.ts +++ b/openrewrite/src/javascript/parser.ts @@ -680,7 +680,7 @@ export class JavaScriptParserVisitor { this.mapDecorators(node), this.mapModifiers(node), node.typeParameters - ? new J.TypeParameters(randomId(), this.suffix(node.name), Markers.EMPTY, [], node.typeParameters.map(tp => new JRightPadded(this.visit(tp), this.suffix(tp), Markers.EMPTY))) + ? new J.TypeParameters(randomId(), this.suffix(node.name), Markers.EMPTY, [], node.typeParameters.map(tp => this.rightPadded(this.visit(tp), this.suffix(tp)))) : null, node.type ? this.visit(node.type) : null, new J.MethodDeclaration.IdentifierWithAnnotations( From a8a9e3c239216bd09533291376b42047d0a64bca Mon Sep 17 00:00:00 2001 From: OlegDokuka Date: Fri, 11 Oct 2024 11:14:09 +0300 Subject: [PATCH 3/7] extra test --- openrewrite/src/javascript/parser.ts | 2 +- openrewrite/test/javascript/parser/method.test.ts | 6 +++--- 2 files changed, 4 insertions(+), 4 deletions(-) diff --git a/openrewrite/src/javascript/parser.ts b/openrewrite/src/javascript/parser.ts index 712d3af1..fe2335da 100644 --- a/openrewrite/src/javascript/parser.ts +++ b/openrewrite/src/javascript/parser.ts @@ -577,7 +577,7 @@ export class JavaScriptParserVisitor { [], [], this.visit(node.name), - null // fix me. this should support complex generics + null ); } diff --git a/openrewrite/test/javascript/parser/method.test.ts b/openrewrite/test/javascript/parser/method.test.ts index 375e7a3a..e4b394cd 100644 --- a/openrewrite/test/javascript/parser/method.test.ts +++ b/openrewrite/test/javascript/parser/method.test.ts @@ -1,6 +1,6 @@ import {connect, disconnect, rewriteRun, rewriteRunWithOptions, typeScript} from '../testHarness'; -describe('function mapping', () => { +describe('method mapping', () => { beforeAll(() => connect()); afterAll(() => disconnect()); @@ -109,12 +109,12 @@ describe('function mapping', () => { ); }); - test('multiple type parameters', () => { + test('type parameters with bounds', () => { rewriteRun( //language=typescript typeScript(` class Handler { - test(input: T , ) { + test(input: T , ) { // hello world comment } } From a483f21a218f1be0c6b8ec586c1ad95185ec26ea Mon Sep 17 00:00:00 2001 From: OlegDokuka Date: Wed, 16 Oct 2024 11:00:19 +0300 Subject: [PATCH 4/7] add fixes Signed-off-by: OlegDokuka --- openrewrite/src/javascript/parser.ts | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/openrewrite/src/javascript/parser.ts b/openrewrite/src/javascript/parser.ts index fe2335da..66cae1b0 100644 --- a/openrewrite/src/javascript/parser.ts +++ b/openrewrite/src/javascript/parser.ts @@ -570,6 +570,10 @@ export class JavaScriptParserVisitor { } visitTypeParameter(node: ts.TypeParameterDeclaration) { + if (node.constraint || (node.modifiers && node.modifiers.length) || node.default) { + return this.visitUnknown(node); + } + return new J.TypeParameter( randomId(), this.prefix(node), From 21bc19ff1a3f040f2f7557fdc1c932c95667a88a Mon Sep 17 00:00:00 2001 From: OlegDokuka Date: Thu, 17 Oct 2024 01:21:40 +0300 Subject: [PATCH 5/7] more fixes Signed-off-by: OlegDokuka --- openrewrite/src/javascript/markers.ts | 27 +++++++++++++- openrewrite/src/javascript/parser.ts | 7 +++- .../test/javascript/parser/method.test.ts | 18 ++++++++-- .../internal/JavaScriptPrinter.java | 10 +++++- .../markers/TypeReferencePrefix.java | 35 +++++++++++++++++++ .../openrewrite/javascript/tree/JsSpace.java | 1 + 6 files changed, 93 insertions(+), 5 deletions(-) create mode 100644 rewrite-javascript/src/main/java/org/openrewrite/javascript/markers/TypeReferencePrefix.java diff --git a/openrewrite/src/javascript/markers.ts b/openrewrite/src/javascript/markers.ts index 336ce12b..4cce45bf 100644 --- a/openrewrite/src/javascript/markers.ts +++ b/openrewrite/src/javascript/markers.ts @@ -1 +1,26 @@ -export {} +import {LstType, Marker, MarkerSymbol, UUID} from "../core"; +import {Space} from "../java"; + +@LstType("org.openrewrite.javascript.markers.TypeReferencePrefix") +export class TypeReferencePrefix implements Marker { + [MarkerSymbol] = true; + private readonly _id: UUID; + private readonly _prefix: Space; + + constructor(id: UUID, prefix: Space) { + this._id = id; + this._prefix = prefix; + } + + get id() { + return this._id; + } + + withId(id: UUID): TypeReferencePrefix { + return id == this._id ? this : new TypeReferencePrefix(id, this._prefix); + } + + withPrefix(prefix: Space): TypeReferencePrefix { + return prefix == this._prefix ? this : new TypeReferencePrefix(this._id, prefix); + } +} diff --git a/openrewrite/src/javascript/parser.ts b/openrewrite/src/javascript/parser.ts index 66cae1b0..5fab7597 100644 --- a/openrewrite/src/javascript/parser.ts +++ b/openrewrite/src/javascript/parser.ts @@ -14,6 +14,7 @@ import { } from "../core"; import {binarySearch, compareTextSpans, getNextSibling, TextSpan} from "./parserUtils"; import {JavaScriptTypeMapping} from "./typeMapping"; +import {TypeReferencePrefix} from "."; export class JavaScriptParser extends Parser { @@ -677,10 +678,14 @@ export class JavaScriptParserVisitor { } visitMethodDeclaration(node: ts.MethodDeclaration) { + const markers: Markers = node.type + ? new Markers(randomId(), [new TypeReferencePrefix(randomId(), this.prefix(node.getChildren().find(t=> (t.kind === ts.SyntaxKind.ColonToken)) as ts.Node))]) + : Markers.EMPTY; + return new J.MethodDeclaration( randomId(), this.prefix(node), - Markers.EMPTY, + markers, this.mapDecorators(node), this.mapModifiers(node), node.typeParameters diff --git a/openrewrite/test/javascript/parser/method.test.ts b/openrewrite/test/javascript/parser/method.test.ts index e4b394cd..e9806f54 100644 --- a/openrewrite/test/javascript/parser/method.test.ts +++ b/openrewrite/test/javascript/parser/method.test.ts @@ -109,13 +109,27 @@ describe('method mapping', () => { ); }); - test('type parameters with bounds', () => { + // test('type parameters with bounds', () => { + // rewriteRun( + // //language=typescript + // typeScript(` + // class Handler { + // test(input: T , ) { + // // hello world comment + // } + // } + // `) + // ); + // }); + + test('return type', () => { rewriteRun( //language=typescript typeScript(` class Handler { - test(input: T , ) { + test(input: string , ) /*1*/ : /*asda*/ string { // hello world comment + return input; } } `) diff --git a/rewrite-javascript/src/main/java/org/openrewrite/javascript/internal/JavaScriptPrinter.java b/rewrite-javascript/src/main/java/org/openrewrite/javascript/internal/JavaScriptPrinter.java index 8895b8bb..5e863453 100644 --- a/rewrite-javascript/src/main/java/org/openrewrite/javascript/internal/JavaScriptPrinter.java +++ b/rewrite-javascript/src/main/java/org/openrewrite/javascript/internal/JavaScriptPrinter.java @@ -38,7 +38,7 @@ public class JavaScriptPrinter

extends JavaScriptVisitor JAVA_SCRIPT_MARKER_WRAPPER = out -> "/*~~" + out + (out.isEmpty() ? "" : "~~") + ">*/"; - private final JavaScriptJavaPrinter delegate = new JavaScriptJavaPrinter(); + private final JavaScriptJavaPrinter delegate = new JavaScriptJavaPrinter(this); @Override public J visit(@Nullable Tree tree, PrintOutputCapture

p) { @@ -425,6 +425,11 @@ public J visitYield(JS.Yield yield, PrintOutputCapture

p) { } private class JavaScriptJavaPrinter extends JavaPrinter

{ + JavaScriptPrinter

javaScriptPrinter; + + JavaScriptJavaPrinter(JavaScriptPrinter

jsp) { + javaScriptPrinter = jsp; + } @Override public J visit(@Nullable Tree tree, PrintOutputCapture

p) { @@ -591,6 +596,9 @@ public J visitMethodDeclaration(J.MethodDeclaration method, PrintOutputCapture

+ javaScriptPrinter.visitSpace(typeReferencePrefix.getPrefix(), JsSpace.Location.TYPE_REFERENCE_PREFIX, p)); + p.append(":"); visit(method.getReturnTypeExpression(), p); } diff --git a/rewrite-javascript/src/main/java/org/openrewrite/javascript/markers/TypeReferencePrefix.java b/rewrite-javascript/src/main/java/org/openrewrite/javascript/markers/TypeReferencePrefix.java new file mode 100644 index 00000000..3be81e84 --- /dev/null +++ b/rewrite-javascript/src/main/java/org/openrewrite/javascript/markers/TypeReferencePrefix.java @@ -0,0 +1,35 @@ +/* + * Copyright 2022 the original author or authors. + *

+ * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + *

+ * https://www.apache.org/licenses/LICENSE-2.0 + *

+ * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ +package org.openrewrite.javascript.markers; + +import lombok.Value; +import lombok.With; +import org.openrewrite.java.tree.Space; +import org.openrewrite.marker.Marker; + +import java.util.UUID; + +@Value +@With +public class TypeReferencePrefix implements Marker { + UUID id; + Space prefix; + + public TypeReferencePrefix(UUID id, Space prefix) { + this.id = id; + this.prefix = prefix; + } +} diff --git a/rewrite-javascript/src/main/java/org/openrewrite/javascript/tree/JsSpace.java b/rewrite-javascript/src/main/java/org/openrewrite/javascript/tree/JsSpace.java index 17143779..abb77e5b 100644 --- a/rewrite-javascript/src/main/java/org/openrewrite/javascript/tree/JsSpace.java +++ b/rewrite-javascript/src/main/java/org/openrewrite/javascript/tree/JsSpace.java @@ -71,5 +71,6 @@ public enum Location { VARIABLE_DECLARATION_PREFIX, VOID_PREFIX, YIELD_PREFIX, + TYPE_REFERENCE_PREFIX, } } From ca71be3857dcfa93971a4af0a54220b5345f362f Mon Sep 17 00:00:00 2001 From: OlegDokuka Date: Mon, 21 Oct 2024 14:27:06 +0300 Subject: [PATCH 6/7] keep spaces before `:` for type definition in a dedicated node Signed-off-by: OlegDokuka --- openrewrite/src/java/remote/receiver.ts | 4 +- openrewrite/src/java/remote/sender.ts | 4 +- openrewrite/src/javascript/markers.ts | 27 +------- openrewrite/src/javascript/parser.ts | 9 +-- openrewrite/src/javascript/remote/receiver.ts | 19 +++++- openrewrite/src/javascript/remote/sender.ts | 10 ++- .../src/javascript/tree/support_types.ts | 1 + openrewrite/src/javascript/tree/tree.ts | 64 +++++++++++++++++++ openrewrite/src/javascript/visitor.ts | 15 ++++- .../test/javascript/parser/method.test.ts | 24 +++---- .../javascript/remote/JavaScriptReceiver.java | 18 ++++++ .../javascript/remote/JavaScriptSender.java | 9 +++ .../javascript/JavaScriptVisitor.java | 14 ++++ .../internal/JavaScriptPrinter.java | 23 ++++--- .../markers/TypeReferencePrefix.java | 35 ---------- .../org/openrewrite/javascript/tree/JS.java | 38 +++++++++++ .../openrewrite/javascript/tree/JsSpace.java | 1 + 17 files changed, 219 insertions(+), 96 deletions(-) delete mode 100644 rewrite-javascript/src/main/java/org/openrewrite/javascript/markers/TypeReferencePrefix.java diff --git a/openrewrite/src/java/remote/receiver.ts b/openrewrite/src/java/remote/receiver.ts index db0d17d9..132b5019 100644 --- a/openrewrite/src/java/remote/receiver.ts +++ b/openrewrite/src/java/remote/receiver.ts @@ -1,9 +1,9 @@ import * as extensions from "./remote_extensions"; import {Checksum, Cursor, FileAttributes, ListUtils, Tree} from '../../core'; import {DetailsReceiver, Receiver, ReceiverContext, ReceiverFactory, ValueType} from '@openrewrite/rewrite-remote'; -import {JavaVisitor} from '../visitor'; +import {JavaVisitor} from '..'; import {J, Comment, Expression, JavaSourceFile, JavaType, JContainer, JLeftPadded, JRightPadded, Loop, MethodCall, NameTree, Space, Statement, TextComment, TypedTree, TypeTree, AnnotatedType, Annotation, ArrayAccess, ArrayType, Assert, Assignment, AssignmentOperation, Binary, Block, Break, Case, ClassDeclaration, CompilationUnit, Continue, DoWhileLoop, Empty, EnumValue, EnumValueSet, FieldAccess, ForEachLoop, ForLoop, ParenthesizedTypeTree, Identifier, If, Import, InstanceOf, IntersectionType, Label, Lambda, Literal, MemberReference, MethodDeclaration, MethodInvocation, Modifier, MultiCatch, NewArray, ArrayDimension, NewClass, NullableType, Package, ParameterizedType, Parentheses, ControlParentheses, Primitive, Return, Switch, SwitchExpression, Synchronized, Ternary, Throw, Try, TypeCast, TypeParameter, TypeParameters, Unary, VariableDeclarations, WhileLoop, Wildcard, Yield, Unknown} from '../tree'; -import * as Java from "../tree"; +import * as Java from "../../java/tree"; export class JavaReceiver implements Receiver { public fork(ctx: ReceiverContext): ReceiverContext { diff --git a/openrewrite/src/java/remote/sender.ts b/openrewrite/src/java/remote/sender.ts index 05e2641c..a8880dbf 100644 --- a/openrewrite/src/java/remote/sender.ts +++ b/openrewrite/src/java/remote/sender.ts @@ -1,9 +1,9 @@ import * as extensions from "./remote_extensions"; import {Cursor, ListUtils, Tree} from '../../core'; import {Sender, SenderContext, ValueType} from '@openrewrite/rewrite-remote'; -import {JavaVisitor} from '../visitor'; +import {JavaVisitor} from '..'; import {J, Comment, Expression, JavaSourceFile, JavaType, JContainer, JLeftPadded, JRightPadded, Loop, MethodCall, NameTree, Space, Statement, TextComment, TypedTree, TypeTree, AnnotatedType, Annotation, ArrayAccess, ArrayType, Assert, Assignment, AssignmentOperation, Binary, Block, Break, Case, ClassDeclaration, CompilationUnit, Continue, DoWhileLoop, Empty, EnumValue, EnumValueSet, FieldAccess, ForEachLoop, ForLoop, ParenthesizedTypeTree, Identifier, If, Import, InstanceOf, IntersectionType, Label, Lambda, Literal, MemberReference, MethodDeclaration, MethodInvocation, Modifier, MultiCatch, NewArray, ArrayDimension, NewClass, NullableType, Package, ParameterizedType, Parentheses, ControlParentheses, Primitive, Return, Switch, SwitchExpression, Synchronized, Ternary, Throw, Try, TypeCast, TypeParameter, TypeParameters, Unary, VariableDeclarations, WhileLoop, Wildcard, Yield, Unknown} from '../tree'; -import * as Java from "../tree"; +import * as Java from "../../java/tree"; export class JavaSender implements Sender { public send(after: J, before: J | null, ctx: SenderContext): void { diff --git a/openrewrite/src/javascript/markers.ts b/openrewrite/src/javascript/markers.ts index 4cce45bf..336ce12b 100644 --- a/openrewrite/src/javascript/markers.ts +++ b/openrewrite/src/javascript/markers.ts @@ -1,26 +1 @@ -import {LstType, Marker, MarkerSymbol, UUID} from "../core"; -import {Space} from "../java"; - -@LstType("org.openrewrite.javascript.markers.TypeReferencePrefix") -export class TypeReferencePrefix implements Marker { - [MarkerSymbol] = true; - private readonly _id: UUID; - private readonly _prefix: Space; - - constructor(id: UUID, prefix: Space) { - this._id = id; - this._prefix = prefix; - } - - get id() { - return this._id; - } - - withId(id: UUID): TypeReferencePrefix { - return id == this._id ? this : new TypeReferencePrefix(id, this._prefix); - } - - withPrefix(prefix: Space): TypeReferencePrefix { - return prefix == this._prefix ? this : new TypeReferencePrefix(this._id, prefix); - } -} +export {} diff --git a/openrewrite/src/javascript/parser.ts b/openrewrite/src/javascript/parser.ts index 5fab7597..167ba70d 100644 --- a/openrewrite/src/javascript/parser.ts +++ b/openrewrite/src/javascript/parser.ts @@ -14,7 +14,6 @@ import { } from "../core"; import {binarySearch, compareTextSpans, getNextSibling, TextSpan} from "./parserUtils"; import {JavaScriptTypeMapping} from "./typeMapping"; -import {TypeReferencePrefix} from "."; export class JavaScriptParser extends Parser { @@ -678,20 +677,16 @@ export class JavaScriptParserVisitor { } visitMethodDeclaration(node: ts.MethodDeclaration) { - const markers: Markers = node.type - ? new Markers(randomId(), [new TypeReferencePrefix(randomId(), this.prefix(node.getChildren().find(t=> (t.kind === ts.SyntaxKind.ColonToken)) as ts.Node))]) - : Markers.EMPTY; - return new J.MethodDeclaration( randomId(), this.prefix(node), - markers, + Markers.EMPTY, this.mapDecorators(node), this.mapModifiers(node), node.typeParameters ? new J.TypeParameters(randomId(), this.suffix(node.name), Markers.EMPTY, [], node.typeParameters.map(tp => this.rightPadded(this.visit(tp), this.suffix(tp)))) : null, - node.type ? this.visit(node.type) : null, + node.type ? new JS.TypeInfo(randomId(), this.prefix(node.getChildAt(node.getChildren().indexOf(node.type) - 1)), Markers.EMPTY, this.visit(node.type)): null, new J.MethodDeclaration.IdentifierWithAnnotations( node.name ? this.visit(node.name) : this.mapIdentifier(node, ""), [] diff --git a/openrewrite/src/javascript/remote/receiver.ts b/openrewrite/src/javascript/remote/receiver.ts index 8497d697..f8091a23 100644 --- a/openrewrite/src/javascript/remote/receiver.ts +++ b/openrewrite/src/javascript/remote/receiver.ts @@ -2,7 +2,7 @@ import * as extensions from "./remote_extensions"; import {Checksum, Cursor, FileAttributes, ListUtils, Tree} from '../../core'; import {DetailsReceiver, Receiver, ReceiverContext, ReceiverFactory, ValueType} from '@openrewrite/rewrite-remote'; import {JavaScriptVisitor} from '..'; -import {JS, JsLeftPadded, JsRightPadded, JsContainer, JsSpace, CompilationUnit, Alias, ArrowFunction, Await, DefaultType, Delete, Export, ExpressionStatement, FunctionType, JsImport, JsBinary, ObjectBindingDeclarations, PropertyAssignment, ScopedVariableDeclarations, StatementExpression, TemplateExpression, Tuple, TypeDeclaration, TypeOf, TypeOperator, Unary, Union, Void, Yield} from '../tree'; +import {JS, JsLeftPadded, JsRightPadded, JsContainer, JsSpace, CompilationUnit, Alias, ArrowFunction, Await, DefaultType, Delete, Export, ExpressionStatement, FunctionType, JsImport, JsBinary, ObjectBindingDeclarations, PropertyAssignment, ScopedVariableDeclarations, StatementExpression, TemplateExpression, Tuple, TypeDeclaration, TypeOf, TypeOperator, Unary, Union, Void, Yield, TypeInfo} from '../tree'; import {Expression, J, JContainer, JLeftPadded, JRightPadded, NameTree, Space, Statement, TypeTree, TypedTree} from "../../java"; import * as Java from "../../java/tree"; @@ -292,6 +292,14 @@ class Visitor extends JavaScriptVisitor { return _yield; } + public visitTypeInfo(typeInfo: TypeInfo, ctx: ReceiverContext): J { + typeInfo = typeInfo.withId(ctx.receiveValue(typeInfo.id, ValueType.UUID)!); + typeInfo = typeInfo.withPrefix(ctx.receiveNode(typeInfo.prefix, receiveSpace)!); + typeInfo = typeInfo.withMarkers(ctx.receiveNode(typeInfo.markers, ctx.receiveMarkers)!); + typeInfo = typeInfo.withTypeIdentifier(ctx.receiveNode(typeInfo.typeIdentifier, ctx.receiveTree)!); + return typeInfo; + } + public visitAnnotatedType(annotatedType: Java.AnnotatedType, ctx: ReceiverContext): J { annotatedType = annotatedType.withId(ctx.receiveValue(annotatedType.id, ValueType.UUID)!); annotatedType = annotatedType.withPrefix(ctx.receiveNode(annotatedType.prefix, receiveSpace)!); @@ -1253,6 +1261,15 @@ class Factory implements ReceiverFactory { ); } + if (type === "org.openrewrite.javascript.tree.JS$TypeInfo") { + return new TypeInfo( + ctx.receiveValue(null, ValueType.UUID)!, + ctx.receiveNode(null, receiveSpace)!, + ctx.receiveNode(null, ctx.receiveMarkers)!, + ctx.receiveNode(null, ctx.receiveTree)! + ); + } + if (type === "org.openrewrite.java.tree.J$AnnotatedType") { return new Java.AnnotatedType( ctx.receiveValue(null, ValueType.UUID)!, diff --git a/openrewrite/src/javascript/remote/sender.ts b/openrewrite/src/javascript/remote/sender.ts index 055105cc..a0531501 100644 --- a/openrewrite/src/javascript/remote/sender.ts +++ b/openrewrite/src/javascript/remote/sender.ts @@ -2,7 +2,7 @@ import * as extensions from "./remote_extensions"; import {Cursor, ListUtils, Tree} from '../../core'; import {Sender, SenderContext, ValueType} from '@openrewrite/rewrite-remote'; import {JavaScriptVisitor} from '..'; -import {JS, JsLeftPadded, JsRightPadded, JsContainer, JsSpace, CompilationUnit, Alias, ArrowFunction, Await, DefaultType, Delete, Export, ExpressionStatement, FunctionType, JsImport, JsBinary, ObjectBindingDeclarations, PropertyAssignment, ScopedVariableDeclarations, StatementExpression, TemplateExpression, Tuple, TypeDeclaration, TypeOf, TypeOperator, Unary, Union, Void, Yield} from '../tree'; +import {JS, JsLeftPadded, JsRightPadded, JsContainer, JsSpace, CompilationUnit, Alias, ArrowFunction, Await, DefaultType, Delete, Export, ExpressionStatement, FunctionType, JsImport, JsBinary, ObjectBindingDeclarations, PropertyAssignment, ScopedVariableDeclarations, StatementExpression, TemplateExpression, Tuple, TypeDeclaration, TypeOf, TypeOperator, Unary, Union, Void, Yield, TypeInfo} from '../tree'; import {Expression, J, JContainer, JLeftPadded, JRightPadded, Space, Statement} from "../../java"; import * as Java from "../../java/tree"; @@ -287,6 +287,14 @@ class Visitor extends JavaScriptVisitor { return _yield; } + public visitTypeInfo(typeInfo: TypeInfo, ctx: SenderContext): J { + ctx.sendValue(typeInfo, v => v.id, ValueType.UUID); + ctx.sendNode(typeInfo, v => v.prefix, Visitor.sendSpace); + ctx.sendNode(typeInfo, v => v.markers, ctx.sendMarkers); + ctx.sendNode(typeInfo, v => v.typeIdentifier, ctx.sendTree); + return typeInfo; + } + public visitAnnotatedType(annotatedType: Java.AnnotatedType, ctx: SenderContext): J { ctx.sendValue(annotatedType, v => v.id, ValueType.UUID); ctx.sendNode(annotatedType, v => v.prefix, Visitor.sendSpace); diff --git a/openrewrite/src/javascript/tree/support_types.ts b/openrewrite/src/javascript/tree/support_types.ts index b2f0090d..15410180 100644 --- a/openrewrite/src/javascript/tree/support_types.ts +++ b/openrewrite/src/javascript/tree/support_types.ts @@ -212,6 +212,7 @@ export namespace JsSpace { UNION_PREFIX, VOID_PREFIX, YIELD_PREFIX, + TYPE_INFO_PREFIX, } } export namespace JsLeftPadded { diff --git a/openrewrite/src/javascript/tree/tree.ts b/openrewrite/src/javascript/tree/tree.ts index f39bd3ab..b58408d6 100644 --- a/openrewrite/src/javascript/tree/tree.ts +++ b/openrewrite/src/javascript/tree/tree.ts @@ -2345,3 +2345,67 @@ export class Yield extends JSMixin(Object) implements Expression { } } + +@LstType("org.openrewrite.javascript.tree.JS$TypeInfo") +export class TypeInfo extends JSMixin(Object) implements Expression, TypeTree { + public constructor(id: UUID, prefix: Space, markers: Markers, typeIdentifier: TypeTree) { + super(); + this._id = id; + this._prefix = prefix; + this._markers = markers; + this._typeIdentifier = typeIdentifier; + } + + private readonly _id: UUID; + + public get id(): UUID { + return this._id; + } + + public withId(id: UUID): TypeInfo { + return id === this._id ? this : new TypeInfo(id, this._prefix, this._markers, this._typeIdentifier); + } + + private readonly _prefix: Space; + + public get prefix(): Space { + return this._prefix; + } + + public withPrefix(prefix: Space): TypeInfo { + return prefix === this._prefix ? this : new TypeInfo(this._id, prefix, this._markers, this._typeIdentifier); + } + + private readonly _markers: Markers; + + public get markers(): Markers { + return this._markers; + } + + public withMarkers(markers: Markers): TypeInfo { + return markers === this._markers ? this : new TypeInfo(this._id, this._prefix, markers, this._typeIdentifier); + } + + private readonly _typeIdentifier: TypeTree; + + public get typeIdentifier(): TypeTree { + return this._typeIdentifier; + } + + public withTypeIdentifier(typeIdentifier: TypeTree): TypeInfo { + return typeIdentifier === this._typeIdentifier ? this : new TypeInfo(this._id, this._prefix, this._markers, typeIdentifier); + } + + public acceptJavaScript

(v: JavaScriptVisitor

, p: P): J | null { + return v.visitTypeInfo(this, p); + } + + public get type(): JavaType | null { + return extensions.getJavaType(this); + } + + public withType(type: JavaType): TypeInfo { + return extensions.withJavaType(this, type); + } + +} diff --git a/openrewrite/src/javascript/visitor.ts b/openrewrite/src/javascript/visitor.ts index 9d3eafae..9798e03b 100644 --- a/openrewrite/src/javascript/visitor.ts +++ b/openrewrite/src/javascript/visitor.ts @@ -1,7 +1,7 @@ import * as extensions from "./extensions"; import {ListUtils, SourceFile, Tree, TreeVisitor} from "../core"; import {JS, isJavaScript, JsLeftPadded, JsRightPadded, JsContainer, JsSpace} from "./tree"; -import {CompilationUnit, Alias, ArrowFunction, Await, DefaultType, Delete, Export, ExpressionStatement, FunctionType, JsImport, JsBinary, ObjectBindingDeclarations, PropertyAssignment, ScopedVariableDeclarations, StatementExpression, TemplateExpression, Tuple, TypeDeclaration, TypeOf, TypeOperator, Unary, Union, Void, Yield} from "./tree"; +import {CompilationUnit, Alias, ArrowFunction, Await, DefaultType, Delete, Export, ExpressionStatement, FunctionType, JsImport, JsBinary, ObjectBindingDeclarations, PropertyAssignment, ScopedVariableDeclarations, StatementExpression, TemplateExpression, Tuple, TypeDeclaration, TypeOf, TypeOperator, Unary, Union, Void, Yield, TypeInfo} from "./tree"; import {Expression, J, JContainer, JLeftPadded, JRightPadded, Space, Statement} from "../java/tree"; import {JavaVisitor} from "../java"; import * as Java from "../java/tree"; @@ -382,6 +382,19 @@ export class JavaScriptVisitor

extends JavaVisitor

{ return _yield; } + public visitTypeInfo(typeInfo: TypeInfo, p: P): J | null { + typeInfo = typeInfo.withPrefix(this.visitJsSpace(typeInfo.prefix, JsSpace.Location.TYPE_INFO_PREFIX, p)!); + let tempExpression = this.visitExpression(typeInfo, p) as Expression; + if (!(tempExpression instanceof TypeInfo)) + { + return tempExpression; + } + typeInfo = tempExpression as TypeInfo; + typeInfo = typeInfo.withMarkers(this.visitMarkers(typeInfo.markers, p)); + typeInfo = typeInfo.withTypeIdentifier(this.visitAndCast(typeInfo.typeIdentifier, p)!); + return typeInfo; + } + public visitJsLeftPadded(left: JLeftPadded | null, loc: JsLeftPadded.Location, p: P): JLeftPadded { return extensions.visitJsLeftPadded(this, left, loc, p); } diff --git a/openrewrite/test/javascript/parser/method.test.ts b/openrewrite/test/javascript/parser/method.test.ts index e9806f54..ac9debb9 100644 --- a/openrewrite/test/javascript/parser/method.test.ts +++ b/openrewrite/test/javascript/parser/method.test.ts @@ -109,18 +109,18 @@ describe('method mapping', () => { ); }); - // test('type parameters with bounds', () => { - // rewriteRun( - // //language=typescript - // typeScript(` - // class Handler { - // test(input: T , ) { - // // hello world comment - // } - // } - // `) - // ); - // }); + test.skip('type parameters with bounds', () => { + rewriteRun( + //language=typescript + typeScript(` + class Handler { + test(input: T , ) { + // hello world comment + } + } + `) + ); + }); test('return type', () => { rewriteRun( diff --git a/rewrite-javascript-remote/src/main/java/org/openrewrite/javascript/remote/JavaScriptReceiver.java b/rewrite-javascript-remote/src/main/java/org/openrewrite/javascript/remote/JavaScriptReceiver.java index c310d8af..06b63a72 100644 --- a/rewrite-javascript-remote/src/main/java/org/openrewrite/javascript/remote/JavaScriptReceiver.java +++ b/rewrite-javascript-remote/src/main/java/org/openrewrite/javascript/remote/JavaScriptReceiver.java @@ -364,6 +364,15 @@ public JS.Yield visitYield(JS.Yield yield, ReceiverContext ctx) { return yield; } + @Override + public JS.TypeInfo visitTypeInfo(JS.TypeInfo typeInfo, ReceiverContext ctx) { + typeInfo = typeInfo.withId(ctx.receiveNonNullValue(typeInfo.getId(), UUID.class)); + typeInfo = typeInfo.withPrefix(ctx.receiveNonNullNode(typeInfo.getPrefix(), JavaScriptReceiver::receiveSpace)); + typeInfo = typeInfo.withMarkers(ctx.receiveNonNullNode(typeInfo.getMarkers(), ctx::receiveMarkers)); + typeInfo = typeInfo.withTypeIdentifier(ctx.receiveNonNullNode(typeInfo.getTypeIdentifier(), ctx::receiveTree)); + return typeInfo; + } + @Override public J.AnnotatedType visitAnnotatedType(J.AnnotatedType annotatedType, ReceiverContext ctx) { annotatedType = annotatedType.withId(ctx.receiveNonNullValue(annotatedType.getId(), UUID.class)); @@ -1355,6 +1364,15 @@ public T create(Class type, ReceiverContext ctx) { ); } + if (type == JS.TypeInfo.class) { + return (T) new JS.TypeInfo( + ctx.receiveNonNullValue(null, UUID.class), + ctx.receiveNonNullNode(null, JavaScriptReceiver::receiveSpace), + ctx.receiveNonNullNode(null, ctx::receiveMarkers), + ctx.receiveNonNullNode(null, ctx::receiveTree) + ); + } + if (type == J.AnnotatedType.class) { return (T) new J.AnnotatedType( ctx.receiveNonNullValue(null, UUID.class), diff --git a/rewrite-javascript-remote/src/main/java/org/openrewrite/javascript/remote/JavaScriptSender.java b/rewrite-javascript-remote/src/main/java/org/openrewrite/javascript/remote/JavaScriptSender.java index 6e619826..2c588d30 100644 --- a/rewrite-javascript-remote/src/main/java/org/openrewrite/javascript/remote/JavaScriptSender.java +++ b/rewrite-javascript-remote/src/main/java/org/openrewrite/javascript/remote/JavaScriptSender.java @@ -347,6 +347,15 @@ public JS.Yield visitYield(JS.Yield yield, SenderContext ctx) { return yield; } + @Override + public JS.TypeInfo visitTypeInfo(JS.TypeInfo typeInfo, SenderContext ctx) { + ctx.sendValue(typeInfo, JS.TypeInfo::getId); + ctx.sendNode(typeInfo, JS.TypeInfo::getPrefix, JavaScriptSender::sendSpace); + ctx.sendNode(typeInfo, JS.TypeInfo::getMarkers, ctx::sendMarkers); + ctx.sendNode(typeInfo, JS.TypeInfo::getTypeIdentifier, ctx::sendTree); + return typeInfo; + } + @Override public J.AnnotatedType visitAnnotatedType(J.AnnotatedType annotatedType, SenderContext ctx) { ctx.sendValue(annotatedType, J.AnnotatedType::getId); diff --git a/rewrite-javascript/src/main/java/org/openrewrite/javascript/JavaScriptVisitor.java b/rewrite-javascript/src/main/java/org/openrewrite/javascript/JavaScriptVisitor.java index b4f027f2..a643060e 100644 --- a/rewrite-javascript/src/main/java/org/openrewrite/javascript/JavaScriptVisitor.java +++ b/rewrite-javascript/src/main/java/org/openrewrite/javascript/JavaScriptVisitor.java @@ -579,4 +579,18 @@ public J visitYield(JS.Yield yield, P p) { y = y.withExpression(visitAndCast(y.getExpression(), p)); return y; } + + public J visitTypeInfo(JS.TypeInfo typeInfo, P p) { + JS.TypeInfo ti = typeInfo; + ti = ti.withPrefix(visitSpace(ti.getPrefix(), JsSpace.Location.YIELD_PREFIX, p)); + ti = ti.withMarkers(visitMarkers(ti.getMarkers(), p)); + Expression temp = (Expression) visitExpression(ti, p); + if (!(temp instanceof JS.TypeInfo)) { + return temp; + } else { + ti = (JS.TypeInfo) temp; + } + ti = ti.withTypeIdentifier(visitAndCast(ti.getTypeIdentifier(), p)); + return ti; + } } diff --git a/rewrite-javascript/src/main/java/org/openrewrite/javascript/internal/JavaScriptPrinter.java b/rewrite-javascript/src/main/java/org/openrewrite/javascript/internal/JavaScriptPrinter.java index 5e863453..206cb619 100644 --- a/rewrite-javascript/src/main/java/org/openrewrite/javascript/internal/JavaScriptPrinter.java +++ b/rewrite-javascript/src/main/java/org/openrewrite/javascript/internal/JavaScriptPrinter.java @@ -38,7 +38,7 @@ public class JavaScriptPrinter

extends JavaScriptVisitor JAVA_SCRIPT_MARKER_WRAPPER = out -> "/*~~" + out + (out.isEmpty() ? "" : "~~") + ">*/"; - private final JavaScriptJavaPrinter delegate = new JavaScriptJavaPrinter(this); + private final JavaScriptJavaPrinter delegate = new JavaScriptJavaPrinter(); @Override public J visit(@Nullable Tree tree, PrintOutputCapture

p) { @@ -424,12 +424,20 @@ public J visitYield(JS.Yield yield, PrintOutputCapture

p) { return yield; } - private class JavaScriptJavaPrinter extends JavaPrinter

{ - JavaScriptPrinter

javaScriptPrinter; + @Override + public J visitTypeInfo(JS.TypeInfo typeInfo, PrintOutputCapture

p) { + beforeSyntax(typeInfo, JsSpace.Location.TYPE_INFO_PREFIX, p); - JavaScriptJavaPrinter(JavaScriptPrinter

jsp) { - javaScriptPrinter = jsp; - } + p.append(":"); + + visit(typeInfo.getTypeIdentifier(), p); + + afterSyntax(typeInfo, p); + + return typeInfo; + } + + private class JavaScriptJavaPrinter extends JavaPrinter

{ @Override public J visit(@Nullable Tree tree, PrintOutputCapture

p) { @@ -596,9 +604,6 @@ public J visitMethodDeclaration(J.MethodDeclaration method, PrintOutputCapture

- javaScriptPrinter.visitSpace(typeReferencePrefix.getPrefix(), JsSpace.Location.TYPE_REFERENCE_PREFIX, p)); - p.append(":"); visit(method.getReturnTypeExpression(), p); } diff --git a/rewrite-javascript/src/main/java/org/openrewrite/javascript/markers/TypeReferencePrefix.java b/rewrite-javascript/src/main/java/org/openrewrite/javascript/markers/TypeReferencePrefix.java deleted file mode 100644 index 3be81e84..00000000 --- a/rewrite-javascript/src/main/java/org/openrewrite/javascript/markers/TypeReferencePrefix.java +++ /dev/null @@ -1,35 +0,0 @@ -/* - * Copyright 2022 the original author or authors. - *

- * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - *

- * https://www.apache.org/licenses/LICENSE-2.0 - *

- * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ -package org.openrewrite.javascript.markers; - -import lombok.Value; -import lombok.With; -import org.openrewrite.java.tree.Space; -import org.openrewrite.marker.Marker; - -import java.util.UUID; - -@Value -@With -public class TypeReferencePrefix implements Marker { - UUID id; - Space prefix; - - public TypeReferencePrefix(UUID id, Space prefix) { - this.id = id; - this.prefix = prefix; - } -} diff --git a/rewrite-javascript/src/main/java/org/openrewrite/javascript/tree/JS.java b/rewrite-javascript/src/main/java/org/openrewrite/javascript/tree/JS.java index 4c17b4e3..86811110 100644 --- a/rewrite-javascript/src/main/java/org/openrewrite/javascript/tree/JS.java +++ b/rewrite-javascript/src/main/java/org/openrewrite/javascript/tree/JS.java @@ -2107,4 +2107,42 @@ public CoordinateBuilder.Expression getCoordinates() { return new CoordinateBuilder.Expression(this); } } + + @Getter + @FieldDefaults(makeFinal = true, level = AccessLevel.PRIVATE) + @EqualsAndHashCode(callSuper = false, onlyExplicitlyIncluded = true) + @RequiredArgsConstructor + @With + final class TypeInfo implements JS, Expression, TypeTree { + + @EqualsAndHashCode.Include + UUID id; + + Space prefix; + + Markers markers; + + TypeTree typeIdentifier; + + @Override + public

J acceptJavaScript(JavaScriptVisitor

v, P p) { + return v.visitTypeInfo(this, p); + } + + @Override + public @Nullable JavaType getType() { + return typeIdentifier.getType(); + } + + @Override + @SuppressWarnings("unchecked") + public TypeInfo withType(@Nullable JavaType type) { + return typeIdentifier.getType() == type ? this : new TypeInfo(id, prefix, markers, typeIdentifier.withType(type)); + } + + @Override + public CoordinateBuilder.Expression getCoordinates() { + return new CoordinateBuilder.Expression(this); + } + } } diff --git a/rewrite-javascript/src/main/java/org/openrewrite/javascript/tree/JsSpace.java b/rewrite-javascript/src/main/java/org/openrewrite/javascript/tree/JsSpace.java index abb77e5b..65f2586a 100644 --- a/rewrite-javascript/src/main/java/org/openrewrite/javascript/tree/JsSpace.java +++ b/rewrite-javascript/src/main/java/org/openrewrite/javascript/tree/JsSpace.java @@ -71,6 +71,7 @@ public enum Location { VARIABLE_DECLARATION_PREFIX, VOID_PREFIX, YIELD_PREFIX, + TYPE_INFO_PREFIX, TYPE_REFERENCE_PREFIX, } } From e651dea1a5b7bd5417529608f4c20cc26037a227 Mon Sep 17 00:00:00 2001 From: OlegDokuka Date: Mon, 21 Oct 2024 14:30:42 +0300 Subject: [PATCH 7/7] update package lock Signed-off-by: OlegDokuka --- openrewrite/package-lock.json | 17 ++++++++++++----- 1 file changed, 12 insertions(+), 5 deletions(-) diff --git a/openrewrite/package-lock.json b/openrewrite/package-lock.json index dddd3b62..1f757b2e 100644 --- a/openrewrite/package-lock.json +++ b/openrewrite/package-lock.json @@ -1,12 +1,12 @@ { "name": "@openrewrite/rewrite", - "version": "0.18.4", + "version": "0.18.9", "lockfileVersion": 3, "requires": true, "packages": { "": { "name": "@openrewrite/rewrite", - "version": "0.18.4", + "version": "0.18.9", "license": "Apache-2.0", "dependencies": { "@jsonjoy.com/json-pack": "^1.1.0", @@ -19,6 +19,7 @@ "uuid": "^10.0.0" }, "devDependencies": { + "@openrewrite/rewrite-remote": "~0.3.0", "@types/diff": "^5.2.2", "@types/jest": "^29.5.13", "@types/uuid": "^10.0.0", @@ -1090,12 +1091,14 @@ "version": "0.3.0", "resolved": "https://registry.npmjs.org/dry-uninstall/-/dry-uninstall-0.3.0.tgz", "integrity": "sha512-b8h94RVpETWkVV59x62NsY++79bM7Si6Dxq7a4iVxRcJU3ZJJ4vaiC7wUZwM8WDK0ySRL+i+T/1SMAzbJLejYA==", + "dev": true, "license": "MIT" }, "node_modules/@openrewrite/rewrite-remote": { - "version": "0.4.0", - "resolved": "https://registry.npmjs.org/@openrewrite/rewrite-remote/-/rewrite-remote-0.4.0.tgz", - "integrity": "sha512-cFVkQD1yRCNiVHOJKPs1xcX9W/SZk0oMJDDfSSbxy3F3q2h5ar+8E5HObYzUw6XLN+RGP1RRNzDmmlxHxMLVrQ==", + "version": "0.3.10", + "resolved": "https://registry.npmjs.org/@openrewrite/rewrite-remote/-/rewrite-remote-0.3.10.tgz", + "integrity": "sha512-i/yVLFLG2WN03wJPxxW2TWUZ3BxFI8J62G/q6I+1c0mtrRKpNJ8D0kPhwpH4fvGL3Q8OBHEROHVAoTfMXs2mkw==", + "dev": true, "license": "Apache-2.0", "dependencies": { "@jsonjoy.com/json-pack": "^1.1.0", @@ -1534,6 +1537,7 @@ "version": "1.5.0", "resolved": "https://registry.npmjs.org/bindings/-/bindings-1.5.0.tgz", "integrity": "sha512-p2q/t/mhvuOj/UeLlV6566GD/guowlr0hHxClI0W9m7MWYkL1F0hLo+0Aexs9HSPCtR1SXQ0TD3MMKrXZajbiQ==", + "dev": true, "license": "MIT", "dependencies": { "file-uri-to-path": "1.0.0" @@ -1844,6 +1848,7 @@ "version": "0.1.30", "resolved": "https://registry.npmjs.org/deasync/-/deasync-0.1.30.tgz", "integrity": "sha512-OaAjvEQuQ9tJsKG4oHO9nV1UHTwb2Qc2+fadB0VeVtD0Z9wiG1XPGLJ4W3aLhAoQSYTaLROFRbd5X20Dkzf7MQ==", + "dev": true, "hasInstallScript": true, "license": "MIT", "dependencies": { @@ -2083,6 +2088,7 @@ "version": "1.0.0", "resolved": "https://registry.npmjs.org/file-uri-to-path/-/file-uri-to-path-1.0.0.tgz", "integrity": "sha512-0Zt+s3L7Vf1biwWZ29aARiVYLx7iMGnEUl9x33fbB/j3jR81u/O2LbqK+Bm1CDSNDKVtJ/YjwY7TUd5SkeLQLw==", + "dev": true, "license": "MIT" }, "node_modules/filelist": { @@ -3348,6 +3354,7 @@ "version": "1.7.2", "resolved": "https://registry.npmjs.org/node-addon-api/-/node-addon-api-1.7.2.tgz", "integrity": "sha512-ibPK3iA+vaY1eEjESkQkM0BbCqFOaZMiXRTtdB0u7b4djtY6JnsjvPdUHVMg6xQt3B8fpTTWHI9A+ADjM9frzg==", + "dev": true, "license": "MIT" }, "node_modules/node-int64": {