diff --git a/src/domain/analysis/context.js b/src/domain/analysis/context.js index a97e5419..a6721b35 100644 --- a/src/domain/analysis/context.js +++ b/src/domain/analysis/context.js @@ -96,7 +96,7 @@ function explainFileImpl(db, target, getFileLines) { function explainFunctionImpl(db, target, noTests, getFileLines) { let nodes = db .prepare( - `SELECT * FROM nodes WHERE name LIKE ? AND kind IN ('function','method','class','interface','type','struct','enum','trait','record','module') ORDER BY file, line`, + `SELECT * FROM nodes WHERE name LIKE ? AND kind IN ('function','method','class','interface','type','struct','enum','trait','record','module','constant') ORDER BY file, line`, ) .all(`%${target}%`); if (noTests) nodes = nodes.filter((n) => !isTestFile(n.file)); diff --git a/src/domain/analysis/symbol-lookup.js b/src/domain/analysis/symbol-lookup.js index 312581cc..ffb5566c 100644 --- a/src/domain/analysis/symbol-lookup.js +++ b/src/domain/analysis/symbol-lookup.js @@ -16,11 +16,11 @@ import { } from '../../db/index.js'; import { debug } from '../../infrastructure/logger.js'; import { isTestFile } from '../../infrastructure/test-filter.js'; -import { ALL_SYMBOL_KINDS } from '../../shared/kinds.js'; +import { EVERY_SYMBOL_KIND } from '../../shared/kinds.js'; import { getFileHash, normalizeSymbol } from '../../shared/normalize.js'; import { paginateResult } from '../../shared/paginate.js'; -const FUNCTION_KINDS = ['function', 'method', 'class']; +const FUNCTION_KINDS = ['function', 'method', 'class', 'constant']; /** * Find nodes matching a name query, ranked by relevance. @@ -110,12 +110,12 @@ export function queryNameData(name, customDbPath, opts = {}) { } function whereSymbolImpl(db, target, noTests) { - const placeholders = ALL_SYMBOL_KINDS.map(() => '?').join(', '); + const placeholders = EVERY_SYMBOL_KIND.map(() => '?').join(', '); let nodes = db .prepare( `SELECT * FROM nodes WHERE name LIKE ? AND kind IN (${placeholders}) ORDER BY file, line`, ) - .all(`%${target}%`, ...ALL_SYMBOL_KINDS); + .all(`%${target}%`, ...EVERY_SYMBOL_KIND); if (noTests) nodes = nodes.filter((n) => !isTestFile(n.file)); const hc = new Map(); diff --git a/src/domain/graph/builder/stages/build-edges.js b/src/domain/graph/builder/stages/build-edges.js index a8879b62..a1529454 100644 --- a/src/domain/graph/builder/stages/build-edges.js +++ b/src/domain/graph/builder/stages/build-edges.js @@ -28,7 +28,7 @@ export async function buildEdges(ctx) { // Pre-load all nodes into lookup maps const allNodes = db .prepare( - `SELECT id, name, kind, file, line FROM nodes WHERE kind IN ('function','method','class','interface','struct','type','module','enum','trait')`, + `SELECT id, name, kind, file, line FROM nodes WHERE kind IN ('function','method','class','interface','struct','type','module','enum','trait','record','constant')`, ) .all(); ctx.nodesByName = new Map(); diff --git a/src/domain/graph/watcher.js b/src/domain/graph/watcher.js index 15b4b4a6..3fea7954 100644 --- a/src/domain/graph/watcher.js +++ b/src/domain/graph/watcher.js @@ -57,10 +57,10 @@ export async function watchProject(rootDir, opts = {}) { countNodes: db.prepare('SELECT COUNT(*) as c FROM nodes WHERE file = ?'), countEdgesForFile: null, findNodeInFile: db.prepare( - "SELECT id, file FROM nodes WHERE name = ? AND kind IN ('function', 'method', 'class', 'interface', 'type', 'struct', 'enum', 'trait', 'record', 'module') AND file = ?", + "SELECT id, file FROM nodes WHERE name = ? AND kind IN ('function', 'method', 'class', 'interface', 'type', 'struct', 'enum', 'trait', 'record', 'module', 'constant') AND file = ?", ), findNodeByName: db.prepare( - "SELECT id, file FROM nodes WHERE name = ? AND kind IN ('function', 'method', 'class', 'interface', 'type', 'struct', 'enum', 'trait', 'record', 'module')", + "SELECT id, file FROM nodes WHERE name = ? AND kind IN ('function', 'method', 'class', 'interface', 'type', 'struct', 'enum', 'trait', 'record', 'module', 'constant')", ), listSymbols: db.prepare("SELECT name, kind, line FROM nodes WHERE file = ? AND kind != 'file'"), }; diff --git a/src/features/export.js b/src/features/export.js index 6f93faae..3bd064e3 100644 --- a/src/features/export.js +++ b/src/features/export.js @@ -67,8 +67,8 @@ function loadFunctionLevelEdges(db, { noTests, minConfidence, limit }) { FROM edges e JOIN nodes n1 ON e.source_id = n1.id JOIN nodes n2 ON e.target_id = n2.id - WHERE n1.kind IN ('function', 'method', 'class', 'interface', 'type', 'struct', 'enum', 'trait', 'record', 'module') - AND n2.kind IN ('function', 'method', 'class', 'interface', 'type', 'struct', 'enum', 'trait', 'record', 'module') + WHERE n1.kind IN ('function', 'method', 'class', 'interface', 'type', 'struct', 'enum', 'trait', 'record', 'module', 'constant') + AND n2.kind IN ('function', 'method', 'class', 'interface', 'type', 'struct', 'enum', 'trait', 'record', 'module', 'constant') AND e.kind = 'calls' AND e.confidence >= ? `, @@ -308,7 +308,7 @@ export function exportGraphSON(db, opts = {}) { let nodes = db .prepare(` SELECT id, name, kind, file, line, role FROM nodes - WHERE kind IN ('function', 'method', 'class', 'interface', 'type', 'struct', 'enum', 'trait', 'record', 'module', 'file') + WHERE kind IN ('function', 'method', 'class', 'interface', 'type', 'struct', 'enum', 'trait', 'record', 'module', 'constant', 'file') `) .all(); if (noTests) nodes = nodes.filter((n) => !isTestFile(n.file)); diff --git a/src/features/graph-enrichment.js b/src/features/graph-enrichment.js index 96e47e2c..adb9fb8e 100644 --- a/src/features/graph-enrichment.js +++ b/src/features/graph-enrichment.js @@ -42,8 +42,8 @@ function prepareFunctionLevelData(db, noTests, minConf, cfg) { FROM edges e JOIN nodes n1 ON e.source_id = n1.id JOIN nodes n2 ON e.target_id = n2.id - WHERE n1.kind IN ('function', 'method', 'class', 'interface', 'type', 'struct', 'enum', 'trait', 'record', 'module') - AND n2.kind IN ('function', 'method', 'class', 'interface', 'type', 'struct', 'enum', 'trait', 'record', 'module') + WHERE n1.kind IN ('function', 'method', 'class', 'interface', 'type', 'struct', 'enum', 'trait', 'record', 'module', 'constant') + AND n2.kind IN ('function', 'method', 'class', 'interface', 'type', 'struct', 'enum', 'trait', 'record', 'module', 'constant') AND e.kind = 'calls' AND e.confidence >= ? `,