@shapeshift-labs/frontier-lang-compiler 0.2.150 → 0.2.151
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/README.md +315 -9
- package/bench/real-repo-corpus-checkout-identity.mjs +134 -0
- package/bench/real-repo-corpus-checkout-proof.mjs +263 -0
- package/bench/real-repo-corpus-command-execution.mjs +314 -0
- package/bench/real-repo-corpus-evidence.mjs +165 -0
- package/bench/real-repo-corpus-suite.mjs +273 -0
- package/bench/smoke.mjs +109 -7
- package/dist/declarations/import-adapter-core.d.ts +4 -3
- package/dist/declarations/import-adapter-options-native.d.ts +21 -0
- package/dist/declarations/js-ts-project-merge-admission-routes.d.ts +35 -0
- package/dist/declarations/js-ts-project-merge-commonjs-interop.d.ts +29 -0
- package/dist/declarations/js-ts-project-merge-confidence.d.ts +64 -0
- package/dist/declarations/js-ts-project-merge-declaration-emit-parity.d.ts +37 -0
- package/dist/declarations/js-ts-project-merge-declarations.d.ts +65 -0
- package/dist/declarations/js-ts-project-merge-diagnostics.d.ts +97 -0
- package/dist/declarations/js-ts-project-merge-global-augmentation.d.ts +30 -0
- package/dist/declarations/js-ts-project-merge-jsx-render-branch.d.ts +48 -0
- package/dist/declarations/js-ts-project-merge-proof-levels.d.ts +109 -0
- package/dist/declarations/js-ts-project-merge-quality-gates.d.ts +38 -0
- package/dist/declarations/js-ts-project-merge-semantic-equivalence-proof.d.ts +45 -0
- package/dist/declarations/js-ts-project-merge-tsconfig.d.ts +43 -0
- package/dist/declarations/js-ts-safe-merge.d.ts +47 -0
- package/dist/declarations/js-ts-safe-project-merge.d.ts +120 -38
- package/dist/declarations/native-project-compiler-assignability-oracle.d.ts +41 -0
- package/dist/declarations/native-project-compiler-callable-signatures.d.ts +31 -0
- package/dist/declarations/native-project-compiler-class-member-runtime-proof.d.ts +87 -0
- package/dist/declarations/native-project-compiler-composite-types.d.ts +23 -0
- package/dist/declarations/native-project-compiler-enum-proof.d.ts +58 -0
- package/dist/declarations/native-project-compiler-index-signature.d.ts +7 -0
- package/dist/declarations/native-project-compiler-public-api-source-binding.d.ts +8 -0
- package/dist/declarations/native-project-compiler-scope.d.ts +37 -0
- package/dist/declarations/native-project-compiler-type-reference-targets.d.ts +38 -0
- package/dist/declarations/native-project-css-modules.d.ts +90 -0
- package/dist/declarations/native-project-decorator-metadata.d.ts +126 -0
- package/dist/declarations/native-project-jsx-graph.d.ts +313 -0
- package/dist/declarations/native-project-module-declarations.d.ts +52 -0
- package/dist/declarations/native-project-module-resolution.d.ts +76 -1
- package/dist/declarations/native-project-runtime-effect-target.d.ts +29 -0
- package/dist/declarations/native-project-runtime-executable-effect-evidence.d.ts +107 -0
- package/dist/declarations/native-project-runtime-mutation-target.d.ts +33 -0
- package/dist/declarations/native-project-runtime-promise-chain.d.ts +30 -0
- package/dist/declarations/native-project-runtime-promise-combinator.d.ts +22 -0
- package/dist/declarations/native-project-runtime-reachability.d.ts +30 -0
- package/dist/declarations/native-project-runtime-resource-management.d.ts +27 -0
- package/dist/declarations/native-project-runtime-yield-delegation.d.ts +10 -0
- package/dist/declarations/native-project-scope-template-reference.d.ts +13 -0
- package/dist/declarations/native-project-source-evidence.d.ts +8 -0
- package/dist/declarations/native-project.d.ts +40 -39
- package/dist/declarations/semantic-edit-script.d.ts +10 -8
- package/dist/declarations/semantic-graph-layers.d.ts +79 -0
- package/dist/declarations/semantic-sidecar.d.ts +3 -2
- package/dist/declarations/semantic-structural-diff.d.ts +94 -0
- package/dist/declarations/source-preservation.d.ts +32 -1
- package/dist/declarations/target-adapters.d.ts +22 -2
- package/dist/index.d.ts +31 -0
- package/dist/index.js +5 -0
- package/dist/internal/index-impl/compileNativeSource.js +53 -5
- package/dist/internal/index-impl/createLightweightNativeImport.js +58 -4
- package/dist/internal/index-impl/createNativeImportFromSyntaxAst.js +17 -1
- package/dist/internal/index-impl/createNativeImportFromTypeScriptAst.js +28 -4
- package/dist/internal/index-impl/createNativeProjectImportResult.js +31 -27
- package/dist/internal/index-impl/createNativeProjectModuleResolutionFromPackageManifests.js +145 -0
- package/dist/internal/index-impl/createNativeSourcePreservation.js +34 -7
- package/dist/internal/index-impl/createSemanticImportSidecar.js +27 -1
- package/dist/internal/index-impl/createTypeScriptCompilerNativeImporterAdapter.js +16 -5
- package/dist/internal/index-impl/dynamicImportExpressionMetadata.js +80 -0
- package/dist/internal/index-impl/importMetaUrlDependencyMetadata.js +176 -0
- package/dist/internal/index-impl/importNativeSource.js +2 -3
- package/dist/internal/index-impl/moduleImportAttributeMetadata.js +232 -0
- package/dist/internal/index-impl/projectSemanticEditScriptToSource.js +8 -1
- package/dist/internal/index-impl/projectSymbolGraphClassStaticBlocks.js +148 -0
- package/dist/internal/index-impl/projectSymbolGraphCompilerAdvancedTypeMetadata.js +45 -0
- package/dist/internal/index-impl/projectSymbolGraphCompilerCallableSignatureEquivalence.js +107 -0
- package/dist/internal/index-impl/projectSymbolGraphCompilerClassPrivateAccessorRuntimeProof.js +280 -0
- package/dist/internal/index-impl/projectSymbolGraphCompilerClassShapeEquivalence.js +103 -0
- package/dist/internal/index-impl/projectSymbolGraphCompilerConditionalTypeEquivalence.js +242 -0
- package/dist/internal/index-impl/projectSymbolGraphCompilerDecoratorRuntimeProof.js +197 -0
- package/dist/internal/index-impl/projectSymbolGraphCompilerEnumEquivalence.js +188 -0
- package/dist/internal/index-impl/projectSymbolGraphCompilerFacts.js +244 -0
- package/dist/internal/index-impl/projectSymbolGraphCompilerIndexSignatureEquivalence.js +58 -0
- package/dist/internal/index-impl/projectSymbolGraphCompilerMetadata.js +168 -0
- package/dist/internal/index-impl/projectSymbolGraphCompilerTypeEquivalence.js +199 -0
- package/dist/internal/index-impl/projectSymbolGraphCompilerTypeEquivalenceProof.js +204 -0
- package/dist/internal/index-impl/projectSymbolGraphCompilerTypeReferenceTargetEquivalence.js +99 -0
- package/dist/internal/index-impl/projectSymbolGraphCssModuleRecords.js +264 -0
- package/dist/internal/index-impl/projectSymbolGraphCssModuleScanners.js +242 -0
- package/dist/internal/index-impl/projectSymbolGraphCssModuleUtils.js +152 -0
- package/dist/internal/index-impl/projectSymbolGraphCssModules.js +82 -0
- package/dist/internal/index-impl/projectSymbolGraphJsxComponentImports.js +170 -0
- package/dist/internal/index-impl/projectSymbolGraphJsxComponentProviderLookup.js +167 -0
- package/dist/internal/index-impl/projectSymbolGraphJsxComponentWrappers.js +150 -0
- package/dist/internal/index-impl/projectSymbolGraphJsxContextTargets.js +71 -0
- package/dist/internal/index-impl/projectSymbolGraphJsxContextValues.js +212 -0
- package/dist/internal/index-impl/projectSymbolGraphJsxEventHandlers.js +172 -0
- package/dist/internal/index-impl/projectSymbolGraphJsxHookEffects.js +124 -0
- package/dist/internal/index-impl/projectSymbolGraphJsxHooks.js +281 -0
- package/dist/internal/index-impl/projectSymbolGraphJsxMemberComponents.js +139 -0
- package/dist/internal/index-impl/projectSymbolGraphJsxPropFlows.js +320 -0
- package/dist/internal/index-impl/projectSymbolGraphJsxPropValues.js +145 -0
- package/dist/internal/index-impl/projectSymbolGraphJsxProviderFlows.js +133 -0
- package/dist/internal/index-impl/projectSymbolGraphJsxRecords.js +315 -0
- package/dist/internal/index-impl/projectSymbolGraphJsxRenderCollections.js +155 -0
- package/dist/internal/index-impl/projectSymbolGraphJsxRenderReturns.js +291 -0
- package/dist/internal/index-impl/projectSymbolGraphJsxRenderRisk.js +279 -0
- package/dist/internal/index-impl/projectSymbolGraphModuleDeclarationShapes.js +138 -0
- package/dist/internal/index-impl/projectSymbolGraphModuleResolution.js +89 -87
- package/dist/internal/index-impl/projectSymbolGraphPackageConditions.js +314 -0
- package/dist/internal/index-impl/projectSymbolGraphReExportImportTargets.js +43 -0
- package/dist/internal/index-impl/projectSymbolGraphReExports.js +55 -1
- package/dist/internal/index-impl/projectSymbolGraphRuntimeRegions.js +108 -0
- package/dist/internal/index-impl/projectSymbolGraphScopeUseDefAliases.js +307 -0
- package/dist/internal/index-impl/projectSymbolGraphScopeUseDefLexical.js +320 -0
- package/dist/internal/index-impl/projectSymbolGraphScopeUseDefOwners.js +50 -0
- package/dist/internal/index-impl/projectSymbolGraphScopeUseDefRecordBuilders.js +112 -0
- package/dist/internal/index-impl/projectSymbolGraphScopeUseDefRecords.js +238 -0
- package/dist/internal/index-impl/projectSymbolGraphScopeUseDefStructural.js +104 -0
- package/dist/internal/index-impl/projectSymbolGraphScopeUseDefStructuralNormalize.js +242 -0
- package/dist/internal/index-impl/projectSymbolGraphScopeUseDefUseHashes.js +107 -0
- package/dist/internal/index-impl/projectSymbolGraphSourceMapGeneratedBoundary.js +111 -0
- package/dist/internal/index-impl/projectSymbolGraphSourceRecords.js +268 -0
- package/dist/internal/index-impl/projectSymbolGraphSourceRecordsOwnership.js +309 -0
- package/dist/internal/index-impl/replaySemanticEditProjection.js +53 -39
- package/dist/internal/index-impl/runtimeOrderEvidenceBinding.js +151 -0
- package/dist/internal/index-impl/runtimeOrderProofSurfaces.js +253 -0
- package/dist/internal/index-impl/semanticEditCallsiteArgumentMerge.js +319 -0
- package/dist/internal/index-impl/semanticEditExplicitSourceReplacement.js +7 -2
- package/dist/internal/index-impl/semanticEditProjectionRecord.js +8 -0
- package/dist/internal/index-impl/semanticEditReplayDiagnostics.js +7 -2
- package/dist/internal/index-impl/semanticEditReplayOutputBinding.js +61 -0
- package/dist/internal/index-impl/semanticEditReplayRerunRoute.js +27 -0
- package/dist/internal/index-impl/semanticEditReplaySourceReplacement.js +6 -1
- package/dist/internal/index-impl/semanticEditRuntimeOrderReasons.js +320 -0
- package/dist/internal/index-impl/semanticEditScriptClassification.js +90 -5
- package/dist/internal/index-impl/semanticEditScripts.js +42 -5
- package/dist/internal/index-impl/semanticEditTypeSyntaxReasons.js +134 -0
- package/dist/internal/index-impl/semanticIndexFromNativeDeclarations.js +11 -5
- package/dist/internal/index-impl/semanticStructuralDiffRecords.js +150 -0
- package/dist/internal/index-impl/sourceMapGeneratedBoundaryGate.js +185 -0
- package/dist/internal/index-impl/staticMemberLiteral.js +31 -0
- package/dist/internal/index-impl/staticOptionalMemberReference.js +22 -0
- package/dist/internal/index-impl/syntaxAstSourcePreservation.js +273 -0
- package/dist/internal/index-impl/syntaxCommonJsModuleDeclarationEntries.js +297 -0
- package/dist/internal/index-impl/syntaxModuleDeclarationEntries.js +56 -132
- package/dist/internal/index-impl/syntaxModuleEntryRecords.js +160 -0
- package/dist/internal/index-impl/typeScriptCompilerAdvancedTypeShapes.js +160 -0
- package/dist/internal/index-impl/typeScriptCompilerAssignabilityOracle.js +97 -0
- package/dist/internal/index-impl/typeScriptCompilerClassApi.js +238 -0
- package/dist/internal/index-impl/typeScriptCompilerDecoratorMetadata.js +290 -0
- package/dist/internal/index-impl/typeScriptCompilerEnumShape.js +279 -0
- package/dist/internal/index-impl/typeScriptCompilerFacts.js +294 -0
- package/dist/internal/index-impl/typeScriptCompilerInferenceSyntax.js +170 -0
- package/dist/internal/index-impl/typeScriptCompilerReferenceGraph.js +186 -0
- package/dist/internal/index-impl/typeScriptCompilerSymbolIdentity.js +294 -0
- package/dist/internal/index-impl/typeScriptCompilerTypeReferenceTargets.js +142 -0
- package/dist/internal/index-impl/typeScriptDeclaration.js +10 -38
- package/dist/internal/index-impl/typeScriptModuleDeclarationEntries.js +52 -15
- package/dist/internal/index-impl/typeScriptSourceFilePreservation.js +296 -0
- package/dist/js-ts-safe-member-class-invariants.js +247 -0
- package/dist/js-ts-safe-member-merge-result.js +23 -3
- package/dist/js-ts-safe-member-merge.js +28 -4
- package/dist/js-ts-safe-merge-binding-patterns.js +170 -0
- package/dist/js-ts-safe-merge-jsx-attribute-fallback.js +151 -157
- package/dist/js-ts-safe-merge-jsx-attribute-parser.js +277 -0
- package/dist/js-ts-safe-merge-jsx-child-expression-fallback.js +161 -0
- package/dist/js-ts-safe-merge-jsx-child-expression-merge.js +319 -0
- package/dist/js-ts-safe-merge-jsx-child-expression-parser.js +300 -0
- package/dist/js-ts-safe-merge-parse-declarations.js +46 -2
- package/dist/js-ts-safe-merge-parse-statements.js +8 -0
- package/dist/js-ts-safe-merge-semantic-edit-fallback.js +13 -5
- package/dist/js-ts-safe-merge-source-shape-fallbacks.js +3 -1
- package/dist/js-ts-safe-merge-top-level-rename-fallback.js +31 -5
- package/dist/js-ts-safe-merge-top-level-rename-result.js +7 -2
- package/dist/js-ts-safe-merge-variable-declarator-fallback.js +124 -6
- package/dist/js-ts-safe-merge-variable-declarator-parser.js +34 -4
- package/dist/js-ts-safe-merge.js +136 -0
- package/dist/js-ts-safe-project-merge-admission-routes.js +216 -0
- package/dist/js-ts-safe-project-merge-admission.js +161 -0
- package/dist/js-ts-safe-project-merge-ambient.js +110 -0
- package/dist/js-ts-safe-project-merge-core.js +85 -0
- package/dist/js-ts-safe-project-merge-css-module-conflicts.js +60 -0
- package/dist/js-ts-safe-project-merge-declaration-emit-parity.js +186 -0
- package/dist/js-ts-safe-project-merge-declarations.js +227 -0
- package/dist/js-ts-safe-project-merge-diagnostics-metadata.js +42 -0
- package/dist/js-ts-safe-project-merge-diagnostics-ts.js +73 -0
- package/dist/js-ts-safe-project-merge-diagnostics.js +283 -0
- package/dist/js-ts-safe-project-merge-evidence-routing.js +38 -0
- package/dist/js-ts-safe-project-merge-files.js +70 -0
- package/dist/js-ts-safe-project-merge-global-augmentation-compatibility.js +99 -0
- package/dist/js-ts-safe-project-merge-graph-conflicts.js +90 -2
- package/dist/js-ts-safe-project-merge-graph-delta-commonjs-interop.js +108 -0
- package/dist/js-ts-safe-project-merge-graph-delta-compiler-conflicts.js +179 -0
- package/dist/js-ts-safe-project-merge-graph-delta-compiler-details.js +189 -0
- package/dist/js-ts-safe-project-merge-graph-delta-conflicts.js +51 -184
- package/dist/js-ts-safe-project-merge-graph-delta-identity-conflicts.js +202 -0
- package/dist/js-ts-safe-project-merge-graph-delta-inference-syntax.js +80 -0
- package/dist/js-ts-safe-project-merge-graph-delta-module-declarations.js +155 -0
- package/dist/js-ts-safe-project-merge-graph-limits.js +16 -1
- package/dist/js-ts-safe-project-merge-graph.js +37 -5
- package/dist/js-ts-safe-project-merge-import-removal.js +292 -0
- package/dist/js-ts-safe-project-merge-jsx-graph-conflict-details.js +235 -0
- package/dist/js-ts-safe-project-merge-jsx-graph-conflicts.js +173 -0
- package/dist/js-ts-safe-project-merge-jsx-prop-contracts.js +86 -0
- package/dist/js-ts-safe-project-merge-jsx-render-branch-proof.js +189 -0
- package/dist/js-ts-safe-project-merge-missing-evidence.js +310 -0
- package/dist/js-ts-safe-project-merge-move-rename.js +209 -0
- package/dist/js-ts-safe-project-merge-proof-conflicts.js +44 -0
- package/dist/js-ts-safe-project-merge-proof-levels.js +320 -0
- package/dist/js-ts-safe-project-merge-quality-gates.js +140 -0
- package/dist/js-ts-safe-project-merge-routing-calibration.js +125 -0
- package/dist/js-ts-safe-project-merge-runtime-region-conflicts.js +156 -0
- package/dist/js-ts-safe-project-merge-scope-use-def-conflicts.js +292 -0
- package/dist/js-ts-safe-project-merge-semantic-equivalence-proof.js +175 -0
- package/dist/js-ts-safe-project-merge-semantic-replay-proof.js +311 -0
- package/dist/js-ts-safe-project-merge-semantic-replay-routes.js +179 -0
- package/dist/js-ts-safe-project-merge-source-span-conflicts.js +310 -0
- package/dist/js-ts-safe-project-merge-source-span-roundtrip-proof.js +172 -0
- package/dist/js-ts-safe-project-merge-split-merge-admission.js +96 -0
- package/dist/js-ts-safe-project-merge-split-merge-records.js +320 -0
- package/dist/js-ts-safe-project-merge-split-merge-shapes.js +234 -0
- package/dist/js-ts-safe-project-merge-split-merge.js +218 -0
- package/dist/js-ts-safe-project-merge-summary.js +320 -0
- package/dist/js-ts-safe-project-merge-symbol-move-admission.js +63 -0
- package/dist/js-ts-safe-project-merge-symbol-move-default-admission.js +143 -0
- package/dist/js-ts-safe-project-merge-symbol-move-risks.js +213 -0
- package/dist/js-ts-safe-project-merge-symbol-move.js +316 -0
- package/dist/js-ts-safe-project-merge-symbol-rename-admission.js +59 -0
- package/dist/js-ts-safe-project-merge-symbol-rename-default-admission.js +111 -0
- package/dist/js-ts-safe-project-merge-symbol-rename.js +319 -0
- package/dist/js-ts-safe-project-merge-ts-options.js +205 -0
- package/dist/js-ts-safe-project-merge-ts-program.js +268 -0
- package/dist/js-ts-safe-project-merge-typed-property-rename-rebase-utils.js +69 -0
- package/dist/js-ts-safe-project-merge-typed-property-rename-rebase.js +317 -0
- package/dist/js-ts-safe-project-merge-unsupported-surfaces.js +319 -0
- package/dist/js-ts-safe-project-merge.js +170 -171
- package/dist/js-ts-semantic-scope-use-def-bindings.js +287 -0
- package/dist/js-ts-semantic-scope-use-def-scan.js +241 -0
- package/dist/js-ts-semantic-scope-use-def-utils.js +132 -0
- package/dist/js-ts-semantic-scope-use-def.js +217 -0
- package/dist/lightweight-dependency-effects.js +28 -4
- package/dist/lightweight-dependency-relations.js +13 -7
- package/dist/lightweight-dependency-top-level.js +63 -0
- package/dist/native-import-language-profiles.js +27 -1
- package/dist/native-js-ts-importers.js +9 -5
- package/dist/native-parser-ast-format-profiles.js +12 -0
- package/dist/native-parser-html-css-format-profiles.js +85 -0
- package/dist/native-region-scanner-core.js +5 -3
- package/dist/native-region-scanner-js-commonjs.js +155 -0
- package/dist/native-region-scanner-js-imports.js +51 -13
- package/dist/native-region-scanner-js-reexports.js +79 -0
- package/dist/native-region-scanner-js-ts-helpers.js +23 -0
- package/dist/native-source-ledger-helpers.js +1 -1
- package/dist/native-source-ledger.js +24 -10
- package/dist/native-source-maps-ecma426.js +316 -0
- package/dist/native-source-maps.js +36 -6
- package/dist/native-source-preservation-ownership.js +292 -0
- package/dist/native-source-preservation-scanner.js +63 -25
- package/dist/native-source-preservation-types.d.ts +3 -0
- package/dist/semantic-import-effect-occurrences.js +242 -0
- package/dist/semantic-import-effect-regions.js +95 -58
- package/dist/semantic-import-graph-layers.js +224 -0
- package/dist/semantic-import-runtime-conditional-evidence.js +135 -0
- package/dist/semantic-import-runtime-effect-target-evidence.js +145 -0
- package/dist/semantic-import-runtime-exit-evidence.js +32 -0
- package/dist/semantic-import-runtime-import-meta-evidence.js +33 -0
- package/dist/semantic-import-runtime-mutation-evidence.js +155 -0
- package/dist/semantic-import-runtime-order-evidence.js +318 -0
- package/dist/semantic-import-runtime-promise-chain-evidence.js +103 -0
- package/dist/semantic-import-runtime-promise-combinator-evidence.js +166 -0
- package/dist/semantic-import-runtime-reachability-evidence.js +269 -0
- package/dist/semantic-import-runtime-resource-management-evidence.js +293 -0
- package/dist/semantic-import-runtime-switch-evidence.js +304 -0
- package/dist/semantic-import-runtime-throw-evidence.js +44 -0
- package/dist/semantic-import-runtime-try-finally-evidence.js +172 -0
- package/dist/semantic-import-sidecar-entry.js +4 -0
- package/dist/semantic-import-source-preservation.js +6 -2
- package/package.json +1 -1
|
@@ -0,0 +1,59 @@
|
|
|
1
|
+
import {
|
|
2
|
+
createExactBranchProjectSemanticEditAdmissionFile,
|
|
3
|
+
summarizeProjectSemanticEditAdmissions
|
|
4
|
+
} from './js-ts-safe-project-merge-admission.js';
|
|
5
|
+
import { hasFailedTypeScriptRefactorEvidence } from './internal/index-impl/typeScriptCompilerFacts.js';
|
|
6
|
+
|
|
7
|
+
function maybeAdmitProjectSymbolRenameFile(fileResult, file, input, classifications) {
|
|
8
|
+
const explicitAdmission = allowsProjectSymbolRename(input);
|
|
9
|
+
const defaultAdmission = allowsDefaultProjectSymbolRename(input, classifications);
|
|
10
|
+
if (!explicitAdmission && !defaultAdmission) return undefined;
|
|
11
|
+
if (hasFailedTypeScriptRefactorEvidence(classifications)) return undefined;
|
|
12
|
+
return createExactBranchProjectSemanticEditAdmissionFile({
|
|
13
|
+
fileResult,
|
|
14
|
+
file,
|
|
15
|
+
classifications,
|
|
16
|
+
admissionKind: 'js-ts-project-symbol-rename-admission',
|
|
17
|
+
action: 'apply-project-symbol-rename',
|
|
18
|
+
operation: (result) => result.status !== 'merged' || result.operation === 'merged-source'
|
|
19
|
+
? 'merged-project-symbol-rename'
|
|
20
|
+
: `${result.operation}+project-symbol-rename`,
|
|
21
|
+
summaryKey: 'projectSymbolRenameAdmissions',
|
|
22
|
+
evidenceKey: 'projectSymbolRenameAdmissionEvidence',
|
|
23
|
+
metadataKey: 'projectSymbolRenameAdmissions',
|
|
24
|
+
requireOtherBranchUnchanged: true,
|
|
25
|
+
allowExistingExactOutput: true,
|
|
26
|
+
admissionFields: (classification) => ({
|
|
27
|
+
defaultAdmission: !explicitAdmission && defaultAdmission ? true : undefined,
|
|
28
|
+
typeScriptRefactorEvidenceId: classification.details?.typeScriptRefactorEvidence?.id
|
|
29
|
+
})
|
|
30
|
+
});
|
|
31
|
+
}
|
|
32
|
+
|
|
33
|
+
function projectSymbolRenameAdmissionSummary(admissions = []) {
|
|
34
|
+
return summarizeProjectSemanticEditAdmissions(admissions, {
|
|
35
|
+
totalKey: 'admissions',
|
|
36
|
+
byKind: [{
|
|
37
|
+
key: 'crossFileSymbolRenameAdmissions',
|
|
38
|
+
property: 'kind',
|
|
39
|
+
value: 'js-ts-project-symbol-rename-admission'
|
|
40
|
+
}],
|
|
41
|
+
evidenceIdsKey: 'admissionEvidenceIds'
|
|
42
|
+
});
|
|
43
|
+
}
|
|
44
|
+
|
|
45
|
+
function allowsProjectSymbolRename(input) {
|
|
46
|
+
return (input?.allowProjectSymbolRenames === true || input?.allowCrossFileSymbolRenames === true)
|
|
47
|
+
&& input?.requireOutputDiagnostics === true
|
|
48
|
+
&& input?.requireDeclarationOutput === true;
|
|
49
|
+
}
|
|
50
|
+
|
|
51
|
+
function allowsDefaultProjectSymbolRename(input, classifications = []) {
|
|
52
|
+
return input?.includeProjectGraphDelta === true
|
|
53
|
+
&& input?.requireOutputDiagnostics === true
|
|
54
|
+
&& input?.requireDeclarationOutput === true
|
|
55
|
+
&& classifications.length > 0
|
|
56
|
+
&& classifications.every((classification) => classification.details?.defaultAdmissionProof?.status === 'passed');
|
|
57
|
+
}
|
|
58
|
+
|
|
59
|
+
export { allowsProjectSymbolRename, maybeAdmitProjectSymbolRenameFile, projectSymbolRenameAdmissionSummary };
|
|
@@ -0,0 +1,111 @@
|
|
|
1
|
+
import { compactRecord } from './js-ts-safe-merge-context.js';
|
|
2
|
+
|
|
3
|
+
function projectSymbolRenameDefaultAdmissionProofs(branch, exportRenames, importRenames, ledgersByPath, sourcePaths, requiredEvidence) {
|
|
4
|
+
const proofs = new Map();
|
|
5
|
+
if (exportRenames.length !== 1) return proofs;
|
|
6
|
+
const exportRename = exportRenames[0];
|
|
7
|
+
const proof = projectSymbolRenameDefaultAdmissionProof(branch, exportRename, importRenames, ledgersByPath, sourcePaths, requiredEvidence);
|
|
8
|
+
if (proof) proofs.set(projectSymbolRenameKey(exportRename.sourcePath, exportRename.fromName, exportRename.toName), proof);
|
|
9
|
+
return proofs;
|
|
10
|
+
}
|
|
11
|
+
|
|
12
|
+
function projectSymbolRenameDefaultAdmissionProof(branch, exportRename, importRenames, ledgersByPath, sourcePaths, requiredEvidence) {
|
|
13
|
+
if ((exportRename.fromEntries?.length ?? 0) !== 1 || (exportRename.toEntries?.length ?? 0) !== 1) return undefined;
|
|
14
|
+
const matchingImportRenames = importRenames.filter((importRename) => importRenameMatchesExportRename(importRename, exportRename, sourcePaths));
|
|
15
|
+
if (!matchingImportRenames.length || matchingImportRenames.length !== importRenames.length) return undefined;
|
|
16
|
+
const baseOldReferences = projectSymbolImportReferences(ledgersByPath, sourcePaths, 'base', exportRename.sourcePath, exportRename.fromName);
|
|
17
|
+
const branchNewReferences = projectSymbolImportReferences(ledgersByPath, sourcePaths, 'branch', exportRename.sourcePath, exportRename.toName);
|
|
18
|
+
const branchOldReferences = projectSymbolImportReferences(ledgersByPath, sourcePaths, 'branch', exportRename.sourcePath, exportRename.fromName);
|
|
19
|
+
if (branchOldReferences.length) return undefined;
|
|
20
|
+
const rewriteKeys = matchingImportRenames.map(importRenameReferenceKey);
|
|
21
|
+
const baseOldKeys = baseOldReferences.map(importReferenceKey);
|
|
22
|
+
const branchNewKeys = branchNewReferences.map(importReferenceKey);
|
|
23
|
+
if (!hasUniqueStrings(rewriteKeys) || !hasUniqueStrings(baseOldKeys) || !hasUniqueStrings(branchNewKeys)) return undefined;
|
|
24
|
+
if (!sameStringSet(rewriteKeys, baseOldKeys) || !sameStringSet(rewriteKeys, branchNewKeys)) return undefined;
|
|
25
|
+
return compactRecord({
|
|
26
|
+
status: 'passed',
|
|
27
|
+
route: 'default-exact-cross-file-symbol-rename',
|
|
28
|
+
branch,
|
|
29
|
+
exportSourcePath: exportRename.sourcePath,
|
|
30
|
+
fromName: exportRename.fromName,
|
|
31
|
+
toName: exportRename.toName,
|
|
32
|
+
importRewriteCount: matchingImportRenames.length,
|
|
33
|
+
rewrittenImportSourcePaths: uniqueStrings(matchingImportRenames.map((importRename) => importRename.sourcePath)),
|
|
34
|
+
staleImportReferences: 0,
|
|
35
|
+
duplicateImportReferences: 0,
|
|
36
|
+
duplicateExportReferences: 0,
|
|
37
|
+
requiredEvidence: [
|
|
38
|
+
'project-graph-delta-evidence',
|
|
39
|
+
...requiredEvidence
|
|
40
|
+
]
|
|
41
|
+
});
|
|
42
|
+
}
|
|
43
|
+
|
|
44
|
+
function importRenameMatchesExportRename(importRename, exportRename, sourcePaths) {
|
|
45
|
+
return importRename.fromName === exportRename.fromName
|
|
46
|
+
&& importRename.toName === exportRename.toName
|
|
47
|
+
&& resolveProjectModuleSpecifier(importRename.sourcePath, importRename.moduleSpecifier, sourcePaths) === exportRename.sourcePath;
|
|
48
|
+
}
|
|
49
|
+
|
|
50
|
+
function projectSymbolImportReferences(ledgersByPath, sourcePaths, stage, exportSourcePath, importedName) {
|
|
51
|
+
const references = [];
|
|
52
|
+
for (const [sourcePath, ledgers] of ledgersByPath) {
|
|
53
|
+
const ledger = ledgers?.[stage];
|
|
54
|
+
for (const entry of ledger?.entries ?? []) {
|
|
55
|
+
if (entry.kind !== 'import' || !entry.importInfo?.moduleSpecifier) continue;
|
|
56
|
+
const resolvedPath = resolveProjectModuleSpecifier(sourcePath, entry.importInfo.moduleSpecifier, sourcePaths);
|
|
57
|
+
if (resolvedPath !== exportSourcePath) continue;
|
|
58
|
+
for (const specifier of entry.importInfo.specifiers ?? []) {
|
|
59
|
+
if (specifier.importedName !== importedName) continue;
|
|
60
|
+
references.push({
|
|
61
|
+
sourcePath,
|
|
62
|
+
moduleSpecifier: entry.importInfo.moduleSpecifier,
|
|
63
|
+
importedName: specifier.importedName,
|
|
64
|
+
localName: specifier.localName,
|
|
65
|
+
typeOnly: entry.importInfo.typeOnly === true || specifier.typeOnly === true
|
|
66
|
+
});
|
|
67
|
+
}
|
|
68
|
+
}
|
|
69
|
+
}
|
|
70
|
+
return references;
|
|
71
|
+
}
|
|
72
|
+
|
|
73
|
+
function resolveProjectModuleSpecifier(sourcePath, moduleSpecifier, sourcePaths) {
|
|
74
|
+
if (typeof moduleSpecifier !== 'string' || !moduleSpecifier.startsWith('.')) return undefined;
|
|
75
|
+
const rawPath = normalizeProjectPath(`${dirname(sourcePath) ? `${dirname(sourcePath)}/` : ''}${moduleSpecifier}`);
|
|
76
|
+
return projectModulePathCandidates(rawPath).find((candidate) => sourcePaths.has(candidate));
|
|
77
|
+
}
|
|
78
|
+
|
|
79
|
+
function projectModulePathCandidates(rawPath) {
|
|
80
|
+
const candidates = [rawPath];
|
|
81
|
+
if (/\.[cm]?[jt]sx?$/.test(rawPath)) {
|
|
82
|
+
candidates.push(...['.ts', '.tsx', '.js', '.jsx', '.mts', '.cts'].map((ext) => rawPath.replace(/\.[cm]?[jt]sx?$/, ext)));
|
|
83
|
+
} else {
|
|
84
|
+
candidates.push(...['.ts', '.tsx', '.js', '.jsx', '.mts', '.cts', '/index.ts', '/index.tsx', '/index.js', '/index.jsx'].map((suffix) => `${rawPath}${suffix}`));
|
|
85
|
+
}
|
|
86
|
+
return uniqueStrings(candidates.map(normalizeProjectPath));
|
|
87
|
+
}
|
|
88
|
+
|
|
89
|
+
function normalizeProjectPath(path) {
|
|
90
|
+
const parts = [];
|
|
91
|
+
for (const part of String(path ?? '').split('/')) {
|
|
92
|
+
if (!part || part === '.') continue;
|
|
93
|
+
if (part === '..') parts.pop();
|
|
94
|
+
else parts.push(part);
|
|
95
|
+
}
|
|
96
|
+
return parts.join('/');
|
|
97
|
+
}
|
|
98
|
+
|
|
99
|
+
function projectSymbolRenameKey(sourcePath, fromName, toName) { return [sourcePath, fromName, toName].join('\u0000'); }
|
|
100
|
+
function importRenameReferenceKey(rename) { return importReferenceKey(rename); }
|
|
101
|
+
function importReferenceKey(reference) { return [reference.sourcePath, reference.moduleSpecifier, reference.typeOnly ? 'type' : 'value'].join('\u0000'); }
|
|
102
|
+
function dirname(path) { const text = String(path ?? ''); const slash = text.lastIndexOf('/'); return slash === -1 ? '' : text.slice(0, slash); }
|
|
103
|
+
function hasUniqueStrings(values) { return new Set(values).size === values.length; }
|
|
104
|
+
function sameStringSet(left, right) {
|
|
105
|
+
if (left.length !== right.length) return false;
|
|
106
|
+
const rightSet = new Set(right);
|
|
107
|
+
return left.every((value) => rightSet.has(value));
|
|
108
|
+
}
|
|
109
|
+
function uniqueStrings(values) { return [...new Set(values.filter((value) => typeof value === 'string' && value.length > 0))]; }
|
|
110
|
+
|
|
111
|
+
export { projectSymbolRenameDefaultAdmissionProofs };
|
|
@@ -0,0 +1,319 @@
|
|
|
1
|
+
import { hashSemanticValue } from '@shapeshift-labs/frontier-lang-kernel';
|
|
2
|
+
import { compactRecord, createMergeContext } from './js-ts-safe-merge-context.js';
|
|
3
|
+
import { scanJsTsTopLevelLedger, validateLedgerUniqueness } from './js-ts-safe-merge-ledger.js';
|
|
4
|
+
import { TypeScriptRefactorEvidenceMissingCode, typeScriptRefactorEvidenceRecordsFromClassifications, withTypeScriptRefactorEvidence } from './internal/index-impl/typeScriptCompilerFacts.js';
|
|
5
|
+
import { projectSymbolRenameDefaultAdmissionProofs } from './js-ts-safe-project-merge-symbol-rename-default-admission.js';
|
|
6
|
+
import { maybeAdmitProjectSymbolRenameFile, projectSymbolRenameAdmissionSummary } from './js-ts-safe-project-merge-symbol-rename-admission.js';
|
|
7
|
+
|
|
8
|
+
const projectSymbolRenameRequiredEvidence = ['import-export-rewrite-evidence', 'output-diagnostics-gate', 'output-declaration-gate'];
|
|
9
|
+
|
|
10
|
+
function classifyProjectSymbolRenames(files, input) {
|
|
11
|
+
const classifications = [...classifyBranchCrossFileSymbolRenames(files, input, 'worker'), ...classifyBranchCrossFileSymbolRenames(files, input, 'head')];
|
|
12
|
+
const byPath = new Map();
|
|
13
|
+
for (const classification of classifications) {
|
|
14
|
+
for (const sourcePath of classification.sourcePaths) {
|
|
15
|
+
const entries = byPath.get(sourcePath) ?? [];
|
|
16
|
+
entries.push(classification);
|
|
17
|
+
byPath.set(sourcePath, entries);
|
|
18
|
+
}
|
|
19
|
+
}
|
|
20
|
+
return { classifications, byPath, summary: projectSymbolRenameSummary(classifications) };
|
|
21
|
+
}
|
|
22
|
+
|
|
23
|
+
function classifyBranchCrossFileSymbolRenames(files, input, branch) {
|
|
24
|
+
const exportRenames = [];
|
|
25
|
+
const importRenames = [];
|
|
26
|
+
const sourcePaths = new Set(files.map((file) => file.sourcePath).filter(Boolean));
|
|
27
|
+
const ledgersByPath = new Map();
|
|
28
|
+
for (const file of files) {
|
|
29
|
+
if (!file.sourcePath || typeof file.baseSourceText !== 'string') continue;
|
|
30
|
+
const branchSourceText = branchStageSourceText(file, branch);
|
|
31
|
+
if (typeof branchSourceText !== 'string') continue;
|
|
32
|
+
const ledgers = projectSymbolRenameLedgers(file, input, branch, branchSourceText);
|
|
33
|
+
if (!ledgers) continue;
|
|
34
|
+
ledgersByPath.set(file.sourcePath, ledgers);
|
|
35
|
+
if (branchSourceText === file.baseSourceText) continue;
|
|
36
|
+
const exportRename = exportedNameRenameCandidate(file, branch, ledgers.base, ledgers.branch);
|
|
37
|
+
if (exportRename) exportRenames.push(exportRename);
|
|
38
|
+
importRenames.push(...importedNameRenameCandidates(file, branch, ledgers.base, ledgers.branch));
|
|
39
|
+
}
|
|
40
|
+
const defaultAdmissionProofs = projectSymbolRenameDefaultAdmissionProofs(branch, exportRenames, importRenames, ledgersByPath, sourcePaths, projectSymbolRenameRequiredEvidence);
|
|
41
|
+
const exportsByPathAndName = new Map(exportRenames.map((rename) => [
|
|
42
|
+
projectSymbolRenameKey(rename.sourcePath, rename.fromName, rename.toName),
|
|
43
|
+
rename
|
|
44
|
+
]));
|
|
45
|
+
const classifications = [];
|
|
46
|
+
const seen = new Set();
|
|
47
|
+
for (const importRename of importRenames) {
|
|
48
|
+
const exportSourcePath = resolveProjectModuleSpecifier(importRename.sourcePath, importRename.moduleSpecifier, sourcePaths);
|
|
49
|
+
if (!exportSourcePath || exportSourcePath === importRename.sourcePath) continue;
|
|
50
|
+
const exportRename = exportsByPathAndName.get(projectSymbolRenameKey(exportSourcePath, importRename.fromName, importRename.toName));
|
|
51
|
+
if (!exportRename) continue;
|
|
52
|
+
const proofKey = projectSymbolRenameKey(exportRename.sourcePath, exportRename.fromName, exportRename.toName);
|
|
53
|
+
const classification = projectSymbolRenameClassification(branch, exportRename, importRename, defaultAdmissionProofs.get(proofKey));
|
|
54
|
+
if (seen.has(classification.details.conflictKey)) continue;
|
|
55
|
+
seen.add(classification.details.conflictKey);
|
|
56
|
+
classifications.push(classification);
|
|
57
|
+
}
|
|
58
|
+
return classifications;
|
|
59
|
+
}
|
|
60
|
+
|
|
61
|
+
function projectSymbolRenameLedgers(file, input, branch, branchSourceText) {
|
|
62
|
+
const context = createMergeContext({
|
|
63
|
+
id: `project_symbol_rename_${branch}_${safeId(file.sourcePath)}`,
|
|
64
|
+
sourcePath: file.sourcePath,
|
|
65
|
+
language: file.language ?? input.language ?? 'typescript'
|
|
66
|
+
});
|
|
67
|
+
const base = scanJsTsTopLevelLedger(file.baseSourceText, 'base', context);
|
|
68
|
+
const branchLedger = scanJsTsTopLevelLedger(branchSourceText, branch, context);
|
|
69
|
+
if (!context.conflicts.length) {
|
|
70
|
+
validateLedgerUniqueness(base, context);
|
|
71
|
+
validateLedgerUniqueness(branchLedger, context);
|
|
72
|
+
}
|
|
73
|
+
return context.conflicts.length ? undefined : { base, branch: branchLedger };
|
|
74
|
+
}
|
|
75
|
+
|
|
76
|
+
function exportedNameRenameCandidate(file, branch, base, branchLedger) {
|
|
77
|
+
const baseNames = exportedNamesByName(base);
|
|
78
|
+
const branchNames = exportedNamesByName(branchLedger);
|
|
79
|
+
const removedNames = [...baseNames.keys()].filter((name) => !branchNames.has(name));
|
|
80
|
+
const addedNames = [...branchNames.keys()].filter((name) => !baseNames.has(name));
|
|
81
|
+
if (removedNames.length !== 1 || addedNames.length !== 1) return undefined;
|
|
82
|
+
const fromName = removedNames[0];
|
|
83
|
+
const toName = addedNames[0];
|
|
84
|
+
if (!renameableProjectSymbolName(fromName) || !renameableProjectSymbolName(toName)) return undefined;
|
|
85
|
+
return {
|
|
86
|
+
kind: 'export-symbol-rename',
|
|
87
|
+
branch,
|
|
88
|
+
sourcePath: file.sourcePath,
|
|
89
|
+
fromName,
|
|
90
|
+
toName,
|
|
91
|
+
fromEntries: baseNames.get(fromName),
|
|
92
|
+
toEntries: branchNames.get(toName)
|
|
93
|
+
};
|
|
94
|
+
}
|
|
95
|
+
|
|
96
|
+
function importedNameRenameCandidates(file, branch, base, branchLedger) {
|
|
97
|
+
const baseImports = importSpecifiersByModule(base);
|
|
98
|
+
const branchImports = importSpecifiersByModule(branchLedger);
|
|
99
|
+
const moduleKeys = uniqueStrings([...baseImports.keys(), ...branchImports.keys()]);
|
|
100
|
+
return moduleKeys.flatMap((moduleKey) => {
|
|
101
|
+
const baseSpecifiers = baseImports.get(moduleKey) ?? [];
|
|
102
|
+
const branchSpecifiers = branchImports.get(moduleKey) ?? [];
|
|
103
|
+
const baseNames = new Set(baseSpecifiers.map((specifier) => specifier.importedName));
|
|
104
|
+
const branchNames = new Set(branchSpecifiers.map((specifier) => specifier.importedName));
|
|
105
|
+
const removedNames = [...baseNames].filter((name) => !branchNames.has(name));
|
|
106
|
+
const addedNames = [...branchNames].filter((name) => !baseNames.has(name));
|
|
107
|
+
if (removedNames.length !== 1 || addedNames.length !== 1) return [];
|
|
108
|
+
const fromName = removedNames[0];
|
|
109
|
+
const toName = addedNames[0];
|
|
110
|
+
if (!renameableProjectSymbolName(fromName) || !renameableProjectSymbolName(toName)) return [];
|
|
111
|
+
const fromSpecifier = baseSpecifiers.find((specifier) => specifier.importedName === fromName);
|
|
112
|
+
const toSpecifier = branchSpecifiers.find((specifier) => specifier.importedName === toName);
|
|
113
|
+
if (!fromSpecifier || !toSpecifier) return [];
|
|
114
|
+
return [{
|
|
115
|
+
kind: 'import-symbol-rename',
|
|
116
|
+
branch,
|
|
117
|
+
sourcePath: file.sourcePath,
|
|
118
|
+
moduleSpecifier: fromSpecifier.moduleSpecifier,
|
|
119
|
+
fromName,
|
|
120
|
+
toName,
|
|
121
|
+
fromLocalName: fromSpecifier.localName,
|
|
122
|
+
toLocalName: toSpecifier.localName,
|
|
123
|
+
typeOnly: fromSpecifier.typeOnly === true || toSpecifier.typeOnly === true
|
|
124
|
+
}];
|
|
125
|
+
});
|
|
126
|
+
}
|
|
127
|
+
|
|
128
|
+
function exportedNamesByName(ledger) {
|
|
129
|
+
const result = new Map();
|
|
130
|
+
for (const entry of ledger?.entries ?? []) {
|
|
131
|
+
const exported = entry.kind === 'export' || entry.declarationInfo?.exported === true;
|
|
132
|
+
if (!exported) continue;
|
|
133
|
+
for (const name of entry.names ?? []) {
|
|
134
|
+
if (!renameableProjectSymbolName(name)) continue;
|
|
135
|
+
const entries = result.get(name) ?? [];
|
|
136
|
+
entries.push(entry);
|
|
137
|
+
result.set(name, entries);
|
|
138
|
+
}
|
|
139
|
+
}
|
|
140
|
+
return result;
|
|
141
|
+
}
|
|
142
|
+
|
|
143
|
+
function importSpecifiersByModule(ledger) {
|
|
144
|
+
const result = new Map();
|
|
145
|
+
for (const entry of ledger?.entries ?? []) {
|
|
146
|
+
if (entry.kind !== 'import' || !entry.importInfo?.moduleSpecifier) continue;
|
|
147
|
+
for (const specifier of entry.importInfo.specifiers ?? []) {
|
|
148
|
+
const importedName = specifier.importedName;
|
|
149
|
+
if (!renameableProjectSymbolName(importedName)) continue;
|
|
150
|
+
const record = {
|
|
151
|
+
moduleSpecifier: entry.importInfo.moduleSpecifier,
|
|
152
|
+
importedName,
|
|
153
|
+
localName: specifier.localName,
|
|
154
|
+
typeOnly: entry.importInfo.typeOnly === true || specifier.typeOnly === true
|
|
155
|
+
};
|
|
156
|
+
const key = importSpecifierModuleKey(record);
|
|
157
|
+
const entries = result.get(key) ?? [];
|
|
158
|
+
entries.push(record);
|
|
159
|
+
result.set(key, entries);
|
|
160
|
+
}
|
|
161
|
+
}
|
|
162
|
+
return result;
|
|
163
|
+
}
|
|
164
|
+
|
|
165
|
+
function projectSymbolRenameClassification(branch, exportRename, importRename, defaultAdmissionProof) {
|
|
166
|
+
const code = `project-${branch}-cross-file-symbol-rename-blocked`;
|
|
167
|
+
return {
|
|
168
|
+
kind: 'cross-file-symbol-rename',
|
|
169
|
+
branch,
|
|
170
|
+
code,
|
|
171
|
+
operation: `blocked-${branch}-cross-file-symbol-rename`,
|
|
172
|
+
sourcePaths: uniqueStrings([exportRename.sourcePath, importRename.sourcePath]),
|
|
173
|
+
details: compactRecord({
|
|
174
|
+
reasonCode: code,
|
|
175
|
+
conflictKey: [
|
|
176
|
+
'project-symbol-rename',
|
|
177
|
+
branch,
|
|
178
|
+
exportRename.sourcePath,
|
|
179
|
+
exportRename.fromName,
|
|
180
|
+
exportRename.toName,
|
|
181
|
+
importRename.sourcePath,
|
|
182
|
+
importRename.moduleSpecifier
|
|
183
|
+
].join('#'),
|
|
184
|
+
branch,
|
|
185
|
+
symbolRenameKind: 'cross-file-export-import-rename',
|
|
186
|
+
fromName: exportRename.fromName,
|
|
187
|
+
toName: exportRename.toName,
|
|
188
|
+
exportSourcePath: exportRename.sourcePath,
|
|
189
|
+
importSourcePath: importRename.sourcePath,
|
|
190
|
+
moduleSpecifier: importRename.moduleSpecifier,
|
|
191
|
+
importFromLocalName: importRename.fromLocalName,
|
|
192
|
+
importToLocalName: importRename.toLocalName,
|
|
193
|
+
importTypeOnly: importRename.typeOnly || undefined,
|
|
194
|
+
observedEvidence: ['export-symbol-rename', 'import-specifier-rename'],
|
|
195
|
+
requiredEvidence: projectSymbolRenameRequiredEvidence,
|
|
196
|
+
defaultAdmissionProof
|
|
197
|
+
})
|
|
198
|
+
};
|
|
199
|
+
}
|
|
200
|
+
|
|
201
|
+
function blockedProjectSymbolRenameFile(file, input, classifications) {
|
|
202
|
+
const language = file.language ?? input.language ?? 'typescript';
|
|
203
|
+
const worker = file.workerDeleted ? undefined : file.workerSourceText ?? file.baseSourceText;
|
|
204
|
+
const head = file.headDeleted ? undefined : file.headSourceText ?? file.baseSourceText;
|
|
205
|
+
const typeScriptRefactorAdmissionEvidence = typeScriptRefactorEvidenceRecordsFromClassifications(classifications);
|
|
206
|
+
const conflicts = classifications.map((classification) => ({
|
|
207
|
+
code: classification.code,
|
|
208
|
+
gateId: 'project-symbol-rename-classifier',
|
|
209
|
+
message: classification.code === TypeScriptRefactorEvidenceMissingCode
|
|
210
|
+
? `Project ${classification.branch} cross-file symbol rename requires caller-supplied TypeScript refactor reference evidence.`
|
|
211
|
+
: `Project ${classification.branch} cross-file symbol rename requires import/export rewrite, diagnostics, and declaration evidence.`,
|
|
212
|
+
sourcePath: file.sourcePath,
|
|
213
|
+
details: compactRecord({ ...classification.details, sourcePath: file.sourcePath })
|
|
214
|
+
}));
|
|
215
|
+
const reasonCodes = uniqueStrings(classifications.map((classification) => classification.code));
|
|
216
|
+
const conflictKeys = uniqueStrings(conflicts.map((conflict) => conflict.details?.conflictKey));
|
|
217
|
+
return compactRecord({
|
|
218
|
+
kind: 'frontier.lang.jsTsProjectSafeMergeFile',
|
|
219
|
+
version: 1,
|
|
220
|
+
sourcePath: file.sourcePath,
|
|
221
|
+
language,
|
|
222
|
+
status: 'blocked',
|
|
223
|
+
operation: classifications[0]?.operation ?? 'blocked-project-symbol-rename',
|
|
224
|
+
baseHash: hashText(file.baseSourceText),
|
|
225
|
+
workerHash: hashText(worker),
|
|
226
|
+
headHash: hashText(head),
|
|
227
|
+
conflicts,
|
|
228
|
+
admission: {
|
|
229
|
+
status: 'blocked',
|
|
230
|
+
action: 'human-review',
|
|
231
|
+
reviewRequired: true,
|
|
232
|
+
autoApplyCandidate: false,
|
|
233
|
+
autoMergeClaim: false,
|
|
234
|
+
semanticEquivalenceClaim: false,
|
|
235
|
+
reasonCodes,
|
|
236
|
+
conflictKeys
|
|
237
|
+
},
|
|
238
|
+
summary: compactRecord({
|
|
239
|
+
conflicts: conflicts.length,
|
|
240
|
+
typeScriptRefactorAdmissionEvidence: nonEmptyArray(typeScriptRefactorAdmissionEvidence),
|
|
241
|
+
projectSymbolRenameClassifications: classifications.map((classification) => classification.details)
|
|
242
|
+
}),
|
|
243
|
+
conflictKeys
|
|
244
|
+
});
|
|
245
|
+
}
|
|
246
|
+
|
|
247
|
+
function applyProjectSymbolRenameClassifications(fileResults, files, input, projectSymbolRenames) {
|
|
248
|
+
if (!projectSymbolRenames?.byPath?.size) return fileResults;
|
|
249
|
+
const filesByPath = new Map(files.map((file) => [file.sourcePath, file]));
|
|
250
|
+
const admissions = [];
|
|
251
|
+
const applied = fileResults.map((fileResult) => {
|
|
252
|
+
const classifications = projectSymbolRenames.byPath.get(fileResult.sourcePath);
|
|
253
|
+
const file = filesByPath.get(fileResult.sourcePath);
|
|
254
|
+
const evidenceClassifications = classifications?.length
|
|
255
|
+
? withTypeScriptRefactorEvidence(input, classifications, files)
|
|
256
|
+
: classifications;
|
|
257
|
+
const admission = evidenceClassifications?.length && file
|
|
258
|
+
? maybeAdmitProjectSymbolRenameFile(fileResult, file, input, evidenceClassifications)
|
|
259
|
+
: undefined;
|
|
260
|
+
if (admission) admissions.push(...admission.admissions);
|
|
261
|
+
return admission?.fileResult ?? (evidenceClassifications?.length && file ? blockedProjectSymbolRenameFile(file, input, evidenceClassifications) : fileResult);
|
|
262
|
+
});
|
|
263
|
+
projectSymbolRenames.admissionSummary = projectSymbolRenameAdmissionSummary(admissions);
|
|
264
|
+
return applied;
|
|
265
|
+
}
|
|
266
|
+
|
|
267
|
+
function projectSymbolRenameSummary(classifications) {
|
|
268
|
+
return {
|
|
269
|
+
classifications: classifications.length,
|
|
270
|
+
crossFileSymbolRenames: classifications.filter((classification) => classification.kind === 'cross-file-symbol-rename').length,
|
|
271
|
+
reasonCodes: uniqueStrings(classifications.map((classification) => classification.code))
|
|
272
|
+
};
|
|
273
|
+
}
|
|
274
|
+
|
|
275
|
+
function branchStageSourceText(file, branch) {
|
|
276
|
+
if (branch === 'worker') return file.workerDeleted ? undefined : file.workerSourceText ?? file.baseSourceText;
|
|
277
|
+
return file.headDeleted ? undefined : file.headSourceText ?? file.baseSourceText;
|
|
278
|
+
}
|
|
279
|
+
|
|
280
|
+
function projectSymbolRenameKey(sourcePath, fromName, toName) { return [sourcePath, fromName, toName].join('\u0000'); }
|
|
281
|
+
function importSpecifierModuleKey(specifier) { return [specifier.moduleSpecifier, specifier.typeOnly ? 'type' : 'value'].join('\u0000'); }
|
|
282
|
+
|
|
283
|
+
function renameableProjectSymbolName(name) {
|
|
284
|
+
return typeof name === 'string' && name.length > 0 && name !== 'default' && name !== '*';
|
|
285
|
+
}
|
|
286
|
+
|
|
287
|
+
function resolveProjectModuleSpecifier(sourcePath, moduleSpecifier, sourcePaths) {
|
|
288
|
+
if (typeof moduleSpecifier !== 'string' || !moduleSpecifier.startsWith('.')) return undefined;
|
|
289
|
+
const rawPath = normalizeProjectPath(`${dirname(sourcePath) ? `${dirname(sourcePath)}/` : ''}${moduleSpecifier}`);
|
|
290
|
+
return projectModulePathCandidates(rawPath).find((candidate) => sourcePaths.has(candidate));
|
|
291
|
+
}
|
|
292
|
+
|
|
293
|
+
function projectModulePathCandidates(rawPath) {
|
|
294
|
+
const candidates = [rawPath];
|
|
295
|
+
if (/\.[cm]?[jt]sx?$/.test(rawPath)) {
|
|
296
|
+
candidates.push(...['.ts', '.tsx', '.js', '.jsx', '.mts', '.cts'].map((ext) => rawPath.replace(/\.[cm]?[jt]sx?$/, ext)));
|
|
297
|
+
} else {
|
|
298
|
+
candidates.push(...['.ts', '.tsx', '.js', '.jsx', '.mts', '.cts', '/index.ts', '/index.tsx', '/index.js', '/index.jsx'].map((suffix) => `${rawPath}${suffix}`));
|
|
299
|
+
}
|
|
300
|
+
return uniqueStrings(candidates.map(normalizeProjectPath));
|
|
301
|
+
}
|
|
302
|
+
|
|
303
|
+
function normalizeProjectPath(path) {
|
|
304
|
+
const parts = [];
|
|
305
|
+
for (const part of String(path ?? '').split('/')) {
|
|
306
|
+
if (!part || part === '.') continue;
|
|
307
|
+
if (part === '..') parts.pop();
|
|
308
|
+
else parts.push(part);
|
|
309
|
+
}
|
|
310
|
+
return parts.join('/');
|
|
311
|
+
}
|
|
312
|
+
|
|
313
|
+
function hashText(text) { return typeof text === 'string' ? hashSemanticValue(text) : undefined; }
|
|
314
|
+
function safeId(value) { return String(value ?? 'unknown').replace(/[^a-zA-Z0-9]+/g, '_').replace(/^_+|_+$/g, '') || 'file'; }
|
|
315
|
+
function dirname(path) { const text = String(path ?? ''); const slash = text.lastIndexOf('/'); return slash === -1 ? '' : text.slice(0, slash); }
|
|
316
|
+
function nonEmptyArray(value) { return Array.isArray(value) && value.length ? value : undefined; }
|
|
317
|
+
function uniqueStrings(values) { return [...new Set(values.filter((value) => typeof value === 'string' && value.length > 0))]; }
|
|
318
|
+
|
|
319
|
+
export { applyProjectSymbolRenameClassifications, blockedProjectSymbolRenameFile, classifyProjectSymbolRenames };
|