Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion src/domain/analysis/context.js
Original file line number Diff line number Diff line change
Expand Up @@ -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));
Expand Down
8 changes: 4 additions & 4 deletions src/domain/analysis/symbol-lookup.js
Original file line number Diff line number Diff line change
Expand Up @@ -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.
Expand Down Expand Up @@ -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();
Expand Down
2 changes: 1 addition & 1 deletion src/domain/graph/builder/stages/build-edges.js
Original file line number Diff line number Diff line change
Expand Up @@ -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();
Expand Down
4 changes: 2 additions & 2 deletions src/domain/graph/watcher.js
Original file line number Diff line number Diff line change
Expand Up @@ -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'"),
};
Expand Down
6 changes: 3 additions & 3 deletions src/features/export.js
Original file line number Diff line number Diff line change
Expand Up @@ -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 >= ?
`,
Expand Down Expand Up @@ -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));
Expand Down
4 changes: 2 additions & 2 deletions src/features/graph-enrichment.js
Original file line number Diff line number Diff line change
Expand Up @@ -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 >= ?
`,
Expand Down
Loading