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

Method getProjectReferenceTask

src/views/StatsView.ts:619–653  ·  view source on GitHub ↗
(projectValue: string)

Source from the content-addressed store, hash-verified

617 }
618
619 private getProjectReferenceTask(projectValue: string): TaskInfo | null {
620 const trimmedProject = projectValue.trim();
621 if (!this.isProjectNoteReference(trimmedProject)) {
622 return null;
623 }
624
625 const parsedPath = parseLinkToPath(trimmedProject);
626 if (!parsedPath) {
627 return null;
628 }
629
630 const pathWithoutExtension = parsedPath.replace(/\.md$/i, "");
631 const resolvedFile = this.plugin.app.metadataCache.getFirstLinkpathDest(
632 pathWithoutExtension,
633 ""
634 );
635 if (resolvedFile) {
636 const resolvedTask = this.plugin.cacheManager.getCachedTaskInfoSync(resolvedFile.path);
637 if (resolvedTask) {
638 return resolvedTask;
639 }
640 }
641
642 const candidatePaths = /\.md$/i.test(parsedPath)
643 ? [parsedPath]
644 : [parsedPath, `${parsedPath}.md`];
645 for (const candidatePath of candidatePaths) {
646 const task = this.plugin.cacheManager.getCachedTaskInfoSync(candidatePath);
647 if (task) {
648 return task;
649 }
650 }
651
652 return null;
653 }
654
655 private isProjectNoteReference(projectValue: string): boolean {
656 return (

Callers 1

Calls 3

parseLinkToPathFunction · 0.90
getCachedTaskInfoSyncMethod · 0.80

Tested by

no test coverage detected