codemaxxing 0.4.5 → 0.4.7
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/auth-cli.js +0 -0
- package/dist/cli.js +0 -0
- package/dist/index.js +1 -1
- package/package.json +1 -1
- package/src/index.tsx +1 -1
- package/dist/utils/treesitter.d.ts +0 -20
- package/dist/utils/treesitter.js +0 -710
package/dist/auth-cli.js
CHANGED
|
File without changes
|
package/dist/cli.js
CHANGED
|
File without changes
|
package/dist/index.js
CHANGED
|
@@ -1820,7 +1820,7 @@ function App() {
|
|
|
1820
1820
|
{ key: "openrouter", icon: "\uD83C\uDF10", label: "OpenRouter", desc: "200+ cloud models, browser login" },
|
|
1821
1821
|
{ key: "apikey", icon: "\uD83D\uDD11", label: "Enter API key manually", desc: "" },
|
|
1822
1822
|
{ key: "existing", icon: "\u2699\uFE0F", label: "I already have a server running", desc: "" },
|
|
1823
|
-
].map((item, i) => (_jsxs(Text, { children: [i === wizardIndex ? _jsx(Text, { color: theme.colors.suggestion, bold: true, children: " \u25B8 " }) : _jsx(Text, { children: " " }), _jsxs(Text, { color: i === wizardIndex ? theme.colors.suggestion : theme.colors.primary, bold: true, children: [item.icon, " ", item.label] }), item.desc ? _jsxs(Text, { color: theme.colors.muted, children: [" (", item.desc, ")"] }) : null] }, item.key))), _jsx(Text, { children: "" }), _jsx(Text, { dimColor: true, children: " \u2191\u2193 navigate \u00B7 Enter to select" })] })), wizardScreen === "models" && wizardHardware && (_jsxs(Box, { flexDirection: "column", borderStyle: "single", borderColor: theme.colors.border, paddingX: 1, marginBottom: 0, children: [_jsx(Text, { bold: true, color: theme.colors.secondary, children: "Your hardware:" }), _jsxs(Text, { color: theme.colors.muted, children: [" CPU: ", wizardHardware.cpu.name, " (", wizardHardware.cpu.cores, " cores)"] }), _jsxs(Text, { color: theme.colors.muted, children: [" RAM: ", formatBytes(wizardHardware.ram)] }), wizardHardware.gpu ? (_jsxs(Text, { color: theme.colors.muted, children: [" GPU: ", wizardHardware.gpu.name, wizardHardware.gpu.vram > 0 ? ` (${formatBytes(wizardHardware.gpu.vram)})` : ""] })) : (_jsx(Text, { color: theme.colors.muted, children: " GPU: none detected" })), !isLlmfitAvailable() && (_jsx(Text, { dimColor: true, children: " Tip: Install llmfit for smarter recommendations: brew install llmfit" })), _jsx(Text, { children: "" }), _jsx(Text, { bold: true, color: theme.colors.secondary, children: "Recommended models:" }), _jsx(Text, { children: "" }), wizardModels.map((m, i) => (_jsxs(Text, { children: [i === wizardIndex ? _jsx(Text, { color: theme.colors.suggestion, bold: true, children: " \u25B8 " }) : _jsx(Text, { children: " " }), _jsxs(Text, { children: [getFitIcon(m.fit), " "] }), _jsx(Text, { color: i === wizardIndex ? theme.colors.suggestion : theme.colors.primary, bold: true, children: m.name }), _jsxs(Text, { color: theme.colors.muted, children: [" ~", m.size, " GB \u00B7 ", m.quality === "best" ? "Best" : m.quality === "great" ? "Great" : "Good", " quality \u00B7 ", m.speed] })] }, m.ollamaId))), wizardModels.length === 0 && (_jsx(Text, { color: theme.colors.error, children: " No suitable models found for your hardware." })), _jsx(Text, { children: "" }), _jsx(Text, { dimColor: true, children: " \u2191\u2193 navigate \u00B7 Enter to install \u00B7 Esc back" })] })), wizardScreen === "install-ollama" && (_jsxs(Box, { flexDirection: "column", borderStyle: "single", borderColor: theme.colors.warning, paddingX: 1, marginBottom: 0, children: [_jsx(Text, { bold: true, color: theme.colors.warning, children: "Ollama is required for local models." }), _jsx(Text, { children: "" }), _jsx(Text, { color: theme.colors.primary, children: " Press Enter to install Ollama automatically" }), _jsxs(Text, { dimColor: true, children: [" Or install manually: ", _jsx(Text, { children: getOllamaInstallCommand(wizardHardware?.os ?? "linux") })] }), _jsx(Text, { children: "" }), _jsx(Text, { dimColor: true, children: " Enter to install · Esc to go back" })] })), wizardScreen === "pulling" && wizardSelectedModel && (_jsx(Box, { flexDirection: "column", borderStyle: "single", borderColor: theme.colors.border, paddingX: 1, marginBottom: 0, children: wizardPullError ? (_jsxs(_Fragment, { children: [_jsxs(Text, { color: theme.colors.error, bold: true, children: [" \u274C Error: ", wizardPullError] }), _jsx(Text, { children: "" }), _jsx(Text, { dimColor: true, children: " Press Enter to retry \u00B7 Esc to go back" })] })) : wizardPullProgress ? (_jsxs(_Fragment, { children: [_jsxs(Text, { bold: true, color: theme.colors.secondary, children: [" Downloading ", wizardSelectedModel.name, "..."] }), wizardPullProgress.status === "downloading" || wizardPullProgress.percent > 0 ? (_jsx(_Fragment, { children: _jsxs(Text, { children: [" ", _jsxs(Text, { color: theme.colors.primary, children: ["\u2588".repeat(Math.floor(wizardPullProgress.percent / 5)), "\u2591".repeat(20 - Math.floor(wizardPullProgress.percent / 5))] }), " ", _jsxs(Text, { bold: true, children: [wizardPullProgress.percent, "%"] }), wizardPullProgress.completed != null && wizardPullProgress.total != null ? (_jsxs(Text, { color: theme.colors.muted, children: [" \u00B7 ", formatBytes(wizardPullProgress.completed), " / ", formatBytes(wizardPullProgress.total)] })) : null] }) })) : (_jsxs(Text, { color: theme.colors.muted, children: [" ", wizardPullProgress.status, "..."] }))] })) : null })), showSuggestions && (_jsxs(Box, { flexDirection: "column", borderStyle: "single", borderColor: theme.colors.muted, paddingX: 1, marginBottom: 0, children: [cmdMatches.slice(0, 6).map((c, i) => (_jsxs(Text, { children: [i === cmdIndex ? _jsx(Text, { color: theme.colors.suggestion, bold: true, children: "▸ " }) : _jsx(Text, { children: " " }), _jsx(Text, { color: i === cmdIndex ? theme.colors.suggestion : theme.colors.primary, bold: true, children: c.cmd }), _jsxs(Text, { color: theme.colors.muted, children: [" — ", c.desc] })] }, i))), _jsx(Text, { dimColor: true, children: " ↑↓ navigate · Tab select" })] })), _jsxs(Box, { borderStyle: "single", borderColor: approval ? theme.colors.warning : theme.colors.border, paddingX: 1, children: [_jsx(Text, { color: theme.colors.secondary, bold: true, children: "> " }), approval ? (_jsx(Text, { color: theme.colors.warning, children: "waiting for approval..." })) : ready && !loading ? (_jsxs(Box, { children: [pastedChunks.map((p) => (_jsxs(Text, { color: theme.colors.muted, children: ["[Pasted text #", p.id, " +", p.lines, " lines]"] }, p.id))), _jsx(TextInput, { value: input, onChange: (v) => { setInput(v); setCmdIndex(0); }, onSubmit: handleSubmit }, inputKey)] })) : (_jsx(Text, { dimColor: true, children: loading ? "waiting for response..." : "initializing..." }))] }), agent && (_jsx(Box, { paddingX: 2, children: _jsxs(Text, { dimColor: true, children: ["💬 ", agent.getContextLength(), " messages · ~", (() => {
|
|
1823
|
+
].map((item, i) => (_jsxs(Text, { children: [i === wizardIndex ? _jsx(Text, { color: theme.colors.suggestion, bold: true, children: " \u25B8 " }) : _jsx(Text, { children: " " }), _jsxs(Text, { color: i === wizardIndex ? theme.colors.suggestion : theme.colors.primary, bold: true, children: [item.icon, " ", item.label] }), item.desc ? _jsxs(Text, { color: theme.colors.muted, children: [" (", item.desc, ")"] }) : null] }, item.key))), _jsx(Text, { children: "" }), _jsx(Text, { dimColor: true, children: " \u2191\u2193 navigate \u00B7 Enter to select" })] })), wizardScreen === "models" && wizardHardware && (_jsxs(Box, { flexDirection: "column", borderStyle: "single", borderColor: theme.colors.border, paddingX: 1, marginBottom: 0, children: [_jsx(Text, { bold: true, color: theme.colors.secondary, children: "Your hardware:" }), _jsxs(Text, { color: theme.colors.muted, children: [" CPU: ", wizardHardware.cpu.name, " (", wizardHardware.cpu.cores, " cores)"] }), _jsxs(Text, { color: theme.colors.muted, children: [" RAM: ", formatBytes(wizardHardware.ram)] }), wizardHardware.gpu ? (_jsxs(Text, { color: theme.colors.muted, children: [" GPU: ", wizardHardware.gpu.name, wizardHardware.gpu.vram > 0 ? ` (${formatBytes(wizardHardware.gpu.vram)})` : ""] })) : (_jsx(Text, { color: theme.colors.muted, children: " GPU: none detected" })), !isLlmfitAvailable() && (_jsx(Text, { dimColor: true, children: " Tip: Install llmfit for smarter recommendations: brew install llmfit" })), _jsx(Text, { children: "" }), _jsx(Text, { bold: true, color: theme.colors.secondary, children: "Recommended models:" }), _jsx(Text, { children: "" }), wizardModels.map((m, i) => (_jsxs(Text, { children: [i === wizardIndex ? _jsx(Text, { color: theme.colors.suggestion, bold: true, children: " \u25B8 " }) : _jsx(Text, { children: " " }), _jsxs(Text, { children: [getFitIcon(m.fit), " "] }), _jsx(Text, { color: i === wizardIndex ? theme.colors.suggestion : theme.colors.primary, bold: true, children: m.name }), _jsxs(Text, { color: theme.colors.muted, children: [" ~", m.size, " GB \u00B7 ", m.quality === "best" ? "Best" : m.quality === "great" ? "Great" : "Good", " quality \u00B7 ", m.speed] })] }, m.ollamaId))), wizardModels.length === 0 && (_jsx(Text, { color: theme.colors.error, children: " No suitable models found for your hardware." })), _jsx(Text, { children: "" }), _jsx(Text, { dimColor: true, children: " \u2191\u2193 navigate \u00B7 Enter to install \u00B7 Esc back" })] })), wizardScreen === "install-ollama" && (_jsxs(Box, { flexDirection: "column", borderStyle: "single", borderColor: theme.colors.warning, paddingX: 1, marginBottom: 0, children: [_jsx(Text, { bold: true, color: theme.colors.warning, children: "Ollama is required for local models." }), _jsx(Text, { children: "" }), _jsx(Text, { color: theme.colors.primary, children: " Press Enter to install Ollama automatically" }), _jsxs(Text, { dimColor: true, children: [" Or install manually: ", _jsx(Text, { children: getOllamaInstallCommand(wizardHardware?.os ?? "linux") })] }), _jsx(Text, { children: "" }), _jsx(Text, { dimColor: true, children: " Enter to install · Esc to go back" })] })), wizardScreen === "pulling" && wizardSelectedModel && (_jsx(Box, { flexDirection: "column", borderStyle: "single", borderColor: theme.colors.border, paddingX: 1, marginBottom: 0, children: wizardPullError ? (_jsxs(_Fragment, { children: [_jsxs(Text, { color: theme.colors.error, bold: true, children: [" \u274C Error: ", wizardPullError] }), _jsx(Text, { children: "" }), _jsx(Text, { dimColor: true, children: " Press Enter to retry \u00B7 Esc to go back" })] })) : wizardPullProgress ? (_jsxs(_Fragment, { children: [_jsxs(Text, { bold: true, color: theme.colors.secondary, children: [" Downloading ", wizardSelectedModel.name, "..."] }), wizardPullProgress.status === "downloading" || wizardPullProgress.percent > 0 ? (_jsx(_Fragment, { children: _jsxs(Text, { children: [" ", _jsxs(Text, { color: theme.colors.primary, children: ["\u2588".repeat(Math.floor(wizardPullProgress.percent / 5)), "\u2591".repeat(20 - Math.floor(wizardPullProgress.percent / 5))] }), " ", _jsxs(Text, { bold: true, children: [wizardPullProgress.percent, "%"] }), wizardPullProgress.completed != null && wizardPullProgress.total != null ? (_jsxs(Text, { color: theme.colors.muted, children: [" \u00B7 ", formatBytes(wizardPullProgress.completed), " / ", formatBytes(wizardPullProgress.total)] })) : null] }) })) : (_jsxs(Text, { color: theme.colors.muted, children: [" ", wizardPullProgress.status, "..."] }))] })) : null })), showSuggestions && (_jsxs(Box, { flexDirection: "column", borderStyle: "single", borderColor: theme.colors.muted, paddingX: 1, marginBottom: 0, children: [cmdMatches.slice(0, 6).map((c, i) => (_jsxs(Text, { children: [i === cmdIndex ? _jsx(Text, { color: theme.colors.suggestion, bold: true, children: "▸ " }) : _jsx(Text, { children: " " }), _jsx(Text, { color: i === cmdIndex ? theme.colors.suggestion : theme.colors.primary, bold: true, children: c.cmd }), _jsxs(Text, { color: theme.colors.muted, children: [" — ", c.desc] })] }, i))), _jsx(Text, { dimColor: true, children: " ↑↓ navigate · Tab select" })] })), _jsxs(Box, { borderStyle: "single", borderColor: approval ? theme.colors.warning : theme.colors.border, paddingX: 1, children: [_jsx(Text, { color: theme.colors.secondary, bold: true, children: "> " }), approval ? (_jsx(Text, { color: theme.colors.warning, children: "waiting for approval..." })) : ready && !loading && !wizardScreen ? (_jsxs(Box, { children: [pastedChunks.map((p) => (_jsxs(Text, { color: theme.colors.muted, children: ["[Pasted text #", p.id, " +", p.lines, " lines]"] }, p.id))), _jsx(TextInput, { value: input, onChange: (v) => { setInput(v); setCmdIndex(0); }, onSubmit: handleSubmit }, inputKey)] })) : (_jsx(Text, { dimColor: true, children: loading ? "waiting for response..." : "initializing..." }))] }), agent && (_jsx(Box, { paddingX: 2, children: _jsxs(Text, { dimColor: true, children: ["💬 ", agent.getContextLength(), " messages · ~", (() => {
|
|
1824
1824
|
const tokens = agent.estimateTokens();
|
|
1825
1825
|
return tokens >= 1000 ? `${(tokens / 1000).toFixed(1)}k` : String(tokens);
|
|
1826
1826
|
})(), " tokens", (() => {
|
package/package.json
CHANGED
package/src/index.tsx
CHANGED
|
@@ -2230,7 +2230,7 @@ function App() {
|
|
|
2230
2230
|
<Text color={theme.colors.secondary} bold>{"> "}</Text>
|
|
2231
2231
|
{approval ? (
|
|
2232
2232
|
<Text color={theme.colors.warning}>waiting for approval...</Text>
|
|
2233
|
-
) : ready && !loading ? (
|
|
2233
|
+
) : ready && !loading && !wizardScreen ? (
|
|
2234
2234
|
<Box>
|
|
2235
2235
|
{pastedChunks.map((p) => (
|
|
2236
2236
|
<Text key={p.id} color={theme.colors.muted}>[Pasted text #{p.id} +{p.lines} lines]</Text>
|
|
@@ -1,20 +0,0 @@
|
|
|
1
|
-
export interface Signature {
|
|
2
|
-
kind: "function" | "class" | "method" | "interface" | "type" | "enum" | "struct" | "trait" | "impl" | "variable" | "const" | "module" | "package" | "export";
|
|
3
|
-
name: string;
|
|
4
|
-
detail: string;
|
|
5
|
-
startLine: number;
|
|
6
|
-
endLine: number;
|
|
7
|
-
children?: Signature[];
|
|
8
|
-
}
|
|
9
|
-
/**
|
|
10
|
-
* Get the language name for a file extension
|
|
11
|
-
*/
|
|
12
|
-
export declare function getLanguageForExt(ext: string): string | null;
|
|
13
|
-
/**
|
|
14
|
-
* Get all supported extensions
|
|
15
|
-
*/
|
|
16
|
-
export declare function getSupportedExtensions(): string[];
|
|
17
|
-
/**
|
|
18
|
-
* Parse a file and extract signatures using tree-sitter queries
|
|
19
|
-
*/
|
|
20
|
-
export declare function extractSignatures(source: string, langName: string): Promise<Signature[]>;
|
package/dist/utils/treesitter.js
DELETED
|
@@ -1,710 +0,0 @@
|
|
|
1
|
-
import { Parser, Language } from "web-tree-sitter";
|
|
2
|
-
import { join, dirname } from "path";
|
|
3
|
-
import { createRequire } from "module";
|
|
4
|
-
const LANGUAGES = {
|
|
5
|
-
javascript: {
|
|
6
|
-
extensions: [".js", ".jsx", ".mjs", ".cjs"],
|
|
7
|
-
wasmFile: "tree-sitter-javascript.wasm",
|
|
8
|
-
query: `
|
|
9
|
-
;; Function declarations
|
|
10
|
-
(function_declaration
|
|
11
|
-
name: (identifier) @fn.name) @fn.def
|
|
12
|
-
|
|
13
|
-
;; Arrow functions assigned to const/let/var
|
|
14
|
-
(lexical_declaration
|
|
15
|
-
(variable_declarator
|
|
16
|
-
name: (identifier) @fn.name
|
|
17
|
-
value: (arrow_function) @fn.arrow)) @fn.def
|
|
18
|
-
|
|
19
|
-
;; Variable declarations (non-arrow)
|
|
20
|
-
(lexical_declaration
|
|
21
|
-
(variable_declarator
|
|
22
|
-
name: (identifier) @var.name
|
|
23
|
-
value: (_) @var.value)) @var.def
|
|
24
|
-
|
|
25
|
-
;; Class declarations
|
|
26
|
-
(class_declaration
|
|
27
|
-
name: (identifier) @class.name) @class.def
|
|
28
|
-
|
|
29
|
-
;; Method definitions inside classes
|
|
30
|
-
(method_definition
|
|
31
|
-
name: (property_identifier) @method.name) @method.def
|
|
32
|
-
|
|
33
|
-
;; Export statements
|
|
34
|
-
(export_statement) @export.stmt
|
|
35
|
-
`,
|
|
36
|
-
},
|
|
37
|
-
typescript: {
|
|
38
|
-
extensions: [".ts", ".tsx"],
|
|
39
|
-
wasmFile: "tree-sitter-typescript.wasm",
|
|
40
|
-
query: `
|
|
41
|
-
;; Function declarations
|
|
42
|
-
(function_declaration
|
|
43
|
-
name: (identifier) @fn.name) @fn.def
|
|
44
|
-
|
|
45
|
-
;; Arrow functions assigned to const/let/var
|
|
46
|
-
(lexical_declaration
|
|
47
|
-
(variable_declarator
|
|
48
|
-
name: (identifier) @fn.name
|
|
49
|
-
value: (arrow_function) @fn.arrow)) @fn.def
|
|
50
|
-
|
|
51
|
-
;; Variable declarations (non-arrow)
|
|
52
|
-
(lexical_declaration
|
|
53
|
-
(variable_declarator
|
|
54
|
-
name: (identifier) @var.name)) @var.def
|
|
55
|
-
|
|
56
|
-
;; Class declarations
|
|
57
|
-
(class_declaration
|
|
58
|
-
name: (type_identifier) @class.name) @class.def
|
|
59
|
-
|
|
60
|
-
;; Method definitions
|
|
61
|
-
(method_definition
|
|
62
|
-
name: (property_identifier) @method.name) @method.def
|
|
63
|
-
|
|
64
|
-
;; Interface declarations
|
|
65
|
-
(interface_declaration
|
|
66
|
-
name: (type_identifier) @iface.name) @iface.def
|
|
67
|
-
|
|
68
|
-
;; Type alias declarations
|
|
69
|
-
(type_alias_declaration
|
|
70
|
-
name: (type_identifier) @type.name) @type.def
|
|
71
|
-
|
|
72
|
-
;; Enum declarations
|
|
73
|
-
(enum_declaration
|
|
74
|
-
name: (identifier) @enum.name) @enum.def
|
|
75
|
-
|
|
76
|
-
;; Export statements
|
|
77
|
-
(export_statement) @export.stmt
|
|
78
|
-
`,
|
|
79
|
-
},
|
|
80
|
-
python: {
|
|
81
|
-
extensions: [".py"],
|
|
82
|
-
wasmFile: "tree-sitter-python.wasm",
|
|
83
|
-
query: `
|
|
84
|
-
;; Function definitions
|
|
85
|
-
(function_definition
|
|
86
|
-
name: (identifier) @fn.name) @fn.def
|
|
87
|
-
|
|
88
|
-
;; Class definitions
|
|
89
|
-
(class_definition
|
|
90
|
-
name: (identifier) @class.name) @class.def
|
|
91
|
-
|
|
92
|
-
;; Decorated definitions
|
|
93
|
-
(decorated_definition) @decorated.def
|
|
94
|
-
|
|
95
|
-
;; Assignments at module level
|
|
96
|
-
(expression_statement
|
|
97
|
-
(assignment
|
|
98
|
-
left: (identifier) @var.name)) @var.def
|
|
99
|
-
`,
|
|
100
|
-
},
|
|
101
|
-
go: {
|
|
102
|
-
extensions: [".go"],
|
|
103
|
-
wasmFile: "tree-sitter-go.wasm",
|
|
104
|
-
query: `
|
|
105
|
-
;; Function declarations
|
|
106
|
-
(function_declaration
|
|
107
|
-
name: (identifier) @fn.name) @fn.def
|
|
108
|
-
|
|
109
|
-
;; Method declarations
|
|
110
|
-
(method_declaration
|
|
111
|
-
name: (field_identifier) @method.name) @method.def
|
|
112
|
-
|
|
113
|
-
;; Type declarations (struct, interface, alias)
|
|
114
|
-
(type_declaration
|
|
115
|
-
(type_spec
|
|
116
|
-
name: (type_identifier) @type.name
|
|
117
|
-
type: (_) @type.body)) @type.def
|
|
118
|
-
|
|
119
|
-
;; Package clause
|
|
120
|
-
(package_clause
|
|
121
|
-
(package_identifier) @pkg.name) @pkg.def
|
|
122
|
-
|
|
123
|
-
;; Const/var declarations
|
|
124
|
-
(const_declaration) @const.def
|
|
125
|
-
(var_declaration) @var.def
|
|
126
|
-
`,
|
|
127
|
-
},
|
|
128
|
-
rust: {
|
|
129
|
-
extensions: [".rs"],
|
|
130
|
-
wasmFile: "tree-sitter-rust.wasm",
|
|
131
|
-
query: `
|
|
132
|
-
;; Function declarations
|
|
133
|
-
(function_item
|
|
134
|
-
name: (identifier) @fn.name) @fn.def
|
|
135
|
-
|
|
136
|
-
;; Struct declarations
|
|
137
|
-
(struct_item
|
|
138
|
-
name: (type_identifier) @struct.name) @struct.def
|
|
139
|
-
|
|
140
|
-
;; Enum declarations
|
|
141
|
-
(enum_item
|
|
142
|
-
name: (type_identifier) @enum.name) @enum.def
|
|
143
|
-
|
|
144
|
-
;; Impl blocks
|
|
145
|
-
(impl_item
|
|
146
|
-
type: (_) @impl.type) @impl.def
|
|
147
|
-
|
|
148
|
-
;; Trait declarations
|
|
149
|
-
(trait_item
|
|
150
|
-
name: (type_identifier) @trait.name) @trait.def
|
|
151
|
-
|
|
152
|
-
;; Type alias
|
|
153
|
-
(type_item
|
|
154
|
-
name: (type_identifier) @type.name) @type.def
|
|
155
|
-
|
|
156
|
-
;; Const/static declarations
|
|
157
|
-
(const_item
|
|
158
|
-
name: (identifier) @const.name) @const.def
|
|
159
|
-
(static_item
|
|
160
|
-
name: (identifier) @static.name) @static.def
|
|
161
|
-
|
|
162
|
-
;; Mod declarations
|
|
163
|
-
(mod_item
|
|
164
|
-
name: (identifier) @mod.name) @mod.def
|
|
165
|
-
`,
|
|
166
|
-
},
|
|
167
|
-
};
|
|
168
|
-
// ── Tree-Sitter Manager ──
|
|
169
|
-
let parserInitialized = false;
|
|
170
|
-
const loadedLanguages = new Map();
|
|
171
|
-
/**
|
|
172
|
-
* Get the language name for a file extension
|
|
173
|
-
*/
|
|
174
|
-
export function getLanguageForExt(ext) {
|
|
175
|
-
for (const [lang, config] of Object.entries(LANGUAGES)) {
|
|
176
|
-
if (config.extensions.includes(ext))
|
|
177
|
-
return lang;
|
|
178
|
-
}
|
|
179
|
-
return null;
|
|
180
|
-
}
|
|
181
|
-
/**
|
|
182
|
-
* Get all supported extensions
|
|
183
|
-
*/
|
|
184
|
-
export function getSupportedExtensions() {
|
|
185
|
-
return Object.values(LANGUAGES).flatMap((c) => c.extensions);
|
|
186
|
-
}
|
|
187
|
-
/**
|
|
188
|
-
* Initialize the tree-sitter WASM runtime
|
|
189
|
-
*/
|
|
190
|
-
async function ensureInit() {
|
|
191
|
-
if (parserInitialized)
|
|
192
|
-
return;
|
|
193
|
-
const require = createRequire(import.meta.url);
|
|
194
|
-
const wasmPath = require.resolve("web-tree-sitter/web-tree-sitter.wasm");
|
|
195
|
-
await Parser.init({
|
|
196
|
-
locateFile: () => wasmPath,
|
|
197
|
-
});
|
|
198
|
-
parserInitialized = true;
|
|
199
|
-
}
|
|
200
|
-
/**
|
|
201
|
-
* Load a language grammar (cached)
|
|
202
|
-
*/
|
|
203
|
-
async function loadLanguage(langName) {
|
|
204
|
-
if (loadedLanguages.has(langName))
|
|
205
|
-
return loadedLanguages.get(langName);
|
|
206
|
-
const config = LANGUAGES[langName];
|
|
207
|
-
if (!config)
|
|
208
|
-
throw new Error(`Unsupported language: ${langName}`);
|
|
209
|
-
const require = createRequire(import.meta.url);
|
|
210
|
-
const wasmDir = join(dirname(require.resolve("tree-sitter-wasms/package.json")), "out");
|
|
211
|
-
const wasmPath = join(wasmDir, config.wasmFile);
|
|
212
|
-
const lang = await Language.load(wasmPath);
|
|
213
|
-
loadedLanguages.set(langName, lang);
|
|
214
|
-
return lang;
|
|
215
|
-
}
|
|
216
|
-
/**
|
|
217
|
-
* Extract a concise one-line signature from a node's text
|
|
218
|
-
*/
|
|
219
|
-
function extractSignatureLine(node, kind, langName) {
|
|
220
|
-
const text = node.text;
|
|
221
|
-
const firstLine = text.split("\n")[0].trim();
|
|
222
|
-
// For functions — show up to the opening brace or body
|
|
223
|
-
if (kind === "function" || kind === "method") {
|
|
224
|
-
// Remove body (everything from { onward) for a clean signature
|
|
225
|
-
const braceIdx = firstLine.indexOf("{");
|
|
226
|
-
if (braceIdx > 0)
|
|
227
|
-
return firstLine.slice(0, braceIdx).trim();
|
|
228
|
-
// Python: remove the colon at end
|
|
229
|
-
if (langName === "python" && firstLine.endsWith(":")) {
|
|
230
|
-
return firstLine.slice(0, -1).trim();
|
|
231
|
-
}
|
|
232
|
-
return firstLine;
|
|
233
|
-
}
|
|
234
|
-
// For classes/structs/interfaces — just the declaration line
|
|
235
|
-
if (["class", "struct", "interface", "trait", "enum", "impl"].includes(kind)) {
|
|
236
|
-
const braceIdx = firstLine.indexOf("{");
|
|
237
|
-
if (braceIdx > 0)
|
|
238
|
-
return firstLine.slice(0, braceIdx).trim();
|
|
239
|
-
if (firstLine.endsWith(":"))
|
|
240
|
-
return firstLine.slice(0, -1).trim();
|
|
241
|
-
return firstLine;
|
|
242
|
-
}
|
|
243
|
-
// For types/consts — show the whole first line
|
|
244
|
-
return firstLine.length > 120 ? firstLine.slice(0, 117) + "..." : firstLine;
|
|
245
|
-
}
|
|
246
|
-
/**
|
|
247
|
-
* Parse a file and extract signatures using tree-sitter queries
|
|
248
|
-
*/
|
|
249
|
-
export async function extractSignatures(source, langName) {
|
|
250
|
-
await ensureInit();
|
|
251
|
-
const config = LANGUAGES[langName];
|
|
252
|
-
if (!config)
|
|
253
|
-
return [];
|
|
254
|
-
const lang = await loadLanguage(langName);
|
|
255
|
-
const parser = new Parser();
|
|
256
|
-
parser.setLanguage(lang);
|
|
257
|
-
const tree = parser.parse(source);
|
|
258
|
-
if (!tree) {
|
|
259
|
-
parser.delete();
|
|
260
|
-
return [];
|
|
261
|
-
}
|
|
262
|
-
const signatures = [];
|
|
263
|
-
// We'll walk the tree manually to get structured output
|
|
264
|
-
// since query matching gives us flat captures
|
|
265
|
-
const rootNode = tree.rootNode;
|
|
266
|
-
for (let i = 0; i < rootNode.childCount; i++) {
|
|
267
|
-
const node = rootNode.child(i);
|
|
268
|
-
const sigs = extractNodeSignatures(node, langName, 0);
|
|
269
|
-
signatures.push(...sigs);
|
|
270
|
-
}
|
|
271
|
-
parser.delete();
|
|
272
|
-
tree.delete();
|
|
273
|
-
return signatures;
|
|
274
|
-
}
|
|
275
|
-
/**
|
|
276
|
-
* Recursively extract signatures from a node
|
|
277
|
-
*/
|
|
278
|
-
function extractNodeSignatures(node, langName, depth) {
|
|
279
|
-
const sigs = [];
|
|
280
|
-
const type = node.type;
|
|
281
|
-
// ── JavaScript / TypeScript ──
|
|
282
|
-
if (langName === "javascript" || langName === "typescript") {
|
|
283
|
-
// Function declaration
|
|
284
|
-
if (type === "function_declaration") {
|
|
285
|
-
const nameNode = node.childForFieldName("name");
|
|
286
|
-
const sig = extractSignatureLine(node, "function", langName);
|
|
287
|
-
sigs.push({
|
|
288
|
-
kind: "function",
|
|
289
|
-
name: nameNode?.text ?? "anonymous",
|
|
290
|
-
detail: sig,
|
|
291
|
-
startLine: node.startPosition.row + 1,
|
|
292
|
-
endLine: node.endPosition.row + 1,
|
|
293
|
-
});
|
|
294
|
-
return sigs;
|
|
295
|
-
}
|
|
296
|
-
// Variable/const declarations (arrow functions, constants)
|
|
297
|
-
if (type === "lexical_declaration" || type === "variable_declaration") {
|
|
298
|
-
for (let c = 0; c < node.childCount; c++) {
|
|
299
|
-
const declarator = node.child(c);
|
|
300
|
-
if (declarator?.type === "variable_declarator") {
|
|
301
|
-
const nameNode = declarator.childForFieldName("name");
|
|
302
|
-
const valueNode = declarator.childForFieldName("value");
|
|
303
|
-
const name = nameNode?.text ?? "unknown";
|
|
304
|
-
if (valueNode?.type === "arrow_function" || valueNode?.type === "function") {
|
|
305
|
-
sigs.push({
|
|
306
|
-
kind: "function",
|
|
307
|
-
name,
|
|
308
|
-
detail: extractSignatureLine(node, "function", langName),
|
|
309
|
-
startLine: node.startPosition.row + 1,
|
|
310
|
-
endLine: node.endPosition.row + 1,
|
|
311
|
-
});
|
|
312
|
-
}
|
|
313
|
-
else {
|
|
314
|
-
sigs.push({
|
|
315
|
-
kind: "variable",
|
|
316
|
-
name,
|
|
317
|
-
detail: extractSignatureLine(node, "variable", langName),
|
|
318
|
-
startLine: node.startPosition.row + 1,
|
|
319
|
-
endLine: node.endPosition.row + 1,
|
|
320
|
-
});
|
|
321
|
-
}
|
|
322
|
-
}
|
|
323
|
-
}
|
|
324
|
-
return sigs;
|
|
325
|
-
}
|
|
326
|
-
// Class declaration
|
|
327
|
-
if (type === "class_declaration") {
|
|
328
|
-
const nameNode = node.childForFieldName("name");
|
|
329
|
-
const name = nameNode?.text ?? "anonymous";
|
|
330
|
-
const children = [];
|
|
331
|
-
// Find class body and extract methods
|
|
332
|
-
const body = node.childForFieldName("body");
|
|
333
|
-
if (body) {
|
|
334
|
-
for (let c = 0; c < body.childCount; c++) {
|
|
335
|
-
const member = body.child(c);
|
|
336
|
-
if (member?.type === "method_definition" || member?.type === "public_field_definition") {
|
|
337
|
-
const methodName = member.childForFieldName("name");
|
|
338
|
-
children.push({
|
|
339
|
-
kind: "method",
|
|
340
|
-
name: methodName?.text ?? "unknown",
|
|
341
|
-
detail: extractSignatureLine(member, "method", langName),
|
|
342
|
-
startLine: member.startPosition.row + 1,
|
|
343
|
-
endLine: member.endPosition.row + 1,
|
|
344
|
-
});
|
|
345
|
-
}
|
|
346
|
-
}
|
|
347
|
-
}
|
|
348
|
-
sigs.push({
|
|
349
|
-
kind: "class",
|
|
350
|
-
name,
|
|
351
|
-
detail: extractSignatureLine(node, "class", langName),
|
|
352
|
-
startLine: node.startPosition.row + 1,
|
|
353
|
-
endLine: node.endPosition.row + 1,
|
|
354
|
-
children,
|
|
355
|
-
});
|
|
356
|
-
return sigs;
|
|
357
|
-
}
|
|
358
|
-
// TypeScript-specific
|
|
359
|
-
if (langName === "typescript") {
|
|
360
|
-
if (type === "interface_declaration") {
|
|
361
|
-
const nameNode = node.childForFieldName("name");
|
|
362
|
-
sigs.push({
|
|
363
|
-
kind: "interface",
|
|
364
|
-
name: nameNode?.text ?? "unknown",
|
|
365
|
-
detail: extractSignatureLine(node, "interface", langName),
|
|
366
|
-
startLine: node.startPosition.row + 1,
|
|
367
|
-
endLine: node.endPosition.row + 1,
|
|
368
|
-
});
|
|
369
|
-
return sigs;
|
|
370
|
-
}
|
|
371
|
-
if (type === "type_alias_declaration") {
|
|
372
|
-
const nameNode = node.childForFieldName("name");
|
|
373
|
-
sigs.push({
|
|
374
|
-
kind: "type",
|
|
375
|
-
name: nameNode?.text ?? "unknown",
|
|
376
|
-
detail: extractSignatureLine(node, "type", langName),
|
|
377
|
-
startLine: node.startPosition.row + 1,
|
|
378
|
-
endLine: node.endPosition.row + 1,
|
|
379
|
-
});
|
|
380
|
-
return sigs;
|
|
381
|
-
}
|
|
382
|
-
if (type === "enum_declaration") {
|
|
383
|
-
const nameNode = node.childForFieldName("name");
|
|
384
|
-
sigs.push({
|
|
385
|
-
kind: "enum",
|
|
386
|
-
name: nameNode?.text ?? "unknown",
|
|
387
|
-
detail: extractSignatureLine(node, "enum", langName),
|
|
388
|
-
startLine: node.startPosition.row + 1,
|
|
389
|
-
endLine: node.endPosition.row + 1,
|
|
390
|
-
});
|
|
391
|
-
return sigs;
|
|
392
|
-
}
|
|
393
|
-
}
|
|
394
|
-
// Export statement — unwrap and recurse into the declaration
|
|
395
|
-
if (type === "export_statement") {
|
|
396
|
-
for (let c = 0; c < node.childCount; c++) {
|
|
397
|
-
const child = node.child(c);
|
|
398
|
-
const childSigs = extractNodeSignatures(child, langName, depth);
|
|
399
|
-
// Mark them as exported by prepending "export " to detail
|
|
400
|
-
for (const s of childSigs) {
|
|
401
|
-
if (!s.detail.startsWith("export")) {
|
|
402
|
-
s.detail = "export " + s.detail;
|
|
403
|
-
}
|
|
404
|
-
s.kind = s.kind === "variable" ? "export" : s.kind;
|
|
405
|
-
}
|
|
406
|
-
sigs.push(...childSigs);
|
|
407
|
-
}
|
|
408
|
-
return sigs;
|
|
409
|
-
}
|
|
410
|
-
}
|
|
411
|
-
// ── Python ──
|
|
412
|
-
if (langName === "python") {
|
|
413
|
-
if (type === "function_definition") {
|
|
414
|
-
const nameNode = node.childForFieldName("name");
|
|
415
|
-
const children = [];
|
|
416
|
-
// Check for methods inside (nested functions)
|
|
417
|
-
const body = node.childForFieldName("body");
|
|
418
|
-
// Don't recurse into function bodies for top-level map
|
|
419
|
-
sigs.push({
|
|
420
|
-
kind: "function",
|
|
421
|
-
name: nameNode?.text ?? "unknown",
|
|
422
|
-
detail: extractSignatureLine(node, "function", langName),
|
|
423
|
-
startLine: node.startPosition.row + 1,
|
|
424
|
-
endLine: node.endPosition.row + 1,
|
|
425
|
-
});
|
|
426
|
-
return sigs;
|
|
427
|
-
}
|
|
428
|
-
if (type === "class_definition") {
|
|
429
|
-
const nameNode = node.childForFieldName("name");
|
|
430
|
-
const name = nameNode?.text ?? "unknown";
|
|
431
|
-
const children = [];
|
|
432
|
-
const body = node.childForFieldName("body");
|
|
433
|
-
if (body) {
|
|
434
|
-
for (let c = 0; c < body.childCount; c++) {
|
|
435
|
-
const member = body.child(c);
|
|
436
|
-
if (member?.type === "function_definition") {
|
|
437
|
-
const methodName = member.childForFieldName("name");
|
|
438
|
-
children.push({
|
|
439
|
-
kind: "method",
|
|
440
|
-
name: methodName?.text ?? "unknown",
|
|
441
|
-
detail: extractSignatureLine(member, "method", langName),
|
|
442
|
-
startLine: member.startPosition.row + 1,
|
|
443
|
-
endLine: member.endPosition.row + 1,
|
|
444
|
-
});
|
|
445
|
-
}
|
|
446
|
-
}
|
|
447
|
-
}
|
|
448
|
-
sigs.push({
|
|
449
|
-
kind: "class",
|
|
450
|
-
name,
|
|
451
|
-
detail: extractSignatureLine(node, "class", langName),
|
|
452
|
-
startLine: node.startPosition.row + 1,
|
|
453
|
-
endLine: node.endPosition.row + 1,
|
|
454
|
-
children,
|
|
455
|
-
});
|
|
456
|
-
return sigs;
|
|
457
|
-
}
|
|
458
|
-
if (type === "decorated_definition") {
|
|
459
|
-
// Unwrap and process the inner definition
|
|
460
|
-
for (let c = 0; c < node.childCount; c++) {
|
|
461
|
-
const child = node.child(c);
|
|
462
|
-
if (child.type === "function_definition" || child.type === "class_definition") {
|
|
463
|
-
const innerSigs = extractNodeSignatures(child, langName, depth);
|
|
464
|
-
sigs.push(...innerSigs);
|
|
465
|
-
}
|
|
466
|
-
}
|
|
467
|
-
return sigs;
|
|
468
|
-
}
|
|
469
|
-
if (type === "expression_statement") {
|
|
470
|
-
const assignment = node.child(0);
|
|
471
|
-
if (assignment?.type === "assignment") {
|
|
472
|
-
const left = assignment.childForFieldName("left");
|
|
473
|
-
if (left?.type === "identifier") {
|
|
474
|
-
sigs.push({
|
|
475
|
-
kind: "variable",
|
|
476
|
-
name: left.text,
|
|
477
|
-
detail: extractSignatureLine(node, "variable", langName),
|
|
478
|
-
startLine: node.startPosition.row + 1,
|
|
479
|
-
endLine: node.endPosition.row + 1,
|
|
480
|
-
});
|
|
481
|
-
}
|
|
482
|
-
}
|
|
483
|
-
return sigs;
|
|
484
|
-
}
|
|
485
|
-
}
|
|
486
|
-
// ── Go ──
|
|
487
|
-
if (langName === "go") {
|
|
488
|
-
if (type === "function_declaration") {
|
|
489
|
-
const nameNode = node.childForFieldName("name");
|
|
490
|
-
sigs.push({
|
|
491
|
-
kind: "function",
|
|
492
|
-
name: nameNode?.text ?? "unknown",
|
|
493
|
-
detail: extractSignatureLine(node, "function", langName),
|
|
494
|
-
startLine: node.startPosition.row + 1,
|
|
495
|
-
endLine: node.endPosition.row + 1,
|
|
496
|
-
});
|
|
497
|
-
return sigs;
|
|
498
|
-
}
|
|
499
|
-
if (type === "method_declaration") {
|
|
500
|
-
const nameNode = node.childForFieldName("name");
|
|
501
|
-
const receiverNode = node.childForFieldName("receiver");
|
|
502
|
-
const receiverText = receiverNode ? `(${receiverNode.text}) ` : "";
|
|
503
|
-
sigs.push({
|
|
504
|
-
kind: "method",
|
|
505
|
-
name: nameNode?.text ?? "unknown",
|
|
506
|
-
detail: extractSignatureLine(node, "method", langName),
|
|
507
|
-
startLine: node.startPosition.row + 1,
|
|
508
|
-
endLine: node.endPosition.row + 1,
|
|
509
|
-
});
|
|
510
|
-
return sigs;
|
|
511
|
-
}
|
|
512
|
-
if (type === "type_declaration") {
|
|
513
|
-
for (let c = 0; c < node.childCount; c++) {
|
|
514
|
-
const spec = node.child(c);
|
|
515
|
-
if (spec?.type === "type_spec") {
|
|
516
|
-
const nameNode = spec.childForFieldName("name");
|
|
517
|
-
const typeNode = spec.childForFieldName("type");
|
|
518
|
-
const typeName = typeNode?.type ?? "";
|
|
519
|
-
const kind = typeName === "struct_type" ? "struct"
|
|
520
|
-
: typeName === "interface_type" ? "interface"
|
|
521
|
-
: "type";
|
|
522
|
-
const children = [];
|
|
523
|
-
// Extract struct fields or interface methods
|
|
524
|
-
if (typeNode && (typeName === "struct_type" || typeName === "interface_type")) {
|
|
525
|
-
const fieldList = typeNode.child(1); // The field list between braces
|
|
526
|
-
if (fieldList) {
|
|
527
|
-
for (let f = 0; f < fieldList.childCount; f++) {
|
|
528
|
-
const field = fieldList.child(f);
|
|
529
|
-
if (field && field.type !== "{" && field.type !== "}" && field.type !== ",") {
|
|
530
|
-
const fieldText = field.text.split("\n")[0].trim();
|
|
531
|
-
if (fieldText) {
|
|
532
|
-
children.push({
|
|
533
|
-
kind: typeName === "interface_type" ? "method" : "variable",
|
|
534
|
-
name: fieldText.split(/\s+/)[0],
|
|
535
|
-
detail: fieldText,
|
|
536
|
-
startLine: field.startPosition.row + 1,
|
|
537
|
-
endLine: field.endPosition.row + 1,
|
|
538
|
-
});
|
|
539
|
-
}
|
|
540
|
-
}
|
|
541
|
-
}
|
|
542
|
-
}
|
|
543
|
-
}
|
|
544
|
-
sigs.push({
|
|
545
|
-
kind,
|
|
546
|
-
name: nameNode?.text ?? "unknown",
|
|
547
|
-
detail: extractSignatureLine(node, kind, langName),
|
|
548
|
-
startLine: node.startPosition.row + 1,
|
|
549
|
-
endLine: node.endPosition.row + 1,
|
|
550
|
-
children: children.length > 0 ? children : undefined,
|
|
551
|
-
});
|
|
552
|
-
}
|
|
553
|
-
}
|
|
554
|
-
return sigs;
|
|
555
|
-
}
|
|
556
|
-
if (type === "package_clause") {
|
|
557
|
-
const nameNode = node.child(1);
|
|
558
|
-
sigs.push({
|
|
559
|
-
kind: "package",
|
|
560
|
-
name: nameNode?.text ?? "unknown",
|
|
561
|
-
detail: node.text,
|
|
562
|
-
startLine: node.startPosition.row + 1,
|
|
563
|
-
endLine: node.endPosition.row + 1,
|
|
564
|
-
});
|
|
565
|
-
return sigs;
|
|
566
|
-
}
|
|
567
|
-
if (type === "const_declaration" || type === "var_declaration") {
|
|
568
|
-
sigs.push({
|
|
569
|
-
kind: "const",
|
|
570
|
-
name: "",
|
|
571
|
-
detail: extractSignatureLine(node, "const", langName),
|
|
572
|
-
startLine: node.startPosition.row + 1,
|
|
573
|
-
endLine: node.endPosition.row + 1,
|
|
574
|
-
});
|
|
575
|
-
return sigs;
|
|
576
|
-
}
|
|
577
|
-
}
|
|
578
|
-
// ── Rust ──
|
|
579
|
-
if (langName === "rust") {
|
|
580
|
-
if (type === "function_item") {
|
|
581
|
-
const nameNode = node.childForFieldName("name");
|
|
582
|
-
sigs.push({
|
|
583
|
-
kind: "function",
|
|
584
|
-
name: nameNode?.text ?? "unknown",
|
|
585
|
-
detail: extractSignatureLine(node, "function", langName),
|
|
586
|
-
startLine: node.startPosition.row + 1,
|
|
587
|
-
endLine: node.endPosition.row + 1,
|
|
588
|
-
});
|
|
589
|
-
return sigs;
|
|
590
|
-
}
|
|
591
|
-
if (type === "struct_item") {
|
|
592
|
-
const nameNode = node.childForFieldName("name");
|
|
593
|
-
sigs.push({
|
|
594
|
-
kind: "struct",
|
|
595
|
-
name: nameNode?.text ?? "unknown",
|
|
596
|
-
detail: extractSignatureLine(node, "struct", langName),
|
|
597
|
-
startLine: node.startPosition.row + 1,
|
|
598
|
-
endLine: node.endPosition.row + 1,
|
|
599
|
-
});
|
|
600
|
-
return sigs;
|
|
601
|
-
}
|
|
602
|
-
if (type === "enum_item") {
|
|
603
|
-
const nameNode = node.childForFieldName("name");
|
|
604
|
-
sigs.push({
|
|
605
|
-
kind: "enum",
|
|
606
|
-
name: nameNode?.text ?? "unknown",
|
|
607
|
-
detail: extractSignatureLine(node, "enum", langName),
|
|
608
|
-
startLine: node.startPosition.row + 1,
|
|
609
|
-
endLine: node.endPosition.row + 1,
|
|
610
|
-
});
|
|
611
|
-
return sigs;
|
|
612
|
-
}
|
|
613
|
-
if (type === "trait_item") {
|
|
614
|
-
const nameNode = node.childForFieldName("name");
|
|
615
|
-
const children = [];
|
|
616
|
-
const body = node.childForFieldName("body");
|
|
617
|
-
if (body) {
|
|
618
|
-
for (let c = 0; c < body.childCount; c++) {
|
|
619
|
-
const member = body.child(c);
|
|
620
|
-
if (member?.type === "function_item") {
|
|
621
|
-
const methodName = member.childForFieldName("name");
|
|
622
|
-
children.push({
|
|
623
|
-
kind: "method",
|
|
624
|
-
name: methodName?.text ?? "unknown",
|
|
625
|
-
detail: extractSignatureLine(member, "method", langName),
|
|
626
|
-
startLine: member.startPosition.row + 1,
|
|
627
|
-
endLine: member.endPosition.row + 1,
|
|
628
|
-
});
|
|
629
|
-
}
|
|
630
|
-
}
|
|
631
|
-
}
|
|
632
|
-
sigs.push({
|
|
633
|
-
kind: "trait",
|
|
634
|
-
name: nameNode?.text ?? "unknown",
|
|
635
|
-
detail: extractSignatureLine(node, "trait", langName),
|
|
636
|
-
startLine: node.startPosition.row + 1,
|
|
637
|
-
endLine: node.endPosition.row + 1,
|
|
638
|
-
children: children.length > 0 ? children : undefined,
|
|
639
|
-
});
|
|
640
|
-
return sigs;
|
|
641
|
-
}
|
|
642
|
-
if (type === "impl_item") {
|
|
643
|
-
const typeNode = node.childForFieldName("type");
|
|
644
|
-
const traitNode = node.childForFieldName("trait");
|
|
645
|
-
const name = traitNode
|
|
646
|
-
? `${traitNode.text} for ${typeNode?.text ?? "?"}`
|
|
647
|
-
: typeNode?.text ?? "unknown";
|
|
648
|
-
const children = [];
|
|
649
|
-
const body = node.childForFieldName("body");
|
|
650
|
-
if (body) {
|
|
651
|
-
for (let c = 0; c < body.childCount; c++) {
|
|
652
|
-
const member = body.child(c);
|
|
653
|
-
if (member?.type === "function_item") {
|
|
654
|
-
const methodName = member.childForFieldName("name");
|
|
655
|
-
children.push({
|
|
656
|
-
kind: "method",
|
|
657
|
-
name: methodName?.text ?? "unknown",
|
|
658
|
-
detail: extractSignatureLine(member, "method", langName),
|
|
659
|
-
startLine: member.startPosition.row + 1,
|
|
660
|
-
endLine: member.endPosition.row + 1,
|
|
661
|
-
});
|
|
662
|
-
}
|
|
663
|
-
}
|
|
664
|
-
}
|
|
665
|
-
sigs.push({
|
|
666
|
-
kind: "impl",
|
|
667
|
-
name,
|
|
668
|
-
detail: extractSignatureLine(node, "impl", langName),
|
|
669
|
-
startLine: node.startPosition.row + 1,
|
|
670
|
-
endLine: node.endPosition.row + 1,
|
|
671
|
-
children: children.length > 0 ? children : undefined,
|
|
672
|
-
});
|
|
673
|
-
return sigs;
|
|
674
|
-
}
|
|
675
|
-
if (type === "type_item") {
|
|
676
|
-
const nameNode = node.childForFieldName("name");
|
|
677
|
-
sigs.push({
|
|
678
|
-
kind: "type",
|
|
679
|
-
name: nameNode?.text ?? "unknown",
|
|
680
|
-
detail: extractSignatureLine(node, "type", langName),
|
|
681
|
-
startLine: node.startPosition.row + 1,
|
|
682
|
-
endLine: node.endPosition.row + 1,
|
|
683
|
-
});
|
|
684
|
-
return sigs;
|
|
685
|
-
}
|
|
686
|
-
if (type === "const_item" || type === "static_item") {
|
|
687
|
-
const nameNode = node.childForFieldName("name");
|
|
688
|
-
sigs.push({
|
|
689
|
-
kind: "const",
|
|
690
|
-
name: nameNode?.text ?? "unknown",
|
|
691
|
-
detail: extractSignatureLine(node, "const", langName),
|
|
692
|
-
startLine: node.startPosition.row + 1,
|
|
693
|
-
endLine: node.endPosition.row + 1,
|
|
694
|
-
});
|
|
695
|
-
return sigs;
|
|
696
|
-
}
|
|
697
|
-
if (type === "mod_item") {
|
|
698
|
-
const nameNode = node.childForFieldName("name");
|
|
699
|
-
sigs.push({
|
|
700
|
-
kind: "module",
|
|
701
|
-
name: nameNode?.text ?? "unknown",
|
|
702
|
-
detail: extractSignatureLine(node, "module", langName),
|
|
703
|
-
startLine: node.startPosition.row + 1,
|
|
704
|
-
endLine: node.endPosition.row + 1,
|
|
705
|
-
});
|
|
706
|
-
return sigs;
|
|
707
|
-
}
|
|
708
|
-
}
|
|
709
|
-
return sigs;
|
|
710
|
-
}
|