symbol-context.test.ts — mcp Source File
Architecture documentation for symbol-context.test.ts, a typescript file in the mcp codebase. 11 imports, 0 dependents.
Entity Profile
Dependency Diagram
graph LR 4e8cb5f6_f6f3_2b7d_9300_e8877f606de7["symbol-context.test.ts"] 108c9ff4_bdb8_518a_9256_9ff4cd9d39a7["graph-cache.ts"] 4e8cb5f6_f6f3_2b7d_9300_e8877f606de7 --> 108c9ff4_bdb8_518a_9256_9ff4cd9d39a7 f20c71b7_2411_d98b_88ba_3ebc36bdd1f5["buildIndexes"] 4e8cb5f6_f6f3_2b7d_9300_e8877f606de7 --> f20c71b7_2411_d98b_88ba_3ebc36bdd1f5 ca77ccf4_30df_6b5c_22dc_f7ba42fd0765["symbol-context.ts"] 4e8cb5f6_f6f3_2b7d_9300_e8877f606de7 --> ca77ccf4_30df_6b5c_22dc_f7ba42fd0765 acad5452_c49c_a5b9_12f1_5263dd556260["findSymbol"] 4e8cb5f6_f6f3_2b7d_9300_e8877f606de7 --> acad5452_c49c_a5b9_12f1_5263dd556260 fd98a844_5daf_fa4c_d573_003b6d89b6be["renderSymbolContext"] 4e8cb5f6_f6f3_2b7d_9300_e8877f606de7 --> fd98a844_5daf_fa4c_d573_003b6d89b6be 67223ccb_3c2b_174e_f218_e621b3b9d580["languageFromExtension"] 4e8cb5f6_f6f3_2b7d_9300_e8877f606de7 --> 67223ccb_3c2b_174e_f218_e621b3b9d580 19f4d048_f875_3a64_f6f5_2d534dca972b["constants.ts"] 4e8cb5f6_f6f3_2b7d_9300_e8877f606de7 --> 19f4d048_f875_3a64_f6f5_2d534dca972b 9304f204_de38_9fc9_faf0_8f287591dc52["globals"] 4e8cb5f6_f6f3_2b7d_9300_e8877f606de7 --> 9304f204_de38_9fc9_faf0_8f287591dc52 222b60e9_a6a9_f11c_deba_8f76f9527fbc["fs"] 4e8cb5f6_f6f3_2b7d_9300_e8877f606de7 --> 222b60e9_a6a9_f11c_deba_8f76f9527fbc 326b2a40_61be_c67e_3a48_e7ce3411f260["path"] 4e8cb5f6_f6f3_2b7d_9300_e8877f606de7 --> 326b2a40_61be_c67e_3a48_e7ce3411f260 70624398_825e_285a_418a_9ee41ac17b82["os"] 4e8cb5f6_f6f3_2b7d_9300_e8877f606de7 --> 70624398_825e_285a_418a_9ee41ac17b82 style 4e8cb5f6_f6f3_2b7d_9300_e8877f606de7 fill:#6366f1,stroke:#818cf8,color:#fff
Relationship Graph
Source Code
import { describe, it, expect, afterAll } from '@jest/globals';
import { promises as fs } from 'fs';
import * as path from 'path';
import * as os from 'os';
import { buildIndexes } from '../cache/graph-cache';
import { findSymbol, renderSymbolContext, languageFromExtension } from './symbol-context';
import { MAX_SOURCE_LINES } from '../constants';
// ── Helpers ──
/** Build a minimal IndexedGraph from inline nodes + relationships */
function buildGraph(
nodes: Array<{ id: string; labels: string[]; properties: Record<string, unknown> }>,
relationships: Array<{ id: string; type: string; startNode: string; endNode: string; properties?: Record<string, unknown> }> = [],
) {
const raw: any = {
repo: 'test-repo',
graph: { nodes, relationships: relationships.map(r => ({ ...r, properties: r.properties ?? {} })) },
};
return buildIndexes(raw, 'test-key');
}
// ── findSymbol tests (Issue #107) ──
describe('findSymbol', () => {
it('query "filter" does NOT match symbol "f" (bidirectional bug regression)', () => {
const graph = buildGraph([
{ id: 'f1', labels: ['Function'], properties: { name: 'f', filePath: 'a.py', startLine: 1 } },
{ id: 'f2', labels: ['Function'], properties: { name: 'filter', filePath: 'b.py', startLine: 1 } },
]);
const results = findSymbol(graph, 'filter');
const names = results.map(n => n.properties?.name);
expect(names).toContain('filter');
expect(names).not.toContain('f');
});
it('single-char query "f" finds exact match via Strategy 1, substring returns empty', () => {
const graph = buildGraph([
{ id: 'f1', labels: ['Function'], properties: { name: 'f', filePath: 'a.py', startLine: 1 } },
{ id: 'f2', labels: ['Function'], properties: { name: 'filter', filePath: 'b.py', startLine: 1 } },
]);
// Exact match works
const exactResults = findSymbol(graph, 'f');
expect(exactResults.length).toBe(1);
expect(exactResults[0].properties?.name).toBe('f');
// A single-char query that has no exact match returns nothing (no substring for len < 2)
const noMatchResults = findSymbol(graph, 'x');
expect(noMatchResults.length).toBe(0);
});
it('two functions named "filter" — one with 3 callers sorts before one with 0', () => {
const graph = buildGraph(
[
{ id: 'popular', labels: ['Function'], properties: { name: 'filter', filePath: 'a.py', startLine: 1 } },
{ id: 'lonely', labels: ['Function'], properties: { name: 'filter', filePath: 'b.py', startLine: 1 } },
{ id: 'c1', labels: ['Function'], properties: { name: 'caller1', filePath: 'c.py', startLine: 1 } },
{ id: 'c2', labels: ['Function'], properties: { name: 'caller2', filePath: 'c.py', startLine: 10 } },
// ... (138 more lines)
Domain
Subdomains
Functions
Dependencies
Source
Frequently Asked Questions
What does symbol-context.test.ts do?
symbol-context.test.ts is a source file in the mcp codebase, written in typescript. It belongs to the AnalysisTools domain, SymbolSearch subdomain.
What functions are defined in symbol-context.test.ts?
symbol-context.test.ts defines 1 function(s): buildGraph.
What does symbol-context.test.ts depend on?
symbol-context.test.ts imports 11 module(s): buildIndexes, constants.ts, findSymbol, fs, globals, graph-cache.ts, languageFromExtension, os, and 3 more.
Where is symbol-context.test.ts in the architecture?
symbol-context.test.ts is located at src/tools/symbol-context.test.ts (domain: AnalysisTools, subdomain: SymbolSearch, directory: src/tools).
Analyze Your Own Codebase
Get architecture documentation, dependency graphs, and domain analysis for your codebase in minutes.
Try Supermodel Free