Skip to content
This repository was archived by the owner on May 12, 2025. It is now read-only.

Commit 00e461c

Browse files
Regenerate Json and Yaml LST models (#212)
* Regenerate `Json` and `Yaml` LST models * Fix `RemotingRecipeRunTest` error
1 parent 7f8b138 commit 00e461c

File tree

14 files changed

+451
-242
lines changed

14 files changed

+451
-242
lines changed

openrewrite/src/json/extensions.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
import {JsonVisitor} from "./visitor";
2-
import {JsonRightPadded, Space} from "./support_types";
2+
import {JsonRightPadded, Space} from "./tree";
33
import {Tree} from "../core";
44

55
export function visitRightPadded<P, T extends Tree>(v: JsonVisitor<P>, right: JsonRightPadded<T> | null, p: P): JsonRightPadded<T> {

openrewrite/src/json/index.ts

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,3 @@
11
export * from './markers';
2-
export * from './support_types';
32
export * from './tree';
43
export * from './visitor';

openrewrite/src/json/support_types.ts

Lines changed: 0 additions & 44 deletions
This file was deleted.
Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
export {}

openrewrite/src/json/tree/index.ts

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,2 @@
1+
export * from './support_types';
2+
export * from './tree';
Lines changed: 104 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,104 @@
1+
import {LstType, Markers, Tree, TreeVisitor, UUID} from "../../core";
2+
import {JsonVisitor} from "../visitor";
3+
4+
export interface Json extends Tree {
5+
get prefix(): Space;
6+
7+
withPrefix(prefix: Space): Json;
8+
9+
get id(): UUID;
10+
11+
withId(id: UUID): Json;
12+
13+
get markers(): Markers;
14+
15+
withMarkers(markers: Markers): Json;
16+
17+
isAcceptable<P>(v: TreeVisitor<Tree, P>, p: P): boolean;
18+
19+
accept<R extends Tree, P>(v: TreeVisitor<R, P>, p: P): R | null;
20+
21+
acceptJson<P>(v: JsonVisitor<P>, p: P): Json | null;
22+
}
23+
24+
type Constructor<T = {}> = new (...args: any[]) => T;
25+
26+
export function isJson(tree: any): tree is Json {
27+
return !!tree.constructor.isJson || !!tree.isJson;
28+
}
29+
30+
export function JsonMixin<TBase extends Constructor<Object>>(Base: TBase) {
31+
abstract class JsonMixed extends Base implements Json {
32+
static isTree = true;
33+
static isJson = true;
34+
35+
abstract get prefix(): Space;
36+
37+
abstract withPrefix(prefix: Space): Json;
38+
39+
abstract get id(): UUID;
40+
41+
abstract withId(id: UUID): Json;
42+
43+
abstract get markers(): Markers;
44+
45+
abstract withMarkers(markers: Markers): Json;
46+
47+
public isAcceptable<P>(v: TreeVisitor<Tree, P>, p: P): boolean {
48+
return v.isAdaptableTo(JsonVisitor);
49+
}
50+
51+
public accept<R extends Tree, P>(v: TreeVisitor<R, P>, p: P): R | null {
52+
return this.acceptJson(v.adapt(JsonVisitor), p) as unknown as R | null;
53+
}
54+
55+
public acceptJson<P>(v: JsonVisitor<P>, p: P): Json | null {
56+
return v.defaultValue(this, p) as Json | null;
57+
}
58+
}
59+
60+
return JsonMixed;
61+
}
62+
63+
export interface JsonKey extends Tree {
64+
}
65+
66+
export interface JsonValue extends Tree {
67+
}
68+
69+
@LstType("org.openrewrite.json.tree.Space")
70+
export class Space {
71+
}
72+
73+
@LstType("org.openrewrite.json.tree.Comment")
74+
export class Comment {
75+
}
76+
77+
@LstType("org.openrewrite.json.tree.JsonRightPadded")
78+
export class JsonRightPadded<T extends Tree> {
79+
constructor(element: T) {
80+
this._element = element;
81+
}
82+
83+
private readonly _element: T;
84+
85+
get element(): T {
86+
return this._element;
87+
}
88+
89+
static getElements<T extends Tree>(padded: JsonRightPadded<T>[]) {
90+
return [];
91+
}
92+
93+
static withElements<T extends Tree>(padded: JsonRightPadded<T>[], elements: T[]) {
94+
return [];
95+
}
96+
97+
static withElement<T extends Tree>(padded: JsonRightPadded<T>, element: T): JsonRightPadded<T> {
98+
return padded;
99+
}
100+
101+
withElement(element: T) : JsonRightPadded<T> {
102+
return undefined!;
103+
}
104+
}

0 commit comments

Comments
 (0)