codesearch-mcp 0.3.0-alpha → 0.4.0-alpha
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/CHANGELOG.md +59 -6
- package/LICENSE +661 -21
- package/README.md +33 -17
- package/dist/app.js +13 -20
- package/dist/src/ast/CallExtractor.d.ts +8 -0
- package/dist/src/ast/CallExtractor.js +68 -0
- package/dist/src/ast/GraphqlNameExtractor.d.ts +22 -0
- package/dist/src/ast/GraphqlNameExtractor.js +240 -0
- package/dist/src/ast/ImportEdgeExtractor.d.ts +11 -0
- package/dist/src/ast/ImportEdgeExtractor.js +129 -0
- package/dist/src/ast/IndexedNodeResolver.d.ts +14 -0
- package/dist/src/ast/IndexedNodeResolver.js +217 -0
- package/dist/src/ast/MemberExtractor.d.ts +8 -0
- package/dist/src/ast/MemberExtractor.js +129 -0
- package/dist/src/ast/TopLevelSymbolExtractor.d.ts +5 -0
- package/dist/src/ast/TopLevelSymbolExtractor.js +86 -0
- package/dist/src/ast/graphql-grammar.d.ts +24 -0
- package/dist/src/ast/graphql-grammar.js +93 -0
- package/dist/src/ast/node-helpers.d.ts +11 -0
- package/dist/src/ast/node-helpers.js +55 -0
- package/dist/src/commands/EvalCommand.d.ts +7 -3
- package/dist/src/commands/EvalCommand.js +36 -158
- package/dist/src/commands/IndexCommand.d.ts +10 -4
- package/dist/src/commands/IndexCommand.js +52 -124
- package/dist/src/commands/McpCommand.d.ts +6 -3
- package/dist/src/commands/McpCommand.js +19 -14
- package/dist/src/commands/WebCommand.d.ts +9 -3
- package/dist/src/commands/WebCommand.js +17 -8
- package/dist/src/commands/eval/baseline-comparison.d.ts +6 -0
- package/dist/src/commands/eval/baseline-comparison.js +54 -0
- package/dist/src/commands/eval/eval-args.d.ts +6 -0
- package/dist/src/commands/eval/eval-args.js +71 -0
- package/dist/src/commands/eval/eval-corpora.d.ts +6 -0
- package/dist/src/commands/eval/eval-corpora.js +76 -0
- package/dist/src/commands/eval/eval-metadata.d.ts +17 -0
- package/dist/src/commands/eval/eval-metadata.js +75 -0
- package/dist/src/commands/eval/index-inspector.d.ts +3 -0
- package/dist/src/commands/eval/index-inspector.js +21 -0
- package/dist/src/commands/eval/staged-search.d.ts +3 -0
- package/dist/src/commands/eval/staged-search.js +20 -0
- package/dist/src/commands/eval/suite-loader.d.ts +8 -0
- package/dist/src/commands/eval/suite-loader.js +52 -0
- package/dist/src/commands/index/backend-probe.d.ts +2 -0
- package/dist/src/commands/index/backend-probe.js +15 -0
- package/dist/src/commands/index/embedding-setup.d.ts +3 -0
- package/dist/src/commands/index/embedding-setup.js +16 -0
- package/dist/src/commands/index/index-summary.d.ts +2 -0
- package/dist/src/commands/index/index-summary.js +22 -0
- package/dist/src/commands/index/legacy-ollama-guard.d.ts +3 -0
- package/dist/src/commands/index/legacy-ollama-guard.js +23 -0
- package/dist/src/commands/index/prune-step.d.ts +3 -0
- package/dist/src/commands/index/prune-step.js +22 -0
- package/dist/src/commands/index/scan-targets.d.ts +8 -0
- package/dist/src/commands/index/scan-targets.js +107 -0
- package/dist/src/config-store.d.ts +0 -1
- package/dist/src/config-store.js +3 -4
- package/dist/src/config.d.ts +1 -1
- package/dist/src/config.js +1 -1
- package/dist/src/constants.d.ts +15 -0
- package/dist/src/constants.js +34 -6
- package/dist/src/container.d.ts +4 -2
- package/dist/src/container.js +7 -5
- package/dist/src/db/drizzle-types.d.ts +7 -0
- package/dist/src/db/index.d.ts +1 -0
- package/dist/src/db/schema-steps.d.ts +8 -0
- package/dist/src/db/schema-steps.js +105 -0
- package/dist/src/declarations/DeclarationTree.d.ts +1 -1
- package/dist/src/eval-results.js +16 -2
- package/dist/src/eval-vector-index.d.ts +5 -0
- package/dist/src/eval-vector-index.js +60 -0
- package/dist/src/help.js +9 -1
- package/dist/src/index-args.d.ts +13 -0
- package/dist/src/index-args.js +48 -0
- package/dist/src/indexing/AnalysisBatcher.d.ts +12 -0
- package/dist/src/indexing/AnalysisBatcher.js +28 -0
- package/dist/src/indexing/ChunkEmbedder.d.ts +24 -0
- package/dist/src/indexing/ChunkEmbedder.js +37 -0
- package/dist/src/indexing/ConsoleScanReporter.d.ts +10 -0
- package/dist/src/indexing/ConsoleScanReporter.js +73 -0
- package/dist/src/indexing/EmbeddingSchemaPreparer.d.ts +14 -0
- package/dist/src/indexing/EmbeddingSchemaPreparer.js +66 -0
- package/dist/src/indexing/FileIngestor.d.ts +22 -0
- package/dist/src/indexing/FileIngestor.js +116 -0
- package/dist/src/indexing/IndexStore.d.ts +24 -0
- package/dist/src/indexing/IndexStore.js +69 -0
- package/dist/src/indexing/StaleFilePruner.d.ts +8 -0
- package/dist/src/indexing/StaleFilePruner.js +55 -0
- package/dist/src/indexing/analysis-rows.d.ts +4 -0
- package/dist/src/indexing/analysis-rows.js +65 -0
- package/dist/src/indexing/project-notices.d.ts +2 -0
- package/dist/src/indexing/project-notices.js +63 -0
- package/dist/src/interfaces/IAstParser.d.ts +2 -1
- package/dist/src/interfaces/ICallGraph.d.ts +28 -0
- package/dist/src/interfaces/ICallGraph.js +2 -0
- package/dist/src/interfaces/IChunkSearch.d.ts +42 -0
- package/dist/src/interfaces/IChunkSearch.js +2 -0
- package/dist/src/interfaces/IDatabase.d.ts +6 -2
- package/dist/src/interfaces/IDependencyGraph.d.ts +24 -0
- package/dist/src/interfaces/IDependencyGraph.js +2 -0
- package/dist/src/interfaces/IIndexIdentityGuard.d.ts +3 -0
- package/dist/src/interfaces/IIndexIdentityGuard.js +2 -0
- package/dist/src/interfaces/IIndexedNodeResolver.d.ts +10 -0
- package/dist/src/interfaces/IIndexedNodeResolver.js +2 -0
- package/dist/src/interfaces/IMcpReadiness.d.ts +12 -0
- package/dist/src/interfaces/IMcpReadiness.js +2 -0
- package/dist/src/interfaces/IProjectCatalog.d.ts +13 -0
- package/dist/src/interfaces/IProjectCatalog.js +2 -0
- package/dist/src/interfaces/IProjectRoots.d.ts +3 -0
- package/dist/src/interfaces/IProjectRoots.js +2 -0
- package/dist/src/interfaces/IRetrievalEvaluator.d.ts +21 -2
- package/dist/src/interfaces/IScanReporter.d.ts +13 -0
- package/dist/src/interfaces/IScanReporter.js +2 -0
- package/dist/src/interfaces/ISymbolLookup.d.ts +49 -0
- package/dist/src/interfaces/ISymbolLookup.js +2 -0
- package/dist/src/interfaces/IToolPaths.d.ts +62 -0
- package/dist/src/interfaces/IToolPaths.js +2 -0
- package/dist/src/interfaces/IWorkspaceFiles.d.ts +28 -0
- package/dist/src/interfaces/IWorkspaceFiles.js +2 -0
- package/dist/src/interfaces/SymbolKind.d.ts +1 -0
- package/dist/src/interfaces/SymbolKind.js +2 -0
- package/dist/src/interfaces/index.d.ts +12 -1
- package/dist/src/project-scope.d.ts +1 -0
- package/dist/src/project-scope.js +5 -0
- package/dist/src/retrieval-eval.d.ts +2 -1
- package/dist/src/retrieval-eval.js +45 -2
- package/dist/src/search/CallGraph.d.ts +9 -0
- package/dist/src/search/CallGraph.js +84 -0
- package/dist/src/search/ChunkSearch.d.ts +23 -0
- package/dist/src/search/ChunkSearch.js +115 -0
- package/dist/src/search/DependencyGraph.d.ts +19 -0
- package/dist/src/search/DependencyGraph.js +180 -0
- package/dist/src/search/IndexIdentityGuard.d.ts +11 -0
- package/dist/src/search/IndexIdentityGuard.js +37 -0
- package/dist/src/search/ProjectCatalog.d.ts +11 -0
- package/dist/src/search/ProjectCatalog.js +38 -0
- package/dist/src/search/SymbolLookup.d.ts +24 -0
- package/dist/src/search/SymbolLookup.js +97 -0
- package/dist/src/search/chunks/CandidateFetcher.d.ts +19 -0
- package/dist/src/search/chunks/CandidateFetcher.js +40 -0
- package/dist/src/search/chunks/IterativeScanGate.d.ts +10 -0
- package/dist/src/search/chunks/IterativeScanGate.js +42 -0
- package/dist/src/search/chunks/RerankStage.d.ts +15 -0
- package/dist/src/search/chunks/RerankStage.js +42 -0
- package/dist/src/search/chunks/search-metrics.d.ts +18 -0
- package/dist/src/search/chunks/search-metrics.js +32 -0
- package/dist/src/search/chunks/search-plan.d.ts +18 -0
- package/dist/src/search/chunks/search-plan.js +19 -0
- package/dist/src/search/create-search-services.d.ts +26 -0
- package/dist/src/search/create-search-services.js +29 -0
- package/dist/src/search/index-paths.d.ts +1 -0
- package/dist/src/search/index-paths.js +5 -0
- package/dist/src/search/symbol-sql.d.ts +13 -0
- package/dist/src/search/symbol-sql.js +66 -0
- package/dist/src/search/symbols/SymbolGrepFallback.d.ts +19 -0
- package/dist/src/search/symbols/SymbolGrepFallback.js +106 -0
- package/dist/src/search/symbols/SymbolIndexQuery.d.ts +14 -0
- package/dist/src/search/symbols/SymbolIndexQuery.js +52 -0
- package/dist/src/search/symbols/SymbolTextSearch.d.ts +13 -0
- package/dist/src/search/symbols/SymbolTextSearch.js +84 -0
- package/dist/src/search/symbols/TargetColumnGate.d.ts +7 -0
- package/dist/src/search/symbols/TargetColumnGate.js +23 -0
- package/dist/src/search/symbols/find-symbol-constants.d.ts +4 -0
- package/dist/src/search/symbols/find-symbol-constants.js +8 -0
- package/dist/src/search/symbols/grep-args.d.ts +3 -0
- package/dist/src/search/symbols/grep-args.js +7 -0
- package/dist/src/search/symbols/grep-patterns.d.ts +4 -0
- package/dist/src/search/symbols/grep-patterns.js +60 -0
- package/dist/src/services/AstParserService.d.ts +8 -44
- package/dist/src/services/AstParserService.js +19 -938
- package/dist/src/services/DatabaseService.d.ts +8 -10
- package/dist/src/services/DatabaseService.js +29 -86
- package/dist/src/services/IndexerService.d.ts +7 -10
- package/dist/src/services/IndexerService.js +36 -255
- package/dist/src/services/McpReadiness.d.ts +18 -0
- package/dist/src/services/McpReadiness.js +73 -0
- package/dist/src/services/McpServer.d.ts +32 -9
- package/dist/src/services/McpServer.js +78 -41
- package/dist/src/services/WebServerService.d.ts +4 -3
- package/dist/src/services/WebServerService.js +16 -8
- package/dist/src/setup.d.ts +16 -4
- package/dist/src/setup.js +115 -40
- package/dist/src/symbol-name.d.ts +1 -0
- package/dist/src/symbol-name.js +16 -12
- package/dist/src/tools/FindSymbolTool.d.ts +17 -7
- package/dist/src/tools/FindSymbolTool.js +54 -35
- package/dist/src/tools/GetCallersTool.d.ts +16 -8
- package/dist/src/tools/GetCallersTool.js +65 -35
- package/dist/src/tools/GetDependenciesTool.d.ts +16 -8
- package/dist/src/tools/GetDependenciesTool.js +35 -28
- package/dist/src/tools/GetDependentsTool.d.ts +20 -8
- package/dist/src/tools/GetDependentsTool.js +47 -33
- package/dist/src/tools/ListFilesTool.d.ts +16 -8
- package/dist/src/tools/ListFilesTool.js +20 -26
- package/dist/src/tools/ListProjectsTool.d.ts +11 -7
- package/dist/src/tools/ListProjectsTool.js +13 -11
- package/dist/src/tools/McpTool.d.ts +17 -0
- package/dist/src/tools/McpTool.js +28 -0
- package/dist/src/tools/ReadFileRangeTool.d.ts +16 -8
- package/dist/src/tools/ReadFileRangeTool.js +23 -25
- package/dist/src/tools/ReadFileTool.d.ts +15 -8
- package/dist/src/tools/ReadFileTool.js +19 -24
- package/dist/src/tools/SearchCodebaseTool.d.ts +22 -10
- package/dist/src/tools/SearchCodebaseTool.js +69 -51
- package/dist/src/tools/format-helpers.d.ts +9 -3
- package/dist/src/tools/format-helpers.js +59 -14
- package/dist/src/tools/tool-args.d.ts +38 -0
- package/dist/src/tools/tool-args.js +95 -0
- package/dist/src/workspace/GrepRunner.d.ts +15 -0
- package/dist/src/workspace/GrepRunner.js +104 -0
- package/dist/src/workspace/ProjectRoots.d.ts +22 -0
- package/dist/src/workspace/ProjectRoots.js +102 -0
- package/dist/src/workspace/ToolPaths.d.ts +31 -0
- package/dist/src/workspace/ToolPaths.js +312 -0
- package/dist/src/workspace/WorkspaceFiles.d.ts +19 -0
- package/dist/src/workspace/WorkspaceFiles.js +285 -0
- package/dist/src/workspace/fs-access.d.ts +9 -0
- package/dist/src/workspace/fs-access.js +47 -0
- package/dist/src/workspace/path-helpers.d.ts +3 -0
- package/dist/src/workspace/path-helpers.js +43 -0
- package/package.json +4 -3
- package/dist/src/interfaces/ISearcher.d.ts +0 -46
- package/dist/src/services/SearcherService.d.ts +0 -235
- package/dist/src/services/SearcherService.js +0 -1118
- /package/dist/src/{interfaces/ISearcher.js → db/drizzle-types.js} +0 -0
|
@@ -0,0 +1,129 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.ImportEdgeExtractor = void 0;
|
|
4
|
+
const ts_morph_1 = require("ts-morph");
|
|
5
|
+
class ImportEdgeExtractor {
|
|
6
|
+
logger;
|
|
7
|
+
constructor(logger) {
|
|
8
|
+
this.logger = logger;
|
|
9
|
+
}
|
|
10
|
+
extractEdges(sourceFile, filePath, serviceName) {
|
|
11
|
+
const edges = [];
|
|
12
|
+
const usageMap = this.buildUsageMap(sourceFile);
|
|
13
|
+
for (const decl of sourceFile.getImportDeclarations()) {
|
|
14
|
+
const namedImports = decl.getNamedImports();
|
|
15
|
+
const defaultImport = decl.getDefaultImport();
|
|
16
|
+
const namespaceImport = decl.getNamespaceImport();
|
|
17
|
+
const hasClause = Boolean(defaultImport || namespaceImport || namedImports.length > 0);
|
|
18
|
+
const resolved = decl.getModuleSpecifierSourceFile();
|
|
19
|
+
let toFile = resolved ? resolved.getFilePath() : null;
|
|
20
|
+
if (!toFile && !hasClause) {
|
|
21
|
+
toFile = this.resolveSideEffectModuleSpecifier(decl, sourceFile, filePath);
|
|
22
|
+
}
|
|
23
|
+
if (!toFile) {
|
|
24
|
+
const specifier = decl.getModuleSpecifierValue();
|
|
25
|
+
const isCodeImport = !/\.(json|css|scss|less|svg|png|jpg|gif|ico|woff2?|ttf|eot)(\?.*)?$/.test(specifier);
|
|
26
|
+
if (specifier.startsWith('.') && isCodeImport) {
|
|
27
|
+
this.logger.debug('AstParser: unresolved import', { specifier, file: filePath });
|
|
28
|
+
}
|
|
29
|
+
continue;
|
|
30
|
+
}
|
|
31
|
+
if (toFile.includes('/node_modules/'))
|
|
32
|
+
continue;
|
|
33
|
+
if (!hasClause) {
|
|
34
|
+
edges.push({
|
|
35
|
+
project: serviceName, fromFile: filePath, fromSymbol: null,
|
|
36
|
+
toFile, toSymbol: null, depType: 'import-side-effect',
|
|
37
|
+
});
|
|
38
|
+
continue;
|
|
39
|
+
}
|
|
40
|
+
if (defaultImport) {
|
|
41
|
+
const fromSymbol = this.resolveFromSymbol(defaultImport.getText(), usageMap);
|
|
42
|
+
edges.push({
|
|
43
|
+
project: serviceName, fromFile: filePath, fromSymbol,
|
|
44
|
+
toFile, toSymbol: null, depType: 'import-default',
|
|
45
|
+
});
|
|
46
|
+
}
|
|
47
|
+
if (namespaceImport) {
|
|
48
|
+
const fromSymbol = this.resolveFromSymbol(namespaceImport.getText(), usageMap);
|
|
49
|
+
edges.push({
|
|
50
|
+
project: serviceName, fromFile: filePath, fromSymbol,
|
|
51
|
+
toFile, toSymbol: null, depType: 'import-namespace',
|
|
52
|
+
});
|
|
53
|
+
}
|
|
54
|
+
for (const named of namedImports) {
|
|
55
|
+
const localName = named.getAliasNode()?.getText() ?? named.getName();
|
|
56
|
+
const fromSymbol = this.resolveFromSymbol(localName, usageMap);
|
|
57
|
+
edges.push({
|
|
58
|
+
project: serviceName, fromFile: filePath, fromSymbol,
|
|
59
|
+
toFile, toSymbol: named.getName(), depType: 'import',
|
|
60
|
+
});
|
|
61
|
+
}
|
|
62
|
+
}
|
|
63
|
+
for (const decl of sourceFile.getExportDeclarations()) {
|
|
64
|
+
const resolved = decl.getModuleSpecifierSourceFile();
|
|
65
|
+
if (!resolved)
|
|
66
|
+
continue;
|
|
67
|
+
const toFile = resolved.getFilePath();
|
|
68
|
+
if (toFile.includes('/node_modules/'))
|
|
69
|
+
continue;
|
|
70
|
+
const namedExports = decl.getNamedExports();
|
|
71
|
+
if (namedExports.length > 0) {
|
|
72
|
+
for (const named of namedExports) {
|
|
73
|
+
edges.push({
|
|
74
|
+
project: serviceName, fromFile: filePath, fromSymbol: null,
|
|
75
|
+
toFile, toSymbol: named.getName(), depType: 'reexport',
|
|
76
|
+
});
|
|
77
|
+
}
|
|
78
|
+
}
|
|
79
|
+
else {
|
|
80
|
+
edges.push({
|
|
81
|
+
project: serviceName, fromFile: filePath, fromSymbol: null,
|
|
82
|
+
toFile, toSymbol: null, depType: 'reexport-namespace',
|
|
83
|
+
});
|
|
84
|
+
}
|
|
85
|
+
}
|
|
86
|
+
return edges;
|
|
87
|
+
}
|
|
88
|
+
resolveSideEffectModuleSpecifier(decl, sourceFile, filePath) {
|
|
89
|
+
const specifier = decl.getModuleSpecifierValue();
|
|
90
|
+
const compilerOptions = sourceFile.getProject().getCompilerOptions();
|
|
91
|
+
const result = ts_morph_1.ts.resolveModuleName(specifier, filePath, compilerOptions, ts_morph_1.ts.sys);
|
|
92
|
+
const resolvedFileName = result.resolvedModule?.resolvedFileName;
|
|
93
|
+
if (!resolvedFileName)
|
|
94
|
+
return null;
|
|
95
|
+
return sourceFile.getProject().getSourceFile(resolvedFileName)?.getFilePath() ?? null;
|
|
96
|
+
}
|
|
97
|
+
resolveFromSymbol(localName, usageMap) {
|
|
98
|
+
const users = usageMap.get(localName);
|
|
99
|
+
return users?.length === 1 ? users[0] : null;
|
|
100
|
+
}
|
|
101
|
+
buildUsageMap(sourceFile) {
|
|
102
|
+
const map = new Map();
|
|
103
|
+
const containers = [
|
|
104
|
+
...sourceFile.getClasses().flatMap(n => n.getName() ? [{ name: n.getName(), node: n }] : []),
|
|
105
|
+
...sourceFile.getFunctions().flatMap(n => n.getName() ? [{ name: n.getName(), node: n }] : []),
|
|
106
|
+
...sourceFile.getVariableStatements()
|
|
107
|
+
.flatMap(stmt => stmt.getDeclarations())
|
|
108
|
+
.flatMap(n => {
|
|
109
|
+
const name = n.getName();
|
|
110
|
+
return name ? [{ name, node: n }] : [];
|
|
111
|
+
}),
|
|
112
|
+
];
|
|
113
|
+
for (const { name, node } of containers) {
|
|
114
|
+
for (const id of node.getDescendantsOfKind(ts_morph_1.SyntaxKind.Identifier)) {
|
|
115
|
+
const text = id.getText();
|
|
116
|
+
const existing = map.get(text);
|
|
117
|
+
if (existing) {
|
|
118
|
+
if (!existing.includes(name))
|
|
119
|
+
existing.push(name);
|
|
120
|
+
}
|
|
121
|
+
else {
|
|
122
|
+
map.set(text, [name]);
|
|
123
|
+
}
|
|
124
|
+
}
|
|
125
|
+
}
|
|
126
|
+
return map;
|
|
127
|
+
}
|
|
128
|
+
}
|
|
129
|
+
exports.ImportEdgeExtractor = ImportEdgeExtractor;
|
|
@@ -0,0 +1,14 @@
|
|
|
1
|
+
import { Node } from 'ts-morph';
|
|
2
|
+
import type { IIndexedNodeResolver, IndexedNodeDescription } from '../interfaces/IIndexedNodeResolver';
|
|
3
|
+
export declare class IndexedNodeResolver implements IIndexedNodeResolver {
|
|
4
|
+
private static isValidSegment;
|
|
5
|
+
private isModuleOrNamespaceLevelVariable;
|
|
6
|
+
private classExpressionRoot;
|
|
7
|
+
private objectLiteralRootValid;
|
|
8
|
+
private isTopLevelOrNamespaceDirect;
|
|
9
|
+
private walkStep;
|
|
10
|
+
private containerSegments;
|
|
11
|
+
describeIndexedNode(node: Node): IndexedNodeDescription | null;
|
|
12
|
+
qualifiedName(described: IndexedNodeDescription): string;
|
|
13
|
+
findFromSymbol(node: Node): string | null;
|
|
14
|
+
}
|
|
@@ -0,0 +1,217 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.IndexedNodeResolver = void 0;
|
|
4
|
+
const ts_morph_1 = require("ts-morph");
|
|
5
|
+
const node_helpers_1 = require("./node-helpers");
|
|
6
|
+
const VALID_SEGMENT = /^#?[\w$]+$/;
|
|
7
|
+
class IndexedNodeResolver {
|
|
8
|
+
static isValidSegment(s) {
|
|
9
|
+
return VALID_SEGMENT.test(s);
|
|
10
|
+
}
|
|
11
|
+
isModuleOrNamespaceLevelVariable(varDecl) {
|
|
12
|
+
const stmt = varDecl.getParent()?.getParent();
|
|
13
|
+
const stmtParent = stmt?.getParent();
|
|
14
|
+
return ts_morph_1.Node.isSourceFile(stmtParent) || ts_morph_1.Node.isModuleBlock(stmtParent);
|
|
15
|
+
}
|
|
16
|
+
classExpressionRoot(classExpr) {
|
|
17
|
+
const parent = (0, node_helpers_1.unwrapParent)(classExpr);
|
|
18
|
+
if (!parent)
|
|
19
|
+
return null;
|
|
20
|
+
if (ts_morph_1.Node.isVariableDeclaration(parent)) {
|
|
21
|
+
const name = parent.getName();
|
|
22
|
+
return name ? { name, namingParent: parent } : null;
|
|
23
|
+
}
|
|
24
|
+
if (ts_morph_1.Node.isExportAssignment(parent) && !parent.isExportEquals()) {
|
|
25
|
+
return { name: 'default', namingParent: parent };
|
|
26
|
+
}
|
|
27
|
+
return null;
|
|
28
|
+
}
|
|
29
|
+
objectLiteralRootValid(obj) {
|
|
30
|
+
const parent = (0, node_helpers_1.unwrapParent)(obj);
|
|
31
|
+
if (!parent)
|
|
32
|
+
return false;
|
|
33
|
+
if (ts_morph_1.Node.isPropertyAssignment(parent))
|
|
34
|
+
return true;
|
|
35
|
+
if (ts_morph_1.Node.isVariableDeclaration(parent))
|
|
36
|
+
return this.isModuleOrNamespaceLevelVariable(parent);
|
|
37
|
+
if (ts_morph_1.Node.isExportAssignment(parent) && !parent.isExportEquals())
|
|
38
|
+
return true;
|
|
39
|
+
return false;
|
|
40
|
+
}
|
|
41
|
+
isTopLevelOrNamespaceDirect(node) {
|
|
42
|
+
return ts_morph_1.Node.isSourceFile(node) || ts_morph_1.Node.isModuleBlock(node);
|
|
43
|
+
}
|
|
44
|
+
walkStep(node) {
|
|
45
|
+
if (ts_morph_1.Node.isModuleDeclaration(node)) {
|
|
46
|
+
if (node.compilerNode.flags & ts_morph_1.NodeFlags.GlobalAugmentation)
|
|
47
|
+
return { kind: 'exclude' };
|
|
48
|
+
const nameNode = node.getNameNode();
|
|
49
|
+
if (ts_morph_1.Node.isStringLiteral(nameNode))
|
|
50
|
+
return { kind: 'exclude' };
|
|
51
|
+
return { kind: 'segment', text: nameNode.getText() };
|
|
52
|
+
}
|
|
53
|
+
if (ts_morph_1.Node.isClassDeclaration(node)) {
|
|
54
|
+
const name = node.getName();
|
|
55
|
+
if (name)
|
|
56
|
+
return { kind: 'segment', text: name };
|
|
57
|
+
if (node.isDefaultExport())
|
|
58
|
+
return { kind: 'segment', text: 'default' };
|
|
59
|
+
return { kind: 'exclude' };
|
|
60
|
+
}
|
|
61
|
+
if (ts_morph_1.Node.isClassExpression(node)) {
|
|
62
|
+
const root = this.classExpressionRoot(node);
|
|
63
|
+
if (!root)
|
|
64
|
+
return { kind: 'exclude' };
|
|
65
|
+
return { kind: 'segment', text: root.name, skipTo: root.namingParent };
|
|
66
|
+
}
|
|
67
|
+
if (ts_morph_1.Node.isFunctionDeclaration(node)) {
|
|
68
|
+
const name = node.getName();
|
|
69
|
+
return name ? { kind: 'segment', text: name } : { kind: 'transparent' };
|
|
70
|
+
}
|
|
71
|
+
if (ts_morph_1.Node.isMethodDeclaration(node) || ts_morph_1.Node.isGetAccessorDeclaration(node) || ts_morph_1.Node.isSetAccessorDeclaration(node)) {
|
|
72
|
+
const name = (0, node_helpers_1.memberName)(node.getNameNode());
|
|
73
|
+
return name !== null ? { kind: 'segment', text: name } : { kind: 'exclude' };
|
|
74
|
+
}
|
|
75
|
+
if (ts_morph_1.Node.isConstructorDeclaration(node)) {
|
|
76
|
+
return { kind: 'segment', text: 'constructor' };
|
|
77
|
+
}
|
|
78
|
+
if (ts_morph_1.Node.isPropertyDeclaration(node) || ts_morph_1.Node.isPropertyAssignment(node)) {
|
|
79
|
+
const name = (0, node_helpers_1.memberName)(node.getNameNode());
|
|
80
|
+
return name !== null ? { kind: 'segment', text: name } : { kind: 'exclude' };
|
|
81
|
+
}
|
|
82
|
+
if (ts_morph_1.Node.isInterfaceDeclaration(node)) {
|
|
83
|
+
return { kind: 'segment', text: node.getName() };
|
|
84
|
+
}
|
|
85
|
+
if (ts_morph_1.Node.isTypeAliasDeclaration(node)) {
|
|
86
|
+
return { kind: 'segment', text: node.getName() };
|
|
87
|
+
}
|
|
88
|
+
if (ts_morph_1.Node.isVariableDeclaration(node)) {
|
|
89
|
+
return { kind: 'segment', text: node.getName() };
|
|
90
|
+
}
|
|
91
|
+
if (ts_morph_1.Node.isObjectLiteralExpression(node)) {
|
|
92
|
+
return this.objectLiteralRootValid(node) ? { kind: 'transparent' } : { kind: 'exclude' };
|
|
93
|
+
}
|
|
94
|
+
return { kind: 'transparent' };
|
|
95
|
+
}
|
|
96
|
+
containerSegments(node) {
|
|
97
|
+
const segments = [];
|
|
98
|
+
let current = node.getParent();
|
|
99
|
+
while (current) {
|
|
100
|
+
const step = this.walkStep(current);
|
|
101
|
+
if (step.kind === 'exclude')
|
|
102
|
+
return null;
|
|
103
|
+
if (step.kind === 'segment') {
|
|
104
|
+
if (!IndexedNodeResolver.isValidSegment(step.text))
|
|
105
|
+
return null;
|
|
106
|
+
segments.unshift(step.text);
|
|
107
|
+
current = step.skipTo ? step.skipTo.getParent() : current.getParent();
|
|
108
|
+
continue;
|
|
109
|
+
}
|
|
110
|
+
current = current.getParent();
|
|
111
|
+
}
|
|
112
|
+
return segments;
|
|
113
|
+
}
|
|
114
|
+
describeIndexedNode(node) {
|
|
115
|
+
if (ts_morph_1.Node.isClassDeclaration(node)) {
|
|
116
|
+
const name = node.getName() ?? (node.isDefaultExport() ? 'default' : null);
|
|
117
|
+
if (name === null)
|
|
118
|
+
return null;
|
|
119
|
+
const container = this.containerSegments(node);
|
|
120
|
+
return container === null ? null : { name, container };
|
|
121
|
+
}
|
|
122
|
+
if (ts_morph_1.Node.isClassExpression(node)) {
|
|
123
|
+
const root = this.classExpressionRoot(node);
|
|
124
|
+
if (!root)
|
|
125
|
+
return null;
|
|
126
|
+
const container = this.containerSegments(root.namingParent);
|
|
127
|
+
return container === null ? null : { name: root.name, container };
|
|
128
|
+
}
|
|
129
|
+
if (ts_morph_1.Node.isFunctionDeclaration(node)) {
|
|
130
|
+
const name = node.getName();
|
|
131
|
+
if (!name || !this.isTopLevelOrNamespaceDirect(node.getParent()))
|
|
132
|
+
return null;
|
|
133
|
+
const container = this.containerSegments(node);
|
|
134
|
+
return container === null ? null : { name, container };
|
|
135
|
+
}
|
|
136
|
+
if (ts_morph_1.Node.isMethodDeclaration(node) || ts_morph_1.Node.isGetAccessorDeclaration(node) || ts_morph_1.Node.isSetAccessorDeclaration(node)) {
|
|
137
|
+
const name = (0, node_helpers_1.memberName)(node.getNameNode());
|
|
138
|
+
if (name === null)
|
|
139
|
+
return null;
|
|
140
|
+
const container = this.containerSegments(node);
|
|
141
|
+
return container === null ? null : { name, container };
|
|
142
|
+
}
|
|
143
|
+
if (ts_morph_1.Node.isConstructorDeclaration(node)) {
|
|
144
|
+
const container = this.containerSegments(node);
|
|
145
|
+
return container === null ? null : { name: 'constructor', container };
|
|
146
|
+
}
|
|
147
|
+
if (ts_morph_1.Node.isPropertyDeclaration(node) || ts_morph_1.Node.isPropertyAssignment(node)) {
|
|
148
|
+
const init = node.getInitializer();
|
|
149
|
+
if (!init)
|
|
150
|
+
return null;
|
|
151
|
+
const unwrapped = (0, node_helpers_1.unwrapExpr)(init);
|
|
152
|
+
if (!(ts_morph_1.Node.isArrowFunction(unwrapped) || ts_morph_1.Node.isFunctionExpression(unwrapped)))
|
|
153
|
+
return null;
|
|
154
|
+
const name = (0, node_helpers_1.memberName)(node.getNameNode());
|
|
155
|
+
if (name === null)
|
|
156
|
+
return null;
|
|
157
|
+
const container = this.containerSegments(node);
|
|
158
|
+
return container === null ? null : { name, container };
|
|
159
|
+
}
|
|
160
|
+
if (ts_morph_1.Node.isInterfaceDeclaration(node)) {
|
|
161
|
+
if (!this.isTopLevelOrNamespaceDirect(node.getParent()))
|
|
162
|
+
return null;
|
|
163
|
+
const container = this.containerSegments(node);
|
|
164
|
+
return container === null ? null : { name: node.getName(), container };
|
|
165
|
+
}
|
|
166
|
+
if (ts_morph_1.Node.isTypeAliasDeclaration(node)) {
|
|
167
|
+
if (!this.isTopLevelOrNamespaceDirect(node.getParent()))
|
|
168
|
+
return null;
|
|
169
|
+
const container = this.containerSegments(node);
|
|
170
|
+
return container === null ? null : { name: node.getName(), container };
|
|
171
|
+
}
|
|
172
|
+
if (ts_morph_1.Node.isVariableDeclaration(node)) {
|
|
173
|
+
if (!this.isModuleOrNamespaceLevelVariable(node))
|
|
174
|
+
return null;
|
|
175
|
+
const container = this.containerSegments(node);
|
|
176
|
+
return container === null ? null : { name: node.getName(), container };
|
|
177
|
+
}
|
|
178
|
+
if (ts_morph_1.Node.isMethodSignature(node) || ts_morph_1.Node.isPropertySignature(node)) {
|
|
179
|
+
if (ts_morph_1.Node.isPropertySignature(node)) {
|
|
180
|
+
const typeNode = node.getTypeNode();
|
|
181
|
+
if (!typeNode || !ts_morph_1.Node.isFunctionTypeNode(typeNode))
|
|
182
|
+
return null;
|
|
183
|
+
}
|
|
184
|
+
const parent = node.getParent();
|
|
185
|
+
let validParent = false;
|
|
186
|
+
if (ts_morph_1.Node.isInterfaceDeclaration(parent)) {
|
|
187
|
+
validParent = true;
|
|
188
|
+
}
|
|
189
|
+
else if (ts_morph_1.Node.isTypeLiteral(parent)) {
|
|
190
|
+
const aliasParent = parent.getParent();
|
|
191
|
+
validParent = ts_morph_1.Node.isTypeAliasDeclaration(aliasParent) && aliasParent.getTypeNode() === parent;
|
|
192
|
+
}
|
|
193
|
+
if (!validParent)
|
|
194
|
+
return null;
|
|
195
|
+
const name = (0, node_helpers_1.memberName)(node.getNameNode());
|
|
196
|
+
if (name === null)
|
|
197
|
+
return null;
|
|
198
|
+
const container = this.containerSegments(node);
|
|
199
|
+
return container === null ? null : { name, container };
|
|
200
|
+
}
|
|
201
|
+
return null;
|
|
202
|
+
}
|
|
203
|
+
qualifiedName(described) {
|
|
204
|
+
return described.container.length ? `${described.container.join('.')}.${described.name}` : described.name;
|
|
205
|
+
}
|
|
206
|
+
findFromSymbol(node) {
|
|
207
|
+
let current = node.getParent();
|
|
208
|
+
while (current) {
|
|
209
|
+
const described = this.describeIndexedNode(current);
|
|
210
|
+
if (described)
|
|
211
|
+
return this.qualifiedName(described);
|
|
212
|
+
current = current.getParent();
|
|
213
|
+
}
|
|
214
|
+
return null;
|
|
215
|
+
}
|
|
216
|
+
}
|
|
217
|
+
exports.IndexedNodeResolver = IndexedNodeResolver;
|
|
@@ -0,0 +1,8 @@
|
|
|
1
|
+
import { type SourceFile } from 'ts-morph';
|
|
2
|
+
import type { IIndexedNodeResolver } from '../interfaces';
|
|
3
|
+
import type { DeclarationCandidate } from '../declarations/DeclarationTreeBuilder';
|
|
4
|
+
export declare class MemberExtractor {
|
|
5
|
+
private readonly resolver;
|
|
6
|
+
constructor(resolver: IIndexedNodeResolver);
|
|
7
|
+
extractMembers(sourceFile: SourceFile, filePath: string, serviceName: string): DeclarationCandidate[];
|
|
8
|
+
}
|
|
@@ -0,0 +1,129 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.MemberExtractor = void 0;
|
|
4
|
+
const ts_morph_1 = require("ts-morph");
|
|
5
|
+
const node_helpers_1 = require("./node-helpers");
|
|
6
|
+
class MemberExtractor {
|
|
7
|
+
resolver;
|
|
8
|
+
constructor(resolver) {
|
|
9
|
+
this.resolver = resolver;
|
|
10
|
+
}
|
|
11
|
+
extractMembers(sourceFile, filePath, serviceName) {
|
|
12
|
+
const candidates = [];
|
|
13
|
+
const sourceLines = sourceFile.getFullText().split('\n');
|
|
14
|
+
const lineAt = (node) => (0, node_helpers_1.lineTextAt)(sourceLines, sourceFile, node);
|
|
15
|
+
const push = (declNode, posNode, name, kind, container, isStatic, hasBody) => {
|
|
16
|
+
const { line, col } = (0, node_helpers_1.getPos)(sourceFile, posNode);
|
|
17
|
+
candidates.push({
|
|
18
|
+
declNode,
|
|
19
|
+
entry: {
|
|
20
|
+
project: serviceName, filePath, name, kind,
|
|
21
|
+
signature: lineAt(posNode),
|
|
22
|
+
line, endLine: declNode.getEndLineNumber(), col,
|
|
23
|
+
container: container.length ? container.join('.') : null,
|
|
24
|
+
isStatic, hasBody,
|
|
25
|
+
},
|
|
26
|
+
});
|
|
27
|
+
};
|
|
28
|
+
for (const cls of [
|
|
29
|
+
...sourceFile.getDescendantsOfKind(ts_morph_1.SyntaxKind.ClassDeclaration),
|
|
30
|
+
...sourceFile.getDescendantsOfKind(ts_morph_1.SyntaxKind.ClassExpression),
|
|
31
|
+
]) {
|
|
32
|
+
if (ts_morph_1.Node.isClassDeclaration(cls) && cls.getName() && ts_morph_1.Node.isSourceFile(cls.getParent()))
|
|
33
|
+
continue;
|
|
34
|
+
const described = this.resolver.describeIndexedNode(cls);
|
|
35
|
+
if (!described)
|
|
36
|
+
continue;
|
|
37
|
+
const posNode = (ts_morph_1.Node.isClassDeclaration(cls) ? cls.getNameNode() : undefined) ?? cls;
|
|
38
|
+
push(cls, posNode, described.name, 'class', described.container, false, true);
|
|
39
|
+
}
|
|
40
|
+
for (const m of sourceFile.getDescendantsOfKind(ts_morph_1.SyntaxKind.MethodDeclaration)) {
|
|
41
|
+
const described = this.resolver.describeIndexedNode(m);
|
|
42
|
+
if (!described)
|
|
43
|
+
continue;
|
|
44
|
+
push(m, m.getNameNode(), described.name, 'method', described.container, m.isStatic(), m.getBody() !== undefined);
|
|
45
|
+
}
|
|
46
|
+
for (const a of sourceFile.getDescendantsOfKind(ts_morph_1.SyntaxKind.GetAccessor)) {
|
|
47
|
+
const described = this.resolver.describeIndexedNode(a);
|
|
48
|
+
if (!described)
|
|
49
|
+
continue;
|
|
50
|
+
push(a, a.getNameNode(), described.name, 'get_accessor', described.container, a.isStatic(), true);
|
|
51
|
+
}
|
|
52
|
+
for (const a of sourceFile.getDescendantsOfKind(ts_morph_1.SyntaxKind.SetAccessor)) {
|
|
53
|
+
const described = this.resolver.describeIndexedNode(a);
|
|
54
|
+
if (!described)
|
|
55
|
+
continue;
|
|
56
|
+
push(a, a.getNameNode(), described.name, 'set_accessor', described.container, a.isStatic(), true);
|
|
57
|
+
}
|
|
58
|
+
for (const c of sourceFile.getDescendantsOfKind(ts_morph_1.SyntaxKind.Constructor)) {
|
|
59
|
+
const described = this.resolver.describeIndexedNode(c);
|
|
60
|
+
if (!described)
|
|
61
|
+
continue;
|
|
62
|
+
const kw = c.getFirstChildByKind(ts_morph_1.SyntaxKind.ConstructorKeyword) ?? c;
|
|
63
|
+
push(c, kw, described.name, 'constructor', described.container, false, c.getBody() !== undefined);
|
|
64
|
+
}
|
|
65
|
+
for (const p of sourceFile.getDescendantsOfKind(ts_morph_1.SyntaxKind.PropertyDeclaration)) {
|
|
66
|
+
const described = this.resolver.describeIndexedNode(p);
|
|
67
|
+
if (!described)
|
|
68
|
+
continue;
|
|
69
|
+
push(p, p.getNameNode(), described.name, 'function_property', described.container, p.isStatic(), true);
|
|
70
|
+
}
|
|
71
|
+
for (const p of sourceFile.getDescendantsOfKind(ts_morph_1.SyntaxKind.PropertyAssignment)) {
|
|
72
|
+
const described = this.resolver.describeIndexedNode(p);
|
|
73
|
+
if (!described)
|
|
74
|
+
continue;
|
|
75
|
+
push(p, p.getNameNode(), described.name, 'function_property', described.container, false, true);
|
|
76
|
+
}
|
|
77
|
+
for (const s of sourceFile.getDescendantsOfKind(ts_morph_1.SyntaxKind.MethodSignature)) {
|
|
78
|
+
const described = this.resolver.describeIndexedNode(s);
|
|
79
|
+
if (!described)
|
|
80
|
+
continue;
|
|
81
|
+
push(s, s.getNameNode(), described.name, 'method_signature', described.container, false, false);
|
|
82
|
+
}
|
|
83
|
+
for (const s of sourceFile.getDescendantsOfKind(ts_morph_1.SyntaxKind.PropertySignature)) {
|
|
84
|
+
const described = this.resolver.describeIndexedNode(s);
|
|
85
|
+
if (!described)
|
|
86
|
+
continue;
|
|
87
|
+
push(s, s.getNameNode(), described.name, 'method_signature', described.container, false, false);
|
|
88
|
+
}
|
|
89
|
+
for (const fn of sourceFile.getDescendantsOfKind(ts_morph_1.SyntaxKind.FunctionDeclaration)) {
|
|
90
|
+
if (!ts_morph_1.Node.isModuleBlock(fn.getParent()))
|
|
91
|
+
continue;
|
|
92
|
+
const described = this.resolver.describeIndexedNode(fn);
|
|
93
|
+
if (!described)
|
|
94
|
+
continue;
|
|
95
|
+
const nameNode = fn.getNameNode();
|
|
96
|
+
if (!nameNode)
|
|
97
|
+
continue;
|
|
98
|
+
push(fn, nameNode, described.name, 'function', described.container, false, fn.getBody() !== undefined);
|
|
99
|
+
}
|
|
100
|
+
for (const iface of sourceFile.getDescendantsOfKind(ts_morph_1.SyntaxKind.InterfaceDeclaration)) {
|
|
101
|
+
if (!ts_morph_1.Node.isModuleBlock(iface.getParent()))
|
|
102
|
+
continue;
|
|
103
|
+
const described = this.resolver.describeIndexedNode(iface);
|
|
104
|
+
if (!described)
|
|
105
|
+
continue;
|
|
106
|
+
push(iface, iface.getNameNode(), described.name, 'interface', described.container, false, true);
|
|
107
|
+
}
|
|
108
|
+
for (const ta of sourceFile.getDescendantsOfKind(ts_morph_1.SyntaxKind.TypeAliasDeclaration)) {
|
|
109
|
+
if (!ts_morph_1.Node.isModuleBlock(ta.getParent()))
|
|
110
|
+
continue;
|
|
111
|
+
const described = this.resolver.describeIndexedNode(ta);
|
|
112
|
+
if (!described)
|
|
113
|
+
continue;
|
|
114
|
+
push(ta, ta.getNameNode(), described.name, 'type', described.container, false, true);
|
|
115
|
+
}
|
|
116
|
+
for (const stmt of sourceFile.getDescendantsOfKind(ts_morph_1.SyntaxKind.VariableStatement)) {
|
|
117
|
+
if (!ts_morph_1.Node.isModuleBlock(stmt.getParent()))
|
|
118
|
+
continue;
|
|
119
|
+
for (const decl of stmt.getDeclarations()) {
|
|
120
|
+
const described = this.resolver.describeIndexedNode(decl);
|
|
121
|
+
if (!described)
|
|
122
|
+
continue;
|
|
123
|
+
push(decl, decl.getNameNode(), described.name, 'variable', described.container, false, true);
|
|
124
|
+
}
|
|
125
|
+
}
|
|
126
|
+
return candidates;
|
|
127
|
+
}
|
|
128
|
+
}
|
|
129
|
+
exports.MemberExtractor = MemberExtractor;
|
|
@@ -0,0 +1,5 @@
|
|
|
1
|
+
import type { SourceFile } from 'ts-morph';
|
|
2
|
+
import type { DeclarationCandidate } from '../declarations/DeclarationTreeBuilder';
|
|
3
|
+
export declare class TopLevelSymbolExtractor {
|
|
4
|
+
extractSymbols(sourceFile: SourceFile, filePath: string, serviceName: string): DeclarationCandidate[];
|
|
5
|
+
}
|
|
@@ -0,0 +1,86 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.TopLevelSymbolExtractor = void 0;
|
|
4
|
+
const node_helpers_1 = require("./node-helpers");
|
|
5
|
+
class TopLevelSymbolExtractor {
|
|
6
|
+
extractSymbols(sourceFile, filePath, serviceName) {
|
|
7
|
+
const candidates = [];
|
|
8
|
+
const sourceLines = sourceFile.getFullText().split('\n');
|
|
9
|
+
const lineAt = (node) => (0, node_helpers_1.lineTextAt)(sourceLines, sourceFile, node);
|
|
10
|
+
for (const cls of sourceFile.getClasses()) {
|
|
11
|
+
const name = cls.getName();
|
|
12
|
+
if (!name)
|
|
13
|
+
continue;
|
|
14
|
+
const nameNode = cls.getNameNode() ?? cls;
|
|
15
|
+
const { line, col } = (0, node_helpers_1.getPos)(sourceFile, nameNode);
|
|
16
|
+
candidates.push({
|
|
17
|
+
declNode: cls,
|
|
18
|
+
entry: {
|
|
19
|
+
project: serviceName, filePath, name, kind: 'class',
|
|
20
|
+
signature: lineAt(nameNode),
|
|
21
|
+
line, endLine: cls.getEndLineNumber(), col,
|
|
22
|
+
container: null, isStatic: false,
|
|
23
|
+
},
|
|
24
|
+
});
|
|
25
|
+
}
|
|
26
|
+
for (const fn of sourceFile.getFunctions()) {
|
|
27
|
+
const name = fn.getName();
|
|
28
|
+
if (!name)
|
|
29
|
+
continue;
|
|
30
|
+
const nameNode = fn.getNameNode() ?? fn;
|
|
31
|
+
const { line, col } = (0, node_helpers_1.getPos)(sourceFile, nameNode);
|
|
32
|
+
candidates.push({
|
|
33
|
+
declNode: fn,
|
|
34
|
+
entry: {
|
|
35
|
+
project: serviceName, filePath, name, kind: 'function',
|
|
36
|
+
signature: lineAt(nameNode),
|
|
37
|
+
line, endLine: fn.getEndLineNumber(), col,
|
|
38
|
+
container: null, isStatic: false, hasBody: fn.getBody() !== undefined,
|
|
39
|
+
},
|
|
40
|
+
});
|
|
41
|
+
}
|
|
42
|
+
for (const iface of sourceFile.getInterfaces()) {
|
|
43
|
+
const nameNode = iface.getNameNode();
|
|
44
|
+
const { line, col } = (0, node_helpers_1.getPos)(sourceFile, nameNode);
|
|
45
|
+
candidates.push({
|
|
46
|
+
declNode: iface,
|
|
47
|
+
entry: {
|
|
48
|
+
project: serviceName, filePath, name: iface.getName(), kind: 'interface',
|
|
49
|
+
signature: lineAt(nameNode),
|
|
50
|
+
line, endLine: iface.getEndLineNumber(), col,
|
|
51
|
+
container: null, isStatic: false,
|
|
52
|
+
},
|
|
53
|
+
});
|
|
54
|
+
}
|
|
55
|
+
for (const ta of sourceFile.getTypeAliases()) {
|
|
56
|
+
const nameNode = ta.getNameNode();
|
|
57
|
+
const { line, col } = (0, node_helpers_1.getPos)(sourceFile, nameNode);
|
|
58
|
+
candidates.push({
|
|
59
|
+
declNode: ta,
|
|
60
|
+
entry: {
|
|
61
|
+
project: serviceName, filePath, name: ta.getName(), kind: 'type',
|
|
62
|
+
signature: lineAt(nameNode),
|
|
63
|
+
line, endLine: ta.getEndLineNumber(), col,
|
|
64
|
+
container: null, isStatic: false,
|
|
65
|
+
},
|
|
66
|
+
});
|
|
67
|
+
}
|
|
68
|
+
for (const stmt of sourceFile.getVariableStatements()) {
|
|
69
|
+
for (const decl of stmt.getDeclarations()) {
|
|
70
|
+
const nameNode = decl.getNameNode();
|
|
71
|
+
const { line, col } = (0, node_helpers_1.getPos)(sourceFile, nameNode);
|
|
72
|
+
candidates.push({
|
|
73
|
+
declNode: decl,
|
|
74
|
+
entry: {
|
|
75
|
+
project: serviceName, filePath, name: decl.getName(), kind: 'variable',
|
|
76
|
+
signature: lineAt(nameNode),
|
|
77
|
+
line, endLine: stmt.getEndLineNumber(), col,
|
|
78
|
+
container: null, isStatic: false,
|
|
79
|
+
},
|
|
80
|
+
});
|
|
81
|
+
}
|
|
82
|
+
}
|
|
83
|
+
return candidates;
|
|
84
|
+
}
|
|
85
|
+
}
|
|
86
|
+
exports.TopLevelSymbolExtractor = TopLevelSymbolExtractor;
|
|
@@ -0,0 +1,24 @@
|
|
|
1
|
+
import { Node, type Decorator, type ObjectLiteralExpression, type PropertyAssignment, type ShorthandPropertyAssignment } from 'ts-morph';
|
|
2
|
+
import type { SymbolKind } from '../interfaces/IAstParser';
|
|
3
|
+
export declare const GRAPHQL_MODULE = "@nestjs/graphql";
|
|
4
|
+
export declare const GRAPHQL_TYPE_DECORATORS: Set<string>;
|
|
5
|
+
export declare const GRAPHQL_OPERATION_KIND: Record<string, SymbolKind>;
|
|
6
|
+
export declare const GRAPHQL_NAME_RE: RegExp;
|
|
7
|
+
export type GraphqlNameResult = {
|
|
8
|
+
ok: true;
|
|
9
|
+
name: string;
|
|
10
|
+
} | {
|
|
11
|
+
ok: false;
|
|
12
|
+
reason: 'non-literal-name' | 'invalid-name';
|
|
13
|
+
value?: string;
|
|
14
|
+
};
|
|
15
|
+
export declare function decoratorIdentifier(dec: Decorator): Node | undefined;
|
|
16
|
+
export declare function literalStringValue(node: Node): string | null;
|
|
17
|
+
export declare function checkGraphqlGrammar(name: string): GraphqlNameResult;
|
|
18
|
+
export declare function isAbstractGraphqlType(args: Node[]): boolean;
|
|
19
|
+
export declare function findNameProperty(obj: ObjectLiteralExpression): PropertyAssignment | ShorthandPropertyAssignment | undefined;
|
|
20
|
+
export declare function peekThroughWrapper(node: Node): {
|
|
21
|
+
inner: Node;
|
|
22
|
+
wrapped: boolean;
|
|
23
|
+
};
|
|
24
|
+
export declare function extractResolverIdentifier(argNode: Node): Node | null;
|