mirror of
https://github.com/morluto/rea.git
synced 2026-12-03 21:46:01 +00:00
refactor(javascript): share built-in graph relation resolution (#15881)
This commit is contained in:
1 parent
0ca5e5733e
commit
f8767e9b71
5 files changed
+15
-47
No files matched your search
@@ -225,11 +225,7 @@ const projectTimerCancellation = (
|
||||
timerNodes: ReadonlyMap<string, JavaScriptSemanticGraphNode>,
|
||||
): void => {
|
||||
const callSite = context.callSiteAt(operation.location);
|
||||
const authority = builtinSemanticRelation(
|
||||
context.file,
|
||||
operation,
|
||||
operation.resolution === "complete" ? "resolved" : "candidate",
|
||||
);
|
||||
const authority = builtinSemanticRelation(context.file, operation);
|
||||
const candidateEvidence = authority.evidence;
|
||||
const target =
|
||||
operation.linkedTimerId === null
|
||||
|
||||
@@ -81,11 +81,7 @@ const projectSpawn = (
|
||||
child: JavaScriptSemanticGraphNode,
|
||||
): void => {
|
||||
const callSite = context.callSiteAt(spawn.location);
|
||||
const authority = builtinSemanticRelation(
|
||||
context.file,
|
||||
spawn,
|
||||
spawn.resolution === "complete" ? "resolved" : "candidate",
|
||||
);
|
||||
const authority = builtinSemanticRelation(context.file, spawn);
|
||||
const candidateEvidence = authority.evidence;
|
||||
addSemanticGraphRelation(context.state, {
|
||||
source: callSite,
|
||||
@@ -188,11 +184,7 @@ const projectInteraction = (
|
||||
interaction: JavaScriptSemanticChildProcessInteraction,
|
||||
processNodes: ReadonlyMap<string, JavaScriptSemanticGraphNode>,
|
||||
): void => {
|
||||
const authority = builtinSemanticRelation(
|
||||
context.file,
|
||||
interaction,
|
||||
interaction.resolution === "complete" ? "resolved" : "candidate",
|
||||
);
|
||||
const authority = builtinSemanticRelation(context.file, interaction);
|
||||
const candidateEvidence = authority.evidence;
|
||||
const children = interaction.linkedProcessIds.flatMap((identifier) => {
|
||||
const child = processNodes.get(identifier);
|
||||
|
||||
@@ -43,22 +43,14 @@ export const projectSemanticConfiguration = (
|
||||
source: config,
|
||||
target,
|
||||
relation: configurationRelation(operation),
|
||||
...builtinSemanticRelation(
|
||||
context.file,
|
||||
operation,
|
||||
operation.resolution === "complete" ? "resolved" : "candidate",
|
||||
),
|
||||
...builtinSemanticRelation(context.file, operation),
|
||||
});
|
||||
if (operation.kind === "default" && operation.sourceConfigId !== null)
|
||||
addSemanticGraphRelation(context.state, {
|
||||
source: configNodes.get(operation.sourceConfigId),
|
||||
target: config,
|
||||
relation: "overrides",
|
||||
...builtinSemanticRelation(
|
||||
context.file,
|
||||
operation,
|
||||
operation.resolution === "complete" ? "resolved" : "candidate",
|
||||
),
|
||||
...builtinSemanticRelation(context.file, operation),
|
||||
});
|
||||
if (operation.resolution !== "complete")
|
||||
addDataUnknown({
|
||||
@@ -187,11 +179,7 @@ const projectRequestConstruction = (
|
||||
request: JavaScriptSemanticGraphNode,
|
||||
): void => {
|
||||
const callSite = context.callSiteAt(operation.location);
|
||||
const authority = builtinSemanticRelation(
|
||||
context.file,
|
||||
operation,
|
||||
operation.resolution === "complete" ? "resolved" : "candidate",
|
||||
);
|
||||
const authority = builtinSemanticRelation(context.file, operation);
|
||||
addSemanticGraphRelation(context.state, {
|
||||
source: callSite,
|
||||
target: request,
|
||||
@@ -227,11 +215,7 @@ const projectResponseConsumer = (
|
||||
response: JavaScriptSemanticGraphNode,
|
||||
requestNodes: ReadonlyMap<string, JavaScriptSemanticGraphNode>,
|
||||
): void => {
|
||||
const authority = builtinSemanticRelation(
|
||||
context.file,
|
||||
operation,
|
||||
operation.resolution === "complete" ? "resolved" : "candidate",
|
||||
);
|
||||
const authority = builtinSemanticRelation(context.file, operation);
|
||||
const evidence =
|
||||
authority.evidence ??
|
||||
inferredSemanticEvidenceAt(context.file, operation.location);
|
||||
|
||||
@@ -147,8 +147,12 @@ export const builtinSemanticNode = (
|
||||
/** Keep conditional built-in authority and relation resolution together. */
|
||||
export const builtinSemanticRelation = (
|
||||
file: JavaScriptArtifactFile,
|
||||
operation: SemanticBuiltinOperation,
|
||||
resolution: "resolved" | "candidate",
|
||||
operation: SemanticBuiltinOperation & {
|
||||
readonly resolution: "complete" | "partial" | "unresolved";
|
||||
},
|
||||
resolution: "resolved" | "candidate" = operation.resolution === "complete"
|
||||
? "resolved"
|
||||
: "candidate",
|
||||
): {
|
||||
readonly resolution: "resolved" | "candidate";
|
||||
readonly evidence?: ApplicationGraphEvidence;
|
||||
|
||||
@@ -31,11 +31,7 @@ export const projectSemanticResources = (
|
||||
source: callSite,
|
||||
target: resource,
|
||||
relation: "acquires",
|
||||
...builtinSemanticRelation(
|
||||
context.file,
|
||||
operation,
|
||||
operation.resolution === "complete" ? "resolved" : "candidate",
|
||||
),
|
||||
...builtinSemanticRelation(context.file, operation),
|
||||
});
|
||||
if (operation.resolution === "partial")
|
||||
addSemanticGraphUnknown(context.state, {
|
||||
@@ -84,11 +80,7 @@ const projectRelease = (
|
||||
source: callSite,
|
||||
target: resource,
|
||||
relation: "releases",
|
||||
...builtinSemanticRelation(
|
||||
context.file,
|
||||
operation,
|
||||
operation.resolution === "complete" ? "resolved" : "candidate",
|
||||
),
|
||||
...builtinSemanticRelation(context.file, operation),
|
||||
});
|
||||
if (operation.resolution === "complete") return;
|
||||
addSemanticGraphUnknown(context.state, {
|
||||
|
||||
Reference in new issue
Block a user