@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,292 @@
|
|
|
1
|
+
import { hashSemanticValue } from '@shapeshift-labs/frontier-lang-kernel';
|
|
2
|
+
import { idFragment } from './native-import-utils.js';
|
|
3
|
+
|
|
4
|
+
function createParserTriviaExactnessRecord(evidence, context = {}) {
|
|
5
|
+
const declared = isPlainObject(evidence) ? evidence : {};
|
|
6
|
+
const hasDeclaredEvidence = Object.keys(declared).length > 0;
|
|
7
|
+
const parserSpanCoverageProof = isPlainObject(declared.parserSpanCoverageProof)
|
|
8
|
+
? declared.parserSpanCoverageProof
|
|
9
|
+
: isPlainObject(context.parserSpanCoverageProof) ? context.parserSpanCoverageProof : undefined;
|
|
10
|
+
const observedSourceHash = firstString(context.sourceHash, context.sourceId);
|
|
11
|
+
const evidenceSourceHash = firstString(declared.evidenceSourceHash, declared.sourceHash, declared.sourceId, declared.roundtripHash);
|
|
12
|
+
const adapterId = firstString(declared.adapterId, declared.parserAdapterId, declared.parserId, declared.adapter, context.adapterId);
|
|
13
|
+
const evidenceId = firstString(declared.evidenceId, declared.id, context.evidenceId);
|
|
14
|
+
const declaredParserEvidence = firstString(declared.parserEvidence);
|
|
15
|
+
const tokenTriviaParserEvidence = firstString(context.parserTokenTriviaEvidence, context.parserEvidence);
|
|
16
|
+
const declaredScannerEvidence = isLightweightScannerParserEvidence(declaredParserEvidence);
|
|
17
|
+
const tokenTriviaScannerEvidence = isLightweightScannerParserEvidence(tokenTriviaParserEvidence);
|
|
18
|
+
const hasDeclaredParserBackedEvidence = Boolean(adapterId || (declaredParserEvidence && !declaredScannerEvidence));
|
|
19
|
+
const hasParserBackedTokenTriviaEvidence = Boolean(tokenTriviaParserEvidence && !tokenTriviaScannerEvidence);
|
|
20
|
+
const exactClaim = declared.exactParserTrivia === true || declared.exact === true || declared.status === 'exact' || declared.losslessCst === true;
|
|
21
|
+
const declaredBlocked = declared.status === 'blocked' || declared.blocked === true;
|
|
22
|
+
const parserSpanCoverageBlocked = exactClaim && parserSpanCoverageProof && parserSpanCoverageProof.status !== 'exact';
|
|
23
|
+
const blockReasonCodes = declaredBlocked
|
|
24
|
+
? uniqueStrings(declared.blockReasonCodes ?? declared.reasonCodes ?? ['parser-trivia-proof-stale-or-incomplete'])
|
|
25
|
+
: exactClaim ? uniqueStrings([
|
|
26
|
+
evidenceSourceHash ? undefined : 'parser-trivia-source-hash-missing',
|
|
27
|
+
evidenceSourceHash && observedSourceHash && evidenceSourceHash !== observedSourceHash ? 'parser-trivia-source-hash-mismatch' : undefined,
|
|
28
|
+
hasDeclaredParserBackedEvidence ? undefined : 'exact-parser-trivia-parser-evidence-missing',
|
|
29
|
+
hasParserBackedTokenTriviaEvidence ? undefined : 'exact-parser-trivia-token-comment-evidence-missing',
|
|
30
|
+
declaredScannerEvidence || tokenTriviaScannerEvidence ? 'exact-parser-trivia-scanner-evidence-not-parser' : undefined,
|
|
31
|
+
parserSpanCoverageBlocked ? 'exact-parser-trivia-span-coverage-blocked' : undefined,
|
|
32
|
+
context.truncated ? 'source-preservation-truncated' : undefined
|
|
33
|
+
].concat(parserSpanCoverageBlocked ? parserSpanCoverageProof.blockReasonCodes ?? [] : [])) : [];
|
|
34
|
+
const parserSpanCoverageReasonCodes = parserSpanCoverageProof
|
|
35
|
+
? uniqueStrings(parserSpanCoverageProof.reasonCodes ?? [])
|
|
36
|
+
: [];
|
|
37
|
+
const parserSpanCoverageBlockReasonCodes = parserSpanCoverageProof
|
|
38
|
+
? uniqueStrings(parserSpanCoverageProof.blockReasonCodes ?? [])
|
|
39
|
+
: [];
|
|
40
|
+
const status = blockReasonCodes.length ? 'blocked' : exactClaim ? 'exact' : 'approximate';
|
|
41
|
+
const parserEvidence = status === 'exact'
|
|
42
|
+
? firstString(tokenTriviaParserEvidence, declaredParserEvidence, adapterId ? `parser-adapter:${adapterId}` : undefined)
|
|
43
|
+
: firstString(context.parserEvidence, tokenTriviaParserEvidence, declaredParserEvidence, 'frontier-lightweight-lexical-scan');
|
|
44
|
+
const reasonCodes = uniqueStrings([
|
|
45
|
+
status === 'exact' ? 'exact-parser-trivia-evidence' : undefined,
|
|
46
|
+
status === 'approximate' ? 'parser-trivia-proof-approximate' : undefined,
|
|
47
|
+
status === 'approximate' && hasDeclaredEvidence ? 'exact-parser-trivia-evidence-not-claimed' : undefined,
|
|
48
|
+
status === 'approximate' && !hasDeclaredEvidence ? 'exact-parser-trivia-evidence-missing' : undefined,
|
|
49
|
+
status === 'blocked' ? 'parser-trivia-proof-stale-or-incomplete' : undefined,
|
|
50
|
+
status === 'exact' && parserSpanCoverageProof?.status === 'exact' ? 'parser-token-comment-span-coverage-exact' : undefined,
|
|
51
|
+
...blockReasonCodes
|
|
52
|
+
]);
|
|
53
|
+
return compactRecord({
|
|
54
|
+
schema: 'frontier.lang.parserTriviaExactness.v1',
|
|
55
|
+
version: 1,
|
|
56
|
+
status,
|
|
57
|
+
exactParserTrivia: status === 'exact',
|
|
58
|
+
losslessCst: status === 'exact' && declared.losslessCst === true,
|
|
59
|
+
sourcePath: context.sourcePath,
|
|
60
|
+
sourceHash: observedSourceHash,
|
|
61
|
+
evidenceSourceHash,
|
|
62
|
+
sourceHashVerified: evidenceSourceHash && observedSourceHash ? evidenceSourceHash === observedSourceHash : undefined,
|
|
63
|
+
parserEvidence,
|
|
64
|
+
adapterId,
|
|
65
|
+
evidenceId,
|
|
66
|
+
parserSpanCoverageStatus: parserSpanCoverageProof?.status,
|
|
67
|
+
parserSpanCoverageEvidenceId: firstString(parserSpanCoverageProof?.evidenceId, parserSpanCoverageProof?.id),
|
|
68
|
+
parserSpanCoverageReasonCodes,
|
|
69
|
+
parserSpanCoverageBlockReasonCodes,
|
|
70
|
+
reasonCodes,
|
|
71
|
+
blockReasonCodes,
|
|
72
|
+
reviewRequired: status !== 'exact',
|
|
73
|
+
autoMergeClaim: false,
|
|
74
|
+
semanticEquivalenceClaim: false
|
|
75
|
+
});
|
|
76
|
+
}
|
|
77
|
+
|
|
78
|
+
function createParserSpanCoverageProof(input = {}) {
|
|
79
|
+
const sourceTextProvided = typeof input.sourceText === 'string';
|
|
80
|
+
const sourceText = sourceTextProvided ? input.sourceText : '';
|
|
81
|
+
const sourceLength = sourceText.length;
|
|
82
|
+
const parserEvidence = firstString(input.parserEvidence);
|
|
83
|
+
const adapterId = firstString(input.adapterId, input.parserAdapterId, input.parserId, input.adapter);
|
|
84
|
+
const sourceHash = firstString(input.sourceHash, sourceTextProvided ? hashSemanticValue(sourceText) : undefined);
|
|
85
|
+
const segments = arrayValue(input.segments)
|
|
86
|
+
.map(normalizeCoverageSegment)
|
|
87
|
+
.filter(Boolean)
|
|
88
|
+
.sort((left, right) => left.start - right.start || left.end - right.end);
|
|
89
|
+
let cursor = 0;
|
|
90
|
+
let coveredSourceLength = 0;
|
|
91
|
+
let hasGap = false;
|
|
92
|
+
let hasOverlap = false;
|
|
93
|
+
let hasOutOfBounds = false;
|
|
94
|
+
let hasTextMismatch = false;
|
|
95
|
+
for (const segment of segments) {
|
|
96
|
+
if (segment.start < 0 || segment.end > sourceLength || segment.end <= segment.start) hasOutOfBounds = true;
|
|
97
|
+
if (segment.start > cursor) hasGap = true;
|
|
98
|
+
if (segment.start < cursor) hasOverlap = true;
|
|
99
|
+
if (typeof segment.text === 'string' && segment.text !== sourceText.slice(segment.start, segment.end)) {
|
|
100
|
+
hasTextMismatch = true;
|
|
101
|
+
}
|
|
102
|
+
coveredSourceLength += Math.max(0, segment.end - segment.start);
|
|
103
|
+
cursor = Math.max(cursor, segment.end);
|
|
104
|
+
}
|
|
105
|
+
const startsAtZero = sourceLength === 0 || segments[0]?.start === 0;
|
|
106
|
+
const endsAtSourceLength = sourceLength === 0 ? segments.length === 0 || cursor === 0 : cursor === sourceLength;
|
|
107
|
+
const parserEvidenceIsScanner = isLightweightScannerParserEvidence(parserEvidence);
|
|
108
|
+
const blockReasonCodes = uniqueStrings([
|
|
109
|
+
sourceTextProvided ? undefined : 'parser-span-coverage-source-text-missing',
|
|
110
|
+
parserEvidence ? undefined : 'parser-span-coverage-parser-evidence-missing',
|
|
111
|
+
parserEvidenceIsScanner ? 'parser-span-coverage-scanner-evidence-not-parser' : undefined,
|
|
112
|
+
input.truncated ? 'parser-span-coverage-truncated' : undefined,
|
|
113
|
+
sourceLength > 0 && segments.length === 0 ? 'parser-span-coverage-empty' : undefined,
|
|
114
|
+
startsAtZero ? undefined : 'parser-span-coverage-start-missing',
|
|
115
|
+
hasGap ? 'parser-span-coverage-gap' : undefined,
|
|
116
|
+
hasOverlap ? 'parser-span-coverage-overlap' : undefined,
|
|
117
|
+
hasOutOfBounds ? 'parser-span-coverage-out-of-bounds' : undefined,
|
|
118
|
+
endsAtSourceLength ? undefined : 'parser-span-coverage-end-missing',
|
|
119
|
+
hasTextMismatch ? 'parser-span-coverage-text-mismatch' : undefined
|
|
120
|
+
]);
|
|
121
|
+
const status = blockReasonCodes.length ? 'blocked' : 'exact';
|
|
122
|
+
const reasonCodes = uniqueStrings([
|
|
123
|
+
status === 'exact' ? 'parser-token-comment-span-coverage-exact' : undefined,
|
|
124
|
+
status === 'blocked' ? 'parser-token-comment-span-coverage-blocked' : undefined,
|
|
125
|
+
...blockReasonCodes
|
|
126
|
+
]);
|
|
127
|
+
return compactRecord({
|
|
128
|
+
schema: 'frontier.lang.parserSpanCoverageProof.v1',
|
|
129
|
+
version: 1,
|
|
130
|
+
status,
|
|
131
|
+
exactParserSpans: status === 'exact',
|
|
132
|
+
sourcePath: input.sourcePath,
|
|
133
|
+
sourceHash,
|
|
134
|
+
sourceLength: sourceTextProvided ? sourceLength : undefined,
|
|
135
|
+
coveredSourceLength,
|
|
136
|
+
spanCount: segments.length,
|
|
137
|
+
tokenCount: numberOrUndefined(input.tokenCount),
|
|
138
|
+
triviaCount: numberOrUndefined(input.triviaCount),
|
|
139
|
+
commentCount: numberOrUndefined(input.commentCount),
|
|
140
|
+
parserEvidence,
|
|
141
|
+
adapterId,
|
|
142
|
+
evidenceId: firstString(input.evidenceId, adapterId && sourceHash ? `${adapterId}:parser-span-coverage:${idFragment(sourceHash)}` : undefined),
|
|
143
|
+
languageMode: input.languageMode,
|
|
144
|
+
boundedLanguages: uniqueStrings(input.boundedLanguages),
|
|
145
|
+
startsAtZero,
|
|
146
|
+
endsAtSourceLength,
|
|
147
|
+
nonOverlapping: !hasOverlap,
|
|
148
|
+
contiguous: !hasGap && !hasOverlap && startsAtZero && endsAtSourceLength,
|
|
149
|
+
textMatchesSource: !hasTextMismatch,
|
|
150
|
+
reasonCodes,
|
|
151
|
+
blockReasonCodes,
|
|
152
|
+
reviewRequired: status !== 'exact',
|
|
153
|
+
autoMergeClaim: false,
|
|
154
|
+
semanticEquivalenceClaim: false
|
|
155
|
+
});
|
|
156
|
+
}
|
|
157
|
+
|
|
158
|
+
function createPreservedSourceOwnershipAnchor(input = {}) {
|
|
159
|
+
const span = input.span ?? {};
|
|
160
|
+
const text = typeof input.text === 'string' ? input.text : undefined;
|
|
161
|
+
const textHash = input.textHash ?? (text === undefined ? undefined : hashSemanticValue(text));
|
|
162
|
+
const sourceHash = input.sourceHash ?? span.sourceHash ?? span.sourceId;
|
|
163
|
+
const sourcePath = input.sourcePath ?? span.path;
|
|
164
|
+
const start = numberOrUndefined(span.start);
|
|
165
|
+
const end = numberOrUndefined(span.end);
|
|
166
|
+
const anchorKind = input.anchorKind ?? preservedOwnershipAnchorKind(input.kind, input.role);
|
|
167
|
+
const identityAnchor = input.identityAnchor ?? preservedOwnershipIdentityAnchor(input.kind, input.role, anchorKind);
|
|
168
|
+
const parserTriviaExactness = input.parserTriviaExactness ?? createParserTriviaExactnessRecord(input.parserTriviaEvidence, {
|
|
169
|
+
sourcePath,
|
|
170
|
+
sourceHash,
|
|
171
|
+
parserEvidence: input.parserEvidence ?? 'frontier-lightweight-lexical-scan'
|
|
172
|
+
});
|
|
173
|
+
const parserEvidence = parserTriviaExactness.status === 'exact'
|
|
174
|
+
? firstString(parserTriviaExactness.parserEvidence, parserTriviaExactness.adapterId ? `parser-adapter:${parserTriviaExactness.adapterId}` : undefined, input.parserEvidence)
|
|
175
|
+
: firstString(input.parserEvidence, parserTriviaExactness.parserEvidence, 'frontier-lightweight-lexical-scan');
|
|
176
|
+
return compactRecord({
|
|
177
|
+
schema: 'frontier.lang.sourceOwnershipAnchor.v1',
|
|
178
|
+
version: 1,
|
|
179
|
+
mode: 'exact-source-span',
|
|
180
|
+
anchorKind,
|
|
181
|
+
identityAnchor,
|
|
182
|
+
sourcePath,
|
|
183
|
+
sourceHash,
|
|
184
|
+
role: input.role,
|
|
185
|
+
kind: input.kind,
|
|
186
|
+
textHash,
|
|
187
|
+
textLength: text === undefined ? input.textLength : text.length,
|
|
188
|
+
start,
|
|
189
|
+
end,
|
|
190
|
+
startLine: numberOrUndefined(span.startLine),
|
|
191
|
+
startColumn: numberOrUndefined(span.startColumn),
|
|
192
|
+
endLine: numberOrUndefined(span.endLine),
|
|
193
|
+
endColumn: numberOrUndefined(span.endColumn),
|
|
194
|
+
spanHash: hashSemanticValue({
|
|
195
|
+
kind: 'frontier.lang.sourceOwnershipAnchor.span',
|
|
196
|
+
sourcePath,
|
|
197
|
+
sourceHash,
|
|
198
|
+
role: input.role,
|
|
199
|
+
spanKind: input.kind,
|
|
200
|
+
textHash,
|
|
201
|
+
start,
|
|
202
|
+
end
|
|
203
|
+
}),
|
|
204
|
+
losslessCst: parserTriviaExactness.losslessCst === true,
|
|
205
|
+
parserEvidence,
|
|
206
|
+
parserTriviaExactnessStatus: parserTriviaExactness.status,
|
|
207
|
+
exactParserTrivia: parserTriviaExactness.exactParserTrivia,
|
|
208
|
+
parserTriviaEvidenceId: parserTriviaExactness.evidenceId,
|
|
209
|
+
parserTriviaAdapterId: parserTriviaExactness.adapterId,
|
|
210
|
+
parserTriviaExactnessReasonCodes: parserTriviaExactness.reasonCodes,
|
|
211
|
+
parserTriviaExactnessBlockReasonCodes: parserTriviaExactness.blockReasonCodes
|
|
212
|
+
});
|
|
213
|
+
}
|
|
214
|
+
|
|
215
|
+
function preservedSourceSegmentRole(kind) {
|
|
216
|
+
if (isCommentKind(kind) || kind === 'source-map-comment' || kind === 'whitespace' || kind === 'newline' || kind === 'shebang') return 'trivia';
|
|
217
|
+
return 'token';
|
|
218
|
+
}
|
|
219
|
+
|
|
220
|
+
function preservedOwnershipAnchorKind(kind, role) {
|
|
221
|
+
if (kind === 'source-map-comment') return 'generated-source-boundary';
|
|
222
|
+
if (kind === 'shebang') return 'file-entrypoint-directive';
|
|
223
|
+
if (role === 'directive' && kind === 'runtime-directive') return 'directive-prologue';
|
|
224
|
+
if (role === 'directive') return 'source-directive';
|
|
225
|
+
if (role === 'protected') return 'protected-source-span';
|
|
226
|
+
if (kind === 'jsdoc-comment') return 'jsdoc-comment-trivia';
|
|
227
|
+
if (kind === 'block-comment') return 'block-comment-trivia';
|
|
228
|
+
if (kind === 'comment') return 'comment-trivia';
|
|
229
|
+
if (kind === 'whitespace' || kind === 'newline') return 'formatting-trivia';
|
|
230
|
+
return 'lexical-source-span';
|
|
231
|
+
}
|
|
232
|
+
|
|
233
|
+
function preservedOwnershipIdentityAnchor(kind, role, anchorKind) {
|
|
234
|
+
if (role === 'directive' && kind === 'runtime-directive') return 'runtime-directive-prologue';
|
|
235
|
+
if (kind === 'source-map-comment') return 'source-map-comment';
|
|
236
|
+
if (kind === 'jsdoc-comment') return 'jsdoc-comment';
|
|
237
|
+
if (kind === 'block-comment') return 'block-comment';
|
|
238
|
+
if (kind === 'typescript-reference') return 'typescript-reference';
|
|
239
|
+
return anchorKind ?? kind ?? role;
|
|
240
|
+
}
|
|
241
|
+
|
|
242
|
+
function isCommentKind(kind) {
|
|
243
|
+
return kind === 'comment' || kind === 'jsdoc-comment' || kind === 'block-comment';
|
|
244
|
+
}
|
|
245
|
+
|
|
246
|
+
function numberOrUndefined(value) {
|
|
247
|
+
return Number.isFinite(value) ? value : undefined;
|
|
248
|
+
}
|
|
249
|
+
|
|
250
|
+
function firstString(...values) {
|
|
251
|
+
return values.find((value) => typeof value === 'string' && value.length > 0);
|
|
252
|
+
}
|
|
253
|
+
|
|
254
|
+
function isPlainObject(value) {
|
|
255
|
+
return Boolean(value && typeof value === 'object' && !Array.isArray(value));
|
|
256
|
+
}
|
|
257
|
+
|
|
258
|
+
function normalizeCoverageSegment(entry) {
|
|
259
|
+
const span = entry?.span ?? entry;
|
|
260
|
+
const start = numberOrUndefined(span?.start);
|
|
261
|
+
const end = numberOrUndefined(span?.end);
|
|
262
|
+
if (start === undefined || end === undefined) return undefined;
|
|
263
|
+
return {
|
|
264
|
+
start,
|
|
265
|
+
end,
|
|
266
|
+
text: typeof entry?.text === 'string' ? entry.text : undefined
|
|
267
|
+
};
|
|
268
|
+
}
|
|
269
|
+
|
|
270
|
+
function compactRecord(record) {
|
|
271
|
+
return Object.fromEntries(Object.entries(record).filter(([, value]) => value !== undefined));
|
|
272
|
+
}
|
|
273
|
+
|
|
274
|
+
function uniqueStrings(values) {
|
|
275
|
+
return [...new Set((values ?? []).filter((value) => typeof value === 'string' && value.length > 0))];
|
|
276
|
+
}
|
|
277
|
+
|
|
278
|
+
function arrayValue(value) {
|
|
279
|
+
return Array.isArray(value) ? value : [];
|
|
280
|
+
}
|
|
281
|
+
|
|
282
|
+
function isLightweightScannerParserEvidence(value) {
|
|
283
|
+
return value === 'frontier-lightweight-lexical-scan' || value === 'frontier-lightweight-js-ts-source-ledger';
|
|
284
|
+
}
|
|
285
|
+
|
|
286
|
+
export {
|
|
287
|
+
createParserSpanCoverageProof,
|
|
288
|
+
createParserTriviaExactnessRecord,
|
|
289
|
+
createPreservedSourceOwnershipAnchor,
|
|
290
|
+
preservedOwnershipAnchorKind,
|
|
291
|
+
preservedSourceSegmentRole
|
|
292
|
+
};
|
|
@@ -1,6 +1,11 @@
|
|
|
1
1
|
import { hashSemanticValue } from '@shapeshift-labs/frontier-lang-kernel';
|
|
2
2
|
import { idFragment, normalizeNativeLanguageId } from './native-import-utils.js';
|
|
3
3
|
import { sourceLines } from './native-region-scanner-core.js';
|
|
4
|
+
import {
|
|
5
|
+
createPreservedSourceOwnershipAnchor,
|
|
6
|
+
preservedOwnershipAnchorKind,
|
|
7
|
+
preservedSourceSegmentRole
|
|
8
|
+
} from './native-source-preservation-ownership.js';
|
|
4
9
|
|
|
5
10
|
function scanPreservedSourceTokens(sourceText, input) {
|
|
6
11
|
const tokens = [];
|
|
@@ -59,7 +64,7 @@ function scanPreservedSourceTokens(sourceText, input) {
|
|
|
59
64
|
offset += 1;
|
|
60
65
|
column += 1;
|
|
61
66
|
}
|
|
62
|
-
push(trivia,
|
|
67
|
+
push(trivia, preservedCommentKind(text), text, start);
|
|
63
68
|
continue;
|
|
64
69
|
}
|
|
65
70
|
if (char === '/' && next === '*') {
|
|
@@ -81,7 +86,7 @@ function scanPreservedSourceTokens(sourceText, input) {
|
|
|
81
86
|
break;
|
|
82
87
|
}
|
|
83
88
|
}
|
|
84
|
-
push(trivia,
|
|
89
|
+
push(trivia, preservedCommentKind(text), text, start);
|
|
85
90
|
continue;
|
|
86
91
|
}
|
|
87
92
|
if (char === '#' && isHashCommentLanguage(input.language)) {
|
|
@@ -171,21 +176,33 @@ function scanPreservedSourceDirectives(sourceText, input) {
|
|
|
171
176
|
continue;
|
|
172
177
|
}
|
|
173
178
|
const startColumn = Math.max(1, line.indexOf(trimmed) + 1);
|
|
179
|
+
const span = {
|
|
180
|
+
sourceId: input.sourceHash,
|
|
181
|
+
path: input.sourcePath,
|
|
182
|
+
start: offset + startColumn - 1,
|
|
183
|
+
end: offset + startColumn - 1 + trimmed.length,
|
|
184
|
+
startLine: number,
|
|
185
|
+
startColumn,
|
|
186
|
+
endLine: number,
|
|
187
|
+
endColumn: startColumn + trimmed.length
|
|
188
|
+
};
|
|
189
|
+
const textHash = hashSemanticValue(trimmed);
|
|
174
190
|
directives.push({
|
|
175
191
|
id: `directive_${idFragment(input.sourcePath ?? input.language)}_${directives.length + 1}`,
|
|
176
192
|
kind: directiveKind,
|
|
177
193
|
text: trimmed,
|
|
178
|
-
textHash
|
|
179
|
-
span
|
|
180
|
-
|
|
181
|
-
|
|
182
|
-
|
|
183
|
-
|
|
184
|
-
|
|
185
|
-
|
|
186
|
-
|
|
187
|
-
|
|
188
|
-
|
|
194
|
+
textHash,
|
|
195
|
+
span,
|
|
196
|
+
ownershipAnchor: createPreservedSourceOwnershipAnchor({
|
|
197
|
+
kind: directiveKind,
|
|
198
|
+
role: 'directive',
|
|
199
|
+
text: trimmed,
|
|
200
|
+
textHash,
|
|
201
|
+
sourcePath: input.sourcePath,
|
|
202
|
+
sourceHash: input.sourceHash,
|
|
203
|
+
span,
|
|
204
|
+
anchorKind: preservedOwnershipAnchorKind(directiveKind, 'directive')
|
|
205
|
+
}),
|
|
189
206
|
metadata: { language: input.language }
|
|
190
207
|
});
|
|
191
208
|
}
|
|
@@ -196,21 +213,33 @@ function scanPreservedSourceDirectives(sourceText, input) {
|
|
|
196
213
|
|
|
197
214
|
function preservedSourceSegment(input) {
|
|
198
215
|
const id = `${input.kind}_${input.index + 1}_${idFragment(input.start.offset)}`;
|
|
216
|
+
const textHash = hashSemanticValue(input.text);
|
|
217
|
+
const span = {
|
|
218
|
+
sourceId: input.sourceHash,
|
|
219
|
+
path: input.sourcePath,
|
|
220
|
+
start: input.start.offset,
|
|
221
|
+
end: input.end.offset,
|
|
222
|
+
startLine: input.start.line,
|
|
223
|
+
startColumn: input.start.column,
|
|
224
|
+
endLine: input.end.line,
|
|
225
|
+
endColumn: input.end.column
|
|
226
|
+
};
|
|
199
227
|
return {
|
|
200
228
|
id,
|
|
201
229
|
kind: input.kind,
|
|
202
230
|
text: input.text,
|
|
203
|
-
textHash
|
|
204
|
-
span
|
|
205
|
-
|
|
206
|
-
|
|
207
|
-
|
|
208
|
-
|
|
209
|
-
|
|
210
|
-
|
|
211
|
-
|
|
212
|
-
|
|
213
|
-
|
|
231
|
+
textHash,
|
|
232
|
+
span,
|
|
233
|
+
ownershipAnchor: createPreservedSourceOwnershipAnchor({
|
|
234
|
+
kind: input.kind,
|
|
235
|
+
role: preservedSourceSegmentRole(input.kind),
|
|
236
|
+
text: input.text,
|
|
237
|
+
textHash,
|
|
238
|
+
sourcePath: input.sourcePath,
|
|
239
|
+
sourceHash: input.sourceHash,
|
|
240
|
+
span,
|
|
241
|
+
anchorKind: preservedOwnershipAnchorKind(input.kind, preservedSourceSegmentRole(input.kind))
|
|
242
|
+
})
|
|
214
243
|
};
|
|
215
244
|
}
|
|
216
245
|
|
|
@@ -218,12 +247,20 @@ function preservedDirectiveKind(trimmed, language) {
|
|
|
218
247
|
if (!trimmed) return undefined;
|
|
219
248
|
if (/^#\s*(include|define|if|ifdef|ifndef|elif|else|endif|pragma)\b/.test(trimmed)) return 'preprocessor';
|
|
220
249
|
if (/^#!\s*/.test(trimmed)) return 'shebang';
|
|
221
|
-
if (/^['"]use
|
|
250
|
+
if (/^['"]use\s+(?:strict|client|server)['"];?$/.test(trimmed)) return 'runtime-directive';
|
|
222
251
|
if (/^(import|export|package|module|namespace|use|using|from|require)\b/.test(trimmed)) return 'module-directive';
|
|
223
252
|
if (normalizeNativeLanguageId(language) === 'python' && /^from\s+\S+\s+import\b/.test(trimmed)) return 'module-directive';
|
|
224
253
|
return undefined;
|
|
225
254
|
}
|
|
226
255
|
|
|
256
|
+
function preservedCommentKind(text) {
|
|
257
|
+
const value = String(text ?? '');
|
|
258
|
+
if (/[#@]\s*sourceMappingURL=|[#@]\s*sourceURL=/.test(value)) return 'source-map-comment';
|
|
259
|
+
if (value.startsWith('/**') && value[3] !== '/') return 'jsdoc-comment';
|
|
260
|
+
if (value.startsWith('/*')) return 'block-comment';
|
|
261
|
+
return 'comment';
|
|
262
|
+
}
|
|
263
|
+
|
|
227
264
|
function preservedHashLineKind(text) {
|
|
228
265
|
return preservedDirectiveKind(String(text).trim(), 'c') ? 'directive' : 'comment';
|
|
229
266
|
}
|
|
@@ -260,6 +297,7 @@ function isIdentifierPart(char) {
|
|
|
260
297
|
}
|
|
261
298
|
|
|
262
299
|
export {
|
|
300
|
+
createPreservedSourceOwnershipAnchor,
|
|
263
301
|
detectNewlineStyle,
|
|
264
302
|
scanPreservedSourceDirectives,
|
|
265
303
|
scanPreservedSourceTokens
|