@shapeshift-labs/frontier-lang-compiler 0.2.149 → 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-patch-bundle-composition.d.ts +62 -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 +32 -0
- package/dist/index.js +6 -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/semanticPatchBundleComposition.js +166 -0
- 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-context.js +1 -0
- package/dist/js-ts-safe-merge-jsx-attribute-fallback.js +314 -0
- 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-plan.js +3 -1
- package/dist/js-ts-safe-merge-semantic-edit-fallback.js +49 -0
- package/dist/js-ts-safe-merge-source-shape-fallbacks.js +5 -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 +171 -172
- 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
|
@@ -1,14 +1,34 @@
|
|
|
1
|
+
import { hashSemanticValue } from '@shapeshift-labs/frontier-lang-kernel';
|
|
1
2
|
import { JsTsSafeMergeConflictCodes, identifierRegExp } from './js-ts-safe-merge-constants.js';
|
|
2
3
|
|
|
3
4
|
export function classifyStatement(text, start, end) {
|
|
5
|
+
const directiveInfo = parseDirectiveInfo(text);
|
|
6
|
+
const textHash = hashSemanticValue(text);
|
|
7
|
+
if (directiveInfo) {
|
|
8
|
+
const key = directiveLedgerKey(directiveInfo);
|
|
9
|
+
return {
|
|
10
|
+
kind: 'directive',
|
|
11
|
+
key,
|
|
12
|
+
text,
|
|
13
|
+
start,
|
|
14
|
+
end,
|
|
15
|
+
textHash,
|
|
16
|
+
ownershipAnchor: topLevelStatementOwnershipAnchor({ kind: 'directive', key, textHash, start, end, directiveInfo }),
|
|
17
|
+
directiveInfo,
|
|
18
|
+
names: []
|
|
19
|
+
};
|
|
20
|
+
}
|
|
4
21
|
const importInfo = parseImportInfo(text);
|
|
5
22
|
if (importInfo) {
|
|
23
|
+
const key = importLedgerKey(importInfo);
|
|
6
24
|
return {
|
|
7
25
|
kind: 'import',
|
|
8
|
-
key
|
|
26
|
+
key,
|
|
9
27
|
text,
|
|
10
28
|
start,
|
|
11
29
|
end,
|
|
30
|
+
textHash,
|
|
31
|
+
ownershipAnchor: topLevelStatementOwnershipAnchor({ kind: 'import', key, textHash, start, end }),
|
|
12
32
|
importInfo,
|
|
13
33
|
names: importInfo.specifiers.map((specifier) => specifier.localName).filter(Boolean)
|
|
14
34
|
};
|
|
@@ -17,12 +37,15 @@ export function classifyStatement(text, start, end) {
|
|
|
17
37
|
if (declarationInfo) {
|
|
18
38
|
const unsupported = unsupportedDeclarationPolicy(text, declarationInfo);
|
|
19
39
|
if (unsupported) return { unsupported, text, start, end };
|
|
40
|
+
const key = declarationLedgerKey(declarationInfo);
|
|
20
41
|
return {
|
|
21
42
|
kind: declarationInfo.kind,
|
|
22
|
-
key
|
|
43
|
+
key,
|
|
23
44
|
text,
|
|
24
45
|
start,
|
|
25
46
|
end,
|
|
47
|
+
textHash,
|
|
48
|
+
ownershipAnchor: topLevelStatementOwnershipAnchor({ kind: declarationInfo.kind, key, textHash, start, end }),
|
|
26
49
|
declarationInfo,
|
|
27
50
|
names: declarationInfo.names
|
|
28
51
|
};
|
|
@@ -30,6 +53,17 @@ export function classifyStatement(text, start, end) {
|
|
|
30
53
|
return undefined;
|
|
31
54
|
}
|
|
32
55
|
|
|
56
|
+
function parseDirectiveInfo(text) {
|
|
57
|
+
const trimmed = text.trim();
|
|
58
|
+
const match = trimmed.match(/^(['"])(use\s+(?:strict|client|server))\1\s*;?$/);
|
|
59
|
+
if (!match) return undefined;
|
|
60
|
+
return { kind: 'runtime-directive', value: match[2], quote: match[1] };
|
|
61
|
+
}
|
|
62
|
+
|
|
63
|
+
function directiveLedgerKey(directiveInfo) {
|
|
64
|
+
return ['directive', directiveInfo.kind, directiveInfo.value].join(':');
|
|
65
|
+
}
|
|
66
|
+
|
|
33
67
|
function parseImportInfo(text) {
|
|
34
68
|
const trimmed = text.trim();
|
|
35
69
|
const sideEffect = trimmed.match(/^import\s+(['"])([^'"]+)\1\s*;?$/s);
|
|
@@ -271,6 +305,16 @@ function importLedgerKey(importInfo) {
|
|
|
271
305
|
].join(':');
|
|
272
306
|
}
|
|
273
307
|
|
|
308
|
+
function topLevelStatementOwnershipAnchor(input) {
|
|
309
|
+
const identityAnchor = input.kind === 'directive' && input.directiveInfo?.kind === 'runtime-directive' ? 'runtime-directive-prologue' : input.key;
|
|
310
|
+
return {
|
|
311
|
+
schema: 'frontier.lang.jsTsTopLevelStatementOwnershipAnchor.v1', version: 1, mode: 'top-level-ledger-entry',
|
|
312
|
+
key: ['js-ts-top-level', input.kind, identityAnchor].join('#'), identityAnchor, statementKind: input.kind,
|
|
313
|
+
start: input.start, end: input.end, textHash: input.textHash, losslessCst: false,
|
|
314
|
+
parserEvidence: 'frontier-js-ts-narrow-top-level-ledger', reasonCodes: ['top-level-ledger-statement-boundary', 'lossless-cst-unavailable']
|
|
315
|
+
};
|
|
316
|
+
}
|
|
317
|
+
|
|
274
318
|
export function importSpecifierCanonical(specifier) {
|
|
275
319
|
return `${specifier.typeOnly ? 'type ' : ''}${specifier.importedName}${specifier.localName === specifier.importedName ? '' : ` as ${specifier.localName}`}`;
|
|
276
320
|
}
|
|
@@ -3,6 +3,10 @@ export function skipTopLevelTrivia(sourceText, offset) {
|
|
|
3
3
|
while (index < sourceText.length) {
|
|
4
4
|
const char = sourceText[index];
|
|
5
5
|
const next = sourceText[index + 1];
|
|
6
|
+
if (char === '#' && next === '!' && isHashbangAtFileStart(sourceText, index)) {
|
|
7
|
+
index = consumeLineComment(sourceText, index + 2);
|
|
8
|
+
continue;
|
|
9
|
+
}
|
|
6
10
|
if (/\s/.test(char)) {
|
|
7
11
|
index += 1;
|
|
8
12
|
continue;
|
|
@@ -22,6 +26,10 @@ export function skipTopLevelTrivia(sourceText, offset) {
|
|
|
22
26
|
return { offset: index };
|
|
23
27
|
}
|
|
24
28
|
|
|
29
|
+
function isHashbangAtFileStart(sourceText, offset) {
|
|
30
|
+
return offset === 0 || (offset === 1 && sourceText.charCodeAt(0) === 0xfeff);
|
|
31
|
+
}
|
|
32
|
+
|
|
25
33
|
function consumeLineComment(sourceText, offset) {
|
|
26
34
|
const lineEnd = sourceText.indexOf('\n', offset);
|
|
27
35
|
return lineEnd === -1 ? sourceText.length : lineEnd + 1;
|
|
@@ -225,11 +225,13 @@ function renderImportStatement(importInfo, specifiers) {
|
|
|
225
225
|
const clause = [];
|
|
226
226
|
if (importInfo.defaultLocalName) clause.push(importInfo.defaultLocalName);
|
|
227
227
|
if (importInfo.namespaceLocalName) clause.push(`* as ${importInfo.namespaceLocalName}`);
|
|
228
|
-
if (specifiers.length) clause.push(`{ ${specifiers.map(
|
|
228
|
+
if (specifiers.length) clause.push(`{ ${specifiers.map((specifier) => renderImportSpecifier(specifier, importInfo)).join(', ')} }`);
|
|
229
229
|
const importType = importInfo.typeOnly ? 'type ' : '';
|
|
230
230
|
return `import ${importType}${clause.join(', ')} from ${importInfo.quote}${importInfo.moduleSpecifier}${importInfo.quote};`;
|
|
231
231
|
}
|
|
232
232
|
|
|
233
|
+
const renderImportSpecifier = (specifier, importInfo) => importSpecifierCanonical(importInfo.typeOnly ? { ...specifier, typeOnly: false } : specifier);
|
|
234
|
+
|
|
233
235
|
function importInsertionText(entries, lineEnding) {
|
|
234
236
|
return entries
|
|
235
237
|
.map((entry) => normalizeLineEndings(entry.text.trimEnd(), lineEnding))
|
|
@@ -1,3 +1,4 @@
|
|
|
1
|
+
import { hashSemanticValue } from '@shapeshift-labs/frontier-lang-kernel';
|
|
1
2
|
import { createSemanticEditScript } from './internal/index-impl/semanticEditScripts.js';
|
|
2
3
|
import { projectSemanticEditScriptToSource } from './internal/index-impl/projectSemanticEditScriptToSource.js';
|
|
3
4
|
import { replaySemanticEditProjection } from './internal/index-impl/replaySemanticEditProjection.js';
|
|
@@ -28,6 +29,14 @@ function semanticEditFallbackResult(input, topLevelResult) {
|
|
|
28
29
|
if (independentDeletionResult) return independentDeletionResult;
|
|
29
30
|
const topLevelRenameAdmission = analyzeTopLevelRenameAdmission(input, topLevelResult);
|
|
30
31
|
if (topLevelRenameAdmission?.status === 'blocked') {
|
|
32
|
+
if (shouldDeferTopLevelRenamePublicContract(input, topLevelRenameAdmission)) {
|
|
33
|
+
const deferredAdmission = deferredTopLevelRenameAdmission(topLevelRenameAdmission);
|
|
34
|
+
const artifacts = createSemanticEditFallbackArtifacts(input, topLevelResult);
|
|
35
|
+
if (artifacts.status !== 'verified') {
|
|
36
|
+
return semanticEditFallbackBlockedResult(input, topLevelResult, artifacts, deferredAdmission);
|
|
37
|
+
}
|
|
38
|
+
return semanticEditFallbackMergedResult(input, topLevelResult, undefined, artifacts, deferredAdmission);
|
|
39
|
+
}
|
|
31
40
|
return topLevelRenameBlockedResult(input, topLevelResult, topLevelRenameAdmission);
|
|
32
41
|
}
|
|
33
42
|
if (topLevelRenameAdmission?.status === 'candidate') {
|
|
@@ -142,6 +151,9 @@ function createSemanticEditFallbackArtifacts(input, topLevelResult, stagedFallba
|
|
|
142
151
|
projection,
|
|
143
152
|
currentSourceText: replayCurrentSourceText,
|
|
144
153
|
currentSourcePath: sourcePath,
|
|
154
|
+
currentSourceHash: typeof replayCurrentSourceText === 'string' ? hashSemanticValue(replayCurrentSourceText) : undefined,
|
|
155
|
+
expectedOutputSourceText: projection.sourceText,
|
|
156
|
+
expectedOutputHash: projection.projectedHash,
|
|
145
157
|
language,
|
|
146
158
|
parser: input.parser,
|
|
147
159
|
metadata: stagedFallback?.metadata
|
|
@@ -215,4 +227,41 @@ function semanticEditFallbackBlockedResult(input, topLevelResult, artifacts) {
|
|
|
215
227
|
};
|
|
216
228
|
}
|
|
217
229
|
|
|
230
|
+
function shouldDeferTopLevelRenamePublicContract(input, admission) {
|
|
231
|
+
if (input.deferTopLevelRenamePublicExportContractToProjectGraph !== true
|
|
232
|
+
|| admission.reasonCodes?.length !== 1
|
|
233
|
+
|| !admission.reasonCodes.includes('top-level-rename-public-export-contract')) {
|
|
234
|
+
return false;
|
|
235
|
+
}
|
|
236
|
+
if (admission.summary?.exported === true) {
|
|
237
|
+
return input.deferDirectExportRenamePublicContractToProjectSymbolRename === true;
|
|
238
|
+
}
|
|
239
|
+
return workerPreservesRenamedExportAlias(input.workerSourceText, admission.summary);
|
|
240
|
+
}
|
|
241
|
+
|
|
242
|
+
function deferredTopLevelRenameAdmission(admission) {
|
|
243
|
+
return {
|
|
244
|
+
...admission,
|
|
245
|
+
status: 'candidate',
|
|
246
|
+
reasonCodes: ['top-level-rename-public-export-contract-deferred-to-project-graph'],
|
|
247
|
+
summary: {
|
|
248
|
+
...admission.summary,
|
|
249
|
+
deferredToProjectGraph: true,
|
|
250
|
+
reasonCodes: ['top-level-rename-public-export-contract-deferred-to-project-graph']
|
|
251
|
+
}
|
|
252
|
+
};
|
|
253
|
+
}
|
|
254
|
+
|
|
255
|
+
function workerPreservesRenamedExportAlias(sourceText, summary) {
|
|
256
|
+
const fromName = summary?.fromName;
|
|
257
|
+
const toName = summary?.toName;
|
|
258
|
+
if (typeof sourceText !== 'string' || !fromName || !toName) return false;
|
|
259
|
+
const exportListPattern = new RegExp(`export\\s*\\{[^}]*\\b${escapeRegExp(toName)}\\s+as\\s+${escapeRegExp(fromName)}\\b[^}]*\\}`);
|
|
260
|
+
return exportListPattern.test(sourceText);
|
|
261
|
+
}
|
|
262
|
+
|
|
263
|
+
function escapeRegExp(value) {
|
|
264
|
+
return String(value).replace(/[.*+?^${}()|[\]\\]/g, '\\$&');
|
|
265
|
+
}
|
|
266
|
+
|
|
218
267
|
export { semanticEditFallbackResult };
|
|
@@ -1,9 +1,13 @@
|
|
|
1
1
|
import { createEnumMemberSemanticFallbackResult } from './js-ts-safe-merge-enum-member-fallback.js';
|
|
2
|
+
import { createJsxAttributeSemanticFallbackResult } from './js-ts-safe-merge-jsx-attribute-fallback.js';
|
|
3
|
+
import { createJsxChildExpressionSemanticFallbackResult } from './js-ts-safe-merge-jsx-child-expression-fallback.js';
|
|
2
4
|
import { createVariableDeclaratorSemanticFallbackResult } from './js-ts-safe-merge-variable-declarator-fallback.js';
|
|
3
5
|
|
|
4
6
|
function createSourceShapeSemanticFallbackResult(input, topLevelResult, stagedFallback) {
|
|
5
7
|
return createVariableDeclaratorSemanticFallbackResult(input, topLevelResult, stagedFallback)
|
|
6
|
-
?? createEnumMemberSemanticFallbackResult(input, topLevelResult, stagedFallback)
|
|
8
|
+
?? createEnumMemberSemanticFallbackResult(input, topLevelResult, stagedFallback)
|
|
9
|
+
?? createJsxAttributeSemanticFallbackResult(input, topLevelResult, stagedFallback)
|
|
10
|
+
?? createJsxChildExpressionSemanticFallbackResult(input, topLevelResult, stagedFallback);
|
|
7
11
|
}
|
|
8
12
|
|
|
9
13
|
export { createSourceShapeSemanticFallbackResult };
|
|
@@ -1,6 +1,7 @@
|
|
|
1
1
|
import { JsTsSafeMergeConflictCodes } from './js-ts-safe-merge-constants.js';
|
|
2
2
|
import { createMergeContext, sameStatementText } from './js-ts-safe-merge-context.js';
|
|
3
3
|
import { scanJsTsTopLevelLedger, validateLedgerUniqueness } from './js-ts-safe-merge-ledger.js';
|
|
4
|
+
import { analyzeTopLevelRenameUseDefEvidence, LexicalUseDefReasonCodes } from './js-ts-semantic-scope-use-def.js';
|
|
4
5
|
import { uniqueStrings } from './native-import-utils.js';
|
|
5
6
|
|
|
6
7
|
const supportedRenameDeclarationKinds = new Set(['function', 'class', 'type']);
|
|
@@ -29,19 +30,42 @@ function analyzeTopLevelRenameAdmission(input, topLevelResult) {
|
|
|
29
30
|
if (!candidate) return undefined;
|
|
30
31
|
|
|
31
32
|
const publicContractReasonCodes = publicContractRenameReasonCodes(base, worker, head, candidate);
|
|
33
|
+
const lexicalUseDefEvidence = analyzeTopLevelRenameUseDefEvidence({
|
|
34
|
+
sourcePath: input.sourcePath,
|
|
35
|
+
baseSourceText: input.baseSourceText,
|
|
36
|
+
workerSourceText: input.workerSourceText,
|
|
37
|
+
headSourceText: input.headSourceText,
|
|
38
|
+
...candidate
|
|
39
|
+
});
|
|
32
40
|
if (publicContractReasonCodes.length) {
|
|
33
41
|
return {
|
|
34
42
|
status: 'blocked',
|
|
35
43
|
reasonCodes: publicContractReasonCodes,
|
|
36
|
-
summary: candidateSummary(candidate, publicContractReasonCodes),
|
|
44
|
+
summary: candidateSummary(candidate, publicContractReasonCodes, lexicalUseDefEvidence),
|
|
37
45
|
ledgers: { base, worker, head }
|
|
38
46
|
};
|
|
39
47
|
}
|
|
40
48
|
|
|
49
|
+
const lexicalBlockerReasonCodes = lexicalUseDefEvidence.reasonCodes
|
|
50
|
+
.filter((code) => code !== LexicalUseDefReasonCodes.noLiveReferences);
|
|
51
|
+
if (lexicalBlockerReasonCodes.length) {
|
|
52
|
+
const reasonCodes = uniqueStrings([...publicContractReasonCodes, ...lexicalBlockerReasonCodes]);
|
|
53
|
+
return {
|
|
54
|
+
status: 'blocked',
|
|
55
|
+
reasonCodes,
|
|
56
|
+
summary: candidateSummary(candidate, reasonCodes, lexicalUseDefEvidence),
|
|
57
|
+
ledgers: { base, worker, head }
|
|
58
|
+
};
|
|
59
|
+
}
|
|
60
|
+
|
|
61
|
+
const candidateReasonCodes = [
|
|
62
|
+
'top-level-rename-source-shape-matches',
|
|
63
|
+
LexicalUseDefReasonCodes.noLiveReferences
|
|
64
|
+
];
|
|
41
65
|
return {
|
|
42
66
|
status: 'candidate',
|
|
43
|
-
reasonCodes:
|
|
44
|
-
summary: candidateSummary(candidate,
|
|
67
|
+
reasonCodes: candidateReasonCodes,
|
|
68
|
+
summary: candidateSummary(candidate, candidateReasonCodes, lexicalUseDefEvidence),
|
|
45
69
|
ledgers: { base, worker, head }
|
|
46
70
|
};
|
|
47
71
|
}
|
|
@@ -79,6 +103,7 @@ function topLevelRenameCandidate(base, worker, head) {
|
|
|
79
103
|
return {
|
|
80
104
|
fromEntry,
|
|
81
105
|
toEntry,
|
|
106
|
+
headEntry: entriesByKey(head.entries).get(fromEntry.key),
|
|
82
107
|
fromName,
|
|
83
108
|
toName,
|
|
84
109
|
declarationKind: fromEntry.declarationInfo.declarationKind
|
|
@@ -124,13 +149,14 @@ function renameDeclarationText(text, declarationKind, fromName, toName) {
|
|
|
124
149
|
return undefined;
|
|
125
150
|
}
|
|
126
151
|
|
|
127
|
-
function candidateSummary(candidate, reasonCodes) {
|
|
152
|
+
function candidateSummary(candidate, reasonCodes, lexicalUseDefEvidence) {
|
|
128
153
|
return {
|
|
129
154
|
fromName: candidate.fromName,
|
|
130
155
|
toName: candidate.toName,
|
|
131
156
|
declarationKind: candidate.declarationKind,
|
|
132
157
|
exported: candidate.fromEntry.declarationInfo?.exported === true || candidate.toEntry.declarationInfo?.exported === true,
|
|
133
|
-
reasonCodes: uniqueStrings(reasonCodes)
|
|
158
|
+
reasonCodes: uniqueStrings(reasonCodes),
|
|
159
|
+
lexicalUseDefEvidence
|
|
134
160
|
};
|
|
135
161
|
}
|
|
136
162
|
|
|
@@ -6,10 +6,15 @@ function topLevelRenameBlockedResult(input, topLevelResult, topLevelRenameAdmiss
|
|
|
6
6
|
...(topLevelResult.admission?.reasonCodes ?? []),
|
|
7
7
|
...(topLevelRenameAdmission.reasonCodes ?? [])
|
|
8
8
|
]);
|
|
9
|
+
const primaryReasonCode = topLevelRenameAdmission.reasonCodes?.[0] ?? JsTsSafeMergeConflictCodes.topLevelRenamePublicExportContract;
|
|
10
|
+
const publicContractBlock = topLevelRenameAdmission.reasonCodes
|
|
11
|
+
?.includes(JsTsSafeMergeConflictCodes.topLevelRenamePublicExportContract);
|
|
9
12
|
const conflict = {
|
|
10
|
-
code: JsTsSafeMergeConflictCodes.topLevelRenamePublicExportContract,
|
|
13
|
+
code: publicContractBlock ? JsTsSafeMergeConflictCodes.topLevelRenamePublicExportContract : primaryReasonCode,
|
|
11
14
|
gateId: JsTsSafeMergeGateIds.stableExistingDeclarations,
|
|
12
|
-
message:
|
|
15
|
+
message: publicContractBlock
|
|
16
|
+
? 'Top-level rename changes a public export contract without project-level evidence.'
|
|
17
|
+
: 'Top-level rename requires lexical use-def evidence before automatic merge.',
|
|
13
18
|
side: 'worker',
|
|
14
19
|
sourcePath: input.sourcePath ?? topLevelResult.sourcePath,
|
|
15
20
|
details: {
|
|
@@ -16,8 +16,13 @@ function createVariableDeclaratorSemanticFallbackResult(input, topLevelResult, s
|
|
|
16
16
|
headSourceText: input.headSourceText,
|
|
17
17
|
currentSourceText
|
|
18
18
|
});
|
|
19
|
-
if (!merge.ok || merge.sourceText === currentSourceText) return undefined;
|
|
20
19
|
const resultBase = stagedFallback?.stagedTopLevelResult ?? topLevelResult;
|
|
20
|
+
if (!merge.ok) {
|
|
21
|
+
return merge.sourceShapeBlocked
|
|
22
|
+
? variableDeclaratorBlockedResult(input, topLevelResult, resultBase, stagedFallback, merge)
|
|
23
|
+
: undefined;
|
|
24
|
+
}
|
|
25
|
+
if (merge.sourceText === currentSourceText) return undefined;
|
|
21
26
|
const language = input.language ?? topLevelResult.language ?? 'typescript';
|
|
22
27
|
const sourcePath = input.sourcePath ?? topLevelResult.sourcePath ?? 'inline.ts';
|
|
23
28
|
const phase = stagedFallback
|
|
@@ -142,17 +147,28 @@ function mergeVariableStatement(base, worker, head, current) {
|
|
|
142
147
|
const workerDeclarator = worker.declarators[index];
|
|
143
148
|
const headDeclarator = head.declarators[index];
|
|
144
149
|
const currentDeclarator = current.declarators[index];
|
|
145
|
-
|
|
146
|
-
|
|
150
|
+
const bindingPatternReasonCodes = classifyDeclaratorBindingPattern(baseDeclarator, workerDeclarator, headDeclarator, currentDeclarator);
|
|
151
|
+
if (bindingPatternReasonCodes.length) return blockedStatement(...bindingPatternReasonCodes);
|
|
152
|
+
if (![workerDeclarator, headDeclarator, currentDeclarator].every((entry) => entry?.key === baseDeclarator.key)) {
|
|
153
|
+
return blockedStatement(
|
|
154
|
+
...declaratorKeyChangeReasonCodes(baseDeclarator, workerDeclarator, headDeclarator, currentDeclarator),
|
|
155
|
+
'variable-declarator-name-order-changed'
|
|
156
|
+
);
|
|
147
157
|
}
|
|
148
158
|
const workerChanged = !sameVariableDeclaratorText(baseDeclarator.text, workerDeclarator.text);
|
|
149
159
|
const headChanged = !sameVariableDeclaratorText(baseDeclarator.text, headDeclarator.text);
|
|
150
160
|
if (workerChanged && headChanged && !sameVariableDeclaratorText(workerDeclarator.text, headDeclarator.text)) {
|
|
151
|
-
return blockedStatement(
|
|
161
|
+
return blockedStatement(
|
|
162
|
+
...bindingDeclaratorConflictReasonCodes(baseDeclarator),
|
|
163
|
+
'variable-declarator-conflict'
|
|
164
|
+
);
|
|
152
165
|
}
|
|
153
166
|
if (!sameVariableDeclaratorText(currentDeclarator.text, headDeclarator.text)
|
|
154
167
|
&& !sameVariableDeclaratorText(currentDeclarator.text, workerDeclarator.text)) {
|
|
155
|
-
return blockedStatement(
|
|
168
|
+
return blockedStatement(
|
|
169
|
+
...bindingDeclaratorConflictReasonCodes(baseDeclarator),
|
|
170
|
+
'variable-declarator-current-diverged'
|
|
171
|
+
);
|
|
156
172
|
}
|
|
157
173
|
const replacement = workerChanged ? workerDeclarator.text : currentDeclarator.text;
|
|
158
174
|
if (!sameVariableDeclaratorText(replacement, currentDeclarator.text)) changed = true;
|
|
@@ -164,6 +180,46 @@ function mergeVariableStatement(base, worker, head, current) {
|
|
|
164
180
|
};
|
|
165
181
|
}
|
|
166
182
|
|
|
183
|
+
function classifyDeclaratorBindingPattern(base, worker, head, current) {
|
|
184
|
+
const declarators = [base, worker, head, current].filter(Boolean);
|
|
185
|
+
if (!declarators.some((entry) => entry.binding?.kind === 'binding-pattern')) return [];
|
|
186
|
+
const reasonCodes = uniqueStrings(declarators.flatMap((entry) => entry.binding?.reasonCodes ?? []));
|
|
187
|
+
if (reasonCodes.length) return reasonCodes;
|
|
188
|
+
if (!declarators.every((entry) => entry.binding?.kind === base.binding?.kind && entry.binding?.patternKind === base.binding?.patternKind)) {
|
|
189
|
+
return [
|
|
190
|
+
'binding-pattern-kind-changed',
|
|
191
|
+
'binding-pattern-merge-requires-binding-use-evidence'
|
|
192
|
+
];
|
|
193
|
+
}
|
|
194
|
+
const patternTexts = declarators.map((entry) => entry.binding?.patternText);
|
|
195
|
+
if (patternTexts.some((text) => !sameVariableDeclaratorText(text, patternTexts[0]))) {
|
|
196
|
+
return [
|
|
197
|
+
'binding-pattern-shape-changed',
|
|
198
|
+
'binding-pattern-merge-requires-binding-use-evidence'
|
|
199
|
+
];
|
|
200
|
+
}
|
|
201
|
+
const bindingNames = declarators.map((entry) => (entry.binding?.bindingNames ?? []).join('\0'));
|
|
202
|
+
if (bindingNames.some((names) => names !== bindingNames[0])) {
|
|
203
|
+
return [
|
|
204
|
+
'binding-pattern-binding-set-changed',
|
|
205
|
+
'binding-pattern-merge-requires-binding-use-evidence'
|
|
206
|
+
];
|
|
207
|
+
}
|
|
208
|
+
return [];
|
|
209
|
+
}
|
|
210
|
+
|
|
211
|
+
function declaratorKeyChangeReasonCodes(base, worker, head, current) {
|
|
212
|
+
return [base, worker, head, current].some((entry) => entry?.binding?.kind === 'binding-pattern')
|
|
213
|
+
? ['binding-pattern-kind-changed', 'binding-pattern-merge-requires-binding-use-evidence']
|
|
214
|
+
: [];
|
|
215
|
+
}
|
|
216
|
+
|
|
217
|
+
function bindingDeclaratorConflictReasonCodes(base) {
|
|
218
|
+
return base?.binding?.kind === 'binding-pattern'
|
|
219
|
+
? ['binding-pattern-merge-requires-binding-use-evidence']
|
|
220
|
+
: [];
|
|
221
|
+
}
|
|
222
|
+
|
|
167
223
|
function semanticArtifactGates(artifacts) {
|
|
168
224
|
return [
|
|
169
225
|
gate('semantic-edit-script', artifacts.script?.admission?.status === 'auto-merge-candidate', artifacts.script?.admission?.reasonCodes),
|
|
@@ -177,8 +233,70 @@ function gate(id, passed, reasonCodes = []) {
|
|
|
177
233
|
return { id, status: passed ? 'passed' : 'blocked', reasonCodes: passed ? [] : uniqueStrings(reasonCodes) };
|
|
178
234
|
}
|
|
179
235
|
|
|
236
|
+
function variableDeclaratorBlockedResult(input, topLevelResult, resultBase, stagedFallback, merge) {
|
|
237
|
+
const reasonCodes = merge.reasonCodes;
|
|
238
|
+
const language = input.language ?? topLevelResult.language ?? 'typescript';
|
|
239
|
+
const sourcePath = input.sourcePath ?? topLevelResult.sourcePath ?? 'inline.ts';
|
|
240
|
+
return {
|
|
241
|
+
...resultBase,
|
|
242
|
+
id: String(input.id ?? resultBase.id ?? topLevelResult.id),
|
|
243
|
+
status: JsTsSafeMergeStatuses.blocked,
|
|
244
|
+
mergedSourceText: undefined,
|
|
245
|
+
outputSourceText: undefined,
|
|
246
|
+
conflicts: [{
|
|
247
|
+
code: reasonCodes[0] ?? 'binding-pattern-merge-blocked',
|
|
248
|
+
gateId: 'variable-declarator-binding-pattern',
|
|
249
|
+
message: 'JS/TS variable declarator binding pattern requires binding/use evidence before automatic merge.',
|
|
250
|
+
side: 'worker',
|
|
251
|
+
sourcePath,
|
|
252
|
+
details: {
|
|
253
|
+
reasonCodes,
|
|
254
|
+
originalReasonCodes: topLevelResult.admission?.reasonCodes ?? []
|
|
255
|
+
}
|
|
256
|
+
}],
|
|
257
|
+
admission: {
|
|
258
|
+
status: 'blocked',
|
|
259
|
+
action: 'human-review',
|
|
260
|
+
reviewRequired: true,
|
|
261
|
+
autoApplyCandidate: false,
|
|
262
|
+
autoMergeClaim: false,
|
|
263
|
+
semanticEquivalenceClaim: false,
|
|
264
|
+
reasonCodes
|
|
265
|
+
},
|
|
266
|
+
summary: {
|
|
267
|
+
...resultBase.summary,
|
|
268
|
+
changedExistingDeclarations: semanticFallbackChangedExistingDeclarations(topLevelResult, resultBase, stagedFallback),
|
|
269
|
+
conflicts: 1,
|
|
270
|
+
variableDeclaratorBindingPatternBlocks: 1,
|
|
271
|
+
composedPhases: stagedFallback ? 2 : 1
|
|
272
|
+
},
|
|
273
|
+
metadata: {
|
|
274
|
+
...resultBase.metadata,
|
|
275
|
+
composed: {
|
|
276
|
+
phase: stagedFallback
|
|
277
|
+
? 'staged-top-level-variable-declarator-binding-pattern-classification'
|
|
278
|
+
: 'variable-declarator-binding-pattern-classification',
|
|
279
|
+
phases: stagedFallback
|
|
280
|
+
? ['top-level-neutralization', 'top-level-ledger', 'variable-declarator-binding-pattern']
|
|
281
|
+
: ['top-level-ledger', 'variable-declarator-binding-pattern'],
|
|
282
|
+
originalReasonCodes: topLevelResult.admission?.reasonCodes ?? [],
|
|
283
|
+
stagedTopLevelSummary: stagedFallback?.stagedTopLevelResult?.summary,
|
|
284
|
+
neutralization: stagedFallback?.neutralization?.summary,
|
|
285
|
+
variableDeclaratorFallback: merge.summary,
|
|
286
|
+
language
|
|
287
|
+
}
|
|
288
|
+
}
|
|
289
|
+
};
|
|
290
|
+
}
|
|
291
|
+
|
|
180
292
|
function blocked(...reasonCodes) {
|
|
181
|
-
|
|
293
|
+
const normalized = uniqueStrings(reasonCodes);
|
|
294
|
+
return {
|
|
295
|
+
ok: false,
|
|
296
|
+
reasonCodes: normalized,
|
|
297
|
+
sourceShapeBlocked: normalized.some((reasonCode) => reasonCode.startsWith('binding-pattern-')),
|
|
298
|
+
summary: { reasonCodes: normalized }
|
|
299
|
+
};
|
|
182
300
|
}
|
|
183
301
|
|
|
184
302
|
function blockedStatement(...reasonCodes) {
|
|
@@ -1,3 +1,7 @@
|
|
|
1
|
+
import {
|
|
2
|
+
analyzeJsTsBindingPattern,
|
|
3
|
+
leadingJsTsBindingPatternText
|
|
4
|
+
} from './js-ts-safe-merge-binding-patterns.js';
|
|
1
5
|
import { normalizeLineEndings, uniqueStrings } from './js-ts-safe-merge-context.js';
|
|
2
6
|
|
|
3
7
|
function variableStatementsByKey(sourceText) {
|
|
@@ -27,14 +31,14 @@ function parseVariableStatement(statement) {
|
|
|
27
31
|
const declaratorText = text.slice(prefixEnd, suffixStart);
|
|
28
32
|
if (/[\r\n]/.test(declaratorText)) return undefined;
|
|
29
33
|
const declarators = splitDeclarators(declaratorText, prefixEnd);
|
|
30
|
-
if (declarators.length < 2 || declarators.some((entry) => !entry.
|
|
34
|
+
if (declarators.length < 2 || declarators.some((entry) => !entry.key)) return undefined;
|
|
31
35
|
return {
|
|
32
36
|
start: statement.start,
|
|
33
37
|
end: statement.end,
|
|
34
38
|
text,
|
|
35
39
|
prefix: text.slice(0, prefixEnd),
|
|
36
40
|
suffix: text.slice(suffixStart),
|
|
37
|
-
names: declarators.map((entry) => entry.
|
|
41
|
+
names: declarators.map((entry) => entry.key),
|
|
38
42
|
declarators
|
|
39
43
|
};
|
|
40
44
|
}
|
|
@@ -104,15 +108,41 @@ function declaratorPart(text, start, end, offset) {
|
|
|
104
108
|
while (localStart < localEnd && /\s/u.test(text[localStart])) localStart += 1;
|
|
105
109
|
while (localEnd > localStart && /\s/u.test(text[localEnd - 1])) localEnd -= 1;
|
|
106
110
|
const value = text.slice(localStart, localEnd);
|
|
107
|
-
const
|
|
111
|
+
const binding = declaratorBinding(value);
|
|
108
112
|
return {
|
|
109
|
-
name: name
|
|
113
|
+
name: binding?.name,
|
|
114
|
+
key: binding?.key,
|
|
115
|
+
binding,
|
|
110
116
|
text: value,
|
|
111
117
|
start: offset + localStart,
|
|
112
118
|
end: offset + localEnd
|
|
113
119
|
};
|
|
114
120
|
}
|
|
115
121
|
|
|
122
|
+
function declaratorBinding(value) {
|
|
123
|
+
const identifier = /^[A-Za-z_$][\w$]*/u.exec(value)?.[0];
|
|
124
|
+
if (identifier && value[identifier.length] !== '?') {
|
|
125
|
+
return { kind: 'identifier', patternKind: 'identifier', name: identifier, key: identifier, reasonCodes: [] };
|
|
126
|
+
}
|
|
127
|
+
let start = 0;
|
|
128
|
+
while (start < value.length && /\s/u.test(value[start])) start += 1;
|
|
129
|
+
const open = value[start];
|
|
130
|
+
if (open !== '{' && open !== '[') return undefined;
|
|
131
|
+
const patternKind = open === '{' ? 'object' : 'array';
|
|
132
|
+
const patternText = leadingJsTsBindingPatternText(value.slice(start), patternKind);
|
|
133
|
+
if (!patternText) return undefined;
|
|
134
|
+
const pattern = analyzeJsTsBindingPattern(patternText, patternKind);
|
|
135
|
+
return {
|
|
136
|
+
kind: 'binding-pattern',
|
|
137
|
+
patternKind: pattern.patternKind,
|
|
138
|
+
name: `binding-pattern:${pattern.patternKind}`,
|
|
139
|
+
key: `binding-pattern:${pattern.patternKind}`,
|
|
140
|
+
patternText,
|
|
141
|
+
bindingNames: pattern.bindingNames,
|
|
142
|
+
reasonCodes: pattern.reasonCodes
|
|
143
|
+
};
|
|
144
|
+
}
|
|
145
|
+
|
|
116
146
|
function topLevelStatements(sourceText) {
|
|
117
147
|
const statements = [];
|
|
118
148
|
let start = 0;
|