@liendev/core 0.24.0 → 0.27.0
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/dist/frameworks/python/config.d.ts +6 -0
- package/dist/frameworks/python/config.d.ts.map +1 -0
- package/dist/frameworks/python/config.js +73 -0
- package/dist/frameworks/python/config.js.map +1 -0
- package/dist/frameworks/python/detector.d.ts +7 -0
- package/dist/frameworks/python/detector.d.ts.map +1 -0
- package/dist/frameworks/python/detector.js +129 -0
- package/dist/frameworks/python/detector.js.map +1 -0
- package/dist/frameworks/registry.d.ts +1 -1
- package/dist/frameworks/registry.d.ts.map +1 -1
- package/dist/frameworks/registry.js +3 -1
- package/dist/frameworks/registry.js.map +1 -1
- package/dist/indexer/ast/chunker.d.ts.map +1 -1
- package/dist/indexer/ast/chunker.js +86 -50
- package/dist/indexer/ast/chunker.js.map +1 -1
- package/dist/indexer/ast/extractors/index.d.ts +25 -0
- package/dist/indexer/ast/extractors/index.d.ts.map +1 -0
- package/dist/indexer/ast/extractors/index.js +49 -0
- package/dist/indexer/ast/extractors/index.js.map +1 -0
- package/dist/indexer/ast/extractors/javascript.d.ts +32 -0
- package/dist/indexer/ast/extractors/javascript.d.ts.map +1 -0
- package/dist/indexer/ast/extractors/javascript.js +97 -0
- package/dist/indexer/ast/extractors/javascript.js.map +1 -0
- package/dist/indexer/ast/extractors/php.d.ts +34 -0
- package/dist/indexer/ast/extractors/php.d.ts.map +1 -0
- package/dist/indexer/ast/extractors/php.js +79 -0
- package/dist/indexer/ast/extractors/php.js.map +1 -0
- package/dist/indexer/ast/extractors/python.d.ts +22 -0
- package/dist/indexer/ast/extractors/python.d.ts.map +1 -0
- package/dist/indexer/ast/extractors/python.js +57 -0
- package/dist/indexer/ast/extractors/python.js.map +1 -0
- package/dist/indexer/ast/extractors/types.d.ts +52 -0
- package/dist/indexer/ast/extractors/types.d.ts.map +1 -0
- package/dist/indexer/ast/extractors/types.js +2 -0
- package/dist/indexer/ast/extractors/types.js.map +1 -0
- package/dist/indexer/ast/symbols.d.ts +72 -1
- package/dist/indexer/ast/symbols.d.ts.map +1 -1
- package/dist/indexer/ast/symbols.js +520 -0
- package/dist/indexer/ast/symbols.js.map +1 -1
- package/dist/indexer/types.d.ts +18 -0
- package/dist/indexer/types.d.ts.map +1 -1
- package/dist/vectordb/batch-insert.d.ts.map +1 -1
- package/dist/vectordb/batch-insert.js +97 -23
- package/dist/vectordb/batch-insert.js.map +1 -1
- package/dist/vectordb/qdrant-payload-mapper.d.ts +11 -0
- package/dist/vectordb/qdrant-payload-mapper.d.ts.map +1 -1
- package/dist/vectordb/qdrant-payload-mapper.js +33 -0
- package/dist/vectordb/qdrant-payload-mapper.js.map +1 -1
- package/dist/vectordb/query.d.ts.map +1 -1
- package/dist/vectordb/query.js +107 -10
- package/dist/vectordb/query.js.map +1 -1
- package/package.json +1 -1
|
@@ -0,0 +1,32 @@
|
|
|
1
|
+
import type Parser from 'tree-sitter';
|
|
2
|
+
import type { LanguageExportExtractor } from './types.js';
|
|
3
|
+
/**
|
|
4
|
+
* JavaScript/TypeScript export extractor
|
|
5
|
+
*
|
|
6
|
+
* Handles explicit export statements:
|
|
7
|
+
* - Named exports: export { foo, bar }
|
|
8
|
+
* - Declaration exports: export function foo() {}, export const bar = ...
|
|
9
|
+
* - Default exports: export default ...
|
|
10
|
+
* - Re-exports: export { foo } from './module'
|
|
11
|
+
*/
|
|
12
|
+
export declare class JavaScriptExportExtractor implements LanguageExportExtractor {
|
|
13
|
+
extractExports(rootNode: Parser.SyntaxNode): string[];
|
|
14
|
+
/**
|
|
15
|
+
* Extract symbols from a single export statement
|
|
16
|
+
*/
|
|
17
|
+
private extractExportStatementSymbols;
|
|
18
|
+
/**
|
|
19
|
+
* Extract exported names from a declaration (function, const, class, interface)
|
|
20
|
+
*/
|
|
21
|
+
private extractDeclarationExports;
|
|
22
|
+
/**
|
|
23
|
+
* Extract symbol names from export clause: export { foo, bar as baz }
|
|
24
|
+
*/
|
|
25
|
+
private extractExportClauseSymbols;
|
|
26
|
+
}
|
|
27
|
+
/**
|
|
28
|
+
* TypeScript uses the same export extraction as JavaScript
|
|
29
|
+
*/
|
|
30
|
+
export declare class TypeScriptExportExtractor extends JavaScriptExportExtractor {
|
|
31
|
+
}
|
|
32
|
+
//# sourceMappingURL=javascript.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"javascript.d.ts","sourceRoot":"","sources":["../../../../src/indexer/ast/extractors/javascript.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,MAAM,MAAM,aAAa,CAAC;AACtC,OAAO,KAAK,EAAE,uBAAuB,EAAE,MAAM,YAAY,CAAC;AAE1D;;;;;;;;GAQG;AACH,qBAAa,yBAA0B,YAAW,uBAAuB;IACvE,cAAc,CAAC,QAAQ,EAAE,MAAM,CAAC,UAAU,GAAG,MAAM,EAAE;IAsBrD;;OAEG;IACH,OAAO,CAAC,6BAA6B;IAsBrC;;OAEG;IACH,OAAO,CAAC,yBAAyB;IAsBjC;;OAEG;IACH,OAAO,CAAC,0BAA0B;CAcnC;AAED;;GAEG;AACH,qBAAa,yBAA0B,SAAQ,yBAAyB;CAAG"}
|
|
@@ -0,0 +1,97 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* JavaScript/TypeScript export extractor
|
|
3
|
+
*
|
|
4
|
+
* Handles explicit export statements:
|
|
5
|
+
* - Named exports: export { foo, bar }
|
|
6
|
+
* - Declaration exports: export function foo() {}, export const bar = ...
|
|
7
|
+
* - Default exports: export default ...
|
|
8
|
+
* - Re-exports: export { foo } from './module'
|
|
9
|
+
*/
|
|
10
|
+
export class JavaScriptExportExtractor {
|
|
11
|
+
extractExports(rootNode) {
|
|
12
|
+
const exports = [];
|
|
13
|
+
const seen = new Set();
|
|
14
|
+
const addExport = (name) => {
|
|
15
|
+
if (name && !seen.has(name)) {
|
|
16
|
+
seen.add(name);
|
|
17
|
+
exports.push(name);
|
|
18
|
+
}
|
|
19
|
+
};
|
|
20
|
+
// Process only top-level export statements
|
|
21
|
+
for (let i = 0; i < rootNode.namedChildCount; i++) {
|
|
22
|
+
const child = rootNode.namedChild(i);
|
|
23
|
+
if (child?.type === 'export_statement') {
|
|
24
|
+
this.extractExportStatementSymbols(child, addExport);
|
|
25
|
+
}
|
|
26
|
+
}
|
|
27
|
+
return exports;
|
|
28
|
+
}
|
|
29
|
+
/**
|
|
30
|
+
* Extract symbols from a single export statement
|
|
31
|
+
*/
|
|
32
|
+
extractExportStatementSymbols(node, addExport) {
|
|
33
|
+
// Check for default export
|
|
34
|
+
const defaultKeyword = node.children.find(c => c.type === 'default');
|
|
35
|
+
if (defaultKeyword) {
|
|
36
|
+
addExport('default');
|
|
37
|
+
}
|
|
38
|
+
// Check for declaration (export function/const/class)
|
|
39
|
+
const declaration = node.childForFieldName('declaration');
|
|
40
|
+
if (declaration) {
|
|
41
|
+
this.extractDeclarationExports(declaration, addExport);
|
|
42
|
+
}
|
|
43
|
+
// Check for export clause (export { foo, bar })
|
|
44
|
+
for (let i = 0; i < node.namedChildCount; i++) {
|
|
45
|
+
const child = node.namedChild(i);
|
|
46
|
+
if (child?.type === 'export_clause') {
|
|
47
|
+
this.extractExportClauseSymbols(child, addExport);
|
|
48
|
+
}
|
|
49
|
+
}
|
|
50
|
+
}
|
|
51
|
+
/**
|
|
52
|
+
* Extract exported names from a declaration (function, const, class, interface)
|
|
53
|
+
*/
|
|
54
|
+
extractDeclarationExports(node, addExport) {
|
|
55
|
+
// function/class/interface declaration
|
|
56
|
+
const nameNode = node.childForFieldName('name');
|
|
57
|
+
if (nameNode) {
|
|
58
|
+
addExport(nameNode.text);
|
|
59
|
+
return;
|
|
60
|
+
}
|
|
61
|
+
// lexical_declaration: const/let declarations
|
|
62
|
+
if (node.type === 'lexical_declaration' || node.type === 'variable_declaration') {
|
|
63
|
+
for (let i = 0; i < node.namedChildCount; i++) {
|
|
64
|
+
const child = node.namedChild(i);
|
|
65
|
+
if (child?.type === 'variable_declarator') {
|
|
66
|
+
const varName = child.childForFieldName('name');
|
|
67
|
+
if (varName) {
|
|
68
|
+
addExport(varName.text);
|
|
69
|
+
}
|
|
70
|
+
}
|
|
71
|
+
}
|
|
72
|
+
}
|
|
73
|
+
}
|
|
74
|
+
/**
|
|
75
|
+
* Extract symbol names from export clause: export { foo, bar as baz }
|
|
76
|
+
*/
|
|
77
|
+
extractExportClauseSymbols(node, addExport) {
|
|
78
|
+
for (let i = 0; i < node.namedChildCount; i++) {
|
|
79
|
+
const child = node.namedChild(i);
|
|
80
|
+
if (child?.type === 'export_specifier') {
|
|
81
|
+
// Use alias if present, otherwise use the name
|
|
82
|
+
const aliasNode = child.childForFieldName('alias');
|
|
83
|
+
const nameNode = child.childForFieldName('name');
|
|
84
|
+
const exported = aliasNode?.text || nameNode?.text;
|
|
85
|
+
if (exported) {
|
|
86
|
+
addExport(exported);
|
|
87
|
+
}
|
|
88
|
+
}
|
|
89
|
+
}
|
|
90
|
+
}
|
|
91
|
+
}
|
|
92
|
+
/**
|
|
93
|
+
* TypeScript uses the same export extraction as JavaScript
|
|
94
|
+
*/
|
|
95
|
+
export class TypeScriptExportExtractor extends JavaScriptExportExtractor {
|
|
96
|
+
}
|
|
97
|
+
//# sourceMappingURL=javascript.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"javascript.js","sourceRoot":"","sources":["../../../../src/indexer/ast/extractors/javascript.ts"],"names":[],"mappings":"AAGA;;;;;;;;GAQG;AACH,MAAM,OAAO,yBAAyB;IACpC,cAAc,CAAC,QAA2B;QACxC,MAAM,OAAO,GAAa,EAAE,CAAC;QAC7B,MAAM,IAAI,GAAG,IAAI,GAAG,EAAU,CAAC;QAE/B,MAAM,SAAS,GAAG,CAAC,IAAY,EAAE,EAAE;YACjC,IAAI,IAAI,IAAI,CAAC,IAAI,CAAC,GAAG,CAAC,IAAI,CAAC,EAAE,CAAC;gBAC5B,IAAI,CAAC,GAAG,CAAC,IAAI,CAAC,CAAC;g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ACjD,MAAM,QAAQ,GAAG,SAAS,EAAE,IAAI,IAAI,QAAQ,EAAE,IAAI,CAAC;gBACnD,IAAI,QAAQ,EAAE,CAAC;oBACb,SAAS,CAAC,QAAQ,CAAC,CAAC;gBACtB,CAAC;YACH,CAAC;QACH,CAAC;IACH,CAAC;CACF;AAED;;GAEG;AACH,MAAM,OAAO,yBAA0B,SAAQ,yBAAyB;CAAG"}
|
|
@@ -0,0 +1,34 @@
|
|
|
1
|
+
import type Parser from 'tree-sitter';
|
|
2
|
+
import type { LanguageExportExtractor } from './types.js';
|
|
3
|
+
/**
|
|
4
|
+
* PHP export extractor
|
|
5
|
+
*
|
|
6
|
+
* PHP doesn't have explicit export syntax. All top-level declarations are
|
|
7
|
+
* considered exported (accessible via `use` statements):
|
|
8
|
+
* - Classes: class User {}
|
|
9
|
+
* - Traits: trait HasTimestamps {}
|
|
10
|
+
* - Interfaces: interface Repository {}
|
|
11
|
+
* - Functions: function helper() {}
|
|
12
|
+
* - Namespaced declarations are also tracked
|
|
13
|
+
*/
|
|
14
|
+
export declare class PHPExportExtractor implements LanguageExportExtractor {
|
|
15
|
+
/**
|
|
16
|
+
* Node types that represent exportable PHP declarations
|
|
17
|
+
*/
|
|
18
|
+
private readonly exportableTypes;
|
|
19
|
+
extractExports(rootNode: Parser.SyntaxNode): string[];
|
|
20
|
+
/**
|
|
21
|
+
* Extract PHP exports from a single AST node
|
|
22
|
+
* Handles both direct declarations and namespace definitions
|
|
23
|
+
*/
|
|
24
|
+
private extractExportsFromNode;
|
|
25
|
+
/**
|
|
26
|
+
* Extract exports from within a PHP namespace definition
|
|
27
|
+
*/
|
|
28
|
+
private extractExportsFromNamespace;
|
|
29
|
+
/**
|
|
30
|
+
* Extract the name from a PHP exportable declaration (class, trait, interface, function)
|
|
31
|
+
*/
|
|
32
|
+
private extractExportableDeclaration;
|
|
33
|
+
}
|
|
34
|
+
//# sourceMappingURL=php.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"php.d.ts","sourceRoot":"","sources":["../../../../src/indexer/ast/extractors/php.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,MAAM,MAAM,aAAa,CAAC;AACtC,OAAO,KAAK,EAAE,uBAAuB,EAAE,MAAM,YAAY,CAAC;AAE1D;;;;;;;;;;GAUG;AACH,qBAAa,kBAAmB,YAAW,uBAAuB;IAChE;;OAEG;IACH,OAAO,CAAC,QAAQ,CAAC,eAAe,CAK7B;IAEH,cAAc,CAAC,QAAQ,EAAE,MAAM,CAAC,UAAU,GAAG,MAAM,EAAE;IAoBrD;;;OAGG;IACH,OAAO,CAAC,sBAAsB;IAS9B;;OAEG;IACH,OAAO,CAAC,2BAA2B;IAiBnC;;OAEG;IACH,OAAO,CAAC,4BAA4B;CAQrC"}
|
|
@@ -0,0 +1,79 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* PHP export extractor
|
|
3
|
+
*
|
|
4
|
+
* PHP doesn't have explicit export syntax. All top-level declarations are
|
|
5
|
+
* considered exported (accessible via `use` statements):
|
|
6
|
+
* - Classes: class User {}
|
|
7
|
+
* - Traits: trait HasTimestamps {}
|
|
8
|
+
* - Interfaces: interface Repository {}
|
|
9
|
+
* - Functions: function helper() {}
|
|
10
|
+
* - Namespaced declarations are also tracked
|
|
11
|
+
*/
|
|
12
|
+
export class PHPExportExtractor {
|
|
13
|
+
/**
|
|
14
|
+
* Node types that represent exportable PHP declarations
|
|
15
|
+
*/
|
|
16
|
+
exportableTypes = new Set([
|
|
17
|
+
'class_declaration',
|
|
18
|
+
'trait_declaration',
|
|
19
|
+
'interface_declaration',
|
|
20
|
+
'function_definition',
|
|
21
|
+
]);
|
|
22
|
+
extractExports(rootNode) {
|
|
23
|
+
const exports = [];
|
|
24
|
+
const seen = new Set();
|
|
25
|
+
for (let i = 0; i < rootNode.namedChildCount; i++) {
|
|
26
|
+
const child = rootNode.namedChild(i);
|
|
27
|
+
if (!child)
|
|
28
|
+
continue;
|
|
29
|
+
const childExports = this.extractExportsFromNode(child);
|
|
30
|
+
childExports.forEach(exp => {
|
|
31
|
+
if (exp && !seen.has(exp)) {
|
|
32
|
+
seen.add(exp);
|
|
33
|
+
exports.push(exp);
|
|
34
|
+
}
|
|
35
|
+
});
|
|
36
|
+
}
|
|
37
|
+
return exports;
|
|
38
|
+
}
|
|
39
|
+
/**
|
|
40
|
+
* Extract PHP exports from a single AST node
|
|
41
|
+
* Handles both direct declarations and namespace definitions
|
|
42
|
+
*/
|
|
43
|
+
extractExportsFromNode(node) {
|
|
44
|
+
if (node.type === 'namespace_definition') {
|
|
45
|
+
return this.extractExportsFromNamespace(node);
|
|
46
|
+
}
|
|
47
|
+
const name = this.extractExportableDeclaration(node);
|
|
48
|
+
return name ? [name] : [];
|
|
49
|
+
}
|
|
50
|
+
/**
|
|
51
|
+
* Extract exports from within a PHP namespace definition
|
|
52
|
+
*/
|
|
53
|
+
extractExportsFromNamespace(node) {
|
|
54
|
+
const exports = [];
|
|
55
|
+
const body = node.childForFieldName('body');
|
|
56
|
+
if (body) {
|
|
57
|
+
for (let i = 0; i < body.namedChildCount; i++) {
|
|
58
|
+
const child = body.namedChild(i);
|
|
59
|
+
if (child) {
|
|
60
|
+
const name = this.extractExportableDeclaration(child);
|
|
61
|
+
if (name)
|
|
62
|
+
exports.push(name);
|
|
63
|
+
}
|
|
64
|
+
}
|
|
65
|
+
}
|
|
66
|
+
return exports;
|
|
67
|
+
}
|
|
68
|
+
/**
|
|
69
|
+
* Extract the name from a PHP exportable declaration (class, trait, interface, function)
|
|
70
|
+
*/
|
|
71
|
+
extractExportableDeclaration(node) {
|
|
72
|
+
if (this.exportableTypes.has(node.type)) {
|
|
73
|
+
const nameNode = node.childForFieldName('name');
|
|
74
|
+
return nameNode ? nameNode.text : null;
|
|
75
|
+
}
|
|
76
|
+
return null;
|
|
77
|
+
}
|
|
78
|
+
}
|
|
79
|
+
//# sourceMappingURL=php.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file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CAAC,EAAE,CAAC;IAC5B,CAAC;IAED;;OAEG;IACK,2BAA2B,CAAC,IAAuB;QACzD,MAAM,OAAO,GAAa,EAAE,CAAC;QAC7B,MAAM,IAAI,GAAG,IAAI,CAAC,iBAAiB,CAAC,MAAM,CAAC,CAAC;QAE5C,IAAI,IAAI,EAAE,CAAC;YACT,KAAK,IAAI,CAAC,GAAG,CAAC,EAAE,CAAC,GAAG,IAAI,CAAC,eAAe,EAAE,CAAC,EAAE,EAAE,CAAC;gBAC9C,MAAM,KAAK,GAAG,IAAI,CAAC,UAAU,CAAC,CAAC,CAAC,CAAC;gBACjC,IAAI,KAAK,EAAE,CAAC;oBACV,MAAM,IAAI,GAAG,IAAI,CAAC,4BAA4B,CAAC,KAAK,CAAC,CAAC;oBACtD,IAAI,IAAI;wBAAE,OAAO,CAAC,IAAI,CAAC,IAAI,CAAC,CAAC;gBAC/B,CAAC;YACH,CAAC;QACH,CAAC;QAED,OAAO,OAAO,CAAC;IACjB,CAAC;IAED;;OAEG;IACK,4BAA4B,CAAC,IAAuB;QAC1D,IAAI,IAAI,CAAC,eAAe,CAAC,GAAG,CAAC,IAAI,CAAC,IAAI,CAAC,EAAE,CAAC;YACxC,MAAM,QAAQ,GAAG,IAAI,CAAC,iBAAiB,CAAC,MAAM,CAAC,CAAC;YAChD,OAAO,QAAQ,CAAC,CAAC,CAAC,QAAQ,CAAC,IAAI,CAAC,CAAC,CAAC,IAAI,CAAC;QACzC,CAAC;QAED,OAAO,IAAI,CAAC;IACd,CAAC;CACF"}
|
|
@@ -0,0 +1,22 @@
|
|
|
1
|
+
import type Parser from 'tree-sitter';
|
|
2
|
+
import type { LanguageExportExtractor } from './types.js';
|
|
3
|
+
/**
|
|
4
|
+
* Python export extractor
|
|
5
|
+
*
|
|
6
|
+
* Python doesn't have explicit export syntax. All module-level (top-level)
|
|
7
|
+
* declarations are considered exported (importable by other modules):
|
|
8
|
+
* - Classes: class User: ...
|
|
9
|
+
* - Functions: def helper(): ...
|
|
10
|
+
* - Async functions: async def fetch_data(): ...
|
|
11
|
+
*
|
|
12
|
+
* Note: Only top-level definitions are tracked. Nested functions/classes
|
|
13
|
+
* inside other functions are not considered exports.
|
|
14
|
+
*/
|
|
15
|
+
export declare class PythonExportExtractor implements LanguageExportExtractor {
|
|
16
|
+
/**
|
|
17
|
+
* Node types that represent exportable Python declarations
|
|
18
|
+
*/
|
|
19
|
+
private readonly exportableTypes;
|
|
20
|
+
extractExports(rootNode: Parser.SyntaxNode): string[];
|
|
21
|
+
}
|
|
22
|
+
//# sourceMappingURL=python.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"python.d.ts","sourceRoot":"","sources":["../../../../src/indexer/ast/extractors/python.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,MAAM,MAAM,aAAa,CAAC;AACtC,OAAO,KAAK,EAAE,uBAAuB,EAAE,MAAM,YAAY,CAAC;AAE1D;;;;;;;;;;;GAWG;AACH,qBAAa,qBAAsB,YAAW,uBAAuB;IACnE;;OAEG;IACH,OAAO,CAAC,QAAQ,CAAC,eAAe,CAI7B;IAEH,cAAc,CAAC,QAAQ,EAAE,MAAM,CAAC,UAAU,GAAG,MAAM,EAAE;CAoCtD"}
|
|
@@ -0,0 +1,57 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Python export extractor
|
|
3
|
+
*
|
|
4
|
+
* Python doesn't have explicit export syntax. All module-level (top-level)
|
|
5
|
+
* declarations are considered exported (importable by other modules):
|
|
6
|
+
* - Classes: class User: ...
|
|
7
|
+
* - Functions: def helper(): ...
|
|
8
|
+
* - Async functions: async def fetch_data(): ...
|
|
9
|
+
*
|
|
10
|
+
* Note: Only top-level definitions are tracked. Nested functions/classes
|
|
11
|
+
* inside other functions are not considered exports.
|
|
12
|
+
*/
|
|
13
|
+
export class PythonExportExtractor {
|
|
14
|
+
/**
|
|
15
|
+
* Node types that represent exportable Python declarations
|
|
16
|
+
*/
|
|
17
|
+
exportableTypes = new Set([
|
|
18
|
+
'class_definition',
|
|
19
|
+
'function_definition',
|
|
20
|
+
'async_function_definition',
|
|
21
|
+
]);
|
|
22
|
+
extractExports(rootNode) {
|
|
23
|
+
const exports = [];
|
|
24
|
+
const seen = new Set();
|
|
25
|
+
const addExport = (name) => {
|
|
26
|
+
if (name && !seen.has(name)) {
|
|
27
|
+
seen.add(name);
|
|
28
|
+
exports.push(name);
|
|
29
|
+
}
|
|
30
|
+
};
|
|
31
|
+
// Process only top-level nodes (module-level definitions)
|
|
32
|
+
for (let i = 0; i < rootNode.namedChildCount; i++) {
|
|
33
|
+
const child = rootNode.namedChild(i);
|
|
34
|
+
if (!child)
|
|
35
|
+
continue;
|
|
36
|
+
// Handle decorated definitions (@dataclass, @property, etc.)
|
|
37
|
+
// Decorators wrap the actual definition in a 'decorated_definition' node
|
|
38
|
+
if (child.type === 'decorated_definition') {
|
|
39
|
+
const definition = child.childForFieldName('definition');
|
|
40
|
+
if (definition && this.exportableTypes.has(definition.type)) {
|
|
41
|
+
const nameNode = definition.childForFieldName('name');
|
|
42
|
+
if (nameNode)
|
|
43
|
+
addExport(nameNode.text);
|
|
44
|
+
}
|
|
45
|
+
continue;
|
|
46
|
+
}
|
|
47
|
+
// Extract name from exportable node types
|
|
48
|
+
if (this.exportableTypes.has(child.type)) {
|
|
49
|
+
const nameNode = child.childForFieldName('name');
|
|
50
|
+
if (nameNode)
|
|
51
|
+
addExport(nameNode.text);
|
|
52
|
+
}
|
|
53
|
+
}
|
|
54
|
+
return exports;
|
|
55
|
+
}
|
|
56
|
+
}
|
|
57
|
+
//# sourceMappingURL=python.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"python.js","sourceRoot":"","sources":["../../../../src/indexer/ast/extractors/python.ts"],"names":[],"mappings":"AAGA;;;;;;;;;;;GAWG;AACH,MAAM,OAAO,qBAAqB;IAChC;;OAEG;IACc,eAAe,GAAG,IAAI,GAAG,CAAC;QACzC,kBAAkB;QAClB,qBAAqB;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D,IAAI,QAAQ;oBAAE,SAAS,CAAC,QAAQ,CAAC,IAAI,CAAC,CAAC;YACzC,CAAC;QACH,CAAC;QAED,OAAO,OAAO,CAAC;IACjB,CAAC;CACF"}
|
|
@@ -0,0 +1,52 @@
|
|
|
1
|
+
import type Parser from 'tree-sitter';
|
|
2
|
+
/**
|
|
3
|
+
* Language-specific export extraction strategy
|
|
4
|
+
*
|
|
5
|
+
* Each language has different export semantics:
|
|
6
|
+
* - JavaScript/TypeScript: Explicit export statements
|
|
7
|
+
* - PHP: All top-level declarations are implicitly exported
|
|
8
|
+
* - Python: All module-level declarations are implicitly exported
|
|
9
|
+
*
|
|
10
|
+
* This interface allows us to implement language-specific export extraction
|
|
11
|
+
* while keeping the core symbol extraction logic language-agnostic.
|
|
12
|
+
*
|
|
13
|
+
* @example JavaScript/TypeScript
|
|
14
|
+
* ```typescript
|
|
15
|
+
* export function validateEmail() {} // Explicit export
|
|
16
|
+
* export { foo, bar } // Named exports
|
|
17
|
+
* export default App // Default export
|
|
18
|
+
* ```
|
|
19
|
+
*
|
|
20
|
+
* @example PHP
|
|
21
|
+
* ```php
|
|
22
|
+
* class User {} // Implicitly exported
|
|
23
|
+
* function helper() {} // Implicitly exported
|
|
24
|
+
* ```
|
|
25
|
+
*
|
|
26
|
+
* @example Python
|
|
27
|
+
* ```python
|
|
28
|
+
* class User: # Implicitly exported
|
|
29
|
+
* pass
|
|
30
|
+
* def helper(): # Implicitly exported
|
|
31
|
+
* pass
|
|
32
|
+
* ```
|
|
33
|
+
*/
|
|
34
|
+
export interface LanguageExportExtractor {
|
|
35
|
+
/**
|
|
36
|
+
* Extract exported symbol names from an AST root node
|
|
37
|
+
*
|
|
38
|
+
* For JavaScript/TypeScript: Processes explicit export statements
|
|
39
|
+
* For PHP/Python: Processes top-level declarations (implicitly exported)
|
|
40
|
+
*
|
|
41
|
+
* @param rootNode - AST root node (typically 'program' or similar)
|
|
42
|
+
* @returns Array of exported symbol names (deduplicated)
|
|
43
|
+
*
|
|
44
|
+
* @example
|
|
45
|
+
* ```typescript
|
|
46
|
+
* // For: export { foo, bar }; export default App;
|
|
47
|
+
* extractExports(rootNode) // => ['foo', 'bar', 'default']
|
|
48
|
+
* ```
|
|
49
|
+
*/
|
|
50
|
+
extractExports(rootNode: Parser.SyntaxNode): string[];
|
|
51
|
+
}
|
|
52
|
+
//# sourceMappingURL=types.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"types.d.ts","sourceRoot":"","sources":["../../../../src/indexer/ast/extractors/types.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,MAAM,MAAM,aAAa,CAAC;AAEtC;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;GA+BG;AACH,MAAM,WAAW,uBAAuB;IACtC;;;;;;;;;;;;;;OAcG;IACH,cAAc,CAAC,QAAQ,EAAE,MAAM,CAAC,UAAU,GAAG,MAAM,EAAE,CAAC;CACvD"}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"types.js","sourceRoot":"","sources":["../../../../src/indexer/ast/extractors/types.ts"],"names":[],"mappings":""}
|
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import type Parser from 'tree-sitter';
|
|
2
|
-
import type { SymbolInfo } from './types.js';
|
|
2
|
+
import type { SymbolInfo, SupportedLanguage } from './types.js';
|
|
3
3
|
/**
|
|
4
4
|
* Extract symbol information from an AST node using specialized extractors
|
|
5
5
|
*
|
|
@@ -14,4 +14,75 @@ export declare function extractSymbolInfo(node: Parser.SyntaxNode, content: stri
|
|
|
14
14
|
* Extract import statements from a file
|
|
15
15
|
*/
|
|
16
16
|
export declare function extractImports(rootNode: Parser.SyntaxNode): string[];
|
|
17
|
+
/**
|
|
18
|
+
* Extract imported symbols mapped to their source paths.
|
|
19
|
+
*
|
|
20
|
+
* Returns a map like: { './validate': ['validateEmail', 'validatePhone'] }
|
|
21
|
+
*
|
|
22
|
+
* Handles various import styles across languages:
|
|
23
|
+
*
|
|
24
|
+
* TypeScript/JavaScript:
|
|
25
|
+
* - Named imports: import { foo, bar } from './module'
|
|
26
|
+
* - Default imports: import foo from './module'
|
|
27
|
+
* - Namespace imports: import * as utils from './module'
|
|
28
|
+
*
|
|
29
|
+
* Python:
|
|
30
|
+
* - from module import foo, bar
|
|
31
|
+
* - import module (module name as symbol)
|
|
32
|
+
*
|
|
33
|
+
* PHP:
|
|
34
|
+
* - use App\Models\User (class name as symbol)
|
|
35
|
+
* - use App\Services\AuthService as Auth (aliased imports)
|
|
36
|
+
*
|
|
37
|
+
* Note: Only top-level static import statements are processed. Dynamic imports
|
|
38
|
+
* (e.g., `await import('./module')`) and non-top-level imports are not tracked.
|
|
39
|
+
* TypeScript/JavaScript side-effect imports without imported symbols (e.g.,
|
|
40
|
+
* `import './styles.css'`) are also not tracked and will not appear in
|
|
41
|
+
* `importedSymbols`.
|
|
42
|
+
*/
|
|
43
|
+
export declare function extractImportedSymbols(rootNode: Parser.SyntaxNode): Record<string, string[]>;
|
|
44
|
+
/**
|
|
45
|
+
* Extract exported symbols from a file.
|
|
46
|
+
*
|
|
47
|
+
* Returns array of exported symbol names like: ['validateEmail', 'validatePhone', 'default']
|
|
48
|
+
*
|
|
49
|
+
* Language-specific behavior:
|
|
50
|
+
*
|
|
51
|
+
* **JavaScript/TypeScript:**
|
|
52
|
+
* - Named exports: export { foo, bar }
|
|
53
|
+
* - Declaration exports: export function foo() {}, export const bar = ...
|
|
54
|
+
* - Default exports: export default ...
|
|
55
|
+
* - Re-exports: export { foo } from './module'
|
|
56
|
+
*
|
|
57
|
+
* **PHP:**
|
|
58
|
+
* - All top-level classes, traits, interfaces, and functions are considered exported
|
|
59
|
+
* - PHP doesn't have explicit export syntax - all public declarations are accessible
|
|
60
|
+
*
|
|
61
|
+
* **Python:**
|
|
62
|
+
* - All module-level classes and functions are considered exported
|
|
63
|
+
* - Python doesn't have explicit export syntax - module-level names are importable
|
|
64
|
+
*
|
|
65
|
+
* Limitations:
|
|
66
|
+
* - Only static, top-level declarations are processed (direct children of the root node).
|
|
67
|
+
* - Dynamic or conditional exports/declarations are not detected.
|
|
68
|
+
*
|
|
69
|
+
* @param rootNode - AST root node
|
|
70
|
+
* @param language - Programming language (defaults to 'javascript' for backwards compatibility)
|
|
71
|
+
* @returns Array of exported symbol names
|
|
72
|
+
*/
|
|
73
|
+
export declare function extractExports(rootNode: Parser.SyntaxNode, language?: SupportedLanguage): string[];
|
|
74
|
+
/**
|
|
75
|
+
* Extract call sites within a function/method body.
|
|
76
|
+
*
|
|
77
|
+
* Returns array of function calls made within the node.
|
|
78
|
+
*
|
|
79
|
+
* Supported languages:
|
|
80
|
+
* - TypeScript/JavaScript: call_expression (foo(), obj.method())
|
|
81
|
+
* - PHP: function_call_expression, member_call_expression, scoped_call_expression
|
|
82
|
+
* - Python: call (similar to JS call_expression)
|
|
83
|
+
*/
|
|
84
|
+
export declare function extractCallSites(node: Parser.SyntaxNode): Array<{
|
|
85
|
+
symbol: string;
|
|
86
|
+
line: number;
|
|
87
|
+
}>;
|
|
17
88
|
//# sourceMappingURL=symbols.d.ts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"symbols.d.ts","sourceRoot":"","sources":["../../../src/indexer/ast/symbols.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,MAAM,MAAM,aAAa,CAAC;AACtC,OAAO,KAAK,EAAE,UAAU,EAAE,MAAM,YAAY,CAAC;
|
|
1
|
+
{"version":3,"file":"symbols.d.ts","sourceRoot":"","sources":["../../../src/indexer/ast/symbols.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,MAAM,MAAM,aAAa,CAAC;AACtC,OAAO,KAAK,EAAE,UAAU,EAAE,iBAAiB,EAAE,MAAM,YAAY,CAAC;AA4MhE;;;;;;;;GAQG;AACH,wBAAgB,iBAAiB,CAC/B,IAAI,EAAE,MAAM,CAAC,UAAU,EACvB,OAAO,EAAE,MAAM,EACf,WAAW,CAAC,EAAE,MAAM,EACpB,QAAQ,CAAC,EAAE,MAAM,GAChB,UAAU,GAAG,IAAI,CASnB;AAkED;;GAEG;AACH,wBAAgB,cAAc,CAAC,QAAQ,EAAE,MAAM,CAAC,UAAU,GAAG,MAAM,EAAE,CA2CpE;AA+CD;;;;;;;;;;;;;;;;;;;;;;;;;GAyBG;AACH,wBAAgB,sBAAsB,CAAC,QAAQ,EAAE,MAAM,CAAC,UAAU,GAAG,MAAM,CAAC,MAAM,EAAE,MAAM,EAAE,CAAC,CA0C5F;AAkRD;;;;;;;;;;;;;;;;;;;;;;;;;;;;GA4BG;AACH,wBAAgB,cAAc,CAAC,QAAQ,EAAE,MAAM,CAAC,UAAU,EAAE,QAAQ,CAAC,EAAE,iBAAiB,GAAG,MAAM,EAAE,CAKlG;AAED;;;;;;;;;GASG;AACH,wBAAgB,gBAAgB,CAAC,IAAI,EAAE,MAAM,CAAC,UAAU,GAAG,KAAK,CAAC;IAAE,MAAM,EAAE,MAAM,CAAC;IAAC,IAAI,EAAE,MAAM,CAAA;CAAE,CAAC,CAMjG"}
|