mirror of
https://github.com/morluto/rea
synced 2026-10-26 14:25:49 -04:00
refactor(javascript): own property capture translation
This commit is contained in:
@@ -11,6 +11,7 @@ import { unwrapJavaScriptExpression } from "./javascriptAstValues.js";
|
||||
import {
|
||||
semanticObjectPropertyReferences,
|
||||
semanticArrayPropertyReferences,
|
||||
type JavaScriptSemanticObjectReference,
|
||||
} from "./javascriptSemanticObjectReferences.js";
|
||||
import { SEMANTIC_ALIAS_SELECTION_LIMIT } from "./javascriptSemanticResourceLimits.js";
|
||||
import {
|
||||
@@ -68,6 +69,27 @@ export const semanticShiftCapturedSelections = (
|
||||
return semanticNormalizeCapturedSelections(shifted);
|
||||
};
|
||||
|
||||
/** Record an object/array property selected when a shallow copy was made. */
|
||||
export const semanticCapturedSelectionsAfterPropertyRead = (
|
||||
selections: readonly SemanticCapturedSelection[] | undefined,
|
||||
source: Pick<
|
||||
JavaScriptSemanticObjectReference,
|
||||
"path" | "capturedSelectionAt" | "ownEnumerable"
|
||||
>,
|
||||
): readonly SemanticCapturedSelection[] => [
|
||||
...(semanticShiftCapturedSelections(selections, source.path.length - 1) ??
|
||||
[]),
|
||||
...(source.capturedSelectionAt === undefined
|
||||
? []
|
||||
: [
|
||||
{
|
||||
at: source.capturedSelectionAt,
|
||||
depth: source.path.length,
|
||||
...(source.ownEnumerable ? { ownEnumerable: true as const } : {}),
|
||||
},
|
||||
]),
|
||||
];
|
||||
|
||||
interface ProjectedSource {
|
||||
readonly node: t.Node;
|
||||
readonly path: SemanticAliasSelectionPath;
|
||||
|
||||
Reference in New Issue
Block a user