@openrewrite/rewrite 8.103.0 → 8.104.0
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/java/tree.d.ts +3 -0
- package/dist/java/tree.d.ts.map +1 -1
- package/dist/java/tree.js +3 -1
- package/dist/java/tree.js.map +1 -1
- package/dist/javascript/add-import.d.ts +28 -0
- package/dist/javascript/add-import.d.ts.map +1 -1
- package/dist/javascript/add-import.js +48 -25
- package/dist/javascript/add-import.js.map +1 -1
- package/dist/javascript/assertions.d.ts.map +1 -1
- package/dist/javascript/assertions.js +60 -67
- package/dist/javascript/assertions.js.map +1 -1
- package/dist/javascript/binding.d.ts +5 -2
- package/dist/javascript/binding.d.ts.map +1 -1
- package/dist/javascript/binding.js +58 -14
- package/dist/javascript/binding.js.map +1 -1
- package/dist/javascript/format/prettier-config-loader.d.ts +1 -0
- package/dist/javascript/format/prettier-config-loader.d.ts.map +1 -1
- package/dist/javascript/format/prettier-config-loader.js +23 -4
- package/dist/javascript/format/prettier-config-loader.js.map +1 -1
- package/dist/javascript/member-spellings.d.ts +88 -0
- package/dist/javascript/member-spellings.d.ts.map +1 -0
- package/dist/javascript/member-spellings.js +357 -0
- package/dist/javascript/member-spellings.js.map +1 -0
- package/dist/javascript/package-manager.d.ts +3 -0
- package/dist/javascript/package-manager.d.ts.map +1 -1
- package/dist/javascript/package-manager.js +49 -0
- package/dist/javascript/package-manager.js.map +1 -1
- package/dist/javascript/project-parser.d.ts.map +1 -1
- package/dist/javascript/project-parser.js +70 -109
- package/dist/javascript/project-parser.js.map +1 -1
- package/dist/javascript/scope.d.ts +2 -0
- package/dist/javascript/scope.d.ts.map +1 -1
- package/dist/javascript/scope.js +2 -1
- package/dist/javascript/scope.js.map +1 -1
- package/dist/json/index.d.ts +1 -0
- package/dist/json/index.d.ts.map +1 -1
- package/dist/json/index.js +1 -0
- package/dist/json/index.js.map +1 -1
- package/dist/json/path-matcher.d.ts +29 -0
- package/dist/json/path-matcher.d.ts.map +1 -0
- package/dist/json/path-matcher.js +974 -0
- package/dist/json/path-matcher.js.map +1 -0
- package/dist/rewrite-javascript-version.txt +1 -1
- package/dist/rpc/request/parse-project.d.ts.map +1 -1
- package/dist/rpc/request/parse-project.js +20 -23
- package/dist/rpc/request/parse-project.js.map +1 -1
- package/package.json +1 -1
- package/src/java/tree.ts +2 -0
- package/src/javascript/add-import.ts +58 -30
- package/src/javascript/assertions.ts +43 -57
- package/src/javascript/binding.ts +72 -17
- package/src/javascript/format/prettier-config-loader.ts +22 -3
- package/src/javascript/member-spellings.ts +374 -0
- package/src/javascript/package-manager.ts +51 -0
- package/src/javascript/project-parser.ts +17 -50
- package/src/javascript/scope.ts +2 -2
- package/src/json/index.ts +1 -0
- package/src/json/path-matcher.ts +1092 -0
- package/src/rpc/request/parse-project.ts +22 -32
|
@@ -339,57 +339,24 @@ export class ProjectParser {
|
|
|
339
339
|
relativeTo: this.relativeTo
|
|
340
340
|
});
|
|
341
341
|
|
|
342
|
-
|
|
343
|
-
const
|
|
344
|
-
|
|
345
|
-
|
|
346
|
-
|
|
347
|
-
|
|
348
|
-
|
|
349
|
-
|
|
350
|
-
|
|
351
|
-
|
|
352
|
-
|
|
353
|
-
|
|
354
|
-
|
|
355
|
-
yield produce(sf, draft => {
|
|
356
|
-
draft.markers = replaceMarkerByKind(draft.markers, prettierMarker);
|
|
357
|
-
});
|
|
358
|
-
} else {
|
|
359
|
-
yield sf;
|
|
360
|
-
}
|
|
361
|
-
}
|
|
362
|
-
} else {
|
|
363
|
-
// Prettier is NOT available: auto-detect styles from parsed files
|
|
364
|
-
this.log("Prettier not found, auto-detecting styles...");
|
|
365
|
-
|
|
366
|
-
// Dynamic import to break circular dependency at module load time
|
|
367
|
-
// (see buildAutodetectMarker for explanation)
|
|
368
|
-
const {Autodetect} = await import("./autodetect.js");
|
|
369
|
-
const {JS} = await import("./tree.js");
|
|
370
|
-
|
|
371
|
-
const parsedFiles: SourceFile[] = [];
|
|
372
|
-
|
|
373
|
-
// Parse all JS files and collect them for sampling
|
|
374
|
-
for await (const sf of parser.parse(...discovered.jsFiles)) {
|
|
375
|
-
current++;
|
|
376
|
-
this.onProgress?.("parsing", current, totalFiles, sf.sourcePath);
|
|
377
|
-
if (sf.kind === JS.Kind.CompilationUnit) {
|
|
378
|
-
parsedFiles.push(sf);
|
|
379
|
-
}
|
|
380
|
-
}
|
|
381
|
-
|
|
382
|
-
// Sample all parsed files and build Autodetect marker
|
|
383
|
-
const detector = Autodetect.detector();
|
|
384
|
-
for (const sf of parsedFiles) {
|
|
385
|
-
await detector.sample(sf);
|
|
342
|
+
const fallbackFiles: SourceFile[] = [];
|
|
343
|
+
for await (const sf of parser.parse(...discovered.jsFiles)) {
|
|
344
|
+
current++;
|
|
345
|
+
this.onProgress?.("parsing", current, totalFiles, sf.sourcePath);
|
|
346
|
+
const prettierMarker = await prettierLoader.getConfigMarker(
|
|
347
|
+
path.join(this.relativeTo, sf.sourcePath)
|
|
348
|
+
);
|
|
349
|
+
if (prettierMarker) {
|
|
350
|
+
yield produce(sf, draft => {
|
|
351
|
+
draft.markers = replaceMarkerByKind(draft.markers, prettierMarker);
|
|
352
|
+
});
|
|
353
|
+
} else {
|
|
354
|
+
fallbackFiles.push(sf);
|
|
386
355
|
}
|
|
387
|
-
|
|
388
|
-
|
|
389
|
-
|
|
390
|
-
|
|
391
|
-
// Yield all files with the Autodetect marker
|
|
392
|
-
for (const sf of parsedFiles) {
|
|
356
|
+
}
|
|
357
|
+
if (fallbackFiles.length > 0) {
|
|
358
|
+
const autodetectMarker = await this.buildAutodetectMarker(fallbackFiles);
|
|
359
|
+
for (const sf of fallbackFiles) {
|
|
393
360
|
yield produce(sf, draft => {
|
|
394
361
|
draft.markers = replaceMarkerByKind(draft.markers, autodetectMarker);
|
|
395
362
|
});
|
package/src/javascript/scope.ts
CHANGED
|
@@ -786,8 +786,8 @@ function enumMemberNames(body: J.Block): Bound[] {
|
|
|
786
786
|
});
|
|
787
787
|
}
|
|
788
788
|
|
|
789
|
-
/** The
|
|
790
|
-
function rootName(name: J | undefined): J | undefined {
|
|
789
|
+
/** The root of a dotted name: `A` in `A.B.C`. */
|
|
790
|
+
export function rootName(name: J | undefined): J | undefined {
|
|
791
791
|
return name?.kind === J.Kind.FieldAccess ? rootName((name as J.FieldAccess).target) : name;
|
|
792
792
|
}
|
|
793
793
|
|