@openrewrite/rewrite 8.66.0-20251027-095903 → 8.66.0-20251027-133754

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.
@@ -1152,6 +1152,7 @@ export class TabsAndIndentsVisitor<P> extends JavaScriptVisitor<P> {
1152
1152
  const ifStmt = tree as J.If;
1153
1153
  if (ifStmt.thenPart.element.kind !== J.Kind.Block) {
1154
1154
  indentShouldIncrease = true;
1155
+ this.cursor.messages.set("else-indent", this.currentIndent);
1155
1156
  }
1156
1157
  } else if (tree.kind === J.Kind.WhileLoop) {
1157
1158
  const whileLoop = tree as J.WhileLoop;
@@ -1165,7 +1166,9 @@ export class TabsAndIndentsVisitor<P> extends JavaScriptVisitor<P> {
1165
1166
  }
1166
1167
  }
1167
1168
 
1168
- if (indentShouldIncrease) {
1169
+ if (tree.kind === J.Kind.IfElse && this.cursor.getNearestMessage("else-indent") !== undefined) {
1170
+ this.cursor.messages.set("indentToUse", this.cursor.getNearestMessage("else-indent"));
1171
+ } else if (indentShouldIncrease) {
1169
1172
  this.cursor.messages.set("indentToUse", this.currentIndent + this.singleIndent);
1170
1173
  }
1171
1174
  return ret;
@@ -1179,7 +1182,12 @@ export class TabsAndIndentsVisitor<P> extends JavaScriptVisitor<P> {
1179
1182
  if (ret == undefined) {
1180
1183
  return ret;
1181
1184
  }
1182
- const relativeIndent = this.currentIndent;
1185
+
1186
+ if (tree.kind === J.Kind.IfElse && this.cursor.messages.get("else-indent") !== undefined) {
1187
+ this.cursor.messages.set("indentToUse", this.cursor.messages.get("else-indent"));
1188
+ this.cursor.messages.delete("else-indent");
1189
+ }
1190
+ const relativeIndent: string = this.currentIndent;
1183
1191
 
1184
1192
  return produce(ret, draft => {
1185
1193
  if (draft.prefix == undefined) {
@@ -23,6 +23,7 @@ export * from "./preconditions";
23
23
  export * from "./templating";
24
24
  export * from "./method-matcher";
25
25
 
26
+ export * from "./add-import";
26
27
  export * from "./remove-import";
27
28
 
28
29
  import "./print";
@@ -214,7 +214,7 @@ export class JavaScriptTypeMapping {
214
214
  let declaredFormalTypeNames: string[] = [];
215
215
 
216
216
  // Handle different kinds of nodes that represent methods or method invocations
217
- if (ts.isCallExpression(node)) {
217
+ if (ts.isCallOrNewExpression(node)) {
218
218
  // For method invocations (e.g., _.map(...))
219
219
  signature = this.checker.getResolvedSignature(node);
220
220
  if (!signature) {