@openrewrite/rewrite 8.69.0-20251212-132620 → 8.69.0-20251212-152027

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.
@@ -13,6 +13,7 @@ export * from "./templating/index";
13
13
  export * from "./method-matcher";
14
14
  export * from "./format";
15
15
  export * from "./autodetect";
16
+ export * from "./tree-debug";
16
17
  export * from "./add-import";
17
18
  export * from "./remove-import";
18
19
  export * from "./recipes/index";
@@ -1 +1 @@
1
- {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../src/javascript/index.ts"],"names":[],"mappings":"AAeA,cAAc,QAAQ,CAAC;AACvB,cAAc,WAAW,CAAC;AAC1B,cAAc,cAAc,CAAC;AAC7B,cAAc,UAAU,CAAC;AACzB,cAAc,SAAS,CAAC;AACxB,cAAc,WAAW,CAAC;AAC1B,cAAc,0BAA0B,CAAC;AACzC,cAAc,uBAAuB,CAAC;AACtC,cAAc,mBAAmB,CAAC;AAClC,cAAc,sBAAsB,CAAC;AACrC,cAAc,iBAAiB,CAAC;AAChC,cAAc,oBAAoB,CAAC;AACnC,cAAc,kBAAkB,CAAC;AACjC,cAAc,UAAU,CAAC;AACzB,cAAc,cAAc,CAAC;AAE7B,cAAc,cAAc,CAAC;AAC7B,cAAc,iBAAiB,CAAC;AAChC,cAAc,iBAAiB,CAAC;AAChC,cAAc,gBAAgB,CAAC;AAE/B,OAAO,SAAS,CAAC;AACjB,OAAO,OAAO,CAAC"}
1
+ {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../src/javascript/index.ts"],"names":[],"mappings":"AAeA,cAAc,QAAQ,CAAC;AACvB,cAAc,WAAW,CAAC;AAC1B,cAAc,cAAc,CAAC;AAC7B,cAAc,UAAU,CAAC;AACzB,cAAc,SAAS,CAAC;AACxB,cAAc,WAAW,CAAC;AAC1B,cAAc,0BAA0B,CAAC;AACzC,cAAc,uBAAuB,CAAC;AACtC,cAAc,mBAAmB,CAAC;AAClC,cAAc,sBAAsB,CAAC;AACrC,cAAc,iBAAiB,CAAC;AAChC,cAAc,oBAAoB,CAAC;AACnC,cAAc,kBAAkB,CAAC;AACjC,cAAc,UAAU,CAAC;AACzB,cAAc,cAAc,CAAC;AAC7B,cAAc,cAAc,CAAC;AAE7B,cAAc,cAAc,CAAC;AAC7B,cAAc,iBAAiB,CAAC;AAChC,cAAc,iBAAiB,CAAC;AAChC,cAAc,gBAAgB,CAAC;AAE/B,OAAO,SAAS,CAAC;AACjB,OAAO,OAAO,CAAC"}
@@ -44,6 +44,7 @@ __exportStar(require("./templating/index"), exports);
44
44
  __exportStar(require("./method-matcher"), exports);
45
45
  __exportStar(require("./format"), exports);
46
46
  __exportStar(require("./autodetect"), exports);
47
+ __exportStar(require("./tree-debug"), exports);
47
48
  __exportStar(require("./add-import"), exports);
48
49
  __exportStar(require("./remove-import"), exports);
49
50
  __exportStar(require("./recipes/index"), exports);
@@ -1 +1 @@
1
- {"version":3,"file":"index.js","sourceRoot":"","sources":["../../src/javascript/index.ts"],"names":[],"mappings":";;;;;;;;;;;;;;;;AAAA;;;;;;;;;;;;;;GAcG;AACH,yCAAuB;AACvB,4CAA0B;AAC1B,+CAA6B;AAC7B,2CAAyB;AACzB,0CAAwB;AACxB,4CAA0B;AAC1B,2DAAyC;AACzC,wDAAsC;AACtC,oDAAkC;AAClC,uDAAqC;AACrC,kDAAgC;AAChC,qDAAmC;AACnC,mDAAiC;AACjC,2CAAyB;AACzB,+CAA6B;AAE7B,+CAA6B;AAC7B,kDAAgC;AAChC,kDAAgC;AAChC,iDAA+B;AAE/B,mBAAiB;AACjB,iBAAe"}
1
+ {"version":3,"file":"index.js","sourceRoot":"","sources":["../../src/javascript/index.ts"],"names":[],"mappings":";;;;;;;;;;;;;;;;AAAA;;;;;;;;;;;;;;GAcG;AACH,yCAAuB;AACvB,4CAA0B;AAC1B,+CAA6B;AAC7B,2CAAyB;AACzB,0CAAwB;AACxB,4CAA0B;AAC1B,2DAAyC;AACzC,wDAAsC;AACtC,oDAAkC;AAClC,uDAAqC;AACrC,kDAAgC;AAChC,qDAAmC;AACnC,mDAAiC;AACjC,2CAAyB;AACzB,+CAA6B;AAC7B,+CAA6B;AAE7B,+CAA6B;AAC7B,kDAAgC;AAChC,kDAAgC;AAChC,iDAA+B;AAE/B,mBAAiB;AACjB,iBAAe"}
@@ -0,0 +1,140 @@
1
+ import { Cursor, Tree } from "../tree";
2
+ import { J } from "../java";
3
+ import { JavaScriptVisitor } from "./visitor";
4
+ /**
5
+ * Options for controlling LST debug output.
6
+ */
7
+ export interface LstDebugOptions {
8
+ /** Include cursor messages in output. Default: true */
9
+ includeCursorMessages?: boolean;
10
+ /** Include markers in output. Default: false */
11
+ includeMarkers?: boolean;
12
+ /** Include IDs in output. Default: false */
13
+ includeIds?: boolean;
14
+ /** Maximum depth to traverse. Default: unlimited (-1) */
15
+ maxDepth?: number;
16
+ /** Properties to always exclude (in addition to defaults). */
17
+ excludeProperties?: string[];
18
+ /** Output destination: 'console' or a file path. Default: 'console' */
19
+ output?: 'console' | string;
20
+ /** Indent string for nested output. Default: ' ' */
21
+ indent?: string;
22
+ }
23
+ /**
24
+ * Format whitespace string for readable debug output.
25
+ * Uses compact notation with subscript counts:
26
+ * - '\n' = 1 newline (implicit ₁)
27
+ * - '\n₂' = 2 newlines
28
+ * - '·₄' = 4 spaces
29
+ * - '-₂' = 2 tabs
30
+ * - '\n·₄' = newline + 4 spaces
31
+ * - '\n·₄-₂' = newline + 4 spaces + 2 tabs
32
+ */
33
+ export declare function formatWhitespace(whitespace: string | undefined): string;
34
+ /**
35
+ * Format a J.Space for debug output.
36
+ *
37
+ * Compact format:
38
+ * - Empty space: `''`
39
+ * - Whitespace only: `'\n·₄'`
40
+ * - Comment only: `//comment`
41
+ * - Comment with suffix: `//comment'\n'`
42
+ * - Multiple comments: `//c1'\n' + //c2'\n·₄'`
43
+ */
44
+ export declare function formatSpace(space: J.Space | undefined): string;
45
+ /**
46
+ * Format cursor messages for debug output.
47
+ * Returns '<no messages>' if no messages, otherwise returns '⟨key=value, ...⟩'
48
+ */
49
+ export declare function formatCursorMessages(cursor: Cursor | undefined): string;
50
+ /**
51
+ * Find which property of the parent contains the given child element.
52
+ * Returns the property name, or property name with array index if in an array.
53
+ * Returns undefined if the relationship cannot be determined.
54
+ *
55
+ * @param cursor - The cursor at the current position
56
+ * @param child - Optional: the actual child node being visited (for RightPadded/LeftPadded/Container visits where cursor.value is the parent)
57
+ */
58
+ export declare function findPropertyPath(cursor: Cursor | undefined, child?: any): string | undefined;
59
+ /**
60
+ * LST Debug Printer - prints LST nodes in a readable format.
61
+ *
62
+ * Usage from within a visitor:
63
+ * ```typescript
64
+ * class MyVisitor extends JavaScriptVisitor<P> {
65
+ * private debug = new LstDebugPrinter({ includeCursorMessages: true });
66
+ *
67
+ * async visitMethodInvocation(mi: J.MethodInvocation, p: P) {
68
+ * this.debug.print(mi, this.cursor);
69
+ * return super.visitMethodInvocation(mi, p);
70
+ * }
71
+ * }
72
+ * ```
73
+ */
74
+ export declare class LstDebugPrinter {
75
+ private readonly options;
76
+ private outputLines;
77
+ constructor(options?: LstDebugOptions);
78
+ /**
79
+ * Print a tree node with optional cursor context.
80
+ * @param tree The tree node to print
81
+ * @param cursor Optional cursor for context
82
+ * @param label Optional label to identify this debug output (shown as comment before output)
83
+ */
84
+ print(tree: Tree | J.Container<any> | J.LeftPadded<any> | J.RightPadded<any>, cursor?: Cursor, label?: string): void;
85
+ /**
86
+ * Print the cursor path from root to current position.
87
+ */
88
+ printCursorPath(cursor: Cursor): void;
89
+ private printNode;
90
+ private printJavaNode;
91
+ private printNodeProperties;
92
+ private printContainer;
93
+ private printLeftPadded;
94
+ private printRightPadded;
95
+ private printGenericObject;
96
+ private isSpace;
97
+ private isContainer;
98
+ private isLeftPadded;
99
+ private isRightPadded;
100
+ private indent;
101
+ private flush;
102
+ }
103
+ /**
104
+ * A visitor that prints the LST structure as it traverses.
105
+ * Useful for debugging the entire tree or a subtree.
106
+ *
107
+ * Usage:
108
+ * ```typescript
109
+ * const debugVisitor = new LstDebugVisitor({ maxDepth: 3 });
110
+ * await debugVisitor.visit(tree, ctx);
111
+ * ```
112
+ */
113
+ export declare class LstDebugVisitor<P> extends JavaScriptVisitor<P> {
114
+ private readonly printer;
115
+ private readonly printPreVisit;
116
+ private readonly printPostVisit;
117
+ private depth;
118
+ constructor(options?: LstDebugOptions, config?: {
119
+ printPreVisit?: boolean;
120
+ printPostVisit?: boolean;
121
+ });
122
+ protected preVisit(tree: J, _p: P): Promise<J | undefined>;
123
+ protected postVisit(tree: J, _p: P): Promise<J | undefined>;
124
+ visitContainer<T extends J>(container: J.Container<T>, p: P): Promise<J.Container<T>>;
125
+ visitLeftPadded<T extends J | J.Space | number | string | boolean>(left: J.LeftPadded<T>, p: P): Promise<J.LeftPadded<T> | undefined>;
126
+ visitRightPadded<T extends J | boolean>(right: J.RightPadded<T>, p: P): Promise<J.RightPadded<T> | undefined>;
127
+ }
128
+ /**
129
+ * Convenience function to print a tree node.
130
+ * @param tree The tree node to print
131
+ * @param cursor Optional cursor for context
132
+ * @param label Optional label to identify this debug output
133
+ * @param options Optional debug options
134
+ */
135
+ export declare function debugPrint(tree: Tree, cursor?: Cursor, label?: string, options?: LstDebugOptions): void;
136
+ /**
137
+ * Convenience function to print cursor path.
138
+ */
139
+ export declare function debugPrintCursorPath(cursor: Cursor, options?: LstDebugOptions): void;
140
+ //# sourceMappingURL=tree-debug.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"tree-debug.d.ts","sourceRoot":"","sources":["../../src/javascript/tree-debug.ts"],"names":[],"mappings":"AAgBA,OAAO,EAAC,MAAM,EAAE,IAAI,EAAC,MAAM,SAAS,CAAC;AACrC,OAAO,EAA2C,CAAC,EAAc,MAAM,SAAS,CAAC;AAEjF,OAAO,EAAC,iBAAiB,EAAC,MAAM,WAAW,CAAC;AAG5C;;GAEG;AACH,MAAM,WAAW,eAAe;IAC5B,uDAAuD;IACvD,qBAAqB,CAAC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