@nithin554/code-crawler 0.0.0 → 0.1.2
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/LICENSE +21 -0
- package/README.md +221 -45
- package/dist/config.d.ts +13 -0
- package/dist/config.js +32 -0
- package/dist/config.js.map +1 -0
- package/dist/crawler.d.ts +46 -0
- package/dist/crawler.js +303 -0
- package/dist/crawler.js.map +1 -0
- package/dist/graph/queries.d.ts +111 -0
- package/dist/graph/queries.js +265 -0
- package/dist/graph/queries.js.map +1 -0
- package/dist/graph/schema.d.ts +63 -0
- package/dist/graph/schema.js +54 -0
- package/dist/graph/schema.js.map +1 -0
- package/dist/graph/store.d.ts +66 -0
- package/dist/graph/store.js +251 -0
- package/dist/graph/store.js.map +1 -0
- package/dist/index.d.ts +2 -0
- package/dist/index.js +133 -0
- package/dist/index.js.map +1 -0
- package/dist/parser/language.d.ts +111 -0
- package/dist/parser/language.js +13 -0
- package/dist/parser/language.js.map +1 -0
- package/dist/parser/languages/index.d.ts +5 -0
- package/dist/parser/languages/index.js +31 -0
- package/dist/parser/languages/index.js.map +1 -0
- package/dist/parser/languages/java.d.ts +10 -0
- package/dist/parser/languages/java.js +334 -0
- package/dist/parser/languages/java.js.map +1 -0
- package/dist/parser/treeSitter.d.ts +28 -0
- package/dist/parser/treeSitter.js +114 -0
- package/dist/parser/treeSitter.js.map +1 -0
- package/dist/resolver/javaResolver.d.ts +20 -0
- package/dist/resolver/javaResolver.js +253 -0
- package/dist/resolver/javaResolver.js.map +1 -0
- package/dist/resolver/types.d.ts +45 -0
- package/dist/resolver/types.js +80 -0
- package/dist/resolver/types.js.map +1 -0
- package/dist/server.d.ts +15 -0
- package/dist/server.js +282 -0
- package/dist/server.js.map +1 -0
- package/package.json +44 -7
|
@@ -0,0 +1,253 @@
|
|
|
1
|
+
import { phantomNodeId } from "./types.js";
|
|
2
|
+
export function resolveJavaFile(file, index, options = {}) {
|
|
3
|
+
const searchInheritance = options.searchInheritance ?? true;
|
|
4
|
+
const results = [];
|
|
5
|
+
for (const call of file.callSites) {
|
|
6
|
+
results.push(resolveCall(call, file, index, searchInheritance));
|
|
7
|
+
}
|
|
8
|
+
return results;
|
|
9
|
+
}
|
|
10
|
+
function resolveCall(call, file, index, searchInheritance) {
|
|
11
|
+
const phantom = {
|
|
12
|
+
callSite: call,
|
|
13
|
+
targetId: phantomNodeId(call),
|
|
14
|
+
resolved: false,
|
|
15
|
+
confidence: 0,
|
|
16
|
+
reason: "",
|
|
17
|
+
};
|
|
18
|
+
// ---- 1. Constructor calls ------------------------------------------------
|
|
19
|
+
if (call.isConstructorCall) {
|
|
20
|
+
const types = resolveTypeName(call.name, file, index);
|
|
21
|
+
if (types.length === 0) {
|
|
22
|
+
return { ...phantom, reason: `type "${call.name}" not found in project` };
|
|
23
|
+
}
|
|
24
|
+
for (const fqn of types) {
|
|
25
|
+
const ctor = `${fqn}#<init>`;
|
|
26
|
+
if (index.methodsByFqn.get(fqn)?.some((m) => m.id === ctor)) {
|
|
27
|
+
return {
|
|
28
|
+
callSite: call,
|
|
29
|
+
targetId: ctor,
|
|
30
|
+
resolved: true,
|
|
31
|
+
confidence: 1.0,
|
|
32
|
+
reason: `constructor of ${fqn}`,
|
|
33
|
+
};
|
|
34
|
+
}
|
|
35
|
+
}
|
|
36
|
+
// Constructor not explicitly declared: Java provides the default one.
|
|
37
|
+
return {
|
|
38
|
+
callSite: call,
|
|
39
|
+
targetId: `${types[0]}#<init>`,
|
|
40
|
+
resolved: true,
|
|
41
|
+
confidence: 0.9,
|
|
42
|
+
reason: `default constructor of ${types[0]}`,
|
|
43
|
+
};
|
|
44
|
+
}
|
|
45
|
+
// ---- Receiver candidate extraction ---------------------------------------
|
|
46
|
+
const candidates = receiverCandidates(call, file, index);
|
|
47
|
+
if (candidates.types.length === 0) {
|
|
48
|
+
return {
|
|
49
|
+
...phantom,
|
|
50
|
+
reason: `could not infer receiver type: ${candidates.how}`,
|
|
51
|
+
};
|
|
52
|
+
}
|
|
53
|
+
for (const typeFqn of candidates.types) {
|
|
54
|
+
const found = findMethod(typeFqn, call.name, call.argumentTexts.length, index, searchInheritance);
|
|
55
|
+
if (found) {
|
|
56
|
+
return {
|
|
57
|
+
callSite: call,
|
|
58
|
+
targetId: found.method.id,
|
|
59
|
+
resolved: true,
|
|
60
|
+
confidence: baseConfidence(candidates) * found.confidence,
|
|
61
|
+
reason: `${found.method.id} (via ${candidates.how}${found.inherited ? ", inherited" : ""})`,
|
|
62
|
+
};
|
|
63
|
+
}
|
|
64
|
+
}
|
|
65
|
+
return {
|
|
66
|
+
...phantom,
|
|
67
|
+
reason: `no method ${call.name}(${call.argumentTexts.length} args) on ${candidates.types.join(" | ")} (${candidates.how})`,
|
|
68
|
+
};
|
|
69
|
+
}
|
|
70
|
+
/**
|
|
71
|
+
* Compute the candidate receiver types for an invocation, in priority order.
|
|
72
|
+
*/
|
|
73
|
+
function receiverCandidates(call, file, index) {
|
|
74
|
+
const receiver = call.receiver;
|
|
75
|
+
// ---- 2. Bare / this / super calls ----------------------------------------
|
|
76
|
+
if (!receiver) {
|
|
77
|
+
return {
|
|
78
|
+
types: enclosingAndAncestors(call.enclosingTypeId, index),
|
|
79
|
+
how: "bare call in " + call.enclosingTypeId,
|
|
80
|
+
};
|
|
81
|
+
}
|
|
82
|
+
if (receiver === "this" || receiver.startsWith("this.")) {
|
|
83
|
+
const field = receiver.startsWith("this.")
|
|
84
|
+
? file.fields.find((f) => f.typeId === call.enclosingTypeId && f.name === receiver.slice(5))
|
|
85
|
+
: null;
|
|
86
|
+
if (field) {
|
|
87
|
+
const types = resolveTypeName(field.type, file, index);
|
|
88
|
+
return { types, how: `field ${receiver} of ${call.enclosingTypeId}` };
|
|
89
|
+
}
|
|
90
|
+
return {
|
|
91
|
+
types: enclosingAndAncestors(call.enclosingTypeId, index),
|
|
92
|
+
how: `this-call in ${call.enclosingTypeId}`,
|
|
93
|
+
};
|
|
94
|
+
}
|
|
95
|
+
if (receiver.startsWith("super.")) {
|
|
96
|
+
return {
|
|
97
|
+
types: superAncestors(call.enclosingTypeId, index),
|
|
98
|
+
how: `super-call from ${call.enclosingTypeId}`,
|
|
99
|
+
};
|
|
100
|
+
}
|
|
101
|
+
// ---- 3. Type-qualified static calls --------------------------------------
|
|
102
|
+
const asType = resolveTypeName(receiver, file, index);
|
|
103
|
+
if (asType.length > 0) {
|
|
104
|
+
return { types: asType, how: `static/type-qualified on ${receiver}` };
|
|
105
|
+
}
|
|
106
|
+
// ---- 4. Instance calls on a variable -------------------------------------
|
|
107
|
+
if (isNameLike(receiver)) {
|
|
108
|
+
const inferred = inferVariableType(receiver, call, file, index);
|
|
109
|
+
if (inferred.types.length > 0)
|
|
110
|
+
return inferred;
|
|
111
|
+
}
|
|
112
|
+
// ---- Fallback: `new Foo().method()` and other expressions ----------------
|
|
113
|
+
const newMatch = receiver.match(/^new\s+([\w.$]+)/);
|
|
114
|
+
if (newMatch && newMatch[1]) {
|
|
115
|
+
const types = resolveTypeName(newMatch[1], file, index);
|
|
116
|
+
return { types, how: `receiver created via new ${newMatch[1]}()` };
|
|
117
|
+
}
|
|
118
|
+
return { types: [], how: `unhandled receiver expression "${receiver}"` };
|
|
119
|
+
}
|
|
120
|
+
/** Infer a variable's declared type from locals, parameters, and fields. */
|
|
121
|
+
function inferVariableType(name, call, file, index) {
|
|
122
|
+
// locals in the enclosing method
|
|
123
|
+
const locals = file.localsByMethod.get(call.enclosingMethodId);
|
|
124
|
+
const localType = locals?.get(name);
|
|
125
|
+
if (localType) {
|
|
126
|
+
return { types: resolveTypeName(localType, file, index), how: `local ${name}: ${localType}` };
|
|
127
|
+
}
|
|
128
|
+
// parameters of the enclosing method
|
|
129
|
+
const method = file.methods.find((m) => m.id === call.enclosingMethodId);
|
|
130
|
+
const param = method?.params.find((p) => p.name === name);
|
|
131
|
+
if (param) {
|
|
132
|
+
return { types: resolveTypeName(param.type, file, index), how: `param ${name}: ${param.type}` };
|
|
133
|
+
}
|
|
134
|
+
// fields of the enclosing type
|
|
135
|
+
const field = file.fields.find((f) => f.typeId === call.enclosingTypeId && f.name === name);
|
|
136
|
+
if (field) {
|
|
137
|
+
return { types: resolveTypeName(field.type, file, index), how: `field ${name}: ${field.type}` };
|
|
138
|
+
}
|
|
139
|
+
// inherited fields (search ancestors of the enclosing type)
|
|
140
|
+
for (const anc of superAncestors(call.enclosingTypeId, index)) {
|
|
141
|
+
const ancField = file.fields.find((f) => f.typeId === anc && f.name === name);
|
|
142
|
+
if (ancField) {
|
|
143
|
+
return { types: resolveTypeName(ancField.type, file, index), how: `field ${name} inherited from ${anc}` };
|
|
144
|
+
}
|
|
145
|
+
}
|
|
146
|
+
return { types: [], how: `unknown variable "${name}"` };
|
|
147
|
+
}
|
|
148
|
+
/** Find a method on a type or (optionally) its ancestors, matching arity. */
|
|
149
|
+
function findMethod(typeFqn, methodName, argCount, index, searchInheritance) {
|
|
150
|
+
const direct = (index.methodsByFqn.get(typeFqn) ?? []).filter((m) => m.name === methodName);
|
|
151
|
+
const match = pickOverload(direct, argCount);
|
|
152
|
+
if (match)
|
|
153
|
+
return { method: { id: match.id }, confidence: 1.0, inherited: false };
|
|
154
|
+
if (searchInheritance) {
|
|
155
|
+
const inherited = findInherited(typeFqn, methodName, argCount, index, new Set(), 0);
|
|
156
|
+
if (inherited)
|
|
157
|
+
return inherited;
|
|
158
|
+
}
|
|
159
|
+
return null;
|
|
160
|
+
}
|
|
161
|
+
function findInherited(typeFqn, methodName, argCount, index, visited, depth) {
|
|
162
|
+
if (depth > 10 || visited.has(typeFqn))
|
|
163
|
+
return null;
|
|
164
|
+
visited.add(typeFqn);
|
|
165
|
+
for (const parentName of index.parentsByFqn.get(typeFqn) ?? []) {
|
|
166
|
+
for (const parent of index.resolveType(parentName)) {
|
|
167
|
+
const candidates = (index.methodsByFqn.get(parent) ?? []).filter((m) => m.name === methodName);
|
|
168
|
+
const match = pickOverload(candidates, argCount);
|
|
169
|
+
if (match) {
|
|
170
|
+
return { method: { id: match.id }, confidence: 0.9, inherited: true };
|
|
171
|
+
}
|
|
172
|
+
const deeper = findInherited(parent, methodName, argCount, index, visited, depth + 1);
|
|
173
|
+
if (deeper)
|
|
174
|
+
return deeper;
|
|
175
|
+
}
|
|
176
|
+
}
|
|
177
|
+
return null;
|
|
178
|
+
}
|
|
179
|
+
/** Pick the overload with matching arity; fall back to the first candidate. */
|
|
180
|
+
function pickOverload(methods, argCount) {
|
|
181
|
+
const exact = methods.find((m) => m.params.length === argCount);
|
|
182
|
+
if (exact)
|
|
183
|
+
return exact;
|
|
184
|
+
return methods[0] ?? null;
|
|
185
|
+
}
|
|
186
|
+
/** Enclosing type + all ancestors, deduped, in order. */
|
|
187
|
+
function enclosingAndAncestors(typeFqn, index) {
|
|
188
|
+
const seen = new Set();
|
|
189
|
+
const out = [];
|
|
190
|
+
const walk = (t) => {
|
|
191
|
+
if (seen.has(t))
|
|
192
|
+
return;
|
|
193
|
+
seen.add(t);
|
|
194
|
+
out.push(t);
|
|
195
|
+
for (const parent of index.parentsByFqn.get(t) ?? []) {
|
|
196
|
+
for (const resolved of index.resolveType(parent))
|
|
197
|
+
walk(resolved);
|
|
198
|
+
}
|
|
199
|
+
};
|
|
200
|
+
walk(typeFqn);
|
|
201
|
+
return out;
|
|
202
|
+
}
|
|
203
|
+
function superAncestors(typeFqn, index) {
|
|
204
|
+
return enclosingAndAncestors(typeFqn, index).slice(1);
|
|
205
|
+
}
|
|
206
|
+
/**
|
|
207
|
+
* Resolve a type name (simple or qualified) to candidate FQNs.
|
|
208
|
+
* Priority: exact FQN in index -> file-declared/imported -> same package ->
|
|
209
|
+
* java.lang -> any simple-name match.
|
|
210
|
+
*/
|
|
211
|
+
function resolveTypeName(name, file, index) {
|
|
212
|
+
const trimmed = name.trim();
|
|
213
|
+
if (!trimmed)
|
|
214
|
+
return [];
|
|
215
|
+
if (index.kindByFqn.has(trimmed))
|
|
216
|
+
return [trimmed];
|
|
217
|
+
// java.lang implicit types
|
|
218
|
+
if (index.kindByFqn.has(`java.lang.${trimmed}`))
|
|
219
|
+
return [`java.lang.${trimmed}`];
|
|
220
|
+
// same package
|
|
221
|
+
const simple = trimmed.includes(".") ? trimmed.split(".").pop() : trimmed;
|
|
222
|
+
const inFile = file.typeByName.get(simple);
|
|
223
|
+
if (inFile)
|
|
224
|
+
return [inFile];
|
|
225
|
+
if (file.packageName) {
|
|
226
|
+
const pkgQualified = `${file.packageName}.${simple}`;
|
|
227
|
+
if (index.kindByFqn.has(pkgQualified))
|
|
228
|
+
return [pkgQualified];
|
|
229
|
+
}
|
|
230
|
+
return index.resolveType(simple);
|
|
231
|
+
}
|
|
232
|
+
/** Whether a receiver looks like a plain (possibly dotted) name. */
|
|
233
|
+
function isNameLike(receiver) {
|
|
234
|
+
return /^[A-Za-z_$][\w$]*(\.[A-Za-z_$][\w$]*)*$/.test(receiver);
|
|
235
|
+
}
|
|
236
|
+
function baseConfidence(candidates) {
|
|
237
|
+
switch (candidates.how.split(" ")[0]) {
|
|
238
|
+
case "local":
|
|
239
|
+
case "static/type-qualified":
|
|
240
|
+
case "param":
|
|
241
|
+
return 1.0;
|
|
242
|
+
case "field":
|
|
243
|
+
case "bare":
|
|
244
|
+
case "this-call":
|
|
245
|
+
case "super-call":
|
|
246
|
+
return 0.95;
|
|
247
|
+
case "receiver":
|
|
248
|
+
return 0.85;
|
|
249
|
+
default:
|
|
250
|
+
return 0.7;
|
|
251
|
+
}
|
|
252
|
+
}
|
|
253
|
+
//# sourceMappingURL=javaResolver.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"javaResolver.js","sourceRoot":"","sources":["../../src/resolver/javaResolver.ts"],"names":[],"mappings":"AACA,OAAO,EAAE,aAAa,EAAqC,MAAM,YAAY,CAAC;AAqB9E,MAAM,UAAU,eAAe,CAC7B,IAAoB,EACpB,KAAgB,EAChB,UAA0B,EAAE;IAE5B,MAAM,iBAAiB,GAAG,OAAO,CAAC,iBAAiB,IAAI,IAAI,CAAC;IA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AY;YACf,OAAO,IAAI,CAAC;QACd,KAAK,UAAU;YACb,OAAO,IAAI,CAAC;QACd;YACE,OAAO,GAAG,CAAC;IACf,CAAC;AACH,CAAC"}
|
|
@@ -0,0 +1,45 @@
|
|
|
1
|
+
import type { CallSite, MethodInfo, ParsedFile, TypeKind } from "../parser/language.js";
|
|
2
|
+
/**
|
|
3
|
+
* Shared resolver contract.
|
|
4
|
+
*
|
|
5
|
+
* A resolver turns raw `CallSite`s from the parser into concrete call edges.
|
|
6
|
+
* Resolution is heuristic: each call site either resolves to a known method
|
|
7
|
+
* node (with a confidence score) or falls back to a phantom `unknown_symbol`
|
|
8
|
+
* node so the graph stays traversable.
|
|
9
|
+
*/
|
|
10
|
+
export interface ResolvedCall {
|
|
11
|
+
callSite: CallSite;
|
|
12
|
+
/** Method node id (`Type#method`) or phantom id for unresolved calls. */
|
|
13
|
+
targetId: string;
|
|
14
|
+
resolved: boolean;
|
|
15
|
+
/** 0..1 heuristic confidence; 1 = statically certain. */
|
|
16
|
+
confidence: number;
|
|
17
|
+
/** Human-readable resolution trace for debugging and tool output. */
|
|
18
|
+
reason: string;
|
|
19
|
+
}
|
|
20
|
+
/**
|
|
21
|
+
* Global index over all parsed files, used to resolve type and method names
|
|
22
|
+
* across the whole project. Built once per crawl pass.
|
|
23
|
+
*/
|
|
24
|
+
export declare class TypeIndex {
|
|
25
|
+
/** simple name -> FQNs declared anywhere in the project. */
|
|
26
|
+
typesBySimpleName: Map<string, string[]>;
|
|
27
|
+
/** FQN -> kind (class/interface/enum). */
|
|
28
|
+
kindByFqn: Map<string, TypeKind>;
|
|
29
|
+
/** FQN -> directly-declared methods (all overloads). */
|
|
30
|
+
methodsByFqn: Map<string, MethodInfo[]>;
|
|
31
|
+
/** FQN -> parent FQNs (extends/implements, resolved where possible). */
|
|
32
|
+
parentsByFqn: Map<string, string[]>;
|
|
33
|
+
addFile(file: ParsedFile): void;
|
|
34
|
+
/** Resolve a (possibly qualified) type name to candidate FQNs. */
|
|
35
|
+
resolveType(name: string): string[];
|
|
36
|
+
/** All methods named `methodName` declared on a type (or inherited). */
|
|
37
|
+
findMethods(typeFqn: string, methodName: string, visited?: Set<string>, depth?: number): MethodInfo[];
|
|
38
|
+
/** True when a type declares (or inherits) the named method. */
|
|
39
|
+
hasMethod(typeFqn: string, methodName: string): boolean;
|
|
40
|
+
}
|
|
41
|
+
/** Build a TypeIndex from many parsed files. */
|
|
42
|
+
export declare function buildTypeIndex(files: ParsedFile[]): TypeIndex;
|
|
43
|
+
/** Node id for an unresolved (phantom) call. */
|
|
44
|
+
export declare function phantomNodeId(call: CallSite): string;
|
|
45
|
+
export type { CallSite, ParsedFile };
|
|
@@ -0,0 +1,80 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Global index over all parsed files, used to resolve type and method names
|
|
3
|
+
* across the whole project. Built once per crawl pass.
|
|
4
|
+
*/
|
|
5
|
+
export class TypeIndex {
|
|
6
|
+
/** simple name -> FQNs declared anywhere in the project. */
|
|
7
|
+
typesBySimpleName = new Map();
|
|
8
|
+
/** FQN -> kind (class/interface/enum). */
|
|
9
|
+
kindByFqn = new Map();
|
|
10
|
+
/** FQN -> directly-declared methods (all overloads). */
|
|
11
|
+
methodsByFqn = new Map();
|
|
12
|
+
/** FQN -> parent FQNs (extends/implements, resolved where possible). */
|
|
13
|
+
parentsByFqn = new Map();
|
|
14
|
+
addFile(file) {
|
|
15
|
+
for (const t of file.types) {
|
|
16
|
+
const list = this.typesBySimpleName.get(t.name) ?? [];
|
|
17
|
+
if (!list.includes(t.id))
|
|
18
|
+
list.push(t.id);
|
|
19
|
+
this.typesBySimpleName.set(t.name, list);
|
|
20
|
+
this.kindByFqn.set(t.id, t.kind);
|
|
21
|
+
this.parentsByFqn.set(t.id, t.extendsTypes.concat(t.implementsTypes));
|
|
22
|
+
}
|
|
23
|
+
for (const m of file.methods) {
|
|
24
|
+
const list = this.methodsByFqn.get(m.typeId) ?? [];
|
|
25
|
+
list.push(m);
|
|
26
|
+
this.methodsByFqn.set(m.typeId, list);
|
|
27
|
+
}
|
|
28
|
+
}
|
|
29
|
+
/** Resolve a (possibly qualified) type name to candidate FQNs. */
|
|
30
|
+
resolveType(name) {
|
|
31
|
+
const trimmed = name.trim();
|
|
32
|
+
if (!trimmed)
|
|
33
|
+
return [];
|
|
34
|
+
// Exact FQN match?
|
|
35
|
+
if (this.kindByFqn.has(trimmed))
|
|
36
|
+
return [trimmed];
|
|
37
|
+
// Simple name match.
|
|
38
|
+
const simple = trimmed.includes(".") ? trimmed.split(".").pop() : trimmed;
|
|
39
|
+
return this.typesBySimpleName.get(simple) ?? [];
|
|
40
|
+
}
|
|
41
|
+
/** All methods named `methodName` declared on a type (or inherited). */
|
|
42
|
+
findMethods(typeFqn, methodName, visited = new Set(), depth = 0) {
|
|
43
|
+
if (depth > 10 || visited.has(typeFqn))
|
|
44
|
+
return [];
|
|
45
|
+
visited.add(typeFqn);
|
|
46
|
+
const direct = (this.methodsByFqn.get(typeFqn) ?? []).filter((m) => m.name === methodName);
|
|
47
|
+
if (direct.length > 0)
|
|
48
|
+
return direct;
|
|
49
|
+
for (const parent of this.parentsByFqn.get(typeFqn) ?? []) {
|
|
50
|
+
const resolved = this.resolveType(parent);
|
|
51
|
+
for (const p of resolved) {
|
|
52
|
+
const found = this.findMethods(p, methodName, visited, depth + 1);
|
|
53
|
+
if (found.length > 0)
|
|
54
|
+
return found;
|
|
55
|
+
}
|
|
56
|
+
}
|
|
57
|
+
return [];
|
|
58
|
+
}
|
|
59
|
+
/** True when a type declares (or inherits) the named method. */
|
|
60
|
+
hasMethod(typeFqn, methodName) {
|
|
61
|
+
return this.findMethods(typeFqn, methodName).length > 0;
|
|
62
|
+
}
|
|
63
|
+
}
|
|
64
|
+
/** Build a TypeIndex from many parsed files. */
|
|
65
|
+
export function buildTypeIndex(files) {
|
|
66
|
+
const index = new TypeIndex();
|
|
67
|
+
for (const f of files)
|
|
68
|
+
index.addFile(f);
|
|
69
|
+
return index;
|
|
70
|
+
}
|
|
71
|
+
/** Node id for an unresolved (phantom) call. */
|
|
72
|
+
export function phantomNodeId(call) {
|
|
73
|
+
const label = call.isConstructorCall
|
|
74
|
+
? `new ${call.name}`
|
|
75
|
+
: call.receiver
|
|
76
|
+
? `${call.receiver}.${call.name}`
|
|
77
|
+
: call.name;
|
|
78
|
+
return `__unknown__:${label}`;
|
|
79
|
+
}
|
|
80
|
+
//# sourceMappingURL=types.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"types.js","sourceRoot":"","sources":["../../src/resolver/types.ts"],"names":[],"mappings":"AAsBA;;;GAGG;AACH,MAAM,OAAO,SAAS;IACpB,4DAA4D;IAC5D,iBAAiB,GAAG,IAAI,GAAG,EAAoB,CAAC;IAChD,0CAA0C;IAC1C,SAAS,GAAG,IAAI,GAAG,EAAoB,CAAC;IACxC,wDAAwD;IACxD,YAAY,GAAG,IAAI,GAAG,EAAwB,CAAC;IAC/C,wEAAwE;IACxE,YAAY,GAAG,IAAI,GAAG,EAAoB,CAAC;IAE3C,OAAO,CAAC,IAAgB;QACtB,KAAK,MAAM,CAAC,IAAI,IAAI,CAAC,KAAK,EAAE,CAAC;YAC3B,MAAM,IAAI,GAAG,IAAI,CAAC,iBAAiB,CAAC,GAAG,CAAC,CAAC,CAAC,IAAI,CAAC,IAAI,EAAE,CAAC;YACtD,IAAI,CAAC,IAAI,CAAC,QAAQ,CAAC,CAAC,CAAC,EAAE,CAAC;gBAAE,IAAI,CAAC,IAAI,CAAC,CAAC,CAAC,EAAE,CAAC,CAAC;YAC1C,IAAI,CAAC,iBAAiB,CAAC,GAAG,CAAC,CAAC,CAAC,IAAI,EAAE,IAAI,CAAC,CAAC;YACzC,IAAI,CAAC,SAAS,CAAC,GAAG,CAAC,CAAC,CAAC,EAAE,EAAE,CAAC,CAAC,IAAI,CAAC,CAAC;YACjC,IAAI,CAAC,YAAY,CAAC,GAAG,CAAC,CAAC,CAAC,EAAE,EAAE,CAAC,CAAC,YAAY,C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,QAAQ,IAAI,IAAI,CAAC,IAAI,EAAE;YACjC,CAAC,CAAC,IAAI,CAAC,IAAI,CAAC;IAChB,OAAO,eAAe,KAAK,EAAE,CAAC;AAChC,CAAC"}
|
package/dist/server.d.ts
ADDED
|
@@ -0,0 +1,15 @@
|
|
|
1
|
+
import { McpServer } from "@modelcontextprotocol/sdk/server/mcp.js";
|
|
2
|
+
import type { GraphStore } from "./graph/store.js";
|
|
3
|
+
import type { Config } from "./config.js";
|
|
4
|
+
import { loadConfig } from "./config.js";
|
|
5
|
+
/**
|
|
6
|
+
* MCP server surface for code-crawler.
|
|
7
|
+
*
|
|
8
|
+
* Thin tool handlers: every tool delegates to the graph/queries/crawler layers
|
|
9
|
+
* and formats the result as JSON text. Line numbers are converted from the
|
|
10
|
+
* internal 0-based convention to 1-based for LLM consumption.
|
|
11
|
+
*/
|
|
12
|
+
export declare const SERVER_NAME = "code-crawler";
|
|
13
|
+
export declare const SERVER_VERSION = "0.1.0";
|
|
14
|
+
export declare function createServer(store: GraphStore, config: Config): McpServer;
|
|
15
|
+
export { loadConfig };
|