MCPcopy Index your code
hub / github.com/callumalpass/tasknotes / indexTaskFile

Method indexTaskFile

src/utils/DependencyCache.ts:270–324  ·  view source on GitHub ↗

* Index a task file's dependencies and project references

(path: string, frontmatter: Record<string, unknown>)

Source from the content-addressed store, hash-verified

268 * Index a task file's dependencies and project references
269 */
270 private indexTaskFile(path: string, frontmatter: Record<string, unknown>): void {
271 if (!this.isValidFile(path)) {
272 return;
273 }
274
275 this.relationshipFingerprints.set(path, this.buildRelationshipFingerprint(frontmatter));
276 this.completedStatusByPath.set(path, this.isCompletedFrontmatter(frontmatter));
277
278 const dependenciesField = this.fieldMapper?.toUserField("blockedBy") || "blockedBy";
279 const projectField = this.fieldMapper?.toUserField("projects") || "project";
280
281 // Index dependencies
282 const dependencies = frontmatter[dependenciesField];
283 if (dependencies) {
284 const normalized = normalizeDependencyList(dependencies);
285 if (normalized) {
286 const blockingTasks = new Set<string>();
287
288 for (const dep of normalized) {
289 const resolved = resolveDependencyEntry(this.app, path, dep);
290 if (resolved?.path && this.isValidFile(resolved.path)) {
291 this.addDependencyLink(path, resolved.path, blockingTasks);
292 }
293 }
294
295 if (blockingTasks.size > 0) {
296 this.dependencySources.set(path, blockingTasks);
297 }
298 }
299 }
300
301 // Index project references
302 const project = frontmatter[projectField];
303 if (project) {
304 const projects = Array.isArray(project) ? project : [project];
305
306 for (const proj of projects) {
307 if (typeof proj === "string") {
308 // Resolve the project reference to a full file path
309 const resolvedPath = this.resolveProjectReference(path, proj);
310 if (resolvedPath && this.isValidFile(resolvedPath)) {
311 if (!this.projectReferences.has(resolvedPath)) {
312 this.projectReferences.set(resolvedPath, new Set());
313 }
314 this.projectReferences.get(resolvedPath)!.add(path);
315
316 if (!this.projectReferenceSources.has(path)) {
317 this.projectReferenceSources.set(path, new Set());
318 }
319 this.projectReferenceSources.get(path)!.add(resolvedPath);
320 }
321 }
322 }
323 }
324 }
325
326 private addDependencyLink(
327 dependentPath: string,

Callers 4

buildIndexesMethod · 0.95
handleFileChangedMethod · 0.95
handleFileRenamedMethod · 0.95
buildIndexesSyncMethod · 0.95

Calls 11

isValidFileMethod · 0.95
addDependencyLinkMethod · 0.95
normalizeDependencyListFunction · 0.90
resolveDependencyEntryFunction · 0.90
hasMethod · 0.80
setMethod · 0.65
toUserFieldMethod · 0.65
getMethod · 0.65

Tested by

no test coverage detected