MCPcopy
hub / github.com/callumalpass/tasknotes / resolveTaskReferencePath

Method resolveTaskReferencePath

src/api/TaskNotesAPI.ts:2632–2653  ·  view source on GitHub ↗
(
		reference: string,
		sourcePath: string
	)

Source from the content-addressed store, hash-verified

2630 }
2631
2632 private async resolveTaskReferencePath(
2633 reference: string,
2634 sourcePath: string
2635 ): Promise<string | null> {
2636 const linkPath = firstReferencePathCandidate(reference);
2637 if (!linkPath) return null;
2638
2639 type Nullable<T> = T | null;
2640 type MetadataCacheWithLinkResolver = {
2641 getFirstLinkpathDest?: (linkpath: string, sourcePath: string) => Nullable<TFile>;
2642 };
2643 const metadataCache = this.plugin.app.metadataCache as MetadataCacheWithLinkResolver | undefined;
2644 const resolvedFile = metadataCache?.getFirstLinkpathDest?.(linkPath, sourcePath);
2645 if (resolvedFile instanceof TFile) return normalizePath(resolvedFile.path);
2646
2647 for (const candidate of taskReferencePathCandidates(linkPath)) {
2648 const task = await this.plugin.cacheManager.getTaskInfo(candidate);
2649 if (task) return task.path;
2650 }
2651
2652 return normalizePath(linkPath);
2653 }
2654
2655 private async requireTask(path: string): Promise<TaskInfo> {
2656 const normalizedPath = this.normalizeTaskPath(path);

Callers 3

getTaskDependenciesMethod · 0.95
resolveTaskReferenceMethod · 0.95
taskReferenceMatchesMethod · 0.95

Calls 4

normalizePathFunction · 0.90
getTaskInfoMethod · 0.65

Tested by

no test coverage detected