diff --git a/backend/internal/codesnippet/usecase/codesnippet.go b/backend/internal/codesnippet/usecase/codesnippet.go index e1db97a..3b879a2 100644 --- a/backend/internal/codesnippet/usecase/codesnippet.go +++ b/backend/internal/codesnippet/usecase/codesnippet.go @@ -31,7 +31,7 @@ func (u *CodeSnippetUsecase) CreateFromIndexResult(ctx context.Context, workspac Name: indexResult.Name, SnippetType: indexResult.Type, Language: indexResult.Language, - Content: indexResult.RangeText, + Content: indexResult.ImplementText, Hash: indexResult.FileHash, StartLine: indexResult.StartLine, EndLine: indexResult.EndLine, diff --git a/backend/internal/workspace/usecase/workspace.go b/backend/internal/workspace/usecase/workspace.go index f7bda2c..62d15e0 100644 --- a/backend/internal/workspace/usecase/workspace.go +++ b/backend/internal/workspace/usecase/workspace.go @@ -134,6 +134,11 @@ func (u *WorkspaceUsecase) Delete(ctx context.Context, id string) error { } func (u *WorkspaceUsecase) EnsureWorkspace(ctx context.Context, userID, rootPath, name string) (*domain.Workspace, error) { + // 自动生成工作区名称(如果未提供) + if name == "" { + name = u.generateWorkspaceName(rootPath) + } + // 首先尝试获取已存在的工作区 workspace, err := u.repo.GetByUserAndPath(ctx, userID, rootPath) if err == nil { @@ -153,20 +158,48 @@ func (u *WorkspaceUsecase) EnsureWorkspace(ctx context.Context, userID, rootPath return nil, fmt.Errorf("failed to check workspace existence: %w", err) } - // 自动生成工作区名称(如果未提供) - if name == "" { - name = u.generateWorkspaceName(rootPath) + // 使用重试机制来处理并发创建的情况 + maxRetries := 3 + for i := range maxRetries { + createReq := &domain.CreateWorkspaceReq{ + UserID: userID, + Name: name, + Description: fmt.Sprintf("Auto-created workspace for %s", rootPath), + RootPath: rootPath, + Settings: map[string]any{}, + } + + workspace, err := u.Create(ctx, createReq) + if err == nil { + return workspace, nil + } + + // 如果是唯一约束错误,说明工作区已经被其他请求创建了 + if strings.Contains(err.Error(), "duplicate key value violates unique constraint") { + // 等待一小段时间,然后尝试获取已创建的工作区 + time.Sleep(10 * time.Millisecond) + + existing, err := u.repo.GetByUserAndPath(ctx, userID, rootPath) + if err == nil { + // 更新最后访问时间 + updated, err := u.repo.Update(ctx, existing.ID.String(), func(up *db.WorkspaceUpdateOne) error { + up.SetLastAccessedAt(time.Now()) + return nil + }) + if err != nil { + u.logger.Warn("failed to update workspace last accessed time", "error", err, "id", existing.ID) + } + return (&domain.Workspace{}).From(updated), nil + } + } + + // 如果不是唯一约束错误,直接返回错误 + if i == maxRetries-1 { + return nil, err + } } - createReq := &domain.CreateWorkspaceReq{ - UserID: userID, - Name: name, - Description: fmt.Sprintf("Auto-created workspace for %s", rootPath), - RootPath: rootPath, - Settings: map[string]any{}, - } - - return u.Create(ctx, createReq) + return nil, fmt.Errorf("failed to create workspace after %d retries", maxRetries) } func (u *WorkspaceUsecase) generateWorkspaceName(rootPath string) string { diff --git a/backend/pkg/cli/cli.go b/backend/pkg/cli/cli.go index fc6195b..7648dd8 100644 --- a/backend/pkg/cli/cli.go +++ b/backend/pkg/cli/cli.go @@ -8,6 +8,9 @@ import ( "github.com/chaitin/MonkeyCode/backend/domain" ) +// cli 脚本工具 +const scriptPath = "./tools/dist/cli.cjs" + // RunCli 运行monkeycode-cli命令 // // @Tags CLI @@ -15,11 +18,11 @@ import ( // @Description 运行monkeycode-cli命令 // @Accept json // @Produce json -// @Param command path string true "命令" -// @Param flag query string false "标志" -// @Param codeFiles body domain.CodeFiles true "代码文件信息" -// @Success 200 {object} []domain.IndexResult "输出结果" -// @Failure 500 {object} web.Resp "内部错误" +// @Param command index string true "命令" +// @Param flag query string false "标志" +// @Param fileMetas body domain.[]FileMeta true "代码文件信息" +// @Success 200 {object} []domain.IndexResult "输出结果" +// @Failure 500 {object} web.Resp "内部错误" // @Router /api/v1/cli/{command} [post] func RunCli(command string, flag string, fileMetas []domain.FileMeta) ([]domain.IndexResult, error) { inputJson, err := json.Marshal(fileMetas) @@ -29,9 +32,9 @@ func RunCli(command string, flag string, fileMetas []domain.FileMeta) ([]domain. var cmd *exec.Cmd if flag == "" { - cmd = exec.Command("monkeycode-cli", command, string(inputJson)) + cmd = exec.Command(scriptPath, command, string(inputJson)) } else { - cmd = exec.Command("monkeycode-cli", command, flag, string(inputJson)) + cmd = exec.Command(scriptPath, command, flag, string(inputJson)) } cmd.Env = os.Environ() diff --git a/backend/pkg/cli/tools/dist/cli.cjs b/backend/pkg/cli/tools/dist/cli.cjs new file mode 100755 index 0000000..fba2b42 --- /dev/null +++ b/backend/pkg/cli/tools/dist/cli.cjs @@ -0,0 +1,18000 @@ +#!/usr/bin/env node +"use strict"; +var __create = Object.create; +var __defProp = Object.defineProperty; +var __getOwnPropDesc = Object.getOwnPropertyDescriptor; +var __getOwnPropNames = Object.getOwnPropertyNames; +var __getProtoOf = Object.getPrototypeOf; +var __hasOwnProp = Object.prototype.hasOwnProperty; +var __commonJS = (cb, mod) => function __require() { + return mod || (0, cb[__getOwnPropNames(cb)[0]])((mod = { exports: {} }).exports, mod), mod.exports; +}; +var __copyProps = (to, from, except, desc) => { + if (from && typeof from === "object" || typeof from === "function") { + for (let key of __getOwnPropNames(from)) + if (!__hasOwnProp.call(to, key) && key !== except) + __defProp(to, key, { get: () => from[key], enumerable: !(desc = __getOwnPropDesc(from, key)) || desc.enumerable }); + } + return to; +}; +var __toESM = (mod, isNodeMode, target) => (target = mod != null ? __create(__getProtoOf(mod)) : {}, __copyProps( + // If the importer is in node compatibility mode or this is not an ESM + // file that has been converted to a CommonJS file using a Babel- + // compatible transform (i.e. "__esModule" has not been set), then set + // "default" to the CommonJS "module.exports" for node compatibility. + isNodeMode || !mod || !mod.__esModule ? __defProp(target, "default", { value: mod, enumerable: true }) : target, + mod +)); + +// ../../../node_modules/.pnpm/web-tree-sitter@0.22.6/node_modules/web-tree-sitter/tree-sitter.js +var require_tree_sitter = __commonJS({ + "../../../node_modules/.pnpm/web-tree-sitter@0.22.6/node_modules/web-tree-sitter/tree-sitter.js"(exports, module) { + var Module = void 0 !== Module ? Module : {}; + var TreeSitter = function() { + var initPromise, document = "object" == typeof window ? { currentScript: window.document.currentScript } : null; + class Parser { + constructor() { + this.initialize(); + } + initialize() { + throw new Error("cannot construct a Parser before calling `init()`"); + } + static init(moduleOptions) { + return initPromise || (Module = Object.assign({}, Module, moduleOptions), initPromise = new Promise((resolveInitPromise) => { + var moduleOverrides = Object.assign({}, Module), arguments_ = [], thisProgram = "./this.program", quit_ = (e, t) => { + throw t; + }, ENVIRONMENT_IS_WEB = "object" == typeof window, ENVIRONMENT_IS_WORKER = "function" == typeof importScripts, ENVIRONMENT_IS_NODE = "object" == typeof process && "object" == typeof process.versions && "string" == typeof process.versions.node, scriptDirectory = "", read_, readAsync, readBinary; + function locateFile(e) { + return Module.locateFile ? Module.locateFile(e, scriptDirectory) : scriptDirectory + e; + } + if (ENVIRONMENT_IS_NODE) { + var fs = require("fs"), nodePath = require("path"); + scriptDirectory = ENVIRONMENT_IS_WORKER ? nodePath.dirname(scriptDirectory) + "/" : __dirname + "/", read_ = (e, t) => (e = isFileURI(e) ? new URL(e) : nodePath.normalize(e), fs.readFileSync(e, t ? void 0 : "utf8")), readBinary = (e) => { + var t = read_(e, true); + return t.buffer || (t = new Uint8Array(t)), t; + }, readAsync = (e, t, _, s = true) => { + e = isFileURI(e) ? new URL(e) : nodePath.normalize(e), fs.readFile(e, s ? void 0 : "utf8", (e2, r) => { + e2 ? _(e2) : t(s ? r.buffer : r); + }); + }, !Module.thisProgram && process.argv.length > 1 && (thisProgram = process.argv[1].replace(/\\/g, "/")), arguments_ = process.argv.slice(2), "undefined" != typeof module && (module.exports = Module), quit_ = (e, t) => { + throw process.exitCode = e, t; + }; + } else (ENVIRONMENT_IS_WEB || ENVIRONMENT_IS_WORKER) && (ENVIRONMENT_IS_WORKER ? scriptDirectory = self.location.href : void 0 !== document && document.currentScript && (scriptDirectory = document.currentScript.src), scriptDirectory = scriptDirectory.startsWith("blob:") ? "" : scriptDirectory.substr(0, scriptDirectory.replace(/[?#].*/, "").lastIndexOf("/") + 1), read_ = (e) => { + var t = new XMLHttpRequest(); + return t.open("GET", e, false), t.send(null), t.responseText; + }, ENVIRONMENT_IS_WORKER && (readBinary = (e) => { + var t = new XMLHttpRequest(); + return t.open("GET", e, false), t.responseType = "arraybuffer", t.send(null), new Uint8Array(t.response); + }), readAsync = (e, t, _) => { + var s = new XMLHttpRequest(); + s.open("GET", e, true), s.responseType = "arraybuffer", s.onload = () => { + 200 == s.status || 0 == s.status && s.response ? t(s.response) : _(); + }, s.onerror = _, s.send(null); + }); + var out = Module.print || console.log.bind(console), err = Module.printErr || console.error.bind(console); + Object.assign(Module, moduleOverrides), moduleOverrides = null, Module.arguments && (arguments_ = Module.arguments), Module.thisProgram && (thisProgram = Module.thisProgram), Module.quit && (quit_ = Module.quit); + var dynamicLibraries = Module.dynamicLibraries || [], wasmBinary, wasmMemory; + Module.wasmBinary && (wasmBinary = Module.wasmBinary), "object" != typeof WebAssembly && abort("no native wasm support detected"); + var ABORT = false, EXITSTATUS, HEAP8, HEAPU8, HEAP16, HEAPU16, HEAP32, HEAPU32, HEAPF32, HEAPF64; + function updateMemoryViews() { + var e = wasmMemory.buffer; + Module.HEAP8 = HEAP8 = new Int8Array(e), Module.HEAP16 = HEAP16 = new Int16Array(e), Module.HEAPU8 = HEAPU8 = new Uint8Array(e), Module.HEAPU16 = HEAPU16 = new Uint16Array(e), Module.HEAP32 = HEAP32 = new Int32Array(e), Module.HEAPU32 = HEAPU32 = new Uint32Array(e), Module.HEAPF32 = HEAPF32 = new Float32Array(e), Module.HEAPF64 = HEAPF64 = new Float64Array(e); + } + var INITIAL_MEMORY = Module.INITIAL_MEMORY || 33554432; + wasmMemory = Module.wasmMemory ? Module.wasmMemory : new WebAssembly.Memory({ initial: INITIAL_MEMORY / 65536, maximum: 32768 }), updateMemoryViews(), INITIAL_MEMORY = wasmMemory.buffer.byteLength; + var __ATPRERUN__ = [], __ATINIT__ = [], __ATMAIN__ = [], __ATPOSTRUN__ = [], __RELOC_FUNCS__ = [], runtimeInitialized = false; + function preRun() { + if (Module.preRun) for ("function" == typeof Module.preRun && (Module.preRun = [Module.preRun]); Module.preRun.length; ) addOnPreRun(Module.preRun.shift()); + callRuntimeCallbacks(__ATPRERUN__); + } + function initRuntime() { + runtimeInitialized = true, callRuntimeCallbacks(__RELOC_FUNCS__), callRuntimeCallbacks(__ATINIT__); + } + function preMain() { + callRuntimeCallbacks(__ATMAIN__); + } + function postRun() { + if (Module.postRun) for ("function" == typeof Module.postRun && (Module.postRun = [Module.postRun]); Module.postRun.length; ) addOnPostRun(Module.postRun.shift()); + callRuntimeCallbacks(__ATPOSTRUN__); + } + function addOnPreRun(e) { + __ATPRERUN__.unshift(e); + } + function addOnInit(e) { + __ATINIT__.unshift(e); + } + function addOnPostRun(e) { + __ATPOSTRUN__.unshift(e); + } + var runDependencies = 0, runDependencyWatcher = null, dependenciesFulfilled = null; + function getUniqueRunDependency(e) { + return e; + } + function addRunDependency(e) { + runDependencies++, Module.monitorRunDependencies?.(runDependencies); + } + function removeRunDependency(e) { + if (runDependencies--, Module.monitorRunDependencies?.(runDependencies), 0 == runDependencies && (null !== runDependencyWatcher && (clearInterval(runDependencyWatcher), runDependencyWatcher = null), dependenciesFulfilled)) { + var t = dependenciesFulfilled; + dependenciesFulfilled = null, t(); + } + } + function abort(e) { + throw Module.onAbort?.(e), err(e = "Aborted(" + e + ")"), ABORT = true, EXITSTATUS = 1, e += ". Build with -sASSERTIONS for more info.", new WebAssembly.RuntimeError(e); + } + var dataURIPrefix = "data:application/octet-stream;base64,", isDataURI = (e) => e.startsWith(dataURIPrefix), isFileURI = (e) => e.startsWith("file://"), wasmBinaryFile; + function getBinarySync(e) { + if (e == wasmBinaryFile && wasmBinary) return new Uint8Array(wasmBinary); + if (readBinary) return readBinary(e); + throw "both async and sync fetching of the wasm failed"; + } + function getBinaryPromise(e) { + if (!wasmBinary && (ENVIRONMENT_IS_WEB || ENVIRONMENT_IS_WORKER)) { + if ("function" == typeof fetch && !isFileURI(e)) return fetch(e, { credentials: "same-origin" }).then((t) => { + if (!t.ok) throw `failed to load wasm binary file at '${e}'`; + return t.arrayBuffer(); + }).catch(() => getBinarySync(e)); + if (readAsync) return new Promise((t, _) => { + readAsync(e, (e2) => t(new Uint8Array(e2)), _); + }); + } + return Promise.resolve().then(() => getBinarySync(e)); + } + function instantiateArrayBuffer(e, t, _) { + return getBinaryPromise(e).then((e2) => WebAssembly.instantiate(e2, t)).then(_, (e2) => { + err(`failed to asynchronously prepare wasm: ${e2}`), abort(e2); + }); + } + function instantiateAsync(e, t, _, s) { + return e || "function" != typeof WebAssembly.instantiateStreaming || isDataURI(t) || isFileURI(t) || ENVIRONMENT_IS_NODE || "function" != typeof fetch ? instantiateArrayBuffer(t, _, s) : fetch(t, { credentials: "same-origin" }).then((e2) => WebAssembly.instantiateStreaming(e2, _).then(s, function(e3) { + return err(`wasm streaming compile failed: ${e3}`), err("falling back to ArrayBuffer instantiation"), instantiateArrayBuffer(t, _, s); + })); + } + function createWasm() { + var e = { env: wasmImports, wasi_snapshot_preview1: wasmImports, "GOT.mem": new Proxy(wasmImports, GOTHandler), "GOT.func": new Proxy(wasmImports, GOTHandler) }; + function t(e2, t2) { + wasmExports = e2.exports, wasmExports = relocateExports(wasmExports, 1024); + var _ = getDylinkMetadata(t2); + return _.neededDynlibs && (dynamicLibraries = _.neededDynlibs.concat(dynamicLibraries)), mergeLibSymbols(wasmExports, "main"), LDSO.init(), loadDylibs(), addOnInit(wasmExports.__wasm_call_ctors), __RELOC_FUNCS__.push(wasmExports.__wasm_apply_data_relocs), removeRunDependency("wasm-instantiate"), wasmExports; + } + if (addRunDependency("wasm-instantiate"), Module.instantiateWasm) try { + return Module.instantiateWasm(e, t); + } catch (e2) { + return err(`Module.instantiateWasm callback failed with error: ${e2}`), false; + } + return instantiateAsync(wasmBinary, wasmBinaryFile, e, function(e2) { + t(e2.instance, e2.module); + }), {}; + } + wasmBinaryFile = "tree-sitter.wasm", isDataURI(wasmBinaryFile) || (wasmBinaryFile = locateFile(wasmBinaryFile)); + var ASM_CONSTS = {}; + function ExitStatus(e) { + this.name = "ExitStatus", this.message = `Program terminated with exit(${e})`, this.status = e; + } + var GOT = {}, currentModuleWeakSymbols = /* @__PURE__ */ new Set([]), GOTHandler = { get(e, t) { + var _ = GOT[t]; + return _ || (_ = GOT[t] = new WebAssembly.Global({ value: "i32", mutable: true })), currentModuleWeakSymbols.has(t) || (_.required = true), _; + } }, callRuntimeCallbacks = (e) => { + for (; e.length > 0; ) e.shift()(Module); + }, UTF8Decoder = "undefined" != typeof TextDecoder ? new TextDecoder("utf8") : void 0, UTF8ArrayToString = (e, t, _) => { + for (var s = t + _, r = t; e[r] && !(r >= s); ) ++r; + if (r - t > 16 && e.buffer && UTF8Decoder) return UTF8Decoder.decode(e.subarray(t, r)); + for (var a = ""; t < r; ) { + var o = e[t++]; + if (128 & o) { + var n = 63 & e[t++]; + if (192 != (224 & o)) { + var l = 63 & e[t++]; + if ((o = 224 == (240 & o) ? (15 & o) << 12 | n << 6 | l : (7 & o) << 18 | n << 12 | l << 6 | 63 & e[t++]) < 65536) a += String.fromCharCode(o); + else { + var d = o - 65536; + a += String.fromCharCode(55296 | d >> 10, 56320 | 1023 & d); + } + } else a += String.fromCharCode((31 & o) << 6 | n); + } else a += String.fromCharCode(o); + } + return a; + }, getDylinkMetadata = (e) => { + var t = 0, _ = 0; + function s() { + for (var _2 = 0, s2 = 1; ; ) { + var r2 = e[t++]; + if (_2 += (127 & r2) * s2, s2 *= 128, !(128 & r2)) break; + } + return _2; + } + function r() { + var _2 = s(); + return UTF8ArrayToString(e, (t += _2) - _2, _2); + } + function a(e2, t2) { + if (e2) throw new Error(t2); + } + var o = "dylink.0"; + if (e instanceof WebAssembly.Module) { + var n = WebAssembly.Module.customSections(e, o); + 0 === n.length && (o = "dylink", n = WebAssembly.Module.customSections(e, o)), a(0 === n.length, "need dylink section"), _ = (e = new Uint8Array(n[0])).length; + } else { + a(!(1836278016 == new Uint32Array(new Uint8Array(e.subarray(0, 24)).buffer)[0]), "need to see wasm magic number"), a(0 !== e[8], "need the dylink section to be first"), t = 9; + var l = s(); + _ = t + l, o = r(); + } + var d = { neededDynlibs: [], tlsExports: /* @__PURE__ */ new Set(), weakImports: /* @__PURE__ */ new Set() }; + if ("dylink" == o) { + d.memorySize = s(), d.memoryAlign = s(), d.tableSize = s(), d.tableAlign = s(); + for (var u = s(), m = 0; m < u; ++m) { + var c = r(); + d.neededDynlibs.push(c); + } + } else { + a("dylink.0" !== o); + for (; t < _; ) { + var w = e[t++], p = s(); + if (1 === w) d.memorySize = s(), d.memoryAlign = s(), d.tableSize = s(), d.tableAlign = s(); + else if (2 === w) for (u = s(), m = 0; m < u; ++m) c = r(), d.neededDynlibs.push(c); + else if (3 === w) for (var h = s(); h--; ) { + var g = r(); + 256 & s() && d.tlsExports.add(g); + } + else if (4 === w) for (h = s(); h--; ) { + r(), g = r(); + 1 == (3 & s()) && d.weakImports.add(g); + } + else t += p; + } + } + return d; + }; + function getValue(e, t = "i8") { + switch (t.endsWith("*") && (t = "*"), t) { + case "i1": + case "i8": + return HEAP8[e]; + case "i16": + return HEAP16[e >> 1]; + case "i32": + return HEAP32[e >> 2]; + case "i64": + abort("to do getValue(i64) use WASM_BIGINT"); + case "float": + return HEAPF32[e >> 2]; + case "double": + return HEAPF64[e >> 3]; + case "*": + return HEAPU32[e >> 2]; + default: + abort(`invalid type for getValue: ${t}`); + } + } + var newDSO = (e, t, _) => { + var s = { refcount: 1 / 0, name: e, exports: _, global: true }; + return LDSO.loadedLibsByName[e] = s, null != t && (LDSO.loadedLibsByHandle[t] = s), s; + }, LDSO = { loadedLibsByName: {}, loadedLibsByHandle: {}, init() { + newDSO("__main__", 0, wasmImports); + } }, ___heap_base = 78096, zeroMemory = (e, t) => (HEAPU8.fill(0, e, e + t), e), alignMemory = (e, t) => Math.ceil(e / t) * t, getMemory = (e) => { + if (runtimeInitialized) return zeroMemory(_malloc(e), e); + var t = ___heap_base, _ = t + alignMemory(e, 16); + return ___heap_base = _, GOT.__heap_base.value = _, t; + }, isInternalSym = (e) => ["__cpp_exception", "__c_longjmp", "__wasm_apply_data_relocs", "__dso_handle", "__tls_size", "__tls_align", "__set_stack_limits", "_emscripten_tls_init", "__wasm_init_tls", "__wasm_call_ctors", "__start_em_asm", "__stop_em_asm", "__start_em_js", "__stop_em_js"].includes(e) || e.startsWith("__em_js__"), uleb128Encode = (e, t) => { + e < 128 ? t.push(e) : t.push(e % 128 | 128, e >> 7); + }, sigToWasmTypes = (e) => { + for (var t = { i: "i32", j: "i64", f: "f32", d: "f64", e: "externref", p: "i32" }, _ = { parameters: [], results: "v" == e[0] ? [] : [t[e[0]]] }, s = 1; s < e.length; ++s) _.parameters.push(t[e[s]]); + return _; + }, generateFuncType = (e, t) => { + var _ = e.slice(0, 1), s = e.slice(1), r = { i: 127, p: 127, j: 126, f: 125, d: 124, e: 111 }; + t.push(96), uleb128Encode(s.length, t); + for (var a = 0; a < s.length; ++a) t.push(r[s[a]]); + "v" == _ ? t.push(0) : t.push(1, r[_]); + }, convertJsFunctionToWasm = (e, t) => { + if ("function" == typeof WebAssembly.Function) return new WebAssembly.Function(sigToWasmTypes(t), e); + var _ = [1]; + generateFuncType(t, _); + var s = [0, 97, 115, 109, 1, 0, 0, 0, 1]; + uleb128Encode(_.length, s), s.push(..._), s.push(2, 7, 1, 1, 101, 1, 102, 0, 0, 7, 5, 1, 1, 102, 0, 0); + var r = new WebAssembly.Module(new Uint8Array(s)); + return new WebAssembly.Instance(r, { e: { f: e } }).exports.f; + }, wasmTableMirror = [], wasmTable = new WebAssembly.Table({ initial: 27, element: "anyfunc" }), getWasmTableEntry = (e) => { + var t = wasmTableMirror[e]; + return t || (e >= wasmTableMirror.length && (wasmTableMirror.length = e + 1), wasmTableMirror[e] = t = wasmTable.get(e)), t; + }, updateTableMap = (e, t) => { + if (functionsInTableMap) for (var _ = e; _ < e + t; _++) { + var s = getWasmTableEntry(_); + s && functionsInTableMap.set(s, _); + } + }, functionsInTableMap, getFunctionAddress = (e) => (functionsInTableMap || (functionsInTableMap = /* @__PURE__ */ new WeakMap(), updateTableMap(0, wasmTable.length)), functionsInTableMap.get(e) || 0), freeTableIndexes = [], getEmptyTableSlot = () => { + if (freeTableIndexes.length) return freeTableIndexes.pop(); + try { + wasmTable.grow(1); + } catch (e) { + if (!(e instanceof RangeError)) throw e; + throw "Unable to grow wasm table. Set ALLOW_TABLE_GROWTH."; + } + return wasmTable.length - 1; + }, setWasmTableEntry = (e, t) => { + wasmTable.set(e, t), wasmTableMirror[e] = wasmTable.get(e); + }, addFunction = (e, t) => { + var _ = getFunctionAddress(e); + if (_) return _; + var s = getEmptyTableSlot(); + try { + setWasmTableEntry(s, e); + } catch (_2) { + if (!(_2 instanceof TypeError)) throw _2; + var r = convertJsFunctionToWasm(e, t); + setWasmTableEntry(s, r); + } + return functionsInTableMap.set(e, s), s; + }, updateGOT = (e, t) => { + for (var _ in e) if (!isInternalSym(_)) { + var s = e[_]; + _.startsWith("orig$") && (_ = _.split("$")[1], t = true), GOT[_] ||= new WebAssembly.Global({ value: "i32", mutable: true }), (t || 0 == GOT[_].value) && ("function" == typeof s ? GOT[_].value = addFunction(s) : "number" == typeof s ? GOT[_].value = s : err(`unhandled export type for '${_}': ${typeof s}`)); + } + }, relocateExports = (e, t, _) => { + var s = {}; + for (var r in e) { + var a = e[r]; + "object" == typeof a && (a = a.value), "number" == typeof a && (a += t), s[r] = a; + } + return updateGOT(s, _), s; + }, isSymbolDefined = (e) => { + var t = wasmImports[e]; + return !(!t || t.stub); + }, dynCallLegacy = (e, t, _) => (0, Module["dynCall_" + e])(t, ..._), dynCall = (e, t, _ = []) => e.includes("j") ? dynCallLegacy(e, t, _) : getWasmTableEntry(t)(..._), createInvokeFunction = (e) => function() { + var t = stackSave(); + try { + return dynCall(e, arguments[0], Array.prototype.slice.call(arguments, 1)); + } catch (e2) { + if (stackRestore(t), e2 !== e2 + 0) throw e2; + _setThrew(1, 0); + } + }, resolveGlobalSymbol = (e, t = false) => { + var _; + return t && "orig$" + e in wasmImports && (e = "orig$" + e), isSymbolDefined(e) ? _ = wasmImports[e] : e.startsWith("invoke_") && (_ = wasmImports[e] = createInvokeFunction(e.split("_")[1])), { sym: _, name: e }; + }, UTF8ToString = (e, t) => e ? UTF8ArrayToString(HEAPU8, e, t) : "", loadWebAssemblyModule = (binary, flags, libName, localScope, handle) => { + var metadata = getDylinkMetadata(binary); + function loadModule() { + var firstLoad = !handle || !HEAP8[handle + 8]; + if (firstLoad) { + var memAlign = Math.pow(2, metadata.memoryAlign), memoryBase = metadata.memorySize ? alignMemory(getMemory(metadata.memorySize + memAlign), memAlign) : 0, tableBase = metadata.tableSize ? wasmTable.length : 0; + handle && (HEAP8[handle + 8] = 1, HEAPU32[handle + 12 >> 2] = memoryBase, HEAP32[handle + 16 >> 2] = metadata.memorySize, HEAPU32[handle + 20 >> 2] = tableBase, HEAP32[handle + 24 >> 2] = metadata.tableSize); + } else memoryBase = HEAPU32[handle + 12 >> 2], tableBase = HEAPU32[handle + 20 >> 2]; + var tableGrowthNeeded = tableBase + metadata.tableSize - wasmTable.length, moduleExports; + function resolveSymbol(e) { + var t = resolveGlobalSymbol(e).sym; + return !t && localScope && (t = localScope[e]), t || (t = moduleExports[e]), t; + } + tableGrowthNeeded > 0 && wasmTable.grow(tableGrowthNeeded); + var proxyHandler = { get(e, t) { + switch (t) { + case "__memory_base": + return memoryBase; + case "__table_base": + return tableBase; + } + if (t in wasmImports && !wasmImports[t].stub) return wasmImports[t]; + var _; + t in e || (e[t] = (...e2) => (_ ||= resolveSymbol(t), _(...e2))); + return e[t]; + } }, proxy = new Proxy({}, proxyHandler), info = { "GOT.mem": new Proxy({}, GOTHandler), "GOT.func": new Proxy({}, GOTHandler), env: proxy, wasi_snapshot_preview1: proxy }; + function postInstantiation(module, instance) { + function addEmAsm(addr, body) { + for (var args = [], arity = 0; arity < 16 && -1 != body.indexOf("$" + arity); arity++) args.push("$" + arity); + args = args.join(","); + var func = `(${args}) => { ${body} };`; + ASM_CONSTS[start] = eval(func); + } + if (updateTableMap(tableBase, metadata.tableSize), moduleExports = relocateExports(instance.exports, memoryBase), flags.allowUndefined || reportUndefinedSymbols(), "__start_em_asm" in moduleExports) for (var start = moduleExports.__start_em_asm, stop = moduleExports.__stop_em_asm; start < stop; ) { + var jsString = UTF8ToString(start); + addEmAsm(start, jsString), start = HEAPU8.indexOf(0, start) + 1; + } + function addEmJs(name, cSig, body) { + var jsArgs = []; + if (cSig = cSig.slice(1, -1), "void" != cSig) for (var i in cSig = cSig.split(","), cSig) { + var jsArg = cSig[i].split(" ").pop(); + jsArgs.push(jsArg.replace("*", "")); + } + var func = `(${jsArgs}) => ${body};`; + moduleExports[name] = eval(func); + } + for (var name in moduleExports) if (name.startsWith("__em_js__")) { + var start = moduleExports[name], jsString = UTF8ToString(start), parts = jsString.split("<::>"); + addEmJs(name.replace("__em_js__", ""), parts[0], parts[1]), delete moduleExports[name]; + } + var applyRelocs = moduleExports.__wasm_apply_data_relocs; + applyRelocs && (runtimeInitialized ? applyRelocs() : __RELOC_FUNCS__.push(applyRelocs)); + var init = moduleExports.__wasm_call_ctors; + return init && (runtimeInitialized ? init() : __ATINIT__.push(init)), moduleExports; + } + if (flags.loadAsync) { + if (binary instanceof WebAssembly.Module) { + var instance = new WebAssembly.Instance(binary, info); + return Promise.resolve(postInstantiation(binary, instance)); + } + return WebAssembly.instantiate(binary, info).then((e) => postInstantiation(e.module, e.instance)); + } + var module = binary instanceof WebAssembly.Module ? binary : new WebAssembly.Module(binary), instance = new WebAssembly.Instance(module, info); + return postInstantiation(module, instance); + } + return currentModuleWeakSymbols = metadata.weakImports, flags.loadAsync ? metadata.neededDynlibs.reduce((e, t) => e.then(() => loadDynamicLibrary(t, flags)), Promise.resolve()).then(loadModule) : (metadata.neededDynlibs.forEach((e) => loadDynamicLibrary(e, flags, localScope)), loadModule()); + }, mergeLibSymbols = (e, t) => { + for (var [_, s] of Object.entries(e)) { + const e2 = (e3) => { + isSymbolDefined(e3) || (wasmImports[e3] = s); + }; + e2(_); + const t2 = "__main_argc_argv"; + "main" == _ && e2(t2), _ == t2 && e2("main"), _.startsWith("dynCall_") && !Module.hasOwnProperty(_) && (Module[_] = s); + } + }, asyncLoad = (e, t, _, s) => { + var r = s ? "" : getUniqueRunDependency(`al ${e}`); + readAsync(e, (e2) => { + t(new Uint8Array(e2)), r && removeRunDependency(r); + }, (t2) => { + if (!_) throw `Loading data file "${e}" failed.`; + _(); + }), r && addRunDependency(r); + }; + function loadDynamicLibrary(e, t = { global: true, nodelete: true }, _, s) { + var r = LDSO.loadedLibsByName[e]; + if (r) return t.global ? r.global || (r.global = true, mergeLibSymbols(r.exports, e)) : _ && Object.assign(_, r.exports), t.nodelete && r.refcount !== 1 / 0 && (r.refcount = 1 / 0), r.refcount++, s && (LDSO.loadedLibsByHandle[s] = r), !t.loadAsync || Promise.resolve(true); + function a() { + if (s) { + var _2 = HEAPU32[s + 28 >> 2], r2 = HEAPU32[s + 32 >> 2]; + if (_2 && r2) { + var a2 = HEAP8.slice(_2, _2 + r2); + return t.loadAsync ? Promise.resolve(a2) : a2; + } + } + var o2 = locateFile(e); + if (t.loadAsync) return new Promise(function(e2, t2) { + asyncLoad(o2, e2, t2); + }); + if (!readBinary) throw new Error(`${o2}: file not found, and synchronous loading of external files is not available`); + return readBinary(o2); + } + function o() { + return t.loadAsync ? a().then((r2) => loadWebAssemblyModule(r2, t, e, _, s)) : loadWebAssemblyModule(a(), t, e, _, s); + } + function n(t2) { + r.global ? mergeLibSymbols(t2, e) : _ && Object.assign(_, t2), r.exports = t2; + } + return (r = newDSO(e, s, "loading")).refcount = t.nodelete ? 1 / 0 : 1, r.global = t.global, t.loadAsync ? o().then((e2) => (n(e2), true)) : (n(o()), true); + } + var reportUndefinedSymbols = () => { + for (var [e, t] of Object.entries(GOT)) if (0 == t.value) { + var _ = resolveGlobalSymbol(e, true).sym; + if (!_ && !t.required) continue; + if ("function" == typeof _) t.value = addFunction(_, _.sig); + else { + if ("number" != typeof _) throw new Error(`bad export type for '${e}': ${typeof _}`); + t.value = _; + } + } + }, loadDylibs = () => { + dynamicLibraries.length ? (addRunDependency("loadDylibs"), dynamicLibraries.reduce((e, t) => e.then(() => loadDynamicLibrary(t, { loadAsync: true, global: true, nodelete: true, allowUndefined: true })), Promise.resolve()).then(() => { + reportUndefinedSymbols(), removeRunDependency("loadDylibs"); + })) : reportUndefinedSymbols(); + }, noExitRuntime = Module.noExitRuntime || true; + function setValue(e, t, _ = "i8") { + switch (_.endsWith("*") && (_ = "*"), _) { + case "i1": + case "i8": + HEAP8[e] = t; + break; + case "i16": + HEAP16[e >> 1] = t; + break; + case "i32": + HEAP32[e >> 2] = t; + break; + case "i64": + abort("to do setValue(i64) use WASM_BIGINT"); + case "float": + HEAPF32[e >> 2] = t; + break; + case "double": + HEAPF64[e >> 3] = t; + break; + case "*": + HEAPU32[e >> 2] = t; + break; + default: + abort(`invalid type for setValue: ${_}`); + } + } + var ___memory_base = new WebAssembly.Global({ value: "i32", mutable: false }, 1024), ___stack_pointer = new WebAssembly.Global({ value: "i32", mutable: true }, 78096), ___table_base = new WebAssembly.Global({ value: "i32", mutable: false }, 1), nowIsMonotonic = 1, __emscripten_get_now_is_monotonic = () => nowIsMonotonic; + __emscripten_get_now_is_monotonic.sig = "i"; + var _abort = () => { + abort(""); + }; + _abort.sig = "v"; + var _emscripten_date_now = () => Date.now(), _emscripten_get_now; + _emscripten_date_now.sig = "d", _emscripten_get_now = () => performance.now(), _emscripten_get_now.sig = "d"; + var _emscripten_memcpy_js = (e, t, _) => HEAPU8.copyWithin(e, t, t + _); + _emscripten_memcpy_js.sig = "vppp"; + var getHeapMax = () => 2147483648, growMemory = (e) => { + var t = (e - wasmMemory.buffer.byteLength + 65535) / 65536; + try { + return wasmMemory.grow(t), updateMemoryViews(), 1; + } catch (e2) { + } + }, _emscripten_resize_heap = (e) => { + var t = HEAPU8.length; + e >>>= 0; + var _ = getHeapMax(); + if (e > _) return false; + for (var s, r, a = 1; a <= 4; a *= 2) { + var o = t * (1 + 0.2 / a); + o = Math.min(o, e + 100663296); + var n = Math.min(_, (s = Math.max(e, o)) + ((r = 65536) - s % r) % r); + if (growMemory(n)) return true; + } + return false; + }; + _emscripten_resize_heap.sig = "ip"; + var _fd_close = (e) => 52; + _fd_close.sig = "ii"; + var convertI32PairToI53Checked = (e, t) => t + 2097152 >>> 0 < 4194305 - !!e ? (e >>> 0) + 4294967296 * t : NaN; + function _fd_seek(e, t, _, s, r) { + convertI32PairToI53Checked(t, _); + return 70; + } + _fd_seek.sig = "iiiiip"; + var printCharBuffers = [null, [], []], printChar = (e, t) => { + var _ = printCharBuffers[e]; + 0 === t || 10 === t ? ((1 === e ? out : err)(UTF8ArrayToString(_, 0)), _.length = 0) : _.push(t); + }, SYSCALLS = { varargs: void 0, get() { + var e = HEAP32[+SYSCALLS.varargs >> 2]; + return SYSCALLS.varargs += 4, e; + }, getp: () => SYSCALLS.get(), getStr: (e) => UTF8ToString(e) }, _fd_write = (e, t, _, s) => { + for (var r = 0, a = 0; a < _; a++) { + var o = HEAPU32[t >> 2], n = HEAPU32[t + 4 >> 2]; + t += 8; + for (var l = 0; l < n; l++) printChar(e, HEAPU8[o + l]); + r += n; + } + return HEAPU32[s >> 2] = r, 0; + }; + function _tree_sitter_log_callback(e, t) { + if (currentLogCallback) { + const _ = UTF8ToString(t); + currentLogCallback(_, 0 !== e); + } + } + function _tree_sitter_parse_callback(e, t, _, s, r) { + const a = currentParseCallback(t, { row: _, column: s }); + "string" == typeof a ? (setValue(r, a.length, "i32"), stringToUTF16(a, e, 10240)) : setValue(r, 0, "i32"); + } + _fd_write.sig = "iippp"; + var runtimeKeepaliveCounter = 0, keepRuntimeAlive = () => noExitRuntime || runtimeKeepaliveCounter > 0, _proc_exit = (e) => { + EXITSTATUS = e, keepRuntimeAlive() || (Module.onExit?.(e), ABORT = true), quit_(e, new ExitStatus(e)); + }; + _proc_exit.sig = "vi"; + var exitJS = (e, t) => { + EXITSTATUS = e, _proc_exit(e); + }, handleException = (e) => { + if (e instanceof ExitStatus || "unwind" == e) return EXITSTATUS; + quit_(1, e); + }, lengthBytesUTF8 = (e) => { + for (var t = 0, _ = 0; _ < e.length; ++_) { + var s = e.charCodeAt(_); + s <= 127 ? t++ : s <= 2047 ? t += 2 : s >= 55296 && s <= 57343 ? (t += 4, ++_) : t += 3; + } + return t; + }, stringToUTF8Array = (e, t, _, s) => { + if (!(s > 0)) return 0; + for (var r = _, a = _ + s - 1, o = 0; o < e.length; ++o) { + var n = e.charCodeAt(o); + if (n >= 55296 && n <= 57343) n = 65536 + ((1023 & n) << 10) | 1023 & e.charCodeAt(++o); + if (n <= 127) { + if (_ >= a) break; + t[_++] = n; + } else if (n <= 2047) { + if (_ + 1 >= a) break; + t[_++] = 192 | n >> 6, t[_++] = 128 | 63 & n; + } else if (n <= 65535) { + if (_ + 2 >= a) break; + t[_++] = 224 | n >> 12, t[_++] = 128 | n >> 6 & 63, t[_++] = 128 | 63 & n; + } else { + if (_ + 3 >= a) break; + t[_++] = 240 | n >> 18, t[_++] = 128 | n >> 12 & 63, t[_++] = 128 | n >> 6 & 63, t[_++] = 128 | 63 & n; + } + } + return t[_] = 0, _ - r; + }, stringToUTF8 = (e, t, _) => stringToUTF8Array(e, HEAPU8, t, _), stringToUTF8OnStack = (e) => { + var t = lengthBytesUTF8(e) + 1, _ = stackAlloc(t); + return stringToUTF8(e, _, t), _; + }, stringToUTF16 = (e, t, _) => { + if (_ ??= 2147483647, _ < 2) return 0; + for (var s = t, r = (_ -= 2) < 2 * e.length ? _ / 2 : e.length, a = 0; a < r; ++a) { + var o = e.charCodeAt(a); + HEAP16[t >> 1] = o, t += 2; + } + return HEAP16[t >> 1] = 0, t - s; + }, AsciiToString = (e) => { + for (var t = ""; ; ) { + var _ = HEAPU8[e++]; + if (!_) return t; + t += String.fromCharCode(_); + } + }, wasmImports = { __heap_base: ___heap_base, __indirect_function_table: wasmTable, __memory_base: ___memory_base, __stack_pointer: ___stack_pointer, __table_base: ___table_base, _emscripten_get_now_is_monotonic: __emscripten_get_now_is_monotonic, abort: _abort, emscripten_get_now: _emscripten_get_now, emscripten_memcpy_js: _emscripten_memcpy_js, emscripten_resize_heap: _emscripten_resize_heap, fd_close: _fd_close, fd_seek: _fd_seek, fd_write: _fd_write, memory: wasmMemory, tree_sitter_log_callback: _tree_sitter_log_callback, tree_sitter_parse_callback: _tree_sitter_parse_callback }, wasmExports = createWasm(), ___wasm_call_ctors = () => (___wasm_call_ctors = wasmExports.__wasm_call_ctors)(), ___wasm_apply_data_relocs = () => (___wasm_apply_data_relocs = wasmExports.__wasm_apply_data_relocs)(), _malloc = Module._malloc = (e) => (_malloc = Module._malloc = wasmExports.malloc)(e), _calloc = Module._calloc = (e, t) => (_calloc = Module._calloc = wasmExports.calloc)(e, t), _realloc = Module._realloc = (e, t) => (_realloc = Module._realloc = wasmExports.realloc)(e, t), _free = Module._free = (e) => (_free = Module._free = wasmExports.free)(e), _ts_language_symbol_count = Module._ts_language_symbol_count = (e) => (_ts_language_symbol_count = Module._ts_language_symbol_count = wasmExports.ts_language_symbol_count)(e), _ts_language_state_count = Module._ts_language_state_count = (e) => (_ts_language_state_count = Module._ts_language_state_count = wasmExports.ts_language_state_count)(e), _ts_language_version = Module._ts_language_version = (e) => (_ts_language_version = Module._ts_language_version = wasmExports.ts_language_version)(e), _ts_language_field_count = Module._ts_language_field_count = (e) => (_ts_language_field_count = Module._ts_language_field_count = wasmExports.ts_language_field_count)(e), _ts_language_next_state = Module._ts_language_next_state = (e, t, _) => (_ts_language_next_state = Module._ts_language_next_state = wasmExports.ts_language_next_state)(e, t, _), _ts_language_symbol_name = Module._ts_language_symbol_name = (e, t) => (_ts_language_symbol_name = Module._ts_language_symbol_name = wasmExports.ts_language_symbol_name)(e, t), _ts_language_symbol_for_name = Module._ts_language_symbol_for_name = (e, t, _, s) => (_ts_language_symbol_for_name = Module._ts_language_symbol_for_name = wasmExports.ts_language_symbol_for_name)(e, t, _, s), _strncmp = Module._strncmp = (e, t, _) => (_strncmp = Module._strncmp = wasmExports.strncmp)(e, t, _), _ts_language_symbol_type = Module._ts_language_symbol_type = (e, t) => (_ts_language_symbol_type = Module._ts_language_symbol_type = wasmExports.ts_language_symbol_type)(e, t), _ts_language_field_name_for_id = Module._ts_language_field_name_for_id = (e, t) => (_ts_language_field_name_for_id = Module._ts_language_field_name_for_id = wasmExports.ts_language_field_name_for_id)(e, t), _ts_lookahead_iterator_new = Module._ts_lookahead_iterator_new = (e, t) => (_ts_lookahead_iterator_new = Module._ts_lookahead_iterator_new = wasmExports.ts_lookahead_iterator_new)(e, t), _ts_lookahead_iterator_delete = Module._ts_lookahead_iterator_delete = (e) => (_ts_lookahead_iterator_delete = Module._ts_lookahead_iterator_delete = wasmExports.ts_lookahead_iterator_delete)(e), _ts_lookahead_iterator_reset_state = Module._ts_lookahead_iterator_reset_state = (e, t) => (_ts_lookahead_iterator_reset_state = Module._ts_lookahead_iterator_reset_state = wasmExports.ts_lookahead_iterator_reset_state)(e, t), _ts_lookahead_iterator_reset = Module._ts_lookahead_iterator_reset = (e, t, _) => (_ts_lookahead_iterator_reset = Module._ts_lookahead_iterator_reset = wasmExports.ts_lookahead_iterator_reset)(e, t, _), _ts_lookahead_iterator_next = Module._ts_lookahead_iterator_next = (e) => (_ts_lookahead_iterator_next = Module._ts_lookahead_iterator_next = wasmExports.ts_lookahead_iterator_next)(e), _ts_lookahead_iterator_current_symbol = Module._ts_lookahead_iterator_current_symbol = (e) => (_ts_lookahead_iterator_current_symbol = Module._ts_lookahead_iterator_current_symbol = wasmExports.ts_lookahead_iterator_current_symbol)(e), _memset = Module._memset = (e, t, _) => (_memset = Module._memset = wasmExports.memset)(e, t, _), _memcpy = Module._memcpy = (e, t, _) => (_memcpy = Module._memcpy = wasmExports.memcpy)(e, t, _), _ts_parser_delete = Module._ts_parser_delete = (e) => (_ts_parser_delete = Module._ts_parser_delete = wasmExports.ts_parser_delete)(e), _ts_parser_reset = Module._ts_parser_reset = (e) => (_ts_parser_reset = Module._ts_parser_reset = wasmExports.ts_parser_reset)(e), _ts_parser_set_language = Module._ts_parser_set_language = (e, t) => (_ts_parser_set_language = Module._ts_parser_set_language = wasmExports.ts_parser_set_language)(e, t), _ts_parser_timeout_micros = Module._ts_parser_timeout_micros = (e) => (_ts_parser_timeout_micros = Module._ts_parser_timeout_micros = wasmExports.ts_parser_timeout_micros)(e), _ts_parser_set_timeout_micros = Module._ts_parser_set_timeout_micros = (e, t, _) => (_ts_parser_set_timeout_micros = Module._ts_parser_set_timeout_micros = wasmExports.ts_parser_set_timeout_micros)(e, t, _), _ts_parser_set_included_ranges = Module._ts_parser_set_included_ranges = (e, t, _) => (_ts_parser_set_included_ranges = Module._ts_parser_set_included_ranges = wasmExports.ts_parser_set_included_ranges)(e, t, _), _memmove = Module._memmove = (e, t, _) => (_memmove = Module._memmove = wasmExports.memmove)(e, t, _), _memcmp = Module._memcmp = (e, t, _) => (_memcmp = Module._memcmp = wasmExports.memcmp)(e, t, _), _ts_query_new = Module._ts_query_new = (e, t, _, s, r) => (_ts_query_new = Module._ts_query_new = wasmExports.ts_query_new)(e, t, _, s, r), _ts_query_delete = Module._ts_query_delete = (e) => (_ts_query_delete = Module._ts_query_delete = wasmExports.ts_query_delete)(e), _iswspace = Module._iswspace = (e) => (_iswspace = Module._iswspace = wasmExports.iswspace)(e), _iswalnum = Module._iswalnum = (e) => (_iswalnum = Module._iswalnum = wasmExports.iswalnum)(e), _ts_query_pattern_count = Module._ts_query_pattern_count = (e) => (_ts_query_pattern_count = Module._ts_query_pattern_count = wasmExports.ts_query_pattern_count)(e), _ts_query_capture_count = Module._ts_query_capture_count = (e) => (_ts_query_capture_count = Module._ts_query_capture_count = wasmExports.ts_query_capture_count)(e), _ts_query_string_count = Module._ts_query_string_count = (e) => (_ts_query_string_count = Module._ts_query_string_count = wasmExports.ts_query_string_count)(e), _ts_query_capture_name_for_id = Module._ts_query_capture_name_for_id = (e, t, _) => (_ts_query_capture_name_for_id = Module._ts_query_capture_name_for_id = wasmExports.ts_query_capture_name_for_id)(e, t, _), _ts_query_string_value_for_id = Module._ts_query_string_value_for_id = (e, t, _) => (_ts_query_string_value_for_id = Module._ts_query_string_value_for_id = wasmExports.ts_query_string_value_for_id)(e, t, _), _ts_query_predicates_for_pattern = Module._ts_query_predicates_for_pattern = (e, t, _) => (_ts_query_predicates_for_pattern = Module._ts_query_predicates_for_pattern = wasmExports.ts_query_predicates_for_pattern)(e, t, _), _ts_query_disable_capture = Module._ts_query_disable_capture = (e, t, _) => (_ts_query_disable_capture = Module._ts_query_disable_capture = wasmExports.ts_query_disable_capture)(e, t, _), _ts_tree_copy = Module._ts_tree_copy = (e) => (_ts_tree_copy = Module._ts_tree_copy = wasmExports.ts_tree_copy)(e), _ts_tree_delete = Module._ts_tree_delete = (e) => (_ts_tree_delete = Module._ts_tree_delete = wasmExports.ts_tree_delete)(e), _ts_init = Module._ts_init = () => (_ts_init = Module._ts_init = wasmExports.ts_init)(), _ts_parser_new_wasm = Module._ts_parser_new_wasm = () => (_ts_parser_new_wasm = Module._ts_parser_new_wasm = wasmExports.ts_parser_new_wasm)(), _ts_parser_enable_logger_wasm = Module._ts_parser_enable_logger_wasm = (e, t) => (_ts_parser_enable_logger_wasm = Module._ts_parser_enable_logger_wasm = wasmExports.ts_parser_enable_logger_wasm)(e, t), _ts_parser_parse_wasm = Module._ts_parser_parse_wasm = (e, t, _, s, r) => (_ts_parser_parse_wasm = Module._ts_parser_parse_wasm = wasmExports.ts_parser_parse_wasm)(e, t, _, s, r), _ts_parser_included_ranges_wasm = Module._ts_parser_included_ranges_wasm = (e) => (_ts_parser_included_ranges_wasm = Module._ts_parser_included_ranges_wasm = wasmExports.ts_parser_included_ranges_wasm)(e), _ts_language_type_is_named_wasm = Module._ts_language_type_is_named_wasm = (e, t) => (_ts_language_type_is_named_wasm = Module._ts_language_type_is_named_wasm = wasmExports.ts_language_type_is_named_wasm)(e, t), _ts_language_type_is_visible_wasm = Module._ts_language_type_is_visible_wasm = (e, t) => (_ts_language_type_is_visible_wasm = Module._ts_language_type_is_visible_wasm = wasmExports.ts_language_type_is_visible_wasm)(e, t), _ts_tree_root_node_wasm = Module._ts_tree_root_node_wasm = (e) => (_ts_tree_root_node_wasm = Module._ts_tree_root_node_wasm = wasmExports.ts_tree_root_node_wasm)(e), _ts_tree_root_node_with_offset_wasm = Module._ts_tree_root_node_with_offset_wasm = (e) => (_ts_tree_root_node_with_offset_wasm = Module._ts_tree_root_node_with_offset_wasm = wasmExports.ts_tree_root_node_with_offset_wasm)(e), _ts_tree_edit_wasm = Module._ts_tree_edit_wasm = (e) => (_ts_tree_edit_wasm = Module._ts_tree_edit_wasm = wasmExports.ts_tree_edit_wasm)(e), _ts_tree_included_ranges_wasm = Module._ts_tree_included_ranges_wasm = (e) => (_ts_tree_included_ranges_wasm = Module._ts_tree_included_ranges_wasm = wasmExports.ts_tree_included_ranges_wasm)(e), _ts_tree_get_changed_ranges_wasm = Module._ts_tree_get_changed_ranges_wasm = (e, t) => (_ts_tree_get_changed_ranges_wasm = Module._ts_tree_get_changed_ranges_wasm = wasmExports.ts_tree_get_changed_ranges_wasm)(e, t), _ts_tree_cursor_new_wasm = Module._ts_tree_cursor_new_wasm = (e) => (_ts_tree_cursor_new_wasm = Module._ts_tree_cursor_new_wasm = wasmExports.ts_tree_cursor_new_wasm)(e), _ts_tree_cursor_delete_wasm = Module._ts_tree_cursor_delete_wasm = (e) => (_ts_tree_cursor_delete_wasm = Module._ts_tree_cursor_delete_wasm = wasmExports.ts_tree_cursor_delete_wasm)(e), _ts_tree_cursor_reset_wasm = Module._ts_tree_cursor_reset_wasm = (e) => (_ts_tree_cursor_reset_wasm = Module._ts_tree_cursor_reset_wasm = wasmExports.ts_tree_cursor_reset_wasm)(e), _ts_tree_cursor_reset_to_wasm = Module._ts_tree_cursor_reset_to_wasm = (e, t) => (_ts_tree_cursor_reset_to_wasm = Module._ts_tree_cursor_reset_to_wasm = wasmExports.ts_tree_cursor_reset_to_wasm)(e, t), _ts_tree_cursor_goto_first_child_wasm = Module._ts_tree_cursor_goto_first_child_wasm = (e) => (_ts_tree_cursor_goto_first_child_wasm = Module._ts_tree_cursor_goto_first_child_wasm = wasmExports.ts_tree_cursor_goto_first_child_wasm)(e), _ts_tree_cursor_goto_last_child_wasm = Module._ts_tree_cursor_goto_last_child_wasm = (e) => (_ts_tree_cursor_goto_last_child_wasm = Module._ts_tree_cursor_goto_last_child_wasm = wasmExports.ts_tree_cursor_goto_last_child_wasm)(e), _ts_tree_cursor_goto_first_child_for_index_wasm = Module._ts_tree_cursor_goto_first_child_for_index_wasm = (e) => (_ts_tree_cursor_goto_first_child_for_index_wasm = Module._ts_tree_cursor_goto_first_child_for_index_wasm = wasmExports.ts_tree_cursor_goto_first_child_for_index_wasm)(e), _ts_tree_cursor_goto_first_child_for_position_wasm = Module._ts_tree_cursor_goto_first_child_for_position_wasm = (e) => (_ts_tree_cursor_goto_first_child_for_position_wasm = Module._ts_tree_cursor_goto_first_child_for_position_wasm = wasmExports.ts_tree_cursor_goto_first_child_for_position_wasm)(e), _ts_tree_cursor_goto_next_sibling_wasm = Module._ts_tree_cursor_goto_next_sibling_wasm = (e) => (_ts_tree_cursor_goto_next_sibling_wasm = Module._ts_tree_cursor_goto_next_sibling_wasm = wasmExports.ts_tree_cursor_goto_next_sibling_wasm)(e), _ts_tree_cursor_goto_previous_sibling_wasm = Module._ts_tree_cursor_goto_previous_sibling_wasm = (e) => (_ts_tree_cursor_goto_previous_sibling_wasm = Module._ts_tree_cursor_goto_previous_sibling_wasm = wasmExports.ts_tree_cursor_goto_previous_sibling_wasm)(e), _ts_tree_cursor_goto_descendant_wasm = Module._ts_tree_cursor_goto_descendant_wasm = (e, t) => (_ts_tree_cursor_goto_descendant_wasm = Module._ts_tree_cursor_goto_descendant_wasm = wasmExports.ts_tree_cursor_goto_descendant_wasm)(e, t), _ts_tree_cursor_goto_parent_wasm = Module._ts_tree_cursor_goto_parent_wasm = (e) => (_ts_tree_cursor_goto_parent_wasm = Module._ts_tree_cursor_goto_parent_wasm = wasmExports.ts_tree_cursor_goto_parent_wasm)(e), _ts_tree_cursor_current_node_type_id_wasm = Module._ts_tree_cursor_current_node_type_id_wasm = (e) => (_ts_tree_cursor_current_node_type_id_wasm = Module._ts_tree_cursor_current_node_type_id_wasm = wasmExports.ts_tree_cursor_current_node_type_id_wasm)(e), _ts_tree_cursor_current_node_state_id_wasm = Module._ts_tree_cursor_current_node_state_id_wasm = (e) => (_ts_tree_cursor_current_node_state_id_wasm = Module._ts_tree_cursor_current_node_state_id_wasm = wasmExports.ts_tree_cursor_current_node_state_id_wasm)(e), _ts_tree_cursor_current_node_is_named_wasm = Module._ts_tree_cursor_current_node_is_named_wasm = (e) => (_ts_tree_cursor_current_node_is_named_wasm = Module._ts_tree_cursor_current_node_is_named_wasm = wasmExports.ts_tree_cursor_current_node_is_named_wasm)(e), _ts_tree_cursor_current_node_is_missing_wasm = Module._ts_tree_cursor_current_node_is_missing_wasm = (e) => (_ts_tree_cursor_current_node_is_missing_wasm = Module._ts_tree_cursor_current_node_is_missing_wasm = wasmExports.ts_tree_cursor_current_node_is_missing_wasm)(e), _ts_tree_cursor_current_node_id_wasm = Module._ts_tree_cursor_current_node_id_wasm = (e) => (_ts_tree_cursor_current_node_id_wasm = Module._ts_tree_cursor_current_node_id_wasm = wasmExports.ts_tree_cursor_current_node_id_wasm)(e), _ts_tree_cursor_start_position_wasm = Module._ts_tree_cursor_start_position_wasm = (e) => (_ts_tree_cursor_start_position_wasm = Module._ts_tree_cursor_start_position_wasm = wasmExports.ts_tree_cursor_start_position_wasm)(e), _ts_tree_cursor_end_position_wasm = Module._ts_tree_cursor_end_position_wasm = (e) => (_ts_tree_cursor_end_position_wasm = Module._ts_tree_cursor_end_position_wasm = wasmExports.ts_tree_cursor_end_position_wasm)(e), _ts_tree_cursor_start_index_wasm = Module._ts_tree_cursor_start_index_wasm = (e) => (_ts_tree_cursor_start_index_wasm = Module._ts_tree_cursor_start_index_wasm = wasmExports.ts_tree_cursor_start_index_wasm)(e), _ts_tree_cursor_end_index_wasm = Module._ts_tree_cursor_end_index_wasm = (e) => (_ts_tree_cursor_end_index_wasm = Module._ts_tree_cursor_end_index_wasm = wasmExports.ts_tree_cursor_end_index_wasm)(e), _ts_tree_cursor_current_field_id_wasm = Module._ts_tree_cursor_current_field_id_wasm = (e) => (_ts_tree_cursor_current_field_id_wasm = Module._ts_tree_cursor_current_field_id_wasm = wasmExports.ts_tree_cursor_current_field_id_wasm)(e), _ts_tree_cursor_current_depth_wasm = Module._ts_tree_cursor_current_depth_wasm = (e) => (_ts_tree_cursor_current_depth_wasm = Module._ts_tree_cursor_current_depth_wasm = wasmExports.ts_tree_cursor_current_depth_wasm)(e), _ts_tree_cursor_current_descendant_index_wasm = Module._ts_tree_cursor_current_descendant_index_wasm = (e) => (_ts_tree_cursor_current_descendant_index_wasm = Module._ts_tree_cursor_current_descendant_index_wasm = wasmExports.ts_tree_cursor_current_descendant_index_wasm)(e), _ts_tree_cursor_current_node_wasm = Module._ts_tree_cursor_current_node_wasm = (e) => (_ts_tree_cursor_current_node_wasm = Module._ts_tree_cursor_current_node_wasm = wasmExports.ts_tree_cursor_current_node_wasm)(e), _ts_node_symbol_wasm = Module._ts_node_symbol_wasm = (e) => (_ts_node_symbol_wasm = Module._ts_node_symbol_wasm = wasmExports.ts_node_symbol_wasm)(e), _ts_node_field_name_for_child_wasm = Module._ts_node_field_name_for_child_wasm = (e, t) => (_ts_node_field_name_for_child_wasm = Module._ts_node_field_name_for_child_wasm = wasmExports.ts_node_field_name_for_child_wasm)(e, t), _ts_node_children_by_field_id_wasm = Module._ts_node_children_by_field_id_wasm = (e, t) => (_ts_node_children_by_field_id_wasm = Module._ts_node_children_by_field_id_wasm = wasmExports.ts_node_children_by_field_id_wasm)(e, t), _ts_node_first_child_for_byte_wasm = Module._ts_node_first_child_for_byte_wasm = (e) => (_ts_node_first_child_for_byte_wasm = Module._ts_node_first_child_for_byte_wasm = wasmExports.ts_node_first_child_for_byte_wasm)(e), _ts_node_first_named_child_for_byte_wasm = Module._ts_node_first_named_child_for_byte_wasm = (e) => (_ts_node_first_named_child_for_byte_wasm = Module._ts_node_first_named_child_for_byte_wasm = wasmExports.ts_node_first_named_child_for_byte_wasm)(e), _ts_node_grammar_symbol_wasm = Module._ts_node_grammar_symbol_wasm = (e) => (_ts_node_grammar_symbol_wasm = Module._ts_node_grammar_symbol_wasm = wasmExports.ts_node_grammar_symbol_wasm)(e), _ts_node_child_count_wasm = Module._ts_node_child_count_wasm = (e) => (_ts_node_child_count_wasm = Module._ts_node_child_count_wasm = wasmExports.ts_node_child_count_wasm)(e), _ts_node_named_child_count_wasm = Module._ts_node_named_child_count_wasm = (e) => (_ts_node_named_child_count_wasm = Module._ts_node_named_child_count_wasm = wasmExports.ts_node_named_child_count_wasm)(e), _ts_node_child_wasm = Module._ts_node_child_wasm = (e, t) => (_ts_node_child_wasm = Module._ts_node_child_wasm = wasmExports.ts_node_child_wasm)(e, t), _ts_node_named_child_wasm = Module._ts_node_named_child_wasm = (e, t) => (_ts_node_named_child_wasm = Module._ts_node_named_child_wasm = wasmExports.ts_node_named_child_wasm)(e, t), _ts_node_child_by_field_id_wasm = Module._ts_node_child_by_field_id_wasm = (e, t) => (_ts_node_child_by_field_id_wasm = Module._ts_node_child_by_field_id_wasm = wasmExports.ts_node_child_by_field_id_wasm)(e, t), _ts_node_next_sibling_wasm = Module._ts_node_next_sibling_wasm = (e) => (_ts_node_next_sibling_wasm = Module._ts_node_next_sibling_wasm = wasmExports.ts_node_next_sibling_wasm)(e), _ts_node_prev_sibling_wasm = Module._ts_node_prev_sibling_wasm = (e) => (_ts_node_prev_sibling_wasm = Module._ts_node_prev_sibling_wasm = wasmExports.ts_node_prev_sibling_wasm)(e), _ts_node_next_named_sibling_wasm = Module._ts_node_next_named_sibling_wasm = (e) => (_ts_node_next_named_sibling_wasm = Module._ts_node_next_named_sibling_wasm = wasmExports.ts_node_next_named_sibling_wasm)(e), _ts_node_prev_named_sibling_wasm = Module._ts_node_prev_named_sibling_wasm = (e) => (_ts_node_prev_named_sibling_wasm = Module._ts_node_prev_named_sibling_wasm = wasmExports.ts_node_prev_named_sibling_wasm)(e), _ts_node_descendant_count_wasm = Module._ts_node_descendant_count_wasm = (e) => (_ts_node_descendant_count_wasm = Module._ts_node_descendant_count_wasm = wasmExports.ts_node_descendant_count_wasm)(e), _ts_node_parent_wasm = Module._ts_node_parent_wasm = (e) => (_ts_node_parent_wasm = Module._ts_node_parent_wasm = wasmExports.ts_node_parent_wasm)(e), _ts_node_descendant_for_index_wasm = Module._ts_node_descendant_for_index_wasm = (e) => (_ts_node_descendant_for_index_wasm = Module._ts_node_descendant_for_index_wasm = wasmExports.ts_node_descendant_for_index_wasm)(e), _ts_node_named_descendant_for_index_wasm = Module._ts_node_named_descendant_for_index_wasm = (e) => (_ts_node_named_descendant_for_index_wasm = Module._ts_node_named_descendant_for_index_wasm = wasmExports.ts_node_named_descendant_for_index_wasm)(e), _ts_node_descendant_for_position_wasm = Module._ts_node_descendant_for_position_wasm = (e) => (_ts_node_descendant_for_position_wasm = Module._ts_node_descendant_for_position_wasm = wasmExports.ts_node_descendant_for_position_wasm)(e), _ts_node_named_descendant_for_position_wasm = Module._ts_node_named_descendant_for_position_wasm = (e) => (_ts_node_named_descendant_for_position_wasm = Module._ts_node_named_descendant_for_position_wasm = wasmExports.ts_node_named_descendant_for_position_wasm)(e), _ts_node_start_point_wasm = Module._ts_node_start_point_wasm = (e) => (_ts_node_start_point_wasm = Module._ts_node_start_point_wasm = wasmExports.ts_node_start_point_wasm)(e), _ts_node_end_point_wasm = Module._ts_node_end_point_wasm = (e) => (_ts_node_end_point_wasm = Module._ts_node_end_point_wasm = wasmExports.ts_node_end_point_wasm)(e), _ts_node_start_index_wasm = Module._ts_node_start_index_wasm = (e) => (_ts_node_start_index_wasm = Module._ts_node_start_index_wasm = wasmExports.ts_node_start_index_wasm)(e), _ts_node_end_index_wasm = Module._ts_node_end_index_wasm = (e) => (_ts_node_end_index_wasm = Module._ts_node_end_index_wasm = wasmExports.ts_node_end_index_wasm)(e), _ts_node_to_string_wasm = Module._ts_node_to_string_wasm = (e) => (_ts_node_to_string_wasm = Module._ts_node_to_string_wasm = wasmExports.ts_node_to_string_wasm)(e), _ts_node_children_wasm = Module._ts_node_children_wasm = (e) => (_ts_node_children_wasm = Module._ts_node_children_wasm = wasmExports.ts_node_children_wasm)(e), _ts_node_named_children_wasm = Module._ts_node_named_children_wasm = (e) => (_ts_node_named_children_wasm = Module._ts_node_named_children_wasm = wasmExports.ts_node_named_children_wasm)(e), _ts_node_descendants_of_type_wasm = Module._ts_node_descendants_of_type_wasm = (e, t, _, s, r, a, o) => (_ts_node_descendants_of_type_wasm = Module._ts_node_descendants_of_type_wasm = wasmExports.ts_node_descendants_of_type_wasm)(e, t, _, s, r, a, o), _ts_node_is_named_wasm = Module._ts_node_is_named_wasm = (e) => (_ts_node_is_named_wasm = Module._ts_node_is_named_wasm = wasmExports.ts_node_is_named_wasm)(e), _ts_node_has_changes_wasm = Module._ts_node_has_changes_wasm = (e) => (_ts_node_has_changes_wasm = Module._ts_node_has_changes_wasm = wasmExports.ts_node_has_changes_wasm)(e), _ts_node_has_error_wasm = Module._ts_node_has_error_wasm = (e) => (_ts_node_has_error_wasm = Module._ts_node_has_error_wasm = wasmExports.ts_node_has_error_wasm)(e), _ts_node_is_error_wasm = Module._ts_node_is_error_wasm = (e) => (_ts_node_is_error_wasm = Module._ts_node_is_error_wasm = wasmExports.ts_node_is_error_wasm)(e), _ts_node_is_missing_wasm = Module._ts_node_is_missing_wasm = (e) => (_ts_node_is_missing_wasm = Module._ts_node_is_missing_wasm = wasmExports.ts_node_is_missing_wasm)(e), _ts_node_is_extra_wasm = Module._ts_node_is_extra_wasm = (e) => (_ts_node_is_extra_wasm = Module._ts_node_is_extra_wasm = wasmExports.ts_node_is_extra_wasm)(e), _ts_node_parse_state_wasm = Module._ts_node_parse_state_wasm = (e) => (_ts_node_parse_state_wasm = Module._ts_node_parse_state_wasm = wasmExports.ts_node_parse_state_wasm)(e), _ts_node_next_parse_state_wasm = Module._ts_node_next_parse_state_wasm = (e) => (_ts_node_next_parse_state_wasm = Module._ts_node_next_parse_state_wasm = wasmExports.ts_node_next_parse_state_wasm)(e), _ts_query_matches_wasm = Module._ts_query_matches_wasm = (e, t, _, s, r, a, o, n, l, d) => (_ts_query_matches_wasm = Module._ts_query_matches_wasm = wasmExports.ts_query_matches_wasm)(e, t, _, s, r, a, o, n, l, d), _ts_query_captures_wasm = Module._ts_query_captures_wasm = (e, t, _, s, r, a, o, n, l, d) => (_ts_query_captures_wasm = Module._ts_query_captures_wasm = wasmExports.ts_query_captures_wasm)(e, t, _, s, r, a, o, n, l, d), _iswalpha = Module._iswalpha = (e) => (_iswalpha = Module._iswalpha = wasmExports.iswalpha)(e), _iswblank = Module._iswblank = (e) => (_iswblank = Module._iswblank = wasmExports.iswblank)(e), _iswdigit = Module._iswdigit = (e) => (_iswdigit = Module._iswdigit = wasmExports.iswdigit)(e), _iswlower = Module._iswlower = (e) => (_iswlower = Module._iswlower = wasmExports.iswlower)(e), _iswupper = Module._iswupper = (e) => (_iswupper = Module._iswupper = wasmExports.iswupper)(e), _iswxdigit = Module._iswxdigit = (e) => (_iswxdigit = Module._iswxdigit = wasmExports.iswxdigit)(e), _memchr = Module._memchr = (e, t, _) => (_memchr = Module._memchr = wasmExports.memchr)(e, t, _), _strlen = Module._strlen = (e) => (_strlen = Module._strlen = wasmExports.strlen)(e), _strcmp = Module._strcmp = (e, t) => (_strcmp = Module._strcmp = wasmExports.strcmp)(e, t), _strncat = Module._strncat = (e, t, _) => (_strncat = Module._strncat = wasmExports.strncat)(e, t, _), _strncpy = Module._strncpy = (e, t, _) => (_strncpy = Module._strncpy = wasmExports.strncpy)(e, t, _), _towlower = Module._towlower = (e) => (_towlower = Module._towlower = wasmExports.towlower)(e), _towupper = Module._towupper = (e) => (_towupper = Module._towupper = wasmExports.towupper)(e), _setThrew = (e, t) => (_setThrew = wasmExports.setThrew)(e, t), stackSave = () => (stackSave = wasmExports.stackSave)(), stackRestore = (e) => (stackRestore = wasmExports.stackRestore)(e), stackAlloc = (e) => (stackAlloc = wasmExports.stackAlloc)(e), dynCall_jiji = Module.dynCall_jiji = (e, t, _, s, r) => (dynCall_jiji = Module.dynCall_jiji = wasmExports.dynCall_jiji)(e, t, _, s, r), _orig$ts_parser_timeout_micros = Module._orig$ts_parser_timeout_micros = (e) => (_orig$ts_parser_timeout_micros = Module._orig$ts_parser_timeout_micros = wasmExports.orig$ts_parser_timeout_micros)(e), _orig$ts_parser_set_timeout_micros = Module._orig$ts_parser_set_timeout_micros = (e, t) => (_orig$ts_parser_set_timeout_micros = Module._orig$ts_parser_set_timeout_micros = wasmExports.orig$ts_parser_set_timeout_micros)(e, t), calledRun; + function callMain(e = []) { + var t = resolveGlobalSymbol("main").sym; + if (t) { + e.unshift(thisProgram); + var _ = e.length, s = stackAlloc(4 * (_ + 1)), r = s; + e.forEach((e2) => { + HEAPU32[r >> 2] = stringToUTF8OnStack(e2), r += 4; + }), HEAPU32[r >> 2] = 0; + try { + var a = t(_, s); + return exitJS(a, true), a; + } catch (e2) { + return handleException(e2); + } + } + } + function run(e = arguments_) { + function t() { + calledRun || (calledRun = true, Module.calledRun = true, ABORT || (initRuntime(), preMain(), Module.onRuntimeInitialized && Module.onRuntimeInitialized(), shouldRunNow && callMain(e), postRun())); + } + runDependencies > 0 || (preRun(), runDependencies > 0 || (Module.setStatus ? (Module.setStatus("Running..."), setTimeout(function() { + setTimeout(function() { + Module.setStatus(""); + }, 1), t(); + }, 1)) : t())); + } + if (Module.AsciiToString = AsciiToString, Module.stringToUTF16 = stringToUTF16, dependenciesFulfilled = function e() { + calledRun || run(), calledRun || (dependenciesFulfilled = e); + }, Module.preInit) for ("function" == typeof Module.preInit && (Module.preInit = [Module.preInit]); Module.preInit.length > 0; ) Module.preInit.pop()(); + var shouldRunNow = true; + Module.noInitialRun && (shouldRunNow = false), run(); + const C = Module, INTERNAL = {}, SIZE_OF_INT = 4, SIZE_OF_CURSOR = 4 * SIZE_OF_INT, SIZE_OF_NODE = 5 * SIZE_OF_INT, SIZE_OF_POINT = 2 * SIZE_OF_INT, SIZE_OF_RANGE = 2 * SIZE_OF_INT + 2 * SIZE_OF_POINT, ZERO_POINT = { row: 0, column: 0 }, QUERY_WORD_REGEX = /[\w-.]*/g, PREDICATE_STEP_TYPE_CAPTURE = 1, PREDICATE_STEP_TYPE_STRING = 2, LANGUAGE_FUNCTION_REGEX = /^_?tree_sitter_\w+/; + let VERSION, MIN_COMPATIBLE_VERSION, TRANSFER_BUFFER, currentParseCallback, currentLogCallback; + class ParserImpl { + static init() { + TRANSFER_BUFFER = C._ts_init(), VERSION = getValue(TRANSFER_BUFFER, "i32"), MIN_COMPATIBLE_VERSION = getValue(TRANSFER_BUFFER + SIZE_OF_INT, "i32"); + } + initialize() { + C._ts_parser_new_wasm(), this[0] = getValue(TRANSFER_BUFFER, "i32"), this[1] = getValue(TRANSFER_BUFFER + SIZE_OF_INT, "i32"); + } + delete() { + C._ts_parser_delete(this[0]), C._free(this[1]), this[0] = 0, this[1] = 0; + } + setLanguage(e) { + let t; + if (e) { + if (e.constructor !== Language) throw new Error("Argument must be a Language"); + { + t = e[0]; + const _ = C._ts_language_version(t); + if (_ < MIN_COMPATIBLE_VERSION || VERSION < _) throw new Error(`Incompatible language version ${_}. Compatibility range ${MIN_COMPATIBLE_VERSION} through ${VERSION}.`); + } + } else t = 0, e = null; + return this.language = e, C._ts_parser_set_language(this[0], t), this; + } + getLanguage() { + return this.language; + } + parse(e, t, _) { + if ("string" == typeof e) currentParseCallback = (t2, _2) => e.slice(t2); + else { + if ("function" != typeof e) throw new Error("Argument must be a string or a function"); + currentParseCallback = e; + } + this.logCallback ? (currentLogCallback = this.logCallback, C._ts_parser_enable_logger_wasm(this[0], 1)) : (currentLogCallback = null, C._ts_parser_enable_logger_wasm(this[0], 0)); + let s = 0, r = 0; + if (_?.includedRanges) { + s = _.includedRanges.length, r = C._calloc(s, SIZE_OF_RANGE); + let e2 = r; + for (let t2 = 0; t2 < s; t2++) marshalRange(e2, _.includedRanges[t2]), e2 += SIZE_OF_RANGE; + } + const a = C._ts_parser_parse_wasm(this[0], this[1], t ? t[0] : 0, r, s); + if (!a) throw currentParseCallback = null, currentLogCallback = null, new Error("Parsing failed"); + const o = new Tree(INTERNAL, a, this.language, currentParseCallback); + return currentParseCallback = null, currentLogCallback = null, o; + } + reset() { + C._ts_parser_reset(this[0]); + } + getIncludedRanges() { + C._ts_parser_included_ranges_wasm(this[0]); + const e = getValue(TRANSFER_BUFFER, "i32"), t = getValue(TRANSFER_BUFFER + SIZE_OF_INT, "i32"), _ = new Array(e); + if (e > 0) { + let s = t; + for (let t2 = 0; t2 < e; t2++) _[t2] = unmarshalRange(s), s += SIZE_OF_RANGE; + C._free(t); + } + return _; + } + getTimeoutMicros() { + return C._ts_parser_timeout_micros(this[0]); + } + setTimeoutMicros(e) { + C._ts_parser_set_timeout_micros(this[0], e); + } + setLogger(e) { + if (e) { + if ("function" != typeof e) throw new Error("Logger callback must be a function"); + } else e = null; + return this.logCallback = e, this; + } + getLogger() { + return this.logCallback; + } + } + class Tree { + constructor(e, t, _, s) { + assertInternal(e), this[0] = t, this.language = _, this.textCallback = s; + } + copy() { + const e = C._ts_tree_copy(this[0]); + return new Tree(INTERNAL, e, this.language, this.textCallback); + } + delete() { + C._ts_tree_delete(this[0]), this[0] = 0; + } + edit(e) { + marshalEdit(e), C._ts_tree_edit_wasm(this[0]); + } + get rootNode() { + return C._ts_tree_root_node_wasm(this[0]), unmarshalNode(this); + } + rootNodeWithOffset(e, t) { + const _ = TRANSFER_BUFFER + SIZE_OF_NODE; + return setValue(_, e, "i32"), marshalPoint(_ + SIZE_OF_INT, t), C._ts_tree_root_node_with_offset_wasm(this[0]), unmarshalNode(this); + } + getLanguage() { + return this.language; + } + walk() { + return this.rootNode.walk(); + } + getChangedRanges(e) { + if (e.constructor !== Tree) throw new TypeError("Argument must be a Tree"); + C._ts_tree_get_changed_ranges_wasm(this[0], e[0]); + const t = getValue(TRANSFER_BUFFER, "i32"), _ = getValue(TRANSFER_BUFFER + SIZE_OF_INT, "i32"), s = new Array(t); + if (t > 0) { + let e2 = _; + for (let _2 = 0; _2 < t; _2++) s[_2] = unmarshalRange(e2), e2 += SIZE_OF_RANGE; + C._free(_); + } + return s; + } + getIncludedRanges() { + C._ts_tree_included_ranges_wasm(this[0]); + const e = getValue(TRANSFER_BUFFER, "i32"), t = getValue(TRANSFER_BUFFER + SIZE_OF_INT, "i32"), _ = new Array(e); + if (e > 0) { + let s = t; + for (let t2 = 0; t2 < e; t2++) _[t2] = unmarshalRange(s), s += SIZE_OF_RANGE; + C._free(t); + } + return _; + } + } + class Node { + constructor(e, t) { + assertInternal(e), this.tree = t; + } + get typeId() { + return marshalNode(this), C._ts_node_symbol_wasm(this.tree[0]); + } + get grammarId() { + return marshalNode(this), C._ts_node_grammar_symbol_wasm(this.tree[0]); + } + get type() { + return this.tree.language.types[this.typeId] || "ERROR"; + } + get grammarType() { + return this.tree.language.types[this.grammarId] || "ERROR"; + } + get endPosition() { + return marshalNode(this), C._ts_node_end_point_wasm(this.tree[0]), unmarshalPoint(TRANSFER_BUFFER); + } + get endIndex() { + return marshalNode(this), C._ts_node_end_index_wasm(this.tree[0]); + } + get text() { + return getText(this.tree, this.startIndex, this.endIndex); + } + get parseState() { + return marshalNode(this), C._ts_node_parse_state_wasm(this.tree[0]); + } + get nextParseState() { + return marshalNode(this), C._ts_node_next_parse_state_wasm(this.tree[0]); + } + get isNamed() { + return marshalNode(this), 1 === C._ts_node_is_named_wasm(this.tree[0]); + } + get hasError() { + return marshalNode(this), 1 === C._ts_node_has_error_wasm(this.tree[0]); + } + get hasChanges() { + return marshalNode(this), 1 === C._ts_node_has_changes_wasm(this.tree[0]); + } + get isError() { + return marshalNode(this), 1 === C._ts_node_is_error_wasm(this.tree[0]); + } + get isMissing() { + return marshalNode(this), 1 === C._ts_node_is_missing_wasm(this.tree[0]); + } + get isExtra() { + return marshalNode(this), 1 === C._ts_node_is_extra_wasm(this.tree[0]); + } + equals(e) { + return this.id === e.id; + } + child(e) { + return marshalNode(this), C._ts_node_child_wasm(this.tree[0], e), unmarshalNode(this.tree); + } + namedChild(e) { + return marshalNode(this), C._ts_node_named_child_wasm(this.tree[0], e), unmarshalNode(this.tree); + } + childForFieldId(e) { + return marshalNode(this), C._ts_node_child_by_field_id_wasm(this.tree[0], e), unmarshalNode(this.tree); + } + childForFieldName(e) { + const t = this.tree.language.fields.indexOf(e); + return -1 !== t ? this.childForFieldId(t) : null; + } + fieldNameForChild(e) { + marshalNode(this); + const t = C._ts_node_field_name_for_child_wasm(this.tree[0], e); + if (!t) return null; + return AsciiToString(t); + } + childrenForFieldName(e) { + const t = this.tree.language.fields.indexOf(e); + return -1 !== t && 0 !== t ? this.childrenForFieldId(t) : []; + } + childrenForFieldId(e) { + marshalNode(this), C._ts_node_children_by_field_id_wasm(this.tree[0], e); + const t = getValue(TRANSFER_BUFFER, "i32"), _ = getValue(TRANSFER_BUFFER + SIZE_OF_INT, "i32"), s = new Array(t); + if (t > 0) { + let e2 = _; + for (let _2 = 0; _2 < t; _2++) s[_2] = unmarshalNode(this.tree, e2), e2 += SIZE_OF_NODE; + C._free(_); + } + return s; + } + firstChildForIndex(e) { + marshalNode(this); + return setValue(TRANSFER_BUFFER + SIZE_OF_NODE, e, "i32"), C._ts_node_first_child_for_byte_wasm(this.tree[0]), unmarshalNode(this.tree); + } + firstNamedChildForIndex(e) { + marshalNode(this); + return setValue(TRANSFER_BUFFER + SIZE_OF_NODE, e, "i32"), C._ts_node_first_named_child_for_byte_wasm(this.tree[0]), unmarshalNode(this.tree); + } + get childCount() { + return marshalNode(this), C._ts_node_child_count_wasm(this.tree[0]); + } + get namedChildCount() { + return marshalNode(this), C._ts_node_named_child_count_wasm(this.tree[0]); + } + get firstChild() { + return this.child(0); + } + get firstNamedChild() { + return this.namedChild(0); + } + get lastChild() { + return this.child(this.childCount - 1); + } + get lastNamedChild() { + return this.namedChild(this.namedChildCount - 1); + } + get children() { + if (!this._children) { + marshalNode(this), C._ts_node_children_wasm(this.tree[0]); + const e = getValue(TRANSFER_BUFFER, "i32"), t = getValue(TRANSFER_BUFFER + SIZE_OF_INT, "i32"); + if (this._children = new Array(e), e > 0) { + let _ = t; + for (let t2 = 0; t2 < e; t2++) this._children[t2] = unmarshalNode(this.tree, _), _ += SIZE_OF_NODE; + C._free(t); + } + } + return this._children; + } + get namedChildren() { + if (!this._namedChildren) { + marshalNode(this), C._ts_node_named_children_wasm(this.tree[0]); + const e = getValue(TRANSFER_BUFFER, "i32"), t = getValue(TRANSFER_BUFFER + SIZE_OF_INT, "i32"); + if (this._namedChildren = new Array(e), e > 0) { + let _ = t; + for (let t2 = 0; t2 < e; t2++) this._namedChildren[t2] = unmarshalNode(this.tree, _), _ += SIZE_OF_NODE; + C._free(t); + } + } + return this._namedChildren; + } + descendantsOfType(e, t, _) { + Array.isArray(e) || (e = [e]), t || (t = ZERO_POINT), _ || (_ = ZERO_POINT); + const s = [], r = this.tree.language.types; + for (let t2 = 0, _2 = r.length; t2 < _2; t2++) e.includes(r[t2]) && s.push(t2); + const a = C._malloc(SIZE_OF_INT * s.length); + for (let e2 = 0, t2 = s.length; e2 < t2; e2++) setValue(a + e2 * SIZE_OF_INT, s[e2], "i32"); + marshalNode(this), C._ts_node_descendants_of_type_wasm(this.tree[0], a, s.length, t.row, t.column, _.row, _.column); + const o = getValue(TRANSFER_BUFFER, "i32"), n = getValue(TRANSFER_BUFFER + SIZE_OF_INT, "i32"), l = new Array(o); + if (o > 0) { + let e2 = n; + for (let t2 = 0; t2 < o; t2++) l[t2] = unmarshalNode(this.tree, e2), e2 += SIZE_OF_NODE; + } + return C._free(n), C._free(a), l; + } + get nextSibling() { + return marshalNode(this), C._ts_node_next_sibling_wasm(this.tree[0]), unmarshalNode(this.tree); + } + get previousSibling() { + return marshalNode(this), C._ts_node_prev_sibling_wasm(this.tree[0]), unmarshalNode(this.tree); + } + get nextNamedSibling() { + return marshalNode(this), C._ts_node_next_named_sibling_wasm(this.tree[0]), unmarshalNode(this.tree); + } + get previousNamedSibling() { + return marshalNode(this), C._ts_node_prev_named_sibling_wasm(this.tree[0]), unmarshalNode(this.tree); + } + get descendantCount() { + return marshalNode(this), C._ts_node_descendant_count_wasm(this.tree[0]); + } + get parent() { + return marshalNode(this), C._ts_node_parent_wasm(this.tree[0]), unmarshalNode(this.tree); + } + descendantForIndex(e, t = e) { + if ("number" != typeof e || "number" != typeof t) throw new Error("Arguments must be numbers"); + marshalNode(this); + const _ = TRANSFER_BUFFER + SIZE_OF_NODE; + return setValue(_, e, "i32"), setValue(_ + SIZE_OF_INT, t, "i32"), C._ts_node_descendant_for_index_wasm(this.tree[0]), unmarshalNode(this.tree); + } + namedDescendantForIndex(e, t = e) { + if ("number" != typeof e || "number" != typeof t) throw new Error("Arguments must be numbers"); + marshalNode(this); + const _ = TRANSFER_BUFFER + SIZE_OF_NODE; + return setValue(_, e, "i32"), setValue(_ + SIZE_OF_INT, t, "i32"), C._ts_node_named_descendant_for_index_wasm(this.tree[0]), unmarshalNode(this.tree); + } + descendantForPosition(e, t = e) { + if (!isPoint(e) || !isPoint(t)) throw new Error("Arguments must be {row, column} objects"); + marshalNode(this); + const _ = TRANSFER_BUFFER + SIZE_OF_NODE; + return marshalPoint(_, e), marshalPoint(_ + SIZE_OF_POINT, t), C._ts_node_descendant_for_position_wasm(this.tree[0]), unmarshalNode(this.tree); + } + namedDescendantForPosition(e, t = e) { + if (!isPoint(e) || !isPoint(t)) throw new Error("Arguments must be {row, column} objects"); + marshalNode(this); + const _ = TRANSFER_BUFFER + SIZE_OF_NODE; + return marshalPoint(_, e), marshalPoint(_ + SIZE_OF_POINT, t), C._ts_node_named_descendant_for_position_wasm(this.tree[0]), unmarshalNode(this.tree); + } + walk() { + return marshalNode(this), C._ts_tree_cursor_new_wasm(this.tree[0]), new TreeCursor(INTERNAL, this.tree); + } + toString() { + marshalNode(this); + const e = C._ts_node_to_string_wasm(this.tree[0]), t = AsciiToString(e); + return C._free(e), t; + } + } + class TreeCursor { + constructor(e, t) { + assertInternal(e), this.tree = t, unmarshalTreeCursor(this); + } + delete() { + marshalTreeCursor(this), C._ts_tree_cursor_delete_wasm(this.tree[0]), this[0] = this[1] = this[2] = 0; + } + reset(e) { + marshalNode(e), marshalTreeCursor(this, TRANSFER_BUFFER + SIZE_OF_NODE), C._ts_tree_cursor_reset_wasm(this.tree[0]), unmarshalTreeCursor(this); + } + resetTo(e) { + marshalTreeCursor(this, TRANSFER_BUFFER), marshalTreeCursor(e, TRANSFER_BUFFER + SIZE_OF_CURSOR), C._ts_tree_cursor_reset_to_wasm(this.tree[0], e.tree[0]), unmarshalTreeCursor(this); + } + get nodeType() { + return this.tree.language.types[this.nodeTypeId] || "ERROR"; + } + get nodeTypeId() { + return marshalTreeCursor(this), C._ts_tree_cursor_current_node_type_id_wasm(this.tree[0]); + } + get nodeStateId() { + return marshalTreeCursor(this), C._ts_tree_cursor_current_node_state_id_wasm(this.tree[0]); + } + get nodeId() { + return marshalTreeCursor(this), C._ts_tree_cursor_current_node_id_wasm(this.tree[0]); + } + get nodeIsNamed() { + return marshalTreeCursor(this), 1 === C._ts_tree_cursor_current_node_is_named_wasm(this.tree[0]); + } + get nodeIsMissing() { + return marshalTreeCursor(this), 1 === C._ts_tree_cursor_current_node_is_missing_wasm(this.tree[0]); + } + get nodeText() { + marshalTreeCursor(this); + const e = C._ts_tree_cursor_start_index_wasm(this.tree[0]), t = C._ts_tree_cursor_end_index_wasm(this.tree[0]); + return getText(this.tree, e, t); + } + get startPosition() { + return marshalTreeCursor(this), C._ts_tree_cursor_start_position_wasm(this.tree[0]), unmarshalPoint(TRANSFER_BUFFER); + } + get endPosition() { + return marshalTreeCursor(this), C._ts_tree_cursor_end_position_wasm(this.tree[0]), unmarshalPoint(TRANSFER_BUFFER); + } + get startIndex() { + return marshalTreeCursor(this), C._ts_tree_cursor_start_index_wasm(this.tree[0]); + } + get endIndex() { + return marshalTreeCursor(this), C._ts_tree_cursor_end_index_wasm(this.tree[0]); + } + get currentNode() { + return marshalTreeCursor(this), C._ts_tree_cursor_current_node_wasm(this.tree[0]), unmarshalNode(this.tree); + } + get currentFieldId() { + return marshalTreeCursor(this), C._ts_tree_cursor_current_field_id_wasm(this.tree[0]); + } + get currentFieldName() { + return this.tree.language.fields[this.currentFieldId]; + } + get currentDepth() { + return marshalTreeCursor(this), C._ts_tree_cursor_current_depth_wasm(this.tree[0]); + } + get currentDescendantIndex() { + return marshalTreeCursor(this), C._ts_tree_cursor_current_descendant_index_wasm(this.tree[0]); + } + gotoFirstChild() { + marshalTreeCursor(this); + const e = C._ts_tree_cursor_goto_first_child_wasm(this.tree[0]); + return unmarshalTreeCursor(this), 1 === e; + } + gotoLastChild() { + marshalTreeCursor(this); + const e = C._ts_tree_cursor_goto_last_child_wasm(this.tree[0]); + return unmarshalTreeCursor(this), 1 === e; + } + gotoFirstChildForIndex(e) { + marshalTreeCursor(this), setValue(TRANSFER_BUFFER + SIZE_OF_CURSOR, e, "i32"); + const t = C._ts_tree_cursor_goto_first_child_for_index_wasm(this.tree[0]); + return unmarshalTreeCursor(this), 1 === t; + } + gotoFirstChildForPosition(e) { + marshalTreeCursor(this), marshalPoint(TRANSFER_BUFFER + SIZE_OF_CURSOR, e); + const t = C._ts_tree_cursor_goto_first_child_for_position_wasm(this.tree[0]); + return unmarshalTreeCursor(this), 1 === t; + } + gotoNextSibling() { + marshalTreeCursor(this); + const e = C._ts_tree_cursor_goto_next_sibling_wasm(this.tree[0]); + return unmarshalTreeCursor(this), 1 === e; + } + gotoPreviousSibling() { + marshalTreeCursor(this); + const e = C._ts_tree_cursor_goto_previous_sibling_wasm(this.tree[0]); + return unmarshalTreeCursor(this), 1 === e; + } + gotoDescendant(e) { + marshalTreeCursor(this), C._ts_tree_cursor_goto_descendant_wasm(this.tree[0], e), unmarshalTreeCursor(this); + } + gotoParent() { + marshalTreeCursor(this); + const e = C._ts_tree_cursor_goto_parent_wasm(this.tree[0]); + return unmarshalTreeCursor(this), 1 === e; + } + } + class Language { + constructor(e, t) { + assertInternal(e), this[0] = t, this.types = new Array(C._ts_language_symbol_count(this[0])); + for (let e2 = 0, t2 = this.types.length; e2 < t2; e2++) C._ts_language_symbol_type(this[0], e2) < 2 && (this.types[e2] = UTF8ToString(C._ts_language_symbol_name(this[0], e2))); + this.fields = new Array(C._ts_language_field_count(this[0]) + 1); + for (let e2 = 0, t2 = this.fields.length; e2 < t2; e2++) { + const t3 = C._ts_language_field_name_for_id(this[0], e2); + this.fields[e2] = 0 !== t3 ? UTF8ToString(t3) : null; + } + } + get version() { + return C._ts_language_version(this[0]); + } + get fieldCount() { + return this.fields.length - 1; + } + get stateCount() { + return C._ts_language_state_count(this[0]); + } + fieldIdForName(e) { + const t = this.fields.indexOf(e); + return -1 !== t ? t : null; + } + fieldNameForId(e) { + return this.fields[e] || null; + } + idForNodeType(e, t) { + const _ = lengthBytesUTF8(e), s = C._malloc(_ + 1); + stringToUTF8(e, s, _ + 1); + const r = C._ts_language_symbol_for_name(this[0], s, _, t); + return C._free(s), r || null; + } + get nodeTypeCount() { + return C._ts_language_symbol_count(this[0]); + } + nodeTypeForId(e) { + const t = C._ts_language_symbol_name(this[0], e); + return t ? UTF8ToString(t) : null; + } + nodeTypeIsNamed(e) { + return !!C._ts_language_type_is_named_wasm(this[0], e); + } + nodeTypeIsVisible(e) { + return !!C._ts_language_type_is_visible_wasm(this[0], e); + } + nextState(e, t) { + return C._ts_language_next_state(this[0], e, t); + } + lookaheadIterator(e) { + const t = C._ts_lookahead_iterator_new(this[0], e); + return t ? new LookaheadIterable(INTERNAL, t, this) : null; + } + query(e) { + const t = lengthBytesUTF8(e), _ = C._malloc(t + 1); + stringToUTF8(e, _, t + 1); + const s = C._ts_query_new(this[0], _, t, TRANSFER_BUFFER, TRANSFER_BUFFER + SIZE_OF_INT); + if (!s) { + const t2 = getValue(TRANSFER_BUFFER + SIZE_OF_INT, "i32"), s2 = getValue(TRANSFER_BUFFER, "i32"), r2 = UTF8ToString(_, s2).length, a2 = e.substr(r2, 100).split("\n")[0]; + let o2, n2 = a2.match(QUERY_WORD_REGEX)[0]; + switch (t2) { + case 2: + o2 = new RangeError(`Bad node name '${n2}'`); + break; + case 3: + o2 = new RangeError(`Bad field name '${n2}'`); + break; + case 4: + o2 = new RangeError(`Bad capture name @${n2}`); + break; + case 5: + o2 = new TypeError(`Bad pattern structure at offset ${r2}: '${a2}'...`), n2 = ""; + break; + default: + o2 = new SyntaxError(`Bad syntax at offset ${r2}: '${a2}'...`), n2 = ""; + } + throw o2.index = r2, o2.length = n2.length, C._free(_), o2; + } + const r = C._ts_query_string_count(s), a = C._ts_query_capture_count(s), o = C._ts_query_pattern_count(s), n = new Array(a), l = new Array(r); + for (let e2 = 0; e2 < a; e2++) { + const t2 = C._ts_query_capture_name_for_id(s, e2, TRANSFER_BUFFER), _2 = getValue(TRANSFER_BUFFER, "i32"); + n[e2] = UTF8ToString(t2, _2); + } + for (let e2 = 0; e2 < r; e2++) { + const t2 = C._ts_query_string_value_for_id(s, e2, TRANSFER_BUFFER), _2 = getValue(TRANSFER_BUFFER, "i32"); + l[e2] = UTF8ToString(t2, _2); + } + const d = new Array(o), u = new Array(o), m = new Array(o), c = new Array(o), w = new Array(o); + for (let e2 = 0; e2 < o; e2++) { + const t2 = C._ts_query_predicates_for_pattern(s, e2, TRANSFER_BUFFER), _2 = getValue(TRANSFER_BUFFER, "i32"); + c[e2] = [], w[e2] = []; + const r2 = []; + let a2 = t2; + for (let t3 = 0; t3 < _2; t3++) { + const t4 = getValue(a2, "i32"); + a2 += SIZE_OF_INT; + const _3 = getValue(a2, "i32"); + if (a2 += SIZE_OF_INT, t4 === PREDICATE_STEP_TYPE_CAPTURE) r2.push({ type: "capture", name: n[_3] }); + else if (t4 === PREDICATE_STEP_TYPE_STRING) r2.push({ type: "string", value: l[_3] }); + else if (r2.length > 0) { + if ("string" !== r2[0].type) throw new Error("Predicates must begin with a literal value"); + const t5 = r2[0].value; + let _4, s2 = true, a3 = true; + switch (t5) { + case "any-not-eq?": + case "not-eq?": + s2 = false; + case "any-eq?": + case "eq?": + if (3 !== r2.length) throw new Error(`Wrong number of arguments to \`#${t5}\` predicate. Expected 2, got ${r2.length - 1}`); + if ("capture" !== r2[1].type) throw new Error(`First argument of \`#${t5}\` predicate must be a capture. Got "${r2[1].value}"`); + if (a3 = !t5.startsWith("any-"), "capture" === r2[2].type) { + const t6 = r2[1].name, _5 = r2[2].name; + w[e2].push((e3) => { + const r3 = [], o3 = []; + for (const s3 of e3) s3.name === t6 && r3.push(s3.node), s3.name === _5 && o3.push(s3.node); + const n3 = (e4, t7, _6) => _6 ? e4.text === t7.text : e4.text !== t7.text; + return a3 ? r3.every((e4) => o3.some((t7) => n3(e4, t7, s2))) : r3.some((e4) => o3.some((t7) => n3(e4, t7, s2))); + }); + } else { + _4 = r2[1].name; + const t6 = r2[2].value, o3 = (e3) => e3.text === t6, n3 = (e3) => e3.text !== t6; + w[e2].push((e3) => { + const t7 = []; + for (const s3 of e3) s3.name === _4 && t7.push(s3.node); + const r3 = s2 ? o3 : n3; + return a3 ? t7.every(r3) : t7.some(r3); + }); + } + break; + case "any-not-match?": + case "not-match?": + s2 = false; + case "any-match?": + case "match?": + if (3 !== r2.length) throw new Error(`Wrong number of arguments to \`#${t5}\` predicate. Expected 2, got ${r2.length - 1}.`); + if ("capture" !== r2[1].type) throw new Error(`First argument of \`#${t5}\` predicate must be a capture. Got "${r2[1].value}".`); + if ("string" !== r2[2].type) throw new Error(`Second argument of \`#${t5}\` predicate must be a string. Got @${r2[2].value}.`); + _4 = r2[1].name; + const o2 = new RegExp(r2[2].value); + a3 = !t5.startsWith("any-"), w[e2].push((e3) => { + const t6 = []; + for (const s3 of e3) s3.name === _4 && t6.push(s3.node.text); + const r3 = (e4, t7) => t7 ? o2.test(e4) : !o2.test(e4); + return 0 === t6.length ? !s2 : a3 ? t6.every((e4) => r3(e4, s2)) : t6.some((e4) => r3(e4, s2)); + }); + break; + case "set!": + if (r2.length < 2 || r2.length > 3) throw new Error(`Wrong number of arguments to \`#set!\` predicate. Expected 1 or 2. Got ${r2.length - 1}.`); + if (r2.some((e3) => "string" !== e3.type)) throw new Error('Arguments to `#set!` predicate must be a strings.".'); + d[e2] || (d[e2] = {}), d[e2][r2[1].value] = r2[2] ? r2[2].value : null; + break; + case "is?": + case "is-not?": + if (r2.length < 2 || r2.length > 3) throw new Error(`Wrong number of arguments to \`#${t5}\` predicate. Expected 1 or 2. Got ${r2.length - 1}.`); + if (r2.some((e3) => "string" !== e3.type)) throw new Error(`Arguments to \`#${t5}\` predicate must be a strings.".`); + const n2 = "is?" === t5 ? u : m; + n2[e2] || (n2[e2] = {}), n2[e2][r2[1].value] = r2[2] ? r2[2].value : null; + break; + case "not-any-of?": + s2 = false; + case "any-of?": + if (r2.length < 2) throw new Error(`Wrong number of arguments to \`#${t5}\` predicate. Expected at least 1. Got ${r2.length - 1}.`); + if ("capture" !== r2[1].type) throw new Error(`First argument of \`#${t5}\` predicate must be a capture. Got "${r2[1].value}".`); + for (let e3 = 2; e3 < r2.length; e3++) if ("string" !== r2[e3].type) throw new Error(`Arguments to \`#${t5}\` predicate must be a strings.".`); + _4 = r2[1].name; + const l2 = r2.slice(2).map((e3) => e3.value); + w[e2].push((e3) => { + const t6 = []; + for (const s3 of e3) s3.name === _4 && t6.push(s3.node.text); + return 0 === t6.length ? !s2 : t6.every((e4) => l2.includes(e4)) === s2; + }); + break; + default: + c[e2].push({ operator: t5, operands: r2.slice(1) }); + } + r2.length = 0; + } + } + Object.freeze(d[e2]), Object.freeze(u[e2]), Object.freeze(m[e2]); + } + return C._free(_), new Query(INTERNAL, s, n, w, c, Object.freeze(d), Object.freeze(u), Object.freeze(m)); + } + static load(e) { + let t; + if (e instanceof Uint8Array) t = Promise.resolve(e); + else { + const _ = e; + if ("undefined" != typeof process && process.versions && process.versions.node) { + const e2 = require("fs"); + t = Promise.resolve(e2.readFileSync(_)); + } else t = fetch(_).then((e2) => e2.arrayBuffer().then((t2) => { + if (e2.ok) return new Uint8Array(t2); + { + const _2 = new TextDecoder("utf-8").decode(t2); + throw new Error(`Language.load failed with status ${e2.status}. + +${_2}`); + } + })); + } + return t.then((e2) => loadWebAssemblyModule(e2, { loadAsync: true })).then((e2) => { + const t2 = Object.keys(e2), _ = t2.find((e3) => LANGUAGE_FUNCTION_REGEX.test(e3) && !e3.includes("external_scanner_")); + _ || console.log(`Couldn't find language function in WASM file. Symbols: +${JSON.stringify(t2, null, 2)}`); + const s = e2[_](); + return new Language(INTERNAL, s); + }); + } + } + class LookaheadIterable { + constructor(e, t, _) { + assertInternal(e), this[0] = t, this.language = _; + } + get currentTypeId() { + return C._ts_lookahead_iterator_current_symbol(this[0]); + } + get currentType() { + return this.language.types[this.currentTypeId] || "ERROR"; + } + delete() { + C._ts_lookahead_iterator_delete(this[0]), this[0] = 0; + } + resetState(e) { + return C._ts_lookahead_iterator_reset_state(this[0], e); + } + reset(e, t) { + return !!C._ts_lookahead_iterator_reset(this[0], e[0], t) && (this.language = e, true); + } + [Symbol.iterator]() { + const e = this; + return { next: () => C._ts_lookahead_iterator_next(e[0]) ? { done: false, value: e.currentType } : { done: true, value: "" } }; + } + } + class Query { + constructor(e, t, _, s, r, a, o, n) { + assertInternal(e), this[0] = t, this.captureNames = _, this.textPredicates = s, this.predicates = r, this.setProperties = a, this.assertedProperties = o, this.refutedProperties = n, this.exceededMatchLimit = false; + } + delete() { + C._ts_query_delete(this[0]), this[0] = 0; + } + matches(e, { startPosition: t = ZERO_POINT, endPosition: _ = ZERO_POINT, startIndex: s = 0, endIndex: r = 0, matchLimit: a = 4294967295, maxStartDepth: o = 4294967295 } = {}) { + if ("number" != typeof a) throw new Error("Arguments must be numbers"); + marshalNode(e), C._ts_query_matches_wasm(this[0], e.tree[0], t.row, t.column, _.row, _.column, s, r, a, o); + const n = getValue(TRANSFER_BUFFER, "i32"), l = getValue(TRANSFER_BUFFER + SIZE_OF_INT, "i32"), d = getValue(TRANSFER_BUFFER + 2 * SIZE_OF_INT, "i32"), u = new Array(n); + this.exceededMatchLimit = Boolean(d); + let m = 0, c = l; + for (let t2 = 0; t2 < n; t2++) { + const t3 = getValue(c, "i32"); + c += SIZE_OF_INT; + const _2 = getValue(c, "i32"); + c += SIZE_OF_INT; + const s2 = new Array(_2); + if (c = unmarshalCaptures(this, e.tree, c, s2), this.textPredicates[t3].every((e2) => e2(s2))) { + u[m] = { pattern: t3, captures: s2 }; + const e2 = this.setProperties[t3]; + e2 && (u[m].setProperties = e2); + const _3 = this.assertedProperties[t3]; + _3 && (u[m].assertedProperties = _3); + const r2 = this.refutedProperties[t3]; + r2 && (u[m].refutedProperties = r2), m++; + } + } + return u.length = m, C._free(l), u; + } + captures(e, { startPosition: t = ZERO_POINT, endPosition: _ = ZERO_POINT, startIndex: s = 0, endIndex: r = 0, matchLimit: a = 4294967295, maxStartDepth: o = 4294967295 } = {}) { + if ("number" != typeof a) throw new Error("Arguments must be numbers"); + marshalNode(e), C._ts_query_captures_wasm(this[0], e.tree[0], t.row, t.column, _.row, _.column, s, r, a, o); + const n = getValue(TRANSFER_BUFFER, "i32"), l = getValue(TRANSFER_BUFFER + SIZE_OF_INT, "i32"), d = getValue(TRANSFER_BUFFER + 2 * SIZE_OF_INT, "i32"), u = []; + this.exceededMatchLimit = Boolean(d); + const m = []; + let c = l; + for (let t2 = 0; t2 < n; t2++) { + const t3 = getValue(c, "i32"); + c += SIZE_OF_INT; + const _2 = getValue(c, "i32"); + c += SIZE_OF_INT; + const s2 = getValue(c, "i32"); + if (c += SIZE_OF_INT, m.length = _2, c = unmarshalCaptures(this, e.tree, c, m), this.textPredicates[t3].every((e2) => e2(m))) { + const e2 = m[s2], _3 = this.setProperties[t3]; + _3 && (e2.setProperties = _3); + const r2 = this.assertedProperties[t3]; + r2 && (e2.assertedProperties = r2); + const a2 = this.refutedProperties[t3]; + a2 && (e2.refutedProperties = a2), u.push(e2); + } + } + return C._free(l), u; + } + predicatesForPattern(e) { + return this.predicates[e]; + } + disableCapture(e) { + const t = lengthBytesUTF8(e), _ = C._malloc(t + 1); + stringToUTF8(e, _, t + 1), C._ts_query_disable_capture(this[0], _, t), C._free(_); + } + didExceedMatchLimit() { + return this.exceededMatchLimit; + } + } + function getText(e, t, _) { + const s = _ - t; + let r = e.textCallback(t, null, _); + for (t += r.length; t < _; ) { + const s2 = e.textCallback(t, null, _); + if (!(s2 && s2.length > 0)) break; + t += s2.length, r += s2; + } + return t > _ && (r = r.slice(0, s)), r; + } + function unmarshalCaptures(e, t, _, s) { + for (let r = 0, a = s.length; r < a; r++) { + const a2 = getValue(_, "i32"), o = unmarshalNode(t, _ += SIZE_OF_INT); + _ += SIZE_OF_NODE, s[r] = { name: e.captureNames[a2], node: o }; + } + return _; + } + function assertInternal(e) { + if (e !== INTERNAL) throw new Error("Illegal constructor"); + } + function isPoint(e) { + return e && "number" == typeof e.row && "number" == typeof e.column; + } + function marshalNode(e) { + let t = TRANSFER_BUFFER; + setValue(t, e.id, "i32"), t += SIZE_OF_INT, setValue(t, e.startIndex, "i32"), t += SIZE_OF_INT, setValue(t, e.startPosition.row, "i32"), t += SIZE_OF_INT, setValue(t, e.startPosition.column, "i32"), t += SIZE_OF_INT, setValue(t, e[0], "i32"); + } + function unmarshalNode(e, t = TRANSFER_BUFFER) { + const _ = getValue(t, "i32"); + if (0 === _) return null; + const s = getValue(t += SIZE_OF_INT, "i32"), r = getValue(t += SIZE_OF_INT, "i32"), a = getValue(t += SIZE_OF_INT, "i32"), o = getValue(t += SIZE_OF_INT, "i32"), n = new Node(INTERNAL, e); + return n.id = _, n.startIndex = s, n.startPosition = { row: r, column: a }, n[0] = o, n; + } + function marshalTreeCursor(e, t = TRANSFER_BUFFER) { + setValue(t + 0 * SIZE_OF_INT, e[0], "i32"), setValue(t + 1 * SIZE_OF_INT, e[1], "i32"), setValue(t + 2 * SIZE_OF_INT, e[2], "i32"), setValue(t + 3 * SIZE_OF_INT, e[3], "i32"); + } + function unmarshalTreeCursor(e) { + e[0] = getValue(TRANSFER_BUFFER + 0 * SIZE_OF_INT, "i32"), e[1] = getValue(TRANSFER_BUFFER + 1 * SIZE_OF_INT, "i32"), e[2] = getValue(TRANSFER_BUFFER + 2 * SIZE_OF_INT, "i32"), e[3] = getValue(TRANSFER_BUFFER + 3 * SIZE_OF_INT, "i32"); + } + function marshalPoint(e, t) { + setValue(e, t.row, "i32"), setValue(e + SIZE_OF_INT, t.column, "i32"); + } + function unmarshalPoint(e) { + return { row: getValue(e, "i32") >>> 0, column: getValue(e + SIZE_OF_INT, "i32") >>> 0 }; + } + function marshalRange(e, t) { + marshalPoint(e, t.startPosition), marshalPoint(e += SIZE_OF_POINT, t.endPosition), setValue(e += SIZE_OF_POINT, t.startIndex, "i32"), setValue(e += SIZE_OF_INT, t.endIndex, "i32"), e += SIZE_OF_INT; + } + function unmarshalRange(e) { + const t = {}; + return t.startPosition = unmarshalPoint(e), e += SIZE_OF_POINT, t.endPosition = unmarshalPoint(e), e += SIZE_OF_POINT, t.startIndex = getValue(e, "i32") >>> 0, e += SIZE_OF_INT, t.endIndex = getValue(e, "i32") >>> 0, t; + } + function marshalEdit(e) { + let t = TRANSFER_BUFFER; + marshalPoint(t, e.startPosition), t += SIZE_OF_POINT, marshalPoint(t, e.oldEndPosition), t += SIZE_OF_POINT, marshalPoint(t, e.newEndPosition), t += SIZE_OF_POINT, setValue(t, e.startIndex, "i32"), t += SIZE_OF_INT, setValue(t, e.oldEndIndex, "i32"), t += SIZE_OF_INT, setValue(t, e.newEndIndex, "i32"), t += SIZE_OF_INT; + } + for (const e of Object.getOwnPropertyNames(ParserImpl.prototype)) Object.defineProperty(Parser.prototype, e, { value: ParserImpl.prototype[e], enumerable: false, writable: false }); + Parser.Language = Language, Module.onRuntimeInitialized = () => { + ParserImpl.init(), resolveInitPromise(); + }; + })); + } + } + return Parser; + }(); + "object" == typeof exports && (module.exports = TreeSitter); + } +}); + +// node_modules/commander/lib/error.js +var require_error = __commonJS({ + "node_modules/commander/lib/error.js"(exports2) { + var CommanderError = class extends Error { + /** + * Constructs the CommanderError class + * @param {number} exitCode suggested exit code which could be used with process.exit + * @param {string} code an id string representing the error + * @param {string} message human-readable description of the error + */ + constructor(exitCode, code, message) { + super(message); + Error.captureStackTrace(this, this.constructor); + this.name = this.constructor.name; + this.code = code; + this.exitCode = exitCode; + this.nestedError = void 0; + } + }; + var InvalidArgumentError = class extends CommanderError { + /** + * Constructs the InvalidArgumentError class + * @param {string} [message] explanation of why argument is invalid + */ + constructor(message) { + super(1, "commander.invalidArgument", message); + Error.captureStackTrace(this, this.constructor); + this.name = this.constructor.name; + } + }; + exports2.CommanderError = CommanderError; + exports2.InvalidArgumentError = InvalidArgumentError; + } +}); + +// node_modules/commander/lib/argument.js +var require_argument = __commonJS({ + "node_modules/commander/lib/argument.js"(exports2) { + var { InvalidArgumentError } = require_error(); + var Argument = class { + /** + * Initialize a new command argument with the given name and description. + * The default is that the argument is required, and you can explicitly + * indicate this with <> around the name. Put [] around the name for an optional argument. + * + * @param {string} name + * @param {string} [description] + */ + constructor(name2, description) { + this.description = description || ""; + this.variadic = false; + this.parseArg = void 0; + this.defaultValue = void 0; + this.defaultValueDescription = void 0; + this.argChoices = void 0; + switch (name2[0]) { + case "<": + this.required = true; + this._name = name2.slice(1, -1); + break; + case "[": + this.required = false; + this._name = name2.slice(1, -1); + break; + default: + this.required = true; + this._name = name2; + break; + } + if (this._name.length > 3 && this._name.slice(-3) === "...") { + this.variadic = true; + this._name = this._name.slice(0, -3); + } + } + /** + * Return argument name. + * + * @return {string} + */ + name() { + return this._name; + } + /** + * @package + */ + _concatValue(value, previous) { + if (previous === this.defaultValue || !Array.isArray(previous)) { + return [value]; + } + return previous.concat(value); + } + /** + * Set the default value, and optionally supply the description to be displayed in the help. + * + * @param {*} value + * @param {string} [description] + * @return {Argument} + */ + default(value, description) { + this.defaultValue = value; + this.defaultValueDescription = description; + return this; + } + /** + * Set the custom handler for processing CLI command arguments into argument values. + * + * @param {Function} [fn] + * @return {Argument} + */ + argParser(fn) { + this.parseArg = fn; + return this; + } + /** + * Only allow argument value to be one of choices. + * + * @param {string[]} values + * @return {Argument} + */ + choices(values) { + this.argChoices = values.slice(); + this.parseArg = (arg, previous) => { + if (!this.argChoices.includes(arg)) { + throw new InvalidArgumentError( + `Allowed choices are ${this.argChoices.join(", ")}.` + ); + } + if (this.variadic) { + return this._concatValue(arg, previous); + } + return arg; + }; + return this; + } + /** + * Make argument required. + * + * @returns {Argument} + */ + argRequired() { + this.required = true; + return this; + } + /** + * Make argument optional. + * + * @returns {Argument} + */ + argOptional() { + this.required = false; + return this; + } + }; + function humanReadableArgName(arg) { + const nameOutput = arg.name() + (arg.variadic === true ? "..." : ""); + return arg.required ? "<" + nameOutput + ">" : "[" + nameOutput + "]"; + } + exports2.Argument = Argument; + exports2.humanReadableArgName = humanReadableArgName; + } +}); + +// node_modules/commander/lib/help.js +var require_help = __commonJS({ + "node_modules/commander/lib/help.js"(exports2) { + var { humanReadableArgName } = require_argument(); + var Help = class { + constructor() { + this.helpWidth = void 0; + this.minWidthToWrap = 40; + this.sortSubcommands = false; + this.sortOptions = false; + this.showGlobalOptions = false; + } + /** + * prepareContext is called by Commander after applying overrides from `Command.configureHelp()` + * and just before calling `formatHelp()`. + * + * Commander just uses the helpWidth and the rest is provided for optional use by more complex subclasses. + * + * @param {{ error?: boolean, helpWidth?: number, outputHasColors?: boolean }} contextOptions + */ + prepareContext(contextOptions) { + this.helpWidth = this.helpWidth ?? contextOptions.helpWidth ?? 80; + } + /** + * Get an array of the visible subcommands. Includes a placeholder for the implicit help command, if there is one. + * + * @param {Command} cmd + * @returns {Command[]} + */ + visibleCommands(cmd) { + const visibleCommands = cmd.commands.filter((cmd2) => !cmd2._hidden); + const helpCommand = cmd._getHelpCommand(); + if (helpCommand && !helpCommand._hidden) { + visibleCommands.push(helpCommand); + } + if (this.sortSubcommands) { + visibleCommands.sort((a, b) => { + return a.name().localeCompare(b.name()); + }); + } + return visibleCommands; + } + /** + * Compare options for sort. + * + * @param {Option} a + * @param {Option} b + * @returns {number} + */ + compareOptions(a, b) { + const getSortKey = (option) => { + return option.short ? option.short.replace(/^-/, "") : option.long.replace(/^--/, ""); + }; + return getSortKey(a).localeCompare(getSortKey(b)); + } + /** + * Get an array of the visible options. Includes a placeholder for the implicit help option, if there is one. + * + * @param {Command} cmd + * @returns {Option[]} + */ + visibleOptions(cmd) { + const visibleOptions = cmd.options.filter((option) => !option.hidden); + const helpOption = cmd._getHelpOption(); + if (helpOption && !helpOption.hidden) { + const removeShort = helpOption.short && cmd._findOption(helpOption.short); + const removeLong = helpOption.long && cmd._findOption(helpOption.long); + if (!removeShort && !removeLong) { + visibleOptions.push(helpOption); + } else if (helpOption.long && !removeLong) { + visibleOptions.push( + cmd.createOption(helpOption.long, helpOption.description) + ); + } else if (helpOption.short && !removeShort) { + visibleOptions.push( + cmd.createOption(helpOption.short, helpOption.description) + ); + } + } + if (this.sortOptions) { + visibleOptions.sort(this.compareOptions); + } + return visibleOptions; + } + /** + * Get an array of the visible global options. (Not including help.) + * + * @param {Command} cmd + * @returns {Option[]} + */ + visibleGlobalOptions(cmd) { + if (!this.showGlobalOptions) return []; + const globalOptions = []; + for (let ancestorCmd = cmd.parent; ancestorCmd; ancestorCmd = ancestorCmd.parent) { + const visibleOptions = ancestorCmd.options.filter( + (option) => !option.hidden + ); + globalOptions.push(...visibleOptions); + } + if (this.sortOptions) { + globalOptions.sort(this.compareOptions); + } + return globalOptions; + } + /** + * Get an array of the arguments if any have a description. + * + * @param {Command} cmd + * @returns {Argument[]} + */ + visibleArguments(cmd) { + if (cmd._argsDescription) { + cmd.registeredArguments.forEach((argument) => { + argument.description = argument.description || cmd._argsDescription[argument.name()] || ""; + }); + } + if (cmd.registeredArguments.find((argument) => argument.description)) { + return cmd.registeredArguments; + } + return []; + } + /** + * Get the command term to show in the list of subcommands. + * + * @param {Command} cmd + * @returns {string} + */ + subcommandTerm(cmd) { + const args2 = cmd.registeredArguments.map((arg) => humanReadableArgName(arg)).join(" "); + return cmd._name + (cmd._aliases[0] ? "|" + cmd._aliases[0] : "") + (cmd.options.length ? " [options]" : "") + // simplistic check for non-help option + (args2 ? " " + args2 : ""); + } + /** + * Get the option term to show in the list of options. + * + * @param {Option} option + * @returns {string} + */ + optionTerm(option) { + return option.flags; + } + /** + * Get the argument term to show in the list of arguments. + * + * @param {Argument} argument + * @returns {string} + */ + argumentTerm(argument) { + return argument.name(); + } + /** + * Get the longest command term length. + * + * @param {Command} cmd + * @param {Help} helper + * @returns {number} + */ + longestSubcommandTermLength(cmd, helper) { + return helper.visibleCommands(cmd).reduce((max, command) => { + return Math.max( + max, + this.displayWidth( + helper.styleSubcommandTerm(helper.subcommandTerm(command)) + ) + ); + }, 0); + } + /** + * Get the longest option term length. + * + * @param {Command} cmd + * @param {Help} helper + * @returns {number} + */ + longestOptionTermLength(cmd, helper) { + return helper.visibleOptions(cmd).reduce((max, option) => { + return Math.max( + max, + this.displayWidth(helper.styleOptionTerm(helper.optionTerm(option))) + ); + }, 0); + } + /** + * Get the longest global option term length. + * + * @param {Command} cmd + * @param {Help} helper + * @returns {number} + */ + longestGlobalOptionTermLength(cmd, helper) { + return helper.visibleGlobalOptions(cmd).reduce((max, option) => { + return Math.max( + max, + this.displayWidth(helper.styleOptionTerm(helper.optionTerm(option))) + ); + }, 0); + } + /** + * Get the longest argument term length. + * + * @param {Command} cmd + * @param {Help} helper + * @returns {number} + */ + longestArgumentTermLength(cmd, helper) { + return helper.visibleArguments(cmd).reduce((max, argument) => { + return Math.max( + max, + this.displayWidth( + helper.styleArgumentTerm(helper.argumentTerm(argument)) + ) + ); + }, 0); + } + /** + * Get the command usage to be displayed at the top of the built-in help. + * + * @param {Command} cmd + * @returns {string} + */ + commandUsage(cmd) { + let cmdName = cmd._name; + if (cmd._aliases[0]) { + cmdName = cmdName + "|" + cmd._aliases[0]; + } + let ancestorCmdNames = ""; + for (let ancestorCmd = cmd.parent; ancestorCmd; ancestorCmd = ancestorCmd.parent) { + ancestorCmdNames = ancestorCmd.name() + " " + ancestorCmdNames; + } + return ancestorCmdNames + cmdName + " " + cmd.usage(); + } + /** + * Get the description for the command. + * + * @param {Command} cmd + * @returns {string} + */ + commandDescription(cmd) { + return cmd.description(); + } + /** + * Get the subcommand summary to show in the list of subcommands. + * (Fallback to description for backwards compatibility.) + * + * @param {Command} cmd + * @returns {string} + */ + subcommandDescription(cmd) { + return cmd.summary() || cmd.description(); + } + /** + * Get the option description to show in the list of options. + * + * @param {Option} option + * @return {string} + */ + optionDescription(option) { + const extraInfo = []; + if (option.argChoices) { + extraInfo.push( + // use stringify to match the display of the default value + `choices: ${option.argChoices.map((choice) => JSON.stringify(choice)).join(", ")}` + ); + } + if (option.defaultValue !== void 0) { + const showDefault = option.required || option.optional || option.isBoolean() && typeof option.defaultValue === "boolean"; + if (showDefault) { + extraInfo.push( + `default: ${option.defaultValueDescription || JSON.stringify(option.defaultValue)}` + ); + } + } + if (option.presetArg !== void 0 && option.optional) { + extraInfo.push(`preset: ${JSON.stringify(option.presetArg)}`); + } + if (option.envVar !== void 0) { + extraInfo.push(`env: ${option.envVar}`); + } + if (extraInfo.length > 0) { + const extraDescription = `(${extraInfo.join(", ")})`; + if (option.description) { + return `${option.description} ${extraDescription}`; + } + return extraDescription; + } + return option.description; + } + /** + * Get the argument description to show in the list of arguments. + * + * @param {Argument} argument + * @return {string} + */ + argumentDescription(argument) { + const extraInfo = []; + if (argument.argChoices) { + extraInfo.push( + // use stringify to match the display of the default value + `choices: ${argument.argChoices.map((choice) => JSON.stringify(choice)).join(", ")}` + ); + } + if (argument.defaultValue !== void 0) { + extraInfo.push( + `default: ${argument.defaultValueDescription || JSON.stringify(argument.defaultValue)}` + ); + } + if (extraInfo.length > 0) { + const extraDescription = `(${extraInfo.join(", ")})`; + if (argument.description) { + return `${argument.description} ${extraDescription}`; + } + return extraDescription; + } + return argument.description; + } + /** + * Format a list of items, given a heading and an array of formatted items. + * + * @param {string} heading + * @param {string[]} items + * @param {Help} helper + * @returns string[] + */ + formatItemList(heading, items, helper) { + if (items.length === 0) return []; + return [helper.styleTitle(heading), ...items, ""]; + } + /** + * Group items by their help group heading. + * + * @param {Command[] | Option[]} unsortedItems + * @param {Command[] | Option[]} visibleItems + * @param {Function} getGroup + * @returns {Map} + */ + groupItems(unsortedItems, visibleItems, getGroup) { + const result = /* @__PURE__ */ new Map(); + unsortedItems.forEach((item) => { + const group = getGroup(item); + if (!result.has(group)) result.set(group, []); + }); + visibleItems.forEach((item) => { + const group = getGroup(item); + if (!result.has(group)) { + result.set(group, []); + } + result.get(group).push(item); + }); + return result; + } + /** + * Generate the built-in help text. + * + * @param {Command} cmd + * @param {Help} helper + * @returns {string} + */ + formatHelp(cmd, helper) { + const termWidth = helper.padWidth(cmd, helper); + const helpWidth = helper.helpWidth ?? 80; + function callFormatItem(term, description) { + return helper.formatItem(term, termWidth, description, helper); + } + let output = [ + `${helper.styleTitle("Usage:")} ${helper.styleUsage(helper.commandUsage(cmd))}`, + "" + ]; + const commandDescription = helper.commandDescription(cmd); + if (commandDescription.length > 0) { + output = output.concat([ + helper.boxWrap( + helper.styleCommandDescription(commandDescription), + helpWidth + ), + "" + ]); + } + const argumentList = helper.visibleArguments(cmd).map((argument) => { + return callFormatItem( + helper.styleArgumentTerm(helper.argumentTerm(argument)), + helper.styleArgumentDescription(helper.argumentDescription(argument)) + ); + }); + output = output.concat( + this.formatItemList("Arguments:", argumentList, helper) + ); + const optionGroups = this.groupItems( + cmd.options, + helper.visibleOptions(cmd), + (option) => option.helpGroupHeading ?? "Options:" + ); + optionGroups.forEach((options, group) => { + const optionList = options.map((option) => { + return callFormatItem( + helper.styleOptionTerm(helper.optionTerm(option)), + helper.styleOptionDescription(helper.optionDescription(option)) + ); + }); + output = output.concat(this.formatItemList(group, optionList, helper)); + }); + if (helper.showGlobalOptions) { + const globalOptionList = helper.visibleGlobalOptions(cmd).map((option) => { + return callFormatItem( + helper.styleOptionTerm(helper.optionTerm(option)), + helper.styleOptionDescription(helper.optionDescription(option)) + ); + }); + output = output.concat( + this.formatItemList("Global Options:", globalOptionList, helper) + ); + } + const commandGroups = this.groupItems( + cmd.commands, + helper.visibleCommands(cmd), + (sub) => sub.helpGroup() || "Commands:" + ); + commandGroups.forEach((commands, group) => { + const commandList = commands.map((sub) => { + return callFormatItem( + helper.styleSubcommandTerm(helper.subcommandTerm(sub)), + helper.styleSubcommandDescription(helper.subcommandDescription(sub)) + ); + }); + output = output.concat(this.formatItemList(group, commandList, helper)); + }); + return output.join("\n"); + } + /** + * Return display width of string, ignoring ANSI escape sequences. Used in padding and wrapping calculations. + * + * @param {string} str + * @returns {number} + */ + displayWidth(str) { + return stripColor(str).length; + } + /** + * Style the title for displaying in the help. Called with 'Usage:', 'Options:', etc. + * + * @param {string} str + * @returns {string} + */ + styleTitle(str) { + return str; + } + styleUsage(str) { + return str.split(" ").map((word) => { + if (word === "[options]") return this.styleOptionText(word); + if (word === "[command]") return this.styleSubcommandText(word); + if (word[0] === "[" || word[0] === "<") + return this.styleArgumentText(word); + return this.styleCommandText(word); + }).join(" "); + } + styleCommandDescription(str) { + return this.styleDescriptionText(str); + } + styleOptionDescription(str) { + return this.styleDescriptionText(str); + } + styleSubcommandDescription(str) { + return this.styleDescriptionText(str); + } + styleArgumentDescription(str) { + return this.styleDescriptionText(str); + } + styleDescriptionText(str) { + return str; + } + styleOptionTerm(str) { + return this.styleOptionText(str); + } + styleSubcommandTerm(str) { + return str.split(" ").map((word) => { + if (word === "[options]") return this.styleOptionText(word); + if (word[0] === "[" || word[0] === "<") + return this.styleArgumentText(word); + return this.styleSubcommandText(word); + }).join(" "); + } + styleArgumentTerm(str) { + return this.styleArgumentText(str); + } + styleOptionText(str) { + return str; + } + styleArgumentText(str) { + return str; + } + styleSubcommandText(str) { + return str; + } + styleCommandText(str) { + return str; + } + /** + * Calculate the pad width from the maximum term length. + * + * @param {Command} cmd + * @param {Help} helper + * @returns {number} + */ + padWidth(cmd, helper) { + return Math.max( + helper.longestOptionTermLength(cmd, helper), + helper.longestGlobalOptionTermLength(cmd, helper), + helper.longestSubcommandTermLength(cmd, helper), + helper.longestArgumentTermLength(cmd, helper) + ); + } + /** + * Detect manually wrapped and indented strings by checking for line break followed by whitespace. + * + * @param {string} str + * @returns {boolean} + */ + preformatted(str) { + return /\n[^\S\r\n]/.test(str); + } + /** + * Format the "item", which consists of a term and description. Pad the term and wrap the description, indenting the following lines. + * + * So "TTT", 5, "DDD DDDD DD DDD" might be formatted for this.helpWidth=17 like so: + * TTT DDD DDDD + * DD DDD + * + * @param {string} term + * @param {number} termWidth + * @param {string} description + * @param {Help} helper + * @returns {string} + */ + formatItem(term, termWidth, description, helper) { + const itemIndent = 2; + const itemIndentStr = " ".repeat(itemIndent); + if (!description) return itemIndentStr + term; + const paddedTerm = term.padEnd( + termWidth + term.length - helper.displayWidth(term) + ); + const spacerWidth = 2; + const helpWidth = this.helpWidth ?? 80; + const remainingWidth = helpWidth - termWidth - spacerWidth - itemIndent; + let formattedDescription; + if (remainingWidth < this.minWidthToWrap || helper.preformatted(description)) { + formattedDescription = description; + } else { + const wrappedDescription = helper.boxWrap(description, remainingWidth); + formattedDescription = wrappedDescription.replace( + /\n/g, + "\n" + " ".repeat(termWidth + spacerWidth) + ); + } + return itemIndentStr + paddedTerm + " ".repeat(spacerWidth) + formattedDescription.replace(/\n/g, ` +${itemIndentStr}`); + } + /** + * Wrap a string at whitespace, preserving existing line breaks. + * Wrapping is skipped if the width is less than `minWidthToWrap`. + * + * @param {string} str + * @param {number} width + * @returns {string} + */ + boxWrap(str, width) { + if (width < this.minWidthToWrap) return str; + const rawLines = str.split(/\r\n|\n/); + const chunkPattern = /[\s]*[^\s]+/g; + const wrappedLines = []; + rawLines.forEach((line) => { + const chunks = line.match(chunkPattern); + if (chunks === null) { + wrappedLines.push(""); + return; + } + let sumChunks = [chunks.shift()]; + let sumWidth = this.displayWidth(sumChunks[0]); + chunks.forEach((chunk) => { + const visibleWidth = this.displayWidth(chunk); + if (sumWidth + visibleWidth <= width) { + sumChunks.push(chunk); + sumWidth += visibleWidth; + return; + } + wrappedLines.push(sumChunks.join("")); + const nextChunk = chunk.trimStart(); + sumChunks = [nextChunk]; + sumWidth = this.displayWidth(nextChunk); + }); + wrappedLines.push(sumChunks.join("")); + }); + return wrappedLines.join("\n"); + } + }; + function stripColor(str) { + const sgrPattern = /\x1b\[\d*(;\d*)*m/g; + return str.replace(sgrPattern, ""); + } + exports2.Help = Help; + exports2.stripColor = stripColor; + } +}); + +// node_modules/commander/lib/option.js +var require_option = __commonJS({ + "node_modules/commander/lib/option.js"(exports2) { + var { InvalidArgumentError } = require_error(); + var Option = class { + /** + * Initialize a new `Option` with the given `flags` and `description`. + * + * @param {string} flags + * @param {string} [description] + */ + constructor(flags2, description) { + this.flags = flags2; + this.description = description || ""; + this.required = flags2.includes("<"); + this.optional = flags2.includes("["); + this.variadic = /\w\.\.\.[>\]]$/.test(flags2); + this.mandatory = false; + const optionFlags = splitOptionFlags(flags2); + this.short = optionFlags.shortFlag; + this.long = optionFlags.longFlag; + this.negate = false; + if (this.long) { + this.negate = this.long.startsWith("--no-"); + } + this.defaultValue = void 0; + this.defaultValueDescription = void 0; + this.presetArg = void 0; + this.envVar = void 0; + this.parseArg = void 0; + this.hidden = false; + this.argChoices = void 0; + this.conflictsWith = []; + this.implied = void 0; + this.helpGroupHeading = void 0; + } + /** + * Set the default value, and optionally supply the description to be displayed in the help. + * + * @param {*} value + * @param {string} [description] + * @return {Option} + */ + default(value, description) { + this.defaultValue = value; + this.defaultValueDescription = description; + return this; + } + /** + * Preset to use when option used without option-argument, especially optional but also boolean and negated. + * The custom processing (parseArg) is called. + * + * @example + * new Option('--color').default('GREYSCALE').preset('RGB'); + * new Option('--donate [amount]').preset('20').argParser(parseFloat); + * + * @param {*} arg + * @return {Option} + */ + preset(arg) { + this.presetArg = arg; + return this; + } + /** + * Add option name(s) that conflict with this option. + * An error will be displayed if conflicting options are found during parsing. + * + * @example + * new Option('--rgb').conflicts('cmyk'); + * new Option('--js').conflicts(['ts', 'jsx']); + * + * @param {(string | string[])} names + * @return {Option} + */ + conflicts(names) { + this.conflictsWith = this.conflictsWith.concat(names); + return this; + } + /** + * Specify implied option values for when this option is set and the implied options are not. + * + * The custom processing (parseArg) is not called on the implied values. + * + * @example + * program + * .addOption(new Option('--log', 'write logging information to file')) + * .addOption(new Option('--trace', 'log extra details').implies({ log: 'trace.txt' })); + * + * @param {object} impliedOptionValues + * @return {Option} + */ + implies(impliedOptionValues) { + let newImplied = impliedOptionValues; + if (typeof impliedOptionValues === "string") { + newImplied = { [impliedOptionValues]: true }; + } + this.implied = Object.assign(this.implied || {}, newImplied); + return this; + } + /** + * Set environment variable to check for option value. + * + * An environment variable is only used if when processed the current option value is + * undefined, or the source of the current value is 'default' or 'config' or 'env'. + * + * @param {string} name + * @return {Option} + */ + env(name2) { + this.envVar = name2; + return this; + } + /** + * Set the custom handler for processing CLI option arguments into option values. + * + * @param {Function} [fn] + * @return {Option} + */ + argParser(fn) { + this.parseArg = fn; + return this; + } + /** + * Whether the option is mandatory and must have a value after parsing. + * + * @param {boolean} [mandatory=true] + * @return {Option} + */ + makeOptionMandatory(mandatory = true) { + this.mandatory = !!mandatory; + return this; + } + /** + * Hide option in help. + * + * @param {boolean} [hide=true] + * @return {Option} + */ + hideHelp(hide = true) { + this.hidden = !!hide; + return this; + } + /** + * @package + */ + _concatValue(value, previous) { + if (previous === this.defaultValue || !Array.isArray(previous)) { + return [value]; + } + return previous.concat(value); + } + /** + * Only allow option value to be one of choices. + * + * @param {string[]} values + * @return {Option} + */ + choices(values) { + this.argChoices = values.slice(); + this.parseArg = (arg, previous) => { + if (!this.argChoices.includes(arg)) { + throw new InvalidArgumentError( + `Allowed choices are ${this.argChoices.join(", ")}.` + ); + } + if (this.variadic) { + return this._concatValue(arg, previous); + } + return arg; + }; + return this; + } + /** + * Return option name. + * + * @return {string} + */ + name() { + if (this.long) { + return this.long.replace(/^--/, ""); + } + return this.short.replace(/^-/, ""); + } + /** + * Return option name, in a camelcase format that can be used + * as an object attribute key. + * + * @return {string} + */ + attributeName() { + if (this.negate) { + return camelcase(this.name().replace(/^no-/, "")); + } + return camelcase(this.name()); + } + /** + * Set the help group heading. + * + * @param {string} heading + * @return {Option} + */ + helpGroup(heading) { + this.helpGroupHeading = heading; + return this; + } + /** + * Check if `arg` matches the short or long flag. + * + * @param {string} arg + * @return {boolean} + * @package + */ + is(arg) { + return this.short === arg || this.long === arg; + } + /** + * Return whether a boolean option. + * + * Options are one of boolean, negated, required argument, or optional argument. + * + * @return {boolean} + * @package + */ + isBoolean() { + return !this.required && !this.optional && !this.negate; + } + }; + var DualOptions = class { + /** + * @param {Option[]} options + */ + constructor(options) { + this.positiveOptions = /* @__PURE__ */ new Map(); + this.negativeOptions = /* @__PURE__ */ new Map(); + this.dualOptions = /* @__PURE__ */ new Set(); + options.forEach((option) => { + if (option.negate) { + this.negativeOptions.set(option.attributeName(), option); + } else { + this.positiveOptions.set(option.attributeName(), option); + } + }); + this.negativeOptions.forEach((value, key) => { + if (this.positiveOptions.has(key)) { + this.dualOptions.add(key); + } + }); + } + /** + * Did the value come from the option, and not from possible matching dual option? + * + * @param {*} value + * @param {Option} option + * @returns {boolean} + */ + valueFromOption(value, option) { + const optionKey = option.attributeName(); + if (!this.dualOptions.has(optionKey)) return true; + const preset = this.negativeOptions.get(optionKey).presetArg; + const negativeValue = preset !== void 0 ? preset : false; + return option.negate === (negativeValue === value); + } + }; + function camelcase(str) { + return str.split("-").reduce((str2, word) => { + return str2 + word[0].toUpperCase() + word.slice(1); + }); + } + function splitOptionFlags(flags2) { + let shortFlag; + let longFlag; + const shortFlagExp = /^-[^-]$/; + const longFlagExp = /^--[^-]/; + const flagParts = flags2.split(/[ |,]+/).concat("guard"); + if (shortFlagExp.test(flagParts[0])) shortFlag = flagParts.shift(); + if (longFlagExp.test(flagParts[0])) longFlag = flagParts.shift(); + if (!shortFlag && shortFlagExp.test(flagParts[0])) + shortFlag = flagParts.shift(); + if (!shortFlag && longFlagExp.test(flagParts[0])) { + shortFlag = longFlag; + longFlag = flagParts.shift(); + } + if (flagParts[0].startsWith("-")) { + const unsupportedFlag = flagParts[0]; + const baseError = `option creation failed due to '${unsupportedFlag}' in option flags '${flags2}'`; + if (/^-[^-][^-]/.test(unsupportedFlag)) + throw new Error( + `${baseError} +- a short flag is a single dash and a single character + - either use a single dash and a single character (for a short flag) + - or use a double dash for a long option (and can have two, like '--ws, --workspace')` + ); + if (shortFlagExp.test(unsupportedFlag)) + throw new Error(`${baseError} +- too many short flags`); + if (longFlagExp.test(unsupportedFlag)) + throw new Error(`${baseError} +- too many long flags`); + throw new Error(`${baseError} +- unrecognised flag format`); + } + if (shortFlag === void 0 && longFlag === void 0) + throw new Error( + `option creation failed due to no flags found in '${flags2}'.` + ); + return { shortFlag, longFlag }; + } + exports2.Option = Option; + exports2.DualOptions = DualOptions; + } +}); + +// node_modules/commander/lib/suggestSimilar.js +var require_suggestSimilar = __commonJS({ + "node_modules/commander/lib/suggestSimilar.js"(exports2) { + var maxDistance = 3; + function editDistance(a, b) { + if (Math.abs(a.length - b.length) > maxDistance) + return Math.max(a.length, b.length); + const d = []; + for (let i2 = 0; i2 <= a.length; i2++) { + d[i2] = [i2]; + } + for (let j = 0; j <= b.length; j++) { + d[0][j] = j; + } + for (let j = 1; j <= b.length; j++) { + for (let i2 = 1; i2 <= a.length; i2++) { + let cost = 1; + if (a[i2 - 1] === b[j - 1]) { + cost = 0; + } else { + cost = 1; + } + d[i2][j] = Math.min( + d[i2 - 1][j] + 1, + // deletion + d[i2][j - 1] + 1, + // insertion + d[i2 - 1][j - 1] + cost + // substitution + ); + if (i2 > 1 && j > 1 && a[i2 - 1] === b[j - 2] && a[i2 - 2] === b[j - 1]) { + d[i2][j] = Math.min(d[i2][j], d[i2 - 2][j - 2] + 1); + } + } + } + return d[a.length][b.length]; + } + function suggestSimilar(word, candidates) { + if (!candidates || candidates.length === 0) return ""; + candidates = Array.from(new Set(candidates)); + const searchingOptions = word.startsWith("--"); + if (searchingOptions) { + word = word.slice(2); + candidates = candidates.map((candidate) => candidate.slice(2)); + } + let similar = []; + let bestDistance = maxDistance; + const minSimilarity = 0.4; + candidates.forEach((candidate) => { + if (candidate.length <= 1) return; + const distance = editDistance(word, candidate); + const length = Math.max(word.length, candidate.length); + const similarity = (length - distance) / length; + if (similarity > minSimilarity) { + if (distance < bestDistance) { + bestDistance = distance; + similar = [candidate]; + } else if (distance === bestDistance) { + similar.push(candidate); + } + } + }); + similar.sort((a, b) => a.localeCompare(b)); + if (searchingOptions) { + similar = similar.map((candidate) => `--${candidate}`); + } + if (similar.length > 1) { + return ` +(Did you mean one of ${similar.join(", ")}?)`; + } + if (similar.length === 1) { + return ` +(Did you mean ${similar[0]}?)`; + } + return ""; + } + exports2.suggestSimilar = suggestSimilar; + } +}); + +// node_modules/commander/lib/command.js +var require_command = __commonJS({ + "node_modules/commander/lib/command.js"(exports2) { + var EventEmitter = require("node:events").EventEmitter; + var childProcess = require("node:child_process"); + var path5 = require("node:path"); + var fs3 = require("node:fs"); + var process2 = require("node:process"); + var { Argument, humanReadableArgName } = require_argument(); + var { CommanderError } = require_error(); + var { Help, stripColor } = require_help(); + var { Option, DualOptions } = require_option(); + var { suggestSimilar } = require_suggestSimilar(); + var Command = class _Command extends EventEmitter { + /** + * Initialize a new `Command`. + * + * @param {string} [name] + */ + constructor(name2) { + super(); + this.commands = []; + this.options = []; + this.parent = null; + this._allowUnknownOption = false; + this._allowExcessArguments = false; + this.registeredArguments = []; + this._args = this.registeredArguments; + this.args = []; + this.rawArgs = []; + this.processedArgs = []; + this._scriptPath = null; + this._name = name2 || ""; + this._optionValues = {}; + this._optionValueSources = {}; + this._storeOptionsAsProperties = false; + this._actionHandler = null; + this._executableHandler = false; + this._executableFile = null; + this._executableDir = null; + this._defaultCommandName = null; + this._exitCallback = null; + this._aliases = []; + this._combineFlagAndOptionalValue = true; + this._description = ""; + this._summary = ""; + this._argsDescription = void 0; + this._enablePositionalOptions = false; + this._passThroughOptions = false; + this._lifeCycleHooks = {}; + this._showHelpAfterError = false; + this._showSuggestionAfterError = true; + this._savedState = null; + this._outputConfiguration = { + writeOut: (str) => process2.stdout.write(str), + writeErr: (str) => process2.stderr.write(str), + outputError: (str, write) => write(str), + getOutHelpWidth: () => process2.stdout.isTTY ? process2.stdout.columns : void 0, + getErrHelpWidth: () => process2.stderr.isTTY ? process2.stderr.columns : void 0, + getOutHasColors: () => useColor() ?? (process2.stdout.isTTY && process2.stdout.hasColors?.()), + getErrHasColors: () => useColor() ?? (process2.stderr.isTTY && process2.stderr.hasColors?.()), + stripColor: (str) => stripColor(str) + }; + this._hidden = false; + this._helpOption = void 0; + this._addImplicitHelpCommand = void 0; + this._helpCommand = void 0; + this._helpConfiguration = {}; + this._helpGroupHeading = void 0; + this._defaultCommandGroup = void 0; + this._defaultOptionGroup = void 0; + } + /** + * Copy settings that are useful to have in common across root command and subcommands. + * + * (Used internally when adding a command using `.command()` so subcommands inherit parent settings.) + * + * @param {Command} sourceCommand + * @return {Command} `this` command for chaining + */ + copyInheritedSettings(sourceCommand) { + this._outputConfiguration = sourceCommand._outputConfiguration; + this._helpOption = sourceCommand._helpOption; + this._helpCommand = sourceCommand._helpCommand; + this._helpConfiguration = sourceCommand._helpConfiguration; + this._exitCallback = sourceCommand._exitCallback; + this._storeOptionsAsProperties = sourceCommand._storeOptionsAsProperties; + this._combineFlagAndOptionalValue = sourceCommand._combineFlagAndOptionalValue; + this._allowExcessArguments = sourceCommand._allowExcessArguments; + this._enablePositionalOptions = sourceCommand._enablePositionalOptions; + this._showHelpAfterError = sourceCommand._showHelpAfterError; + this._showSuggestionAfterError = sourceCommand._showSuggestionAfterError; + return this; + } + /** + * @returns {Command[]} + * @private + */ + _getCommandAndAncestors() { + const result = []; + for (let command = this; command; command = command.parent) { + result.push(command); + } + return result; + } + /** + * Define a command. + * + * There are two styles of command: pay attention to where to put the description. + * + * @example + * // Command implemented using action handler (description is supplied separately to `.command`) + * program + * .command('clone [destination]') + * .description('clone a repository into a newly created directory') + * .action((source, destination) => { + * console.log('clone command called'); + * }); + * + * // Command implemented using separate executable file (description is second parameter to `.command`) + * program + * .command('start ', 'start named service') + * .command('stop [service]', 'stop named service, or all if no name supplied'); + * + * @param {string} nameAndArgs - command name and arguments, args are `` or `[optional]` and last may also be `variadic...` + * @param {(object | string)} [actionOptsOrExecDesc] - configuration options (for action), or description (for executable) + * @param {object} [execOpts] - configuration options (for executable) + * @return {Command} returns new command for action handler, or `this` for executable command + */ + command(nameAndArgs, actionOptsOrExecDesc, execOpts) { + let desc = actionOptsOrExecDesc; + let opts = execOpts; + if (typeof desc === "object" && desc !== null) { + opts = desc; + desc = null; + } + opts = opts || {}; + const [, name2, args2] = nameAndArgs.match(/([^ ]+) *(.*)/); + const cmd = this.createCommand(name2); + if (desc) { + cmd.description(desc); + cmd._executableHandler = true; + } + if (opts.isDefault) this._defaultCommandName = cmd._name; + cmd._hidden = !!(opts.noHelp || opts.hidden); + cmd._executableFile = opts.executableFile || null; + if (args2) cmd.arguments(args2); + this._registerCommand(cmd); + cmd.parent = this; + cmd.copyInheritedSettings(this); + if (desc) return this; + return cmd; + } + /** + * Factory routine to create a new unattached command. + * + * See .command() for creating an attached subcommand, which uses this routine to + * create the command. You can override createCommand to customise subcommands. + * + * @param {string} [name] + * @return {Command} new command + */ + createCommand(name2) { + return new _Command(name2); + } + /** + * You can customise the help with a subclass of Help by overriding createHelp, + * or by overriding Help properties using configureHelp(). + * + * @return {Help} + */ + createHelp() { + return Object.assign(new Help(), this.configureHelp()); + } + /** + * You can customise the help by overriding Help properties using configureHelp(), + * or with a subclass of Help by overriding createHelp(). + * + * @param {object} [configuration] - configuration options + * @return {(Command | object)} `this` command for chaining, or stored configuration + */ + configureHelp(configuration) { + if (configuration === void 0) return this._helpConfiguration; + this._helpConfiguration = configuration; + return this; + } + /** + * The default output goes to stdout and stderr. You can customise this for special + * applications. You can also customise the display of errors by overriding outputError. + * + * The configuration properties are all functions: + * + * // change how output being written, defaults to stdout and stderr + * writeOut(str) + * writeErr(str) + * // change how output being written for errors, defaults to writeErr + * outputError(str, write) // used for displaying errors and not used for displaying help + * // specify width for wrapping help + * getOutHelpWidth() + * getErrHelpWidth() + * // color support, currently only used with Help + * getOutHasColors() + * getErrHasColors() + * stripColor() // used to remove ANSI escape codes if output does not have colors + * + * @param {object} [configuration] - configuration options + * @return {(Command | object)} `this` command for chaining, or stored configuration + */ + configureOutput(configuration) { + if (configuration === void 0) return this._outputConfiguration; + this._outputConfiguration = Object.assign( + {}, + this._outputConfiguration, + configuration + ); + return this; + } + /** + * Display the help or a custom message after an error occurs. + * + * @param {(boolean|string)} [displayHelp] + * @return {Command} `this` command for chaining + */ + showHelpAfterError(displayHelp = true) { + if (typeof displayHelp !== "string") displayHelp = !!displayHelp; + this._showHelpAfterError = displayHelp; + return this; + } + /** + * Display suggestion of similar commands for unknown commands, or options for unknown options. + * + * @param {boolean} [displaySuggestion] + * @return {Command} `this` command for chaining + */ + showSuggestionAfterError(displaySuggestion = true) { + this._showSuggestionAfterError = !!displaySuggestion; + return this; + } + /** + * Add a prepared subcommand. + * + * See .command() for creating an attached subcommand which inherits settings from its parent. + * + * @param {Command} cmd - new subcommand + * @param {object} [opts] - configuration options + * @return {Command} `this` command for chaining + */ + addCommand(cmd, opts) { + if (!cmd._name) { + throw new Error(`Command passed to .addCommand() must have a name +- specify the name in Command constructor or using .name()`); + } + opts = opts || {}; + if (opts.isDefault) this._defaultCommandName = cmd._name; + if (opts.noHelp || opts.hidden) cmd._hidden = true; + this._registerCommand(cmd); + cmd.parent = this; + cmd._checkForBrokenPassThrough(); + return this; + } + /** + * Factory routine to create a new unattached argument. + * + * See .argument() for creating an attached argument, which uses this routine to + * create the argument. You can override createArgument to return a custom argument. + * + * @param {string} name + * @param {string} [description] + * @return {Argument} new argument + */ + createArgument(name2, description) { + return new Argument(name2, description); + } + /** + * Define argument syntax for command. + * + * The default is that the argument is required, and you can explicitly + * indicate this with <> around the name. Put [] around the name for an optional argument. + * + * @example + * program.argument(''); + * program.argument('[output-file]'); + * + * @param {string} name + * @param {string} [description] + * @param {(Function|*)} [parseArg] - custom argument processing function or default value + * @param {*} [defaultValue] + * @return {Command} `this` command for chaining + */ + argument(name2, description, parseArg, defaultValue) { + const argument = this.createArgument(name2, description); + if (typeof parseArg === "function") { + argument.default(defaultValue).argParser(parseArg); + } else { + argument.default(parseArg); + } + this.addArgument(argument); + return this; + } + /** + * Define argument syntax for command, adding multiple at once (without descriptions). + * + * See also .argument(). + * + * @example + * program.arguments(' [env]'); + * + * @param {string} names + * @return {Command} `this` command for chaining + */ + arguments(names) { + names.trim().split(/ +/).forEach((detail) => { + this.argument(detail); + }); + return this; + } + /** + * Define argument syntax for command, adding a prepared argument. + * + * @param {Argument} argument + * @return {Command} `this` command for chaining + */ + addArgument(argument) { + const previousArgument = this.registeredArguments.slice(-1)[0]; + if (previousArgument && previousArgument.variadic) { + throw new Error( + `only the last argument can be variadic '${previousArgument.name()}'` + ); + } + if (argument.required && argument.defaultValue !== void 0 && argument.parseArg === void 0) { + throw new Error( + `a default value for a required argument is never used: '${argument.name()}'` + ); + } + this.registeredArguments.push(argument); + return this; + } + /** + * Customise or override default help command. By default a help command is automatically added if your command has subcommands. + * + * @example + * program.helpCommand('help [cmd]'); + * program.helpCommand('help [cmd]', 'show help'); + * program.helpCommand(false); // suppress default help command + * program.helpCommand(true); // add help command even if no subcommands + * + * @param {string|boolean} enableOrNameAndArgs - enable with custom name and/or arguments, or boolean to override whether added + * @param {string} [description] - custom description + * @return {Command} `this` command for chaining + */ + helpCommand(enableOrNameAndArgs, description) { + if (typeof enableOrNameAndArgs === "boolean") { + this._addImplicitHelpCommand = enableOrNameAndArgs; + if (enableOrNameAndArgs && this._defaultCommandGroup) { + this._initCommandGroup(this._getHelpCommand()); + } + return this; + } + const nameAndArgs = enableOrNameAndArgs ?? "help [command]"; + const [, helpName, helpArgs] = nameAndArgs.match(/([^ ]+) *(.*)/); + const helpDescription = description ?? "display help for command"; + const helpCommand = this.createCommand(helpName); + helpCommand.helpOption(false); + if (helpArgs) helpCommand.arguments(helpArgs); + if (helpDescription) helpCommand.description(helpDescription); + this._addImplicitHelpCommand = true; + this._helpCommand = helpCommand; + if (enableOrNameAndArgs || description) this._initCommandGroup(helpCommand); + return this; + } + /** + * Add prepared custom help command. + * + * @param {(Command|string|boolean)} helpCommand - custom help command, or deprecated enableOrNameAndArgs as for `.helpCommand()` + * @param {string} [deprecatedDescription] - deprecated custom description used with custom name only + * @return {Command} `this` command for chaining + */ + addHelpCommand(helpCommand, deprecatedDescription) { + if (typeof helpCommand !== "object") { + this.helpCommand(helpCommand, deprecatedDescription); + return this; + } + this._addImplicitHelpCommand = true; + this._helpCommand = helpCommand; + this._initCommandGroup(helpCommand); + return this; + } + /** + * Lazy create help command. + * + * @return {(Command|null)} + * @package + */ + _getHelpCommand() { + const hasImplicitHelpCommand = this._addImplicitHelpCommand ?? (this.commands.length && !this._actionHandler && !this._findCommand("help")); + if (hasImplicitHelpCommand) { + if (this._helpCommand === void 0) { + this.helpCommand(void 0, void 0); + } + return this._helpCommand; + } + return null; + } + /** + * Add hook for life cycle event. + * + * @param {string} event + * @param {Function} listener + * @return {Command} `this` command for chaining + */ + hook(event, listener) { + const allowedValues = ["preSubcommand", "preAction", "postAction"]; + if (!allowedValues.includes(event)) { + throw new Error(`Unexpected value for event passed to hook : '${event}'. +Expecting one of '${allowedValues.join("', '")}'`); + } + if (this._lifeCycleHooks[event]) { + this._lifeCycleHooks[event].push(listener); + } else { + this._lifeCycleHooks[event] = [listener]; + } + return this; + } + /** + * Register callback to use as replacement for calling process.exit. + * + * @param {Function} [fn] optional callback which will be passed a CommanderError, defaults to throwing + * @return {Command} `this` command for chaining + */ + exitOverride(fn) { + if (fn) { + this._exitCallback = fn; + } else { + this._exitCallback = (err2) => { + if (err2.code !== "commander.executeSubCommandAsync") { + throw err2; + } else { + } + }; + } + return this; + } + /** + * Call process.exit, and _exitCallback if defined. + * + * @param {number} exitCode exit code for using with process.exit + * @param {string} code an id string representing the error + * @param {string} message human-readable description of the error + * @return never + * @private + */ + _exit(exitCode, code, message) { + if (this._exitCallback) { + this._exitCallback(new CommanderError(exitCode, code, message)); + } + process2.exit(exitCode); + } + /** + * Register callback `fn` for the command. + * + * @example + * program + * .command('serve') + * .description('start service') + * .action(function() { + * // do work here + * }); + * + * @param {Function} fn + * @return {Command} `this` command for chaining + */ + action(fn) { + const listener = (args2) => { + const expectedArgsCount = this.registeredArguments.length; + const actionArgs = args2.slice(0, expectedArgsCount); + if (this._storeOptionsAsProperties) { + actionArgs[expectedArgsCount] = this; + } else { + actionArgs[expectedArgsCount] = this.opts(); + } + actionArgs.push(this); + return fn.apply(this, actionArgs); + }; + this._actionHandler = listener; + return this; + } + /** + * Factory routine to create a new unattached option. + * + * See .option() for creating an attached option, which uses this routine to + * create the option. You can override createOption to return a custom option. + * + * @param {string} flags + * @param {string} [description] + * @return {Option} new option + */ + createOption(flags2, description) { + return new Option(flags2, description); + } + /** + * Wrap parseArgs to catch 'commander.invalidArgument'. + * + * @param {(Option | Argument)} target + * @param {string} value + * @param {*} previous + * @param {string} invalidArgumentMessage + * @private + */ + _callParseArg(target, value, previous, invalidArgumentMessage) { + try { + return target.parseArg(value, previous); + } catch (err2) { + if (err2.code === "commander.invalidArgument") { + const message = `${invalidArgumentMessage} ${err2.message}`; + this.error(message, { exitCode: err2.exitCode, code: err2.code }); + } + throw err2; + } + } + /** + * Check for option flag conflicts. + * Register option if no conflicts found, or throw on conflict. + * + * @param {Option} option + * @private + */ + _registerOption(option) { + const matchingOption = option.short && this._findOption(option.short) || option.long && this._findOption(option.long); + if (matchingOption) { + const matchingFlag = option.long && this._findOption(option.long) ? option.long : option.short; + throw new Error(`Cannot add option '${option.flags}'${this._name && ` to command '${this._name}'`} due to conflicting flag '${matchingFlag}' +- already used by option '${matchingOption.flags}'`); + } + this._initOptionGroup(option); + this.options.push(option); + } + /** + * Check for command name and alias conflicts with existing commands. + * Register command if no conflicts found, or throw on conflict. + * + * @param {Command} command + * @private + */ + _registerCommand(command) { + const knownBy = (cmd) => { + return [cmd.name()].concat(cmd.aliases()); + }; + const alreadyUsed = knownBy(command).find( + (name2) => this._findCommand(name2) + ); + if (alreadyUsed) { + const existingCmd = knownBy(this._findCommand(alreadyUsed)).join("|"); + const newCmd = knownBy(command).join("|"); + throw new Error( + `cannot add command '${newCmd}' as already have command '${existingCmd}'` + ); + } + this._initCommandGroup(command); + this.commands.push(command); + } + /** + * Add an option. + * + * @param {Option} option + * @return {Command} `this` command for chaining + */ + addOption(option) { + this._registerOption(option); + const oname = option.name(); + const name2 = option.attributeName(); + if (option.negate) { + const positiveLongFlag = option.long.replace(/^--no-/, "--"); + if (!this._findOption(positiveLongFlag)) { + this.setOptionValueWithSource( + name2, + option.defaultValue === void 0 ? true : option.defaultValue, + "default" + ); + } + } else if (option.defaultValue !== void 0) { + this.setOptionValueWithSource(name2, option.defaultValue, "default"); + } + const handleOptionValue = (val, invalidValueMessage, valueSource) => { + if (val == null && option.presetArg !== void 0) { + val = option.presetArg; + } + const oldValue = this.getOptionValue(name2); + if (val !== null && option.parseArg) { + val = this._callParseArg(option, val, oldValue, invalidValueMessage); + } else if (val !== null && option.variadic) { + val = option._concatValue(val, oldValue); + } + if (val == null) { + if (option.negate) { + val = false; + } else if (option.isBoolean() || option.optional) { + val = true; + } else { + val = ""; + } + } + this.setOptionValueWithSource(name2, val, valueSource); + }; + this.on("option:" + oname, (val) => { + const invalidValueMessage = `error: option '${option.flags}' argument '${val}' is invalid.`; + handleOptionValue(val, invalidValueMessage, "cli"); + }); + if (option.envVar) { + this.on("optionEnv:" + oname, (val) => { + const invalidValueMessage = `error: option '${option.flags}' value '${val}' from env '${option.envVar}' is invalid.`; + handleOptionValue(val, invalidValueMessage, "env"); + }); + } + return this; + } + /** + * Internal implementation shared by .option() and .requiredOption() + * + * @return {Command} `this` command for chaining + * @private + */ + _optionEx(config, flags2, description, fn, defaultValue) { + if (typeof flags2 === "object" && flags2 instanceof Option) { + throw new Error( + "To add an Option object use addOption() instead of option() or requiredOption()" + ); + } + const option = this.createOption(flags2, description); + option.makeOptionMandatory(!!config.mandatory); + if (typeof fn === "function") { + option.default(defaultValue).argParser(fn); + } else if (fn instanceof RegExp) { + const regex = fn; + fn = (val, def) => { + const m = regex.exec(val); + return m ? m[0] : def; + }; + option.default(defaultValue).argParser(fn); + } else { + option.default(fn); + } + return this.addOption(option); + } + /** + * Define option with `flags`, `description`, and optional argument parsing function or `defaultValue` or both. + * + * The `flags` string contains the short and/or long flags, separated by comma, a pipe or space. A required + * option-argument is indicated by `<>` and an optional option-argument by `[]`. + * + * See the README for more details, and see also addOption() and requiredOption(). + * + * @example + * program + * .option('-p, --pepper', 'add pepper') + * .option('--pt, --pizza-type ', 'type of pizza') // required option-argument + * .option('-c, --cheese [CHEESE]', 'add extra cheese', 'mozzarella') // optional option-argument with default + * .option('-t, --tip ', 'add tip to purchase cost', parseFloat) // custom parse function + * + * @param {string} flags + * @param {string} [description] + * @param {(Function|*)} [parseArg] - custom option processing function or default value + * @param {*} [defaultValue] + * @return {Command} `this` command for chaining + */ + option(flags2, description, parseArg, defaultValue) { + return this._optionEx({}, flags2, description, parseArg, defaultValue); + } + /** + * Add a required option which must have a value after parsing. This usually means + * the option must be specified on the command line. (Otherwise the same as .option().) + * + * The `flags` string contains the short and/or long flags, separated by comma, a pipe or space. + * + * @param {string} flags + * @param {string} [description] + * @param {(Function|*)} [parseArg] - custom option processing function or default value + * @param {*} [defaultValue] + * @return {Command} `this` command for chaining + */ + requiredOption(flags2, description, parseArg, defaultValue) { + return this._optionEx( + { mandatory: true }, + flags2, + description, + parseArg, + defaultValue + ); + } + /** + * Alter parsing of short flags with optional values. + * + * @example + * // for `.option('-f,--flag [value]'): + * program.combineFlagAndOptionalValue(true); // `-f80` is treated like `--flag=80`, this is the default behaviour + * program.combineFlagAndOptionalValue(false) // `-fb` is treated like `-f -b` + * + * @param {boolean} [combine] - if `true` or omitted, an optional value can be specified directly after the flag. + * @return {Command} `this` command for chaining + */ + combineFlagAndOptionalValue(combine = true) { + this._combineFlagAndOptionalValue = !!combine; + return this; + } + /** + * Allow unknown options on the command line. + * + * @param {boolean} [allowUnknown] - if `true` or omitted, no error will be thrown for unknown options. + * @return {Command} `this` command for chaining + */ + allowUnknownOption(allowUnknown = true) { + this._allowUnknownOption = !!allowUnknown; + return this; + } + /** + * Allow excess command-arguments on the command line. Pass false to make excess arguments an error. + * + * @param {boolean} [allowExcess] - if `true` or omitted, no error will be thrown for excess arguments. + * @return {Command} `this` command for chaining + */ + allowExcessArguments(allowExcess = true) { + this._allowExcessArguments = !!allowExcess; + return this; + } + /** + * Enable positional options. Positional means global options are specified before subcommands which lets + * subcommands reuse the same option names, and also enables subcommands to turn on passThroughOptions. + * The default behaviour is non-positional and global options may appear anywhere on the command line. + * + * @param {boolean} [positional] + * @return {Command} `this` command for chaining + */ + enablePositionalOptions(positional = true) { + this._enablePositionalOptions = !!positional; + return this; + } + /** + * Pass through options that come after command-arguments rather than treat them as command-options, + * so actual command-options come before command-arguments. Turning this on for a subcommand requires + * positional options to have been enabled on the program (parent commands). + * The default behaviour is non-positional and options may appear before or after command-arguments. + * + * @param {boolean} [passThrough] for unknown options. + * @return {Command} `this` command for chaining + */ + passThroughOptions(passThrough = true) { + this._passThroughOptions = !!passThrough; + this._checkForBrokenPassThrough(); + return this; + } + /** + * @private + */ + _checkForBrokenPassThrough() { + if (this.parent && this._passThroughOptions && !this.parent._enablePositionalOptions) { + throw new Error( + `passThroughOptions cannot be used for '${this._name}' without turning on enablePositionalOptions for parent command(s)` + ); + } + } + /** + * Whether to store option values as properties on command object, + * or store separately (specify false). In both cases the option values can be accessed using .opts(). + * + * @param {boolean} [storeAsProperties=true] + * @return {Command} `this` command for chaining + */ + storeOptionsAsProperties(storeAsProperties = true) { + if (this.options.length) { + throw new Error("call .storeOptionsAsProperties() before adding options"); + } + if (Object.keys(this._optionValues).length) { + throw new Error( + "call .storeOptionsAsProperties() before setting option values" + ); + } + this._storeOptionsAsProperties = !!storeAsProperties; + return this; + } + /** + * Retrieve option value. + * + * @param {string} key + * @return {object} value + */ + getOptionValue(key) { + if (this._storeOptionsAsProperties) { + return this[key]; + } + return this._optionValues[key]; + } + /** + * Store option value. + * + * @param {string} key + * @param {object} value + * @return {Command} `this` command for chaining + */ + setOptionValue(key, value) { + return this.setOptionValueWithSource(key, value, void 0); + } + /** + * Store option value and where the value came from. + * + * @param {string} key + * @param {object} value + * @param {string} source - expected values are default/config/env/cli/implied + * @return {Command} `this` command for chaining + */ + setOptionValueWithSource(key, value, source) { + if (this._storeOptionsAsProperties) { + this[key] = value; + } else { + this._optionValues[key] = value; + } + this._optionValueSources[key] = source; + return this; + } + /** + * Get source of option value. + * Expected values are default | config | env | cli | implied + * + * @param {string} key + * @return {string} + */ + getOptionValueSource(key) { + return this._optionValueSources[key]; + } + /** + * Get source of option value. See also .optsWithGlobals(). + * Expected values are default | config | env | cli | implied + * + * @param {string} key + * @return {string} + */ + getOptionValueSourceWithGlobals(key) { + let source; + this._getCommandAndAncestors().forEach((cmd) => { + if (cmd.getOptionValueSource(key) !== void 0) { + source = cmd.getOptionValueSource(key); + } + }); + return source; + } + /** + * Get user arguments from implied or explicit arguments. + * Side-effects: set _scriptPath if args included script. Used for default program name, and subcommand searches. + * + * @private + */ + _prepareUserArgs(argv, parseOptions) { + if (argv !== void 0 && !Array.isArray(argv)) { + throw new Error("first parameter to parse must be array or undefined"); + } + parseOptions = parseOptions || {}; + if (argv === void 0 && parseOptions.from === void 0) { + if (process2.versions?.electron) { + parseOptions.from = "electron"; + } + const execArgv = process2.execArgv ?? []; + if (execArgv.includes("-e") || execArgv.includes("--eval") || execArgv.includes("-p") || execArgv.includes("--print")) { + parseOptions.from = "eval"; + } + } + if (argv === void 0) { + argv = process2.argv; + } + this.rawArgs = argv.slice(); + let userArgs; + switch (parseOptions.from) { + case void 0: + case "node": + this._scriptPath = argv[1]; + userArgs = argv.slice(2); + break; + case "electron": + if (process2.defaultApp) { + this._scriptPath = argv[1]; + userArgs = argv.slice(2); + } else { + userArgs = argv.slice(1); + } + break; + case "user": + userArgs = argv.slice(0); + break; + case "eval": + userArgs = argv.slice(1); + break; + default: + throw new Error( + `unexpected parse option { from: '${parseOptions.from}' }` + ); + } + if (!this._name && this._scriptPath) + this.nameFromFilename(this._scriptPath); + this._name = this._name || "program"; + return userArgs; + } + /** + * Parse `argv`, setting options and invoking commands when defined. + * + * Use parseAsync instead of parse if any of your action handlers are async. + * + * Call with no parameters to parse `process.argv`. Detects Electron and special node options like `node --eval`. Easy mode! + * + * Or call with an array of strings to parse, and optionally where the user arguments start by specifying where the arguments are `from`: + * - `'node'`: default, `argv[0]` is the application and `argv[1]` is the script being run, with user arguments after that + * - `'electron'`: `argv[0]` is the application and `argv[1]` varies depending on whether the electron application is packaged + * - `'user'`: just user arguments + * + * @example + * program.parse(); // parse process.argv and auto-detect electron and special node flags + * program.parse(process.argv); // assume argv[0] is app and argv[1] is script + * program.parse(my-args, { from: 'user' }); // just user supplied arguments, nothing special about argv[0] + * + * @param {string[]} [argv] - optional, defaults to process.argv + * @param {object} [parseOptions] - optionally specify style of options with from: node/user/electron + * @param {string} [parseOptions.from] - where the args are from: 'node', 'user', 'electron' + * @return {Command} `this` command for chaining + */ + parse(argv, parseOptions) { + this._prepareForParse(); + const userArgs = this._prepareUserArgs(argv, parseOptions); + this._parseCommand([], userArgs); + return this; + } + /** + * Parse `argv`, setting options and invoking commands when defined. + * + * Call with no parameters to parse `process.argv`. Detects Electron and special node options like `node --eval`. Easy mode! + * + * Or call with an array of strings to parse, and optionally where the user arguments start by specifying where the arguments are `from`: + * - `'node'`: default, `argv[0]` is the application and `argv[1]` is the script being run, with user arguments after that + * - `'electron'`: `argv[0]` is the application and `argv[1]` varies depending on whether the electron application is packaged + * - `'user'`: just user arguments + * + * @example + * await program.parseAsync(); // parse process.argv and auto-detect electron and special node flags + * await program.parseAsync(process.argv); // assume argv[0] is app and argv[1] is script + * await program.parseAsync(my-args, { from: 'user' }); // just user supplied arguments, nothing special about argv[0] + * + * @param {string[]} [argv] + * @param {object} [parseOptions] + * @param {string} parseOptions.from - where the args are from: 'node', 'user', 'electron' + * @return {Promise} + */ + async parseAsync(argv, parseOptions) { + this._prepareForParse(); + const userArgs = this._prepareUserArgs(argv, parseOptions); + await this._parseCommand([], userArgs); + return this; + } + _prepareForParse() { + if (this._savedState === null) { + this.saveStateBeforeParse(); + } else { + this.restoreStateBeforeParse(); + } + } + /** + * Called the first time parse is called to save state and allow a restore before subsequent calls to parse. + * Not usually called directly, but available for subclasses to save their custom state. + * + * This is called in a lazy way. Only commands used in parsing chain will have state saved. + */ + saveStateBeforeParse() { + this._savedState = { + // name is stable if supplied by author, but may be unspecified for root command and deduced during parsing + _name: this._name, + // option values before parse have default values (including false for negated options) + // shallow clones + _optionValues: { ...this._optionValues }, + _optionValueSources: { ...this._optionValueSources } + }; + } + /** + * Restore state before parse for calls after the first. + * Not usually called directly, but available for subclasses to save their custom state. + * + * This is called in a lazy way. Only commands used in parsing chain will have state restored. + */ + restoreStateBeforeParse() { + if (this._storeOptionsAsProperties) + throw new Error(`Can not call parse again when storeOptionsAsProperties is true. +- either make a new Command for each call to parse, or stop storing options as properties`); + this._name = this._savedState._name; + this._scriptPath = null; + this.rawArgs = []; + this._optionValues = { ...this._savedState._optionValues }; + this._optionValueSources = { ...this._savedState._optionValueSources }; + this.args = []; + this.processedArgs = []; + } + /** + * Throw if expected executable is missing. Add lots of help for author. + * + * @param {string} executableFile + * @param {string} executableDir + * @param {string} subcommandName + */ + _checkForMissingExecutable(executableFile, executableDir, subcommandName) { + if (fs3.existsSync(executableFile)) return; + const executableDirMessage = executableDir ? `searched for local subcommand relative to directory '${executableDir}'` : "no directory for search for local subcommand, use .executableDir() to supply a custom directory"; + const executableMissing = `'${executableFile}' does not exist + - if '${subcommandName}' is not meant to be an executable command, remove description parameter from '.command()' and use '.description()' instead + - if the default executable name is not suitable, use the executableFile option to supply a custom name or path + - ${executableDirMessage}`; + throw new Error(executableMissing); + } + /** + * Execute a sub-command executable. + * + * @private + */ + _executeSubCommand(subcommand, args2) { + args2 = args2.slice(); + let launchWithNode = false; + const sourceExt = [".js", ".ts", ".tsx", ".mjs", ".cjs"]; + function findFile(baseDir, baseName) { + const localBin = path5.resolve(baseDir, baseName); + if (fs3.existsSync(localBin)) return localBin; + if (sourceExt.includes(path5.extname(baseName))) return void 0; + const foundExt = sourceExt.find( + (ext) => fs3.existsSync(`${localBin}${ext}`) + ); + if (foundExt) return `${localBin}${foundExt}`; + return void 0; + } + this._checkForMissingMandatoryOptions(); + this._checkForConflictingOptions(); + let executableFile = subcommand._executableFile || `${this._name}-${subcommand._name}`; + let executableDir = this._executableDir || ""; + if (this._scriptPath) { + let resolvedScriptPath; + try { + resolvedScriptPath = fs3.realpathSync(this._scriptPath); + } catch { + resolvedScriptPath = this._scriptPath; + } + executableDir = path5.resolve( + path5.dirname(resolvedScriptPath), + executableDir + ); + } + if (executableDir) { + let localFile = findFile(executableDir, executableFile); + if (!localFile && !subcommand._executableFile && this._scriptPath) { + const legacyName = path5.basename( + this._scriptPath, + path5.extname(this._scriptPath) + ); + if (legacyName !== this._name) { + localFile = findFile( + executableDir, + `${legacyName}-${subcommand._name}` + ); + } + } + executableFile = localFile || executableFile; + } + launchWithNode = sourceExt.includes(path5.extname(executableFile)); + let proc; + if (process2.platform !== "win32") { + if (launchWithNode) { + args2.unshift(executableFile); + args2 = incrementNodeInspectorPort(process2.execArgv).concat(args2); + proc = childProcess.spawn(process2.argv[0], args2, { stdio: "inherit" }); + } else { + proc = childProcess.spawn(executableFile, args2, { stdio: "inherit" }); + } + } else { + this._checkForMissingExecutable( + executableFile, + executableDir, + subcommand._name + ); + args2.unshift(executableFile); + args2 = incrementNodeInspectorPort(process2.execArgv).concat(args2); + proc = childProcess.spawn(process2.execPath, args2, { stdio: "inherit" }); + } + if (!proc.killed) { + const signals = ["SIGUSR1", "SIGUSR2", "SIGTERM", "SIGINT", "SIGHUP"]; + signals.forEach((signal) => { + process2.on(signal, () => { + if (proc.killed === false && proc.exitCode === null) { + proc.kill(signal); + } + }); + }); + } + const exitCallback = this._exitCallback; + proc.on("close", (code) => { + code = code ?? 1; + if (!exitCallback) { + process2.exit(code); + } else { + exitCallback( + new CommanderError( + code, + "commander.executeSubCommandAsync", + "(close)" + ) + ); + } + }); + proc.on("error", (err2) => { + if (err2.code === "ENOENT") { + this._checkForMissingExecutable( + executableFile, + executableDir, + subcommand._name + ); + } else if (err2.code === "EACCES") { + throw new Error(`'${executableFile}' not executable`); + } + if (!exitCallback) { + process2.exit(1); + } else { + const wrappedError = new CommanderError( + 1, + "commander.executeSubCommandAsync", + "(error)" + ); + wrappedError.nestedError = err2; + exitCallback(wrappedError); + } + }); + this.runningCommand = proc; + } + /** + * @private + */ + _dispatchSubcommand(commandName, operands, unknown) { + const subCommand = this._findCommand(commandName); + if (!subCommand) this.help({ error: true }); + subCommand._prepareForParse(); + let promiseChain; + promiseChain = this._chainOrCallSubCommandHook( + promiseChain, + subCommand, + "preSubcommand" + ); + promiseChain = this._chainOrCall(promiseChain, () => { + if (subCommand._executableHandler) { + this._executeSubCommand(subCommand, operands.concat(unknown)); + } else { + return subCommand._parseCommand(operands, unknown); + } + }); + return promiseChain; + } + /** + * Invoke help directly if possible, or dispatch if necessary. + * e.g. help foo + * + * @private + */ + _dispatchHelpCommand(subcommandName) { + if (!subcommandName) { + this.help(); + } + const subCommand = this._findCommand(subcommandName); + if (subCommand && !subCommand._executableHandler) { + subCommand.help(); + } + return this._dispatchSubcommand( + subcommandName, + [], + [this._getHelpOption()?.long ?? this._getHelpOption()?.short ?? "--help"] + ); + } + /** + * Check this.args against expected this.registeredArguments. + * + * @private + */ + _checkNumberOfArguments() { + this.registeredArguments.forEach((arg, i2) => { + if (arg.required && this.args[i2] == null) { + this.missingArgument(arg.name()); + } + }); + if (this.registeredArguments.length > 0 && this.registeredArguments[this.registeredArguments.length - 1].variadic) { + return; + } + if (this.args.length > this.registeredArguments.length) { + this._excessArguments(this.args); + } + } + /** + * Process this.args using this.registeredArguments and save as this.processedArgs! + * + * @private + */ + _processArguments() { + const myParseArg = (argument, value, previous) => { + let parsedValue = value; + if (value !== null && argument.parseArg) { + const invalidValueMessage = `error: command-argument value '${value}' is invalid for argument '${argument.name()}'.`; + parsedValue = this._callParseArg( + argument, + value, + previous, + invalidValueMessage + ); + } + return parsedValue; + }; + this._checkNumberOfArguments(); + const processedArgs = []; + this.registeredArguments.forEach((declaredArg, index2) => { + let value = declaredArg.defaultValue; + if (declaredArg.variadic) { + if (index2 < this.args.length) { + value = this.args.slice(index2); + if (declaredArg.parseArg) { + value = value.reduce((processed, v) => { + return myParseArg(declaredArg, v, processed); + }, declaredArg.defaultValue); + } + } else if (value === void 0) { + value = []; + } + } else if (index2 < this.args.length) { + value = this.args[index2]; + if (declaredArg.parseArg) { + value = myParseArg(declaredArg, value, declaredArg.defaultValue); + } + } + processedArgs[index2] = value; + }); + this.processedArgs = processedArgs; + } + /** + * Once we have a promise we chain, but call synchronously until then. + * + * @param {(Promise|undefined)} promise + * @param {Function} fn + * @return {(Promise|undefined)} + * @private + */ + _chainOrCall(promise, fn) { + if (promise && promise.then && typeof promise.then === "function") { + return promise.then(() => fn()); + } + return fn(); + } + /** + * + * @param {(Promise|undefined)} promise + * @param {string} event + * @return {(Promise|undefined)} + * @private + */ + _chainOrCallHooks(promise, event) { + let result = promise; + const hooks = []; + this._getCommandAndAncestors().reverse().filter((cmd) => cmd._lifeCycleHooks[event] !== void 0).forEach((hookedCommand) => { + hookedCommand._lifeCycleHooks[event].forEach((callback) => { + hooks.push({ hookedCommand, callback }); + }); + }); + if (event === "postAction") { + hooks.reverse(); + } + hooks.forEach((hookDetail) => { + result = this._chainOrCall(result, () => { + return hookDetail.callback(hookDetail.hookedCommand, this); + }); + }); + return result; + } + /** + * + * @param {(Promise|undefined)} promise + * @param {Command} subCommand + * @param {string} event + * @return {(Promise|undefined)} + * @private + */ + _chainOrCallSubCommandHook(promise, subCommand, event) { + let result = promise; + if (this._lifeCycleHooks[event] !== void 0) { + this._lifeCycleHooks[event].forEach((hook) => { + result = this._chainOrCall(result, () => { + return hook(this, subCommand); + }); + }); + } + return result; + } + /** + * Process arguments in context of this command. + * Returns action result, in case it is a promise. + * + * @private + */ + _parseCommand(operands, unknown) { + const parsed = this.parseOptions(unknown); + this._parseOptionsEnv(); + this._parseOptionsImplied(); + operands = operands.concat(parsed.operands); + unknown = parsed.unknown; + this.args = operands.concat(unknown); + if (operands && this._findCommand(operands[0])) { + return this._dispatchSubcommand(operands[0], operands.slice(1), unknown); + } + if (this._getHelpCommand() && operands[0] === this._getHelpCommand().name()) { + return this._dispatchHelpCommand(operands[1]); + } + if (this._defaultCommandName) { + this._outputHelpIfRequested(unknown); + return this._dispatchSubcommand( + this._defaultCommandName, + operands, + unknown + ); + } + if (this.commands.length && this.args.length === 0 && !this._actionHandler && !this._defaultCommandName) { + this.help({ error: true }); + } + this._outputHelpIfRequested(parsed.unknown); + this._checkForMissingMandatoryOptions(); + this._checkForConflictingOptions(); + const checkForUnknownOptions = () => { + if (parsed.unknown.length > 0) { + this.unknownOption(parsed.unknown[0]); + } + }; + const commandEvent = `command:${this.name()}`; + if (this._actionHandler) { + checkForUnknownOptions(); + this._processArguments(); + let promiseChain; + promiseChain = this._chainOrCallHooks(promiseChain, "preAction"); + promiseChain = this._chainOrCall( + promiseChain, + () => this._actionHandler(this.processedArgs) + ); + if (this.parent) { + promiseChain = this._chainOrCall(promiseChain, () => { + this.parent.emit(commandEvent, operands, unknown); + }); + } + promiseChain = this._chainOrCallHooks(promiseChain, "postAction"); + return promiseChain; + } + if (this.parent && this.parent.listenerCount(commandEvent)) { + checkForUnknownOptions(); + this._processArguments(); + this.parent.emit(commandEvent, operands, unknown); + } else if (operands.length) { + if (this._findCommand("*")) { + return this._dispatchSubcommand("*", operands, unknown); + } + if (this.listenerCount("command:*")) { + this.emit("command:*", operands, unknown); + } else if (this.commands.length) { + this.unknownCommand(); + } else { + checkForUnknownOptions(); + this._processArguments(); + } + } else if (this.commands.length) { + checkForUnknownOptions(); + this.help({ error: true }); + } else { + checkForUnknownOptions(); + this._processArguments(); + } + } + /** + * Find matching command. + * + * @private + * @return {Command | undefined} + */ + _findCommand(name2) { + if (!name2) return void 0; + return this.commands.find( + (cmd) => cmd._name === name2 || cmd._aliases.includes(name2) + ); + } + /** + * Return an option matching `arg` if any. + * + * @param {string} arg + * @return {Option} + * @package + */ + _findOption(arg) { + return this.options.find((option) => option.is(arg)); + } + /** + * Display an error message if a mandatory option does not have a value. + * Called after checking for help flags in leaf subcommand. + * + * @private + */ + _checkForMissingMandatoryOptions() { + this._getCommandAndAncestors().forEach((cmd) => { + cmd.options.forEach((anOption) => { + if (anOption.mandatory && cmd.getOptionValue(anOption.attributeName()) === void 0) { + cmd.missingMandatoryOptionValue(anOption); + } + }); + }); + } + /** + * Display an error message if conflicting options are used together in this. + * + * @private + */ + _checkForConflictingLocalOptions() { + const definedNonDefaultOptions = this.options.filter((option) => { + const optionKey = option.attributeName(); + if (this.getOptionValue(optionKey) === void 0) { + return false; + } + return this.getOptionValueSource(optionKey) !== "default"; + }); + const optionsWithConflicting = definedNonDefaultOptions.filter( + (option) => option.conflictsWith.length > 0 + ); + optionsWithConflicting.forEach((option) => { + const conflictingAndDefined = definedNonDefaultOptions.find( + (defined) => option.conflictsWith.includes(defined.attributeName()) + ); + if (conflictingAndDefined) { + this._conflictingOption(option, conflictingAndDefined); + } + }); + } + /** + * Display an error message if conflicting options are used together. + * Called after checking for help flags in leaf subcommand. + * + * @private + */ + _checkForConflictingOptions() { + this._getCommandAndAncestors().forEach((cmd) => { + cmd._checkForConflictingLocalOptions(); + }); + } + /** + * Parse options from `argv` removing known options, + * and return argv split into operands and unknown arguments. + * + * Side effects: modifies command by storing options. Does not reset state if called again. + * + * Examples: + * + * argv => operands, unknown + * --known kkk op => [op], [] + * op --known kkk => [op], [] + * sub --unknown uuu op => [sub], [--unknown uuu op] + * sub -- --unknown uuu op => [sub --unknown uuu op], [] + * + * @param {string[]} argv + * @return {{operands: string[], unknown: string[]}} + */ + parseOptions(argv) { + const operands = []; + const unknown = []; + let dest = operands; + const args2 = argv.slice(); + function maybeOption(arg) { + return arg.length > 1 && arg[0] === "-"; + } + const negativeNumberArg = (arg) => { + if (!/^-\d*\.?\d+(e[+-]?\d+)?$/.test(arg)) return false; + return !this._getCommandAndAncestors().some( + (cmd) => cmd.options.map((opt) => opt.short).some((short) => /^-\d$/.test(short)) + ); + }; + let activeVariadicOption = null; + while (args2.length) { + const arg = args2.shift(); + if (arg === "--") { + if (dest === unknown) dest.push(arg); + dest.push(...args2); + break; + } + if (activeVariadicOption && (!maybeOption(arg) || negativeNumberArg(arg))) { + this.emit(`option:${activeVariadicOption.name()}`, arg); + continue; + } + activeVariadicOption = null; + if (maybeOption(arg)) { + const option = this._findOption(arg); + if (option) { + if (option.required) { + const value = args2.shift(); + if (value === void 0) this.optionMissingArgument(option); + this.emit(`option:${option.name()}`, value); + } else if (option.optional) { + let value = null; + if (args2.length > 0 && (!maybeOption(args2[0]) || negativeNumberArg(args2[0]))) { + value = args2.shift(); + } + this.emit(`option:${option.name()}`, value); + } else { + this.emit(`option:${option.name()}`); + } + activeVariadicOption = option.variadic ? option : null; + continue; + } + } + if (arg.length > 2 && arg[0] === "-" && arg[1] !== "-") { + const option = this._findOption(`-${arg[1]}`); + if (option) { + if (option.required || option.optional && this._combineFlagAndOptionalValue) { + this.emit(`option:${option.name()}`, arg.slice(2)); + } else { + this.emit(`option:${option.name()}`); + args2.unshift(`-${arg.slice(2)}`); + } + continue; + } + } + if (/^--[^=]+=/.test(arg)) { + const index2 = arg.indexOf("="); + const option = this._findOption(arg.slice(0, index2)); + if (option && (option.required || option.optional)) { + this.emit(`option:${option.name()}`, arg.slice(index2 + 1)); + continue; + } + } + if (dest === operands && maybeOption(arg) && !(this.commands.length === 0 && negativeNumberArg(arg))) { + dest = unknown; + } + if ((this._enablePositionalOptions || this._passThroughOptions) && operands.length === 0 && unknown.length === 0) { + if (this._findCommand(arg)) { + operands.push(arg); + if (args2.length > 0) unknown.push(...args2); + break; + } else if (this._getHelpCommand() && arg === this._getHelpCommand().name()) { + operands.push(arg); + if (args2.length > 0) operands.push(...args2); + break; + } else if (this._defaultCommandName) { + unknown.push(arg); + if (args2.length > 0) unknown.push(...args2); + break; + } + } + if (this._passThroughOptions) { + dest.push(arg); + if (args2.length > 0) dest.push(...args2); + break; + } + dest.push(arg); + } + return { operands, unknown }; + } + /** + * Return an object containing local option values as key-value pairs. + * + * @return {object} + */ + opts() { + if (this._storeOptionsAsProperties) { + const result = {}; + const len = this.options.length; + for (let i2 = 0; i2 < len; i2++) { + const key = this.options[i2].attributeName(); + result[key] = key === this._versionOptionName ? this._version : this[key]; + } + return result; + } + return this._optionValues; + } + /** + * Return an object containing merged local and global option values as key-value pairs. + * + * @return {object} + */ + optsWithGlobals() { + return this._getCommandAndAncestors().reduce( + (combinedOptions, cmd) => Object.assign(combinedOptions, cmd.opts()), + {} + ); + } + /** + * Display error message and exit (or call exitOverride). + * + * @param {string} message + * @param {object} [errorOptions] + * @param {string} [errorOptions.code] - an id string representing the error + * @param {number} [errorOptions.exitCode] - used with process.exit + */ + error(message, errorOptions) { + this._outputConfiguration.outputError( + `${message} +`, + this._outputConfiguration.writeErr + ); + if (typeof this._showHelpAfterError === "string") { + this._outputConfiguration.writeErr(`${this._showHelpAfterError} +`); + } else if (this._showHelpAfterError) { + this._outputConfiguration.writeErr("\n"); + this.outputHelp({ error: true }); + } + const config = errorOptions || {}; + const exitCode = config.exitCode || 1; + const code = config.code || "commander.error"; + this._exit(exitCode, code, message); + } + /** + * Apply any option related environment variables, if option does + * not have a value from cli or client code. + * + * @private + */ + _parseOptionsEnv() { + this.options.forEach((option) => { + if (option.envVar && option.envVar in process2.env) { + const optionKey = option.attributeName(); + if (this.getOptionValue(optionKey) === void 0 || ["default", "config", "env"].includes( + this.getOptionValueSource(optionKey) + )) { + if (option.required || option.optional) { + this.emit(`optionEnv:${option.name()}`, process2.env[option.envVar]); + } else { + this.emit(`optionEnv:${option.name()}`); + } + } + } + }); + } + /** + * Apply any implied option values, if option is undefined or default value. + * + * @private + */ + _parseOptionsImplied() { + const dualHelper = new DualOptions(this.options); + const hasCustomOptionValue = (optionKey) => { + return this.getOptionValue(optionKey) !== void 0 && !["default", "implied"].includes(this.getOptionValueSource(optionKey)); + }; + this.options.filter( + (option) => option.implied !== void 0 && hasCustomOptionValue(option.attributeName()) && dualHelper.valueFromOption( + this.getOptionValue(option.attributeName()), + option + ) + ).forEach((option) => { + Object.keys(option.implied).filter((impliedKey) => !hasCustomOptionValue(impliedKey)).forEach((impliedKey) => { + this.setOptionValueWithSource( + impliedKey, + option.implied[impliedKey], + "implied" + ); + }); + }); + } + /** + * Argument `name` is missing. + * + * @param {string} name + * @private + */ + missingArgument(name2) { + const message = `error: missing required argument '${name2}'`; + this.error(message, { code: "commander.missingArgument" }); + } + /** + * `Option` is missing an argument. + * + * @param {Option} option + * @private + */ + optionMissingArgument(option) { + const message = `error: option '${option.flags}' argument missing`; + this.error(message, { code: "commander.optionMissingArgument" }); + } + /** + * `Option` does not have a value, and is a mandatory option. + * + * @param {Option} option + * @private + */ + missingMandatoryOptionValue(option) { + const message = `error: required option '${option.flags}' not specified`; + this.error(message, { code: "commander.missingMandatoryOptionValue" }); + } + /** + * `Option` conflicts with another option. + * + * @param {Option} option + * @param {Option} conflictingOption + * @private + */ + _conflictingOption(option, conflictingOption) { + const findBestOptionFromValue = (option2) => { + const optionKey = option2.attributeName(); + const optionValue = this.getOptionValue(optionKey); + const negativeOption = this.options.find( + (target) => target.negate && optionKey === target.attributeName() + ); + const positiveOption = this.options.find( + (target) => !target.negate && optionKey === target.attributeName() + ); + if (negativeOption && (negativeOption.presetArg === void 0 && optionValue === false || negativeOption.presetArg !== void 0 && optionValue === negativeOption.presetArg)) { + return negativeOption; + } + return positiveOption || option2; + }; + const getErrorMessage = (option2) => { + const bestOption = findBestOptionFromValue(option2); + const optionKey = bestOption.attributeName(); + const source = this.getOptionValueSource(optionKey); + if (source === "env") { + return `environment variable '${bestOption.envVar}'`; + } + return `option '${bestOption.flags}'`; + }; + const message = `error: ${getErrorMessage(option)} cannot be used with ${getErrorMessage(conflictingOption)}`; + this.error(message, { code: "commander.conflictingOption" }); + } + /** + * Unknown option `flag`. + * + * @param {string} flag + * @private + */ + unknownOption(flag) { + if (this._allowUnknownOption) return; + let suggestion = ""; + if (flag.startsWith("--") && this._showSuggestionAfterError) { + let candidateFlags = []; + let command = this; + do { + const moreFlags = command.createHelp().visibleOptions(command).filter((option) => option.long).map((option) => option.long); + candidateFlags = candidateFlags.concat(moreFlags); + command = command.parent; + } while (command && !command._enablePositionalOptions); + suggestion = suggestSimilar(flag, candidateFlags); + } + const message = `error: unknown option '${flag}'${suggestion}`; + this.error(message, { code: "commander.unknownOption" }); + } + /** + * Excess arguments, more than expected. + * + * @param {string[]} receivedArgs + * @private + */ + _excessArguments(receivedArgs) { + if (this._allowExcessArguments) return; + const expected = this.registeredArguments.length; + const s = expected === 1 ? "" : "s"; + const forSubcommand = this.parent ? ` for '${this.name()}'` : ""; + const message = `error: too many arguments${forSubcommand}. Expected ${expected} argument${s} but got ${receivedArgs.length}.`; + this.error(message, { code: "commander.excessArguments" }); + } + /** + * Unknown command. + * + * @private + */ + unknownCommand() { + const unknownName = this.args[0]; + let suggestion = ""; + if (this._showSuggestionAfterError) { + const candidateNames = []; + this.createHelp().visibleCommands(this).forEach((command) => { + candidateNames.push(command.name()); + if (command.alias()) candidateNames.push(command.alias()); + }); + suggestion = suggestSimilar(unknownName, candidateNames); + } + const message = `error: unknown command '${unknownName}'${suggestion}`; + this.error(message, { code: "commander.unknownCommand" }); + } + /** + * Get or set the program version. + * + * This method auto-registers the "-V, --version" option which will print the version number. + * + * You can optionally supply the flags and description to override the defaults. + * + * @param {string} [str] + * @param {string} [flags] + * @param {string} [description] + * @return {(this | string | undefined)} `this` command for chaining, or version string if no arguments + */ + version(str, flags2, description) { + if (str === void 0) return this._version; + this._version = str; + flags2 = flags2 || "-V, --version"; + description = description || "output the version number"; + const versionOption = this.createOption(flags2, description); + this._versionOptionName = versionOption.attributeName(); + this._registerOption(versionOption); + this.on("option:" + versionOption.name(), () => { + this._outputConfiguration.writeOut(`${str} +`); + this._exit(0, "commander.version", str); + }); + return this; + } + /** + * Set the description. + * + * @param {string} [str] + * @param {object} [argsDescription] + * @return {(string|Command)} + */ + description(str, argsDescription) { + if (str === void 0 && argsDescription === void 0) + return this._description; + this._description = str; + if (argsDescription) { + this._argsDescription = argsDescription; + } + return this; + } + /** + * Set the summary. Used when listed as subcommand of parent. + * + * @param {string} [str] + * @return {(string|Command)} + */ + summary(str) { + if (str === void 0) return this._summary; + this._summary = str; + return this; + } + /** + * Set an alias for the command. + * + * You may call more than once to add multiple aliases. Only the first alias is shown in the auto-generated help. + * + * @param {string} [alias] + * @return {(string|Command)} + */ + alias(alias) { + if (alias === void 0) return this._aliases[0]; + let command = this; + if (this.commands.length !== 0 && this.commands[this.commands.length - 1]._executableHandler) { + command = this.commands[this.commands.length - 1]; + } + if (alias === command._name) + throw new Error("Command alias can't be the same as its name"); + const matchingCommand = this.parent?._findCommand(alias); + if (matchingCommand) { + const existingCmd = [matchingCommand.name()].concat(matchingCommand.aliases()).join("|"); + throw new Error( + `cannot add alias '${alias}' to command '${this.name()}' as already have command '${existingCmd}'` + ); + } + command._aliases.push(alias); + return this; + } + /** + * Set aliases for the command. + * + * Only the first alias is shown in the auto-generated help. + * + * @param {string[]} [aliases] + * @return {(string[]|Command)} + */ + aliases(aliases) { + if (aliases === void 0) return this._aliases; + aliases.forEach((alias) => this.alias(alias)); + return this; + } + /** + * Set / get the command usage `str`. + * + * @param {string} [str] + * @return {(string|Command)} + */ + usage(str) { + if (str === void 0) { + if (this._usage) return this._usage; + const args2 = this.registeredArguments.map((arg) => { + return humanReadableArgName(arg); + }); + return [].concat( + this.options.length || this._helpOption !== null ? "[options]" : [], + this.commands.length ? "[command]" : [], + this.registeredArguments.length ? args2 : [] + ).join(" "); + } + this._usage = str; + return this; + } + /** + * Get or set the name of the command. + * + * @param {string} [str] + * @return {(string|Command)} + */ + name(str) { + if (str === void 0) return this._name; + this._name = str; + return this; + } + /** + * Set/get the help group heading for this subcommand in parent command's help. + * + * @param {string} [heading] + * @return {Command | string} + */ + helpGroup(heading) { + if (heading === void 0) return this._helpGroupHeading ?? ""; + this._helpGroupHeading = heading; + return this; + } + /** + * Set/get the default help group heading for subcommands added to this command. + * (This does not override a group set directly on the subcommand using .helpGroup().) + * + * @example + * program.commandsGroup('Development Commands:); + * program.command('watch')... + * program.command('lint')... + * ... + * + * @param {string} [heading] + * @returns {Command | string} + */ + commandsGroup(heading) { + if (heading === void 0) return this._defaultCommandGroup ?? ""; + this._defaultCommandGroup = heading; + return this; + } + /** + * Set/get the default help group heading for options added to this command. + * (This does not override a group set directly on the option using .helpGroup().) + * + * @example + * program + * .optionsGroup('Development Options:') + * .option('-d, --debug', 'output extra debugging') + * .option('-p, --profile', 'output profiling information') + * + * @param {string} [heading] + * @returns {Command | string} + */ + optionsGroup(heading) { + if (heading === void 0) return this._defaultOptionGroup ?? ""; + this._defaultOptionGroup = heading; + return this; + } + /** + * @param {Option} option + * @private + */ + _initOptionGroup(option) { + if (this._defaultOptionGroup && !option.helpGroupHeading) + option.helpGroup(this._defaultOptionGroup); + } + /** + * @param {Command} cmd + * @private + */ + _initCommandGroup(cmd) { + if (this._defaultCommandGroup && !cmd.helpGroup()) + cmd.helpGroup(this._defaultCommandGroup); + } + /** + * Set the name of the command from script filename, such as process.argv[1], + * or require.main.filename, or __filename. + * + * (Used internally and public although not documented in README.) + * + * @example + * program.nameFromFilename(require.main.filename); + * + * @param {string} filename + * @return {Command} + */ + nameFromFilename(filename) { + this._name = path5.basename(filename, path5.extname(filename)); + return this; + } + /** + * Get or set the directory for searching for executable subcommands of this command. + * + * @example + * program.executableDir(__dirname); + * // or + * program.executableDir('subcommands'); + * + * @param {string} [path] + * @return {(string|null|Command)} + */ + executableDir(path6) { + if (path6 === void 0) return this._executableDir; + this._executableDir = path6; + return this; + } + /** + * Return program help documentation. + * + * @param {{ error: boolean }} [contextOptions] - pass {error:true} to wrap for stderr instead of stdout + * @return {string} + */ + helpInformation(contextOptions) { + const helper = this.createHelp(); + const context = this._getOutputContext(contextOptions); + helper.prepareContext({ + error: context.error, + helpWidth: context.helpWidth, + outputHasColors: context.hasColors + }); + const text = helper.formatHelp(this, helper); + if (context.hasColors) return text; + return this._outputConfiguration.stripColor(text); + } + /** + * @typedef HelpContext + * @type {object} + * @property {boolean} error + * @property {number} helpWidth + * @property {boolean} hasColors + * @property {function} write - includes stripColor if needed + * + * @returns {HelpContext} + * @private + */ + _getOutputContext(contextOptions) { + contextOptions = contextOptions || {}; + const error = !!contextOptions.error; + let baseWrite; + let hasColors; + let helpWidth; + if (error) { + baseWrite = (str) => this._outputConfiguration.writeErr(str); + hasColors = this._outputConfiguration.getErrHasColors(); + helpWidth = this._outputConfiguration.getErrHelpWidth(); + } else { + baseWrite = (str) => this._outputConfiguration.writeOut(str); + hasColors = this._outputConfiguration.getOutHasColors(); + helpWidth = this._outputConfiguration.getOutHelpWidth(); + } + const write = (str) => { + if (!hasColors) str = this._outputConfiguration.stripColor(str); + return baseWrite(str); + }; + return { error, write, hasColors, helpWidth }; + } + /** + * Output help information for this command. + * + * Outputs built-in help, and custom text added using `.addHelpText()`. + * + * @param {{ error: boolean } | Function} [contextOptions] - pass {error:true} to write to stderr instead of stdout + */ + outputHelp(contextOptions) { + let deprecatedCallback; + if (typeof contextOptions === "function") { + deprecatedCallback = contextOptions; + contextOptions = void 0; + } + const outputContext = this._getOutputContext(contextOptions); + const eventContext = { + error: outputContext.error, + write: outputContext.write, + command: this + }; + this._getCommandAndAncestors().reverse().forEach((command) => command.emit("beforeAllHelp", eventContext)); + this.emit("beforeHelp", eventContext); + let helpInformation = this.helpInformation({ error: outputContext.error }); + if (deprecatedCallback) { + helpInformation = deprecatedCallback(helpInformation); + if (typeof helpInformation !== "string" && !Buffer.isBuffer(helpInformation)) { + throw new Error("outputHelp callback must return a string or a Buffer"); + } + } + outputContext.write(helpInformation); + if (this._getHelpOption()?.long) { + this.emit(this._getHelpOption().long); + } + this.emit("afterHelp", eventContext); + this._getCommandAndAncestors().forEach( + (command) => command.emit("afterAllHelp", eventContext) + ); + } + /** + * You can pass in flags and a description to customise the built-in help option. + * Pass in false to disable the built-in help option. + * + * @example + * program.helpOption('-?, --help' 'show help'); // customise + * program.helpOption(false); // disable + * + * @param {(string | boolean)} flags + * @param {string} [description] + * @return {Command} `this` command for chaining + */ + helpOption(flags2, description) { + if (typeof flags2 === "boolean") { + if (flags2) { + if (this._helpOption === null) this._helpOption = void 0; + if (this._defaultOptionGroup) { + this._initOptionGroup(this._getHelpOption()); + } + } else { + this._helpOption = null; + } + return this; + } + this._helpOption = this.createOption( + flags2 ?? "-h, --help", + description ?? "display help for command" + ); + if (flags2 || description) this._initOptionGroup(this._helpOption); + return this; + } + /** + * Lazy create help option. + * Returns null if has been disabled with .helpOption(false). + * + * @returns {(Option | null)} the help option + * @package + */ + _getHelpOption() { + if (this._helpOption === void 0) { + this.helpOption(void 0, void 0); + } + return this._helpOption; + } + /** + * Supply your own option to use for the built-in help option. + * This is an alternative to using helpOption() to customise the flags and description etc. + * + * @param {Option} option + * @return {Command} `this` command for chaining + */ + addHelpOption(option) { + this._helpOption = option; + this._initOptionGroup(option); + return this; + } + /** + * Output help information and exit. + * + * Outputs built-in help, and custom text added using `.addHelpText()`. + * + * @param {{ error: boolean }} [contextOptions] - pass {error:true} to write to stderr instead of stdout + */ + help(contextOptions) { + this.outputHelp(contextOptions); + let exitCode = Number(process2.exitCode ?? 0); + if (exitCode === 0 && contextOptions && typeof contextOptions !== "function" && contextOptions.error) { + exitCode = 1; + } + this._exit(exitCode, "commander.help", "(outputHelp)"); + } + /** + * // Do a little typing to coordinate emit and listener for the help text events. + * @typedef HelpTextEventContext + * @type {object} + * @property {boolean} error + * @property {Command} command + * @property {function} write + */ + /** + * Add additional text to be displayed with the built-in help. + * + * Position is 'before' or 'after' to affect just this command, + * and 'beforeAll' or 'afterAll' to affect this command and all its subcommands. + * + * @param {string} position - before or after built-in help + * @param {(string | Function)} text - string to add, or a function returning a string + * @return {Command} `this` command for chaining + */ + addHelpText(position, text) { + const allowedValues = ["beforeAll", "before", "after", "afterAll"]; + if (!allowedValues.includes(position)) { + throw new Error(`Unexpected value for position to addHelpText. +Expecting one of '${allowedValues.join("', '")}'`); + } + const helpEvent = `${position}Help`; + this.on(helpEvent, (context) => { + let helpStr; + if (typeof text === "function") { + helpStr = text({ error: context.error, command: context.command }); + } else { + helpStr = text; + } + if (helpStr) { + context.write(`${helpStr} +`); + } + }); + return this; + } + /** + * Output help information if help flags specified + * + * @param {Array} args - array of options to search for help flags + * @private + */ + _outputHelpIfRequested(args2) { + const helpOption = this._getHelpOption(); + const helpRequested = helpOption && args2.find((arg) => helpOption.is(arg)); + if (helpRequested) { + this.outputHelp(); + this._exit(0, "commander.helpDisplayed", "(outputHelp)"); + } + } + }; + function incrementNodeInspectorPort(args2) { + return args2.map((arg) => { + if (!arg.startsWith("--inspect")) { + return arg; + } + let debugOption; + let debugHost = "127.0.0.1"; + let debugPort = "9229"; + let match; + if ((match = arg.match(/^(--inspect(-brk)?)$/)) !== null) { + debugOption = match[1]; + } else if ((match = arg.match(/^(--inspect(-brk|-port)?)=([^:]+)$/)) !== null) { + debugOption = match[1]; + if (/^\d+$/.test(match[3])) { + debugPort = match[3]; + } else { + debugHost = match[3]; + } + } else if ((match = arg.match(/^(--inspect(-brk|-port)?)=([^:]+):(\d+)$/)) !== null) { + debugOption = match[1]; + debugHost = match[3]; + debugPort = match[4]; + } + if (debugOption && debugPort !== "0") { + return `${debugOption}=${debugHost}:${parseInt(debugPort) + 1}`; + } + return arg; + }); + } + function useColor() { + if (process2.env.NO_COLOR || process2.env.FORCE_COLOR === "0" || process2.env.FORCE_COLOR === "false") + return false; + if (process2.env.FORCE_COLOR || process2.env.CLICOLOR_FORCE !== void 0) + return true; + return void 0; + } + exports2.Command = Command; + exports2.useColor = useColor; + } +}); + +// node_modules/commander/index.js +var require_commander = __commonJS({ + "node_modules/commander/index.js"(exports2) { + var { Argument } = require_argument(); + var { Command } = require_command(); + var { CommanderError, InvalidArgumentError } = require_error(); + var { Help } = require_help(); + var { Option } = require_option(); + exports2.program = new Command(); + exports2.createCommand = (name2) => new Command(name2); + exports2.createOption = (flags2, description) => new Option(flags2, description); + exports2.createArgument = (name2, description) => new Argument(name2, description); + exports2.Command = Command; + exports2.Option = Option; + exports2.Argument = Argument; + exports2.Help = Help; + exports2.CommanderError = CommanderError; + exports2.InvalidArgumentError = InvalidArgumentError; + exports2.InvalidOptionArgumentError = InvalidArgumentError; + } +}); + +// ../autocompletion/v2/CodeSnippets.ts +var CodeSnippets = class _CodeSnippets { + _nextId = 0; + _idMap = /* @__PURE__ */ new Map(); + _byName = /* @__PURE__ */ new Map(); + _fileIndex = /* @__PURE__ */ new Map(); + // 基于结构化信息的索引 + _byDefinitionType = /* @__PURE__ */ new Map(); + // 按定义类型索引 + _bySignature = /* @__PURE__ */ new Map(); + // 按签名索引 + snippets = []; + filesHash = /* @__PURE__ */ new Map(); + _addToIndices(id, snippet) { + if (!this._byName.has(snippet.name)) this._byName.set(snippet.name, /* @__PURE__ */ new Set()); + this._byName.get(snippet.name).add(id); + if (!this._fileIndex.has(snippet.filePath)) { + this._fileIndex.set(snippet.filePath, { + allIds: /* @__PURE__ */ new Set(), + byName: /* @__PURE__ */ new Map() + }); + } + const bucket = this._fileIndex.get(snippet.filePath); + bucket.allIds.add(id); + if (!bucket.byName.has(snippet.name)) bucket.byName.set(snippet.name, /* @__PURE__ */ new Set()); + bucket.byName.get(snippet.name).add(id); + this._addToStructuredIndices(id, snippet); + } + _removeFromIndices(id, snippet) { + const nameSet = this._byName.get(snippet.name); + if (nameSet) { + nameSet.delete(id); + if (nameSet.size === 0) this._byName.delete(snippet.name); + } + const bucket = this._fileIndex.get(snippet.filePath); + if (bucket) { + bucket.allIds.delete(id); + const nameSetInFile = bucket.byName.get(snippet.name); + if (nameSetInFile) { + nameSetInFile.delete(id); + if (nameSetInFile.size === 0) bucket.byName.delete(snippet.name); + } + if (bucket.allIds.size === 0) this._fileIndex.delete(snippet.filePath); + } + this._removeFromStructuredIndices(id, snippet); + } + /** + * 添加结构化信息索引 + */ + _addToStructuredIndices(id, snippet) { + if (snippet.definition?.type) { + if (!this._byDefinitionType.has(snippet.definition.type)) { + this._byDefinitionType.set(snippet.definition.type, /* @__PURE__ */ new Set()); + } + this._byDefinitionType.get(snippet.definition.type).add(id); + } + if (snippet.signature) { + if (!this._bySignature.has(snippet.signature)) { + this._bySignature.set(snippet.signature, /* @__PURE__ */ new Set()); + } + this._bySignature.get(snippet.signature).add(id); + } + } + /** + * 移除结构化信息索引 + */ + _removeFromStructuredIndices(id, snippet) { + if (snippet.definition?.type) { + const typeSet = this._byDefinitionType.get(snippet.definition.type); + if (typeSet) { + typeSet.delete(id); + if (typeSet.size === 0) this._byDefinitionType.delete(snippet.definition.type); + } + } + if (snippet.signature) { + const signatureSet = this._bySignature.get(snippet.signature); + if (signatureSet) { + signatureSet.delete(id); + if (signatureSet.size === 0) this._bySignature.delete(snippet.signature); + } + } + } + /** + * 按名称查找单个片段 + */ + async findByName(name2) { + const results = await this.find({ name: name2 }); + return results.length > 0 ? results[0] : void 0; + } + /** + * 按文件查找片段 + */ + async findByFile(filePath) { + return await this.find({ filePath }); + } + /** + * 按定义类型查找片段 + */ + async findByDefinitionType(definitionType) { + const ids = this._byDefinitionType.get(definitionType) ?? /* @__PURE__ */ new Set(); + return Array.from(ids).map((id) => this._idMap.get(id)); + } + /** + * 按签名查找片段 + */ + async findBySignature(signature) { + const ids = this._bySignature.get(signature) ?? /* @__PURE__ */ new Set(); + return Array.from(ids).map((id) => this._idMap.get(id)); + } + /** + * 查找具有特定参数类型的函数 + */ + async findFunctionsWithParameterTypes(paramTypes) { + const results = []; + for (const snippet of this.snippets) { + if (snippet.parameters && snippet.parameters.length >= paramTypes.length) { + let match = true; + for (let i2 = 0; i2 < paramTypes.length; i2++) { + if (snippet.parameters[i2]?.type !== paramTypes[i2]) { + match = false; + break; + } + } + if (match) { + results.push(snippet); + } + } + } + return results; + } + async merge(codeSnippets) { + if (codeSnippets && codeSnippets.snippets) { + await this.insert(codeSnippets.snippets); + } + } + /** + * 获取统计信息 + */ + getStats() { + const typeDistribution = {}; + const definitionTypeDistribution = {}; + let totalLines = 0; + for (const snippet of this.snippets) { + typeDistribution[snippet.type] = (typeDistribution[snippet.type] || 0) + 1; + if (snippet.definition?.type) { + definitionTypeDistribution[snippet.definition.type] = (definitionTypeDistribution[snippet.definition.type] || 0) + 1; + } + totalLines += snippet.endLine - snippet.startLine + 1; + } + const files = new Set(this.snippets.map((s) => s.filePath)); + return { + totalSnippets: this.snippets.length, + fileCount: files.size, + typeDistribution, + definitionTypeDistribution, + avgLinesPerSnippet: this.snippets.length > 0 ? totalLines / this.snippets.length : 0 + }; + } + /** + * Find snippets by partial information + */ + async find(query) { + if (query.filePath && query.name) { + const bucket = this._fileIndex.get(query.filePath); + const ids = bucket?.byName.get(query.name) ?? /* @__PURE__ */ new Set(); + let res = Array.from(ids).map((id) => this._idMap.get(id)); + if (query.type) res = res.filter((s) => s.type === query.type); + if (query.field) { + res = res.filter((s) => s.field === query.field); + } else { + res = res.filter((s) => s.field === void 0 || s.field === null || s.field === ""); + } + return res; + } + if (query.name) { + const ids = this._byName.get(query.name) ?? /* @__PURE__ */ new Set(); + return Array.from(ids).map((id) => this._idMap.get(id)); + } + if (query.filePath) { + const bucket = this._fileIndex.get(query.filePath); + const ids = bucket?.allIds ?? /* @__PURE__ */ new Set(); + return Array.from(ids).map((id) => this._idMap.get(id)); + } + return Array.from(this._idMap.values()); + } + /** + * Delete all snippets from a specific file + */ + async deleteByFile(filePath) { + const bucket = this._fileIndex.get(filePath); + if (!bucket) return []; + const deleted = []; + for (const id of Array.from(bucket.allIds)) { + const snippet = this._idMap.get(id); + this._removeFromIndices(id, snippet); + this._idMap.delete(id); + deleted.push(snippet); + } + if (deleted.length) { + this.snippets = this.snippets.filter((s) => s.filePath !== filePath); + } + return deleted; + } + /** + * Insert snippets in batch + */ + async insert(snippets) { + for (const snippet of snippets) { + const id = ++this._nextId; + this._idMap.set(id, snippet); + this._addToIndices(id, snippet); + this.snippets.push(snippet); + if (snippet.fileHash && snippet.filePath) { + this.filesHash.set(snippet.filePath, snippet.fileHash); + } + } + return snippets.length; + } + /** + * Update a single snippet + */ + async update(snippet) { + if (snippet.filePath && snippet.name && snippet.type) { + const bucket = this._fileIndex.get(snippet.filePath); + if (!bucket) return false; + const candidateIds = bucket.byName.get(snippet.name) ?? /* @__PURE__ */ new Set(); + for (const id of candidateIds) { + const old = this._idMap.get(id); + if (old.type === snippet.type) { + this._removeFromIndices(id, old); + this._idMap.set(id, snippet); + this._addToIndices(id, snippet); + const idx = this.snippets.indexOf(old); + if (idx > -1) this.snippets[idx] = snippet; + return true; + } + } + } + if (snippet.filePath && snippet.name) { + const bucket = this._fileIndex.get(snippet.filePath); + if (!bucket) return false; + const candidateIds = bucket.byName.get(snippet.name) ?? /* @__PURE__ */ new Set(); + if (candidateIds.size > 0) { + const id = Array.from(candidateIds)[0]; + const old = this._idMap.get(id); + this._removeFromIndices(id, old); + this._idMap.set(id, snippet); + this._addToIndices(id, snippet); + const idx = this.snippets.indexOf(old); + if (idx > -1) this.snippets[idx] = snippet; + return true; + } + } + return false; + } + async updateByFile(file, snippets) { + await this.deleteByFile(file.filePath); + await this.merge(snippets); + const fileHash = file.fileHash || file.hash; + if (fileHash) { + this.filesHash.set(file.filePath, fileHash); + } + return true; + } + /** + * Clear all snippets + */ + clear() { + this._nextId = 0; + this._idMap.clear(); + this._byName.clear(); + this._fileIndex.clear(); + this._byDefinitionType.clear(); + this._bySignature.clear(); + this.snippets = []; + } + /** + * Filter snippets by condition + */ + async filter(predicate) { + const result = new _CodeSnippets(); + for (const snippet of this._idMap.values()) { + if (predicate(snippet)) await result.insert([snippet]); + } + return result; + } + /** + * Check if a code file's index is up to date + * @param file The file to check + * @returns true if the file needs to be updated (index is NOT latest), false if index is current + */ + isCodeFileLatestIndex(file) { + const storedHash = this.filesHash.get(file.filePath); + if (!storedHash) { + return true; + } + const currentHash = file.fileHash || file.hash; + return currentHash !== storedHash; + } + getSnippets() { + return this.snippets; + } +}; + +// ../autocompletion/v2/types.ts +var CodeLanguageType = /* @__PURE__ */ ((CodeLanguageType3) => { + CodeLanguageType3["Python"] = "python"; + CodeLanguageType3["Java"] = "java"; + CodeLanguageType3["JavaScript"] = "javascript"; + CodeLanguageType3["TypeScript"] = "typescript"; + CodeLanguageType3["JSX"] = "jsx"; + CodeLanguageType3["TSX"] = "tsx"; + CodeLanguageType3["Go"] = "go"; + CodeLanguageType3["Swift"] = "swift"; + CodeLanguageType3["CSS"] = "css"; + CodeLanguageType3["HTML"] = "html"; + CodeLanguageType3["Kotlin"] = "kotlin"; + CodeLanguageType3["PHP"] = "php"; + CodeLanguageType3["Rust"] = "rust"; + CodeLanguageType3["C"] = "c"; + CodeLanguageType3["CPP"] = "cpp"; + CodeLanguageType3["Unknown"] = "unknown"; + return CodeLanguageType3; +})(CodeLanguageType || {}); +var CodeLanguageTypeSupport = [ + "python" /* Python */, + "java" /* Java */, + "javascript" /* JavaScript */, + "typescript" /* TypeScript */, + "jsx" /* JSX */, + "tsx" /* TSX */, + "go" /* Go */, + "swift" /* Swift */, + "css" /* CSS */, + "html" /* HTML */, + "kotlin" /* Kotlin */, + "php" /* PHP */, + "rust" /* Rust */, + "c" /* C */, + "cpp" /* CPP */ +]; +var FileExtensionLanguageMap = { + ".py": "python" /* Python */, + ".java": "java" /* Java */, + ".js": "javascript" /* JavaScript */, + ".mjs": "javascript" /* JavaScript */, + ".ts": "typescript" /* TypeScript */, + ".tsx": "tsx" /* TSX */, + ".jsx": "jsx" /* JSX */, + ".go": "go" /* Go */, + ".swift": "swift" /* Swift */, + ".css": "css" /* CSS */, + ".html": "html" /* HTML */, + ".kt": "kotlin" /* Kotlin */, + ".kts": "kotlin" /* Kotlin */, + ".php": "php" /* PHP */, + ".rs": "rust" /* Rust */, + ".c": "c" /* C */, + ".h": "c" /* C */, + ".cpp": "cpp" /* CPP */, + ".cxx": "cpp" /* CPP */, + ".cc": "cpp" /* CPP */, + ".hpp": "cpp" /* CPP */, + ".hxx": "cpp" /* CPP */ +}; +var LanguageFileExtensionMap = Object.entries(FileExtensionLanguageMap).reduce( + (acc, [extension, language]) => { + if (!acc[language]) acc[language] = []; + acc[language].push(extension); + return acc; + }, + {} +); + +// ../autocompletion/v2/CodeContext.ts +var path4 = __toESM(require("path")); +var crypto3 = __toESM(require("crypto")); + +// ../../../src/services/CT-tree-sitter/languageParser.ts +var path = __toESM(require("path")); +var import_web_tree_sitter = __toESM(require_tree_sitter()); + +// ../../../src/services/CT-tree-sitter/queries/solidity.ts +var solidityQuery = ` +; Contract declarations +(contract_declaration + name: (identifier) @name.definition.contract) @definition.contract + +(interface_declaration + name: (identifier) @name.definition.interface) @definition.interface + +(library_declaration + name: (identifier) @name.definition.library) @definition.library + +; Function declarations +(function_definition + name: (identifier) @name.definition.function) @definition.function + +(modifier_definition + name: (identifier) @name.definition.modifier) @definition.modifier + +(constructor_definition) @definition.constructor + +(fallback_receive_definition + (visibility) + (state_mutability)) @definition.fallback + +; Type declarations +(struct_declaration + name: (identifier) @name.definition.struct) @definition.struct + +(enum_declaration + name: (identifier) @name.definition.enum) @definition.enum + +(event_definition + name: (identifier) @name.definition.event) @definition.event + +(error_declaration + name: (identifier) @name.definition.error) @definition.error + +; Variable declarations +(state_variable_declaration + name: (identifier) @name.definition.variable) @definition.variable + +; Using directives +(using_directive + (type_alias) @name.definition.using) @definition.using`; + +// ../../../src/services/CT-tree-sitter/queries/php.ts +var php_default = ` +;-------------------------- +; 1. CLASS DEFINITIONS +;-------------------------- +; Regular classes +(class_declaration + name: (name) @name.definition.class) @definition.class + +; Abstract classes +(class_declaration + (abstract_modifier) + name: (name) @name.definition.abstract_class) @definition.abstract_class + +; Final classes +(class_declaration + (final_modifier) + name: (name) @name.definition.final_class) @definition.final_class + +; Readonly classes (PHP 8.2+) +(class_declaration + (readonly_modifier) + name: (name) @name.definition.readonly_class) @definition.readonly_class + +;-------------------------- +; 2. INTERFACE & TRAIT DEFINITIONS +;-------------------------- +; Interfaces +(interface_declaration + name: (name) @name.definition.interface) @definition.interface + +; Traits +(trait_declaration + name: (name) @name.definition.trait) @definition.trait + +; Enums (PHP 8.1+) +(enum_declaration + name: (name) @name.definition.enum) @definition.enum + +;-------------------------- +; 3. FUNCTION & METHOD DEFINITIONS +;-------------------------- +; Global functions +(function_definition + name: (name) @name.definition.function + parameters: (formal_parameters) @parameters.definition.function + body: (compound_statement) @body.definition.function) @definition.function + +; Regular methods +(method_declaration + name: (name) @name.definition.method + parameters: (formal_parameters) @parameters.definition.method) @definition.method + +; Static methods +(method_declaration + (static_modifier) + name: (name) @name.definition.static_method + parameters: (formal_parameters) @parameters.definition.static_method) @definition.static_method + +; Abstract methods +(method_declaration + (abstract_modifier) + name: (name) @name.definition.abstract_method + parameters: (formal_parameters) @parameters.definition.abstract_method) @definition.abstract_method + +; Final methods +(method_declaration + (final_modifier) + name: (name) @name.definition.final_method + parameters: (formal_parameters) @parameters.definition.final_method) @definition.final_method + +; Arrow functions (PHP 7.4+) +(arrow_function) @definition.arrow_function + +;-------------------------- +; 4. PROPERTY DEFINITIONS +;-------------------------- +; Regular properties +(property_declaration + (property_element + (variable_name + (name) @name.definition.property))) @definition.property + +; Static properties +(property_declaration + (static_modifier) + (property_element + (variable_name + (name) @name.definition.static_property))) @definition.static_property + +; Readonly properties (PHP 8.1+) +(property_declaration + (readonly_modifier) + (property_element + (variable_name + (name) @name.definition.readonly_property))) @definition.readonly_property + +; Constructor property promotion (PHP 8.0+) +(property_promotion_parameter + name: (variable_name + (name) @name.definition.promoted_property)) @definition.promoted_property + +;-------------------------- +; 5. OTHER LANGUAGE CONSTRUCTS +;-------------------------- +; Constants +(const_declaration + (const_element + (name) @name.definition.constant)) @definition.constant + +; Namespaces +(namespace_definition + name: (namespace_name) @name.definition.namespace) @definition.namespace + +; Use statements (imports) +(namespace_use_declaration + (namespace_use_clause + (qualified_name) @name.definition.use)) @definition.use + +; Anonymous classes +(object_creation_expression + (declaration_list)) @definition.anonymous_class + +; Attributes (PHP 8.0+) +(attribute_group + (attribute + (name) @name.definition.attribute)) @definition.attribute + +; Match expressions (PHP 8.0+) +(match_expression) @definition.match_expression + +; Heredoc syntax +(heredoc) @definition.heredoc + +; Nowdoc syntax +(nowdoc) @definition.nowdoc +`; + +// ../../../src/services/CT-tree-sitter/queries/vue.ts +var vueQuery = ` +; Top-level structure +(component) @component.definition + +; Template section +(template_element) @template.definition +(template_element + (element + (start_tag + (tag_name) @element.name.definition)) + (element + (start_tag + (attribute + (attribute_name) @attribute.name.definition))) + (element + (start_tag + (directive_attribute + (directive_name) @directive.name.definition)))) + +; Script section +(script_element) @script.definition +(script_element + (raw_text) @script.content.definition) + +; Style section +(style_element) @style.definition +(style_element + (raw_text) @style.content.definition) +`; + +// ../../../src/services/CT-tree-sitter/queries/typescript.ts +var typescript_default = ` +; === Import Declarations === +(import_statement + (import_clause + (named_imports + (import_specifier + name: (identifier) @name.import)))) @definition.import + +; === Default Imports === +(import_statement + (import_clause + (identifier) @name.import)) @definition.import + +; === Class Declarations === +(class_declaration + name: (type_identifier) @name.class) @definition.class + +; === Abstract Class Declarations === +(abstract_class_declaration + name: (type_identifier) @name.class) @definition.class + +; === Interface Declarations === +(interface_declaration + name: (type_identifier) @name.interface) @definition.interface + +; === Type Alias Declarations === +(type_alias_declaration + name: (type_identifier) @name.type_alias) @definition.type_alias + +; === Enum Declarations === +(enum_declaration + name: (identifier) @name.enum) @definition.enum + +; === Function Declarations === +(function_declaration + name: (identifier) @name.function + parameters: (formal_parameters) @parameters.function + body: (statement_block) @body.function) @definition.function + +; === Generator Function Declarations === +(generator_function_declaration + name: (identifier) @name.function + parameters: (formal_parameters) @parameters.function + body: (statement_block) @body.function) @definition.function + +; === Method Definitions in Classes === +(method_definition + name: (property_identifier) @name.method + parameters: (formal_parameters) @parameters.method + body: (statement_block) @body.method) @definition.method + +; === Variable Declarations === +(variable_declaration + (variable_declarator + name: (identifier) @name.variable)) @definition.variable + +; === Lexical Declarations (const, let) === +(lexical_declaration + (variable_declarator + name: (identifier) @name.variable)) @definition.variable + +; === Property Signatures in Interfaces === +(property_signature + name: (property_identifier) @name.property) @definition.property + +; === Method Signatures in Interfaces === +(method_signature + name: (property_identifier) @name.method + parameters: (formal_parameters) @parameters.method) @definition.method + +; === Arrow Functions assigned to variables === +(lexical_declaration + (variable_declarator + name: (identifier) @name.function + value: (arrow_function + parameters: (formal_parameters) @parameters.function))) @definition.function + +(variable_declaration + (variable_declarator + name: (identifier) @name.function + value: (arrow_function + parameters: (formal_parameters) @parameters.function))) @definition.function + +; === Function Expressions assigned to variables === +(lexical_declaration + (variable_declarator + name: (identifier) @name.function + value: (function_expression + parameters: (formal_parameters) @parameters.function))) @definition.function + +(variable_declaration + (variable_declarator + name: (identifier) @name.function + value: (function_expression + parameters: (formal_parameters) @parameters.function))) @definition.function +`; + +// ../../../src/services/CT-tree-sitter/queries/tsx.ts +var tsx_default = `${typescript_default} + +; Function Components - Both function declarations and arrow functions +(function_declaration + name: (identifier) @name) @definition.component + +; Arrow Function Components +(variable_declaration + (variable_declarator + name: (identifier) @name + value: (arrow_function))) @definition.component + +; Export Statement Components +(export_statement + (variable_declaration + (variable_declarator + name: (identifier) @name + value: (arrow_function)))) @definition.component + +; Class Components +(class_declaration + name: (type_identifier) @name) @definition.class_component + +; Interface Declarations +(interface_declaration + name: (type_identifier) @name) @definition.interface + +; Type Alias Declarations +(type_alias_declaration + name: (type_identifier) @name) @definition.type + +; HOC Components +(variable_declaration + (variable_declarator + name: (identifier) @name + value: (call_expression + function: (identifier)))) @definition.component + +; JSX Component Usage - Capture all components in JSX +(jsx_element + open_tag: (jsx_opening_element + name: [(identifier) @component (member_expression) @component])) @definition.jsx_element + +; Self-closing JSX elements +(jsx_self_closing_element + name: [(identifier) @component (member_expression) @component]) @definition.jsx_self_closing_element + +; Capture all identifiers in JSX expressions that start with capital letters +(jsx_expression + (identifier) @jsx_component) @definition.jsx_component + +; Capture all member expressions in JSX +(member_expression + object: (identifier) @object + property: (property_identifier) @property) @definition.member_component + +; Capture components in conditional expressions +(ternary_expression + consequence: (parenthesized_expression + (jsx_element + open_tag: (jsx_opening_element + name: (identifier) @component)))) @definition.conditional_component + +(ternary_expression + alternative: (jsx_self_closing_element + name: (identifier) @component)) @definition.conditional_component + +; Generic Components +(function_declaration + name: (identifier) @name + type_parameters: (type_parameters)) @definition.generic_component +`; + +// ../../../src/services/CT-tree-sitter/queries/python.ts +var python_default = ` +; Class definitions (including decorated) +(class_definition + name: (identifier) @name.definition.class) @definition.class + +(decorated_definition + definition: (class_definition + name: (identifier) @name.definition.class)) @definition.class + +; Function definitions with parameters and body (including async and decorated) +(function_definition + name: (identifier) @name.definition.function + parameters: (parameters) @parameters.definition.function + body: (block) @body.definition.function) @definition.function + +(decorated_definition + definition: (function_definition + name: (identifier) @name.definition.function + parameters: (parameters) @parameters.definition.function)) @definition.function + +; Assignment statements for variables +(assignment + left: (identifier) @name.definition.variable) @definition.variable + +; Multiple assignment (tuple unpacking) - capture each identifier separately +(assignment + left: (pattern_list + (identifier) @name.definition.variable)) @definition.variable + +; Augmented assignment (+=, -=, etc.) +(augmented_assignment + left: (identifier) @name.definition.variable) @definition.variable + +; Annotated assignment (with type hints) +(expression_statement + (assignment + left: (identifier) @name.definition.variable + type: (type))) @definition.variable + +; Attribute assignments (self.attribute = value) - capture the attribute name +(assignment + left: (attribute + object: (identifier) + attribute: (identifier) @name.definition.member_variable)) @definition.variable + +; Lambda expressions +(expression_statement + (assignment + left: (identifier) @name.definition.lambda + right: (parenthesized_expression + (lambda)))) @definition.lambda + +; Generator functions (functions containing yield) +(function_definition + name: (identifier) @name.definition.generator + body: (block + (expression_statement + (yield)))) @definition.generator + +; Comprehensions +(expression_statement + (assignment + left: (identifier) @name.definition.comprehension + right: [ + (list_comprehension) + (dictionary_comprehension) + (set_comprehension) + ])) @definition.comprehension + +; With statements +(with_statement) @definition.with_statement + +; Try statements +(try_statement) @definition.try_statement + +; Import statements +(import_statement + name: (dotted_name) @name.definition.import) @definition.import + +(import_from_statement + module_name: (dotted_name) @name.definition.import) @definition.import + +(import_from_statement + name: (dotted_name) @name.definition.import) @definition.import + +; Global/Nonlocal statements +(function_definition + body: (block + [(global_statement) (nonlocal_statement)])) @definition.scope + +; Match case statements +(function_definition + body: (block + (match_statement))) @definition.match_case + +; Type annotations +(typed_parameter + type: (type)) @definition.type_annotation + +(expression_statement + (assignment + left: (identifier) @name.definition.type + type: (type))) @definition.type_annotation +`; + +// ../../../src/services/CT-tree-sitter/queries/javascript.ts +var javascript_default = ` +( + (comment)* @doc + . + (method_definition + name: (property_identifier) @name + parameters: (formal_parameters) @parameters.definition.method) @definition.method + (#not-eq? @name "constructor") + (#strip! @doc "^[\\s\\*/]+|^[\\s\\*/]$") + (#select-adjacent! @doc @definition.method) +) + +( + (comment)* @doc + . + [ + (class + name: (_) @name.definition.class) + (class_declaration + name: (_) @name.definition.class) + ] @definition.class + (#strip! @doc "^[\\s\\*/]+|^[\\s\\*/]$") + (#select-adjacent! @doc @definition.class) +) + +( + (comment)* @doc + . + [ + (function_declaration + name: (identifier) @name.definition.function + parameters: (formal_parameters) @parameters.definition.function + body: (statement_block) @body.definition.function) @definition.function + (generator_function_declaration + name: (identifier) @name.definition.function + parameters: (formal_parameters) @parameters.definition.function) @definition.function + ] + (#strip! @doc "^[\\s\\*/]+|^[\\s\\*/]$") + (#select-adjacent! @doc @definition.function) +) + +( + (comment)* @doc + . + (lexical_declaration + (variable_declarator + name: (identifier) @name + value: [ + (arrow_function + parameters: (formal_parameters) @parameters.definition.function) + (function_expression + parameters: (formal_parameters) @parameters.definition.function) + ]) @definition.function) + (#strip! @doc "^[\\s\\*/]+|^[\\s\\*/]$") + (#select-adjacent! @doc @definition.function) +) + +( + (comment)* @doc + . + (variable_declaration + (variable_declarator + name: (identifier) @name + value: [ + (arrow_function + parameters: (formal_parameters) @parameters.definition.function) + (function_expression + parameters: (formal_parameters) @parameters.definition.function) + ]) @definition.function) + (#strip! @doc "^[\\s\\*/]+|^[\\s\\*/]$") + (#select-adjacent! @doc @definition.function) +) + +; Variable declarations (let, const, var) - capture each declarator separately +(variable_declarator + name: (identifier) @name.definition.variable) @definition.variable + +; Also capture from parent declarations for context +(variable_declaration + (variable_declarator + name: (identifier) @name.definition.variable)) @definition.variable + +(lexical_declaration + (variable_declarator + name: (identifier) @name.definition.variable)) @definition.variable + +; Destructuring assignments - capture all identifiers in destructuring patterns +(shorthand_property_identifier_pattern) @name.definition.variable @definition.variable + +; Array destructuring - capture the whole pattern for manual processing +(lexical_declaration + (variable_declarator + name: (array_pattern) @array_pattern)) @definition.variable + +(variable_declaration + (variable_declarator + name: (array_pattern) @array_pattern)) @definition.variable + +; Class field declarations +(field_definition + property: (property_identifier) @name.definition.member_variable) @definition.variable + +; Assignment expressions for member variables (this.property = value) +(assignment_expression + left: (member_expression + object: (this) + property: (property_identifier) @name.definition.member_variable)) @definition.variable + +; Object property assignments +(assignment_expression + left: (member_expression + property: (property_identifier) @name.definition.member_variable)) @definition.variable + +; JSON object definitions +(object) @object.definition + +; JSON object key-value pairs +(pair + key: (string) @property.name.definition + value: [ + (object) @object.value + (array) @array.value + (string) @string.value + (number) @number.value + (true) @boolean.value + (false) @boolean.value + (null) @null.value + ] +) @property.definition + +; JSON array definitions +(array) @array.definition + +; Decorated method definitions +( + [ + (method_definition + decorator: (decorator) + name: (property_identifier) @name + parameters: (formal_parameters) @parameters.definition.method) @definition.method + (method_definition + decorator: (decorator + (call_expression + function: (identifier) @decorator_name)) + name: (property_identifier) @name + parameters: (formal_parameters) @parameters.definition.method) @definition.method + ] + (#not-eq? @name "constructor") +) + +; Decorated class definitions +( + [ + (class + decorator: (decorator) + name: (_) @name.definition.class) @definition.class + (class_declaration + decorator: (decorator) + name: (_) @name.definition.class) @definition.class + ] +) + +; Capture method names in decorated classes +( + (class_declaration + decorator: (decorator) + body: (class_body + (method_definition + name: (property_identifier) @name + parameters: (formal_parameters) @parameters.definition.method) @definition.method)) + (#not-eq? @name "constructor") +) +`; + +// ../../../src/services/CT-tree-sitter/queries/jsx.ts +var jsx_default = `${javascript_default} + +; === React Function Components (override JavaScript base patterns) === + +( + (comment)* @doc + . + (function_declaration + name: (identifier) @name.definition.function + parameters: (formal_parameters) @parameters.definition.function + body: (statement_block) @body.definition.function) @definition.function + (#strip! @doc "^[\\s\\*/]+|^[\\s\\*/]$") + (#select-adjacent! @doc @definition.function) +) + +( + (comment)* @doc + . + (lexical_declaration + (variable_declarator + name: (identifier) @name.definition.function + value: (arrow_function + parameters: (formal_parameters) @parameters.definition.function + ) + ) + ) @definition.function + (#strip! @doc "^[\\s\\*/]+|^[\\s\\*/]$") + (#select-adjacent! @doc @definition.function) +) + +( + (comment)* @doc + . + (variable_declaration + (variable_declarator + name: (identifier) @name.definition.function + value: (arrow_function + parameters: (formal_parameters) @parameters.definition.function + ) + ) + ) @definition.function + (#strip! @doc "^[\\s\\*/]+|^[\\s\\*/]$") + (#select-adjacent! @doc @definition.function) +) + +; === JSX Elements === + +(jsx_element + open_tag: (jsx_opening_element + name: (identifier) @name.jsx_element)) @definition.jsx_element + +(jsx_self_closing_element + name: (identifier) @name.jsx_element) @definition.jsx_element + +; === Array pattern destructuring (for useState hooks) === + +(lexical_declaration + (variable_declarator + name: (array_pattern) @array_pattern)) @definition.variable + +(variable_declaration + (variable_declarator + name: (array_pattern) @array_pattern)) @definition.variable + +; === Function calls (for hooks like useEffect) === + +(call_expression + function: (identifier) @name.definition.function) @definition.function_call +`; + +// ../../../src/services/CT-tree-sitter/queries/java.ts +var java_default = ` +; Import declarations +(import_declaration + (scoped_identifier) @name.definition.import) @definition.import + +; Package declarations +(package_declaration + (scoped_identifier) @name.definition.package) @definition.package + +; Class declarations +(class_declaration + name: (identifier) @name.definition.class) @definition.class + +; Interface declarations +(interface_declaration + name: (identifier) @name.definition.interface) @definition.interface + +; Enum declarations +(enum_declaration + name: (identifier) @name.definition.enum) @definition.enum + +; Record declarations +(record_declaration + name: (identifier) @name.definition.record) @definition.record + +; Annotation type declarations +(annotation_type_declaration + name: (identifier) @name.definition.annotation) @definition.annotation + +; Annotation type element declarations (annotation methods) +(annotation_type_element_declaration + name: (identifier) @name.definition.method) @definition.method + +; Method declarations with parameters and body +(method_declaration + name: (identifier) @name.definition.method + parameters: (formal_parameters) @parameters.definition.method + body: (block) @body.definition.method) @definition.method + +; Abstract method declarations (interface methods without body) +(method_declaration + name: (identifier) @name.definition.method + parameters: (formal_parameters) @parameters.definition.method) @definition.method + +; Constructor declarations +(constructor_declaration + name: (identifier) @name.definition.constructor + parameters: (formal_parameters) @parameters.definition.constructor + body: (constructor_body) @body.definition.constructor) @definition.constructor + +; Field declarations - handle multiple declarators +(field_declaration + declarator: (variable_declarator + name: (identifier) @name.definition.field)) @definition.field + +; Enum constant declarations +(enum_declaration + body: (enum_body + (enum_constant + name: (identifier) @name.definition.enum_constant))) @definition.enum_constant + +; Static initializers +(static_initializer) @definition.static_initializer + +; Instance initializers +(block) @definition.instance_initializer +`; + +// ../../../src/services/CT-tree-sitter/queries/rust.ts +var rust_default = ` +; Function definitions +(function_item + name: (identifier) @name.definition.function + parameters: (parameters) @parameters.definition.function + body: (block) @body.definition.function) @definition.function + +; Struct definitions and their fields +(struct_item + name: (type_identifier) @name.definition.struct + body: (field_declaration_list + (field_declaration + name: (field_identifier) @name.definition.struct_field)*)) @definition.struct + +; Tuple struct definitions +(struct_item + name: (type_identifier) @name.definition.struct + body: (ordered_field_declaration_list)*) @definition.struct + +; Unit struct definitions +(struct_item + name: (type_identifier) @name.definition.struct) @definition.struct + +; Enum definitions with variants +(enum_item + name: (type_identifier) @name.definition.enum + body: (enum_variant_list + (enum_variant + name: (identifier) @name.definition.enum_variant)*)) @definition.enum + +; Trait definitions and their methods +(trait_item + name: (type_identifier) @name.definition.trait + body: (declaration_list + (function_signature_item + name: (identifier) @name.definition.trait_method)*)) @definition.trait + +; Impl blocks (inherent implementation) and their methods +(impl_item + type: (type_identifier) @name.definition.impl + body: (declaration_list + (function_item + name: (identifier) @name.definition.method + parameters: (parameters) @parameters.definition.method + body: (block) @body.definition.method)*)) @definition.impl + +; Trait implementations and their methods +(impl_item + trait: (type_identifier) @name.definition.impl_trait + type: (type_identifier) @name.definition.impl_for + body: (declaration_list + (function_item + name: (identifier) @name.definition.method + parameters: (parameters) @parameters.definition.method + body: (block) @body.definition.method)*)) @definition.impl_trait + +; Module definitions +(mod_item + name: (identifier) @name.definition.module) @definition.module + +; Macro definitions (macro_rules!) +(macro_definition + name: (identifier) @name.definition.macro) @definition.macro + +; Type aliases +(type_item + name: (type_identifier) @name.definition.type_alias) @definition.type_alias + +; Constants +(const_item + name: (identifier) @name.definition.constant) @definition.constant + +; Static items +(static_item + name: (identifier) @name.definition.static) @definition.static + +; Use declarations (imports) +(use_declaration) @definition.use_declaration + +; Let bindings (local variables) +(let_declaration + pattern: (identifier) @name.definition.variable) @definition.variable + +; Associated functions and methods in impl blocks +(impl_item + body: (declaration_list)*) @definition.method_container + +; Function parameters capture +(function_item + parameters: (parameters + (parameter + pattern: (identifier) @name.definition.parameter)*)) + +; Associated types in traits +(trait_item + body: (declaration_list + (associated_type + name: (type_identifier) @name.definition.associated_type)*)) + +; Associated constants in traits and impls +(trait_item + body: (declaration_list + (const_item + name: (identifier) @name.definition.trait_constant)*)) + +(impl_item + body: (declaration_list + (const_item + name: (identifier) @name.definition.impl_constant)*)) +`; + +// ../../../src/services/CT-tree-sitter/queries/ruby.ts +var ruby_default = ` +; Method definitions +(method + name: (identifier) @name.definition.method) @definition.method + +; Singleton methods +(singleton_method + object: (_) + name: (identifier) @name.definition.method) @definition.method + +; Method aliases +(alias + name: (_) @name.definition.method) @definition.method + +; Class definitions +(class + name: [ + (constant) @name.definition.class + (scope_resolution + name: (_) @name.definition.class) + ]) @definition.class + +; Singleton classes +(singleton_class + value: [ + (constant) @name.definition.class + (scope_resolution + name: (_) @name.definition.class) + ]) @definition.class + +; Module definitions +(module + name: [ + (constant) @name.definition.module + (scope_resolution + name: (_) @name.definition.module) + ]) @definition.module + +; Constants +(assignment + left: (constant) @name.definition.constant) @definition.constant + +; Global variables +(global_variable) @definition.global_variable + +; Instance variables +(instance_variable) @definition.instance_variable + +; Class variables +(class_variable) @definition.class_variable + +; Symbols +(simple_symbol) @definition.symbol +(hash_key_symbol) @definition.symbol + +; Blocks +(block) @definition.block +(do_block) @definition.block + +; Basic mixin statements - capture all include/extend/prepend calls +(call + method: (identifier) @_mixin_method + arguments: (argument_list + (constant) @name.definition.mixin) + (#match? @_mixin_method "^(include|extend|prepend)$")) @definition.mixin + +; Mixin module definition +(module + name: (constant) @name.definition.mixin_module + (#match? @name.definition.mixin_module ".*Module$")) @definition.mixin_module + +; Mixin-related methods +(method + name: (identifier) @name.definition.mixin_method + (#match? @name.definition.mixin_method "(included|extended|prepended)_method")) @definition.mixin_method + +; Singleton class blocks +(singleton_class) @definition.singleton_class + +; Class methods in singleton context +(singleton_method + object: (self) + name: (identifier) @name.definition.singleton_method) @definition.singleton_method + +; Attribute accessors +(call + method: (identifier) @_attr_accessor + arguments: (argument_list + (_) @name.definition.attr_accessor) + (#eq? @_attr_accessor "attr_accessor")) @definition.attr_accessor + +(call + method: (identifier) @_attr_reader + arguments: (argument_list + (_) @name.definition.attr_reader) + (#eq? @_attr_reader "attr_reader")) @definition.attr_reader + +(call + method: (identifier) @_attr_writer + arguments: (argument_list + (_) @name.definition.attr_writer) + (#eq? @_attr_writer "attr_writer")) @definition.attr_writer + +; Class macros (Rails-like) +(call + method: (identifier) @_macro_name + arguments: (argument_list + (_) @name.definition.class_macro) + (#match? @_macro_name "^(has_many|belongs_to|has_one|validates|scope|before_action|after_action)$")) @definition.class_macro + +; Exception handling +(begin) @definition.begin +(rescue) @definition.rescue +(ensure) @definition.ensure + +; Keyword arguments +(keyword_parameter + name: (identifier) @name.definition.keyword_parameter) @definition.keyword_parameter + +; Splat operators +(splat_parameter) @definition.splat_parameter +(splat_argument) @definition.splat_argument + +; Hash syntax variants +(pair + key: (_) @name.definition.hash_key) @definition.hash_pair + +; String interpolation - capture the string with interpolation and surrounding context +(assignment + left: (identifier) @name.definition.string_var + right: (string + (interpolation))) @definition.string_interpolation + +; Regular expressions - capture the regex pattern and assignment +(assignment + left: (identifier) @name.definition.regex_var + right: (regex)) @definition.regex_assignment + +; Pattern matching - capture the entire case_match structure +(case_match) @definition.case_match + +; Pattern matching - capture in_clause with hash pattern +(in_clause + pattern: (hash_pattern)) @definition.hash_pattern_clause + +; Endless methods - capture the method definition with name and surrounding context +(comment) @_endless_method_comment +(#match? @_endless_method_comment "Ruby 3.0\\+ endless method") +(method + name: (identifier) @name.definition.endless_method + body: (binary + operator: "=")) @definition.endless_method + +; Pin operator - capture the entire in_clause with variable_reference_pattern +(in_clause + pattern: (variable_reference_pattern)) @definition.pin_pattern_clause + +; Shorthand hash syntax - capture the method containing shorthand hash +(comment) @_shorthand_hash_comment +(#match? @_shorthand_hash_comment "Ruby 3.1\\+ shorthand hash syntax") +(method + name: (identifier) @name.definition.shorthand_method) @definition.shorthand_method + +; Shorthand hash syntax - capture the hash with shorthand syntax +(hash + (pair + (hash_key_symbol) + ":")) @definition.shorthand_hash + +; Capture larger contexts for features that need at least 4 lines + +; Capture the entire program to include all comments and code +(program) @definition.program + +; Capture all comments +(comment) @definition.comment + +; Capture all method definitions +(method) @definition.method_all +`; + +// ../../../src/services/CT-tree-sitter/queries/cpp.ts +var cpp_default = ` +; Include directives +(preproc_include + path: (_) @name.definition.include) @definition.include + +; Function definitions +(function_definition + declarator: (function_declarator + declarator: (identifier) @name.definition.function + parameters: (parameter_list) @parameters.definition.function) + body: (compound_statement) @body.definition.function) @definition.function + +; Function declarations (prototypes) +(declaration + declarator: (function_declarator + declarator: (identifier) @name.definition.function + parameters: (parameter_list) @parameters.definition.function)) @definition.function + +; Struct definitions with fields +(struct_specifier + name: (type_identifier) @name.definition.struct + body: (field_declaration_list) @body.definition.struct) @definition.struct + +; Union definitions with fields +(union_specifier + name: (type_identifier) @name.definition.union + body: (field_declaration_list) @body.definition.union) @definition.union + +; Enum definitions with values +(enum_specifier + name: (type_identifier) @name.definition.enum + body: (enumerator_list) @body.definition.enum) @definition.enum + +; Typedef declarations +(type_definition + declarator: (type_identifier) @name.definition.type) @definition.type + +; Global variables +(declaration + declarator: (identifier) @name.definition.variable) @definition.variable + +(declaration + declarator: (init_declarator + declarator: (identifier) @name.definition.variable)) @definition.variable + +(declaration + declarator: (init_declarator + declarator: (array_declarator + declarator: (identifier) @name.definition.variable))) @definition.variable + +(declaration + declarator: (pointer_declarator + declarator: (identifier) @name.definition.variable)) @definition.variable + +(declaration + declarator: (pointer_declarator + declarator: (pointer_declarator + declarator: (identifier) @name.definition.variable))) @definition.variable + +(declaration + declarator: (init_declarator + declarator: (pointer_declarator + declarator: (identifier) @name.definition.variable))) @definition.variable + +(declaration + declarator: (function_declarator + declarator: (parenthesized_declarator + (pointer_declarator + declarator: (identifier) @name.definition.variable)))) @definition.variable + +(declaration + declarator: (array_declarator + declarator: (identifier) @name.definition.variable)) @definition.variable + +(declaration + declarator: (array_declarator + declarator: (array_declarator + declarator: (identifier) @name.definition.variable))) @definition.variable + +(declaration + declarator: (array_declarator + declarator: (array_declarator + declarator: (array_declarator + declarator: (identifier) @name.definition.variable)))) @definition.variable + +; Static variables +(declaration + (storage_class_specifier) @storage + declarator: (identifier) @name.definition.variable) @definition.variable + +(declaration + (storage_class_specifier) @storage + declarator: (init_declarator + declarator: (identifier) @name.definition.variable)) @definition.variable + +(declaration + (storage_class_specifier) @storage + declarator: (array_declarator + declarator: (identifier) @name.definition.variable)) @definition.variable + +(declaration + (storage_class_specifier) @storage + declarator: (pointer_declarator + declarator: (identifier) @name.definition.variable)) @definition.variable + +; Object-like macros +(preproc_def + name: (identifier) @name.definition.macro) @definition.macro + +; Function-like macros +(preproc_function_def + name: (identifier) @name.definition.macro + parameters: (preproc_params) @parameters.definition.macro) @definition.macro + +; Field declarations (members) +(field_declaration + declarator: (field_identifier) @name.definition.field) @definition.field + +; Enum values/enumerators +(enumerator + name: (identifier) @name.definition.enumerator) @definition.enumerator + +; Parameter declarations +(parameter_declaration + declarator: (identifier) @name.definition.parameter) @definition.parameter + +; C++ specific constructs + +; Destructor definitions +(function_definition + declarator: (function_declarator + declarator: (destructor_name) @name.definition.destructor + parameters: (parameter_list) @parameters.definition.destructor) + body: (compound_statement) @body.definition.destructor) @definition.destructor + +; Operator overloading +(function_definition + declarator: (function_declarator + declarator: (operator_name) @name.definition.operator + parameters: (parameter_list) @parameters.definition.operator) + body: (compound_statement) @body.definition.operator) @definition.operator + +; Method definitions (class/struct members) +(function_definition + declarator: (function_declarator + declarator: (field_identifier) @name.definition.method + parameters: (parameter_list) @parameters.definition.method) + body: (compound_statement) @body.definition.method) @definition.method + +; Class definitions +(class_specifier + name: (type_identifier) @name.definition.class + body: (field_declaration_list) @body.definition.class) @definition.class + +; Namespace definitions +(namespace_definition + name: (namespace_identifier) @name.definition.namespace + body: (declaration_list) @body.definition.namespace) @definition.namespace + +; Template declarations +(template_declaration + parameters: (template_parameter_list) @parameters.definition.template + (class_specifier + name: (type_identifier) @name.definition.template.class)) @definition.template + +; Template function declarations +(template_declaration + parameters: (template_parameter_list) @parameters.definition.template + (function_definition + declarator: (function_declarator + declarator: (identifier) @name.definition.template.function))) @definition.template + +; Typedef declarations +(type_definition + declarator: (type_identifier) @name.definition.typedef) @definition.typedef + +; Using declarations +(using_declaration) @definition.using + +; More variable patterns for pointers and references +(declaration + declarator: (init_declarator + declarator: (identifier) @name.definition.variable + value: (_))) @definition.variable + +; Additional pointer declarator patterns +(declaration + type: (_) + declarator: (pointer_declarator + declarator: (identifier) @name.definition.variable)) @definition.variable + +; Reference variables (using & in type) +(declaration + type: (_) + declarator: (identifier) @name.definition.variable) @definition.variable +`; + +// ../../../src/services/CT-tree-sitter/queries/c.ts +var c_default = ` +; Include directives +(preproc_include + path: (_) @name.definition.include) @definition.include + +; Function definitions +(function_definition + declarator: (function_declarator + declarator: (identifier) @name.definition.function + parameters: (parameter_list) @parameters.definition.function) + body: (compound_statement) @body.definition.function) @definition.function + +; Function declarations (prototypes) +(declaration + declarator: (function_declarator + declarator: (identifier) @name.definition.function + parameters: (parameter_list) @parameters.definition.function)) @definition.function + +; Struct definitions with fields +(struct_specifier + name: (type_identifier) @name.definition.struct + body: (field_declaration_list) @body.definition.struct) @definition.struct + +; Union definitions with fields +(union_specifier + name: (type_identifier) @name.definition.union + body: (field_declaration_list) @body.definition.union) @definition.union + +; Enum definitions with values +(enum_specifier + name: (type_identifier) @name.definition.enum + body: (enumerator_list) @body.definition.enum) @definition.enum + +; Typedef declarations +(type_definition + declarator: (type_identifier) @name.definition.type) @definition.type + +; Global variables +(declaration + declarator: (identifier) @name.definition.variable) @definition.variable + +(declaration + declarator: (init_declarator + declarator: (identifier) @name.definition.variable)) @definition.variable + +(declaration + declarator: (init_declarator + declarator: (array_declarator + declarator: (identifier) @name.definition.variable))) @definition.variable + +(declaration + declarator: (pointer_declarator + declarator: (identifier) @name.definition.variable)) @definition.variable + +(declaration + declarator: (pointer_declarator + declarator: (pointer_declarator + declarator: (identifier) @name.definition.variable))) @definition.variable + +(declaration + declarator: (init_declarator + declarator: (pointer_declarator + declarator: (identifier) @name.definition.variable))) @definition.variable + +(declaration + declarator: (function_declarator + declarator: (parenthesized_declarator + (pointer_declarator + declarator: (identifier) @name.definition.variable)))) @definition.variable + +(declaration + declarator: (array_declarator + declarator: (identifier) @name.definition.variable)) @definition.variable + +(declaration + declarator: (array_declarator + declarator: (array_declarator + declarator: (identifier) @name.definition.variable))) @definition.variable + +(declaration + declarator: (array_declarator + declarator: (array_declarator + declarator: (array_declarator + declarator: (identifier) @name.definition.variable)))) @definition.variable + +; Static variables +(declaration + (storage_class_specifier) @storage + declarator: (identifier) @name.definition.variable) @definition.variable + +(declaration + (storage_class_specifier) @storage + declarator: (init_declarator + declarator: (identifier) @name.definition.variable)) @definition.variable + +(declaration + (storage_class_specifier) @storage + declarator: (array_declarator + declarator: (identifier) @name.definition.variable)) @definition.variable + +(declaration + (storage_class_specifier) @storage + declarator: (pointer_declarator + declarator: (identifier) @name.definition.variable)) @definition.variable + +; Object-like macros +(preproc_def + name: (identifier) @name.definition.macro) @definition.macro + +; Function-like macros +(preproc_function_def + name: (identifier) @name.definition.macro + parameters: (preproc_params) @parameters.definition.macro) @definition.macro + +; Field declarations (members) +(field_declaration + declarator: (field_identifier) @name.definition.field) @definition.field + +; Enum values/enumerators +(enumerator + name: (identifier) @name.definition.enumerator) @definition.enumerator + +; Parameter declarations +(parameter_declaration + declarator: (identifier) @name.definition.parameter) @definition.parameter +`; + +// ../../../src/services/CT-tree-sitter/queries/c-sharp.ts +var c_sharp_default = ` +; Using directives +(using_directive) @name.definition.using + +; Namespace declarations (including file-scoped) +(namespace_declaration + name: (identifier) @name.definition.namespace) +(file_scoped_namespace_declaration + name: (identifier) @name.definition.namespace) + +; Class declarations (including generic, static, abstract, partial, nested) +(class_declaration + name: (identifier) @name.definition.class) + +; Interface declarations +(interface_declaration + name: (identifier) @name.definition.interface) + +; Struct declarations +(struct_declaration + name: (identifier) @name.definition.struct) + +; Enum declarations +(enum_declaration + name: (identifier) @name.definition.enum) + +; Record declarations +(record_declaration + name: (identifier) @name.definition.record) + +; Method declarations (including async, static, generic) +(method_declaration + name: (identifier) @name.definition.method + parameter_list: (parameter_list) @parameters.definition.method + body: (block) @body.definition.method) @definition.method + +; Property declarations +(property_declaration + name: (identifier) @name.definition.property) + +; Event declarations +(event_declaration + name: (identifier) @name.definition.event) + +; Delegate declarations +(delegate_declaration + name: (identifier) @name.definition.delegate) + +; Attribute declarations +(class_declaration + (attribute_list + (attribute + name: (identifier) @name.definition.attribute))) + +; Generic type parameters +(type_parameter_list + (type_parameter + name: (identifier) @name.definition.type_parameter)) + +; LINQ expressions +(query_expression) @name.definition.linq_expression +`; + +// ../../../src/services/CT-tree-sitter/queries/go.ts +var go_default = ` +; Package declarations +(package_clause + (package_identifier) @name.definition.package) + +; Import declarations +(import_declaration + (import_spec_list + (import_spec path: (_) @name.definition.import))) + +; Const declarations +(const_declaration) @definition.const +(const_declaration + (const_spec name: (identifier) @name.definition.const)) + +; Var declarations +(var_declaration) @definition.var +(var_declaration + (var_spec name: (identifier) @name.definition.var)) + +; Interface declarations +(type_declaration) @definition.interface +(type_declaration + (type_spec + name: (type_identifier) @name.definition.interface + type: (interface_type))) + +; Struct declarations +(type_declaration) @definition.struct +(type_declaration + (type_spec + name: (type_identifier) @name.definition.struct + type: (struct_type))) + +; Type declarations +(type_declaration) @definition.type +(type_declaration + (type_spec + name: (type_identifier) @name.definition.type)) + +; Function declarations with result (parameter_list) +(function_declaration + name: (identifier) @name.definition.function + parameters: (parameter_list) @parameters.definition.function + result: (parameter_list) @result.definition.function + body: (block) @body.definition.function) @definition.function + +; Function declarations with result (type_identifier) +(function_declaration + name: (identifier) @name.definition.function + parameters: (parameter_list) @parameters.definition.function + result: (type_identifier) @result.definition.function + body: (block) @body.definition.function) @definition.function + +; Function declarations without result +(function_declaration + name: (identifier) @name.definition.function + parameters: (parameter_list) @parameters.definition.function + body: (block) @body.definition.function) @definition.function + +; Method declarations with result (parameter_list) +(method_declaration + receiver: (parameter_list + (parameter_declaration + (pointer_type + (type_identifier) @class.definition.method + ) + ) + ) @self.definition.method + name: (field_identifier) @name.definition.method + parameters: (parameter_list) @parameters.definition.method + result: (parameter_list) @result.definition.method + body: (block) @body.definition.method) @definition.method + +; Method declarations with result (type_identifier) +(method_declaration + receiver: (parameter_list + (parameter_declaration + (pointer_type + (type_identifier) @class.definition.method + ) + ) + ) @self.definition.method + name: (field_identifier) @name.definition.method + parameters: (parameter_list) @parameters.definition.method + result: (type_identifier) @result.definition.method + body: (block) @body.definition.method) @definition.method + +; Method declarations without result +(method_declaration + receiver: (parameter_list + (parameter_declaration + (pointer_type + (type_identifier) @class.definition.method + ) + ) + ) @self.definition.method + name: (field_identifier) @name.definition.method + parameters: (parameter_list) @parameters.definition.method + body: (block) @body.definition.method) @definition.method + +; Channel operations +(channel_type) @name.definition.channel + +; Goroutine declarations +(go_statement) @name.definition.goroutine + +; Defer statements +(defer_statement) @name.definition.defer + +; Select statements +(select_statement) @name.definition.select +`; + +// ../../../src/services/CT-tree-sitter/queries/swift.ts +var swift_default = ` +; Import declarations +(import_declaration) @definition.import +(import_declaration + (identifier) @name.definition.import) + +; Class declarations (includes class, struct, enum, extension) +(class_declaration) @definition.class + +; Class name capture (for class, struct, enum) +(class_declaration + (type_identifier) @name.definition.class) + +; Extension name capture (extension extends user_type) +(class_declaration + "extension" + (user_type + (type_identifier) @name.definition.class)) + +; Protocol declarations +(protocol_declaration + (type_identifier) @name.definition.protocol) @definition.protocol + +; Function declarations (both methods and global functions) +(function_declaration + (simple_identifier) @name.definition.method) @definition.method + +; Property declarations (all property declarations) +(property_declaration + (pattern + (simple_identifier) @name.definition.property)) @definition.property + +; Computed properties (property declarations with computed_property body) +(property_declaration + (pattern + (simple_identifier) @name.definition.computed_property) + (computed_property)) @definition.computed_property + +; Global variables and constants (property_declaration at top level) +(source_file + (property_declaration + (pattern + (simple_identifier) @name.definition.global_var)) @definition.global_var) + +; Initializers +(init_declaration + "init" @name.definition.initializer) @definition.initializer + +; Deinitializers +(deinit_declaration + "deinit" @name.definition.deinitializer) @definition.deinitializer + +; Type alias +(typealias_declaration + (type_identifier) @name.definition.type_alias) @definition.type_alias + +; Protocol function declarations +(protocol_function_declaration + (simple_identifier) @name.definition.protocol_method) @definition.protocol_method +`; + +// ../../../src/services/CT-tree-sitter/queries/kotlin.ts +var kotlin_default = ` +; Based on actual tree-sitter-kotlin grammar +; Package declarations +(package_header + (identifier) @name.definition.package) @definition.package + +; Import declarations - capture the full import path including wildcards +(import_header) @definition.import +(import_header + (identifier) @name.definition.import) + +; Class declarations (includes all types: class, interface, object, enum, etc.) +(class_declaration + (type_identifier) @name.definition.class) @definition.class + +; Object declarations (try alternative naming) +(object_declaration + (type_identifier) @name.definition.object) @definition.object + +; Function declarations +(function_declaration + (simple_identifier) @name.definition.function) @definition.function + +; Property declarations +(property_declaration + (variable_declaration + (simple_identifier) @name.definition.property) +) @definition.property + +; Type alias declarations +(type_alias + (type_identifier) @name.definition.type_alias) @definition.type_alias + +`; + +// ../../../src/services/CT-tree-sitter/queries/css.ts +var css_default = ` +; CSS\u89C4\u5219\u96C6\uFF08\u5305\u542B\u6240\u6709\u7C7B\u578B\u7684\u9009\u62E9\u5668\uFF09 +(rule_set + (selectors) @selectors.definition.rule + (block) @body.definition.rule) @definition.rule + +; CSS\u58F0\u660E\uFF08\u5C5E\u6027\uFF09- \u5904\u7406\u591A\u79CD\u503C\u7C7B\u578B +(declaration + (property_name) @property.definition.declaration + (plain_value) @value.definition.declaration) @definition.declaration + +(declaration + (property_name) @property.definition.declaration + (color_value) @value.definition.declaration) @definition.declaration + +(declaration + (property_name) @property.definition.declaration + (integer_value) @value.definition.declaration) @definition.declaration + +; @import\u8BED\u53E5 - \u5B57\u7B26\u4E32\u5F62\u5F0F +(import_statement + (string_value) @name.definition.import) @definition.import + +; @import\u8BED\u53E5 - url()\u51FD\u6570\u5F62\u5F0F +(import_statement + (call_expression + (function_name) @func.definition.import + (arguments + (string_value) @name.definition.import))) @definition.import + +; CSS\u51FD\u6570\u8C03\u7528\uFF08\u5728\u58F0\u660E\u503C\u4E2D\uFF09 +(declaration + (property_name) @property.definition.function + (call_expression + (function_name) @name.definition.function + (arguments) @args.definition.function)) @definition.function + +; @keyframes\u52A8\u753B +(keyframes_statement + (keyframes_name) @name.definition.keyframes + (keyframe_block_list) @body.definition.keyframes) @definition.keyframes + +; @media\u67E5\u8BE2 - \u652F\u6301\u4E0D\u540C\u7C7B\u578B\u7684\u67E5\u8BE2 +(media_statement + (binary_query) @query.definition.media + (block) @body.definition.media) @definition.media + +(media_statement + (feature_query) @query.definition.media + (block) @body.definition.media) @definition.media + +(media_statement + (keyword_query) @query.definition.media + (block) @body.definition.media) @definition.media +`; + +// ../../../src/services/CT-tree-sitter/queries/elixir.ts +var elixir_default = String.raw` +; Module, Protocol, and Implementation definitions +(call + target: (identifier) @function + (arguments) @args + (do_block)? + (#match? @function "^(defmodule|defprotocol|defimpl)$")) @definition.module + +; Function definitions +(call + target: (identifier) @function + (arguments) @args + (do_block)? + (#eq? @function "def")) @definition.function + +; Macro definitions +(call + target: (identifier) @function + (arguments) @args + (do_block)? + (#eq? @function "defmacro")) @definition.macro + +; Struct definitions +(call + target: (identifier) @function + (arguments (list)) + (#eq? @function "defstruct")) @definition.struct + +; Guard definitions +(call + target: (identifier) @function + (arguments) @args + (#eq? @function "defguard")) @definition.guard + +; Behaviour callback definitions +(call + target: (identifier) @function + (arguments) @args + (#eq? @function "@callback")) @definition.behaviour + +; Sigils +(sigil + (sigil_name) + (quoted_content)) @definition.sigil + +; Module attributes +(unary_operator + operator: "@" + operand: (call)) @definition.attribute + +; Test definitions with string name and map args +(call + target: (identifier) @function + (arguments + (string) + (map)) + (#eq? @function "test")) @definition.test + +; Pipeline operator usage +(binary_operator + operator: "|>" + left: (_) @left + right: (_) @right) @definition.pipeline + +; For comprehensions with generator and filter clauses +(call + target: (identifier) @function + (arguments) @args + (do_block)? + (#eq? @function "for")) @definition.for_comprehension`; + +// ../../../src/services/CT-tree-sitter/queries/html.ts +var html_default = ` +; Document structure +(document) @definition.document + +; Void elements (self-closing) - using explicit element names for better readability +; Area element +(element + (start_tag + (tag_name) @name.definition.void + (#eq? @name.definition.void "area")) + (#not-has? end_tag)) @definition.void_element + +; Base element +(element + (start_tag + (tag_name) @name.definition.void + (#eq? @name.definition.void "base")) + (#not-has? end_tag)) @definition.void_element + +; Line break element +(element + (start_tag + (tag_name) @name.definition.void + (#eq? @name.definition.void "br")) + (#not-has? end_tag)) @definition.void_element + +; Column element +(element + (start_tag + (tag_name) @name.definition.void + (#eq? @name.definition.void "col")) + (#not-has? end_tag)) @definition.void_element + +; Embed element +(element + (start_tag + (tag_name) @name.definition.void + (#eq? @name.definition.void "embed")) + (#not-has? end_tag)) @definition.void_element + +; Horizontal rule element +(element + (start_tag + (tag_name) @name.definition.void + (#eq? @name.definition.void "hr")) + (#not-has? end_tag)) @definition.void_element + +; Image element +(element + (start_tag + (tag_name) @name.definition.void + (#eq? @name.definition.void "img")) + (#not-has? end_tag)) @definition.void_element + +; Input element +(element + (start_tag + (tag_name) @name.definition.void + (#eq? @name.definition.void "input")) + (#not-has? end_tag)) @definition.void_element + +; Link element +(element + (start_tag + (tag_name) @name.definition.void + (#eq? @name.definition.void "link")) + (#not-has? end_tag)) @definition.void_element + +; Meta element +(element + (start_tag + (tag_name) @name.definition.void + (#eq? @name.definition.void "meta")) + (#not-has? end_tag)) @definition.void_element + +; Parameter element +(element + (start_tag + (tag_name) @name.definition.void + (#eq? @name.definition.void "param")) + (#not-has? end_tag)) @definition.void_element + +; Source element +(element + (start_tag + (tag_name) @name.definition.void + (#eq? @name.definition.void "source")) + (#not-has? end_tag)) @definition.void_element + +; Track element +(element + (start_tag + (tag_name) @name.definition.void + (#eq? @name.definition.void "track")) + (#not-has? end_tag)) @definition.void_element + +; Word break opportunity element +(element + (start_tag + (tag_name) @name.definition.void + (#eq? @name.definition.void "wbr")) + (#not-has? end_tag)) @definition.void_element + +; Elements with content (exclude script and style) +(element + (start_tag + (tag_name) @name.definition) + (#not-eq? @name.definition "script") + (#not-eq? @name.definition "style")) @definition.element + +; Script elements +(script_element + (start_tag + (tag_name) @name.definition)) @definition.script + +; Style elements +(style_element + (start_tag + (tag_name) @name.definition)) @definition.style + +; Attributes +(attribute + (attribute_name) @name.definition) @definition.attribute + +; Comments +(comment) @definition.comment + +; Text content +(text) @definition.text + +; Raw text content +(raw_text) @definition.raw_text + +; Self-closing tags +(self_closing_tag + (tag_name) @name.definition) @definition.self_closing_tag + +; Doctype declarations +(doctype) @definition.doctype + +; Multiple elements (parent with children) +(element + (element)+) @definition.nested_elements +`; + +// ../../../src/services/CT-tree-sitter/queries/lua.ts +var lua_default = String.raw` +; Function definitions +(function_definition_statement + name: (identifier) @name.definition.function + parameters: (parameters) @parameters.definition.function + body: (block) @body.definition.function) @definition.function + +(function_definition_statement + name: (variable + table: (identifier) + field: (identifier) @name.definition.method)) @definition.method + +(local_function_definition_statement + name: (identifier) @name.definition.function) @definition.function + +; Table constructors (class-like structures) +(local_variable_declaration + (variable_list + (variable name: (identifier) @name.definition.table)) + (expression_list + value: (table))) @definition.table + +; Variable declarations +(variable_assignment + (variable_list + (variable name: (identifier) @name.definition.variable))) @definition.variable + +; Local variable declarations +(local_variable_declaration + (variable_list + (variable name: (identifier) @name.definition.variable))) @definition.variable +`; + +// ../../../src/services/CT-tree-sitter/queries/ocaml.ts +var ocamlQuery = ` +; Captures module definitions +(module_definition + (module_binding + name: (module_name) @name.definition)) @definition.module + +; Captures type definitions +(type_definition + (type_binding + name: (type_constructor) @name.definition)) @definition.type + +; Captures function definitions +(value_definition + (let_binding + pattern: (value_name) @name.definition + (parameter))) @definition.function + +; Captures class definitions +(class_definition + (class_binding + name: (class_name) @name.definition)) @definition.class + +; Captures method definitions +(method_definition + name: (method_name) @name.definition) @definition.method + +; Captures value bindings +(value_definition + (let_binding + pattern: (value_name) @name.definition)) @definition.value +`; + +// ../../../src/services/CT-tree-sitter/queries/toml.ts +var tomlQuery = ` +; Tables - capture the entire table node +(table) @definition + +; Array tables - capture the entire array table node +(table_array_element) @definition + +; Key-value pairs - capture the entire pair +(pair) @definition + +; Arrays and inline tables +(array) @definition +(inline_table) @definition + +; Basic values +(string) @definition +(integer) @definition +(float) @definition +(boolean) @definition +(offset_date_time) @definition +(local_date) @definition +(local_time) @definition +`; + +// ../../../src/services/CT-tree-sitter/queries/systemrdl.ts +var systemrdl_default = ` +; Component declarations +(component_named_def + type: (component_type) + id: (id) @name.definition.component) @definition.component + +; Field declarations +(component_anon_def + type: (component_type (component_primary_type)) + body: (component_body + (component_body_elem + (property_assignment)))) @definition.field + +; Property declarations +(property_definition + (id) @name.definition.property) @definition.property + +; Parameter declarations +(component_inst + id: (id) @name.definition.parameter) @definition.parameter + +; Enum declarations +(enum_def + (id) @name.definition.enum) @definition.enum +`; + +// ../../../src/services/CT-tree-sitter/queries/tlaplus.ts +var tlaplus_default = ` +; Module declarations +(module + name: (identifier) @name.definition.module) @definition.module + +; Operator definitions with optional parameters +(operator_definition + name: (identifier) @name.definition.operator + parameter: (identifier)?) @definition.operator + +; Function definitions with bounds +(function_definition + name: (identifier) @name.definition.function + (quantifier_bound)?) @definition.function + +; Variable declarations +(variable_declaration + (identifier) @name.definition.variable) @definition.variable + +; Constant declarations +(constant_declaration + (identifier) @name.definition.constant) @definition.constant +`; + +// ../../../src/services/CT-tree-sitter/queries/zig.ts +var zigQuery = ` +; Functions +(function_declaration) @function.definition + +; Structs and containers +(variable_declaration + (identifier) @name + (struct_declaration) +) @container.definition + +; Enums +(variable_declaration + (identifier) @name + (enum_declaration) +) @container.definition + +; Variables and constants +(variable_declaration + (identifier) @name +) @variable.definition +`; + +// ../../../src/services/CT-tree-sitter/queries/embedded_template.ts +var embedded_template_default = ` +; Code blocks - class, module, method definitions +(directive + (code) @name.definition.code) @definition.directive + +; Output blocks - expressions +(output_directive + (code) @output.content) @output + +; Comments - documentation and section markers +(comment_directive + (comment) @name.definition.comment) @definition.comment +`; + +// ../../../src/services/CT-tree-sitter/queries/elisp.ts +var elispQuery = ` +; Function definitions - capture only name and actual function node +((function_definition + name: (symbol) @name.definition.function) @_func + (#match? @name.definition.function "^[^;]")) + +; Macro definitions - capture only name and actual macro node +((macro_definition + name: (symbol) @name.definition.macro) @_macro + (#match? @name.definition.macro "^[^;]")) + +; Custom forms - match defcustom specifically and avoid comments +((list + . (symbol) @_def + . (symbol) @name.definition.custom) @_custom + (#eq? @_def "defcustom") + (#match? @name.definition.custom "^[^;]")) + +; Face definitions - match defface specifically and avoid comments +((list + . (symbol) @_def + . (symbol) @name.definition.face) @_face + (#eq? @_def "defface") + (#match? @name.definition.face "^[^;]")) + +; Group definitions - match defgroup specifically and avoid comments +((list + . (symbol) @_def + . (symbol) @name.definition.group) @_group + (#eq? @_def "defgroup") + (#match? @name.definition.group "^[^;]")) + +; Advice definitions - match defadvice specifically and avoid comments +((list + . (symbol) @_def + . (symbol) @name.definition.advice) @_advice + (#eq? @_def "defadvice") + (#match? @name.definition.advice "^[^;]")) +`; + +// ../../../src/services/CT-tree-sitter/languageParser.ts +async function loadLanguage(langName) { + return await import_web_tree_sitter.default.Language.load(path.join(__dirname, `tree-sitter-${langName}.wasm`)); +} +var isParserInitialized = false; +async function initializeParser() { + if (!isParserInitialized) { + await import_web_tree_sitter.default.init(); + isParserInitialized = true; + } +} +async function loadRequiredLanguageParsers(filesToParse) { + await initializeParser(); + const extensionsToLoad = new Set(filesToParse.map((file) => path.extname(file).toLowerCase().slice(1))); + const parsers = {}; + for (const ext of extensionsToLoad) { + let language; + let query; + let parserKey = ext; + switch (ext) { + case "js": + case "json": + language = await loadLanguage("javascript"); + query = language.query(javascript_default); + break; + case "jsx": + language = await loadLanguage("javascript"); + query = language.query(jsx_default); + break; + case "ts": + language = await loadLanguage("typescript"); + query = language.query(typescript_default); + break; + case "tsx": + language = await loadLanguage("tsx"); + query = language.query(tsx_default); + break; + case "py": + language = await loadLanguage("python"); + query = language.query(python_default); + break; + case "rs": + language = await loadLanguage("rust"); + query = language.query(rust_default); + break; + case "go": + language = await loadLanguage("go"); + query = language.query(go_default); + break; + case "cpp": + case "hpp": + language = await loadLanguage("cpp"); + query = language.query(cpp_default); + break; + case "c": + case "h": + language = await loadLanguage("c"); + query = language.query(c_default); + break; + case "cs": + language = await loadLanguage("c_sharp"); + query = language.query(c_sharp_default); + break; + case "rb": + language = await loadLanguage("ruby"); + query = language.query(ruby_default); + break; + case "java": + language = await loadLanguage("java"); + query = language.query(java_default); + break; + case "php": + language = await loadLanguage("php"); + query = language.query(php_default); + break; + case "swift": + language = await loadLanguage("swift"); + query = language.query(swift_default); + break; + case "kt": + case "kts": + language = await loadLanguage("kotlin"); + query = language.query(kotlin_default); + break; + case "css": + language = await loadLanguage("css"); + query = language.query(css_default); + break; + case "html": + language = await loadLanguage("html"); + query = language.query(html_default); + break; + case "ml": + case "mli": + language = await loadLanguage("ocaml"); + query = language.query(ocamlQuery); + break; + case "scala": + language = await loadLanguage("scala"); + query = language.query(lua_default); + break; + case "sol": + language = await loadLanguage("solidity"); + query = language.query(solidityQuery); + break; + case "toml": + language = await loadLanguage("toml"); + query = language.query(tomlQuery); + break; + case "vue": + language = await loadLanguage("vue"); + query = language.query(vueQuery); + break; + case "lua": + language = await loadLanguage("lua"); + query = language.query(lua_default); + break; + case "rdl": + language = await loadLanguage("systemrdl"); + query = language.query(systemrdl_default); + break; + case "tla": + language = await loadLanguage("tlaplus"); + query = language.query(tlaplus_default); + break; + case "zig": + language = await loadLanguage("zig"); + query = language.query(zigQuery); + break; + case "ejs": + case "erb": + language = await loadLanguage("embedded_template"); + parserKey = "embedded_template"; + query = language.query(embedded_template_default); + break; + case "el": + language = await loadLanguage("elisp"); + query = language.query(elispQuery); + break; + case "ex": + case "exs": + language = await loadLanguage("elixir"); + query = language.query(elixir_default); + break; + default: + throw new Error(`Unsupported language: ${ext}`); + } + const parser = new import_web_tree_sitter.default(); + parser.setLanguage(language); + parsers[parserKey] = { parser, query }; + } + return parsers; +} + +// ../autocompletion/v2/utils/processUtils.ts +var symbolPairs = { + "(": ")", + "[": "]", + "{": "}", + // '<': '>', + "'": "'", + '"': '"', + "`": "`" +}; +var openSymbols = new Set(Object.keys(symbolPairs)); +var closeSymbols = new Set(Object.values(symbolPairs)); +function findFirstMatchingCloseSymbol(fullStr, splitStr) { + const splitIndex = fullStr.indexOf(splitStr); + if (splitIndex === -1) { + return { closeSymbol: "", suffixPrefix: "" }; + } + const partA = fullStr.substring(0, splitIndex); + const partB = fullStr.substring(splitIndex + splitStr.length); + const stackA = []; + for (let i2 = 0; i2 < partA.length; i2++) { + const char = partA[i2]; + if (char === "\\") { + i2++; + continue; + } + if (openSymbols.has(char)) { + if ((char === "'" || char === '"' || char === "`") && stackA.length > 0 && stackA[stackA.length - 1] === char) { + stackA.pop(); + } else { + stackA.push(char); + } + } else if (closeSymbols.has(char)) { + if (stackA.length === 0) continue; + const lastOpen = stackA[stackA.length - 1]; + if (symbolPairs[lastOpen] === char) { + stackA.pop(); + } + } + } + if (stackA.length === 0) { + return { closeSymbol: "", suffixPrefix: "" }; + } + const lastOpenSymbol = stackA[stackA.length - 1]; + const expectedCloseSymbol = symbolPairs[lastOpenSymbol]; + const stackB = []; + for (let i2 = 0; i2 < partB.length; i2++) { + const char = partB[i2]; + if (char === "\\") { + i2++; + continue; + } + if (stackB.length === 0 && char === expectedCloseSymbol) { + return { closeSymbol: char, suffixPrefix: partB.slice(0, i2) }; + } + if (openSymbols.has(char)) { + if ((char === "'" || char === '"' || char === "`") && stackB.length > 0 && stackB[stackB.length - 1] === char) { + stackB.pop(); + } else { + stackB.push(char); + } + } else if (closeSymbols.has(char)) { + if (stackB.length === 0) continue; + const lastOpen = stackB[stackB.length - 1]; + if (symbolPairs[lastOpen] === char) { + stackB.pop(); + } + } + } + return { closeSymbol: "", suffixPrefix: "" }; +} +function findMaxOverlap(str1, str2) { + if (str1 === "" || str2 === "") return ""; + let maxOverlap = ""; + for (let len = Math.min(str1.length, str2.length); len > 0; len--) { + const suffix = str1.substring(str1.length - len); + const prefix = str2.substring(0, len); + if (suffix === prefix) { + maxOverlap = suffix; + break; + } + } + if (maxOverlap === "") { + const str2Trimmed = str2.trimStart(); + for (let len = Math.min(str1.length, str2Trimmed.length); len > 0; len--) { + const suffix = str1.substring(str1.length - len); + const prefix = str2Trimmed.substring(0, len); + if (suffix === prefix) { + maxOverlap = suffix; + break; + } + } + } + return maxOverlap; +} +function getStringBeforeCloseSymbol(str, closeSymbol) { + if (!closeSymbols.has(closeSymbol)) { + return ""; + } + const stack = []; + let result = ""; + for (let i2 = 0; i2 < str.length; i2++) { + const char = str[i2]; + if (char === "\\") { + result += char; + if (i2 + 1 < str.length) { + result += str[++i2]; + } + continue; + } + if (stack.length === 0 && char === closeSymbol) { + return result; + } + if (openSymbols.has(char)) { + if ((char === "'" || char === '"' || char === "`") && stack.length > 0 && stack[stack.length - 1] === char) { + stack.pop(); + } else { + stack.push(char); + } + } else if (closeSymbols.has(char)) { + if (stack.length > 0) { + const lastOpen = stack[stack.length - 1]; + if (symbolPairs[lastOpen] === char) { + stack.pop(); + } + } + } + result += char; + } + return result; +} +function postProcessCompletionSynthesis(completion, prefix, suffix, closeSymbolChar, suffixPrefixString) { + if (closeSymbolChar && closeSymbolChar.length > 0) { + let cutCompletion = getStringBeforeCloseSymbol(completion, closeSymbolChar); + let commonSubstring = findMaxOverlap(cutCompletion, suffixPrefixString); + completion = cutCompletion.slice(0, cutCompletion.length - commonSubstring.length); + } else { + let commonSubstring = findMaxOverlap(completion, suffix); + if (commonSubstring.length >= 10) { + completion = completion.slice(0, completion.length - commonSubstring.length); + } + } + return completion; +} +function isInsideWord(prefix, suffix, logCallback) { + const charBefore = prefix.length > 0 ? prefix[prefix.length - 1] : ""; + const charAfter = suffix.length > 0 ? suffix[0] : ""; + const isLetter = (char) => { + if (char.length !== 1) return false; + const code = char.charCodeAt(0); + return code >= 65 && code <= 90 || // A-Z + code >= 97 && code <= 122; + }; + const hasLetterBefore = isLetter(charBefore); + const hasLetterAfter = isLetter(charAfter); + if (hasLetterBefore && hasLetterAfter) { + if (logCallback) { + logCallback(`Skipping completion: cursor inside word (${charBefore}|${charAfter})`); + } + return true; + } + return false; +} + +// ../autocompletion/v2/capturesProcess/general.ts +var import_path = __toESM(require("path")); +var import_crypto = __toESM(require("crypto")); + +// ../autocompletion/v2/Logger.ts +var logLevelPriorityMap = { + ["DEBUG" /* Debug */]: 0, + ["INFO" /* Info */]: 1, + ["WARN" /* Warn */]: 2, + ["ERROR" /* Error */]: 3 +}; +var Logger = class _Logger { + static _instance = null; + prefix = ""; + level = "WARN" /* Warn */; + constructor(prefix, level) { + if (prefix) { + this.prefix = prefix; + } + if (level) { + this.level = level; + } + } + static getDefaultLogger() { + if (!_Logger._instance) { + _Logger._instance = new _Logger(); + } + return _Logger._instance; + } + static setDefaultLogger(logger) { + _Logger._instance = logger; + } + debug(message, ...optionalParams) { + if (logLevelPriorityMap[this.level] <= logLevelPriorityMap["DEBUG" /* Debug */]) { + console.debug(`${this.prefix}${message} ${optionalParams.join(" ")}`); + } + } + info(message, ...optionalParams) { + if (logLevelPriorityMap[this.level] <= logLevelPriorityMap["INFO" /* Info */]) { + console.log(`${this.prefix}${message} ${optionalParams.join(" ")}`); + } + } + warn(message, ...optionalParams) { + if (logLevelPriorityMap[this.level] <= logLevelPriorityMap["WARN" /* Warn */]) { + console.warn(`${this.prefix}${message} ${optionalParams.join(" ")}`); + } + } + error(message, ...optionalParams) { + if (logLevelPriorityMap[this.level] <= logLevelPriorityMap["ERROR" /* Error */]) { + console.error(`${this.prefix}${message} ${optionalParams.join(" ")}`); + } + } + with(prefix) { + return new _Logger(this.prefix + prefix + " "); + } +}; + +// ../autocompletion/v2/capturesProcess/general.ts +function isFunctionNode(node) { + const functionTypes = [ + "function_declaration", + "function_definition", + // Go + "method_declaration", + // Go methods + "method_definition", + // Class methods + "arrow_function", + "function_expression" + ]; + return functionTypes.includes(node.type); +} +function isClassNode(node) { + const classTypes = [ + "class_declaration", + "class_definition", + "interface_declaration", + "struct_specifier" + // C++ structs + ]; + return classTypes.includes(node.type); +} +function findIdentifierInNode(node) { + const identifierTypes = /* @__PURE__ */ new Set([ + "identifier", + "name", + "property_identifier", + "field_identifier", + "method_name", + "function_name", + "class_name", + "type_identifier" + ]); + for (let i2 = 0; i2 < node.childCount; i2++) { + const child = node.child(i2); + if (child && identifierTypes.has(child.type)) { + return child; + } + } + for (let i2 = 0; i2 < node.childCount; i2++) { + const child = node.child(i2); + if (child) { + const found = findIdentifierInNode(child); + if (found) return found; + } + } + return null; +} +function isScopeNode(node) { + const scopeTypes = /* @__PURE__ */ new Set([ + "function_declaration", + "method_definition", + "arrow_function", + "function_expression", + "class_declaration", + "interface_declaration", + "namespace_declaration", + "module_declaration", + "function_definition", + "class_definition" + ]); + return scopeTypes.has(node.type); +} +function extractScopeName(node) { + const identifierNode = findIdentifierInNode(node); + if (identifierNode) { + return node.text.substring( + identifierNode.startIndex - node.startIndex, + identifierNode.endIndex - node.startIndex + ); + } + return node.type; +} +function generateSnippetHash(filePath, startLine, endLine, rangeText) { + const content = `${filePath}:${startLine}-${endLine}:${rangeText.substring(0, 100)}`; + return import_crypto.default.createHash("sha256").update(content).digest("hex").substring(0, 16); +} +function extractSymbolName(node, sourceCode) { + const identifierNode = findIdentifierInNode(node); + if (identifierNode) { + return sourceCode.substring(identifierNode.startIndex, identifierNode.endIndex); + } + return `${node.type}_${node.startPosition.row + 1}`; +} +function buildScopeChain(node) { + const scope = []; + let current = node.parent; + while (current) { + if (isScopeNode(current)) { + const scopeName = extractScopeName(current); + if (scopeName) { + scope.unshift(scopeName); + } + } + current = current.parent; + } + return scope; +} +function determineSnippetTypeFromCapture(capture, allowedTypes) { + const captureTypeMap = { + import: "import_or_include" /* ImportOrInclude */, + "import.statement": "import_or_include" /* ImportOrInclude */, + "function.definition": "function_or_method" /* FunctionOrMethod */, + "class.definition": "class_or_interface_or_struct" /* ClassOrInterfaceOrStructOrEnum */, + "method.definition": "function_or_method" /* FunctionOrMethod */, + "variable.definition": "variable_or_constant" /* VariableOrConstant */ + }; + const mappedType = captureTypeMap[capture.name]; + if (mappedType && allowedTypes.includes(mappedType)) { + return mappedType; + } + if (capture.node.type.includes("import") && allowedTypes.includes("import_or_include" /* ImportOrInclude */)) { + return "import_or_include" /* ImportOrInclude */; + } + if (isFunctionNode(capture.node) && allowedTypes.includes("function_or_method" /* FunctionOrMethod */)) { + return "function_or_method" /* FunctionOrMethod */; + } + if (isClassNode(capture.node) && allowedTypes.includes("class_or_interface_or_struct" /* ClassOrInterfaceOrStructOrEnum */)) { + return "class_or_interface_or_struct" /* ClassOrInterfaceOrStructOrEnum */; + } + return allowedTypes[0]; +} +function createSnippetFromQueryCapture(capture, allCaptures, sourceCode, lines, filePath, fileHash, snippetTypes, options, seenHashes) { + const node = capture.node; + const startLine = node.startPosition.row + 1; + const endLine = node.endPosition.row + 1; + const startColumn = node.startPosition.column; + const endColumn = node.endPosition.column; + const lineCount = endLine - startLine + 1; + if (lineCount < Math.max(1, options.minSnippetLines - 2) || lineCount > options.maxSnippetLines * 2) { + return null; + } + const rangeText = sourceCode.substring(node.startIndex, node.endIndex); + const snippetHash = generateSnippetHash(filePath, startLine, endLine, rangeText); + if (seenHashes.has(snippetHash)) { + return null; + } + seenHashes.add(snippetHash); + const name2 = extractSymbolName(node, sourceCode); + const scope = buildScopeChain(node); + const snippetType = determineSnippetTypeFromCapture(capture, snippetTypes); + return { + name: name2, + type: snippetType, + filePath, + startLine, + endLine, + startColumn, + endColumn, + rangeText, + scope, + fileHash + }; +} +async function extractSnippetsFromCapturesForGeneral(captures, sourceCode, filePath, fileHash, snippetTypes, options) { + const logger = Logger.getDefaultLogger().with("[extractSnippetsFromCapturesForGeneral]"); + const snippets = []; + const seenHashes = /* @__PURE__ */ new Set(); + const lines = sourceCode.split("\n"); + try { + logger.info(`[CodeContext] Starting query execution for: ${import_path.default.basename(filePath)}`); + logger.info(`[CodeContext] Query found ${captures.length} captures`); + const capturesByType = /* @__PURE__ */ new Map(); + captures.forEach((capture) => { + const captureType = capture.name; + if (!capturesByType.has(captureType)) { + capturesByType.set(captureType, []); + } + capturesByType.get(captureType).push(capture); + }); + logger.info(`[CodeContext] Capture types found:`, Array.from(capturesByType.keys())); + for (const [captureType, captureList] of capturesByType) { + logger.info(`[CodeContext] Processing ${captureList.length} ${captureType} captures`); + for (const capture of captureList) { + const snippet = createSnippetFromQueryCapture( + capture, + captures, + sourceCode, + lines, + filePath, + fileHash, + snippetTypes, + options, + seenHashes + ); + if (snippet) { + snippets.push(snippet); + logger.info( + `"[CodeContext] Created snippet: ${snippet.name} (${snippet.startLine}-${snippet.endLine}) from ${captureType}` + ); + } + } + } + logger.info(`[CodeContext] Total snippets extracted: ${snippets.length}`); + } catch (error) { + logger.error(`[CodeContext] Error executing query:`, error); + } + return snippets; +} + +// ../autocompletion/v2/capturesProcess/go.ts +async function extractSnippetsFromCapturesForGo(captures, sourceCode, filePath, fileHash, snippetTypes, options) { + const logger = Logger.getDefaultLogger().with("[extractSnippetsFromCapturesForGo]"); + const snippets = []; + const seenHashes = /* @__PURE__ */ new Set(); + if (snippetTypes.length === 0) { + logger.warn(`No snippet types provided, skipping`); + return snippets; + } + const functionCaptureNames = /* @__PURE__ */ new Set([ + "name.definition.function", + "name.definition.method", + "parameters.definition.function", + "body.definition.function", + "definition.function" + ]); + const functionNodeMap = /* @__PURE__ */ new Map(); + captures.forEach((capture) => { + if (functionCaptureNames.has(capture.name)) { + const node = capture.node; + const key = `${node.startIndex}:${node.endIndex}`; + if (!functionNodeMap.has(key)) { + functionNodeMap.set(key, capture); + } + } + }); + captures.forEach((capture) => { + if (capture.name === "name.definition.import") { + const node = capture.node; + const startLine = node.startPosition.row + 1; + const endLine = node.endPosition.row + 1; + const rangeText = sourceCode.substring(node.startIndex, node.endIndex); + const snippetHash = generateSnippetHash(filePath, startLine, endLine, rangeText); + if (seenHashes.has(snippetHash)) return; + seenHashes.add(snippetHash); + const name2 = sourceCode.substring(node.startIndex, node.endIndex); + const scope = buildScopeChain(node); + snippets.push({ + name: name2, + type: "import_or_include" /* ImportOrInclude */, + filePath, + startLine, + endLine, + rangeText, + definitionText: rangeText, + scope, + fileHash + }); + } + }); + for (const capture of captures) { + if (capture.name !== "definition.function" && capture.name !== "definition.method") continue; + const node = capture.node; + const startLine = node.startPosition.row + 1; + const endLine = node.endPosition.row + 1; + const isMethod = capture.name === "definition.method"; + const nameCap = captures.find( + (c) => c.name === (isMethod ? "name.definition.method" : "name.definition.function") && c.node.startIndex >= node.startIndex && c.node.endIndex <= node.endIndex + ); + if (!nameCap) continue; + const name2 = sourceCode.substring(nameCap.node.startIndex, nameCap.node.endIndex); + const paramCaps = captures.filter( + (c) => c.name === (isMethod ? "parameters.definition.method" : "parameters.definition.function") && c.node.startIndex >= node.startIndex && c.node.endIndex <= node.endIndex + ); + const parameters = paramCaps.map((paramCap) => ({ + name: sourceCode.substring(paramCap.node.startIndex, paramCap.node.endIndex) + })); + const bodyCap = captures.find( + (c) => c.name === (isMethod ? "body.definition.method" : "body.definition.function") && c.node.startIndex >= node.startIndex && c.node.endIndex <= node.endIndex + ); + let rangeText; + let implementText = void 0; + if (bodyCap) { + rangeText = sourceCode.substring(node.startIndex, bodyCap.node.startIndex).trimEnd(); + implementText = sourceCode.substring(node.startIndex, node.endIndex); + } else { + rangeText = sourceCode.substring(node.startIndex, node.endIndex); + } + const snippetHash = generateSnippetHash(filePath, startLine, endLine, rangeText); + if (seenHashes.has(snippetHash)) continue; + seenHashes.add(snippetHash); + const resultCap = captures.find( + (c) => c.name === (isMethod ? "result.definition.method" : "result.definition.function") && c.node.startIndex >= node.startIndex && c.node.endIndex <= node.endIndex + ); + let returnType = ""; + if (resultCap) { + returnType = sourceCode.substring(resultCap.node.startIndex, resultCap.node.endIndex).trim(); + } + const paramStr = parameters.map((p) => p.name).join(", "); + const signature = `${name2}(${paramStr})`; + const scope = buildScopeChain(node); + let field = void 0; + if (isMethod) { + const selfCap = captures.find( + (c) => c.name === "self.definition.method" && c.node.startIndex >= node.startIndex && c.node.endIndex <= node.endIndex + ); + if (selfCap) { + const classCap = captures.find( + (c) => c.name === "class.definition.method" && c.node.startIndex >= selfCap.node.startIndex && c.node.endIndex <= selfCap.node.endIndex + ); + if (classCap) { + field = sourceCode.substring(classCap.node.startIndex, classCap.node.endIndex); + } + } + } + snippets.push({ + name: name2, + type: "function_or_method" /* FunctionOrMethod */, + filePath, + startLine, + endLine, + rangeText, + definitionText: rangeText, + scope, + fileHash, + field, + definition: { + name: name2, + type: node.type, + parameters, + returnType + }, + parameters, + signature, + language: "go" /* Go */, + ...implementText ? { implementText } : {} + }); + } + const typeDefs = [ + { capture: "name.definition.struct", outlineType: "struct" }, + { capture: "name.definition.interface", outlineType: "interface" }, + { capture: "name.definition.type", outlineType: "type" } + ]; + for (const { capture, outlineType } of typeDefs) { + const defCaptureName = `definition.${outlineType}`; + for (const cap of captures.filter((c) => c.name === capture)) { + const node = cap.node; + const isInFunc = captures.some( + (fc) => (fc.name === "definition.function" || fc.name === "definition.method") && fc.node.startIndex < node.startIndex && node.endIndex < fc.node.endIndex + ); + if (isInFunc) continue; + const defCap = captures.find( + (c) => c.name === defCaptureName && c.node.startIndex <= node.startIndex && node.endIndex <= c.node.endIndex + ); + const rangeText = defCap ? sourceCode.substring(defCap.node.startIndex, defCap.node.endIndex) : sourceCode.substring(node.startIndex, node.endIndex); + const startLine = node.startPosition.row + 1; + const endLine = node.endPosition.row + 1; + const snippetHash = generateSnippetHash(filePath, startLine, endLine, rangeText); + if (seenHashes.has(snippetHash)) continue; + seenHashes.add(snippetHash); + const name2 = sourceCode.substring(node.startIndex, node.endIndex); + snippets.push({ + name: name2, + type: "class_or_interface_or_struct" /* ClassOrInterfaceOrStructOrEnum */, + filePath, + startLine, + endLine, + rangeText, + definitionText: rangeText, + implementText: rangeText, + scope: [], + fileHash, + field: "", + definition: { name: name2, type: outlineType }, + language: "go" /* Go */ + }); + } + } + const varDefs = [ + { capture: "name.definition.const", outlineType: "const" }, + { capture: "name.definition.var", outlineType: "var" } + ]; + for (const { capture, outlineType } of varDefs) { + const defCaptureName = `definition.${outlineType}`; + for (const cap of captures.filter((c) => c.name === capture)) { + const node = cap.node; + const isInFunc = captures.some( + (fc) => (fc.name === "definition.function" || fc.name === "definition.method") && fc.node.startIndex < node.startIndex && node.endIndex < fc.node.endIndex + ); + if (isInFunc) continue; + const defCap = captures.find( + (c) => c.name === defCaptureName && c.node.startIndex <= node.startIndex && node.endIndex <= c.node.endIndex + ); + const rangeText = defCap ? sourceCode.substring(defCap.node.startIndex, defCap.node.endIndex) : sourceCode.substring(node.startIndex, node.endIndex); + const startLine = node.startPosition.row + 1; + const endLine = node.endPosition.row + 1; + const snippetHash = generateSnippetHash(filePath, startLine, endLine, rangeText); + if (seenHashes.has(snippetHash)) continue; + seenHashes.add(snippetHash); + const name2 = sourceCode.substring(node.startIndex, node.endIndex); + snippets.push({ + name: name2, + type: "variable_or_constant" /* VariableOrConstant */, + filePath, + startLine, + endLine, + rangeText, + definitionText: rangeText, + implementText: rangeText, + scope: [], + fileHash, + field: "", + definition: { name: name2, type: outlineType }, + language: "go" /* Go */ + }); + } + } + return snippets.filter((snippet) => snippetTypes.includes(snippet.type)).sort((a, b) => a.startLine - b.startLine); +} +function buildSummaryFromSnippets(snippets) { + const outline = []; + const isGlobal = (s) => !s.scope || s.scope.length === 0 || s.scope.every((x) => !x); + for (const s of snippets) { + if (!isGlobal(s)) continue; + if (s.type === "import_or_include" /* ImportOrInclude */) { + outline.push({ + type: "import", + name: s.name, + file: s.filePath, + field: "", + description: s.definitionText + }); + } else if (s.type === "function_or_method" /* FunctionOrMethod */) { + if (s.field) { + outline.push({ + type: "method", + name: s.name, + file: s.filePath, + field: s.field, + description: s.definitionText + }); + } else { + outline.push({ + type: "function", + name: s.name, + file: s.filePath, + field: "", + description: s.definitionText + }); + } + } else if (s.type === "variable_or_constant" /* VariableOrConstant */) { + const t = s.definition?.type === "const" ? "const" : "var"; + outline.push({ + type: t, + name: s.name, + file: s.filePath, + field: "", + description: s.definitionText + }); + } else if (s.type === "class_or_interface_or_struct" /* ClassOrInterfaceOrStructOrEnum */) { + const t = s.definition?.type || "type"; + outline.push({ + type: t, + name: s.name, + file: s.filePath, + field: "", + description: s.definitionText + }); + } + } + return outline; +} +function formatOutlineText(outline) { + const groups = {}; + for (const entry of outline) { + const key = entry.field ?? ""; + if (!groups[key]) groups[key] = []; + groups[key].push(entry); + } + let result = ""; + for (const field of Object.keys(groups).sort()) { + const group = groups[field]; + const title = field === "" ? "[global]" : `[${field}]`; + result += title + "\n"; + for (const entry of group) { + let line = ` ${entry.type}`; + if (entry.description) line += `: ${entry.description.replace(/\n/g, " ")}`; + result += line + "\n"; + } + result += "\n"; + } + return result.trimEnd(); +} + +// ../autocompletion/v2/capturesProcess/python.ts +async function extractSnippetsFromCapturesForPython(captures, sourceCode, filePath, fileHash, snippetTypes, options) { + const snippets = []; + const seenHashes = /* @__PURE__ */ new Set(); + const classCaptures = captures.filter((c) => c.name === "definition.class").map((c) => ({ + node: c.node, + start: c.node.startIndex, + end: c.node.endIndex, + nameCap: captures.find( + (nc) => nc.name === "name.definition.class" && nc.node.startIndex >= c.node.startIndex && nc.node.endIndex <= c.node.endIndex + ) + })); + for (const capture of captures) { + if (capture.name !== "definition.function") continue; + const node = capture.node; + const startLine = node.startPosition.row + 1; + const endLine = node.endPosition.row + 1; + const nameCap = captures.find( + (c) => c.name === "name.definition.function" && c.node.startIndex >= node.startIndex && c.node.endIndex <= node.endIndex + ); + if (!nameCap) continue; + const name2 = sourceCode.substring(nameCap.node.startIndex, nameCap.node.endIndex); + const paramCap = captures.find( + (c) => c.name === "parameters.definition.function" && c.node.startIndex >= node.startIndex && c.node.endIndex <= node.endIndex + ); + const parameters = []; + if (paramCap) { + const paramText = sourceCode.substring(paramCap.node.startIndex, paramCap.node.endIndex); + const cleanParams = paramText.replace(/^\(|\)$/g, "").trim(); + if (cleanParams) { + const paramList = splitPythonParameters(cleanParams); + parameters.push(...paramList.map((param) => ({ name: param }))); + } + } + const bodyCap = captures.find( + (c) => c.name === "body.definition.function" && c.node.startIndex >= node.startIndex && c.node.endIndex <= node.endIndex + ); + let definitionText; + let implementText = void 0; + if (bodyCap) { + const functionHeader = sourceCode.substring(node.startIndex, bodyCap.node.startIndex).trimEnd(); + definitionText = functionHeader.endsWith(":") ? functionHeader : functionHeader + ":"; + implementText = sourceCode.substring(node.startIndex, node.endIndex); + } else { + definitionText = sourceCode.substring(node.startIndex, node.endIndex); + } + const rangeText = sourceCode.substring(node.startIndex, node.endIndex); + let field = void 0; + for (const cls of classCaptures) { + if (node.startIndex > cls.start && node.endIndex <= cls.end && cls.nameCap) { + field = sourceCode.substring(cls.nameCap.node.startIndex, cls.nameCap.node.endIndex); + break; + } + } + const snippetHash = generateSnippetHash(filePath, startLine, endLine, rangeText); + if (seenHashes.has(snippetHash)) continue; + seenHashes.add(snippetHash); + const paramStr = parameters.map((p) => p.name).join(", "); + const signature = `${name2}(${paramStr})`; + const scope = buildScopeChain(node); + let functionType = "function"; + const nodeText = sourceCode.substring(node.startIndex, Math.min(node.startIndex + 100, node.endIndex)); + if (nodeText.includes("async def")) functionType = "async function"; + if (field) functionType = "method"; + snippets.push({ + name: name2, + type: "function_or_method" /* FunctionOrMethod */, + filePath, + startLine, + endLine, + rangeText, + definitionText, + scope, + fileHash, + field, + definition: { + name: name2, + type: functionType, + parameters, + returnType: "" + // Python没有显式返回类型(除非有类型注解) + }, + parameters, + signature, + language: "python" /* Python */, + ...implementText ? { implementText } : {} + }); + } + for (const capture of captures) { + if (capture.name !== "definition.class") continue; + const node = capture.node; + const startLine = node.startPosition.row + 1; + const endLine = node.endPosition.row + 1; + const nameCap = captures.find( + (c) => c.name === "name.definition.class" && c.node.startIndex >= node.startIndex && c.node.endIndex <= node.endIndex + ); + if (!nameCap) continue; + const name2 = sourceCode.substring(nameCap.node.startIndex, nameCap.node.endIndex); + const rangeText = sourceCode.substring(node.startIndex, node.endIndex); + const snippetHash = generateSnippetHash(filePath, startLine, endLine, rangeText); + if (seenHashes.has(snippetHash)) continue; + seenHashes.add(snippetHash); + const scope = buildScopeChain(node); + snippets.push({ + name: name2, + type: "class_or_interface_or_struct" /* ClassOrInterfaceOrStructOrEnum */, + filePath, + startLine, + endLine, + rangeText, + definitionText: rangeText, + scope, + fileHash, + definition: { + name: name2, + type: "class" + }, + language: "python" /* Python */ + }); + } + for (const capture of captures) { + if (capture.name !== "definition.variable") continue; + const node = capture.node; + const startLine = node.startPosition.row + 1; + const endLine = node.endPosition.row + 1; + const memberVarCaps = captures.filter( + (c) => c.name === "name.definition.member_variable" && c.node.startIndex >= node.startIndex && c.node.endIndex <= node.endIndex + ); + const regularVarCaps = captures.filter( + (c) => c.name === "name.definition.variable" && c.node.startIndex >= node.startIndex && c.node.endIndex <= node.endIndex + ); + const allVarCaps = [...memberVarCaps, ...regularVarCaps]; + if (allVarCaps.length === 0) continue; + for (const nameCap of allVarCaps) { + const name2 = sourceCode.substring(nameCap.node.startIndex, nameCap.node.endIndex); + const isMemberVar = nameCap.name === "name.definition.member_variable"; + if (!isMemberVar) { + const isInFunction = captures.some( + (fc) => fc.name === "definition.function" && fc.node.startIndex < nameCap.node.startIndex && nameCap.node.endIndex < fc.node.endIndex + ); + if (isInFunction) continue; + } + const rangeText = sourceCode.substring(node.startIndex, node.endIndex); + let field = void 0; + for (const cls of classCaptures) { + if (nameCap.node.startIndex > cls.start && nameCap.node.endIndex <= cls.end && cls.nameCap) { + field = sourceCode.substring(cls.nameCap.node.startIndex, cls.nameCap.node.endIndex); + break; + } + } + const snippetHash = generateSnippetHash(filePath, startLine, endLine, rangeText + name2); + if (seenHashes.has(snippetHash)) continue; + seenHashes.add(snippetHash); + const scope = buildScopeChain(nameCap.node); + snippets.push({ + name: name2, + type: "variable_or_constant" /* VariableOrConstant */, + filePath, + startLine, + endLine, + rangeText, + definitionText: rangeText, + scope, + fileHash, + field, + definition: { + name: name2, + type: field ? "member_variable" : "global_variable" + }, + language: "python" /* Python */ + }); + } + } + const importDefs = captures.filter((c) => c.name === "definition.import"); + for (const nameCap of captures.filter((c) => c.name === "name.definition.import")) { + const defCap = importDefs.find( + (def) => nameCap.node.startIndex >= def.node.startIndex && nameCap.node.endIndex <= def.node.endIndex + ); + if (!defCap) continue; + const node = defCap.node; + const startLine = node.startPosition.row + 1; + const endLine = node.endPosition.row + 1; + const rangeText = sourceCode.substring(node.startIndex, node.endIndex); + const name2 = sourceCode.substring(nameCap.node.startIndex, nameCap.node.endIndex); + const snippetHash = generateSnippetHash(filePath, startLine, endLine, name2); + if (seenHashes.has(snippetHash)) continue; + seenHashes.add(snippetHash); + const scope = buildScopeChain(node); + snippets.push({ + name: name2, + type: "import_or_include" /* ImportOrInclude */, + filePath, + startLine, + endLine, + rangeText, + definitionText: rangeText, + scope, + fileHash, + language: "python" /* Python */ + }); + } + return snippets.filter((snippet) => snippetTypes.includes(snippet.type)).sort((a, b) => a.startLine - b.startLine); +} +function splitPythonParameters(params) { + const result = []; + let current = ""; + let parenDepth = 0; + let bracketDepth = 0; + let braceDepth = 0; + let inString = false; + let stringChar = ""; + for (let i2 = 0; i2 < params.length; i2++) { + const char = params[i2]; + const prevChar = i2 > 0 ? params[i2 - 1] : ""; + if (!inString && (char === '"' || char === "'" || char === "`")) { + inString = true; + stringChar = char; + } else if (inString && char === stringChar && prevChar !== "\\") { + inString = false; + stringChar = ""; + } + if (!inString) { + if (char === "(") parenDepth++; + else if (char === ")") parenDepth--; + else if (char === "[") bracketDepth++; + else if (char === "]") bracketDepth--; + else if (char === "{") braceDepth++; + else if (char === "}") braceDepth--; + else if (char === "," && parenDepth === 0 && bracketDepth === 0 && braceDepth === 0) { + if (current.trim()) { + result.push(current.trim()); + } + current = ""; + continue; + } + } + current += char; + } + if (current.trim()) { + result.push(current.trim()); + } + return result; +} +function buildSummaryFromSnippets2(snippets) { + const outline = []; + for (const s of snippets) { + const isTopLevelFunction = s.type === "function_or_method" /* FunctionOrMethod */ && !s.field && (!s.scope || s.scope.length === 0); + const isClassOrGlobalVar = (s.type === "class_or_interface_or_struct" /* ClassOrInterfaceOrStructOrEnum */ || s.type === "variable_or_constant" /* VariableOrConstant */) && !s.scope?.some((scopeItem) => scopeItem.startsWith("function")); + const isMethodOrMemberVar = !!s.field; + const isImport = s.type === "import_or_include" /* ImportOrInclude */; + if (!(isTopLevelFunction || isClassOrGlobalVar || isMethodOrMemberVar || isImport)) { + continue; + } + if (s.type === "import_or_include" /* ImportOrInclude */) { + outline.push({ + type: "import", + name: s.name, + file: s.filePath, + field: "", + description: s.definitionText + }); + } else if (s.type === "function_or_method" /* FunctionOrMethod */) { + if (s.field) { + outline.push({ + type: "method", + name: s.name, + file: s.filePath, + field: s.field, + description: s.definitionText + }); + } else { + outline.push({ + type: "function", + name: s.name, + file: s.filePath, + field: "", + description: s.definitionText + }); + } + } else if (s.type === "variable_or_constant" /* VariableOrConstant */) { + const t = s.definition?.type === "global_variable" ? "variable" : "member_variable"; + const displayName = s.name.startsWith("self.") ? s.name.substring(5) : s.name; + outline.push({ + type: t, + name: displayName, + file: s.filePath, + field: s.field || "", + description: s.definitionText + }); + } else if (s.type === "class_or_interface_or_struct" /* ClassOrInterfaceOrStructOrEnum */) { + outline.push({ + type: "class", + name: s.name, + file: s.filePath, + field: "", + description: s.name + }); + } + } + return outline; +} +function formatOutlineText2(outline) { + const groups = {}; + for (const entry of outline) { + const key = entry.field ?? ""; + if (!groups[key]) groups[key] = []; + groups[key].push(entry); + } + let result = ""; + for (const field of Object.keys(groups).sort()) { + if (groups[field].length === 0) continue; + const group = groups[field]; + const title = field === "" ? "[global]" : `[${field}]`; + result += title + "\n"; + for (const entry of group) { + let line = ` ${entry.type}`; + if (entry.type === "variable" || entry.type === "member_variable") { + line += `: ${entry.name}`; + } else if (entry.description) { + line += `: ${entry.description.replace(/\n/g, " ")}`; + } + result += line + "\n"; + } + result += "\n"; + } + return result.trimEnd(); +} + +// ../autocompletion/v2/capturesProcess/java.ts +async function extractSnippetsFromCapturesForJava(captures, sourceCode, filePath, fileHash, snippetTypes, options) { + const logger = Logger.getDefaultLogger().with("[extractSnippetsFromCapturesForJava]"); + const snippets = []; + const seenHashes = /* @__PURE__ */ new Set(); + if (snippetTypes.length === 0) { + logger.warn(`No snippet types provided, skipping`); + return snippets; + } + captures.forEach((capture) => { + if (capture.name === "name.definition.import") { + const node = capture.node; + const startLine = node.startPosition.row + 1; + const endLine = node.endPosition.row + 1; + const rangeText = sourceCode.substring(node.startIndex, node.endIndex); + const snippetHash = generateSnippetHash(filePath, startLine, endLine, rangeText); + if (seenHashes.has(snippetHash)) return; + seenHashes.add(snippetHash); + const name2 = sourceCode.substring(node.startIndex, node.endIndex); + const scope = buildScopeChain(node); + snippets.push({ + name: name2, + type: "import_or_include" /* ImportOrInclude */, + filePath, + startLine, + endLine, + rangeText, + definitionText: rangeText, + scope, + fileHash + }); + } + }); + for (const capture of captures) { + if (capture.name !== "definition.method" && capture.name !== "definition.constructor") continue; + const node = capture.node; + const startLine = node.startPosition.row + 1; + const endLine = node.endPosition.row + 1; + const isConstructor = capture.name === "definition.constructor"; + const nameCapName = isConstructor ? "name.definition.constructor" : "name.definition.method"; + const paramCapName = isConstructor ? "parameters.definition.constructor" : "parameters.definition.method"; + const bodyCapName = isConstructor ? "body.definition.constructor" : "body.definition.method"; + const nameCap = captures.find( + (c) => c.name === nameCapName && c.node.startIndex >= node.startIndex && c.node.endIndex <= node.endIndex + ); + if (!nameCap) continue; + const name2 = sourceCode.substring(nameCap.node.startIndex, nameCap.node.endIndex); + const paramCap = captures.find( + (c) => c.name === paramCapName && c.node.startIndex >= node.startIndex && c.node.endIndex <= node.endIndex + ); + const parameters = []; + if (paramCap) { + const paramText = sourceCode.substring(paramCap.node.startIndex, paramCap.node.endIndex); + const cleanText = paramText.replace(/^\(|\)$/g, "").trim(); + if (cleanText) { + const paramList = parseJavaParameters(cleanText); + parameters.push(...paramList.map((param) => ({ name: param }))); + } + } + const bodyCap = captures.find( + (c) => c.name === bodyCapName && c.node.startIndex >= node.startIndex && c.node.endIndex <= node.endIndex + ); + let rangeText; + let implementText = void 0; + if (bodyCap) { + rangeText = sourceCode.substring(node.startIndex, bodyCap.node.startIndex).trimEnd(); + implementText = sourceCode.substring(node.startIndex, node.endIndex); + } else { + rangeText = sourceCode.substring(node.startIndex, node.endIndex); + } + const snippetHash = generateSnippetHash(filePath, startLine, endLine, rangeText); + if (seenHashes.has(snippetHash)) continue; + seenHashes.add(snippetHash); + const paramStr = parameters.map((p) => p.name).join(", "); + const signature = `${name2}(${paramStr})`; + const scope = buildScopeChain(node); + let field = void 0; + const parentTypes = ["class", "interface", "enum", "record", "annotation"]; + for (const parentType of parentTypes) { + const parentCap = captures.find( + (c) => c.name === `definition.${parentType}` && c.node.startIndex < node.startIndex && node.endIndex < c.node.endIndex + ); + if (parentCap) { + const parentNameCap = captures.find( + (c) => c.name === `name.definition.${parentType}` && c.node.startIndex >= parentCap.node.startIndex && c.node.endIndex <= parentCap.node.endIndex + ); + if (parentNameCap) { + field = sourceCode.substring(parentNameCap.node.startIndex, parentNameCap.node.endIndex); + break; + } + } + } + snippets.push({ + name: name2, + type: "function_or_method" /* FunctionOrMethod */, + filePath, + startLine, + endLine, + rangeText, + definitionText: rangeText, + scope, + fileHash, + field, + definition: { + name: name2, + type: isConstructor ? "constructor" : "method", + parameters, + returnType: isConstructor ? "" : "void" + // Java 方法默认返回类型 + }, + parameters, + signature, + language: "java" /* Java */, + ...implementText ? { implementText } : {} + }); + } + const typeDefs = [ + { capture: "name.definition.class", outlineType: "class" }, + { capture: "name.definition.interface", outlineType: "interface" }, + { capture: "name.definition.enum", outlineType: "enum" }, + { capture: "name.definition.record", outlineType: "record" }, + { capture: "name.definition.annotation", outlineType: "annotation" } + ]; + for (const { capture, outlineType } of typeDefs) { + const defCaptureName = `definition.${outlineType}`; + for (const cap of captures.filter((c) => c.name === capture)) { + const node = cap.node; + const isInMethod = captures.some( + (fc) => (fc.name === "definition.method" || fc.name === "definition.constructor") && fc.node.startIndex < node.startIndex && node.endIndex < fc.node.endIndex + ); + if (isInMethod) continue; + const defCap = captures.find( + (c) => c.name === defCaptureName && c.node.startIndex <= node.startIndex && node.endIndex <= c.node.endIndex + ); + const rangeText = defCap ? sourceCode.substring(defCap.node.startIndex, defCap.node.endIndex) : sourceCode.substring(node.startIndex, node.endIndex); + const startLine = node.startPosition.row + 1; + const endLine = node.endPosition.row + 1; + const snippetHash = generateSnippetHash(filePath, startLine, endLine, rangeText); + if (seenHashes.has(snippetHash)) continue; + seenHashes.add(snippetHash); + const name2 = sourceCode.substring(node.startIndex, node.endIndex); + snippets.push({ + name: name2, + type: "class_or_interface_or_struct" /* ClassOrInterfaceOrStructOrEnum */, + filePath, + startLine, + endLine, + rangeText, + definitionText: rangeText, + implementText: rangeText, + scope: [], + fileHash, + field: "", + definition: { name: name2, type: outlineType }, + language: "java" /* Java */ + }); + } + } + const fieldNameCaptures = captures.filter((c) => c.name === "name.definition.field"); + for (const nameCap of fieldNameCaptures) { + const name2 = sourceCode.substring(nameCap.node.startIndex, nameCap.node.endIndex); + const fieldCap = captures.find( + (c) => c.name === "definition.field" && c.node.startIndex <= nameCap.node.startIndex && nameCap.node.endIndex <= c.node.endIndex + ); + if (!fieldCap) continue; + const node = fieldCap.node; + const startLine = node.startPosition.row + 1; + const endLine = node.endPosition.row + 1; + const isInMethod = captures.some( + (fc) => (fc.name === "definition.method" || fc.name === "definition.constructor") && fc.node.startIndex < node.startIndex && node.endIndex < fc.node.endIndex + ); + if (isInMethod) continue; + const rangeText = sourceCode.substring(node.startIndex, node.endIndex); + const nameStartLine = nameCap.node.startPosition.row + 1; + const nameEndLine = nameCap.node.endPosition.row + 1; + const nameRangeText = sourceCode.substring(nameCap.node.startIndex, nameCap.node.endIndex); + const snippetHash = generateSnippetHash(filePath, nameStartLine, nameEndLine, nameRangeText); + if (seenHashes.has(snippetHash)) continue; + seenHashes.add(snippetHash); + let field = void 0; + const parentTypes = ["class", "interface", "enum", "record", "annotation"]; + for (const parentType of parentTypes) { + const parentCap = captures.find( + (c) => c.name === `definition.${parentType}` && c.node.startIndex < node.startIndex && node.endIndex < c.node.endIndex + ); + if (parentCap) { + const parentNameCap = captures.find( + (c) => c.name === `name.definition.${parentType}` && c.node.startIndex >= parentCap.node.startIndex && c.node.endIndex <= parentCap.node.endIndex + ); + if (parentNameCap) { + field = sourceCode.substring(parentNameCap.node.startIndex, parentNameCap.node.endIndex); + break; + } + } + } + const scope = buildScopeChain(node); + snippets.push({ + name: name2, + type: "variable_or_constant" /* VariableOrConstant */, + filePath, + startLine, + endLine, + rangeText, + definitionText: rangeText, + implementText: rangeText, + scope, + fileHash, + field: field || "", + definition: { name: name2, type: "field" }, + language: "java" /* Java */ + }); + } + return snippets.filter((snippet) => snippetTypes.includes(snippet.type)).sort((a, b) => a.startLine - b.startLine); +} +function buildSummaryFromSnippets3(snippets) { + const outline = []; + const isTopLevel = (s) => { + return !s.scope || s.scope.length <= 1; + }; + for (const s of snippets) { + if (!isTopLevel(s)) continue; + if (s.type === "import_or_include" /* ImportOrInclude */) { + outline.push({ + type: "import", + name: s.name, + file: s.filePath, + field: "", + description: s.definitionText + }); + } else if (s.type === "function_or_method" /* FunctionOrMethod */) { + if (s.field) { + const methodType = s.definition?.type === "constructor" ? "constructor" : "method"; + outline.push({ + type: methodType, + name: s.name, + file: s.filePath, + field: s.field, + description: s.definitionText + }); + } else { + outline.push({ + type: "method", + name: s.name, + file: s.filePath, + field: "", + description: s.definitionText + }); + } + } else if (s.type === "variable_or_constant" /* VariableOrConstant */) { + const fieldType = s.definition?.type === "field" ? "field" : "variable"; + const simpleDescription = s.name; + outline.push({ + type: fieldType, + name: s.name, + file: s.filePath, + field: s.field || "", + description: simpleDescription + }); + } else if (s.type === "class_or_interface_or_struct" /* ClassOrInterfaceOrStructOrEnum */) { + const t = s.definition?.type || "class"; + outline.push({ + type: t, + name: s.name, + file: s.filePath, + field: "", + description: s.name + }); + } + } + return outline; +} +function formatOutlineText3(outline) { + const groups = {}; + for (const entry of outline) { + const key = entry.field ?? ""; + if (!groups[key]) groups[key] = []; + groups[key].push(entry); + } + let result = ""; + for (const field of Object.keys(groups).sort()) { + const group = groups[field]; + const title = field === "" ? "[global]" : `[${field}]`; + result += title + "\n"; + for (const entry of group) { + let line = ` ${entry.type}`; + if (entry.description) line += `: ${entry.description.replace(/\n/g, " ")}`; + result += line + "\n"; + } + result += "\n"; + } + return result.trimEnd(); +} +function parseJavaParameters(paramText) { + if (!paramText.trim()) return []; + const params = []; + let current = ""; + let bracketDepth = 0; + let i2 = 0; + while (i2 < paramText.length) { + const char = paramText[i2]; + if (char === "<") { + bracketDepth++; + current += char; + } else if (char === ">") { + bracketDepth--; + current += char; + } else if (char === "," && bracketDepth === 0) { + if (current.trim()) { + params.push(current.trim()); + } + current = ""; + } else { + current += char; + } + i2++; + } + if (current.trim()) { + params.push(current.trim()); + } + return params; +} + +// ../autocompletion/v2/capturesProcess/javascript.ts +function removeParentheses(text) { + let result = text.trim(); + if (result.startsWith("(") && result.endsWith(")")) { + result = result.slice(1, -1).trim(); + } + return result; +} +function removeBrackets(text) { + let result = text.trim(); + if (result.startsWith("[") && result.endsWith("]")) { + result = result.slice(1, -1).trim(); + } + return result; +} +function isValidJavaScriptIdentifier(name2) { + if (!name2) return false; + const firstChar = name2[0]; + if (!(firstChar >= "a" && firstChar <= "z") && !(firstChar >= "A" && firstChar <= "Z") && firstChar !== "_" && firstChar !== "$") { + return false; + } + for (let i2 = 1; i2 < name2.length; i2++) { + const char = name2[i2]; + if (!(char >= "a" && char <= "z") && !(char >= "A" && char <= "Z") && !(char >= "0" && char <= "9") && char !== "_" && char !== "$") { + return false; + } + } + return true; +} +function replaceNewlinesWithSpaces(text) { + return text.split("\n").join(" "); +} +function extractParametersFromMethodText(methodText) { + const openParen = methodText.indexOf("("); + const closeParen = methodText.lastIndexOf(")"); + if (openParen !== -1 && closeParen !== -1 && closeParen > openParen) { + return methodText.substring(openParen + 1, closeParen).trim(); + } + return null; +} +async function extractSnippetsFromCapturesForJavaScript(captures, sourceCode, filePath, fileHash, snippetTypes, options) { + const snippets = []; + const seenHashes = /* @__PURE__ */ new Set(); + const classCaptures = captures.filter((c) => c.name === "definition.class").map((c) => ({ + node: c.node, + start: c.node.startIndex, + end: c.node.endIndex, + nameCap: captures.find( + (nc) => nc.name === "name" && nc.node.startIndex >= c.node.startIndex && nc.node.endIndex <= c.node.endIndex + ) + })); + for (const capture of captures) { + if (capture.name !== "definition.function") continue; + const node = capture.node; + const startLine = node.startPosition.row + 1; + const endLine = node.endPosition.row + 1; + const nameCap = captures.find( + (c) => (c.name === "name.definition.function" || c.name === "name") && c.node.startIndex >= node.startIndex && c.node.endIndex <= node.endIndex + ); + if (!nameCap) continue; + const name2 = sourceCode.substring(nameCap.node.startIndex, nameCap.node.endIndex); + const paramCap = captures.find( + (c) => c.name === "parameters.definition.function" && c.node.startIndex >= node.startIndex && c.node.endIndex <= node.endIndex + ); + const parameters = []; + if (paramCap) { + const paramText = sourceCode.substring(paramCap.node.startIndex, paramCap.node.endIndex); + const cleanParams = removeParentheses(paramText); + if (cleanParams) { + const paramList = splitJavaScriptParameters(cleanParams); + parameters.push(...paramList.map((param) => ({ name: param }))); + } + } + const bodyCap = captures.find( + (c) => c.name === "body.definition.function" && c.node.startIndex >= node.startIndex && c.node.endIndex <= node.endIndex + ); + let rangeText; + let implementText = void 0; + if (bodyCap) { + rangeText = sourceCode.substring(node.startIndex, bodyCap.node.startIndex).trimEnd(); + implementText = sourceCode.substring(node.startIndex, node.endIndex); + } else { + rangeText = sourceCode.substring(node.startIndex, node.endIndex); + } + let field = void 0; + for (const cls of classCaptures) { + if (node.startIndex > cls.start && node.endIndex < cls.end && cls.nameCap) { + field = sourceCode.substring(cls.nameCap.node.startIndex, cls.nameCap.node.endIndex); + break; + } + } + const snippetHash = generateSnippetHash(filePath, startLine, endLine, rangeText); + if (seenHashes.has(snippetHash)) continue; + seenHashes.add(snippetHash); + const paramStr = parameters.map((p) => p.name).join(", "); + const signature = `${name2}(${paramStr})`; + const scope = buildScopeChain(node); + let functionType = "function"; + const nodeText = sourceCode.substring(node.startIndex, Math.min(node.startIndex + 100, node.endIndex)); + if (nodeText.includes("async")) functionType = "async function"; + if (nodeText.includes("function*")) functionType = "generator function"; + if (nodeText.includes("=>")) functionType = "arrow function"; + snippets.push({ + name: name2, + type: "function_or_method" /* FunctionOrMethod */, + filePath, + startLine, + endLine, + rangeText, + definitionText: rangeText, + scope, + fileHash, + field, + definition: { + name: name2, + type: functionType, + parameters, + returnType: "" + // JavaScript doesn't have explicit return types + }, + parameters, + signature, + language: "javascript" /* JavaScript */, + ...implementText ? { implementText } : {} + }); + } + for (const capture of captures) { + if (capture.name !== "definition.method") continue; + const node = capture.node; + const startLine = node.startPosition.row + 1; + const endLine = node.endPosition.row + 1; + const nameCap = captures.find( + (c) => c.name === "name" && c.node.startIndex >= node.startIndex && c.node.endIndex <= node.endIndex + ); + if (!nameCap) continue; + const name2 = sourceCode.substring(nameCap.node.startIndex, nameCap.node.endIndex); + const paramCap = captures.find( + (c) => c.name === "parameters.definition.method" && c.node.startIndex >= node.startIndex && c.node.endIndex <= node.endIndex + ); + const parameters = []; + if (paramCap) { + const paramText = sourceCode.substring(paramCap.node.startIndex, paramCap.node.endIndex); + const cleanParams = removeParentheses(paramText); + if (cleanParams) { + const paramList = splitJavaScriptParameters(cleanParams); + parameters.push(...paramList.map((param) => ({ name: param }))); + } + } else { + const methodText2 = sourceCode.substring(node.startIndex, node.endIndex); + const paramString = extractParametersFromMethodText(methodText2); + if (paramString) { + const paramList = splitJavaScriptParameters(paramString); + parameters.push(...paramList.map((param) => ({ name: param }))); + } + } + let field = void 0; + const rangeText = sourceCode.substring(node.startIndex, node.endIndex); + const snippetHash = generateSnippetHash(filePath, startLine, endLine, rangeText); + if (seenHashes.has(snippetHash)) continue; + seenHashes.add(snippetHash); + const paramStr = parameters.map((p) => p.name).join(", "); + const signature = `${name2}(${paramStr})`; + const scope = buildScopeChain(node); + let methodType = "method"; + const methodText = sourceCode.substring(node.startIndex, node.endIndex); + if (methodText.includes("async")) methodType = "async method"; + if (methodText.includes("static")) methodType = "static method"; + if (methodText.includes("get ")) methodType = "getter"; + if (methodText.includes("set ")) methodType = "setter"; + snippets.push({ + name: name2, + type: "function_or_method" /* FunctionOrMethod */, + filePath, + startLine, + endLine, + rangeText, + definitionText: rangeText, + scope, + fileHash, + field, + definition: { + name: name2, + type: methodType, + parameters, + returnType: "" + }, + parameters, + signature, + language: "javascript" /* JavaScript */, + implementText: rangeText + }); + } + for (const capture of captures) { + if (capture.name !== "definition.class") continue; + const node = capture.node; + const startLine = node.startPosition.row + 1; + const endLine = node.endPosition.row + 1; + const nameCap = captures.find( + (c) => c.name === "name.definition.class" && c.node.startIndex >= node.startIndex && c.node.endIndex <= node.endIndex + ); + if (!nameCap) continue; + const name2 = sourceCode.substring(nameCap.node.startIndex, nameCap.node.endIndex); + const rangeText = sourceCode.substring(node.startIndex, node.endIndex); + const snippetHash = generateSnippetHash(filePath, startLine, endLine, rangeText); + if (seenHashes.has(snippetHash)) continue; + seenHashes.add(snippetHash); + const scope = buildScopeChain(node); + snippets.push({ + name: name2, + type: "class_or_interface_or_struct" /* ClassOrInterfaceOrStructOrEnum */, + filePath, + startLine, + endLine, + rangeText, + definitionText: rangeText, + scope, + fileHash, + definition: { + name: name2, + type: "class" + }, + language: "javascript" /* JavaScript */ + }); + } + const allClasses = snippets.filter((s) => s.type === "class_or_interface_or_struct" /* ClassOrInterfaceOrStructOrEnum */); + for (const method of snippets) { + if (method.type === "function_or_method" /* FunctionOrMethod */ && !method.field) { + for (const cls of allClasses) { + if (method.startLine >= cls.startLine && method.endLine <= cls.endLine) { + method.field = cls.name; + break; + } + } + } + } + for (const capture of captures) { + if (capture.name !== "definition.variable") continue; + const node = capture.node; + const startLine = node.startPosition.row + 1; + const endLine = node.endPosition.row + 1; + const arrayPatternCap = captures.find( + (c) => c.name === "array_pattern" && c.node.startIndex >= node.startIndex && c.node.endIndex <= node.endIndex + ); + if (arrayPatternCap) { + const arrayPatternText = sourceCode.substring( + arrayPatternCap.node.startIndex, + arrayPatternCap.node.endIndex + ); + const variableNames = removeBrackets(arrayPatternText).split(",").map((name3) => name3.trim()).filter((name3) => name3 && isValidJavaScriptIdentifier(name3)); + for (const varName of variableNames) { + const scope2 = buildScopeChain(node); + const isInsideFunction2 = scope2.length > 0 && scope2.some((scopeItem) => { + return !allClasses.some((cls) => cls.name === scopeItem); + }); + if (isInsideFunction2) continue; + const rangeText2 = sourceCode.substring(node.startIndex, node.endIndex); + const snippetHash2 = generateSnippetHash(filePath, startLine, endLine, `${rangeText2}_${varName}`); + if (seenHashes.has(snippetHash2)) continue; + seenHashes.add(snippetHash2); + let field2 = void 0; + let variableType2 = "global_variable"; + for (const cls of allClasses) { + if (startLine >= cls.startLine && endLine <= cls.endLine) { + field2 = cls.name; + variableType2 = "member_variable"; + break; + } + } + let definitionText2 = varName; + if (variableType2 === "global_variable") { + definitionText2 = replaceNewlinesWithSpaces(rangeText2).trim(); + } + snippets.push({ + name: varName, + type: "variable_or_constant" /* VariableOrConstant */, + filePath, + startLine, + endLine, + rangeText: rangeText2, + definitionText: definitionText2, + scope: scope2, + fileHash, + field: field2, + definition: { + name: varName, + type: variableType2 + }, + language: "javascript" /* JavaScript */ + }); + } + continue; + } + const nameCap = captures.find( + (c) => c.name === "name.definition.variable" && c.node.startIndex >= node.startIndex && c.node.endIndex <= node.endIndex + ) || captures.find( + (c) => c.name === "name.definition.member_variable" && c.node.startIndex >= node.startIndex && c.node.endIndex <= node.endIndex + ); + if (!nameCap) continue; + const name2 = sourceCode.substring(nameCap.node.startIndex, nameCap.node.endIndex); + const scope = buildScopeChain(node); + const isMemberVariable = captures.some( + (c) => c.name === "name.definition.member_variable" && c.node.startIndex >= node.startIndex && c.node.endIndex <= node.endIndex && sourceCode.substring(c.node.startIndex, c.node.endIndex) === name2 + ); + const isInsideFunction = scope.length > 0 && scope.some((scopeItem) => { + return !allClasses.some((cls) => cls.name === scopeItem); + }); + if (isInsideFunction && !isMemberVariable) continue; + const rangeText = sourceCode.substring(node.startIndex, node.endIndex); + const snippetHash = generateSnippetHash(filePath, startLine, endLine, rangeText); + if (seenHashes.has(snippetHash)) continue; + seenHashes.add(snippetHash); + let field = void 0; + let variableType = "global_variable"; + for (const cls of allClasses) { + if (startLine >= cls.startLine && endLine <= cls.endLine) { + field = cls.name; + variableType = "member_variable"; + break; + } + } + let definitionText = name2; + if (variableType === "global_variable") { + definitionText = replaceNewlinesWithSpaces(rangeText).trim(); + } + snippets.push({ + name: name2, + type: "variable_or_constant" /* VariableOrConstant */, + filePath, + startLine, + endLine, + rangeText, + definitionText, + scope, + fileHash, + field, + definition: { + name: name2, + type: variableType + }, + language: "javascript" /* JavaScript */ + }); + } + return snippets.filter((snippet) => snippetTypes.includes(snippet.type)).sort((a, b) => a.startLine - b.startLine); +} +function splitJavaScriptParameters(params) { + const result = []; + let current = ""; + let braceDepth = 0; + let bracketDepth = 0; + let parenDepth = 0; + let inString = false; + let stringChar = ""; + for (let i2 = 0; i2 < params.length; i2++) { + const char = params[i2]; + const prevChar = i2 > 0 ? params[i2 - 1] : ""; + if (!inString && (char === '"' || char === "'" || char === "`")) { + inString = true; + stringChar = char; + } else if (inString && char === stringChar && prevChar !== "\\") { + inString = false; + stringChar = ""; + } + if (!inString) { + if (char === "{") braceDepth++; + else if (char === "}") braceDepth--; + else if (char === "[") bracketDepth++; + else if (char === "]") bracketDepth--; + else if (char === "(") parenDepth++; + else if (char === ")") parenDepth--; + else if (char === "," && braceDepth === 0 && bracketDepth === 0 && parenDepth === 0) { + if (current.trim()) { + result.push(current.trim()); + } + current = ""; + continue; + } + } + current += char; + } + if (current.trim()) { + result.push(current.trim()); + } + return result; +} + +// ../autocompletion/v2/capturesProcess/jsx.ts +async function extractSnippetsFromCapturesForJSX(captures, sourceCode, filePath, fileHash, snippetTypes, options) { + const jsSnippets = await extractSnippetsFromCapturesForJavaScript( + captures, + sourceCode, + filePath, + fileHash, + snippetTypes, + options + ); + for (const snippet of jsSnippets) { + snippet.language = "jsx" /* JSX */; + if (snippet.type === "function_or_method" /* FunctionOrMethod */ && snippet.definition?.type === "function") { + snippet.definition.type = "react_component"; + if (snippet.parameters && snippet.parameters.length > 0) { + const improvedParams = []; + for (const param of snippet.parameters) { + if (param.name.includes("{") && param.name.includes("}")) { + const openBrace = param.name.indexOf("{"); + const closeBrace = param.name.indexOf("}"); + if (openBrace !== -1 && closeBrace !== -1 && closeBrace > openBrace) { + const destructuredContent = param.name.substring(openBrace + 1, closeBrace); + const destructuredParams = destructuredContent.split(",").map((p) => { + const equalIndex = p.indexOf("="); + const cleanParam = equalIndex !== -1 ? p.substring(0, equalIndex).trim() : p.trim(); + return cleanParam; + }); + improvedParams.push(...destructuredParams.map((p) => ({ name: p }))); + } + } else { + improvedParams.push(param); + } + } + snippet.parameters = improvedParams; + const paramStr = improvedParams.map((p) => p.name).join(", "); + snippet.signature = `${snippet.name}(${paramStr})`; + } + } else if (snippet.type === "function_or_method" /* FunctionOrMethod */ && snippet.definition?.type === "arrow function") { + snippet.definition.type = "react_component"; + if (snippet.parameters && snippet.parameters.length > 0) { + const improvedParams = []; + for (const param of snippet.parameters) { + if (param.name.includes("{") && param.name.includes("}")) { + const openBrace = param.name.indexOf("{"); + const closeBrace = param.name.indexOf("}"); + if (openBrace !== -1 && closeBrace !== -1 && closeBrace > openBrace) { + const destructuredContent = param.name.substring(openBrace + 1, closeBrace); + const destructuredParams = destructuredContent.split(",").map((p) => { + const equalIndex = p.indexOf("="); + const cleanParam = equalIndex !== -1 ? p.substring(0, equalIndex).trim() : p.trim(); + return cleanParam; + }); + improvedParams.push(...destructuredParams.map((p) => ({ name: p }))); + } + } else { + improvedParams.push(param); + } + } + snippet.parameters = improvedParams; + const paramStr = improvedParams.map((p) => p.name).join(", "); + snippet.signature = `${snippet.name}(${paramStr})`; + } + } else if (snippet.type === "class_or_interface_or_struct" /* ClassOrInterfaceOrStructOrEnum */ && snippet.definition?.type === "class") { + snippet.definition.type = "react_class_component"; + } else if (snippet.type === "import_or_include" /* ImportOrInclude */ && snippet.definition?.type === "import") { + snippet.definition.type = "react_import"; + } + if (snippet.type === "function_or_method" /* FunctionOrMethod */ && snippet.name.startsWith("use") && snippet.definition?.type === "react_component") { + snippet.definition.type = "react_custom_hook"; + if (snippet.parameters && snippet.parameters.length > 0) { + const improvedParams = []; + for (const param of snippet.parameters) { + const equalIndex = param.name.indexOf("="); + const cleanName = equalIndex !== -1 ? param.name.substring(0, equalIndex).trim() : param.name; + improvedParams.push({ name: cleanName }); + } + snippet.parameters = improvedParams; + const paramStr = improvedParams.map((p) => p.name).join(", "); + snippet.signature = `${snippet.name}(${paramStr})`; + } + } + } + const snippets = [...jsSnippets]; + const seenHashes = /* @__PURE__ */ new Set(); + for (const snippet of snippets) { + const hash = generateSnippetHash(snippet.filePath, snippet.startLine, snippet.endLine, snippet.rangeText); + seenHashes.add(hash); + } + for (const capture of captures) { + if (capture.name !== "definition.jsx_element") continue; + const node = capture.node; + const startLine = node.startPosition.row + 1; + const endLine = node.endPosition.row + 1; + const nameCap = captures.find( + (c) => c.name === "name.jsx_element" && c.node.startIndex >= node.startIndex && c.node.endIndex <= node.endIndex + ); + if (!nameCap) continue; + const name2 = sourceCode.substring(nameCap.node.startIndex, nameCap.node.endIndex); + const firstChar = name2.charAt(0); + if (firstChar < "A" || firstChar > "Z") continue; + const rangeText = sourceCode.substring(node.startIndex, node.endIndex); + const snippetHash = generateSnippetHash(filePath, startLine, endLine, rangeText); + if (seenHashes.has(snippetHash)) continue; + seenHashes.add(snippetHash); + const scope = buildScopeChain(node); + snippets.push({ + name: name2, + signature: `<${name2}>`, + parameters: [], + type: "variable_or_constant" /* VariableOrConstant */, + filePath, + startLine, + endLine, + rangeText, + implementText: rangeText, + scope, + fileHash, + language: "jsx" /* JSX */, + definition: { + name: name2, + type: "jsx_element", + parameters: [] + } + }); + } + for (const capture of captures) { + if (capture.name !== "array_pattern") continue; + const node = capture.node; + const startLine = node.startPosition.row + 1; + const endLine = node.endPosition.row + 1; + const parentNode = node.parent; + if (!parentNode || parentNode.type !== "variable_declarator") continue; + const valueNode = parentNode.namedChild(1); + if (!valueNode || valueNode.type !== "call_expression") continue; + const functionNode = valueNode.namedChild(0); + if (!functionNode || functionNode.type !== "identifier") continue; + const functionName = sourceCode.substring(functionNode.startIndex, functionNode.endIndex); + if (functionName !== "useState") continue; + const firstIdentifier = node.namedChild(0); + const secondIdentifier = node.namedChild(1); + if (!firstIdentifier || !secondIdentifier || firstIdentifier.type !== "identifier" || secondIdentifier.type !== "identifier") { + continue; + } + const stateName = sourceCode.substring(firstIdentifier.startIndex, firstIdentifier.endIndex); + const setterName = sourceCode.substring(secondIdentifier.startIndex, secondIdentifier.endIndex); + const rangeText = sourceCode.substring(parentNode.startIndex, parentNode.endIndex); + const snippetHash = generateSnippetHash(filePath, startLine, endLine, rangeText); + if (seenHashes.has(snippetHash)) continue; + seenHashes.add(snippetHash); + const scope = buildScopeChain(node); + snippets.push({ + name: stateName, + signature: `useState()`, + parameters: [], + type: "variable_or_constant" /* VariableOrConstant */, + filePath, + startLine, + endLine, + rangeText, + implementText: rangeText, + scope, + fileHash, + language: "jsx" /* JSX */, + definition: { + name: stateName, + type: "react_hook", + parameters: [] + } + }); + } + for (const capture of captures) { + if (capture.name !== "name.definition.function") continue; + const node = capture.node; + const functionName = sourceCode.substring(node.startIndex, node.endIndex); + if (!functionName.startsWith("use")) continue; + const startLine = node.startPosition.row + 1; + const endLine = node.endPosition.row + 1; + let callExpressionNode = node.parent; + while (callExpressionNode && callExpressionNode.type !== "call_expression") { + callExpressionNode = callExpressionNode.parent; + } + if (!callExpressionNode) continue; + if (functionName === "useState") { + let parentNode = callExpressionNode.parent; + while (parentNode && parentNode.type !== "variable_declarator") { + parentNode = parentNode.parent; + } + if (parentNode) { + const nameNode = parentNode.namedChild(0); + if (nameNode && nameNode.type === "array_pattern") { + continue; + } + } + } + const rangeText = sourceCode.substring(callExpressionNode.startIndex, callExpressionNode.endIndex); + const snippetHash = generateSnippetHash(filePath, startLine, endLine, rangeText); + if (seenHashes.has(snippetHash)) continue; + seenHashes.add(snippetHash); + const scope = buildScopeChain(node); + snippets.push({ + name: functionName, + signature: `${functionName}()`, + parameters: [], + type: "variable_or_constant" /* VariableOrConstant */, + filePath, + startLine, + endLine, + rangeText, + implementText: rangeText, + scope, + fileHash, + language: "jsx" /* JSX */, + definition: { + name: functionName, + type: "react_hook", + parameters: [] + } + }); + } + for (const capture of captures) { + if (capture.name !== "name.definition.variable") continue; + const node = capture.node; + const variableName = sourceCode.substring(node.startIndex, node.endIndex); + let declaratorNode = node.parent; + while (declaratorNode && declaratorNode.type !== "variable_declarator") { + declaratorNode = declaratorNode.parent; + } + if (!declaratorNode) continue; + const valueNode = declaratorNode.namedChild(1); + if (!valueNode || valueNode.type !== "call_expression") continue; + const functionNode = valueNode.namedChild(0); + if (!functionNode || functionNode.type !== "identifier") continue; + const functionName = sourceCode.substring(functionNode.startIndex, functionNode.endIndex); + const firstChar = functionName.charAt(0); + const isUppercase = firstChar >= "A" && firstChar <= "Z"; + const startsWithWith = functionName.startsWith("with"); + if (!isUppercase && !startsWithWith) continue; + const startLine = node.startPosition.row + 1; + const endLine = node.endPosition.row + 1; + const rangeText = sourceCode.substring(declaratorNode.startIndex, declaratorNode.endIndex); + const snippetHash = generateSnippetHash(filePath, startLine, endLine, rangeText); + if (seenHashes.has(snippetHash)) continue; + seenHashes.add(snippetHash); + const scope = buildScopeChain(node); + snippets.push({ + name: variableName, + signature: `${functionName}(${variableName})`, + parameters: [], + type: "function_or_method" /* FunctionOrMethod */, + filePath, + startLine, + endLine, + rangeText, + implementText: rangeText, + scope, + fileHash, + language: "jsx" /* JSX */, + definition: { + name: variableName, + type: "react_hoc", + parameters: [] + } + }); + } + return snippets; +} +function buildSummaryFromSnippets4(snippets) { + const outline = []; + const isTopLevel = (s) => { + return !s.scope || s.scope.length <= 1; + }; + for (const s of snippets) { + if (!isTopLevel(s)) continue; + if (s.type === "import_or_include" /* ImportOrInclude */) { + continue; + } else if (s.type === "function_or_method" /* FunctionOrMethod */) { + const definitionType = s.definition?.type; + if (definitionType === "react_component") { + outline.push({ + type: "component", + name: s.name, + file: s.filePath, + field: "", + description: s.signature + }); + } else if (definitionType === "react_custom_hook") { + outline.push({ + type: "custom_hook", + name: s.name, + file: s.filePath, + field: "", + description: s.signature + }); + } else { + outline.push({ + type: "function", + name: s.name, + file: s.filePath, + field: s.field || "", + description: s.signature + }); + } + } else if (s.type === "class_or_interface_or_struct" /* ClassOrInterfaceOrStructOrEnum */) { + outline.push({ + type: "class", + name: s.name, + file: s.filePath, + field: "", + description: s.signature || s.name + }); + } else if (s.type === "variable_or_constant" /* VariableOrConstant */) { + const definitionType = s.definition?.type; + if (definitionType === "react_hook") { + outline.push({ + type: "hook", + name: s.name, + file: s.filePath, + field: "", + description: s.signature + }); + } else if (definitionType === "jsx_element") { + outline.push({ + type: "jsx_element", + name: s.name, + file: s.filePath, + field: "", + description: s.signature + }); + } else { + outline.push({ + type: "variable", + name: s.name, + file: s.filePath, + field: s.field || "", + description: s.signature || s.name + }); + } + } + } + return outline; +} +function formatOutlineText4(outline) { + const groups = {}; + for (const entry of outline) { + const key = entry.type; + if (!groups[key]) groups[key] = []; + groups[key].push(entry); + } + let result = ""; + const typeOrder = ["component", "class", "custom_hook", "hook", "jsx_element", "function", "variable"]; + const typeLabels = { + component: "## React Components", + class: "## Classes", + custom_hook: "## Custom Hooks", + hook: "## React Hooks", + jsx_element: "## JSX Elements", + function: "## Functions", + variable: "## Variables" + }; + for (const type of typeOrder) { + const group = groups[type]; + if (!group || group.length === 0) continue; + result += typeLabels[type] + "\n"; + for (const entry of group) { + result += `- ${entry.description || entry.name} +`; + } + result += "\n"; + } + return result; +} + +// ../autocompletion/v2/capturesProcess/typescript.ts +async function extractSnippetsFromCapturesForTypeScript(captures, sourceCode, filePath, fileHash, snippetTypes, options) { + const logger = Logger.getDefaultLogger().with("[TS extract]"); + const snippets = []; + const seen = /* @__PURE__ */ new Set(); + if (snippetTypes.length === 0) return snippets; + for (const c of captures.filter((c2) => c2.name === "name.import")) { + const node = c.node; + const startLine = node.startPosition.row + 1; + const endLine = node.endPosition.row + 1; + const text = sourceCode.slice(node.startIndex, node.endIndex); + const hash = generateSnippetHash(filePath, startLine, endLine, text); + if (seen.has(hash)) continue; + seen.add(hash); + snippets.push({ + name: text, + type: "import_or_include" /* ImportOrInclude */, + filePath, + startLine, + endLine, + rangeText: text, + definitionText: text, + scope: buildScopeChain(node), + fileHash + }); + } + for (const def of captures.filter((c) => c.name === "definition.function" || c.name === "definition.method")) { + const node = def.node; + const startLine = node.startPosition.row + 1; + const endLine = node.endPosition.row + 1; + const nameCap = captures.find( + (c) => c.name === (def.name === "definition.method" ? "name.method" : "name.function") && c.node.startIndex >= node.startIndex && c.node.endIndex <= node.endIndex + ); + if (!nameCap) continue; + const name2 = sourceCode.slice(nameCap.node.startIndex, nameCap.node.endIndex); + const paramsCap = captures.find( + (c) => c.name === "parameters.function" && c.node.startIndex >= node.startIndex && c.node.endIndex <= node.endIndex + ); + const parameters = []; + if (paramsCap) { + const raw = sourceCode.slice(paramsCap.node.startIndex, paramsCap.node.endIndex); + raw.replace(/^\(|\)$/g, "").split(",").map((p) => p.trim()).filter((p) => p).forEach((p) => parameters.push({ name: p })); + } + const isMethod = def.name === "definition.method"; + let field; + if (isMethod) { + const classDefCap = captures.find( + (c) => c.name === "definition.class" && c.node.startIndex < node.startIndex && c.node.endIndex > node.endIndex + ); + if (classDefCap) { + const classCap = captures.find( + (c) => c.name === "name.class" && c.node.startIndex >= classDefCap.node.startIndex && c.node.endIndex <= classDefCap.node.endIndex + ); + if (classCap) { + field = sourceCode.slice(classCap.node.startIndex, classCap.node.endIndex); + } + } + } + const sig = `${name2}(${parameters.map((p) => p.name).join(", ")})`; + const hash = generateSnippetHash(filePath, startLine, endLine, sig); + if (seen.has(hash)) continue; + seen.add(hash); + snippets.push({ + name: name2, + type: "function_or_method" /* FunctionOrMethod */, + filePath, + startLine, + endLine, + rangeText: sourceCode.slice(node.startIndex, node.endIndex), + definitionText: sig, + scope: buildScopeChain(node), + fileHash, + field, + parameters, + signature: sig, + definition: { + name: name2, + type: def.name === "definition.method" ? "method" : "function", + parameters, + returnType: "" + }, + language: "typescript" /* TypeScript */, + implementText: sourceCode.slice(node.startIndex, node.endIndex) + }); + } + const typeDefs = [ + { + name: "name.class", + def: "definition.class", + kind: "class", + type: "class_or_interface_or_struct" /* ClassOrInterfaceOrStructOrEnum */ + }, + { + name: "name.interface", + def: "definition.interface", + kind: "interface", + type: "class_or_interface_or_struct" /* ClassOrInterfaceOrStructOrEnum */ + }, + { name: "name.enum", def: "definition.enum", kind: "enum", type: "class_or_interface_or_struct" /* ClassOrInterfaceOrStructOrEnum */ }, + { + name: "name.type_alias", + def: "definition.type_alias", + kind: "type", + type: "class_or_interface_or_struct" /* ClassOrInterfaceOrStructOrEnum */ + } + ]; + for (const { name: capName, def: defName, kind, type } of typeDefs) { + for (const c of captures.filter((c2) => c2.name === capName)) { + const node = c.node; + const startLine = node.startPosition.row + 1; + const endLine = node.endPosition.row + 1; + const text = sourceCode.slice(node.startIndex, node.endIndex); + const inFunc = captures.some( + (fc) => (fc.name === "definition.function" || fc.name === "definition.method") && fc.node.startIndex < node.startIndex && node.endIndex < fc.node.endIndex + ); + if (inFunc) continue; + const defCap = captures.find( + (dc) => dc.name === defName && dc.node.startIndex <= node.startIndex && node.endIndex <= dc.node.endIndex + ); + const defNode = defCap ? defCap.node : node.parent || node; + const hash = generateSnippetHash(filePath, startLine, endLine, text); + if (seen.has(hash)) continue; + seen.add(hash); + snippets.push({ + name: text, + type, + filePath, + startLine, + endLine, + rangeText: sourceCode.slice(defNode.startIndex, defNode.endIndex), + definitionText: text, + implementText: sourceCode.slice(defNode.startIndex, defNode.endIndex), + scope: buildScopeChain(node), + fileHash, + definition: { name: text, type: kind }, + language: "typescript" /* TypeScript */, + field: "" + }); + } + } + for (const c of captures.filter((c2) => c2.name === "name.variable")) { + const node = c.node; + const startLine = node.startPosition.row + 1; + const endLine = node.endPosition.row + 1; + const name2 = sourceCode.slice(node.startIndex, node.endIndex); + const inFunc = captures.some( + (fc) => (fc.name === "definition.function" || fc.name === "definition.method") && fc.node.startIndex < node.startIndex && node.endIndex < fc.node.endIndex + ); + if (inFunc) continue; + const hash = generateSnippetHash(filePath, startLine, endLine, name2); + if (seen.has(hash)) continue; + seen.add(hash); + snippets.push({ + name: name2, + type: "variable_or_constant" /* VariableOrConstant */, + filePath, + startLine, + endLine, + rangeText: sourceCode.slice(node.startIndex, node.endIndex), + definitionText: name2, + implementText: name2, + scope: buildScopeChain(node), + fileHash, + definition: { name: name2, type: "variable" }, + language: "typescript" /* TypeScript */, + field: "" + }); + } + for (const c of captures.filter((c2) => c2.name === "name.property")) { + const node = c.node; + const startLine = node.startPosition.row + 1; + const endLine = node.endPosition.row + 1; + const name2 = sourceCode.slice(node.startIndex, node.endIndex); + let field; + const parentInterface = captures.find( + (ic) => ic.name === "definition.interface" && ic.node.startIndex < node.startIndex && ic.node.endIndex > node.endIndex + ); + const parentClass = captures.find( + (cc) => cc.name === "definition.class" && cc.node.startIndex < node.startIndex && cc.node.endIndex > node.endIndex + ); + if (parentInterface) { + const interfaceCap = captures.find( + (ic) => ic.name === "name.interface" && ic.node.startIndex >= parentInterface.node.startIndex && ic.node.endIndex <= parentInterface.node.endIndex + ); + if (interfaceCap) { + field = sourceCode.slice(interfaceCap.node.startIndex, interfaceCap.node.endIndex); + } + } else if (parentClass) { + const classCap = captures.find( + (cc) => cc.name === "name.class" && cc.node.startIndex >= parentClass.node.startIndex && cc.node.endIndex <= parentClass.node.endIndex + ); + if (classCap) { + field = sourceCode.slice(classCap.node.startIndex, classCap.node.endIndex); + } + } + const hash = generateSnippetHash(filePath, startLine, endLine, name2); + if (seen.has(hash)) continue; + seen.add(hash); + snippets.push({ + name: name2, + type: "variable_or_constant" /* VariableOrConstant */, + filePath, + startLine, + endLine, + rangeText: sourceCode.slice(node.startIndex, node.endIndex), + definitionText: name2, + implementText: name2, + scope: buildScopeChain(node), + fileHash, + field, + definition: { name: name2, type: "property" }, + language: "typescript" /* TypeScript */ + }); + } + return snippets; +} +function buildSummaryFromSnippets5(snips) { + const outline = []; + for (const s of snips) { + if (s.type === "import_or_include" /* ImportOrInclude */) { + outline.push({ type: "import", name: s.name, file: s.filePath, field: "", description: s.definitionText }); + } else if (s.type === "function_or_method" /* FunctionOrMethod */) { + outline.push({ + type: s.field ? "method" : "function", + name: s.name, + file: s.filePath, + field: s.field || "", + description: s.definitionText + }); + } else if (s.type === "class_or_interface_or_struct" /* ClassOrInterfaceOrStructOrEnum */) { + outline.push({ + type: s.definition?.type || "type", + name: s.name, + file: s.filePath, + field: "", + description: s.name + }); + } else if (s.type === "variable_or_constant" /* VariableOrConstant */) { + outline.push({ type: "variable", name: s.name, file: s.filePath, field: "", description: s.definitionText }); + } + } + return outline; +} +function formatOutlineText5(outline) { + const groups = {}; + for (const e of outline) { + const key = e.field || ""; + (groups[key] ||= []).push(e); + } + let out2 = ""; + for (const field of Object.keys(groups).sort()) { + out2 += (field ? `[${field}]` : "[global]") + "\n"; + for (const e of groups[field]) { + out2 += ` ${e.type}: ${e.description} +`; + } + out2 += "\n"; + } + return out2.trimEnd(); +} + +// ../autocompletion/v2/capturesProcess/tsx.ts +function startsWithUppercase(name2) { + return name2.length > 0 && name2[0] >= "A" && name2[0] <= "Z"; +} +function isGenericComponent(rangeText) { + return rangeText.includes("function") && rangeText.includes("<") && rangeText.includes(">("); +} +function cleanParameterName(paramText) { + let cleaned = paramText.trim(); + const colonIndex = cleaned.indexOf(":"); + if (colonIndex !== -1) { + cleaned = cleaned.substring(0, colonIndex).trim(); + } + const equalsIndex = cleaned.indexOf("="); + if (equalsIndex !== -1) { + cleaned = cleaned.substring(0, equalsIndex).trim(); + } + if (cleaned.endsWith("?")) { + cleaned = cleaned.slice(0, -1).trim(); + } + return cleaned; +} +function extractDestructuredParamsFromText(paramText) { + const params = []; + const openBrace = paramText.indexOf("{"); + const closeBrace = paramText.lastIndexOf("}"); + if (openBrace !== -1 && closeBrace !== -1 && closeBrace > openBrace) { + const destructuredContent = paramText.substring(openBrace + 1, closeBrace); + const paramNames = destructuredContent.split(","); + for (const param of paramNames) { + const cleanName = cleanParameterName(param); + if (cleanName && cleanName !== "..." && !cleanName.includes("...")) { + params.push(cleanName); + } + } + } + return params; +} +async function extractSnippetsFromCapturesForTSX(captures, sourceCode, filePath, fileHash, snippetTypes, options) { + const logger = Logger.getDefaultLogger().with("[TSX extract]"); + const tsSnippets = await extractSnippetsFromCapturesForTypeScript( + captures, + sourceCode, + filePath, + fileHash, + snippetTypes, + options + ); + for (const snippet of tsSnippets) { + snippet.language = "tsx" /* TSX */; + if (snippet.type === "function_or_method" /* FunctionOrMethod */ && snippet.definition?.type === "function") { + if (snippet.name.startsWith("use")) { + snippet.definition.type = "react_custom_hook"; + } else { + const isReactComponent = startsWithUppercase(snippet.name) || snippet.rangeText.includes("return") && snippet.rangeText.includes("<") && snippet.rangeText.includes(">"); + if (isReactComponent) { + if (snippet.rangeText.includes("<") && snippet.rangeText.includes(">(") && isGenericComponent(snippet.rangeText)) { + snippet.definition.type = "react_generic_component"; + } else { + snippet.definition.type = "react_component"; + } + } + } + if (snippet.parameters && snippet.parameters.length > 0) { + const paramTexts = snippet.parameters.map((p) => p.name.trim()); + const fullParamText = paramTexts.join(", "); + const improvedParams = []; + if (fullParamText.includes("{") && fullParamText.includes("}")) { + const destructuredParams = extractDestructuredParamsFromText(fullParamText); + improvedParams.push(...destructuredParams.map((p) => ({ name: p }))); + } else { + for (const param of snippet.parameters) { + const paramText = param.name.trim(); + const cleanName = cleanParameterName(paramText); + if (cleanName && !cleanName.includes("{") && !cleanName.includes("}")) { + improvedParams.push({ name: cleanName }); + } + } + } + snippet.parameters = improvedParams; + const paramStr = improvedParams.map((p) => p.name).join(", "); + snippet.signature = `${snippet.name}(${paramStr})`; + } else if (!snippet.parameters || snippet.parameters.length === 0) { + if (snippet.definition?.parameters && snippet.definition.parameters.length > 0) { + const paramTexts = snippet.definition.parameters.map((p) => p.name || ""); + const fullParamText = paramTexts.join(", "); + const improvedParams = []; + if (fullParamText.includes("{") && fullParamText.includes("}")) { + const destructuredParams = extractDestructuredParamsFromText(fullParamText); + improvedParams.push(...destructuredParams.map((p) => ({ name: p }))); + } else { + for (const param of snippet.definition.parameters) { + const paramText = param.name?.trim() || ""; + const cleanName = cleanParameterName(paramText); + if (cleanName && !cleanName.includes("{") && !cleanName.includes("}")) { + improvedParams.push({ name: cleanName }); + } + } + } + snippet.parameters = improvedParams; + const paramStr = improvedParams.map((p) => p.name).join(", "); + snippet.signature = `${snippet.name}(${paramStr})`; + } + } + } else if (snippet.type === "function_or_method" /* FunctionOrMethod */ && snippet.definition?.type === "method") { + } else if (snippet.type === "class_or_interface_or_struct" /* ClassOrInterfaceOrStructOrEnum */ && snippet.definition?.type === "class") { + if (snippet.rangeText.includes("extends") && (snippet.rangeText.includes("Component") || snippet.rangeText.includes("PureComponent"))) { + snippet.definition.type = "react_class_component"; + } + } else if (snippet.type === "import_or_include" /* ImportOrInclude */ && snippet.definition?.type === "import") { + snippet.definition.type = "react_import"; + } else if (snippet.type === "variable_or_constant" /* VariableOrConstant */ && snippet.definition?.type === "variable") { + if (startsWithUppercase(snippet.name)) { + const isLikelyComponent = tsSnippets.some( + (s) => s.name === snippet.name && s.type === "function_or_method" /* FunctionOrMethod */ && s.definition?.type === "react_component" + ) || // 或者检查常见的 React 组件模式 + snippet.rangeText.includes("withError") || snippet.rangeText.includes("memo(") || snippet.rangeText.includes("forwardRef(") || snippet.rangeText.includes("lazy(") || snippet.rangeText.includes("React.") || snippet.rangeText.includes("FC") || snippet.rangeText.includes("FunctionComponent") || snippet.rangeText.includes("=>") && snippet.rangeText.includes("<") && snippet.rangeText.includes(">"); + if (isLikelyComponent) { + snippet.definition.type = "react_component"; + snippet.type = "function_or_method" /* FunctionOrMethod */; + } + } + } + } + const snippets = [...tsSnippets]; + const seenHashes = /* @__PURE__ */ new Set(); + for (const snippet of snippets) { + const hash = generateSnippetHash(snippet.filePath, snippet.startLine, snippet.endLine, snippet.rangeText); + seenHashes.add(hash); + } + for (const capture of captures) { + if (capture.name !== "definition.component" && capture.name !== "definition.jsx_element" && capture.name !== "definition.jsx_self_closing_element") + continue; + const node = capture.node; + const startLine = node.startPosition.row + 1; + const endLine = node.endPosition.row + 1; + let nameCap; + if (capture.name === "definition.component") { + nameCap = captures.find( + (c) => c.name === "name" && c.node.startIndex >= node.startIndex && c.node.endIndex <= node.endIndex + ); + } else { + nameCap = captures.find( + (c) => c.name === "component" && c.node.startIndex >= node.startIndex && c.node.endIndex <= node.endIndex + ); + } + if (!nameCap) continue; + const name2 = sourceCode.substring(nameCap.node.startIndex, nameCap.node.endIndex); + if (!startsWithUppercase(name2) && !isKnownReactComponent(name2)) continue; + const rangeText = sourceCode.substring(node.startIndex, node.endIndex); + const snippetHash = generateSnippetHash(filePath, startLine, endLine, rangeText); + if (seenHashes.has(snippetHash)) continue; + seenHashes.add(snippetHash); + const scope = buildScopeChain(node); + snippets.push({ + name: name2, + signature: `<${name2}>`, + type: "function_or_method" /* FunctionOrMethod */, + filePath, + startLine, + endLine, + rangeText, + definitionText: `<${name2}>`, + implementText: rangeText, + scope, + fileHash, + language: "tsx" /* TSX */, + definition: { + name: name2, + type: "jsx_component", + parameters: [], + returnType: "JSX.Element" + } + }); + } + for (const capture of captures) { + if (capture.name !== "definition.member_component") continue; + const node = capture.node; + const startLine = node.startPosition.row + 1; + const endLine = node.endPosition.row + 1; + const objectCap = captures.find( + (c) => c.name === "object" && c.node.startIndex >= node.startIndex && c.node.endIndex <= node.endIndex + ); + const propertyCap = captures.find( + (c) => c.name === "property" && c.node.startIndex >= node.startIndex && c.node.endIndex <= node.endIndex + ); + if (!objectCap || !propertyCap) continue; + const objectName = sourceCode.substring(objectCap.node.startIndex, objectCap.node.endIndex); + const propertyName = sourceCode.substring(propertyCap.node.startIndex, propertyCap.node.endIndex); + const fullName = `${objectName}.${propertyName}`; + if (!startsWithUppercase(objectName)) continue; + const rangeText = sourceCode.substring(node.startIndex, node.endIndex); + const snippetHash = generateSnippetHash(filePath, startLine, endLine, rangeText); + if (seenHashes.has(snippetHash)) continue; + seenHashes.add(snippetHash); + const scope = buildScopeChain(node); + snippets.push({ + name: fullName, + signature: `<${fullName}>`, + type: "function_or_method" /* FunctionOrMethod */, + filePath, + startLine, + endLine, + rangeText, + definitionText: `<${fullName}>`, + implementText: rangeText, + scope, + fileHash, + field: objectName, + language: "tsx" /* TSX */, + definition: { + name: fullName, + type: "jsx_member_component", + parameters: [], + returnType: "JSX.Element" + } + }); + } + for (const capture of captures) { + if (capture.name !== "definition.conditional_component") continue; + const node = capture.node; + const startLine = node.startPosition.row + 1; + const endLine = node.endPosition.row + 1; + const componentCap = captures.find( + (c) => c.name === "component" && c.node.startIndex >= node.startIndex && c.node.endIndex <= node.endIndex + ); + if (!componentCap) continue; + const name2 = sourceCode.substring(componentCap.node.startIndex, componentCap.node.endIndex); + if (!startsWithUppercase(name2)) continue; + const rangeText = sourceCode.substring(node.startIndex, node.endIndex); + const snippetHash = generateSnippetHash(filePath, startLine, endLine, rangeText); + if (seenHashes.has(snippetHash)) continue; + seenHashes.add(snippetHash); + const scope = buildScopeChain(node); + snippets.push({ + name: name2, + signature: `{condition ? <${name2}> : null}`, + type: "function_or_method" /* FunctionOrMethod */, + filePath, + startLine, + endLine, + rangeText, + definitionText: `{condition ? <${name2}> : null}`, + implementText: rangeText, + scope, + fileHash, + language: "tsx" /* TSX */, + definition: { + name: name2, + type: "jsx_conditional_component", + parameters: [], + returnType: "JSX.Element | null" + } + }); + } + for (const capture of captures) { + if (capture.name !== "definition.generic_component") continue; + const node = capture.node; + const startLine = node.startPosition.row + 1; + const endLine = node.endPosition.row + 1; + const nameCap = captures.find( + (c) => c.name === "name" && c.node.startIndex >= node.startIndex && c.node.endIndex <= node.endIndex + ); + if (!nameCap) continue; + const name2 = sourceCode.substring(nameCap.node.startIndex, nameCap.node.endIndex); + const isReactComponent = startsWithUppercase(name2) || sourceCode.substring(node.startIndex, node.endIndex).includes("JSX"); + if (!isReactComponent) continue; + const rangeText = sourceCode.substring(node.startIndex, node.endIndex); + const snippetHash = generateSnippetHash(filePath, startLine, endLine, rangeText); + if (seenHashes.has(snippetHash)) continue; + seenHashes.add(snippetHash); + const scope = buildScopeChain(node); + snippets.push({ + name: name2, + signature: `${name2}`, + type: "function_or_method" /* FunctionOrMethod */, + filePath, + startLine, + endLine, + rangeText, + definitionText: `${name2}`, + implementText: rangeText, + scope, + fileHash, + language: "tsx" /* TSX */, + definition: { + name: name2, + type: "react_generic_component", + parameters: [], + returnType: "JSX.Element" + } + }); + } + return snippets; +} +function isKnownReactComponent(name2) { + const knownComponents = [ + "Fragment", + "Suspense", + "StrictMode", + "Profiler", + "ErrorBoundary", + "Provider", + "Consumer", + "Portal" + ]; + return knownComponents.includes(name2); +} +function buildSummaryFromSnippets6(snips) { + const outline = []; + for (const s of snips) { + if (s.type === "import_or_include" /* ImportOrInclude */) { + outline.push({ + type: "import", + name: s.name, + file: s.filePath, + field: "", + description: s.definitionText + }); + } else if (s.type === "function_or_method" /* FunctionOrMethod */) { + let type = "function"; + if (s.definition?.type === "react_component") type = "component"; + else if (s.definition?.type === "react_custom_hook") type = "hook"; + else if (s.definition?.type === "jsx_component") type = "jsx"; + else if (s.definition?.type === "jsx_member_component") type = "jsx.member"; + else if (s.definition?.type === "jsx_conditional_component") type = "jsx.conditional"; + else if (s.definition?.type === "react_generic_component") type = "component.generic"; + else if (s.field) type = "method"; + outline.push({ + type, + name: s.name, + file: s.filePath, + field: s.field || "", + description: s.definitionText + }); + } else if (s.type === "class_or_interface_or_struct" /* ClassOrInterfaceOrStructOrEnum */) { + let type = s.definition?.type || "type"; + if (s.definition?.type === "react_class_component") type = "class.component"; + outline.push({ + type, + name: s.name, + file: s.filePath, + field: "", + description: s.name + }); + } else if (s.type === "variable_or_constant" /* VariableOrConstant */) { + outline.push({ + type: "variable", + name: s.name, + file: s.filePath, + field: s.field || "", + description: s.definitionText + }); + } + } + return outline; +} +function formatOutlineText6(outline) { + const groups = {}; + for (const e of outline) { + const key = e.field || ""; + (groups[key] ||= []).push(e); + } + let out2 = ""; + for (const field of Object.keys(groups).sort()) { + out2 += (field ? `[${field}]` : "[global]") + "\n"; + for (const e of groups[field]) { + out2 += ` ${e.type}: ${e.description} +`; + } + out2 += "\n"; + } + return out2.trimEnd(); +} + +// ../autocompletion/v2/capturesProcess/swift.ts +async function extractSnippetsFromCapturesForSwift(captures, sourceCode, filePath, fileHash, snippetTypes, options) { + const logger = Logger.getDefaultLogger().with("[extractSnippetsFromCapturesForSwift]"); + const snippets = []; + const seenHashes = /* @__PURE__ */ new Set(); + if (snippetTypes.length === 0) { + logger.warn(`No snippet types provided, skipping`); + return snippets; + } + const containerCaptures = captures.filter( + (c) => c.name === "definition.class" || c.name === "definition.struct" || c.name === "definition.protocol" || c.name === "definition.enum" + ).map((c) => { + const node = c.node; + const type = c.name.split(".")[1]; + let nameCap = captures.find( + (nc) => nc.name === `name.${c.name}` && nc.node.startIndex >= node.startIndex && nc.node.endIndex <= node.endIndex + ); + let actualName = nameCap ? sourceCode.substring(nameCap.node.startIndex, nameCap.node.endIndex) : ""; + if (type === "class") { + const actualType = determineClassDeclarationType(node, sourceCode); + if (actualType === "extension") { + if (node.childCount >= 2) { + const userTypeNode = node.child(1); + if (userTypeNode && userTypeNode.type === "user_type" && userTypeNode.childCount > 0) { + const typeIdNode = userTypeNode.child(0); + if (typeIdNode && typeIdNode.type === "type_identifier") { + actualName = sourceCode.substring(typeIdNode.startIndex, typeIdNode.endIndex); + } + } + } + } + } + return { + node, + start: node.startIndex, + end: node.endIndex, + type, + nameCap, + actualName + // 实际的类型名(对于extension是被扩展的类型) + }; + }); + captures.forEach((capture) => { + if (capture.name === "name.definition.import") { + const node = capture.node; + const startLine = node.startPosition.row + 1; + const endLine = node.endPosition.row + 1; + const rangeText = sourceCode.substring(node.startIndex, node.endIndex); + const snippetHash = generateSnippetHash(filePath, startLine, endLine, rangeText); + if (seenHashes.has(snippetHash)) return; + seenHashes.add(snippetHash); + const name2 = sourceCode.substring(node.startIndex, node.endIndex); + const scope = buildScopeChain(node); + snippets.push({ + name: name2, + type: "import_or_include" /* ImportOrInclude */, + filePath, + startLine, + endLine, + rangeText, + definitionText: rangeText, + scope, + fileHash + }); + } + }); + for (const capture of captures) { + let findParameterNodes = function(node2) { + if (node2.type === "parameter") { + parameterNodes.push(node2); + } + for (let i2 = 0; i2 < node2.childCount; i2++) { + const child = node2.child(i2); + if (child) { + findParameterNodes(child); + } + } + }; + if (capture.name !== "definition.method" && capture.name !== "definition.initializer" && capture.name !== "definition.deinitializer" && capture.name !== "definition.protocol_method") + continue; + const node = capture.node; + const startLine = node.startPosition.row + 1; + const endLine = node.endPosition.row + 1; + let nameCap; + if (capture.name === "definition.method") { + nameCap = captures.find( + (c) => c.name === "name.definition.method" && c.node.startIndex >= node.startIndex && c.node.endIndex <= node.endIndex + ); + } else if (capture.name === "definition.protocol_method") { + nameCap = captures.find( + (c) => c.name === "name.definition.protocol_method" && c.node.startIndex >= node.startIndex && c.node.endIndex <= node.endIndex + ); + } else if (capture.name === "definition.initializer") { + nameCap = captures.find( + (c) => c.name === "name.definition.initializer" && c.node.startIndex >= node.startIndex && c.node.endIndex <= node.endIndex + ); + } else if (capture.name === "definition.deinitializer") { + nameCap = captures.find( + (c) => c.name === "name.definition.deinitializer" && c.node.startIndex >= node.startIndex && c.node.endIndex <= node.endIndex + ); + } + if (!nameCap) continue; + const name2 = sourceCode.substring(nameCap.node.startIndex, nameCap.node.endIndex); + const parameters = []; + let parameterNodes = []; + findParameterNodes(node); + for (const paramNode of parameterNodes) { + let paramName = ""; + for (let i2 = 0; i2 < paramNode.childCount; i2++) { + const child = paramNode.child(i2); + if (child && child.type === "simple_identifier") { + paramName = sourceCode.substring(child.startIndex, child.endIndex); + break; + } + } + if (paramName) { + parameters.push({ + name: paramName, + type: "Any" + // 暂时使用占位符类型 + }); + } + } + const bodyCap = captures.find( + (c) => c.name === "body.definition.method" && c.node.startIndex >= node.startIndex && c.node.endIndex <= node.endIndex + ); + let rangeText; + let implementText = void 0; + if (bodyCap) { + rangeText = sourceCode.substring(node.startIndex, bodyCap.node.startIndex).trimEnd(); + implementText = sourceCode.substring(node.startIndex, node.endIndex); + } else { + rangeText = sourceCode.substring(node.startIndex, node.endIndex); + } + const snippetHash = generateSnippetHash(filePath, startLine, endLine, rangeText); + if (seenHashes.has(snippetHash)) continue; + seenHashes.add(snippetHash); + let returnType = ""; + const paramStr = parameters.map((p) => p.name).join(", "); + const signature = `${name2}(${paramStr})`; + const scope = buildScopeChain(node); + let field = void 0; + let closestContainer = void 0; + for (const container of containerCaptures) { + if (node.startIndex > container.start && node.endIndex <= container.end) { + if (!closestContainer || container.end - container.start < closestContainer.end - closestContainer.start) { + closestContainer = container; + } + } + } + if (closestContainer) { + field = closestContainer.actualName || (closestContainer.nameCap ? sourceCode.substring( + closestContainer.nameCap.node.startIndex, + closestContainer.nameCap.node.endIndex + ) : void 0); + } + snippets.push({ + name: name2, + type: "function_or_method" /* FunctionOrMethod */, + filePath, + startLine, + endLine, + rangeText, + definitionText: rangeText, + scope, + fileHash, + field, + definition: { + name: name2, + type: node.type, + parameters, + returnType + }, + parameters, + signature, + language: "swift" /* Swift */, + ...implementText ? { implementText } : {} + }); + } + for (const capture of captures) { + if (capture.name !== "definition.property" && capture.name !== "definition.computed_property") continue; + const node = capture.node; + const startLine = node.startPosition.row + 1; + const endLine = node.endPosition.row + 1; + const nodeHash = `${node.startIndex}-${node.endIndex}`; + const isAlreadyProcessed = snippets.some( + (s) => s.rangeText === sourceCode.substring(node.startIndex, node.endIndex) && s.startLine === startLine + ); + if (isAlreadyProcessed) continue; + let nameCap; + let isComputedProperty = false; + nameCap = captures.find( + (c) => c.name === "name.definition.computed_property" && c.node.startIndex >= node.startIndex && c.node.endIndex <= node.endIndex + ); + if (nameCap) { + isComputedProperty = true; + } else { + nameCap = captures.find( + (c) => c.name === "name.definition.property" && c.node.startIndex >= node.startIndex && c.node.endIndex <= node.endIndex + ); + } + if (!nameCap) continue; + const name2 = sourceCode.substring(nameCap.node.startIndex, nameCap.node.endIndex); + const isInContainer = containerCaptures.some( + (container) => node.startIndex > container.start && node.endIndex <= container.end + ); + if (!isInContainer) continue; + const rangeText = sourceCode.substring(node.startIndex, node.endIndex); + const snippetHash = generateSnippetHash(filePath, startLine, endLine, rangeText); + if (seenHashes.has(snippetHash)) continue; + seenHashes.add(snippetHash); + const scope = buildScopeChain(node); + let field = void 0; + let closestContainer = void 0; + for (const container of containerCaptures) { + if (node.startIndex > container.start && node.endIndex <= container.end) { + if (!closestContainer || container.end - container.start < closestContainer.end - closestContainer.start) { + closestContainer = container; + } + } + } + if (closestContainer) { + field = closestContainer.actualName || (closestContainer.nameCap ? sourceCode.substring( + closestContainer.nameCap.node.startIndex, + closestContainer.nameCap.node.endIndex + ) : void 0); + } + snippets.push({ + name: name2, + type: "variable_or_constant" /* VariableOrConstant */, + filePath, + startLine, + endLine, + rangeText, + definitionText: rangeText, + implementText: rangeText, + scope, + fileHash, + field, + definition: { + name: name2, + type: isComputedProperty ? "computed_property" : "property" + }, + language: "swift" /* Swift */ + }); + } + for (const capture of captures) { + if (capture.name !== "definition.global_var") continue; + const node = capture.node; + const startLine = node.startPosition.row + 1; + const endLine = node.endPosition.row + 1; + const nameCap = captures.find( + (c) => c.name === "name.definition.global_var" && c.node.startIndex >= node.startIndex && c.node.endIndex <= node.endIndex + ); + if (!nameCap) continue; + const name2 = sourceCode.substring(nameCap.node.startIndex, nameCap.node.endIndex); + const rangeText = sourceCode.substring(node.startIndex, node.endIndex); + const snippetHash = generateSnippetHash(filePath, startLine, endLine, rangeText); + if (seenHashes.has(snippetHash)) continue; + seenHashes.add(snippetHash); + const scope = buildScopeChain(node); + let varType = "var"; + if (rangeText.trim().startsWith("let")) { + varType = "let"; + } + snippets.push({ + name: name2, + type: "variable_or_constant" /* VariableOrConstant */, + filePath, + startLine, + endLine, + rangeText, + definitionText: rangeText, + implementText: rangeText, + scope, + fileHash, + field: "", + definition: { name: name2, type: varType }, + language: "swift" /* Swift */ + }); + } + const typeDefs = [ + { capture: "name.definition.class", outlineType: "class" }, + { capture: "name.definition.protocol", outlineType: "protocol" }, + { capture: "name.definition.type_alias", outlineType: "typealias" } + ]; + for (const { capture, outlineType } of typeDefs) { + const defCaptureName = `definition.${outlineType === "typealias" ? "type_alias" : outlineType}`; + for (const cap of captures.filter((c) => c.name === capture)) { + const node = cap.node; + const isInFunc = captures.some( + (fc) => (fc.name === "definition.method" || fc.name === "definition.initializer" || fc.name === "definition.deinitializer") && fc.node.startIndex < node.startIndex && node.endIndex < fc.node.endIndex + ); + if (isInFunc) continue; + let defCap = captures.filter( + (c) => c.name === defCaptureName && c.node.startIndex <= node.startIndex && node.endIndex <= c.node.endIndex + ).sort((a, b) => a.node.endIndex - a.node.startIndex - (b.node.endIndex - b.node.startIndex))[0]; + const rangeText = defCap ? sourceCode.substring(defCap.node.startIndex, defCap.node.endIndex) : sourceCode.substring(node.startIndex, node.endIndex); + let actualType = outlineType; + if (outlineType === "class" && defCap) { + actualType = determineClassDeclarationType(defCap.node, sourceCode); + } + const startLine = node.startPosition.row + 1; + const endLine = node.endPosition.row + 1; + const snippetHash = generateSnippetHash(filePath, startLine, endLine, rangeText); + if (seenHashes.has(snippetHash)) continue; + seenHashes.add(snippetHash); + const name2 = sourceCode.substring(node.startIndex, node.endIndex); + snippets.push({ + name: name2, + type: "class_or_interface_or_struct" /* ClassOrInterfaceOrStructOrEnum */, + filePath, + startLine, + endLine, + rangeText, + definitionText: rangeText, + implementText: rangeText, + scope: [], + fileHash, + field: "", + definition: { name: name2, type: actualType }, + language: "swift" /* Swift */ + }); + } + } + return snippets.filter((snippet) => snippetTypes.includes(snippet.type)).sort((a, b) => a.startLine - b.startLine); +} +function normalizeTextForSummary(text) { + return text.split("\n").join(" "); +} +function determineClassDeclarationType(node, sourceCode) { + if (node.childCount > 0) { + const firstChild = node.child(0); + if (firstChild) { + const firstChildType = firstChild.type; + if (firstChildType === "struct") return "struct"; + if (firstChildType === "enum") return "enum"; + if (firstChildType === "class") return "class"; + if (firstChildType === "extension") return "extension"; + } + } + return "class"; +} +function buildSummaryFromSnippets7(snippets) { + const outline = []; + const isGlobal = (s) => !s.scope || s.scope.length === 0 || s.scope.every((x) => !x); + for (const s of snippets) { + if (!isGlobal(s)) continue; + if (s.type === "import_or_include" /* ImportOrInclude */) { + outline.push({ + type: "import", + name: s.name, + file: s.filePath, + field: "", + description: s.definitionText + }); + } else if (s.type === "function_or_method" /* FunctionOrMethod */) { + if (s.field) { + outline.push({ + type: "method", + name: s.name, + file: s.filePath, + field: s.field, + description: s.definitionText + }); + } else { + outline.push({ + type: "function", + name: s.name, + file: s.filePath, + field: "", + description: s.definitionText + }); + } + } else if (s.type === "variable_or_constant" /* VariableOrConstant */) { + const t = s.definition?.type || "var"; + outline.push({ + type: t, + name: s.name, + file: s.filePath, + field: s.field || "", + description: s.definitionText + }); + } else if (s.type === "class_or_interface_or_struct" /* ClassOrInterfaceOrStructOrEnum */) { + const t = s.definition?.type || "type"; + outline.push({ + type: t, + name: s.name, + file: s.filePath, + field: "", + description: s.name + }); + } + } + return outline; +} +function formatOutlineText7(outline) { + const groups = {}; + for (const entry of outline) { + const key = entry.field ?? ""; + if (!groups[key]) groups[key] = []; + groups[key].push(entry); + } + let result = ""; + for (const field of Object.keys(groups).sort()) { + const group = groups[field]; + const title = field === "" ? "[global]" : `[${field}]`; + result += title + "\n"; + for (const entry of group) { + let line = ` ${entry.type}`; + if (entry.description) line += `: ${normalizeTextForSummary(entry.description)}`; + result += line + "\n"; + } + result += "\n"; + } + return result.trimEnd(); +} + +// ../autocompletion/v2/capturesProcess/css.ts +function extractSelectorName(selectorsNode, sourceCode) { + function findSelectorName(node) { + if (node.type === "class_selector") { + const classNameNode = findChildByType(node, "class_name"); + if (classNameNode) { + return getNodeText(classNameNode, sourceCode); + } + } + if (node.type === "id_selector") { + const idNameNode = findChildByType(node, "id_name"); + if (idNameNode) { + return getNodeText(idNameNode, sourceCode); + } + } + if (node.type === "tag_name") { + return getNodeText(node, sourceCode); + } + if (node.type === "pseudo_class_selector" || node.type === "pseudo_element_selector") { + const nameNode = findChildByType(node, "class_name") || findChildByType(node, "tag_name"); + if (nameNode) { + return getNodeText(nameNode, sourceCode); + } + } + for (let i2 = 0; i2 < node.childCount; i2++) { + const child = node.child(i2); + if (child) { + const name3 = findSelectorName(child); + if (name3) return name3; + } + } + return null; + } + const name2 = findSelectorName(selectorsNode); + if (name2) return name2; + const selectorText = getNodeText(selectorsNode, sourceCode).trim(); + let firstSelector = selectorText; + const separators = [" ", ",", ">", "+", "~"]; + for (const sep of separators) { + const index2 = firstSelector.indexOf(sep); + if (index2 >= 0) { + firstSelector = firstSelector.substring(0, index2); + } + } + if (firstSelector.startsWith(".")) return firstSelector.substring(1); + if (firstSelector.startsWith("#")) return firstSelector.substring(1); + return firstSelector || "selector"; +} +function isCSSVariable(propertyName) { + return propertyName.startsWith("--"); +} +function getNodeText(node, sourceCode) { + return sourceCode.substring(node.startIndex, node.endIndex); +} +function findChildByType(node, type) { + for (let i2 = 0; i2 < node.childCount; i2++) { + const child = node.child(i2); + if (child && child.type === type) { + return child; + } + } + return null; +} +async function extractSnippetsFromCapturesForCSS(captures, sourceCode, filePath, fileHash, snippetTypes, options) { + const logger = Logger.getDefaultLogger().with("[extractSnippetsFromCapturesForCSS]"); + const snippets = []; + const seenHashes = /* @__PURE__ */ new Set(); + if (snippetTypes.length === 0) { + logger.warn(`No snippet types provided, skipping`); + return snippets; + } + for (const capture of captures) { + const node = capture.node; + const startLine = node.startPosition.row + 1; + const endLine = node.endPosition.row + 1; + const rangeText = getNodeText(node, sourceCode); + const snippetHash = generateSnippetHash(filePath, startLine, endLine, rangeText); + if (seenHashes.has(snippetHash)) continue; + seenHashes.add(snippetHash); + if (capture.name === "definition.rule" && snippetTypes.includes("class_or_interface_or_struct" /* ClassOrInterfaceOrStructOrEnum */)) { + const selectorsCapture = captures.find( + (c) => c.name === "selectors.definition.rule" && c.node.startIndex >= node.startIndex && c.node.endIndex <= node.endIndex + ); + if (selectorsCapture) { + let findSelectorType = function(node2) { + if (node2.type === "class_selector") return "class_selector"; + if (node2.type === "id_selector") return "id_selector"; + if (node2.type === "tag_name") return "tag_selector"; + if (node2.type === "pseudo_class_selector" || node2.type === "pseudo_element_selector") + return "pseudo_selector"; + for (let i2 = 0; i2 < node2.childCount; i2++) { + const child = node2.child(i2); + if (child) { + const type = findSelectorType(child); + if (type !== "selector") return type; + } + } + return "selector"; + }; + const selectorText = getNodeText(selectorsCapture.node, sourceCode); + const selectorName = extractSelectorName(selectorsCapture.node, sourceCode); + let definitionType = "selector"; + definitionType = findSelectorType(selectorsCapture.node); + snippets.push({ + name: selectorName, + type: "class_or_interface_or_struct" /* ClassOrInterfaceOrStructOrEnum */, + filePath, + startLine, + endLine, + rangeText, + fileHash, + language: "css" /* CSS */, + definition: { + name: selectorName, + type: definitionType + }, + definitionText: rangeText, + signature: selectorName, + scope: buildScopeChain(node) + }); + } + } else if (capture.name === "definition.import" && snippetTypes.includes("import_or_include" /* ImportOrInclude */)) { + const nameCapture = captures.find( + (c) => c.name === "name.definition.import" && c.node.startIndex >= node.startIndex && c.node.endIndex <= node.endIndex + ); + let importName = "import"; + if (nameCapture) { + let rawName = getNodeText(nameCapture.node, sourceCode); + if (rawName.startsWith('"') && rawName.endsWith('"')) { + rawName = rawName.slice(1, -1); + } else if (rawName.startsWith("'") && rawName.endsWith("'")) { + rawName = rawName.slice(1, -1); + } + importName = rawName; + } + snippets.push({ + name: importName, + type: "import_or_include" /* ImportOrInclude */, + filePath, + startLine, + endLine, + rangeText, + fileHash, + language: "css" /* CSS */, + definitionText: rangeText, + signature: `@import "${importName}"`, + scope: buildScopeChain(node) + }); + } else if (capture.name === "definition.keyframes" && snippetTypes.includes("class_or_interface_or_struct" /* ClassOrInterfaceOrStructOrEnum */)) { + const nameCapture = captures.find( + (c) => c.name === "name.definition.keyframes" && c.node.startIndex >= node.startIndex && c.node.endIndex <= node.endIndex + ); + let keyframesName = "animation"; + if (nameCapture) { + keyframesName = getNodeText(nameCapture.node, sourceCode); + } + snippets.push({ + name: keyframesName, + type: "class_or_interface_or_struct" /* ClassOrInterfaceOrStructOrEnum */, + filePath, + startLine, + endLine, + rangeText, + fileHash, + language: "css" /* CSS */, + definition: { + name: keyframesName, + type: "keyframes" + }, + definitionText: rangeText, + signature: keyframesName, + scope: buildScopeChain(node) + }); + } else if (capture.name === "definition.media" && snippetTypes.includes("class_or_interface_or_struct" /* ClassOrInterfaceOrStructOrEnum */)) { + const queryCapture = captures.find( + (c) => c.name === "query.definition.media" && c.node.startIndex >= node.startIndex && c.node.endIndex <= node.endIndex + ); + let mediaName = "media"; + if (queryCapture) { + mediaName = getNodeText(queryCapture.node, sourceCode).trim(); + } + snippets.push({ + name: mediaName, + type: "class_or_interface_or_struct" /* ClassOrInterfaceOrStructOrEnum */, + filePath, + startLine, + endLine, + rangeText, + fileHash, + language: "css" /* CSS */, + definition: { + name: mediaName, + type: "media" + }, + definitionText: rangeText, + signature: `@media ${mediaName}`, + scope: buildScopeChain(node) + }); + } else if (capture.name === "definition.function" && snippetTypes.includes("function_or_method" /* FunctionOrMethod */)) { + const nameCapture = captures.find( + (c) => c.name === "name.definition.function" && c.node.startIndex >= node.startIndex && c.node.endIndex <= node.endIndex + ); + if (nameCapture) { + const functionName = getNodeText(nameCapture.node, sourceCode); + const argsCapture = captures.find( + (c) => c.name === "args.definition.function" && c.node.startIndex >= node.startIndex && c.node.endIndex <= node.endIndex + ); + const parameters = []; + if (argsCapture) { + const argsText = getNodeText(argsCapture.node, sourceCode); + const args2 = argsText.split(",").map((arg) => arg.trim()).filter((arg) => arg.length > 0); + parameters.push(...args2.map((arg) => ({ name: arg }))); + } + const signature = parameters.length > 0 ? `${functionName}(${parameters.map((p) => p.name).join(", ")})` : `${functionName}()`; + snippets.push({ + name: functionName, + type: "function_or_method" /* FunctionOrMethod */, + filePath, + startLine, + endLine, + rangeText, + fileHash, + language: "css" /* CSS */, + parameters, + definition: { + name: functionName, + type: "function", + parameters + }, + definitionText: rangeText, + signature, + scope: buildScopeChain(node) + }); + } + } else if (capture.name === "definition.declaration" && snippetTypes.includes("variable_or_constant" /* VariableOrConstant */)) { + const propertyCapture = captures.find( + (c) => c.name === "property.definition.declaration" && c.node.startIndex >= node.startIndex && c.node.endIndex <= node.endIndex + ); + if (propertyCapture) { + const propertyName = getNodeText(propertyCapture.node, sourceCode); + if (isCSSVariable(propertyName)) { + const valueCapture = captures.find( + (c) => c.name === "value.definition.declaration" && c.node.startIndex >= node.startIndex && c.node.endIndex <= node.endIndex + ); + let propertyValue = ""; + if (valueCapture) { + propertyValue = getNodeText(valueCapture.node, sourceCode); + } + snippets.push({ + name: propertyName, + type: "variable_or_constant" /* VariableOrConstant */, + filePath, + startLine, + endLine, + rangeText, + fileHash, + language: "css" /* CSS */, + definition: { + name: propertyName, + type: "css_variable" + }, + definitionText: `${propertyName}: ${propertyValue};`, + signature: `${propertyName}: ${propertyValue}`, + scope: buildScopeChain(node) + }); + } + } + } + } + logger.info(`Extracted ${snippets.length} CSS snippets`); + return snippets; +} +function buildSummaryFromSnippets8(snippets) { + const selectors = []; + const variables = []; + const functions = []; + const atRules = []; + const imports = []; + for (const snippet of snippets) { + switch (snippet.type) { + case "import_or_include" /* ImportOrInclude */: + imports.push(snippet); + break; + case "function_or_method" /* FunctionOrMethod */: + functions.push(snippet); + break; + case "variable_or_constant" /* VariableOrConstant */: + variables.push(snippet); + break; + case "class_or_interface_or_struct" /* ClassOrInterfaceOrStructOrEnum */: + if (snippet.definition?.type?.includes("selector")) { + selectors.push(snippet); + } else { + atRules.push(snippet); + } + break; + } + } + return { selectors, variables, functions, atRules, imports }; +} +function formatOutlineText8(summary) { + let outline = "CSS File Overview:\n\n"; + if (summary.imports.length > 0) { + outline += "Imports:\n"; + for (const imp of summary.imports) { + outline += ` - ${imp.signature} +`; + } + outline += "\n"; + } + if (summary.variables.length > 0) { + outline += "CSS Variables & Properties:\n"; + for (const variable of summary.variables) { + outline += ` - ${variable.signature} +`; + } + outline += "\n"; + } + if (summary.selectors.length > 0) { + outline += "Selectors:\n"; + for (const selector of summary.selectors) { + const type = selector.definition?.type || "selector"; + outline += ` - ${selector.name} (${type}) +`; + } + outline += "\n"; + } + if (summary.functions.length > 0) { + outline += "CSS Functions:\n"; + for (const func2 of summary.functions) { + outline += ` - ${func2.signature} +`; + } + outline += "\n"; + } + if (summary.atRules.length > 0) { + outline += "At-Rules:\n"; + for (const rule of summary.atRules) { + outline += ` - @${rule.definition?.type}: ${rule.name} +`; + } + outline += "\n"; + } + return outline.trim(); +} + +// ../autocompletion/v2/capturesProcess/html.ts +function escapeNewlinesForLogging(text) { + return text.split("\n").join("\\n"); +} +function formatTypeLabel(type) { + return type.split("_").map((word) => word.charAt(0).toUpperCase() + word.slice(1).toLowerCase()).join(" "); +} +function getNodeText2(node, sourceCode) { + return sourceCode.substring(node.startIndex, node.endIndex); +} +function findChildByType2(node, type) { + for (let i2 = 0; i2 < node.childCount; i2++) { + const child = node.child(i2); + if (child && child.type === type) { + return child; + } + } + return null; +} +function findChildByTypeRecursive(node, type) { + if (node.type === type) { + return node; + } + for (let i2 = 0; i2 < node.childCount; i2++) { + const child = node.child(i2); + if (child) { + const found = findChildByTypeRecursive(child, type); + if (found) return found; + } + } + return null; +} +function extractTagName(node, sourceCode) { + const tagNameNode = findChildByTypeRecursive(node, "tag_name"); + if (tagNameNode) { + return getNodeText2(tagNameNode, sourceCode); + } + return "element"; +} +function extractAttributeInfo(node, sourceCode) { + const attributeNameNode = findChildByType2(node, "attribute_name"); + const attributeValueNode = findChildByType2(node, "attribute_value") || findChildByType2(node, "quoted_attribute_value"); + const name2 = attributeNameNode ? getNodeText2(attributeNameNode, sourceCode) : "attribute"; + let value; + if (attributeValueNode) { + let rawValue = getNodeText2(attributeValueNode, sourceCode); + if (rawValue.startsWith('"') && rawValue.endsWith('"') || rawValue.startsWith("'") && rawValue.endsWith("'")) { + rawValue = rawValue.slice(1, -1); + } + value = rawValue; + } + return { name: name2, value }; +} +function isSemanticElement(tagName) { + const semanticTags = /* @__PURE__ */ new Set([ + "header", + "nav", + "main", + "section", + "article", + "aside", + "footer", + "figure", + "figcaption", + "details", + "summary", + "mark", + "time" + ]); + return semanticTags.has(tagName.toLowerCase()); +} +function isInteractiveElement(tagName) { + const interactiveTags = /* @__PURE__ */ new Set(["button", "input", "select", "textarea", "a", "form"]); + return interactiveTags.has(tagName.toLowerCase()); +} +async function extractSnippetsFromCapturesForHTML(captures, sourceCode, filePath, fileHash, snippetTypes, options) { + const logger = Logger.getDefaultLogger().with("[extractSnippetsFromCapturesForHTML]"); + const snippets = []; + const seenHashes = /* @__PURE__ */ new Set(); + if (snippetTypes.length === 0) { + logger.warn(`No snippet types provided, skipping`); + return snippets; + } + for (const capture of captures) { + const node = capture.node; + const startLine = node.startPosition.row + 1; + const endLine = node.endPosition.row + 1; + const rangeText = getNodeText2(node, sourceCode); + const snippetHash = generateSnippetHash(filePath, startLine, endLine, rangeText) + "_" + capture.name; + if (seenHashes.has(snippetHash)) continue; + seenHashes.add(snippetHash); + logger.info(`Processing capture: ${capture.name} -> "${escapeNewlinesForLogging(rangeText)}"`); + if (capture.name === "definition.doctype" && snippetTypes.includes("import_or_include" /* ImportOrInclude */)) { + snippets.push({ + name: "DOCTYPE", + type: "import_or_include" /* ImportOrInclude */, + filePath, + startLine, + endLine, + rangeText, + fileHash, + language: "html" /* HTML */, + definition: { + name: "DOCTYPE", + type: "doctype" + }, + definitionText: rangeText, + signature: "DOCTYPE html", + scope: buildScopeChain(node) + }); + } else if (capture.name === "definition.document" && snippetTypes.includes("class_or_interface_or_struct" /* ClassOrInterfaceOrStructOrEnum */)) { + snippets.push({ + name: "document", + type: "class_or_interface_or_struct" /* ClassOrInterfaceOrStructOrEnum */, + filePath, + startLine, + endLine, + rangeText, + fileHash, + language: "html" /* HTML */, + definition: { + name: "document", + type: "document" + }, + definitionText: rangeText, + signature: "HTML Document", + scope: buildScopeChain(node) + }); + } else if (capture.name === "definition.element" && snippetTypes.includes("class_or_interface_or_struct" /* ClassOrInterfaceOrStructOrEnum */)) { + const nameCapture = captures.find( + (c) => c.name === "name.definition" && c.node.startIndex >= node.startIndex && c.node.endIndex <= node.endIndex + ); + const elementName = nameCapture ? getNodeText2(nameCapture.node, sourceCode) : extractTagName(node, sourceCode); + let elementType = "element"; + if (isSemanticElement(elementName)) { + elementType = "semantic_element"; + } else if (isInteractiveElement(elementName)) { + elementType = "interactive_element"; + } + snippets.push({ + name: elementName, + type: "class_or_interface_or_struct" /* ClassOrInterfaceOrStructOrEnum */, + filePath, + startLine, + endLine, + rangeText, + fileHash, + language: "html" /* HTML */, + definition: { + name: elementName, + type: elementType + }, + definitionText: rangeText, + signature: `<${elementName}>`, + scope: buildScopeChain(node) + }); + } else if (capture.name === "definition.script" && snippetTypes.includes("function_or_method" /* FunctionOrMethod */)) { + const nameCapture = captures.find( + (c) => c.name === "name.definition" && c.node.startIndex >= node.startIndex && c.node.endIndex <= node.endIndex + ); + const scriptName = nameCapture ? getNodeText2(nameCapture.node, sourceCode) : "script"; + snippets.push({ + name: scriptName, + type: "function_or_method" /* FunctionOrMethod */, + filePath, + startLine, + endLine, + rangeText, + fileHash, + language: "html" /* HTML */, + definition: { + name: scriptName, + type: "script" + }, + definitionText: rangeText, + signature: `<${scriptName}>`, + scope: buildScopeChain(node) + }); + } else if (capture.name === "definition.style" && snippetTypes.includes("function_or_method" /* FunctionOrMethod */)) { + const nameCapture = captures.find( + (c) => c.name === "name.definition" && c.node.startIndex >= node.startIndex && c.node.endIndex <= node.endIndex + ); + const styleName = nameCapture ? getNodeText2(nameCapture.node, sourceCode) : "style"; + snippets.push({ + name: styleName, + type: "function_or_method" /* FunctionOrMethod */, + filePath, + startLine, + endLine, + rangeText, + fileHash, + language: "html" /* HTML */, + definition: { + name: styleName, + type: "style" + }, + definitionText: rangeText, + signature: `<${styleName}>`, + scope: buildScopeChain(node) + }); + } else if (capture.name === "definition.void_element" && snippetTypes.includes("class_or_interface_or_struct" /* ClassOrInterfaceOrStructOrEnum */)) { + const nameCapture = captures.find( + (c) => c.name === "name.definition.void" && c.node.startIndex >= node.startIndex && c.node.endIndex <= node.endIndex + ); + const elementName = nameCapture ? getNodeText2(nameCapture.node, sourceCode) : extractTagName(node, sourceCode); + let elementType = "void_element"; + if (isInteractiveElement(elementName)) { + elementType = "interactive_element"; + } else if (isSemanticElement(elementName)) { + elementType = "semantic_element"; + } + snippets.push({ + name: elementName, + type: "class_or_interface_or_struct" /* ClassOrInterfaceOrStructOrEnum */, + filePath, + startLine, + endLine, + rangeText, + fileHash, + language: "html" /* HTML */, + definition: { + name: elementName, + type: elementType + }, + definitionText: rangeText, + signature: elementType === "void_element" ? `<${elementName} />` : `<${elementName}>`, + scope: buildScopeChain(node) + }); + } else if (capture.name === "definition.self_closing_tag" && snippetTypes.includes("class_or_interface_or_struct" /* ClassOrInterfaceOrStructOrEnum */)) { + const nameCapture = captures.find( + (c) => c.name === "name.definition" && c.node.startIndex >= node.startIndex && c.node.endIndex <= node.endIndex + ); + const tagName = nameCapture ? getNodeText2(nameCapture.node, sourceCode) : "self_closing_tag"; + snippets.push({ + name: tagName, + type: "class_or_interface_or_struct" /* ClassOrInterfaceOrStructOrEnum */, + filePath, + startLine, + endLine, + rangeText, + fileHash, + language: "html" /* HTML */, + definition: { + name: tagName, + type: "self_closing_tag" + }, + definitionText: rangeText, + signature: `<${tagName} />`, + scope: buildScopeChain(node) + }); + } else if (capture.name === "definition.attribute" && snippetTypes.includes("variable_or_constant" /* VariableOrConstant */)) { + const nameCapture = captures.find( + (c) => c.name === "name.definition" && c.node.startIndex >= node.startIndex && c.node.endIndex <= node.endIndex + ); + if (nameCapture) { + const attributeInfo = extractAttributeInfo(node, sourceCode); + const attributeName = attributeInfo.name; + let attributeType = "attribute"; + if (attributeName.startsWith("data-")) { + attributeType = "data_attribute"; + } else if (attributeName.startsWith("aria-")) { + attributeType = "aria_attribute"; + } else if (["id", "class"].includes(attributeName)) { + attributeType = "core_attribute"; + } + const signature = attributeInfo.value ? `${attributeName}="${attributeInfo.value}"` : attributeName; + snippets.push({ + name: attributeName, + type: "variable_or_constant" /* VariableOrConstant */, + filePath, + startLine, + endLine, + rangeText, + fileHash, + language: "html" /* HTML */, + definition: { + name: attributeName, + type: attributeType + }, + definitionText: rangeText, + signature, + scope: buildScopeChain(node) + }); + } + } else if (capture.name === "definition.comment" && snippetTypes.includes("import_or_include" /* ImportOrInclude */)) { + let commentText = rangeText.trim(); + if (commentText.startsWith("")) { + commentText = commentText.slice(4, -3).trim(); + } + const firstLine = commentText.split("\n")[0].trim(); + const commentName = firstLine.length > 0 ? firstLine : "comment"; + snippets.push({ + name: commentName, + type: "import_or_include" /* ImportOrInclude */, + filePath, + startLine, + endLine, + rangeText, + fileHash, + language: "html" /* HTML */, + definition: { + name: commentName, + type: "comment" + }, + definitionText: rangeText, + signature: ``, + scope: buildScopeChain(node) + }); + } else if (capture.name === "definition.text" && snippetTypes.includes("variable_or_constant" /* VariableOrConstant */)) { + const lineCount = endLine - startLine + 1; + if (lineCount >= options.minSnippetLines) { + const textContent = rangeText.trim(); + const firstLine = textContent.split("\n")[0].trim(); + const textName = firstLine.length > 0 ? firstLine : "text"; + snippets.push({ + name: textName, + type: "variable_or_constant" /* VariableOrConstant */, + filePath, + startLine, + endLine, + rangeText, + fileHash, + language: "html" /* HTML */, + definition: { + name: textName, + type: "text" + }, + definitionText: rangeText, + signature: textName, + scope: buildScopeChain(node) + }); + } + } else if (capture.name === "definition.raw_text" && snippetTypes.includes("variable_or_constant" /* VariableOrConstant */)) { + const lineCount = endLine - startLine + 1; + if (lineCount >= options.minSnippetLines) { + const textContent = rangeText.trim(); + const firstLine = textContent.split("\n")[0].trim(); + const rawTextName = firstLine.length > 0 ? firstLine : "raw_text"; + snippets.push({ + name: rawTextName, + type: "variable_or_constant" /* VariableOrConstant */, + filePath, + startLine, + endLine, + rangeText, + fileHash, + language: "html" /* HTML */, + definition: { + name: rawTextName, + type: "raw_text" + }, + definitionText: rangeText, + signature: rawTextName, + scope: buildScopeChain(node) + }); + } + } else if (capture.name === "definition.nested_elements" && snippetTypes.includes("class_or_interface_or_struct" /* ClassOrInterfaceOrStructOrEnum */)) { + const tagName = extractTagName(node, sourceCode); + snippets.push({ + name: `${tagName}_container`, + type: "class_or_interface_or_struct" /* ClassOrInterfaceOrStructOrEnum */, + filePath, + startLine, + endLine, + rangeText, + fileHash, + language: "html" /* HTML */, + definition: { + name: `${tagName}_container`, + type: "nested_elements" + }, + definitionText: rangeText, + signature: `<${tagName}> (with children)`, + scope: buildScopeChain(node) + }); + } + } + logger.info(`[CodeContext] Extracted ${snippets.length} HTML snippets`); + return snippets; +} +function buildSummaryFromSnippets9(snippets) { + const summary = { + doctypes: [], + elements: [], + attributes: [], + scripts: [], + styles: [], + comments: [], + textContent: [] + }; + for (const snippet of snippets) { + const defType = snippet.definition?.type || ""; + switch (defType) { + case "doctype": + summary.doctypes.push(snippet); + break; + case "element": + case "semantic_element": + case "interactive_element": + case "void_element": + case "self_closing_tag": + case "nested_elements": + summary.elements.push(snippet); + break; + case "attribute": + case "data_attribute": + case "aria_attribute": + case "core_attribute": + summary.attributes.push(snippet); + break; + case "script": + summary.scripts.push(snippet); + break; + case "style": + summary.styles.push(snippet); + break; + case "comment": + summary.comments.push(snippet); + break; + case "text": + case "raw_text": + summary.textContent.push(snippet); + break; + } + } + return summary; +} +function formatOutlineText9(summary) { + const lines = []; + if (summary.doctypes.length > 0) { + lines.push("## Document Type"); + summary.doctypes.forEach((snippet) => { + lines.push(`- ${snippet.signature || snippet.name}`); + }); + lines.push(""); + } + if (summary.elements.length > 0) { + lines.push("## HTML Elements"); + summary.elements.forEach((snippet) => { + const typeSuffix = snippet.definition?.type === "semantic_element" ? " (semantic)" : snippet.definition?.type === "interactive_element" ? " (interactive)" : ""; + lines.push(`- ${snippet.signature || snippet.name}${typeSuffix}`); + }); + lines.push(""); + } + if (summary.scripts.length > 0 || summary.styles.length > 0) { + lines.push("## Scripts & Styles"); + summary.scripts.forEach((snippet) => { + lines.push(`- ${snippet.signature || snippet.name} (script)`); + }); + summary.styles.forEach((snippet) => { + lines.push(`- ${snippet.signature || snippet.name} (style)`); + }); + lines.push(""); + } + if (summary.attributes.length > 0) { + lines.push("## Attributes"); + const attributesByType = {}; + summary.attributes.forEach((snippet) => { + const type = snippet.definition?.type || "attribute"; + if (!attributesByType[type]) attributesByType[type] = []; + attributesByType[type].push(snippet); + }); + Object.keys(attributesByType).sort().forEach((type) => { + const typeLabel = formatTypeLabel(type); + lines.push(`### ${typeLabel}`); + attributesByType[type].forEach((snippet) => { + lines.push(`- ${snippet.signature || snippet.name}`); + }); + }); + lines.push(""); + } + if (summary.comments.length > 0) { + lines.push("## Comments"); + summary.comments.forEach((snippet) => { + lines.push(`- ${snippet.name}`); + }); + lines.push(""); + } + if (summary.textContent.length > 0) { + lines.push("## Text Content"); + summary.textContent.forEach((snippet) => { + const preview = snippet.name.length > 50 ? snippet.name.substring(0, 47) + "..." : snippet.name; + lines.push(`- ${preview}`); + }); + lines.push(""); + } + return lines.join("\n").trim(); +} + +// ../autocompletion/v2/capturesProcess/kotlin.ts +var crypto2 = __toESM(require("crypto")); +function extractModifiers(node, sourceCode) { + const modifiers = []; + const modifierNode = node.children.find((child) => child.type === "modifiers"); + if (modifierNode) { + modifierNode.children.forEach((child) => { + if (child.type === "visibility_modifier" || child.type === "modifier") { + const modifier = sourceCode.substring(child.startIndex, child.endIndex); + modifiers.push(modifier); + } + }); + } + return modifiers; +} +function extractImportPath(importNode, sourceCode) { + const fullImportText = sourceCode.substring(importNode.startIndex, importNode.endIndex); + const importKeywordIndex = fullImportText.indexOf("import"); + if (importKeywordIndex === -1) return fullImportText.trim(); + const importKeywordEnd = importKeywordIndex + 6; + let pathPart = fullImportText.substring(importKeywordEnd).trim(); + pathPart = pathPart.split("\n")[0].split("\r")[0].split(";")[0].trim(); + return pathPart; +} +function getDefinitionType(node, sourceCode) { + if (node.type === "object_declaration") return "object"; + if (node.type === "type_alias") return "typealias"; + if (node.type === "class_declaration") { + const modifierNode = node.children.find((child) => child.type === "modifiers"); + if (modifierNode) { + const modifierTexts = modifierNode.children.map( + (child) => sourceCode.substring(child.startIndex, child.endIndex) + ); + if (modifierTexts.includes("sealed")) return "sealed class"; + if (modifierTexts.includes("data")) return "data class"; + if (modifierTexts.includes("enum")) return "enum"; + if (modifierTexts.includes("annotation")) return "annotation class"; + } + const hasEnumBody = node.children.some((child) => child.type === "enum_class_body"); + if (hasEnumBody) return "enum"; + const hasInterfaceKeyword = node.children.some((child) => { + if (child.type === "interface") return true; + const childText = sourceCode.substring(child.startIndex, child.endIndex); + return childText === "interface"; + }); + if (hasInterfaceKeyword) return "interface"; + return "class"; + } + return "class"; +} +function findParentClassName(captures, node, sourceCode) { + const classCapture = captures.find( + (c) => c.name === "definition.class" && c.node.startIndex <= node.startIndex && c.node.endIndex >= node.endIndex + ); + if (classCapture) { + const nameNode = classCapture.node.children.find((child) => child.type === "type_identifier"); + return nameNode ? sourceCode.substring(nameNode.startIndex, nameNode.endIndex) : void 0; + } + return void 0; +} +function parseParameterInfo(paramNode, sourceCode) { + const nameNode = paramNode.children.find((child) => child.type === "simple_identifier"); + const name2 = nameNode ? sourceCode.substring(nameNode.startIndex, nameNode.endIndex) : ""; + const typeNode = paramNode.children.find((child) => child.type === "user_type" || child.type === "type_identifier"); + const type = typeNode ? sourceCode.substring(typeNode.startIndex, typeNode.endIndex) : void 0; + const defaultValueNode = paramNode.children.find((child) => child.type === "default_value"); + const defaultValue = defaultValueNode ? sourceCode.substring(defaultValueNode.startIndex, defaultValueNode.endIndex) : void 0; + return { + name: name2.trim(), + type: type?.trim(), + defaultValue: defaultValue?.trim(), + isOptional: !!defaultValue + }; +} +function extractParameters(node, sourceCode) { + const parameters = []; + const parameterList = node.children.find((child) => child.type === "function_value_parameters"); + if (parameterList) { + const paramNodes = parameterList.children.filter((child) => child.type === "parameter"); + paramNodes.forEach((paramNode) => { + const paramInfo = parseParameterInfo(paramNode, sourceCode); + if (paramInfo.name) { + parameters.push(paramInfo); + } + }); + } + return parameters; +} +function extractReturnType(node, sourceCode) { + const returnTypeNode = node.children.find((child) => child.type === "user_type" || child.type === "type_identifier"); + if (returnTypeNode) { + return sourceCode.substring(returnTypeNode.startIndex, returnTypeNode.endIndex); + } + return "Unit"; +} +async function extractSnippetsFromCapturesForKotlin(captures, sourceCode, filePath, fileHash, snippetTypes, options) { + const logger = Logger.getDefaultLogger().with("[extractSnippetsFromCapturesForKotlin]"); + const snippets = []; + const seenHashes = /* @__PURE__ */ new Set(); + if (snippetTypes.length === 0) { + logger.warn(`No snippet types provided, skipping`); + return snippets; + } + if (snippetTypes.includes("import_or_include" /* ImportOrInclude */)) { + captures.forEach((capture) => { + if (capture.name === "definition.import") { + const node = capture.node; + const startLine = node.startPosition.row + 1; + const endLine = node.endPosition.row + 1; + const importPath = extractImportPath(node, sourceCode); + const name2 = importPath; + const scope = ["global"]; + const rangeText = sourceCode.substring(node.startIndex, node.endIndex).trim(); + const hash = crypto2.createHash("md5").update(`${name2}-${filePath}-${startLine}`).digest("hex"); + if (seenHashes.has(hash)) { + return; + } + seenHashes.add(hash); + snippets.push({ + name: name2, + type: "import_or_include" /* ImportOrInclude */, + filePath, + startLine, + endLine, + rangeText, + definitionText: rangeText, + scope, + fileHash, + language: "kotlin" /* Kotlin */, + definition: { + name: name2, + type: "import" + } + }); + } + }); + } + if (snippetTypes.includes("class_or_interface_or_struct" /* ClassOrInterfaceOrStructOrEnum */)) { + captures.forEach((capture) => { + if (capture.name === "definition.class" || capture.name === "definition.object") { + const node = capture.node; + const startLine = node.startPosition.row + 1; + const endLine = node.endPosition.row + 1; + const nameNode = node.children.find((child) => child.type === "type_identifier"); + const name2 = nameNode ? sourceCode.substring(nameNode.startIndex, nameNode.endIndex) : ""; + if (!name2) return; + const scope = ["global"]; + const rangeText = sourceCode.substring(node.startIndex, node.endIndex); + const hash = crypto2.createHash("md5").update(`${name2}-${filePath}-${startLine}`).digest("hex"); + if (seenHashes.has(hash)) { + return; + } + seenHashes.add(hash); + const modifiers = extractModifiers(node, sourceCode); + const definitionType = getDefinitionType(node, sourceCode); + snippets.push({ + name: name2, + type: "class_or_interface_or_struct" /* ClassOrInterfaceOrStructOrEnum */, + filePath, + startLine, + endLine, + rangeText, + definitionText: rangeText, + scope, + fileHash, + language: "kotlin" /* Kotlin */, + definition: { + name: name2, + type: definitionType, + visibility: modifiers.includes("private") ? "private" : modifiers.includes("protected") ? "protected" : modifiers.includes("internal") ? "internal" : "public" + } + }); + } + }); + } + if (snippetTypes.includes("function_or_method" /* FunctionOrMethod */)) { + captures.forEach((capture) => { + if (capture.name === "definition.function") { + const node = capture.node; + const startLine = node.startPosition.row + 1; + const endLine = node.endPosition.row + 1; + const nameNode = node.children.find((child) => child.type === "simple_identifier"); + const name2 = nameNode ? sourceCode.substring(nameNode.startIndex, nameNode.endIndex) : ""; + if (!name2) return; + const scope = ["global"]; + const rangeText = sourceCode.substring(node.startIndex, node.endIndex); + const hash = crypto2.createHash("md5").update(`${name2}-${filePath}-${startLine}`).digest("hex"); + if (seenHashes.has(hash)) { + return; + } + seenHashes.add(hash); + const parameters = extractParameters(node, sourceCode); + const returnType = extractReturnType(node, sourceCode); + const modifiers = extractModifiers(node, sourceCode); + const className = findParentClassName(captures, node, sourceCode); + snippets.push({ + name: name2, + type: "function_or_method" /* FunctionOrMethod */, + filePath, + startLine, + endLine, + rangeText, + definitionText: rangeText, + scope, + fileHash, + language: "kotlin" /* Kotlin */, + parameters, + ...className && { field: className }, + definition: { + name: name2, + type: "function", + parameters, + returnType, + visibility: modifiers.includes("private") ? "private" : modifiers.includes("protected") ? "protected" : modifiers.includes("internal") ? "internal" : "public", + ...className && { className } + } + }); + } + }); + } + if (snippetTypes.includes("variable_or_constant" /* VariableOrConstant */)) { + captures.forEach((capture) => { + if (capture.name === "definition.property") { + const node = capture.node; + const startLine = node.startPosition.row + 1; + const endLine = node.endPosition.row + 1; + let nameNode = node.children.find((child) => child.type === "simple_identifier"); + if (!nameNode) { + const variableDecl = node.children.find((child) => child.type === "variable_declaration"); + if (variableDecl) { + nameNode = variableDecl.children.find((child) => child.type === "simple_identifier"); + } + } + const name2 = nameNode ? sourceCode.substring(nameNode.startIndex, nameNode.endIndex) : ""; + if (!name2) return; + const scope = ["global"]; + const rangeText = sourceCode.substring(node.startIndex, node.endIndex); + const hash = crypto2.createHash("md5").update(`${name2}-${filePath}-${startLine}`).digest("hex"); + if (seenHashes.has(hash)) { + return; + } + seenHashes.add(hash); + const modifiers = extractModifiers(node, sourceCode); + const className = findParentClassName(captures, node, sourceCode); + snippets.push({ + name: name2, + type: "variable_or_constant" /* VariableOrConstant */, + filePath, + startLine, + endLine, + rangeText, + definitionText: rangeText, + scope, + fileHash, + language: "kotlin" /* Kotlin */, + ...className && { field: className }, + definition: { + name: name2, + type: "property", + visibility: modifiers.includes("private") ? "private" : modifiers.includes("protected") ? "protected" : modifiers.includes("internal") ? "internal" : "public", + ...className && { className } + } + }); + } + }); + } + if (snippetTypes.includes("class_or_interface_or_struct" /* ClassOrInterfaceOrStructOrEnum */)) { + captures.forEach((capture) => { + if (capture.name === "definition.type_alias") { + const node = capture.node; + const startLine = node.startPosition.row + 1; + const endLine = node.endPosition.row + 1; + const nameNode = node.children.find((child) => child.type === "type_identifier"); + const name2 = nameNode ? sourceCode.substring(nameNode.startIndex, nameNode.endIndex) : ""; + if (!name2) return; + const scope = ["global"]; + const rangeText = sourceCode.substring(node.startIndex, node.endIndex); + const hash = crypto2.createHash("md5").update(`${name2}-${filePath}-${startLine}`).digest("hex"); + if (seenHashes.has(hash)) { + return; + } + seenHashes.add(hash); + snippets.push({ + name: name2, + type: "class_or_interface_or_struct" /* ClassOrInterfaceOrStructOrEnum */, + filePath, + startLine, + endLine, + rangeText, + definitionText: rangeText, + scope, + fileHash, + language: "kotlin" /* Kotlin */, + definition: { + name: name2, + type: "type_alias" + } + }); + } + }); + } + return snippets; +} +function buildSummaryFromSnippets10(snippets) { + const summary = { + imports: snippets.filter((s) => s.type === "import_or_include" /* ImportOrInclude */), + classes: snippets.filter((s) => s.type === "class_or_interface_or_struct" /* ClassOrInterfaceOrStructOrEnum */), + functions: snippets.filter((s) => s.type === "function_or_method" /* FunctionOrMethod */), + variables: snippets.filter((s) => s.type === "variable_or_constant" /* VariableOrConstant */) + }; + return summary; +} +function formatOutlineText10(summary) { + const lines = []; + if (summary.imports?.length > 0) { + lines.push("# Imports"); + summary.imports.forEach((item) => { + lines.push(` import: ${item.name}`); + }); + lines.push(""); + } + if (summary.classes?.length > 0) { + lines.push("# Classes/Interfaces/Objects"); + summary.classes.forEach((item) => { + const type = item.definition?.type || "class"; + lines.push(` ${type}: ${item.name}`); + }); + lines.push(""); + } + if (summary.functions?.length > 0) { + lines.push("# Functions/Methods"); + summary.functions.forEach((item) => { + const params = item.definition?.parameters?.map((p) => `${p.name}: ${p.type || "Any"}`).join(", ") || ""; + const returnType = item.definition?.returnType || "Unit"; + const className = item.field; + const prefix = className ? `[${className}] ` : ""; + lines.push(` ${prefix}${item.name}(${params}): ${returnType}`); + }); + lines.push(""); + } + if (summary.variables?.length > 0) { + lines.push("# Variables/Properties"); + summary.variables.forEach((item) => { + const className = item.field; + const prefix = className ? `[${className}] ` : ""; + lines.push(` ${prefix}property: ${item.name}`); + }); + lines.push(""); + } + return lines.join("\n"); +} + +// ../autocompletion/v2/capturesProcess/php.ts +async function extractSnippetsFromCapturesForPHP(captures, sourceCode, filePath, fileHash, snippetTypes, options) { + const logger = Logger.getDefaultLogger().with("[extractSnippetsFromCapturesForPHP]"); + const snippets = []; + const seenHashes = /* @__PURE__ */ new Set(); + if (snippetTypes.length === 0) { + logger.warn(`No snippet types provided, skipping`); + return snippets; + } + const classCaptures = captures.filter( + (c) => c.name === "definition.class" || c.name === "definition.abstract_class" || c.name === "definition.final_class" || c.name === "definition.readonly_class" + ).map((c) => ({ + node: c.node, + start: c.node.startIndex, + end: c.node.endIndex, + nameCap: captures.find( + (nc) => (nc.name === "name.definition.class" || nc.name === "name.definition.abstract_class" || nc.name === "name.definition.final_class" || nc.name === "name.definition.readonly_class") && nc.node.startIndex >= c.node.startIndex && nc.node.endIndex <= c.node.endIndex + ) + })); + const interfaceCaptures = captures.filter((c) => c.name === "definition.interface").map((c) => ({ + node: c.node, + start: c.node.startIndex, + end: c.node.endIndex, + nameCap: captures.find( + (nc) => nc.name === "name.definition.interface" && nc.node.startIndex >= c.node.startIndex && nc.node.endIndex <= c.node.endIndex + ) + })); + const traitCaptures = captures.filter((c) => c.name === "definition.trait").map((c) => ({ + node: c.node, + start: c.node.startIndex, + end: c.node.endIndex, + nameCap: captures.find( + (nc) => nc.name === "name.definition.trait" && nc.node.startIndex >= c.node.startIndex && nc.node.endIndex <= c.node.endIndex + ) + })); + const enumCaptures = captures.filter((c) => c.name === "definition.enum").map((c) => ({ + node: c.node, + start: c.node.startIndex, + end: c.node.endIndex, + nameCap: captures.find( + (nc) => nc.name === "name.definition.enum" && nc.node.startIndex >= c.node.startIndex && nc.node.endIndex <= c.node.endIndex + ) + })); + const namespaceCaptures = captures.filter((c) => c.name === "definition.namespace").map((c) => ({ + node: c.node, + start: c.node.startIndex, + end: c.node.endIndex, + nameCap: captures.find( + (nc) => nc.name === "name.definition.namespace" && nc.node.startIndex >= c.node.startIndex && nc.node.endIndex <= c.node.endIndex + ) + })); + function findNamespaceForNode(node) { + let closestNamespace = void 0; + let closestDistance = Infinity; + for (const ns of namespaceCaptures) { + if (ns.start < node.startIndex && ns.nameCap) { + const distance = node.startIndex - ns.start; + if (distance < closestDistance) { + closestDistance = distance; + closestNamespace = sourceCode.substring(ns.nameCap.node.startIndex, ns.nameCap.node.endIndex); + } + } + } + return closestNamespace; + } + captures.forEach((capture) => { + if (capture.name === "name.definition.use") { + const node = capture.node; + const startLine = node.startPosition.row + 1; + const endLine = node.endPosition.row + 1; + const rangeText = sourceCode.substring(node.startIndex, node.endIndex); + const snippetHash = generateSnippetHash(filePath, startLine, endLine, rangeText); + if (seenHashes.has(snippetHash)) return; + seenHashes.add(snippetHash); + const name2 = sourceCode.substring(node.startIndex, node.endIndex); + const scope = buildScopeChain(node); + const namespace = findNamespaceForNode(node); + snippets.push({ + name: name2, + type: "import_or_include" /* ImportOrInclude */, + filePath, + startLine, + endLine, + rangeText, + definitionText: rangeText, + scope, + fileHash, + namespace + }); + } + }); + for (const capture of captures) { + if (capture.name !== "definition.function" && capture.name !== "definition.method" && capture.name !== "definition.static_method" && capture.name !== "definition.abstract_method" && capture.name !== "definition.final_method") + continue; + const node = capture.node; + const startLine = node.startPosition.row + 1; + const endLine = node.endPosition.row + 1; + let nameCapName; + let paramCapName; + let bodyCapName; + if (capture.name === "definition.function") { + nameCapName = "name.definition.function"; + paramCapName = "parameters.definition.function"; + bodyCapName = "body.definition.function"; + } else if (capture.name === "definition.method") { + nameCapName = "name.definition.method"; + paramCapName = "parameters.definition.method"; + bodyCapName = "body.definition.method"; + } else if (capture.name === "definition.static_method") { + nameCapName = "name.definition.static_method"; + paramCapName = "parameters.definition.static_method"; + bodyCapName = "body.definition.static_method"; + } else if (capture.name === "definition.abstract_method") { + nameCapName = "name.definition.abstract_method"; + paramCapName = "parameters.definition.abstract_method"; + bodyCapName = "body.definition.abstract_method"; + } else if (capture.name === "definition.final_method") { + nameCapName = "name.definition.final_method"; + paramCapName = "parameters.definition.final_method"; + bodyCapName = "body.definition.final_method"; + } else { + continue; + } + const nameCap = captures.find( + (c) => c.name === nameCapName && c.node.startIndex >= node.startIndex && c.node.endIndex <= node.endIndex + ); + if (!nameCap) continue; + const name2 = sourceCode.substring(nameCap.node.startIndex, nameCap.node.endIndex); + const paramCap = captures.find( + (c) => c.name === paramCapName && c.node.startIndex >= node.startIndex && c.node.endIndex <= node.endIndex + ); + const parameters = []; + if (paramCap) { + const paramText = sourceCode.substring(paramCap.node.startIndex, paramCap.node.endIndex); + const cleanText = removeParentheses2(paramText).trim(); + if (cleanText) { + const paramList = parsePHPParameters(cleanText); + parameters.push(...paramList.map((param) => ({ name: param }))); + } + } + const bodyCap = captures.find( + (c) => c.name === bodyCapName && c.node.startIndex >= node.startIndex && c.node.endIndex <= node.endIndex + ); + let rangeText; + let implementText = void 0; + if (bodyCap) { + rangeText = sourceCode.substring(node.startIndex, bodyCap.node.startIndex).trimEnd(); + implementText = sourceCode.substring(node.startIndex, node.endIndex); + } else { + rangeText = sourceCode.substring(node.startIndex, node.endIndex); + } + const snippetHash = generateSnippetHash(filePath, startLine, endLine, rangeText); + if (seenHashes.has(snippetHash)) continue; + seenHashes.add(snippetHash); + const paramStr = parameters.map((p) => p.name).join(", "); + const signature = `${name2}(${paramStr})`; + const scope = buildScopeChain(node); + let field = void 0; + const allParentCaptures = [...classCaptures, ...interfaceCaptures, ...traitCaptures, ...enumCaptures]; + for (const parent of allParentCaptures) { + if (node.startIndex > parent.start && node.endIndex <= parent.end && parent.nameCap) { + field = sourceCode.substring(parent.nameCap.node.startIndex, parent.nameCap.node.endIndex); + break; + } + } + const namespace = findNamespaceForNode(node); + snippets.push({ + name: name2, + type: "function_or_method" /* FunctionOrMethod */, + filePath, + startLine, + endLine, + rangeText, + definitionText: rangeText, + scope, + fileHash, + field, + namespace, + definition: { + name: name2, + type: capture.name === "definition.function" ? "function" : "method", + parameters, + returnType: "mixed" + // PHP默认返回类型 + }, + parameters, + signature, + language: "php" /* PHP */, + ...implementText ? { implementText } : {} + }); + } + for (const capture of captures) { + if (capture.name !== "definition.property" && capture.name !== "definition.static_property" && capture.name !== "definition.readonly_property" && capture.name !== "definition.promoted_property") + continue; + const node = capture.node; + const startLine = node.startPosition.row + 1; + const endLine = node.endPosition.row + 1; + let nameCapName; + if (capture.name === "definition.property") { + nameCapName = "name.definition.property"; + } else if (capture.name === "definition.static_property") { + nameCapName = "name.definition.static_property"; + } else if (capture.name === "definition.readonly_property") { + nameCapName = "name.definition.readonly_property"; + } else if (capture.name === "definition.promoted_property") { + nameCapName = "name.definition.promoted_property"; + } else { + continue; + } + const nameCap = captures.find( + (c) => c.name === nameCapName && c.node.startIndex >= node.startIndex && c.node.endIndex <= node.endIndex + ); + if (!nameCap) continue; + const name2 = sourceCode.substring(nameCap.node.startIndex, nameCap.node.endIndex); + const rangeText = sourceCode.substring(node.startIndex, node.endIndex); + const snippetHash = generateSnippetHash(filePath, startLine, endLine, rangeText); + if (seenHashes.has(snippetHash)) continue; + seenHashes.add(snippetHash); + const scope = buildScopeChain(node); + let field = void 0; + const allParentCaptures = [...classCaptures, ...interfaceCaptures, ...traitCaptures, ...enumCaptures]; + for (const parent of allParentCaptures) { + if (node.startIndex > parent.start && node.endIndex <= parent.end && parent.nameCap) { + field = sourceCode.substring(parent.nameCap.node.startIndex, parent.nameCap.node.endIndex); + break; + } + } + const namespace = findNamespaceForNode(node); + snippets.push({ + name: name2, + type: "variable_or_constant" /* VariableOrConstant */, + filePath, + startLine, + endLine, + rangeText, + definitionText: rangeText, + scope, + fileHash, + field, + namespace, + language: "php" /* PHP */ + }); + } + for (const capture of captures) { + if (capture.name !== "definition.constant") continue; + const node = capture.node; + const startLine = node.startPosition.row + 1; + const endLine = node.endPosition.row + 1; + const nameCap = captures.find( + (c) => c.name === "name.definition.constant" && c.node.startIndex >= node.startIndex && c.node.endIndex <= node.endIndex + ); + if (!nameCap) continue; + const name2 = sourceCode.substring(nameCap.node.startIndex, nameCap.node.endIndex); + const rangeText = sourceCode.substring(node.startIndex, node.endIndex); + const snippetHash = generateSnippetHash(filePath, startLine, endLine, rangeText); + if (seenHashes.has(snippetHash)) continue; + seenHashes.add(snippetHash); + const scope = buildScopeChain(node); + let field = void 0; + const allParentCaptures = [...classCaptures, ...interfaceCaptures, ...traitCaptures, ...enumCaptures]; + for (const parent of allParentCaptures) { + if (node.startIndex > parent.start && node.endIndex <= parent.end && parent.nameCap) { + field = sourceCode.substring(parent.nameCap.node.startIndex, parent.nameCap.node.endIndex); + break; + } + } + const namespace = findNamespaceForNode(node); + snippets.push({ + name: name2, + type: "variable_or_constant" /* VariableOrConstant */, + filePath, + startLine, + endLine, + rangeText, + definitionText: rangeText, + scope, + fileHash, + field, + namespace, + language: "php" /* PHP */ + }); + } + const typeDefs = [ + { capture: "name.definition.class", outlineType: "class" }, + { capture: "name.definition.abstract_class", outlineType: "abstract_class" }, + { capture: "name.definition.final_class", outlineType: "final_class" }, + { capture: "name.definition.readonly_class", outlineType: "readonly_class" }, + { capture: "name.definition.interface", outlineType: "interface" }, + { capture: "name.definition.trait", outlineType: "trait" }, + { capture: "name.definition.enum", outlineType: "enum" } + ]; + for (const { capture, outlineType } of typeDefs) { + const defCaptureName = `definition.${outlineType}`; + for (const cap of captures.filter((c) => c.name === capture)) { + const node = cap.node; + const isInMethod = captures.some( + (fc) => (fc.name === "definition.function" || fc.name === "definition.method" || fc.name === "definition.static_method" || fc.name === "definition.abstract_method" || fc.name === "definition.final_method") && fc.node.startIndex < node.startIndex && node.endIndex < fc.node.endIndex + ); + if (isInMethod) continue; + const defCap = captures.find( + (c) => c.name === defCaptureName && c.node.startIndex <= node.startIndex && node.endIndex <= c.node.endIndex + ); + const rangeText = defCap ? sourceCode.substring(defCap.node.startIndex, defCap.node.endIndex) : sourceCode.substring(node.startIndex, node.endIndex); + const startLine = node.startPosition.row + 1; + const endLine = node.endPosition.row + 1; + const snippetHash = generateSnippetHash(filePath, startLine, endLine, rangeText); + if (seenHashes.has(snippetHash)) continue; + seenHashes.add(snippetHash); + const name2 = sourceCode.substring(node.startIndex, node.endIndex); + const scope = buildScopeChain(node); + const namespace = findNamespaceForNode(node); + snippets.push({ + name: name2, + type: "class_or_interface_or_struct" /* ClassOrInterfaceOrStructOrEnum */, + filePath, + startLine, + endLine, + rangeText, + definitionText: rangeText, + implementText: rangeText, + scope, + fileHash, + namespace, + language: "php" /* PHP */ + }); + } + } + return snippets; +} +function parsePHPParameters(paramText) { + const params = []; + let current = ""; + let depth = 0; + let inString = false; + let stringChar = ""; + for (let i2 = 0; i2 < paramText.length; i2++) { + const char = paramText[i2]; + const prev = i2 > 0 ? paramText[i2 - 1] : ""; + if (!inString) { + if (char === '"' || char === "'") { + inString = true; + stringChar = char; + } else if (char === "(" || char === "[" || char === "{") { + depth++; + } else if (char === ")" || char === "]" || char === "}") { + depth--; + } else if (char === "," && depth === 0) { + if (current.trim()) { + params.push(extractPHPParamName(current.trim())); + } + current = ""; + continue; + } + } else { + if (char === stringChar && prev !== "\\") { + inString = false; + stringChar = ""; + } + } + current += char; + } + if (current.trim()) { + params.push(extractPHPParamName(current.trim())); + } + return params; +} +function extractPHPParamName(param) { + let cleaned = removeReferenceAndSplatOperators(param); + const variableName = findPHPVariableName(cleaned); + if (variableName) { + return variableName; + } + return param; +} +function removeParentheses2(text) { + if (text.startsWith("(") && text.endsWith(")")) { + return text.slice(1, -1); + } + return text; +} +function removeReferenceAndSplatOperators(param) { + let result = param.trim(); + while (result.startsWith(" ") || result.startsWith(" ")) { + result = result.slice(1); + } + if (result.startsWith("&")) { + result = result.slice(1).trim(); + } + if (result.startsWith("...")) { + result = result.slice(3).trim(); + } + return result; +} +function findPHPVariableName(text) { + for (let i2 = 0; i2 < text.length; i2++) { + if (text[i2] === "$") { + let variableName = "$"; + let j = i2 + 1; + while (j < text.length) { + const char = text[j]; + if (isValidPHPVariableChar(char)) { + variableName += char; + j++; + } else { + break; + } + } + if (variableName.length > 1) { + return variableName; + } + } + } + return null; +} +function isValidPHPVariableChar(char) { + return char >= "a" && char <= "z" || char >= "A" && char <= "Z" || char >= "0" && char <= "9" || char === "_"; +} +function buildSummaryFromSnippets11(snippets) { + const outline = { + imports: [], + classes: [], + interfaces: [], + traits: [], + enums: [], + functions: [], + constants: [], + namespaces: [] + }; + for (const snippet of snippets) { + if (snippet.namespace && !outline.namespaces.includes(snippet.namespace)) { + outline.namespaces.push(snippet.namespace); + } + switch (snippet.type) { + case "import_or_include" /* ImportOrInclude */: + outline.imports.push(snippet.name); + break; + case "class_or_interface_or_struct" /* ClassOrInterfaceOrStructOrEnum */: + if (snippet.name.includes("interface")) { + outline.interfaces.push(snippet.name); + } else if (snippet.name.includes("trait")) { + outline.traits.push(snippet.name); + } else if (snippet.name.includes("enum")) { + outline.enums.push(snippet.name); + } else { + outline.classes.push(snippet.name); + } + break; + case "function_or_method" /* FunctionOrMethod */: + outline.functions.push(snippet.name); + break; + case "variable_or_constant" /* VariableOrConstant */: + if (snippet.name.includes("const")) { + outline.constants.push(snippet.name); + } + break; + } + } + return outline; +} +function formatOutlineText11(outline) { + const sections = []; + if (outline.namespaces.length > 0) { + sections.push(`Namespaces: ${outline.namespaces.join(", ")}`); + } + if (outline.imports.length > 0) { + sections.push(`Imports: ${outline.imports.join(", ")}`); + } + if (outline.classes.length > 0) { + sections.push(`Classes: ${outline.classes.join(", ")}`); + } + if (outline.interfaces.length > 0) { + sections.push(`Interfaces: ${outline.interfaces.join(", ")}`); + } + if (outline.traits.length > 0) { + sections.push(`Traits: ${outline.traits.join(", ")}`); + } + if (outline.enums.length > 0) { + sections.push(`Enums: ${outline.enums.join(", ")}`); + } + if (outline.functions.length > 0) { + sections.push(`Functions: ${outline.functions.join(", ")}`); + } + if (outline.constants.length > 0) { + sections.push(`Constants: ${outline.constants.join(", ")}`); + } + return sections.join("\n"); +} + +// ../autocompletion/v2/capturesProcess/rust.ts +async function extractSnippetsFromCapturesForRust(captures, sourceCode, filePath, fileHash, snippetTypes, options) { + const logger = Logger.getDefaultLogger().with("[extractSnippetsFromCapturesForRust]"); + const snippets = []; + const seenHashes = /* @__PURE__ */ new Set(); + if (snippetTypes.length === 0) { + logger.warn(`No snippet types provided, skipping`); + return snippets; + } + const containerCaptures = captures.filter( + (c) => c.name === "definition.struct" || c.name === "definition.enum" || c.name === "definition.trait" || c.name === "definition.impl" || c.name === "definition.impl_trait" + ).map((c) => ({ + node: c.node, + start: c.node.startIndex, + end: c.node.endIndex, + name: c.name, + nameCap: findNameCaptureForContainer(c, captures, sourceCode) + })).filter((c) => c.nameCap); + if (snippetTypes.includes("import_or_include" /* ImportOrInclude */)) { + captures.forEach((capture) => { + if (capture.name === "definition.use_declaration") { + const node = capture.node; + const startLine = node.startPosition.row + 1; + const endLine = node.endPosition.row + 1; + const rangeText = sourceCode.substring(node.startIndex, node.endIndex); + const snippetHash = generateSnippetHash(filePath, startLine, endLine, rangeText); + if (seenHashes.has(snippetHash)) return; + seenHashes.add(snippetHash); + const name2 = extractUseStatementName(rangeText); + const scope = buildScopeChain(node); + snippets.push({ + name: name2, + type: "import_or_include" /* ImportOrInclude */, + filePath, + startLine, + endLine, + rangeText, + definitionText: rangeText, + scope, + fileHash + }); + } + }); + } + if (snippetTypes.includes("function_or_method" /* FunctionOrMethod */)) { + for (const capture of captures) { + if (capture.name !== "definition.function") continue; + const node = capture.node; + const startLine = node.startPosition.row + 1; + const endLine = node.endPosition.row + 1; + const nameCap = captures.find( + (c) => c.name === "name.definition.function" && c.node.startIndex >= node.startIndex && c.node.endIndex <= node.endIndex + ); + if (!nameCap) continue; + const name2 = sourceCode.substring(nameCap.node.startIndex, nameCap.node.endIndex); + const paramCap = captures.find( + (c) => c.name === "parameters.definition.function" && c.node.startIndex >= node.startIndex && c.node.endIndex <= node.endIndex + ); + const parameters = []; + if (paramCap) { + const paramText = sourceCode.substring(paramCap.node.startIndex, paramCap.node.endIndex); + const cleanParams = removeParentheses3(paramText).trim(); + if (cleanParams) { + const paramList = parseRustParameters(cleanParams); + parameters.push(...paramList.map((param) => ({ name: param }))); + } + } + const bodyCap = captures.find( + (c) => c.name === "body.definition.function" && c.node.startIndex >= node.startIndex && c.node.endIndex <= node.endIndex + ); + let definitionText; + let implementText = void 0; + if (bodyCap) { + const functionHeader = sourceCode.substring(node.startIndex, bodyCap.node.startIndex).trimEnd(); + definitionText = functionHeader.endsWith("{") ? functionHeader.slice(0, -1).trim() : functionHeader; + implementText = sourceCode.substring(node.startIndex, node.endIndex); + } else { + definitionText = sourceCode.substring(node.startIndex, node.endIndex); + } + const rangeText = sourceCode.substring(node.startIndex, node.endIndex); + let field = void 0; + const sortedContainers = containerCaptures.sort((a, b) => { + if (a.name === "definition.impl_trait" && b.name !== "definition.impl_trait") return -1; + if (a.name !== "definition.impl_trait" && b.name === "definition.impl_trait") return 1; + return 0; + }); + for (const container of sortedContainers) { + if (node.startIndex > container.start && node.endIndex <= container.end && container.nameCap) { + field = container.nameCap; + break; + } + } + const snippetHash = generateSnippetHash(filePath, startLine, endLine, rangeText); + if (seenHashes.has(snippetHash)) continue; + seenHashes.add(snippetHash); + const scope = buildScopeChain(node); + snippets.push({ + name: name2, + type: "function_or_method" /* FunctionOrMethod */, + filePath, + startLine, + endLine, + rangeText, + definitionText, + implementText, + parameters, + field, + scope, + fileHash + }); + } + for (const capture of captures) { + if (capture.name !== "name.definition.method") continue; + const methodNode = capture.node; + const name2 = sourceCode.substring(methodNode.startIndex, methodNode.endIndex); + const implCapture = captures.find( + (c) => (c.name === "definition.impl" || c.name === "definition.impl_trait") && c.node.startIndex <= methodNode.startIndex && c.node.endIndex >= methodNode.endIndex + ); + if (!implCapture) continue; + const functionNode = findParentFunctionNode(methodNode, sourceCode); + if (!functionNode) continue; + const startLine = functionNode.startPosition.row + 1; + const endLine = functionNode.endPosition.row + 1; + const paramCap = captures.find( + (c) => c.name === "parameters.definition.method" && c.node.startIndex >= functionNode.startIndex && c.node.endIndex <= functionNode.endIndex + ); + const parameters = []; + if (paramCap) { + const paramText = sourceCode.substring(paramCap.node.startIndex, paramCap.node.endIndex); + const cleanParams = removeParentheses3(paramText).trim(); + if (cleanParams) { + const paramList = parseRustParameters(cleanParams); + parameters.push(...paramList.map((param) => ({ name: param }))); + } + } + const bodyCap = captures.find( + (c) => c.name === "body.definition.method" && c.node.startIndex >= functionNode.startIndex && c.node.endIndex <= functionNode.endIndex + ); + let definitionText; + let implementText = void 0; + if (bodyCap) { + const methodHeader = sourceCode.substring(functionNode.startIndex, bodyCap.node.startIndex).trimEnd(); + definitionText = methodHeader.endsWith("{") ? methodHeader.slice(0, -1).trim() : methodHeader; + implementText = sourceCode.substring(functionNode.startIndex, functionNode.endIndex); + } else { + definitionText = sourceCode.substring(functionNode.startIndex, functionNode.endIndex); + } + const rangeText = sourceCode.substring(functionNode.startIndex, functionNode.endIndex); + let field = void 0; + const sortedContainers = containerCaptures.sort((a, b) => { + if (a.name === "definition.impl_trait" && b.name !== "definition.impl_trait") return -1; + if (a.name !== "definition.impl_trait" && b.name === "definition.impl_trait") return 1; + return 0; + }); + for (const container of sortedContainers) { + if (functionNode.startIndex > container.start && functionNode.endIndex <= container.end && container.nameCap) { + field = container.nameCap; + break; + } + } + const snippetHash = generateSnippetHash(filePath, startLine, endLine, rangeText); + if (seenHashes.has(snippetHash)) continue; + seenHashes.add(snippetHash); + const scope = buildScopeChain(functionNode); + snippets.push({ + name: name2, + type: "function_or_method" /* FunctionOrMethod */, + filePath, + startLine, + endLine, + rangeText, + definitionText, + implementText, + parameters, + field, + scope, + fileHash + }); + } + } + if (snippetTypes.includes("class_or_interface_or_struct" /* ClassOrInterfaceOrStructOrEnum */)) { + const structureTypes = [ + "definition.struct", + "definition.enum", + "definition.trait", + "definition.impl", + "definition.impl_trait" + ]; + const processedNodes = /* @__PURE__ */ new Set(); + for (const capture of captures) { + if (!structureTypes.includes(capture.name)) continue; + const node = capture.node; + const startLine = node.startPosition.row + 1; + const endLine = node.endPosition.row + 1; + const nodeKey = `${node.startIndex}:${node.endIndex}`; + if (processedNodes.has(nodeKey)) continue; + if (capture.name === "definition.impl") { + const hasImplTrait = captures.some( + (c) => c.name === "definition.impl_trait" && c.node.startIndex === node.startIndex && c.node.endIndex === node.endIndex + ); + if (hasImplTrait) continue; + } + processedNodes.add(nodeKey); + let nameCap; + let name2 = ""; + switch (capture.name) { + case "definition.struct": + nameCap = captures.find( + (c) => c.name === "name.definition.struct" && c.node.startIndex >= node.startIndex && c.node.endIndex <= node.endIndex + ); + if (nameCap) { + name2 = sourceCode.substring(nameCap.node.startIndex, nameCap.node.endIndex); + } + break; + case "definition.enum": + nameCap = captures.find( + (c) => c.name === "name.definition.enum" && c.node.startIndex >= node.startIndex && c.node.endIndex <= node.endIndex + ); + if (nameCap) { + name2 = sourceCode.substring(nameCap.node.startIndex, nameCap.node.endIndex); + } + break; + case "definition.trait": + nameCap = captures.find( + (c) => c.name === "name.definition.trait" && c.node.startIndex >= node.startIndex && c.node.endIndex <= node.endIndex + ); + if (nameCap) { + name2 = sourceCode.substring(nameCap.node.startIndex, nameCap.node.endIndex); + } + break; + case "definition.impl": + nameCap = captures.find( + (c) => c.name === "name.definition.impl" && c.node.startIndex >= node.startIndex && c.node.endIndex <= node.endIndex + ); + if (nameCap) { + name2 = sourceCode.substring(nameCap.node.startIndex, nameCap.node.endIndex); + } + break; + case "definition.impl_trait": + const traitCap = captures.find( + (c) => c.name === "name.definition.impl_trait" && c.node.startIndex >= node.startIndex && c.node.endIndex <= node.endIndex + ); + const forCap = captures.find( + (c) => c.name === "name.definition.impl_for" && c.node.startIndex >= node.startIndex && c.node.endIndex <= node.endIndex + ); + if (traitCap && forCap) { + const traitName = sourceCode.substring(traitCap.node.startIndex, traitCap.node.endIndex); + const forName = sourceCode.substring(forCap.node.startIndex, forCap.node.endIndex); + name2 = `${traitName} for ${forName}`; + } + break; + } + if (!name2) continue; + const rangeText = sourceCode.substring(node.startIndex, node.endIndex); + const snippetHash = generateSnippetHash(filePath, startLine, endLine, rangeText); + if (seenHashes.has(snippetHash)) continue; + seenHashes.add(snippetHash); + const scope = buildScopeChain(node); + snippets.push({ + name: name2, + type: "class_or_interface_or_struct" /* ClassOrInterfaceOrStructOrEnum */, + filePath, + startLine, + endLine, + rangeText, + definitionText: rangeText, + scope, + fileHash + }); + } + } + if (snippetTypes.includes("variable_or_constant" /* VariableOrConstant */)) { + const variableTypes = [ + { captureName: "definition.variable", nameCapture: "name.definition.variable" }, + { captureName: "definition.constant", nameCapture: "name.definition.constant" }, + { captureName: "definition.static", nameCapture: "name.definition.static" } + ]; + for (const { captureName, nameCapture } of variableTypes) { + for (const capture of captures) { + if (capture.name !== captureName) continue; + const node = capture.node; + const startLine = node.startPosition.row + 1; + const endLine = node.endPosition.row + 1; + const nameCap = captures.find( + (c) => c.name === nameCapture && c.node.startIndex >= node.startIndex && c.node.endIndex <= node.endIndex + ); + if (!nameCap) continue; + const name2 = sourceCode.substring(nameCap.node.startIndex, nameCap.node.endIndex); + const rangeText = sourceCode.substring(node.startIndex, node.endIndex); + const snippetHash = generateSnippetHash(filePath, startLine, endLine, rangeText); + if (seenHashes.has(snippetHash)) continue; + seenHashes.add(snippetHash); + let field = void 0; + for (const container of containerCaptures) { + if (node.startIndex > container.start && node.endIndex <= container.end && container.nameCap) { + field = container.nameCap; + break; + } + } + const scope = buildScopeChain(node); + snippets.push({ + name: name2, + type: "variable_or_constant" /* VariableOrConstant */, + filePath, + startLine, + endLine, + rangeText, + definitionText: rangeText, + field, + scope, + fileHash + }); + } + } + } + return snippets; +} +function parseRustParameters(paramText) { + const params = []; + let current = ""; + let depth = 0; + let inString = false; + let escapeNext = false; + for (let i2 = 0; i2 < paramText.length; i2++) { + const char = paramText[i2]; + if (escapeNext) { + current += char; + escapeNext = false; + continue; + } + if (char === "\\") { + escapeNext = true; + current += char; + continue; + } + if (char === '"' || char === "'") { + inString = !inString; + current += char; + continue; + } + if (inString) { + current += char; + continue; + } + if (char === "<" || char === "(" || char === "[" || char === "{") { + depth++; + } else if (char === ">" || char === ")" || char === "]" || char === "}") { + depth--; + } + if (char === "," && depth === 0) { + const param2 = current.trim(); + if (param2) { + const colonIndex = param2.indexOf(":"); + const paramName = colonIndex > -1 ? param2.substring(0, colonIndex).trim() : param2; + if (paramName === "self" || paramName === "&self" || paramName === "&mut self") { + params.push(paramName); + } else { + params.push(paramName); + } + } + current = ""; + } else { + current += char; + } + } + const param = current.trim(); + if (param) { + const colonIndex = param.indexOf(":"); + const paramName = colonIndex > -1 ? param.substring(0, colonIndex).trim() : param; + if (paramName === "self" || paramName === "&self" || paramName === "&mut self") { + params.push(paramName); + } else { + params.push(paramName); + } + } + return params; +} +function extractUseStatementName(useStatement) { + let cleaned = removeUseKeywordAndSemicolon(useStatement).trim(); + const asIndex = cleaned.lastIndexOf(" as "); + if (asIndex > -1) { + return cleaned.substring(asIndex + 4).trim(); + } + if (cleaned.includes("{") && cleaned.includes("}")) { + const braceContent = extractBraceContent(cleaned); + if (braceContent) { + const items = braceContent.split(",").map((s) => s.trim()); + return items.join(", "); + } + } + const parts2 = cleaned.split("::"); + return parts2[parts2.length - 1].trim(); +} +function findNameCaptureForContainer(container, captures, sourceCode) { + let nameCaptureName; + switch (container.name) { + case "definition.struct": + nameCaptureName = "name.definition.struct"; + break; + case "definition.enum": + nameCaptureName = "name.definition.enum"; + break; + case "definition.trait": + nameCaptureName = "name.definition.trait"; + break; + case "definition.impl": + nameCaptureName = "name.definition.impl"; + break; + case "definition.impl_trait": + const traitCap = captures.find( + (c) => c.name === "name.definition.impl_trait" && c.node.startIndex >= container.node.startIndex && c.node.endIndex <= container.node.endIndex + ); + const forCap = captures.find( + (c) => c.name === "name.definition.impl_for" && c.node.startIndex >= container.node.startIndex && c.node.endIndex <= container.node.endIndex + ); + if (traitCap && forCap) { + const traitName = sourceCode.substring(traitCap.node.startIndex, traitCap.node.endIndex); + const forName = sourceCode.substring(forCap.node.startIndex, forCap.node.endIndex); + return `${traitName} for ${forName}`; + } + return void 0; + default: + return void 0; + } + const nameCap = captures.find( + (c) => c.name === nameCaptureName && c.node.startIndex >= container.node.startIndex && c.node.endIndex <= container.node.endIndex + ); + return nameCap ? sourceCode.substring(nameCap.node.startIndex, nameCap.node.endIndex) : void 0; +} +function findParentFunctionNode(methodNameNode, sourceCode) { + let current = methodNameNode.parent; + while (current) { + if (current.type === "function_item") { + return current; + } + current = current.parent; + } + return void 0; +} +function removeParentheses3(text) { + if (text.startsWith("(") && text.endsWith(")")) { + return text.slice(1, -1); + } + return text; +} +function removeUseKeywordAndSemicolon(useStatement) { + let result = useStatement.trim(); + if (result.startsWith("use ")) { + result = result.substring(4); + } + if (result.endsWith(";")) { + result = result.slice(0, -1); + } + return result; +} +function extractBraceContent(text) { + const startIndex = text.indexOf("{"); + const endIndex = text.lastIndexOf("}"); + if (startIndex > -1 && endIndex > startIndex) { + return text.substring(startIndex + 1, endIndex); + } + return null; +} +function buildSummaryFromSnippets12(snippets) { + const summary = { + functions: [], + structs: [], + enums: [], + traits: [], + impls: [], + constants: [], + variables: [], + imports: [] + }; + for (const snippet of snippets) { + switch (snippet.type) { + case "function_or_method" /* FunctionOrMethod */: + summary.functions.push({ + name: snippet.name, + parameters: snippet.parameters?.map((p) => p.name) || [], + field: snippet.field + }); + break; + case "class_or_interface_or_struct" /* ClassOrInterfaceOrStructOrEnum */: + const defText = snippet.definitionText || ""; + if (defText.startsWith("struct ")) { + summary.structs.push({ name: snippet.name }); + } else if (defText.startsWith("enum ")) { + summary.enums.push({ name: snippet.name }); + } else if (defText.startsWith("trait ")) { + summary.traits.push({ name: snippet.name }); + } else if (defText.startsWith("impl ")) { + summary.impls.push({ name: snippet.name }); + } + break; + case "variable_or_constant" /* VariableOrConstant */: + const varDefText = snippet.definitionText || ""; + if (varDefText.startsWith("const ") || varDefText.startsWith("static ")) { + summary.constants.push({ + name: snippet.name, + field: snippet.field + }); + } else { + summary.variables.push({ + name: snippet.name, + field: snippet.field + }); + } + break; + case "import_or_include" /* ImportOrInclude */: + summary.imports.push({ name: snippet.name }); + break; + } + } + return summary; +} +function formatOutlineText12(summary) { + let outlineText = ""; + if (summary.imports.length > 0) { + outlineText += "Imports:\n"; + for (const imp of summary.imports) { + outlineText += ` - ${imp.name} +`; + } + outlineText += "\n"; + } + if (summary.structs.length > 0) { + outlineText += "Structs:\n"; + for (const struct of summary.structs) { + outlineText += ` - ${struct.name} +`; + } + outlineText += "\n"; + } + if (summary.enums.length > 0) { + outlineText += "Enums:\n"; + for (const enumItem of summary.enums) { + outlineText += ` - ${enumItem.name} +`; + } + outlineText += "\n"; + } + if (summary.traits.length > 0) { + outlineText += "Traits:\n"; + for (const trait of summary.traits) { + outlineText += ` - ${trait.name} +`; + } + outlineText += "\n"; + } + if (summary.impls.length > 0) { + outlineText += "Implementations:\n"; + for (const impl of summary.impls) { + outlineText += ` - ${impl.name} +`; + } + outlineText += "\n"; + } + if (summary.functions.length > 0) { + outlineText += "Functions/Methods:\n"; + for (const func2 of summary.functions) { + const paramStr = func2.parameters.length > 0 ? `(${func2.parameters.join(", ")})` : "()"; + const fieldStr = func2.field ? ` [in ${func2.field}]` : ""; + outlineText += ` - ${func2.name}${paramStr}${fieldStr} +`; + } + outlineText += "\n"; + } + if (summary.constants.length > 0) { + outlineText += "Constants/Statics:\n"; + for (const constant of summary.constants) { + const fieldStr = constant.field ? ` [in ${constant.field}]` : ""; + outlineText += ` - ${constant.name}${fieldStr} +`; + } + outlineText += "\n"; + } + if (summary.variables.length > 0) { + outlineText += "Variables:\n"; + for (const variable of summary.variables) { + const fieldStr = variable.field ? ` [in ${variable.field}]` : ""; + outlineText += ` - ${variable.name}${fieldStr} +`; + } + outlineText += "\n"; + } + return outlineText.trim(); +} + +// ../autocompletion/v2/capturesProcess/c.ts +async function extractSnippetsFromCapturesForC(captures, sourceCode, filePath, fileHash, snippetTypes, options) { + const logger = Logger.getDefaultLogger().with("[extractSnippetsFromCapturesForC]"); + const snippets = []; + const seenHashes = /* @__PURE__ */ new Set(); + if (snippetTypes.length === 0) { + logger.warn(`No snippet types provided, skipping`); + return snippets; + } + const containerCaptures = captures.filter((c) => c.name === "definition.struct" || c.name === "definition.union" || c.name === "definition.enum").map((c) => ({ + node: c.node, + start: c.node.startIndex, + end: c.node.endIndex, + name: c.name, + nameCap: findNameCaptureForContainer2(c, captures, sourceCode) + })).filter((c) => c.nameCap); + if (snippetTypes.includes("import_or_include" /* ImportOrInclude */)) { + captures.forEach((capture) => { + if (capture.name === "definition.include") { + const node = capture.node; + const startLine = node.startPosition.row + 1; + const endLine = node.endPosition.row + 1; + const rangeText = sourceCode.substring(node.startIndex, node.endIndex); + const snippetHash = generateSnippetHash(filePath, startLine, endLine, rangeText); + if (!seenHashes.has(snippetHash)) { + seenHashes.add(snippetHash); + const scope = buildScopeChain(node); + const includeNameCapture = captures.find( + (c) => c.name === "name.definition.include" && c.node.startIndex >= node.startIndex && c.node.endIndex <= node.endIndex + ); + const includeName = includeNameCapture ? sourceCode.substring(includeNameCapture.node.startIndex, includeNameCapture.node.endIndex) : ""; + snippets.push({ + type: "import_or_include" /* ImportOrInclude */, + name: includeName, + rangeText, + startLine, + endLine, + filePath, + fileHash, + scope, + language: "c" /* C */ + }); + } + } + }); + } + if (snippetTypes.includes("function_or_method" /* FunctionOrMethod */)) { + const functionCaptures = captures.filter((c) => c.name === "definition.function"); + functionCaptures.forEach((capture) => { + const node = capture.node; + const startLine = node.startPosition.row + 1; + const endLine = node.endPosition.row + 1; + const rangeText = sourceCode.substring(node.startIndex, node.endIndex); + const snippetHash = generateSnippetHash(filePath, startLine, endLine, rangeText); + if (!seenHashes.has(snippetHash)) { + seenHashes.add(snippetHash); + const scope = buildScopeChain(node); + const functionNameCapture = captures.find( + (c) => c.name === "name.definition.function" && c.node.startIndex >= node.startIndex && c.node.endIndex <= node.endIndex + ); + const functionName = functionNameCapture ? sourceCode.substring(functionNameCapture.node.startIndex, functionNameCapture.node.endIndex) : ""; + const parametersCapture = captures.find( + (c) => c.name === "parameters.definition.function" && c.node.startIndex >= node.startIndex && c.node.endIndex <= node.endIndex + ); + const parameters = parametersCapture ? extractParametersFromNode(parametersCapture.node, sourceCode) : []; + const bodyCapture = captures.find( + (c) => c.name === "body.definition.function" && c.node.startIndex >= node.startIndex && c.node.endIndex <= node.endIndex + ); + const hasBody = !!bodyCapture; + snippets.push({ + type: "function_or_method" /* FunctionOrMethod */, + name: functionName, + rangeText, + startLine, + endLine, + filePath, + fileHash, + scope, + language: "c" /* C */, + parameters, + definition: { + name: functionName, + type: "function", + parameters + } + }); + } + }); + } + if (snippetTypes.includes("class_or_interface_or_struct" /* ClassOrInterfaceOrStructOrEnum */)) { + const structCaptures = captures.filter((c) => c.name === "definition.struct"); + structCaptures.forEach((capture) => { + const node = capture.node; + const startLine = node.startPosition.row + 1; + const endLine = node.endPosition.row + 1; + const rangeText = sourceCode.substring(node.startIndex, node.endIndex); + const snippetHash = generateSnippetHash(filePath, startLine, endLine, rangeText); + if (!seenHashes.has(snippetHash)) { + seenHashes.add(snippetHash); + const scope = buildScopeChain(node); + const structNameCapture = captures.find( + (c) => c.name === "name.definition.struct" && c.node.startIndex >= node.startIndex && c.node.endIndex <= node.endIndex + ); + const structName = structNameCapture ? sourceCode.substring(structNameCapture.node.startIndex, structNameCapture.node.endIndex) : ""; + const fields = extractFieldsFromStructNode(node, sourceCode, captures); + snippets.push({ + type: "class_or_interface_or_struct" /* ClassOrInterfaceOrStructOrEnum */, + name: structName, + rangeText, + startLine, + endLine, + filePath, + fileHash, + scope, + language: "c" /* C */, + definition: { + name: structName, + type: "struct" + } + }); + } + }); + } + if (snippetTypes.includes("class_or_interface_or_struct" /* ClassOrInterfaceOrStructOrEnum */)) { + const unionCaptures = captures.filter((c) => c.name === "definition.union"); + unionCaptures.forEach((capture) => { + const node = capture.node; + const startLine = node.startPosition.row + 1; + const endLine = node.endPosition.row + 1; + const rangeText = sourceCode.substring(node.startIndex, node.endIndex); + const snippetHash = generateSnippetHash(filePath, startLine, endLine, rangeText); + if (!seenHashes.has(snippetHash)) { + seenHashes.add(snippetHash); + const scope = buildScopeChain(node); + const unionNameCapture = captures.find( + (c) => c.name === "name.definition.union" && c.node.startIndex >= node.startIndex && c.node.endIndex <= node.endIndex + ); + const unionName = unionNameCapture ? sourceCode.substring(unionNameCapture.node.startIndex, unionNameCapture.node.endIndex) : ""; + const fields = extractFieldsFromStructNode(node, sourceCode, captures); + snippets.push({ + type: "class_or_interface_or_struct" /* ClassOrInterfaceOrStructOrEnum */, + name: unionName, + rangeText, + startLine, + endLine, + filePath, + fileHash, + scope, + language: "c" /* C */, + definition: { + name: unionName, + type: "union" + } + }); + } + }); + } + if (snippetTypes.includes("class_or_interface_or_struct" /* ClassOrInterfaceOrStructOrEnum */)) { + const enumCaptures = captures.filter((c) => c.name === "definition.enum"); + enumCaptures.forEach((capture) => { + const node = capture.node; + const startLine = node.startPosition.row + 1; + const endLine = node.endPosition.row + 1; + const rangeText = sourceCode.substring(node.startIndex, node.endIndex); + const snippetHash = generateSnippetHash(filePath, startLine, endLine, rangeText); + if (!seenHashes.has(snippetHash)) { + seenHashes.add(snippetHash); + const scope = buildScopeChain(node); + const enumNameCapture = captures.find( + (c) => c.name === "name.definition.enum" && c.node.startIndex >= node.startIndex && c.node.endIndex <= node.endIndex + ); + const enumName = enumNameCapture ? sourceCode.substring(enumNameCapture.node.startIndex, enumNameCapture.node.endIndex) : ""; + const enumerators = extractEnumeratorsFromEnumNode(node, sourceCode, captures); + snippets.push({ + type: "class_or_interface_or_struct" /* ClassOrInterfaceOrStructOrEnum */, + name: enumName, + rangeText, + startLine, + endLine, + filePath, + fileHash, + scope, + language: "c" /* C */, + definition: { + name: enumName, + type: "enum" + } + }); + } + }); + } + if (snippetTypes.includes("variable_or_constant" /* VariableOrConstant */)) { + const variableCaptures = captures.filter((c) => c.name === "definition.variable"); + variableCaptures.forEach((capture) => { + const node = capture.node; + const startLine = node.startPosition.row + 1; + const endLine = node.endPosition.row + 1; + const rangeText = sourceCode.substring(node.startIndex, node.endIndex); + const snippetHash = generateSnippetHash(filePath, startLine, endLine, rangeText); + if (!seenHashes.has(snippetHash)) { + seenHashes.add(snippetHash); + const scope = buildScopeChain(node); + const variableNameCapture = captures.find( + (c) => c.name === "name.definition.variable" && c.node.startIndex >= node.startIndex && c.node.endIndex <= node.endIndex + ); + const variableName = variableNameCapture ? sourceCode.substring(variableNameCapture.node.startIndex, variableNameCapture.node.endIndex) : ""; + snippets.push({ + type: "variable_or_constant" /* VariableOrConstant */, + name: variableName, + rangeText, + startLine, + endLine, + filePath, + fileHash, + scope, + language: "c" /* C */, + definition: { + name: variableName, + type: "variable" + } + }); + } + }); + } + if (snippetTypes.includes("variable_or_constant" /* VariableOrConstant */)) { + const staticVariableCaptures = captures.filter((c) => c.name === "definition.static_variable"); + staticVariableCaptures.forEach((capture) => { + const node = capture.node; + const startLine = node.startPosition.row + 1; + const endLine = node.endPosition.row + 1; + const rangeText = sourceCode.substring(node.startIndex, node.endIndex); + const snippetHash = generateSnippetHash(filePath, startLine, endLine, rangeText); + if (!seenHashes.has(snippetHash)) { + seenHashes.add(snippetHash); + const scope = buildScopeChain(node); + const staticVariableNameCapture = captures.find( + (c) => c.name === "name.definition.variable" && c.node.startIndex >= node.startIndex && c.node.endIndex <= node.endIndex + ); + const staticVariableName = staticVariableNameCapture ? sourceCode.substring( + staticVariableNameCapture.node.startIndex, + staticVariableNameCapture.node.endIndex + ) : ""; + snippets.push({ + type: "variable_or_constant" /* VariableOrConstant */, + name: staticVariableName, + rangeText, + startLine, + endLine, + filePath, + fileHash, + scope, + language: "c" /* C */, + definition: { + name: staticVariableName, + type: "static_variable" + } + }); + } + }); + } + if (snippetTypes.includes("class_or_interface_or_struct" /* ClassOrInterfaceOrStructOrEnum */)) { + const typedefCaptures = captures.filter((c) => c.name === "definition.type"); + typedefCaptures.forEach((capture) => { + const node = capture.node; + const startLine = node.startPosition.row + 1; + const endLine = node.endPosition.row + 1; + const rangeText = sourceCode.substring(node.startIndex, node.endIndex); + const snippetHash = generateSnippetHash(filePath, startLine, endLine, rangeText); + if (!seenHashes.has(snippetHash)) { + seenHashes.add(snippetHash); + const scope = buildScopeChain(node); + const typedefNameCapture = captures.find( + (c) => c.name === "name.definition.type" && c.node.startIndex >= node.startIndex && c.node.endIndex <= node.endIndex + ); + const typedefName = typedefNameCapture ? sourceCode.substring(typedefNameCapture.node.startIndex, typedefNameCapture.node.endIndex) : ""; + snippets.push({ + type: "class_or_interface_or_struct" /* ClassOrInterfaceOrStructOrEnum */, + name: typedefName, + rangeText, + startLine, + endLine, + filePath, + fileHash, + scope, + language: "c" /* C */, + definition: { + name: typedefName, + type: "typedef" + } + }); + } + }); + } + logger.info(`Extracted ${snippets.length} C snippets`); + return snippets; +} +function extractParametersFromNode(node, sourceCode) { + const parameters = []; + for (let i2 = 0; i2 < node.childCount; i2++) { + const child = node.child(i2); + if (child && child.type === "parameter_declaration") { + const parameterText = sourceCode.substring(child.startIndex, child.endIndex); + const parameterName = extractParameterName(child, sourceCode); + parameters.push({ + name: parameterName, + type: parameterText + }); + } + } + return parameters; +} +function extractParameterName(node, sourceCode) { + for (let i2 = 0; i2 < node.childCount; i2++) { + const child = node.child(i2); + if (child && child.type === "identifier") { + return sourceCode.substring(child.startIndex, child.endIndex); + } + } + return ""; +} +function extractFieldsFromStructNode(node, sourceCode, captures) { + const fields = []; + const fieldCaptures = captures.filter( + (c) => c.name === "name.definition.field" && c.node.startIndex >= node.startIndex && c.node.endIndex <= node.endIndex + ); + fieldCaptures.forEach((capture) => { + const fieldName = sourceCode.substring(capture.node.startIndex, capture.node.endIndex); + fields.push(fieldName); + }); + return fields; +} +function extractEnumeratorsFromEnumNode(node, sourceCode, captures) { + const enumerators = []; + const enumeratorCaptures = captures.filter( + (c) => c.name === "name.definition.enumerator" && c.node.startIndex >= node.startIndex && c.node.endIndex <= node.endIndex + ); + enumeratorCaptures.forEach((capture) => { + const enumeratorName = sourceCode.substring(capture.node.startIndex, capture.node.endIndex); + enumerators.push(enumeratorName); + }); + return enumerators; +} +function getNameCaptureNameForContainer(containerCaptureName) { + switch (containerCaptureName) { + case "definition.struct": + return "name.definition.struct"; + case "definition.union": + return "name.definition.union"; + case "definition.enum": + return "name.definition.enum"; + default: + return containerCaptureName; + } +} +function findNameCaptureForContainer2(containerCapture, captures, sourceCode) { + const node = containerCapture.node; + const nameCaptureName = getNameCaptureNameForContainer(containerCapture.name); + const nameCapture = captures.find( + (c) => c.name === nameCaptureName && c.node.startIndex >= node.startIndex && c.node.endIndex <= node.endIndex + ); + return nameCapture ? sourceCode.substring(nameCapture.node.startIndex, nameCapture.node.endIndex) : null; +} +function buildSummaryFromSnippets13(snippets) { + const summary = { + includes: [], + functions: [], + structs: [], + unions: [], + enums: [], + variables: [] + }; + snippets.forEach((snippet) => { + switch (snippet.type) { + case "import_or_include" /* ImportOrInclude */: + summary.includes.push(snippet.name); + break; + case "function_or_method" /* FunctionOrMethod */: + summary.functions.push(snippet.name); + break; + case "class_or_interface_or_struct" /* ClassOrInterfaceOrStructOrEnum */: + if (snippet.rangeText.includes("struct")) { + summary.structs.push(snippet.name); + } else if (snippet.rangeText.includes("union")) { + summary.unions.push(snippet.name); + } else if (snippet.rangeText.includes("enum")) { + summary.enums.push(snippet.name); + } + break; + case "variable_or_constant" /* VariableOrConstant */: + summary.variables.push(snippet.name); + break; + } + }); + return summary; +} +function formatOutlineText13(summary) { + let outline = ""; + if (summary.includes.length > 0) { + outline += `Includes: ${summary.includes.join(", ")} +`; + } + if (summary.functions.length > 0) { + outline += `Functions: ${summary.functions.join(", ")} +`; + } + if (summary.structs.length > 0) { + outline += `Structs: ${summary.structs.join(", ")} +`; + } + if (summary.unions.length > 0) { + outline += `Unions: ${summary.unions.join(", ")} +`; + } + if (summary.enums.length > 0) { + outline += `Enums: ${summary.enums.join(", ")} +`; + } + if (summary.variables.length > 0) { + outline += `Variables: ${summary.variables.join(", ")} +`; + } + return outline; +} + +// ../autocompletion/v2/capturesProcess/cpp.ts +async function extractSnippetsFromCapturesForCPP(captures, sourceCode, filePath, fileHash, snippetTypes, options) { + const logger = Logger.getDefaultLogger().with("[extractSnippetsFromCapturesForCPP]"); + const snippets = []; + const seenHashes = /* @__PURE__ */ new Set(); + if (snippetTypes.length === 0) { + logger.warn(`No snippet types provided, skipping`); + return snippets; + } + const containerCaptures = captures.filter( + (c) => c.name === "definition.class" || c.name === "definition.struct" || c.name === "definition.union" || c.name === "definition.enum" || c.name === "definition.template" + ).map((c) => ({ + node: c.node, + start: c.node.startIndex, + end: c.node.endIndex, + name: c.name, + nameCap: findNameCaptureForContainer3(c, captures, sourceCode) + })).filter((c) => c.nameCap); + if (snippetTypes.includes("import_or_include" /* ImportOrInclude */)) { + captures.forEach((capture) => { + if (capture.name === "definition.include") { + const node = capture.node; + const startLine = node.startPosition.row + 1; + const endLine = node.endPosition.row + 1; + const rangeText = sourceCode.substring(node.startIndex, node.endIndex); + const snippetHash = generateSnippetHash(filePath, startLine, endLine, rangeText); + if (!seenHashes.has(snippetHash)) { + seenHashes.add(snippetHash); + const scope = buildScopeChain(node); + const includeNameCapture = captures.find( + (c) => c.name === "name.definition.include" && c.node.startIndex >= node.startIndex && c.node.endIndex <= node.endIndex + ); + const includeName = includeNameCapture ? sourceCode.substring(includeNameCapture.node.startIndex, includeNameCapture.node.endIndex) : ""; + snippets.push({ + type: "import_or_include" /* ImportOrInclude */, + name: includeName, + rangeText, + startLine, + endLine, + filePath, + fileHash, + scope, + language: "cpp" /* CPP */ + }); + } + } + }); + } + if (snippetTypes.includes("function_or_method" /* FunctionOrMethod */)) { + const functionCaptures = captures.filter((c) => c.name === "definition.function"); + functionCaptures.forEach((capture) => { + const node = capture.node; + const startLine = node.startPosition.row + 1; + const endLine = node.endPosition.row + 1; + const rangeText = sourceCode.substring(node.startIndex, node.endIndex); + const snippetHash = generateSnippetHash(filePath, startLine, endLine, rangeText); + if (!seenHashes.has(snippetHash)) { + seenHashes.add(snippetHash); + const scope = buildScopeChain(node); + const functionNameCapture = captures.find( + (c) => c.name === "name.definition.function" && c.node.startIndex >= node.startIndex && c.node.endIndex <= node.endIndex + ); + const functionName = functionNameCapture ? sourceCode.substring(functionNameCapture.node.startIndex, functionNameCapture.node.endIndex) : ""; + const parametersCapture = captures.find( + (c) => c.name === "parameters.definition.function" && c.node.startIndex >= node.startIndex && c.node.endIndex <= node.endIndex + ); + const parameters = parametersCapture ? extractParametersFromNode2(parametersCapture.node, sourceCode) : []; + const bodyCapture = captures.find( + (c) => c.name === "body.definition.function" && c.node.startIndex >= node.startIndex && c.node.endIndex <= node.endIndex + ); + const hasBody = !!bodyCapture; + snippets.push({ + type: "function_or_method" /* FunctionOrMethod */, + name: functionName, + rangeText, + startLine, + endLine, + filePath, + fileHash, + scope, + language: "cpp" /* CPP */, + parameters, + definition: { + name: functionName, + type: "function", + parameters + } + }); + } + }); + } + if (snippetTypes.includes("function_or_method" /* FunctionOrMethod */)) { + const methodCaptures = captures.filter((c) => c.name === "definition.method"); + methodCaptures.forEach((capture) => { + const node = capture.node; + const startLine = node.startPosition.row + 1; + const endLine = node.endPosition.row + 1; + const rangeText = sourceCode.substring(node.startIndex, node.endIndex); + const snippetHash = generateSnippetHash(filePath, startLine, endLine, rangeText); + if (!seenHashes.has(snippetHash)) { + seenHashes.add(snippetHash); + const scope = buildScopeChain(node); + const methodNameCapture = captures.find( + (c) => c.name === "name.definition.method" && c.node.startIndex >= node.startIndex && c.node.endIndex <= node.endIndex + ); + const methodName = methodNameCapture ? sourceCode.substring(methodNameCapture.node.startIndex, methodNameCapture.node.endIndex) : ""; + const parametersCapture = captures.find( + (c) => c.name === "parameters.definition.method" && c.node.startIndex >= node.startIndex && c.node.endIndex <= node.endIndex + ); + const parameters = parametersCapture ? extractParametersFromNode2(parametersCapture.node, sourceCode) : []; + const bodyCapture = captures.find( + (c) => c.name === "body.definition.method" && c.node.startIndex >= node.startIndex && c.node.endIndex <= node.endIndex + ); + const hasBody = !!bodyCapture; + const parentContainer = findParentContainer(node, containerCaptures); + const field = parentContainer?.nameCap || void 0; + snippets.push({ + type: "function_or_method" /* FunctionOrMethod */, + name: methodName, + rangeText, + startLine, + endLine, + filePath, + fileHash, + scope, + language: "cpp" /* CPP */, + parameters, + field, + definition: { + name: methodName, + type: "method", + parameters + } + }); + } + }); + } + if (snippetTypes.includes("function_or_method" /* FunctionOrMethod */)) { + const constructorCaptures = captures.filter((c) => c.name === "definition.constructor"); + constructorCaptures.forEach((capture) => { + const node = capture.node; + const startLine = node.startPosition.row + 1; + const endLine = node.endPosition.row + 1; + const rangeText = sourceCode.substring(node.startIndex, node.endIndex); + const snippetHash = generateSnippetHash(filePath, startLine, endLine, rangeText); + if (!seenHashes.has(snippetHash)) { + seenHashes.add(snippetHash); + const scope = buildScopeChain(node); + const constructorNameCapture = captures.find( + (c) => c.name === "name.definition.constructor" && c.node.startIndex >= node.startIndex && c.node.endIndex <= node.endIndex + ); + const constructorName = constructorNameCapture ? sourceCode.substring(constructorNameCapture.node.startIndex, constructorNameCapture.node.endIndex) : ""; + const parametersCapture = captures.find( + (c) => c.name === "parameters.definition.constructor" && c.node.startIndex >= node.startIndex && c.node.endIndex <= node.endIndex + ); + const parameters = parametersCapture ? extractParametersFromNode2(parametersCapture.node, sourceCode) : []; + const parentContainer = findParentContainer(node, containerCaptures); + const field = parentContainer?.nameCap || void 0; + snippets.push({ + type: "function_or_method" /* FunctionOrMethod */, + name: constructorName, + rangeText, + startLine, + endLine, + filePath, + fileHash, + scope, + language: "cpp" /* CPP */, + parameters, + field, + definition: { + name: constructorName, + type: "constructor", + parameters + } + }); + } + }); + } + if (snippetTypes.includes("function_or_method" /* FunctionOrMethod */)) { + const destructorCaptures = captures.filter((c) => c.name === "definition.destructor"); + destructorCaptures.forEach((capture) => { + const node = capture.node; + const startLine = node.startPosition.row + 1; + const endLine = node.endPosition.row + 1; + const rangeText = sourceCode.substring(node.startIndex, node.endIndex); + const snippetHash = generateSnippetHash(filePath, startLine, endLine, rangeText); + if (!seenHashes.has(snippetHash)) { + seenHashes.add(snippetHash); + const scope = buildScopeChain(node); + const destructorNameCapture = captures.find( + (c) => c.name === "name.definition.destructor" && c.node.startIndex >= node.startIndex && c.node.endIndex <= node.endIndex + ); + const destructorName = destructorNameCapture ? sourceCode.substring(destructorNameCapture.node.startIndex, destructorNameCapture.node.endIndex) : ""; + const parentContainer = findParentContainer(node, containerCaptures); + const field = parentContainer?.nameCap || void 0; + snippets.push({ + type: "function_or_method" /* FunctionOrMethod */, + name: destructorName, + rangeText, + startLine, + endLine, + filePath, + fileHash, + scope, + language: "cpp" /* CPP */, + field, + definition: { + name: destructorName, + type: "destructor", + parameters: [] + } + }); + } + }); + } + if (snippetTypes.includes("function_or_method" /* FunctionOrMethod */)) { + const operatorCaptures = captures.filter((c) => c.name === "definition.operator"); + operatorCaptures.forEach((capture) => { + const node = capture.node; + const startLine = node.startPosition.row + 1; + const endLine = node.endPosition.row + 1; + const rangeText = sourceCode.substring(node.startIndex, node.endIndex); + const snippetHash = generateSnippetHash(filePath, startLine, endLine, rangeText); + if (!seenHashes.has(snippetHash)) { + seenHashes.add(snippetHash); + const scope = buildScopeChain(node); + const operatorNameCapture = captures.find( + (c) => c.name === "name.definition.operator" && c.node.startIndex >= node.startIndex && c.node.endIndex <= node.endIndex + ); + const operatorName = operatorNameCapture ? sourceCode.substring(operatorNameCapture.node.startIndex, operatorNameCapture.node.endIndex) : ""; + const parametersCapture = captures.find( + (c) => c.name === "parameters.definition.operator" && c.node.startIndex >= node.startIndex && c.node.endIndex <= node.endIndex + ); + const parameters = parametersCapture ? extractParametersFromNode2(parametersCapture.node, sourceCode) : []; + const parentContainer = findParentContainer(node, containerCaptures); + const field = parentContainer?.nameCap || void 0; + snippets.push({ + type: "function_or_method" /* FunctionOrMethod */, + name: operatorName, + rangeText, + startLine, + endLine, + filePath, + fileHash, + scope, + language: "cpp" /* CPP */, + parameters, + field, + definition: { + name: operatorName, + type: "operator", + parameters + } + }); + } + }); + } + if (snippetTypes.includes("class_or_interface_or_struct" /* ClassOrInterfaceOrStructOrEnum */)) { + const classCaptures = captures.filter((c) => c.name === "definition.class"); + const templateCaptures = captures.filter((c) => c.name === "definition.template"); + classCaptures.forEach((capture) => { + const node = capture.node; + const isWithinTemplate = templateCaptures.some((templateCapture) => { + return templateCapture.node.startIndex <= node.startIndex && node.endIndex <= templateCapture.node.endIndex; + }); + if (isWithinTemplate) { + return; + } + const startLine = node.startPosition.row + 1; + const endLine = node.endPosition.row + 1; + const rangeText = sourceCode.substring(node.startIndex, node.endIndex); + const snippetHash = generateSnippetHash(filePath, startLine, endLine, rangeText); + if (!seenHashes.has(snippetHash)) { + seenHashes.add(snippetHash); + const scope = buildScopeChain(node); + const classNameCapture = captures.find( + (c) => c.name === "name.definition.class" && c.node.startIndex >= node.startIndex && c.node.endIndex <= node.endIndex + ); + const className = classNameCapture ? sourceCode.substring(classNameCapture.node.startIndex, classNameCapture.node.endIndex) : ""; + const fields = extractFieldsFromContainerNode(node, sourceCode, captures); + snippets.push({ + type: "class_or_interface_or_struct" /* ClassOrInterfaceOrStructOrEnum */, + name: className, + rangeText, + startLine, + endLine, + filePath, + fileHash, + scope, + language: "cpp" /* CPP */, + definition: { + name: className, + type: "class" + } + }); + } + }); + } + if (snippetTypes.includes("class_or_interface_or_struct" /* ClassOrInterfaceOrStructOrEnum */)) { + const structCaptures = captures.filter((c) => c.name === "definition.struct"); + structCaptures.forEach((capture) => { + const node = capture.node; + const startLine = node.startPosition.row + 1; + const endLine = node.endPosition.row + 1; + const rangeText = sourceCode.substring(node.startIndex, node.endIndex); + const snippetHash = generateSnippetHash(filePath, startLine, endLine, rangeText); + if (!seenHashes.has(snippetHash)) { + seenHashes.add(snippetHash); + const scope = buildScopeChain(node); + const structNameCapture = captures.find( + (c) => c.name === "name.definition.struct" && c.node.startIndex >= node.startIndex && c.node.endIndex <= node.endIndex + ); + const structName = structNameCapture ? sourceCode.substring(structNameCapture.node.startIndex, structNameCapture.node.endIndex) : ""; + const fields = extractFieldsFromContainerNode(node, sourceCode, captures); + snippets.push({ + type: "class_or_interface_or_struct" /* ClassOrInterfaceOrStructOrEnum */, + name: structName, + rangeText, + startLine, + endLine, + filePath, + fileHash, + scope, + language: "cpp" /* CPP */, + definition: { + name: structName, + type: "struct" + } + }); + } + }); + } + if (snippetTypes.includes("class_or_interface_or_struct" /* ClassOrInterfaceOrStructOrEnum */)) { + const unionCaptures = captures.filter((c) => c.name === "definition.union"); + unionCaptures.forEach((capture) => { + const node = capture.node; + const startLine = node.startPosition.row + 1; + const endLine = node.endPosition.row + 1; + const rangeText = sourceCode.substring(node.startIndex, node.endIndex); + const snippetHash = generateSnippetHash(filePath, startLine, endLine, rangeText); + if (!seenHashes.has(snippetHash)) { + seenHashes.add(snippetHash); + const scope = buildScopeChain(node); + const unionNameCapture = captures.find( + (c) => c.name === "name.definition.union" && c.node.startIndex >= node.startIndex && c.node.endIndex <= node.endIndex + ); + const unionName = unionNameCapture ? sourceCode.substring(unionNameCapture.node.startIndex, unionNameCapture.node.endIndex) : ""; + const fields = extractFieldsFromContainerNode(node, sourceCode, captures); + snippets.push({ + type: "class_or_interface_or_struct" /* ClassOrInterfaceOrStructOrEnum */, + name: unionName, + rangeText, + startLine, + endLine, + filePath, + fileHash, + scope, + language: "cpp" /* CPP */, + definition: { + name: unionName, + type: "union" + } + }); + } + }); + } + if (snippetTypes.includes("class_or_interface_or_struct" /* ClassOrInterfaceOrStructOrEnum */)) { + const enumCaptures = captures.filter((c) => c.name === "definition.enum"); + enumCaptures.forEach((capture) => { + const node = capture.node; + const startLine = node.startPosition.row + 1; + const endLine = node.endPosition.row + 1; + const rangeText = sourceCode.substring(node.startIndex, node.endIndex); + const snippetHash = generateSnippetHash(filePath, startLine, endLine, rangeText); + if (!seenHashes.has(snippetHash)) { + seenHashes.add(snippetHash); + const scope = buildScopeChain(node); + const enumNameCapture = captures.find( + (c) => c.name === "name.definition.enum" && c.node.startIndex >= node.startIndex && c.node.endIndex <= node.endIndex + ); + const enumName = enumNameCapture ? sourceCode.substring(enumNameCapture.node.startIndex, enumNameCapture.node.endIndex) : ""; + const enumerators = extractEnumeratorsFromEnumNode2(node, sourceCode, captures); + snippets.push({ + type: "class_or_interface_or_struct" /* ClassOrInterfaceOrStructOrEnum */, + name: enumName, + rangeText, + startLine, + endLine, + filePath, + fileHash, + scope, + language: "cpp" /* CPP */, + definition: { + name: enumName, + type: "enum" + } + }); + } + }); + } + if (snippetTypes.includes("class_or_interface_or_struct" /* ClassOrInterfaceOrStructOrEnum */)) { + const templateCaptures = captures.filter((c) => c.name === "definition.template"); + templateCaptures.forEach((capture) => { + const node = capture.node; + const startLine = node.startPosition.row + 1; + const endLine = node.endPosition.row + 1; + const rangeText = sourceCode.substring(node.startIndex, node.endIndex); + const snippetHash = generateSnippetHash(filePath, startLine, endLine, rangeText); + if (!seenHashes.has(snippetHash)) { + seenHashes.add(snippetHash); + const scope = buildScopeChain(node); + const templateClassNameCapture = captures.find( + (c) => c.name === "name.definition.template.class" && c.node.startIndex >= node.startIndex && c.node.endIndex <= node.endIndex + ); + const templateStructNameCapture = captures.find( + (c) => c.name === "name.definition.template.struct" && c.node.startIndex >= node.startIndex && c.node.endIndex <= node.endIndex + ); + const templateFunctionNameCapture = captures.find( + (c) => c.name === "name.definition.template.function" && c.node.startIndex >= node.startIndex && c.node.endIndex <= node.endIndex + ); + let templateName = ""; + let templateType = "template"; + if (templateClassNameCapture) { + templateName = sourceCode.substring( + templateClassNameCapture.node.startIndex, + templateClassNameCapture.node.endIndex + ); + templateType = "template_class"; + } else if (templateStructNameCapture) { + templateName = sourceCode.substring( + templateStructNameCapture.node.startIndex, + templateStructNameCapture.node.endIndex + ); + templateType = "template_struct"; + } else if (templateFunctionNameCapture) { + templateName = sourceCode.substring( + templateFunctionNameCapture.node.startIndex, + templateFunctionNameCapture.node.endIndex + ); + templateType = "template_function"; + } + const parametersCapture = captures.find( + (c) => c.name === "parameters.definition.template" && c.node.startIndex >= node.startIndex && c.node.endIndex <= node.endIndex + ); + const templateParameters = parametersCapture ? extractTemplateParametersFromNode(parametersCapture.node, sourceCode) : []; + if (templateType === "template_function") { + if (snippetTypes.includes("function_or_method" /* FunctionOrMethod */)) { + const functionParametersCapture = captures.find( + (c) => c.name === "parameters.definition.template.function" && c.node.startIndex >= node.startIndex && c.node.endIndex <= node.endIndex + ); + const functionParameters = functionParametersCapture ? extractParametersFromNode2(functionParametersCapture.node, sourceCode) : []; + snippets.push({ + type: "function_or_method" /* FunctionOrMethod */, + name: templateName, + rangeText, + startLine, + endLine, + filePath, + fileHash, + scope, + language: "cpp" /* CPP */, + parameters: functionParameters, + definition: { + name: templateName, + type: templateType, + parameters: functionParameters + } + }); + } + } else { + snippets.push({ + type: "class_or_interface_or_struct" /* ClassOrInterfaceOrStructOrEnum */, + name: templateName, + rangeText, + startLine, + endLine, + filePath, + fileHash, + scope, + language: "cpp" /* CPP */, + definition: { + name: templateName, + type: templateType + } + }); + } + } + }); + } + if (snippetTypes.includes("class_or_interface_or_struct" /* ClassOrInterfaceOrStructOrEnum */)) { + const namespaceCaptures = captures.filter((c) => c.name === "definition.namespace"); + namespaceCaptures.forEach((capture) => { + const node = capture.node; + const startLine = node.startPosition.row + 1; + const endLine = node.endPosition.row + 1; + const rangeText = sourceCode.substring(node.startIndex, node.endIndex); + const snippetHash = generateSnippetHash(filePath, startLine, endLine, rangeText); + if (!seenHashes.has(snippetHash)) { + seenHashes.add(snippetHash); + const scope = buildScopeChain(node); + const namespaceNameCapture = captures.find( + (c) => c.name === "name.definition.namespace" && c.node.startIndex >= node.startIndex && c.node.endIndex <= node.endIndex + ); + const namespaceName = namespaceNameCapture ? sourceCode.substring(namespaceNameCapture.node.startIndex, namespaceNameCapture.node.endIndex) : ""; + snippets.push({ + type: "class_or_interface_or_struct" /* ClassOrInterfaceOrStructOrEnum */, + name: namespaceName, + rangeText, + startLine, + endLine, + filePath, + fileHash, + scope, + language: "cpp" /* CPP */, + definition: { + name: namespaceName, + type: "namespace" + } + }); + } + }); + } + if (snippetTypes.includes("class_or_interface_or_struct" /* ClassOrInterfaceOrStructOrEnum */)) { + const typedefCaptures = captures.filter((c) => c.name === "definition.typedef"); + typedefCaptures.forEach((capture) => { + const node = capture.node; + const startLine = node.startPosition.row + 1; + const endLine = node.endPosition.row + 1; + const rangeText = sourceCode.substring(node.startIndex, node.endIndex); + const snippetHash = generateSnippetHash(filePath, startLine, endLine, rangeText); + if (!seenHashes.has(snippetHash)) { + seenHashes.add(snippetHash); + const scope = buildScopeChain(node); + const typedefNameCapture = captures.find( + (c) => c.name === "name.definition.typedef" && c.node.startIndex >= node.startIndex && c.node.endIndex <= node.endIndex + ); + const typedefName = typedefNameCapture ? sourceCode.substring(typedefNameCapture.node.startIndex, typedefNameCapture.node.endIndex) : ""; + snippets.push({ + type: "class_or_interface_or_struct" /* ClassOrInterfaceOrStructOrEnum */, + name: typedefName, + rangeText, + startLine, + endLine, + filePath, + fileHash, + scope, + language: "cpp" /* CPP */, + definition: { + name: typedefName, + type: "typedef" + } + }); + } + }); + } + if (snippetTypes.includes("class_or_interface_or_struct" /* ClassOrInterfaceOrStructOrEnum */)) { + const usingCaptures = captures.filter((c) => c.name === "definition.using"); + usingCaptures.forEach((capture) => { + const node = capture.node; + const startLine = node.startPosition.row + 1; + const endLine = node.endPosition.row + 1; + const rangeText = sourceCode.substring(node.startIndex, node.endIndex); + const snippetHash = generateSnippetHash(filePath, startLine, endLine, rangeText); + if (!seenHashes.has(snippetHash)) { + seenHashes.add(snippetHash); + const scope = buildScopeChain(node); + const usingNameCapture = captures.find( + (c) => c.name === "name.definition.using" && c.node.startIndex >= node.startIndex && c.node.endIndex <= node.endIndex + ); + const usingName = usingNameCapture ? sourceCode.substring(usingNameCapture.node.startIndex, usingNameCapture.node.endIndex) : ""; + snippets.push({ + type: "class_or_interface_or_struct" /* ClassOrInterfaceOrStructOrEnum */, + name: usingName, + rangeText, + startLine, + endLine, + filePath, + fileHash, + scope, + language: "cpp" /* CPP */, + definition: { + name: usingName, + type: "using" + } + }); + } + }); + } + if (snippetTypes.includes("variable_or_constant" /* VariableOrConstant */)) { + const variableCaptures = captures.filter((c) => c.name === "definition.variable"); + variableCaptures.forEach((capture) => { + const node = capture.node; + const startLine = node.startPosition.row + 1; + const endLine = node.endPosition.row + 1; + const rangeText = sourceCode.substring(node.startIndex, node.endIndex); + const snippetHash = generateSnippetHash(filePath, startLine, endLine, rangeText); + if (!seenHashes.has(snippetHash)) { + seenHashes.add(snippetHash); + const scope = buildScopeChain(node); + const variableNameCapture = captures.find( + (c) => c.name === "name.definition.variable" && c.node.startIndex >= node.startIndex && c.node.endIndex <= node.endIndex + ); + const variableName = variableNameCapture ? sourceCode.substring(variableNameCapture.node.startIndex, variableNameCapture.node.endIndex) : ""; + snippets.push({ + type: "variable_or_constant" /* VariableOrConstant */, + name: variableName, + rangeText, + startLine, + endLine, + filePath, + fileHash, + scope, + language: "cpp" /* CPP */, + definition: { + name: variableName, + type: "variable" + } + }); + } + }); + } + logger.info(`Extracted ${snippets.length} C++ snippets`); + return snippets; +} +function extractParametersFromNode2(node, sourceCode) { + const parameters = []; + for (let i2 = 0; i2 < node.childCount; i2++) { + const child = node.child(i2); + if (child && child.type === "parameter_declaration") { + const parameterText = sourceCode.substring(child.startIndex, child.endIndex); + const parameterName = extractParameterName2(child, sourceCode); + parameters.push({ + name: parameterName, + type: parameterText + }); + } + } + return parameters; +} +function extractParameterName2(node, sourceCode) { + for (let i2 = 0; i2 < node.childCount; i2++) { + const child = node.child(i2); + if (child && child.type === "identifier") { + return sourceCode.substring(child.startIndex, child.endIndex); + } + } + return ""; +} +function extractTemplateParametersFromNode(node, sourceCode) { + const parameters = []; + for (let i2 = 0; i2 < node.childCount; i2++) { + const child = node.child(i2); + if (child && (child.type === "type_parameter_declaration" || child.type === "parameter_declaration")) { + const parameterText = sourceCode.substring(child.startIndex, child.endIndex); + const parameterName = extractTemplateParameterName(child, sourceCode); + parameters.push({ + name: parameterName, + type: parameterText + }); + } + } + return parameters; +} +function extractTemplateParameterName(node, sourceCode) { + for (let i2 = 0; i2 < node.childCount; i2++) { + const child = node.child(i2); + if (child && (child.type === "type_identifier" || child.type === "identifier")) { + return sourceCode.substring(child.startIndex, child.endIndex); + } + } + return ""; +} +function extractFieldsFromContainerNode(node, sourceCode, captures) { + const fields = []; + const fieldCaptures = captures.filter( + (c) => c.name === "name.definition.field" && c.node.startIndex >= node.startIndex && c.node.endIndex <= node.endIndex + ); + fieldCaptures.forEach((capture) => { + const fieldName = sourceCode.substring(capture.node.startIndex, capture.node.endIndex); + fields.push(fieldName); + }); + return fields; +} +function extractEnumeratorsFromEnumNode2(node, sourceCode, captures) { + const enumerators = []; + const enumeratorCaptures = captures.filter( + (c) => c.name === "name.definition.enumerator" && c.node.startIndex >= node.startIndex && c.node.endIndex <= node.endIndex + ); + enumeratorCaptures.forEach((capture) => { + const enumeratorName = sourceCode.substring(capture.node.startIndex, capture.node.endIndex); + enumerators.push(enumeratorName); + }); + return enumerators; +} +function findParentContainer(node, containerCaptures) { + for (const container of containerCaptures) { + if (container.start <= node.startIndex && node.endIndex <= container.end) { + return container; + } + } + return null; +} +function getNameCaptureNameForContainer2(containerCaptureName) { + switch (containerCaptureName) { + case "definition.class": + return "name.definition.class"; + case "definition.struct": + return "name.definition.struct"; + case "definition.union": + return "name.definition.union"; + case "definition.enum": + return "name.definition.enum"; + case "definition.template": + return "name.definition.template.class"; + // 默认查找类模板 + default: + return containerCaptureName; + } +} +function findNameCaptureForContainer3(containerCapture, captures, sourceCode) { + const node = containerCapture.node; + const nameCaptureName = getNameCaptureNameForContainer2(containerCapture.name); + if (containerCapture.name === "definition.template") { + const templateClassNameCapture = captures.find( + (c) => c.name === "name.definition.template.class" && c.node.startIndex >= node.startIndex && c.node.endIndex <= node.endIndex + ); + if (templateClassNameCapture) { + return sourceCode.substring( + templateClassNameCapture.node.startIndex, + templateClassNameCapture.node.endIndex + ); + } + const templateStructNameCapture = captures.find( + (c) => c.name === "name.definition.template.struct" && c.node.startIndex >= node.startIndex && c.node.endIndex <= node.endIndex + ); + if (templateStructNameCapture) { + return sourceCode.substring( + templateStructNameCapture.node.startIndex, + templateStructNameCapture.node.endIndex + ); + } + const templateFunctionNameCapture = captures.find( + (c) => c.name === "name.definition.template.function" && c.node.startIndex >= node.startIndex && c.node.endIndex <= node.endIndex + ); + if (templateFunctionNameCapture) { + return sourceCode.substring( + templateFunctionNameCapture.node.startIndex, + templateFunctionNameCapture.node.endIndex + ); + } + } + const nameCapture = captures.find( + (c) => c.name === nameCaptureName && c.node.startIndex >= node.startIndex && c.node.endIndex <= node.endIndex + ); + return nameCapture ? sourceCode.substring(nameCapture.node.startIndex, nameCapture.node.endIndex) : null; +} +function buildSummaryFromSnippets14(snippets) { + const summary = { + includes: [], + namespaces: [], + classes: [], + structs: [], + unions: [], + enums: [], + templates: [], + functions: [], + methods: [], + constructors: [], + destructors: [], + operators: [], + variables: [], + typedefs: [], + usings: [] + }; + snippets.forEach((snippet) => { + switch (snippet.type) { + case "import_or_include" /* ImportOrInclude */: + summary.includes.push(snippet.name); + break; + case "function_or_method" /* FunctionOrMethod */: + if (snippet.definition?.type === "function") { + summary.functions.push(snippet.name); + } else if (snippet.definition?.type === "method") { + summary.methods.push(snippet.name); + } else if (snippet.definition?.type === "constructor") { + summary.constructors.push(snippet.name); + } else if (snippet.definition?.type === "destructor") { + summary.destructors.push(snippet.name); + } else if (snippet.definition?.type === "operator") { + summary.operators.push(snippet.name); + } else if (snippet.definition?.type === "template_function") { + summary.functions.push(snippet.name); + } + break; + case "class_or_interface_or_struct" /* ClassOrInterfaceOrStructOrEnum */: + if (snippet.definition?.type === "class") { + summary.classes.push(snippet.name); + } else if (snippet.definition?.type === "struct") { + summary.structs.push(snippet.name); + } else if (snippet.definition?.type === "union") { + summary.unions.push(snippet.name); + } else if (snippet.definition?.type === "enum") { + summary.enums.push(snippet.name); + } else if (snippet.definition?.type === "template_class" || snippet.definition?.type === "template_struct") { + summary.templates.push(snippet.name); + } else if (snippet.definition?.type === "namespace") { + summary.namespaces.push(snippet.name); + } else if (snippet.definition?.type === "typedef") { + summary.typedefs.push(snippet.name); + } else if (snippet.definition?.type === "using") { + summary.usings.push(snippet.name); + } + break; + case "variable_or_constant" /* VariableOrConstant */: + summary.variables.push(snippet.name); + break; + } + }); + return summary; +} +function formatOutlineText14(summary) { + let outline = ""; + if (summary.includes.length > 0) { + outline += `Includes: ${summary.includes.join(", ")} +`; + } + if (summary.namespaces.length > 0) { + outline += `Namespaces: ${summary.namespaces.join(", ")} +`; + } + if (summary.classes.length > 0) { + outline += `Classes: ${summary.classes.join(", ")} +`; + } + if (summary.structs.length > 0) { + outline += `Structs: ${summary.structs.join(", ")} +`; + } + if (summary.unions.length > 0) { + outline += `Unions: ${summary.unions.join(", ")} +`; + } + if (summary.enums.length > 0) { + outline += `Enums: ${summary.enums.join(", ")} +`; + } + if (summary.templates.length > 0) { + outline += `Templates: ${summary.templates.join(", ")} +`; + } + if (summary.functions.length > 0) { + outline += `Functions: ${summary.functions.join(", ")} +`; + } + if (summary.methods.length > 0) { + outline += `Methods: ${summary.methods.join(", ")} +`; + } + if (summary.constructors.length > 0) { + outline += `Constructors: ${summary.constructors.join(", ")} +`; + } + if (summary.destructors.length > 0) { + outline += `Destructors: ${summary.destructors.join(", ")} +`; + } + if (summary.operators.length > 0) { + outline += `Operators: ${summary.operators.join(", ")} +`; + } + if (summary.variables.length > 0) { + outline += `Variables: ${summary.variables.join(", ")} +`; + } + if (summary.typedefs.length > 0) { + outline += `Typedefs: ${summary.typedefs.join(", ")} +`; + } + if (summary.usings.length > 0) { + outline += `Usings: ${summary.usings.join(", ")} +`; + } + return outline; +} + +// ../autocompletion/v2/capturesProcess/index.ts +var extractSnippetsFromCaptures = { + ["go" /* Go */]: extractSnippetsFromCapturesForGo, + ["python" /* Python */]: extractSnippetsFromCapturesForPython, + ["java" /* Java */]: extractSnippetsFromCapturesForJava, + ["javascript" /* JavaScript */]: extractSnippetsFromCapturesForJavaScript, + ["jsx" /* JSX */]: extractSnippetsFromCapturesForJSX, + ["typescript" /* TypeScript */]: extractSnippetsFromCapturesForTypeScript, + ["tsx" /* TSX */]: extractSnippetsFromCapturesForTSX, + ["swift" /* Swift */]: extractSnippetsFromCapturesForSwift, + ["css" /* CSS */]: extractSnippetsFromCapturesForCSS, + ["html" /* HTML */]: extractSnippetsFromCapturesForHTML, + ["kotlin" /* Kotlin */]: extractSnippetsFromCapturesForKotlin, + ["php" /* PHP */]: extractSnippetsFromCapturesForPHP, + ["rust" /* Rust */]: extractSnippetsFromCapturesForRust, + ["c" /* C */]: extractSnippetsFromCapturesForC, + ["cpp" /* CPP */]: extractSnippetsFromCapturesForCPP, + ["unknown" /* Unknown */]: extractSnippetsFromCapturesForGeneral +}; +var generateOverViewFromSnippets = { + ["go" /* Go */]: (snippets) => { + return formatOutlineText(buildSummaryFromSnippets(snippets)); + }, + ["python" /* Python */]: (snippets) => { + return formatOutlineText2(buildSummaryFromSnippets2(snippets)); + }, + ["java" /* Java */]: (snippets) => { + return formatOutlineText3(buildSummaryFromSnippets3(snippets)); + }, + ["javascript" /* JavaScript */]: (snippets) => { + return ""; + }, + ["jsx" /* JSX */]: (snippets) => { + return formatOutlineText4(buildSummaryFromSnippets4(snippets)); + }, + ["typescript" /* TypeScript */]: (snippets) => { + return formatOutlineText5(buildSummaryFromSnippets5(snippets)); + }, + ["tsx" /* TSX */]: (snippets) => { + return formatOutlineText6(buildSummaryFromSnippets6(snippets)); + }, + ["swift" /* Swift */]: (snippets) => { + return formatOutlineText7(buildSummaryFromSnippets7(snippets)); + }, + ["css" /* CSS */]: (snippets) => { + return formatOutlineText8(buildSummaryFromSnippets8(snippets)); + }, + ["html" /* HTML */]: (snippets) => { + return formatOutlineText9(buildSummaryFromSnippets9(snippets)); + }, + ["kotlin" /* Kotlin */]: (snippets) => { + return formatOutlineText10(buildSummaryFromSnippets10(snippets)); + }, + ["php" /* PHP */]: (snippets) => { + return formatOutlineText11(buildSummaryFromSnippets11(snippets)); + }, + ["rust" /* Rust */]: (snippets) => { + return formatOutlineText12(buildSummaryFromSnippets12(snippets)); + }, + ["c" /* C */]: (snippets) => { + return formatOutlineText13(buildSummaryFromSnippets13(snippets)); + }, + ["cpp" /* CPP */]: (snippets) => { + return formatOutlineText14(buildSummaryFromSnippets14(snippets)); + }, + ["unknown" /* Unknown */]: (snippets) => { + return ""; + } +}; + +// ../autocompletion/v2/dependenciesProcess/queries/go.ts +var go_default2 = `(call_expression + function: (identifier) @function.call.direct) + +(call_expression + function: (selector_expression + operand: (identifier) @method.call.receiver + field: (field_identifier) @method.call.name))`; + +// ../autocompletion/v2/dependenciesProcess/queries/typescript.ts +var typescript_default2 = ` +; \u76F4\u63A5\u51FD\u6570\u8C03\u7528 - function() +(call_expression + function: (identifier) @function.call.direct) + +; \u65B9\u6CD5\u8C03\u7528 - object.method() +(call_expression + function: (member_expression + object: (identifier) @method.call.receiver + property: (property_identifier) @method.call.name) + (#not-match? @method.call.receiver "^[A-Z]")) + +; \u94FE\u5F0F\u65B9\u6CD5\u8C03\u7528 - object.method1().method2() +(call_expression + function: (member_expression + object: (call_expression) + property: (property_identifier) @method.call.chain)) + +; \u9759\u6001\u65B9\u6CD5\u8C03\u7528 - Class.staticMethod() (\u9996\u5B57\u6BCD\u5927\u5199\u7684\u6807\u8BC6\u7B26) +(call_expression + function: (member_expression + object: (identifier) @static.call.class + property: (property_identifier) @static.call.method) + (#match? @static.call.class "^[A-Z]")) + +; \u547D\u540D\u7A7A\u95F4/\u6A21\u5757\u8C03\u7528 - namespace.function() +(call_expression + function: (member_expression + object: (identifier) @namespace.call.name + property: (property_identifier) @namespace.call.function) + (#match? @namespace.call.name "^[A-Z]") + (#not-match? @namespace.call.function "^(constructor|new|create|get|set|add|remove|update|delete)$")) + +; \u5D4C\u5957\u5C5E\u6027\u8C03\u7528 - object.nested.method() +(call_expression + function: (member_expression + object: (member_expression + object: (identifier) @nested.call.root + property: (property_identifier) @nested.call.intermediate) + property: (property_identifier) @nested.call.method)) + +; this \u65B9\u6CD5\u8C03\u7528 - this.method() +(call_expression + function: (member_expression + object: (this) @this.call.receiver + property: (property_identifier) @this.call.method)) + +; super \u65B9\u6CD5\u8C03\u7528 - super.method() +(call_expression + function: (member_expression + object: (super) @super.call.receiver + property: (property_identifier) @super.call.method)) + +; \u7BAD\u5934\u51FD\u6570\u8C03\u7528 - (() => {})() +(call_expression + function: (arrow_function) @arrow.call.function) + +; \u51FD\u6570\u8868\u8FBE\u5F0F\u8C03\u7528 - (function() {})() +(call_expression + function: (function_expression) @function.call.expression) + +; \u6570\u7EC4\u65B9\u6CD5\u8C03\u7528 - array.map(), array.filter() +(call_expression + function: (member_expression + object: (identifier) @array.call.object + property: (property_identifier) @array.call.method) + (#match? @array.call.method "^(map|filter|reduce|forEach|find|some|every|sort|push|pop|shift|unshift|slice|splice|concat|join|indexOf|includes)$")) + +; Promise \u65B9\u6CD5\u8C03\u7528 - promise.then(), promise.catch() (\u660E\u786E\u7684Promise\u65B9\u6CD5) +(call_expression + function: (member_expression + object: (identifier) @promise.call.object + property: (property_identifier) @promise.call.method) + (#match? @promise.call.method "^(then|catch|finally)$")) + +; \u53EF\u9009\u94FE\u8C03\u7528 - object?.method?.() +(call_expression + function: (member_expression + object: (identifier) @optional.call.receiver + property: (property_identifier) @optional.call.method)) + +; \u6784\u9020\u51FD\u6570\u8C03\u7528 - new Constructor() +(new_expression + constructor: (identifier) @constructor.call.name) + +; \u6CDB\u578B\u51FD\u6570\u8C03\u7528 - genericFunction() +(call_expression + function: (identifier) @generic.call.function + type_arguments: (type_arguments)) + +; \u6A21\u677F\u5B57\u7B26\u4E32\u4E2D\u7684\u8868\u8FBE\u5F0F\u8C03\u7528 +(template_substitution + (call_expression + function: (identifier) @template.call.function)) + +; await \u8868\u8FBE\u5F0F\u4E2D\u7684\u51FD\u6570\u8C03\u7528 +(await_expression + (call_expression + function: (identifier) @await.call.function)) + +; \u5F02\u6B65\u65B9\u6CD5\u8C03\u7528 +(await_expression + (call_expression + function: (member_expression + object: (identifier) @async.call.receiver + property: (property_identifier) @async.call.method))) +`; + +// ../autocompletion/v2/dependenciesProcess/queries/javascript.ts +var javascript_default2 = ` +; \u76F4\u63A5\u51FD\u6570\u8C03\u7528 - function() +(call_expression + function: (identifier) @function.call.direct) + +; \u65B9\u6CD5\u8C03\u7528 - object.method() +(call_expression + function: (member_expression + object: (identifier) @method.call.receiver + property: (property_identifier) @method.call.name) + (#not-match? @method.call.receiver "^[A-Z]")) + +; \u94FE\u5F0F\u65B9\u6CD5\u8C03\u7528 - object.method1().method2() +(call_expression + function: (member_expression + object: (call_expression) + property: (property_identifier) @method.call.chain)) + +; \u9759\u6001\u65B9\u6CD5\u8C03\u7528 - Class.staticMethod() (\u9996\u5B57\u6BCD\u5927\u5199\u7684\u6807\u8BC6\u7B26) +(call_expression + function: (member_expression + object: (identifier) @static.call.class + property: (property_identifier) @static.call.method) + (#match? @static.call.class "^[A-Z]")) + +; \u547D\u540D\u7A7A\u95F4/\u6A21\u5757\u8C03\u7528 - namespace.function() +(call_expression + function: (member_expression + object: (identifier) @namespace.call.name + property: (property_identifier) @namespace.call.function) + (#match? @namespace.call.name "^[A-Z]") + (#not-match? @namespace.call.function "^(constructor|new|create|get|set|add|remove|update|delete)$")) + +; \u5D4C\u5957\u5C5E\u6027\u8C03\u7528 - object.nested.method() +(call_expression + function: (member_expression + object: (member_expression + object: (identifier) @nested.call.root + property: (property_identifier) @nested.call.intermediate) + property: (property_identifier) @nested.call.method)) + +; this \u65B9\u6CD5\u8C03\u7528 - this.method() +(call_expression + function: (member_expression + object: (this) @this.call.receiver + property: (property_identifier) @this.call.method)) + +; super \u65B9\u6CD5\u8C03\u7528 - super.method() +(call_expression + function: (member_expression + object: (super) @super.call.receiver + property: (property_identifier) @super.call.method)) + +; \u7BAD\u5934\u51FD\u6570\u8C03\u7528 - (() => {})() +(call_expression + function: (arrow_function) @arrow.call.function) + +; \u51FD\u6570\u8868\u8FBE\u5F0F\u8C03\u7528 - (function() {})() +(call_expression + function: (function_expression) @function.call.expression) + +; \u6570\u7EC4\u65B9\u6CD5\u8C03\u7528 - array.map(), array.filter() +(call_expression + function: (member_expression + object: (identifier) @array.call.object + property: (property_identifier) @array.call.method) + (#match? @array.call.method "^(map|filter|reduce|forEach|find|some|every|sort|push|pop|shift|unshift|slice|splice|concat|join|indexOf|includes)$")) + +; Promise \u65B9\u6CD5\u8C03\u7528 - promise.then(), promise.catch() (\u660E\u786E\u7684Promise\u65B9\u6CD5) +(call_expression + function: (member_expression + object: (identifier) @promise.call.object + property: (property_identifier) @promise.call.method) + (#match? @promise.call.method "^(then|catch|finally)$")) + +; \u53EF\u9009\u94FE\u8C03\u7528 - object?.method?.() +(call_expression + function: (member_expression + object: (identifier) @optional.call.receiver + property: (property_identifier) @optional.call.method)) + +; \u6784\u9020\u51FD\u6570\u8C03\u7528 - new Constructor() +(new_expression + constructor: (identifier) @constructor.call.name) + +; \u6A21\u677F\u5B57\u7B26\u4E32\u4E2D\u7684\u8868\u8FBE\u5F0F\u8C03\u7528 +(template_substitution + (call_expression + function: (identifier) @template.call.function)) + +; await \u8868\u8FBE\u5F0F\u4E2D\u7684\u51FD\u6570\u8C03\u7528 +(await_expression + (call_expression + function: (identifier) @await.call.function)) + +; \u5F02\u6B65\u65B9\u6CD5\u8C03\u7528 +(await_expression + (call_expression + function: (member_expression + object: (identifier) @async.call.receiver + property: (property_identifier) @async.call.method))) +`; + +// ../autocompletion/v2/dependenciesProcess/queries/java.ts +var java_default2 = ` +; \u76F4\u63A5\u65B9\u6CD5\u8C03\u7528 - method() +(method_invocation + name: (identifier) @method.call.direct) + +; \u5BF9\u8C61\u65B9\u6CD5\u8C03\u7528 - object.method() +(method_invocation + object: (identifier) @method.call.receiver + name: (identifier) @method.call.name) + +; \u94FE\u5F0F\u65B9\u6CD5\u8C03\u7528 - object.method1().method2() +(method_invocation + object: (method_invocation) + name: (identifier) @method.call.chain) + +; \u9759\u6001\u65B9\u6CD5\u8C03\u7528 - Class.staticMethod() +(method_invocation + object: (identifier) @static.call.class + name: (identifier) @static.call.method + (#match? @static.call.class "^[A-Z]")) + +; this \u65B9\u6CD5\u8C03\u7528 - this.method() +(method_invocation + object: (this) @this.call.receiver + name: (identifier) @this.call.method) + +; super \u65B9\u6CD5\u8C03\u7528 - super.method() +(method_invocation + object: (super) @super.call.receiver + name: (identifier) @super.call.method) + +; \u6784\u9020\u51FD\u6570\u8C03\u7528 - new Constructor() +(object_creation_expression + type: (type_identifier) @constructor.call.name) +`; + +// ../autocompletion/v2/dependenciesProcess/queries/python.ts +var python_default2 = ` +; \u76F4\u63A5\u51FD\u6570\u8C03\u7528 - function() +(call + function: (identifier) @function.call.direct) + +; \u65B9\u6CD5\u8C03\u7528 - object.method() +(call + function: (attribute + object: (identifier) @method.call.receiver + attribute: (identifier) @method.call.name)) + +; \u7C7B\u65B9\u6CD5\u8C03\u7528 - ClassName.method() (\u9996\u5B57\u6BCD\u5927\u5199) +(call + function: (attribute + object: (identifier) @class.call.name + attribute: (identifier) @class.call.method) + (#match? @class.call.name "^[A-Z]")) + +; \u94FE\u5F0F\u65B9\u6CD5\u8C03\u7528 - obj.method1().method2() +(call + function: (attribute + object: (call) + attribute: (identifier) @method.call.chain)) + +; self\u65B9\u6CD5\u8C03\u7528 - self.method() +(call + function: (attribute + object: (identifier) @self.call.receiver + attribute: (identifier) @self.call.method) + (#eq? @self.call.receiver "self")) + +; super\u65B9\u6CD5\u8C03\u7528 - super().method() +(call + function: (attribute + object: (call + function: (identifier) @super.call.function) + attribute: (identifier) @super.call.method) + (#eq? @super.call.function "super")) + +; \u5F02\u6B65\u51FD\u6570\u8C03\u7528 - await function() +(await + (call + function: (identifier) @async.call.function)) + +; \u5F02\u6B65\u65B9\u6CD5\u8C03\u7528 - await obj.method() +(await + (call + function: (attribute + object: (identifier) @async.call.receiver + attribute: (identifier) @async.call.method))) + +; \u88C5\u9970\u5668\u51FD\u6570\u8C03\u7528 - @decorator +(decorator + (identifier) @decorator.call.function) + +; \u88C5\u9970\u5668\u65B9\u6CD5\u8C03\u7528 - @obj.decorator +(decorator + (attribute + object: (identifier) @decorator.call.receiver + attribute: (identifier) @decorator.call.method)) + +; \u5217\u8868\u63A8\u5BFC\u5F0F\u4E2D\u7684\u51FD\u6570\u8C03\u7528 +(list_comprehension + (call + function: (identifier) @comprehension.call.function)) + +; \u5217\u8868\u63A8\u5BFC\u5F0F\u4E2D\u7684\u65B9\u6CD5\u8C03\u7528 +(list_comprehension + (call + function: (attribute + object: (identifier) @comprehension.call.receiver + attribute: (identifier) @comprehension.call.method))) + +; \u751F\u6210\u5668\u8868\u8FBE\u5F0F\u4E2D\u7684\u51FD\u6570\u8C03\u7528 +(generator_expression + (call + function: (identifier) @generator.call.function)) + +; \u751F\u6210\u5668\u8868\u8FBE\u5F0F\u4E2D\u7684\u65B9\u6CD5\u8C03\u7528 +(generator_expression + (call + function: (attribute + object: (identifier) @generator.call.receiver + attribute: (identifier) @generator.call.method))) + +; Lambda \u8868\u8FBE\u5F0F\u4E2D\u7684\u51FD\u6570\u8C03\u7528 +(lambda + (call + function: (identifier) @lambda.call.function)) + +; Lambda \u8868\u8FBE\u5F0F\u4E2D\u7684\u65B9\u6CD5\u8C03\u7528 +(lambda + (call + function: (attribute + object: (identifier) @lambda.call.receiver + attribute: (identifier) @lambda.call.method))) + +; \u5D4C\u5957\u5C5E\u6027\u8C03\u7528 - obj.attr.method() +(call + function: (attribute + object: (attribute + object: (identifier) @nested.call.root + attribute: (identifier) @nested.call.intermediate) + attribute: (identifier) @nested.call.method)) + +; \u51FD\u6570\u4F5C\u4E3A\u53C2\u6570\u7684\u8C03\u7528 - func(other_func) +(call + function: (identifier) @function.call.direct + arguments: (argument_list + (identifier) @function.call.argument)) + +; \u65B9\u6CD5\u4F5C\u4E3A\u53C2\u6570\u7684\u8C03\u7528 - func(obj.method) +(call + function: (identifier) @function.call.direct + arguments: (argument_list + (attribute + object: (identifier) @method.call.receiver + attribute: (identifier) @method.call.name))) +`; + +// ../autocompletion/v2/dependenciesProcess/queries/jsx.ts +var jsx_default2 = ` +; === React\u7279\u5B9A\u67E5\u8BE2\uFF08\u4F18\u5148\u7EA7\u6700\u9AD8\uFF09=== + +; \u9AD8\u9636\u7EC4\u4EF6 HOC \u8C03\u7528 - withRouter(Component), memo(Component) - \u5FC5\u987B\u5728\u76F4\u63A5\u51FD\u6570\u8C03\u7528\u4E4B\u524D +(call_expression + function: (identifier) @hoc.call.name + arguments: (arguments + (identifier) @hoc.call.component) + (#match? @hoc.call.name "^(with[A-Z]|connect|memo|forwardRef)")) + +; React.createElement \u8C03\u7528 - \u5FC5\u987B\u5728\u5176\u4ED6\u65B9\u6CD5\u8C03\u7528\u4E4B\u524D +(call_expression + function: (member_expression + object: (identifier) @react.create.namespace + property: (property_identifier) @react.create.method) + (#eq? @react.create.namespace "React") + (#eq? @react.create.method "createElement")) + +; State \u76F8\u5173 hooks - useState, useReducer +(call_expression + function: (identifier) @state.hook.call + (#match? @state.hook.call "^(useState|useReducer)$")) + +; Effect \u76F8\u5173 hooks - useEffect, useLayoutEffect +(call_expression + function: (identifier) @effect.hook.call + (#match? @effect.hook.call "^(useEffect|useLayoutEffect|useInsertionEffect)$")) + +; Memo \u76F8\u5173 hooks - useMemo, useCallback +(call_expression + function: (identifier) @memo.hook.call + (#match? @memo.hook.call "^(useMemo|useCallback)$")) + +; Ref \u8C03\u7528 - useRef, createRef +(call_expression + function: (identifier) @ref.hook.call + (#match? @ref.hook.call "^(useRef|createRef)$")) + +; Context \u8C03\u7528 - useContext(ThemeContext) +(call_expression + function: (identifier) @context.hook.call + (#eq? @context.hook.call "useContext")) + +; \u5176\u4ED6 React Hooks \u8C03\u7528 - \u4E0D\u5728\u4E0A\u8FF0\u7279\u5B9A\u5206\u7C7B\u4E2D\u7684hooks +(call_expression + function: (identifier) @react.hook.call + (#match? @react.hook.call "^use[A-Z]") + (#not-match? @react.hook.call "^(useState|useReducer|useEffect|useLayoutEffect|useInsertionEffect|useMemo|useCallback|useRef|createRef|useContext)$")) + +; Event handlers \u5728\u8C03\u7528\u8868\u8FBE\u5F0F\u4E2D - handleClick() +(call_expression + function: (identifier) @event.handler.function + (#match? @event.handler.function "^handle[A-Z]")) + +; === \u5F02\u6B65\u8C03\u7528\uFF08\u4F18\u5148\u7EA7\u8F83\u9AD8\uFF09=== + +; await \u8868\u8FBE\u5F0F\u4E2D\u7684\u51FD\u6570\u8C03\u7528 +(await_expression + (call_expression + function: (identifier) @await.call.function)) + +; \u5F02\u6B65\u65B9\u6CD5\u8C03\u7528 +(await_expression + (call_expression + function: (member_expression + object: (identifier) @async.call.receiver + property: (property_identifier) @async.call.method))) + +; === \u7279\u5B9A\u65B9\u6CD5\u8C03\u7528\uFF08\u4F18\u5148\u7EA7\u9AD8\u4E8E\u901A\u7528\u65B9\u6CD5\u8C03\u7528\uFF09=== + +; Promise \u65B9\u6CD5\u8C03\u7528 - promise.then(), promise.catch() +(call_expression + function: (member_expression + object: (identifier) @promise.call.object + property: (property_identifier) @promise.call.method) + (#match? @promise.call.method "^(then|catch|finally)$")) + +; \u6570\u7EC4\u65B9\u6CD5\u8C03\u7528 - array.map(), array.filter() +(call_expression + function: (member_expression + object: (identifier) @array.call.object + property: (property_identifier) @array.call.method) + (#match? @array.call.method "^(map|filter|reduce|forEach|find|some|every|sort|push|pop|shift|unshift|slice|splice|concat|join|indexOf|includes)$")) + +; === \u6784\u9020\u51FD\u6570\u548C\u7C7B\u8C03\u7528 === + +; \u6784\u9020\u51FD\u6570\u8C03\u7528 - new Constructor() +(new_expression + constructor: (identifier) @constructor.call.name) + +; \u9759\u6001\u65B9\u6CD5\u8C03\u7528 - Class.staticMethod() (\u9996\u5B57\u6BCD\u5927\u5199\u7684\u6807\u8BC6\u7B26) +(call_expression + function: (member_expression + object: (identifier) @static.call.class + property: (property_identifier) @static.call.method) + (#match? @static.call.class "^[A-Z]")) + +; === \u5BF9\u8C61\u65B9\u6CD5\u8C03\u7528 === + +; this \u65B9\u6CD5\u8C03\u7528 - this.method() +(call_expression + function: (member_expression + object: (this) @this.call.receiver + property: (property_identifier) @this.call.method)) + +; super \u65B9\u6CD5\u8C03\u7528 - super.method() +(call_expression + function: (member_expression + object: (super) @super.call.receiver + property: (property_identifier) @super.call.method)) + +; \u53EF\u9009\u94FE\u8C03\u7528 - object?.method?.() +(call_expression + function: (member_expression + object: (identifier) @optional.call.receiver + property: (property_identifier) @optional.call.method)) + +; \u94FE\u5F0F\u65B9\u6CD5\u8C03\u7528 - object.method1().method2() +(call_expression + function: (member_expression + object: (call_expression) + property: (property_identifier) @method.call.chain)) + +; \u5D4C\u5957\u5C5E\u6027\u8C03\u7528 - object.nested.method() +(call_expression + function: (member_expression + object: (member_expression + object: (identifier) @nested.call.root + property: (property_identifier) @nested.call.intermediate) + property: (property_identifier) @nested.call.method)) + +; \u65B9\u6CD5\u8C03\u7528 - object.method() +(call_expression + function: (member_expression + object: (identifier) @method.call.receiver + property: (property_identifier) @method.call.name) + (#not-match? @method.call.receiver "^[A-Z]")) + +; === \u547D\u540D\u7A7A\u95F4\u8C03\u7528 === + +; \u547D\u540D\u7A7A\u95F4/\u6A21\u5757\u8C03\u7528 - namespace.function() +(call_expression + function: (member_expression + object: (identifier) @namespace.call.name + property: (property_identifier) @namespace.call.function) + (#match? @namespace.call.name "^[A-Z]") + (#not-match? @namespace.call.function "^(constructor|new|create|get|set|add|remove|update|delete)$")) + +; === \u7279\u6B8A\u51FD\u6570\u8C03\u7528 === + +; \u7BAD\u5934\u51FD\u6570\u8C03\u7528 - (() => {})() +(call_expression + function: (arrow_function) @arrow.call.function) + +; \u51FD\u6570\u8868\u8FBE\u5F0F\u8C03\u7528 - (function() {})() +(call_expression + function: (function_expression) @function.call.expression) + +; \u6A21\u677F\u5B57\u7B26\u4E32\u4E2D\u7684\u8868\u8FBE\u5F0F\u8C03\u7528 +(template_substitution + (call_expression + function: (identifier) @template.call.function)) + +; === \u901A\u7528\u76F4\u63A5\u51FD\u6570\u8C03\u7528\uFF08\u4F18\u5148\u7EA7\u6700\u4F4E\uFF09=== + +; \u76F4\u63A5\u51FD\u6570\u8C03\u7528 - function() +(call_expression + function: (identifier) @function.call.direct) +`; + +// ../autocompletion/v2/dependenciesProcess/queries/tsx.ts +var tsx_default2 = ` +; === React\u7279\u5B9A\u67E5\u8BE2\uFF08\u4F18\u5148\u7EA7\u6700\u9AD8\uFF09=== + +; \u9AD8\u9636\u7EC4\u4EF6 HOC \u8C03\u7528 - withRouter(Component), memo(Component) - \u5FC5\u987B\u5728\u76F4\u63A5\u51FD\u6570\u8C03\u7528\u4E4B\u524D +(call_expression + function: (identifier) @hoc.call.name + arguments: (arguments + (identifier) @hoc.call.component) + (#match? @hoc.call.name "^(with[A-Z]|connect|memo|forwardRef)")) + +; React.createElement \u8C03\u7528 - \u5FC5\u987B\u5728\u5176\u4ED6\u65B9\u6CD5\u8C03\u7528\u4E4B\u524D +(call_expression + function: (member_expression + object: (identifier) @react.create.namespace + property: (property_identifier) @react.create.method) + (#eq? @react.create.namespace "React") + (#eq? @react.create.method "createElement")) + +; State \u76F8\u5173 hooks - useState, useReducer +(call_expression + function: (identifier) @state.hook.call + (#match? @state.hook.call "^(useState|useReducer)$")) + +; Effect \u76F8\u5173 hooks - useEffect, useLayoutEffect +(call_expression + function: (identifier) @effect.hook.call + (#match? @effect.hook.call "^(useEffect|useLayoutEffect|useInsertionEffect)$")) + +; Memo \u76F8\u5173 hooks - useMemo, useCallback +(call_expression + function: (identifier) @memo.hook.call + (#match? @memo.hook.call "^(useMemo|useCallback)$")) + +; Ref \u8C03\u7528 - useRef, createRef +(call_expression + function: (identifier) @ref.hook.call + (#match? @ref.hook.call "^(useRef|createRef)$")) + +; Context \u8C03\u7528 - useContext(ThemeContext) +(call_expression + function: (identifier) @context.hook.call + (#eq? @context.hook.call "useContext")) + +; \u5176\u4ED6 React Hooks \u8C03\u7528 - \u4E0D\u5728\u4E0A\u8FF0\u7279\u5B9A\u5206\u7C7B\u4E2D\u7684hooks +(call_expression + function: (identifier) @react.hook.call + (#match? @react.hook.call "^use[A-Z]") + (#not-match? @react.hook.call "^(useState|useReducer|useEffect|useLayoutEffect|useInsertionEffect|useMemo|useCallback|useRef|createRef|useContext)$")) + +; Event handlers \u5728\u8C03\u7528\u8868\u8FBE\u5F0F\u4E2D - handleClick() +(call_expression + function: (identifier) @event.handler.function + (#match? @event.handler.function "^handle[A-Z]")) + +; === TypeScript\u7279\u5B9A\u67E5\u8BE2 === + +; \u6CDB\u578B\u51FD\u6570\u8C03\u7528 - function() +(call_expression + function: (identifier) @generic.call.function + type_arguments: (type_arguments)) + +; \u6CDB\u578B\u65B9\u6CD5\u8C03\u7528 - object.method() +(call_expression + function: (member_expression + object: (identifier) @generic.call.receiver + property: (property_identifier) @generic.call.method) + type_arguments: (type_arguments)) + +; \u6CDB\u578BPromise\u65B9\u6CD5\u8C03\u7528 - promise.then() +(call_expression + function: (member_expression + object: (identifier) @promise.call.object + property: (property_identifier) @promise.call.method) + type_arguments: (type_arguments) + (#match? @promise.call.method "^(then|catch|finally)$")) + +; \u7C7B\u578B\u65AD\u8A00\u8C03\u7528 - as Type +(as_expression) @type.assertion + +; === \u5F02\u6B65\u8C03\u7528\uFF08\u4F18\u5148\u7EA7\u8F83\u9AD8\uFF09=== + +; await \u8868\u8FBE\u5F0F\u4E2D\u7684\u51FD\u6570\u8C03\u7528 +(await_expression + (call_expression + function: (identifier) @await.call.function)) + +; \u5F02\u6B65\u65B9\u6CD5\u8C03\u7528 +(await_expression + (call_expression + function: (member_expression + object: (identifier) @async.call.receiver + property: (property_identifier) @async.call.method))) + +; === \u7279\u5B9A\u65B9\u6CD5\u8C03\u7528\uFF08\u4F18\u5148\u7EA7\u9AD8\u4E8E\u901A\u7528\u65B9\u6CD5\u8C03\u7528\uFF09=== + +; Promise \u65B9\u6CD5\u8C03\u7528 - promise.then(), promise.catch() +(call_expression + function: (member_expression + object: (identifier) @promise.call.object + property: (property_identifier) @promise.call.method) + (#match? @promise.call.method "^(then|catch|finally)$")) + +; \u6570\u7EC4\u65B9\u6CD5\u8C03\u7528 - array.map(), array.filter() +(call_expression + function: (member_expression + object: (identifier) @array.call.object + property: (property_identifier) @array.call.method) + (#match? @array.call.method "^(map|filter|reduce|forEach|find|some|every|sort|push|pop|shift|unshift|slice|splice|concat|join|indexOf|includes)$")) + +; === \u6784\u9020\u51FD\u6570\u548C\u7C7B\u8C03\u7528 === + +; \u6784\u9020\u51FD\u6570\u8C03\u7528 - new Constructor() +(new_expression + constructor: (identifier) @constructor.call.name) + +; \u6CDB\u578B\u6784\u9020\u51FD\u6570\u8C03\u7528 - new Constructor() +(new_expression + constructor: (identifier) @generic.constructor.call.name + type_arguments: (type_arguments)) + +; \u9759\u6001\u65B9\u6CD5\u8C03\u7528 - Class.staticMethod() (\u9996\u5B57\u6BCD\u5927\u5199\u7684\u6807\u8BC6\u7B26) +(call_expression + function: (member_expression + object: (identifier) @static.call.class + property: (property_identifier) @static.call.method) + (#match? @static.call.class "^[A-Z]")) + +; === \u5BF9\u8C61\u65B9\u6CD5\u8C03\u7528 === + +; this \u65B9\u6CD5\u8C03\u7528 - this.method() +(call_expression + function: (member_expression + object: (this) @this.call.receiver + property: (property_identifier) @this.call.method)) + +; super \u65B9\u6CD5\u8C03\u7528 - super.method() +(call_expression + function: (member_expression + object: (super) @super.call.receiver + property: (property_identifier) @super.call.method)) + +; \u53EF\u9009\u94FE\u8C03\u7528 - object?.method?.() +(call_expression + function: (member_expression + object: (identifier) @optional.call.receiver + property: (property_identifier) @optional.call.method)) + +; \u94FE\u5F0F\u65B9\u6CD5\u8C03\u7528 - object.method1().method2() +(call_expression + function: (member_expression + object: (call_expression) + property: (property_identifier) @method.call.chain)) + +; \u5D4C\u5957\u5C5E\u6027\u8C03\u7528 - object.nested.method() +(call_expression + function: (member_expression + object: (member_expression + object: (identifier) @nested.call.root + property: (property_identifier) @nested.call.intermediate) + property: (property_identifier) @nested.call.method)) + +; \u65B9\u6CD5\u8C03\u7528 - object.method() +(call_expression + function: (member_expression + object: (identifier) @method.call.receiver + property: (property_identifier) @method.call.name) + (#not-match? @method.call.receiver "^[A-Z]")) + +; === \u547D\u540D\u7A7A\u95F4\u8C03\u7528 === + +; \u547D\u540D\u7A7A\u95F4/\u6A21\u5757\u8C03\u7528 - namespace.function() +(call_expression + function: (member_expression + object: (identifier) @namespace.call.name + property: (property_identifier) @namespace.call.function) + (#match? @namespace.call.name "^[A-Z]") + (#not-match? @namespace.call.function "^(constructor|new|create|get|set|add|remove|update|delete)$")) + +; === \u7279\u6B8A\u51FD\u6570\u8C03\u7528 === + +; \u7BAD\u5934\u51FD\u6570\u8C03\u7528 - (() => {})() +(call_expression + function: (arrow_function) @arrow.call.function) + +; \u51FD\u6570\u8868\u8FBE\u5F0F\u8C03\u7528 - (function() {})() +(call_expression + function: (function_expression) @function.call.expression) + +; \u6A21\u677F\u5B57\u7B26\u4E32\u4E2D\u7684\u8868\u8FBE\u5F0F\u8C03\u7528 +(template_substitution + (call_expression + function: (identifier) @template.call.function)) + +; === \u901A\u7528\u76F4\u63A5\u51FD\u6570\u8C03\u7528\uFF08\u4F18\u5148\u7EA7\u6700\u4F4E\uFF09=== + +; \u76F4\u63A5\u51FD\u6570\u8C03\u7528 - function() +(call_expression + function: (identifier) @function.call.direct) +`; + +// ../autocompletion/v2/dependenciesProcess/go.ts +function dependenciesCapturesProcessForGo(captures) { + const result = analyzeGoFunctionCalls(captures); + return result.functionCalls.map((call) => ({ + name: call.calledFunctionName, + type: "function_or_method" /* FunctionOrMethod */, + filePath: "", + startLine: call.line, + endLine: call.line, + startPosition: { + row: call.line, + column: call.column + }, + endPosition: { + row: call.line, + column: call.column + }, + rangeText: "", + fileHash: "" + })); +} +function analyzeGoFunctionCalls(captures) { + const functionCalls = []; + const scopeInfo = { + packageName: void 0, + typeName: void 0, + functionName: "unknown" + }; + console.log(`[analyzeGoFunctionCalls] Processing ${captures.length} captures`); + const methodCallsByLine = /* @__PURE__ */ new Map(); + for (const capture of captures) { + const node = capture.node; + const captureText = node.text.trim(); + const line = node.startPosition.row; + console.log(`[analyzeGoFunctionCalls] Processing capture: ${capture.name} = "${captureText}"`); + switch (capture.name) { + case "function.call.direct": + console.log(`[analyzeGoFunctionCalls] Adding direct function call: ${captureText}`); + functionCalls.push({ + calledFunctionName: captureText, + callType: "direct", + line: line + 1, + column: node.startPosition.column + }); + break; + case "method.call.name": + if (!methodCallsByLine.has(line)) { + methodCallsByLine.set(line, {}); + } + methodCallsByLine.get(line).functionName = captureText; + break; + case "method.call.receiver": + if (!methodCallsByLine.has(line)) { + methodCallsByLine.set(line, {}); + } + methodCallsByLine.get(line).receiver = captureText; + break; + default: + console.log(`[analyzeGoFunctionCalls] Unhandled capture type: ${capture.name}`); + break; + } + } + for (const [line, callInfo] of methodCallsByLine) { + if (callInfo.functionName && callInfo.receiver) { + console.log(`[analyzeGoFunctionCalls] Adding method call: ${callInfo.receiver}.${callInfo.functionName}`); + functionCalls.push({ + calledFunctionName: callInfo.functionName, + callType: "method", + receiver: callInfo.receiver, + line: line + 1, + column: 0 + }); + } + } + console.log( + `[analyzeGoFunctionCalls] Final result: ${functionCalls.length} function calls, scope: ${JSON.stringify(scopeInfo)}` + ); + return { functionCalls, scopeInfo }; +} + +// ../autocompletion/v2/dependenciesProcess/typescript.ts +function dependenciesCapturesProcessForTypeScript(captures) { + const result = analyzeTypeScriptFunctionCalls(captures); + return result.functionCalls.map((call) => ({ + name: call.calledFunctionName, + type: "function_or_method" /* FunctionOrMethod */, + filePath: "", + startLine: call.line, + endLine: call.line, + startPosition: { + row: call.line, + column: call.column + }, + endPosition: { + row: call.line, + column: call.column + }, + rangeText: "", + fileHash: "", + definition: { + name: call.calledFunctionName, + type: call.callType + }, + field: call.className || call.namespace, + signature: `${call.calledFunctionName}()`, + language: "typescript" /* TypeScript */ + })); +} +function analyzeTypeScriptFunctionCalls(captures) { + const functionCalls = []; + const scopeInfo = { + moduleName: void 0, + className: void 0, + functionName: "unknown", + isAsync: false + }; + const callGroups = /* @__PURE__ */ new Map(); + const callsByLine = /* @__PURE__ */ new Map(); + for (const capture of captures) { + const node = capture.node; + const captureText = node.text.trim(); + const line = node.startPosition.row; + switch (capture.name) { + case "function.call.direct": + functionCalls.push({ + calledFunctionName: captureText, + callType: "direct", + line: line + 1, + column: node.startPosition.column + }); + break; + case "method.call.name": + if (!callsByLine.has(line)) { + callsByLine.set(line, {}); + } + const methodCall = callsByLine.get(line); + methodCall.functionName = captureText; + methodCall.callType = "method"; + break; + case "method.call.receiver": + if (!callsByLine.has(line)) { + callsByLine.set(line, {}); + } + callsByLine.get(line).receiver = captureText; + break; + case "static.call.class": + if (!callsByLine.has(line)) { + callsByLine.set(line, {}); + } + const staticCall = callsByLine.get(line); + staticCall.className = captureText; + staticCall.callType = "static"; + break; + case "static.call.method": + if (!callsByLine.has(line)) { + callsByLine.set(line, {}); + } + callsByLine.get(line).functionName = captureText; + break; + case "namespace.call.name": + if (!callsByLine.has(line)) { + callsByLine.set(line, {}); + } + const namespaceCall = callsByLine.get(line); + namespaceCall.namespace = captureText; + namespaceCall.callType = "namespace"; + break; + case "namespace.call.function": + if (!callsByLine.has(line)) { + callsByLine.set(line, {}); + } + callsByLine.get(line).functionName = captureText; + break; + case "this.call.method": + functionCalls.push({ + calledFunctionName: captureText, + callType: "this", + receiver: "this", + line: line + 1, + column: node.startPosition.column + }); + break; + case "super.call.method": + functionCalls.push({ + calledFunctionName: captureText, + callType: "super", + receiver: "super", + line: line + 1, + column: node.startPosition.column + }); + break; + case "constructor.call.name": + functionCalls.push({ + calledFunctionName: captureText, + callType: "constructor", + line: line + 1, + column: node.startPosition.column + }); + break; + case "method.call.chain": + functionCalls.push({ + calledFunctionName: captureText, + callType: "chain", + line: line + 1, + column: node.startPosition.column + }); + break; + case "array.call.method": + if (!callsByLine.has(line)) { + callsByLine.set(line, {}); + } + const arrayCall = callsByLine.get(line); + arrayCall.functionName = captureText; + arrayCall.callType = "array"; + break; + case "array.call.object": + if (!callsByLine.has(line)) { + callsByLine.set(line, {}); + } + callsByLine.get(line).receiver = captureText; + break; + case "promise.call.method": + const promiseGroupKey = `promise-${line}`; + if (!callGroups.has(promiseGroupKey)) { + callGroups.set(promiseGroupKey, {}); + } + callGroups.get(promiseGroupKey)["method"] = captureText; + callGroups.get(promiseGroupKey)["line"] = line.toString(); + callGroups.get(promiseGroupKey)["column"] = node.startPosition.column.toString(); + break; + case "promise.call.object": + const promiseObjGroupKey = `promise-${line}`; + if (!callGroups.has(promiseObjGroupKey)) { + callGroups.set(promiseObjGroupKey, {}); + } + callGroups.get(promiseObjGroupKey)["receiver"] = captureText; + break; + case "await.call.function": + functionCalls.push({ + calledFunctionName: captureText, + callType: "async", + isAsync: true, + line: line + 1, + column: node.startPosition.column + }); + break; + case "async.call.method": + if (!callsByLine.has(line)) { + callsByLine.set(line, {}); + } + const asyncCall = callsByLine.get(line); + asyncCall.functionName = captureText; + asyncCall.callType = "async"; + asyncCall.isAsync = true; + break; + case "async.call.receiver": + if (!callsByLine.has(line)) { + callsByLine.set(line, {}); + } + callsByLine.get(line).receiver = captureText; + break; + case "optional.call.method": + if (!callsByLine.has(line)) { + callsByLine.set(line, {}); + } + const optionalCall = callsByLine.get(line); + optionalCall.functionName = captureText; + optionalCall.callType = "optional"; + optionalCall.isOptional = true; + break; + case "optional.call.receiver": + if (!callsByLine.has(line)) { + callsByLine.set(line, {}); + } + callsByLine.get(line).receiver = captureText; + break; + case "generic.call.function": + console.log(`[analyzeTypeScriptFunctionCalls] Adding generic function call: ${captureText}`); + functionCalls.push({ + calledFunctionName: captureText, + callType: "generic", + isGeneric: true, + line: line + 1, + column: node.startPosition.column + }); + break; + case "template.call.function": + console.log(`[analyzeTypeScriptFunctionCalls] Adding template function call: ${captureText}`); + functionCalls.push({ + calledFunctionName: captureText, + callType: "template", + line: line + 1, + column: node.startPosition.column + }); + break; + case "nested.call.root": + if (!callsByLine.has(line)) { + callsByLine.set(line, {}); + } + const nestedCall = callsByLine.get(line); + nestedCall.receiver = captureText; + nestedCall.callType = "nested"; + break; + case "nested.call.method": + if (!callsByLine.has(line)) { + callsByLine.set(line, {}); + } + callsByLine.get(line).functionName = captureText; + break; + default: + break; + } + } + for (const [groupKey, group] of callGroups) { + if (groupKey.startsWith("promise-") && group["method"] && group["receiver"]) { + functionCalls.push({ + calledFunctionName: group["method"], + callType: "promise", + receiver: group["receiver"], + line: parseInt(group["line"]) + 1, + column: parseInt(group["column"]) + }); + } + } + const processedCalls = /* @__PURE__ */ new Set(); + for (const [line, callInfo] of callsByLine) { + if (callInfo.functionName) { + const callTypes = []; + if (callInfo.callType === "promise") { + callTypes.push({ + type: "promise", + receiver: callInfo.receiver, + functionName: callInfo.functionName + }); + } + if (callInfo.callType === "array") { + callTypes.push({ + type: "array", + receiver: callInfo.receiver, + functionName: callInfo.functionName + }); + } + if (callInfo.className) { + callTypes.push({ + type: "static", + receiver: callInfo.className, + functionName: callInfo.functionName, + className: callInfo.className + }); + } + if (callInfo.namespace) { + callTypes.push({ + type: "namespace", + receiver: callInfo.namespace, + functionName: callInfo.functionName, + namespace: callInfo.namespace + }); + } + if (callInfo.isAsync) { + callTypes.push({ + type: "async", + receiver: callInfo.receiver, + functionName: callInfo.functionName, + isAsync: true + }); + } + if (callInfo.callType === "nested") { + callTypes.push({ + type: "nested", + receiver: callInfo.receiver, + functionName: callInfo.functionName + }); + } + if (callTypes.length === 0 && callInfo.receiver) { + callTypes.push({ + type: "method", + receiver: callInfo.receiver, + functionName: callInfo.functionName + }); + } + for (const callType of callTypes) { + const callKey = `${line}-${callType.type}-${callType.functionName}-${callType.receiver || ""}`; + if (!processedCalls.has(callKey)) { + processedCalls.add(callKey); + functionCalls.push({ + calledFunctionName: callType.functionName, + callType: callType.type, + receiver: callType.receiver, + className: callType.className, + namespace: callType.namespace, + line: line + 1, + column: 0, + isAsync: callType.isAsync, + isOptional: callInfo.isOptional, + isGeneric: callInfo.isGeneric + }); + } + } + } + } + return { functionCalls, scopeInfo }; +} + +// ../autocompletion/v2/dependenciesProcess/javascript.ts +function dependenciesCapturesProcessForJavaScript(captures) { + const result = analyzeJavaScriptFunctionCalls(captures); + return result.functionCalls.map((call) => ({ + name: call.calledFunctionName, + type: "function_or_method" /* FunctionOrMethod */, + filePath: "", + startLine: call.line, + endLine: call.line, + startPosition: { + row: call.line, + column: call.column + }, + endPosition: { + row: call.line, + column: call.column + }, + rangeText: "", + fileHash: "", + definition: { + name: call.calledFunctionName, + type: call.callType + }, + field: call.className || call.namespace, + signature: `${call.calledFunctionName}()`, + language: "javascript" /* JavaScript */ + })); +} +function analyzeJavaScriptFunctionCalls(captures) { + const functionCalls = []; + const scopeInfo = { + moduleName: void 0, + className: void 0, + functionName: "unknown", + isAsync: false + }; + const callsByLine = /* @__PURE__ */ new Map(); + for (const capture of captures) { + const node = capture.node; + const captureText = node.text.trim(); + const line = node.startPosition.row; + switch (capture.name) { + case "function.call.direct": + functionCalls.push({ + calledFunctionName: captureText, + callType: "direct", + line: line + 1, + column: node.startPosition.column + }); + break; + case "method.call.name": + if (!callsByLine.has(line)) { + callsByLine.set(line, {}); + } + const methodCall = callsByLine.get(line); + methodCall.functionName = captureText; + methodCall.callType = "method"; + break; + case "method.call.receiver": + if (!callsByLine.has(line)) { + callsByLine.set(line, {}); + } + callsByLine.get(line).receiver = captureText; + break; + case "static.call.class": + if (!callsByLine.has(line)) { + callsByLine.set(line, {}); + } + const staticCall = callsByLine.get(line); + staticCall.className = captureText; + staticCall.callType = "static"; + break; + case "static.call.method": + if (!callsByLine.has(line)) { + callsByLine.set(line, {}); + } + callsByLine.get(line).functionName = captureText; + break; + case "this.call.method": + functionCalls.push({ + calledFunctionName: captureText, + callType: "this", + receiver: "this", + line: line + 1, + column: node.startPosition.column + }); + break; + case "super.call.receiver": + if (!callsByLine.has(line)) { + callsByLine.set(line, {}); + } + callsByLine.get(line).receiver = "super"; + break; + case "super.call.method": + if (!callsByLine.has(line)) { + callsByLine.set(line, {}); + } + const superCall = callsByLine.get(line); + superCall.functionName = captureText; + superCall.callType = "super"; + break; + case "constructor.call.name": + functionCalls.push({ + calledFunctionName: captureText, + callType: "constructor", + line: line + 1, + column: node.startPosition.column + }); + break; + case "method.call.chain": + functionCalls.push({ + calledFunctionName: captureText, + callType: "chain", + line: line + 1, + column: node.startPosition.column + }); + break; + case "namespace.call.name": + if (!callsByLine.has(line)) { + callsByLine.set(line, {}); + } + const namespaceCall = callsByLine.get(line); + namespaceCall.namespace = captureText; + namespaceCall.callType = "namespace"; + break; + case "namespace.call.function": + if (!callsByLine.has(line)) { + callsByLine.set(line, {}); + } + callsByLine.get(line).functionName = captureText; + break; + case "arrow.call.function": + functionCalls.push({ + calledFunctionName: "arrow_function", + callType: "arrow", + line: line + 1, + column: node.startPosition.column + }); + break; + case "function.call.expression": + functionCalls.push({ + calledFunctionName: "function_expression", + callType: "arrow", + // 归类为箭头函数类型 + line: line + 1, + column: node.startPosition.column + }); + break; + case "array.call.method": + if (!callsByLine.has(line)) { + callsByLine.set(line, {}); + } + const arrayCall = callsByLine.get(line); + arrayCall.functionName = captureText; + arrayCall.callType = "array"; + break; + case "array.call.object": + if (!callsByLine.has(line)) { + callsByLine.set(line, {}); + } + callsByLine.get(line).receiver = captureText; + break; + case "promise.call.method": + if (!callsByLine.has(line)) { + callsByLine.set(line, {}); + } + const promiseCall = callsByLine.get(line); + promiseCall.functionName = captureText; + promiseCall.callType = "promise"; + break; + case "promise.call.object": + if (!callsByLine.has(line)) { + callsByLine.set(line, {}); + } + callsByLine.get(line).receiver = captureText; + break; + case "template.call.function": + functionCalls.push({ + calledFunctionName: captureText, + callType: "template", + line: line + 1, + column: node.startPosition.column + }); + break; + case "optional.call.receiver": + if (!callsByLine.has(line)) { + callsByLine.set(line, {}); + } + const optionalCall = callsByLine.get(line); + optionalCall.receiver = captureText; + optionalCall.isOptional = true; + break; + case "optional.call.method": + if (!callsByLine.has(line)) { + callsByLine.set(line, {}); + } + const optionalMethodCall = callsByLine.get(line); + optionalMethodCall.functionName = captureText; + optionalMethodCall.callType = "optional"; + break; + case "await.call.function": + functionCalls.push({ + calledFunctionName: captureText, + callType: "async", + isAsync: true, + line: line + 1, + column: node.startPosition.column + }); + break; + case "async.call.receiver": + if (!callsByLine.has(line)) { + callsByLine.set(line, {}); + } + const asyncCall = callsByLine.get(line); + asyncCall.receiver = captureText; + asyncCall.isAsync = true; + break; + case "async.call.method": + if (!callsByLine.has(line)) { + callsByLine.set(line, {}); + } + const asyncMethodCall = callsByLine.get(line); + asyncMethodCall.functionName = captureText; + asyncMethodCall.callType = "async"; + break; + case "nested.call.method": + if (!callsByLine.has(line)) { + callsByLine.set(line, {}); + } + const nestedCall = callsByLine.get(line); + nestedCall.functionName = captureText; + nestedCall.callType = "nested"; + break; + case "nested.call.root": + if (!callsByLine.has(line)) { + callsByLine.set(line, {}); + } + callsByLine.get(line).receiver = captureText; + break; + default: + break; + } + } + for (const [line, callInfo] of callsByLine) { + if (callInfo.functionName) { + functionCalls.push({ + calledFunctionName: callInfo.functionName, + callType: callInfo.callType || "method", + receiver: callInfo.receiver, + className: callInfo.className, + namespace: callInfo.namespace, + line: line + 1, + column: 0, + isAsync: callInfo.isAsync, + isOptional: callInfo.isOptional + }); + } + } + return { + functionCalls, + scopeInfo + }; +} + +// ../autocompletion/v2/dependenciesProcess/java.ts +function dependenciesCapturesProcessForJava(captures) { + const result = analyzeJavaFunctionCalls(captures); + return result.functionCalls.map((call) => ({ + name: call.calledFunctionName, + type: "function_or_method" /* FunctionOrMethod */, + filePath: "", + startLine: call.line, + endLine: call.line, + startPosition: { + row: call.line, + column: call.column + }, + endPosition: { + row: call.line, + column: call.column + }, + rangeText: "", + fileHash: "", + definition: { + name: call.calledFunctionName, + type: call.callType + }, + field: call.className || call.packageName, + signature: `${call.calledFunctionName}()`, + language: "java" /* Java */ + })); +} +function analyzeJavaFunctionCalls(captures) { + const functionCalls = []; + const scopeInfo = { + packageName: void 0, + className: void 0, + functionName: "unknown" + }; + const callsByLine = /* @__PURE__ */ new Map(); + for (const capture of captures) { + const node = capture.node; + const captureText = node.text.trim(); + const line = node.startPosition.row; + switch (capture.name) { + case "method.call.direct": + functionCalls.push({ + calledFunctionName: captureText, + callType: "direct", + line: line + 1, + column: node.startPosition.column + }); + break; + case "method.call.name": + if (!callsByLine.has(line)) { + callsByLine.set(line, {}); + } + const methodCall = callsByLine.get(line); + methodCall.functionName = captureText; + methodCall.callType = "method"; + break; + case "method.call.receiver": + if (!callsByLine.has(line)) { + callsByLine.set(line, {}); + } + callsByLine.get(line).receiver = captureText; + break; + case "static.call.class": + if (!callsByLine.has(line)) { + callsByLine.set(line, {}); + } + const staticCall = callsByLine.get(line); + staticCall.className = captureText; + staticCall.callType = "static"; + break; + case "static.call.method": + if (!callsByLine.has(line)) { + callsByLine.set(line, {}); + } + callsByLine.get(line).functionName = captureText; + break; + case "this.call.method": + functionCalls.push({ + calledFunctionName: captureText, + callType: "this", + receiver: "this", + line: line + 1, + column: node.startPosition.column + }); + break; + case "super.call.method": + functionCalls.push({ + calledFunctionName: captureText, + callType: "super", + receiver: "super", + line: line + 1, + column: node.startPosition.column + }); + break; + case "constructor.call.name": + functionCalls.push({ + calledFunctionName: captureText, + callType: "constructor", + line: line + 1, + column: node.startPosition.column + }); + break; + case "method.call.chain": + functionCalls.push({ + calledFunctionName: captureText, + callType: "chain", + line: line + 1, + column: node.startPosition.column + }); + break; + default: + break; + } + } + for (const [line, callInfo] of callsByLine) { + if (callInfo.functionName) { + const callData = { + calledFunctionName: callInfo.functionName, + callType: callInfo.callType || "method", + receiver: callInfo.receiver, + className: callInfo.className, + packageName: callInfo.packageName, + fieldName: callInfo.fieldName, + line: line + 1, + column: 0, + isGeneric: callInfo.isGeneric, + isException: callInfo.isException + }; + functionCalls.push(callData); + } + } + return { functionCalls, scopeInfo }; +} + +// ../autocompletion/v2/dependenciesProcess/python.ts +function dependenciesCapturesProcessForPython(captures) { + const result = analyzePythonFunctionCalls(captures); + return result.functionCalls.map((call) => ({ + name: call.calledFunctionName, + type: "function_or_method" /* FunctionOrMethod */, + filePath: "", + startLine: call.line, + endLine: call.line, + startPosition: { + row: call.line, + column: call.column + }, + endPosition: { + row: call.line, + column: call.column + }, + rangeText: "", + fileHash: "", + definition: { + name: call.calledFunctionName, + type: call.callType + }, + field: call.className, + signature: `${call.calledFunctionName}()`, + language: "python" /* Python */ + })); +} +function analyzePythonFunctionCalls(captures) { + const functionCalls = []; + const scopeInfo = { + moduleName: void 0, + className: void 0, + functionName: "unknown", + isAsync: false + }; + console.log(`[analyzePythonFunctionCalls] Processing ${captures.length} captures`); + const callsByLine = /* @__PURE__ */ new Map(); + for (const capture of captures) { + const node = capture.node; + const captureText = node.text.trim(); + const line = node.startPosition.row; + console.log(`[analyzePythonFunctionCalls] Processing capture: ${capture.name} = "${captureText}"`); + switch (capture.name) { + case "function.call.direct": + console.log(`[analyzePythonFunctionCalls] Adding direct function call: ${captureText}`); + if (!callsByLine.has(line)) { + callsByLine.set(line, {}); + } + const directCall = callsByLine.get(line); + if (!directCall.functionName) { + directCall.functionName = captureText; + } + if (!directCall.callType) { + directCall.callType = "direct"; + } + break; + case "method.call.name": + if (!callsByLine.has(line)) { + callsByLine.set(line, {}); + } + const methodCall = callsByLine.get(line); + methodCall.functionName = captureText; + methodCall.callType = "method"; + break; + case "method.call.receiver": + if (!callsByLine.has(line)) { + callsByLine.set(line, {}); + } + callsByLine.get(line).receiver = captureText; + break; + case "class.call.name": + if (!callsByLine.has(line)) { + callsByLine.set(line, {}); + } + const classCall = callsByLine.get(line); + classCall.className = captureText; + classCall.callType = "class"; + break; + case "class.call.method": + if (!callsByLine.has(line)) { + callsByLine.set(line, {}); + } + callsByLine.get(line).functionName = captureText; + break; + case "self.call.receiver": + if (!callsByLine.has(line)) { + callsByLine.set(line, {}); + } + const selfCall = callsByLine.get(line); + selfCall.receiver = captureText; + selfCall.callType = "self"; + break; + case "self.call.method": + if (!callsByLine.has(line)) { + callsByLine.set(line, {}); + } + callsByLine.get(line).functionName = captureText; + break; + case "super.call.function": + if (!callsByLine.has(line)) { + callsByLine.set(line, {}); + } + const superCall = callsByLine.get(line); + superCall.receiver = "super"; + superCall.callType = "super"; + break; + case "super.call.method": + if (!callsByLine.has(line)) { + callsByLine.set(line, {}); + } + callsByLine.get(line).functionName = captureText; + break; + case "async.call.function": + console.log(`[analyzePythonFunctionCalls] Adding async function call: ${captureText}`); + if (!callsByLine.has(line)) { + callsByLine.set(line, {}); + } + const asyncDirectCall = callsByLine.get(line); + asyncDirectCall.functionName = captureText; + asyncDirectCall.callType = "async"; + asyncDirectCall.isAsync = true; + break; + case "async.call.receiver": + if (!callsByLine.has(line)) { + callsByLine.set(line, {}); + } + const asyncCall = callsByLine.get(line); + asyncCall.receiver = captureText; + asyncCall.callType = "async"; + asyncCall.isAsync = true; + break; + case "async.call.method": + if (!callsByLine.has(line)) { + callsByLine.set(line, {}); + } + callsByLine.get(line).functionName = captureText; + break; + case "decorator.call.function": + console.log(`[analyzePythonFunctionCalls] Adding decorator function call: ${captureText}`); + if (!callsByLine.has(line)) { + callsByLine.set(line, {}); + } + const decoratorDirectCall = callsByLine.get(line); + decoratorDirectCall.functionName = captureText; + decoratorDirectCall.callType = "decorator"; + decoratorDirectCall.isDecorator = true; + break; + case "decorator.call.receiver": + if (!callsByLine.has(line)) { + callsByLine.set(line, {}); + } + const decoratorCall = callsByLine.get(line); + decoratorCall.receiver = captureText; + decoratorCall.callType = "decorator"; + decoratorCall.isDecorator = true; + break; + case "decorator.call.method": + if (!callsByLine.has(line)) { + callsByLine.set(line, {}); + } + callsByLine.get(line).functionName = captureText; + break; + case "method.call.chain": + console.log(`[analyzePythonFunctionCalls] Adding chain method call: ${captureText}`); + if (!callsByLine.has(line)) { + callsByLine.set(line, {}); + } + const chainCall = callsByLine.get(line); + chainCall.functionName = captureText; + chainCall.callType = "chain"; + break; + case "comprehension.call.function": + console.log(`[analyzePythonFunctionCalls] Adding comprehension function call: ${captureText}`); + if (!callsByLine.has(line)) { + callsByLine.set(line, {}); + } + const comprehensionDirectCall = callsByLine.get(line); + comprehensionDirectCall.functionName = captureText; + comprehensionDirectCall.callType = "comprehension"; + break; + case "comprehension.call.receiver": + if (!callsByLine.has(line)) { + callsByLine.set(line, {}); + } + const comprehensionCall = callsByLine.get(line); + comprehensionCall.receiver = captureText; + comprehensionCall.callType = "comprehension"; + break; + case "comprehension.call.method": + if (!callsByLine.has(line)) { + callsByLine.set(line, {}); + } + callsByLine.get(line).functionName = captureText; + break; + case "generator.call.function": + console.log(`[analyzePythonFunctionCalls] Adding generator function call: ${captureText}`); + if (!callsByLine.has(line)) { + callsByLine.set(line, {}); + } + const generatorDirectCall = callsByLine.get(line); + generatorDirectCall.functionName = captureText; + generatorDirectCall.callType = "generator"; + break; + case "generator.call.receiver": + if (!callsByLine.has(line)) { + callsByLine.set(line, {}); + } + const generatorCall = callsByLine.get(line); + generatorCall.receiver = captureText; + generatorCall.callType = "generator"; + break; + case "generator.call.method": + if (!callsByLine.has(line)) { + callsByLine.set(line, {}); + } + callsByLine.get(line).functionName = captureText; + break; + case "lambda.call.function": + console.log(`[analyzePythonFunctionCalls] Adding lambda function call: ${captureText}`); + if (!callsByLine.has(line)) { + callsByLine.set(line, {}); + } + const lambdaDirectCall = callsByLine.get(line); + lambdaDirectCall.functionName = captureText; + lambdaDirectCall.callType = "lambda"; + break; + case "lambda.call.receiver": + if (!callsByLine.has(line)) { + callsByLine.set(line, {}); + } + const lambdaCall = callsByLine.get(line); + lambdaCall.receiver = captureText; + lambdaCall.callType = "lambda"; + break; + case "lambda.call.method": + if (!callsByLine.has(line)) { + callsByLine.set(line, {}); + } + callsByLine.get(line).functionName = captureText; + break; + case "nested.call.root": + if (!callsByLine.has(line)) { + callsByLine.set(line, {}); + } + const nestedCall = callsByLine.get(line); + nestedCall.root = captureText; + nestedCall.callType = "nested"; + break; + case "nested.call.intermediate": + if (!callsByLine.has(line)) { + callsByLine.set(line, {}); + } + callsByLine.get(line).intermediate = captureText; + break; + case "nested.call.method": + if (!callsByLine.has(line)) { + callsByLine.set(line, {}); + } + callsByLine.get(line).functionName = captureText; + break; + case "function.call.argument": + console.log(`[analyzePythonFunctionCalls] Adding argument function call: ${captureText}`); + if (!callsByLine.has(line)) { + callsByLine.set(line, {}); + } + const argumentCall = callsByLine.get(line); + argumentCall.functionName = captureText; + argumentCall.callType = "argument"; + break; + default: + console.log(`[analyzePythonFunctionCalls] Unhandled capture type: ${capture.name}`); + break; + } + } + const processedCalls = /* @__PURE__ */ new Set(); + for (const [line, callInfo] of callsByLine) { + if (callInfo.functionName) { + let finalCallType = callInfo.callType; + if (callInfo.isDecorator) { + finalCallType = "decorator"; + } else if (callInfo.isAsync) { + finalCallType = "async"; + } else if (callInfo.receiver === "self") { + finalCallType = "self"; + } else if (callInfo.className) { + finalCallType = "class"; + } else if (callInfo.receiver && callInfo.callType === "method") { + finalCallType = "method"; + } + const callKey = `${line}-${finalCallType}-${callInfo.functionName}-${callInfo.receiver || ""}-${callInfo.className || ""}`; + if (!processedCalls.has(callKey)) { + processedCalls.add(callKey); + let receiver = callInfo.receiver; + if (finalCallType === "nested" && callInfo.root && callInfo.intermediate) { + receiver = `${callInfo.root}.${callInfo.intermediate}`; + } + functionCalls.push({ + calledFunctionName: callInfo.functionName, + callType: finalCallType, + receiver, + className: callInfo.className, + line: line + 1, + column: 0, + isAsync: callInfo.isAsync, + isDecorator: callInfo.isDecorator + }); + console.log( + `[analyzePythonFunctionCalls] Adding ${finalCallType} call: ${callInfo.functionName} (receiver: ${receiver || "none"})` + ); + } + } + } + console.log( + `[analyzePythonFunctionCalls] Final result: ${functionCalls.length} function calls, scope: ${JSON.stringify(scopeInfo)}` + ); + return { functionCalls, scopeInfo }; +} + +// ../autocompletion/v2/dependenciesProcess/jsx.ts +function dependenciesCapturesProcessForJSX(captures) { + const result = analyzeJSXFunctionCalls(captures); + return result.functionCalls.map((call) => ({ + name: call.calledFunctionName, + type: "function_or_method" /* FunctionOrMethod */, + filePath: "", + startLine: call.line, + endLine: call.line, + startPosition: { + row: call.line, + column: call.column + }, + endPosition: { + row: call.line, + column: call.column + }, + rangeText: "", + fileHash: "", + definition: { + name: call.calledFunctionName, + type: call.callType, + isAsync: call.isAsync + }, + field: call.className || call.namespace || call.component || call.context, + signature: buildSignatureForJSXCall(call), + language: "jsx" /* JSX */ + })); +} +function buildSignatureForJSXCall(call) { + switch (call.callType) { + case "react_hook": + return `${call.calledFunctionName}() // React Hook`; + case "react_component": + return `${call.calledFunctionName}() // React Component`; + case "event_handler": + return `${call.calledFunctionName}() // Event Handler`; + case "react_create": + return `React.createElement(${call.component}) // React.createElement`; + case "hoc": + return `${call.calledFunctionName}(${call.component}) // Higher-Order Component`; + case "context_hook": + return `useContext(${call.context}) // Context Hook`; + case "ref_hook": + return `${call.calledFunctionName}() // Ref Hook`; + case "state_hook": + return `${call.calledFunctionName}() // State Hook`; + case "effect_hook": + return `${call.calledFunctionName}() // Effect Hook`; + case "memo_hook": + return `${call.calledFunctionName}() // Memo Hook`; + default: + return `${call.calledFunctionName}()`; + } +} +function analyzeJSXFunctionCalls(captures) { + const functionCalls = []; + const scopeInfo = { + moduleName: void 0, + componentName: void 0, + functionName: "unknown", + isAsync: false, + isReactComponent: false + }; + const callsByLine = /* @__PURE__ */ new Map(); + const processedCalls = /* @__PURE__ */ new Set(); + const priorityGroups = { + hoc: [], + reactCreate: [], + reactHooks: [], + eventHandlers: [], + awaitCalls: [], + arrayMethods: [], + promiseMethods: [], + directCalls: [], + methodCalls: [], + other: [] + }; + for (const capture of captures) { + switch (capture.name) { + case "hoc.call.name": + case "hoc.call.component": + priorityGroups.hoc.push(capture); + break; + case "react.create.namespace": + case "react.create.method": + priorityGroups.reactCreate.push(capture); + break; + case "state.hook.call": + case "effect.hook.call": + case "memo.hook.call": + case "ref.hook.call": + case "context.hook.call": + case "react.hook.call": + priorityGroups.reactHooks.push(capture); + break; + case "event.handler.function": + priorityGroups.eventHandlers.push(capture); + break; + case "await.call.function": + case "async.call.receiver": + case "async.call.method": + priorityGroups.awaitCalls.push(capture); + break; + case "array.call.method": + case "array.call.object": + priorityGroups.arrayMethods.push(capture); + break; + case "promise.call.method": + case "promise.call.object": + priorityGroups.promiseMethods.push(capture); + break; + case "function.call.direct": + priorityGroups.directCalls.push(capture); + break; + case "method.call.name": + case "method.call.receiver": + case "method.call.chain": + case "optional.call.receiver": + case "optional.call.method": + case "static.call.class": + case "static.call.method": + priorityGroups.methodCalls.push(capture); + break; + default: + priorityGroups.other.push(capture); + break; + } + } + const allGroups = [ + priorityGroups.hoc, + priorityGroups.reactCreate, + priorityGroups.reactHooks, + priorityGroups.eventHandlers, + priorityGroups.awaitCalls, + priorityGroups.arrayMethods, + priorityGroups.promiseMethods, + priorityGroups.methodCalls, + priorityGroups.other, + priorityGroups.directCalls + // 直接调用放最后,优先级最低 + ]; + for (const group of allGroups) { + for (const capture of group) { + const node = capture.node; + const captureText = node.text.trim(); + const line = node.startPosition.row; + const callKey = `${line}-${node.startPosition.column}-${captureText}-${capture.name}`; + if (processedCalls.has(callKey)) { + continue; + } + if (capture.name === "function.call.direct") { + const generalCallKey = `${line}-${captureText}`; + let isAlreadyProcessed = false; + for (const existingKey of processedCalls) { + if (existingKey.includes(generalCallKey)) { + isAlreadyProcessed = true; + break; + } + } + const lineCall = callsByLine.get(line); + if (lineCall?.functionName === captureText) { + isAlreadyProcessed = true; + } + if (isAlreadyProcessed) { + continue; + } + } + switch (capture.name) { + case "hoc.call.name": + if (!callsByLine.has(line)) { + callsByLine.set(line, {}); + } + const hocCall = callsByLine.get(line); + hocCall.functionName = captureText; + hocCall.callType = "hoc"; + hocCall.isReactSpecific = true; + break; + case "hoc.call.component": + if (!callsByLine.has(line)) { + callsByLine.set(line, {}); + } + callsByLine.get(line).component = captureText; + break; + case "react.create.method": + if (!callsByLine.has(line)) { + callsByLine.set(line, {}); + } + const createCall = callsByLine.get(line); + createCall.functionName = captureText; + createCall.callType = "react_create"; + createCall.isReactSpecific = true; + break; + case "state.hook.call": + functionCalls.push({ + calledFunctionName: captureText, + callType: "state_hook", + line: line + 1, + column: node.startPosition.column, + isReactSpecific: true + }); + processedCalls.add(callKey); + break; + case "effect.hook.call": + functionCalls.push({ + calledFunctionName: captureText, + callType: "effect_hook", + line: line + 1, + column: node.startPosition.column, + isReactSpecific: true + }); + processedCalls.add(callKey); + break; + case "memo.hook.call": + functionCalls.push({ + calledFunctionName: captureText, + callType: "memo_hook", + line: line + 1, + column: node.startPosition.column, + isReactSpecific: true + }); + processedCalls.add(callKey); + break; + case "ref.hook.call": + functionCalls.push({ + calledFunctionName: captureText, + callType: "ref_hook", + line: line + 1, + column: node.startPosition.column, + isReactSpecific: true + }); + processedCalls.add(callKey); + break; + case "context.hook.call": + functionCalls.push({ + calledFunctionName: captureText, + callType: "context_hook", + line: line + 1, + column: node.startPosition.column, + isReactSpecific: true + }); + processedCalls.add(callKey); + break; + case "react.hook.call": + functionCalls.push({ + calledFunctionName: captureText, + callType: "react_hook", + line: line + 1, + column: node.startPosition.column, + isReactSpecific: true + }); + processedCalls.add(callKey); + break; + case "event.handler.function": + functionCalls.push({ + calledFunctionName: captureText, + callType: "event_handler", + line: line + 1, + column: node.startPosition.column, + isReactSpecific: true + }); + processedCalls.add(callKey); + break; + case "await.call.function": + functionCalls.push({ + calledFunctionName: captureText, + callType: "async", + isAsync: true, + line: line + 1, + column: node.startPosition.column + }); + processedCalls.add(callKey); + break; + case "promise.call.method": + if (!callsByLine.has(line)) { + callsByLine.set(line, {}); + } + const promiseCall = callsByLine.get(line); + promiseCall.functionName = captureText; + promiseCall.callType = "promise"; + break; + case "promise.call.object": + if (!callsByLine.has(line)) { + callsByLine.set(line, {}); + } + callsByLine.get(line).receiver = captureText; + break; + case "array.call.method": + if (!callsByLine.has(line)) { + callsByLine.set(line, {}); + } + const arrayCall = callsByLine.get(line); + arrayCall.functionName = captureText; + arrayCall.callType = "array"; + break; + case "array.call.object": + if (!callsByLine.has(line)) { + callsByLine.set(line, {}); + } + callsByLine.get(line).receiver = captureText; + break; + case "async.call.receiver": + if (!callsByLine.has(line)) { + callsByLine.set(line, {}); + } + const asyncCall = callsByLine.get(line); + asyncCall.receiver = captureText; + asyncCall.isAsync = true; + break; + case "async.call.method": + if (!callsByLine.has(line)) { + callsByLine.set(line, {}); + } + const asyncMethodCall = callsByLine.get(line); + asyncMethodCall.functionName = captureText; + asyncMethodCall.callType = "async"; + break; + case "method.call.name": + if (!callsByLine.has(line)) { + callsByLine.set(line, {}); + } + const methodCall = callsByLine.get(line); + if (!methodCall.callType) { + methodCall.functionName = captureText; + methodCall.callType = "method"; + } + break; + case "method.call.receiver": + if (!callsByLine.has(line)) { + callsByLine.set(line, {}); + } + callsByLine.get(line).receiver = captureText; + break; + case "static.call.class": + if (!callsByLine.has(line)) { + callsByLine.set(line, {}); + } + const staticClassCall = callsByLine.get(line); + if (!staticClassCall.callType || staticClassCall.callType === "method") { + staticClassCall.className = captureText; + staticClassCall.callType = "static"; + } + break; + case "static.call.method": + if (!callsByLine.has(line)) { + callsByLine.set(line, {}); + } + const staticMethodCall = callsByLine.get(line); + if (!staticMethodCall.callType || staticMethodCall.callType === "method") { + staticMethodCall.functionName = captureText; + staticMethodCall.callType = "static"; + } + break; + case "optional.call.receiver": + if (!callsByLine.has(line)) { + callsByLine.set(line, {}); + } + const optionalCall = callsByLine.get(line); + optionalCall.receiver = captureText; + optionalCall.isOptional = true; + break; + case "optional.call.method": + if (!callsByLine.has(line)) { + callsByLine.set(line, {}); + } + const optionalMethodCall = callsByLine.get(line); + break; + case "function.call.direct": + functionCalls.push({ + calledFunctionName: captureText, + callType: "direct", + line: line + 1, + column: node.startPosition.column + }); + processedCalls.add(callKey); + break; + case "method.call.chain": + if (!callsByLine.has(line)) { + callsByLine.set(line, {}); + } + const chainCall = callsByLine.get(line); + if (captureText.match(/^(then|catch|finally)$/)) { + chainCall.functionName = captureText; + chainCall.callType = "promise"; + } else { + if (!chainCall.callType) { + chainCall.functionName = captureText; + chainCall.callType = "chain"; + } + } + break; + // 其他情况处理... + default: + break; + } + } + } + for (const [line, callInfo] of callsByLine) { + if (callInfo.functionName) { + const callKey = `${line}-0-${callInfo.functionName}-compound`; + if (!processedCalls.has(callKey)) { + functionCalls.push({ + calledFunctionName: callInfo.functionName, + callType: callInfo.callType || "method", + receiver: callInfo.receiver, + className: callInfo.className, + namespace: callInfo.namespace, + component: callInfo.component, + context: callInfo.context, + line: line + 1, + column: 0, + isAsync: callInfo.isAsync, + isOptional: callInfo.isOptional, + isReactSpecific: callInfo.isReactSpecific + }); + processedCalls.add(callKey); + } + } + } + return { + functionCalls, + scopeInfo + }; +} + +// ../autocompletion/v2/dependenciesProcess/tsx.ts +function dependenciesCapturesProcessForTSX(captures) { + const result = analyzeTSXFunctionCalls(captures); + return result.functionCalls.map((call) => { + const def = { + name: call.calledFunctionName, + type: call.callType, + isAsync: call.isAsync + }; + if (call.isGeneric) def.isGeneric = true; + if (call.isReactSpecific) def.isReactSpecific = true; + return { + name: call.calledFunctionName, + type: "function_or_method" /* FunctionOrMethod */, + filePath: "", + startLine: call.line, + endLine: call.line, + startPosition: { + row: call.line, + column: call.column + }, + endPosition: { + row: call.line, + column: call.column + }, + rangeText: "", + fileHash: "", + definition: def, + field: call.className || call.namespace || call.component || call.context || call.typeArgument, + signature: buildSignatureForTSXCall(call), + language: "tsx" /* TSX */ + }; + }); +} +function buildSignatureForTSXCall(call) { + switch (call.callType) { + case "react_hook": + return `${call.calledFunctionName}() // React Hook`; + case "react_component": + return `${call.calledFunctionName}() // React Component`; + case "tsx_component": + return `${call.calledFunctionName}() // TSX Component`; + case "event_handler": + return `${call.calledFunctionName}() // Event Handler`; + case "react_create": + return `React.createElement(${call.component}) // React.createElement`; + case "hoc": + return `${call.calledFunctionName}(${call.component}) // Higher-Order Component`; + case "context_hook": + return `useContext(${call.context}) // Context Hook`; + case "ref_hook": + return `${call.calledFunctionName}() // Ref Hook`; + case "state_hook": + return `${call.calledFunctionName}() // State Hook`; + case "effect_hook": + return `${call.calledFunctionName}() // Effect Hook`; + case "memo_hook": + return `${call.calledFunctionName}() // Memo Hook`; + case "generic_call": + return `${call.calledFunctionName}<${call.typeArgument}>() // Generic Function`; + case "generic_method": + return `${call.receiver}.${call.calledFunctionName}<${call.typeArgument}>() // Generic Method`; + case "type_assertion": + return `as ${call.typeArgument} // Type Assertion`; + default: + return `${call.calledFunctionName}()`; + } +} +function analyzeTSXFunctionCalls(captures) { + const functionCalls = []; + const scopeInfo = { + moduleName: void 0, + componentName: void 0, + functionName: "unknown", + isAsync: false, + isReactComponent: false, + isTypeScript: true + }; + const callsByLine = /* @__PURE__ */ new Map(); + const processedCalls = /* @__PURE__ */ new Set(); + const priorityGroups = { + hoc: [], + reactCreate: [], + reactHooks: [], + eventHandlers: [], + genericCalls: [], + typeAssertions: [], + awaitCalls: [], + arrayMethods: [], + promiseMethods: [], + directCalls: [], + methodCalls: [], + other: [] + }; + for (const capture of captures) { + switch (capture.name) { + case "hoc.call.name": + case "hoc.call.component": + priorityGroups.hoc.push(capture); + break; + case "react.create.namespace": + case "react.create.method": + priorityGroups.reactCreate.push(capture); + break; + case "state.hook.call": + case "effect.hook.call": + case "memo.hook.call": + case "ref.hook.call": + case "context.hook.call": + case "react.hook.call": + priorityGroups.reactHooks.push(capture); + break; + case "event.handler.function": + priorityGroups.eventHandlers.push(capture); + break; + case "generic.call.function": + case "generic.call.receiver": + case "generic.call.method": + case "generic.constructor.call.name": + priorityGroups.genericCalls.push(capture); + break; + case "type.assertion.type": + priorityGroups.typeAssertions.push(capture); + break; + case "await.call.function": + case "async.call.receiver": + case "async.call.method": + priorityGroups.awaitCalls.push(capture); + break; + case "array.call.method": + case "array.call.object": + priorityGroups.arrayMethods.push(capture); + break; + case "promise.call.method": + case "promise.call.object": + priorityGroups.promiseMethods.push(capture); + break; + case "function.call.direct": + priorityGroups.directCalls.push(capture); + break; + case "method.call.name": + case "method.call.receiver": + case "method.call.chain": + case "optional.call.receiver": + case "optional.call.method": + case "static.call.class": + case "static.call.method": + priorityGroups.methodCalls.push(capture); + break; + default: + priorityGroups.other.push(capture); + break; + } + } + const allGroups = [ + priorityGroups.hoc, + priorityGroups.reactCreate, + priorityGroups.reactHooks, + priorityGroups.eventHandlers, + priorityGroups.genericCalls, + priorityGroups.typeAssertions, + priorityGroups.awaitCalls, + priorityGroups.arrayMethods, + priorityGroups.promiseMethods, + priorityGroups.methodCalls, + priorityGroups.other, + priorityGroups.directCalls + // 直接调用放最后,优先级最低 + ]; + for (const group of allGroups) { + for (const capture of group) { + const node = capture.node; + const captureText = node.text.trim(); + const line = node.startPosition.row; + const callKey = `${line}-${node.startPosition.column}-${captureText}-${capture.name}`; + if (processedCalls.has(callKey)) { + continue; + } + if (capture.name === "function.call.direct") { + const generalCallKey = `${line}-${captureText}`; + let isAlreadyProcessed = false; + for (const existingKey of processedCalls) { + if (existingKey.includes(generalCallKey)) { + isAlreadyProcessed = true; + break; + } + } + const lineCall = callsByLine.get(line); + if (lineCall?.functionName === captureText) { + isAlreadyProcessed = true; + } + if (isAlreadyProcessed) { + continue; + } + } + switch (capture.name) { + case "hoc.call.name": + if (!callsByLine.has(line)) { + callsByLine.set(line, {}); + } + const hocCall = callsByLine.get(line); + hocCall.functionName = captureText; + hocCall.callType = "hoc"; + hocCall.isReactSpecific = true; + break; + case "hoc.call.component": + if (!callsByLine.has(line)) { + callsByLine.set(line, {}); + } + callsByLine.get(line).component = captureText; + break; + case "react.create.method": + if (!callsByLine.has(line)) { + callsByLine.set(line, {}); + } + const createCall = callsByLine.get(line); + createCall.functionName = captureText; + createCall.callType = "react_create"; + createCall.isReactSpecific = true; + break; + case "state.hook.call": + functionCalls.push({ + calledFunctionName: captureText, + callType: "state_hook", + line: line + 1, + column: node.startPosition.column, + isReactSpecific: true + }); + processedCalls.add(callKey); + break; + case "effect.hook.call": + functionCalls.push({ + calledFunctionName: captureText, + callType: "effect_hook", + line: line + 1, + column: node.startPosition.column, + isReactSpecific: true + }); + processedCalls.add(callKey); + break; + case "memo.hook.call": + functionCalls.push({ + calledFunctionName: captureText, + callType: "memo_hook", + line: line + 1, + column: node.startPosition.column, + isReactSpecific: true + }); + processedCalls.add(callKey); + break; + case "ref.hook.call": + functionCalls.push({ + calledFunctionName: captureText, + callType: "ref_hook", + line: line + 1, + column: node.startPosition.column, + isReactSpecific: true + }); + processedCalls.add(callKey); + break; + case "context.hook.call": + functionCalls.push({ + calledFunctionName: captureText, + callType: "context_hook", + line: line + 1, + column: node.startPosition.column, + isReactSpecific: true + }); + processedCalls.add(callKey); + break; + case "react.hook.call": + functionCalls.push({ + calledFunctionName: captureText, + callType: "react_hook", + line: line + 1, + column: node.startPosition.column, + isReactSpecific: true + }); + processedCalls.add(callKey); + break; + case "event.handler.function": + console.log( + `[DEBUG] Event handler captured: ${captureText} at line ${line + 1}, column ${node.startPosition.column}` + ); + functionCalls.push({ + calledFunctionName: captureText, + callType: "event_handler", + line: line + 1, + column: node.startPosition.column, + isReactSpecific: true + }); + processedCalls.add(callKey); + break; + case "generic.call.function": + if (!callsByLine.has(line)) { + callsByLine.set(line, {}); + } + const genericCall = callsByLine.get(line); + genericCall.functionName = captureText; + genericCall.callType = "generic_call"; + genericCall.isGeneric = true; + break; + case "generic.call.receiver": + if (!callsByLine.has(line)) { + callsByLine.set(line, {}); + } + callsByLine.get(line).receiver = captureText; + break; + case "generic.call.method": + if (!callsByLine.has(line)) { + callsByLine.set(line, {}); + } + const genericMethodCall = callsByLine.get(line); + genericMethodCall.functionName = captureText; + genericMethodCall.callType = "generic_method"; + genericMethodCall.isGeneric = true; + break; + case "generic.constructor.call.name": + if (!callsByLine.has(line)) { + callsByLine.set(line, {}); + } + const genericConstructorCall = callsByLine.get(line); + genericConstructorCall.functionName = captureText; + genericConstructorCall.callType = "constructor"; + genericConstructorCall.isGeneric = true; + break; + case "type.assertion.type": + functionCalls.push({ + calledFunctionName: "as", + callType: "type_assertion", + typeArgument: captureText, + line: line + 1, + column: node.startPosition.column + }); + processedCalls.add(callKey); + break; + case "await.call.function": + functionCalls.push({ + calledFunctionName: captureText, + callType: "async", + isAsync: true, + line: line + 1, + column: node.startPosition.column + }); + processedCalls.add(callKey); + break; + case "promise.call.method": + console.log( + `[DEBUG] Promise method captured: ${captureText} at line ${line + 1}, column ${node.startPosition.column}` + ); + if (!callsByLine.has(line)) { + callsByLine.set(line, {}); + } + const promiseCall = callsByLine.get(line); + promiseCall.functionName = captureText; + promiseCall.callType = "promise"; + break; + case "promise.call.object": + if (!callsByLine.has(line)) { + callsByLine.set(line, {}); + } + callsByLine.get(line).receiver = captureText; + break; + case "array.call.method": + if (!callsByLine.has(line)) { + callsByLine.set(line, {}); + } + const arrayCall = callsByLine.get(line); + arrayCall.functionName = captureText; + arrayCall.callType = "array"; + break; + case "array.call.object": + if (!callsByLine.has(line)) { + callsByLine.set(line, {}); + } + callsByLine.get(line).receiver = captureText; + break; + case "async.call.receiver": + if (!callsByLine.has(line)) { + callsByLine.set(line, {}); + } + const asyncCall = callsByLine.get(line); + asyncCall.receiver = captureText; + asyncCall.isAsync = true; + break; + case "async.call.method": + if (!callsByLine.has(line)) { + callsByLine.set(line, {}); + } + const asyncMethodCall = callsByLine.get(line); + asyncMethodCall.functionName = captureText; + asyncMethodCall.callType = "async"; + break; + case "method.call.name": + if (!callsByLine.has(line)) { + callsByLine.set(line, {}); + } + const methodCall = callsByLine.get(line); + if (!methodCall.callType) { + methodCall.functionName = captureText; + methodCall.callType = "method"; + } + break; + case "method.call.receiver": + if (!callsByLine.has(line)) { + callsByLine.set(line, {}); + } + callsByLine.get(line).receiver = captureText; + break; + case "static.call.class": + if (!callsByLine.has(line)) { + callsByLine.set(line, {}); + } + const staticClassCall = callsByLine.get(line); + if (!staticClassCall.callType || staticClassCall.callType === "method") { + staticClassCall.className = captureText; + staticClassCall.callType = "static"; + } + break; + case "static.call.method": + functionCalls.push({ + calledFunctionName: captureText, + callType: "static", + line: line + 1, + column: node.startPosition.column + }); + processedCalls.add(callKey); + break; + case "optional.call.receiver": + if (!callsByLine.has(line)) { + callsByLine.set(line, {}); + } + const optionalCall = callsByLine.get(line); + optionalCall.receiver = captureText; + optionalCall.isOptional = true; + break; + case "optional.call.method": + if (!callsByLine.has(line)) { + callsByLine.set(line, {}); + } + const optionalMethodCall = callsByLine.get(line); + break; + case "function.call.direct": + functionCalls.push({ + calledFunctionName: captureText, + callType: "direct", + line: line + 1, + column: node.startPosition.column + }); + processedCalls.add(callKey); + break; + case "method.call.chain": + if (!callsByLine.has(line)) { + callsByLine.set(line, {}); + } + const chainCall = callsByLine.get(line); + if (captureText.match(/^(then|catch|finally)$/)) { + chainCall.functionName = captureText; + chainCall.callType = "promise"; + } else { + if (!chainCall.callType) { + chainCall.functionName = captureText; + chainCall.callType = "chain"; + } + } + break; + // 其他情况处理... + default: + break; + } + } + } + for (const [line, callInfo] of callsByLine) { + if (callInfo.functionName) { + const callKey = `${line}-0-${callInfo.functionName}-compound`; + if (!processedCalls.has(callKey)) { + let callType = callInfo.callType; + if (callType === "event_handler") { + } else if (callType === "promise") { + } else if (callInfo.className && (callType === "generic_method" || callType === "method")) { + callType = "static"; + } + functionCalls.push({ + calledFunctionName: callInfo.functionName, + callType: callType || "method", + receiver: callInfo.receiver, + className: callInfo.className, + namespace: callInfo.namespace, + component: callInfo.component, + context: callInfo.context, + typeArgument: callInfo.typeArgument, + line: line + 1, + column: 0, + isAsync: callInfo.isAsync, + isOptional: callInfo.isOptional, + isReactSpecific: callInfo.isReactSpecific, + isGeneric: callInfo.isGeneric + }); + processedCalls.add(callKey); + } + } + } + for (const capture of captures) { + if (capture.name === "type.assertion") { + const node = capture.node; + functionCalls.push({ + calledFunctionName: "as", + callType: "type_assertion", + line: node.startPosition.row + 1, + column: node.startPosition.column + }); + } + } + return { + functionCalls, + scopeInfo + }; +} + +// ../autocompletion/v2/dependenciesProcess/index.ts +var dependenciesCapturesQueries = { + ["go" /* Go */]: go_default2, + ["python" /* Python */]: python_default2, + ["typescript" /* TypeScript */]: typescript_default2, + ["javascript" /* JavaScript */]: javascript_default2, + ["java" /* Java */]: java_default2, + ["jsx" /* JSX */]: jsx_default2, + ["tsx" /* TSX */]: tsx_default2, + ["swift" /* Swift */]: null, + ["css" /* CSS */]: null, + ["html" /* HTML */]: null, + ["kotlin" /* Kotlin */]: null, + ["php" /* PHP */]: null, + ["rust" /* Rust */]: null, + ["c" /* C */]: null, + ["cpp" /* CPP */]: null, + ["unknown" /* Unknown */]: null +}; +var dependenciesProcessors = { + ["go" /* Go */]: dependenciesCapturesProcessForGo, + ["python" /* Python */]: dependenciesCapturesProcessForPython, + ["typescript" /* TypeScript */]: dependenciesCapturesProcessForTypeScript, + ["javascript" /* JavaScript */]: dependenciesCapturesProcessForJavaScript, + ["java" /* Java */]: dependenciesCapturesProcessForJava, + ["jsx" /* JSX */]: dependenciesCapturesProcessForJSX, + ["tsx" /* TSX */]: dependenciesCapturesProcessForTSX, + ["swift" /* Swift */]: (captures) => [], + ["css" /* CSS */]: (captures) => [], + ["html" /* HTML */]: (captures) => [], + ["kotlin" /* Kotlin */]: (captures) => [], + ["php" /* PHP */]: (captures) => [], + ["rust" /* Rust */]: (captures) => [], + ["c" /* C */]: (captures) => [], + ["cpp" /* CPP */]: (captures) => [], + ["unknown" /* Unknown */]: (captures) => [] +}; + +// ../autocompletion/v2/utils/languageCommentUtils.ts +var lineCommentSymbols = { + ["go" /* Go */]: "//", + ["python" /* Python */]: "#", + ["typescript" /* TypeScript */]: "//", + ["javascript" /* JavaScript */]: "//", + ["java" /* Java */]: "//", + ["unknown" /* Unknown */]: "" +}; +function formatCodeWithLanguageWithLineComment(text, language) { + if (language === "unknown" /* Unknown */) { + return text; + } + const lineCommentSymbol = lineCommentSymbols[language]; + if (!lineCommentSymbol) { + return text; + } + const lines = text.split("\n"); + const formattedLines = lines.map((line) => { + return `${lineCommentSymbol} ${line}`; + }); + return formattedLines.join("\n"); +} + +// ../autocompletion/v2/utils/treeUtils.ts +var fs2 = __toESM(require("fs/promises")); +var path3 = __toESM(require("path")); +var gitignoreCache = /* @__PURE__ */ new Map(); +async function getGitignoreFilter(dirPathRoot) { + const gitignorePath = path3.join(dirPathRoot, ".gitignore"); + try { + const stat2 = await fs2.stat(gitignorePath); + const cached = gitignoreCache.get(gitignorePath); + if (cached && cached.mtimeMs === stat2.mtimeMs) { + return cached.filter; + } + const content = await fs2.readFile(gitignorePath, "utf8"); + const rules = content.split(/\r?\n/).map((l) => l.trim()).filter((l) => l && !l.startsWith("#")); + const matchers = rules.map((rule) => { + if (rule.endsWith("/")) { + const dirRule = rule.replace(/\/$/, ""); + return (p, isDir) => isDir && p.includes(dirRule); + } else { + return (p, isDir) => p.includes(rule); + } + }); + const filter = (p, isDir) => !matchers.some((fn) => fn(p, isDir)); + gitignoreCache.set(gitignorePath, { mtimeMs: stat2.mtimeMs, rules, filter }); + return filter; + } catch { + return () => true; + } +} +async function treeView(dirPathRoot, filePaths, limitNum, maxDepth, options = {}) { + const { showDotDirs = false, allowOtherExtensions = false } = options; + const absRoot = path3.resolve(dirPathRoot); + const normFilePaths = filePaths.map((fp) => path3.resolve(dirPathRoot, fp)); + const expandDirs = /* @__PURE__ */ new Set(); + const siblingDirs = /* @__PURE__ */ new Set(); + const fileExts = /* @__PURE__ */ new Map(); + for (const fileAbs of normFilePaths) { + let cur = path3.dirname(fileAbs); + siblingDirs.add(cur); + if (!fileExts.has(cur)) fileExts.set(cur, /* @__PURE__ */ new Set()); + fileExts.get(cur).add(path3.extname(fileAbs)); + while (cur.startsWith(absRoot)) { + expandDirs.add(cur); + if (cur === absRoot) break; + cur = path3.dirname(cur); + } + } + const gitignoreFilter = await getGitignoreFilter(absRoot); + async function walk(dir, depth, prefix, isLast) { + if (depth > maxDepth) { + const entries2 = await fs2.readdir(dir, { withFileTypes: true }); + return [prefix + ellipsisLine(entries2.length, "(\u8D85\u51FA\u6DF1\u5EA6)")]; + } + let entries = []; + try { + entries = await fs2.readdir(dir, { withFileTypes: true }); + } catch { + return [prefix + "[\u65E0\u6CD5\u8BFB\u53D6\u76EE\u5F55]"]; + } + const isSiblingDir = siblingDirs.has(dir); + if (!showDotDirs && !isSiblingDir) { + entries = entries.filter((e) => !e.name.startsWith(".")); + } + entries = entries.filter( + (e) => gitignoreFilter(path3.relative(absRoot, path3.join(dir, e.name)), e.isDirectory()) + ); + entries.sort((a, b) => { + const aPath = path3.join(dir, a.name); + const bPath = path3.join(dir, b.name); + const aExpand = expandDirs.has(dir); + const bExpand = expandDirs.has(dir); + if (aExpand && bExpand) { + if (a.isDirectory() !== b.isDirectory()) return Number(a.isDirectory()) - Number(b.isDirectory()); + return a.name.localeCompare(b.name); + } else { + if (a.isDirectory() !== b.isDirectory()) return Number(b.isDirectory()) - Number(a.isDirectory()); + return a.name.localeCompare(b.name); + } + }); + const lines2 = []; + let shown = 0; + let omitted = 0; + const showAllSiblings = isSiblingDir; + const requiredExts = fileExts.get(dir); + if (showAllSiblings) { + const siblingFiles = entries.filter( + (e) => !e.isDirectory() && (allowOtherExtensions || !requiredExts || requiredExts.has(path3.extname(e.name))) + ); + const siblingDirs2 = entries.filter((e) => e.isDirectory()); + for (let i2 = 0; i2 < siblingFiles.length && shown < limitNum; i2++, shown++) { + const entry = siblingFiles[i2]; + const isEntryLast = shown === limitNum - 1 || i2 === siblingFiles.length - 1 && shown + siblingDirs2.length >= limitNum || shown === siblingFiles.length + siblingDirs2.length - 1; + const branch = isEntryLast ? "\u2514\u2500\u2500 " : "\u251C\u2500\u2500 "; + lines2.push(prefix + branch + entry.name); + } + for (let i2 = 0; i2 < siblingDirs2.length && shown < limitNum; i2++, shown++) { + const entry = siblingDirs2[i2]; + const entryPath = path3.join(dir, entry.name); + const isEntryLast = shown === limitNum - 1 || i2 === siblingDirs2.length - 1 || shown === siblingFiles.length + siblingDirs2.length - 1; + const branch = isEntryLast ? "\u2514\u2500\u2500 " : "\u251C\u2500\u2500 "; + const nextPrefix = prefix + (isEntryLast ? " " : "\u2502 "); + if (expandDirs.has(entryPath)) { + lines2.push(prefix + branch + entry.name + "/"); + const sub = await walk(entryPath, depth + 1, nextPrefix, isEntryLast); + lines2.push(...sub); + } else { + const subEntries = await fs2.readdir(entryPath, { withFileTypes: true }); + const filteredSubEntries = subEntries.filter( + (e) => gitignoreFilter(path3.relative(absRoot, path3.join(entryPath, e.name)), e.isDirectory()) + ); + lines2.push(prefix + branch + entry.name + `/ ...(${filteredSubEntries.length}\u9879)`); + } + } + const total = siblingFiles.length + siblingDirs2.length; + if (shown < total) { + lines2.push(prefix + ellipsisLine(total - shown)); + } + return lines2; + } + for (let i2 = 0; i2 < entries.length; i2++) { + const entry = entries[i2]; + const entryPath = path3.join(dir, entry.name); + const isDir = entry.isDirectory(); + const isEntryLast = shown === limitNum - 1 || i2 === entries.length - 1 || shown === entries.length - 1; + if (shown >= limitNum) { + omitted = entries.length - shown; + lines2.push(prefix + ellipsisLine(omitted)); + break; + } + const branch = isEntryLast ? "\u2514\u2500\u2500 " : "\u251C\u2500\u2500 "; + const nextPrefix = prefix + (isEntryLast ? " " : "\u2502 "); + if (isDir) { + if (expandDirs.has(entryPath)) { + lines2.push(prefix + branch + entry.name + "/"); + const sub = await walk(entryPath, depth + 1, nextPrefix, isEntryLast); + lines2.push(...sub); + } else { + const subEntries = await fs2.readdir(entryPath, { withFileTypes: true }); + const filteredSubEntries = subEntries.filter( + (e) => gitignoreFilter(path3.relative(absRoot, path3.join(entryPath, e.name)), e.isDirectory()) + ); + lines2.push(prefix + branch + entry.name + `/ ...(${filteredSubEntries.length}\u9879)`); + } + } else { + if (showAllSiblings) { + if (allowOtherExtensions || !requiredExts || requiredExts.has(path3.extname(entry.name))) { + lines2.push(prefix + branch + entry.name); + } + } else if (normFilePaths.includes(entryPath)) { + lines2.push(prefix + branch + entry.name); + } + } + shown++; + } + return lines2; + } + function ellipsisLine(count, note) { + return `...(${count}\u9879${note ? note : ""})`; + } + const rootName = path3.basename(absRoot) || absRoot; + const lines = await walk(absRoot, 1, "", true); + return [rootName + "/", ...lines].join("\n"); +} + +// ../autocompletion/v2/CodeContext.ts +var CodeContext = class { + _options; + logger; + get options() { + return this._options; + } + constructor(options, logger) { + this._options = { + numLinesAsContext: 128, + numLinesAsContextSuffix: 32, + numImplementContexts: 3 + }; + this.logger = logger?.with("[CodeContext]") || Logger.getDefaultLogger().with("[CodeContext]"); + try { + if (options && typeof options === "object") { + for (const key in options) { + if (options[key] === void 0) { + throw new Error(`Option ${key} is not defined`); + } + this._options[key] = options[key]; + } + } + } catch (error) { + this.logger.error(`Error checking options: ${error}, using default options`); + } + } + async capture(codeText, file) { + const languageParsers = await loadRequiredLanguageParsers([file.filePath]); + const languageParser = languageParsers[file.fileExtension]; + if (!languageParser) { + this.logger.warn(`No languageParser available for extension: ${file.fileExtension}`); + return null; + } + const parser = languageParser.parser; + const query = languageParser.query; + if (!parser || !query) { + this.logger.warn(`No parser or query available for extension: ${file.fileExtension}`); + return null; + } + const tree = parser.parse(codeText); + this.logger.info(`Successfully parsed AST for: ${path4.basename(file.filePath)}`); + const captures = query.captures(tree.rootNode); + return captures; + } + async captureDependencies(codeText, file) { + const queryText = dependenciesCapturesQueries[file.language]; + if (!queryText) { + this.logger.warn(`No query available for extension: ${file.fileExtension}`); + return null; + } + const languageParsers = await loadRequiredLanguageParsers([file.filePath]); + const languageParser = languageParsers[file.fileExtension]; + if (!languageParser) { + this.logger.warn(`No languageParser available for extension: ${file.fileExtension}`); + return null; + } + const parser = languageParser.parser; + const query = parser.getLanguage().query(queryText); + if (!parser || !query) { + this.logger.warn(`No parser or query available for extension: ${file.fileExtension}`); + return null; + } + const tree = parser.parse(codeText); + this.logger.info(`Successfully parsed AST for: ${path4.basename(file.filePath)}`); + const captures = query.captures(tree.rootNode); + return captures; + } + /** + * 切分代码为 CodeSnippets + * 使用 tree-sitter 进行语义切分,提取完整的函数、类、方法等定义 + */ + async chunk(codeText, options) { + const { file, snippetTypes = [], maxSnippetLines = 50, minSnippetLines = 3 } = options; + const codeSnippets = new CodeSnippets(); + try { + const fileHash = this.calculateFileHash(codeText); + if (!this.isSupportedLanguage(file.language)) { + if (file.language === "unknown" /* Unknown */) { + this.logger.info(`Language ${file.language} not supported now`); + } else { + this.logger.warn(`Language ${file.language} not supported now`); + } + return codeSnippets; + } + const captures = await this.capture(codeText, file); + if (!captures || captures.length === 0) { + this.logger.warn(`No captures found`); + return codeSnippets; + } + const extractSnippetsFromCapturesFunc = extractSnippetsFromCaptures[file.language]; + try { + if (!extractSnippetsFromCapturesFunc) { + this.logger.info(`No extractSnippetsFromCapturesFunc available for language: ${file.language}`); + return codeSnippets; + } + const snippets = await extractSnippetsFromCapturesFunc( + captures, + codeText, + file.filePath, + fileHash, + snippetTypes, + { + maxSnippetLines, + minSnippetLines + } + ); + this.logger.info(`Extracted ${snippets.length} snippets total`); + if (snippets && snippets.length > 0) { + await codeSnippets.insert(snippets); + } + } catch (error) { + this.logger.warn(`Error extracting snippets for ${file.filePath}:`, error); + } + return codeSnippets; + } catch (error) { + this.logger.error(`Error parsing AST for ${file.filePath}:`, error); + return codeSnippets; + } + } + async extractDependencies(codeText, file) { + const captures = await this.captureDependencies(codeText, file); + if (!captures || captures.length === 0) { + this.logger.warn(`No captures found`); + return []; + } + const processor = dependenciesProcessors[file.language]; + if (!processor) { + this.logger.warn(`No processor available for language: ${file.language}`); + return []; + } + try { + const dependencies = processor(captures); + if (!dependencies || dependencies.length === 0) { + this.logger.warn(`No dependencies found`); + return []; + } + return dependencies; + } catch (error) { + this.logger.warn(`Error extracting dependencies for ${file.filePath}:`, error); + return []; + } + } + /** + * 索引文件集合,提取所有文件的代码片段 + */ + async index(codeFiles, options) { + const { maxSnippetLines = 50, minSnippetLines = 3, snippetTypes = [], includeFileTypes = [] } = options || {}; + const allSnippets = new CodeSnippets(); + this.logger.info(`Indexing ${codeFiles.files?.length || 0} files`); + const indexPromises = (codeFiles.files || []).map(async (fileMeta) => { + try { + const fileExtension = path4.extname(fileMeta.filePath).toLowerCase().slice(1); + if (!includeFileTypes.includes(fileExtension)) { + return new CodeSnippets(); + } + const content = await fileMeta.read?.(); + if (!content) { + this.logger.warn(`Could not read content for file: ${fileMeta.filePath}`); + return new CodeSnippets(); + } + const fileSnippets = await this.chunk(content, { + file: fileMeta, + snippetTypes, + maxSnippetLines, + minSnippetLines + }); + this.logger.info( + `Indexed ${fileSnippets.snippets.length} snippets from ${path4.basename(fileMeta.filePath)}` + ); + return fileSnippets; + } catch (error) { + this.logger.error(`Error indexing file ${fileMeta.filePath}:`, error); + return new CodeSnippets(); + } + }); + const fileSnippetsArray = await Promise.all(indexPromises); + for (const fileSnippets of fileSnippetsArray) { + await allSnippets.merge(fileSnippets); + } + this.logger.info(`Total indexed snippets: ${allSnippets.snippets.length}`); + return allSnippets; + } + async getFunctionOrMethodSurroundingCursor(codeSnippets, cursorPosition, file) { + const snippets = await codeSnippets.filter((snippet) => { + return cursorPosition.row >= snippet.startLine && cursorPosition.row <= snippet.endLine; + }); + if (!snippets || snippets.snippets.length === 0) { + this.logger.warn(`No snippets found for file: ${file.filePath}`); + return null; + } + return snippets.snippets[0]; + } + /** + * 检索与当前位置相关的代码片段 - 智能上下文策略 + */ + /** + * 检索与当前位置相关的代码片段 - 使用 capture 机制,直接返回文件原文 + */ + async retriveRelates(codeText, line, column, file, globalContext) { + const relatedSnippets = new CodeSnippets(); + if (!globalContext) { + this.logger.warn(`No global context provided`); + return relatedSnippets; + } + this.logger.info(`Retrieving related snippets for line ${line}, column ${column}`); + const functionOrMethod = await this.getFunctionOrMethodSurroundingCursor( + globalContext, + { row: line, column }, + file + ); + if (!functionOrMethod) { + this.logger.warn(`No function or method found for line ${line}, column ${column}`); + return relatedSnippets; + } + if (!functionOrMethod.implementText) { + this.logger.warn(`No implementText available for function or method: ${functionOrMethod.name}`); + return relatedSnippets; + } + const dependencies = await this.extractDependencies(functionOrMethod.implementText, file); + if (!dependencies || dependencies.length === 0) { + this.logger.warn(`No dependencies found`); + return relatedSnippets; + } + let relatedSnippetsWithDependencies = []; + dependencies.sort((a, b) => { + return Math.abs(functionOrMethod.startLine + a.startLine - line) - Math.abs(functionOrMethod.startLine + b.startLine - line); + }); + for (const dependency of dependencies) { + if (relatedSnippetsWithDependencies.length >= this.options.numImplementContexts) { + break; + } + relatedSnippetsWithDependencies = relatedSnippetsWithDependencies.concat( + await globalContext.find({ + filePath: file.filePath, + name: dependency.name, + type: dependency.type, + field: dependency.field + }) + ); + } + await relatedSnippets.insert(relatedSnippetsWithDependencies); + return relatedSnippets; + } + /** + * 后处理 LLM 生成的补全文本 + * 使用 getStringBeforeCloseSymbol 处理符号闭合 + */ + postprocess(completion, options) { + if (!completion || completion.trim() === "") { + return ""; + } + this.logger.info(`Postprocessing completion: "${completion.substring(0, 100)}..."`); + let processedCompletion = completion; + processedCompletion = processedCompletion.trimEnd(); + if (options && options.modelType === "qwen" /* Qwen */) { + let { closeSymbol, suffixPrefix } = findFirstMatchingCloseSymbol(options.prompt, "<|fim_suffix|>"); + processedCompletion = postProcessCompletionSynthesis( + processedCompletion, + options.prefix, + options.suffix, + closeSymbol, + suffixPrefix + ); + } + this.logger.info(`Postprocessed result: "${processedCompletion.substring(0, 100)}..."`); + return processedCompletion; + } + /** + * 获取代码补全所需的完整上下文 + */ + async getCompletionContext(documentInfo, positionInfo, globalContext) { + this.logger.info( + `Getting completion context for line ${positionInfo.line}, character ${positionInfo.character}` + ); + const { prefix, suffix } = await this.getCurrentContext(documentInfo, positionInfo); + this.logger.info(`Prefix: "${prefix.substring(prefix.length - 50)}..."`); + this.logger.info(`Suffix: "${suffix.substring(0, 50)}..."`); + const generateOverViewFromSnippetsFunc = generateOverViewFromSnippets[documentInfo.file.language]; + let overview = void 0; + if (typeof generateOverViewFromSnippetsFunc === "function" && documentInfo.file.snippetMetas) { + overview = generateOverViewFromSnippetsFunc(documentInfo.file.snippetMetas || []); + } + const relatedSnippets = await this.retriveRelates( + documentInfo.content, + positionInfo.line + 1, + // 转换为 1-based + positionInfo.character, + documentInfo.file, + globalContext + ); + this.logger.info(`Found ${relatedSnippets.snippets.length} related snippets`); + return { + prefix, + suffix, + snippets: relatedSnippets.snippets, + overview, + filePath: documentInfo.file.filePath, + fileHash: documentInfo.file.fileHash, + gitUrl: "" + }; + } + /** + * 预处理上下文 - 输出3个字符串 + */ + async preprocess(completionContext, options) { + if (isInsideWord(completionContext.prefix, completionContext.suffix, (msg) => this.logger.info(msg))) { + return { + prefix: completionContext.prefix, + suffix: completionContext.suffix, + extraContexts: [], + shouldSkipCompletion: false + }; + } + const extraContexts = []; + const recentOpenFiles = options.recentOpenFiles.filter((file) => file.language === options.codeFile.language).map((file) => file.filePath); + if (options.codeFile.projectRoot) { + try { + const treeViewText = await treeView(options.codeFile.projectRoot, recentOpenFiles, 10, 10); + extraContexts.push({ + type: "RepoTreeView" /* RepoTreeView */, + content: `## Repo Tree View +${treeViewText}` + }); + } catch (error) { + this.logger.warn(`Error getting repo tree view: ${error}`); + } + } + extraContexts.push({ + type: "FileInfo" /* FileInfo */, + content: `## Description + This is a ${options.codeFile.language} file.` + }); + if (completionContext.overview) { + extraContexts.push({ + type: "FileCodeOverview" /* FileCodeOverview */, + content: `## File Overview +${completionContext.overview}` + }); + } + if (completionContext.snippets.length > 0) { + extraContexts.push({ + type: "RelatedFunctionDefinition" /* RelatedFunctionDefinition */, + content: `## Related Function Definitions +${completionContext.snippets.map((snippet) => snippet.definitionText).join("\n")}` + }); + } + if (this.options.numImplementContexts > 0 && completionContext.snippets.length > 0) { + extraContexts.push({ + type: "RelatedFuntionImplement" /* RelatedFuntionImplement */, + content: `## Related Function Implementations +${completionContext.snippets.map((snippet) => snippet.implementText).join("\n")}` + }); + } + if (options.recentOpenFiles && options.recentOpenFiles.length > 0) { + const sameLanguageFiles = options.recentOpenFiles.filter( + (file) => file.language === options.codeFile.language && file.filePath !== options.codeFile.filePath + ); + if (sameLanguageFiles.length > 0) { + const symbolOverviews = []; + for (const file of sameLanguageFiles) { + if (file.snippetMetas && file.snippetMetas.length > 0) { + const generateOverViewFunc = generateOverViewFromSnippets[file.language]; + if (typeof generateOverViewFunc === "function") { + const overview = generateOverViewFunc(file.snippetMetas); + if (overview.trim()) { + symbolOverviews.push(`### ${file.filePath} +${overview}`); + } + } + } + } + if (symbolOverviews.length > 0) { + extraContexts.push({ + type: "RelatedFunctionDefinition" /* RelatedFunctionDefinition */, + content: `## Open Tabs Symbol Overview +${symbolOverviews.join("\n\n")}` + }); + } + } + } + extraContexts.push({ + type: "EndContextPrompt" /* EndContextPrompt */, + content: `## Recent Open Files +${recentOpenFiles.join(", ")} + + End of Context, Above is the context of the current file. You are editing the file at line ${options.editCursor.line}, character ${options.editCursor.character}, Starting Coding.` + }); + for (const extraContext of extraContexts) { + extraContext.content = formatCodeWithLanguageWithLineComment( + extraContext.content, + options.codeFile.language + ); + } + return { + prefix: completionContext.prefix, + suffix: completionContext.suffix, + extraContexts, + shouldSkipCompletion: false + }; + } + /** + * 获取当前光标位置的上下文 - 基于函数级别而非行級別 + */ + async getCurrentContext(documentInfo, positionInfo) { + const currentFunction = documentInfo.file.snippetMetas?.filter((snippet) => { + if (snippet.startLine && snippet.endLine) { + return positionInfo.line >= snippet.startLine && positionInfo.line <= snippet.endLine; + } + return false; + })[0]; + if (currentFunction) { + this.logger.info( + `Found function: ${currentFunction.name} at lines ${currentFunction.startLine}-${currentFunction.endLine}` + ); + if (!currentFunction.implementText) { + this.logger.warn(`No implementText available for function: ${currentFunction.name}`); + return this.getSurroundingCodeContextSimple(documentInfo, positionInfo); + } + const originalTextLines = documentInfo.content.split("\n"); + let startLine = Math.max(1, currentFunction.startLine); + const functionLines = currentFunction.implementText.split("\n"); + let endLine = Math.min(startLine + functionLines.length, documentInfo.lineCount); + const remainsLinesCount = this.options.numLinesAsContext - (endLine - startLine); + if (remainsLinesCount > 0) { + const halfRemainsLinesCount = Math.floor(remainsLinesCount / 2); + startLine = Math.max(1, startLine - halfRemainsLinesCount); + endLine = Math.min(documentInfo.lineCount, endLine + halfRemainsLinesCount); + } + const startIndex = startLine - 1; + const endIndex = endLine - 1; + if (startIndex < 0 || startIndex > originalTextLines.length || endIndex < 0 || endIndex > originalTextLines.length) { + this.logger.warn(`Invalid startIndex or endIndex: ${startIndex}, ${endIndex}`); + return this.getSurroundingCodeContextSimple(documentInfo, positionInfo); + } + let prefix = originalTextLines.slice(startIndex, positionInfo.line).join("\n"); + let suffix = ""; + if (positionInfo.line < originalTextLines.length) { + suffix = originalTextLines[positionInfo.line].substring(positionInfo.character) + "\n" + originalTextLines.slice(positionInfo.line + 1, endIndex + 1).join("\n"); + } + if (positionInfo.line >= 0 && positionInfo.line < originalTextLines.length) { + prefix += "\n" + originalTextLines[positionInfo.line].substring(0, positionInfo.character); + } + this.logger.info(`Function-level context - Prefix: ${prefix.length} chars, Suffix: ${suffix.length} chars`); + return { prefix, suffix }; + } else { + this.logger.info(`No function found at position, using line-level context`); + return this.getSurroundingCodeContextSimple(documentInfo, positionInfo); + } + } + isSimpleContextEnough(documentInfo, positionInfo) { + const { startLine, endLine } = this.getSurroundingCodeContextSimpleStartAndEnd(documentInfo, positionInfo); + return startLine <= 0 && endLine >= documentInfo.lineCount - 1; + } + getSurroundingCodeContextSimpleStartAndEnd(documentInfo, positionInfo) { + const line = positionInfo.line; + const startLine = Math.max(0, line - this.options.numLinesAsContext); + const endLine = Math.min(documentInfo.lineCount - 1, line + this.options.numLinesAsContextSuffix); + return { startLine, endLine }; + } + getSurroundingCodeContextSimple(documentInfo, positionInfo) { + const line = positionInfo.line; + const { startLine, endLine } = this.getSurroundingCodeContextSimpleStartAndEnd(documentInfo, positionInfo); + const lines = documentInfo.content.split("\n"); + let prefix = lines.slice(startLine, line).join("\n"); + let suffix = ""; + if (line < lines.length) { + suffix = lines[line].substring(positionInfo.character) + "\n" + lines.slice(line + 1, endLine).join("\n"); + } + if (line >= 0 && line < lines.length) { + prefix += "\n" + lines[line].substring(0, positionInfo.character); + } + return { prefix, suffix }; + } + // ==================== 辅助方法 ==================== + calculateFileHash(content) { + return crypto3.createHash("md5").update(content).digest("hex"); + } + isSupportedLanguage(language) { + return CodeLanguageTypeSupport.includes(language); + } +}; + +// cli.ts +var { program } = require_commander(); +var codeContext = new CodeContext(); +function getExtension(filePath) { + return filePath.substring(filePath.lastIndexOf(".") + 1, filePath.length); +} +async function index(codeFiles, maxSnippetLines) { + const maxLines = maxSnippetLines || 100; + const allSnippets = new CodeSnippets(); + const indexPromises = codeFiles.files.map(async (file) => { + try { + if (file.language === void 0 || !Object.values(CodeLanguageType).includes(file.language)) { + console.log(`Unsupported language: ${file.language}`); + return new CodeSnippets(); + } + const content = file.content; + if (!content) { + console.log(`Content is empty for file: ${file.filePath}`); + return new CodeSnippets(); + } + file.fileExtension = getExtension(file.filePath); + const fileSnippets = await codeContext.chunk(content, { + file, + maxSnippetLines: maxLines, + snippetTypes: [ + "function_or_method" /* FunctionOrMethod */, + "class_or_interface_or_struct" /* ClassOrInterfaceOrStructOrEnum */, + "variable_or_constant" /* VariableOrConstant */, + "import_or_include" /* ImportOrInclude */ + ] + }); + return fileSnippets; + } catch (error) { + return new CodeSnippets(); + } + }); + const fileSnippetsArray = await Promise.all(indexPromises); + for (const fileSnippets of fileSnippetsArray) { + await allSnippets.merge(fileSnippets); + } + return allSnippets; +} +program.command("index ").option("-m ", "--maxlines ", "Maximum number of lines for each snippet").description("Index the given files.").action(async (input, cmd) => { + const codeFiles = { files: JSON.parse(input) }; + const indexResult = await index( + codeFiles, + cmd.maxlines ? parseInt(cmd.maxlines, 10) : void 0 + ); + console.log(`${JSON.stringify(indexResult.getSnippets(), null, 2)}`); +}); +program.parse(process.argv); +//# sourceMappingURL=cli.cjs.map diff --git a/backend/pkg/cli/tools/dist/cli.cjs.map b/backend/pkg/cli/tools/dist/cli.cjs.map new file mode 100644 index 0000000..d06fcce --- /dev/null +++ b/backend/pkg/cli/tools/dist/cli.cjs.map @@ -0,0 +1,7 @@ +{ + "version": 3, + "sources": ["../../../../node_modules/.pnpm/web-tree-sitter@0.22.6/node_modules/web-tree-sitter/tree-sitter.js", "../node_modules/commander/lib/error.js", "../node_modules/commander/lib/argument.js", "../node_modules/commander/lib/help.js", "../node_modules/commander/lib/option.js", "../node_modules/commander/lib/suggestSimilar.js", "../node_modules/commander/lib/command.js", "../node_modules/commander/index.js", "../../autocompletion/v2/CodeSnippets.ts", "../../autocompletion/v2/types.ts", "../../autocompletion/v2/CodeContext.ts", "../../../../src/services/CT-tree-sitter/languageParser.ts", "../../../../src/services/CT-tree-sitter/queries/solidity.ts", "../../../../src/services/CT-tree-sitter/queries/php.ts", "../../../../src/services/CT-tree-sitter/queries/vue.ts", "../../../../src/services/CT-tree-sitter/queries/typescript.ts", "../../../../src/services/CT-tree-sitter/queries/tsx.ts", "../../../../src/services/CT-tree-sitter/queries/python.ts", "../../../../src/services/CT-tree-sitter/queries/javascript.ts", "../../../../src/services/CT-tree-sitter/queries/jsx.ts", "../../../../src/services/CT-tree-sitter/queries/java.ts", "../../../../src/services/CT-tree-sitter/queries/rust.ts", "../../../../src/services/CT-tree-sitter/queries/ruby.ts", "../../../../src/services/CT-tree-sitter/queries/cpp.ts", "../../../../src/services/CT-tree-sitter/queries/c.ts", "../../../../src/services/CT-tree-sitter/queries/c-sharp.ts", "../../../../src/services/CT-tree-sitter/queries/go.ts", "../../../../src/services/CT-tree-sitter/queries/swift.ts", "../../../../src/services/CT-tree-sitter/queries/kotlin.ts", "../../../../src/services/CT-tree-sitter/queries/css.ts", "../../../../src/services/CT-tree-sitter/queries/elixir.ts", "../../../../src/services/CT-tree-sitter/queries/html.ts", "../../../../src/services/CT-tree-sitter/queries/lua.ts", "../../../../src/services/CT-tree-sitter/queries/ocaml.ts", "../../../../src/services/CT-tree-sitter/queries/toml.ts", "../../../../src/services/CT-tree-sitter/queries/systemrdl.ts", "../../../../src/services/CT-tree-sitter/queries/tlaplus.ts", "../../../../src/services/CT-tree-sitter/queries/zig.ts", "../../../../src/services/CT-tree-sitter/queries/embedded_template.ts", "../../../../src/services/CT-tree-sitter/queries/elisp.ts", "../../autocompletion/v2/utils/processUtils.ts", "../../autocompletion/v2/capturesProcess/general.ts", "../../autocompletion/v2/Logger.ts", "../../autocompletion/v2/capturesProcess/go.ts", "../../autocompletion/v2/capturesProcess/python.ts", "../../autocompletion/v2/capturesProcess/java.ts", "../../autocompletion/v2/capturesProcess/javascript.ts", "../../autocompletion/v2/capturesProcess/jsx.ts", "../../autocompletion/v2/capturesProcess/typescript.ts", "../../autocompletion/v2/capturesProcess/tsx.ts", "../../autocompletion/v2/capturesProcess/swift.ts", "../../autocompletion/v2/capturesProcess/css.ts", "../../autocompletion/v2/capturesProcess/html.ts", "../../autocompletion/v2/capturesProcess/kotlin.ts", "../../autocompletion/v2/capturesProcess/php.ts", "../../autocompletion/v2/capturesProcess/rust.ts", "../../autocompletion/v2/capturesProcess/c.ts", "../../autocompletion/v2/capturesProcess/cpp.ts", "../../autocompletion/v2/capturesProcess/index.ts", "../../autocompletion/v2/dependenciesProcess/queries/go.ts", "../../autocompletion/v2/dependenciesProcess/queries/typescript.ts", "../../autocompletion/v2/dependenciesProcess/queries/javascript.ts", "../../autocompletion/v2/dependenciesProcess/queries/java.ts", "../../autocompletion/v2/dependenciesProcess/queries/python.ts", "../../autocompletion/v2/dependenciesProcess/queries/jsx.ts", "../../autocompletion/v2/dependenciesProcess/queries/tsx.ts", "../../autocompletion/v2/dependenciesProcess/go.ts", "../../autocompletion/v2/dependenciesProcess/typescript.ts", "../../autocompletion/v2/dependenciesProcess/javascript.ts", "../../autocompletion/v2/dependenciesProcess/java.ts", "../../autocompletion/v2/dependenciesProcess/python.ts", "../../autocompletion/v2/dependenciesProcess/jsx.ts", "../../autocompletion/v2/dependenciesProcess/tsx.ts", "../../autocompletion/v2/dependenciesProcess/index.ts", "../../autocompletion/v2/utils/languageCommentUtils.ts", "../../autocompletion/v2/utils/treeUtils.ts", "../cli.ts"], + "sourcesContent": ["var Module=void 0!==Module?Module:{},TreeSitter=function(){var initPromise,document=\"object\"==typeof window?{currentScript:window.document.currentScript}:null;class Parser{constructor(){this.initialize()}initialize(){throw new Error(\"cannot construct a Parser before calling `init()`\")}static init(moduleOptions){return initPromise||(Module=Object.assign({},Module,moduleOptions),initPromise=new Promise((resolveInitPromise=>{var moduleOverrides=Object.assign({},Module),arguments_=[],thisProgram=\"./this.program\",quit_=(e,t)=>{throw t},ENVIRONMENT_IS_WEB=\"object\"==typeof window,ENVIRONMENT_IS_WORKER=\"function\"==typeof importScripts,ENVIRONMENT_IS_NODE=\"object\"==typeof process&&\"object\"==typeof process.versions&&\"string\"==typeof process.versions.node,scriptDirectory=\"\",read_,readAsync,readBinary;function locateFile(e){return Module.locateFile?Module.locateFile(e,scriptDirectory):scriptDirectory+e}if(ENVIRONMENT_IS_NODE){var fs=require(\"fs\"),nodePath=require(\"path\");scriptDirectory=ENVIRONMENT_IS_WORKER?nodePath.dirname(scriptDirectory)+\"/\":__dirname+\"/\",read_=(e,t)=>(e=isFileURI(e)?new URL(e):nodePath.normalize(e),fs.readFileSync(e,t?void 0:\"utf8\")),readBinary=e=>{var t=read_(e,!0);return t.buffer||(t=new Uint8Array(t)),t},readAsync=(e,t,_,s=!0)=>{e=isFileURI(e)?new URL(e):nodePath.normalize(e),fs.readFile(e,s?void 0:\"utf8\",((e,r)=>{e?_(e):t(s?r.buffer:r)}))},!Module.thisProgram&&process.argv.length>1&&(thisProgram=process.argv[1].replace(/\\\\/g,\"/\")),arguments_=process.argv.slice(2),\"undefined\"!=typeof module&&(module.exports=Module),quit_=(e,t)=>{throw process.exitCode=e,t}}else(ENVIRONMENT_IS_WEB||ENVIRONMENT_IS_WORKER)&&(ENVIRONMENT_IS_WORKER?scriptDirectory=self.location.href:void 0!==document&&document.currentScript&&(scriptDirectory=document.currentScript.src),scriptDirectory=scriptDirectory.startsWith(\"blob:\")?\"\":scriptDirectory.substr(0,scriptDirectory.replace(/[?#].*/,\"\").lastIndexOf(\"/\")+1),read_=e=>{var t=new XMLHttpRequest;return t.open(\"GET\",e,!1),t.send(null),t.responseText},ENVIRONMENT_IS_WORKER&&(readBinary=e=>{var t=new XMLHttpRequest;return t.open(\"GET\",e,!1),t.responseType=\"arraybuffer\",t.send(null),new Uint8Array(t.response)}),readAsync=(e,t,_)=>{var s=new XMLHttpRequest;s.open(\"GET\",e,!0),s.responseType=\"arraybuffer\",s.onload=()=>{200==s.status||0==s.status&&s.response?t(s.response):_()},s.onerror=_,s.send(null)});var out=Module.print||console.log.bind(console),err=Module.printErr||console.error.bind(console);Object.assign(Module,moduleOverrides),moduleOverrides=null,Module.arguments&&(arguments_=Module.arguments),Module.thisProgram&&(thisProgram=Module.thisProgram),Module.quit&&(quit_=Module.quit);var dynamicLibraries=Module.dynamicLibraries||[],wasmBinary,wasmMemory;Module.wasmBinary&&(wasmBinary=Module.wasmBinary),\"object\"!=typeof WebAssembly&&abort(\"no native wasm support detected\");var ABORT=!1,EXITSTATUS,HEAP8,HEAPU8,HEAP16,HEAPU16,HEAP32,HEAPU32,HEAPF32,HEAPF64;function updateMemoryViews(){var e=wasmMemory.buffer;Module.HEAP8=HEAP8=new Int8Array(e),Module.HEAP16=HEAP16=new Int16Array(e),Module.HEAPU8=HEAPU8=new Uint8Array(e),Module.HEAPU16=HEAPU16=new Uint16Array(e),Module.HEAP32=HEAP32=new Int32Array(e),Module.HEAPU32=HEAPU32=new Uint32Array(e),Module.HEAPF32=HEAPF32=new Float32Array(e),Module.HEAPF64=HEAPF64=new Float64Array(e)}var INITIAL_MEMORY=Module.INITIAL_MEMORY||33554432;wasmMemory=Module.wasmMemory?Module.wasmMemory:new WebAssembly.Memory({initial:INITIAL_MEMORY/65536,maximum:32768}),updateMemoryViews(),INITIAL_MEMORY=wasmMemory.buffer.byteLength;var __ATPRERUN__=[],__ATINIT__=[],__ATMAIN__=[],__ATPOSTRUN__=[],__RELOC_FUNCS__=[],runtimeInitialized=!1;function preRun(){if(Module.preRun)for(\"function\"==typeof Module.preRun&&(Module.preRun=[Module.preRun]);Module.preRun.length;)addOnPreRun(Module.preRun.shift());callRuntimeCallbacks(__ATPRERUN__)}function initRuntime(){runtimeInitialized=!0,callRuntimeCallbacks(__RELOC_FUNCS__),callRuntimeCallbacks(__ATINIT__)}function preMain(){callRuntimeCallbacks(__ATMAIN__)}function postRun(){if(Module.postRun)for(\"function\"==typeof Module.postRun&&(Module.postRun=[Module.postRun]);Module.postRun.length;)addOnPostRun(Module.postRun.shift());callRuntimeCallbacks(__ATPOSTRUN__)}function addOnPreRun(e){__ATPRERUN__.unshift(e)}function addOnInit(e){__ATINIT__.unshift(e)}function addOnPostRun(e){__ATPOSTRUN__.unshift(e)}var runDependencies=0,runDependencyWatcher=null,dependenciesFulfilled=null;function getUniqueRunDependency(e){return e}function addRunDependency(e){runDependencies++,Module.monitorRunDependencies?.(runDependencies)}function removeRunDependency(e){if(runDependencies--,Module.monitorRunDependencies?.(runDependencies),0==runDependencies&&(null!==runDependencyWatcher&&(clearInterval(runDependencyWatcher),runDependencyWatcher=null),dependenciesFulfilled)){var t=dependenciesFulfilled;dependenciesFulfilled=null,t()}}function abort(e){throw Module.onAbort?.(e),err(e=\"Aborted(\"+e+\")\"),ABORT=!0,EXITSTATUS=1,e+=\". Build with -sASSERTIONS for more info.\",new WebAssembly.RuntimeError(e)}var dataURIPrefix=\"data:application/octet-stream;base64,\",isDataURI=e=>e.startsWith(dataURIPrefix),isFileURI=e=>e.startsWith(\"file://\"),wasmBinaryFile;function getBinarySync(e){if(e==wasmBinaryFile&&wasmBinary)return new Uint8Array(wasmBinary);if(readBinary)return readBinary(e);throw\"both async and sync fetching of the wasm failed\"}function getBinaryPromise(e){if(!wasmBinary&&(ENVIRONMENT_IS_WEB||ENVIRONMENT_IS_WORKER)){if(\"function\"==typeof fetch&&!isFileURI(e))return fetch(e,{credentials:\"same-origin\"}).then((t=>{if(!t.ok)throw`failed to load wasm binary file at '${e}'`;return t.arrayBuffer()})).catch((()=>getBinarySync(e)));if(readAsync)return new Promise(((t,_)=>{readAsync(e,(e=>t(new Uint8Array(e))),_)}))}return Promise.resolve().then((()=>getBinarySync(e)))}function instantiateArrayBuffer(e,t,_){return getBinaryPromise(e).then((e=>WebAssembly.instantiate(e,t))).then(_,(e=>{err(`failed to asynchronously prepare wasm: ${e}`),abort(e)}))}function instantiateAsync(e,t,_,s){return e||\"function\"!=typeof WebAssembly.instantiateStreaming||isDataURI(t)||isFileURI(t)||ENVIRONMENT_IS_NODE||\"function\"!=typeof fetch?instantiateArrayBuffer(t,_,s):fetch(t,{credentials:\"same-origin\"}).then((e=>WebAssembly.instantiateStreaming(e,_).then(s,(function(e){return err(`wasm streaming compile failed: ${e}`),err(\"falling back to ArrayBuffer instantiation\"),instantiateArrayBuffer(t,_,s)}))))}function createWasm(){var e={env:wasmImports,wasi_snapshot_preview1:wasmImports,\"GOT.mem\":new Proxy(wasmImports,GOTHandler),\"GOT.func\":new Proxy(wasmImports,GOTHandler)};function t(e,t){wasmExports=e.exports,wasmExports=relocateExports(wasmExports,1024);var _=getDylinkMetadata(t);return _.neededDynlibs&&(dynamicLibraries=_.neededDynlibs.concat(dynamicLibraries)),mergeLibSymbols(wasmExports,\"main\"),LDSO.init(),loadDylibs(),addOnInit(wasmExports.__wasm_call_ctors),__RELOC_FUNCS__.push(wasmExports.__wasm_apply_data_relocs),removeRunDependency(\"wasm-instantiate\"),wasmExports}if(addRunDependency(\"wasm-instantiate\"),Module.instantiateWasm)try{return Module.instantiateWasm(e,t)}catch(e){return err(`Module.instantiateWasm callback failed with error: ${e}`),!1}return instantiateAsync(wasmBinary,wasmBinaryFile,e,(function(e){t(e.instance,e.module)})),{}}wasmBinaryFile=\"tree-sitter.wasm\",isDataURI(wasmBinaryFile)||(wasmBinaryFile=locateFile(wasmBinaryFile));var ASM_CONSTS={};function ExitStatus(e){this.name=\"ExitStatus\",this.message=`Program terminated with exit(${e})`,this.status=e}var GOT={},currentModuleWeakSymbols=new Set([]),GOTHandler={get(e,t){var _=GOT[t];return _||(_=GOT[t]=new WebAssembly.Global({value:\"i32\",mutable:!0})),currentModuleWeakSymbols.has(t)||(_.required=!0),_}},callRuntimeCallbacks=e=>{for(;e.length>0;)e.shift()(Module)},UTF8Decoder=\"undefined\"!=typeof TextDecoder?new TextDecoder(\"utf8\"):void 0,UTF8ArrayToString=(e,t,_)=>{for(var s=t+_,r=t;e[r]&&!(r>=s);)++r;if(r-t>16&&e.buffer&&UTF8Decoder)return UTF8Decoder.decode(e.subarray(t,r));for(var a=\"\";t>10,56320|1023&d)}}else a+=String.fromCharCode((31&o)<<6|n)}else a+=String.fromCharCode(o)}return a},getDylinkMetadata=e=>{var t=0,_=0;function s(){for(var _=0,s=1;;){var r=e[t++];if(_+=(127&r)*s,s*=128,!(128&r))break}return _}function r(){var _=s();return UTF8ArrayToString(e,(t+=_)-_,_)}function a(e,t){if(e)throw new Error(t)}var o=\"dylink.0\";if(e instanceof WebAssembly.Module){var n=WebAssembly.Module.customSections(e,o);0===n.length&&(o=\"dylink\",n=WebAssembly.Module.customSections(e,o)),a(0===n.length,\"need dylink section\"),_=(e=new Uint8Array(n[0])).length}else{a(!(1836278016==new Uint32Array(new Uint8Array(e.subarray(0,24)).buffer)[0]),\"need to see wasm magic number\"),a(0!==e[8],\"need the dylink section to be first\"),t=9;var l=s();_=t+l,o=r()}var d={neededDynlibs:[],tlsExports:new Set,weakImports:new Set};if(\"dylink\"==o){d.memorySize=s(),d.memoryAlign=s(),d.tableSize=s(),d.tableAlign=s();for(var u=s(),m=0;m>1];case\"i32\":return HEAP32[e>>2];case\"i64\":abort(\"to do getValue(i64) use WASM_BIGINT\");case\"float\":return HEAPF32[e>>2];case\"double\":return HEAPF64[e>>3];case\"*\":return HEAPU32[e>>2];default:abort(`invalid type for getValue: ${t}`)}}var newDSO=(e,t,_)=>{var s={refcount:1/0,name:e,exports:_,global:!0};return LDSO.loadedLibsByName[e]=s,null!=t&&(LDSO.loadedLibsByHandle[t]=s),s},LDSO={loadedLibsByName:{},loadedLibsByHandle:{},init(){newDSO(\"__main__\",0,wasmImports)}},___heap_base=78096,zeroMemory=(e,t)=>(HEAPU8.fill(0,e,e+t),e),alignMemory=(e,t)=>Math.ceil(e/t)*t,getMemory=e=>{if(runtimeInitialized)return zeroMemory(_malloc(e),e);var t=___heap_base,_=t+alignMemory(e,16);return ___heap_base=_,GOT.__heap_base.value=_,t},isInternalSym=e=>[\"__cpp_exception\",\"__c_longjmp\",\"__wasm_apply_data_relocs\",\"__dso_handle\",\"__tls_size\",\"__tls_align\",\"__set_stack_limits\",\"_emscripten_tls_init\",\"__wasm_init_tls\",\"__wasm_call_ctors\",\"__start_em_asm\",\"__stop_em_asm\",\"__start_em_js\",\"__stop_em_js\"].includes(e)||e.startsWith(\"__em_js__\"),uleb128Encode=(e,t)=>{e<128?t.push(e):t.push(e%128|128,e>>7)},sigToWasmTypes=e=>{for(var t={i:\"i32\",j:\"i64\",f:\"f32\",d:\"f64\",e:\"externref\",p:\"i32\"},_={parameters:[],results:\"v\"==e[0]?[]:[t[e[0]]]},s=1;s{var _=e.slice(0,1),s=e.slice(1),r={i:127,p:127,j:126,f:125,d:124,e:111};t.push(96),uleb128Encode(s.length,t);for(var a=0;a{if(\"function\"==typeof WebAssembly.Function)return new WebAssembly.Function(sigToWasmTypes(t),e);var _=[1];generateFuncType(t,_);var s=[0,97,115,109,1,0,0,0,1];uleb128Encode(_.length,s),s.push(..._),s.push(2,7,1,1,101,1,102,0,0,7,5,1,1,102,0,0);var r=new WebAssembly.Module(new Uint8Array(s));return new WebAssembly.Instance(r,{e:{f:e}}).exports.f},wasmTableMirror=[],wasmTable=new WebAssembly.Table({initial:27,element:\"anyfunc\"}),getWasmTableEntry=e=>{var t=wasmTableMirror[e];return t||(e>=wasmTableMirror.length&&(wasmTableMirror.length=e+1),wasmTableMirror[e]=t=wasmTable.get(e)),t},updateTableMap=(e,t)=>{if(functionsInTableMap)for(var _=e;_(functionsInTableMap||(functionsInTableMap=new WeakMap,updateTableMap(0,wasmTable.length)),functionsInTableMap.get(e)||0),freeTableIndexes=[],getEmptyTableSlot=()=>{if(freeTableIndexes.length)return freeTableIndexes.pop();try{wasmTable.grow(1)}catch(e){if(!(e instanceof RangeError))throw e;throw\"Unable to grow wasm table. Set ALLOW_TABLE_GROWTH.\"}return wasmTable.length-1},setWasmTableEntry=(e,t)=>{wasmTable.set(e,t),wasmTableMirror[e]=wasmTable.get(e)},addFunction=(e,t)=>{var _=getFunctionAddress(e);if(_)return _;var s=getEmptyTableSlot();try{setWasmTableEntry(s,e)}catch(_){if(!(_ instanceof TypeError))throw _;var r=convertJsFunctionToWasm(e,t);setWasmTableEntry(s,r)}return functionsInTableMap.set(e,s),s},updateGOT=(e,t)=>{for(var _ in e)if(!isInternalSym(_)){var s=e[_];_.startsWith(\"orig$\")&&(_=_.split(\"$\")[1],t=!0),GOT[_]||=new WebAssembly.Global({value:\"i32\",mutable:!0}),(t||0==GOT[_].value)&&(\"function\"==typeof s?GOT[_].value=addFunction(s):\"number\"==typeof s?GOT[_].value=s:err(`unhandled export type for '${_}': ${typeof s}`))}},relocateExports=(e,t,_)=>{var s={};for(var r in e){var a=e[r];\"object\"==typeof a&&(a=a.value),\"number\"==typeof a&&(a+=t),s[r]=a}return updateGOT(s,_),s},isSymbolDefined=e=>{var t=wasmImports[e];return!(!t||t.stub)},dynCallLegacy=(e,t,_)=>(0,Module[\"dynCall_\"+e])(t,..._),dynCall=(e,t,_=[])=>e.includes(\"j\")?dynCallLegacy(e,t,_):getWasmTableEntry(t)(..._),createInvokeFunction=e=>function(){var t=stackSave();try{return dynCall(e,arguments[0],Array.prototype.slice.call(arguments,1))}catch(e){if(stackRestore(t),e!==e+0)throw e;_setThrew(1,0)}},resolveGlobalSymbol=(e,t=!1)=>{var _;return t&&\"orig$\"+e in wasmImports&&(e=\"orig$\"+e),isSymbolDefined(e)?_=wasmImports[e]:e.startsWith(\"invoke_\")&&(_=wasmImports[e]=createInvokeFunction(e.split(\"_\")[1])),{sym:_,name:e}},UTF8ToString=(e,t)=>e?UTF8ArrayToString(HEAPU8,e,t):\"\",loadWebAssemblyModule=(binary,flags,libName,localScope,handle)=>{var metadata=getDylinkMetadata(binary);function loadModule(){var firstLoad=!handle||!HEAP8[handle+8];if(firstLoad){var memAlign=Math.pow(2,metadata.memoryAlign),memoryBase=metadata.memorySize?alignMemory(getMemory(metadata.memorySize+memAlign),memAlign):0,tableBase=metadata.tableSize?wasmTable.length:0;handle&&(HEAP8[handle+8]=1,HEAPU32[handle+12>>2]=memoryBase,HEAP32[handle+16>>2]=metadata.memorySize,HEAPU32[handle+20>>2]=tableBase,HEAP32[handle+24>>2]=metadata.tableSize)}else memoryBase=HEAPU32[handle+12>>2],tableBase=HEAPU32[handle+20>>2];var tableGrowthNeeded=tableBase+metadata.tableSize-wasmTable.length,moduleExports;function resolveSymbol(e){var t=resolveGlobalSymbol(e).sym;return!t&&localScope&&(t=localScope[e]),t||(t=moduleExports[e]),t}tableGrowthNeeded>0&&wasmTable.grow(tableGrowthNeeded);var proxyHandler={get(e,t){switch(t){case\"__memory_base\":return memoryBase;case\"__table_base\":return tableBase}if(t in wasmImports&&!wasmImports[t].stub)return wasmImports[t];var _;t in e||(e[t]=(...e)=>(_||=resolveSymbol(t),_(...e)));return e[t]}},proxy=new Proxy({},proxyHandler),info={\"GOT.mem\":new Proxy({},GOTHandler),\"GOT.func\":new Proxy({},GOTHandler),env:proxy,wasi_snapshot_preview1:proxy};function postInstantiation(module,instance){function addEmAsm(addr,body){for(var args=[],arity=0;arity<16&&-1!=body.indexOf(\"$\"+arity);arity++)args.push(\"$\"+arity);args=args.join(\",\");var func=`(${args}) => { ${body} };`;ASM_CONSTS[start]=eval(func)}if(updateTableMap(tableBase,metadata.tableSize),moduleExports=relocateExports(instance.exports,memoryBase),flags.allowUndefined||reportUndefinedSymbols(),\"__start_em_asm\"in moduleExports)for(var start=moduleExports.__start_em_asm,stop=moduleExports.__stop_em_asm;start ${body};`;moduleExports[name]=eval(func)}for(var name in moduleExports)if(name.startsWith(\"__em_js__\")){var start=moduleExports[name],jsString=UTF8ToString(start),parts=jsString.split(\"<::>\");addEmJs(name.replace(\"__em_js__\",\"\"),parts[0],parts[1]),delete moduleExports[name]}var applyRelocs=moduleExports.__wasm_apply_data_relocs;applyRelocs&&(runtimeInitialized?applyRelocs():__RELOC_FUNCS__.push(applyRelocs));var init=moduleExports.__wasm_call_ctors;return init&&(runtimeInitialized?init():__ATINIT__.push(init)),moduleExports}if(flags.loadAsync){if(binary instanceof WebAssembly.Module){var instance=new WebAssembly.Instance(binary,info);return Promise.resolve(postInstantiation(binary,instance))}return WebAssembly.instantiate(binary,info).then((e=>postInstantiation(e.module,e.instance)))}var module=binary instanceof WebAssembly.Module?binary:new WebAssembly.Module(binary),instance=new WebAssembly.Instance(module,info);return postInstantiation(module,instance)}return currentModuleWeakSymbols=metadata.weakImports,flags.loadAsync?metadata.neededDynlibs.reduce(((e,t)=>e.then((()=>loadDynamicLibrary(t,flags)))),Promise.resolve()).then(loadModule):(metadata.neededDynlibs.forEach((e=>loadDynamicLibrary(e,flags,localScope))),loadModule())},mergeLibSymbols=(e,t)=>{for(var[_,s]of Object.entries(e)){const e=e=>{isSymbolDefined(e)||(wasmImports[e]=s)};e(_);const t=\"__main_argc_argv\";\"main\"==_&&e(t),_==t&&e(\"main\"),_.startsWith(\"dynCall_\")&&!Module.hasOwnProperty(_)&&(Module[_]=s)}},asyncLoad=(e,t,_,s)=>{var r=s?\"\":getUniqueRunDependency(`al ${e}`);readAsync(e,(e=>{t(new Uint8Array(e)),r&&removeRunDependency(r)}),(t=>{if(!_)throw`Loading data file \"${e}\" failed.`;_()})),r&&addRunDependency(r)};function loadDynamicLibrary(e,t={global:!0,nodelete:!0},_,s){var r=LDSO.loadedLibsByName[e];if(r)return t.global?r.global||(r.global=!0,mergeLibSymbols(r.exports,e)):_&&Object.assign(_,r.exports),t.nodelete&&r.refcount!==1/0&&(r.refcount=1/0),r.refcount++,s&&(LDSO.loadedLibsByHandle[s]=r),!t.loadAsync||Promise.resolve(!0);function a(){if(s){var _=HEAPU32[s+28>>2],r=HEAPU32[s+32>>2];if(_&&r){var a=HEAP8.slice(_,_+r);return t.loadAsync?Promise.resolve(a):a}}var o=locateFile(e);if(t.loadAsync)return new Promise((function(e,t){asyncLoad(o,e,t)}));if(!readBinary)throw new Error(`${o}: file not found, and synchronous loading of external files is not available`);return readBinary(o)}function o(){return t.loadAsync?a().then((r=>loadWebAssemblyModule(r,t,e,_,s))):loadWebAssemblyModule(a(),t,e,_,s)}function n(t){r.global?mergeLibSymbols(t,e):_&&Object.assign(_,t),r.exports=t}return(r=newDSO(e,s,\"loading\")).refcount=t.nodelete?1/0:1,r.global=t.global,t.loadAsync?o().then((e=>(n(e),!0))):(n(o()),!0)}var reportUndefinedSymbols=()=>{for(var[e,t]of Object.entries(GOT))if(0==t.value){var _=resolveGlobalSymbol(e,!0).sym;if(!_&&!t.required)continue;if(\"function\"==typeof _)t.value=addFunction(_,_.sig);else{if(\"number\"!=typeof _)throw new Error(`bad export type for '${e}': ${typeof _}`);t.value=_}}},loadDylibs=()=>{dynamicLibraries.length?(addRunDependency(\"loadDylibs\"),dynamicLibraries.reduce(((e,t)=>e.then((()=>loadDynamicLibrary(t,{loadAsync:!0,global:!0,nodelete:!0,allowUndefined:!0})))),Promise.resolve()).then((()=>{reportUndefinedSymbols(),removeRunDependency(\"loadDylibs\")}))):reportUndefinedSymbols()},noExitRuntime=Module.noExitRuntime||!0;function setValue(e,t,_=\"i8\"){switch(_.endsWith(\"*\")&&(_=\"*\"),_){case\"i1\":case\"i8\":HEAP8[e]=t;break;case\"i16\":HEAP16[e>>1]=t;break;case\"i32\":HEAP32[e>>2]=t;break;case\"i64\":abort(\"to do setValue(i64) use WASM_BIGINT\");case\"float\":HEAPF32[e>>2]=t;break;case\"double\":HEAPF64[e>>3]=t;break;case\"*\":HEAPU32[e>>2]=t;break;default:abort(`invalid type for setValue: ${_}`)}}var ___memory_base=new WebAssembly.Global({value:\"i32\",mutable:!1},1024),___stack_pointer=new WebAssembly.Global({value:\"i32\",mutable:!0},78096),___table_base=new WebAssembly.Global({value:\"i32\",mutable:!1},1),nowIsMonotonic=1,__emscripten_get_now_is_monotonic=()=>nowIsMonotonic;__emscripten_get_now_is_monotonic.sig=\"i\";var _abort=()=>{abort(\"\")};_abort.sig=\"v\";var _emscripten_date_now=()=>Date.now(),_emscripten_get_now;_emscripten_date_now.sig=\"d\",_emscripten_get_now=()=>performance.now(),_emscripten_get_now.sig=\"d\";var _emscripten_memcpy_js=(e,t,_)=>HEAPU8.copyWithin(e,t,t+_);_emscripten_memcpy_js.sig=\"vppp\";var getHeapMax=()=>2147483648,growMemory=e=>{var t=(e-wasmMemory.buffer.byteLength+65535)/65536;try{return wasmMemory.grow(t),updateMemoryViews(),1}catch(e){}},_emscripten_resize_heap=e=>{var t=HEAPU8.length;e>>>=0;var _=getHeapMax();if(e>_)return!1;for(var s,r,a=1;a<=4;a*=2){var o=t*(1+.2/a);o=Math.min(o,e+100663296);var n=Math.min(_,(s=Math.max(e,o))+((r=65536)-s%r)%r);if(growMemory(n))return!0}return!1};_emscripten_resize_heap.sig=\"ip\";var _fd_close=e=>52;_fd_close.sig=\"ii\";var convertI32PairToI53Checked=(e,t)=>t+2097152>>>0<4194305-!!e?(e>>>0)+4294967296*t:NaN;function _fd_seek(e,t,_,s,r){convertI32PairToI53Checked(t,_);return 70}_fd_seek.sig=\"iiiiip\";var printCharBuffers=[null,[],[]],printChar=(e,t)=>{var _=printCharBuffers[e];0===t||10===t?((1===e?out:err)(UTF8ArrayToString(_,0)),_.length=0):_.push(t)},SYSCALLS={varargs:void 0,get(){var e=HEAP32[+SYSCALLS.varargs>>2];return SYSCALLS.varargs+=4,e},getp:()=>SYSCALLS.get(),getStr:e=>UTF8ToString(e)},_fd_write=(e,t,_,s)=>{for(var r=0,a=0;a<_;a++){var o=HEAPU32[t>>2],n=HEAPU32[t+4>>2];t+=8;for(var l=0;l>2]=r,0};function _tree_sitter_log_callback(e,t){if(currentLogCallback){const _=UTF8ToString(t);currentLogCallback(_,0!==e)}}function _tree_sitter_parse_callback(e,t,_,s,r){const a=currentParseCallback(t,{row:_,column:s});\"string\"==typeof a?(setValue(r,a.length,\"i32\"),stringToUTF16(a,e,10240)):setValue(r,0,\"i32\")}_fd_write.sig=\"iippp\";var runtimeKeepaliveCounter=0,keepRuntimeAlive=()=>noExitRuntime||runtimeKeepaliveCounter>0,_proc_exit=e=>{EXITSTATUS=e,keepRuntimeAlive()||(Module.onExit?.(e),ABORT=!0),quit_(e,new ExitStatus(e))};_proc_exit.sig=\"vi\";var exitJS=(e,t)=>{EXITSTATUS=e,_proc_exit(e)},handleException=e=>{if(e instanceof ExitStatus||\"unwind\"==e)return EXITSTATUS;quit_(1,e)},lengthBytesUTF8=e=>{for(var t=0,_=0;_=55296&&s<=57343?(t+=4,++_):t+=3}return t},stringToUTF8Array=(e,t,_,s)=>{if(!(s>0))return 0;for(var r=_,a=_+s-1,o=0;o=55296&&n<=57343)n=65536+((1023&n)<<10)|1023&e.charCodeAt(++o);if(n<=127){if(_>=a)break;t[_++]=n}else if(n<=2047){if(_+1>=a)break;t[_++]=192|n>>6,t[_++]=128|63&n}else if(n<=65535){if(_+2>=a)break;t[_++]=224|n>>12,t[_++]=128|n>>6&63,t[_++]=128|63&n}else{if(_+3>=a)break;t[_++]=240|n>>18,t[_++]=128|n>>12&63,t[_++]=128|n>>6&63,t[_++]=128|63&n}}return t[_]=0,_-r},stringToUTF8=(e,t,_)=>stringToUTF8Array(e,HEAPU8,t,_),stringToUTF8OnStack=e=>{var t=lengthBytesUTF8(e)+1,_=stackAlloc(t);return stringToUTF8(e,_,t),_},stringToUTF16=(e,t,_)=>{if(_??=2147483647,_<2)return 0;for(var s=t,r=(_-=2)<2*e.length?_/2:e.length,a=0;a>1]=o,t+=2}return HEAP16[t>>1]=0,t-s},AsciiToString=e=>{for(var t=\"\";;){var _=HEAPU8[e++];if(!_)return t;t+=String.fromCharCode(_)}},wasmImports={__heap_base:___heap_base,__indirect_function_table:wasmTable,__memory_base:___memory_base,__stack_pointer:___stack_pointer,__table_base:___table_base,_emscripten_get_now_is_monotonic:__emscripten_get_now_is_monotonic,abort:_abort,emscripten_get_now:_emscripten_get_now,emscripten_memcpy_js:_emscripten_memcpy_js,emscripten_resize_heap:_emscripten_resize_heap,fd_close:_fd_close,fd_seek:_fd_seek,fd_write:_fd_write,memory:wasmMemory,tree_sitter_log_callback:_tree_sitter_log_callback,tree_sitter_parse_callback:_tree_sitter_parse_callback},wasmExports=createWasm(),___wasm_call_ctors=()=>(___wasm_call_ctors=wasmExports.__wasm_call_ctors)(),___wasm_apply_data_relocs=()=>(___wasm_apply_data_relocs=wasmExports.__wasm_apply_data_relocs)(),_malloc=Module._malloc=e=>(_malloc=Module._malloc=wasmExports.malloc)(e),_calloc=Module._calloc=(e,t)=>(_calloc=Module._calloc=wasmExports.calloc)(e,t),_realloc=Module._realloc=(e,t)=>(_realloc=Module._realloc=wasmExports.realloc)(e,t),_free=Module._free=e=>(_free=Module._free=wasmExports.free)(e),_ts_language_symbol_count=Module._ts_language_symbol_count=e=>(_ts_language_symbol_count=Module._ts_language_symbol_count=wasmExports.ts_language_symbol_count)(e),_ts_language_state_count=Module._ts_language_state_count=e=>(_ts_language_state_count=Module._ts_language_state_count=wasmExports.ts_language_state_count)(e),_ts_language_version=Module._ts_language_version=e=>(_ts_language_version=Module._ts_language_version=wasmExports.ts_language_version)(e),_ts_language_field_count=Module._ts_language_field_count=e=>(_ts_language_field_count=Module._ts_language_field_count=wasmExports.ts_language_field_count)(e),_ts_language_next_state=Module._ts_language_next_state=(e,t,_)=>(_ts_language_next_state=Module._ts_language_next_state=wasmExports.ts_language_next_state)(e,t,_),_ts_language_symbol_name=Module._ts_language_symbol_name=(e,t)=>(_ts_language_symbol_name=Module._ts_language_symbol_name=wasmExports.ts_language_symbol_name)(e,t),_ts_language_symbol_for_name=Module._ts_language_symbol_for_name=(e,t,_,s)=>(_ts_language_symbol_for_name=Module._ts_language_symbol_for_name=wasmExports.ts_language_symbol_for_name)(e,t,_,s),_strncmp=Module._strncmp=(e,t,_)=>(_strncmp=Module._strncmp=wasmExports.strncmp)(e,t,_),_ts_language_symbol_type=Module._ts_language_symbol_type=(e,t)=>(_ts_language_symbol_type=Module._ts_language_symbol_type=wasmExports.ts_language_symbol_type)(e,t),_ts_language_field_name_for_id=Module._ts_language_field_name_for_id=(e,t)=>(_ts_language_field_name_for_id=Module._ts_language_field_name_for_id=wasmExports.ts_language_field_name_for_id)(e,t),_ts_lookahead_iterator_new=Module._ts_lookahead_iterator_new=(e,t)=>(_ts_lookahead_iterator_new=Module._ts_lookahead_iterator_new=wasmExports.ts_lookahead_iterator_new)(e,t),_ts_lookahead_iterator_delete=Module._ts_lookahead_iterator_delete=e=>(_ts_lookahead_iterator_delete=Module._ts_lookahead_iterator_delete=wasmExports.ts_lookahead_iterator_delete)(e),_ts_lookahead_iterator_reset_state=Module._ts_lookahead_iterator_reset_state=(e,t)=>(_ts_lookahead_iterator_reset_state=Module._ts_lookahead_iterator_reset_state=wasmExports.ts_lookahead_iterator_reset_state)(e,t),_ts_lookahead_iterator_reset=Module._ts_lookahead_iterator_reset=(e,t,_)=>(_ts_lookahead_iterator_reset=Module._ts_lookahead_iterator_reset=wasmExports.ts_lookahead_iterator_reset)(e,t,_),_ts_lookahead_iterator_next=Module._ts_lookahead_iterator_next=e=>(_ts_lookahead_iterator_next=Module._ts_lookahead_iterator_next=wasmExports.ts_lookahead_iterator_next)(e),_ts_lookahead_iterator_current_symbol=Module._ts_lookahead_iterator_current_symbol=e=>(_ts_lookahead_iterator_current_symbol=Module._ts_lookahead_iterator_current_symbol=wasmExports.ts_lookahead_iterator_current_symbol)(e),_memset=Module._memset=(e,t,_)=>(_memset=Module._memset=wasmExports.memset)(e,t,_),_memcpy=Module._memcpy=(e,t,_)=>(_memcpy=Module._memcpy=wasmExports.memcpy)(e,t,_),_ts_parser_delete=Module._ts_parser_delete=e=>(_ts_parser_delete=Module._ts_parser_delete=wasmExports.ts_parser_delete)(e),_ts_parser_reset=Module._ts_parser_reset=e=>(_ts_parser_reset=Module._ts_parser_reset=wasmExports.ts_parser_reset)(e),_ts_parser_set_language=Module._ts_parser_set_language=(e,t)=>(_ts_parser_set_language=Module._ts_parser_set_language=wasmExports.ts_parser_set_language)(e,t),_ts_parser_timeout_micros=Module._ts_parser_timeout_micros=e=>(_ts_parser_timeout_micros=Module._ts_parser_timeout_micros=wasmExports.ts_parser_timeout_micros)(e),_ts_parser_set_timeout_micros=Module._ts_parser_set_timeout_micros=(e,t,_)=>(_ts_parser_set_timeout_micros=Module._ts_parser_set_timeout_micros=wasmExports.ts_parser_set_timeout_micros)(e,t,_),_ts_parser_set_included_ranges=Module._ts_parser_set_included_ranges=(e,t,_)=>(_ts_parser_set_included_ranges=Module._ts_parser_set_included_ranges=wasmExports.ts_parser_set_included_ranges)(e,t,_),_memmove=Module._memmove=(e,t,_)=>(_memmove=Module._memmove=wasmExports.memmove)(e,t,_),_memcmp=Module._memcmp=(e,t,_)=>(_memcmp=Module._memcmp=wasmExports.memcmp)(e,t,_),_ts_query_new=Module._ts_query_new=(e,t,_,s,r)=>(_ts_query_new=Module._ts_query_new=wasmExports.ts_query_new)(e,t,_,s,r),_ts_query_delete=Module._ts_query_delete=e=>(_ts_query_delete=Module._ts_query_delete=wasmExports.ts_query_delete)(e),_iswspace=Module._iswspace=e=>(_iswspace=Module._iswspace=wasmExports.iswspace)(e),_iswalnum=Module._iswalnum=e=>(_iswalnum=Module._iswalnum=wasmExports.iswalnum)(e),_ts_query_pattern_count=Module._ts_query_pattern_count=e=>(_ts_query_pattern_count=Module._ts_query_pattern_count=wasmExports.ts_query_pattern_count)(e),_ts_query_capture_count=Module._ts_query_capture_count=e=>(_ts_query_capture_count=Module._ts_query_capture_count=wasmExports.ts_query_capture_count)(e),_ts_query_string_count=Module._ts_query_string_count=e=>(_ts_query_string_count=Module._ts_query_string_count=wasmExports.ts_query_string_count)(e),_ts_query_capture_name_for_id=Module._ts_query_capture_name_for_id=(e,t,_)=>(_ts_query_capture_name_for_id=Module._ts_query_capture_name_for_id=wasmExports.ts_query_capture_name_for_id)(e,t,_),_ts_query_string_value_for_id=Module._ts_query_string_value_for_id=(e,t,_)=>(_ts_query_string_value_for_id=Module._ts_query_string_value_for_id=wasmExports.ts_query_string_value_for_id)(e,t,_),_ts_query_predicates_for_pattern=Module._ts_query_predicates_for_pattern=(e,t,_)=>(_ts_query_predicates_for_pattern=Module._ts_query_predicates_for_pattern=wasmExports.ts_query_predicates_for_pattern)(e,t,_),_ts_query_disable_capture=Module._ts_query_disable_capture=(e,t,_)=>(_ts_query_disable_capture=Module._ts_query_disable_capture=wasmExports.ts_query_disable_capture)(e,t,_),_ts_tree_copy=Module._ts_tree_copy=e=>(_ts_tree_copy=Module._ts_tree_copy=wasmExports.ts_tree_copy)(e),_ts_tree_delete=Module._ts_tree_delete=e=>(_ts_tree_delete=Module._ts_tree_delete=wasmExports.ts_tree_delete)(e),_ts_init=Module._ts_init=()=>(_ts_init=Module._ts_init=wasmExports.ts_init)(),_ts_parser_new_wasm=Module._ts_parser_new_wasm=()=>(_ts_parser_new_wasm=Module._ts_parser_new_wasm=wasmExports.ts_parser_new_wasm)(),_ts_parser_enable_logger_wasm=Module._ts_parser_enable_logger_wasm=(e,t)=>(_ts_parser_enable_logger_wasm=Module._ts_parser_enable_logger_wasm=wasmExports.ts_parser_enable_logger_wasm)(e,t),_ts_parser_parse_wasm=Module._ts_parser_parse_wasm=(e,t,_,s,r)=>(_ts_parser_parse_wasm=Module._ts_parser_parse_wasm=wasmExports.ts_parser_parse_wasm)(e,t,_,s,r),_ts_parser_included_ranges_wasm=Module._ts_parser_included_ranges_wasm=e=>(_ts_parser_included_ranges_wasm=Module._ts_parser_included_ranges_wasm=wasmExports.ts_parser_included_ranges_wasm)(e),_ts_language_type_is_named_wasm=Module._ts_language_type_is_named_wasm=(e,t)=>(_ts_language_type_is_named_wasm=Module._ts_language_type_is_named_wasm=wasmExports.ts_language_type_is_named_wasm)(e,t),_ts_language_type_is_visible_wasm=Module._ts_language_type_is_visible_wasm=(e,t)=>(_ts_language_type_is_visible_wasm=Module._ts_language_type_is_visible_wasm=wasmExports.ts_language_type_is_visible_wasm)(e,t),_ts_tree_root_node_wasm=Module._ts_tree_root_node_wasm=e=>(_ts_tree_root_node_wasm=Module._ts_tree_root_node_wasm=wasmExports.ts_tree_root_node_wasm)(e),_ts_tree_root_node_with_offset_wasm=Module._ts_tree_root_node_with_offset_wasm=e=>(_ts_tree_root_node_with_offset_wasm=Module._ts_tree_root_node_with_offset_wasm=wasmExports.ts_tree_root_node_with_offset_wasm)(e),_ts_tree_edit_wasm=Module._ts_tree_edit_wasm=e=>(_ts_tree_edit_wasm=Module._ts_tree_edit_wasm=wasmExports.ts_tree_edit_wasm)(e),_ts_tree_included_ranges_wasm=Module._ts_tree_included_ranges_wasm=e=>(_ts_tree_included_ranges_wasm=Module._ts_tree_included_ranges_wasm=wasmExports.ts_tree_included_ranges_wasm)(e),_ts_tree_get_changed_ranges_wasm=Module._ts_tree_get_changed_ranges_wasm=(e,t)=>(_ts_tree_get_changed_ranges_wasm=Module._ts_tree_get_changed_ranges_wasm=wasmExports.ts_tree_get_changed_ranges_wasm)(e,t),_ts_tree_cursor_new_wasm=Module._ts_tree_cursor_new_wasm=e=>(_ts_tree_cursor_new_wasm=Module._ts_tree_cursor_new_wasm=wasmExports.ts_tree_cursor_new_wasm)(e),_ts_tree_cursor_delete_wasm=Module._ts_tree_cursor_delete_wasm=e=>(_ts_tree_cursor_delete_wasm=Module._ts_tree_cursor_delete_wasm=wasmExports.ts_tree_cursor_delete_wasm)(e),_ts_tree_cursor_reset_wasm=Module._ts_tree_cursor_reset_wasm=e=>(_ts_tree_cursor_reset_wasm=Module._ts_tree_cursor_reset_wasm=wasmExports.ts_tree_cursor_reset_wasm)(e),_ts_tree_cursor_reset_to_wasm=Module._ts_tree_cursor_reset_to_wasm=(e,t)=>(_ts_tree_cursor_reset_to_wasm=Module._ts_tree_cursor_reset_to_wasm=wasmExports.ts_tree_cursor_reset_to_wasm)(e,t),_ts_tree_cursor_goto_first_child_wasm=Module._ts_tree_cursor_goto_first_child_wasm=e=>(_ts_tree_cursor_goto_first_child_wasm=Module._ts_tree_cursor_goto_first_child_wasm=wasmExports.ts_tree_cursor_goto_first_child_wasm)(e),_ts_tree_cursor_goto_last_child_wasm=Module._ts_tree_cursor_goto_last_child_wasm=e=>(_ts_tree_cursor_goto_last_child_wasm=Module._ts_tree_cursor_goto_last_child_wasm=wasmExports.ts_tree_cursor_goto_last_child_wasm)(e),_ts_tree_cursor_goto_first_child_for_index_wasm=Module._ts_tree_cursor_goto_first_child_for_index_wasm=e=>(_ts_tree_cursor_goto_first_child_for_index_wasm=Module._ts_tree_cursor_goto_first_child_for_index_wasm=wasmExports.ts_tree_cursor_goto_first_child_for_index_wasm)(e),_ts_tree_cursor_goto_first_child_for_position_wasm=Module._ts_tree_cursor_goto_first_child_for_position_wasm=e=>(_ts_tree_cursor_goto_first_child_for_position_wasm=Module._ts_tree_cursor_goto_first_child_for_position_wasm=wasmExports.ts_tree_cursor_goto_first_child_for_position_wasm)(e),_ts_tree_cursor_goto_next_sibling_wasm=Module._ts_tree_cursor_goto_next_sibling_wasm=e=>(_ts_tree_cursor_goto_next_sibling_wasm=Module._ts_tree_cursor_goto_next_sibling_wasm=wasmExports.ts_tree_cursor_goto_next_sibling_wasm)(e),_ts_tree_cursor_goto_previous_sibling_wasm=Module._ts_tree_cursor_goto_previous_sibling_wasm=e=>(_ts_tree_cursor_goto_previous_sibling_wasm=Module._ts_tree_cursor_goto_previous_sibling_wasm=wasmExports.ts_tree_cursor_goto_previous_sibling_wasm)(e),_ts_tree_cursor_goto_descendant_wasm=Module._ts_tree_cursor_goto_descendant_wasm=(e,t)=>(_ts_tree_cursor_goto_descendant_wasm=Module._ts_tree_cursor_goto_descendant_wasm=wasmExports.ts_tree_cursor_goto_descendant_wasm)(e,t),_ts_tree_cursor_goto_parent_wasm=Module._ts_tree_cursor_goto_parent_wasm=e=>(_ts_tree_cursor_goto_parent_wasm=Module._ts_tree_cursor_goto_parent_wasm=wasmExports.ts_tree_cursor_goto_parent_wasm)(e),_ts_tree_cursor_current_node_type_id_wasm=Module._ts_tree_cursor_current_node_type_id_wasm=e=>(_ts_tree_cursor_current_node_type_id_wasm=Module._ts_tree_cursor_current_node_type_id_wasm=wasmExports.ts_tree_cursor_current_node_type_id_wasm)(e),_ts_tree_cursor_current_node_state_id_wasm=Module._ts_tree_cursor_current_node_state_id_wasm=e=>(_ts_tree_cursor_current_node_state_id_wasm=Module._ts_tree_cursor_current_node_state_id_wasm=wasmExports.ts_tree_cursor_current_node_state_id_wasm)(e),_ts_tree_cursor_current_node_is_named_wasm=Module._ts_tree_cursor_current_node_is_named_wasm=e=>(_ts_tree_cursor_current_node_is_named_wasm=Module._ts_tree_cursor_current_node_is_named_wasm=wasmExports.ts_tree_cursor_current_node_is_named_wasm)(e),_ts_tree_cursor_current_node_is_missing_wasm=Module._ts_tree_cursor_current_node_is_missing_wasm=e=>(_ts_tree_cursor_current_node_is_missing_wasm=Module._ts_tree_cursor_current_node_is_missing_wasm=wasmExports.ts_tree_cursor_current_node_is_missing_wasm)(e),_ts_tree_cursor_current_node_id_wasm=Module._ts_tree_cursor_current_node_id_wasm=e=>(_ts_tree_cursor_current_node_id_wasm=Module._ts_tree_cursor_current_node_id_wasm=wasmExports.ts_tree_cursor_current_node_id_wasm)(e),_ts_tree_cursor_start_position_wasm=Module._ts_tree_cursor_start_position_wasm=e=>(_ts_tree_cursor_start_position_wasm=Module._ts_tree_cursor_start_position_wasm=wasmExports.ts_tree_cursor_start_position_wasm)(e),_ts_tree_cursor_end_position_wasm=Module._ts_tree_cursor_end_position_wasm=e=>(_ts_tree_cursor_end_position_wasm=Module._ts_tree_cursor_end_position_wasm=wasmExports.ts_tree_cursor_end_position_wasm)(e),_ts_tree_cursor_start_index_wasm=Module._ts_tree_cursor_start_index_wasm=e=>(_ts_tree_cursor_start_index_wasm=Module._ts_tree_cursor_start_index_wasm=wasmExports.ts_tree_cursor_start_index_wasm)(e),_ts_tree_cursor_end_index_wasm=Module._ts_tree_cursor_end_index_wasm=e=>(_ts_tree_cursor_end_index_wasm=Module._ts_tree_cursor_end_index_wasm=wasmExports.ts_tree_cursor_end_index_wasm)(e),_ts_tree_cursor_current_field_id_wasm=Module._ts_tree_cursor_current_field_id_wasm=e=>(_ts_tree_cursor_current_field_id_wasm=Module._ts_tree_cursor_current_field_id_wasm=wasmExports.ts_tree_cursor_current_field_id_wasm)(e),_ts_tree_cursor_current_depth_wasm=Module._ts_tree_cursor_current_depth_wasm=e=>(_ts_tree_cursor_current_depth_wasm=Module._ts_tree_cursor_current_depth_wasm=wasmExports.ts_tree_cursor_current_depth_wasm)(e),_ts_tree_cursor_current_descendant_index_wasm=Module._ts_tree_cursor_current_descendant_index_wasm=e=>(_ts_tree_cursor_current_descendant_index_wasm=Module._ts_tree_cursor_current_descendant_index_wasm=wasmExports.ts_tree_cursor_current_descendant_index_wasm)(e),_ts_tree_cursor_current_node_wasm=Module._ts_tree_cursor_current_node_wasm=e=>(_ts_tree_cursor_current_node_wasm=Module._ts_tree_cursor_current_node_wasm=wasmExports.ts_tree_cursor_current_node_wasm)(e),_ts_node_symbol_wasm=Module._ts_node_symbol_wasm=e=>(_ts_node_symbol_wasm=Module._ts_node_symbol_wasm=wasmExports.ts_node_symbol_wasm)(e),_ts_node_field_name_for_child_wasm=Module._ts_node_field_name_for_child_wasm=(e,t)=>(_ts_node_field_name_for_child_wasm=Module._ts_node_field_name_for_child_wasm=wasmExports.ts_node_field_name_for_child_wasm)(e,t),_ts_node_children_by_field_id_wasm=Module._ts_node_children_by_field_id_wasm=(e,t)=>(_ts_node_children_by_field_id_wasm=Module._ts_node_children_by_field_id_wasm=wasmExports.ts_node_children_by_field_id_wasm)(e,t),_ts_node_first_child_for_byte_wasm=Module._ts_node_first_child_for_byte_wasm=e=>(_ts_node_first_child_for_byte_wasm=Module._ts_node_first_child_for_byte_wasm=wasmExports.ts_node_first_child_for_byte_wasm)(e),_ts_node_first_named_child_for_byte_wasm=Module._ts_node_first_named_child_for_byte_wasm=e=>(_ts_node_first_named_child_for_byte_wasm=Module._ts_node_first_named_child_for_byte_wasm=wasmExports.ts_node_first_named_child_for_byte_wasm)(e),_ts_node_grammar_symbol_wasm=Module._ts_node_grammar_symbol_wasm=e=>(_ts_node_grammar_symbol_wasm=Module._ts_node_grammar_symbol_wasm=wasmExports.ts_node_grammar_symbol_wasm)(e),_ts_node_child_count_wasm=Module._ts_node_child_count_wasm=e=>(_ts_node_child_count_wasm=Module._ts_node_child_count_wasm=wasmExports.ts_node_child_count_wasm)(e),_ts_node_named_child_count_wasm=Module._ts_node_named_child_count_wasm=e=>(_ts_node_named_child_count_wasm=Module._ts_node_named_child_count_wasm=wasmExports.ts_node_named_child_count_wasm)(e),_ts_node_child_wasm=Module._ts_node_child_wasm=(e,t)=>(_ts_node_child_wasm=Module._ts_node_child_wasm=wasmExports.ts_node_child_wasm)(e,t),_ts_node_named_child_wasm=Module._ts_node_named_child_wasm=(e,t)=>(_ts_node_named_child_wasm=Module._ts_node_named_child_wasm=wasmExports.ts_node_named_child_wasm)(e,t),_ts_node_child_by_field_id_wasm=Module._ts_node_child_by_field_id_wasm=(e,t)=>(_ts_node_child_by_field_id_wasm=Module._ts_node_child_by_field_id_wasm=wasmExports.ts_node_child_by_field_id_wasm)(e,t),_ts_node_next_sibling_wasm=Module._ts_node_next_sibling_wasm=e=>(_ts_node_next_sibling_wasm=Module._ts_node_next_sibling_wasm=wasmExports.ts_node_next_sibling_wasm)(e),_ts_node_prev_sibling_wasm=Module._ts_node_prev_sibling_wasm=e=>(_ts_node_prev_sibling_wasm=Module._ts_node_prev_sibling_wasm=wasmExports.ts_node_prev_sibling_wasm)(e),_ts_node_next_named_sibling_wasm=Module._ts_node_next_named_sibling_wasm=e=>(_ts_node_next_named_sibling_wasm=Module._ts_node_next_named_sibling_wasm=wasmExports.ts_node_next_named_sibling_wasm)(e),_ts_node_prev_named_sibling_wasm=Module._ts_node_prev_named_sibling_wasm=e=>(_ts_node_prev_named_sibling_wasm=Module._ts_node_prev_named_sibling_wasm=wasmExports.ts_node_prev_named_sibling_wasm)(e),_ts_node_descendant_count_wasm=Module._ts_node_descendant_count_wasm=e=>(_ts_node_descendant_count_wasm=Module._ts_node_descendant_count_wasm=wasmExports.ts_node_descendant_count_wasm)(e),_ts_node_parent_wasm=Module._ts_node_parent_wasm=e=>(_ts_node_parent_wasm=Module._ts_node_parent_wasm=wasmExports.ts_node_parent_wasm)(e),_ts_node_descendant_for_index_wasm=Module._ts_node_descendant_for_index_wasm=e=>(_ts_node_descendant_for_index_wasm=Module._ts_node_descendant_for_index_wasm=wasmExports.ts_node_descendant_for_index_wasm)(e),_ts_node_named_descendant_for_index_wasm=Module._ts_node_named_descendant_for_index_wasm=e=>(_ts_node_named_descendant_for_index_wasm=Module._ts_node_named_descendant_for_index_wasm=wasmExports.ts_node_named_descendant_for_index_wasm)(e),_ts_node_descendant_for_position_wasm=Module._ts_node_descendant_for_position_wasm=e=>(_ts_node_descendant_for_position_wasm=Module._ts_node_descendant_for_position_wasm=wasmExports.ts_node_descendant_for_position_wasm)(e),_ts_node_named_descendant_for_position_wasm=Module._ts_node_named_descendant_for_position_wasm=e=>(_ts_node_named_descendant_for_position_wasm=Module._ts_node_named_descendant_for_position_wasm=wasmExports.ts_node_named_descendant_for_position_wasm)(e),_ts_node_start_point_wasm=Module._ts_node_start_point_wasm=e=>(_ts_node_start_point_wasm=Module._ts_node_start_point_wasm=wasmExports.ts_node_start_point_wasm)(e),_ts_node_end_point_wasm=Module._ts_node_end_point_wasm=e=>(_ts_node_end_point_wasm=Module._ts_node_end_point_wasm=wasmExports.ts_node_end_point_wasm)(e),_ts_node_start_index_wasm=Module._ts_node_start_index_wasm=e=>(_ts_node_start_index_wasm=Module._ts_node_start_index_wasm=wasmExports.ts_node_start_index_wasm)(e),_ts_node_end_index_wasm=Module._ts_node_end_index_wasm=e=>(_ts_node_end_index_wasm=Module._ts_node_end_index_wasm=wasmExports.ts_node_end_index_wasm)(e),_ts_node_to_string_wasm=Module._ts_node_to_string_wasm=e=>(_ts_node_to_string_wasm=Module._ts_node_to_string_wasm=wasmExports.ts_node_to_string_wasm)(e),_ts_node_children_wasm=Module._ts_node_children_wasm=e=>(_ts_node_children_wasm=Module._ts_node_children_wasm=wasmExports.ts_node_children_wasm)(e),_ts_node_named_children_wasm=Module._ts_node_named_children_wasm=e=>(_ts_node_named_children_wasm=Module._ts_node_named_children_wasm=wasmExports.ts_node_named_children_wasm)(e),_ts_node_descendants_of_type_wasm=Module._ts_node_descendants_of_type_wasm=(e,t,_,s,r,a,o)=>(_ts_node_descendants_of_type_wasm=Module._ts_node_descendants_of_type_wasm=wasmExports.ts_node_descendants_of_type_wasm)(e,t,_,s,r,a,o),_ts_node_is_named_wasm=Module._ts_node_is_named_wasm=e=>(_ts_node_is_named_wasm=Module._ts_node_is_named_wasm=wasmExports.ts_node_is_named_wasm)(e),_ts_node_has_changes_wasm=Module._ts_node_has_changes_wasm=e=>(_ts_node_has_changes_wasm=Module._ts_node_has_changes_wasm=wasmExports.ts_node_has_changes_wasm)(e),_ts_node_has_error_wasm=Module._ts_node_has_error_wasm=e=>(_ts_node_has_error_wasm=Module._ts_node_has_error_wasm=wasmExports.ts_node_has_error_wasm)(e),_ts_node_is_error_wasm=Module._ts_node_is_error_wasm=e=>(_ts_node_is_error_wasm=Module._ts_node_is_error_wasm=wasmExports.ts_node_is_error_wasm)(e),_ts_node_is_missing_wasm=Module._ts_node_is_missing_wasm=e=>(_ts_node_is_missing_wasm=Module._ts_node_is_missing_wasm=wasmExports.ts_node_is_missing_wasm)(e),_ts_node_is_extra_wasm=Module._ts_node_is_extra_wasm=e=>(_ts_node_is_extra_wasm=Module._ts_node_is_extra_wasm=wasmExports.ts_node_is_extra_wasm)(e),_ts_node_parse_state_wasm=Module._ts_node_parse_state_wasm=e=>(_ts_node_parse_state_wasm=Module._ts_node_parse_state_wasm=wasmExports.ts_node_parse_state_wasm)(e),_ts_node_next_parse_state_wasm=Module._ts_node_next_parse_state_wasm=e=>(_ts_node_next_parse_state_wasm=Module._ts_node_next_parse_state_wasm=wasmExports.ts_node_next_parse_state_wasm)(e),_ts_query_matches_wasm=Module._ts_query_matches_wasm=(e,t,_,s,r,a,o,n,l,d)=>(_ts_query_matches_wasm=Module._ts_query_matches_wasm=wasmExports.ts_query_matches_wasm)(e,t,_,s,r,a,o,n,l,d),_ts_query_captures_wasm=Module._ts_query_captures_wasm=(e,t,_,s,r,a,o,n,l,d)=>(_ts_query_captures_wasm=Module._ts_query_captures_wasm=wasmExports.ts_query_captures_wasm)(e,t,_,s,r,a,o,n,l,d),_iswalpha=Module._iswalpha=e=>(_iswalpha=Module._iswalpha=wasmExports.iswalpha)(e),_iswblank=Module._iswblank=e=>(_iswblank=Module._iswblank=wasmExports.iswblank)(e),_iswdigit=Module._iswdigit=e=>(_iswdigit=Module._iswdigit=wasmExports.iswdigit)(e),_iswlower=Module._iswlower=e=>(_iswlower=Module._iswlower=wasmExports.iswlower)(e),_iswupper=Module._iswupper=e=>(_iswupper=Module._iswupper=wasmExports.iswupper)(e),_iswxdigit=Module._iswxdigit=e=>(_iswxdigit=Module._iswxdigit=wasmExports.iswxdigit)(e),_memchr=Module._memchr=(e,t,_)=>(_memchr=Module._memchr=wasmExports.memchr)(e,t,_),_strlen=Module._strlen=e=>(_strlen=Module._strlen=wasmExports.strlen)(e),_strcmp=Module._strcmp=(e,t)=>(_strcmp=Module._strcmp=wasmExports.strcmp)(e,t),_strncat=Module._strncat=(e,t,_)=>(_strncat=Module._strncat=wasmExports.strncat)(e,t,_),_strncpy=Module._strncpy=(e,t,_)=>(_strncpy=Module._strncpy=wasmExports.strncpy)(e,t,_),_towlower=Module._towlower=e=>(_towlower=Module._towlower=wasmExports.towlower)(e),_towupper=Module._towupper=e=>(_towupper=Module._towupper=wasmExports.towupper)(e),_setThrew=(e,t)=>(_setThrew=wasmExports.setThrew)(e,t),stackSave=()=>(stackSave=wasmExports.stackSave)(),stackRestore=e=>(stackRestore=wasmExports.stackRestore)(e),stackAlloc=e=>(stackAlloc=wasmExports.stackAlloc)(e),dynCall_jiji=Module.dynCall_jiji=(e,t,_,s,r)=>(dynCall_jiji=Module.dynCall_jiji=wasmExports.dynCall_jiji)(e,t,_,s,r),_orig$ts_parser_timeout_micros=Module._orig$ts_parser_timeout_micros=e=>(_orig$ts_parser_timeout_micros=Module._orig$ts_parser_timeout_micros=wasmExports.orig$ts_parser_timeout_micros)(e),_orig$ts_parser_set_timeout_micros=Module._orig$ts_parser_set_timeout_micros=(e,t)=>(_orig$ts_parser_set_timeout_micros=Module._orig$ts_parser_set_timeout_micros=wasmExports.orig$ts_parser_set_timeout_micros)(e,t),calledRun;function callMain(e=[]){var t=resolveGlobalSymbol(\"main\").sym;if(t){e.unshift(thisProgram);var _=e.length,s=stackAlloc(4*(_+1)),r=s;e.forEach((e=>{HEAPU32[r>>2]=stringToUTF8OnStack(e),r+=4})),HEAPU32[r>>2]=0;try{var a=t(_,s);return exitJS(a,!0),a}catch(e){return handleException(e)}}}function run(e=arguments_){function t(){calledRun||(calledRun=!0,Module.calledRun=!0,ABORT||(initRuntime(),preMain(),Module.onRuntimeInitialized&&Module.onRuntimeInitialized(),shouldRunNow&&callMain(e),postRun()))}runDependencies>0||(preRun(),runDependencies>0||(Module.setStatus?(Module.setStatus(\"Running...\"),setTimeout((function(){setTimeout((function(){Module.setStatus(\"\")}),1),t()}),1)):t()))}if(Module.AsciiToString=AsciiToString,Module.stringToUTF16=stringToUTF16,dependenciesFulfilled=function e(){calledRun||run(),calledRun||(dependenciesFulfilled=e)},Module.preInit)for(\"function\"==typeof Module.preInit&&(Module.preInit=[Module.preInit]);Module.preInit.length>0;)Module.preInit.pop()();var shouldRunNow=!0;Module.noInitialRun&&(shouldRunNow=!1),run();const C=Module,INTERNAL={},SIZE_OF_INT=4,SIZE_OF_CURSOR=4*SIZE_OF_INT,SIZE_OF_NODE=5*SIZE_OF_INT,SIZE_OF_POINT=2*SIZE_OF_INT,SIZE_OF_RANGE=2*SIZE_OF_INT+2*SIZE_OF_POINT,ZERO_POINT={row:0,column:0},QUERY_WORD_REGEX=/[\\w-.]*/g,PREDICATE_STEP_TYPE_CAPTURE=1,PREDICATE_STEP_TYPE_STRING=2,LANGUAGE_FUNCTION_REGEX=/^_?tree_sitter_\\w+/;let VERSION,MIN_COMPATIBLE_VERSION,TRANSFER_BUFFER,currentParseCallback,currentLogCallback;class ParserImpl{static init(){TRANSFER_BUFFER=C._ts_init(),VERSION=getValue(TRANSFER_BUFFER,\"i32\"),MIN_COMPATIBLE_VERSION=getValue(TRANSFER_BUFFER+SIZE_OF_INT,\"i32\")}initialize(){C._ts_parser_new_wasm(),this[0]=getValue(TRANSFER_BUFFER,\"i32\"),this[1]=getValue(TRANSFER_BUFFER+SIZE_OF_INT,\"i32\")}delete(){C._ts_parser_delete(this[0]),C._free(this[1]),this[0]=0,this[1]=0}setLanguage(e){let t;if(e){if(e.constructor!==Language)throw new Error(\"Argument must be a Language\");{t=e[0];const _=C._ts_language_version(t);if(_e.slice(t);else{if(\"function\"!=typeof e)throw new Error(\"Argument must be a string or a function\");currentParseCallback=e}this.logCallback?(currentLogCallback=this.logCallback,C._ts_parser_enable_logger_wasm(this[0],1)):(currentLogCallback=null,C._ts_parser_enable_logger_wasm(this[0],0));let s=0,r=0;if(_?.includedRanges){s=_.includedRanges.length,r=C._calloc(s,SIZE_OF_RANGE);let e=r;for(let t=0;t0){let s=t;for(let t=0;t0){let e=_;for(let _=0;_0){let s=t;for(let t=0;t0){let e=_;for(let _=0;_0){let _=t;for(let t=0;t0){let _=t;for(let t=0;t0){let e=n;for(let t=0;t0){if(\"string\"!==r[0].type)throw new Error(\"Predicates must begin with a literal value\");const t=r[0].value;let _,s=!0,a=!0;switch(t){case\"any-not-eq?\":case\"not-eq?\":s=!1;case\"any-eq?\":case\"eq?\":if(3!==r.length)throw new Error(`Wrong number of arguments to \\`#${t}\\` predicate. Expected 2, got ${r.length-1}`);if(\"capture\"!==r[1].type)throw new Error(`First argument of \\`#${t}\\` predicate must be a capture. Got \"${r[1].value}\"`);if(a=!t.startsWith(\"any-\"),\"capture\"===r[2].type){const t=r[1].name,_=r[2].name;w[e].push((e=>{const r=[],o=[];for(const s of e)s.name===t&&r.push(s.node),s.name===_&&o.push(s.node);const n=(e,t,_)=>_?e.text===t.text:e.text!==t.text;return a?r.every((e=>o.some((t=>n(e,t,s))))):r.some((e=>o.some((t=>n(e,t,s)))))}))}else{_=r[1].name;const t=r[2].value,o=e=>e.text===t,n=e=>e.text!==t;w[e].push((e=>{const t=[];for(const s of e)s.name===_&&t.push(s.node);const r=s?o:n;return a?t.every(r):t.some(r)}))}break;case\"any-not-match?\":case\"not-match?\":s=!1;case\"any-match?\":case\"match?\":if(3!==r.length)throw new Error(`Wrong number of arguments to \\`#${t}\\` predicate. Expected 2, got ${r.length-1}.`);if(\"capture\"!==r[1].type)throw new Error(`First argument of \\`#${t}\\` predicate must be a capture. Got \"${r[1].value}\".`);if(\"string\"!==r[2].type)throw new Error(`Second argument of \\`#${t}\\` predicate must be a string. Got @${r[2].value}.`);_=r[1].name;const o=new RegExp(r[2].value);a=!t.startsWith(\"any-\"),w[e].push((e=>{const t=[];for(const s of e)s.name===_&&t.push(s.node.text);const r=(e,t)=>t?o.test(e):!o.test(e);return 0===t.length?!s:a?t.every((e=>r(e,s))):t.some((e=>r(e,s)))}));break;case\"set!\":if(r.length<2||r.length>3)throw new Error(`Wrong number of arguments to \\`#set!\\` predicate. Expected 1 or 2. Got ${r.length-1}.`);if(r.some((e=>\"string\"!==e.type)))throw new Error('Arguments to `#set!` predicate must be a strings.\".');d[e]||(d[e]={}),d[e][r[1].value]=r[2]?r[2].value:null;break;case\"is?\":case\"is-not?\":if(r.length<2||r.length>3)throw new Error(`Wrong number of arguments to \\`#${t}\\` predicate. Expected 1 or 2. Got ${r.length-1}.`);if(r.some((e=>\"string\"!==e.type)))throw new Error(`Arguments to \\`#${t}\\` predicate must be a strings.\".`);const n=\"is?\"===t?u:m;n[e]||(n[e]={}),n[e][r[1].value]=r[2]?r[2].value:null;break;case\"not-any-of?\":s=!1;case\"any-of?\":if(r.length<2)throw new Error(`Wrong number of arguments to \\`#${t}\\` predicate. Expected at least 1. Got ${r.length-1}.`);if(\"capture\"!==r[1].type)throw new Error(`First argument of \\`#${t}\\` predicate must be a capture. Got \"${r[1].value}\".`);for(let e=2;ee.value));w[e].push((e=>{const t=[];for(const s of e)s.name===_&&t.push(s.node.text);return 0===t.length?!s:t.every((e=>l.includes(e)))===s}));break;default:c[e].push({operator:t,operands:r.slice(1)})}r.length=0}}Object.freeze(d[e]),Object.freeze(u[e]),Object.freeze(m[e])}return C._free(_),new Query(INTERNAL,s,n,w,c,Object.freeze(d),Object.freeze(u),Object.freeze(m))}static load(e){let t;if(e instanceof Uint8Array)t=Promise.resolve(e);else{const _=e;if(\"undefined\"!=typeof process&&process.versions&&process.versions.node){const e=require(\"fs\");t=Promise.resolve(e.readFileSync(_))}else t=fetch(_).then((e=>e.arrayBuffer().then((t=>{if(e.ok)return new Uint8Array(t);{const _=new TextDecoder(\"utf-8\").decode(t);throw new Error(`Language.load failed with status ${e.status}.\\n\\n${_}`)}}))))}return t.then((e=>loadWebAssemblyModule(e,{loadAsync:!0}))).then((e=>{const t=Object.keys(e),_=t.find((e=>LANGUAGE_FUNCTION_REGEX.test(e)&&!e.includes(\"external_scanner_\")));_||console.log(`Couldn't find language function in WASM file. Symbols:\\n${JSON.stringify(t,null,2)}`);const s=e[_]();return new Language(INTERNAL,s)}))}}class LookaheadIterable{constructor(e,t,_){assertInternal(e),this[0]=t,this.language=_}get currentTypeId(){return C._ts_lookahead_iterator_current_symbol(this[0])}get currentType(){return this.language.types[this.currentTypeId]||\"ERROR\"}delete(){C._ts_lookahead_iterator_delete(this[0]),this[0]=0}resetState(e){return C._ts_lookahead_iterator_reset_state(this[0],e)}reset(e,t){return!!C._ts_lookahead_iterator_reset(this[0],e[0],t)&&(this.language=e,!0)}[Symbol.iterator](){const e=this;return{next:()=>C._ts_lookahead_iterator_next(e[0])?{done:!1,value:e.currentType}:{done:!0,value:\"\"}}}}class Query{constructor(e,t,_,s,r,a,o,n){assertInternal(e),this[0]=t,this.captureNames=_,this.textPredicates=s,this.predicates=r,this.setProperties=a,this.assertedProperties=o,this.refutedProperties=n,this.exceededMatchLimit=!1}delete(){C._ts_query_delete(this[0]),this[0]=0}matches(e,{startPosition:t=ZERO_POINT,endPosition:_=ZERO_POINT,startIndex:s=0,endIndex:r=0,matchLimit:a=4294967295,maxStartDepth:o=4294967295}={}){if(\"number\"!=typeof a)throw new Error(\"Arguments must be numbers\");marshalNode(e),C._ts_query_matches_wasm(this[0],e.tree[0],t.row,t.column,_.row,_.column,s,r,a,o);const n=getValue(TRANSFER_BUFFER,\"i32\"),l=getValue(TRANSFER_BUFFER+SIZE_OF_INT,\"i32\"),d=getValue(TRANSFER_BUFFER+2*SIZE_OF_INT,\"i32\"),u=new Array(n);this.exceededMatchLimit=Boolean(d);let m=0,c=l;for(let t=0;te(s)))){u[m]={pattern:t,captures:s};const e=this.setProperties[t];e&&(u[m].setProperties=e);const _=this.assertedProperties[t];_&&(u[m].assertedProperties=_);const r=this.refutedProperties[t];r&&(u[m].refutedProperties=r),m++}}return u.length=m,C._free(l),u}captures(e,{startPosition:t=ZERO_POINT,endPosition:_=ZERO_POINT,startIndex:s=0,endIndex:r=0,matchLimit:a=4294967295,maxStartDepth:o=4294967295}={}){if(\"number\"!=typeof a)throw new Error(\"Arguments must be numbers\");marshalNode(e),C._ts_query_captures_wasm(this[0],e.tree[0],t.row,t.column,_.row,_.column,s,r,a,o);const n=getValue(TRANSFER_BUFFER,\"i32\"),l=getValue(TRANSFER_BUFFER+SIZE_OF_INT,\"i32\"),d=getValue(TRANSFER_BUFFER+2*SIZE_OF_INT,\"i32\"),u=[];this.exceededMatchLimit=Boolean(d);const m=[];let c=l;for(let t=0;te(m)))){const e=m[s],_=this.setProperties[t];_&&(e.setProperties=_);const r=this.assertedProperties[t];r&&(e.assertedProperties=r);const a=this.refutedProperties[t];a&&(e.refutedProperties=a),u.push(e)}}return C._free(l),u}predicatesForPattern(e){return this.predicates[e]}disableCapture(e){const t=lengthBytesUTF8(e),_=C._malloc(t+1);stringToUTF8(e,_,t+1),C._ts_query_disable_capture(this[0],_,t),C._free(_)}didExceedMatchLimit(){return this.exceededMatchLimit}}function getText(e,t,_){const s=_-t;let r=e.textCallback(t,null,_);for(t+=r.length;t<_;){const s=e.textCallback(t,null,_);if(!(s&&s.length>0))break;t+=s.length,r+=s}return t>_&&(r=r.slice(0,s)),r}function unmarshalCaptures(e,t,_,s){for(let r=0,a=s.length;r>>0,column:getValue(e+SIZE_OF_INT,\"i32\")>>>0}}function marshalRange(e,t){marshalPoint(e,t.startPosition),marshalPoint(e+=SIZE_OF_POINT,t.endPosition),setValue(e+=SIZE_OF_POINT,t.startIndex,\"i32\"),setValue(e+=SIZE_OF_INT,t.endIndex,\"i32\"),e+=SIZE_OF_INT}function unmarshalRange(e){const t={};return t.startPosition=unmarshalPoint(e),e+=SIZE_OF_POINT,t.endPosition=unmarshalPoint(e),e+=SIZE_OF_POINT,t.startIndex=getValue(e,\"i32\")>>>0,e+=SIZE_OF_INT,t.endIndex=getValue(e,\"i32\")>>>0,t}function marshalEdit(e){let t=TRANSFER_BUFFER;marshalPoint(t,e.startPosition),t+=SIZE_OF_POINT,marshalPoint(t,e.oldEndPosition),t+=SIZE_OF_POINT,marshalPoint(t,e.newEndPosition),t+=SIZE_OF_POINT,setValue(t,e.startIndex,\"i32\"),t+=SIZE_OF_INT,setValue(t,e.oldEndIndex,\"i32\"),t+=SIZE_OF_INT,setValue(t,e.newEndIndex,\"i32\"),t+=SIZE_OF_INT}for(const e of Object.getOwnPropertyNames(ParserImpl.prototype))Object.defineProperty(Parser.prototype,e,{value:ParserImpl.prototype[e],enumerable:!1,writable:!1});Parser.Language=Language,Module.onRuntimeInitialized=()=>{ParserImpl.init(),resolveInitPromise()}})))}}return Parser}();\"object\"==typeof exports&&(module.exports=TreeSitter);\n", "/**\n * CommanderError class\n */\nclass CommanderError extends Error {\n /**\n * Constructs the CommanderError class\n * @param {number} exitCode suggested exit code which could be used with process.exit\n * @param {string} code an id string representing the error\n * @param {string} message human-readable description of the error\n */\n constructor(exitCode, code, message) {\n super(message);\n // properly capture stack trace in Node.js\n Error.captureStackTrace(this, this.constructor);\n this.name = this.constructor.name;\n this.code = code;\n this.exitCode = exitCode;\n this.nestedError = undefined;\n }\n}\n\n/**\n * InvalidArgumentError class\n */\nclass InvalidArgumentError extends CommanderError {\n /**\n * Constructs the InvalidArgumentError class\n * @param {string} [message] explanation of why argument is invalid\n */\n constructor(message) {\n super(1, 'commander.invalidArgument', message);\n // properly capture stack trace in Node.js\n Error.captureStackTrace(this, this.constructor);\n this.name = this.constructor.name;\n }\n}\n\nexports.CommanderError = CommanderError;\nexports.InvalidArgumentError = InvalidArgumentError;\n", "const { InvalidArgumentError } = require('./error.js');\n\nclass Argument {\n /**\n * Initialize a new command argument with the given name and description.\n * The default is that the argument is required, and you can explicitly\n * indicate this with <> around the name. Put [] around the name for an optional argument.\n *\n * @param {string} name\n * @param {string} [description]\n */\n\n constructor(name, description) {\n this.description = description || '';\n this.variadic = false;\n this.parseArg = undefined;\n this.defaultValue = undefined;\n this.defaultValueDescription = undefined;\n this.argChoices = undefined;\n\n switch (name[0]) {\n case '<': // e.g. \n this.required = true;\n this._name = name.slice(1, -1);\n break;\n case '[': // e.g. [optional]\n this.required = false;\n this._name = name.slice(1, -1);\n break;\n default:\n this.required = true;\n this._name = name;\n break;\n }\n\n if (this._name.length > 3 && this._name.slice(-3) === '...') {\n this.variadic = true;\n this._name = this._name.slice(0, -3);\n }\n }\n\n /**\n * Return argument name.\n *\n * @return {string}\n */\n\n name() {\n return this._name;\n }\n\n /**\n * @package\n */\n\n _concatValue(value, previous) {\n if (previous === this.defaultValue || !Array.isArray(previous)) {\n return [value];\n }\n\n return previous.concat(value);\n }\n\n /**\n * Set the default value, and optionally supply the description to be displayed in the help.\n *\n * @param {*} value\n * @param {string} [description]\n * @return {Argument}\n */\n\n default(value, description) {\n this.defaultValue = value;\n this.defaultValueDescription = description;\n return this;\n }\n\n /**\n * Set the custom handler for processing CLI command arguments into argument values.\n *\n * @param {Function} [fn]\n * @return {Argument}\n */\n\n argParser(fn) {\n this.parseArg = fn;\n return this;\n }\n\n /**\n * Only allow argument value to be one of choices.\n *\n * @param {string[]} values\n * @return {Argument}\n */\n\n choices(values) {\n this.argChoices = values.slice();\n this.parseArg = (arg, previous) => {\n if (!this.argChoices.includes(arg)) {\n throw new InvalidArgumentError(\n `Allowed choices are ${this.argChoices.join(', ')}.`,\n );\n }\n if (this.variadic) {\n return this._concatValue(arg, previous);\n }\n return arg;\n };\n return this;\n }\n\n /**\n * Make argument required.\n *\n * @returns {Argument}\n */\n argRequired() {\n this.required = true;\n return this;\n }\n\n /**\n * Make argument optional.\n *\n * @returns {Argument}\n */\n argOptional() {\n this.required = false;\n return this;\n }\n}\n\n/**\n * Takes an argument and returns its human readable equivalent for help usage.\n *\n * @param {Argument} arg\n * @return {string}\n * @private\n */\n\nfunction humanReadableArgName(arg) {\n const nameOutput = arg.name() + (arg.variadic === true ? '...' : '');\n\n return arg.required ? '<' + nameOutput + '>' : '[' + nameOutput + ']';\n}\n\nexports.Argument = Argument;\nexports.humanReadableArgName = humanReadableArgName;\n", "const { humanReadableArgName } = require('./argument.js');\n\n/**\n * TypeScript import types for JSDoc, used by Visual Studio Code IntelliSense and `npm run typescript-checkJS`\n * https://www.typescriptlang.org/docs/handbook/jsdoc-supported-types.html#import-types\n * @typedef { import(\"./argument.js\").Argument } Argument\n * @typedef { import(\"./command.js\").Command } Command\n * @typedef { import(\"./option.js\").Option } Option\n */\n\n// Although this is a class, methods are static in style to allow override using subclass or just functions.\nclass Help {\n constructor() {\n this.helpWidth = undefined;\n this.minWidthToWrap = 40;\n this.sortSubcommands = false;\n this.sortOptions = false;\n this.showGlobalOptions = false;\n }\n\n /**\n * prepareContext is called by Commander after applying overrides from `Command.configureHelp()`\n * and just before calling `formatHelp()`.\n *\n * Commander just uses the helpWidth and the rest is provided for optional use by more complex subclasses.\n *\n * @param {{ error?: boolean, helpWidth?: number, outputHasColors?: boolean }} contextOptions\n */\n prepareContext(contextOptions) {\n this.helpWidth = this.helpWidth ?? contextOptions.helpWidth ?? 80;\n }\n\n /**\n * Get an array of the visible subcommands. Includes a placeholder for the implicit help command, if there is one.\n *\n * @param {Command} cmd\n * @returns {Command[]}\n */\n\n visibleCommands(cmd) {\n const visibleCommands = cmd.commands.filter((cmd) => !cmd._hidden);\n const helpCommand = cmd._getHelpCommand();\n if (helpCommand && !helpCommand._hidden) {\n visibleCommands.push(helpCommand);\n }\n if (this.sortSubcommands) {\n visibleCommands.sort((a, b) => {\n // @ts-ignore: because overloaded return type\n return a.name().localeCompare(b.name());\n });\n }\n return visibleCommands;\n }\n\n /**\n * Compare options for sort.\n *\n * @param {Option} a\n * @param {Option} b\n * @returns {number}\n */\n compareOptions(a, b) {\n const getSortKey = (option) => {\n // WYSIWYG for order displayed in help. Short used for comparison if present. No special handling for negated.\n return option.short\n ? option.short.replace(/^-/, '')\n : option.long.replace(/^--/, '');\n };\n return getSortKey(a).localeCompare(getSortKey(b));\n }\n\n /**\n * Get an array of the visible options. Includes a placeholder for the implicit help option, if there is one.\n *\n * @param {Command} cmd\n * @returns {Option[]}\n */\n\n visibleOptions(cmd) {\n const visibleOptions = cmd.options.filter((option) => !option.hidden);\n // Built-in help option.\n const helpOption = cmd._getHelpOption();\n if (helpOption && !helpOption.hidden) {\n // Automatically hide conflicting flags. Bit dubious but a historical behaviour that is convenient for single-command programs.\n const removeShort = helpOption.short && cmd._findOption(helpOption.short);\n const removeLong = helpOption.long && cmd._findOption(helpOption.long);\n if (!removeShort && !removeLong) {\n visibleOptions.push(helpOption); // no changes needed\n } else if (helpOption.long && !removeLong) {\n visibleOptions.push(\n cmd.createOption(helpOption.long, helpOption.description),\n );\n } else if (helpOption.short && !removeShort) {\n visibleOptions.push(\n cmd.createOption(helpOption.short, helpOption.description),\n );\n }\n }\n if (this.sortOptions) {\n visibleOptions.sort(this.compareOptions);\n }\n return visibleOptions;\n }\n\n /**\n * Get an array of the visible global options. (Not including help.)\n *\n * @param {Command} cmd\n * @returns {Option[]}\n */\n\n visibleGlobalOptions(cmd) {\n if (!this.showGlobalOptions) return [];\n\n const globalOptions = [];\n for (\n let ancestorCmd = cmd.parent;\n ancestorCmd;\n ancestorCmd = ancestorCmd.parent\n ) {\n const visibleOptions = ancestorCmd.options.filter(\n (option) => !option.hidden,\n );\n globalOptions.push(...visibleOptions);\n }\n if (this.sortOptions) {\n globalOptions.sort(this.compareOptions);\n }\n return globalOptions;\n }\n\n /**\n * Get an array of the arguments if any have a description.\n *\n * @param {Command} cmd\n * @returns {Argument[]}\n */\n\n visibleArguments(cmd) {\n // Side effect! Apply the legacy descriptions before the arguments are displayed.\n if (cmd._argsDescription) {\n cmd.registeredArguments.forEach((argument) => {\n argument.description =\n argument.description || cmd._argsDescription[argument.name()] || '';\n });\n }\n\n // If there are any arguments with a description then return all the arguments.\n if (cmd.registeredArguments.find((argument) => argument.description)) {\n return cmd.registeredArguments;\n }\n return [];\n }\n\n /**\n * Get the command term to show in the list of subcommands.\n *\n * @param {Command} cmd\n * @returns {string}\n */\n\n subcommandTerm(cmd) {\n // Legacy. Ignores custom usage string, and nested commands.\n const args = cmd.registeredArguments\n .map((arg) => humanReadableArgName(arg))\n .join(' ');\n return (\n cmd._name +\n (cmd._aliases[0] ? '|' + cmd._aliases[0] : '') +\n (cmd.options.length ? ' [options]' : '') + // simplistic check for non-help option\n (args ? ' ' + args : '')\n );\n }\n\n /**\n * Get the option term to show in the list of options.\n *\n * @param {Option} option\n * @returns {string}\n */\n\n optionTerm(option) {\n return option.flags;\n }\n\n /**\n * Get the argument term to show in the list of arguments.\n *\n * @param {Argument} argument\n * @returns {string}\n */\n\n argumentTerm(argument) {\n return argument.name();\n }\n\n /**\n * Get the longest command term length.\n *\n * @param {Command} cmd\n * @param {Help} helper\n * @returns {number}\n */\n\n longestSubcommandTermLength(cmd, helper) {\n return helper.visibleCommands(cmd).reduce((max, command) => {\n return Math.max(\n max,\n this.displayWidth(\n helper.styleSubcommandTerm(helper.subcommandTerm(command)),\n ),\n );\n }, 0);\n }\n\n /**\n * Get the longest option term length.\n *\n * @param {Command} cmd\n * @param {Help} helper\n * @returns {number}\n */\n\n longestOptionTermLength(cmd, helper) {\n return helper.visibleOptions(cmd).reduce((max, option) => {\n return Math.max(\n max,\n this.displayWidth(helper.styleOptionTerm(helper.optionTerm(option))),\n );\n }, 0);\n }\n\n /**\n * Get the longest global option term length.\n *\n * @param {Command} cmd\n * @param {Help} helper\n * @returns {number}\n */\n\n longestGlobalOptionTermLength(cmd, helper) {\n return helper.visibleGlobalOptions(cmd).reduce((max, option) => {\n return Math.max(\n max,\n this.displayWidth(helper.styleOptionTerm(helper.optionTerm(option))),\n );\n }, 0);\n }\n\n /**\n * Get the longest argument term length.\n *\n * @param {Command} cmd\n * @param {Help} helper\n * @returns {number}\n */\n\n longestArgumentTermLength(cmd, helper) {\n return helper.visibleArguments(cmd).reduce((max, argument) => {\n return Math.max(\n max,\n this.displayWidth(\n helper.styleArgumentTerm(helper.argumentTerm(argument)),\n ),\n );\n }, 0);\n }\n\n /**\n * Get the command usage to be displayed at the top of the built-in help.\n *\n * @param {Command} cmd\n * @returns {string}\n */\n\n commandUsage(cmd) {\n // Usage\n let cmdName = cmd._name;\n if (cmd._aliases[0]) {\n cmdName = cmdName + '|' + cmd._aliases[0];\n }\n let ancestorCmdNames = '';\n for (\n let ancestorCmd = cmd.parent;\n ancestorCmd;\n ancestorCmd = ancestorCmd.parent\n ) {\n ancestorCmdNames = ancestorCmd.name() + ' ' + ancestorCmdNames;\n }\n return ancestorCmdNames + cmdName + ' ' + cmd.usage();\n }\n\n /**\n * Get the description for the command.\n *\n * @param {Command} cmd\n * @returns {string}\n */\n\n commandDescription(cmd) {\n // @ts-ignore: because overloaded return type\n return cmd.description();\n }\n\n /**\n * Get the subcommand summary to show in the list of subcommands.\n * (Fallback to description for backwards compatibility.)\n *\n * @param {Command} cmd\n * @returns {string}\n */\n\n subcommandDescription(cmd) {\n // @ts-ignore: because overloaded return type\n return cmd.summary() || cmd.description();\n }\n\n /**\n * Get the option description to show in the list of options.\n *\n * @param {Option} option\n * @return {string}\n */\n\n optionDescription(option) {\n const extraInfo = [];\n\n if (option.argChoices) {\n extraInfo.push(\n // use stringify to match the display of the default value\n `choices: ${option.argChoices.map((choice) => JSON.stringify(choice)).join(', ')}`,\n );\n }\n if (option.defaultValue !== undefined) {\n // default for boolean and negated more for programmer than end user,\n // but show true/false for boolean option as may be for hand-rolled env or config processing.\n const showDefault =\n option.required ||\n option.optional ||\n (option.isBoolean() && typeof option.defaultValue === 'boolean');\n if (showDefault) {\n extraInfo.push(\n `default: ${option.defaultValueDescription || JSON.stringify(option.defaultValue)}`,\n );\n }\n }\n // preset for boolean and negated are more for programmer than end user\n if (option.presetArg !== undefined && option.optional) {\n extraInfo.push(`preset: ${JSON.stringify(option.presetArg)}`);\n }\n if (option.envVar !== undefined) {\n extraInfo.push(`env: ${option.envVar}`);\n }\n if (extraInfo.length > 0) {\n const extraDescription = `(${extraInfo.join(', ')})`;\n if (option.description) {\n return `${option.description} ${extraDescription}`;\n }\n return extraDescription;\n }\n\n return option.description;\n }\n\n /**\n * Get the argument description to show in the list of arguments.\n *\n * @param {Argument} argument\n * @return {string}\n */\n\n argumentDescription(argument) {\n const extraInfo = [];\n if (argument.argChoices) {\n extraInfo.push(\n // use stringify to match the display of the default value\n `choices: ${argument.argChoices.map((choice) => JSON.stringify(choice)).join(', ')}`,\n );\n }\n if (argument.defaultValue !== undefined) {\n extraInfo.push(\n `default: ${argument.defaultValueDescription || JSON.stringify(argument.defaultValue)}`,\n );\n }\n if (extraInfo.length > 0) {\n const extraDescription = `(${extraInfo.join(', ')})`;\n if (argument.description) {\n return `${argument.description} ${extraDescription}`;\n }\n return extraDescription;\n }\n return argument.description;\n }\n\n /**\n * Format a list of items, given a heading and an array of formatted items.\n *\n * @param {string} heading\n * @param {string[]} items\n * @param {Help} helper\n * @returns string[]\n */\n formatItemList(heading, items, helper) {\n if (items.length === 0) return [];\n\n return [helper.styleTitle(heading), ...items, ''];\n }\n\n /**\n * Group items by their help group heading.\n *\n * @param {Command[] | Option[]} unsortedItems\n * @param {Command[] | Option[]} visibleItems\n * @param {Function} getGroup\n * @returns {Map}\n */\n groupItems(unsortedItems, visibleItems, getGroup) {\n const result = new Map();\n // Add groups in order of appearance in unsortedItems.\n unsortedItems.forEach((item) => {\n const group = getGroup(item);\n if (!result.has(group)) result.set(group, []);\n });\n // Add items in order of appearance in visibleItems.\n visibleItems.forEach((item) => {\n const group = getGroup(item);\n if (!result.has(group)) {\n result.set(group, []);\n }\n result.get(group).push(item);\n });\n return result;\n }\n\n /**\n * Generate the built-in help text.\n *\n * @param {Command} cmd\n * @param {Help} helper\n * @returns {string}\n */\n\n formatHelp(cmd, helper) {\n const termWidth = helper.padWidth(cmd, helper);\n const helpWidth = helper.helpWidth ?? 80; // in case prepareContext() was not called\n\n function callFormatItem(term, description) {\n return helper.formatItem(term, termWidth, description, helper);\n }\n\n // Usage\n let output = [\n `${helper.styleTitle('Usage:')} ${helper.styleUsage(helper.commandUsage(cmd))}`,\n '',\n ];\n\n // Description\n const commandDescription = helper.commandDescription(cmd);\n if (commandDescription.length > 0) {\n output = output.concat([\n helper.boxWrap(\n helper.styleCommandDescription(commandDescription),\n helpWidth,\n ),\n '',\n ]);\n }\n\n // Arguments\n const argumentList = helper.visibleArguments(cmd).map((argument) => {\n return callFormatItem(\n helper.styleArgumentTerm(helper.argumentTerm(argument)),\n helper.styleArgumentDescription(helper.argumentDescription(argument)),\n );\n });\n output = output.concat(\n this.formatItemList('Arguments:', argumentList, helper),\n );\n\n // Options\n const optionGroups = this.groupItems(\n cmd.options,\n helper.visibleOptions(cmd),\n (option) => option.helpGroupHeading ?? 'Options:',\n );\n optionGroups.forEach((options, group) => {\n const optionList = options.map((option) => {\n return callFormatItem(\n helper.styleOptionTerm(helper.optionTerm(option)),\n helper.styleOptionDescription(helper.optionDescription(option)),\n );\n });\n output = output.concat(this.formatItemList(group, optionList, helper));\n });\n\n if (helper.showGlobalOptions) {\n const globalOptionList = helper\n .visibleGlobalOptions(cmd)\n .map((option) => {\n return callFormatItem(\n helper.styleOptionTerm(helper.optionTerm(option)),\n helper.styleOptionDescription(helper.optionDescription(option)),\n );\n });\n output = output.concat(\n this.formatItemList('Global Options:', globalOptionList, helper),\n );\n }\n\n // Commands\n const commandGroups = this.groupItems(\n cmd.commands,\n helper.visibleCommands(cmd),\n (sub) => sub.helpGroup() || 'Commands:',\n );\n commandGroups.forEach((commands, group) => {\n const commandList = commands.map((sub) => {\n return callFormatItem(\n helper.styleSubcommandTerm(helper.subcommandTerm(sub)),\n helper.styleSubcommandDescription(helper.subcommandDescription(sub)),\n );\n });\n output = output.concat(this.formatItemList(group, commandList, helper));\n });\n\n return output.join('\\n');\n }\n\n /**\n * Return display width of string, ignoring ANSI escape sequences. Used in padding and wrapping calculations.\n *\n * @param {string} str\n * @returns {number}\n */\n displayWidth(str) {\n return stripColor(str).length;\n }\n\n /**\n * Style the title for displaying in the help. Called with 'Usage:', 'Options:', etc.\n *\n * @param {string} str\n * @returns {string}\n */\n styleTitle(str) {\n return str;\n }\n\n styleUsage(str) {\n // Usage has lots of parts the user might like to color separately! Assume default usage string which is formed like:\n // command subcommand [options] [command] [bar]\n return str\n .split(' ')\n .map((word) => {\n if (word === '[options]') return this.styleOptionText(word);\n if (word === '[command]') return this.styleSubcommandText(word);\n if (word[0] === '[' || word[0] === '<')\n return this.styleArgumentText(word);\n return this.styleCommandText(word); // Restrict to initial words?\n })\n .join(' ');\n }\n styleCommandDescription(str) {\n return this.styleDescriptionText(str);\n }\n styleOptionDescription(str) {\n return this.styleDescriptionText(str);\n }\n styleSubcommandDescription(str) {\n return this.styleDescriptionText(str);\n }\n styleArgumentDescription(str) {\n return this.styleDescriptionText(str);\n }\n styleDescriptionText(str) {\n return str;\n }\n styleOptionTerm(str) {\n return this.styleOptionText(str);\n }\n styleSubcommandTerm(str) {\n // This is very like usage with lots of parts! Assume default string which is formed like:\n // subcommand [options] [bar]\n return str\n .split(' ')\n .map((word) => {\n if (word === '[options]') return this.styleOptionText(word);\n if (word[0] === '[' || word[0] === '<')\n return this.styleArgumentText(word);\n return this.styleSubcommandText(word); // Restrict to initial words?\n })\n .join(' ');\n }\n styleArgumentTerm(str) {\n return this.styleArgumentText(str);\n }\n styleOptionText(str) {\n return str;\n }\n styleArgumentText(str) {\n return str;\n }\n styleSubcommandText(str) {\n return str;\n }\n styleCommandText(str) {\n return str;\n }\n\n /**\n * Calculate the pad width from the maximum term length.\n *\n * @param {Command} cmd\n * @param {Help} helper\n * @returns {number}\n */\n\n padWidth(cmd, helper) {\n return Math.max(\n helper.longestOptionTermLength(cmd, helper),\n helper.longestGlobalOptionTermLength(cmd, helper),\n helper.longestSubcommandTermLength(cmd, helper),\n helper.longestArgumentTermLength(cmd, helper),\n );\n }\n\n /**\n * Detect manually wrapped and indented strings by checking for line break followed by whitespace.\n *\n * @param {string} str\n * @returns {boolean}\n */\n preformatted(str) {\n return /\\n[^\\S\\r\\n]/.test(str);\n }\n\n /**\n * Format the \"item\", which consists of a term and description. Pad the term and wrap the description, indenting the following lines.\n *\n * So \"TTT\", 5, \"DDD DDDD DD DDD\" might be formatted for this.helpWidth=17 like so:\n * TTT DDD DDDD\n * DD DDD\n *\n * @param {string} term\n * @param {number} termWidth\n * @param {string} description\n * @param {Help} helper\n * @returns {string}\n */\n formatItem(term, termWidth, description, helper) {\n const itemIndent = 2;\n const itemIndentStr = ' '.repeat(itemIndent);\n if (!description) return itemIndentStr + term;\n\n // Pad the term out to a consistent width, so descriptions are aligned.\n const paddedTerm = term.padEnd(\n termWidth + term.length - helper.displayWidth(term),\n );\n\n // Format the description.\n const spacerWidth = 2; // between term and description\n const helpWidth = this.helpWidth ?? 80; // in case prepareContext() was not called\n const remainingWidth = helpWidth - termWidth - spacerWidth - itemIndent;\n let formattedDescription;\n if (\n remainingWidth < this.minWidthToWrap ||\n helper.preformatted(description)\n ) {\n formattedDescription = description;\n } else {\n const wrappedDescription = helper.boxWrap(description, remainingWidth);\n formattedDescription = wrappedDescription.replace(\n /\\n/g,\n '\\n' + ' '.repeat(termWidth + spacerWidth),\n );\n }\n\n // Construct and overall indent.\n return (\n itemIndentStr +\n paddedTerm +\n ' '.repeat(spacerWidth) +\n formattedDescription.replace(/\\n/g, `\\n${itemIndentStr}`)\n );\n }\n\n /**\n * Wrap a string at whitespace, preserving existing line breaks.\n * Wrapping is skipped if the width is less than `minWidthToWrap`.\n *\n * @param {string} str\n * @param {number} width\n * @returns {string}\n */\n boxWrap(str, width) {\n if (width < this.minWidthToWrap) return str;\n\n const rawLines = str.split(/\\r\\n|\\n/);\n // split up text by whitespace\n const chunkPattern = /[\\s]*[^\\s]+/g;\n const wrappedLines = [];\n rawLines.forEach((line) => {\n const chunks = line.match(chunkPattern);\n if (chunks === null) {\n wrappedLines.push('');\n return;\n }\n\n let sumChunks = [chunks.shift()];\n let sumWidth = this.displayWidth(sumChunks[0]);\n chunks.forEach((chunk) => {\n const visibleWidth = this.displayWidth(chunk);\n // Accumulate chunks while they fit into width.\n if (sumWidth + visibleWidth <= width) {\n sumChunks.push(chunk);\n sumWidth += visibleWidth;\n return;\n }\n wrappedLines.push(sumChunks.join(''));\n\n const nextChunk = chunk.trimStart(); // trim space at line break\n sumChunks = [nextChunk];\n sumWidth = this.displayWidth(nextChunk);\n });\n wrappedLines.push(sumChunks.join(''));\n });\n\n return wrappedLines.join('\\n');\n }\n}\n\n/**\n * Strip style ANSI escape sequences from the string. In particular, SGR (Select Graphic Rendition) codes.\n *\n * @param {string} str\n * @returns {string}\n * @package\n */\n\nfunction stripColor(str) {\n // eslint-disable-next-line no-control-regex\n const sgrPattern = /\\x1b\\[\\d*(;\\d*)*m/g;\n return str.replace(sgrPattern, '');\n}\n\nexports.Help = Help;\nexports.stripColor = stripColor;\n", "const { InvalidArgumentError } = require('./error.js');\n\nclass Option {\n /**\n * Initialize a new `Option` with the given `flags` and `description`.\n *\n * @param {string} flags\n * @param {string} [description]\n */\n\n constructor(flags, description) {\n this.flags = flags;\n this.description = description || '';\n\n this.required = flags.includes('<'); // A value must be supplied when the option is specified.\n this.optional = flags.includes('['); // A value is optional when the option is specified.\n // variadic test ignores et al which might be used to describe custom splitting of single argument\n this.variadic = /\\w\\.\\.\\.[>\\]]$/.test(flags); // The option can take multiple values.\n this.mandatory = false; // The option must have a value after parsing, which usually means it must be specified on command line.\n const optionFlags = splitOptionFlags(flags);\n this.short = optionFlags.shortFlag; // May be a short flag, undefined, or even a long flag (if option has two long flags).\n this.long = optionFlags.longFlag;\n this.negate = false;\n if (this.long) {\n this.negate = this.long.startsWith('--no-');\n }\n this.defaultValue = undefined;\n this.defaultValueDescription = undefined;\n this.presetArg = undefined;\n this.envVar = undefined;\n this.parseArg = undefined;\n this.hidden = false;\n this.argChoices = undefined;\n this.conflictsWith = [];\n this.implied = undefined;\n this.helpGroupHeading = undefined; // soft initialised when option added to command\n }\n\n /**\n * Set the default value, and optionally supply the description to be displayed in the help.\n *\n * @param {*} value\n * @param {string} [description]\n * @return {Option}\n */\n\n default(value, description) {\n this.defaultValue = value;\n this.defaultValueDescription = description;\n return this;\n }\n\n /**\n * Preset to use when option used without option-argument, especially optional but also boolean and negated.\n * The custom processing (parseArg) is called.\n *\n * @example\n * new Option('--color').default('GREYSCALE').preset('RGB');\n * new Option('--donate [amount]').preset('20').argParser(parseFloat);\n *\n * @param {*} arg\n * @return {Option}\n */\n\n preset(arg) {\n this.presetArg = arg;\n return this;\n }\n\n /**\n * Add option name(s) that conflict with this option.\n * An error will be displayed if conflicting options are found during parsing.\n *\n * @example\n * new Option('--rgb').conflicts('cmyk');\n * new Option('--js').conflicts(['ts', 'jsx']);\n *\n * @param {(string | string[])} names\n * @return {Option}\n */\n\n conflicts(names) {\n this.conflictsWith = this.conflictsWith.concat(names);\n return this;\n }\n\n /**\n * Specify implied option values for when this option is set and the implied options are not.\n *\n * The custom processing (parseArg) is not called on the implied values.\n *\n * @example\n * program\n * .addOption(new Option('--log', 'write logging information to file'))\n * .addOption(new Option('--trace', 'log extra details').implies({ log: 'trace.txt' }));\n *\n * @param {object} impliedOptionValues\n * @return {Option}\n */\n implies(impliedOptionValues) {\n let newImplied = impliedOptionValues;\n if (typeof impliedOptionValues === 'string') {\n // string is not documented, but easy mistake and we can do what user probably intended.\n newImplied = { [impliedOptionValues]: true };\n }\n this.implied = Object.assign(this.implied || {}, newImplied);\n return this;\n }\n\n /**\n * Set environment variable to check for option value.\n *\n * An environment variable is only used if when processed the current option value is\n * undefined, or the source of the current value is 'default' or 'config' or 'env'.\n *\n * @param {string} name\n * @return {Option}\n */\n\n env(name) {\n this.envVar = name;\n return this;\n }\n\n /**\n * Set the custom handler for processing CLI option arguments into option values.\n *\n * @param {Function} [fn]\n * @return {Option}\n */\n\n argParser(fn) {\n this.parseArg = fn;\n return this;\n }\n\n /**\n * Whether the option is mandatory and must have a value after parsing.\n *\n * @param {boolean} [mandatory=true]\n * @return {Option}\n */\n\n makeOptionMandatory(mandatory = true) {\n this.mandatory = !!mandatory;\n return this;\n }\n\n /**\n * Hide option in help.\n *\n * @param {boolean} [hide=true]\n * @return {Option}\n */\n\n hideHelp(hide = true) {\n this.hidden = !!hide;\n return this;\n }\n\n /**\n * @package\n */\n\n _concatValue(value, previous) {\n if (previous === this.defaultValue || !Array.isArray(previous)) {\n return [value];\n }\n\n return previous.concat(value);\n }\n\n /**\n * Only allow option value to be one of choices.\n *\n * @param {string[]} values\n * @return {Option}\n */\n\n choices(values) {\n this.argChoices = values.slice();\n this.parseArg = (arg, previous) => {\n if (!this.argChoices.includes(arg)) {\n throw new InvalidArgumentError(\n `Allowed choices are ${this.argChoices.join(', ')}.`,\n );\n }\n if (this.variadic) {\n return this._concatValue(arg, previous);\n }\n return arg;\n };\n return this;\n }\n\n /**\n * Return option name.\n *\n * @return {string}\n */\n\n name() {\n if (this.long) {\n return this.long.replace(/^--/, '');\n }\n return this.short.replace(/^-/, '');\n }\n\n /**\n * Return option name, in a camelcase format that can be used\n * as an object attribute key.\n *\n * @return {string}\n */\n\n attributeName() {\n if (this.negate) {\n return camelcase(this.name().replace(/^no-/, ''));\n }\n return camelcase(this.name());\n }\n\n /**\n * Set the help group heading.\n *\n * @param {string} heading\n * @return {Option}\n */\n helpGroup(heading) {\n this.helpGroupHeading = heading;\n return this;\n }\n\n /**\n * Check if `arg` matches the short or long flag.\n *\n * @param {string} arg\n * @return {boolean}\n * @package\n */\n\n is(arg) {\n return this.short === arg || this.long === arg;\n }\n\n /**\n * Return whether a boolean option.\n *\n * Options are one of boolean, negated, required argument, or optional argument.\n *\n * @return {boolean}\n * @package\n */\n\n isBoolean() {\n return !this.required && !this.optional && !this.negate;\n }\n}\n\n/**\n * This class is to make it easier to work with dual options, without changing the existing\n * implementation. We support separate dual options for separate positive and negative options,\n * like `--build` and `--no-build`, which share a single option value. This works nicely for some\n * use cases, but is tricky for others where we want separate behaviours despite\n * the single shared option value.\n */\nclass DualOptions {\n /**\n * @param {Option[]} options\n */\n constructor(options) {\n this.positiveOptions = new Map();\n this.negativeOptions = new Map();\n this.dualOptions = new Set();\n options.forEach((option) => {\n if (option.negate) {\n this.negativeOptions.set(option.attributeName(), option);\n } else {\n this.positiveOptions.set(option.attributeName(), option);\n }\n });\n this.negativeOptions.forEach((value, key) => {\n if (this.positiveOptions.has(key)) {\n this.dualOptions.add(key);\n }\n });\n }\n\n /**\n * Did the value come from the option, and not from possible matching dual option?\n *\n * @param {*} value\n * @param {Option} option\n * @returns {boolean}\n */\n valueFromOption(value, option) {\n const optionKey = option.attributeName();\n if (!this.dualOptions.has(optionKey)) return true;\n\n // Use the value to deduce if (probably) came from the option.\n const preset = this.negativeOptions.get(optionKey).presetArg;\n const negativeValue = preset !== undefined ? preset : false;\n return option.negate === (negativeValue === value);\n }\n}\n\n/**\n * Convert string from kebab-case to camelCase.\n *\n * @param {string} str\n * @return {string}\n * @private\n */\n\nfunction camelcase(str) {\n return str.split('-').reduce((str, word) => {\n return str + word[0].toUpperCase() + word.slice(1);\n });\n}\n\n/**\n * Split the short and long flag out of something like '-m,--mixed '\n *\n * @private\n */\n\nfunction splitOptionFlags(flags) {\n let shortFlag;\n let longFlag;\n // short flag, single dash and single character\n const shortFlagExp = /^-[^-]$/;\n // long flag, double dash and at least one character\n const longFlagExp = /^--[^-]/;\n\n const flagParts = flags.split(/[ |,]+/).concat('guard');\n // Normal is short and/or long.\n if (shortFlagExp.test(flagParts[0])) shortFlag = flagParts.shift();\n if (longFlagExp.test(flagParts[0])) longFlag = flagParts.shift();\n // Long then short. Rarely used but fine.\n if (!shortFlag && shortFlagExp.test(flagParts[0]))\n shortFlag = flagParts.shift();\n // Allow two long flags, like '--ws, --workspace'\n // This is the supported way to have a shortish option flag.\n if (!shortFlag && longFlagExp.test(flagParts[0])) {\n shortFlag = longFlag;\n longFlag = flagParts.shift();\n }\n\n // Check for unprocessed flag. Fail noisily rather than silently ignore.\n if (flagParts[0].startsWith('-')) {\n const unsupportedFlag = flagParts[0];\n const baseError = `option creation failed due to '${unsupportedFlag}' in option flags '${flags}'`;\n if (/^-[^-][^-]/.test(unsupportedFlag))\n throw new Error(\n `${baseError}\n- a short flag is a single dash and a single character\n - either use a single dash and a single character (for a short flag)\n - or use a double dash for a long option (and can have two, like '--ws, --workspace')`,\n );\n if (shortFlagExp.test(unsupportedFlag))\n throw new Error(`${baseError}\n- too many short flags`);\n if (longFlagExp.test(unsupportedFlag))\n throw new Error(`${baseError}\n- too many long flags`);\n\n throw new Error(`${baseError}\n- unrecognised flag format`);\n }\n if (shortFlag === undefined && longFlag === undefined)\n throw new Error(\n `option creation failed due to no flags found in '${flags}'.`,\n );\n\n return { shortFlag, longFlag };\n}\n\nexports.Option = Option;\nexports.DualOptions = DualOptions;\n", "const maxDistance = 3;\n\nfunction editDistance(a, b) {\n // https://en.wikipedia.org/wiki/Damerau\u2013Levenshtein_distance\n // Calculating optimal string alignment distance, no substring is edited more than once.\n // (Simple implementation.)\n\n // Quick early exit, return worst case.\n if (Math.abs(a.length - b.length) > maxDistance)\n return Math.max(a.length, b.length);\n\n // distance between prefix substrings of a and b\n const d = [];\n\n // pure deletions turn a into empty string\n for (let i = 0; i <= a.length; i++) {\n d[i] = [i];\n }\n // pure insertions turn empty string into b\n for (let j = 0; j <= b.length; j++) {\n d[0][j] = j;\n }\n\n // fill matrix\n for (let j = 1; j <= b.length; j++) {\n for (let i = 1; i <= a.length; i++) {\n let cost = 1;\n if (a[i - 1] === b[j - 1]) {\n cost = 0;\n } else {\n cost = 1;\n }\n d[i][j] = Math.min(\n d[i - 1][j] + 1, // deletion\n d[i][j - 1] + 1, // insertion\n d[i - 1][j - 1] + cost, // substitution\n );\n // transposition\n if (i > 1 && j > 1 && a[i - 1] === b[j - 2] && a[i - 2] === b[j - 1]) {\n d[i][j] = Math.min(d[i][j], d[i - 2][j - 2] + 1);\n }\n }\n }\n\n return d[a.length][b.length];\n}\n\n/**\n * Find close matches, restricted to same number of edits.\n *\n * @param {string} word\n * @param {string[]} candidates\n * @returns {string}\n */\n\nfunction suggestSimilar(word, candidates) {\n if (!candidates || candidates.length === 0) return '';\n // remove possible duplicates\n candidates = Array.from(new Set(candidates));\n\n const searchingOptions = word.startsWith('--');\n if (searchingOptions) {\n word = word.slice(2);\n candidates = candidates.map((candidate) => candidate.slice(2));\n }\n\n let similar = [];\n let bestDistance = maxDistance;\n const minSimilarity = 0.4;\n candidates.forEach((candidate) => {\n if (candidate.length <= 1) return; // no one character guesses\n\n const distance = editDistance(word, candidate);\n const length = Math.max(word.length, candidate.length);\n const similarity = (length - distance) / length;\n if (similarity > minSimilarity) {\n if (distance < bestDistance) {\n // better edit distance, throw away previous worse matches\n bestDistance = distance;\n similar = [candidate];\n } else if (distance === bestDistance) {\n similar.push(candidate);\n }\n }\n });\n\n similar.sort((a, b) => a.localeCompare(b));\n if (searchingOptions) {\n similar = similar.map((candidate) => `--${candidate}`);\n }\n\n if (similar.length > 1) {\n return `\\n(Did you mean one of ${similar.join(', ')}?)`;\n }\n if (similar.length === 1) {\n return `\\n(Did you mean ${similar[0]}?)`;\n }\n return '';\n}\n\nexports.suggestSimilar = suggestSimilar;\n", "const EventEmitter = require('node:events').EventEmitter;\nconst childProcess = require('node:child_process');\nconst path = require('node:path');\nconst fs = require('node:fs');\nconst process = require('node:process');\n\nconst { Argument, humanReadableArgName } = require('./argument.js');\nconst { CommanderError } = require('./error.js');\nconst { Help, stripColor } = require('./help.js');\nconst { Option, DualOptions } = require('./option.js');\nconst { suggestSimilar } = require('./suggestSimilar');\n\nclass Command extends EventEmitter {\n /**\n * Initialize a new `Command`.\n *\n * @param {string} [name]\n */\n\n constructor(name) {\n super();\n /** @type {Command[]} */\n this.commands = [];\n /** @type {Option[]} */\n this.options = [];\n this.parent = null;\n this._allowUnknownOption = false;\n this._allowExcessArguments = false;\n /** @type {Argument[]} */\n this.registeredArguments = [];\n this._args = this.registeredArguments; // deprecated old name\n /** @type {string[]} */\n this.args = []; // cli args with options removed\n this.rawArgs = [];\n this.processedArgs = []; // like .args but after custom processing and collecting variadic\n this._scriptPath = null;\n this._name = name || '';\n this._optionValues = {};\n this._optionValueSources = {}; // default, env, cli etc\n this._storeOptionsAsProperties = false;\n this._actionHandler = null;\n this._executableHandler = false;\n this._executableFile = null; // custom name for executable\n this._executableDir = null; // custom search directory for subcommands\n this._defaultCommandName = null;\n this._exitCallback = null;\n this._aliases = [];\n this._combineFlagAndOptionalValue = true;\n this._description = '';\n this._summary = '';\n this._argsDescription = undefined; // legacy\n this._enablePositionalOptions = false;\n this._passThroughOptions = false;\n this._lifeCycleHooks = {}; // a hash of arrays\n /** @type {(boolean | string)} */\n this._showHelpAfterError = false;\n this._showSuggestionAfterError = true;\n this._savedState = null; // used in save/restoreStateBeforeParse\n\n // see configureOutput() for docs\n this._outputConfiguration = {\n writeOut: (str) => process.stdout.write(str),\n writeErr: (str) => process.stderr.write(str),\n outputError: (str, write) => write(str),\n getOutHelpWidth: () =>\n process.stdout.isTTY ? process.stdout.columns : undefined,\n getErrHelpWidth: () =>\n process.stderr.isTTY ? process.stderr.columns : undefined,\n getOutHasColors: () =>\n useColor() ?? (process.stdout.isTTY && process.stdout.hasColors?.()),\n getErrHasColors: () =>\n useColor() ?? (process.stderr.isTTY && process.stderr.hasColors?.()),\n stripColor: (str) => stripColor(str),\n };\n\n this._hidden = false;\n /** @type {(Option | null | undefined)} */\n this._helpOption = undefined; // Lazy created on demand. May be null if help option is disabled.\n this._addImplicitHelpCommand = undefined; // undecided whether true or false yet, not inherited\n /** @type {Command} */\n this._helpCommand = undefined; // lazy initialised, inherited\n this._helpConfiguration = {};\n /** @type {string | undefined} */\n this._helpGroupHeading = undefined; // soft initialised when added to parent\n /** @type {string | undefined} */\n this._defaultCommandGroup = undefined;\n /** @type {string | undefined} */\n this._defaultOptionGroup = undefined;\n }\n\n /**\n * Copy settings that are useful to have in common across root command and subcommands.\n *\n * (Used internally when adding a command using `.command()` so subcommands inherit parent settings.)\n *\n * @param {Command} sourceCommand\n * @return {Command} `this` command for chaining\n */\n copyInheritedSettings(sourceCommand) {\n this._outputConfiguration = sourceCommand._outputConfiguration;\n this._helpOption = sourceCommand._helpOption;\n this._helpCommand = sourceCommand._helpCommand;\n this._helpConfiguration = sourceCommand._helpConfiguration;\n this._exitCallback = sourceCommand._exitCallback;\n this._storeOptionsAsProperties = sourceCommand._storeOptionsAsProperties;\n this._combineFlagAndOptionalValue =\n sourceCommand._combineFlagAndOptionalValue;\n this._allowExcessArguments = sourceCommand._allowExcessArguments;\n this._enablePositionalOptions = sourceCommand._enablePositionalOptions;\n this._showHelpAfterError = sourceCommand._showHelpAfterError;\n this._showSuggestionAfterError = sourceCommand._showSuggestionAfterError;\n\n return this;\n }\n\n /**\n * @returns {Command[]}\n * @private\n */\n\n _getCommandAndAncestors() {\n const result = [];\n // eslint-disable-next-line @typescript-eslint/no-this-alias\n for (let command = this; command; command = command.parent) {\n result.push(command);\n }\n return result;\n }\n\n /**\n * Define a command.\n *\n * There are two styles of command: pay attention to where to put the description.\n *\n * @example\n * // Command implemented using action handler (description is supplied separately to `.command`)\n * program\n * .command('clone [destination]')\n * .description('clone a repository into a newly created directory')\n * .action((source, destination) => {\n * console.log('clone command called');\n * });\n *\n * // Command implemented using separate executable file (description is second parameter to `.command`)\n * program\n * .command('start ', 'start named service')\n * .command('stop [service]', 'stop named service, or all if no name supplied');\n *\n * @param {string} nameAndArgs - command name and arguments, args are `` or `[optional]` and last may also be `variadic...`\n * @param {(object | string)} [actionOptsOrExecDesc] - configuration options (for action), or description (for executable)\n * @param {object} [execOpts] - configuration options (for executable)\n * @return {Command} returns new command for action handler, or `this` for executable command\n */\n\n command(nameAndArgs, actionOptsOrExecDesc, execOpts) {\n let desc = actionOptsOrExecDesc;\n let opts = execOpts;\n if (typeof desc === 'object' && desc !== null) {\n opts = desc;\n desc = null;\n }\n opts = opts || {};\n const [, name, args] = nameAndArgs.match(/([^ ]+) *(.*)/);\n\n const cmd = this.createCommand(name);\n if (desc) {\n cmd.description(desc);\n cmd._executableHandler = true;\n }\n if (opts.isDefault) this._defaultCommandName = cmd._name;\n cmd._hidden = !!(opts.noHelp || opts.hidden); // noHelp is deprecated old name for hidden\n cmd._executableFile = opts.executableFile || null; // Custom name for executable file, set missing to null to match constructor\n if (args) cmd.arguments(args);\n this._registerCommand(cmd);\n cmd.parent = this;\n cmd.copyInheritedSettings(this);\n\n if (desc) return this;\n return cmd;\n }\n\n /**\n * Factory routine to create a new unattached command.\n *\n * See .command() for creating an attached subcommand, which uses this routine to\n * create the command. You can override createCommand to customise subcommands.\n *\n * @param {string} [name]\n * @return {Command} new command\n */\n\n createCommand(name) {\n return new Command(name);\n }\n\n /**\n * You can customise the help with a subclass of Help by overriding createHelp,\n * or by overriding Help properties using configureHelp().\n *\n * @return {Help}\n */\n\n createHelp() {\n return Object.assign(new Help(), this.configureHelp());\n }\n\n /**\n * You can customise the help by overriding Help properties using configureHelp(),\n * or with a subclass of Help by overriding createHelp().\n *\n * @param {object} [configuration] - configuration options\n * @return {(Command | object)} `this` command for chaining, or stored configuration\n */\n\n configureHelp(configuration) {\n if (configuration === undefined) return this._helpConfiguration;\n\n this._helpConfiguration = configuration;\n return this;\n }\n\n /**\n * The default output goes to stdout and stderr. You can customise this for special\n * applications. You can also customise the display of errors by overriding outputError.\n *\n * The configuration properties are all functions:\n *\n * // change how output being written, defaults to stdout and stderr\n * writeOut(str)\n * writeErr(str)\n * // change how output being written for errors, defaults to writeErr\n * outputError(str, write) // used for displaying errors and not used for displaying help\n * // specify width for wrapping help\n * getOutHelpWidth()\n * getErrHelpWidth()\n * // color support, currently only used with Help\n * getOutHasColors()\n * getErrHasColors()\n * stripColor() // used to remove ANSI escape codes if output does not have colors\n *\n * @param {object} [configuration] - configuration options\n * @return {(Command | object)} `this` command for chaining, or stored configuration\n */\n\n configureOutput(configuration) {\n if (configuration === undefined) return this._outputConfiguration;\n\n this._outputConfiguration = Object.assign(\n {},\n this._outputConfiguration,\n configuration,\n );\n return this;\n }\n\n /**\n * Display the help or a custom message after an error occurs.\n *\n * @param {(boolean|string)} [displayHelp]\n * @return {Command} `this` command for chaining\n */\n showHelpAfterError(displayHelp = true) {\n if (typeof displayHelp !== 'string') displayHelp = !!displayHelp;\n this._showHelpAfterError = displayHelp;\n return this;\n }\n\n /**\n * Display suggestion of similar commands for unknown commands, or options for unknown options.\n *\n * @param {boolean} [displaySuggestion]\n * @return {Command} `this` command for chaining\n */\n showSuggestionAfterError(displaySuggestion = true) {\n this._showSuggestionAfterError = !!displaySuggestion;\n return this;\n }\n\n /**\n * Add a prepared subcommand.\n *\n * See .command() for creating an attached subcommand which inherits settings from its parent.\n *\n * @param {Command} cmd - new subcommand\n * @param {object} [opts] - configuration options\n * @return {Command} `this` command for chaining\n */\n\n addCommand(cmd, opts) {\n if (!cmd._name) {\n throw new Error(`Command passed to .addCommand() must have a name\n- specify the name in Command constructor or using .name()`);\n }\n\n opts = opts || {};\n if (opts.isDefault) this._defaultCommandName = cmd._name;\n if (opts.noHelp || opts.hidden) cmd._hidden = true; // modifying passed command due to existing implementation\n\n this._registerCommand(cmd);\n cmd.parent = this;\n cmd._checkForBrokenPassThrough();\n\n return this;\n }\n\n /**\n * Factory routine to create a new unattached argument.\n *\n * See .argument() for creating an attached argument, which uses this routine to\n * create the argument. You can override createArgument to return a custom argument.\n *\n * @param {string} name\n * @param {string} [description]\n * @return {Argument} new argument\n */\n\n createArgument(name, description) {\n return new Argument(name, description);\n }\n\n /**\n * Define argument syntax for command.\n *\n * The default is that the argument is required, and you can explicitly\n * indicate this with <> around the name. Put [] around the name for an optional argument.\n *\n * @example\n * program.argument('');\n * program.argument('[output-file]');\n *\n * @param {string} name\n * @param {string} [description]\n * @param {(Function|*)} [parseArg] - custom argument processing function or default value\n * @param {*} [defaultValue]\n * @return {Command} `this` command for chaining\n */\n argument(name, description, parseArg, defaultValue) {\n const argument = this.createArgument(name, description);\n if (typeof parseArg === 'function') {\n argument.default(defaultValue).argParser(parseArg);\n } else {\n argument.default(parseArg);\n }\n this.addArgument(argument);\n return this;\n }\n\n /**\n * Define argument syntax for command, adding multiple at once (without descriptions).\n *\n * See also .argument().\n *\n * @example\n * program.arguments(' [env]');\n *\n * @param {string} names\n * @return {Command} `this` command for chaining\n */\n\n arguments(names) {\n names\n .trim()\n .split(/ +/)\n .forEach((detail) => {\n this.argument(detail);\n });\n return this;\n }\n\n /**\n * Define argument syntax for command, adding a prepared argument.\n *\n * @param {Argument} argument\n * @return {Command} `this` command for chaining\n */\n addArgument(argument) {\n const previousArgument = this.registeredArguments.slice(-1)[0];\n if (previousArgument && previousArgument.variadic) {\n throw new Error(\n `only the last argument can be variadic '${previousArgument.name()}'`,\n );\n }\n if (\n argument.required &&\n argument.defaultValue !== undefined &&\n argument.parseArg === undefined\n ) {\n throw new Error(\n `a default value for a required argument is never used: '${argument.name()}'`,\n );\n }\n this.registeredArguments.push(argument);\n return this;\n }\n\n /**\n * Customise or override default help command. By default a help command is automatically added if your command has subcommands.\n *\n * @example\n * program.helpCommand('help [cmd]');\n * program.helpCommand('help [cmd]', 'show help');\n * program.helpCommand(false); // suppress default help command\n * program.helpCommand(true); // add help command even if no subcommands\n *\n * @param {string|boolean} enableOrNameAndArgs - enable with custom name and/or arguments, or boolean to override whether added\n * @param {string} [description] - custom description\n * @return {Command} `this` command for chaining\n */\n\n helpCommand(enableOrNameAndArgs, description) {\n if (typeof enableOrNameAndArgs === 'boolean') {\n this._addImplicitHelpCommand = enableOrNameAndArgs;\n if (enableOrNameAndArgs && this._defaultCommandGroup) {\n // make the command to store the group\n this._initCommandGroup(this._getHelpCommand());\n }\n return this;\n }\n\n const nameAndArgs = enableOrNameAndArgs ?? 'help [command]';\n const [, helpName, helpArgs] = nameAndArgs.match(/([^ ]+) *(.*)/);\n const helpDescription = description ?? 'display help for command';\n\n const helpCommand = this.createCommand(helpName);\n helpCommand.helpOption(false);\n if (helpArgs) helpCommand.arguments(helpArgs);\n if (helpDescription) helpCommand.description(helpDescription);\n\n this._addImplicitHelpCommand = true;\n this._helpCommand = helpCommand;\n // init group unless lazy create\n if (enableOrNameAndArgs || description) this._initCommandGroup(helpCommand);\n\n return this;\n }\n\n /**\n * Add prepared custom help command.\n *\n * @param {(Command|string|boolean)} helpCommand - custom help command, or deprecated enableOrNameAndArgs as for `.helpCommand()`\n * @param {string} [deprecatedDescription] - deprecated custom description used with custom name only\n * @return {Command} `this` command for chaining\n */\n addHelpCommand(helpCommand, deprecatedDescription) {\n // If not passed an object, call through to helpCommand for backwards compatibility,\n // as addHelpCommand was originally used like helpCommand is now.\n if (typeof helpCommand !== 'object') {\n this.helpCommand(helpCommand, deprecatedDescription);\n return this;\n }\n\n this._addImplicitHelpCommand = true;\n this._helpCommand = helpCommand;\n this._initCommandGroup(helpCommand);\n return this;\n }\n\n /**\n * Lazy create help command.\n *\n * @return {(Command|null)}\n * @package\n */\n _getHelpCommand() {\n const hasImplicitHelpCommand =\n this._addImplicitHelpCommand ??\n (this.commands.length &&\n !this._actionHandler &&\n !this._findCommand('help'));\n\n if (hasImplicitHelpCommand) {\n if (this._helpCommand === undefined) {\n this.helpCommand(undefined, undefined); // use default name and description\n }\n return this._helpCommand;\n }\n return null;\n }\n\n /**\n * Add hook for life cycle event.\n *\n * @param {string} event\n * @param {Function} listener\n * @return {Command} `this` command for chaining\n */\n\n hook(event, listener) {\n const allowedValues = ['preSubcommand', 'preAction', 'postAction'];\n if (!allowedValues.includes(event)) {\n throw new Error(`Unexpected value for event passed to hook : '${event}'.\nExpecting one of '${allowedValues.join(\"', '\")}'`);\n }\n if (this._lifeCycleHooks[event]) {\n this._lifeCycleHooks[event].push(listener);\n } else {\n this._lifeCycleHooks[event] = [listener];\n }\n return this;\n }\n\n /**\n * Register callback to use as replacement for calling process.exit.\n *\n * @param {Function} [fn] optional callback which will be passed a CommanderError, defaults to throwing\n * @return {Command} `this` command for chaining\n */\n\n exitOverride(fn) {\n if (fn) {\n this._exitCallback = fn;\n } else {\n this._exitCallback = (err) => {\n if (err.code !== 'commander.executeSubCommandAsync') {\n throw err;\n } else {\n // Async callback from spawn events, not useful to throw.\n }\n };\n }\n return this;\n }\n\n /**\n * Call process.exit, and _exitCallback if defined.\n *\n * @param {number} exitCode exit code for using with process.exit\n * @param {string} code an id string representing the error\n * @param {string} message human-readable description of the error\n * @return never\n * @private\n */\n\n _exit(exitCode, code, message) {\n if (this._exitCallback) {\n this._exitCallback(new CommanderError(exitCode, code, message));\n // Expecting this line is not reached.\n }\n process.exit(exitCode);\n }\n\n /**\n * Register callback `fn` for the command.\n *\n * @example\n * program\n * .command('serve')\n * .description('start service')\n * .action(function() {\n * // do work here\n * });\n *\n * @param {Function} fn\n * @return {Command} `this` command for chaining\n */\n\n action(fn) {\n const listener = (args) => {\n // The .action callback takes an extra parameter which is the command or options.\n const expectedArgsCount = this.registeredArguments.length;\n const actionArgs = args.slice(0, expectedArgsCount);\n if (this._storeOptionsAsProperties) {\n actionArgs[expectedArgsCount] = this; // backwards compatible \"options\"\n } else {\n actionArgs[expectedArgsCount] = this.opts();\n }\n actionArgs.push(this);\n\n return fn.apply(this, actionArgs);\n };\n this._actionHandler = listener;\n return this;\n }\n\n /**\n * Factory routine to create a new unattached option.\n *\n * See .option() for creating an attached option, which uses this routine to\n * create the option. You can override createOption to return a custom option.\n *\n * @param {string} flags\n * @param {string} [description]\n * @return {Option} new option\n */\n\n createOption(flags, description) {\n return new Option(flags, description);\n }\n\n /**\n * Wrap parseArgs to catch 'commander.invalidArgument'.\n *\n * @param {(Option | Argument)} target\n * @param {string} value\n * @param {*} previous\n * @param {string} invalidArgumentMessage\n * @private\n */\n\n _callParseArg(target, value, previous, invalidArgumentMessage) {\n try {\n return target.parseArg(value, previous);\n } catch (err) {\n if (err.code === 'commander.invalidArgument') {\n const message = `${invalidArgumentMessage} ${err.message}`;\n this.error(message, { exitCode: err.exitCode, code: err.code });\n }\n throw err;\n }\n }\n\n /**\n * Check for option flag conflicts.\n * Register option if no conflicts found, or throw on conflict.\n *\n * @param {Option} option\n * @private\n */\n\n _registerOption(option) {\n const matchingOption =\n (option.short && this._findOption(option.short)) ||\n (option.long && this._findOption(option.long));\n if (matchingOption) {\n const matchingFlag =\n option.long && this._findOption(option.long)\n ? option.long\n : option.short;\n throw new Error(`Cannot add option '${option.flags}'${this._name && ` to command '${this._name}'`} due to conflicting flag '${matchingFlag}'\n- already used by option '${matchingOption.flags}'`);\n }\n\n this._initOptionGroup(option);\n this.options.push(option);\n }\n\n /**\n * Check for command name and alias conflicts with existing commands.\n * Register command if no conflicts found, or throw on conflict.\n *\n * @param {Command} command\n * @private\n */\n\n _registerCommand(command) {\n const knownBy = (cmd) => {\n return [cmd.name()].concat(cmd.aliases());\n };\n\n const alreadyUsed = knownBy(command).find((name) =>\n this._findCommand(name),\n );\n if (alreadyUsed) {\n const existingCmd = knownBy(this._findCommand(alreadyUsed)).join('|');\n const newCmd = knownBy(command).join('|');\n throw new Error(\n `cannot add command '${newCmd}' as already have command '${existingCmd}'`,\n );\n }\n\n this._initCommandGroup(command);\n this.commands.push(command);\n }\n\n /**\n * Add an option.\n *\n * @param {Option} option\n * @return {Command} `this` command for chaining\n */\n addOption(option) {\n this._registerOption(option);\n\n const oname = option.name();\n const name = option.attributeName();\n\n // store default value\n if (option.negate) {\n // --no-foo is special and defaults foo to true, unless a --foo option is already defined\n const positiveLongFlag = option.long.replace(/^--no-/, '--');\n if (!this._findOption(positiveLongFlag)) {\n this.setOptionValueWithSource(\n name,\n option.defaultValue === undefined ? true : option.defaultValue,\n 'default',\n );\n }\n } else if (option.defaultValue !== undefined) {\n this.setOptionValueWithSource(name, option.defaultValue, 'default');\n }\n\n // handler for cli and env supplied values\n const handleOptionValue = (val, invalidValueMessage, valueSource) => {\n // val is null for optional option used without an optional-argument.\n // val is undefined for boolean and negated option.\n if (val == null && option.presetArg !== undefined) {\n val = option.presetArg;\n }\n\n // custom processing\n const oldValue = this.getOptionValue(name);\n if (val !== null && option.parseArg) {\n val = this._callParseArg(option, val, oldValue, invalidValueMessage);\n } else if (val !== null && option.variadic) {\n val = option._concatValue(val, oldValue);\n }\n\n // Fill-in appropriate missing values. Long winded but easy to follow.\n if (val == null) {\n if (option.negate) {\n val = false;\n } else if (option.isBoolean() || option.optional) {\n val = true;\n } else {\n val = ''; // not normal, parseArg might have failed or be a mock function for testing\n }\n }\n this.setOptionValueWithSource(name, val, valueSource);\n };\n\n this.on('option:' + oname, (val) => {\n const invalidValueMessage = `error: option '${option.flags}' argument '${val}' is invalid.`;\n handleOptionValue(val, invalidValueMessage, 'cli');\n });\n\n if (option.envVar) {\n this.on('optionEnv:' + oname, (val) => {\n const invalidValueMessage = `error: option '${option.flags}' value '${val}' from env '${option.envVar}' is invalid.`;\n handleOptionValue(val, invalidValueMessage, 'env');\n });\n }\n\n return this;\n }\n\n /**\n * Internal implementation shared by .option() and .requiredOption()\n *\n * @return {Command} `this` command for chaining\n * @private\n */\n _optionEx(config, flags, description, fn, defaultValue) {\n if (typeof flags === 'object' && flags instanceof Option) {\n throw new Error(\n 'To add an Option object use addOption() instead of option() or requiredOption()',\n );\n }\n const option = this.createOption(flags, description);\n option.makeOptionMandatory(!!config.mandatory);\n if (typeof fn === 'function') {\n option.default(defaultValue).argParser(fn);\n } else if (fn instanceof RegExp) {\n // deprecated\n const regex = fn;\n fn = (val, def) => {\n const m = regex.exec(val);\n return m ? m[0] : def;\n };\n option.default(defaultValue).argParser(fn);\n } else {\n option.default(fn);\n }\n\n return this.addOption(option);\n }\n\n /**\n * Define option with `flags`, `description`, and optional argument parsing function or `defaultValue` or both.\n *\n * The `flags` string contains the short and/or long flags, separated by comma, a pipe or space. A required\n * option-argument is indicated by `<>` and an optional option-argument by `[]`.\n *\n * See the README for more details, and see also addOption() and requiredOption().\n *\n * @example\n * program\n * .option('-p, --pepper', 'add pepper')\n * .option('--pt, --pizza-type ', 'type of pizza') // required option-argument\n * .option('-c, --cheese [CHEESE]', 'add extra cheese', 'mozzarella') // optional option-argument with default\n * .option('-t, --tip ', 'add tip to purchase cost', parseFloat) // custom parse function\n *\n * @param {string} flags\n * @param {string} [description]\n * @param {(Function|*)} [parseArg] - custom option processing function or default value\n * @param {*} [defaultValue]\n * @return {Command} `this` command for chaining\n */\n\n option(flags, description, parseArg, defaultValue) {\n return this._optionEx({}, flags, description, parseArg, defaultValue);\n }\n\n /**\n * Add a required option which must have a value after parsing. This usually means\n * the option must be specified on the command line. (Otherwise the same as .option().)\n *\n * The `flags` string contains the short and/or long flags, separated by comma, a pipe or space.\n *\n * @param {string} flags\n * @param {string} [description]\n * @param {(Function|*)} [parseArg] - custom option processing function or default value\n * @param {*} [defaultValue]\n * @return {Command} `this` command for chaining\n */\n\n requiredOption(flags, description, parseArg, defaultValue) {\n return this._optionEx(\n { mandatory: true },\n flags,\n description,\n parseArg,\n defaultValue,\n );\n }\n\n /**\n * Alter parsing of short flags with optional values.\n *\n * @example\n * // for `.option('-f,--flag [value]'):\n * program.combineFlagAndOptionalValue(true); // `-f80` is treated like `--flag=80`, this is the default behaviour\n * program.combineFlagAndOptionalValue(false) // `-fb` is treated like `-f -b`\n *\n * @param {boolean} [combine] - if `true` or omitted, an optional value can be specified directly after the flag.\n * @return {Command} `this` command for chaining\n */\n combineFlagAndOptionalValue(combine = true) {\n this._combineFlagAndOptionalValue = !!combine;\n return this;\n }\n\n /**\n * Allow unknown options on the command line.\n *\n * @param {boolean} [allowUnknown] - if `true` or omitted, no error will be thrown for unknown options.\n * @return {Command} `this` command for chaining\n */\n allowUnknownOption(allowUnknown = true) {\n this._allowUnknownOption = !!allowUnknown;\n return this;\n }\n\n /**\n * Allow excess command-arguments on the command line. Pass false to make excess arguments an error.\n *\n * @param {boolean} [allowExcess] - if `true` or omitted, no error will be thrown for excess arguments.\n * @return {Command} `this` command for chaining\n */\n allowExcessArguments(allowExcess = true) {\n this._allowExcessArguments = !!allowExcess;\n return this;\n }\n\n /**\n * Enable positional options. Positional means global options are specified before subcommands which lets\n * subcommands reuse the same option names, and also enables subcommands to turn on passThroughOptions.\n * The default behaviour is non-positional and global options may appear anywhere on the command line.\n *\n * @param {boolean} [positional]\n * @return {Command} `this` command for chaining\n */\n enablePositionalOptions(positional = true) {\n this._enablePositionalOptions = !!positional;\n return this;\n }\n\n /**\n * Pass through options that come after command-arguments rather than treat them as command-options,\n * so actual command-options come before command-arguments. Turning this on for a subcommand requires\n * positional options to have been enabled on the program (parent commands).\n * The default behaviour is non-positional and options may appear before or after command-arguments.\n *\n * @param {boolean} [passThrough] for unknown options.\n * @return {Command} `this` command for chaining\n */\n passThroughOptions(passThrough = true) {\n this._passThroughOptions = !!passThrough;\n this._checkForBrokenPassThrough();\n return this;\n }\n\n /**\n * @private\n */\n\n _checkForBrokenPassThrough() {\n if (\n this.parent &&\n this._passThroughOptions &&\n !this.parent._enablePositionalOptions\n ) {\n throw new Error(\n `passThroughOptions cannot be used for '${this._name}' without turning on enablePositionalOptions for parent command(s)`,\n );\n }\n }\n\n /**\n * Whether to store option values as properties on command object,\n * or store separately (specify false). In both cases the option values can be accessed using .opts().\n *\n * @param {boolean} [storeAsProperties=true]\n * @return {Command} `this` command for chaining\n */\n\n storeOptionsAsProperties(storeAsProperties = true) {\n if (this.options.length) {\n throw new Error('call .storeOptionsAsProperties() before adding options');\n }\n if (Object.keys(this._optionValues).length) {\n throw new Error(\n 'call .storeOptionsAsProperties() before setting option values',\n );\n }\n this._storeOptionsAsProperties = !!storeAsProperties;\n return this;\n }\n\n /**\n * Retrieve option value.\n *\n * @param {string} key\n * @return {object} value\n */\n\n getOptionValue(key) {\n if (this._storeOptionsAsProperties) {\n return this[key];\n }\n return this._optionValues[key];\n }\n\n /**\n * Store option value.\n *\n * @param {string} key\n * @param {object} value\n * @return {Command} `this` command for chaining\n */\n\n setOptionValue(key, value) {\n return this.setOptionValueWithSource(key, value, undefined);\n }\n\n /**\n * Store option value and where the value came from.\n *\n * @param {string} key\n * @param {object} value\n * @param {string} source - expected values are default/config/env/cli/implied\n * @return {Command} `this` command for chaining\n */\n\n setOptionValueWithSource(key, value, source) {\n if (this._storeOptionsAsProperties) {\n this[key] = value;\n } else {\n this._optionValues[key] = value;\n }\n this._optionValueSources[key] = source;\n return this;\n }\n\n /**\n * Get source of option value.\n * Expected values are default | config | env | cli | implied\n *\n * @param {string} key\n * @return {string}\n */\n\n getOptionValueSource(key) {\n return this._optionValueSources[key];\n }\n\n /**\n * Get source of option value. See also .optsWithGlobals().\n * Expected values are default | config | env | cli | implied\n *\n * @param {string} key\n * @return {string}\n */\n\n getOptionValueSourceWithGlobals(key) {\n // global overwrites local, like optsWithGlobals\n let source;\n this._getCommandAndAncestors().forEach((cmd) => {\n if (cmd.getOptionValueSource(key) !== undefined) {\n source = cmd.getOptionValueSource(key);\n }\n });\n return source;\n }\n\n /**\n * Get user arguments from implied or explicit arguments.\n * Side-effects: set _scriptPath if args included script. Used for default program name, and subcommand searches.\n *\n * @private\n */\n\n _prepareUserArgs(argv, parseOptions) {\n if (argv !== undefined && !Array.isArray(argv)) {\n throw new Error('first parameter to parse must be array or undefined');\n }\n parseOptions = parseOptions || {};\n\n // auto-detect argument conventions if nothing supplied\n if (argv === undefined && parseOptions.from === undefined) {\n if (process.versions?.electron) {\n parseOptions.from = 'electron';\n }\n // check node specific options for scenarios where user CLI args follow executable without scriptname\n const execArgv = process.execArgv ?? [];\n if (\n execArgv.includes('-e') ||\n execArgv.includes('--eval') ||\n execArgv.includes('-p') ||\n execArgv.includes('--print')\n ) {\n parseOptions.from = 'eval'; // internal usage, not documented\n }\n }\n\n // default to using process.argv\n if (argv === undefined) {\n argv = process.argv;\n }\n this.rawArgs = argv.slice();\n\n // extract the user args and scriptPath\n let userArgs;\n switch (parseOptions.from) {\n case undefined:\n case 'node':\n this._scriptPath = argv[1];\n userArgs = argv.slice(2);\n break;\n case 'electron':\n // @ts-ignore: because defaultApp is an unknown property\n if (process.defaultApp) {\n this._scriptPath = argv[1];\n userArgs = argv.slice(2);\n } else {\n userArgs = argv.slice(1);\n }\n break;\n case 'user':\n userArgs = argv.slice(0);\n break;\n case 'eval':\n userArgs = argv.slice(1);\n break;\n default:\n throw new Error(\n `unexpected parse option { from: '${parseOptions.from}' }`,\n );\n }\n\n // Find default name for program from arguments.\n if (!this._name && this._scriptPath)\n this.nameFromFilename(this._scriptPath);\n this._name = this._name || 'program';\n\n return userArgs;\n }\n\n /**\n * Parse `argv`, setting options and invoking commands when defined.\n *\n * Use parseAsync instead of parse if any of your action handlers are async.\n *\n * Call with no parameters to parse `process.argv`. Detects Electron and special node options like `node --eval`. Easy mode!\n *\n * Or call with an array of strings to parse, and optionally where the user arguments start by specifying where the arguments are `from`:\n * - `'node'`: default, `argv[0]` is the application and `argv[1]` is the script being run, with user arguments after that\n * - `'electron'`: `argv[0]` is the application and `argv[1]` varies depending on whether the electron application is packaged\n * - `'user'`: just user arguments\n *\n * @example\n * program.parse(); // parse process.argv and auto-detect electron and special node flags\n * program.parse(process.argv); // assume argv[0] is app and argv[1] is script\n * program.parse(my-args, { from: 'user' }); // just user supplied arguments, nothing special about argv[0]\n *\n * @param {string[]} [argv] - optional, defaults to process.argv\n * @param {object} [parseOptions] - optionally specify style of options with from: node/user/electron\n * @param {string} [parseOptions.from] - where the args are from: 'node', 'user', 'electron'\n * @return {Command} `this` command for chaining\n */\n\n parse(argv, parseOptions) {\n this._prepareForParse();\n const userArgs = this._prepareUserArgs(argv, parseOptions);\n this._parseCommand([], userArgs);\n\n return this;\n }\n\n /**\n * Parse `argv`, setting options and invoking commands when defined.\n *\n * Call with no parameters to parse `process.argv`. Detects Electron and special node options like `node --eval`. Easy mode!\n *\n * Or call with an array of strings to parse, and optionally where the user arguments start by specifying where the arguments are `from`:\n * - `'node'`: default, `argv[0]` is the application and `argv[1]` is the script being run, with user arguments after that\n * - `'electron'`: `argv[0]` is the application and `argv[1]` varies depending on whether the electron application is packaged\n * - `'user'`: just user arguments\n *\n * @example\n * await program.parseAsync(); // parse process.argv and auto-detect electron and special node flags\n * await program.parseAsync(process.argv); // assume argv[0] is app and argv[1] is script\n * await program.parseAsync(my-args, { from: 'user' }); // just user supplied arguments, nothing special about argv[0]\n *\n * @param {string[]} [argv]\n * @param {object} [parseOptions]\n * @param {string} parseOptions.from - where the args are from: 'node', 'user', 'electron'\n * @return {Promise}\n */\n\n async parseAsync(argv, parseOptions) {\n this._prepareForParse();\n const userArgs = this._prepareUserArgs(argv, parseOptions);\n await this._parseCommand([], userArgs);\n\n return this;\n }\n\n _prepareForParse() {\n if (this._savedState === null) {\n this.saveStateBeforeParse();\n } else {\n this.restoreStateBeforeParse();\n }\n }\n\n /**\n * Called the first time parse is called to save state and allow a restore before subsequent calls to parse.\n * Not usually called directly, but available for subclasses to save their custom state.\n *\n * This is called in a lazy way. Only commands used in parsing chain will have state saved.\n */\n saveStateBeforeParse() {\n this._savedState = {\n // name is stable if supplied by author, but may be unspecified for root command and deduced during parsing\n _name: this._name,\n // option values before parse have default values (including false for negated options)\n // shallow clones\n _optionValues: { ...this._optionValues },\n _optionValueSources: { ...this._optionValueSources },\n };\n }\n\n /**\n * Restore state before parse for calls after the first.\n * Not usually called directly, but available for subclasses to save their custom state.\n *\n * This is called in a lazy way. Only commands used in parsing chain will have state restored.\n */\n restoreStateBeforeParse() {\n if (this._storeOptionsAsProperties)\n throw new Error(`Can not call parse again when storeOptionsAsProperties is true.\n- either make a new Command for each call to parse, or stop storing options as properties`);\n\n // clear state from _prepareUserArgs\n this._name = this._savedState._name;\n this._scriptPath = null;\n this.rawArgs = [];\n // clear state from setOptionValueWithSource\n this._optionValues = { ...this._savedState._optionValues };\n this._optionValueSources = { ...this._savedState._optionValueSources };\n // clear state from _parseCommand\n this.args = [];\n // clear state from _processArguments\n this.processedArgs = [];\n }\n\n /**\n * Throw if expected executable is missing. Add lots of help for author.\n *\n * @param {string} executableFile\n * @param {string} executableDir\n * @param {string} subcommandName\n */\n _checkForMissingExecutable(executableFile, executableDir, subcommandName) {\n if (fs.existsSync(executableFile)) return;\n\n const executableDirMessage = executableDir\n ? `searched for local subcommand relative to directory '${executableDir}'`\n : 'no directory for search for local subcommand, use .executableDir() to supply a custom directory';\n const executableMissing = `'${executableFile}' does not exist\n - if '${subcommandName}' is not meant to be an executable command, remove description parameter from '.command()' and use '.description()' instead\n - if the default executable name is not suitable, use the executableFile option to supply a custom name or path\n - ${executableDirMessage}`;\n throw new Error(executableMissing);\n }\n\n /**\n * Execute a sub-command executable.\n *\n * @private\n */\n\n _executeSubCommand(subcommand, args) {\n args = args.slice();\n let launchWithNode = false; // Use node for source targets so do not need to get permissions correct, and on Windows.\n const sourceExt = ['.js', '.ts', '.tsx', '.mjs', '.cjs'];\n\n function findFile(baseDir, baseName) {\n // Look for specified file\n const localBin = path.resolve(baseDir, baseName);\n if (fs.existsSync(localBin)) return localBin;\n\n // Stop looking if candidate already has an expected extension.\n if (sourceExt.includes(path.extname(baseName))) return undefined;\n\n // Try all the extensions.\n const foundExt = sourceExt.find((ext) =>\n fs.existsSync(`${localBin}${ext}`),\n );\n if (foundExt) return `${localBin}${foundExt}`;\n\n return undefined;\n }\n\n // Not checking for help first. Unlikely to have mandatory and executable, and can't robustly test for help flags in external command.\n this._checkForMissingMandatoryOptions();\n this._checkForConflictingOptions();\n\n // executableFile and executableDir might be full path, or just a name\n let executableFile =\n subcommand._executableFile || `${this._name}-${subcommand._name}`;\n let executableDir = this._executableDir || '';\n if (this._scriptPath) {\n let resolvedScriptPath; // resolve possible symlink for installed npm binary\n try {\n resolvedScriptPath = fs.realpathSync(this._scriptPath);\n } catch {\n resolvedScriptPath = this._scriptPath;\n }\n executableDir = path.resolve(\n path.dirname(resolvedScriptPath),\n executableDir,\n );\n }\n\n // Look for a local file in preference to a command in PATH.\n if (executableDir) {\n let localFile = findFile(executableDir, executableFile);\n\n // Legacy search using prefix of script name instead of command name\n if (!localFile && !subcommand._executableFile && this._scriptPath) {\n const legacyName = path.basename(\n this._scriptPath,\n path.extname(this._scriptPath),\n );\n if (legacyName !== this._name) {\n localFile = findFile(\n executableDir,\n `${legacyName}-${subcommand._name}`,\n );\n }\n }\n executableFile = localFile || executableFile;\n }\n\n launchWithNode = sourceExt.includes(path.extname(executableFile));\n\n let proc;\n if (process.platform !== 'win32') {\n if (launchWithNode) {\n args.unshift(executableFile);\n // add executable arguments to spawn\n args = incrementNodeInspectorPort(process.execArgv).concat(args);\n\n proc = childProcess.spawn(process.argv[0], args, { stdio: 'inherit' });\n } else {\n proc = childProcess.spawn(executableFile, args, { stdio: 'inherit' });\n }\n } else {\n this._checkForMissingExecutable(\n executableFile,\n executableDir,\n subcommand._name,\n );\n args.unshift(executableFile);\n // add executable arguments to spawn\n args = incrementNodeInspectorPort(process.execArgv).concat(args);\n proc = childProcess.spawn(process.execPath, args, { stdio: 'inherit' });\n }\n\n if (!proc.killed) {\n // testing mainly to avoid leak warnings during unit tests with mocked spawn\n const signals = ['SIGUSR1', 'SIGUSR2', 'SIGTERM', 'SIGINT', 'SIGHUP'];\n signals.forEach((signal) => {\n process.on(signal, () => {\n if (proc.killed === false && proc.exitCode === null) {\n // @ts-ignore because signals not typed to known strings\n proc.kill(signal);\n }\n });\n });\n }\n\n // By default terminate process when spawned process terminates.\n const exitCallback = this._exitCallback;\n proc.on('close', (code) => {\n code = code ?? 1; // code is null if spawned process terminated due to a signal\n if (!exitCallback) {\n process.exit(code);\n } else {\n exitCallback(\n new CommanderError(\n code,\n 'commander.executeSubCommandAsync',\n '(close)',\n ),\n );\n }\n });\n proc.on('error', (err) => {\n // @ts-ignore: because err.code is an unknown property\n if (err.code === 'ENOENT') {\n this._checkForMissingExecutable(\n executableFile,\n executableDir,\n subcommand._name,\n );\n // @ts-ignore: because err.code is an unknown property\n } else if (err.code === 'EACCES') {\n throw new Error(`'${executableFile}' not executable`);\n }\n if (!exitCallback) {\n process.exit(1);\n } else {\n const wrappedError = new CommanderError(\n 1,\n 'commander.executeSubCommandAsync',\n '(error)',\n );\n wrappedError.nestedError = err;\n exitCallback(wrappedError);\n }\n });\n\n // Store the reference to the child process\n this.runningCommand = proc;\n }\n\n /**\n * @private\n */\n\n _dispatchSubcommand(commandName, operands, unknown) {\n const subCommand = this._findCommand(commandName);\n if (!subCommand) this.help({ error: true });\n\n subCommand._prepareForParse();\n let promiseChain;\n promiseChain = this._chainOrCallSubCommandHook(\n promiseChain,\n subCommand,\n 'preSubcommand',\n );\n promiseChain = this._chainOrCall(promiseChain, () => {\n if (subCommand._executableHandler) {\n this._executeSubCommand(subCommand, operands.concat(unknown));\n } else {\n return subCommand._parseCommand(operands, unknown);\n }\n });\n return promiseChain;\n }\n\n /**\n * Invoke help directly if possible, or dispatch if necessary.\n * e.g. help foo\n *\n * @private\n */\n\n _dispatchHelpCommand(subcommandName) {\n if (!subcommandName) {\n this.help();\n }\n const subCommand = this._findCommand(subcommandName);\n if (subCommand && !subCommand._executableHandler) {\n subCommand.help();\n }\n\n // Fallback to parsing the help flag to invoke the help.\n return this._dispatchSubcommand(\n subcommandName,\n [],\n [this._getHelpOption()?.long ?? this._getHelpOption()?.short ?? '--help'],\n );\n }\n\n /**\n * Check this.args against expected this.registeredArguments.\n *\n * @private\n */\n\n _checkNumberOfArguments() {\n // too few\n this.registeredArguments.forEach((arg, i) => {\n if (arg.required && this.args[i] == null) {\n this.missingArgument(arg.name());\n }\n });\n // too many\n if (\n this.registeredArguments.length > 0 &&\n this.registeredArguments[this.registeredArguments.length - 1].variadic\n ) {\n return;\n }\n if (this.args.length > this.registeredArguments.length) {\n this._excessArguments(this.args);\n }\n }\n\n /**\n * Process this.args using this.registeredArguments and save as this.processedArgs!\n *\n * @private\n */\n\n _processArguments() {\n const myParseArg = (argument, value, previous) => {\n // Extra processing for nice error message on parsing failure.\n let parsedValue = value;\n if (value !== null && argument.parseArg) {\n const invalidValueMessage = `error: command-argument value '${value}' is invalid for argument '${argument.name()}'.`;\n parsedValue = this._callParseArg(\n argument,\n value,\n previous,\n invalidValueMessage,\n );\n }\n return parsedValue;\n };\n\n this._checkNumberOfArguments();\n\n const processedArgs = [];\n this.registeredArguments.forEach((declaredArg, index) => {\n let value = declaredArg.defaultValue;\n if (declaredArg.variadic) {\n // Collect together remaining arguments for passing together as an array.\n if (index < this.args.length) {\n value = this.args.slice(index);\n if (declaredArg.parseArg) {\n value = value.reduce((processed, v) => {\n return myParseArg(declaredArg, v, processed);\n }, declaredArg.defaultValue);\n }\n } else if (value === undefined) {\n value = [];\n }\n } else if (index < this.args.length) {\n value = this.args[index];\n if (declaredArg.parseArg) {\n value = myParseArg(declaredArg, value, declaredArg.defaultValue);\n }\n }\n processedArgs[index] = value;\n });\n this.processedArgs = processedArgs;\n }\n\n /**\n * Once we have a promise we chain, but call synchronously until then.\n *\n * @param {(Promise|undefined)} promise\n * @param {Function} fn\n * @return {(Promise|undefined)}\n * @private\n */\n\n _chainOrCall(promise, fn) {\n // thenable\n if (promise && promise.then && typeof promise.then === 'function') {\n // already have a promise, chain callback\n return promise.then(() => fn());\n }\n // callback might return a promise\n return fn();\n }\n\n /**\n *\n * @param {(Promise|undefined)} promise\n * @param {string} event\n * @return {(Promise|undefined)}\n * @private\n */\n\n _chainOrCallHooks(promise, event) {\n let result = promise;\n const hooks = [];\n this._getCommandAndAncestors()\n .reverse()\n .filter((cmd) => cmd._lifeCycleHooks[event] !== undefined)\n .forEach((hookedCommand) => {\n hookedCommand._lifeCycleHooks[event].forEach((callback) => {\n hooks.push({ hookedCommand, callback });\n });\n });\n if (event === 'postAction') {\n hooks.reverse();\n }\n\n hooks.forEach((hookDetail) => {\n result = this._chainOrCall(result, () => {\n return hookDetail.callback(hookDetail.hookedCommand, this);\n });\n });\n return result;\n }\n\n /**\n *\n * @param {(Promise|undefined)} promise\n * @param {Command} subCommand\n * @param {string} event\n * @return {(Promise|undefined)}\n * @private\n */\n\n _chainOrCallSubCommandHook(promise, subCommand, event) {\n let result = promise;\n if (this._lifeCycleHooks[event] !== undefined) {\n this._lifeCycleHooks[event].forEach((hook) => {\n result = this._chainOrCall(result, () => {\n return hook(this, subCommand);\n });\n });\n }\n return result;\n }\n\n /**\n * Process arguments in context of this command.\n * Returns action result, in case it is a promise.\n *\n * @private\n */\n\n _parseCommand(operands, unknown) {\n const parsed = this.parseOptions(unknown);\n this._parseOptionsEnv(); // after cli, so parseArg not called on both cli and env\n this._parseOptionsImplied();\n operands = operands.concat(parsed.operands);\n unknown = parsed.unknown;\n this.args = operands.concat(unknown);\n\n if (operands && this._findCommand(operands[0])) {\n return this._dispatchSubcommand(operands[0], operands.slice(1), unknown);\n }\n if (\n this._getHelpCommand() &&\n operands[0] === this._getHelpCommand().name()\n ) {\n return this._dispatchHelpCommand(operands[1]);\n }\n if (this._defaultCommandName) {\n this._outputHelpIfRequested(unknown); // Run the help for default command from parent rather than passing to default command\n return this._dispatchSubcommand(\n this._defaultCommandName,\n operands,\n unknown,\n );\n }\n if (\n this.commands.length &&\n this.args.length === 0 &&\n !this._actionHandler &&\n !this._defaultCommandName\n ) {\n // probably missing subcommand and no handler, user needs help (and exit)\n this.help({ error: true });\n }\n\n this._outputHelpIfRequested(parsed.unknown);\n this._checkForMissingMandatoryOptions();\n this._checkForConflictingOptions();\n\n // We do not always call this check to avoid masking a \"better\" error, like unknown command.\n const checkForUnknownOptions = () => {\n if (parsed.unknown.length > 0) {\n this.unknownOption(parsed.unknown[0]);\n }\n };\n\n const commandEvent = `command:${this.name()}`;\n if (this._actionHandler) {\n checkForUnknownOptions();\n this._processArguments();\n\n let promiseChain;\n promiseChain = this._chainOrCallHooks(promiseChain, 'preAction');\n promiseChain = this._chainOrCall(promiseChain, () =>\n this._actionHandler(this.processedArgs),\n );\n if (this.parent) {\n promiseChain = this._chainOrCall(promiseChain, () => {\n this.parent.emit(commandEvent, operands, unknown); // legacy\n });\n }\n promiseChain = this._chainOrCallHooks(promiseChain, 'postAction');\n return promiseChain;\n }\n if (this.parent && this.parent.listenerCount(commandEvent)) {\n checkForUnknownOptions();\n this._processArguments();\n this.parent.emit(commandEvent, operands, unknown); // legacy\n } else if (operands.length) {\n if (this._findCommand('*')) {\n // legacy default command\n return this._dispatchSubcommand('*', operands, unknown);\n }\n if (this.listenerCount('command:*')) {\n // skip option check, emit event for possible misspelling suggestion\n this.emit('command:*', operands, unknown);\n } else if (this.commands.length) {\n this.unknownCommand();\n } else {\n checkForUnknownOptions();\n this._processArguments();\n }\n } else if (this.commands.length) {\n checkForUnknownOptions();\n // This command has subcommands and nothing hooked up at this level, so display help (and exit).\n this.help({ error: true });\n } else {\n checkForUnknownOptions();\n this._processArguments();\n // fall through for caller to handle after calling .parse()\n }\n }\n\n /**\n * Find matching command.\n *\n * @private\n * @return {Command | undefined}\n */\n _findCommand(name) {\n if (!name) return undefined;\n return this.commands.find(\n (cmd) => cmd._name === name || cmd._aliases.includes(name),\n );\n }\n\n /**\n * Return an option matching `arg` if any.\n *\n * @param {string} arg\n * @return {Option}\n * @package\n */\n\n _findOption(arg) {\n return this.options.find((option) => option.is(arg));\n }\n\n /**\n * Display an error message if a mandatory option does not have a value.\n * Called after checking for help flags in leaf subcommand.\n *\n * @private\n */\n\n _checkForMissingMandatoryOptions() {\n // Walk up hierarchy so can call in subcommand after checking for displaying help.\n this._getCommandAndAncestors().forEach((cmd) => {\n cmd.options.forEach((anOption) => {\n if (\n anOption.mandatory &&\n cmd.getOptionValue(anOption.attributeName()) === undefined\n ) {\n cmd.missingMandatoryOptionValue(anOption);\n }\n });\n });\n }\n\n /**\n * Display an error message if conflicting options are used together in this.\n *\n * @private\n */\n _checkForConflictingLocalOptions() {\n const definedNonDefaultOptions = this.options.filter((option) => {\n const optionKey = option.attributeName();\n if (this.getOptionValue(optionKey) === undefined) {\n return false;\n }\n return this.getOptionValueSource(optionKey) !== 'default';\n });\n\n const optionsWithConflicting = definedNonDefaultOptions.filter(\n (option) => option.conflictsWith.length > 0,\n );\n\n optionsWithConflicting.forEach((option) => {\n const conflictingAndDefined = definedNonDefaultOptions.find((defined) =>\n option.conflictsWith.includes(defined.attributeName()),\n );\n if (conflictingAndDefined) {\n this._conflictingOption(option, conflictingAndDefined);\n }\n });\n }\n\n /**\n * Display an error message if conflicting options are used together.\n * Called after checking for help flags in leaf subcommand.\n *\n * @private\n */\n _checkForConflictingOptions() {\n // Walk up hierarchy so can call in subcommand after checking for displaying help.\n this._getCommandAndAncestors().forEach((cmd) => {\n cmd._checkForConflictingLocalOptions();\n });\n }\n\n /**\n * Parse options from `argv` removing known options,\n * and return argv split into operands and unknown arguments.\n *\n * Side effects: modifies command by storing options. Does not reset state if called again.\n *\n * Examples:\n *\n * argv => operands, unknown\n * --known kkk op => [op], []\n * op --known kkk => [op], []\n * sub --unknown uuu op => [sub], [--unknown uuu op]\n * sub -- --unknown uuu op => [sub --unknown uuu op], []\n *\n * @param {string[]} argv\n * @return {{operands: string[], unknown: string[]}}\n */\n\n parseOptions(argv) {\n const operands = []; // operands, not options or values\n const unknown = []; // first unknown option and remaining unknown args\n let dest = operands;\n const args = argv.slice();\n\n function maybeOption(arg) {\n return arg.length > 1 && arg[0] === '-';\n }\n\n const negativeNumberArg = (arg) => {\n // return false if not a negative number\n if (!/^-\\d*\\.?\\d+(e[+-]?\\d+)?$/.test(arg)) return false;\n // negative number is ok unless digit used as an option in command hierarchy\n return !this._getCommandAndAncestors().some((cmd) =>\n cmd.options\n .map((opt) => opt.short)\n .some((short) => /^-\\d$/.test(short)),\n );\n };\n\n // parse options\n let activeVariadicOption = null;\n while (args.length) {\n const arg = args.shift();\n\n // literal\n if (arg === '--') {\n if (dest === unknown) dest.push(arg);\n dest.push(...args);\n break;\n }\n\n if (\n activeVariadicOption &&\n (!maybeOption(arg) || negativeNumberArg(arg))\n ) {\n this.emit(`option:${activeVariadicOption.name()}`, arg);\n continue;\n }\n activeVariadicOption = null;\n\n if (maybeOption(arg)) {\n const option = this._findOption(arg);\n // recognised option, call listener to assign value with possible custom processing\n if (option) {\n if (option.required) {\n const value = args.shift();\n if (value === undefined) this.optionMissingArgument(option);\n this.emit(`option:${option.name()}`, value);\n } else if (option.optional) {\n let value = null;\n // historical behaviour is optional value is following arg unless an option\n if (\n args.length > 0 &&\n (!maybeOption(args[0]) || negativeNumberArg(args[0]))\n ) {\n value = args.shift();\n }\n this.emit(`option:${option.name()}`, value);\n } else {\n // boolean flag\n this.emit(`option:${option.name()}`);\n }\n activeVariadicOption = option.variadic ? option : null;\n continue;\n }\n }\n\n // Look for combo options following single dash, eat first one if known.\n if (arg.length > 2 && arg[0] === '-' && arg[1] !== '-') {\n const option = this._findOption(`-${arg[1]}`);\n if (option) {\n if (\n option.required ||\n (option.optional && this._combineFlagAndOptionalValue)\n ) {\n // option with value following in same argument\n this.emit(`option:${option.name()}`, arg.slice(2));\n } else {\n // boolean option, emit and put back remainder of arg for further processing\n this.emit(`option:${option.name()}`);\n args.unshift(`-${arg.slice(2)}`);\n }\n continue;\n }\n }\n\n // Look for known long flag with value, like --foo=bar\n if (/^--[^=]+=/.test(arg)) {\n const index = arg.indexOf('=');\n const option = this._findOption(arg.slice(0, index));\n if (option && (option.required || option.optional)) {\n this.emit(`option:${option.name()}`, arg.slice(index + 1));\n continue;\n }\n }\n\n // Not a recognised option by this command.\n // Might be a command-argument, or subcommand option, or unknown option, or help command or option.\n\n // An unknown option means further arguments also classified as unknown so can be reprocessed by subcommands.\n // A negative number in a leaf command is not an unknown option.\n if (\n dest === operands &&\n maybeOption(arg) &&\n !(this.commands.length === 0 && negativeNumberArg(arg))\n ) {\n dest = unknown;\n }\n\n // If using positionalOptions, stop processing our options at subcommand.\n if (\n (this._enablePositionalOptions || this._passThroughOptions) &&\n operands.length === 0 &&\n unknown.length === 0\n ) {\n if (this._findCommand(arg)) {\n operands.push(arg);\n if (args.length > 0) unknown.push(...args);\n break;\n } else if (\n this._getHelpCommand() &&\n arg === this._getHelpCommand().name()\n ) {\n operands.push(arg);\n if (args.length > 0) operands.push(...args);\n break;\n } else if (this._defaultCommandName) {\n unknown.push(arg);\n if (args.length > 0) unknown.push(...args);\n break;\n }\n }\n\n // If using passThroughOptions, stop processing options at first command-argument.\n if (this._passThroughOptions) {\n dest.push(arg);\n if (args.length > 0) dest.push(...args);\n break;\n }\n\n // add arg\n dest.push(arg);\n }\n\n return { operands, unknown };\n }\n\n /**\n * Return an object containing local option values as key-value pairs.\n *\n * @return {object}\n */\n opts() {\n if (this._storeOptionsAsProperties) {\n // Preserve original behaviour so backwards compatible when still using properties\n const result = {};\n const len = this.options.length;\n\n for (let i = 0; i < len; i++) {\n const key = this.options[i].attributeName();\n result[key] =\n key === this._versionOptionName ? this._version : this[key];\n }\n return result;\n }\n\n return this._optionValues;\n }\n\n /**\n * Return an object containing merged local and global option values as key-value pairs.\n *\n * @return {object}\n */\n optsWithGlobals() {\n // globals overwrite locals\n return this._getCommandAndAncestors().reduce(\n (combinedOptions, cmd) => Object.assign(combinedOptions, cmd.opts()),\n {},\n );\n }\n\n /**\n * Display error message and exit (or call exitOverride).\n *\n * @param {string} message\n * @param {object} [errorOptions]\n * @param {string} [errorOptions.code] - an id string representing the error\n * @param {number} [errorOptions.exitCode] - used with process.exit\n */\n error(message, errorOptions) {\n // output handling\n this._outputConfiguration.outputError(\n `${message}\\n`,\n this._outputConfiguration.writeErr,\n );\n if (typeof this._showHelpAfterError === 'string') {\n this._outputConfiguration.writeErr(`${this._showHelpAfterError}\\n`);\n } else if (this._showHelpAfterError) {\n this._outputConfiguration.writeErr('\\n');\n this.outputHelp({ error: true });\n }\n\n // exit handling\n const config = errorOptions || {};\n const exitCode = config.exitCode || 1;\n const code = config.code || 'commander.error';\n this._exit(exitCode, code, message);\n }\n\n /**\n * Apply any option related environment variables, if option does\n * not have a value from cli or client code.\n *\n * @private\n */\n _parseOptionsEnv() {\n this.options.forEach((option) => {\n if (option.envVar && option.envVar in process.env) {\n const optionKey = option.attributeName();\n // Priority check. Do not overwrite cli or options from unknown source (client-code).\n if (\n this.getOptionValue(optionKey) === undefined ||\n ['default', 'config', 'env'].includes(\n this.getOptionValueSource(optionKey),\n )\n ) {\n if (option.required || option.optional) {\n // option can take a value\n // keep very simple, optional always takes value\n this.emit(`optionEnv:${option.name()}`, process.env[option.envVar]);\n } else {\n // boolean\n // keep very simple, only care that envVar defined and not the value\n this.emit(`optionEnv:${option.name()}`);\n }\n }\n }\n });\n }\n\n /**\n * Apply any implied option values, if option is undefined or default value.\n *\n * @private\n */\n _parseOptionsImplied() {\n const dualHelper = new DualOptions(this.options);\n const hasCustomOptionValue = (optionKey) => {\n return (\n this.getOptionValue(optionKey) !== undefined &&\n !['default', 'implied'].includes(this.getOptionValueSource(optionKey))\n );\n };\n this.options\n .filter(\n (option) =>\n option.implied !== undefined &&\n hasCustomOptionValue(option.attributeName()) &&\n dualHelper.valueFromOption(\n this.getOptionValue(option.attributeName()),\n option,\n ),\n )\n .forEach((option) => {\n Object.keys(option.implied)\n .filter((impliedKey) => !hasCustomOptionValue(impliedKey))\n .forEach((impliedKey) => {\n this.setOptionValueWithSource(\n impliedKey,\n option.implied[impliedKey],\n 'implied',\n );\n });\n });\n }\n\n /**\n * Argument `name` is missing.\n *\n * @param {string} name\n * @private\n */\n\n missingArgument(name) {\n const message = `error: missing required argument '${name}'`;\n this.error(message, { code: 'commander.missingArgument' });\n }\n\n /**\n * `Option` is missing an argument.\n *\n * @param {Option} option\n * @private\n */\n\n optionMissingArgument(option) {\n const message = `error: option '${option.flags}' argument missing`;\n this.error(message, { code: 'commander.optionMissingArgument' });\n }\n\n /**\n * `Option` does not have a value, and is a mandatory option.\n *\n * @param {Option} option\n * @private\n */\n\n missingMandatoryOptionValue(option) {\n const message = `error: required option '${option.flags}' not specified`;\n this.error(message, { code: 'commander.missingMandatoryOptionValue' });\n }\n\n /**\n * `Option` conflicts with another option.\n *\n * @param {Option} option\n * @param {Option} conflictingOption\n * @private\n */\n _conflictingOption(option, conflictingOption) {\n // The calling code does not know whether a negated option is the source of the\n // value, so do some work to take an educated guess.\n const findBestOptionFromValue = (option) => {\n const optionKey = option.attributeName();\n const optionValue = this.getOptionValue(optionKey);\n const negativeOption = this.options.find(\n (target) => target.negate && optionKey === target.attributeName(),\n );\n const positiveOption = this.options.find(\n (target) => !target.negate && optionKey === target.attributeName(),\n );\n if (\n negativeOption &&\n ((negativeOption.presetArg === undefined && optionValue === false) ||\n (negativeOption.presetArg !== undefined &&\n optionValue === negativeOption.presetArg))\n ) {\n return negativeOption;\n }\n return positiveOption || option;\n };\n\n const getErrorMessage = (option) => {\n const bestOption = findBestOptionFromValue(option);\n const optionKey = bestOption.attributeName();\n const source = this.getOptionValueSource(optionKey);\n if (source === 'env') {\n return `environment variable '${bestOption.envVar}'`;\n }\n return `option '${bestOption.flags}'`;\n };\n\n const message = `error: ${getErrorMessage(option)} cannot be used with ${getErrorMessage(conflictingOption)}`;\n this.error(message, { code: 'commander.conflictingOption' });\n }\n\n /**\n * Unknown option `flag`.\n *\n * @param {string} flag\n * @private\n */\n\n unknownOption(flag) {\n if (this._allowUnknownOption) return;\n let suggestion = '';\n\n if (flag.startsWith('--') && this._showSuggestionAfterError) {\n // Looping to pick up the global options too\n let candidateFlags = [];\n // eslint-disable-next-line @typescript-eslint/no-this-alias\n let command = this;\n do {\n const moreFlags = command\n .createHelp()\n .visibleOptions(command)\n .filter((option) => option.long)\n .map((option) => option.long);\n candidateFlags = candidateFlags.concat(moreFlags);\n command = command.parent;\n } while (command && !command._enablePositionalOptions);\n suggestion = suggestSimilar(flag, candidateFlags);\n }\n\n const message = `error: unknown option '${flag}'${suggestion}`;\n this.error(message, { code: 'commander.unknownOption' });\n }\n\n /**\n * Excess arguments, more than expected.\n *\n * @param {string[]} receivedArgs\n * @private\n */\n\n _excessArguments(receivedArgs) {\n if (this._allowExcessArguments) return;\n\n const expected = this.registeredArguments.length;\n const s = expected === 1 ? '' : 's';\n const forSubcommand = this.parent ? ` for '${this.name()}'` : '';\n const message = `error: too many arguments${forSubcommand}. Expected ${expected} argument${s} but got ${receivedArgs.length}.`;\n this.error(message, { code: 'commander.excessArguments' });\n }\n\n /**\n * Unknown command.\n *\n * @private\n */\n\n unknownCommand() {\n const unknownName = this.args[0];\n let suggestion = '';\n\n if (this._showSuggestionAfterError) {\n const candidateNames = [];\n this.createHelp()\n .visibleCommands(this)\n .forEach((command) => {\n candidateNames.push(command.name());\n // just visible alias\n if (command.alias()) candidateNames.push(command.alias());\n });\n suggestion = suggestSimilar(unknownName, candidateNames);\n }\n\n const message = `error: unknown command '${unknownName}'${suggestion}`;\n this.error(message, { code: 'commander.unknownCommand' });\n }\n\n /**\n * Get or set the program version.\n *\n * This method auto-registers the \"-V, --version\" option which will print the version number.\n *\n * You can optionally supply the flags and description to override the defaults.\n *\n * @param {string} [str]\n * @param {string} [flags]\n * @param {string} [description]\n * @return {(this | string | undefined)} `this` command for chaining, or version string if no arguments\n */\n\n version(str, flags, description) {\n if (str === undefined) return this._version;\n this._version = str;\n flags = flags || '-V, --version';\n description = description || 'output the version number';\n const versionOption = this.createOption(flags, description);\n this._versionOptionName = versionOption.attributeName();\n this._registerOption(versionOption);\n\n this.on('option:' + versionOption.name(), () => {\n this._outputConfiguration.writeOut(`${str}\\n`);\n this._exit(0, 'commander.version', str);\n });\n return this;\n }\n\n /**\n * Set the description.\n *\n * @param {string} [str]\n * @param {object} [argsDescription]\n * @return {(string|Command)}\n */\n description(str, argsDescription) {\n if (str === undefined && argsDescription === undefined)\n return this._description;\n this._description = str;\n if (argsDescription) {\n this._argsDescription = argsDescription;\n }\n return this;\n }\n\n /**\n * Set the summary. Used when listed as subcommand of parent.\n *\n * @param {string} [str]\n * @return {(string|Command)}\n */\n summary(str) {\n if (str === undefined) return this._summary;\n this._summary = str;\n return this;\n }\n\n /**\n * Set an alias for the command.\n *\n * You may call more than once to add multiple aliases. Only the first alias is shown in the auto-generated help.\n *\n * @param {string} [alias]\n * @return {(string|Command)}\n */\n\n alias(alias) {\n if (alias === undefined) return this._aliases[0]; // just return first, for backwards compatibility\n\n /** @type {Command} */\n // eslint-disable-next-line @typescript-eslint/no-this-alias\n let command = this;\n if (\n this.commands.length !== 0 &&\n this.commands[this.commands.length - 1]._executableHandler\n ) {\n // assume adding alias for last added executable subcommand, rather than this\n command = this.commands[this.commands.length - 1];\n }\n\n if (alias === command._name)\n throw new Error(\"Command alias can't be the same as its name\");\n const matchingCommand = this.parent?._findCommand(alias);\n if (matchingCommand) {\n // c.f. _registerCommand\n const existingCmd = [matchingCommand.name()]\n .concat(matchingCommand.aliases())\n .join('|');\n throw new Error(\n `cannot add alias '${alias}' to command '${this.name()}' as already have command '${existingCmd}'`,\n );\n }\n\n command._aliases.push(alias);\n return this;\n }\n\n /**\n * Set aliases for the command.\n *\n * Only the first alias is shown in the auto-generated help.\n *\n * @param {string[]} [aliases]\n * @return {(string[]|Command)}\n */\n\n aliases(aliases) {\n // Getter for the array of aliases is the main reason for having aliases() in addition to alias().\n if (aliases === undefined) return this._aliases;\n\n aliases.forEach((alias) => this.alias(alias));\n return this;\n }\n\n /**\n * Set / get the command usage `str`.\n *\n * @param {string} [str]\n * @return {(string|Command)}\n */\n\n usage(str) {\n if (str === undefined) {\n if (this._usage) return this._usage;\n\n const args = this.registeredArguments.map((arg) => {\n return humanReadableArgName(arg);\n });\n return []\n .concat(\n this.options.length || this._helpOption !== null ? '[options]' : [],\n this.commands.length ? '[command]' : [],\n this.registeredArguments.length ? args : [],\n )\n .join(' ');\n }\n\n this._usage = str;\n return this;\n }\n\n /**\n * Get or set the name of the command.\n *\n * @param {string} [str]\n * @return {(string|Command)}\n */\n\n name(str) {\n if (str === undefined) return this._name;\n this._name = str;\n return this;\n }\n\n /**\n * Set/get the help group heading for this subcommand in parent command's help.\n *\n * @param {string} [heading]\n * @return {Command | string}\n */\n\n helpGroup(heading) {\n if (heading === undefined) return this._helpGroupHeading ?? '';\n this._helpGroupHeading = heading;\n return this;\n }\n\n /**\n * Set/get the default help group heading for subcommands added to this command.\n * (This does not override a group set directly on the subcommand using .helpGroup().)\n *\n * @example\n * program.commandsGroup('Development Commands:);\n * program.command('watch')...\n * program.command('lint')...\n * ...\n *\n * @param {string} [heading]\n * @returns {Command | string}\n */\n commandsGroup(heading) {\n if (heading === undefined) return this._defaultCommandGroup ?? '';\n this._defaultCommandGroup = heading;\n return this;\n }\n\n /**\n * Set/get the default help group heading for options added to this command.\n * (This does not override a group set directly on the option using .helpGroup().)\n *\n * @example\n * program\n * .optionsGroup('Development Options:')\n * .option('-d, --debug', 'output extra debugging')\n * .option('-p, --profile', 'output profiling information')\n *\n * @param {string} [heading]\n * @returns {Command | string}\n */\n optionsGroup(heading) {\n if (heading === undefined) return this._defaultOptionGroup ?? '';\n this._defaultOptionGroup = heading;\n return this;\n }\n\n /**\n * @param {Option} option\n * @private\n */\n _initOptionGroup(option) {\n if (this._defaultOptionGroup && !option.helpGroupHeading)\n option.helpGroup(this._defaultOptionGroup);\n }\n\n /**\n * @param {Command} cmd\n * @private\n */\n _initCommandGroup(cmd) {\n if (this._defaultCommandGroup && !cmd.helpGroup())\n cmd.helpGroup(this._defaultCommandGroup);\n }\n\n /**\n * Set the name of the command from script filename, such as process.argv[1],\n * or require.main.filename, or __filename.\n *\n * (Used internally and public although not documented in README.)\n *\n * @example\n * program.nameFromFilename(require.main.filename);\n *\n * @param {string} filename\n * @return {Command}\n */\n\n nameFromFilename(filename) {\n this._name = path.basename(filename, path.extname(filename));\n\n return this;\n }\n\n /**\n * Get or set the directory for searching for executable subcommands of this command.\n *\n * @example\n * program.executableDir(__dirname);\n * // or\n * program.executableDir('subcommands');\n *\n * @param {string} [path]\n * @return {(string|null|Command)}\n */\n\n executableDir(path) {\n if (path === undefined) return this._executableDir;\n this._executableDir = path;\n return this;\n }\n\n /**\n * Return program help documentation.\n *\n * @param {{ error: boolean }} [contextOptions] - pass {error:true} to wrap for stderr instead of stdout\n * @return {string}\n */\n\n helpInformation(contextOptions) {\n const helper = this.createHelp();\n const context = this._getOutputContext(contextOptions);\n helper.prepareContext({\n error: context.error,\n helpWidth: context.helpWidth,\n outputHasColors: context.hasColors,\n });\n const text = helper.formatHelp(this, helper);\n if (context.hasColors) return text;\n return this._outputConfiguration.stripColor(text);\n }\n\n /**\n * @typedef HelpContext\n * @type {object}\n * @property {boolean} error\n * @property {number} helpWidth\n * @property {boolean} hasColors\n * @property {function} write - includes stripColor if needed\n *\n * @returns {HelpContext}\n * @private\n */\n\n _getOutputContext(contextOptions) {\n contextOptions = contextOptions || {};\n const error = !!contextOptions.error;\n let baseWrite;\n let hasColors;\n let helpWidth;\n if (error) {\n baseWrite = (str) => this._outputConfiguration.writeErr(str);\n hasColors = this._outputConfiguration.getErrHasColors();\n helpWidth = this._outputConfiguration.getErrHelpWidth();\n } else {\n baseWrite = (str) => this._outputConfiguration.writeOut(str);\n hasColors = this._outputConfiguration.getOutHasColors();\n helpWidth = this._outputConfiguration.getOutHelpWidth();\n }\n const write = (str) => {\n if (!hasColors) str = this._outputConfiguration.stripColor(str);\n return baseWrite(str);\n };\n return { error, write, hasColors, helpWidth };\n }\n\n /**\n * Output help information for this command.\n *\n * Outputs built-in help, and custom text added using `.addHelpText()`.\n *\n * @param {{ error: boolean } | Function} [contextOptions] - pass {error:true} to write to stderr instead of stdout\n */\n\n outputHelp(contextOptions) {\n let deprecatedCallback;\n if (typeof contextOptions === 'function') {\n deprecatedCallback = contextOptions;\n contextOptions = undefined;\n }\n\n const outputContext = this._getOutputContext(contextOptions);\n /** @type {HelpTextEventContext} */\n const eventContext = {\n error: outputContext.error,\n write: outputContext.write,\n command: this,\n };\n\n this._getCommandAndAncestors()\n .reverse()\n .forEach((command) => command.emit('beforeAllHelp', eventContext));\n this.emit('beforeHelp', eventContext);\n\n let helpInformation = this.helpInformation({ error: outputContext.error });\n if (deprecatedCallback) {\n helpInformation = deprecatedCallback(helpInformation);\n if (\n typeof helpInformation !== 'string' &&\n !Buffer.isBuffer(helpInformation)\n ) {\n throw new Error('outputHelp callback must return a string or a Buffer');\n }\n }\n outputContext.write(helpInformation);\n\n if (this._getHelpOption()?.long) {\n this.emit(this._getHelpOption().long); // deprecated\n }\n this.emit('afterHelp', eventContext);\n this._getCommandAndAncestors().forEach((command) =>\n command.emit('afterAllHelp', eventContext),\n );\n }\n\n /**\n * You can pass in flags and a description to customise the built-in help option.\n * Pass in false to disable the built-in help option.\n *\n * @example\n * program.helpOption('-?, --help' 'show help'); // customise\n * program.helpOption(false); // disable\n *\n * @param {(string | boolean)} flags\n * @param {string} [description]\n * @return {Command} `this` command for chaining\n */\n\n helpOption(flags, description) {\n // Support enabling/disabling built-in help option.\n if (typeof flags === 'boolean') {\n if (flags) {\n if (this._helpOption === null) this._helpOption = undefined; // reenable\n if (this._defaultOptionGroup) {\n // make the option to store the group\n this._initOptionGroup(this._getHelpOption());\n }\n } else {\n this._helpOption = null; // disable\n }\n return this;\n }\n\n // Customise flags and description.\n this._helpOption = this.createOption(\n flags ?? '-h, --help',\n description ?? 'display help for command',\n );\n // init group unless lazy create\n if (flags || description) this._initOptionGroup(this._helpOption);\n\n return this;\n }\n\n /**\n * Lazy create help option.\n * Returns null if has been disabled with .helpOption(false).\n *\n * @returns {(Option | null)} the help option\n * @package\n */\n _getHelpOption() {\n // Lazy create help option on demand.\n if (this._helpOption === undefined) {\n this.helpOption(undefined, undefined);\n }\n return this._helpOption;\n }\n\n /**\n * Supply your own option to use for the built-in help option.\n * This is an alternative to using helpOption() to customise the flags and description etc.\n *\n * @param {Option} option\n * @return {Command} `this` command for chaining\n */\n addHelpOption(option) {\n this._helpOption = option;\n this._initOptionGroup(option);\n return this;\n }\n\n /**\n * Output help information and exit.\n *\n * Outputs built-in help, and custom text added using `.addHelpText()`.\n *\n * @param {{ error: boolean }} [contextOptions] - pass {error:true} to write to stderr instead of stdout\n */\n\n help(contextOptions) {\n this.outputHelp(contextOptions);\n let exitCode = Number(process.exitCode ?? 0); // process.exitCode does allow a string or an integer, but we prefer just a number\n if (\n exitCode === 0 &&\n contextOptions &&\n typeof contextOptions !== 'function' &&\n contextOptions.error\n ) {\n exitCode = 1;\n }\n // message: do not have all displayed text available so only passing placeholder.\n this._exit(exitCode, 'commander.help', '(outputHelp)');\n }\n\n /**\n * // Do a little typing to coordinate emit and listener for the help text events.\n * @typedef HelpTextEventContext\n * @type {object}\n * @property {boolean} error\n * @property {Command} command\n * @property {function} write\n */\n\n /**\n * Add additional text to be displayed with the built-in help.\n *\n * Position is 'before' or 'after' to affect just this command,\n * and 'beforeAll' or 'afterAll' to affect this command and all its subcommands.\n *\n * @param {string} position - before or after built-in help\n * @param {(string | Function)} text - string to add, or a function returning a string\n * @return {Command} `this` command for chaining\n */\n\n addHelpText(position, text) {\n const allowedValues = ['beforeAll', 'before', 'after', 'afterAll'];\n if (!allowedValues.includes(position)) {\n throw new Error(`Unexpected value for position to addHelpText.\nExpecting one of '${allowedValues.join(\"', '\")}'`);\n }\n\n const helpEvent = `${position}Help`;\n this.on(helpEvent, (/** @type {HelpTextEventContext} */ context) => {\n let helpStr;\n if (typeof text === 'function') {\n helpStr = text({ error: context.error, command: context.command });\n } else {\n helpStr = text;\n }\n // Ignore falsy value when nothing to output.\n if (helpStr) {\n context.write(`${helpStr}\\n`);\n }\n });\n return this;\n }\n\n /**\n * Output help information if help flags specified\n *\n * @param {Array} args - array of options to search for help flags\n * @private\n */\n\n _outputHelpIfRequested(args) {\n const helpOption = this._getHelpOption();\n const helpRequested = helpOption && args.find((arg) => helpOption.is(arg));\n if (helpRequested) {\n this.outputHelp();\n // (Do not have all displayed text available so only passing placeholder.)\n this._exit(0, 'commander.helpDisplayed', '(outputHelp)');\n }\n }\n}\n\n/**\n * Scan arguments and increment port number for inspect calls (to avoid conflicts when spawning new command).\n *\n * @param {string[]} args - array of arguments from node.execArgv\n * @returns {string[]}\n * @private\n */\n\nfunction incrementNodeInspectorPort(args) {\n // Testing for these options:\n // --inspect[=[host:]port]\n // --inspect-brk[=[host:]port]\n // --inspect-port=[host:]port\n return args.map((arg) => {\n if (!arg.startsWith('--inspect')) {\n return arg;\n }\n let debugOption;\n let debugHost = '127.0.0.1';\n let debugPort = '9229';\n let match;\n if ((match = arg.match(/^(--inspect(-brk)?)$/)) !== null) {\n // e.g. --inspect\n debugOption = match[1];\n } else if (\n (match = arg.match(/^(--inspect(-brk|-port)?)=([^:]+)$/)) !== null\n ) {\n debugOption = match[1];\n if (/^\\d+$/.test(match[3])) {\n // e.g. --inspect=1234\n debugPort = match[3];\n } else {\n // e.g. --inspect=localhost\n debugHost = match[3];\n }\n } else if (\n (match = arg.match(/^(--inspect(-brk|-port)?)=([^:]+):(\\d+)$/)) !== null\n ) {\n // e.g. --inspect=localhost:1234\n debugOption = match[1];\n debugHost = match[3];\n debugPort = match[4];\n }\n\n if (debugOption && debugPort !== '0') {\n return `${debugOption}=${debugHost}:${parseInt(debugPort) + 1}`;\n }\n return arg;\n });\n}\n\n/**\n * @returns {boolean | undefined}\n * @package\n */\nfunction useColor() {\n // Test for common conventions.\n // NB: the observed behaviour is in combination with how author adds color! For example:\n // - we do not test NODE_DISABLE_COLORS, but util:styletext does\n // - we do test NO_COLOR, but Chalk does not\n //\n // References:\n // https://no-color.org\n // https://bixense.com/clicolors/\n // https://github.com/nodejs/node/blob/0a00217a5f67ef4a22384cfc80eb6dd9a917fdc1/lib/internal/tty.js#L109\n // https://github.com/chalk/supports-color/blob/c214314a14bcb174b12b3014b2b0a8de375029ae/index.js#L33\n // (https://force-color.org recent web page from 2023, does not match major javascript implementations)\n\n if (\n process.env.NO_COLOR ||\n process.env.FORCE_COLOR === '0' ||\n process.env.FORCE_COLOR === 'false'\n )\n return false;\n if (process.env.FORCE_COLOR || process.env.CLICOLOR_FORCE !== undefined)\n return true;\n return undefined;\n}\n\nexports.Command = Command;\nexports.useColor = useColor; // exporting for tests\n", "const { Argument } = require('./lib/argument.js');\nconst { Command } = require('./lib/command.js');\nconst { CommanderError, InvalidArgumentError } = require('./lib/error.js');\nconst { Help } = require('./lib/help.js');\nconst { Option } = require('./lib/option.js');\n\nexports.program = new Command();\n\nexports.createCommand = (name) => new Command(name);\nexports.createOption = (flags, description) => new Option(flags, description);\nexports.createArgument = (name, description) => new Argument(name, description);\n\n/**\n * Expose classes\n */\n\nexports.Command = Command;\nexports.Option = Option;\nexports.Argument = Argument;\nexports.Help = Help;\n\nexports.CommanderError = CommanderError;\nexports.InvalidArgumentError = InvalidArgumentError;\nexports.InvalidOptionArgumentError = InvalidArgumentError; // Deprecated\n", "// CTCode/src/autocompletion/v2/CodeSnippets.ts\n// Default implementation of code snippets collection and related operations\n\nimport { ISnippetMeta, ICodeSnippets, IFileMeta } from \"./types\"\n\nexport class CodeSnippets implements ICodeSnippets {\n\tprivate _nextId = 0\n\tprivate _idMap: Map = new Map()\n\n\tprivate _byName: Map> = new Map()\n\tprivate _fileIndex: Map; byName: Map> }> = new Map()\n\n\t// \u57FA\u4E8E\u7ED3\u6784\u5316\u4FE1\u606F\u7684\u7D22\u5F15\n\tprivate _byDefinitionType: Map> = new Map() // \u6309\u5B9A\u4E49\u7C7B\u578B\u7D22\u5F15\n\tprivate _bySignature: Map> = new Map() // \u6309\u7B7E\u540D\u7D22\u5F15\n\n\tsnippets: ISnippetMeta[] = []\n\n\tfilesHash: Map = new Map()\n\n\tprivate _addToIndices(id: number, snippet: ISnippetMeta) {\n\t\t// byName\n\t\tif (!this._byName.has(snippet.name)) this._byName.set(snippet.name, new Set())\n\t\tthis._byName.get(snippet.name)!.add(id)\n\n\t\t// fileIndex\n\t\tif (!this._fileIndex.has(snippet.filePath)) {\n\t\t\tthis._fileIndex.set(snippet.filePath, {\n\t\t\t\tallIds: new Set(),\n\t\t\t\tbyName: new Map(),\n\t\t\t})\n\t\t}\n\t\tconst bucket = this._fileIndex.get(snippet.filePath)!\n\t\tbucket.allIds.add(id)\n\n\t\tif (!bucket.byName.has(snippet.name)) bucket.byName.set(snippet.name, new Set())\n\t\tbucket.byName.get(snippet.name)!.add(id)\n\n\t\t// \u7ED3\u6784\u5316\u4FE1\u606F\u7D22\u5F15\n\t\tthis._addToStructuredIndices(id, snippet)\n\t}\n\n\tprivate _removeFromIndices(id: number, snippet: ISnippetMeta) {\n\t\t// byName\n\t\tconst nameSet = this._byName.get(snippet.name)\n\t\tif (nameSet) {\n\t\t\tnameSet.delete(id)\n\t\t\tif (nameSet.size === 0) this._byName.delete(snippet.name)\n\t\t}\n\n\t\t// fileIndex\n\t\tconst bucket = this._fileIndex.get(snippet.filePath)\n\t\tif (bucket) {\n\t\t\tbucket.allIds.delete(id)\n\t\t\tconst nameSetInFile = bucket.byName.get(snippet.name)\n\t\t\tif (nameSetInFile) {\n\t\t\t\tnameSetInFile.delete(id)\n\t\t\t\tif (nameSetInFile.size === 0) bucket.byName.delete(snippet.name)\n\t\t\t}\n\t\t\tif (bucket.allIds.size === 0) this._fileIndex.delete(snippet.filePath)\n\t\t}\n\n\t\t// \u79FB\u9664\u7ED3\u6784\u5316\u4FE1\u606F\u7D22\u5F15\n\t\tthis._removeFromStructuredIndices(id, snippet)\n\t}\n\n\t/**\n\t * \u6DFB\u52A0\u7ED3\u6784\u5316\u4FE1\u606F\u7D22\u5F15\n\t */\n\tprivate _addToStructuredIndices(id: number, snippet: ISnippetMeta) {\n\t\t// \u6309\u5B9A\u4E49\u7C7B\u578B\u7D22\u5F15\n\t\tif (snippet.definition?.type) {\n\t\t\tif (!this._byDefinitionType.has(snippet.definition.type)) {\n\t\t\t\tthis._byDefinitionType.set(snippet.definition.type, new Set())\n\t\t\t}\n\t\t\tthis._byDefinitionType.get(snippet.definition.type)!.add(id)\n\t\t}\n\n\t\t// \u6309\u7B7E\u540D\u7D22\u5F15\n\t\tif (snippet.signature) {\n\t\t\tif (!this._bySignature.has(snippet.signature)) {\n\t\t\t\tthis._bySignature.set(snippet.signature, new Set())\n\t\t\t}\n\t\t\tthis._bySignature.get(snippet.signature)!.add(id)\n\t\t}\n\t}\n\n\t/**\n\t * \u79FB\u9664\u7ED3\u6784\u5316\u4FE1\u606F\u7D22\u5F15\n\t */\n\tprivate _removeFromStructuredIndices(id: number, snippet: ISnippetMeta) {\n\t\t// \u6309\u5B9A\u4E49\u7C7B\u578B\u7D22\u5F15\n\t\tif (snippet.definition?.type) {\n\t\t\tconst typeSet = this._byDefinitionType.get(snippet.definition.type)\n\t\t\tif (typeSet) {\n\t\t\t\ttypeSet.delete(id)\n\t\t\t\tif (typeSet.size === 0) this._byDefinitionType.delete(snippet.definition.type)\n\t\t\t}\n\t\t}\n\n\t\t// \u6309\u7B7E\u540D\u7D22\u5F15\n\t\tif (snippet.signature) {\n\t\t\tconst signatureSet = this._bySignature.get(snippet.signature)\n\t\t\tif (signatureSet) {\n\t\t\t\tsignatureSet.delete(id)\n\t\t\t\tif (signatureSet.size === 0) this._bySignature.delete(snippet.signature)\n\t\t\t}\n\t\t}\n\t}\n\n\t/**\n\t * \u6309\u540D\u79F0\u67E5\u627E\u5355\u4E2A\u7247\u6BB5\n\t */\n\tasync findByName(name: string): Promise {\n\t\tconst results = await this.find({ name })\n\t\treturn results.length > 0 ? results[0] : undefined\n\t}\n\n\t/**\n\t * \u6309\u6587\u4EF6\u67E5\u627E\u7247\u6BB5\n\t */\n\tasync findByFile(filePath: string): Promise {\n\t\treturn await this.find({ filePath })\n\t}\n\n\t/**\n\t * \u6309\u5B9A\u4E49\u7C7B\u578B\u67E5\u627E\u7247\u6BB5\n\t */\n\tasync findByDefinitionType(definitionType: string): Promise {\n\t\tconst ids = this._byDefinitionType.get(definitionType) ?? new Set()\n\t\treturn Array.from(ids).map((id) => this._idMap.get(id)!)\n\t}\n\n\t/**\n\t * \u6309\u7B7E\u540D\u67E5\u627E\u7247\u6BB5\n\t */\n\tasync findBySignature(signature: string): Promise {\n\t\tconst ids = this._bySignature.get(signature) ?? new Set()\n\t\treturn Array.from(ids).map((id) => this._idMap.get(id)!)\n\t}\n\n\t/**\n\t * \u67E5\u627E\u5177\u6709\u7279\u5B9A\u53C2\u6570\u7C7B\u578B\u7684\u51FD\u6570\n\t */\n\tasync findFunctionsWithParameterTypes(paramTypes: string[]): Promise {\n\t\tconst results: ISnippetMeta[] = []\n\n\t\tfor (const snippet of this.snippets) {\n\t\t\tif (snippet.parameters && snippet.parameters.length >= paramTypes.length) {\n\t\t\t\tlet match = true\n\t\t\t\tfor (let i = 0; i < paramTypes.length; i++) {\n\t\t\t\t\tif (snippet.parameters[i]?.type !== paramTypes[i]) {\n\t\t\t\t\t\tmatch = false\n\t\t\t\t\t\tbreak\n\t\t\t\t\t}\n\t\t\t\t}\n\t\t\t\tif (match) {\n\t\t\t\t\tresults.push(snippet)\n\t\t\t\t}\n\t\t\t}\n\t\t}\n\n\t\treturn results\n\t}\n\n\tasync merge(codeSnippets: ICodeSnippets): Promise {\n\t\tif (codeSnippets && codeSnippets.snippets) {\n\t\t\tawait this.insert(codeSnippets.snippets)\n\t\t}\n\t}\n\n\t/**\n\t * \u83B7\u53D6\u7EDF\u8BA1\u4FE1\u606F\n\t */\n\tgetStats(): {\n\t\ttotalSnippets: number\n\t\tfileCount: number\n\t\ttypeDistribution: Record\n\t\tdefinitionTypeDistribution: Record\n\t\tavgLinesPerSnippet: number\n\t} {\n\t\tconst typeDistribution: Record = {}\n\t\tconst definitionTypeDistribution: Record = {}\n\t\tlet totalLines = 0\n\n\t\tfor (const snippet of this.snippets) {\n\t\t\t// \u7EDF\u8BA1\u7C7B\u578B\u5206\u5E03\n\t\t\ttypeDistribution[snippet.type] = (typeDistribution[snippet.type] || 0) + 1\n\n\t\t\t// \u7EDF\u8BA1\u5B9A\u4E49\u7C7B\u578B\u5206\u5E03\n\t\t\tif (snippet.definition?.type) {\n\t\t\t\tdefinitionTypeDistribution[snippet.definition.type] =\n\t\t\t\t\t(definitionTypeDistribution[snippet.definition.type] || 0) + 1\n\t\t\t}\n\n\t\t\t// \u7EDF\u8BA1\u603B\u884C\u6570\n\t\t\ttotalLines += snippet.endLine - snippet.startLine + 1\n\t\t}\n\n\t\tconst files = new Set(this.snippets.map((s) => s.filePath))\n\n\t\treturn {\n\t\t\ttotalSnippets: this.snippets.length,\n\t\t\tfileCount: files.size,\n\t\t\ttypeDistribution,\n\t\t\tdefinitionTypeDistribution,\n\t\t\tavgLinesPerSnippet: this.snippets.length > 0 ? totalLines / this.snippets.length : 0,\n\t\t}\n\t}\n\n\t/**\n\t * Find snippets by partial information\n\t */\n\tasync find(query: Partial): Promise {\n\t\t// filePath + name\n\t\tif (query.filePath && query.name) {\n\t\t\tconst bucket = this._fileIndex.get(query.filePath)\n\t\t\tconst ids = bucket?.byName.get(query.name) ?? new Set()\n\t\t\tlet res = Array.from(ids).map((id) => this._idMap.get(id)!)\n\t\t\tif (query.type) res = res.filter((s) => s.type === query.type)\n\t\t\tif (query.field) {\n\t\t\t\tres = res.filter((s) => s.field === query.field)\n\t\t\t} else {\n\t\t\t\tres = res.filter((s) => s.field === undefined || s.field === null || s.field === \"\")\n\t\t\t}\n\t\t\treturn res\n\t\t}\n\n\t\t// name\n\t\tif (query.name) {\n\t\t\tconst ids = this._byName.get(query.name) ?? new Set()\n\t\t\treturn Array.from(ids).map((id) => this._idMap.get(id)!)\n\t\t}\n\n\t\t// filePath\n\t\tif (query.filePath) {\n\t\t\tconst bucket = this._fileIndex.get(query.filePath)\n\t\t\tconst ids = bucket?.allIds ?? new Set()\n\t\t\treturn Array.from(ids).map((id) => this._idMap.get(id)!)\n\t\t}\n\n\t\treturn Array.from(this._idMap.values())\n\t}\n\n\t/**\n\t * Delete all snippets from a specific file\n\t */\n\tasync deleteByFile(filePath: string): Promise {\n\t\tconst bucket = this._fileIndex.get(filePath)\n\t\tif (!bucket) return []\n\n\t\tconst deleted: ISnippetMeta[] = []\n\t\tfor (const id of Array.from(bucket.allIds)) {\n\t\t\tconst snippet = this._idMap.get(id)!\n\t\t\tthis._removeFromIndices(id, snippet)\n\t\t\tthis._idMap.delete(id)\n\t\t\tdeleted.push(snippet)\n\t\t}\n\n\t\tif (deleted.length) {\n\t\t\tthis.snippets = this.snippets.filter((s) => s.filePath !== filePath)\n\t\t}\n\t\treturn deleted\n\t}\n\n\t/**\n\t * Insert snippets in batch\n\t */\n\tasync insert(snippets: ISnippetMeta[]): Promise {\n\t\tfor (const snippet of snippets) {\n\t\t\tconst id = ++this._nextId\n\t\t\tthis._idMap.set(id, snippet)\n\t\t\tthis._addToIndices(id, snippet)\n\t\t\tthis.snippets.push(snippet)\n\n\t\t\t// \u66F4\u65B0\u6587\u4EF6hash\u6620\u5C04\n\t\t\tif (snippet.fileHash && snippet.filePath) {\n\t\t\t\tthis.filesHash.set(snippet.filePath, snippet.fileHash)\n\t\t\t}\n\t\t}\n\t\treturn snippets.length\n\t}\n\n\t/**\n\t * Update a single snippet\n\t */\n\tasync update(snippet: ISnippetMeta): Promise {\n\t\t// \u901A\u8FC7 filePath + name + type \u7CBE\u786E\u5B9A\u4F4D\n\t\tif (snippet.filePath && snippet.name && snippet.type) {\n\t\t\tconst bucket = this._fileIndex.get(snippet.filePath)\n\t\t\tif (!bucket) return false\n\n\t\t\tconst candidateIds = bucket.byName.get(snippet.name) ?? new Set()\n\t\t\tfor (const id of candidateIds) {\n\t\t\t\tconst old = this._idMap.get(id)!\n\t\t\t\tif (old.type === snippet.type) {\n\t\t\t\t\t// \u627E\u5230\u5339\u914D\u7684\u7247\u6BB5\uFF0C\u8FDB\u884C\u66F4\u65B0\n\t\t\t\t\tthis._removeFromIndices(id, old)\n\t\t\t\t\tthis._idMap.set(id, snippet)\n\t\t\t\t\tthis._addToIndices(id, snippet)\n\n\t\t\t\t\t// \u66F4\u65B0\u516C\u5F00\u6570\u7EC4\n\t\t\t\t\tconst idx = this.snippets.indexOf(old)\n\t\t\t\t\tif (idx > -1) this.snippets[idx] = snippet\n\t\t\t\t\treturn true\n\t\t\t\t}\n\t\t\t}\n\t\t}\n\n\t\t// \u5982\u679C type \u4E0D\u5339\u914D\u6216\u4FE1\u606F\u4E0D\u5B8C\u6574\uFF0C\u5C1D\u8BD5\u53EA\u901A\u8FC7 filePath + name \u67E5\u627E\n\t\tif (snippet.filePath && snippet.name) {\n\t\t\tconst bucket = this._fileIndex.get(snippet.filePath)\n\t\t\tif (!bucket) return false\n\n\t\t\tconst candidateIds = bucket.byName.get(snippet.name) ?? new Set()\n\t\t\tif (candidateIds.size > 0) {\n\t\t\t\t// \u53D6\u7B2C\u4E00\u4E2A\u5339\u914D\u7684\u7247\u6BB5\u8FDB\u884C\u66F4\u65B0\n\t\t\t\tconst id = Array.from(candidateIds)[0]\n\t\t\t\tconst old = this._idMap.get(id)!\n\n\t\t\t\tthis._removeFromIndices(id, old)\n\t\t\t\tthis._idMap.set(id, snippet)\n\t\t\t\tthis._addToIndices(id, snippet)\n\n\t\t\t\t// \u66F4\u65B0\u516C\u5F00\u6570\u7EC4\n\t\t\t\tconst idx = this.snippets.indexOf(old)\n\t\t\t\tif (idx > -1) this.snippets[idx] = snippet\n\t\t\t\treturn true\n\t\t\t}\n\t\t}\n\n\t\treturn false\n\t}\n\n\tasync updateByFile(file: IFileMeta, snippets: CodeSnippets): Promise {\n\t\tawait this.deleteByFile(file.filePath)\n\t\tawait this.merge(snippets)\n\n\t\t// \u66F4\u65B0\u6587\u4EF6hash\n\t\tconst fileHash = file.fileHash || (file as any).hash\n\t\tif (fileHash) {\n\t\t\tthis.filesHash.set(file.filePath, fileHash)\n\t\t}\n\n\t\treturn true\n\t}\n\n\t/**\n\t * Clear all snippets\n\t */\n\tclear(): void {\n\t\tthis._nextId = 0\n\t\tthis._idMap.clear()\n\t\tthis._byName.clear()\n\t\tthis._fileIndex.clear()\n\t\tthis._byDefinitionType.clear()\n\t\tthis._bySignature.clear()\n\n\t\tthis.snippets = []\n\t}\n\n\t/**\n\t * Filter snippets by condition\n\t */\n\tasync filter(predicate: (snippet: ISnippetMeta) => boolean): Promise {\n\t\tconst result = new CodeSnippets()\n\t\tfor (const snippet of this._idMap.values()) {\n\t\t\tif (predicate(snippet)) await result.insert([snippet])\n\t\t}\n\t\treturn result as ICodeSnippets\n\t}\n\n\t/**\n\t * Check if a code file's index is up to date\n\t * @param file The file to check\n\t * @returns true if the file needs to be updated (index is NOT latest), false if index is current\n\t */\n\tisCodeFileLatestIndex(file: IFileMeta): boolean {\n\t\tconst storedHash = this.filesHash.get(file.filePath)\n\t\tif (!storedHash) {\n\t\t\t// No stored hash means file is not indexed yet, needs update\n\t\t\treturn true\n\t\t}\n\n\t\t// Compare current file hash with stored hash\n\t\t// If hashes don't match, file needs update\n\t\tconst currentHash = file.fileHash || (file as any).hash\n\t\treturn currentHash !== storedHash\n\t}\n\n\tgetSnippets(): ISnippetMeta[] {\n\t\treturn this.snippets\n\t}\n}\n", "// CTCode/src/autocompletion/v2/types.ts\n// \u6240\u6709\u6838\u5FC3\u7C7B\u578B\u548C\u63A5\u53E3\u5B9A\u4E49\uFF0C\u4F9B\u591A\u4EBA\u534F\u4F5C\u5B9E\u73B0\n\nexport enum CodeLanguageType {\n\tPython = \"python\",\n\tJava = \"java\",\n\tJavaScript = \"javascript\",\n\tTypeScript = \"typescript\",\n\tJSX = \"jsx\",\n\tTSX = \"tsx\",\n\tGo = \"go\",\n\tSwift = \"swift\",\n\tCSS = \"css\",\n\tHTML = \"html\",\n\tKotlin = \"kotlin\",\n\tPHP = \"php\",\n\tRust = \"rust\",\n\tC = \"c\",\n\tCPP = \"cpp\",\n\tUnknown = \"unknown\",\n}\n\nexport const CodeLanguageTypeSupport = [\n\tCodeLanguageType.Python,\n\tCodeLanguageType.Java,\n\tCodeLanguageType.JavaScript,\n\tCodeLanguageType.TypeScript,\n\tCodeLanguageType.JSX,\n\tCodeLanguageType.TSX,\n\tCodeLanguageType.Go,\n\tCodeLanguageType.Swift,\n\tCodeLanguageType.CSS,\n\tCodeLanguageType.HTML,\n\tCodeLanguageType.Kotlin,\n\tCodeLanguageType.PHP,\n\tCodeLanguageType.Rust,\n\tCodeLanguageType.C,\n\tCodeLanguageType.CPP,\n]\n\nexport const FileExtensionLanguageMap = {\n\t\".py\": CodeLanguageType.Python,\n\t\".java\": CodeLanguageType.Java,\n\t\".js\": CodeLanguageType.JavaScript,\n\t\".mjs\": CodeLanguageType.JavaScript,\n\t\".ts\": CodeLanguageType.TypeScript,\n\t\".tsx\": CodeLanguageType.TSX,\n\t\".jsx\": CodeLanguageType.JSX,\n\t\".go\": CodeLanguageType.Go,\n\t\".swift\": CodeLanguageType.Swift,\n\t\".css\": CodeLanguageType.CSS,\n\t\".html\": CodeLanguageType.HTML,\n\t\".kt\": CodeLanguageType.Kotlin,\n\t\".kts\": CodeLanguageType.Kotlin,\n\t\".php\": CodeLanguageType.PHP,\n\t\".rs\": CodeLanguageType.Rust,\n\t\".c\": CodeLanguageType.C,\n\t\".h\": CodeLanguageType.C,\n\t\".cpp\": CodeLanguageType.CPP,\n\t\".cxx\": CodeLanguageType.CPP,\n\t\".cc\": CodeLanguageType.CPP,\n\t\".hpp\": CodeLanguageType.CPP,\n\t\".hxx\": CodeLanguageType.CPP,\n}\n\nexport const LanguageFileExtensionMap = Object.entries(FileExtensionLanguageMap).reduce(\n\t(acc, [extension, language]) => {\n\t\tif (!acc[language]) acc[language] = []\n\t\tacc[language].push(extension)\n\t\treturn acc\n\t},\n\t{} as Record,\n)\n\n// \u7247\u6BB5\u7C7B\u578B/\u6765\u6E90\u679A\u4E3E\nexport enum SnippetType {\n\tImportOrInclude = \"import_or_include\",\n\tFunctionOrMethod = \"function_or_method\",\n\tClassOrInterfaceOrStructOrEnum = \"class_or_interface_or_struct\",\n\tVariableOrConstant = \"variable_or_constant\",\n}\n\nexport type Point = {\n\trow: number\n\tcolumn: number\n}\n\n// \u4EE3\u7801\u7247\u6BB5\u5143\u4FE1\u606F\u7ED3\u6784\nexport interface ISnippetMeta {\n\tname: string // \u7B26\u53F7\u540D\u79F0\n\ttype: SnippetType // \u7247\u6BB5\u7C7B\u578B/\u6765\u6E90\n\tfilePath: string // \u6240\u5728\u6587\u4EF6\u8DEF\u5F84\n\tstartLine: number // \u8D77\u59CB\u884C\u53F7\n\tendLine: number // \u7ED3\u675F\u884C\u53F7\n\tstartPosition?: Point // \u8D77\u59CB\u4F4D\u7F6E\n\tendPosition?: Point // \u7ED3\u675F\u4F4D\u7F6E\n\trangeText: string // \u7247\u6BB5\u539F\u59CB\u6355\u83B7\u4EE3\u7801\u5185\u5BB9\n\tfileHash: string // \u6240\u5C5E\u6587\u4EF6\u5185\u5BB9 hash\n\tstartColumn?: number // \u6DFB\u52A0\u8D77\u59CB\u5217\n\tendColumn?: number // \u6DFB\u52A0\u7ED3\u675F\u5217\n\n\tlanguage?: CodeLanguageType // \u8BED\u8A00\u7C7B\u578B\n\tfield?: string // \u6240\u5904\u7684class/struct\u540D\u79F0\n\tnamespace?: string // \u6240\u5904\u7684namespace\u540D\u79F0\n\n\t// \u7ED3\u6784\u5316\u4FE1\u606F\n\tdefinition?: {\n\t\tname: string // \u5B9A\u4E49\u540D\u79F0\uFF08\u51FD\u6570\u540D\u3001\u7C7B\u540D\u3001\u53D8\u91CF\u540D\u7B49\uFF09\n\t\ttype: string // \u5B9A\u4E49\u7C7B\u578B\uFF08function, class, interface, variable, method\u7B49\uFF09\n\t\tparameters?: ParameterInfo[] // \u53C2\u6570\u4FE1\u606F\uFF08\u4EC5\u5BF9\u51FD\u6570/\u65B9\u6CD5\u6709\u6548\uFF09\n\t\treturnType?: string // \u8FD4\u56DE\u7C7B\u578B\uFF08\u4EC5\u5BF9\u51FD\u6570/\u65B9\u6CD5\u6709\u6548\uFF09\n\t\tvisibility?: string // \u53EF\u89C1\u6027\uFF08public, private, protected\u7B49\uFF09\n\t\tisStatic?: boolean // \u662F\u5426\u4E3A\u9759\u6001\u6210\u5458\n\t\tisAsync?: boolean // \u662F\u5426\u4E3A\u5F02\u6B65\u51FD\u6570\n\t}\n\n\t// \u53C2\u6570\u4FE1\u606F\u7ED3\u6784\n\tparameters?: ParameterInfo[]\n\n\t// \u7B7E\u540D\u4FE1\u606F\uFF08\u7528\u4E8E\u5FEB\u901F\u5339\u914D\u548Cprompt\u751F\u6210\uFF09\n\tsignature?: string // \u51FD\u6570/\u65B9\u6CD5\u7B7E\u540D\uFF0C\u5982 \"add(a: number, b: number): number\"\n\tdefinitionText?: string // \u5B9A\u4E49\u6587\u672C\uFF0C\u7528\u4E8E\u63D0\u4F9B\u5B9A\u4E49\u53C2\u8003\n\timplementText?: string // \u5B9E\u73B0\u6587\u672C\uFF0C\u7528\u4E8E\u63D0\u4F9B\u5B9E\u73B0\u53C2\u8003\n\n\t// \u53EF\u9009: score, source, extraMeta \u7B49\n\tscope?: string[] // \u4F5C\u7528\u57DF\u94FE\n\tid?: string // \u552F\u4E00\u6807\u8BC6\n\tdependencies?: string[]\n}\n\n// \u53C2\u6570\u4FE1\u606F\u63A5\u53E3\nexport interface ParameterInfo {\n\tname: string // \u53C2\u6570\u540D\u79F0\n\ttype?: string // \u53C2\u6570\u7C7B\u578B\n\tdefaultValue?: string // \u9ED8\u8BA4\u503C\n\tisOptional?: boolean // \u662F\u5426\u4E3A\u53EF\u9009\u53C2\u6570\n\tisRest?: boolean // \u662F\u5426\u4E3A\u5269\u4F59\u53C2\u6570\uFF08...args\uFF09\n\tdescription?: string // \u53C2\u6570\u63CF\u8FF0\n}\n\n// \u5355\u4E2A\u6E90\u6587\u4EF6\u7684\u5143\u4FE1\u606F\u7ED3\u6784\nexport interface IFileMeta {\n\tfilePath: string\n\tfileExtension?: string\n\tlanguage?: CodeLanguageType // \u8BED\u8A00\u7C7B\u578B\uFF08\u53EF\u9009\uFF09\n\tsnippetMetas?: ISnippetMeta[] // \u4EE3\u7801\u7247\u6BB5\uFF08\u53EF\u9009\uFF09\n\tprojectRoot?: string // \u9879\u76EE\u6839\u76EE\u5F55\uFF08\u53EF\u9009\uFF09\n\tfileHash?: string // \u6587\u4EF6\u54C8\u5E0C\uFF08\u53EF\u9009\uFF09\n\tcontent?: string // \u6587\u4EF6\u5185\u5BB9\uFF08\u53EF\u9009\uFF09\n\tread?(): Promise // \u5F02\u6B65\u8BFB\u53D6\u6587\u4EF6\u5185\u5BB9\uFF08\u53EF\u9009\uFF09\n}\n\n// \u591A\u6587\u4EF6\u5143\u4FE1\u606F\u96C6\u5408\nexport interface ICodeFiles {\n\tfiles: IFileMeta[]\n}\n\n// \u4EE3\u7801\u7247\u6BB5\u96C6\u5408\u53CA\u76F8\u5173\u64CD\u4F5C\u63A5\u53E3\nexport interface ICodeSnippets {\n\tsnippets: ISnippetMeta[]\n\tmerge(globalContext: ICodeSnippets): Promise\n\tfind(query: Partial): Promise\n\tdeleteByFile(filePath: string): Promise\n\tupdateByFile(file: IFileMeta, snippets: ICodeSnippets): Promise\n\tinsert(snippets: ISnippetMeta[]): Promise\n\tupdate(snippet: ISnippetMeta): Promise\n\tmerge(codeSnippets: ICodeSnippets): Promise\n\tclear(): void\n\tfilter(predicate: (snippet: ISnippetMeta) => boolean): Promise\n\tisCodeFileLatestIndex(file: IFileMeta): boolean\n}\n\n// \u7C7B\u578B\u5B9A\u4E49\nexport interface ChunkOptions {\n\tfile: IFileMeta\n\tsnippetTypes?: SnippetType[]\n\tmaxSnippetLines?: number\n\tminSnippetLines?: number\n}\n\n// \u4EE3\u7801\u4E0A\u4E0B\u6587\u7BA1\u7406\u4E3B\u63A5\u53E3\nexport interface ICodeContext {\n\tchunk(codeText: string, options: ChunkOptions): Promise\n\tindex(codeFiles: ICodeFiles, options: any): Promise\n\tretriveRelates(\n\t\tcodeText: string,\n\t\tline: number,\n\t\tcolumn: number,\n\t\tfile: IFileMeta,\n\t\tglobalContext?: ICodeSnippets,\n\t): Promise\n}\n\n// \u7ED3\u6784\u5316\u8865\u5168\u8BF7\u6C42\u4F53\nexport interface ICompletionContext {\n\tsnippets: ISnippetMeta[]\n\toverview?: string // \u6587\u4EF6\u6982\u89C8\n\tprefix: string\n\tsuffix: string\n\tfilePath?: string\n\tfileHash?: string\n\tgitUrl?: string\n\t// \u5176\u4ED6\u5168\u5C40\u4FE1\u606F\n}\n\n// \u5171\u4EAB\u7684\u6587\u6863\u548C\u4F4D\u7F6E\u4FE1\u606F\u63A5\u53E3\nexport interface DocumentInfo {\n\tfile: IFileMeta\n\tcontent: string\n\tlineCount: number\n\tlanguage: string\n\tgetLineText(line: number): string\n}\n\nexport interface PositionInfo {\n\tline: number\n\tcharacter: number\n}\n\nexport enum ModelType {\n\tDeepSeek = \"deepseek\",\n\tQwen = \"qwen\",\n}\n\nexport enum IContextSectionType {\n\tRepoTreeView = \"RepoTreeView\",\n\tFileInfo = \"FileInfo\",\n\tFileCodeOverview = \"FileCodeOverview\",\n\tRelatedFunctionDefinition = \"RelatedFunctionDefinition\",\n\tRelatedFuntionImplement = \"RelatedFuntionImplement\",\n\tEndContextPrompt = \"EndContextPrompt\",\n}\n\nexport interface IContextSection {\n\ttype: IContextSectionType\n\tcontent: string\n}\n\nexport interface CompletionResponse {\n\tcompletion: string\n\tid: string\n}\n\nexport interface ICodeModel {\n\tmodelType: ModelType\n\tmodelId: string\n\tbaseUrl: string\n\tapiKey: string\n\tcommonStops?: string[]\n\tgenerateCompletion(prompt: string, languageType: CodeLanguageType | undefined): Promise\n\tbuildCompletionPrompt(prefix: string, suffix: string, extraContexts: IContextSection[], file: IFileMeta): string\n}\n\nexport interface IPreprocessOptions {\n\tmaxContextLength: number\n\tcodeFile: IFileMeta\n\teditCursor: PositionInfo\n\trecentOpenFiles: IFileMeta[]\n}\n\nexport interface IPreprocessResult {\n\tprefix: string\n\tsuffix: string\n\textraContexts: IContextSection[]\n\tshouldSkipCompletion?: boolean\n}\n\nexport interface PostProcessOptions {\n\tprompt: string\n\tprefix: string\n\tsuffix: string\n\tmodelType: ModelType\n}\n\nexport interface ICodeContextOptions {\n\tnumLinesAsContext: number\n\tnumLinesAsContextSuffix: number\n\tnumImplementContexts: number\n}\n\nexport enum LogLevel {\n\tDebug = \"DEBUG\",\n\tInfo = \"INFO\",\n\tWarn = \"WARN\",\n\tError = \"ERROR\",\n}\n\nexport interface ILogger {\n\tprefix: string\n\tlevel: LogLevel\n\twith(prefix: string): ILogger\n\tdebug(message?: any, ...optionalParams: any[]): void\n\tinfo(message?: any, ...optionalParams: any[]): void\n\twarn(message?: any, ...optionalParams: any[]): void\n\terror(message?: any, ...optionalParams: any[]): void\n}\n", "// CTCode/src/autocompletion/v2/CodeContext.ts\n// \u4EE3\u7801\u4E0A\u4E0B\u6587\u7BA1\u7406\u4E3B\u7C7B\u7684\u9ED8\u8BA4\u5B9E\u73B0\n// \u4E13\u6CE8\u4E8E\u4EE3\u7801\u7247\u6BB5\u7684\u63D0\u53D6\u3001\u7D22\u5F15\u3001\u641C\u7D22\u548C\u9884\u5904\u7406\uFF0C\u4E0D\u6D89\u53CA LLM \u8C03\u7528\n\nimport * as path from \"path\"\nimport * as crypto from \"crypto\"\nimport Parser from \"web-tree-sitter\"\nimport { loadRequiredLanguageParsers } from \"../../../../src/services/CT-tree-sitter/languageParser\"\nimport { CodeSnippets } from \"./CodeSnippets\"\nimport {\n\tISnippetMeta,\n\tSnippetType,\n\tICodeSnippets,\n\tICodeFiles,\n\tICodeContext,\n\tDocumentInfo,\n\tPositionInfo,\n\tPostProcessOptions,\n\tModelType,\n\tChunkOptions,\n\tICodeContextOptions,\n\tCodeLanguageType,\n\tCodeLanguageTypeSupport,\n\tIFileMeta,\n\tICompletionContext,\n\tILogger,\n\tIPreprocessOptions,\n\tIPreprocessResult,\n\tPoint,\n\tIContextSection,\n\tIContextSectionType,\n} from \"./types\"\nimport { postProcessCompletionSynthesis, findFirstMatchingCloseSymbol } from \"./utils/processUtils\"\nimport * as capturesProcess from \"./capturesProcess\"\nimport { isInsideWord } from \"./utils/processUtils\"\nimport * as dependenciesProcess from \"./dependenciesProcess\"\nimport { formatCodeWithLanguageWithLineComment } from \"./utils/languageCommentUtils\"\nimport { treeView } from \"./utils/treeUtils\"\nimport { Logger } from \"./Logger\"\n\nexport class CodeContext implements ICodeContext {\n\tprivate _options: ICodeContextOptions\n\tprivate logger: ILogger\n\n\tget options(): ICodeContextOptions {\n\t\treturn this._options\n\t}\n\n\tconstructor(options?: ICodeContextOptions, logger?: ILogger) {\n\t\tthis._options = {\n\t\t\tnumLinesAsContext: 128,\n\t\t\tnumLinesAsContextSuffix: 32,\n\t\t\tnumImplementContexts: 3,\n\t\t}\n\t\tthis.logger = logger?.with(\"[CodeContext]\") || Logger.getDefaultLogger().with(\"[CodeContext]\")\n\t\ttry {\n\t\t\tif (options && typeof options === \"object\") {\n\t\t\t\tfor (const key in options) {\n\t\t\t\t\tif (options[key as keyof ICodeContextOptions] === undefined) {\n\t\t\t\t\t\tthrow new Error(`Option ${key} is not defined`)\n\t\t\t\t\t}\n\t\t\t\t\tthis._options[key as keyof ICodeContextOptions] = options[key as keyof ICodeContextOptions]\n\t\t\t\t}\n\t\t\t}\n\t\t} catch (error) {\n\t\t\tthis.logger.error(`Error checking options: ${error}, using default options`)\n\t\t}\n\t}\n\n\tasync capture(codeText: string, file: IFileMeta): Promise {\n\t\t// \u52A0\u8F7D\u8BED\u8A00\u89E3\u6790\u5668\n\t\tconst languageParsers = await loadRequiredLanguageParsers([file.filePath])\n\t\tconst languageParser = languageParsers[file.fileExtension as keyof typeof languageParsers]\n\t\t\n\t\tif (!languageParser) {\n\t\t\tthis.logger.warn(`No languageParser available for extension: ${file.fileExtension}`)\n\t\t\treturn null\n\t\t}\n\n\t\t// 1. \u89E3\u6790 AST \u6811\n\t\tconst parser = languageParser.parser\n\t\tconst query = languageParser.query\n\n\t\tif (!parser || !query) {\n\t\t\tthis.logger.warn(`No parser or query available for extension: ${file.fileExtension}`)\n\t\t\treturn null\n\t\t}\n\n\t\tconst tree = parser.parse(codeText)\n\n\t\tthis.logger.info(`Successfully parsed AST for: ${path.basename(file.filePath)}`)\n\n\t\tconst captures = query.captures(tree.rootNode)\n\n\t\treturn captures\n\t}\n\n\tasync captureDependencies(codeText: string, file: IFileMeta): Promise {\n\t\tconst queryText = dependenciesProcess.dependenciesCapturesQueries[file.language as CodeLanguageType]\n\t\tif (!queryText) {\n\t\t\tthis.logger.warn(`No query available for extension: ${file.fileExtension}`)\n\t\t\treturn null\n\t\t}\n\n\t\t// \u52A0\u8F7D\u8BED\u8A00\u89E3\u6790\u5668\n\t\tconst languageParsers = await loadRequiredLanguageParsers([file.filePath])\n\t\tconst languageParser = languageParsers[file.fileExtension as keyof typeof languageParsers]\n\n\t\tif (!languageParser) {\n\t\t\tthis.logger.warn(`No languageParser available for extension: ${file.fileExtension}`)\n\t\t\treturn null\n\t\t}\n\n\t\t// 1. \u89E3\u6790 AST \u6811\n\t\tconst parser = languageParser.parser\n\t\tconst query = parser.getLanguage().query(queryText)\n\n\t\tif (!parser || !query) {\n\t\t\tthis.logger.warn(`No parser or query available for extension: ${file.fileExtension}`)\n\t\t\treturn null\n\t\t}\n\n\t\tconst tree = parser.parse(codeText)\n\n\t\tthis.logger.info(`Successfully parsed AST for: ${path.basename(file.filePath)}`)\n\n\t\tconst captures = query.captures(tree.rootNode)\n\n\t\treturn captures\n\t}\n\n\t/**\n\t * \u5207\u5206\u4EE3\u7801\u4E3A CodeSnippets\n\t * \u4F7F\u7528 tree-sitter \u8FDB\u884C\u8BED\u4E49\u5207\u5206\uFF0C\u63D0\u53D6\u5B8C\u6574\u7684\u51FD\u6570\u3001\u7C7B\u3001\u65B9\u6CD5\u7B49\u5B9A\u4E49\n\t */\n\tasync chunk(codeText: string, options: ChunkOptions): Promise {\n\t\tconst { file, snippetTypes = [], maxSnippetLines = 50, minSnippetLines = 3 } = options\n\n\t\tconst codeSnippets = new CodeSnippets()\n\n\t\ttry {\n\t\t\t// \u8BA1\u7B97\u6587\u4EF6\u5185\u5BB9\u7684 hash\n\t\t\tconst fileHash = this.calculateFileHash(codeText)\n\n\t\t\t// \u68C0\u67E5\u8BED\u8A00\u662F\u5426\u652F\u6301 tree-sitter\n\t\t\tif (!this.isSupportedLanguage(file.language as CodeLanguageType)) {\n\t\t\t\tif (file.language === CodeLanguageType.Unknown) {\n\t\t\t\t\tthis.logger.info(`Language ${file.language} not supported now`)\n\t\t\t\t} else {\n\t\t\t\t\tthis.logger.warn(`Language ${file.language} not supported now`)\n\t\t\t\t}\n\t\t\t\treturn codeSnippets\n\t\t\t}\n\n\t\t\tconst captures = await this.capture(codeText, file)\n\n\t\t\tif (!captures || captures.length === 0) {\n\t\t\t\tthis.logger.warn(`No captures found`)\n\t\t\t\treturn codeSnippets\n\t\t\t}\n\n\t\t\t// 2. \u4F7F\u7528 Query \u63D0\u53D6\u4EE3\u7801\u7247\u6BB5\n\t\t\tconst extractSnippetsFromCapturesFunc =\n\t\t\t\tcapturesProcess.extractSnippetsFromCaptures[file.language as CodeLanguageType]\n\n\t\t\ttry {\n\t\t\t\tif (!extractSnippetsFromCapturesFunc) {\n\t\t\t\t\tthis.logger.info(`No extractSnippetsFromCapturesFunc available for language: ${file.language}`)\n\t\t\t\t\treturn codeSnippets\n\t\t\t\t}\n\n\t\t\t\tconst snippets = await extractSnippetsFromCapturesFunc(\n\t\t\t\t\tcaptures,\n\t\t\t\t\tcodeText,\n\t\t\t\t\tfile.filePath,\n\t\t\t\t\tfileHash,\n\t\t\t\t\tsnippetTypes,\n\t\t\t\t\t{\n\t\t\t\t\t\tmaxSnippetLines,\n\t\t\t\t\t\tminSnippetLines,\n\t\t\t\t\t},\n\t\t\t\t)\n\n\t\t\t\tthis.logger.info(`Extracted ${snippets.length} snippets total`)\n\n\t\t\t\tif (snippets && snippets.length > 0) {\n\t\t\t\t\tawait codeSnippets.insert(snippets)\n\t\t\t\t}\n\t\t\t} catch (error) {\n\t\t\t\tthis.logger.warn(`Error extracting snippets for ${file.filePath}:`, error)\n\t\t\t}\n\n\t\t\treturn codeSnippets\n\t\t} catch (error) {\n\t\t\tthis.logger.error(`Error parsing AST for ${file.filePath}:`, error)\n\t\t\treturn codeSnippets\n\t\t}\n\t}\n\n\tasync extractDependencies(codeText: string, file: IFileMeta): Promise {\n\t\tconst captures = await this.captureDependencies(codeText, file)\n\t\tif (!captures || captures.length === 0) {\n\t\t\tthis.logger.warn(`No captures found`)\n\t\t\treturn []\n\t\t}\n\n\t\tconst processor = dependenciesProcess.dependenciesProcessors[file.language as CodeLanguageType]\n\t\tif (!processor) {\n\t\t\tthis.logger.warn(`No processor available for language: ${file.language}`)\n\t\t\treturn []\n\t\t}\n\n\t\ttry {\n\t\t\tconst dependencies = processor(captures)\n\t\t\tif (!dependencies || dependencies.length === 0) {\n\t\t\t\tthis.logger.warn(`No dependencies found`)\n\t\t\t\treturn []\n\t\t\t}\n\t\t\treturn dependencies\n\t\t} catch (error) {\n\t\t\tthis.logger.warn(`Error extracting dependencies for ${file.filePath}:`, error)\n\t\t\treturn []\n\t\t}\n\t}\n\n\t/**\n\t * \u7D22\u5F15\u6587\u4EF6\u96C6\u5408\uFF0C\u63D0\u53D6\u6240\u6709\u6587\u4EF6\u7684\u4EE3\u7801\u7247\u6BB5\n\t */\n\tasync index(codeFiles: ICodeFiles, options: any): Promise {\n\t\tconst { maxSnippetLines = 50, minSnippetLines = 3, snippetTypes = [], includeFileTypes = [] } = options || {}\n\n\t\tconst allSnippets = new CodeSnippets()\n\n\t\tthis.logger.info(`Indexing ${codeFiles.files?.length || 0} files`)\n\n\t\t// \u5E76\u884C\u5904\u7406\u6587\u4EF6\u4EE5\u63D0\u9AD8\u6027\u80FD\n\t\tconst indexPromises = (codeFiles.files || []).map(async (fileMeta) => {\n\t\t\ttry {\n\t\t\t\tconst fileExtension = path.extname(fileMeta.filePath).toLowerCase().slice(1)\n\n\t\t\t\t// \u68C0\u67E5\u6587\u4EF6\u7C7B\u578B\u662F\u5426\u9700\u8981\u7D22\u5F15\n\t\t\t\tif (!includeFileTypes.includes(fileExtension)) {\n\t\t\t\t\treturn new CodeSnippets()\n\t\t\t\t}\n\n\t\t\t\t// \u8BFB\u53D6\u6587\u4EF6\u5185\u5BB9\n\t\t\t\tconst content = await fileMeta.read?.()\n\t\t\t\tif (!content) {\n\t\t\t\t\tthis.logger.warn(`Could not read content for file: ${fileMeta.filePath}`)\n\t\t\t\t\treturn new CodeSnippets()\n\t\t\t\t}\n\n\t\t\t\t// \u5BF9\u6BCF\u4E2A\u6587\u4EF6\u8FDB\u884C chunk\n\t\t\t\tconst fileSnippets = await this.chunk(content, {\n\t\t\t\t\tfile: fileMeta,\n\t\t\t\t\tsnippetTypes,\n\t\t\t\t\tmaxSnippetLines,\n\t\t\t\t\tminSnippetLines,\n\t\t\t\t})\n\n\t\t\t\tthis.logger.info(\n\t\t\t\t\t`Indexed ${fileSnippets.snippets.length} snippets from ${path.basename(fileMeta.filePath)}`,\n\t\t\t\t)\n\t\t\t\treturn fileSnippets\n\t\t\t} catch (error) {\n\t\t\t\tthis.logger.error(`Error indexing file ${fileMeta.filePath}:`, error)\n\t\t\t\treturn new CodeSnippets()\n\t\t\t}\n\t\t})\n\n\t\t// \u7B49\u5F85\u6240\u6709\u6587\u4EF6\u5904\u7406\u5B8C\u6210\n\t\tconst fileSnippetsArray = await Promise.all(indexPromises)\n\n\t\t// \u5408\u5E76\u6240\u6709\u7247\u6BB5\n\t\tfor (const fileSnippets of fileSnippetsArray) {\n\t\t\tawait allSnippets.merge(fileSnippets)\n\t\t}\n\n\t\tthis.logger.info(`Total indexed snippets: ${allSnippets.snippets.length}`)\n\t\treturn allSnippets\n\t}\n\n\tasync getFunctionOrMethodSurroundingCursor(\n\t\tcodeSnippets: ICodeSnippets,\n\t\tcursorPosition: Point,\n\t\tfile: IFileMeta,\n\t): Promise {\n\t\t// find the function or method that contains the cursor position using startLine and endLine\n\t\tconst snippets = await codeSnippets.filter((snippet) => {\n\t\t\treturn cursorPosition.row >= snippet.startLine && cursorPosition.row <= snippet.endLine\n\t\t})\n\n\t\tif (!snippets || snippets.snippets.length === 0) {\n\t\t\tthis.logger.warn(`No snippets found for file: ${file.filePath}`)\n\t\t\treturn null\n\t\t}\n\n\t\treturn snippets.snippets[0]\n\t}\n\n\t/**\n\t * \u68C0\u7D22\u4E0E\u5F53\u524D\u4F4D\u7F6E\u76F8\u5173\u7684\u4EE3\u7801\u7247\u6BB5 - \u667A\u80FD\u4E0A\u4E0B\u6587\u7B56\u7565\n\t */\n\t/**\n\t * \u68C0\u7D22\u4E0E\u5F53\u524D\u4F4D\u7F6E\u76F8\u5173\u7684\u4EE3\u7801\u7247\u6BB5 - \u4F7F\u7528 capture \u673A\u5236\uFF0C\u76F4\u63A5\u8FD4\u56DE\u6587\u4EF6\u539F\u6587\n\t */\n\tasync retriveRelates(\n\t\tcodeText: string,\n\t\tline: number,\n\t\tcolumn: number,\n\t\tfile: IFileMeta,\n\t\tglobalContext?: ICodeSnippets,\n\t): Promise {\n\t\tconst relatedSnippets = new CodeSnippets()\n\n\t\tif (!globalContext) {\n\t\t\tthis.logger.warn(`No global context provided`)\n\t\t\treturn relatedSnippets\n\t\t}\n\n\t\tthis.logger.info(`Retrieving related snippets for line ${line}, column ${column}`)\n\n\t\tconst functionOrMethod = await this.getFunctionOrMethodSurroundingCursor(\n\t\t\tglobalContext,\n\t\t\t{ row: line, column },\n\t\t\tfile,\n\t\t)\n\t\tif (!functionOrMethod) {\n\t\t\tthis.logger.warn(`No function or method found for line ${line}, column ${column}`)\n\t\t\treturn relatedSnippets\n\t\t}\n\n\t\tif (!functionOrMethod.implementText) {\n\t\t\tthis.logger.warn(`No implementText available for function or method: ${functionOrMethod.name}`)\n\t\t\treturn relatedSnippets\n\t\t}\n\n\t\t// search for dependencies of the function or method\n\t\tconst dependencies = await this.extractDependencies(functionOrMethod.implementText, file)\n\t\tif (!dependencies || dependencies.length === 0) {\n\t\t\tthis.logger.warn(`No dependencies found`)\n\t\t\treturn relatedSnippets\n\t\t}\n\n\t\t// find from globalContext\n\t\tlet relatedSnippetsWithDependencies: ISnippetMeta[] = []\n\n\t\t// sort dependencies by position, if surrounding cursor is in the dependency, it should be the first\n\t\tdependencies.sort((a, b) => {\n\t\t\treturn (\n\t\t\t\tMath.abs(functionOrMethod.startLine + a.startLine - line) -\n\t\t\t\tMath.abs(functionOrMethod.startLine + b.startLine - line)\n\t\t\t)\n\t\t})\n\n\t\tfor (const dependency of dependencies) {\n\t\t\tif (relatedSnippetsWithDependencies.length >= this.options.numImplementContexts) {\n\t\t\t\tbreak\n\t\t\t}\n\t\t\trelatedSnippetsWithDependencies = relatedSnippetsWithDependencies.concat(\n\t\t\t\tawait globalContext.find({\n\t\t\t\t\tfilePath: file.filePath,\n\t\t\t\t\tname: dependency.name,\n\t\t\t\t\ttype: dependency.type,\n\t\t\t\t\tfield: dependency.field,\n\t\t\t\t}),\n\t\t\t)\n\t\t}\n\n\t\t// merge dependencies to relatedSnippets\n\t\tawait relatedSnippets.insert(relatedSnippetsWithDependencies)\n\n\t\treturn relatedSnippets\n\t}\n\n\t/**\n\t * \u540E\u5904\u7406 LLM \u751F\u6210\u7684\u8865\u5168\u6587\u672C\n\t * \u4F7F\u7528 getStringBeforeCloseSymbol \u5904\u7406\u7B26\u53F7\u95ED\u5408\n\t */\n\tpostprocess(completion: string, options?: PostProcessOptions): string {\n\t\tif (!completion || completion.trim() === \"\") {\n\t\t\treturn \"\"\n\t\t}\n\n\t\tthis.logger.info(`Postprocessing completion: \"${completion.substring(0, 100)}...\"`)\n\n\t\tlet processedCompletion = completion\n\n\t\t// \u57FA\u672C\u6E05\u7406\uFF1A\u79FB\u9664\u672B\u5C3E\u591A\u4F59\u7684\u7A7A\u767D\u5B57\u7B26\n\t\tprocessedCompletion = processedCompletion.trimEnd()\n\n\t\tif (options && options.modelType === ModelType.Qwen) {\n\t\t\tlet { closeSymbol, suffixPrefix } = findFirstMatchingCloseSymbol(options.prompt, \"<|fim_suffix|>\")\n\t\t\tprocessedCompletion = postProcessCompletionSynthesis(\n\t\t\t\tprocessedCompletion,\n\t\t\t\toptions.prefix,\n\t\t\t\toptions.suffix,\n\t\t\t\tcloseSymbol,\n\t\t\t\tsuffixPrefix,\n\t\t\t)\n\t\t}\n\n\t\tthis.logger.info(`Postprocessed result: \"${processedCompletion.substring(0, 100)}...\"`)\n\n\t\treturn processedCompletion\n\t}\n\n\t/**\n\t * \u83B7\u53D6\u4EE3\u7801\u8865\u5168\u6240\u9700\u7684\u5B8C\u6574\u4E0A\u4E0B\u6587\n\t */\n\tasync getCompletionContext(\n\t\tdocumentInfo: DocumentInfo,\n\t\tpositionInfo: PositionInfo,\n\t\tglobalContext?: ICodeSnippets,\n\t): Promise {\n\t\tthis.logger.info(\n\t\t\t`Getting completion context for line ${positionInfo.line}, character ${positionInfo.character}`,\n\t\t)\n\n\t\t// 1. \u6784\u5EFA\u524D\u7F00\u548C\u540E\u7F00\n\t\tconst { prefix, suffix } = await this.getCurrentContext(documentInfo, positionInfo)\n\n\t\tthis.logger.info(`Prefix: \"${prefix.substring(prefix.length - 50)}...\"`)\n\t\tthis.logger.info(`Suffix: \"${suffix.substring(0, 50)}...\"`)\n\n\t\t// 2. \u83B7\u53D6\u6587\u4EF6\u6982\u89C8\n\t\tconst generateOverViewFromSnippetsFunc =\n\t\t\tcapturesProcess.generateOverViewFromSnippets[documentInfo.file.language as CodeLanguageType]\n\t\tlet overview: string | undefined = undefined\n\t\tif (typeof generateOverViewFromSnippetsFunc === \"function\" && documentInfo.file.snippetMetas) {\n\t\t\toverview = generateOverViewFromSnippetsFunc(documentInfo.file.snippetMetas || [])\n\t\t}\n\n\t\t// 3. \u83B7\u53D6\u76F8\u5173\u4E0A\u4E0B\u6587\n\t\tconst relatedSnippets = await this.retriveRelates(\n\t\t\tdocumentInfo.content,\n\t\t\tpositionInfo.line + 1, // \u8F6C\u6362\u4E3A 1-based\n\t\t\tpositionInfo.character,\n\t\t\tdocumentInfo.file,\n\t\t\tglobalContext,\n\t\t)\n\n\t\tthis.logger.info(`Found ${relatedSnippets.snippets.length} related snippets`)\n\n\t\treturn {\n\t\t\tprefix,\n\t\t\tsuffix,\n\t\t\tsnippets: relatedSnippets.snippets,\n\t\t\toverview,\n\t\t\tfilePath: documentInfo.file.filePath,\n\t\t\tfileHash: documentInfo.file.fileHash,\n\t\t\tgitUrl: \"\",\n\t\t}\n\t}\n\n\t/**\n\t * \u9884\u5904\u7406\u4E0A\u4E0B\u6587 - \u8F93\u51FA3\u4E2A\u5B57\u7B26\u4E32\n\t */\n\tasync preprocess(completionContext: ICompletionContext, options: IPreprocessOptions): Promise {\n\t\t// \u68C0\u67E5\u5149\u6807\u662F\u5426\u5728\u5355\u8BCD\u5185\u90E8 - \u5982\u679C\u662F\u5219\u8BBE\u7F6E\u8DF3\u8FC7\u6807\u5FD7\n\t\tif (isInsideWord(completionContext.prefix, completionContext.suffix, (msg) => this.logger.info(msg))) {\n\t\t\treturn {\n\t\t\t\tprefix: completionContext.prefix,\n\t\t\t\tsuffix: completionContext.suffix,\n\t\t\t\textraContexts: [],\n\t\t\t\tshouldSkipCompletion: false,\n\t\t\t}\n\t\t}\n\n\t\tconst extraContexts: IContextSection[] = []\n\n\t\tconst recentOpenFiles = options.recentOpenFiles\n\t\t\t.filter((file) => file.language === options.codeFile.language)\n\t\t\t.map((file) => file.filePath)\n\n\t\t// type: IContextSectionType.RepoTreeView\n\t\tif (options.codeFile.projectRoot) {\n\t\t\ttry {\n\t\t\t\t// filter recentOpenFiles by language\n\t\t\t\tconst treeViewText = await treeView(options.codeFile.projectRoot, recentOpenFiles, 10, 10)\n\t\t\t\textraContexts.push({\n\t\t\t\t\ttype: IContextSectionType.RepoTreeView,\n\t\t\t\t\tcontent: `## Repo Tree View\\n${treeViewText}`,\n\t\t\t\t})\n\t\t\t} catch (error) {\n\t\t\t\tthis.logger.warn(`Error getting repo tree view: ${error}`)\n\t\t\t}\n\t\t}\n\n\t\t// type: IContextSectionType.FileInfo\n\t\textraContexts.push({\n\t\t\ttype: IContextSectionType.FileInfo,\n\t\t\tcontent: `## Description\\n\\tThis is a ${options.codeFile.language} file.`,\n\t\t})\n\n\t\tif (completionContext.overview) {\n\t\t\t// type: IContextSectionType.FileOverview\n\t\t\textraContexts.push({\n\t\t\t\ttype: IContextSectionType.FileCodeOverview,\n\t\t\t\tcontent: `## File Overview\\n${completionContext.overview}`,\n\t\t\t})\n\t\t}\n\n\t\tif (completionContext.snippets.length > 0) {\n\t\t\t// type: IContextSectionType.RelatedFunctionDefinition\n\t\t\textraContexts.push({\n\t\t\t\ttype: IContextSectionType.RelatedFunctionDefinition,\n\t\t\t\tcontent: `## Related Function Definitions\\n${completionContext.snippets.map((snippet) => snippet.definitionText).join(\"\\n\")}`,\n\t\t\t})\n\t\t}\n\n\t\tif (this.options.numImplementContexts > 0 && completionContext.snippets.length > 0) {\n\t\t\t// type: IContextSectionType.RelatedFunctionImplement\n\t\t\textraContexts.push({\n\t\t\t\ttype: IContextSectionType.RelatedFuntionImplement,\n\t\t\t\tcontent: `## Related Function Implementations\\n${completionContext.snippets.map((snippet) => snippet.implementText).join(\"\\n\")}`,\n\t\t\t})\n\t\t}\n\n\t\t// \u6DFB\u52A0\u5F00\u653E\u6807\u7B7E\u9875\u7684\u7B26\u53F7\u4FE1\u606F - \u6309\u8BED\u8A00\u7C7B\u578B\u8FC7\u6EE4\uFF0C\u5E76\u6392\u9664\u5F53\u524D\u6587\u4EF6\n\t\tif (options.recentOpenFiles && options.recentOpenFiles.length > 0) {\n\t\t\tconst sameLanguageFiles = options.recentOpenFiles.filter(\n\t\t\t\t(file) =>\n\t\t\t\t\tfile.language === options.codeFile.language && file.filePath !== options.codeFile.filePath,\n\t\t\t)\n\n\t\t\tif (sameLanguageFiles.length > 0) {\n\t\t\t\t// \u4E3A\u6BCF\u4E2A\u540C\u8BED\u8A00\u7684\u6587\u4EF6\u83B7\u53D6\u7B26\u53F7\u6982\u8981\n\t\t\t\tconst symbolOverviews: string[] = []\n\n\t\t\t\tfor (const file of sameLanguageFiles) {\n\t\t\t\t\tif (file.snippetMetas && file.snippetMetas.length > 0) {\n\t\t\t\t\t\tconst generateOverViewFunc =\n\t\t\t\t\t\t\tcapturesProcess.generateOverViewFromSnippets[file.language as CodeLanguageType]\n\t\t\t\t\t\tif (typeof generateOverViewFunc === \"function\") {\n\t\t\t\t\t\t\tconst overview = generateOverViewFunc(file.snippetMetas)\n\t\t\t\t\t\t\tif (overview.trim()) {\n\t\t\t\t\t\t\t\tsymbolOverviews.push(`### ${file.filePath}\\n${overview}`)\n\t\t\t\t\t\t\t}\n\t\t\t\t\t\t}\n\t\t\t\t\t}\n\t\t\t\t}\n\n\t\t\t\tif (symbolOverviews.length > 0) {\n\t\t\t\t\textraContexts.push({\n\t\t\t\t\t\ttype: IContextSectionType.RelatedFunctionDefinition,\n\t\t\t\t\t\tcontent: `## Open Tabs Symbol Overview\\n${symbolOverviews.join(\"\\n\\n\")}`,\n\t\t\t\t\t})\n\t\t\t\t}\n\t\t\t}\n\t\t}\n\n\t\t// type: IContextSectionType.EndContextPrompt\n\t\textraContexts.push({\n\t\t\ttype: IContextSectionType.EndContextPrompt,\n\t\t\tcontent: `## Recent Open Files\\n${recentOpenFiles.join(\", \")}\\n\\n End of Context, Above is the context of the current file. You are editing the file at line ${options.editCursor.line}, character ${options.editCursor.character}, Starting Coding.`,\n\t\t})\n\n\t\tfor (const extraContext of extraContexts) {\n\t\t\textraContext.content = formatCodeWithLanguageWithLineComment(\n\t\t\t\textraContext.content,\n\t\t\t\toptions.codeFile.language as CodeLanguageType,\n\t\t\t)\n\t\t}\n\n\t\treturn {\n\t\t\tprefix: completionContext.prefix,\n\t\t\tsuffix: completionContext.suffix,\n\t\t\textraContexts: extraContexts,\n\t\t\tshouldSkipCompletion: false,\n\t\t}\n\t}\n\n\t/**\n\t * \u83B7\u53D6\u5F53\u524D\u5149\u6807\u4F4D\u7F6E\u7684\u4E0A\u4E0B\u6587 - \u57FA\u4E8E\u51FD\u6570\u7EA7\u522B\u800C\u975E\u884C\u7D1A\u5225\n\t */\n\tprivate async getCurrentContext(\n\t\tdocumentInfo: DocumentInfo,\n\t\tpositionInfo: PositionInfo,\n\t): Promise<{\n\t\tprefix: string\n\t\tsuffix: string\n\t}> {\n\t\t// find current function from file snippets where position is in\n\t\tconst currentFunction = documentInfo.file.snippetMetas?.filter((snippet) => {\n\t\t\tif (snippet.startLine && snippet.endLine) {\n\t\t\t\treturn positionInfo.line >= snippet.startLine && positionInfo.line <= snippet.endLine\n\t\t\t}\n\t\t\treturn false\n\t\t})[0]\n\t\tif (currentFunction) {\n\t\t\tthis.logger.info(\n\t\t\t\t`Found function: ${currentFunction.name} at lines ${currentFunction.startLine}-${currentFunction.endLine}`,\n\t\t\t)\n\n\t\t\t// 3. \u83B7\u53D6\u51FD\u6570\u7684\u5B8C\u6574\u6587\u672C\n\t\t\tif (!currentFunction.implementText) {\n\t\t\t\tthis.logger.warn(`No implementText available for function: ${currentFunction.name}`)\n\t\t\t\treturn this.getSurroundingCodeContextSimple(documentInfo, positionInfo)\n\t\t\t}\n\n\t\t\tconst originalTextLines = documentInfo.content.split(\"\\n\")\n\n\t\t\tlet startLine = Math.max(1, currentFunction.startLine)\n\t\t\tconst functionLines = currentFunction.implementText.split(\"\\n\")\n\t\t\tlet endLine = Math.min(startLine + functionLines.length, documentInfo.lineCount)\n\n\t\t\tconst remainsLinesCount = this.options.numLinesAsContext - (endLine - startLine)\n\n\t\t\tif (remainsLinesCount > 0) {\n\t\t\t\t// extend startLine and endLine\n\t\t\t\tconst halfRemainsLinesCount = Math.floor(remainsLinesCount / 2)\n\t\t\t\tstartLine = Math.max(1, startLine - halfRemainsLinesCount)\n\t\t\t\tendLine = Math.min(documentInfo.lineCount, endLine + halfRemainsLinesCount)\n\t\t\t}\n\n\t\t\tconst startIndex = startLine - 1\n\t\t\tconst endIndex = endLine - 1\n\n\t\t\tif (\n\t\t\t\tstartIndex < 0 ||\n\t\t\t\tstartIndex > originalTextLines.length ||\n\t\t\t\tendIndex < 0 ||\n\t\t\t\tendIndex > originalTextLines.length\n\t\t\t) {\n\t\t\t\tthis.logger.warn(`Invalid startIndex or endIndex: ${startIndex}, ${endIndex}`)\n\t\t\t\treturn this.getSurroundingCodeContextSimple(documentInfo, positionInfo)\n\t\t\t}\n\n\t\t\tlet prefix = originalTextLines.slice(startIndex, positionInfo.line).join(\"\\n\")\n\t\t\tlet suffix = \"\"\n\n\t\t\tif (positionInfo.line < originalTextLines.length) {\n\t\t\t\tsuffix =\n\t\t\t\t\toriginalTextLines[positionInfo.line].substring(positionInfo.character) +\n\t\t\t\t\t\"\\n\" +\n\t\t\t\t\toriginalTextLines.slice(positionInfo.line + 1, endIndex + 1).join(\"\\n\")\n\t\t\t}\n\n\t\t\tif (positionInfo.line >= 0 && positionInfo.line < originalTextLines.length) {\n\t\t\t\tprefix += \"\\n\" + originalTextLines[positionInfo.line].substring(0, positionInfo.character)\n\t\t\t}\n\n\t\t\tthis.logger.info(`Function-level context - Prefix: ${prefix.length} chars, Suffix: ${suffix.length} chars`)\n\n\t\t\treturn { prefix, suffix }\n\t\t} else {\n\t\t\tthis.logger.info(`No function found at position, using line-level context`)\n\t\t\treturn this.getSurroundingCodeContextSimple(documentInfo, positionInfo)\n\t\t}\n\t}\n\n\tpublic isSimpleContextEnough(documentInfo: DocumentInfo, positionInfo: PositionInfo): boolean {\n\t\tconst { startLine, endLine } = this.getSurroundingCodeContextSimpleStartAndEnd(documentInfo, positionInfo)\n\t\treturn startLine <= 0 && endLine >= documentInfo.lineCount - 1\n\t}\n\n\tprivate getSurroundingCodeContextSimpleStartAndEnd(\n\t\tdocumentInfo: DocumentInfo,\n\t\tpositionInfo: PositionInfo,\n\t): { startLine: number; endLine: number } {\n\t\tconst line = positionInfo.line\n\t\tconst startLine = Math.max(0, line - this.options.numLinesAsContext)\n\t\tconst endLine = Math.min(documentInfo.lineCount - 1, line + this.options.numLinesAsContextSuffix)\n\n\t\treturn { startLine, endLine }\n\t}\n\n\tprivate getSurroundingCodeContextSimple(\n\t\tdocumentInfo: DocumentInfo,\n\t\tpositionInfo: PositionInfo,\n\t): { prefix: string; suffix: string } {\n\t\tconst line = positionInfo.line\n\t\tconst { startLine, endLine } = this.getSurroundingCodeContextSimpleStartAndEnd(documentInfo, positionInfo)\n\n\t\tconst lines = documentInfo.content.split(\"\\n\")\n\t\tlet prefix = lines.slice(startLine, line).join(\"\\n\")\n\t\tlet suffix = \"\"\n\t\tif (line < lines.length) {\n\t\t\tsuffix = lines[line].substring(positionInfo.character) + \"\\n\" + lines.slice(line + 1, endLine).join(\"\\n\")\n\t\t}\n\t\tif (line >= 0 && line < lines.length) {\n\t\t\tprefix += \"\\n\" + lines[line].substring(0, positionInfo.character)\n\t\t}\n\t\treturn { prefix, suffix }\n\t}\n\n\t// ==================== \u8F85\u52A9\u65B9\u6CD5 ====================\n\n\tprivate calculateFileHash(content: string): string {\n\t\treturn crypto.createHash(\"md5\").update(content).digest(\"hex\")\n\t}\n\n\tprivate isSupportedLanguage(language: CodeLanguageType): boolean {\n\t\treturn CodeLanguageTypeSupport.includes(language)\n\t}\n}\n", "import * as path from \"path\"\nimport Parser from \"web-tree-sitter\"\nimport {\n\tjavascriptQuery,\n\tjsxQuery,\n\ttypescriptQuery,\n\ttsxQuery,\n\tpythonQuery,\n\trustQuery,\n\tgoQuery,\n\tcppQuery,\n\tcQuery,\n\tcsharpQuery,\n\trubyQuery,\n\tjavaQuery,\n\tphpQuery,\n\thtmlQuery,\n\tswiftQuery,\n\tkotlinQuery,\n\tcssQuery,\n\tocamlQuery,\n\tsolidityQuery,\n\ttomlQuery,\n\tvueQuery,\n\tluaQuery,\n\tsystemrdlQuery,\n\ttlaPlusQuery,\n\tzigQuery,\n\tembeddedTemplateQuery,\n\telispQuery,\n\telixirQuery,\n} from \"./queries\"\n\nexport interface LanguageParser {\n\t[key: string]: {\n\t\tparser: Parser\n\t\tquery: Parser.Query\n\t}\n}\n\nasync function loadLanguage(langName: string) {\n\treturn await Parser.Language.load(path.join(__dirname, `tree-sitter-${langName}.wasm`))\n}\n\nlet isParserInitialized = false\n\nasync function initializeParser() {\n\tif (!isParserInitialized) {\n\t\tawait Parser.init()\n\t\tisParserInitialized = true\n\t}\n}\n\n/*\nUsing node bindings for tree-sitter is problematic in vscode extensions \nbecause of incompatibility with electron. Going the .wasm route has the \nadvantage of not having to build for multiple architectures.\n\nWe use web-tree-sitter and tree-sitter-wasms which provides auto-updating prebuilt WASM binaries for tree-sitter's language parsers.\n\nThis function loads WASM modules for relevant language parsers based on input files:\n1. Extracts unique file extensions\n2. Maps extensions to language names\n3. Loads corresponding WASM files (containing grammar rules)\n4. Uses WASM modules to initialize tree-sitter parsers\n\nThis approach optimizes performance by loading only necessary parsers once for all relevant files.\n\nSources:\n- https://github.com/tree-sitter/node-tree-sitter/issues/169\n- https://github.com/tree-sitter/node-tree-sitter/issues/168\n- https://github.com/Gregoor/tree-sitter-wasms/blob/main/README.md\n- https://github.com/tree-sitter/tree-sitter/blob/master/lib/binding_web/README.md\n- https://github.com/tree-sitter/tree-sitter/blob/master/lib/binding_web/test/query-test.js\n*/\nexport async function loadRequiredLanguageParsers(filesToParse: string[]): Promise {\n\tawait initializeParser()\n\tconst extensionsToLoad = new Set(filesToParse.map((file) => path.extname(file).toLowerCase().slice(1)))\n\tconst parsers: LanguageParser = {}\n\tfor (const ext of extensionsToLoad) {\n\t\tlet language: Parser.Language\n\t\tlet query: Parser.Query\n\t\tlet parserKey = ext // Default to using extension as key\n\t\tswitch (ext) {\n\t\t\tcase \"js\":\n\t\t\tcase \"json\":\n\t\t\t\tlanguage = await loadLanguage(\"javascript\")\n\t\t\t\tquery = language.query(javascriptQuery)\n\t\t\t\tbreak\n\t\t\tcase \"jsx\":\n\t\t\t\tlanguage = await loadLanguage(\"javascript\")\n\t\t\t\tquery = language.query(jsxQuery)\n\t\t\t\tbreak\n\t\t\tcase \"ts\":\n\t\t\t\tlanguage = await loadLanguage(\"typescript\")\n\t\t\t\tquery = language.query(typescriptQuery)\n\t\t\t\tbreak\n\t\t\tcase \"tsx\":\n\t\t\t\tlanguage = await loadLanguage(\"tsx\")\n\t\t\t\tquery = language.query(tsxQuery)\n\t\t\t\tbreak\n\t\t\tcase \"py\":\n\t\t\t\tlanguage = await loadLanguage(\"python\")\n\t\t\t\tquery = language.query(pythonQuery)\n\t\t\t\tbreak\n\t\t\tcase \"rs\":\n\t\t\t\tlanguage = await loadLanguage(\"rust\")\n\t\t\t\tquery = language.query(rustQuery)\n\t\t\t\tbreak\n\t\t\tcase \"go\":\n\t\t\t\tlanguage = await loadLanguage(\"go\")\n\t\t\t\tquery = language.query(goQuery)\n\t\t\t\tbreak\n\t\t\tcase \"cpp\":\n\t\t\tcase \"hpp\":\n\t\t\t\tlanguage = await loadLanguage(\"cpp\")\n\t\t\t\tquery = language.query(cppQuery)\n\t\t\t\tbreak\n\t\t\tcase \"c\":\n\t\t\tcase \"h\":\n\t\t\t\tlanguage = await loadLanguage(\"c\")\n\t\t\t\tquery = language.query(cQuery)\n\t\t\t\tbreak\n\t\t\tcase \"cs\":\n\t\t\t\tlanguage = await loadLanguage(\"c_sharp\")\n\t\t\t\tquery = language.query(csharpQuery)\n\t\t\t\tbreak\n\t\t\tcase \"rb\":\n\t\t\t\tlanguage = await loadLanguage(\"ruby\")\n\t\t\t\tquery = language.query(rubyQuery)\n\t\t\t\tbreak\n\t\t\tcase \"java\":\n\t\t\t\tlanguage = await loadLanguage(\"java\")\n\t\t\t\tquery = language.query(javaQuery)\n\t\t\t\tbreak\n\t\t\tcase \"php\":\n\t\t\t\tlanguage = await loadLanguage(\"php\")\n\t\t\t\tquery = language.query(phpQuery)\n\t\t\t\tbreak\n\t\t\tcase \"swift\":\n\t\t\t\tlanguage = await loadLanguage(\"swift\")\n\t\t\t\tquery = language.query(swiftQuery)\n\t\t\t\tbreak\n\t\t\tcase \"kt\":\n\t\t\tcase \"kts\":\n\t\t\t\tlanguage = await loadLanguage(\"kotlin\")\n\t\t\t\tquery = language.query(kotlinQuery)\n\t\t\t\tbreak\n\t\t\tcase \"css\":\n\t\t\t\tlanguage = await loadLanguage(\"css\")\n\t\t\t\tquery = language.query(cssQuery)\n\t\t\t\tbreak\n\t\t\tcase \"html\":\n\t\t\t\tlanguage = await loadLanguage(\"html\")\n\t\t\t\tquery = language.query(htmlQuery)\n\t\t\t\tbreak\n\t\t\tcase \"ml\":\n\t\t\tcase \"mli\":\n\t\t\t\tlanguage = await loadLanguage(\"ocaml\")\n\t\t\t\tquery = language.query(ocamlQuery)\n\t\t\t\tbreak\n\t\t\tcase \"scala\":\n\t\t\t\tlanguage = await loadLanguage(\"scala\")\n\t\t\t\tquery = language.query(luaQuery) // Temporarily use Lua query until Scala is implemented\n\t\t\t\tbreak\n\t\t\tcase \"sol\":\n\t\t\t\tlanguage = await loadLanguage(\"solidity\")\n\t\t\t\tquery = language.query(solidityQuery)\n\t\t\t\tbreak\n\t\t\tcase \"toml\":\n\t\t\t\tlanguage = await loadLanguage(\"toml\")\n\t\t\t\tquery = language.query(tomlQuery)\n\t\t\t\tbreak\n\t\t\tcase \"vue\":\n\t\t\t\tlanguage = await loadLanguage(\"vue\")\n\t\t\t\tquery = language.query(vueQuery)\n\t\t\t\tbreak\n\t\t\tcase \"lua\":\n\t\t\t\tlanguage = await loadLanguage(\"lua\")\n\t\t\t\tquery = language.query(luaQuery)\n\t\t\t\tbreak\n\t\t\tcase \"rdl\":\n\t\t\t\tlanguage = await loadLanguage(\"systemrdl\")\n\t\t\t\tquery = language.query(systemrdlQuery)\n\t\t\t\tbreak\n\t\t\tcase \"tla\":\n\t\t\t\tlanguage = await loadLanguage(\"tlaplus\")\n\t\t\t\tquery = language.query(tlaPlusQuery)\n\t\t\t\tbreak\n\t\t\tcase \"zig\":\n\t\t\t\tlanguage = await loadLanguage(\"zig\")\n\t\t\t\tquery = language.query(zigQuery)\n\t\t\t\tbreak\n\t\t\tcase \"ejs\":\n\t\t\tcase \"erb\":\n\t\t\t\tlanguage = await loadLanguage(\"embedded_template\")\n\t\t\t\tparserKey = \"embedded_template\" // Use same key for both extensions\n\t\t\t\tquery = language.query(embeddedTemplateQuery)\n\t\t\t\tbreak\n\t\t\tcase \"el\":\n\t\t\t\tlanguage = await loadLanguage(\"elisp\")\n\t\t\t\tquery = language.query(elispQuery)\n\t\t\t\tbreak\n\t\t\tcase \"ex\":\n\t\t\tcase \"exs\":\n\t\t\t\tlanguage = await loadLanguage(\"elixir\")\n\t\t\t\tquery = language.query(elixirQuery)\n\t\t\t\tbreak\n\t\t\tdefault:\n\t\t\t\tthrow new Error(`Unsupported language: ${ext}`)\n\t\t}\n\t\tconst parser = new Parser()\n\t\tparser.setLanguage(language)\n\t\tparsers[parserKey] = { parser, query }\n\t}\n\treturn parsers\n}\n", "export const solidityQuery = `\n; Contract declarations\n(contract_declaration\n name: (identifier) @name.definition.contract) @definition.contract\n\n(interface_declaration\n name: (identifier) @name.definition.interface) @definition.interface\n\n(library_declaration\n name: (identifier) @name.definition.library) @definition.library\n\n; Function declarations\n(function_definition\n name: (identifier) @name.definition.function) @definition.function\n\n(modifier_definition\n name: (identifier) @name.definition.modifier) @definition.modifier\n\n(constructor_definition) @definition.constructor\n\n(fallback_receive_definition\n (visibility)\n (state_mutability)) @definition.fallback\n\n; Type declarations\n(struct_declaration\n name: (identifier) @name.definition.struct) @definition.struct\n\n(enum_declaration\n name: (identifier) @name.definition.enum) @definition.enum\n\n(event_definition\n name: (identifier) @name.definition.event) @definition.event\n\n(error_declaration\n name: (identifier) @name.definition.error) @definition.error\n\n; Variable declarations\n(state_variable_declaration\n name: (identifier) @name.definition.variable) @definition.variable\n\n; Using directives\n(using_directive\n (type_alias) @name.definition.using) @definition.using`\n", "/*\nPHP Tree-sitter Query - Standardized Version\n\nThis query file captures PHP language constructs for code navigation and analysis.\nEach query pattern is organized by construct type and includes clear comments.\n\nSUPPORTED LANGUAGE CONSTRUCTS:\n------------------------------\n1. CLASS DEFINITIONS\n - Regular classes\n - Abstract classes\n - Final classes\n - Readonly classes (PHP 8.2+)\n\n2. INTERFACE & TRAIT DEFINITIONS\n - Interfaces\n - Traits\n - Enums (PHP 8.1+)\n\n3. FUNCTION & METHOD DEFINITIONS\n - Global functions\n - Class methods\n - Static methods\n - Abstract methods\n - Final methods\n - Arrow functions (PHP 7.4+)\n\n4. PROPERTY DEFINITIONS\n - Regular properties\n - Static properties\n - Readonly properties (PHP 8.1+)\n - Constructor property promotion (PHP 8.0+)\n\n5. OTHER LANGUAGE CONSTRUCTS\n - Constants\n - Namespaces\n - Use statements (imports)\n - Anonymous classes\n - Attributes (PHP 8.0+)\n - Match expressions (PHP 8.0+)\n - Heredoc and nowdoc syntax\n*/\nexport default `\n;--------------------------\n; 1. CLASS DEFINITIONS\n;--------------------------\n; Regular classes\n(class_declaration\n name: (name) @name.definition.class) @definition.class\n\n; Abstract classes\n(class_declaration\n (abstract_modifier)\n name: (name) @name.definition.abstract_class) @definition.abstract_class\n\n; Final classes\n(class_declaration\n (final_modifier)\n name: (name) @name.definition.final_class) @definition.final_class\n\n; Readonly classes (PHP 8.2+)\n(class_declaration\n (readonly_modifier)\n name: (name) @name.definition.readonly_class) @definition.readonly_class\n\n;--------------------------\n; 2. INTERFACE & TRAIT DEFINITIONS\n;--------------------------\n; Interfaces\n(interface_declaration\n name: (name) @name.definition.interface) @definition.interface\n\n; Traits\n(trait_declaration\n name: (name) @name.definition.trait) @definition.trait\n\n; Enums (PHP 8.1+)\n(enum_declaration\n name: (name) @name.definition.enum) @definition.enum\n\n;--------------------------\n; 3. FUNCTION & METHOD DEFINITIONS\n;--------------------------\n; Global functions\n(function_definition\n name: (name) @name.definition.function\n parameters: (formal_parameters) @parameters.definition.function\n body: (compound_statement) @body.definition.function) @definition.function\n\n; Regular methods\n(method_declaration\n name: (name) @name.definition.method\n parameters: (formal_parameters) @parameters.definition.method) @definition.method\n\n; Static methods\n(method_declaration\n (static_modifier)\n name: (name) @name.definition.static_method\n parameters: (formal_parameters) @parameters.definition.static_method) @definition.static_method\n\n; Abstract methods\n(method_declaration\n (abstract_modifier)\n name: (name) @name.definition.abstract_method\n parameters: (formal_parameters) @parameters.definition.abstract_method) @definition.abstract_method\n\n; Final methods\n(method_declaration\n (final_modifier)\n name: (name) @name.definition.final_method\n parameters: (formal_parameters) @parameters.definition.final_method) @definition.final_method\n\n; Arrow functions (PHP 7.4+)\n(arrow_function) @definition.arrow_function\n\n;--------------------------\n; 4. PROPERTY DEFINITIONS\n;--------------------------\n; Regular properties\n(property_declaration\n (property_element\n (variable_name\n (name) @name.definition.property))) @definition.property\n\n; Static properties\n(property_declaration\n (static_modifier)\n (property_element\n (variable_name\n (name) @name.definition.static_property))) @definition.static_property\n\n; Readonly properties (PHP 8.1+)\n(property_declaration\n (readonly_modifier)\n (property_element\n (variable_name\n (name) @name.definition.readonly_property))) @definition.readonly_property\n\n; Constructor property promotion (PHP 8.0+)\n(property_promotion_parameter\n name: (variable_name\n (name) @name.definition.promoted_property)) @definition.promoted_property\n\n;--------------------------\n; 5. OTHER LANGUAGE CONSTRUCTS\n;--------------------------\n; Constants\n(const_declaration\n (const_element\n (name) @name.definition.constant)) @definition.constant\n\n; Namespaces\n(namespace_definition\n name: (namespace_name) @name.definition.namespace) @definition.namespace\n\n; Use statements (imports)\n(namespace_use_declaration\n (namespace_use_clause\n (qualified_name) @name.definition.use)) @definition.use\n\n; Anonymous classes\n(object_creation_expression\n (declaration_list)) @definition.anonymous_class\n\n; Attributes (PHP 8.0+)\n(attribute_group\n (attribute\n (name) @name.definition.attribute)) @definition.attribute\n\n; Match expressions (PHP 8.0+)\n(match_expression) @definition.match_expression\n\n; Heredoc syntax\n(heredoc) @definition.heredoc\n\n; Nowdoc syntax\n(nowdoc) @definition.nowdoc\n`\n", "export const vueQuery = `\n; Top-level structure\n(component) @component.definition\n\n; Template section\n(template_element) @template.definition\n(template_element\n (element\n (start_tag\n (tag_name) @element.name.definition))\n (element\n (start_tag\n (attribute\n (attribute_name) @attribute.name.definition)))\n (element\n (start_tag\n (directive_attribute\n (directive_name) @directive.name.definition))))\n\n; Script section\n(script_element) @script.definition\n(script_element\n (raw_text) @script.content.definition)\n\n; Style section\n(style_element) @style.definition\n(style_element\n (raw_text) @style.content.definition)\n`\n", "/*\nTypeScript Tree-sitter Query Patterns\n*/\nexport default `\n; === Import Declarations ===\n(import_statement\n (import_clause\n (named_imports\n (import_specifier\n name: (identifier) @name.import)))) @definition.import\n\n; === Default Imports ===\n(import_statement\n (import_clause\n (identifier) @name.import)) @definition.import\n\n; === Class Declarations ===\n(class_declaration\n name: (type_identifier) @name.class) @definition.class\n\n; === Abstract Class Declarations ===\n(abstract_class_declaration\n name: (type_identifier) @name.class) @definition.class\n\n; === Interface Declarations ===\n(interface_declaration\n name: (type_identifier) @name.interface) @definition.interface\n\n; === Type Alias Declarations ===\n(type_alias_declaration\n name: (type_identifier) @name.type_alias) @definition.type_alias\n\n; === Enum Declarations ===\n(enum_declaration\n name: (identifier) @name.enum) @definition.enum\n\n; === Function Declarations ===\n(function_declaration\n name: (identifier) @name.function\n parameters: (formal_parameters) @parameters.function\n body: (statement_block) @body.function) @definition.function\n\n; === Generator Function Declarations ===\n(generator_function_declaration\n name: (identifier) @name.function\n parameters: (formal_parameters) @parameters.function\n body: (statement_block) @body.function) @definition.function\n\n; === Method Definitions in Classes ===\n(method_definition\n name: (property_identifier) @name.method\n parameters: (formal_parameters) @parameters.method\n body: (statement_block) @body.method) @definition.method\n\n; === Variable Declarations ===\n(variable_declaration\n (variable_declarator\n name: (identifier) @name.variable)) @definition.variable\n\n; === Lexical Declarations (const, let) ===\n(lexical_declaration\n (variable_declarator\n name: (identifier) @name.variable)) @definition.variable\n\n; === Property Signatures in Interfaces ===\n(property_signature\n name: (property_identifier) @name.property) @definition.property\n\n; === Method Signatures in Interfaces ===\n(method_signature\n name: (property_identifier) @name.method\n parameters: (formal_parameters) @parameters.method) @definition.method\n\n; === Arrow Functions assigned to variables ===\n(lexical_declaration\n (variable_declarator\n name: (identifier) @name.function\n value: (arrow_function\n parameters: (formal_parameters) @parameters.function))) @definition.function\n\n(variable_declaration\n (variable_declarator\n name: (identifier) @name.function\n value: (arrow_function\n parameters: (formal_parameters) @parameters.function))) @definition.function\n\n; === Function Expressions assigned to variables ===\n(lexical_declaration\n (variable_declarator\n name: (identifier) @name.function\n value: (function_expression\n parameters: (formal_parameters) @parameters.function))) @definition.function\n\n(variable_declaration\n (variable_declarator\n name: (identifier) @name.function\n value: (function_expression\n parameters: (formal_parameters) @parameters.function))) @definition.function\n`\n", "import typescriptQuery from \"./typescript\"\n\n/**\n * Tree-sitter Query for TSX Files\n *\n * This query captures React component definitions in TSX files:\n * - Function Components\n * - Class Components\n * - Higher Order Components\n * - Type Definitions\n * - Props Interfaces\n * - State Definitions\n * - Generic Components\n */\n\nexport default `${typescriptQuery}\n\n; Function Components - Both function declarations and arrow functions\n(function_declaration\n name: (identifier) @name) @definition.component\n\n; Arrow Function Components\n(variable_declaration\n (variable_declarator\n name: (identifier) @name\n value: (arrow_function))) @definition.component\n\n; Export Statement Components\n(export_statement\n (variable_declaration\n (variable_declarator\n name: (identifier) @name\n value: (arrow_function)))) @definition.component\n\n; Class Components\n(class_declaration\n name: (type_identifier) @name) @definition.class_component\n\n; Interface Declarations\n(interface_declaration\n name: (type_identifier) @name) @definition.interface\n\n; Type Alias Declarations\n(type_alias_declaration\n name: (type_identifier) @name) @definition.type\n\n; HOC Components\n(variable_declaration\n (variable_declarator\n name: (identifier) @name\n value: (call_expression\n function: (identifier)))) @definition.component\n\n; JSX Component Usage - Capture all components in JSX\n(jsx_element\n open_tag: (jsx_opening_element\n name: [(identifier) @component (member_expression) @component])) @definition.jsx_element\n\n; Self-closing JSX elements\n(jsx_self_closing_element\n name: [(identifier) @component (member_expression) @component]) @definition.jsx_self_closing_element\n\n; Capture all identifiers in JSX expressions that start with capital letters\n(jsx_expression\n (identifier) @jsx_component) @definition.jsx_component\n\n; Capture all member expressions in JSX\n(member_expression\n object: (identifier) @object\n property: (property_identifier) @property) @definition.member_component\n\n; Capture components in conditional expressions\n(ternary_expression\n consequence: (parenthesized_expression\n (jsx_element\n open_tag: (jsx_opening_element\n name: (identifier) @component)))) @definition.conditional_component\n\n(ternary_expression\n alternative: (jsx_self_closing_element\n name: (identifier) @component)) @definition.conditional_component\n\n; Generic Components\n(function_declaration\n name: (identifier) @name\n type_parameters: (type_parameters)) @definition.generic_component\n`\n", "/*\nPython Tree-sitter Query Patterns\n*/\nexport default `\n; Class definitions (including decorated)\n(class_definition\n name: (identifier) @name.definition.class) @definition.class\n\n(decorated_definition\n definition: (class_definition\n name: (identifier) @name.definition.class)) @definition.class\n\n; Function definitions with parameters and body (including async and decorated)\n(function_definition\n name: (identifier) @name.definition.function\n parameters: (parameters) @parameters.definition.function\n body: (block) @body.definition.function) @definition.function\n\n(decorated_definition\n definition: (function_definition\n name: (identifier) @name.definition.function\n parameters: (parameters) @parameters.definition.function)) @definition.function\n\n; Assignment statements for variables\n(assignment\n left: (identifier) @name.definition.variable) @definition.variable\n\n; Multiple assignment (tuple unpacking) - capture each identifier separately\n(assignment\n left: (pattern_list\n (identifier) @name.definition.variable)) @definition.variable\n\n; Augmented assignment (+=, -=, etc.)\n(augmented_assignment\n left: (identifier) @name.definition.variable) @definition.variable\n\n; Annotated assignment (with type hints)\n(expression_statement\n (assignment\n left: (identifier) @name.definition.variable\n type: (type))) @definition.variable\n\n; Attribute assignments (self.attribute = value) - capture the attribute name\n(assignment\n left: (attribute\n object: (identifier)\n attribute: (identifier) @name.definition.member_variable)) @definition.variable\n\n; Lambda expressions\n(expression_statement\n (assignment\n left: (identifier) @name.definition.lambda\n right: (parenthesized_expression\n (lambda)))) @definition.lambda\n\n; Generator functions (functions containing yield)\n(function_definition\n name: (identifier) @name.definition.generator\n body: (block\n (expression_statement\n (yield)))) @definition.generator\n\n; Comprehensions\n(expression_statement\n (assignment\n left: (identifier) @name.definition.comprehension\n right: [\n (list_comprehension)\n (dictionary_comprehension)\n (set_comprehension)\n ])) @definition.comprehension\n\n; With statements\n(with_statement) @definition.with_statement\n\n; Try statements\n(try_statement) @definition.try_statement\n\n; Import statements\n(import_statement\n name: (dotted_name) @name.definition.import) @definition.import\n\n(import_from_statement\n module_name: (dotted_name) @name.definition.import) @definition.import\n\n(import_from_statement\n name: (dotted_name) @name.definition.import) @definition.import\n\n; Global/Nonlocal statements\n(function_definition\n body: (block\n [(global_statement) (nonlocal_statement)])) @definition.scope\n\n; Match case statements\n(function_definition\n body: (block\n (match_statement))) @definition.match_case\n\n; Type annotations\n(typed_parameter\n type: (type)) @definition.type_annotation\n\n(expression_statement\n (assignment\n left: (identifier) @name.definition.type\n type: (type))) @definition.type_annotation\n`\n", "/*\n- class definitions\n- method definitions (including decorated methods)\n- named function declarations\n- arrow functions and function expressions assigned to variables\n- variable declarations (global and class member variables)\n- JSON object and array definitions (for JSON files)\n- decorators and decorated elements\n*/\nexport default `\n(\n (comment)* @doc\n .\n (method_definition\n name: (property_identifier) @name\n parameters: (formal_parameters) @parameters.definition.method) @definition.method\n (#not-eq? @name \"constructor\")\n (#strip! @doc \"^[\\\\s\\\\*/]+|^[\\\\s\\\\*/]$\")\n (#select-adjacent! @doc @definition.method)\n)\n\n(\n (comment)* @doc\n .\n [\n (class\n name: (_) @name.definition.class)\n (class_declaration\n name: (_) @name.definition.class)\n ] @definition.class\n (#strip! @doc \"^[\\\\s\\\\*/]+|^[\\\\s\\\\*/]$\")\n (#select-adjacent! @doc @definition.class)\n)\n\n(\n (comment)* @doc\n .\n [\n (function_declaration\n name: (identifier) @name.definition.function\n parameters: (formal_parameters) @parameters.definition.function\n body: (statement_block) @body.definition.function) @definition.function\n (generator_function_declaration\n name: (identifier) @name.definition.function\n parameters: (formal_parameters) @parameters.definition.function) @definition.function\n ]\n (#strip! @doc \"^[\\\\s\\\\*/]+|^[\\\\s\\\\*/]$\")\n (#select-adjacent! @doc @definition.function)\n)\n\n(\n (comment)* @doc\n .\n (lexical_declaration\n (variable_declarator\n name: (identifier) @name\n value: [\n (arrow_function\n parameters: (formal_parameters) @parameters.definition.function)\n (function_expression\n parameters: (formal_parameters) @parameters.definition.function)\n ]) @definition.function)\n (#strip! @doc \"^[\\\\s\\\\*/]+|^[\\\\s\\\\*/]$\")\n (#select-adjacent! @doc @definition.function)\n)\n\n(\n (comment)* @doc\n .\n (variable_declaration\n (variable_declarator\n name: (identifier) @name\n value: [\n (arrow_function\n parameters: (formal_parameters) @parameters.definition.function)\n (function_expression\n parameters: (formal_parameters) @parameters.definition.function)\n ]) @definition.function)\n (#strip! @doc \"^[\\\\s\\\\*/]+|^[\\\\s\\\\*/]$\")\n (#select-adjacent! @doc @definition.function)\n)\n\n; Variable declarations (let, const, var) - capture each declarator separately\n(variable_declarator\n name: (identifier) @name.definition.variable) @definition.variable\n\n; Also capture from parent declarations for context\n(variable_declaration\n (variable_declarator\n name: (identifier) @name.definition.variable)) @definition.variable\n\n(lexical_declaration\n (variable_declarator\n name: (identifier) @name.definition.variable)) @definition.variable\n\n; Destructuring assignments - capture all identifiers in destructuring patterns\n(shorthand_property_identifier_pattern) @name.definition.variable @definition.variable\n\n; Array destructuring - capture the whole pattern for manual processing\n(lexical_declaration\n (variable_declarator\n name: (array_pattern) @array_pattern)) @definition.variable\n\n(variable_declaration\n (variable_declarator\n name: (array_pattern) @array_pattern)) @definition.variable\n\n; Class field declarations\n(field_definition\n property: (property_identifier) @name.definition.member_variable) @definition.variable\n\n; Assignment expressions for member variables (this.property = value)\n(assignment_expression\n left: (member_expression\n object: (this)\n property: (property_identifier) @name.definition.member_variable)) @definition.variable\n\n; Object property assignments\n(assignment_expression\n left: (member_expression\n property: (property_identifier) @name.definition.member_variable)) @definition.variable\n\n; JSON object definitions\n(object) @object.definition\n\n; JSON object key-value pairs\n(pair\n key: (string) @property.name.definition\n value: [\n (object) @object.value\n (array) @array.value\n (string) @string.value\n (number) @number.value\n (true) @boolean.value\n (false) @boolean.value\n (null) @null.value\n ]\n) @property.definition\n\n; JSON array definitions\n(array) @array.definition\n\n; Decorated method definitions\n(\n [\n (method_definition\n decorator: (decorator)\n name: (property_identifier) @name\n parameters: (formal_parameters) @parameters.definition.method) @definition.method\n (method_definition\n decorator: (decorator\n (call_expression\n function: (identifier) @decorator_name))\n name: (property_identifier) @name\n parameters: (formal_parameters) @parameters.definition.method) @definition.method\n ]\n (#not-eq? @name \"constructor\")\n)\n\n; Decorated class definitions\n(\n [\n (class\n decorator: (decorator)\n name: (_) @name.definition.class) @definition.class\n (class_declaration\n decorator: (decorator)\n name: (_) @name.definition.class) @definition.class\n ]\n)\n\n; Capture method names in decorated classes\n(\n (class_declaration\n decorator: (decorator)\n body: (class_body\n (method_definition\n name: (property_identifier) @name\n parameters: (formal_parameters) @parameters.definition.method) @definition.method))\n (#not-eq? @name \"constructor\")\n)\n`\n", "import javascriptQuery from \"./javascript\"\n\n/*\nJSX Tree-sitter Query Patterns\nBased on JavaScript tree-sitter patterns but extended for React/JSX\n*/\n\nexport default `${javascriptQuery}\n\n; === React Function Components (override JavaScript base patterns) ===\n\n(\n (comment)* @doc\n .\n (function_declaration\n name: (identifier) @name.definition.function\n parameters: (formal_parameters) @parameters.definition.function\n body: (statement_block) @body.definition.function) @definition.function\n (#strip! @doc \"^[\\\\s\\\\*/]+|^[\\\\s\\\\*/]$\")\n (#select-adjacent! @doc @definition.function)\n)\n\n(\n (comment)* @doc\n .\n (lexical_declaration\n (variable_declarator\n name: (identifier) @name.definition.function\n value: (arrow_function\n parameters: (formal_parameters) @parameters.definition.function\n )\n )\n ) @definition.function\n (#strip! @doc \"^[\\\\s\\\\*/]+|^[\\\\s\\\\*/]$\")\n (#select-adjacent! @doc @definition.function)\n)\n\n(\n (comment)* @doc\n .\n (variable_declaration\n (variable_declarator\n name: (identifier) @name.definition.function\n value: (arrow_function\n parameters: (formal_parameters) @parameters.definition.function\n )\n )\n ) @definition.function\n (#strip! @doc \"^[\\\\s\\\\*/]+|^[\\\\s\\\\*/]$\")\n (#select-adjacent! @doc @definition.function)\n)\n\n; === JSX Elements ===\n\n(jsx_element\n open_tag: (jsx_opening_element\n name: (identifier) @name.jsx_element)) @definition.jsx_element\n\n(jsx_self_closing_element\n name: (identifier) @name.jsx_element) @definition.jsx_element\n\n; === Array pattern destructuring (for useState hooks) ===\n\n(lexical_declaration\n (variable_declarator\n name: (array_pattern) @array_pattern)) @definition.variable\n\n(variable_declaration\n (variable_declarator\n name: (array_pattern) @array_pattern)) @definition.variable\n\n; === Function calls (for hooks like useEffect) ===\n\n(call_expression\n function: (identifier) @name.definition.function) @definition.function_call\n`\n", "/*\nJava Tree-sitter Query Patterns\n- import declarations\n- package declarations\n- class declarations (including abstract)\n- interface declarations\n- enum declarations\n- record declarations\n- annotation type declarations\n- method declarations\n- constructor declarations\n- field declarations\n- variable declarations (excluding local variables inside methods)\n*/\nexport default `\n; Import declarations\n(import_declaration\n (scoped_identifier) @name.definition.import) @definition.import\n\n; Package declarations\n(package_declaration\n (scoped_identifier) @name.definition.package) @definition.package\n\n; Class declarations\n(class_declaration\n name: (identifier) @name.definition.class) @definition.class\n\n; Interface declarations\n(interface_declaration\n name: (identifier) @name.definition.interface) @definition.interface\n\n; Enum declarations\n(enum_declaration\n name: (identifier) @name.definition.enum) @definition.enum\n\n; Record declarations\n(record_declaration\n name: (identifier) @name.definition.record) @definition.record\n\n; Annotation type declarations\n(annotation_type_declaration\n name: (identifier) @name.definition.annotation) @definition.annotation\n\n; Annotation type element declarations (annotation methods)\n(annotation_type_element_declaration\n name: (identifier) @name.definition.method) @definition.method\n\n; Method declarations with parameters and body\n(method_declaration\n name: (identifier) @name.definition.method\n parameters: (formal_parameters) @parameters.definition.method\n body: (block) @body.definition.method) @definition.method\n\n; Abstract method declarations (interface methods without body)\n(method_declaration\n name: (identifier) @name.definition.method\n parameters: (formal_parameters) @parameters.definition.method) @definition.method\n\n; Constructor declarations\n(constructor_declaration\n name: (identifier) @name.definition.constructor\n parameters: (formal_parameters) @parameters.definition.constructor\n body: (constructor_body) @body.definition.constructor) @definition.constructor\n\n; Field declarations - handle multiple declarators\n(field_declaration\n declarator: (variable_declarator\n name: (identifier) @name.definition.field)) @definition.field\n\n; Enum constant declarations\n(enum_declaration\n body: (enum_body\n (enum_constant\n name: (identifier) @name.definition.enum_constant))) @definition.enum_constant\n\n; Static initializers\n(static_initializer) @definition.static_initializer\n\n; Instance initializers\n(block) @definition.instance_initializer\n`\n", "/*\nRust language structures for tree-sitter parsing\nCaptures all required constructs for code completion and analysis\n*/\nexport default `\n; Function definitions\n(function_item\n name: (identifier) @name.definition.function\n parameters: (parameters) @parameters.definition.function\n body: (block) @body.definition.function) @definition.function\n\n; Struct definitions and their fields\n(struct_item\n name: (type_identifier) @name.definition.struct\n body: (field_declaration_list\n (field_declaration\n name: (field_identifier) @name.definition.struct_field)*)) @definition.struct\n\n; Tuple struct definitions\n(struct_item\n name: (type_identifier) @name.definition.struct\n body: (ordered_field_declaration_list)*) @definition.struct\n\n; Unit struct definitions\n(struct_item\n name: (type_identifier) @name.definition.struct) @definition.struct\n\n; Enum definitions with variants\n(enum_item\n name: (type_identifier) @name.definition.enum\n body: (enum_variant_list\n (enum_variant\n name: (identifier) @name.definition.enum_variant)*)) @definition.enum\n\n; Trait definitions and their methods\n(trait_item\n name: (type_identifier) @name.definition.trait\n body: (declaration_list\n (function_signature_item\n name: (identifier) @name.definition.trait_method)*)) @definition.trait\n\n; Impl blocks (inherent implementation) and their methods\n(impl_item\n type: (type_identifier) @name.definition.impl\n body: (declaration_list\n (function_item\n name: (identifier) @name.definition.method\n parameters: (parameters) @parameters.definition.method\n body: (block) @body.definition.method)*)) @definition.impl\n\n; Trait implementations and their methods\n(impl_item\n trait: (type_identifier) @name.definition.impl_trait\n type: (type_identifier) @name.definition.impl_for\n body: (declaration_list\n (function_item\n name: (identifier) @name.definition.method\n parameters: (parameters) @parameters.definition.method\n body: (block) @body.definition.method)*)) @definition.impl_trait\n\n; Module definitions\n(mod_item\n name: (identifier) @name.definition.module) @definition.module\n\n; Macro definitions (macro_rules!)\n(macro_definition\n name: (identifier) @name.definition.macro) @definition.macro\n\n; Type aliases\n(type_item\n name: (type_identifier) @name.definition.type_alias) @definition.type_alias\n\n; Constants\n(const_item\n name: (identifier) @name.definition.constant) @definition.constant\n\n; Static items\n(static_item\n name: (identifier) @name.definition.static) @definition.static\n\n; Use declarations (imports)\n(use_declaration) @definition.use_declaration\n\n; Let bindings (local variables)\n(let_declaration\n pattern: (identifier) @name.definition.variable) @definition.variable\n\n; Associated functions and methods in impl blocks\n(impl_item\n body: (declaration_list)*) @definition.method_container\n\n; Function parameters capture\n(function_item\n parameters: (parameters\n (parameter\n pattern: (identifier) @name.definition.parameter)*))\n\n; Associated types in traits\n(trait_item\n body: (declaration_list\n (associated_type\n name: (type_identifier) @name.definition.associated_type)*))\n\n; Associated constants in traits and impls\n(trait_item\n body: (declaration_list\n (const_item\n name: (identifier) @name.definition.trait_constant)*))\n\n(impl_item\n body: (declaration_list\n (const_item\n name: (identifier) @name.definition.impl_constant)*))\n`\n", "/*\n- method definitions (including singleton methods and aliases, with associated comments)\n- class definitions (including singleton classes, with associated comments)\n- module definitions\n- constants\n- global variables\n- instance variables\n- class variables\n- symbols\n- blocks, procs, and lambdas\n- mixins (include, extend, prepend)\n- metaprogramming constructs (define_method, method_missing)\n- attribute accessors (attr_reader, attr_writer, attr_accessor)\n- class macros (has_many, belongs_to, etc. in Rails-like code)\n- exception handling (begin/rescue/ensure)\n- keyword arguments\n- splat operators\n- hash rocket and JSON-style hashes\n- string interpolation\n- regular expressions\n- Ruby 2.7+ pattern matching\n- Ruby 3.0+ endless methods\n- Ruby 3.1+ pin operator and shorthand hash syntax\n*/\nexport default `\n; Method definitions\n(method\n name: (identifier) @name.definition.method) @definition.method\n\n; Singleton methods\n(singleton_method\n object: (_)\n name: (identifier) @name.definition.method) @definition.method\n\n; Method aliases\n(alias\n name: (_) @name.definition.method) @definition.method\n\n; Class definitions\n(class\n name: [\n (constant) @name.definition.class\n (scope_resolution\n name: (_) @name.definition.class)\n ]) @definition.class\n\n; Singleton classes\n(singleton_class\n value: [\n (constant) @name.definition.class\n (scope_resolution\n name: (_) @name.definition.class)\n ]) @definition.class\n\n; Module definitions\n(module\n name: [\n (constant) @name.definition.module\n (scope_resolution\n name: (_) @name.definition.module)\n ]) @definition.module\n\n; Constants\n(assignment\n left: (constant) @name.definition.constant) @definition.constant\n\n; Global variables\n(global_variable) @definition.global_variable\n\n; Instance variables\n(instance_variable) @definition.instance_variable\n\n; Class variables\n(class_variable) @definition.class_variable\n\n; Symbols\n(simple_symbol) @definition.symbol\n(hash_key_symbol) @definition.symbol\n\n; Blocks\n(block) @definition.block\n(do_block) @definition.block\n\n; Basic mixin statements - capture all include/extend/prepend calls\n(call\n method: (identifier) @_mixin_method\n arguments: (argument_list\n (constant) @name.definition.mixin)\n (#match? @_mixin_method \"^(include|extend|prepend)$\")) @definition.mixin\n\n; Mixin module definition\n(module\n name: (constant) @name.definition.mixin_module\n (#match? @name.definition.mixin_module \".*Module$\")) @definition.mixin_module\n\n; Mixin-related methods\n(method\n name: (identifier) @name.definition.mixin_method\n (#match? @name.definition.mixin_method \"(included|extended|prepended)_method\")) @definition.mixin_method\n\n; Singleton class blocks\n(singleton_class) @definition.singleton_class\n\n; Class methods in singleton context\n(singleton_method\n object: (self)\n name: (identifier) @name.definition.singleton_method) @definition.singleton_method\n\n; Attribute accessors\n(call\n method: (identifier) @_attr_accessor\n arguments: (argument_list\n (_) @name.definition.attr_accessor)\n (#eq? @_attr_accessor \"attr_accessor\")) @definition.attr_accessor\n\n(call\n method: (identifier) @_attr_reader\n arguments: (argument_list\n (_) @name.definition.attr_reader)\n (#eq? @_attr_reader \"attr_reader\")) @definition.attr_reader\n\n(call\n method: (identifier) @_attr_writer\n arguments: (argument_list\n (_) @name.definition.attr_writer)\n (#eq? @_attr_writer \"attr_writer\")) @definition.attr_writer\n\n; Class macros (Rails-like)\n(call\n method: (identifier) @_macro_name\n arguments: (argument_list\n (_) @name.definition.class_macro)\n (#match? @_macro_name \"^(has_many|belongs_to|has_one|validates|scope|before_action|after_action)$\")) @definition.class_macro\n\n; Exception handling\n(begin) @definition.begin\n(rescue) @definition.rescue\n(ensure) @definition.ensure\n\n; Keyword arguments\n(keyword_parameter\n name: (identifier) @name.definition.keyword_parameter) @definition.keyword_parameter\n\n; Splat operators\n(splat_parameter) @definition.splat_parameter\n(splat_argument) @definition.splat_argument\n\n; Hash syntax variants\n(pair\n key: (_) @name.definition.hash_key) @definition.hash_pair\n\n; String interpolation - capture the string with interpolation and surrounding context\n(assignment\n left: (identifier) @name.definition.string_var\n right: (string\n (interpolation))) @definition.string_interpolation\n\n; Regular expressions - capture the regex pattern and assignment\n(assignment\n left: (identifier) @name.definition.regex_var\n right: (regex)) @definition.regex_assignment\n\n; Pattern matching - capture the entire case_match structure\n(case_match) @definition.case_match\n\n; Pattern matching - capture in_clause with hash pattern\n(in_clause\n pattern: (hash_pattern)) @definition.hash_pattern_clause\n\n; Endless methods - capture the method definition with name and surrounding context\n(comment) @_endless_method_comment\n(#match? @_endless_method_comment \"Ruby 3.0\\\\+ endless method\")\n(method\n name: (identifier) @name.definition.endless_method\n body: (binary\n operator: \"=\")) @definition.endless_method\n\n; Pin operator - capture the entire in_clause with variable_reference_pattern\n(in_clause\n pattern: (variable_reference_pattern)) @definition.pin_pattern_clause\n\n; Shorthand hash syntax - capture the method containing shorthand hash\n(comment) @_shorthand_hash_comment\n(#match? @_shorthand_hash_comment \"Ruby 3.1\\\\+ shorthand hash syntax\")\n(method\n name: (identifier) @name.definition.shorthand_method) @definition.shorthand_method\n\n; Shorthand hash syntax - capture the hash with shorthand syntax\n(hash\n (pair\n (hash_key_symbol)\n \":\")) @definition.shorthand_hash\n\n; Capture larger contexts for features that need at least 4 lines\n\n; Capture the entire program to include all comments and code\n(program) @definition.program\n\n; Capture all comments\n(comment) @definition.comment\n\n; Capture all method definitions\n(method) @definition.method_all\n`\n", "/*\nC Language Constructs Supported by Tree-Sitter Parser:\n\n1. Class-like Constructs:\n- struct definitions (with fields)\n- union definitions (with variants)\n- enum definitions (with values)\n- anonymous unions/structs\n- aligned structs\n\n2. Function-related Constructs:\n- function definitions (with parameters)\n- function declarations (prototypes)\n- static functions\n- function pointers\n\n3. Type Definitions:\n- typedef declarations (all types)\n- function pointer typedefs\n- struct/union typedefs\n\n4. Variable Declarations:\n- global variables\n- static variables\n- array declarations\n- pointer declarations\n\n5. Preprocessor Constructs:\n- function-like macros\n- object-like macros\n- conditional compilation\n- include directives\n*/\n\nexport default `\n; Include directives\n(preproc_include\n path: (_) @name.definition.include) @definition.include\n\n; Function definitions\n(function_definition\n declarator: (function_declarator\n declarator: (identifier) @name.definition.function\n parameters: (parameter_list) @parameters.definition.function)\n body: (compound_statement) @body.definition.function) @definition.function\n\n; Function declarations (prototypes)\n(declaration\n declarator: (function_declarator\n declarator: (identifier) @name.definition.function\n parameters: (parameter_list) @parameters.definition.function)) @definition.function\n\n; Struct definitions with fields\n(struct_specifier\n name: (type_identifier) @name.definition.struct\n body: (field_declaration_list) @body.definition.struct) @definition.struct\n\n; Union definitions with fields\n(union_specifier\n name: (type_identifier) @name.definition.union\n body: (field_declaration_list) @body.definition.union) @definition.union\n\n; Enum definitions with values\n(enum_specifier\n name: (type_identifier) @name.definition.enum\n body: (enumerator_list) @body.definition.enum) @definition.enum\n\n; Typedef declarations\n(type_definition\n declarator: (type_identifier) @name.definition.type) @definition.type\n\n; Global variables\n(declaration\n declarator: (identifier) @name.definition.variable) @definition.variable\n\n(declaration\n declarator: (init_declarator\n declarator: (identifier) @name.definition.variable)) @definition.variable\n\n(declaration\n declarator: (init_declarator\n declarator: (array_declarator\n declarator: (identifier) @name.definition.variable))) @definition.variable\n\n(declaration\n declarator: (pointer_declarator\n declarator: (identifier) @name.definition.variable)) @definition.variable\n\n(declaration\n declarator: (pointer_declarator\n declarator: (pointer_declarator\n declarator: (identifier) @name.definition.variable))) @definition.variable\n\n(declaration\n declarator: (init_declarator\n declarator: (pointer_declarator\n declarator: (identifier) @name.definition.variable))) @definition.variable\n\n(declaration\n declarator: (function_declarator\n declarator: (parenthesized_declarator\n (pointer_declarator\n declarator: (identifier) @name.definition.variable)))) @definition.variable\n\n(declaration\n declarator: (array_declarator\n declarator: (identifier) @name.definition.variable)) @definition.variable\n\n(declaration\n declarator: (array_declarator\n declarator: (array_declarator\n declarator: (identifier) @name.definition.variable))) @definition.variable\n\n(declaration\n declarator: (array_declarator\n declarator: (array_declarator\n declarator: (array_declarator\n declarator: (identifier) @name.definition.variable)))) @definition.variable\n\n; Static variables\n(declaration\n (storage_class_specifier) @storage\n declarator: (identifier) @name.definition.variable) @definition.variable\n\n(declaration\n (storage_class_specifier) @storage\n declarator: (init_declarator\n declarator: (identifier) @name.definition.variable)) @definition.variable\n\n(declaration\n (storage_class_specifier) @storage\n declarator: (array_declarator\n declarator: (identifier) @name.definition.variable)) @definition.variable\n\n(declaration\n (storage_class_specifier) @storage\n declarator: (pointer_declarator\n declarator: (identifier) @name.definition.variable)) @definition.variable\n\n; Object-like macros\n(preproc_def\n name: (identifier) @name.definition.macro) @definition.macro\n\n; Function-like macros\n(preproc_function_def\n name: (identifier) @name.definition.macro\n parameters: (preproc_params) @parameters.definition.macro) @definition.macro\n\n; Field declarations (members)\n(field_declaration\n declarator: (field_identifier) @name.definition.field) @definition.field\n\n; Enum values/enumerators\n(enumerator\n name: (identifier) @name.definition.enumerator) @definition.enumerator\n\n; Parameter declarations\n(parameter_declaration\n declarator: (identifier) @name.definition.parameter) @definition.parameter\n\n; C++ specific constructs\n\n; Destructor definitions\n(function_definition\n declarator: (function_declarator\n declarator: (destructor_name) @name.definition.destructor\n parameters: (parameter_list) @parameters.definition.destructor)\n body: (compound_statement) @body.definition.destructor) @definition.destructor\n\n; Operator overloading\n(function_definition\n declarator: (function_declarator\n declarator: (operator_name) @name.definition.operator\n parameters: (parameter_list) @parameters.definition.operator)\n body: (compound_statement) @body.definition.operator) @definition.operator\n\n; Method definitions (class/struct members)\n(function_definition\n declarator: (function_declarator\n declarator: (field_identifier) @name.definition.method\n parameters: (parameter_list) @parameters.definition.method)\n body: (compound_statement) @body.definition.method) @definition.method\n\n; Class definitions\n(class_specifier\n name: (type_identifier) @name.definition.class\n body: (field_declaration_list) @body.definition.class) @definition.class\n\n; Namespace definitions\n(namespace_definition\n name: (namespace_identifier) @name.definition.namespace\n body: (declaration_list) @body.definition.namespace) @definition.namespace\n\n; Template declarations\n(template_declaration\n parameters: (template_parameter_list) @parameters.definition.template\n (class_specifier\n name: (type_identifier) @name.definition.template.class)) @definition.template\n\n; Template function declarations\n(template_declaration\n parameters: (template_parameter_list) @parameters.definition.template\n (function_definition\n declarator: (function_declarator\n declarator: (identifier) @name.definition.template.function))) @definition.template\n\n; Typedef declarations\n(type_definition\n declarator: (type_identifier) @name.definition.typedef) @definition.typedef\n\n; Using declarations \n(using_declaration) @definition.using\n\n; More variable patterns for pointers and references\n(declaration\n declarator: (init_declarator\n declarator: (identifier) @name.definition.variable\n value: (_))) @definition.variable\n\n; Additional pointer declarator patterns\n(declaration\n type: (_)\n declarator: (pointer_declarator\n declarator: (identifier) @name.definition.variable)) @definition.variable\n\n; Reference variables (using & in type)\n(declaration\n type: (_)\n declarator: (identifier) @name.definition.variable) @definition.variable\n`\n", "/*\nC Language Constructs Supported by Tree-Sitter Parser:\n\n1. Class-like Constructs:\n- struct definitions (with fields)\n- union definitions (with variants)\n- enum definitions (with values)\n- anonymous unions/structs\n- aligned structs\n\n2. Function-related Constructs:\n- function definitions (with parameters)\n- function declarations (prototypes)\n- static functions\n- function pointers\n\n3. Type Definitions:\n- typedef declarations (all types)\n- function pointer typedefs\n- struct/union typedefs\n\n4. Variable Declarations:\n- global variables\n- static variables\n- array declarations\n- pointer declarations\n\n5. Preprocessor Constructs:\n- function-like macros\n- object-like macros\n- conditional compilation\n- include directives\n*/\n\nexport default `\n; Include directives\n(preproc_include\n path: (_) @name.definition.include) @definition.include\n\n; Function definitions\n(function_definition\n declarator: (function_declarator\n declarator: (identifier) @name.definition.function\n parameters: (parameter_list) @parameters.definition.function)\n body: (compound_statement) @body.definition.function) @definition.function\n\n; Function declarations (prototypes)\n(declaration\n declarator: (function_declarator\n declarator: (identifier) @name.definition.function\n parameters: (parameter_list) @parameters.definition.function)) @definition.function\n\n; Struct definitions with fields\n(struct_specifier\n name: (type_identifier) @name.definition.struct\n body: (field_declaration_list) @body.definition.struct) @definition.struct\n\n; Union definitions with fields\n(union_specifier\n name: (type_identifier) @name.definition.union\n body: (field_declaration_list) @body.definition.union) @definition.union\n\n; Enum definitions with values\n(enum_specifier\n name: (type_identifier) @name.definition.enum\n body: (enumerator_list) @body.definition.enum) @definition.enum\n\n; Typedef declarations\n(type_definition\n declarator: (type_identifier) @name.definition.type) @definition.type\n\n; Global variables\n(declaration\n declarator: (identifier) @name.definition.variable) @definition.variable\n\n(declaration\n declarator: (init_declarator\n declarator: (identifier) @name.definition.variable)) @definition.variable\n\n(declaration\n declarator: (init_declarator\n declarator: (array_declarator\n declarator: (identifier) @name.definition.variable))) @definition.variable\n\n(declaration\n declarator: (pointer_declarator\n declarator: (identifier) @name.definition.variable)) @definition.variable\n\n(declaration\n declarator: (pointer_declarator\n declarator: (pointer_declarator\n declarator: (identifier) @name.definition.variable))) @definition.variable\n\n(declaration\n declarator: (init_declarator\n declarator: (pointer_declarator\n declarator: (identifier) @name.definition.variable))) @definition.variable\n\n(declaration\n declarator: (function_declarator\n declarator: (parenthesized_declarator\n (pointer_declarator\n declarator: (identifier) @name.definition.variable)))) @definition.variable\n\n(declaration\n declarator: (array_declarator\n declarator: (identifier) @name.definition.variable)) @definition.variable\n\n(declaration\n declarator: (array_declarator\n declarator: (array_declarator\n declarator: (identifier) @name.definition.variable))) @definition.variable\n\n(declaration\n declarator: (array_declarator\n declarator: (array_declarator\n declarator: (array_declarator\n declarator: (identifier) @name.definition.variable)))) @definition.variable\n\n; Static variables\n(declaration\n (storage_class_specifier) @storage\n declarator: (identifier) @name.definition.variable) @definition.variable\n\n(declaration\n (storage_class_specifier) @storage\n declarator: (init_declarator\n declarator: (identifier) @name.definition.variable)) @definition.variable\n\n(declaration\n (storage_class_specifier) @storage\n declarator: (array_declarator\n declarator: (identifier) @name.definition.variable)) @definition.variable\n\n(declaration\n (storage_class_specifier) @storage\n declarator: (pointer_declarator\n declarator: (identifier) @name.definition.variable)) @definition.variable\n\n; Object-like macros\n(preproc_def\n name: (identifier) @name.definition.macro) @definition.macro\n\n; Function-like macros\n(preproc_function_def\n name: (identifier) @name.definition.macro\n parameters: (preproc_params) @parameters.definition.macro) @definition.macro\n\n; Field declarations (members)\n(field_declaration\n declarator: (field_identifier) @name.definition.field) @definition.field\n\n; Enum values/enumerators\n(enumerator\n name: (identifier) @name.definition.enumerator) @definition.enumerator\n\n; Parameter declarations\n(parameter_declaration\n declarator: (identifier) @name.definition.parameter) @definition.parameter\n`\n", "/*\nC# Tree-Sitter Query Patterns\n*/\nexport default `\n; Using directives\n(using_directive) @name.definition.using\n\n; Namespace declarations (including file-scoped)\n(namespace_declaration\n name: (identifier) @name.definition.namespace)\n(file_scoped_namespace_declaration\n name: (identifier) @name.definition.namespace)\n\n; Class declarations (including generic, static, abstract, partial, nested)\n(class_declaration\n name: (identifier) @name.definition.class)\n\n; Interface declarations\n(interface_declaration\n name: (identifier) @name.definition.interface)\n\n; Struct declarations\n(struct_declaration\n name: (identifier) @name.definition.struct)\n\n; Enum declarations\n(enum_declaration\n name: (identifier) @name.definition.enum)\n\n; Record declarations\n(record_declaration\n name: (identifier) @name.definition.record)\n\n; Method declarations (including async, static, generic)\n(method_declaration\n name: (identifier) @name.definition.method\n parameter_list: (parameter_list) @parameters.definition.method\n body: (block) @body.definition.method) @definition.method\n\n; Property declarations\n(property_declaration\n name: (identifier) @name.definition.property)\n\n; Event declarations\n(event_declaration\n name: (identifier) @name.definition.event)\n\n; Delegate declarations\n(delegate_declaration\n name: (identifier) @name.definition.delegate)\n\n; Attribute declarations\n(class_declaration\n (attribute_list\n (attribute\n name: (identifier) @name.definition.attribute)))\n\n; Generic type parameters\n(type_parameter_list\n (type_parameter\n name: (identifier) @name.definition.type_parameter))\n\n; LINQ expressions\n(query_expression) @name.definition.linq_expression\n`\n", "/*\nGo Tree-Sitter Query Patterns\n*/\nexport default `\n; Package declarations\n(package_clause\n (package_identifier) @name.definition.package)\n\n; Import declarations\n(import_declaration\n (import_spec_list\n (import_spec path: (_) @name.definition.import)))\n\n; Const declarations\n(const_declaration) @definition.const\n(const_declaration\n (const_spec name: (identifier) @name.definition.const))\n\n; Var declarations\n(var_declaration) @definition.var\n(var_declaration\n (var_spec name: (identifier) @name.definition.var))\n\n; Interface declarations\n(type_declaration) @definition.interface\n(type_declaration\n (type_spec\n name: (type_identifier) @name.definition.interface\n type: (interface_type)))\n\n; Struct declarations\n(type_declaration) @definition.struct\n(type_declaration\n (type_spec\n name: (type_identifier) @name.definition.struct\n type: (struct_type)))\n\n; Type declarations\n(type_declaration) @definition.type\n(type_declaration\n (type_spec\n name: (type_identifier) @name.definition.type))\n\n; Function declarations with result (parameter_list)\n(function_declaration\n name: (identifier) @name.definition.function\n parameters: (parameter_list) @parameters.definition.function\n result: (parameter_list) @result.definition.function\n body: (block) @body.definition.function) @definition.function\n\n; Function declarations with result (type_identifier)\n(function_declaration\n name: (identifier) @name.definition.function\n parameters: (parameter_list) @parameters.definition.function\n result: (type_identifier) @result.definition.function\n body: (block) @body.definition.function) @definition.function\n\n; Function declarations without result\n(function_declaration\n name: (identifier) @name.definition.function\n parameters: (parameter_list) @parameters.definition.function\n body: (block) @body.definition.function) @definition.function\n\n; Method declarations with result (parameter_list)\n(method_declaration\n receiver: (parameter_list\n \t(parameter_declaration\n \t(pointer_type\n \t(type_identifier) @class.definition.method\n )\n )\n ) @self.definition.method\n name: (field_identifier) @name.definition.method\n parameters: (parameter_list) @parameters.definition.method\n result: (parameter_list) @result.definition.method\n body: (block) @body.definition.method) @definition.method\n\n; Method declarations with result (type_identifier)\n(method_declaration\n receiver: (parameter_list\n \t(parameter_declaration\n \t(pointer_type\n \t(type_identifier) @class.definition.method\n )\n )\n ) @self.definition.method\n name: (field_identifier) @name.definition.method\n parameters: (parameter_list) @parameters.definition.method\n result: (type_identifier) @result.definition.method\n body: (block) @body.definition.method) @definition.method\n\n; Method declarations without result\n(method_declaration\n receiver: (parameter_list\n \t(parameter_declaration\n \t(pointer_type\n \t(type_identifier) @class.definition.method\n )\n )\n ) @self.definition.method\n name: (field_identifier) @name.definition.method\n parameters: (parameter_list) @parameters.definition.method\n body: (block) @body.definition.method) @definition.method\n\n; Channel operations\n(channel_type) @name.definition.channel\n\n; Goroutine declarations\n(go_statement) @name.definition.goroutine\n\n; Defer statements\n(defer_statement) @name.definition.defer\n\n; Select statements\n(select_statement) @name.definition.select\n`\n", "/*\nSwift Tree-Sitter Query Patterns\n\nSimplified Swift language constructs that work with tree-sitter\n*/\nexport default `\n; Import declarations\n(import_declaration) @definition.import\n(import_declaration\n (identifier) @name.definition.import)\n\n; Class declarations (includes class, struct, enum, extension)\n(class_declaration) @definition.class\n\n; Class name capture (for class, struct, enum)\n(class_declaration\n (type_identifier) @name.definition.class)\n\n; Extension name capture (extension extends user_type)\n(class_declaration\n \"extension\"\n (user_type\n (type_identifier) @name.definition.class))\n\n; Protocol declarations\n(protocol_declaration\n (type_identifier) @name.definition.protocol) @definition.protocol\n\n; Function declarations (both methods and global functions)\n(function_declaration\n (simple_identifier) @name.definition.method) @definition.method\n\n; Property declarations (all property declarations)\n(property_declaration\n (pattern\n (simple_identifier) @name.definition.property)) @definition.property\n\n; Computed properties (property declarations with computed_property body)\n(property_declaration\n (pattern\n (simple_identifier) @name.definition.computed_property)\n (computed_property)) @definition.computed_property\n\n; Global variables and constants (property_declaration at top level)\n(source_file\n (property_declaration\n (pattern\n (simple_identifier) @name.definition.global_var)) @definition.global_var)\n\n; Initializers\n(init_declaration\n \"init\" @name.definition.initializer) @definition.initializer\n\n; Deinitializers\n(deinit_declaration\n \"deinit\" @name.definition.deinitializer) @definition.deinitializer\n\n; Type alias\n(typealias_declaration\n (type_identifier) @name.definition.type_alias) @definition.type_alias\n\n; Protocol function declarations\n(protocol_function_declaration\n (simple_identifier) @name.definition.protocol_method) @definition.protocol_method\n`\n", "/*\nKotlin Tree-sitter Query Patterns\n\u57FA\u4E8Etree-sitter-kotlin\u7684\u8BED\u6CD5\u6811\u7ED3\u6784\uFF0C\u652F\u6301Kotlin\u8BED\u8A00\u7684\u4E3B\u8981\u6784\u9020\n\u652F\u6301\u7C7B\u3001\u63A5\u53E3\u3001\u679A\u4E3E\u3001\u51FD\u6570\u3001\u5C5E\u6027\u3001\u53D8\u91CF\u3001\u5BFC\u5165\u3001\u5305\u58F0\u660E\u7B49\n*/\nexport default `\n; Based on actual tree-sitter-kotlin grammar\n; Package declarations\n(package_header\n (identifier) @name.definition.package) @definition.package\n\n; Import declarations - capture the full import path including wildcards\n(import_header) @definition.import\n(import_header\n (identifier) @name.definition.import)\n\n; Class declarations (includes all types: class, interface, object, enum, etc.)\n(class_declaration\n (type_identifier) @name.definition.class) @definition.class\n\n; Object declarations (try alternative naming)\n(object_declaration\n (type_identifier) @name.definition.object) @definition.object\n\n; Function declarations\n(function_declaration\n (simple_identifier) @name.definition.function) @definition.function\n\n; Property declarations\n(property_declaration\n (variable_declaration\n (simple_identifier) @name.definition.property)\n) @definition.property\n\n; Type alias declarations\n(type_alias\n (type_identifier) @name.definition.type_alias) @definition.type_alias\n\n`\n", "/*\nCSS Tree-Sitter Query Patterns\n\u4E3ACSS\u6587\u4EF6\u63D0\u4F9B\u57FA\u4E8Etree-sitter\u7684\u4EE3\u7801\u8865\u5168\u652F\u6301\n\u652F\u6301\u7C7B\u9009\u62E9\u5668\u3001ID\u9009\u62E9\u5668\u3001CSS\u53D8\u91CF\u3001\u5173\u952E\u5E27\u52A8\u753B\u3001@\u89C4\u5219\u7B49\n*/\nexport default `\n; CSS\u89C4\u5219\u96C6\uFF08\u5305\u542B\u6240\u6709\u7C7B\u578B\u7684\u9009\u62E9\u5668\uFF09\n(rule_set\n (selectors) @selectors.definition.rule\n (block) @body.definition.rule) @definition.rule\n\n; CSS\u58F0\u660E\uFF08\u5C5E\u6027\uFF09- \u5904\u7406\u591A\u79CD\u503C\u7C7B\u578B\n(declaration\n (property_name) @property.definition.declaration\n (plain_value) @value.definition.declaration) @definition.declaration\n\n(declaration\n (property_name) @property.definition.declaration\n (color_value) @value.definition.declaration) @definition.declaration\n\n(declaration\n (property_name) @property.definition.declaration\n (integer_value) @value.definition.declaration) @definition.declaration\n\n; @import\u8BED\u53E5 - \u5B57\u7B26\u4E32\u5F62\u5F0F\n(import_statement\n (string_value) @name.definition.import) @definition.import\n\n; @import\u8BED\u53E5 - url()\u51FD\u6570\u5F62\u5F0F\n(import_statement\n (call_expression\n (function_name) @func.definition.import\n (arguments\n (string_value) @name.definition.import))) @definition.import\n\n; CSS\u51FD\u6570\u8C03\u7528\uFF08\u5728\u58F0\u660E\u503C\u4E2D\uFF09\n(declaration\n (property_name) @property.definition.function\n (call_expression\n (function_name) @name.definition.function\n (arguments) @args.definition.function)) @definition.function\n\n; @keyframes\u52A8\u753B\n(keyframes_statement\n (keyframes_name) @name.definition.keyframes\n (keyframe_block_list) @body.definition.keyframes) @definition.keyframes\n\n; @media\u67E5\u8BE2 - \u652F\u6301\u4E0D\u540C\u7C7B\u578B\u7684\u67E5\u8BE2\n(media_statement\n (binary_query) @query.definition.media\n (block) @body.definition.media) @definition.media\n\n(media_statement\n (feature_query) @query.definition.media\n (block) @body.definition.media) @definition.media\n\n(media_statement\n (keyword_query) @query.definition.media\n (block) @body.definition.media) @definition.media\n`\n", "export default String.raw`\n; Module, Protocol, and Implementation definitions\n(call\n target: (identifier) @function\n (arguments) @args\n (do_block)?\n (#match? @function \"^(defmodule|defprotocol|defimpl)$\")) @definition.module\n\n; Function definitions\n(call\n target: (identifier) @function\n (arguments) @args\n (do_block)?\n (#eq? @function \"def\")) @definition.function\n\n; Macro definitions\n(call\n target: (identifier) @function\n (arguments) @args\n (do_block)?\n (#eq? @function \"defmacro\")) @definition.macro\n\n; Struct definitions\n(call\n target: (identifier) @function\n (arguments (list))\n (#eq? @function \"defstruct\")) @definition.struct\n\n; Guard definitions\n(call\n target: (identifier) @function\n (arguments) @args\n (#eq? @function \"defguard\")) @definition.guard\n\n; Behaviour callback definitions\n(call\n target: (identifier) @function\n (arguments) @args\n (#eq? @function \"@callback\")) @definition.behaviour\n\n; Sigils\n(sigil\n (sigil_name)\n (quoted_content)) @definition.sigil\n\n; Module attributes\n(unary_operator\n operator: \"@\"\n operand: (call)) @definition.attribute\n\n; Test definitions with string name and map args\n(call\n target: (identifier) @function\n (arguments\n (string)\n (map))\n (#eq? @function \"test\")) @definition.test\n\n; Pipeline operator usage\n(binary_operator\n operator: \"|>\"\n left: (_) @left\n right: (_) @right) @definition.pipeline\n\n; For comprehensions with generator and filter clauses\n(call\n target: (identifier) @function\n (arguments) @args\n (do_block)?\n (#eq? @function \"for\")) @definition.for_comprehension`\n", "export default `\n; Document structure\n(document) @definition.document\n\n; Void elements (self-closing) - using explicit element names for better readability\n; Area element\n(element\n (start_tag\n (tag_name) @name.definition.void\n (#eq? @name.definition.void \"area\"))\n (#not-has? end_tag)) @definition.void_element\n\n; Base element \n(element\n (start_tag\n (tag_name) @name.definition.void\n (#eq? @name.definition.void \"base\"))\n (#not-has? end_tag)) @definition.void_element\n\n; Line break element\n(element\n (start_tag\n (tag_name) @name.definition.void\n (#eq? @name.definition.void \"br\"))\n (#not-has? end_tag)) @definition.void_element\n\n; Column element\n(element\n (start_tag\n (tag_name) @name.definition.void\n (#eq? @name.definition.void \"col\"))\n (#not-has? end_tag)) @definition.void_element\n\n; Embed element\n(element\n (start_tag\n (tag_name) @name.definition.void\n (#eq? @name.definition.void \"embed\"))\n (#not-has? end_tag)) @definition.void_element\n\n; Horizontal rule element\n(element\n (start_tag\n (tag_name) @name.definition.void\n (#eq? @name.definition.void \"hr\"))\n (#not-has? end_tag)) @definition.void_element\n\n; Image element\n(element\n (start_tag\n (tag_name) @name.definition.void\n (#eq? @name.definition.void \"img\"))\n (#not-has? end_tag)) @definition.void_element\n\n; Input element \n(element\n (start_tag\n (tag_name) @name.definition.void\n (#eq? @name.definition.void \"input\"))\n (#not-has? end_tag)) @definition.void_element\n\n; Link element\n(element\n (start_tag\n (tag_name) @name.definition.void\n (#eq? @name.definition.void \"link\"))\n (#not-has? end_tag)) @definition.void_element\n\n; Meta element\n(element\n (start_tag\n (tag_name) @name.definition.void\n (#eq? @name.definition.void \"meta\"))\n (#not-has? end_tag)) @definition.void_element\n\n; Parameter element\n(element\n (start_tag\n (tag_name) @name.definition.void\n (#eq? @name.definition.void \"param\"))\n (#not-has? end_tag)) @definition.void_element\n\n; Source element\n(element\n (start_tag\n (tag_name) @name.definition.void\n (#eq? @name.definition.void \"source\"))\n (#not-has? end_tag)) @definition.void_element\n\n; Track element\n(element\n (start_tag\n (tag_name) @name.definition.void\n (#eq? @name.definition.void \"track\"))\n (#not-has? end_tag)) @definition.void_element\n\n; Word break opportunity element\n(element\n (start_tag\n (tag_name) @name.definition.void\n (#eq? @name.definition.void \"wbr\"))\n (#not-has? end_tag)) @definition.void_element\n\n; Elements with content (exclude script and style)\n(element\n (start_tag\n (tag_name) @name.definition)\n (#not-eq? @name.definition \"script\")\n (#not-eq? @name.definition \"style\")) @definition.element\n\n; Script elements\n(script_element\n (start_tag\n (tag_name) @name.definition)) @definition.script\n\n; Style elements\n(style_element\n (start_tag\n (tag_name) @name.definition)) @definition.style\n\n; Attributes\n(attribute\n (attribute_name) @name.definition) @definition.attribute\n\n; Comments\n(comment) @definition.comment\n\n; Text content\n(text) @definition.text\n\n; Raw text content\n(raw_text) @definition.raw_text\n\n; Self-closing tags\n(self_closing_tag\n (tag_name) @name.definition) @definition.self_closing_tag\n\n; Doctype declarations\n(doctype) @definition.doctype\n\n; Multiple elements (parent with children)\n(element\n (element)+) @definition.nested_elements\n`\n", "/*\nSupported Lua structures:\n- function definitions (global, local, and method)\n- table constructors\n- variable declarations\n- class-like structures\n*/\nexport default String.raw`\n; Function definitions\n(function_definition_statement\n name: (identifier) @name.definition.function\n parameters: (parameters) @parameters.definition.function\n body: (block) @body.definition.function) @definition.function\n\n(function_definition_statement\n name: (variable\n table: (identifier)\n field: (identifier) @name.definition.method)) @definition.method\n\n(local_function_definition_statement\n name: (identifier) @name.definition.function) @definition.function\n\n; Table constructors (class-like structures)\n(local_variable_declaration\n (variable_list\n (variable name: (identifier) @name.definition.table))\n (expression_list\n value: (table))) @definition.table\n\n; Variable declarations\n(variable_assignment\n (variable_list\n (variable name: (identifier) @name.definition.variable))) @definition.variable\n\n; Local variable declarations\n(local_variable_declaration\n (variable_list\n (variable name: (identifier) @name.definition.variable))) @definition.variable\n`\n", "export const ocamlQuery = `\n; Captures module definitions\n(module_definition\n (module_binding\n name: (module_name) @name.definition)) @definition.module\n\n; Captures type definitions\n(type_definition\n (type_binding\n name: (type_constructor) @name.definition)) @definition.type\n\n; Captures function definitions\n(value_definition\n (let_binding\n pattern: (value_name) @name.definition\n (parameter))) @definition.function\n\n; Captures class definitions\n(class_definition\n (class_binding\n name: (class_name) @name.definition)) @definition.class\n\n; Captures method definitions\n(method_definition\n name: (method_name) @name.definition) @definition.method\n\n; Captures value bindings\n(value_definition\n (let_binding\n pattern: (value_name) @name.definition)) @definition.value\n`\n", "// Query patterns for TOML syntax elements\nexport const tomlQuery = `\n; Tables - capture the entire table node\n(table) @definition\n\n; Array tables - capture the entire array table node\n(table_array_element) @definition\n\n; Key-value pairs - capture the entire pair\n(pair) @definition\n\n; Arrays and inline tables\n(array) @definition\n(inline_table) @definition\n\n; Basic values\n(string) @definition\n(integer) @definition\n(float) @definition\n(boolean) @definition\n(offset_date_time) @definition\n(local_date) @definition\n(local_time) @definition\n`\n", "/*\nSupported SystemRDL structures:\n- component declarations\n- field declarations\n- property assignments\n- parameter declarations\n- enum declarations\n*/\nexport default `\n; Component declarations\n(component_named_def\n type: (component_type)\n id: (id) @name.definition.component) @definition.component\n\n; Field declarations\n(component_anon_def\n type: (component_type (component_primary_type))\n body: (component_body\n (component_body_elem\n (property_assignment)))) @definition.field\n\n; Property declarations\n(property_definition\n (id) @name.definition.property) @definition.property\n\n; Parameter declarations\n(component_inst\n id: (id) @name.definition.parameter) @definition.parameter\n\n; Enum declarations\n(enum_def\n (id) @name.definition.enum) @definition.enum\n`\n", "/*\nSupported TLA+ structures:\n- modules with header, extends, constants, variables\n- operator definitions with parameters and bodies\n- function definitions with quantifier bounds\n- let expressions with operator definitions\n- case expressions with multiple arms\n- variable and constant declarations\n*/\nexport default `\n; Module declarations\n(module\n name: (identifier) @name.definition.module) @definition.module\n\n; Operator definitions with optional parameters\n(operator_definition\n name: (identifier) @name.definition.operator\n parameter: (identifier)?) @definition.operator\n\n; Function definitions with bounds\n(function_definition\n name: (identifier) @name.definition.function\n (quantifier_bound)?) @definition.function\n\n; Variable declarations\n(variable_declaration\n (identifier) @name.definition.variable) @definition.variable\n\n; Constant declarations\n(constant_declaration\n (identifier) @name.definition.constant) @definition.constant\n`\n", "export const zigQuery = `\n; Functions\n(function_declaration) @function.definition\n\n; Structs and containers\n(variable_declaration\n (identifier) @name\n (struct_declaration)\n) @container.definition\n\n; Enums\n(variable_declaration\n (identifier) @name\n (enum_declaration)\n) @container.definition\n\n; Variables and constants\n(variable_declaration\n (identifier) @name\n) @variable.definition\n`\n", "/*\nSupported Embedded Template structures:\n- Code blocks (class, module, method definitions)\n- Output blocks (expressions)\n- Comments\n*/\nexport default `\n; Code blocks - class, module, method definitions\n(directive\n (code) @name.definition.code) @definition.directive\n\n; Output blocks - expressions\n(output_directive\n (code) @output.content) @output\n\n; Comments - documentation and section markers\n(comment_directive\n (comment) @name.definition.comment) @definition.comment\n`\n", "// Query patterns for Emacs Lisp\nexport const elispQuery = `\n; Function definitions - capture only name and actual function node\n((function_definition\n name: (symbol) @name.definition.function) @_func\n (#match? @name.definition.function \"^[^;]\"))\n\n; Macro definitions - capture only name and actual macro node\n((macro_definition\n name: (symbol) @name.definition.macro) @_macro\n (#match? @name.definition.macro \"^[^;]\"))\n\n; Custom forms - match defcustom specifically and avoid comments\n((list\n . (symbol) @_def\n . (symbol) @name.definition.custom) @_custom\n (#eq? @_def \"defcustom\")\n (#match? @name.definition.custom \"^[^;]\"))\n\n; Face definitions - match defface specifically and avoid comments\n((list\n . (symbol) @_def\n . (symbol) @name.definition.face) @_face\n (#eq? @_def \"defface\")\n (#match? @name.definition.face \"^[^;]\"))\n\n; Group definitions - match defgroup specifically and avoid comments\n((list\n . (symbol) @_def\n . (symbol) @name.definition.group) @_group\n (#eq? @_def \"defgroup\")\n (#match? @name.definition.group \"^[^;]\"))\n\n; Advice definitions - match defadvice specifically and avoid comments\n((list\n . (symbol) @_def\n . (symbol) @name.definition.advice) @_advice\n (#eq? @_def \"defadvice\")\n (#match? @name.definition.advice \"^[^;]\"))\n`\n", "const symbolPairs: Record = {\n\t\"(\": \")\",\n\t\"[\": \"]\",\n\t\"{\": \"}\",\n\t// '<': '>',\n\t\"'\": \"'\",\n\t'\"': '\"',\n\t\"`\": \"`\",\n}\nconst openSymbols = new Set(Object.keys(symbolPairs))\nconst closeSymbols = new Set(Object.values(symbolPairs))\n\n/**\n * splitStr \u5C06 fullStr \u5206\u4E3A A \u548C B \u4E24\u4E2A\u5B57\u7B26\u4E32\uFF0C\n * \u8D1F\u8D23\u67E5\u627E B \u90E8\u5206\u4E2D\u7B2C\u4E00\u4E2A\u4E0E A \u90E8\u5206\u6700\u540E\u4E00\u4E2A\u5165\u6808\u7B26\u53F7\u5339\u914D\u7684\u95ED\u5408\u7B26\u53F7\n * @param fullStr \u5B8C\u6574\u5B57\u7B26\u4E32\n * @param splitStr \u5206\u5272\u5B57\u7B26\u4E32\n * @returns B\u90E8\u5206\u4E2D\u7B2C\u4E00\u4E2A\u5339\u914D\u7684\u95ED\u5408\u7B26\u53F7\uFF0CB \u90E8\u5206\u4E2D\u8BE5\u7B26\u53F7\u524D\u7684\u5B57\u7B26\u4E32\n */\nexport function findFirstMatchingCloseSymbol(\n\tfullStr: string,\n\tsplitStr: string,\n): { closeSymbol: string; suffixPrefix: string } {\n\tconst splitIndex = fullStr.indexOf(splitStr)\n\tif (splitIndex === -1) {\n\t\treturn { closeSymbol: \"\", suffixPrefix: \"\" }\n\t}\n\n\tconst partA = fullStr.substring(0, splitIndex)\n\tconst partB = fullStr.substring(splitIndex + splitStr.length)\n\tconst stackA: string[] = []\n\n\t// \u5904\u7406A\u90E8\u5206\u7684\u7B26\u53F7\u5165\u6808\n\tfor (let i = 0; i < partA.length; i++) {\n\t\tconst char = partA[i]\n\n\t\t// \u5904\u7406\u8F6C\u4E49\u5B57\u7B26\n\t\tif (char === \"\\\\\") {\n\t\t\ti++ // \u8DF3\u8FC7\u4E0B\u4E00\u4E2A\u5B57\u7B26\n\t\t\tcontinue\n\t\t}\n\n\t\tif (openSymbols.has(char)) {\n\t\t\t// \u5BF9\u4E8E\u5355\u5B57\u7B26\u5F15\u53F7\uFF0C\u9700\u8981\u68C0\u67E5\u6808\u9876\u662F\u5426\u5DF2\u7ECF\u662F\u76F8\u540C\u7684\u5F15\u53F7\uFF08\u8868\u793A\u95ED\u5408\uFF09\n\t\t\tif (\n\t\t\t\t(char === \"'\" || char === '\"' || char === \"`\") &&\n\t\t\t\tstackA.length > 0 &&\n\t\t\t\tstackA[stackA.length - 1] === char\n\t\t\t) {\n\t\t\t\tstackA.pop() // \u5339\u914D\u5230\u95ED\u5408\u5F15\u53F7\n\t\t\t} else {\n\t\t\t\tstackA.push(char) // \u538B\u5165\u65B0\u7684\u5F00\u7B26\u53F7\n\t\t\t}\n\t\t} else if (closeSymbols.has(char)) {\n\t\t\tif (stackA.length === 0) continue\n\t\t\tconst lastOpen = stackA[stackA.length - 1]\n\t\t\tif (symbolPairs[lastOpen] === char) {\n\t\t\t\tstackA.pop() // \u5339\u914D\u5230\u95ED\u5408\u7B26\u53F7\n\t\t\t}\n\t\t}\n\t}\n\n\tif (stackA.length === 0) {\n\t\treturn { closeSymbol: \"\", suffixPrefix: \"\" }\n\t}\n\n\tconst lastOpenSymbol = stackA[stackA.length - 1]\n\tconst expectedCloseSymbol = symbolPairs[lastOpenSymbol]\n\tconst stackB: string[] = []\n\n\t// \u5728B\u90E8\u5206\u67E5\u627E\u7B2C\u4E00\u4E2A\u5339\u914D\u7684\u95ED\u5408\u7B26\u53F7\n\tfor (let i = 0; i < partB.length; i++) {\n\t\tconst char = partB[i]\n\n\t\t// \u5904\u7406\u8F6C\u4E49\u5B57\u7B26\n\t\tif (char === \"\\\\\") {\n\t\t\ti++ // \u8DF3\u8FC7\u4E0B\u4E00\u4E2A\u5B57\u7B26\n\t\t\tcontinue\n\t\t}\n\t\t// \u68C0\u67E5\u5355\u5B57\u7B26\u95ED\u5408\u7B26\u53F7\n\t\tif (stackB.length === 0 && char === expectedCloseSymbol) {\n\t\t\treturn { closeSymbol: char, suffixPrefix: partB.slice(0, i) }\n\t\t}\n\t\tif (openSymbols.has(char)) {\n\t\t\t// \u5BF9\u4E8E\u5355\u5B57\u7B26\u5F15\u53F7\uFF0C\u9700\u8981\u68C0\u67E5\u6808\u9876\u662F\u5426\u5DF2\u7ECF\u662F\u76F8\u540C\u7684\u5F15\u53F7\uFF08\u8868\u793A\u95ED\u5408\uFF09\n\t\t\tif (\n\t\t\t\t(char === \"'\" || char === '\"' || char === \"`\") &&\n\t\t\t\tstackB.length > 0 &&\n\t\t\t\tstackB[stackB.length - 1] === char\n\t\t\t) {\n\t\t\t\tstackB.pop() // \u5339\u914D\u5230\u95ED\u5408\u5F15\u53F7\n\t\t\t} else {\n\t\t\t\tstackB.push(char) // \u538B\u5165\u65B0\u7684\u5F00\u7B26\u53F7\n\t\t\t}\n\t\t} else if (closeSymbols.has(char)) {\n\t\t\tif (stackB.length === 0) continue\n\t\t\tconst lastOpen = stackB[stackB.length - 1]\n\t\t\tif (symbolPairs[lastOpen] === char) {\n\t\t\t\tstackB.pop() // \u5339\u914D\u5230\u95ED\u5408\u7B26\u53F7\n\t\t\t}\n\t\t}\n\t}\n\n\treturn { closeSymbol: \"\", suffixPrefix: \"\" }\n}\n\n/**\n * \u67E5\u627E str1 \u7684\u540E\u7F00\u4E2D\u4E0E str2 \u7684\u524D\u7F00\u4E2D\u7684\u6700\u5927\u76F8\u540C\u5B57\u7B26\u4E32\n * @param str1 \u7B2C\u4E00\u4E2A\u5B57\u7B26\u4E32\n * @param str2 \u7B2C\u4E8C\u4E2A\u5B57\u7B26\u4E32\n * @returns \u6700\u5927\u7684\u516C\u5171\u5B50\u4E32\uFF0C\u5982\u679C\u6CA1\u6709\u5219\u8FD4\u56DE\u7A7A\u5B57\u7B26\u4E32\n */\nexport function findMaxOverlap(str1: string, str2: string): string {\n\t// \u5982\u679C\u4EFB\u4E00\u5B57\u7B26\u4E32\u4E3A\u7A7A\uFF0C\u76F4\u63A5\u8FD4\u56DE\u7A7A\u5B57\u7B26\u4E32\n\tif (str1 === \"\" || str2 === \"\") return \"\"\n\n\tlet maxOverlap = \"\"\n\n\t// \u4ECE\u53EF\u80FD\u7684\u6700\u5927\u957F\u5EA6\u5F00\u59CB\u9012\u51CF\u904D\u5386\uFF08\u6700\u5927\u4E3A min(a.length, b.length)\uFF09\n\tfor (let len = Math.min(str1.length, str2.length); len > 0; len--) {\n\t\tconst suffix = str1.substring(str1.length - len)\n\t\tconst prefix = str2.substring(0, len)\n\n\t\t// \u5982\u679C\u540E\u7F00\u7B49\u4E8E\u524D\u7F00\uFF0C\u5219\u627E\u5230\u6709\u6548\u91CD\u53E0\n\t\tif (suffix === prefix) {\n\t\t\tmaxOverlap = suffix\n\t\t\tbreak // \u627E\u5230\u6700\u5927\u91CD\u53E0\u540E\u7ACB\u5373\u9000\u51FA\u5FAA\u73AF\n\t\t}\n\t}\n\n\t// \u5982\u679C\u76F4\u63A5\u5339\u914D\u5931\u8D25\uFF0C\u5C1D\u8BD5\u53BB\u9664str2\u524D\u5BFC\u7A7A\u683C\u540E\u5339\u914D\uFF08\u4FEE\u590D\u7A7A\u683C\u5DEE\u5F02\u95EE\u9898\uFF09\n\tif (maxOverlap === \"\") {\n\t\tconst str2Trimmed = str2.trimStart()\n\n\t\tfor (let len = Math.min(str1.length, str2Trimmed.length); len > 0; len--) {\n\t\t\tconst suffix = str1.substring(str1.length - len)\n\t\t\tconst prefix = str2Trimmed.substring(0, len)\n\n\t\t\tif (suffix === prefix) {\n\t\t\t\tmaxOverlap = suffix\n\t\t\t\tbreak\n\t\t\t}\n\t\t}\n\t}\n\n\treturn maxOverlap\n}\n\n/**\n * \u83B7\u53D6\u5B57\u7B26\u4E32\u4E2D\u5728\u6307\u5B9A\u95ED\u5408\u7B26\u53F7\u524D\u7684\u5185\u5BB9\uFF0C\u5904\u7406\u7B26\u53F7\u5D4C\u5957\n * @param str \u8F93\u5165\u5B57\u7B26\u4E32\n * @param closeSymbol \u8981\u67E5\u627E\u7684\u95ED\u5408\u7B26\u53F7\n * @returns \u95ED\u5408\u7B26\u53F7\u524D\u7684\u5185\u5BB9\n */\nexport function getStringBeforeCloseSymbol(str: string, closeSymbol: string): string {\n\tif (!closeSymbols.has(closeSymbol)) {\n\t\treturn \"\"\n\t}\n\n\tconst stack: string[] = []\n\tlet result = \"\"\n\n\tfor (let i = 0; i < str.length; i++) {\n\t\tconst char = str[i]\n\n\t\t// \u5904\u7406\u8F6C\u4E49\u5B57\u7B26\n\t\tif (char === \"\\\\\") {\n\t\t\tresult += char\n\t\t\tif (i + 1 < str.length) {\n\t\t\t\tresult += str[++i]\n\t\t\t}\n\t\t\tcontinue\n\t\t}\n\n\t\t// \u68C0\u67E5\u662F\u5426\u5339\u914D\u76EE\u6807\u95ED\u5408\u7B26\u53F7\n\t\tif (stack.length === 0 && char === closeSymbol) {\n\t\t\treturn result\n\t\t}\n\n\t\t// \u5904\u7406\u5F00\u7B26\u53F7\n\t\tif (openSymbols.has(char)) {\n\t\t\t// \u5BF9\u4E8E\u5355\u5B57\u7B26\u5F15\u53F7\uFF0C\u68C0\u67E5\u6808\u9876\u662F\u5426\u76F8\u540C\n\t\t\tif (\n\t\t\t\t(char === \"'\" || char === '\"' || char === \"`\") &&\n\t\t\t\tstack.length > 0 &&\n\t\t\t\tstack[stack.length - 1] === char\n\t\t\t) {\n\t\t\t\tstack.pop()\n\t\t\t} else {\n\t\t\t\tstack.push(char)\n\t\t\t}\n\t\t}\n\t\t// \u5904\u7406\u95ED\u7B26\u53F7\n\t\telse if (closeSymbols.has(char)) {\n\t\t\tif (stack.length > 0) {\n\t\t\t\tconst lastOpen = stack[stack.length - 1]\n\t\t\t\tif (symbolPairs[lastOpen] === char) {\n\t\t\t\t\tstack.pop()\n\t\t\t\t}\n\t\t\t}\n\t\t}\n\n\t\tresult += char\n\t}\n\n\treturn result\n}\n\nexport function postProcessCompletionSynthesis(\n\tcompletion: string,\n\tprefix: string,\n\tsuffix: string,\n\tcloseSymbolChar: string,\n\tsuffixPrefixString: string,\n): string {\n\t// TODO: \u6682\u65F6\u6CE8\u91CA\u6389\u622A\u65AD\u5230\u4E00\u884C\u7684\u5B9E\u73B0\uFF0C\u6C38\u8FDC\u4FDD\u6301\u591A\u884C\n\t// \u68C0\u67E5\u662F\u5426\u9700\u8981\u622A\u65AD\u5230\u4E00\u884C\n\t// const lastLineBeforeCursor = prefix.split(\"\\n\").pop() || \"\"\n\t// const hasValidCharBeforeCursor = /\\S/.test(lastLineBeforeCursor)\n\n\t// \u5982\u679C\u6362\u884C\u524D\u6709\u6709\u6548\u5B57\u7B26\uFF0C\u622A\u65AD\u5230\u4E00\u884C\n\t// if (hasValidCharBeforeCursor) {\n\t// \t// \u5982\u679Ccompletion\u4EE5\u6362\u884C\u7B26\u5F00\u5934\uFF0C\u5148\u53BB\u6389\u5F00\u5934\u7684\u6362\u884C\u7B26\u548C\u7A7A\u767D\u5B57\u7B26\n\t// \tlet processedCompletion = completion\n\t// \tif (processedCompletion.startsWith(\"\\n\")) {\n\t// \t\tprocessedCompletion = processedCompletion.substring(1)\n\t// \t\t// \u53BB\u6389\u5F00\u5934\u7684\u7F29\u8FDB\u7A7A\u767D\uFF0C\u4F46\u4FDD\u7559\u7B2C\u4E00\u4E2A\u975E\u7A7A\u767D\u5B57\u7B26\u540E\u7684\u5185\u5BB9\n\t// \t\tprocessedCompletion = processedCompletion.replace(/^\\s*/, \"\")\n\t// \t}\n\t//\n\t// \t// \u622A\u65AD\u5230\u7B2C\u4E00\u4E2A\u6362\u884C\u7B26\n\t// \tconst firstLineIndex = processedCompletion.indexOf(\"\\n\")\n\t// \tif (firstLineIndex !== -1) {\n\t// \t\t// this.outputChannel.appendLine(\"\u622A\u65AD\u591A\u884C\u8865\u5168\u5230\u5355\u884C\")\n\t// \t\tconst truncatedCompletion = processedCompletion.substring(0, firstLineIndex)\n\t// \t\tcompletion = truncatedCompletion\n\t// \t} else {\n\t// \t\tcompletion = processedCompletion\n\t// \t}\n\t// }\n\n\t// \u4FDD\u6301\u591A\u884Ccompletion\uFF0C\u53EA\u5904\u7406\u7B26\u53F7\u5339\u914D\u548C\u91CD\u53E0\u90E8\u5206\n\tif (closeSymbolChar && closeSymbolChar.length > 0) {\n\t\tlet cutCompletion = getStringBeforeCloseSymbol(completion, closeSymbolChar)\n\t\tlet commonSubstring = findMaxOverlap(cutCompletion, suffixPrefixString)\n\t\tcompletion = cutCompletion.slice(0, cutCompletion.length - commonSubstring.length)\n\t} else {\n\t\tlet commonSubstring = findMaxOverlap(completion, suffix)\n\t\tif (commonSubstring.length >= 10) {\n\t\t\tcompletion = completion.slice(0, completion.length - commonSubstring.length)\n\t\t}\n\t}\n\treturn completion\n}\n\n/**\n * \u5224\u65AD\u5149\u6807\u662F\u5426\u5728\u5355\u8BCD\u5185\u90E8\n * @param prefix \u5149\u6807\u524D\u7684\u6587\u672C\n * @param suffix \u5149\u6807\u540E\u7684\u6587\u672C\n * @param logCallback \u53EF\u9009\u7684\u65E5\u5FD7\u56DE\u8C03\u51FD\u6570\n * @returns \u5982\u679C\u5728\u5355\u8BCD\u5185\u90E8\u8FD4\u56DEtrue\uFF0C\u5426\u5219\u8FD4\u56DEfalse\n */\nexport function isInsideWord(prefix: string, suffix: string, logCallback?: (message: string) => void): boolean {\n\t// \u4ECE prefix \u7684\u672B\u5C3E\u83B7\u53D6\u5149\u6807\u524D\u7684\u5B57\u7B26\n\tconst charBefore = prefix.length > 0 ? prefix[prefix.length - 1] : \"\"\n\t// \u4ECE suffix \u7684\u5F00\u5934\u83B7\u53D6\u5149\u6807\u540E\u7684\u6587\u672C\n\tconst charAfter = suffix.length > 0 ? suffix[0] : \"\"\n\n\t// \u68C0\u67E5\u662F\u5426\u90FD\u662F\u82F1\u6587\u5B57\u6BCD\uFF08\u5927\u5C0F\u5199\uFF09 - \u4F7F\u7528\u5B57\u7B26\u7F16\u7801\u5224\u65AD\n\tconst isLetter = (char: string): boolean => {\n\t\tif (char.length !== 1) return false\n\t\tconst code = char.charCodeAt(0)\n\t\treturn (\n\t\t\t(code >= 65 && code <= 90) || // A-Z\n\t\t\t(code >= 97 && code <= 122)\n\t\t) // a-z\n\t}\n\n\tconst hasLetterBefore = isLetter(charBefore)\n\tconst hasLetterAfter = isLetter(charAfter)\n\n\t// \u5982\u679C\u524D\u540E\u90FD\u662F\u5B57\u6BCD\uFF0C\u8BF4\u660E\u5728\u5355\u8BCD\u5185\u90E8\n\tif (hasLetterBefore && hasLetterAfter) {\n\t\tif (logCallback) {\n\t\t\tlogCallback(`Skipping completion: cursor inside word (${charBefore}|${charAfter})`)\n\t\t}\n\t\treturn true\n\t}\n\n\treturn false\n}\n", "import { SnippetType, ISnippetMeta } from \"../types\"\nimport Parser from \"web-tree-sitter\"\nimport path from \"path\"\nimport crypto from \"crypto\"\nimport { Logger } from \"../Logger\"\n\nexport function isFunctionNode(node: Parser.SyntaxNode): boolean {\n\tconst functionTypes = [\n\t\t\"function_declaration\",\n\t\t\"function_definition\", // Go\n\t\t\"method_declaration\", // Go methods\n\t\t\"method_definition\", // Class methods\n\t\t\"arrow_function\",\n\t\t\"function_expression\",\n\t]\n\treturn functionTypes.includes(node.type)\n}\n\nexport function isClassNode(node: Parser.SyntaxNode): boolean {\n\tconst classTypes = [\n\t\t\"class_declaration\",\n\t\t\"class_definition\",\n\t\t\"interface_declaration\",\n\t\t\"struct_specifier\", // C++ structs\n\t]\n\treturn classTypes.includes(node.type)\n}\n\nexport function findIdentifierInNode(node: Parser.SyntaxNode): Parser.SyntaxNode | null {\n\tconst identifierTypes = new Set([\n\t\t\"identifier\",\n\t\t\"name\",\n\t\t\"property_identifier\",\n\t\t\"field_identifier\",\n\t\t\"method_name\",\n\t\t\"function_name\",\n\t\t\"class_name\",\n\t\t\"type_identifier\",\n\t])\n\n\tfor (let i = 0; i < node.childCount; i++) {\n\t\tconst child = node.child(i)\n\t\tif (child && identifierTypes.has(child.type)) {\n\t\t\treturn child\n\t\t}\n\t}\n\n\tfor (let i = 0; i < node.childCount; i++) {\n\t\tconst child = node.child(i)\n\t\tif (child) {\n\t\t\tconst found = findIdentifierInNode(child)\n\t\t\tif (found) return found\n\t\t}\n\t}\n\n\treturn null\n}\n\nexport function isScopeNode(node: Parser.SyntaxNode): boolean {\n\tconst scopeTypes = new Set([\n\t\t\"function_declaration\",\n\t\t\"method_definition\",\n\t\t\"arrow_function\",\n\t\t\"function_expression\",\n\t\t\"class_declaration\",\n\t\t\"interface_declaration\",\n\t\t\"namespace_declaration\",\n\t\t\"module_declaration\",\n\t\t\"function_definition\",\n\t\t\"class_definition\",\n\t])\n\treturn scopeTypes.has(node.type)\n}\n\nexport function extractScopeName(node: Parser.SyntaxNode): string | null {\n\tconst identifierNode = findIdentifierInNode(node)\n\tif (identifierNode) {\n\t\treturn node.text.substring(\n\t\t\tidentifierNode.startIndex - node.startIndex,\n\t\t\tidentifierNode.endIndex - node.startIndex,\n\t\t)\n\t}\n\treturn node.type\n}\n\nexport function generateSnippetHash(filePath: string, startLine: number, endLine: number, rangeText: string): string {\n\tconst content = `${filePath}:${startLine}-${endLine}:${rangeText.substring(0, 100)}`\n\treturn crypto.createHash(\"sha256\").update(content).digest(\"hex\").substring(0, 16)\n}\n\nexport function extractSymbolName(node: Parser.SyntaxNode, sourceCode: string): string {\n\tconst identifierNode = findIdentifierInNode(node)\n\tif (identifierNode) {\n\t\treturn sourceCode.substring(identifierNode.startIndex, identifierNode.endIndex)\n\t}\n\treturn `${node.type}_${node.startPosition.row + 1}`\n}\n\nexport function buildScopeChain(node: Parser.SyntaxNode): string[] {\n\tconst scope: string[] = []\n\tlet current = node.parent\n\n\twhile (current) {\n\t\tif (isScopeNode(current)) {\n\t\t\tconst scopeName = extractScopeName(current)\n\t\t\tif (scopeName) {\n\t\t\t\tscope.unshift(scopeName)\n\t\t\t}\n\t\t}\n\t\tcurrent = current.parent\n\t}\n\n\treturn scope\n}\n\n/**\n * \u6839\u636E Query \u6355\u83B7\u786E\u5B9A snippet \u7C7B\u578B\n */\nexport function determineSnippetTypeFromCapture(\n\tcapture: Parser.QueryCapture,\n\tallowedTypes: SnippetType[],\n): SnippetType {\n\t// \u6839\u636E capture \u540D\u79F0\u6620\u5C04\u7C7B\u578B\n\tconst captureTypeMap: Record = {\n\t\timport: SnippetType.ImportOrInclude,\n\t\t\"import.statement\": SnippetType.ImportOrInclude,\n\t\t\"function.definition\": SnippetType.FunctionOrMethod,\n\t\t\"class.definition\": SnippetType.ClassOrInterfaceOrStructOrEnum,\n\t\t\"method.definition\": SnippetType.FunctionOrMethod,\n\t\t\"variable.definition\": SnippetType.VariableOrConstant,\n\t}\n\n\tconst mappedType = captureTypeMap[capture.name]\n\tif (mappedType && allowedTypes.includes(mappedType)) {\n\t\treturn mappedType\n\t}\n\n\t// \u6839\u636E\u8282\u70B9\u7C7B\u578B\u5224\u65AD\n\tif (capture.node.type.includes(\"import\") && allowedTypes.includes(SnippetType.ImportOrInclude)) {\n\t\treturn SnippetType.ImportOrInclude\n\t}\n\n\tif (isFunctionNode(capture.node) && allowedTypes.includes(SnippetType.FunctionOrMethod)) {\n\t\treturn SnippetType.FunctionOrMethod\n\t}\n\n\tif (isClassNode(capture.node) && allowedTypes.includes(SnippetType.ClassOrInterfaceOrStructOrEnum)) {\n\t\treturn SnippetType.ClassOrInterfaceOrStructOrEnum\n\t}\n\n\t// \u9ED8\u8BA4\u4F7F\u7528\u7B2C\u4E00\u4E2A\u5141\u8BB8\u7684\u7C7B\u578B\n\treturn allowedTypes[0]\n}\n\nexport function createSnippetFromQueryCapture(\n\tcapture: Parser.QueryCapture,\n\tallCaptures: Parser.QueryCapture[],\n\tsourceCode: string,\n\tlines: string[],\n\tfilePath: string,\n\tfileHash: string,\n\tsnippetTypes: SnippetType[],\n\toptions: { maxSnippetLines: number; minSnippetLines: number },\n\tseenHashes: Set,\n): ISnippetMeta | null {\n\tconst node = capture.node\n\tconst startLine = node.startPosition.row + 1\n\tconst endLine = node.endPosition.row + 1\n\tconst startColumn = node.startPosition.column\n\tconst endColumn = node.endPosition.column\n\tconst lineCount = endLine - startLine + 1\n\n\tif (lineCount < Math.max(1, options.minSnippetLines - 2) || lineCount > options.maxSnippetLines * 2) {\n\t\treturn null\n\t}\n\n\tconst rangeText = sourceCode.substring(node.startIndex, node.endIndex)\n\n\tconst snippetHash = generateSnippetHash(filePath, startLine, endLine, rangeText)\n\tif (seenHashes.has(snippetHash)) {\n\t\treturn null\n\t}\n\tseenHashes.add(snippetHash)\n\n\tconst name = extractSymbolName(node, sourceCode)\n\tconst scope = buildScopeChain(node)\n\n\t// \uD83D\uDD27 \u6839\u636E capture \u540D\u79F0\u548C\u8282\u70B9\u7C7B\u578B\u786E\u5B9A snippet \u7C7B\u578B\n\tconst snippetType = determineSnippetTypeFromCapture(capture, snippetTypes)\n\n\treturn {\n\t\tname,\n\t\ttype: snippetType,\n\t\tfilePath,\n\t\tstartLine,\n\t\tendLine,\n\t\tstartColumn,\n\t\tendColumn,\n\t\trangeText,\n\t\tscope,\n\t\tfileHash,\n\t}\n}\n\nexport async function extractSnippetsFromCapturesForGeneral(\n\tcaptures: Parser.QueryCapture[],\n\tsourceCode: string,\n\tfilePath: string,\n\tfileHash: string,\n\tsnippetTypes: SnippetType[],\n\toptions: { maxSnippetLines: number; minSnippetLines: number },\n): Promise {\n\tconst logger = Logger.getDefaultLogger().with(\"[extractSnippetsFromCapturesForGeneral]\")\n\tconst snippets: ISnippetMeta[] = []\n\tconst seenHashes = new Set()\n\tconst lines = sourceCode.split(\"\\n\")\n\n\ttry {\n\t\tlogger.info(`[CodeContext] Starting query execution for: ${path.basename(filePath)}`)\n\n\t\t// const captures = query.captures(tree.rootNode)\n\t\tlogger.info(`[CodeContext] Query found ${captures.length} captures`)\n\n\t\t// \u6309\u6355\u83B7\u7C7B\u578B\u5206\u7EC4\n\t\tconst capturesByType = new Map()\n\t\tcaptures.forEach((capture) => {\n\t\t\tconst captureType = capture.name\n\t\t\tif (!capturesByType.has(captureType)) {\n\t\t\t\tcapturesByType.set(captureType, [])\n\t\t\t}\n\t\t\tcapturesByType.get(captureType)!.push(capture)\n\t\t})\n\n\t\tlogger.info(`[CodeContext] Capture types found:`, Array.from(capturesByType.keys()))\n\n\t\t// \u5904\u7406\u6240\u6709\u627E\u5230\u7684\u6355\u83B7\n\t\tfor (const [captureType, captureList] of capturesByType) {\n\t\t\tlogger.info(`[CodeContext] Processing ${captureList.length} ${captureType} captures`)\n\n\t\t\tfor (const capture of captureList) {\n\t\t\t\tconst snippet = createSnippetFromQueryCapture(\n\t\t\t\t\tcapture,\n\t\t\t\t\tcaptures,\n\t\t\t\t\tsourceCode,\n\t\t\t\t\tlines,\n\t\t\t\t\tfilePath,\n\t\t\t\t\tfileHash,\n\t\t\t\t\tsnippetTypes,\n\t\t\t\t\toptions,\n\t\t\t\t\tseenHashes,\n\t\t\t\t)\n\n\t\t\t\tif (snippet) {\n\t\t\t\t\tsnippets.push(snippet)\n\t\t\t\t\tlogger.info(\n\t\t\t\t\t\t`\"[CodeContext] Created snippet: ${snippet.name} (${snippet.startLine}-${snippet.endLine}) from ${captureType}`,\n\t\t\t\t\t)\n\t\t\t\t}\n\t\t\t}\n\t\t}\n\n\t\tlogger.info(`[CodeContext] Total snippets extracted: ${snippets.length}`)\n\t} catch (error) {\n\t\tlogger.error(`[CodeContext] Error executing query:`, error)\n\t}\n\n\treturn snippets\n}\n", "import { ILogger, LogLevel } from \"./types\"\n\nconst logLevelPriorityMap = {\n\t[LogLevel.Debug]: 0,\n\t[LogLevel.Info]: 1,\n\t[LogLevel.Warn]: 2,\n\t[LogLevel.Error]: 3,\n}\n\nexport class Logger implements ILogger {\n\tprivate static _instance: Logger | null = null\n\tprefix: string = \"\"\n\tlevel: LogLevel = LogLevel.Warn\n\n\tconstructor(prefix?: string, level?: LogLevel) {\n\t\tif (prefix) {\n\t\t\tthis.prefix = prefix\n\t\t}\n\t\tif (level) {\n\t\t\tthis.level = level\n\t\t}\n\t}\n\n\tstatic getDefaultLogger(): ILogger {\n\t\tif (!Logger._instance) {\n\t\t\tLogger._instance = new Logger()\n\t\t}\n\t\treturn Logger._instance\n\t}\n\n\tstatic setDefaultLogger(logger: ILogger) {\n\t\tLogger._instance = logger\n\t}\n\n\tdebug(message?: any, ...optionalParams: any[]): void {\n\t\tif (logLevelPriorityMap[this.level] <= logLevelPriorityMap[LogLevel.Debug]) {\n\t\t\tconsole.debug(`${this.prefix}${message} ${optionalParams.join(\" \")}`)\n\t\t}\n\t}\n\tinfo(message?: any, ...optionalParams: any[]): void {\n\t\tif (logLevelPriorityMap[this.level] <= logLevelPriorityMap[LogLevel.Info]) {\n\t\t\tconsole.log(`${this.prefix}${message} ${optionalParams.join(\" \")}`)\n\t\t}\n\t}\n\twarn(message?: any, ...optionalParams: any[]): void {\n\t\tif (logLevelPriorityMap[this.level] <= logLevelPriorityMap[LogLevel.Warn]) {\n\t\t\tconsole.warn(`${this.prefix}${message} ${optionalParams.join(\" \")}`)\n\t\t}\n\t}\n\terror(message?: any, ...optionalParams: any[]): void {\n\t\tif (logLevelPriorityMap[this.level] <= logLevelPriorityMap[LogLevel.Error]) {\n\t\t\tconsole.error(`${this.prefix}${message} ${optionalParams.join(\" \")}`)\n\t\t}\n\t}\n\twith(prefix: string): ILogger {\n\t\treturn new Logger(this.prefix + prefix + \" \")\n\t}\n}\n", "import { SnippetType, ISnippetMeta, ParameterInfo, CodeLanguageType } from \"../types\"\nimport Parser from \"web-tree-sitter\"\nimport { generateSnippetHash, buildScopeChain } from \"./general\"\nimport { Logger } from \"../Logger\"\n\nexport async function extractSnippetsFromCapturesForGo(\n\tcaptures: Parser.QueryCapture[],\n\tsourceCode: string,\n\tfilePath: string,\n\tfileHash: string,\n\tsnippetTypes: SnippetType[],\n\toptions: { maxSnippetLines: number; minSnippetLines: number },\n): Promise {\n\tconst logger = Logger.getDefaultLogger().with(\"[extractSnippetsFromCapturesForGo]\")\n\n\tconst snippets: ISnippetMeta[] = []\n\tconst seenHashes = new Set()\n\n\tif (snippetTypes.length === 0) {\n\t\tlogger.warn(`No snippet types provided, skipping`)\n\t\treturn snippets\n\t}\n\n\tconst functionCaptureNames = new Set([\n\t\t\"name.definition.function\",\n\t\t\"name.definition.method\",\n\t\t\"parameters.definition.function\",\n\t\t\"body.definition.function\",\n\t\t\"definition.function\",\n\t])\n\tconst functionNodeMap = new Map()\n\n\tcaptures.forEach((capture) => {\n\t\tif (functionCaptureNames.has(capture.name)) {\n\t\t\tconst node = capture.node\n\t\t\tconst key = `${node.startIndex}:${node.endIndex}`\n\t\t\tif (!functionNodeMap.has(key)) {\n\t\t\t\tfunctionNodeMap.set(key, capture)\n\t\t\t}\n\t\t}\n\t})\n\n\t// \u5904\u7406 import\n\tcaptures.forEach((capture) => {\n\t\tif (capture.name === \"name.definition.import\") {\n\t\t\tconst node = capture.node\n\t\t\tconst startLine = node.startPosition.row + 1\n\t\t\tconst endLine = node.endPosition.row + 1\n\t\t\tconst rangeText = sourceCode.substring(node.startIndex, node.endIndex)\n\t\t\tconst snippetHash = generateSnippetHash(filePath, startLine, endLine, rangeText)\n\t\t\tif (seenHashes.has(snippetHash)) return\n\t\t\tseenHashes.add(snippetHash)\n\t\t\tconst name = sourceCode.substring(node.startIndex, node.endIndex)\n\t\t\tconst scope = buildScopeChain(node)\n\t\t\tsnippets.push({\n\t\t\t\tname,\n\t\t\t\ttype: SnippetType.ImportOrInclude,\n\t\t\t\tfilePath,\n\t\t\t\tstartLine,\n\t\t\t\tendLine,\n\t\t\t\trangeText,\n\t\t\t\tdefinitionText: rangeText,\n\t\t\t\tscope,\n\t\t\t\tfileHash,\n\t\t\t})\n\t\t}\n\t})\n\n\t// \u5904\u7406 function/method\n\tfor (const capture of captures) {\n\t\tif (capture.name !== \"definition.function\" && capture.name !== \"definition.method\") continue\n\t\tconst node = capture.node\n\t\tconst startLine = node.startPosition.row + 1\n\t\tconst endLine = node.endPosition.row + 1\n\n\t\t// \u5224\u65AD\u662F function \u8FD8\u662F method\n\t\tconst isMethod = capture.name === \"definition.method\"\n\t\tconst nameCap = captures.find(\n\t\t\t(c) =>\n\t\t\t\tc.name === (isMethod ? \"name.definition.method\" : \"name.definition.function\") &&\n\t\t\t\tc.node.startIndex >= node.startIndex &&\n\t\t\t\tc.node.endIndex <= node.endIndex,\n\t\t)\n\t\tif (!nameCap) continue\n\t\tconst name = sourceCode.substring(nameCap.node.startIndex, nameCap.node.endIndex)\n\n\t\tconst paramCaps = captures.filter(\n\t\t\t(c) =>\n\t\t\t\tc.name === (isMethod ? \"parameters.definition.method\" : \"parameters.definition.function\") &&\n\t\t\t\tc.node.startIndex >= node.startIndex &&\n\t\t\t\tc.node.endIndex <= node.endIndex,\n\t\t)\n\t\tconst parameters: ParameterInfo[] = paramCaps.map((paramCap) => ({\n\t\t\tname: sourceCode.substring(paramCap.node.startIndex, paramCap.node.endIndex),\n\t\t}))\n\n\t\tconst bodyCap = captures.find(\n\t\t\t(c) =>\n\t\t\t\tc.name === (isMethod ? \"body.definition.method\" : \"body.definition.function\") &&\n\t\t\t\tc.node.startIndex >= node.startIndex &&\n\t\t\t\tc.node.endIndex <= node.endIndex,\n\t\t)\n\n\t\tlet rangeText: string\n\t\tlet implementText: string | undefined = undefined\n\t\tif (bodyCap) {\n\t\t\trangeText = sourceCode.substring(node.startIndex, bodyCap.node.startIndex).trimEnd()\n\t\t\timplementText = sourceCode.substring(node.startIndex, node.endIndex)\n\t\t} else {\n\t\t\trangeText = sourceCode.substring(node.startIndex, node.endIndex)\n\t\t}\n\n\t\tconst snippetHash = generateSnippetHash(filePath, startLine, endLine, rangeText)\n\t\tif (seenHashes.has(snippetHash)) continue\n\t\tseenHashes.add(snippetHash)\n\n\t\t// \u67E5\u627E returnType\uFF08result.definition.function/method\uFF09\n\t\tconst resultCap = captures.find(\n\t\t\t(c) =>\n\t\t\t\tc.name === (isMethod ? \"result.definition.method\" : \"result.definition.function\") &&\n\t\t\t\tc.node.startIndex >= node.startIndex &&\n\t\t\t\tc.node.endIndex <= node.endIndex,\n\t\t)\n\t\tlet returnType = \"\"\n\t\tif (resultCap) {\n\t\t\treturnType = sourceCode.substring(resultCap.node.startIndex, resultCap.node.endIndex).trim()\n\t\t}\n\n\t\tconst paramStr = parameters.map((p) => p.name).join(\", \")\n\t\tconst signature = `${name}(${paramStr})`\n\t\tconst scope = buildScopeChain(node)\n\n\t\t// \u63D0\u53D6 field/class \u540D\u79F0\uFF08\u4EC5 method \u6709\uFF09\n\t\tlet field: string | undefined = undefined\n\t\tif (isMethod) {\n\t\t\tconst selfCap = captures.find(\n\t\t\t\t(c) =>\n\t\t\t\t\tc.name === \"self.definition.method\" &&\n\t\t\t\t\tc.node.startIndex >= node.startIndex &&\n\t\t\t\t\tc.node.endIndex <= node.endIndex,\n\t\t\t)\n\t\t\tif (selfCap) {\n\t\t\t\t// Go query: (type_identifier) @class.definition.method\n\t\t\t\tconst classCap = captures.find(\n\t\t\t\t\t(c) =>\n\t\t\t\t\t\tc.name === \"class.definition.method\" &&\n\t\t\t\t\t\tc.node.startIndex >= selfCap.node.startIndex &&\n\t\t\t\t\t\tc.node.endIndex <= selfCap.node.endIndex,\n\t\t\t\t)\n\t\t\t\tif (classCap) {\n\t\t\t\t\tfield = sourceCode.substring(classCap.node.startIndex, classCap.node.endIndex)\n\t\t\t\t}\n\t\t\t}\n\t\t}\n\n\t\tsnippets.push({\n\t\t\tname,\n\t\t\ttype: SnippetType.FunctionOrMethod,\n\t\t\tfilePath,\n\t\t\tstartLine,\n\t\t\tendLine,\n\t\t\trangeText,\n\t\t\tdefinitionText: rangeText,\n\t\t\tscope,\n\t\t\tfileHash,\n\t\t\tfield,\n\t\t\tdefinition: {\n\t\t\t\tname,\n\t\t\t\ttype: node.type,\n\t\t\t\tparameters,\n\t\t\t\treturnType,\n\t\t\t},\n\t\t\tparameters,\n\t\t\tsignature,\n\t\t\tlanguage: CodeLanguageType.Go,\n\t\t\t...(implementText ? { implementText } : {}),\n\t\t})\n\t}\n\n\t// \u5904\u7406 struct/interface/type\n\tconst typeDefs = [\n\t\t{ capture: \"name.definition.struct\", outlineType: \"struct\" },\n\t\t{ capture: \"name.definition.interface\", outlineType: \"interface\" },\n\t\t{ capture: \"name.definition.type\", outlineType: \"type\" },\n\t]\n\tfor (const { capture, outlineType } of typeDefs) {\n\t\tconst defCaptureName = `definition.${outlineType}`\n\t\tfor (const cap of captures.filter((c) => c.name === capture)) {\n\t\t\tconst node = cap.node\n\t\t\t// \u5224\u65AD\u662F\u5426\u5728\u51FD\u6570/\u65B9\u6CD5\u5185\n\t\t\tconst isInFunc = captures.some(\n\t\t\t\t(fc) =>\n\t\t\t\t\t(fc.name === \"definition.function\" || fc.name === \"definition.method\") &&\n\t\t\t\t\tfc.node.startIndex < node.startIndex &&\n\t\t\t\t\tnode.endIndex < fc.node.endIndex,\n\t\t\t)\n\t\t\tif (isInFunc) continue\n\t\t\t// \u4F18\u5148\u7528 @definition.xxx \u533A\u95F4\n\t\t\tconst defCap = captures.find(\n\t\t\t\t(c) =>\n\t\t\t\t\tc.name === defCaptureName &&\n\t\t\t\t\tc.node.startIndex <= node.startIndex &&\n\t\t\t\t\tnode.endIndex <= c.node.endIndex,\n\t\t\t)\n\t\t\tconst rangeText = defCap\n\t\t\t\t? sourceCode.substring(defCap.node.startIndex, defCap.node.endIndex)\n\t\t\t\t: sourceCode.substring(node.startIndex, node.endIndex)\n\t\t\tconst startLine = node.startPosition.row + 1\n\t\t\tconst endLine = node.endPosition.row + 1\n\t\t\tconst snippetHash = generateSnippetHash(filePath, startLine, endLine, rangeText)\n\t\t\tif (seenHashes.has(snippetHash)) continue\n\t\t\tseenHashes.add(snippetHash)\n\t\t\tconst name = sourceCode.substring(node.startIndex, node.endIndex)\n\t\t\tsnippets.push({\n\t\t\t\tname,\n\t\t\t\ttype: SnippetType.ClassOrInterfaceOrStructOrEnum,\n\t\t\t\tfilePath,\n\t\t\t\tstartLine,\n\t\t\t\tendLine,\n\t\t\t\trangeText,\n\t\t\t\tdefinitionText: rangeText,\n\t\t\t\timplementText: rangeText,\n\t\t\t\tscope: [],\n\t\t\t\tfileHash,\n\t\t\t\tfield: \"\",\n\t\t\t\tdefinition: { name, type: outlineType },\n\t\t\t\tlanguage: CodeLanguageType.Go,\n\t\t\t})\n\t\t}\n\t}\n\n\t// \u5904\u7406 const/var\uFF08\u5168\u5C40\u53D8\u91CF/\u5E38\u91CF\uFF09\n\tconst varDefs = [\n\t\t{ capture: \"name.definition.const\", outlineType: \"const\" },\n\t\t{ capture: \"name.definition.var\", outlineType: \"var\" },\n\t]\n\tfor (const { capture, outlineType } of varDefs) {\n\t\tconst defCaptureName = `definition.${outlineType}`\n\t\tfor (const cap of captures.filter((c) => c.name === capture)) {\n\t\t\tconst node = cap.node\n\t\t\t// \u5224\u65AD\u662F\u5426\u5728\u51FD\u6570/\u65B9\u6CD5\u5185\n\t\t\tconst isInFunc = captures.some(\n\t\t\t\t(fc) =>\n\t\t\t\t\t(fc.name === \"definition.function\" || fc.name === \"definition.method\") &&\n\t\t\t\t\tfc.node.startIndex < node.startIndex &&\n\t\t\t\t\tnode.endIndex < fc.node.endIndex,\n\t\t\t)\n\t\t\tif (isInFunc) continue\n\t\t\t// \u4F18\u5148\u7528 @definition.xxx \u533A\u95F4\n\t\t\tconst defCap = captures.find(\n\t\t\t\t(c) =>\n\t\t\t\t\tc.name === defCaptureName &&\n\t\t\t\t\tc.node.startIndex <= node.startIndex &&\n\t\t\t\t\tnode.endIndex <= c.node.endIndex,\n\t\t\t)\n\t\t\tconst rangeText = defCap\n\t\t\t\t? sourceCode.substring(defCap.node.startIndex, defCap.node.endIndex)\n\t\t\t\t: sourceCode.substring(node.startIndex, node.endIndex)\n\t\t\tconst startLine = node.startPosition.row + 1\n\t\t\tconst endLine = node.endPosition.row + 1\n\t\t\tconst snippetHash = generateSnippetHash(filePath, startLine, endLine, rangeText)\n\t\t\tif (seenHashes.has(snippetHash)) continue\n\t\t\tseenHashes.add(snippetHash)\n\t\t\tconst name = sourceCode.substring(node.startIndex, node.endIndex)\n\t\t\tsnippets.push({\n\t\t\t\tname,\n\t\t\t\ttype: SnippetType.VariableOrConstant,\n\t\t\t\tfilePath,\n\t\t\t\tstartLine,\n\t\t\t\tendLine,\n\t\t\t\trangeText,\n\t\t\t\tdefinitionText: rangeText,\n\t\t\t\timplementText: rangeText,\n\t\t\t\tscope: [],\n\t\t\t\tfileHash,\n\t\t\t\tfield: \"\",\n\t\t\t\tdefinition: { name, type: outlineType },\n\t\t\t\tlanguage: CodeLanguageType.Go,\n\t\t\t})\n\t\t}\n\t}\n\n\t// filter snippets by snippetTypes\n\treturn snippets.filter((snippet) => snippetTypes.includes(snippet.type)).sort((a, b) => a.startLine - b.startLine)\n}\n\n// VSCode Outline Entry \u7C7B\u578B\nexport interface OutlineEntry {\n\ttype: string\n\tname: string\n\tfile: string // \u8868\u793A\u5F53\u524D\u6587\u4EF6\n\tfield?: string // \u7A7A\u5B57\u7B26\u4E32\u4EE3\u8868\u5F53\u524D\u6587\u4EF6\u7684global\n\tdescription?: string\n}\n\n/**\n * \u6839\u636E Go \u6587\u4EF6\u7684\u6240\u6709 snippet \u751F\u6210\u5927\u7EB2\uFF08Outline\uFF09\uFF0C\u652F\u6301 import\u3001const\u3001var\u3001function\u3001method\uFF08\u5E26 field\uFF09\u3001\u5168\u5C40\u53D8\u91CF\n */\nexport function buildSummaryFromSnippets(snippets: ISnippetMeta[]): OutlineEntry[] {\n\tconst outline: OutlineEntry[] = []\n\n\t// \u53EA\u4FDD\u7559\u5168\u5C40\u5B9A\u4E49\uFF08scope \u4E3A\u7A7A\u6216\u5168\u4E3A \"\"\uFF09\n\tconst isGlobal = (s: ISnippetMeta) => !s.scope || s.scope.length === 0 || s.scope.every((x) => !x)\n\n\tfor (const s of snippets) {\n\t\tif (!isGlobal(s)) continue\n\t\tif (s.type === SnippetType.ImportOrInclude) {\n\t\t\toutline.push({\n\t\t\t\ttype: \"import\",\n\t\t\t\tname: s.name,\n\t\t\t\tfile: s.filePath,\n\t\t\t\tfield: \"\",\n\t\t\t\tdescription: s.definitionText,\n\t\t\t})\n\t\t} else if (s.type === SnippetType.FunctionOrMethod) {\n\t\t\tif (s.field) {\n\t\t\t\toutline.push({\n\t\t\t\t\ttype: \"method\",\n\t\t\t\t\tname: s.name,\n\t\t\t\t\tfile: s.filePath,\n\t\t\t\t\tfield: s.field,\n\t\t\t\t\tdescription: s.definitionText,\n\t\t\t\t})\n\t\t\t} else {\n\t\t\t\toutline.push({\n\t\t\t\t\ttype: \"function\",\n\t\t\t\t\tname: s.name,\n\t\t\t\t\tfile: s.filePath,\n\t\t\t\t\tfield: \"\",\n\t\t\t\t\tdescription: s.definitionText,\n\t\t\t\t})\n\t\t\t}\n\t\t} else if (s.type === SnippetType.VariableOrConstant) {\n\t\t\tconst t = s.definition?.type === \"const\" ? \"const\" : \"var\"\n\t\t\toutline.push({\n\t\t\t\ttype: t,\n\t\t\t\tname: s.name,\n\t\t\t\tfile: s.filePath,\n\t\t\t\tfield: \"\",\n\t\t\t\tdescription: s.definitionText,\n\t\t\t})\n\t\t} else if (s.type === SnippetType.ClassOrInterfaceOrStructOrEnum) {\n\t\t\tconst t = s.definition?.type || \"type\"\n\t\t\toutline.push({\n\t\t\t\ttype: t,\n\t\t\t\tname: s.name,\n\t\t\t\tfile: s.filePath,\n\t\t\t\tfield: \"\",\n\t\t\t\tdescription: s.definitionText,\n\t\t\t})\n\t\t}\n\t\t// \u53EF\u6269\u5C55 channel/goroutine \u7B49\n\t}\n\n\treturn outline\n}\n\n/**\n * \u5C06 OutlineEntry[] \u683C\u5F0F\u5316\u4E3A\u6587\u672C\uFF0C\u540C\u4E00\u4E2A field \u7684\u653E\u5728\u4E00\u8D77\u3002\n * @param outline OutlineEntry[]\n * @returns string\n */\nexport function formatOutlineText(outline: OutlineEntry[]): string {\n\t// \u6309 field \u5206\u7EC4\n\tconst groups: Record = {}\n\tfor (const entry of outline) {\n\t\tconst key = entry.field ?? \"\"\n\t\tif (!groups[key]) groups[key] = []\n\t\tgroups[key].push(entry)\n\t}\n\n\t// \u5408\u6210\u6587\u672C\n\tlet result = \"\"\n\tfor (const field of Object.keys(groups).sort()) {\n\t\tconst group = groups[field]\n\t\tconst title = field === \"\" ? \"[global]\" : `[${field}]`\n\t\tresult += title + \"\\n\"\n\t\tfor (const entry of group) {\n\t\t\tlet line = ` ${entry.type}`\n\t\t\tif (entry.description) line += `: ${entry.description.replace(/\\n/g, \" \")}`\n\t\t\tresult += line + \"\\n\"\n\t\t}\n\t\tresult += \"\\n\"\n\t}\n\treturn result.trimEnd()\n}\n", "import { SnippetType, ISnippetMeta, ParameterInfo, CodeLanguageType } from \"../types\"\nimport Parser from \"web-tree-sitter\"\nimport { generateSnippetHash, buildScopeChain } from \"./general\"\n\nexport async function extractSnippetsFromCapturesForPython(\n\tcaptures: Parser.QueryCapture[],\n\tsourceCode: string,\n\tfilePath: string,\n\tfileHash: string,\n\tsnippetTypes: SnippetType[],\n\toptions: { maxSnippetLines: number; minSnippetLines: number },\n): Promise {\n\tconst snippets: ISnippetMeta[] = []\n\tconst seenHashes = new Set()\n\n\t// --- \u6536\u96C6\u6240\u6709 class captures \u7528\u4E8E\u786E\u5B9A field ---\n\tconst classCaptures = captures\n\t\t.filter((c) => c.name === \"definition.class\")\n\t\t.map((c) => ({\n\t\t\tnode: c.node,\n\t\t\tstart: c.node.startIndex,\n\t\t\tend: c.node.endIndex,\n\t\t\tnameCap: captures.find(\n\t\t\t\t(nc) =>\n\t\t\t\t\tnc.name === \"name.definition.class\" &&\n\t\t\t\t\tnc.node.startIndex >= c.node.startIndex &&\n\t\t\t\t\tnc.node.endIndex <= c.node.endIndex,\n\t\t\t),\n\t\t}))\n\n\t// --- Function/Method ---\n\tfor (const capture of captures) {\n\t\tif (capture.name !== \"definition.function\") continue\n\t\tconst node = capture.node\n\t\tconst startLine = node.startPosition.row + 1\n\t\tconst endLine = node.endPosition.row + 1\n\n\t\t// \u67E5\u627E\u51FD\u6570\u540D\n\t\tconst nameCap = captures.find(\n\t\t\t(c) =>\n\t\t\t\tc.name === \"name.definition.function\" &&\n\t\t\t\tc.node.startIndex >= node.startIndex &&\n\t\t\t\tc.node.endIndex <= node.endIndex,\n\t\t)\n\t\tif (!nameCap) continue\n\t\tconst name = sourceCode.substring(nameCap.node.startIndex, nameCap.node.endIndex)\n\n\t\t// \u67E5\u627E\u53C2\u6570\n\t\tconst paramCap = captures.find(\n\t\t\t(c) =>\n\t\t\t\tc.name === \"parameters.definition.function\" &&\n\t\t\t\tc.node.startIndex >= node.startIndex &&\n\t\t\t\tc.node.endIndex <= node.endIndex,\n\t\t)\n\n\t\tconst parameters: ParameterInfo[] = []\n\t\tif (paramCap) {\n\t\t\tconst paramText = sourceCode.substring(paramCap.node.startIndex, paramCap.node.endIndex)\n\t\t\tconst cleanParams = paramText.replace(/^\\(|\\)$/g, \"\").trim()\n\t\t\tif (cleanParams) {\n\t\t\t\t// Python\u53C2\u6570\u89E3\u6790 - \u5904\u7406\u9ED8\u8BA4\u53C2\u6570\u3001\u7C7B\u578B\u6CE8\u89E3\u7B49\n\t\t\t\tconst paramList = splitPythonParameters(cleanParams)\n\t\t\t\tparameters.push(...paramList.map((param) => ({ name: param })))\n\t\t\t}\n\t\t}\n\n\t\t// \u67E5\u627E\u51FD\u6570\u4F53\n\t\tconst bodyCap = captures.find(\n\t\t\t(c) =>\n\t\t\t\tc.name === \"body.definition.function\" &&\n\t\t\t\tc.node.startIndex >= node.startIndex &&\n\t\t\t\tc.node.endIndex <= node.endIndex,\n\t\t)\n\n\t\t// \u751F\u6210\u51FD\u6570\u7B7E\u540D\u4F5C\u4E3A\u5B9A\u4E49\u6587\u672C\n\t\tlet definitionText: string\n\t\tlet implementText: string | undefined = undefined\n\n\t\tif (bodyCap) {\n\t\t\t// \u4ECE\u51FD\u6570\u5F00\u59CB\u5230\u51FD\u6570\u4F53\u5F00\u59CB\uFF08\u4E0D\u5305\u62EC\u51FD\u6570\u4F53\uFF09\n\t\t\tconst functionHeader = sourceCode.substring(node.startIndex, bodyCap.node.startIndex).trimEnd()\n\t\t\t// \u786E\u4FDD\u4EE5\u5192\u53F7\u7ED3\u5C3E\n\t\t\tdefinitionText = functionHeader.endsWith(\":\") ? functionHeader : functionHeader + \":\"\n\t\t\timplementText = sourceCode.substring(node.startIndex, node.endIndex)\n\t\t} else {\n\t\t\t// \u5982\u679C\u6CA1\u6709\u51FD\u6570\u4F53\uFF0C\u4F7F\u7528\u6574\u4E2A\u8282\u70B9\u5185\u5BB9\n\t\t\tdefinitionText = sourceCode.substring(node.startIndex, node.endIndex)\n\t\t}\n\n\t\tconst rangeText = sourceCode.substring(node.startIndex, node.endIndex)\n\n\t\t// \u786E\u5B9A\u662F\u5426\u5C5E\u4E8E\u67D0\u4E2A\u7C7B\uFF08\u8BBE\u7F6Efield\uFF09\n\t\tlet field: string | undefined = undefined\n\t\tfor (const cls of classCaptures) {\n\t\t\tif (node.startIndex > cls.start && node.endIndex <= cls.end && cls.nameCap) {\n\t\t\t\tfield = sourceCode.substring(cls.nameCap.node.startIndex, cls.nameCap.node.endIndex)\n\t\t\t\tbreak\n\t\t\t}\n\t\t}\n\n\t\tconst snippetHash = generateSnippetHash(filePath, startLine, endLine, rangeText)\n\t\tif (seenHashes.has(snippetHash)) continue\n\t\tseenHashes.add(snippetHash)\n\n\t\tconst paramStr = parameters.map((p) => p.name).join(\", \")\n\t\tconst signature = `${name}(${paramStr})`\n\t\tconst scope = buildScopeChain(node)\n\n\t\t// \u68C0\u6D4B\u51FD\u6570\u7C7B\u578B\n\t\tlet functionType = \"function\"\n\t\tconst nodeText = sourceCode.substring(node.startIndex, Math.min(node.startIndex + 100, node.endIndex))\n\t\tif (nodeText.includes(\"async def\")) functionType = \"async function\"\n\t\tif (field) functionType = \"method\"\n\n\t\tsnippets.push({\n\t\t\tname,\n\t\t\ttype: SnippetType.FunctionOrMethod,\n\t\t\tfilePath,\n\t\t\tstartLine,\n\t\t\tendLine,\n\t\t\trangeText,\n\t\t\tdefinitionText,\n\t\t\tscope,\n\t\t\tfileHash,\n\t\t\tfield,\n\t\t\tdefinition: {\n\t\t\t\tname,\n\t\t\t\ttype: functionType,\n\t\t\t\tparameters,\n\t\t\t\treturnType: \"\", // Python\u6CA1\u6709\u663E\u5F0F\u8FD4\u56DE\u7C7B\u578B\uFF08\u9664\u975E\u6709\u7C7B\u578B\u6CE8\u89E3\uFF09\n\t\t\t},\n\t\t\tparameters,\n\t\t\tsignature,\n\t\t\tlanguage: CodeLanguageType.Python,\n\t\t\t...(implementText ? { implementText } : {}),\n\t\t})\n\t}\n\n\t// --- Class ---\n\tfor (const capture of captures) {\n\t\tif (capture.name !== \"definition.class\") continue\n\t\tconst node = capture.node\n\t\tconst startLine = node.startPosition.row + 1\n\t\tconst endLine = node.endPosition.row + 1\n\n\t\tconst nameCap = captures.find(\n\t\t\t(c) =>\n\t\t\t\tc.name === \"name.definition.class\" &&\n\t\t\t\tc.node.startIndex >= node.startIndex &&\n\t\t\t\tc.node.endIndex <= node.endIndex,\n\t\t)\n\t\tif (!nameCap) continue\n\t\tconst name = sourceCode.substring(nameCap.node.startIndex, nameCap.node.endIndex)\n\n\t\tconst rangeText = sourceCode.substring(node.startIndex, node.endIndex)\n\t\tconst snippetHash = generateSnippetHash(filePath, startLine, endLine, rangeText)\n\t\tif (seenHashes.has(snippetHash)) continue\n\t\tseenHashes.add(snippetHash)\n\n\t\tconst scope = buildScopeChain(node)\n\n\t\tsnippets.push({\n\t\t\tname,\n\t\t\ttype: SnippetType.ClassOrInterfaceOrStructOrEnum,\n\t\t\tfilePath,\n\t\t\tstartLine,\n\t\t\tendLine,\n\t\t\trangeText,\n\t\t\tdefinitionText: rangeText,\n\t\t\tscope,\n\t\t\tfileHash,\n\t\t\tdefinition: {\n\t\t\t\tname,\n\t\t\t\ttype: \"class\",\n\t\t\t},\n\t\t\tlanguage: CodeLanguageType.Python,\n\t\t})\n\t}\n\n\t// --- \u5168\u5C40\u53D8\u91CF\u548C\u7C7B\u6210\u5458\u53D8\u91CF ---\n\tfor (const capture of captures) {\n\t\tif (capture.name !== \"definition.variable\") continue\n\t\tconst node = capture.node\n\t\tconst startLine = node.startPosition.row + 1\n\t\tconst endLine = node.endPosition.row + 1\n\n\t\t// \u67E5\u627E\u53D8\u91CF\u540D - \u652F\u6301\u666E\u901A\u53D8\u91CF\u548C\u6210\u5458\u53D8\u91CF\n\t\tconst memberVarCaps = captures.filter(\n\t\t\t(c) =>\n\t\t\t\tc.name === \"name.definition.member_variable\" &&\n\t\t\t\tc.node.startIndex >= node.startIndex &&\n\t\t\t\tc.node.endIndex <= node.endIndex,\n\t\t)\n\n\t\tconst regularVarCaps = captures.filter(\n\t\t\t(c) =>\n\t\t\t\tc.name === \"name.definition.variable\" &&\n\t\t\t\tc.node.startIndex >= node.startIndex &&\n\t\t\t\tc.node.endIndex <= node.endIndex,\n\t\t)\n\n\t\tconst allVarCaps = [...memberVarCaps, ...regularVarCaps]\n\t\tif (allVarCaps.length === 0) continue\n\n\t\tfor (const nameCap of allVarCaps) {\n\t\t\tconst name = sourceCode.substring(nameCap.node.startIndex, nameCap.node.endIndex)\n\t\t\tconst isMemberVar = nameCap.name === \"name.definition.member_variable\"\n\n\t\t\t// \u5982\u679C\u662F\u666E\u901A\u53D8\u91CF\u4E14\u5728\u51FD\u6570\u5185\u90E8\uFF0C\u5219\u8DF3\u8FC7\uFF08\u5C40\u90E8\u53D8\u91CF\uFF09\n\t\t\tif (!isMemberVar) {\n\t\t\t\tconst isInFunction = captures.some(\n\t\t\t\t\t(fc) =>\n\t\t\t\t\t\tfc.name === \"definition.function\" &&\n\t\t\t\t\t\tfc.node.startIndex < nameCap.node.startIndex &&\n\t\t\t\t\t\tnameCap.node.endIndex < fc.node.endIndex,\n\t\t\t\t)\n\t\t\t\tif (isInFunction) continue\n\t\t\t}\n\n\t\t\tconst rangeText = sourceCode.substring(node.startIndex, node.endIndex)\n\n\t\t\t// \u786E\u5B9A\u662F\u5426\u5C5E\u4E8E\u67D0\u4E2A\u7C7B\uFF08\u8BBE\u7F6Efield\uFF09\n\t\t\tlet field: string | undefined = undefined\n\t\t\tfor (const cls of classCaptures) {\n\t\t\t\tif (nameCap.node.startIndex > cls.start && nameCap.node.endIndex <= cls.end && cls.nameCap) {\n\t\t\t\t\tfield = sourceCode.substring(cls.nameCap.node.startIndex, cls.nameCap.node.endIndex)\n\t\t\t\t\tbreak\n\t\t\t\t}\n\t\t\t}\n\n\t\t\tconst snippetHash = generateSnippetHash(filePath, startLine, endLine, rangeText + name)\n\t\t\tif (seenHashes.has(snippetHash)) continue\n\t\t\tseenHashes.add(snippetHash)\n\n\t\t\tconst scope = buildScopeChain(nameCap.node)\n\n\t\t\tsnippets.push({\n\t\t\t\tname,\n\t\t\t\ttype: SnippetType.VariableOrConstant,\n\t\t\t\tfilePath,\n\t\t\t\tstartLine,\n\t\t\t\tendLine,\n\t\t\t\trangeText,\n\t\t\t\tdefinitionText: rangeText,\n\t\t\t\tscope,\n\t\t\t\tfileHash,\n\t\t\t\tfield,\n\t\t\t\tdefinition: {\n\t\t\t\t\tname,\n\t\t\t\t\ttype: field ? \"member_variable\" : \"global_variable\",\n\t\t\t\t},\n\t\t\t\tlanguage: CodeLanguageType.Python,\n\t\t\t})\n\t\t}\n\t}\n\n\t// --- Import ---\n\t// \u5148\u627E\u6240\u6709 definition.import\uFF0C\u8BB0\u4E0B\u5176\u533A\u95F4\n\tconst importDefs = captures.filter((c) => c.name === \"definition.import\")\n\t// \u518D\u627E\u6240\u6709 name.definition.import\uFF0C\u5F52\u5C5E\u5230\u6700\u8FD1\u7684 definition.import\n\tfor (const nameCap of captures.filter((c) => c.name === \"name.definition.import\")) {\n\t\t// \u627E\u5230\u5305\u542B\u5B83\u7684 definition.import capture\n\t\tconst defCap = importDefs.find(\n\t\t\t(def) => nameCap.node.startIndex >= def.node.startIndex && nameCap.node.endIndex <= def.node.endIndex,\n\t\t)\n\t\tif (!defCap) continue\n\t\tconst node = defCap.node\n\t\tconst startLine = node.startPosition.row + 1\n\t\tconst endLine = node.endPosition.row + 1\n\t\tconst rangeText = sourceCode.substring(node.startIndex, node.endIndex)\n\t\tconst name = sourceCode.substring(nameCap.node.startIndex, nameCap.node.endIndex)\n\t\tconst snippetHash = generateSnippetHash(filePath, startLine, endLine, name)\n\t\tif (seenHashes.has(snippetHash)) continue\n\t\tseenHashes.add(snippetHash)\n\t\tconst scope = buildScopeChain(node)\n\t\tsnippets.push({\n\t\t\tname,\n\t\t\ttype: SnippetType.ImportOrInclude,\n\t\t\tfilePath,\n\t\t\tstartLine,\n\t\t\tendLine,\n\t\t\trangeText,\n\t\t\tdefinitionText: rangeText,\n\t\t\tscope,\n\t\t\tfileHash,\n\t\t\tlanguage: CodeLanguageType.Python,\n\t\t})\n\t}\n\n\t// filter by snippetTypes\n\treturn snippets.filter((snippet) => snippetTypes.includes(snippet.type)).sort((a, b) => a.startLine - b.startLine)\n}\n\n/**\n * \u5206\u5272Python\u53C2\u6570\uFF0C\u5904\u7406\u9ED8\u8BA4\u53C2\u6570\u3001\u7C7B\u578B\u6CE8\u89E3\u3001*args\u3001**kwargs\u7B49\n */\nfunction splitPythonParameters(params: string): string[] {\n\tconst result: string[] = []\n\tlet current = \"\"\n\tlet parenDepth = 0\n\tlet bracketDepth = 0\n\tlet braceDepth = 0\n\tlet inString = false\n\tlet stringChar = \"\"\n\n\tfor (let i = 0; i < params.length; i++) {\n\t\tconst char = params[i]\n\t\tconst prevChar = i > 0 ? params[i - 1] : \"\"\n\n\t\t// \u5904\u7406\u5B57\u7B26\u4E32\u5B57\u9762\u91CF\n\t\tif (!inString && (char === '\"' || char === \"'\" || char === \"`\")) {\n\t\t\tinString = true\n\t\t\tstringChar = char\n\t\t} else if (inString && char === stringChar && prevChar !== \"\\\\\") {\n\t\t\tinString = false\n\t\t\tstringChar = \"\"\n\t\t}\n\n\t\tif (!inString) {\n\t\t\t// \u8DDF\u8E2A\u5D4C\u5957\u6DF1\u5EA6\n\t\t\tif (char === \"(\") parenDepth++\n\t\t\telse if (char === \")\") parenDepth--\n\t\t\telse if (char === \"[\") bracketDepth++\n\t\t\telse if (char === \"]\") bracketDepth--\n\t\t\telse if (char === \"{\") braceDepth++\n\t\t\telse if (char === \"}\") braceDepth--\n\t\t\telse if (char === \",\" && parenDepth === 0 && bracketDepth === 0 && braceDepth === 0) {\n\t\t\t\t// \u53EA\u5728\u9876\u5C42\u9017\u53F7\u5206\u5272\n\t\t\t\tif (current.trim()) {\n\t\t\t\t\tresult.push(current.trim())\n\t\t\t\t}\n\t\t\t\tcurrent = \"\"\n\t\t\t\tcontinue\n\t\t\t}\n\t\t}\n\n\t\tcurrent += char\n\t}\n\n\tif (current.trim()) {\n\t\tresult.push(current.trim())\n\t}\n\n\treturn result\n}\n\n// VSCode Outline Entry \u7C7B\u578B\nexport interface OutlineEntry {\n\ttype: string\n\tname: string\n\tfile: string // \u8868\u793A\u5F53\u524D\u6587\u4EF6\n\tfield?: string // \u7A7A\u5B57\u7B26\u4E32\u4EE3\u8868\u5F53\u524D\u6587\u4EF6\u7684global\n\tdescription?: string\n}\n\n/**\n * \u6839\u636E Python \u6587\u4EF6\u7684\u6240\u6709 snippet \u751F\u6210\u5927\u7EB2\uFF08Outline\uFF09\uFF0C\u652F\u6301 import\u3001global variables\u3001function\u3001method\uFF08\u5E26 field\uFF09\u3001class\n */\nexport function buildSummaryFromSnippets(snippets: ISnippetMeta[]): OutlineEntry[] {\n\tconst outline: OutlineEntry[] = []\n\n\tfor (const s of snippets) {\n\t\t// \u5224\u65AD\u662F\u5426\u662F\u9876\u5C42\u9879\u6216\u7C7B\u6210\u5458\n\t\tconst isTopLevelFunction =\n\t\t\ts.type === SnippetType.FunctionOrMethod && !s.field && (!s.scope || s.scope.length === 0)\n\t\tconst isClassOrGlobalVar =\n\t\t\t(s.type === SnippetType.ClassOrInterfaceOrStructOrEnum || s.type === SnippetType.VariableOrConstant) &&\n\t\t\t!s.scope?.some((scopeItem) => scopeItem.startsWith(\"function\"))\n\t\tconst isMethodOrMemberVar = !!s.field\n\t\tconst isImport = s.type === SnippetType.ImportOrInclude\n\n\t\tif (!(isTopLevelFunction || isClassOrGlobalVar || isMethodOrMemberVar || isImport)) {\n\t\t\tcontinue\n\t\t}\n\n\t\tif (s.type === SnippetType.ImportOrInclude) {\n\t\t\toutline.push({\n\t\t\t\ttype: \"import\",\n\t\t\t\tname: s.name,\n\t\t\t\tfile: s.filePath,\n\t\t\t\tfield: \"\",\n\t\t\t\tdescription: s.definitionText,\n\t\t\t})\n\t\t} else if (s.type === SnippetType.FunctionOrMethod) {\n\t\t\tif (s.field) {\n\t\t\t\toutline.push({\n\t\t\t\t\ttype: \"method\",\n\t\t\t\t\tname: s.name,\n\t\t\t\t\tfile: s.filePath,\n\t\t\t\t\tfield: s.field,\n\t\t\t\t\tdescription: s.definitionText,\n\t\t\t\t})\n\t\t\t} else {\n\t\t\t\toutline.push({\n\t\t\t\t\ttype: \"function\",\n\t\t\t\t\tname: s.name,\n\t\t\t\t\tfile: s.filePath,\n\t\t\t\t\tfield: \"\",\n\t\t\t\t\tdescription: s.definitionText,\n\t\t\t\t})\n\t\t\t}\n\t\t} else if (s.type === SnippetType.VariableOrConstant) {\n\t\t\tconst t = s.definition?.type === \"global_variable\" ? \"variable\" : \"member_variable\"\n\t\t\t// \u5BF9\u4E8E\u5B9E\u4F8B\u53D8\u91CF\uFF0C\u663E\u793A\u4E0D\u5E26self.\u524D\u7F00\u7684\u540D\u79F0\n\t\t\tconst displayName = s.name.startsWith(\"self.\") ? s.name.substring(5) : s.name\n\t\t\toutline.push({\n\t\t\t\ttype: t,\n\t\t\t\tname: displayName,\n\t\t\t\tfile: s.filePath,\n\t\t\t\tfield: s.field || \"\",\n\t\t\t\tdescription: s.definitionText,\n\t\t\t})\n\t\t} else if (s.type === SnippetType.ClassOrInterfaceOrStructOrEnum) {\n\t\t\toutline.push({\n\t\t\t\ttype: \"class\",\n\t\t\t\tname: s.name,\n\t\t\t\tfile: s.filePath,\n\t\t\t\tfield: \"\",\n\t\t\t\tdescription: s.name,\n\t\t\t})\n\t\t}\n\t}\n\n\treturn outline\n}\n\n/**\n * \u5C06 OutlineEntry[] \u683C\u5F0F\u5316\u4E3A\u6587\u672C\uFF0C\u540C\u4E00\u4E2A field \u7684\u653E\u5728\u4E00\u8D77\u3002\n * @param outline OutlineEntry[]\n * @returns string\n */\nexport function formatOutlineText(outline: OutlineEntry[]): string {\n\t// \u6309 field \u5206\u7EC4\n\tconst groups: Record = {}\n\tfor (const entry of outline) {\n\t\tconst key = entry.field ?? \"\"\n\t\tif (!groups[key]) groups[key] = []\n\t\tgroups[key].push(entry)\n\t}\n\n\t// \u5408\u6210\u6587\u672C\n\tlet result = \"\"\n\tfor (const field of Object.keys(groups).sort()) {\n\t\tif (groups[field].length === 0) continue\n\t\tconst group = groups[field]\n\t\tconst title = field === \"\" ? \"[global]\" : `[${field}]`\n\t\tresult += title + \"\\n\"\n\t\tfor (const entry of group) {\n\t\t\tlet line = ` ${entry.type}`\n\t\t\t// \u5BF9\u4E8E\u53D8\u91CF\u7C7B\u578B\uFF0C\u663E\u793A\u540D\u79F0\u800C\u4E0D\u662F\u5B8C\u6574\u63CF\u8FF0\n\t\t\tif (entry.type === \"variable\" || entry.type === \"member_variable\") {\n\t\t\t\tline += `: ${entry.name}`\n\t\t\t} else if (entry.description) {\n\t\t\t\tline += `: ${entry.description.replace(/\\n/g, \" \")}`\n\t\t\t}\n\t\t\tresult += line + \"\\n\"\n\t\t}\n\t\tresult += \"\\n\"\n\t}\n\treturn result.trimEnd()\n}\n", "import { SnippetType, ISnippetMeta, ParameterInfo, CodeLanguageType } from \"../types\"\nimport Parser from \"web-tree-sitter\"\nimport { generateSnippetHash, buildScopeChain } from \"./general\"\nimport { Logger } from \"../Logger\"\n\nexport async function extractSnippetsFromCapturesForJava(\n\tcaptures: Parser.QueryCapture[],\n\tsourceCode: string,\n\tfilePath: string,\n\tfileHash: string,\n\tsnippetTypes: SnippetType[],\n\toptions: { maxSnippetLines: number; minSnippetLines: number },\n): Promise {\n\tconst logger = Logger.getDefaultLogger().with(\"[extractSnippetsFromCapturesForJava]\")\n\n\tconst snippets: ISnippetMeta[] = []\n\tconst seenHashes = new Set()\n\n\tif (snippetTypes.length === 0) {\n\t\tlogger.warn(`No snippet types provided, skipping`)\n\t\treturn snippets\n\t}\n\n\t// \u5904\u7406 import \u548C package\n\tcaptures.forEach((capture) => {\n\t\tif (capture.name === \"name.definition.import\") {\n\t\t\tconst node = capture.node\n\t\t\tconst startLine = node.startPosition.row + 1\n\t\t\tconst endLine = node.endPosition.row + 1\n\t\t\tconst rangeText = sourceCode.substring(node.startIndex, node.endIndex)\n\t\t\tconst snippetHash = generateSnippetHash(filePath, startLine, endLine, rangeText)\n\t\t\tif (seenHashes.has(snippetHash)) return\n\t\t\tseenHashes.add(snippetHash)\n\t\t\tconst name = sourceCode.substring(node.startIndex, node.endIndex)\n\t\t\tconst scope = buildScopeChain(node)\n\t\t\tsnippets.push({\n\t\t\t\tname,\n\t\t\t\ttype: SnippetType.ImportOrInclude,\n\t\t\t\tfilePath,\n\t\t\t\tstartLine,\n\t\t\t\tendLine,\n\t\t\t\trangeText,\n\t\t\t\tdefinitionText: rangeText,\n\t\t\t\tscope,\n\t\t\t\tfileHash,\n\t\t\t})\n\t\t}\n\t})\n\n\t// \u5904\u7406 method \u548C constructor\n\tfor (const capture of captures) {\n\t\tif (capture.name !== \"definition.method\" && capture.name !== \"definition.constructor\") continue\n\t\tconst node = capture.node\n\t\tconst startLine = node.startPosition.row + 1\n\t\tconst endLine = node.endPosition.row + 1\n\n\t\tconst isConstructor = capture.name === \"definition.constructor\"\n\t\tconst nameCapName = isConstructor ? \"name.definition.constructor\" : \"name.definition.method\"\n\t\tconst paramCapName = isConstructor ? \"parameters.definition.constructor\" : \"parameters.definition.method\"\n\t\tconst bodyCapName = isConstructor ? \"body.definition.constructor\" : \"body.definition.method\"\n\n\t\tconst nameCap = captures.find(\n\t\t\t(c) => c.name === nameCapName && c.node.startIndex >= node.startIndex && c.node.endIndex <= node.endIndex,\n\t\t)\n\t\tif (!nameCap) continue\n\t\tconst name = sourceCode.substring(nameCap.node.startIndex, nameCap.node.endIndex)\n\n\t\t// \u89E3\u6790\u53C2\u6570\n\t\tconst paramCap = captures.find(\n\t\t\t(c) => c.name === paramCapName && c.node.startIndex >= node.startIndex && c.node.endIndex <= node.endIndex,\n\t\t)\n\t\tconst parameters: ParameterInfo[] = []\n\t\tif (paramCap) {\n\t\t\tconst paramText = sourceCode.substring(paramCap.node.startIndex, paramCap.node.endIndex)\n\t\t\t// \u89E3\u6790 Java \u53C2\u6570: (Type param1, Type param2, ...)\n\t\t\tconst cleanText = paramText.replace(/^\\(|\\)$/g, \"\").trim()\n\t\t\tif (cleanText) {\n\t\t\t\t// \u66F4\u597D\u7684Java\u53C2\u6570\u89E3\u6790\uFF0C\u4FDD\u6301\u5B8C\u6574\u7684\u7C7B\u578B\u4FE1\u606F\n\t\t\t\tconst paramList = parseJavaParameters(cleanText)\n\t\t\t\tparameters.push(...paramList.map((param: string) => ({ name: param })))\n\t\t\t}\n\t\t}\n\n\t\t// \u67E5\u627E\u65B9\u6CD5\u4F53\n\t\tconst bodyCap = captures.find(\n\t\t\t(c) => c.name === bodyCapName && c.node.startIndex >= node.startIndex && c.node.endIndex <= node.endIndex,\n\t\t)\n\n\t\tlet rangeText: string\n\t\tlet implementText: string | undefined = undefined\n\t\tif (bodyCap) {\n\t\t\trangeText = sourceCode.substring(node.startIndex, bodyCap.node.startIndex).trimEnd()\n\t\t\timplementText = sourceCode.substring(node.startIndex, node.endIndex)\n\t\t} else {\n\t\t\trangeText = sourceCode.substring(node.startIndex, node.endIndex)\n\t\t}\n\n\t\tconst snippetHash = generateSnippetHash(filePath, startLine, endLine, rangeText)\n\t\tif (seenHashes.has(snippetHash)) continue\n\t\tseenHashes.add(snippetHash)\n\n\t\tconst paramStr = parameters.map((p) => p.name).join(\", \")\n\t\tconst signature = `${name}(${paramStr})`\n\t\tconst scope = buildScopeChain(node)\n\n\t\t// \u67E5\u627E\u5F52\u5C5E\u7684\u7C7B/\u63A5\u53E3/\u679A\u4E3E/record\n\t\tlet field: string | undefined = undefined\n\t\tconst parentTypes = [\"class\", \"interface\", \"enum\", \"record\", \"annotation\"]\n\t\tfor (const parentType of parentTypes) {\n\t\t\tconst parentCap = captures.find(\n\t\t\t\t(c) =>\n\t\t\t\t\tc.name === `definition.${parentType}` &&\n\t\t\t\t\tc.node.startIndex < node.startIndex &&\n\t\t\t\t\tnode.endIndex < c.node.endIndex,\n\t\t\t)\n\t\t\tif (parentCap) {\n\t\t\t\tconst parentNameCap = captures.find(\n\t\t\t\t\t(c) =>\n\t\t\t\t\t\tc.name === `name.definition.${parentType}` &&\n\t\t\t\t\t\tc.node.startIndex >= parentCap.node.startIndex &&\n\t\t\t\t\t\tc.node.endIndex <= parentCap.node.endIndex,\n\t\t\t\t)\n\t\t\t\tif (parentNameCap) {\n\t\t\t\t\tfield = sourceCode.substring(parentNameCap.node.startIndex, parentNameCap.node.endIndex)\n\t\t\t\t\tbreak\n\t\t\t\t}\n\t\t\t}\n\t\t}\n\n\t\tsnippets.push({\n\t\t\tname,\n\t\t\ttype: SnippetType.FunctionOrMethod,\n\t\t\tfilePath,\n\t\t\tstartLine,\n\t\t\tendLine,\n\t\t\trangeText,\n\t\t\tdefinitionText: rangeText,\n\t\t\tscope,\n\t\t\tfileHash,\n\t\t\tfield,\n\t\t\tdefinition: {\n\t\t\t\tname,\n\t\t\t\ttype: isConstructor ? \"constructor\" : \"method\",\n\t\t\t\tparameters,\n\t\t\t\treturnType: isConstructor ? \"\" : \"void\", // Java \u65B9\u6CD5\u9ED8\u8BA4\u8FD4\u56DE\u7C7B\u578B\n\t\t\t},\n\t\t\tparameters,\n\t\t\tsignature,\n\t\t\tlanguage: CodeLanguageType.Java,\n\t\t\t...(implementText ? { implementText } : {}),\n\t\t})\n\t}\n\n\t// \u5904\u7406 class/interface/enum/record/annotation\n\tconst typeDefs = [\n\t\t{ capture: \"name.definition.class\", outlineType: \"class\" },\n\t\t{ capture: \"name.definition.interface\", outlineType: \"interface\" },\n\t\t{ capture: \"name.definition.enum\", outlineType: \"enum\" },\n\t\t{ capture: \"name.definition.record\", outlineType: \"record\" },\n\t\t{ capture: \"name.definition.annotation\", outlineType: \"annotation\" },\n\t]\n\n\tfor (const { capture, outlineType } of typeDefs) {\n\t\tconst defCaptureName = `definition.${outlineType}`\n\t\tfor (const cap of captures.filter((c) => c.name === capture)) {\n\t\t\tconst node = cap.node\n\t\t\t// \u5224\u65AD\u662F\u5426\u5728\u65B9\u6CD5/\u6784\u9020\u51FD\u6570\u5185\uFF08\u5C40\u90E8\u7C7B\uFF09\n\t\t\tconst isInMethod = captures.some(\n\t\t\t\t(fc) =>\n\t\t\t\t\t(fc.name === \"definition.method\" || fc.name === \"definition.constructor\") &&\n\t\t\t\t\tfc.node.startIndex < node.startIndex &&\n\t\t\t\t\tnode.endIndex < fc.node.endIndex,\n\t\t\t)\n\t\t\tif (isInMethod) continue\n\n\t\t\t// \u4F18\u5148\u7528 @definition.xxx \u533A\u95F4\n\t\t\tconst defCap = captures.find(\n\t\t\t\t(c) =>\n\t\t\t\t\tc.name === defCaptureName &&\n\t\t\t\t\tc.node.startIndex <= node.startIndex &&\n\t\t\t\t\tnode.endIndex <= c.node.endIndex,\n\t\t\t)\n\t\t\tconst rangeText = defCap\n\t\t\t\t? sourceCode.substring(defCap.node.startIndex, defCap.node.endIndex)\n\t\t\t\t: sourceCode.substring(node.startIndex, node.endIndex)\n\t\t\tconst startLine = node.startPosition.row + 1\n\t\t\tconst endLine = node.endPosition.row + 1\n\t\t\tconst snippetHash = generateSnippetHash(filePath, startLine, endLine, rangeText)\n\t\t\tif (seenHashes.has(snippetHash)) continue\n\t\t\tseenHashes.add(snippetHash)\n\t\t\tconst name = sourceCode.substring(node.startIndex, node.endIndex)\n\t\t\tsnippets.push({\n\t\t\t\tname,\n\t\t\t\ttype: SnippetType.ClassOrInterfaceOrStructOrEnum,\n\t\t\t\tfilePath,\n\t\t\t\tstartLine,\n\t\t\t\tendLine,\n\t\t\t\trangeText,\n\t\t\t\tdefinitionText: rangeText,\n\t\t\t\timplementText: rangeText,\n\t\t\t\tscope: [],\n\t\t\t\tfileHash,\n\t\t\t\tfield: \"\",\n\t\t\t\tdefinition: { name, type: outlineType },\n\t\t\t\tlanguage: CodeLanguageType.Java,\n\t\t\t})\n\t\t}\n\t}\n\n\t// \u5904\u7406 field\uFF08\u5B57\u6BB5\uFF09- \u76F4\u63A5\u5904\u7406\u6BCF\u4E2A\u5B57\u6BB5\u540D\u79F0\n\tconst fieldNameCaptures = captures.filter((c) => c.name === \"name.definition.field\")\n\tfor (const nameCap of fieldNameCaptures) {\n\t\tconst name = sourceCode.substring(nameCap.node.startIndex, nameCap.node.endIndex)\n\n\t\t// \u627E\u5230\u5305\u542B\u8FD9\u4E2A\u540D\u79F0\u7684field_declaration\u8282\u70B9\n\t\tconst fieldCap = captures.find(\n\t\t\t(c) =>\n\t\t\t\tc.name === \"definition.field\" &&\n\t\t\t\tc.node.startIndex <= nameCap.node.startIndex &&\n\t\t\t\tnameCap.node.endIndex <= c.node.endIndex,\n\t\t)\n\n\t\tif (!fieldCap) continue\n\n\t\tconst node = fieldCap.node\n\t\tconst startLine = node.startPosition.row + 1\n\t\tconst endLine = node.endPosition.row + 1\n\n\t\t// \u5224\u65AD\u662F\u5426\u5728\u65B9\u6CD5\u5185\uFF08\u5C40\u90E8\u53D8\u91CF\uFF09\n\t\tconst isInMethod = captures.some(\n\t\t\t(fc) =>\n\t\t\t\t(fc.name === \"definition.method\" || fc.name === \"definition.constructor\") &&\n\t\t\t\tfc.node.startIndex < node.startIndex &&\n\t\t\t\tnode.endIndex < fc.node.endIndex,\n\t\t)\n\t\tif (isInMethod) continue\n\n\t\tconst rangeText = sourceCode.substring(node.startIndex, node.endIndex)\n\t\t// \u5BF9\u4E8E\u5B57\u6BB5\uFF0C\u4F7F\u7528\u53D8\u91CF\u540D\u7684\u4F4D\u7F6E\u6765\u751F\u6210hash\uFF0C\u907F\u514D\u540C\u4E00\u884C\u591A\u4E2A\u53D8\u91CF\u88AB\u53BB\u91CD\n\t\tconst nameStartLine = nameCap.node.startPosition.row + 1\n\t\tconst nameEndLine = nameCap.node.endPosition.row + 1\n\t\tconst nameRangeText = sourceCode.substring(nameCap.node.startIndex, nameCap.node.endIndex)\n\t\tconst snippetHash = generateSnippetHash(filePath, nameStartLine, nameEndLine, nameRangeText)\n\t\tif (seenHashes.has(snippetHash)) continue\n\t\tseenHashes.add(snippetHash)\n\n\t\t// \u67E5\u627E\u5F52\u5C5E\u7684\u7C7B/\u63A5\u53E3/\u679A\u4E3E/record\n\t\tlet field: string | undefined = undefined\n\t\tconst parentTypes = [\"class\", \"interface\", \"enum\", \"record\", \"annotation\"]\n\t\tfor (const parentType of parentTypes) {\n\t\t\tconst parentCap = captures.find(\n\t\t\t\t(c) =>\n\t\t\t\t\tc.name === `definition.${parentType}` &&\n\t\t\t\t\tc.node.startIndex < node.startIndex &&\n\t\t\t\t\tnode.endIndex < c.node.endIndex,\n\t\t\t)\n\t\t\tif (parentCap) {\n\t\t\t\tconst parentNameCap = captures.find(\n\t\t\t\t\t(c) =>\n\t\t\t\t\t\tc.name === `name.definition.${parentType}` &&\n\t\t\t\t\t\tc.node.startIndex >= parentCap.node.startIndex &&\n\t\t\t\t\t\tc.node.endIndex <= parentCap.node.endIndex,\n\t\t\t\t)\n\t\t\t\tif (parentNameCap) {\n\t\t\t\t\tfield = sourceCode.substring(parentNameCap.node.startIndex, parentNameCap.node.endIndex)\n\t\t\t\t\tbreak\n\t\t\t\t}\n\t\t\t}\n\t\t}\n\n\t\tconst scope = buildScopeChain(node)\n\t\tsnippets.push({\n\t\t\tname,\n\t\t\ttype: SnippetType.VariableOrConstant,\n\t\t\tfilePath,\n\t\t\tstartLine,\n\t\t\tendLine,\n\t\t\trangeText,\n\t\t\tdefinitionText: rangeText,\n\t\t\timplementText: rangeText,\n\t\t\tscope,\n\t\t\tfileHash,\n\t\t\tfield: field || \"\",\n\t\t\tdefinition: { name, type: \"field\" },\n\t\t\tlanguage: CodeLanguageType.Java,\n\t\t})\n\t}\n\n\t// filter snippets by snippetTypes\n\treturn snippets.filter((snippet) => snippetTypes.includes(snippet.type)).sort((a, b) => a.startLine - b.startLine)\n}\n\n// VSCode Outline Entry \u7C7B\u578B\nexport interface OutlineEntry {\n\ttype: string\n\tname: string\n\tfile: string // \u8868\u793A\u5F53\u524D\u6587\u4EF6\n\tfield?: string // \u7A7A\u5B57\u7B26\u4E32\u4EE3\u8868\u5F53\u524D\u6587\u4EF6\u7684global\n\tdescription?: string\n}\n\n/**\n * \u6839\u636E Java \u6587\u4EF6\u7684\u6240\u6709 snippet \u751F\u6210\u5927\u7EB2\uFF08Outline\uFF09\uFF0C\u652F\u6301 import\u3001class\u3001interface\u3001enum\u3001record\u3001annotation\u3001method\u3001constructor\u3001field\n */\nexport function buildSummaryFromSnippets(snippets: ISnippetMeta[]): OutlineEntry[] {\n\tconst outline: OutlineEntry[] = []\n\n\t// \u5728Java\u4E2D\uFF0C\u6211\u4EEC\u5E94\u8BE5\u5305\u542B\u6240\u6709\u9876\u7EA7\u5B9A\u4E49\uFF08\u4E0D\u5728\u65B9\u6CD5\u5185\u90E8\u7684\uFF09\n\t// \u5305\u62EC\u7C7B\u3001\u63A5\u53E3\u3001\u65B9\u6CD5\u3001\u5B57\u6BB5\u7B49\n\tconst isTopLevel = (s: ISnippetMeta) => {\n\t\t// \u5982\u679Cscope\u4E3A\u7A7A\u6216\u8005\u53EA\u6709\u4E00\u5C42\uFF08\u6BD4\u5982\u53EA\u6709\u7C7B\u540D\uFF09\uFF0C\u5219\u8BA4\u4E3A\u662F\u9876\u7EA7\n\t\treturn !s.scope || s.scope.length <= 1\n\t}\n\n\tfor (const s of snippets) {\n\t\tif (!isTopLevel(s)) continue\n\t\tif (s.type === SnippetType.ImportOrInclude) {\n\t\t\toutline.push({\n\t\t\t\ttype: \"import\",\n\t\t\t\tname: s.name,\n\t\t\t\tfile: s.filePath,\n\t\t\t\tfield: \"\",\n\t\t\t\tdescription: s.definitionText,\n\t\t\t})\n\t\t} else if (s.type === SnippetType.FunctionOrMethod) {\n\t\t\tif (s.field) {\n\t\t\t\tconst methodType = s.definition?.type === \"constructor\" ? \"constructor\" : \"method\"\n\t\t\t\toutline.push({\n\t\t\t\t\ttype: methodType,\n\t\t\t\t\tname: s.name,\n\t\t\t\t\tfile: s.filePath,\n\t\t\t\t\tfield: s.field,\n\t\t\t\t\tdescription: s.definitionText,\n\t\t\t\t})\n\t\t\t} else {\n\t\t\t\toutline.push({\n\t\t\t\t\ttype: \"method\",\n\t\t\t\t\tname: s.name,\n\t\t\t\t\tfile: s.filePath,\n\t\t\t\t\tfield: \"\",\n\t\t\t\t\tdescription: s.definitionText,\n\t\t\t\t})\n\t\t\t}\n\t\t} else if (s.type === SnippetType.VariableOrConstant) {\n\t\t\tconst fieldType = s.definition?.type === \"field\" ? \"field\" : \"variable\"\n\t\t\t// \u5BF9\u4E8Eoutline\u663E\u793A\uFF0C\u4F7F\u7528\u7B80\u5355\u7684\u5B57\u6BB5\u540D\n\t\t\tconst simpleDescription = s.name\n\t\t\toutline.push({\n\t\t\t\ttype: fieldType,\n\t\t\t\tname: s.name,\n\t\t\t\tfile: s.filePath,\n\t\t\t\tfield: s.field || \"\",\n\t\t\t\tdescription: simpleDescription,\n\t\t\t})\n\t\t} else if (s.type === SnippetType.ClassOrInterfaceOrStructOrEnum) {\n\t\t\tconst t = s.definition?.type || \"class\"\n\t\t\t// \u5BF9\u4E8Eoutline\u663E\u793A\uFF0C\u4F7F\u7528\u7B80\u5355\u7684\u7C7B\u540D\n\t\t\toutline.push({\n\t\t\t\ttype: t,\n\t\t\t\tname: s.name,\n\t\t\t\tfile: s.filePath,\n\t\t\t\tfield: \"\",\n\t\t\t\tdescription: s.name,\n\t\t\t})\n\t\t}\n\t}\n\n\treturn outline\n}\n\n/**\n * \u5C06 OutlineEntry[] \u683C\u5F0F\u5316\u4E3A\u6587\u672C\uFF0C\u540C\u4E00\u4E2A field \u7684\u653E\u5728\u4E00\u8D77\u3002\n * @param outline OutlineEntry[]\n * @returns string\n */\nexport function formatOutlineText(outline: OutlineEntry[]): string {\n\t// \u6309 field \u5206\u7EC4\n\tconst groups: Record = {}\n\tfor (const entry of outline) {\n\t\tconst key = entry.field ?? \"\"\n\t\tif (!groups[key]) groups[key] = []\n\t\tgroups[key].push(entry)\n\t}\n\n\t// \u5408\u6210\u6587\u672C\n\tlet result = \"\"\n\tfor (const field of Object.keys(groups).sort()) {\n\t\tconst group = groups[field]\n\t\tconst title = field === \"\" ? \"[global]\" : `[${field}]`\n\t\tresult += title + \"\\n\"\n\t\tfor (const entry of group) {\n\t\t\tlet line = ` ${entry.type}`\n\t\t\tif (entry.description) line += `: ${entry.description.replace(/\\n/g, \" \")}`\n\t\t\tresult += line + \"\\n\"\n\t\t}\n\t\tresult += \"\\n\"\n\t}\n\treturn result.trimEnd()\n}\n\n/**\n * \u89E3\u6790Java\u53C2\u6570\u5217\u8868\uFF0C\u4FDD\u6301\u5B8C\u6574\u7684\u7C7B\u578B\u4FE1\u606F\n * @param paramText \u53C2\u6570\u6587\u672C\uFF0C\u4F8B\u5982 \"String name, int age, List items\"\n * @returns \u53C2\u6570\u6570\u7EC4\uFF0C\u6BCF\u4E2A\u5143\u7D20\u662F \"Type paramName\" \u5F62\u5F0F\n */\nfunction parseJavaParameters(paramText: string): string[] {\n\tif (!paramText.trim()) return []\n\n\tconst params: string[] = []\n\tlet current = \"\"\n\tlet bracketDepth = 0\n\tlet i = 0\n\n\twhile (i < paramText.length) {\n\t\tconst char = paramText[i]\n\n\t\tif (char === \"<\") {\n\t\t\tbracketDepth++\n\t\t\tcurrent += char\n\t\t} else if (char === \">\") {\n\t\t\tbracketDepth--\n\t\t\tcurrent += char\n\t\t} else if (char === \",\" && bracketDepth === 0) {\n\t\t\t// \u5230\u8FBE\u53C2\u6570\u5206\u9694\u7B26\n\t\t\tif (current.trim()) {\n\t\t\t\tparams.push(current.trim())\n\t\t\t}\n\t\t\tcurrent = \"\"\n\t\t} else {\n\t\t\tcurrent += char\n\t\t}\n\t\ti++\n\t}\n\n\t// \u6DFB\u52A0\u6700\u540E\u4E00\u4E2A\u53C2\u6570\n\tif (current.trim()) {\n\t\tparams.push(current.trim())\n\t}\n\n\treturn params\n}\n", "import { SnippetType, ISnippetMeta, ParameterInfo, CodeLanguageType } from \"../types\"\nimport Parser from \"web-tree-sitter\"\nimport { generateSnippetHash, buildScopeChain } from \"./general\"\n\n// Helper function to remove parentheses from parameter string\nfunction removeParentheses(text: string): string {\n\tlet result = text.trim()\n\tif (result.startsWith(\"(\") && result.endsWith(\")\")) {\n\t\tresult = result.slice(1, -1).trim()\n\t}\n\treturn result\n}\n\n// Helper function to remove brackets from array destructuring\nfunction removeBrackets(text: string): string {\n\tlet result = text.trim()\n\tif (result.startsWith(\"[\") && result.endsWith(\"]\")) {\n\t\tresult = result.slice(1, -1).trim()\n\t}\n\treturn result\n}\n\n// Helper function to check if a string is a valid JavaScript identifier\nfunction isValidJavaScriptIdentifier(name: string): boolean {\n\tif (!name) return false\n\n\t// First character must be letter, underscore, or dollar sign\n\tconst firstChar = name[0]\n\tif (\n\t\t!(firstChar >= \"a\" && firstChar <= \"z\") &&\n\t\t!(firstChar >= \"A\" && firstChar <= \"Z\") &&\n\t\tfirstChar !== \"_\" &&\n\t\tfirstChar !== \"$\"\n\t) {\n\t\treturn false\n\t}\n\n\t// Remaining characters can be letters, digits, underscore, or dollar sign\n\tfor (let i = 1; i < name.length; i++) {\n\t\tconst char = name[i]\n\t\tif (\n\t\t\t!(char >= \"a\" && char <= \"z\") &&\n\t\t\t!(char >= \"A\" && char <= \"Z\") &&\n\t\t\t!(char >= \"0\" && char <= \"9\") &&\n\t\t\tchar !== \"_\" &&\n\t\t\tchar !== \"$\"\n\t\t) {\n\t\t\treturn false\n\t\t}\n\t}\n\n\treturn true\n}\n\n// Helper function to replace newlines with spaces for formatting\nfunction replaceNewlinesWithSpaces(text: string): string {\n\treturn text.split(\"\\n\").join(\" \")\n}\n\n// Helper function to extract parameters from method text using string parsing\nfunction extractParametersFromMethodText(methodText: string): string | null {\n\tconst openParen = methodText.indexOf(\"(\")\n\tconst closeParen = methodText.lastIndexOf(\")\")\n\n\tif (openParen !== -1 && closeParen !== -1 && closeParen > openParen) {\n\t\treturn methodText.substring(openParen + 1, closeParen).trim()\n\t}\n\n\treturn null\n}\n\nexport async function extractSnippetsFromCapturesForJavaScript(\n\tcaptures: Parser.QueryCapture[],\n\tsourceCode: string,\n\tfilePath: string,\n\tfileHash: string,\n\tsnippetTypes: SnippetType[],\n\toptions: { maxSnippetLines: number; minSnippetLines: number },\n): Promise {\n\tconst snippets: ISnippetMeta[] = []\n\tconst seenHashes = new Set()\n\n\t// --- Function/Method ---\n\t// Collect all class captures first for context\n\tconst classCaptures = captures\n\t\t.filter((c) => c.name === \"definition.class\")\n\t\t.map((c) => ({\n\t\t\tnode: c.node,\n\t\t\tstart: c.node.startIndex,\n\t\t\tend: c.node.endIndex,\n\t\t\tnameCap: captures.find(\n\t\t\t\t(nc) =>\n\t\t\t\t\tnc.name === \"name\" &&\n\t\t\t\t\tnc.node.startIndex >= c.node.startIndex &&\n\t\t\t\t\tnc.node.endIndex <= c.node.endIndex,\n\t\t\t),\n\t\t}))\n\n\t// Process function declarations\n\tfor (const capture of captures) {\n\t\tif (capture.name !== \"definition.function\") continue\n\t\tconst node = capture.node\n\t\tconst startLine = node.startPosition.row + 1\n\t\tconst endLine = node.endPosition.row + 1\n\n\t\t// Find function name\n\t\tconst nameCap = captures.find(\n\t\t\t(c) =>\n\t\t\t\t(c.name === \"name.definition.function\" || c.name === \"name\") &&\n\t\t\t\tc.node.startIndex >= node.startIndex &&\n\t\t\t\tc.node.endIndex <= node.endIndex,\n\t\t)\n\t\tif (!nameCap) continue\n\t\tconst name = sourceCode.substring(nameCap.node.startIndex, nameCap.node.endIndex)\n\n\t\t// Find parameters\n\t\tconst paramCap = captures.find(\n\t\t\t(c) =>\n\t\t\t\tc.name === \"parameters.definition.function\" &&\n\t\t\t\tc.node.startIndex >= node.startIndex &&\n\t\t\t\tc.node.endIndex <= node.endIndex,\n\t\t)\n\n\t\tconst parameters: ParameterInfo[] = []\n\t\tif (paramCap) {\n\t\t\tconst paramText = sourceCode.substring(paramCap.node.startIndex, paramCap.node.endIndex)\n\t\t\tconst cleanParams = removeParentheses(paramText)\n\t\t\tif (cleanParams) {\n\t\t\t\t// JavaScript parameter parsing - handle destructuring, defaults, etc.\n\t\t\t\tconst paramList = splitJavaScriptParameters(cleanParams)\n\t\t\t\tparameters.push(...paramList.map((param) => ({ name: param })))\n\t\t\t}\n\t\t}\n\n\t\t// Find function body\n\t\tconst bodyCap = captures.find(\n\t\t\t(c) =>\n\t\t\t\tc.name === \"body.definition.function\" &&\n\t\t\t\tc.node.startIndex >= node.startIndex &&\n\t\t\t\tc.node.endIndex <= node.endIndex,\n\t\t)\n\n\t\tlet rangeText: string\n\t\tlet implementText: string | undefined = undefined\n\t\tif (bodyCap) {\n\t\t\trangeText = sourceCode.substring(node.startIndex, bodyCap.node.startIndex).trimEnd()\n\t\t\timplementText = sourceCode.substring(node.startIndex, node.endIndex)\n\t\t} else {\n\t\t\trangeText = sourceCode.substring(node.startIndex, node.endIndex)\n\t\t}\n\n\t\t// Check if function belongs to a class\n\t\tlet field: string | undefined = undefined\n\t\tfor (const cls of classCaptures) {\n\t\t\tif (node.startIndex > cls.start && node.endIndex < cls.end && cls.nameCap) {\n\t\t\t\tfield = sourceCode.substring(cls.nameCap.node.startIndex, cls.nameCap.node.endIndex)\n\t\t\t\tbreak\n\t\t\t}\n\t\t}\n\n\t\tconst snippetHash = generateSnippetHash(filePath, startLine, endLine, rangeText)\n\t\tif (seenHashes.has(snippetHash)) continue\n\t\tseenHashes.add(snippetHash)\n\n\t\tconst paramStr = parameters.map((p) => p.name).join(\", \")\n\t\tconst signature = `${name}(${paramStr})`\n\t\tconst scope = buildScopeChain(node)\n\n\t\t// Detect function type (async, generator, arrow, etc.)\n\t\tlet functionType = \"function\"\n\t\tconst nodeText = sourceCode.substring(node.startIndex, Math.min(node.startIndex + 100, node.endIndex))\n\t\tif (nodeText.includes(\"async\")) functionType = \"async function\"\n\t\tif (nodeText.includes(\"function*\")) functionType = \"generator function\"\n\t\tif (nodeText.includes(\"=>\")) functionType = \"arrow function\"\n\n\t\tsnippets.push({\n\t\t\tname,\n\t\t\ttype: SnippetType.FunctionOrMethod,\n\t\t\tfilePath,\n\t\t\tstartLine,\n\t\t\tendLine,\n\t\t\trangeText,\n\t\t\tdefinitionText: rangeText,\n\t\t\tscope,\n\t\t\tfileHash,\n\t\t\tfield,\n\t\t\tdefinition: {\n\t\t\t\tname,\n\t\t\t\ttype: functionType,\n\t\t\t\tparameters,\n\t\t\t\treturnType: \"\", // JavaScript doesn't have explicit return types\n\t\t\t},\n\t\t\tparameters,\n\t\t\tsignature,\n\t\t\tlanguage: CodeLanguageType.JavaScript,\n\t\t\t...(implementText ? { implementText } : {}),\n\t\t})\n\t}\n\n\t// --- Method definitions ---\n\tfor (const capture of captures) {\n\t\tif (capture.name !== \"definition.method\") continue\n\t\tconst node = capture.node\n\t\tconst startLine = node.startPosition.row + 1\n\t\tconst endLine = node.endPosition.row + 1\n\n\t\t// Find method name\n\t\tconst nameCap = captures.find(\n\t\t\t(c) => c.name === \"name\" && c.node.startIndex >= node.startIndex && c.node.endIndex <= node.endIndex,\n\t\t)\n\t\tif (!nameCap) continue\n\t\tconst name = sourceCode.substring(nameCap.node.startIndex, nameCap.node.endIndex)\n\n\t\t// Find method parameters - prioritize captured parameters\n\t\tconst paramCap = captures.find(\n\t\t\t(c) =>\n\t\t\t\tc.name === \"parameters.definition.method\" &&\n\t\t\t\tc.node.startIndex >= node.startIndex &&\n\t\t\t\tc.node.endIndex <= node.endIndex,\n\t\t)\n\n\t\tconst parameters: ParameterInfo[] = []\n\t\tif (paramCap) {\n\t\t\t// Use captured parameters\n\t\t\tconst paramText = sourceCode.substring(paramCap.node.startIndex, paramCap.node.endIndex)\n\t\t\tconst cleanParams = removeParentheses(paramText)\n\t\t\tif (cleanParams) {\n\t\t\t\tconst paramList = splitJavaScriptParameters(cleanParams)\n\t\t\t\tparameters.push(...paramList.map((param) => ({ name: param })))\n\t\t\t}\n\t\t} else {\n\t\t\t// Fallback to string parsing\n\t\t\tconst methodText = sourceCode.substring(node.startIndex, node.endIndex)\n\t\t\tconst paramString = extractParametersFromMethodText(methodText)\n\t\t\tif (paramString) {\n\t\t\t\tconst paramList = splitJavaScriptParameters(paramString)\n\t\t\t\tparameters.push(...paramList.map((param) => ({ name: param })))\n\t\t\t}\n\t\t}\n\n\t\t// Find containing class - we'll do this after all classes are processed\n\t\tlet field: string | undefined = undefined\n\n\t\tconst rangeText = sourceCode.substring(node.startIndex, node.endIndex)\n\t\tconst snippetHash = generateSnippetHash(filePath, startLine, endLine, rangeText)\n\t\tif (seenHashes.has(snippetHash)) continue\n\t\tseenHashes.add(snippetHash)\n\n\t\tconst paramStr = parameters.map((p) => p.name).join(\", \")\n\t\tconst signature = `${name}(${paramStr})`\n\t\tconst scope = buildScopeChain(node)\n\n\t\t// Detect method type\n\t\tlet methodType = \"method\"\n\t\tconst methodText = sourceCode.substring(node.startIndex, node.endIndex)\n\t\tif (methodText.includes(\"async\")) methodType = \"async method\"\n\t\tif (methodText.includes(\"static\")) methodType = \"static method\"\n\t\tif (methodText.includes(\"get \")) methodType = \"getter\"\n\t\tif (methodText.includes(\"set \")) methodType = \"setter\"\n\n\t\tsnippets.push({\n\t\t\tname,\n\t\t\ttype: SnippetType.FunctionOrMethod,\n\t\t\tfilePath,\n\t\t\tstartLine,\n\t\t\tendLine,\n\t\t\trangeText,\n\t\t\tdefinitionText: rangeText,\n\t\t\tscope,\n\t\t\tfileHash,\n\t\t\tfield,\n\t\t\tdefinition: {\n\t\t\t\tname,\n\t\t\t\ttype: methodType,\n\t\t\t\tparameters,\n\t\t\t\treturnType: \"\",\n\t\t\t},\n\t\t\tparameters,\n\t\t\tsignature,\n\t\t\tlanguage: CodeLanguageType.JavaScript,\n\t\t\timplementText: rangeText,\n\t\t})\n\t}\n\n\t// --- Class definitions ---\n\tfor (const capture of captures) {\n\t\tif (capture.name !== \"definition.class\") continue\n\t\tconst node = capture.node\n\t\tconst startLine = node.startPosition.row + 1\n\t\tconst endLine = node.endPosition.row + 1\n\n\t\tconst nameCap = captures.find(\n\t\t\t(c) =>\n\t\t\t\tc.name === \"name.definition.class\" &&\n\t\t\t\tc.node.startIndex >= node.startIndex &&\n\t\t\t\tc.node.endIndex <= node.endIndex,\n\t\t)\n\t\tif (!nameCap) continue\n\t\tconst name = sourceCode.substring(nameCap.node.startIndex, nameCap.node.endIndex)\n\n\t\tconst rangeText = sourceCode.substring(node.startIndex, node.endIndex)\n\t\tconst snippetHash = generateSnippetHash(filePath, startLine, endLine, rangeText)\n\t\tif (seenHashes.has(snippetHash)) continue\n\t\tseenHashes.add(snippetHash)\n\t\tconst scope = buildScopeChain(node)\n\n\t\tsnippets.push({\n\t\t\tname,\n\t\t\ttype: SnippetType.ClassOrInterfaceOrStructOrEnum,\n\t\t\tfilePath,\n\t\t\tstartLine,\n\t\t\tendLine,\n\t\t\trangeText,\n\t\t\tdefinitionText: rangeText,\n\t\t\tscope,\n\t\t\tfileHash,\n\t\t\tdefinition: {\n\t\t\t\tname,\n\t\t\t\ttype: \"class\",\n\t\t\t},\n\t\t\tlanguage: CodeLanguageType.JavaScript,\n\t\t})\n\t}\n\n\t// --- Fix method field associations ---\n\t// Get all classes to determine field associations\n\tconst allClasses = snippets.filter((s) => s.type === SnippetType.ClassOrInterfaceOrStructOrEnum)\n\n\t// Update method field associations\n\tfor (const method of snippets) {\n\t\tif (method.type === SnippetType.FunctionOrMethod && !method.field) {\n\t\t\tfor (const cls of allClasses) {\n\t\t\t\tif (method.startLine >= cls.startLine && method.endLine <= cls.endLine) {\n\t\t\t\t\tmethod.field = cls.name\n\t\t\t\t\tbreak\n\t\t\t\t}\n\t\t\t}\n\t\t}\n\t}\n\n\t// --- Variable definitions ---\n\n\tfor (const capture of captures) {\n\t\tif (capture.name !== \"definition.variable\") continue\n\n\t\tconst node = capture.node\n\t\tconst startLine = node.startPosition.row + 1\n\t\tconst endLine = node.endPosition.row + 1\n\n\t\t// Check if this is an array destructuring pattern\n\t\tconst arrayPatternCap = captures.find(\n\t\t\t(c) =>\n\t\t\t\tc.name === \"array_pattern\" && c.node.startIndex >= node.startIndex && c.node.endIndex <= node.endIndex,\n\t\t)\n\n\t\tif (arrayPatternCap) {\n\t\t\t// Handle array destructuring manually\n\t\t\tconst arrayPatternText = sourceCode.substring(\n\t\t\t\tarrayPatternCap.node.startIndex,\n\t\t\t\tarrayPatternCap.node.endIndex,\n\t\t\t)\n\t\t\t// Extract variable names from array pattern like [first, second]\n\t\t\tconst variableNames = removeBrackets(arrayPatternText)\n\t\t\t\t.split(\",\")\n\t\t\t\t.map((name) => name.trim())\n\t\t\t\t.filter((name) => name && isValidJavaScriptIdentifier(name)) // Valid identifiers only\n\n\t\t\t// Process each variable separately\n\t\t\tfor (const varName of variableNames) {\n\t\t\t\t// Skip local variables (inside functions)\n\t\t\t\tconst scope = buildScopeChain(node)\n\t\t\t\tconst isInsideFunction =\n\t\t\t\t\tscope.length > 0 &&\n\t\t\t\t\tscope.some((scopeItem) => {\n\t\t\t\t\t\treturn !allClasses.some((cls) => cls.name === scopeItem)\n\t\t\t\t\t})\n\n\t\t\t\tif (isInsideFunction) continue\n\n\t\t\t\tconst rangeText = sourceCode.substring(node.startIndex, node.endIndex)\n\t\t\t\tconst snippetHash = generateSnippetHash(filePath, startLine, endLine, `${rangeText}_${varName}`)\n\t\t\t\tif (seenHashes.has(snippetHash)) continue\n\t\t\t\tseenHashes.add(snippetHash)\n\n\t\t\t\t// Determine if this is a class member variable\n\t\t\t\tlet field: string | undefined = undefined\n\t\t\t\tlet variableType = \"global_variable\"\n\n\t\t\t\t// Check if variable is inside a class\n\t\t\t\tfor (const cls of allClasses) {\n\t\t\t\t\tif (startLine >= cls.startLine && endLine <= cls.endLine) {\n\t\t\t\t\t\tfield = cls.name\n\t\t\t\t\t\tvariableType = \"member_variable\"\n\t\t\t\t\t\tbreak\n\t\t\t\t\t}\n\t\t\t\t}\n\n\t\t\t\t// Create definition text\n\t\t\t\tlet definitionText = varName\n\t\t\t\tif (variableType === \"global_variable\") {\n\t\t\t\t\tdefinitionText = replaceNewlinesWithSpaces(rangeText).trim()\n\t\t\t\t}\n\n\t\t\t\tsnippets.push({\n\t\t\t\t\tname: varName,\n\t\t\t\t\ttype: SnippetType.VariableOrConstant,\n\t\t\t\t\tfilePath,\n\t\t\t\t\tstartLine,\n\t\t\t\t\tendLine,\n\t\t\t\t\trangeText,\n\t\t\t\t\tdefinitionText,\n\t\t\t\t\tscope,\n\t\t\t\t\tfileHash,\n\t\t\t\t\tfield,\n\t\t\t\t\tdefinition: {\n\t\t\t\t\t\tname: varName,\n\t\t\t\t\t\ttype: variableType,\n\t\t\t\t\t},\n\t\t\t\t\tlanguage: CodeLanguageType.JavaScript,\n\t\t\t\t})\n\t\t\t}\n\t\t\tcontinue\n\t\t}\n\n\t\tconst nameCap =\n\t\t\tcaptures.find(\n\t\t\t\t(c) =>\n\t\t\t\t\tc.name === \"name.definition.variable\" &&\n\t\t\t\t\tc.node.startIndex >= node.startIndex &&\n\t\t\t\t\tc.node.endIndex <= node.endIndex,\n\t\t\t) ||\n\t\t\tcaptures.find(\n\t\t\t\t(c) =>\n\t\t\t\t\tc.name === \"name.definition.member_variable\" &&\n\t\t\t\t\tc.node.startIndex >= node.startIndex &&\n\t\t\t\t\tc.node.endIndex <= node.endIndex,\n\t\t\t)\n\t\tif (!nameCap) continue\n\t\tconst name = sourceCode.substring(nameCap.node.startIndex, nameCap.node.endIndex)\n\n\t\t// Skip local variables (inside functions)\n\t\tconst scope = buildScopeChain(node)\n\n\t\t// Check if this is a member variable assignment (this.property)\n\t\tconst isMemberVariable = captures.some(\n\t\t\t(c) =>\n\t\t\t\tc.name === \"name.definition.member_variable\" &&\n\t\t\t\tc.node.startIndex >= node.startIndex &&\n\t\t\t\tc.node.endIndex <= node.endIndex &&\n\t\t\t\tsourceCode.substring(c.node.startIndex, c.node.endIndex) === name,\n\t\t)\n\n\t\t// A variable is local if it's inside any function (scope has function names)\n\t\t// But we need to allow class member variables (inside classes but not functions)\n\t\t// and this.property assignments even if they're inside constructors\n\t\tconst isInsideFunction =\n\t\t\tscope.length > 0 &&\n\t\t\tscope.some((scopeItem) => {\n\t\t\t\t// Check if this scope item is a function by looking at the node type\n\t\t\t\t// For now, we'll use a heuristic: if it's not a class name, it's likely a function\n\t\t\t\treturn !allClasses.some((cls) => cls.name === scopeItem)\n\t\t\t})\n\n\t\t// Skip if it's a local variable but not a member variable\n\t\tif (isInsideFunction && !isMemberVariable) continue\n\n\t\tconst rangeText = sourceCode.substring(node.startIndex, node.endIndex)\n\t\tconst snippetHash = generateSnippetHash(filePath, startLine, endLine, rangeText)\n\t\tif (seenHashes.has(snippetHash)) continue\n\t\tseenHashes.add(snippetHash)\n\n\t\t// Determine if this is a class member variable\n\t\tlet field: string | undefined = undefined\n\t\tlet variableType = \"global_variable\"\n\n\t\t// Check if variable is inside a class\n\t\tfor (const cls of allClasses) {\n\t\t\tif (startLine >= cls.startLine && endLine <= cls.endLine) {\n\t\t\t\tfield = cls.name\n\t\t\t\tvariableType = \"member_variable\"\n\t\t\t\tbreak\n\t\t\t}\n\t\t}\n\n\t\t// Create definition text (just the variable name for member variables)\n\t\tlet definitionText = name\n\t\tif (variableType === \"global_variable\") {\n\t\t\t// For global variables, show the full declaration\n\t\t\tdefinitionText = replaceNewlinesWithSpaces(rangeText).trim()\n\t\t}\n\n\t\tsnippets.push({\n\t\t\tname,\n\t\t\ttype: SnippetType.VariableOrConstant,\n\t\t\tfilePath,\n\t\t\tstartLine,\n\t\t\tendLine,\n\t\t\trangeText,\n\t\t\tdefinitionText,\n\t\t\tscope,\n\t\t\tfileHash,\n\t\t\tfield,\n\t\t\tdefinition: {\n\t\t\t\tname,\n\t\t\t\ttype: variableType,\n\t\t\t},\n\t\t\tlanguage: CodeLanguageType.JavaScript,\n\t\t})\n\t}\n\n\t// Filter by requested snippet types\n\treturn snippets.filter((snippet) => snippetTypes.includes(snippet.type)).sort((a, b) => a.startLine - b.startLine)\n}\n\n/**\n * Split JavaScript parameters handling destructuring, defaults, rest parameters, etc.\n */\nfunction splitJavaScriptParameters(params: string): string[] {\n\tconst result: string[] = []\n\tlet current = \"\"\n\tlet braceDepth = 0\n\tlet bracketDepth = 0\n\tlet parenDepth = 0\n\tlet inString = false\n\tlet stringChar = \"\"\n\n\tfor (let i = 0; i < params.length; i++) {\n\t\tconst char = params[i]\n\t\tconst prevChar = i > 0 ? params[i - 1] : \"\"\n\n\t\t// Handle string literals\n\t\tif (!inString && (char === '\"' || char === \"'\" || char === \"`\")) {\n\t\t\tinString = true\n\t\t\tstringChar = char\n\t\t} else if (inString && char === stringChar && prevChar !== \"\\\\\") {\n\t\t\tinString = false\n\t\t\tstringChar = \"\"\n\t\t}\n\n\t\tif (!inString) {\n\t\t\t// Track nesting depth\n\t\t\tif (char === \"{\") braceDepth++\n\t\t\telse if (char === \"}\") braceDepth--\n\t\t\telse if (char === \"[\") bracketDepth++\n\t\t\telse if (char === \"]\") bracketDepth--\n\t\t\telse if (char === \"(\") parenDepth++\n\t\t\telse if (char === \")\") parenDepth--\n\t\t\telse if (char === \",\" && braceDepth === 0 && bracketDepth === 0 && parenDepth === 0) {\n\t\t\t\t// Split only at top-level commas\n\t\t\t\tif (current.trim()) {\n\t\t\t\t\tresult.push(current.trim())\n\t\t\t\t}\n\t\t\t\tcurrent = \"\"\n\t\t\t\tcontinue\n\t\t\t}\n\t\t}\n\n\t\tcurrent += char\n\t}\n\n\tif (current.trim()) {\n\t\tresult.push(current.trim())\n\t}\n\n\treturn result\n}\n// VSCode Outline Entry \u7C7B\u578B\nexport interface OutlineEntry {\n\ttype: string\n\tname: string\n\tfile: string // \u8868\u793A\u5F53\u524D\u6587\u4EF6\n\tfield?: string // \u7A7A\u5B57\u7B26\u4E32\u4EE3\u8868\u5F53\u524D\u6587\u4EF6\u7684global\n\tdescription?: string\n}\n\n/**\n * \u6839\u636E JavaScript \u6587\u4EF6\u7684\u6240\u6709 snippet \u751F\u6210\u5927\u7EB2\uFF08Outline\uFF09\uFF0C\u652F\u6301 import\u3001global variables\u3001function\u3001method\uFF08\u5E26 field\uFF09\u3001class\n */\nexport function buildSummaryFromSnippets(snippets: ISnippetMeta[]): OutlineEntry[] {\n\tconst outline: OutlineEntry[] = []\n\n\tfor (const s of snippets) {\n\t\t// \u5224\u65AD\u662F\u5426\u662F\u9876\u5C42\u9879\u6216\u7C7B\u6210\u5458\n\t\tconst isTopLevelFunction =\n\t\t\ts.type === SnippetType.FunctionOrMethod && !s.field && (!s.scope || s.scope.length === 0)\n\t\tconst isClassOrGlobalVar =\n\t\t\t(s.type === SnippetType.ClassOrInterfaceOrStructOrEnum || s.type === SnippetType.VariableOrConstant) &&\n\t\t\t!s.scope?.some((scopeItem) => scopeItem.startsWith(\"function\"))\n\t\tconst isMethodOrMemberVar = !!s.field\n\t\tconst isImport = s.type === SnippetType.ImportOrInclude\n\n\t\tif (!(isTopLevelFunction || isClassOrGlobalVar || isMethodOrMemberVar || isImport)) {\n\t\t\tcontinue\n\t\t}\n\n\t\tif (s.type === SnippetType.ImportOrInclude) {\n\t\t\toutline.push({\n\t\t\t\ttype: \"import\",\n\t\t\t\tname: s.name,\n\t\t\t\tfile: s.filePath,\n\t\t\t\tfield: \"\",\n\t\t\t\tdescription: s.definitionText,\n\t\t\t})\n\t\t} else if (s.type === SnippetType.FunctionOrMethod) {\n\t\t\tif (s.field) {\n\t\t\t\toutline.push({\n\t\t\t\t\ttype: \"method\",\n\t\t\t\t\tname: s.name,\n\t\t\t\t\tfile: s.filePath,\n\t\t\t\t\tfield: s.field,\n\t\t\t\t\tdescription: s.definitionText,\n\t\t\t\t})\n\t\t\t} else {\n\t\t\t\toutline.push({\n\t\t\t\t\ttype: \"function\",\n\t\t\t\t\tname: s.name,\n\t\t\t\t\tfile: s.filePath,\n\t\t\t\t\tfield: \"\",\n\t\t\t\t\tdescription: s.definitionText,\n\t\t\t\t})\n\t\t\t}\n\t\t} else if (s.type === SnippetType.VariableOrConstant) {\n\t\t\tconst t = s.definition?.type === \"global_variable\" ? \"variable\" : \"member_variable\"\n\t\t\t// \u5BF9\u4E8E\u6210\u5458\u53D8\u91CF\uFF0C\u663E\u793A\u4E0D\u5E26this.\u524D\u7F00\u7684\u540D\u79F0\n\t\t\tconst displayName = s.name.startsWith(\"this.\") ? s.name.substring(5) : s.name\n\t\t\toutline.push({\n\t\t\t\ttype: t,\n\t\t\t\tname: displayName,\n\t\t\t\tfile: s.filePath,\n\t\t\t\tfield: s.field || \"\",\n\t\t\t\tdescription: s.definitionText,\n\t\t\t})\n\t\t} else if (s.type === SnippetType.ClassOrInterfaceOrStructOrEnum) {\n\t\t\toutline.push({\n\t\t\t\ttype: \"class\",\n\t\t\t\tname: s.name,\n\t\t\t\tfile: s.filePath,\n\t\t\t\tfield: \"\",\n\t\t\t\tdescription: s.name,\n\t\t\t})\n\t\t}\n\t}\n\n\treturn outline\n}\n\n/**\n * \u5C06 OutlineEntry[] \u683C\u5F0F\u5316\u4E3A\u6587\u672C\uFF0C\u540C\u4E00\u4E2A field \u7684\u653E\u5728\u4E00\u8D77\u3002\n * @param outline OutlineEntry[]\n * @returns string\n */\nexport function formatOutlineText(outline: OutlineEntry[]): string {\n\t// \u6309 field \u5206\u7EC4\n\tconst groups: Record = {}\n\tfor (const entry of outline) {\n\t\tconst key = entry.field ?? \"\"\n\t\tif (!groups[key]) groups[key] = []\n\t\tgroups[key].push(entry)\n\t}\n\n\t// \u5408\u6210\u6587\u672C\n\tlet result = \"\"\n\tfor (const field of Object.keys(groups).sort()) {\n\t\tif (groups[field].length === 0) continue\n\t\tconst group = groups[field]\n\t\tconst title = field === \"\" ? \"[global]\" : `[${field}]`\n\t\tresult += title + \"\\n\"\n\t\tfor (const entry of group) {\n\t\t\tlet line = ` ${entry.type}`\n\t\t\t// \u5BF9\u4E8E\u53D8\u91CF\u7C7B\u578B\uFF0C\u663E\u793A\u540D\u79F0\u800C\u4E0D\u662F\u5B8C\u6574\u63CF\u8FF0\n\t\t\tif (entry.type === \"variable\" || entry.type === \"member_variable\") {\n\t\t\t\tline += `: ${entry.name}`\n\t\t\t} else if (entry.description) {\n\t\t\t\tline += `: ${replaceNewlinesWithSpaces(entry.description)}`\n\t\t\t}\n\t\t\tresult += line + \"\\n\"\n\t\t}\n\t\tresult += \"\\n\"\n\t}\n\treturn result.trimEnd()\n}\n", "import { SnippetType, ISnippetMeta, ParameterInfo, CodeLanguageType } from \"../types\"\nimport Parser from \"web-tree-sitter\"\nimport { generateSnippetHash, buildScopeChain } from \"./general\"\nimport { extractSnippetsFromCapturesForJavaScript } from \"./javascript\"\n\nexport async function extractSnippetsFromCapturesForJSX(\n\tcaptures: Parser.QueryCapture[],\n\tsourceCode: string,\n\tfilePath: string,\n\tfileHash: string,\n\tsnippetTypes: SnippetType[],\n\toptions: { maxSnippetLines: number; minSnippetLines: number },\n): Promise {\n\t// \u9996\u5148\u8BA9JavaScript\u5904\u7406\u5668\u5904\u7406\u57FA\u7840\u7684\u51FD\u6570\u548C\u53D8\u91CF\n\tconst jsSnippets = await extractSnippetsFromCapturesForJavaScript(\n\t\tcaptures,\n\t\tsourceCode,\n\t\tfilePath,\n\t\tfileHash,\n\t\tsnippetTypes,\n\t\toptions,\n\t)\n\n\t// \u66F4\u65B0language\u5B57\u6BB5\u4E3AJSX\uFF0C\u5E76\u4FEE\u6539definition\u7C7B\u578B\u4EE5\u7B26\u5408React\u60EF\u4F8B\n\tfor (const snippet of jsSnippets) {\n\t\tsnippet.language = CodeLanguageType.JSX\n\n\t\t// \u4FEE\u6539\u51FD\u6570\u7684definition\u7C7B\u578B\u4E3Areact_component\n\t\tif (snippet.type === SnippetType.FunctionOrMethod && snippet.definition?.type === \"function\") {\n\t\t\tsnippet.definition.type = \"react_component\"\n\n\t\t\t// \u6539\u8FDB\u53C2\u6570\u89E3\u6790 - \u89E3\u6784\u53C2\u6570\n\t\t\tif (snippet.parameters && snippet.parameters.length > 0) {\n\t\t\t\tconst improvedParams: ParameterInfo[] = []\n\t\t\t\tfor (const param of snippet.parameters) {\n\t\t\t\t\t// \u5904\u7406\u89E3\u6784\u53C2\u6570 {name, age, email}\n\t\t\t\t\tif (param.name.includes(\"{\") && param.name.includes(\"}\")) {\n\t\t\t\t\t\tconst openBrace = param.name.indexOf(\"{\")\n\t\t\t\t\t\tconst closeBrace = param.name.indexOf(\"}\")\n\t\t\t\t\t\tif (openBrace !== -1 && closeBrace !== -1 && closeBrace > openBrace) {\n\t\t\t\t\t\t\tconst destructuredContent = param.name.substring(openBrace + 1, closeBrace)\n\t\t\t\t\t\t\tconst destructuredParams = destructuredContent.split(\",\").map((p) => {\n\t\t\t\t\t\t\t\t// \u79FB\u9664\u9ED8\u8BA4\u503C - \u4F7F\u7528indexOf\u800C\u4E0D\u662F\u6B63\u5219\u8868\u8FBE\u5F0F\n\t\t\t\t\t\t\t\tconst equalIndex = p.indexOf(\"=\")\n\t\t\t\t\t\t\t\tconst cleanParam = equalIndex !== -1 ? p.substring(0, equalIndex).trim() : p.trim()\n\t\t\t\t\t\t\t\treturn cleanParam\n\t\t\t\t\t\t\t})\n\t\t\t\t\t\t\timprovedParams.push(...destructuredParams.map((p) => ({ name: p })))\n\t\t\t\t\t\t}\n\t\t\t\t\t} else {\n\t\t\t\t\t\timprovedParams.push(param)\n\t\t\t\t\t}\n\t\t\t\t}\n\t\t\t\tsnippet.parameters = improvedParams\n\n\t\t\t\t// \u66F4\u65B0\u7B7E\u540D\n\t\t\t\tconst paramStr = improvedParams.map((p) => p.name).join(\", \")\n\t\t\t\tsnippet.signature = `${snippet.name}(${paramStr})`\n\t\t\t}\n\t\t} else if (snippet.type === SnippetType.FunctionOrMethod && snippet.definition?.type === \"arrow function\") {\n\t\t\tsnippet.definition.type = \"react_component\"\n\n\t\t\t// \u6539\u8FDB\u53C2\u6570\u89E3\u6790 - \u89E3\u6784\u53C2\u6570\n\t\t\tif (snippet.parameters && snippet.parameters.length > 0) {\n\t\t\t\tconst improvedParams: ParameterInfo[] = []\n\t\t\t\tfor (const param of snippet.parameters) {\n\t\t\t\t\t// \u5904\u7406\u89E3\u6784\u53C2\u6570 {name, age, email}\n\t\t\t\t\tif (param.name.includes(\"{\") && param.name.includes(\"}\")) {\n\t\t\t\t\t\t// \u4F7F\u7528indexOf\u548Csubstring\u66FF\u4EE3\u6B63\u5219\u8868\u8FBE\u5F0F\n\t\t\t\t\t\tconst openBrace = param.name.indexOf(\"{\")\n\t\t\t\t\t\tconst closeBrace = param.name.indexOf(\"}\")\n\t\t\t\t\t\tif (openBrace !== -1 && closeBrace !== -1 && closeBrace > openBrace) {\n\t\t\t\t\t\t\tconst destructuredContent = param.name.substring(openBrace + 1, closeBrace)\n\t\t\t\t\t\t\tconst destructuredParams = destructuredContent.split(\",\").map((p) => {\n\t\t\t\t\t\t\t\t// \u79FB\u9664\u9ED8\u8BA4\u503C - \u4F7F\u7528indexOf\u800C\u4E0D\u662F\u6B63\u5219\u8868\u8FBE\u5F0F\n\t\t\t\t\t\t\t\tconst equalIndex = p.indexOf(\"=\")\n\t\t\t\t\t\t\t\tconst cleanParam = equalIndex !== -1 ? p.substring(0, equalIndex).trim() : p.trim()\n\t\t\t\t\t\t\t\treturn cleanParam\n\t\t\t\t\t\t\t})\n\t\t\t\t\t\t\timprovedParams.push(...destructuredParams.map((p) => ({ name: p })))\n\t\t\t\t\t\t}\n\t\t\t\t\t} else {\n\t\t\t\t\t\timprovedParams.push(param)\n\t\t\t\t\t}\n\t\t\t\t}\n\t\t\t\tsnippet.parameters = improvedParams\n\n\t\t\t\t// \u66F4\u65B0\u7B7E\u540D\n\t\t\t\tconst paramStr = improvedParams.map((p) => p.name).join(\", \")\n\t\t\t\tsnippet.signature = `${snippet.name}(${paramStr})`\n\t\t\t}\n\t\t} else if (\n\t\t\tsnippet.type === SnippetType.ClassOrInterfaceOrStructOrEnum &&\n\t\t\tsnippet.definition?.type === \"class\"\n\t\t) {\n\t\t\tsnippet.definition.type = \"react_class_component\"\n\t\t} else if (snippet.type === SnippetType.ImportOrInclude && snippet.definition?.type === \"import\") {\n\t\t\tsnippet.definition.type = \"react_import\"\n\t\t}\n\n\t\t// \u4FEE\u6539\u81EA\u5B9A\u4E49hook\uFF08\u4EE5use\u5F00\u5934\u7684\u51FD\u6570\uFF09\u7684definition\u7C7B\u578B\n\t\tif (\n\t\t\tsnippet.type === SnippetType.FunctionOrMethod &&\n\t\t\tsnippet.name.startsWith(\"use\") &&\n\t\t\tsnippet.definition?.type === \"react_component\"\n\t\t) {\n\t\t\tsnippet.definition.type = \"react_custom_hook\"\n\n\t\t\t// \u6539\u8FDB\u81EA\u5B9A\u4E49hook\u7684\u53C2\u6570\u89E3\u6790 - \u4F7F\u7528tree-sitter\u800C\u975E\u6B63\u5219\u8868\u8FBE\u5F0F\n\t\t\tif (snippet.parameters && snippet.parameters.length > 0) {\n\t\t\t\tconst improvedParams: ParameterInfo[] = []\n\t\t\t\tfor (const param of snippet.parameters) {\n\t\t\t\t\t// \u79FB\u9664\u9ED8\u8BA4\u503C\n\t\t\t\t\tconst equalIndex = param.name.indexOf(\"=\")\n\t\t\t\t\tconst cleanName = equalIndex !== -1 ? param.name.substring(0, equalIndex).trim() : param.name\n\t\t\t\t\timprovedParams.push({ name: cleanName })\n\t\t\t\t}\n\t\t\t\tsnippet.parameters = improvedParams\n\n\t\t\t\t// \u66F4\u65B0\u7B7E\u540D\n\t\t\t\tconst paramStr = improvedParams.map((p) => p.name).join(\", \")\n\t\t\t\tsnippet.signature = `${snippet.name}(${paramStr})`\n\t\t\t}\n\t\t}\n\t}\n\n\tconst snippets: ISnippetMeta[] = [...jsSnippets]\n\tconst seenHashes = new Set()\n\n\t// \u586B\u5145\u5DF2\u89C1\u8FC7\u7684\u54C8\u5E0C\u503C\n\tfor (const snippet of snippets) {\n\t\tconst hash = generateSnippetHash(snippet.filePath, snippet.startLine, snippet.endLine, snippet.rangeText)\n\t\tseenHashes.add(hash)\n\t}\n\n\t// === JSX Elements ===\n\tfor (const capture of captures) {\n\t\tif (capture.name !== \"definition.jsx_element\") continue\n\n\t\tconst node = capture.node\n\t\tconst startLine = node.startPosition.row + 1\n\t\tconst endLine = node.endPosition.row + 1\n\n\t\t// Find JSX component name\n\t\tconst nameCap = captures.find(\n\t\t\t(c) =>\n\t\t\t\tc.name === \"name.jsx_element\" &&\n\t\t\t\tc.node.startIndex >= node.startIndex &&\n\t\t\t\tc.node.endIndex <= node.endIndex,\n\t\t)\n\t\tif (!nameCap) continue\n\t\tconst name = sourceCode.substring(nameCap.node.startIndex, nameCap.node.endIndex)\n\n\t\t// Only capture custom components (starting with uppercase) - using character comparison instead of regex\n\t\tconst firstChar = name.charAt(0)\n\t\tif (firstChar < \"A\" || firstChar > \"Z\") continue\n\n\t\tconst rangeText = sourceCode.substring(node.startIndex, node.endIndex)\n\t\tconst snippetHash = generateSnippetHash(filePath, startLine, endLine, rangeText)\n\t\tif (seenHashes.has(snippetHash)) continue\n\t\tseenHashes.add(snippetHash)\n\n\t\tconst scope = buildScopeChain(node)\n\n\t\tsnippets.push({\n\t\t\tname,\n\t\t\tsignature: `<${name}>`,\n\t\t\tparameters: [],\n\t\t\ttype: SnippetType.VariableOrConstant,\n\t\t\tfilePath,\n\t\t\tstartLine,\n\t\t\tendLine,\n\t\t\trangeText,\n\t\t\timplementText: rangeText,\n\t\t\tscope,\n\t\t\tfileHash,\n\t\t\tlanguage: CodeLanguageType.JSX,\n\t\t\tdefinition: {\n\t\t\t\tname,\n\t\t\t\ttype: \"jsx_element\",\n\t\t\t\tparameters: [],\n\t\t\t},\n\t\t})\n\t}\n\n\t// === Process array patterns for useState hooks ===\n\tfor (const capture of captures) {\n\t\tif (capture.name !== \"array_pattern\") continue\n\n\t\tconst node = capture.node\n\t\tconst startLine = node.startPosition.row + 1\n\t\tconst endLine = node.endPosition.row + 1\n\n\t\t// \u68C0\u67E5\u662F\u5426\u662FuseState\u7684\u89E3\u6784\n\t\tconst parentNode = node.parent\n\t\tif (!parentNode || parentNode.type !== \"variable_declarator\") continue\n\n\t\tconst valueNode = parentNode.namedChild(1) // value\u8282\u70B9\n\t\tif (!valueNode || valueNode.type !== \"call_expression\") continue\n\n\t\tconst functionNode = valueNode.namedChild(0) // function\u8282\u70B9\n\t\tif (!functionNode || functionNode.type !== \"identifier\") continue\n\n\t\tconst functionName = sourceCode.substring(functionNode.startIndex, functionNode.endIndex)\n\t\tif (functionName !== \"useState\") continue\n\n\t\t// \u83B7\u53D6\u89E3\u6784\u7684\u53D8\u91CF\u540D\n\t\tconst firstIdentifier = node.namedChild(0)\n\t\tconst secondIdentifier = node.namedChild(1)\n\n\t\tif (\n\t\t\t!firstIdentifier ||\n\t\t\t!secondIdentifier ||\n\t\t\tfirstIdentifier.type !== \"identifier\" ||\n\t\t\tsecondIdentifier.type !== \"identifier\"\n\t\t) {\n\t\t\tcontinue\n\t\t}\n\n\t\tconst stateName = sourceCode.substring(firstIdentifier.startIndex, firstIdentifier.endIndex)\n\t\tconst setterName = sourceCode.substring(secondIdentifier.startIndex, secondIdentifier.endIndex)\n\t\tconst rangeText = sourceCode.substring(parentNode.startIndex, parentNode.endIndex)\n\t\tconst snippetHash = generateSnippetHash(filePath, startLine, endLine, rangeText)\n\t\tif (seenHashes.has(snippetHash)) continue\n\t\tseenHashes.add(snippetHash)\n\n\t\tconst scope = buildScopeChain(node)\n\n\t\tsnippets.push({\n\t\t\tname: stateName,\n\t\t\tsignature: `useState()`,\n\t\t\tparameters: [],\n\t\t\ttype: SnippetType.VariableOrConstant,\n\t\t\tfilePath,\n\t\t\tstartLine,\n\t\t\tendLine,\n\t\t\trangeText,\n\t\t\timplementText: rangeText,\n\t\t\tscope,\n\t\t\tfileHash,\n\t\t\tlanguage: CodeLanguageType.JSX,\n\t\t\tdefinition: {\n\t\t\t\tname: stateName,\n\t\t\t\ttype: \"react_hook\",\n\t\t\t\tparameters: [],\n\t\t\t},\n\t\t})\n\t}\n\n\t// === Process useEffect and other hooks ===\n\tfor (const capture of captures) {\n\t\tif (capture.name !== \"name.definition.function\") continue\n\n\t\tconst node = capture.node\n\t\tconst functionName = sourceCode.substring(node.startIndex, node.endIndex)\n\n\t\t// \u53EA\u5904\u7406React hooks\n\t\tif (!functionName.startsWith(\"use\")) continue\n\n\t\tconst startLine = node.startPosition.row + 1\n\t\tconst endLine = node.endPosition.row + 1\n\n\t\t// \u627E\u5230\u8C03\u7528\u8868\u8FBE\u5F0F\u7684\u7236\u8282\u70B9\n\t\tlet callExpressionNode = node.parent\n\t\twhile (callExpressionNode && callExpressionNode.type !== \"call_expression\") {\n\t\t\tcallExpressionNode = callExpressionNode.parent\n\t\t}\n\n\t\tif (!callExpressionNode) continue\n\n\t\t// \u8DF3\u8FC7\u5DF2\u7ECF\u5904\u7406\u8FC7\u7684useState hooks\uFF08\u907F\u514D\u91CD\u590D\uFF09\n\t\tif (functionName === \"useState\") {\n\t\t\t// \u68C0\u67E5\u662F\u5426\u662F\u89E3\u6784\u8D4B\u503C\n\t\t\tlet parentNode = callExpressionNode.parent\n\t\t\twhile (parentNode && parentNode.type !== \"variable_declarator\") {\n\t\t\t\tparentNode = parentNode.parent\n\t\t\t}\n\t\t\tif (parentNode) {\n\t\t\t\tconst nameNode = parentNode.namedChild(0)\n\t\t\t\tif (nameNode && nameNode.type === \"array_pattern\") {\n\t\t\t\t\tcontinue // \u8DF3\u8FC7\uFF0C\u56E0\u4E3A\u5DF2\u7ECF\u5728useState\u5904\u7406\u4E2D\u5904\u7406\u4E86\n\t\t\t\t}\n\t\t\t}\n\t\t}\n\n\t\tconst rangeText = sourceCode.substring(callExpressionNode.startIndex, callExpressionNode.endIndex)\n\t\tconst snippetHash = generateSnippetHash(filePath, startLine, endLine, rangeText)\n\t\tif (seenHashes.has(snippetHash)) continue\n\t\tseenHashes.add(snippetHash)\n\n\t\tconst scope = buildScopeChain(node)\n\n\t\tsnippets.push({\n\t\t\tname: functionName,\n\t\t\tsignature: `${functionName}()`,\n\t\t\tparameters: [],\n\t\t\ttype: SnippetType.VariableOrConstant,\n\t\t\tfilePath,\n\t\t\tstartLine,\n\t\t\tendLine,\n\t\t\trangeText,\n\t\t\timplementText: rangeText,\n\t\t\tscope,\n\t\t\tfileHash,\n\t\t\tlanguage: CodeLanguageType.JSX,\n\t\t\tdefinition: {\n\t\t\t\tname: functionName,\n\t\t\t\ttype: \"react_hook\",\n\t\t\t\tparameters: [],\n\t\t\t},\n\t\t})\n\t}\n\n\t// === Process HOCs ===\n\tfor (const capture of captures) {\n\t\tif (capture.name !== \"name.definition.variable\") continue\n\n\t\tconst node = capture.node\n\t\tconst variableName = sourceCode.substring(node.startIndex, node.endIndex)\n\n\t\t// \u627E\u5230\u53D8\u91CF\u58F0\u660E\u7684\u7236\u8282\u70B9\n\t\tlet declaratorNode = node.parent\n\t\twhile (declaratorNode && declaratorNode.type !== \"variable_declarator\") {\n\t\t\tdeclaratorNode = declaratorNode.parent\n\t\t}\n\n\t\tif (!declaratorNode) continue\n\n\t\t// \u68C0\u67E5\u662F\u5426\u662F\u51FD\u6570\u8C03\u7528\u8D4B\u503C\n\t\tconst valueNode = declaratorNode.namedChild(1)\n\t\tif (!valueNode || valueNode.type !== \"call_expression\") continue\n\n\t\tconst functionNode = valueNode.namedChild(0)\n\t\tif (!functionNode || functionNode.type !== \"identifier\") continue\n\n\t\tconst functionName = sourceCode.substring(functionNode.startIndex, functionNode.endIndex)\n\n\t\t// Simple HOC detection: function name starts with uppercase or with \"with\" - using character comparison instead of regex\n\t\tconst firstChar = functionName.charAt(0)\n\t\tconst isUppercase = firstChar >= \"A\" && firstChar <= \"Z\"\n\t\tconst startsWithWith = functionName.startsWith(\"with\")\n\n\t\tif (!isUppercase && !startsWithWith) continue\n\n\t\tconst startLine = node.startPosition.row + 1\n\t\tconst endLine = node.endPosition.row + 1\n\n\t\tconst rangeText = sourceCode.substring(declaratorNode.startIndex, declaratorNode.endIndex)\n\t\tconst snippetHash = generateSnippetHash(filePath, startLine, endLine, rangeText)\n\t\tif (seenHashes.has(snippetHash)) continue\n\t\tseenHashes.add(snippetHash)\n\n\t\tconst scope = buildScopeChain(node)\n\n\t\tsnippets.push({\n\t\t\tname: variableName,\n\t\t\tsignature: `${functionName}(${variableName})`,\n\t\t\tparameters: [],\n\t\t\ttype: SnippetType.FunctionOrMethod,\n\t\t\tfilePath,\n\t\t\tstartLine,\n\t\t\tendLine,\n\t\t\trangeText,\n\t\t\timplementText: rangeText,\n\t\t\tscope,\n\t\t\tfileHash,\n\t\t\tlanguage: CodeLanguageType.JSX,\n\t\t\tdefinition: {\n\t\t\t\tname: variableName,\n\t\t\t\ttype: \"react_hoc\",\n\t\t\t\tparameters: [],\n\t\t\t},\n\t\t})\n\t}\n\n\treturn snippets\n}\n\nexport interface OutlineEntry {\n\ttype: string\n\tname: string\n\tfile: string // \u8868\u793A\u5F53\u524D\u6587\u4EF6\n\tfield?: string // \u7A7A\u5B57\u7B26\u4E32\u4EE3\u8868\u5F53\u524D\u6587\u4EF6\u7684global\n\tdescription?: string\n}\n\n/**\n * \u6839\u636E JSX \u6587\u4EF6\u7684\u6240\u6709 snippet \u751F\u6210\u5927\u7EB2\uFF08Outline\uFF09\uFF0C\u652F\u6301 import\u3001component\u3001class\u3001hook\u3001jsx_element\u3001variable\n */\nexport function buildSummaryFromSnippets(snippets: ISnippetMeta[]): OutlineEntry[] {\n\tconst outline: OutlineEntry[] = []\n\n\t// \u5728JSX\u4E2D\uFF0C\u6211\u4EEC\u5E94\u8BE5\u5305\u542B\u6240\u6709\u9876\u7EA7\u5B9A\u4E49\uFF08\u4E0D\u5728\u65B9\u6CD5\u5185\u90E8\u7684\uFF09\n\t// \u5305\u62EC\u7EC4\u4EF6\u3001\u7C7B\u3001hooks\u3001JSX\u5143\u7D20\u3001\u53D8\u91CF\u7B49\n\tconst isTopLevel = (s: ISnippetMeta) => {\n\t\t// \u5982\u679Cscope\u4E3A\u7A7A\u6216\u8005\u53EA\u6709\u4E00\u5C42\uFF08\u6BD4\u5982\u53EA\u6709\u7EC4\u4EF6\u540D\uFF09\uFF0C\u5219\u8BA4\u4E3A\u662F\u9876\u7EA7\n\t\treturn !s.scope || s.scope.length <= 1\n\t}\n\n\tfor (const s of snippets) {\n\t\tif (!isTopLevel(s)) continue\n\t\t// Skip imports - focus on file-level definitions only\n\t\tif (s.type === SnippetType.ImportOrInclude) {\n\t\t\tcontinue\n\t\t} else if (s.type === SnippetType.FunctionOrMethod) {\n\t\t\tconst definitionType = s.definition?.type\n\t\t\tif (definitionType === \"react_component\") {\n\t\t\t\toutline.push({\n\t\t\t\t\ttype: \"component\",\n\t\t\t\t\tname: s.name,\n\t\t\t\t\tfile: s.filePath,\n\t\t\t\t\tfield: \"\",\n\t\t\t\t\tdescription: s.signature,\n\t\t\t\t})\n\t\t\t} else if (definitionType === \"react_custom_hook\") {\n\t\t\t\toutline.push({\n\t\t\t\t\ttype: \"custom_hook\",\n\t\t\t\t\tname: s.name,\n\t\t\t\t\tfile: s.filePath,\n\t\t\t\t\tfield: \"\",\n\t\t\t\t\tdescription: s.signature,\n\t\t\t\t})\n\t\t\t} else {\n\t\t\t\toutline.push({\n\t\t\t\t\ttype: \"function\",\n\t\t\t\t\tname: s.name,\n\t\t\t\t\tfile: s.filePath,\n\t\t\t\t\tfield: s.field || \"\",\n\t\t\t\t\tdescription: s.signature,\n\t\t\t\t})\n\t\t\t}\n\t\t} else if (s.type === SnippetType.ClassOrInterfaceOrStructOrEnum) {\n\t\t\toutline.push({\n\t\t\t\ttype: \"class\",\n\t\t\t\tname: s.name,\n\t\t\t\tfile: s.filePath,\n\t\t\t\tfield: \"\",\n\t\t\t\tdescription: s.signature || s.name,\n\t\t\t})\n\t\t} else if (s.type === SnippetType.VariableOrConstant) {\n\t\t\tconst definitionType = s.definition?.type\n\t\t\tif (definitionType === \"react_hook\") {\n\t\t\t\toutline.push({\n\t\t\t\t\ttype: \"hook\",\n\t\t\t\t\tname: s.name,\n\t\t\t\t\tfile: s.filePath,\n\t\t\t\t\tfield: \"\",\n\t\t\t\t\tdescription: s.signature,\n\t\t\t\t})\n\t\t\t} else if (definitionType === \"jsx_element\") {\n\t\t\t\toutline.push({\n\t\t\t\t\ttype: \"jsx_element\",\n\t\t\t\t\tname: s.name,\n\t\t\t\t\tfile: s.filePath,\n\t\t\t\t\tfield: \"\",\n\t\t\t\t\tdescription: s.signature,\n\t\t\t\t})\n\t\t\t} else {\n\t\t\t\toutline.push({\n\t\t\t\t\ttype: \"variable\",\n\t\t\t\t\tname: s.name,\n\t\t\t\t\tfile: s.filePath,\n\t\t\t\t\tfield: s.field || \"\",\n\t\t\t\t\tdescription: s.signature || s.name,\n\t\t\t\t})\n\t\t\t}\n\t\t}\n\t}\n\n\treturn outline\n}\n\nexport function formatOutlineText(outline: OutlineEntry[]): string {\n\t// \u6309\u7C7B\u578B\u5206\u7EC4\n\tconst groups: Record = {}\n\tfor (const entry of outline) {\n\t\tconst key = entry.type\n\t\tif (!groups[key]) groups[key] = []\n\t\tgroups[key].push(entry)\n\t}\n\n\t// \u5408\u6210\u6587\u672C\n\tlet result = \"\"\n\tconst typeOrder = [\"component\", \"class\", \"custom_hook\", \"hook\", \"jsx_element\", \"function\", \"variable\"]\n\tconst typeLabels: Record = {\n\t\tcomponent: \"## React Components\",\n\t\tclass: \"## Classes\",\n\t\tcustom_hook: \"## Custom Hooks\",\n\t\thook: \"## React Hooks\",\n\t\tjsx_element: \"## JSX Elements\",\n\t\tfunction: \"## Functions\",\n\t\tvariable: \"## Variables\",\n\t}\n\n\tfor (const type of typeOrder) {\n\t\tconst group = groups[type]\n\t\tif (!group || group.length === 0) continue\n\n\t\tresult += typeLabels[type] + \"\\n\"\n\t\tfor (const entry of group) {\n\t\t\tresult += `- ${entry.description || entry.name}\\n`\n\t\t}\n\t\tresult += \"\\n\"\n\t}\n\n\treturn result\n}\n", "import { SnippetType, ISnippetMeta, ParameterInfo, CodeLanguageType } from \"../types\"\nimport Parser from \"web-tree-sitter\"\nimport { generateSnippetHash, buildScopeChain } from \"./general\"\nimport { Logger } from \"../Logger\"\n\nexport async function extractSnippetsFromCapturesForTypeScript(\n\tcaptures: Parser.QueryCapture[],\n\tsourceCode: string,\n\tfilePath: string,\n\tfileHash: string,\n\tsnippetTypes: SnippetType[],\n\toptions: { maxSnippetLines: number; minSnippetLines: number },\n): Promise {\n\tconst logger = Logger.getDefaultLogger().with(\"[TS extract]\")\n\tconst snippets: ISnippetMeta[] = []\n\tconst seen = new Set()\n\tif (snippetTypes.length === 0) return snippets\n\n\t// --- imports ---\n\tfor (const c of captures.filter((c) => c.name === \"name.import\")) {\n\t\tconst node = c.node\n\t\tconst startLine = node.startPosition.row + 1\n\t\tconst endLine = node.endPosition.row + 1\n\t\tconst text = sourceCode.slice(node.startIndex, node.endIndex)\n\t\tconst hash = generateSnippetHash(filePath, startLine, endLine, text)\n\t\tif (seen.has(hash)) continue\n\t\tseen.add(hash)\n\t\tsnippets.push({\n\t\t\tname: text,\n\t\t\ttype: SnippetType.ImportOrInclude,\n\t\t\tfilePath,\n\t\t\tstartLine,\n\t\t\tendLine,\n\t\t\trangeText: text,\n\t\t\tdefinitionText: text,\n\t\t\tscope: buildScopeChain(node),\n\t\t\tfileHash,\n\t\t})\n\t}\n\n\t// --- functions & methods ---\n\tfor (const def of captures.filter((c) => c.name === \"definition.function\" || c.name === \"definition.method\")) {\n\t\tconst node = def.node\n\t\tconst startLine = node.startPosition.row + 1\n\t\tconst endLine = node.endPosition.row + 1\n\n\t\t// \u540D\u79F0\n\t\tconst nameCap = captures.find(\n\t\t\t(c) =>\n\t\t\t\tc.name === (def.name === \"definition.method\" ? \"name.method\" : \"name.function\") &&\n\t\t\t\tc.node.startIndex >= node.startIndex &&\n\t\t\t\tc.node.endIndex <= node.endIndex,\n\t\t)\n\t\tif (!nameCap) continue\n\t\tconst name = sourceCode.slice(nameCap.node.startIndex, nameCap.node.endIndex)\n\n\t\t// \u53C2\u6570\u5217\u8868\n\t\tconst paramsCap = captures.find(\n\t\t\t(c) =>\n\t\t\t\tc.name === \"parameters.function\" &&\n\t\t\t\tc.node.startIndex >= node.startIndex &&\n\t\t\t\tc.node.endIndex <= node.endIndex,\n\t\t)\n\t\tconst parameters: ParameterInfo[] = []\n\t\tif (paramsCap) {\n\t\t\tconst raw = sourceCode.slice(paramsCap.node.startIndex, paramsCap.node.endIndex)\n\t\t\traw.replace(/^\\(|\\)$/g, \"\")\n\t\t\t\t.split(\",\")\n\t\t\t\t.map((p) => p.trim())\n\t\t\t\t.filter((p) => p)\n\t\t\t\t.forEach((p) => parameters.push({ name: p }))\n\t\t}\n\n\t\t// \u662F\u5426\u662F\u7C7B\u65B9\u6CD5\n\t\tconst isMethod = def.name === \"definition.method\"\n\t\t// \u63D0\u53D6\u65B9\u6CD5\u6240\u5C5E class\n\t\tlet field: string | undefined\n\t\tif (isMethod) {\n\t\t\t// \u5728TypeScript\u4E2D\uFF0Cmethod\u5728class\u5185\u90E8\uFF0C\u6240\u4EE5\u67E5\u627E\u5305\u542B\u8FD9\u4E2Amethod\u7684class\n\t\t\t// \u9700\u8981\u627E\u5230\u5305\u542B\u5F53\u524Dmethod\u8282\u70B9\u7684class declaration\n\t\t\tconst classDefCap = captures.find(\n\t\t\t\t(c) =>\n\t\t\t\t\tc.name === \"definition.class\" &&\n\t\t\t\t\tc.node.startIndex < node.startIndex &&\n\t\t\t\t\tc.node.endIndex > node.endIndex,\n\t\t\t)\n\t\t\tif (classDefCap) {\n\t\t\t\tconst classCap = captures.find(\n\t\t\t\t\t(c) =>\n\t\t\t\t\t\tc.name === \"name.class\" &&\n\t\t\t\t\t\tc.node.startIndex >= classDefCap.node.startIndex &&\n\t\t\t\t\t\tc.node.endIndex <= classDefCap.node.endIndex,\n\t\t\t\t)\n\t\t\t\tif (classCap) {\n\t\t\t\t\tfield = sourceCode.slice(classCap.node.startIndex, classCap.node.endIndex)\n\t\t\t\t}\n\t\t\t}\n\t\t}\n\n\t\t// \u7B7E\u540D\u3001hash\n\t\tconst sig = `${name}(${parameters.map((p) => p.name).join(\", \")})`\n\t\tconst hash = generateSnippetHash(filePath, startLine, endLine, sig)\n\t\tif (seen.has(hash)) continue\n\t\tseen.add(hash)\n\n\t\tsnippets.push({\n\t\t\tname,\n\t\t\ttype: SnippetType.FunctionOrMethod,\n\t\t\tfilePath,\n\t\t\tstartLine,\n\t\t\tendLine,\n\t\t\trangeText: sourceCode.slice(node.startIndex, node.endIndex),\n\t\t\tdefinitionText: sig,\n\t\t\tscope: buildScopeChain(node),\n\t\t\tfileHash,\n\t\t\tfield,\n\t\t\tparameters,\n\t\t\tsignature: sig,\n\t\t\tdefinition: {\n\t\t\t\tname,\n\t\t\t\ttype: def.name === \"definition.method\" ? \"method\" : \"function\",\n\t\t\t\tparameters,\n\t\t\t\treturnType: \"\",\n\t\t\t},\n\t\t\tlanguage: CodeLanguageType.TypeScript,\n\t\t\timplementText: sourceCode.slice(node.startIndex, node.endIndex),\n\t\t})\n\t}\n\n\t// --- classes / interfaces / enums / types ---\n\tconst typeDefs = [\n\t\t{\n\t\t\tname: \"name.class\",\n\t\t\tdef: \"definition.class\",\n\t\t\tkind: \"class\",\n\t\t\ttype: SnippetType.ClassOrInterfaceOrStructOrEnum,\n\t\t},\n\t\t{\n\t\t\tname: \"name.interface\",\n\t\t\tdef: \"definition.interface\",\n\t\t\tkind: \"interface\",\n\t\t\ttype: SnippetType.ClassOrInterfaceOrStructOrEnum,\n\t\t},\n\t\t{ name: \"name.enum\", def: \"definition.enum\", kind: \"enum\", type: SnippetType.ClassOrInterfaceOrStructOrEnum },\n\t\t{\n\t\t\tname: \"name.type_alias\",\n\t\t\tdef: \"definition.type_alias\",\n\t\t\tkind: \"type\",\n\t\t\ttype: SnippetType.ClassOrInterfaceOrStructOrEnum,\n\t\t},\n\t]\n\tfor (const { name: capName, def: defName, kind, type } of typeDefs) {\n\t\tfor (const c of captures.filter((c) => c.name === capName)) {\n\t\t\tconst node = c.node\n\t\t\tconst startLine = node.startPosition.row + 1\n\t\t\tconst endLine = node.endPosition.row + 1\n\t\t\tconst text = sourceCode.slice(node.startIndex, node.endIndex)\n\n\t\t\t// \u5224\u65AD\u662F\u5426\u5728\u51FD\u6570/\u65B9\u6CD5\u5185\n\t\t\tconst inFunc = captures.some(\n\t\t\t\t(fc) =>\n\t\t\t\t\t(fc.name === \"definition.function\" || fc.name === \"definition.method\") &&\n\t\t\t\t\tfc.node.startIndex < node.startIndex &&\n\t\t\t\t\tnode.endIndex < fc.node.endIndex,\n\t\t\t)\n\t\t\tif (inFunc) continue\n\n\t\t\t// \u4F18\u5148\u4F7F\u7528definition\u533A\u95F4\n\t\t\tconst defCap = captures.find(\n\t\t\t\t(dc) =>\n\t\t\t\t\tdc.name === defName && dc.node.startIndex <= node.startIndex && node.endIndex <= dc.node.endIndex,\n\t\t\t)\n\t\t\tconst defNode = defCap ? defCap.node : node.parent || node\n\n\t\t\tconst hash = generateSnippetHash(filePath, startLine, endLine, text)\n\t\t\tif (seen.has(hash)) continue\n\t\t\tseen.add(hash)\n\n\t\t\tsnippets.push({\n\t\t\t\tname: text,\n\t\t\t\ttype,\n\t\t\t\tfilePath,\n\t\t\t\tstartLine,\n\t\t\t\tendLine,\n\t\t\t\trangeText: sourceCode.slice(defNode.startIndex, defNode.endIndex),\n\t\t\t\tdefinitionText: text,\n\t\t\t\timplementText: sourceCode.slice(defNode.startIndex, defNode.endIndex),\n\t\t\t\tscope: buildScopeChain(node),\n\t\t\t\tfileHash,\n\t\t\t\tdefinition: { name: text, type: kind },\n\t\t\t\tlanguage: CodeLanguageType.TypeScript,\n\t\t\t\tfield: \"\",\n\t\t\t})\n\t\t}\n\t}\n\n\t// --- \u53D8\u91CF / \u5E38\u91CF ---\n\tfor (const c of captures.filter((c) => c.name === \"name.variable\")) {\n\t\tconst node = c.node\n\t\tconst startLine = node.startPosition.row + 1\n\t\tconst endLine = node.endPosition.row + 1\n\t\tconst name = sourceCode.slice(node.startIndex, node.endIndex)\n\n\t\t// \u8DF3\u8FC7\u51FD\u6570\u5185\u90E8\u5C40\u90E8\u53D8\u91CF\n\t\tconst inFunc = captures.some(\n\t\t\t(fc) =>\n\t\t\t\t(fc.name === \"definition.function\" || fc.name === \"definition.method\") &&\n\t\t\t\tfc.node.startIndex < node.startIndex &&\n\t\t\t\tnode.endIndex < fc.node.endIndex,\n\t\t)\n\t\tif (inFunc) continue\n\n\t\tconst hash = generateSnippetHash(filePath, startLine, endLine, name)\n\t\tif (seen.has(hash)) continue\n\t\tseen.add(hash)\n\n\t\tsnippets.push({\n\t\t\tname,\n\t\t\ttype: SnippetType.VariableOrConstant,\n\t\t\tfilePath,\n\t\t\tstartLine,\n\t\t\tendLine,\n\t\t\trangeText: sourceCode.slice(node.startIndex, node.endIndex),\n\t\t\tdefinitionText: name,\n\t\t\timplementText: name,\n\t\t\tscope: buildScopeChain(node),\n\t\t\tfileHash,\n\t\t\tdefinition: { name, type: \"variable\" },\n\t\t\tlanguage: CodeLanguageType.TypeScript,\n\t\t\tfield: \"\",\n\t\t})\n\t}\n\n\t// --- properties ---\n\tfor (const c of captures.filter((c) => c.name === \"name.property\")) {\n\t\tconst node = c.node\n\t\tconst startLine = node.startPosition.row + 1\n\t\tconst endLine = node.endPosition.row + 1\n\t\tconst name = sourceCode.slice(node.startIndex, node.endIndex)\n\n\t\t// \u67E5\u627E\u6240\u5C5E\u7684interface\u6216class\n\t\tlet field: string | undefined\n\t\tconst parentInterface = captures.find(\n\t\t\t(ic) =>\n\t\t\t\tic.name === \"definition.interface\" &&\n\t\t\t\tic.node.startIndex < node.startIndex &&\n\t\t\t\tic.node.endIndex > node.endIndex,\n\t\t)\n\t\tconst parentClass = captures.find(\n\t\t\t(cc) =>\n\t\t\t\tcc.name === \"definition.class\" &&\n\t\t\t\tcc.node.startIndex < node.startIndex &&\n\t\t\t\tcc.node.endIndex > node.endIndex,\n\t\t)\n\n\t\tif (parentInterface) {\n\t\t\tconst interfaceCap = captures.find(\n\t\t\t\t(ic) =>\n\t\t\t\t\tic.name === \"name.interface\" &&\n\t\t\t\t\tic.node.startIndex >= parentInterface.node.startIndex &&\n\t\t\t\t\tic.node.endIndex <= parentInterface.node.endIndex,\n\t\t\t)\n\t\t\tif (interfaceCap) {\n\t\t\t\tfield = sourceCode.slice(interfaceCap.node.startIndex, interfaceCap.node.endIndex)\n\t\t\t}\n\t\t} else if (parentClass) {\n\t\t\tconst classCap = captures.find(\n\t\t\t\t(cc) =>\n\t\t\t\t\tcc.name === \"name.class\" &&\n\t\t\t\t\tcc.node.startIndex >= parentClass.node.startIndex &&\n\t\t\t\t\tcc.node.endIndex <= parentClass.node.endIndex,\n\t\t\t)\n\t\t\tif (classCap) {\n\t\t\t\tfield = sourceCode.slice(classCap.node.startIndex, classCap.node.endIndex)\n\t\t\t}\n\t\t}\n\n\t\tconst hash = generateSnippetHash(filePath, startLine, endLine, name)\n\t\tif (seen.has(hash)) continue\n\t\tseen.add(hash)\n\n\t\tsnippets.push({\n\t\t\tname,\n\t\t\ttype: SnippetType.VariableOrConstant,\n\t\t\tfilePath,\n\t\t\tstartLine,\n\t\t\tendLine,\n\t\t\trangeText: sourceCode.slice(node.startIndex, node.endIndex),\n\t\t\tdefinitionText: name,\n\t\t\timplementText: name,\n\t\t\tscope: buildScopeChain(node),\n\t\t\tfileHash,\n\t\t\tfield,\n\t\t\tdefinition: { name, type: \"property\" },\n\t\t\tlanguage: CodeLanguageType.TypeScript,\n\t\t})\n\t}\n\n\treturn snippets\n}\n\nexport interface OutlineEntry {\n\ttype: string\n\tname: string\n\tfile: string\n\tfield?: string\n\tdescription?: string\n}\n\nexport function buildSummaryFromSnippets(snips: ISnippetMeta[]): OutlineEntry[] {\n\tconst outline: OutlineEntry[] = []\n\tfor (const s of snips) {\n\t\tif (s.type === SnippetType.ImportOrInclude) {\n\t\t\toutline.push({ type: \"import\", name: s.name, file: s.filePath, field: \"\", description: s.definitionText })\n\t\t} else if (s.type === SnippetType.FunctionOrMethod) {\n\t\t\toutline.push({\n\t\t\t\ttype: s.field ? \"method\" : \"function\",\n\t\t\t\tname: s.name,\n\t\t\t\tfile: s.filePath,\n\t\t\t\tfield: s.field || \"\",\n\t\t\t\tdescription: s.definitionText,\n\t\t\t})\n\t\t} else if (s.type === SnippetType.ClassOrInterfaceOrStructOrEnum) {\n\t\t\toutline.push({\n\t\t\t\ttype: s.definition?.type || \"type\",\n\t\t\t\tname: s.name,\n\t\t\t\tfile: s.filePath,\n\t\t\t\tfield: \"\",\n\t\t\t\tdescription: s.name,\n\t\t\t})\n\t\t} else if (s.type === SnippetType.VariableOrConstant) {\n\t\t\toutline.push({ type: \"variable\", name: s.name, file: s.filePath, field: \"\", description: s.definitionText })\n\t\t}\n\t}\n\treturn outline\n}\n\nexport function formatOutlineText(outline: OutlineEntry[]): string {\n\tconst groups: Record = {}\n\tfor (const e of outline) {\n\t\tconst key = e.field || \"\"\n\t\t;(groups[key] ||= []).push(e)\n\t}\n\tlet out = \"\"\n\tfor (const field of Object.keys(groups).sort()) {\n\t\tout += (field ? `[${field}]` : \"[global]\") + \"\\n\"\n\t\tfor (const e of groups[field]) {\n\t\t\tout += ` ${e.type}: ${e.description}\\n`\n\t\t}\n\t\tout += \"\\n\"\n\t}\n\treturn out.trimEnd()\n}\n", "import { SnippetType, ISnippetMeta, ParameterInfo, CodeLanguageType } from \"../types\"\nimport Parser from \"web-tree-sitter\"\nimport { generateSnippetHash, buildScopeChain } from \"./general\"\nimport { extractSnippetsFromCapturesForTypeScript } from \"./typescript\"\nimport { Logger } from \"../Logger\"\n\n// Helper function to check if a name starts with uppercase letter\nfunction startsWithUppercase(name: string): boolean {\n\treturn name.length > 0 && name[0] >= \"A\" && name[0] <= \"Z\"\n}\n\n// Helper function to check if a function is a generic component\nfunction isGenericComponent(rangeText: string): boolean {\n\treturn rangeText.includes(\"function\") && rangeText.includes(\"<\") && rangeText.includes(\">(\")\n}\n\n// Helper function to clean parameter name by removing type annotations, defaults, and optional markers\nfunction cleanParameterName(paramText: string): string {\n\tlet cleaned = paramText.trim()\n\n\t// Remove type annotation (: type)\n\tconst colonIndex = cleaned.indexOf(\":\")\n\tif (colonIndex !== -1) {\n\t\tcleaned = cleaned.substring(0, colonIndex).trim()\n\t}\n\n\t// Remove default value (= value)\n\tconst equalsIndex = cleaned.indexOf(\"=\")\n\tif (equalsIndex !== -1) {\n\t\tcleaned = cleaned.substring(0, equalsIndex).trim()\n\t}\n\n\t// Remove optional marker (?)\n\tif (cleaned.endsWith(\"?\")) {\n\t\tcleaned = cleaned.slice(0, -1).trim()\n\t}\n\n\treturn cleaned\n}\n\n// Helper function to extract parameters from destructured props using string parsing\nfunction extractDestructuredParamsFromText(paramText: string): string[] {\n\tconst params: string[] = []\n\n\t// Find destructuring pattern { ... }\n\tconst openBrace = paramText.indexOf(\"{\")\n\tconst closeBrace = paramText.lastIndexOf(\"}\")\n\n\tif (openBrace !== -1 && closeBrace !== -1 && closeBrace > openBrace) {\n\t\tconst destructuredContent = paramText.substring(openBrace + 1, closeBrace)\n\t\tconst paramNames = destructuredContent.split(\",\")\n\n\t\tfor (const param of paramNames) {\n\t\t\tconst cleanName = cleanParameterName(param)\n\t\t\tif (cleanName && cleanName !== \"...\" && !cleanName.includes(\"...\")) {\n\t\t\t\tparams.push(cleanName)\n\t\t\t}\n\t\t}\n\t}\n\n\treturn params\n}\n\nexport async function extractSnippetsFromCapturesForTSX(\n\tcaptures: Parser.QueryCapture[],\n\tsourceCode: string,\n\tfilePath: string,\n\tfileHash: string,\n\tsnippetTypes: SnippetType[],\n\toptions: { maxSnippetLines: number; minSnippetLines: number },\n): Promise {\n\tconst logger = Logger.getDefaultLogger().with(\"[TSX extract]\")\n\n\t// \u9996\u5148\u8BA9TypeScript\u5904\u7406\u5668\u5904\u7406\u57FA\u7840\u7684\u51FD\u6570\u3001\u7C7B\u3001\u63A5\u53E3\u3001\u53D8\u91CF\u7B49\n\tconst tsSnippets = await extractSnippetsFromCapturesForTypeScript(\n\t\tcaptures,\n\t\tsourceCode,\n\t\tfilePath,\n\t\tfileHash,\n\t\tsnippetTypes,\n\t\toptions,\n\t)\n\n\t// \u66F4\u65B0language\u5B57\u6BB5\u4E3ATSX\uFF0C\u5E76\u4FEE\u6539definition\u7C7B\u578B\u4EE5\u7B26\u5408React\u60EF\u4F8B\n\tfor (const snippet of tsSnippets) {\n\t\tsnippet.language = CodeLanguageType.TSX\n\n\t\t// \u4FEE\u6539\u51FD\u6570\u7684definition\u7C7B\u578B\u4E3Areact_component\n\t\tif (snippet.type === SnippetType.FunctionOrMethod && snippet.definition?.type === \"function\") {\n\t\t\t// \u4FEE\u6539\u81EA\u5B9A\u4E49hook\uFF08\u4EE5use\u5F00\u5934\u7684\u51FD\u6570\uFF09\u7684definition\u7C7B\u578B\n\t\t\tif (snippet.name.startsWith(\"use\")) {\n\t\t\t\tsnippet.definition.type = \"react_custom_hook\"\n\t\t\t} else {\n\t\t\t\t// \u68C0\u67E5\u662F\u5426\u662FReact\u7EC4\u4EF6\uFF08\u51FD\u6570\u540D\u4EE5\u5927\u5199\u5B57\u6BCD\u5F00\u5934\u6216\u8FD4\u56DEJSX\uFF09\n\t\t\t\tconst isReactComponent =\n\t\t\t\t\tstartsWithUppercase(snippet.name) ||\n\t\t\t\t\t(snippet.rangeText.includes(\"return\") &&\n\t\t\t\t\t\tsnippet.rangeText.includes(\"<\") &&\n\t\t\t\t\t\tsnippet.rangeText.includes(\">\"))\n\n\t\t\t\tif (isReactComponent) {\n\t\t\t\t\t// \u68C0\u67E5\u662F\u5426\u662F\u6CDB\u578B\u7EC4\u4EF6\n\t\t\t\t\tif (\n\t\t\t\t\t\tsnippet.rangeText.includes(\"<\") &&\n\t\t\t\t\t\tsnippet.rangeText.includes(\">(\") &&\n\t\t\t\t\t\tisGenericComponent(snippet.rangeText)\n\t\t\t\t\t) {\n\t\t\t\t\t\tsnippet.definition.type = \"react_generic_component\"\n\t\t\t\t\t} else {\n\t\t\t\t\t\tsnippet.definition.type = \"react_component\"\n\t\t\t\t\t}\n\t\t\t\t}\n\t\t\t}\n\n\t\t\t// \u6539\u8FDB\u53C2\u6570\u89E3\u6790 - \u5904\u7406props\u89E3\u6784\u53C2\u6570\n\t\t\tif (snippet.parameters && snippet.parameters.length > 0) {\n\t\t\t\t// \u9996\u5148\u91CD\u65B0\u7EC4\u5408\u6240\u6709\u53C2\u6570\uFF0C\u4EE5\u68C0\u6D4B\u88AB\u5206\u5272\u7684\u89E3\u6784\u53C2\u6570\n\t\t\t\tconst paramTexts = snippet.parameters.map((p) => p.name.trim())\n\t\t\t\tconst fullParamText = paramTexts.join(\", \")\n\n\t\t\t\tconst improvedParams: ParameterInfo[] = []\n\n\t\t\t\t// \u68C0\u67E5\u91CD\u65B0\u7EC4\u5408\u7684\u6587\u672C\u662F\u5426\u5305\u542B\u89E3\u6784\u53C2\u6570\n\t\t\t\tif (fullParamText.includes(\"{\") && fullParamText.includes(\"}\")) {\n\t\t\t\t\t// \u91CD\u65B0\u89E3\u6790\u6574\u4E2A\u53C2\u6570\u5B57\u7B26\u4E32\u4F7F\u7528\u5B57\u7B26\u4E32\u65B9\u6CD5\n\t\t\t\t\tconst destructuredParams = extractDestructuredParamsFromText(fullParamText)\n\t\t\t\t\timprovedParams.push(...destructuredParams.map((p) => ({ name: p })))\n\t\t\t\t} else {\n\t\t\t\t\t// \u5904\u7406\u666E\u901A\u53C2\u6570\n\t\t\t\t\tfor (const param of snippet.parameters) {\n\t\t\t\t\t\tconst paramText = param.name.trim()\n\t\t\t\t\t\tconst cleanName = cleanParameterName(paramText)\n\t\t\t\t\t\tif (cleanName && !cleanName.includes(\"{\") && !cleanName.includes(\"}\")) {\n\t\t\t\t\t\t\timprovedParams.push({ name: cleanName })\n\t\t\t\t\t\t}\n\t\t\t\t\t}\n\t\t\t\t}\n\n\t\t\t\tsnippet.parameters = improvedParams\n\n\t\t\t\t// \u66F4\u65B0\u7B7E\u540D\n\t\t\t\tconst paramStr = improvedParams.map((p) => p.name).join(\", \")\n\t\t\t\tsnippet.signature = `${snippet.name}(${paramStr})`\n\t\t\t} else if (!snippet.parameters || snippet.parameters.length === 0) {\n\t\t\t\t// \u5982\u679C snippet.parameters \u662F\u7A7A\u7684\u6216\u4E0D\u5B58\u5728\uFF0C\u4F46 definition.parameters \u6709\u5185\u5BB9\uFF0C\u4F7F\u7528 definition.parameters\n\t\t\t\tif (snippet.definition?.parameters && snippet.definition.parameters.length > 0) {\n\t\t\t\t\t// \u9700\u8981\u91CD\u65B0\u7EC4\u5408\u88AB\u9519\u8BEF\u5206\u5272\u7684\u89E3\u6784\u53C2\u6570\n\t\t\t\t\tconst paramTexts = snippet.definition.parameters.map((p) => p.name || \"\")\n\t\t\t\t\tconst fullParamText = paramTexts.join(\", \")\n\n\t\t\t\t\tconst improvedParams: ParameterInfo[] = []\n\n\t\t\t\t\t// \u68C0\u67E5\u662F\u5426\u5305\u542B\u89E3\u6784\u53C2\u6570\n\t\t\t\t\tif (fullParamText.includes(\"{\") && fullParamText.includes(\"}\")) {\n\t\t\t\t\t\t// \u91CD\u65B0\u89E3\u6790\u6574\u4E2A\u53C2\u6570\u5B57\u7B26\u4E32\u4F7F\u7528\u5B57\u7B26\u4E32\u65B9\u6CD5\n\t\t\t\t\t\tconst destructuredParams = extractDestructuredParamsFromText(fullParamText)\n\t\t\t\t\t\timprovedParams.push(...destructuredParams.map((p) => ({ name: p })))\n\t\t\t\t\t} else {\n\t\t\t\t\t\t// \u5904\u7406\u666E\u901A\u53C2\u6570\n\t\t\t\t\t\tfor (const param of snippet.definition.parameters) {\n\t\t\t\t\t\t\tconst paramText = param.name?.trim() || \"\"\n\t\t\t\t\t\t\tconst cleanName = cleanParameterName(paramText)\n\t\t\t\t\t\t\tif (cleanName && !cleanName.includes(\"{\") && !cleanName.includes(\"}\")) {\n\t\t\t\t\t\t\t\timprovedParams.push({ name: cleanName })\n\t\t\t\t\t\t\t}\n\t\t\t\t\t\t}\n\t\t\t\t\t}\n\n\t\t\t\t\tsnippet.parameters = improvedParams\n\n\t\t\t\t\t// \u66F4\u65B0\u7B7E\u540D\n\t\t\t\t\tconst paramStr = improvedParams.map((p) => p.name).join(\", \")\n\t\t\t\t\tsnippet.signature = `${snippet.name}(${paramStr})`\n\t\t\t\t}\n\t\t\t}\n\t\t} else if (snippet.type === SnippetType.FunctionOrMethod && snippet.definition?.type === \"method\") {\n\t\t\t// \u7C7B\u65B9\u6CD5\u4FDD\u6301\u539F\u6837\uFF0C\u4F46\u66F4\u65B0\u8BED\u8A00\u7C7B\u578B\n\t\t} else if (\n\t\t\tsnippet.type === SnippetType.ClassOrInterfaceOrStructOrEnum &&\n\t\t\tsnippet.definition?.type === \"class\"\n\t\t) {\n\t\t\t// \u68C0\u67E5\u662F\u5426\u662FReact\u7C7B\u7EC4\u4EF6\uFF08\u7EE7\u627F\u81EAComponent\u6216PureComponent\uFF09\n\t\t\tif (\n\t\t\t\tsnippet.rangeText.includes(\"extends\") &&\n\t\t\t\t(snippet.rangeText.includes(\"Component\") || snippet.rangeText.includes(\"PureComponent\"))\n\t\t\t) {\n\t\t\t\tsnippet.definition.type = \"react_class_component\"\n\t\t\t}\n\t\t} else if (snippet.type === SnippetType.ImportOrInclude && snippet.definition?.type === \"import\") {\n\t\t\tsnippet.definition.type = \"react_import\"\n\t\t} else if (snippet.type === SnippetType.VariableOrConstant && snippet.definition?.type === \"variable\") {\n\t\t\t// \u68C0\u67E5\u53D8\u91CF\u662F\u5426\u662FReact\u7EC4\u4EF6\uFF08\u4EE5\u5927\u5199\u5B57\u6BCD\u5F00\u5934\u4E14\u53EF\u80FD\u5305\u542BJSX\uFF09\n\t\t\tif (startsWithUppercase(snippet.name)) {\n\t\t\t\t// \u7531\u4E8E rangeText \u53EF\u80FD\u53EA\u5305\u542B\u53D8\u91CF\u540D\uFF0C\u6211\u4EEC\u9700\u8981\u68C0\u67E5\u4EE3\u7801\u4E0A\u4E0B\u6587\n\t\t\t\t// \u68C0\u67E5\u662F\u5426\u5728\u540C\u4E00\u6587\u4EF6\u4E2D\u6709\u5BF9\u5E94\u7684\u51FD\u6570\u7EC4\u4EF6\u5B9A\u4E49\n\t\t\t\tconst isLikelyComponent =\n\t\t\t\t\ttsSnippets.some(\n\t\t\t\t\t\t(s) =>\n\t\t\t\t\t\t\ts.name === snippet.name &&\n\t\t\t\t\t\t\ts.type === SnippetType.FunctionOrMethod &&\n\t\t\t\t\t\t\ts.definition?.type === \"react_component\",\n\t\t\t\t\t) ||\n\t\t\t\t\t// \u6216\u8005\u68C0\u67E5\u5E38\u89C1\u7684 React \u7EC4\u4EF6\u6A21\u5F0F\n\t\t\t\t\tsnippet.rangeText.includes(\"withError\") ||\n\t\t\t\t\tsnippet.rangeText.includes(\"memo(\") ||\n\t\t\t\t\tsnippet.rangeText.includes(\"forwardRef(\") ||\n\t\t\t\t\tsnippet.rangeText.includes(\"lazy(\") ||\n\t\t\t\t\tsnippet.rangeText.includes(\"React.\") ||\n\t\t\t\t\tsnippet.rangeText.includes(\"FC\") ||\n\t\t\t\t\tsnippet.rangeText.includes(\"FunctionComponent\") ||\n\t\t\t\t\t(snippet.rangeText.includes(\"=>\") &&\n\t\t\t\t\t\tsnippet.rangeText.includes(\"<\") &&\n\t\t\t\t\t\tsnippet.rangeText.includes(\">\"))\n\n\t\t\t\tif (isLikelyComponent) {\n\t\t\t\t\tsnippet.definition.type = \"react_component\"\n\t\t\t\t\tsnippet.type = SnippetType.FunctionOrMethod // \u6539\u53D8\u7C7B\u578B\u4E3A\u51FD\u6570\u7EC4\u4EF6\n\t\t\t\t}\n\t\t\t}\n\t\t}\n\t}\n\n\tconst snippets: ISnippetMeta[] = [...tsSnippets]\n\tconst seenHashes = new Set()\n\n\t// \u586B\u5145\u5DF2\u89C1\u8FC7\u7684\u54C8\u5E0C\u503C\n\tfor (const snippet of snippets) {\n\t\tconst hash = generateSnippetHash(snippet.filePath, snippet.startLine, snippet.endLine, snippet.rangeText)\n\t\tseenHashes.add(hash)\n\t}\n\n\t// === JSX Components ===\n\tfor (const capture of captures) {\n\t\tif (\n\t\t\tcapture.name !== \"definition.component\" &&\n\t\t\tcapture.name !== \"definition.jsx_element\" &&\n\t\t\tcapture.name !== \"definition.jsx_self_closing_element\"\n\t\t)\n\t\t\tcontinue\n\n\t\tconst node = capture.node\n\t\tconst startLine = node.startPosition.row + 1\n\t\tconst endLine = node.endPosition.row + 1\n\n\t\t// Find JSX component name\n\t\tlet nameCap: Parser.QueryCapture | undefined\n\t\tif (capture.name === \"definition.component\") {\n\t\t\tnameCap = captures.find(\n\t\t\t\t(c) => c.name === \"name\" && c.node.startIndex >= node.startIndex && c.node.endIndex <= node.endIndex,\n\t\t\t)\n\t\t} else {\n\t\t\tnameCap = captures.find(\n\t\t\t\t(c) =>\n\t\t\t\t\tc.name === \"component\" && c.node.startIndex >= node.startIndex && c.node.endIndex <= node.endIndex,\n\t\t\t)\n\t\t}\n\n\t\tif (!nameCap) continue\n\t\tconst name = sourceCode.substring(nameCap.node.startIndex, nameCap.node.endIndex)\n\n\t\t// Only capture custom components (starting with uppercase) or known React components\n\t\tif (!startsWithUppercase(name) && !isKnownReactComponent(name)) continue\n\n\t\tconst rangeText = sourceCode.substring(node.startIndex, node.endIndex)\n\t\tconst snippetHash = generateSnippetHash(filePath, startLine, endLine, rangeText)\n\t\tif (seenHashes.has(snippetHash)) continue\n\t\tseenHashes.add(snippetHash)\n\n\t\tconst scope = buildScopeChain(node)\n\n\t\tsnippets.push({\n\t\t\tname,\n\t\t\tsignature: `<${name}>`,\n\t\t\ttype: SnippetType.FunctionOrMethod,\n\t\t\tfilePath,\n\t\t\tstartLine,\n\t\t\tendLine,\n\t\t\trangeText,\n\t\t\tdefinitionText: `<${name}>`,\n\t\t\timplementText: rangeText,\n\t\t\tscope,\n\t\t\tfileHash,\n\t\t\tlanguage: CodeLanguageType.TSX,\n\t\t\tdefinition: {\n\t\t\t\tname,\n\t\t\t\ttype: \"jsx_component\",\n\t\t\t\tparameters: [],\n\t\t\t\treturnType: \"JSX.Element\",\n\t\t\t},\n\t\t})\n\t}\n\n\t// === JSX Member Components (e.g., Button.Primary) ===\n\tfor (const capture of captures) {\n\t\tif (capture.name !== \"definition.member_component\") continue\n\n\t\tconst node = capture.node\n\t\tconst startLine = node.startPosition.row + 1\n\t\tconst endLine = node.endPosition.row + 1\n\n\t\t// Find object and property\n\t\tconst objectCap = captures.find(\n\t\t\t(c) => c.name === \"object\" && c.node.startIndex >= node.startIndex && c.node.endIndex <= node.endIndex,\n\t\t)\n\t\tconst propertyCap = captures.find(\n\t\t\t(c) => c.name === \"property\" && c.node.startIndex >= node.startIndex && c.node.endIndex <= node.endIndex,\n\t\t)\n\n\t\tif (!objectCap || !propertyCap) continue\n\n\t\tconst objectName = sourceCode.substring(objectCap.node.startIndex, objectCap.node.endIndex)\n\t\tconst propertyName = sourceCode.substring(propertyCap.node.startIndex, propertyCap.node.endIndex)\n\t\tconst fullName = `${objectName}.${propertyName}`\n\n\t\t// Only capture if object starts with uppercase (component namespace)\n\t\tif (!startsWithUppercase(objectName)) continue\n\n\t\tconst rangeText = sourceCode.substring(node.startIndex, node.endIndex)\n\t\tconst snippetHash = generateSnippetHash(filePath, startLine, endLine, rangeText)\n\t\tif (seenHashes.has(snippetHash)) continue\n\t\tseenHashes.add(snippetHash)\n\n\t\tconst scope = buildScopeChain(node)\n\n\t\tsnippets.push({\n\t\t\tname: fullName,\n\t\t\tsignature: `<${fullName}>`,\n\t\t\ttype: SnippetType.FunctionOrMethod,\n\t\t\tfilePath,\n\t\t\tstartLine,\n\t\t\tendLine,\n\t\t\trangeText,\n\t\t\tdefinitionText: `<${fullName}>`,\n\t\t\timplementText: rangeText,\n\t\t\tscope,\n\t\t\tfileHash,\n\t\t\tfield: objectName,\n\t\t\tlanguage: CodeLanguageType.TSX,\n\t\t\tdefinition: {\n\t\t\t\tname: fullName,\n\t\t\t\ttype: \"jsx_member_component\",\n\t\t\t\tparameters: [],\n\t\t\t\treturnType: \"JSX.Element\",\n\t\t\t},\n\t\t})\n\t}\n\n\t// === JSX Conditional Components ===\n\tfor (const capture of captures) {\n\t\tif (capture.name !== \"definition.conditional_component\") continue\n\n\t\tconst node = capture.node\n\t\tconst startLine = node.startPosition.row + 1\n\t\tconst endLine = node.endPosition.row + 1\n\n\t\t// Find component name in conditional expression\n\t\tconst componentCap = captures.find(\n\t\t\t(c) => c.name === \"component\" && c.node.startIndex >= node.startIndex && c.node.endIndex <= node.endIndex,\n\t\t)\n\n\t\tif (!componentCap) continue\n\t\tconst name = sourceCode.substring(componentCap.node.startIndex, componentCap.node.endIndex)\n\n\t\t// Only capture custom components (starting with uppercase)\n\t\tif (!startsWithUppercase(name)) continue\n\n\t\tconst rangeText = sourceCode.substring(node.startIndex, node.endIndex)\n\t\tconst snippetHash = generateSnippetHash(filePath, startLine, endLine, rangeText)\n\t\tif (seenHashes.has(snippetHash)) continue\n\t\tseenHashes.add(snippetHash)\n\n\t\tconst scope = buildScopeChain(node)\n\n\t\tsnippets.push({\n\t\t\tname,\n\t\t\tsignature: `{condition ? <${name}> : null}`,\n\t\t\ttype: SnippetType.FunctionOrMethod,\n\t\t\tfilePath,\n\t\t\tstartLine,\n\t\t\tendLine,\n\t\t\trangeText,\n\t\t\tdefinitionText: `{condition ? <${name}> : null}`,\n\t\t\timplementText: rangeText,\n\t\t\tscope,\n\t\t\tfileHash,\n\t\t\tlanguage: CodeLanguageType.TSX,\n\t\t\tdefinition: {\n\t\t\t\tname,\n\t\t\t\ttype: \"jsx_conditional_component\",\n\t\t\t\tparameters: [],\n\t\t\t\treturnType: \"JSX.Element | null\",\n\t\t\t},\n\t\t})\n\t}\n\n\t// === Generic Components ===\n\tfor (const capture of captures) {\n\t\tif (capture.name !== \"definition.generic_component\") continue\n\n\t\tconst node = capture.node\n\t\tconst startLine = node.startPosition.row + 1\n\t\tconst endLine = node.endPosition.row + 1\n\n\t\t// Find component name\n\t\tconst nameCap = captures.find(\n\t\t\t(c) => c.name === \"name\" && c.node.startIndex >= node.startIndex && c.node.endIndex <= node.endIndex,\n\t\t)\n\n\t\tif (!nameCap) continue\n\t\tconst name = sourceCode.substring(nameCap.node.startIndex, nameCap.node.endIndex)\n\n\t\t// Check if it's a React component (starts with uppercase or returns JSX)\n\t\tconst isReactComponent =\n\t\t\tstartsWithUppercase(name) || sourceCode.substring(node.startIndex, node.endIndex).includes(\"JSX\")\n\n\t\tif (!isReactComponent) continue\n\n\t\tconst rangeText = sourceCode.substring(node.startIndex, node.endIndex)\n\t\tconst snippetHash = generateSnippetHash(filePath, startLine, endLine, rangeText)\n\t\tif (seenHashes.has(snippetHash)) continue\n\t\tseenHashes.add(snippetHash)\n\n\t\tconst scope = buildScopeChain(node)\n\n\t\tsnippets.push({\n\t\t\tname,\n\t\t\tsignature: `${name}`,\n\t\t\ttype: SnippetType.FunctionOrMethod,\n\t\t\tfilePath,\n\t\t\tstartLine,\n\t\t\tendLine,\n\t\t\trangeText,\n\t\t\tdefinitionText: `${name}`,\n\t\t\timplementText: rangeText,\n\t\t\tscope,\n\t\t\tfileHash,\n\t\t\tlanguage: CodeLanguageType.TSX,\n\t\t\tdefinition: {\n\t\t\t\tname,\n\t\t\t\ttype: \"react_generic_component\",\n\t\t\t\tparameters: [],\n\t\t\t\treturnType: \"JSX.Element\",\n\t\t\t},\n\t\t})\n\t}\n\n\treturn snippets\n}\n\n// Helper function to check if a component name is a known React component\nfunction isKnownReactComponent(name: string): boolean {\n\tconst knownComponents = [\n\t\t\"Fragment\",\n\t\t\"Suspense\",\n\t\t\"StrictMode\",\n\t\t\"Profiler\",\n\t\t\"ErrorBoundary\",\n\t\t\"Provider\",\n\t\t\"Consumer\",\n\t\t\"Portal\",\n\t]\n\treturn knownComponents.includes(name)\n}\n\nexport interface OutlineEntry {\n\ttype: string\n\tname: string\n\tfile: string\n\tfield?: string\n\tdescription?: string\n}\n\nexport function buildSummaryFromSnippets(snips: ISnippetMeta[]): OutlineEntry[] {\n\tconst outline: OutlineEntry[] = []\n\tfor (const s of snips) {\n\t\tif (s.type === SnippetType.ImportOrInclude) {\n\t\t\toutline.push({\n\t\t\t\ttype: \"import\",\n\t\t\t\tname: s.name,\n\t\t\t\tfile: s.filePath,\n\t\t\t\tfield: \"\",\n\t\t\t\tdescription: s.definitionText,\n\t\t\t})\n\t\t} else if (s.type === SnippetType.FunctionOrMethod) {\n\t\t\tlet type = \"function\"\n\t\t\tif (s.definition?.type === \"react_component\") type = \"component\"\n\t\t\telse if (s.definition?.type === \"react_custom_hook\") type = \"hook\"\n\t\t\telse if (s.definition?.type === \"jsx_component\") type = \"jsx\"\n\t\t\telse if (s.definition?.type === \"jsx_member_component\") type = \"jsx.member\"\n\t\t\telse if (s.definition?.type === \"jsx_conditional_component\") type = \"jsx.conditional\"\n\t\t\telse if (s.definition?.type === \"react_generic_component\") type = \"component.generic\"\n\t\t\telse if (s.field) type = \"method\"\n\n\t\t\toutline.push({\n\t\t\t\ttype,\n\t\t\t\tname: s.name,\n\t\t\t\tfile: s.filePath,\n\t\t\t\tfield: s.field || \"\",\n\t\t\t\tdescription: s.definitionText,\n\t\t\t})\n\t\t} else if (s.type === SnippetType.ClassOrInterfaceOrStructOrEnum) {\n\t\t\tlet type = s.definition?.type || \"type\"\n\t\t\tif (s.definition?.type === \"react_class_component\") type = \"class.component\"\n\n\t\t\toutline.push({\n\t\t\t\ttype,\n\t\t\t\tname: s.name,\n\t\t\t\tfile: s.filePath,\n\t\t\t\tfield: \"\",\n\t\t\t\tdescription: s.name,\n\t\t\t})\n\t\t} else if (s.type === SnippetType.VariableOrConstant) {\n\t\t\toutline.push({\n\t\t\t\ttype: \"variable\",\n\t\t\t\tname: s.name,\n\t\t\t\tfile: s.filePath,\n\t\t\t\tfield: s.field || \"\",\n\t\t\t\tdescription: s.definitionText,\n\t\t\t})\n\t\t}\n\t}\n\treturn outline\n}\n\nexport function formatOutlineText(outline: OutlineEntry[]): string {\n\tconst groups: Record = {}\n\tfor (const e of outline) {\n\t\tconst key = e.field || \"\"\n\t\t;(groups[key] ||= []).push(e)\n\t}\n\tlet out = \"\"\n\tfor (const field of Object.keys(groups).sort()) {\n\t\tout += (field ? `[${field}]` : \"[global]\") + \"\\n\"\n\t\tfor (const e of groups[field]) {\n\t\t\tout += ` ${e.type}: ${e.description}\\n`\n\t\t}\n\t\tout += \"\\n\"\n\t}\n\treturn out.trimEnd()\n}\n", "import { SnippetType, ISnippetMeta, ParameterInfo, CodeLanguageType } from \"../types\"\nimport Parser from \"web-tree-sitter\"\nimport { generateSnippetHash, buildScopeChain } from \"./general\"\nimport { Logger } from \"../Logger\"\n\nexport async function extractSnippetsFromCapturesForSwift(\n\tcaptures: Parser.QueryCapture[],\n\tsourceCode: string,\n\tfilePath: string,\n\tfileHash: string,\n\tsnippetTypes: SnippetType[],\n\toptions: { maxSnippetLines: number; minSnippetLines: number },\n): Promise {\n\tconst logger = Logger.getDefaultLogger().with(\"[extractSnippetsFromCapturesForSwift]\")\n\n\tconst snippets: ISnippetMeta[] = []\n\tconst seenHashes = new Set()\n\n\tif (snippetTypes.length === 0) {\n\t\tlogger.warn(`No snippet types provided, skipping`)\n\t\treturn snippets\n\t}\n\n\t// \u6536\u96C6\u6240\u6709\u7C7B/\u7ED3\u6784\u4F53/\u534F\u8BAE/\u6269\u5C55captures\u7528\u4E8E\u786E\u5B9Afield\n\tconst containerCaptures = captures\n\t\t.filter(\n\t\t\t(c) =>\n\t\t\t\tc.name === \"definition.class\" ||\n\t\t\t\tc.name === \"definition.struct\" ||\n\t\t\t\tc.name === \"definition.protocol\" ||\n\t\t\t\tc.name === \"definition.enum\",\n\t\t)\n\t\t.map((c) => {\n\t\t\tconst node = c.node\n\t\t\tconst type = c.name.split(\".\")[1] // class, struct, protocol, enum\n\n\t\t\t// \u67E5\u627E\u540D\u79F0capture\n\t\t\tlet nameCap = captures.find(\n\t\t\t\t(nc) =>\n\t\t\t\t\tnc.name === `name.${c.name}` &&\n\t\t\t\t\tnc.node.startIndex >= node.startIndex &&\n\t\t\t\t\tnc.node.endIndex <= node.endIndex,\n\t\t\t)\n\n\t\t\t// \u7279\u6B8A\u5904\u7406extension\uFF1A\u83B7\u53D6\u88AB\u6269\u5C55\u7684\u7C7B\u578B\u540D\n\t\t\tlet actualName = nameCap ? sourceCode.substring(nameCap.node.startIndex, nameCap.node.endIndex) : \"\"\n\t\t\tif (type === \"class\") {\n\t\t\t\tconst actualType = determineClassDeclarationType(node, sourceCode)\n\t\t\t\tif (actualType === \"extension\") {\n\t\t\t\t\t// \u5BF9\u4E8Eextension\uFF0C\u83B7\u53D6\u88AB\u6269\u5C55\u7684\u7C7B\u578B\u540D\uFF08\u7B2C\u4E8C\u4E2A\u5B50\u8282\u70B9\u7684type_identifier\uFF09\n\t\t\t\t\tif (node.childCount >= 2) {\n\t\t\t\t\t\tconst userTypeNode = node.child(1) // user_type\u8282\u70B9\n\t\t\t\t\t\tif (userTypeNode && userTypeNode.type === \"user_type\" && userTypeNode.childCount > 0) {\n\t\t\t\t\t\t\tconst typeIdNode = userTypeNode.child(0)\n\t\t\t\t\t\t\tif (typeIdNode && typeIdNode.type === \"type_identifier\") {\n\t\t\t\t\t\t\t\tactualName = sourceCode.substring(typeIdNode.startIndex, typeIdNode.endIndex)\n\t\t\t\t\t\t\t}\n\t\t\t\t\t\t}\n\t\t\t\t\t}\n\t\t\t\t}\n\t\t\t}\n\n\t\t\treturn {\n\t\t\t\tnode,\n\t\t\t\tstart: node.startIndex,\n\t\t\t\tend: node.endIndex,\n\t\t\t\ttype,\n\t\t\t\tnameCap,\n\t\t\t\tactualName, // \u5B9E\u9645\u7684\u7C7B\u578B\u540D\uFF08\u5BF9\u4E8Eextension\u662F\u88AB\u6269\u5C55\u7684\u7C7B\u578B\uFF09\n\t\t\t}\n\t\t})\n\n\t// \u5904\u7406import\u8BED\u53E5\n\tcaptures.forEach((capture) => {\n\t\tif (capture.name === \"name.definition.import\") {\n\t\t\tconst node = capture.node\n\t\t\tconst startLine = node.startPosition.row + 1\n\t\t\tconst endLine = node.endPosition.row + 1\n\t\t\tconst rangeText = sourceCode.substring(node.startIndex, node.endIndex)\n\t\t\tconst snippetHash = generateSnippetHash(filePath, startLine, endLine, rangeText)\n\t\t\tif (seenHashes.has(snippetHash)) return\n\t\t\tseenHashes.add(snippetHash)\n\n\t\t\tconst name = sourceCode.substring(node.startIndex, node.endIndex)\n\t\t\tconst scope = buildScopeChain(node)\n\n\t\t\tsnippets.push({\n\t\t\t\tname,\n\t\t\t\ttype: SnippetType.ImportOrInclude,\n\t\t\t\tfilePath,\n\t\t\t\tstartLine,\n\t\t\t\tendLine,\n\t\t\t\trangeText,\n\t\t\t\tdefinitionText: rangeText,\n\t\t\t\tscope,\n\t\t\t\tfileHash,\n\t\t\t})\n\t\t}\n\t})\n\n\t// \u5904\u7406\u51FD\u6570/\u65B9\u6CD5\u5B9A\u4E49\n\tfor (const capture of captures) {\n\t\tif (\n\t\t\tcapture.name !== \"definition.method\" &&\n\t\t\tcapture.name !== \"definition.initializer\" &&\n\t\t\tcapture.name !== \"definition.deinitializer\" &&\n\t\t\tcapture.name !== \"definition.protocol_method\"\n\t\t)\n\t\t\tcontinue\n\n\t\tconst node = capture.node\n\t\tconst startLine = node.startPosition.row + 1\n\t\tconst endLine = node.endPosition.row + 1\n\n\t\t// \u67E5\u627E\u51FD\u6570/\u65B9\u6CD5\u540D\n\t\tlet nameCap: Parser.QueryCapture | undefined\n\t\tif (capture.name === \"definition.method\") {\n\t\t\tnameCap = captures.find(\n\t\t\t\t(c) =>\n\t\t\t\t\tc.name === \"name.definition.method\" &&\n\t\t\t\t\tc.node.startIndex >= node.startIndex &&\n\t\t\t\t\tc.node.endIndex <= node.endIndex,\n\t\t\t)\n\t\t} else if (capture.name === \"definition.protocol_method\") {\n\t\t\tnameCap = captures.find(\n\t\t\t\t(c) =>\n\t\t\t\t\tc.name === \"name.definition.protocol_method\" &&\n\t\t\t\t\tc.node.startIndex >= node.startIndex &&\n\t\t\t\t\tc.node.endIndex <= node.endIndex,\n\t\t\t)\n\t\t} else if (capture.name === \"definition.initializer\") {\n\t\t\tnameCap = captures.find(\n\t\t\t\t(c) =>\n\t\t\t\t\tc.name === \"name.definition.initializer\" &&\n\t\t\t\t\tc.node.startIndex >= node.startIndex &&\n\t\t\t\t\tc.node.endIndex <= node.endIndex,\n\t\t\t)\n\t\t} else if (capture.name === \"definition.deinitializer\") {\n\t\t\tnameCap = captures.find(\n\t\t\t\t(c) =>\n\t\t\t\t\tc.name === \"name.definition.deinitializer\" &&\n\t\t\t\t\tc.node.startIndex >= node.startIndex &&\n\t\t\t\t\tc.node.endIndex <= node.endIndex,\n\t\t\t)\n\t\t}\n\n\t\tif (!nameCap) continue\n\t\tconst name = sourceCode.substring(nameCap.node.startIndex, nameCap.node.endIndex)\n\n\t\t// \u67E5\u627E\u53C2\u6570 - \u4E3ASwift\u5B9E\u73B0\u57FA\u672C\u7684\u53C2\u6570\u89E3\u6790\n\t\tconst parameters: ParameterInfo[] = []\n\n\t\t// \u67E5\u627E\u51FD\u6570\u58F0\u660E\u4E2D\u7684\u53C2\u6570\u5217\u8868\n\t\t// Swift\u51FD\u6570\u53C2\u6570\u5728 parameter_list \u8282\u70B9\u4E2D\n\t\tlet parameterNodes: Parser.SyntaxNode[] = []\n\t\tfunction findParameterNodes(node: Parser.SyntaxNode) {\n\t\t\tif (node.type === \"parameter\") {\n\t\t\t\tparameterNodes.push(node)\n\t\t\t}\n\t\t\tfor (let i = 0; i < node.childCount; i++) {\n\t\t\t\tconst child = node.child(i)\n\t\t\t\tif (child) {\n\t\t\t\t\tfindParameterNodes(child)\n\t\t\t\t}\n\t\t\t}\n\t\t}\n\t\tfindParameterNodes(node)\n\n\t\t// \u89E3\u6790\u6BCF\u4E2A\u53C2\u6570\n\t\tfor (const paramNode of parameterNodes) {\n\t\t\t// \u67E5\u627E\u53C2\u6570\u540D - Swift\u53C2\u6570\u53EF\u80FD\u6709external name\u548Cinternal name\n\t\t\tlet paramName = \"\"\n\t\t\tfor (let i = 0; i < paramNode.childCount; i++) {\n\t\t\t\tconst child = paramNode.child(i)\n\t\t\t\tif (child && child.type === \"simple_identifier\") {\n\t\t\t\t\tparamName = sourceCode.substring(child.startIndex, child.endIndex)\n\t\t\t\t\tbreak\n\t\t\t\t}\n\t\t\t}\n\n\t\t\tif (paramName) {\n\t\t\t\tparameters.push({\n\t\t\t\t\tname: paramName,\n\t\t\t\t\ttype: \"Any\", // \u6682\u65F6\u4F7F\u7528\u5360\u4F4D\u7B26\u7C7B\u578B\n\t\t\t\t})\n\t\t\t}\n\t\t}\n\n\t\t// \u67E5\u627E\u65B9\u6CD5\u4F53\n\t\tconst bodyCap = captures.find(\n\t\t\t(c) =>\n\t\t\t\tc.name === \"body.definition.method\" &&\n\t\t\t\tc.node.startIndex >= node.startIndex &&\n\t\t\t\tc.node.endIndex <= node.endIndex,\n\t\t)\n\n\t\tlet rangeText: string\n\t\tlet implementText: string | undefined = undefined\n\n\t\tif (bodyCap) {\n\t\t\t// \u83B7\u53D6\u65B9\u6CD5\u7B7E\u540D\uFF08\u4E0D\u5305\u62EC\u65B9\u6CD5\u4F53\uFF09\n\t\t\trangeText = sourceCode.substring(node.startIndex, bodyCap.node.startIndex).trimEnd()\n\t\t\timplementText = sourceCode.substring(node.startIndex, node.endIndex)\n\t\t} else {\n\t\t\trangeText = sourceCode.substring(node.startIndex, node.endIndex)\n\t\t}\n\n\t\tconst snippetHash = generateSnippetHash(filePath, startLine, endLine, rangeText)\n\t\tif (seenHashes.has(snippetHash)) continue\n\t\tseenHashes.add(snippetHash)\n\n\t\t// \u67E5\u627E\u8FD4\u56DE\u7C7B\u578B - \u6682\u65F6\u8DF3\u8FC7\n\t\tlet returnType = \"\"\n\n\t\tconst paramStr = parameters.map((p) => p.name).join(\", \")\n\t\tconst signature = `${name}(${paramStr})`\n\t\tconst scope = buildScopeChain(node)\n\n\t\t// \u786E\u5B9A\u662F\u5426\u5C5E\u4E8E\u67D0\u4E2A\u7C7B/\u7ED3\u6784\u4F53/\u534F\u8BAE\uFF08\u8BBE\u7F6Efield\uFF09\n\t\tlet field: string | undefined = undefined\n\t\tlet closestContainer: (typeof containerCaptures)[0] | undefined = undefined\n\n\t\t// \u627E\u5230\u6700\u5C0F\u7684\u5305\u542B\u5F53\u524D\u8282\u70B9\u7684\u5BB9\u5668\n\t\tfor (const container of containerCaptures) {\n\t\t\tif (node.startIndex > container.start && node.endIndex <= container.end) {\n\t\t\t\tif (\n\t\t\t\t\t!closestContainer ||\n\t\t\t\t\tcontainer.end - container.start < closestContainer.end - closestContainer.start\n\t\t\t\t) {\n\t\t\t\t\tclosestContainer = container\n\t\t\t\t}\n\t\t\t}\n\t\t}\n\n\t\tif (closestContainer) {\n\t\t\t// \u5BF9\u4E8Eextension\uFF0C\u4F7F\u7528\u88AB\u6269\u5C55\u7684\u7C7B\u578B\u540D\uFF1B\u5426\u5219\u4F7F\u7528\u5BB9\u5668\u7684\u540D\u79F0\n\t\t\tfield =\n\t\t\t\tclosestContainer.actualName ||\n\t\t\t\t(closestContainer.nameCap\n\t\t\t\t\t? sourceCode.substring(\n\t\t\t\t\t\t\tclosestContainer.nameCap.node.startIndex,\n\t\t\t\t\t\t\tclosestContainer.nameCap.node.endIndex,\n\t\t\t\t\t\t)\n\t\t\t\t\t: undefined)\n\t\t}\n\n\t\tsnippets.push({\n\t\t\tname,\n\t\t\ttype: SnippetType.FunctionOrMethod,\n\t\t\tfilePath,\n\t\t\tstartLine,\n\t\t\tendLine,\n\t\t\trangeText,\n\t\t\tdefinitionText: rangeText,\n\t\t\tscope,\n\t\t\tfileHash,\n\t\t\tfield,\n\t\t\tdefinition: {\n\t\t\t\tname,\n\t\t\t\ttype: node.type,\n\t\t\t\tparameters,\n\t\t\t\treturnType,\n\t\t\t},\n\t\t\tparameters,\n\t\t\tsignature,\n\t\t\tlanguage: CodeLanguageType.Swift,\n\t\t\t...(implementText ? { implementText } : {}),\n\t\t})\n\t}\n\n\t// \u5904\u7406\u5C5E\u6027\u5B9A\u4E49\uFF08\u5305\u542B\u8BA1\u7B97\u5C5E\u6027\uFF09\n\tfor (const capture of captures) {\n\t\tif (capture.name !== \"definition.property\" && capture.name !== \"definition.computed_property\") continue\n\n\t\tconst node = capture.node\n\t\tconst startLine = node.startPosition.row + 1\n\t\tconst endLine = node.endPosition.row + 1\n\n\t\t// \u68C0\u67E5\u662F\u5426\u5DF2\u7ECF\u5904\u7406\u8FC7\u8FD9\u4E2A\u8282\u70B9\uFF08\u9632\u6B62\u91CD\u590D\u5904\u7406\u540C\u4E00\u4E2A\u5C5E\u6027\uFF09\n\t\tconst nodeHash = `${node.startIndex}-${node.endIndex}`\n\t\tconst isAlreadyProcessed = snippets.some(\n\t\t\t(s) => s.rangeText === sourceCode.substring(node.startIndex, node.endIndex) && s.startLine === startLine,\n\t\t)\n\t\tif (isAlreadyProcessed) continue\n\n\t\t// \u67E5\u627E\u5C5E\u6027\u540D\uFF0C\u4F18\u5148\u4F7F\u7528computed_property\u7684\u540D\u79F0\n\t\tlet nameCap: Parser.QueryCapture | undefined\n\t\tlet isComputedProperty = false\n\n\t\t// \u9996\u5148\u68C0\u67E5\u662F\u5426\u6709computed_property\u540D\u79F0capture\n\t\tnameCap = captures.find(\n\t\t\t(c) =>\n\t\t\t\tc.name === \"name.definition.computed_property\" &&\n\t\t\t\tc.node.startIndex >= node.startIndex &&\n\t\t\t\tc.node.endIndex <= node.endIndex,\n\t\t)\n\n\t\tif (nameCap) {\n\t\t\tisComputedProperty = true\n\t\t} else {\n\t\t\t// \u5982\u679C\u6CA1\u6709\uFF0C\u4F7F\u7528\u666E\u901Aproperty\u540D\u79F0capture\n\t\t\tnameCap = captures.find(\n\t\t\t\t(c) =>\n\t\t\t\t\tc.name === \"name.definition.property\" &&\n\t\t\t\t\tc.node.startIndex >= node.startIndex &&\n\t\t\t\t\tc.node.endIndex <= node.endIndex,\n\t\t\t)\n\t\t}\n\n\t\tif (!nameCap) continue\n\t\tconst name = sourceCode.substring(nameCap.node.startIndex, nameCap.node.endIndex)\n\n\t\t// \u5224\u65AD\u662F\u5426\u5728\u5BB9\u5668\u5185\u90E8\n\t\tconst isInContainer = containerCaptures.some(\n\t\t\t(container) => node.startIndex > container.start && node.endIndex <= container.end,\n\t\t)\n\n\t\tif (!isInContainer) continue // \u53EA\u5904\u7406\u7C7B/\u7ED3\u6784\u4F53\u5185\u7684\u5C5E\u6027\n\n\t\tconst rangeText = sourceCode.substring(node.startIndex, node.endIndex)\n\t\tconst snippetHash = generateSnippetHash(filePath, startLine, endLine, rangeText)\n\t\tif (seenHashes.has(snippetHash)) continue\n\t\tseenHashes.add(snippetHash)\n\n\t\tconst scope = buildScopeChain(node)\n\n\t\t// \u786E\u5B9A\u5C5E\u4E8E\u54EA\u4E2A\u5BB9\u5668\n\t\tlet field: string | undefined = undefined\n\t\tlet closestContainer: (typeof containerCaptures)[0] | undefined = undefined\n\n\t\t// \u627E\u5230\u6700\u5C0F\u7684\u5305\u542B\u5F53\u524D\u8282\u70B9\u7684\u5BB9\u5668\n\t\tfor (const container of containerCaptures) {\n\t\t\tif (node.startIndex > container.start && node.endIndex <= container.end) {\n\t\t\t\tif (\n\t\t\t\t\t!closestContainer ||\n\t\t\t\t\tcontainer.end - container.start < closestContainer.end - closestContainer.start\n\t\t\t\t) {\n\t\t\t\t\tclosestContainer = container\n\t\t\t\t}\n\t\t\t}\n\t\t}\n\n\t\tif (closestContainer) {\n\t\t\t// \u5BF9\u4E8Eextension\uFF0C\u4F7F\u7528\u88AB\u6269\u5C55\u7684\u7C7B\u578B\u540D\uFF1B\u5426\u5219\u4F7F\u7528\u5BB9\u5668\u7684\u540D\u79F0\n\t\t\tfield =\n\t\t\t\tclosestContainer.actualName ||\n\t\t\t\t(closestContainer.nameCap\n\t\t\t\t\t? sourceCode.substring(\n\t\t\t\t\t\t\tclosestContainer.nameCap.node.startIndex,\n\t\t\t\t\t\t\tclosestContainer.nameCap.node.endIndex,\n\t\t\t\t\t\t)\n\t\t\t\t\t: undefined)\n\t\t}\n\n\t\tsnippets.push({\n\t\t\tname,\n\t\t\ttype: SnippetType.VariableOrConstant,\n\t\t\tfilePath,\n\t\t\tstartLine,\n\t\t\tendLine,\n\t\t\trangeText,\n\t\t\tdefinitionText: rangeText,\n\t\t\timplementText: rangeText,\n\t\t\tscope,\n\t\t\tfileHash,\n\t\t\tfield,\n\t\t\tdefinition: {\n\t\t\t\tname,\n\t\t\t\ttype: isComputedProperty ? \"computed_property\" : \"property\",\n\t\t\t},\n\t\t\tlanguage: CodeLanguageType.Swift,\n\t\t})\n\t}\n\n\t// \u5904\u7406\u5168\u5C40\u53D8\u91CF\u548C\u5E38\u91CF\n\tfor (const capture of captures) {\n\t\tif (capture.name !== \"definition.global_var\") continue\n\n\t\tconst node = capture.node\n\t\tconst startLine = node.startPosition.row + 1\n\t\tconst endLine = node.endPosition.row + 1\n\n\t\t// \u67E5\u627E\u53D8\u91CF\u540D\n\t\tconst nameCap = captures.find(\n\t\t\t(c) =>\n\t\t\t\tc.name === \"name.definition.global_var\" &&\n\t\t\t\tc.node.startIndex >= node.startIndex &&\n\t\t\t\tc.node.endIndex <= node.endIndex,\n\t\t)\n\n\t\tif (!nameCap) continue\n\t\tconst name = sourceCode.substring(nameCap.node.startIndex, nameCap.node.endIndex)\n\n\t\tconst rangeText = sourceCode.substring(node.startIndex, node.endIndex)\n\t\tconst snippetHash = generateSnippetHash(filePath, startLine, endLine, rangeText)\n\t\tif (seenHashes.has(snippetHash)) continue\n\t\tseenHashes.add(snippetHash)\n\n\t\tconst scope = buildScopeChain(node)\n\n\t\t// \u5224\u65AD\u662Flet\u8FD8\u662Fvar\n\t\tlet varType = \"var\"\n\t\tif (rangeText.trim().startsWith(\"let\")) {\n\t\t\tvarType = \"let\"\n\t\t}\n\n\t\tsnippets.push({\n\t\t\tname,\n\t\t\ttype: SnippetType.VariableOrConstant,\n\t\t\tfilePath,\n\t\t\tstartLine,\n\t\t\tendLine,\n\t\t\trangeText,\n\t\t\tdefinitionText: rangeText,\n\t\t\timplementText: rangeText,\n\t\t\tscope,\n\t\t\tfileHash,\n\t\t\tfield: \"\",\n\t\t\tdefinition: { name, type: varType },\n\t\t\tlanguage: CodeLanguageType.Swift,\n\t\t})\n\t}\n\n\t// \u5904\u7406\u7C7B/\u7ED3\u6784\u4F53/\u534F\u8BAE/\u679A\u4E3E\u5B9A\u4E49\n\tconst typeDefs = [\n\t\t{ capture: \"name.definition.class\", outlineType: \"class\" },\n\t\t{ capture: \"name.definition.protocol\", outlineType: \"protocol\" },\n\t\t{ capture: \"name.definition.type_alias\", outlineType: \"typealias\" },\n\t]\n\n\tfor (const { capture, outlineType } of typeDefs) {\n\t\tconst defCaptureName = `definition.${outlineType === \"typealias\" ? \"type_alias\" : outlineType}`\n\n\t\tfor (const cap of captures.filter((c) => c.name === capture)) {\n\t\t\tconst node = cap.node\n\n\t\t\t// \u5224\u65AD\u662F\u5426\u5728\u51FD\u6570/\u65B9\u6CD5\u5185\n\t\t\tconst isInFunc = captures.some(\n\t\t\t\t(fc) =>\n\t\t\t\t\t(fc.name === \"definition.method\" ||\n\t\t\t\t\t\tfc.name === \"definition.initializer\" ||\n\t\t\t\t\t\tfc.name === \"definition.deinitializer\") &&\n\t\t\t\t\tfc.node.startIndex < node.startIndex &&\n\t\t\t\t\tnode.endIndex < fc.node.endIndex,\n\t\t\t)\n\t\t\tif (isInFunc) continue\n\n\t\t\t// \u4F18\u5148\u4F7F\u7528@definition.xxx\u533A\u95F4 - \u627E\u5230\u6700\u5177\u4F53\uFF08\u6700\u5C0F\uFF09\u7684\u5305\u542B\u6B64\u540D\u79F0\u7684\u5B9A\u4E49\n\t\t\tlet defCap = captures\n\t\t\t\t.filter(\n\t\t\t\t\t(c) =>\n\t\t\t\t\t\tc.name === defCaptureName &&\n\t\t\t\t\t\tc.node.startIndex <= node.startIndex &&\n\t\t\t\t\t\tnode.endIndex <= c.node.endIndex,\n\t\t\t\t)\n\t\t\t\t.sort((a, b) => a.node.endIndex - a.node.startIndex - (b.node.endIndex - b.node.startIndex))[0]\n\n\t\t\tconst rangeText = defCap\n\t\t\t\t? sourceCode.substring(defCap.node.startIndex, defCap.node.endIndex)\n\t\t\t\t: sourceCode.substring(node.startIndex, node.endIndex)\n\n\t\t\t// \u5BF9\u4E8Eclass_declaration\uFF0C\u4F7F\u7528AST\u68C0\u67E5\u786E\u5B9A\u771F\u5B9E\u7C7B\u578B\n\t\t\tlet actualType = outlineType\n\t\t\tif (outlineType === \"class\" && defCap) {\n\t\t\t\tactualType = determineClassDeclarationType(defCap.node, sourceCode)\n\t\t\t}\n\n\t\t\tconst startLine = node.startPosition.row + 1\n\t\t\tconst endLine = node.endPosition.row + 1\n\t\t\tconst snippetHash = generateSnippetHash(filePath, startLine, endLine, rangeText)\n\t\t\tif (seenHashes.has(snippetHash)) continue\n\t\t\tseenHashes.add(snippetHash)\n\n\t\t\tconst name = sourceCode.substring(node.startIndex, node.endIndex)\n\n\t\t\tsnippets.push({\n\t\t\t\tname,\n\t\t\t\ttype: SnippetType.ClassOrInterfaceOrStructOrEnum,\n\t\t\t\tfilePath,\n\t\t\t\tstartLine,\n\t\t\t\tendLine,\n\t\t\t\trangeText,\n\t\t\t\tdefinitionText: rangeText,\n\t\t\t\timplementText: rangeText,\n\t\t\t\tscope: [],\n\t\t\t\tfileHash,\n\t\t\t\tfield: \"\",\n\t\t\t\tdefinition: { name, type: actualType },\n\t\t\t\tlanguage: CodeLanguageType.Swift,\n\t\t\t})\n\t\t}\n\t}\n\n\t// \u6839\u636EsnippetTypes\u8FC7\u6EE4\u5E76\u6392\u5E8F\n\treturn snippets.filter((snippet) => snippetTypes.includes(snippet.type)).sort((a, b) => a.startLine - b.startLine)\n}\n\n/**\n * \u5C06\u6587\u672C\u4E2D\u7684\u6362\u884C\u7B26\u66FF\u6362\u4E3A\u7A7A\u683C\uFF0C\u63D0\u9AD8\u53EF\u8BFB\u6027\n */\nfunction normalizeTextForSummary(text: string): string {\n\treturn text.split(\"\\n\").join(\" \")\n}\n\n/**\n * \u786E\u5B9Aclass_declaration\u7684\u5B9E\u9645\u7C7B\u578B\uFF08class\u3001struct\u3001enum\u3001extension\uFF09\n */\nfunction determineClassDeclarationType(node: Parser.SyntaxNode, sourceCode: string): string {\n\t// \u68C0\u67E5\u7B2C\u4E00\u4E2A\u5B50\u8282\u70B9\u6765\u786E\u5B9A\u7C7B\u578B\n\tif (node.childCount > 0) {\n\t\tconst firstChild = node.child(0)\n\t\tif (firstChild) {\n\t\t\tconst firstChildType = firstChild.type\n\t\t\tif (firstChildType === \"struct\") return \"struct\"\n\t\t\tif (firstChildType === \"enum\") return \"enum\"\n\t\t\tif (firstChildType === \"class\") return \"class\"\n\t\t\tif (firstChildType === \"extension\") return \"extension\"\n\t\t}\n\t}\n\t// \u9ED8\u8BA4\u8FD4\u56DEclass\n\treturn \"class\"\n}\nfunction parseSwiftParameters(paramText: string): string[] {\n\tif (!paramText.trim()) return []\n\n\tconst params: string[] = []\n\tlet current = \"\"\n\tlet parenDepth = 0\n\tlet bracketDepth = 0\n\tlet inString = false\n\tlet stringChar = \"\"\n\n\tfor (let i = 0; i < paramText.length; i++) {\n\t\tconst char = paramText[i]\n\n\t\tif (!inString) {\n\t\t\tif (char === '\"' || char === \"'\") {\n\t\t\t\tinString = true\n\t\t\t\tstringChar = char\n\t\t\t} else if (char === \"(\") {\n\t\t\t\tparenDepth++\n\t\t\t} else if (char === \")\") {\n\t\t\t\tparenDepth--\n\t\t\t} else if (char === \"[\") {\n\t\t\t\tbracketDepth++\n\t\t\t} else if (char === \"]\") {\n\t\t\t\tbracketDepth--\n\t\t\t} else if (char === \",\" && parenDepth === 0 && bracketDepth === 0) {\n\t\t\t\tif (current.trim()) {\n\t\t\t\t\tparams.push(current.trim())\n\t\t\t\t}\n\t\t\t\tcurrent = \"\"\n\t\t\t\tcontinue\n\t\t\t}\n\t\t} else {\n\t\t\tif (char === stringChar && paramText[i - 1] !== \"\\\\\") {\n\t\t\t\tinString = false\n\t\t\t\tstringChar = \"\"\n\t\t\t}\n\t\t}\n\n\t\tcurrent += char\n\t}\n\n\tif (current.trim()) {\n\t\tparams.push(current.trim())\n\t}\n\n\treturn params\n}\n\n// VSCode Outline Entry \u7C7B\u578B\nexport interface OutlineEntry {\n\ttype: string\n\tname: string\n\tfile: string // \u8868\u793A\u5F53\u524D\u6587\u4EF6\n\tfield?: string // \u7A7A\u5B57\u7B26\u4E32\u4EE3\u8868\u5F53\u524D\u6587\u4EF6\u7684global\n\tdescription?: string\n}\n\n/**\n * \u6839\u636ESwift\u6587\u4EF6\u7684\u6240\u6709snippet\u751F\u6210\u5927\u7EB2\uFF08Outline\uFF09\n */\nexport function buildSummaryFromSnippets(snippets: ISnippetMeta[]): OutlineEntry[] {\n\tconst outline: OutlineEntry[] = []\n\n\t// \u53EA\u4FDD\u7559\u5168\u5C40\u5B9A\u4E49\uFF08scope\u4E3A\u7A7A\u6216\u5168\u4E3A\"\"\uFF09\n\tconst isGlobal = (s: ISnippetMeta) => !s.scope || s.scope.length === 0 || s.scope.every((x) => !x)\n\n\tfor (const s of snippets) {\n\t\tif (!isGlobal(s)) continue\n\n\t\tif (s.type === SnippetType.ImportOrInclude) {\n\t\t\toutline.push({\n\t\t\t\ttype: \"import\",\n\t\t\t\tname: s.name,\n\t\t\t\tfile: s.filePath,\n\t\t\t\tfield: \"\",\n\t\t\t\tdescription: s.definitionText,\n\t\t\t})\n\t\t} else if (s.type === SnippetType.FunctionOrMethod) {\n\t\t\tif (s.field) {\n\t\t\t\toutline.push({\n\t\t\t\t\ttype: \"method\",\n\t\t\t\t\tname: s.name,\n\t\t\t\t\tfile: s.filePath,\n\t\t\t\t\tfield: s.field,\n\t\t\t\t\tdescription: s.definitionText,\n\t\t\t\t})\n\t\t\t} else {\n\t\t\t\toutline.push({\n\t\t\t\t\ttype: \"function\",\n\t\t\t\t\tname: s.name,\n\t\t\t\t\tfile: s.filePath,\n\t\t\t\t\tfield: \"\",\n\t\t\t\t\tdescription: s.definitionText,\n\t\t\t\t})\n\t\t\t}\n\t\t} else if (s.type === SnippetType.VariableOrConstant) {\n\t\t\tconst t = s.definition?.type || \"var\"\n\t\t\toutline.push({\n\t\t\t\ttype: t,\n\t\t\t\tname: s.name,\n\t\t\t\tfile: s.filePath,\n\t\t\t\tfield: s.field || \"\",\n\t\t\t\tdescription: s.definitionText,\n\t\t\t})\n\t\t} else if (s.type === SnippetType.ClassOrInterfaceOrStructOrEnum) {\n\t\t\tconst t = s.definition?.type || \"type\"\n\t\t\toutline.push({\n\t\t\t\ttype: t,\n\t\t\t\tname: s.name,\n\t\t\t\tfile: s.filePath,\n\t\t\t\tfield: \"\",\n\t\t\t\tdescription: s.name,\n\t\t\t})\n\t\t}\n\t}\n\n\treturn outline\n}\n\n/**\n * \u5C06OutlineEntry[]\u683C\u5F0F\u5316\u4E3A\u6587\u672C\uFF0C\u540C\u4E00\u4E2Afield\u7684\u653E\u5728\u4E00\u8D77\u3002\n */\nexport function formatOutlineText(outline: OutlineEntry[]): string {\n\t// \u6309field\u5206\u7EC4\n\tconst groups: Record = {}\n\tfor (const entry of outline) {\n\t\tconst key = entry.field ?? \"\"\n\t\tif (!groups[key]) groups[key] = []\n\t\tgroups[key].push(entry)\n\t}\n\n\t// \u5408\u6210\u6587\u672C\n\tlet result = \"\"\n\tfor (const field of Object.keys(groups).sort()) {\n\t\tconst group = groups[field]\n\t\tconst title = field === \"\" ? \"[global]\" : `[${field}]`\n\t\tresult += title + \"\\n\"\n\t\tfor (const entry of group) {\n\t\t\tlet line = ` ${entry.type}`\n\t\t\tif (entry.description) line += `: ${normalizeTextForSummary(entry.description)}`\n\t\t\tresult += line + \"\\n\"\n\t\t}\n\t\tresult += \"\\n\"\n\t}\n\treturn result.trimEnd()\n}\n", "import { SnippetType, ISnippetMeta, ParameterInfo, CodeLanguageType } from \"../types\"\nimport Parser from \"web-tree-sitter\"\nimport { generateSnippetHash, buildScopeChain } from \"./general\"\nimport { Logger } from \"../Logger\"\n\n/**\n * CSS\u7279\u5B9A\u7684\u8F85\u52A9\u51FD\u6570\n */\n\n/**\n * \u89E3\u6790CSS\u9009\u62E9\u5668\u8282\u70B9\uFF0C\u57FA\u4E8Etree-sitter AST\u63D0\u53D6\u9009\u62E9\u5668\u540D\u79F0\n */\nfunction extractSelectorName(selectorsNode: Parser.SyntaxNode, sourceCode: string): string {\n\t// \u9012\u5F52\u67E5\u627E\u7B2C\u4E00\u4E2A\u6709\u610F\u4E49\u7684\u9009\u62E9\u5668\u540D\u79F0\n\tfunction findSelectorName(node: Parser.SyntaxNode): string | null {\n\t\t// \u5904\u7406\u7C7B\u9009\u62E9\u5668\n\t\tif (node.type === \"class_selector\") {\n\t\t\tconst classNameNode = findChildByType(node, \"class_name\")\n\t\t\tif (classNameNode) {\n\t\t\t\treturn getNodeText(classNameNode, sourceCode)\n\t\t\t}\n\t\t}\n\n\t\t// \u5904\u7406ID\u9009\u62E9\u5668\n\t\tif (node.type === \"id_selector\") {\n\t\t\tconst idNameNode = findChildByType(node, \"id_name\")\n\t\t\tif (idNameNode) {\n\t\t\t\treturn getNodeText(idNameNode, sourceCode)\n\t\t\t}\n\t\t}\n\n\t\t// \u5904\u7406\u6807\u7B7E\u9009\u62E9\u5668\n\t\tif (node.type === \"tag_name\") {\n\t\t\treturn getNodeText(node, sourceCode)\n\t\t}\n\n\t\t// \u5904\u7406\u4F2A\u7C7B/\u4F2A\u5143\u7D20\u9009\u62E9\u5668\n\t\tif (node.type === \"pseudo_class_selector\" || node.type === \"pseudo_element_selector\") {\n\t\t\tconst nameNode = findChildByType(node, \"class_name\") || findChildByType(node, \"tag_name\")\n\t\t\tif (nameNode) {\n\t\t\t\treturn getNodeText(nameNode, sourceCode)\n\t\t\t}\n\t\t}\n\n\t\t// \u9012\u5F52\u67E5\u627E\u5B50\u8282\u70B9\n\t\tfor (let i = 0; i < node.childCount; i++) {\n\t\t\tconst child = node.child(i)\n\t\t\tif (child) {\n\t\t\t\tconst name = findSelectorName(child)\n\t\t\t\tif (name) return name\n\t\t\t}\n\t\t}\n\n\t\treturn null\n\t}\n\n\tconst name = findSelectorName(selectorsNode)\n\tif (name) return name\n\n\t// \u5982\u679C\u65E0\u6CD5\u4ECEAST\u4E2D\u63D0\u53D6\u540D\u79F0\uFF0C\u56DE\u9000\u5230\u7B80\u5355\u7684\u6587\u672C\u5904\u7406\n\tconst selectorText = getNodeText(selectorsNode, sourceCode).trim()\n\n\tlet firstSelector = selectorText\n\tconst separators = [\" \", \",\", \">\", \"+\", \"~\"]\n\tfor (const sep of separators) {\n\t\tconst index = firstSelector.indexOf(sep)\n\t\tif (index >= 0) {\n\t\t\tfirstSelector = firstSelector.substring(0, index)\n\t\t}\n\t}\n\n\t// \u79FB\u9664\u7279\u6B8A\u5B57\u7B26\n\tif (firstSelector.startsWith(\".\")) return firstSelector.substring(1)\n\tif (firstSelector.startsWith(\"#\")) return firstSelector.substring(1)\n\n\treturn firstSelector || \"selector\"\n}\n\n/**\n * \u5224\u65AD\u662F\u5426\u4E3ACSS\u53D8\u91CF\uFF08\u81EA\u5B9A\u4E49\u5C5E\u6027\uFF09\n */\nfunction isCSSVariable(propertyName: string): boolean {\n\treturn propertyName.startsWith(\"--\")\n}\n\n/**\n * \u4ECE\u8282\u70B9\u4E2D\u63D0\u53D6\u6587\u672C\u5185\u5BB9\n */\nfunction getNodeText(node: Parser.SyntaxNode, sourceCode: string): string {\n\treturn sourceCode.substring(node.startIndex, node.endIndex)\n}\n\n/**\n * \u67E5\u627E\u5B50\u8282\u70B9\u6309\u7C7B\u578B\n */\nfunction findChildByType(node: Parser.SyntaxNode, type: string): Parser.SyntaxNode | null {\n\tfor (let i = 0; i < node.childCount; i++) {\n\t\tconst child = node.child(i)\n\t\tif (child && child.type === type) {\n\t\t\treturn child\n\t\t}\n\t}\n\treturn null\n}\n\n/**\n * \u4E3B\u8981\u7684CSS\u6355\u83B7\u5904\u7406\u51FD\u6570\n * \u4ECEtree-sitter\u7684captures\u4E2D\u63D0\u53D6CSS\u4EE3\u7801\u7247\u6BB5\u4FE1\u606F\n */\nexport async function extractSnippetsFromCapturesForCSS(\n\tcaptures: Parser.QueryCapture[],\n\tsourceCode: string,\n\tfilePath: string,\n\tfileHash: string,\n\tsnippetTypes: SnippetType[],\n\toptions: { maxSnippetLines: number; minSnippetLines: number },\n): Promise {\n\tconst logger = Logger.getDefaultLogger().with(\"[extractSnippetsFromCapturesForCSS]\")\n\tconst snippets: ISnippetMeta[] = []\n\tconst seenHashes = new Set()\n\n\tif (snippetTypes.length === 0) {\n\t\tlogger.warn(`No snippet types provided, skipping`)\n\t\treturn snippets\n\t}\n\n\t// \u5904\u7406\u6355\u83B7\u7684\u6BCF\u4E2A\u8282\u70B9\n\tfor (const capture of captures) {\n\t\tconst node = capture.node\n\t\tconst startLine = node.startPosition.row + 1\n\t\tconst endLine = node.endPosition.row + 1\n\t\tconst rangeText = getNodeText(node, sourceCode)\n\n\t\tconst snippetHash = generateSnippetHash(filePath, startLine, endLine, rangeText)\n\t\tif (seenHashes.has(snippetHash)) continue\n\t\tseenHashes.add(snippetHash)\n\n\t\t// \u5904\u7406CSS\u89C4\u5219\u96C6\uFF08\u9009\u62E9\u5668\uFF09\n\t\tif (capture.name === \"definition.rule\" && snippetTypes.includes(SnippetType.ClassOrInterfaceOrStructOrEnum)) {\n\t\t\t// \u67E5\u627E\u9009\u62E9\u5668capture\n\t\t\tconst selectorsCapture = captures.find(\n\t\t\t\t(c) =>\n\t\t\t\t\tc.name === \"selectors.definition.rule\" &&\n\t\t\t\t\tc.node.startIndex >= node.startIndex &&\n\t\t\t\t\tc.node.endIndex <= node.endIndex,\n\t\t\t)\n\n\t\t\tif (selectorsCapture) {\n\t\t\t\tconst selectorText = getNodeText(selectorsCapture.node, sourceCode)\n\t\t\t\tconst selectorName = extractSelectorName(selectorsCapture.node, sourceCode)\n\n\t\t\t\t// \u57FA\u4E8EAST\u8282\u70B9\u786E\u5B9A\u9009\u62E9\u5668\u7C7B\u578B\n\t\t\t\tlet definitionType = \"selector\"\n\n\t\t\t\t// \u9012\u5F52\u67E5\u627E\u9009\u62E9\u5668\u7C7B\u578B\n\t\t\t\tfunction findSelectorType(node: Parser.SyntaxNode): string {\n\t\t\t\t\tif (node.type === \"class_selector\") return \"class_selector\"\n\t\t\t\t\tif (node.type === \"id_selector\") return \"id_selector\"\n\t\t\t\t\tif (node.type === \"tag_name\") return \"tag_selector\"\n\t\t\t\t\tif (node.type === \"pseudo_class_selector\" || node.type === \"pseudo_element_selector\")\n\t\t\t\t\t\treturn \"pseudo_selector\"\n\n\t\t\t\t\tfor (let i = 0; i < node.childCount; i++) {\n\t\t\t\t\t\tconst child = node.child(i)\n\t\t\t\t\t\tif (child) {\n\t\t\t\t\t\t\tconst type = findSelectorType(child)\n\t\t\t\t\t\t\tif (type !== \"selector\") return type\n\t\t\t\t\t\t}\n\t\t\t\t\t}\n\t\t\t\t\treturn \"selector\"\n\t\t\t\t}\n\n\t\t\t\tdefinitionType = findSelectorType(selectorsCapture.node)\n\n\t\t\t\tsnippets.push({\n\t\t\t\t\tname: selectorName,\n\t\t\t\t\ttype: SnippetType.ClassOrInterfaceOrStructOrEnum,\n\t\t\t\t\tfilePath,\n\t\t\t\t\tstartLine,\n\t\t\t\t\tendLine,\n\t\t\t\t\trangeText,\n\t\t\t\t\tfileHash,\n\t\t\t\t\tlanguage: CodeLanguageType.CSS,\n\t\t\t\t\tdefinition: {\n\t\t\t\t\t\tname: selectorName,\n\t\t\t\t\t\ttype: definitionType,\n\t\t\t\t\t},\n\t\t\t\t\tdefinitionText: rangeText,\n\t\t\t\t\tsignature: selectorName,\n\t\t\t\t\tscope: buildScopeChain(node),\n\t\t\t\t})\n\t\t\t}\n\t\t}\n\n\t\t// \u5904\u7406@import\u8BED\u53E5\n\t\telse if (capture.name === \"definition.import\" && snippetTypes.includes(SnippetType.ImportOrInclude)) {\n\t\t\t// \u67E5\u627E\u5BFC\u5165\u540D\u79F0capture\n\t\t\tconst nameCapture = captures.find(\n\t\t\t\t(c) =>\n\t\t\t\t\tc.name === \"name.definition.import\" &&\n\t\t\t\t\tc.node.startIndex >= node.startIndex &&\n\t\t\t\t\tc.node.endIndex <= node.endIndex,\n\t\t\t)\n\n\t\t\tlet importName = \"import\"\n\t\t\tif (nameCapture) {\n\t\t\t\t// \u4F7F\u7528\u5B57\u7B26\u4E32\u65B9\u6CD5\u79FB\u9664\u5F15\u53F7\uFF0C\u4EE3\u66FF\u6B63\u5219\u8868\u8FBE\u5F0F\n\t\t\t\tlet rawName = getNodeText(nameCapture.node, sourceCode)\n\t\t\t\tif (rawName.startsWith('\"') && rawName.endsWith('\"')) {\n\t\t\t\t\trawName = rawName.slice(1, -1)\n\t\t\t\t} else if (rawName.startsWith(\"'\") && rawName.endsWith(\"'\")) {\n\t\t\t\t\trawName = rawName.slice(1, -1)\n\t\t\t\t}\n\t\t\t\timportName = rawName\n\t\t\t}\n\n\t\t\tsnippets.push({\n\t\t\t\tname: importName,\n\t\t\t\ttype: SnippetType.ImportOrInclude,\n\t\t\t\tfilePath,\n\t\t\t\tstartLine,\n\t\t\t\tendLine,\n\t\t\t\trangeText,\n\t\t\t\tfileHash,\n\t\t\t\tlanguage: CodeLanguageType.CSS,\n\t\t\t\tdefinitionText: rangeText,\n\t\t\t\tsignature: `@import \"${importName}\"`,\n\t\t\t\tscope: buildScopeChain(node),\n\t\t\t})\n\t\t}\n\n\t\t// \u5904\u7406@keyframes\u52A8\u753B\n\t\telse if (\n\t\t\tcapture.name === \"definition.keyframes\" &&\n\t\t\tsnippetTypes.includes(SnippetType.ClassOrInterfaceOrStructOrEnum)\n\t\t) {\n\t\t\t// \u67E5\u627Ekeyframes\u540D\u79F0capture\n\t\t\tconst nameCapture = captures.find(\n\t\t\t\t(c) =>\n\t\t\t\t\tc.name === \"name.definition.keyframes\" &&\n\t\t\t\t\tc.node.startIndex >= node.startIndex &&\n\t\t\t\t\tc.node.endIndex <= node.endIndex,\n\t\t\t)\n\n\t\t\tlet keyframesName = \"animation\"\n\t\t\tif (nameCapture) {\n\t\t\t\tkeyframesName = getNodeText(nameCapture.node, sourceCode)\n\t\t\t}\n\n\t\t\tsnippets.push({\n\t\t\t\tname: keyframesName,\n\t\t\t\ttype: SnippetType.ClassOrInterfaceOrStructOrEnum,\n\t\t\t\tfilePath,\n\t\t\t\tstartLine,\n\t\t\t\tendLine,\n\t\t\t\trangeText,\n\t\t\t\tfileHash,\n\t\t\t\tlanguage: CodeLanguageType.CSS,\n\t\t\t\tdefinition: {\n\t\t\t\t\tname: keyframesName,\n\t\t\t\t\ttype: \"keyframes\",\n\t\t\t\t},\n\t\t\t\tdefinitionText: rangeText,\n\t\t\t\tsignature: keyframesName,\n\t\t\t\tscope: buildScopeChain(node),\n\t\t\t})\n\t\t}\n\n\t\t// \u5904\u7406@media\u67E5\u8BE2\n\t\telse if (\n\t\t\tcapture.name === \"definition.media\" &&\n\t\t\tsnippetTypes.includes(SnippetType.ClassOrInterfaceOrStructOrEnum)\n\t\t) {\n\t\t\t// \u67E5\u627E\u5A92\u4F53\u67E5\u8BE2capture\n\t\t\tconst queryCapture = captures.find(\n\t\t\t\t(c) =>\n\t\t\t\t\tc.name === \"query.definition.media\" &&\n\t\t\t\t\tc.node.startIndex >= node.startIndex &&\n\t\t\t\t\tc.node.endIndex <= node.endIndex,\n\t\t\t)\n\n\t\t\tlet mediaName = \"media\"\n\t\t\tif (queryCapture) {\n\t\t\t\tmediaName = getNodeText(queryCapture.node, sourceCode).trim()\n\t\t\t}\n\n\t\t\tsnippets.push({\n\t\t\t\tname: mediaName,\n\t\t\t\ttype: SnippetType.ClassOrInterfaceOrStructOrEnum,\n\t\t\t\tfilePath,\n\t\t\t\tstartLine,\n\t\t\t\tendLine,\n\t\t\t\trangeText,\n\t\t\t\tfileHash,\n\t\t\t\tlanguage: CodeLanguageType.CSS,\n\t\t\t\tdefinition: {\n\t\t\t\t\tname: mediaName,\n\t\t\t\t\ttype: \"media\",\n\t\t\t\t},\n\t\t\t\tdefinitionText: rangeText,\n\t\t\t\tsignature: `@media ${mediaName}`,\n\t\t\t\tscope: buildScopeChain(node),\n\t\t\t})\n\t\t}\n\n\t\t// \u5904\u7406CSS\u51FD\u6570\n\t\telse if (capture.name === \"definition.function\" && snippetTypes.includes(SnippetType.FunctionOrMethod)) {\n\t\t\t// \u67E5\u627E\u51FD\u6570\u540Dcapture\n\t\t\tconst nameCapture = captures.find(\n\t\t\t\t(c) =>\n\t\t\t\t\tc.name === \"name.definition.function\" &&\n\t\t\t\t\tc.node.startIndex >= node.startIndex &&\n\t\t\t\t\tc.node.endIndex <= node.endIndex,\n\t\t\t)\n\n\t\t\tif (nameCapture) {\n\t\t\t\tconst functionName = getNodeText(nameCapture.node, sourceCode)\n\n\t\t\t\t// \u67E5\u627E\u53C2\u6570capture\n\t\t\t\tconst argsCapture = captures.find(\n\t\t\t\t\t(c) =>\n\t\t\t\t\t\tc.name === \"args.definition.function\" &&\n\t\t\t\t\t\tc.node.startIndex >= node.startIndex &&\n\t\t\t\t\t\tc.node.endIndex <= node.endIndex,\n\t\t\t\t)\n\n\t\t\t\tconst parameters: ParameterInfo[] = []\n\t\t\t\tif (argsCapture) {\n\t\t\t\t\tconst argsText = getNodeText(argsCapture.node, sourceCode)\n\t\t\t\t\t// \u7B80\u5355\u7684\u53C2\u6570\u5206\u5272\uFF0C\u5904\u7406\u9017\u53F7\u5206\u9694\u7684\u53C2\u6570\n\t\t\t\t\tconst args = argsText\n\t\t\t\t\t\t.split(\",\")\n\t\t\t\t\t\t.map((arg) => arg.trim())\n\t\t\t\t\t\t.filter((arg) => arg.length > 0)\n\t\t\t\t\tparameters.push(...args.map((arg) => ({ name: arg })))\n\t\t\t\t}\n\n\t\t\t\tconst signature =\n\t\t\t\t\tparameters.length > 0\n\t\t\t\t\t\t? `${functionName}(${parameters.map((p) => p.name).join(\", \")})`\n\t\t\t\t\t\t: `${functionName}()`\n\n\t\t\t\tsnippets.push({\n\t\t\t\t\tname: functionName,\n\t\t\t\t\ttype: SnippetType.FunctionOrMethod,\n\t\t\t\t\tfilePath,\n\t\t\t\t\tstartLine,\n\t\t\t\t\tendLine,\n\t\t\t\t\trangeText,\n\t\t\t\t\tfileHash,\n\t\t\t\t\tlanguage: CodeLanguageType.CSS,\n\t\t\t\t\tparameters,\n\t\t\t\t\tdefinition: {\n\t\t\t\t\t\tname: functionName,\n\t\t\t\t\t\ttype: \"function\",\n\t\t\t\t\t\tparameters,\n\t\t\t\t\t},\n\t\t\t\t\tdefinitionText: rangeText,\n\t\t\t\t\tsignature,\n\t\t\t\t\tscope: buildScopeChain(node),\n\t\t\t\t})\n\t\t\t}\n\t\t}\n\n\t\t// \u5904\u7406CSS\u58F0\u660E\uFF08\u53D8\u91CF\u548C\u5C5E\u6027\uFF09\n\t\telse if (capture.name === \"definition.declaration\" && snippetTypes.includes(SnippetType.VariableOrConstant)) {\n\t\t\t// \u67E5\u627E\u5C5E\u6027\u540Dcapture\n\t\t\tconst propertyCapture = captures.find(\n\t\t\t\t(c) =>\n\t\t\t\t\tc.name === \"property.definition.declaration\" &&\n\t\t\t\t\tc.node.startIndex >= node.startIndex &&\n\t\t\t\t\tc.node.endIndex <= node.endIndex,\n\t\t\t)\n\n\t\t\tif (propertyCapture) {\n\t\t\t\tconst propertyName = getNodeText(propertyCapture.node, sourceCode)\n\n\t\t\t\t// \u53EA\u5904\u7406CSS\u53D8\u91CF\n\t\t\t\tif (isCSSVariable(propertyName)) {\n\t\t\t\t\t// \u67E5\u627E\u503Ccapture\n\t\t\t\t\tconst valueCapture = captures.find(\n\t\t\t\t\t\t(c) =>\n\t\t\t\t\t\t\tc.name === \"value.definition.declaration\" &&\n\t\t\t\t\t\t\tc.node.startIndex >= node.startIndex &&\n\t\t\t\t\t\t\tc.node.endIndex <= node.endIndex,\n\t\t\t\t\t)\n\n\t\t\t\t\tlet propertyValue = \"\"\n\t\t\t\t\tif (valueCapture) {\n\t\t\t\t\t\tpropertyValue = getNodeText(valueCapture.node, sourceCode)\n\t\t\t\t\t}\n\n\t\t\t\t\tsnippets.push({\n\t\t\t\t\t\tname: propertyName,\n\t\t\t\t\t\ttype: SnippetType.VariableOrConstant,\n\t\t\t\t\t\tfilePath,\n\t\t\t\t\t\tstartLine,\n\t\t\t\t\t\tendLine,\n\t\t\t\t\t\trangeText,\n\t\t\t\t\t\tfileHash,\n\t\t\t\t\t\tlanguage: CodeLanguageType.CSS,\n\t\t\t\t\t\tdefinition: {\n\t\t\t\t\t\t\tname: propertyName,\n\t\t\t\t\t\t\ttype: \"css_variable\",\n\t\t\t\t\t\t},\n\t\t\t\t\t\tdefinitionText: `${propertyName}: ${propertyValue};`,\n\t\t\t\t\t\tsignature: `${propertyName}: ${propertyValue}`,\n\t\t\t\t\t\tscope: buildScopeChain(node),\n\t\t\t\t\t})\n\t\t\t\t}\n\t\t\t}\n\t\t}\n\t}\n\n\tlogger.info(`Extracted ${snippets.length} CSS snippets`)\n\treturn snippets\n}\n\n/**\n * \u6784\u5EFACSS\u6587\u4EF6\u7684\u6458\u8981\u4FE1\u606F\n */\nexport function buildSummaryFromSnippets(snippets: ISnippetMeta[]): {\n\tselectors: ISnippetMeta[]\n\tvariables: ISnippetMeta[]\n\tfunctions: ISnippetMeta[]\n\tatRules: ISnippetMeta[]\n\timports: ISnippetMeta[]\n} {\n\tconst selectors: ISnippetMeta[] = []\n\tconst variables: ISnippetMeta[] = []\n\tconst functions: ISnippetMeta[] = []\n\tconst atRules: ISnippetMeta[] = []\n\tconst imports: ISnippetMeta[] = []\n\n\tfor (const snippet of snippets) {\n\t\tswitch (snippet.type) {\n\t\t\tcase SnippetType.ImportOrInclude:\n\t\t\t\timports.push(snippet)\n\t\t\t\tbreak\n\t\t\tcase SnippetType.FunctionOrMethod:\n\t\t\t\tfunctions.push(snippet)\n\t\t\t\tbreak\n\t\t\tcase SnippetType.VariableOrConstant:\n\t\t\t\tvariables.push(snippet)\n\t\t\t\tbreak\n\t\t\tcase SnippetType.ClassOrInterfaceOrStructOrEnum:\n\t\t\t\tif (snippet.definition?.type?.includes(\"selector\")) {\n\t\t\t\t\tselectors.push(snippet)\n\t\t\t\t} else {\n\t\t\t\t\tatRules.push(snippet)\n\t\t\t\t}\n\t\t\t\tbreak\n\t\t}\n\t}\n\n\treturn { selectors, variables, functions, atRules, imports }\n}\n\n/**\n * \u683C\u5F0F\u5316CSS\u6587\u4EF6\u7684\u5927\u7EB2\u6587\u672C\n */\nexport function formatOutlineText(summary: {\n\tselectors: ISnippetMeta[]\n\tvariables: ISnippetMeta[]\n\tfunctions: ISnippetMeta[]\n\tatRules: ISnippetMeta[]\n\timports: ISnippetMeta[]\n}): string {\n\tlet outline = \"CSS File Overview:\\n\\n\"\n\n\tif (summary.imports.length > 0) {\n\t\toutline += \"Imports:\\n\"\n\t\tfor (const imp of summary.imports) {\n\t\t\toutline += ` - ${imp.signature}\\n`\n\t\t}\n\t\toutline += \"\\n\"\n\t}\n\n\tif (summary.variables.length > 0) {\n\t\toutline += \"CSS Variables & Properties:\\n\"\n\t\tfor (const variable of summary.variables) {\n\t\t\toutline += ` - ${variable.signature}\\n`\n\t\t}\n\t\toutline += \"\\n\"\n\t}\n\n\tif (summary.selectors.length > 0) {\n\t\toutline += \"Selectors:\\n\"\n\t\tfor (const selector of summary.selectors) {\n\t\t\tconst type = selector.definition?.type || \"selector\"\n\t\t\toutline += ` - ${selector.name} (${type})\\n`\n\t\t}\n\t\toutline += \"\\n\"\n\t}\n\n\tif (summary.functions.length > 0) {\n\t\toutline += \"CSS Functions:\\n\"\n\t\tfor (const func of summary.functions) {\n\t\t\toutline += ` - ${func.signature}\\n`\n\t\t}\n\t\toutline += \"\\n\"\n\t}\n\n\tif (summary.atRules.length > 0) {\n\t\toutline += \"At-Rules:\\n\"\n\t\tfor (const rule of summary.atRules) {\n\t\t\toutline += ` - @${rule.definition?.type}: ${rule.name}\\n`\n\t\t}\n\t\toutline += \"\\n\"\n\t}\n\n\treturn outline.trim()\n}\n", "import { SnippetType, ISnippetMeta, ParameterInfo, CodeLanguageType } from \"../types\"\nimport Parser from \"web-tree-sitter\"\nimport { generateSnippetHash, buildScopeChain } from \"./general\"\nimport { Logger } from \"../Logger\"\n\n/**\n * HTML\u7279\u5B9A\u7684\u8F85\u52A9\u51FD\u6570\n */\n\n/**\n * \u66FF\u6362\u5B57\u7B26\u4E32\u4E2D\u7684\u6362\u884C\u7B26\u4E3A\u53EF\u89C6\u5316\u5B57\u7B26\uFF08\u7528\u4E8E\u65E5\u5FD7\u8F93\u51FA\uFF09\n */\nfunction escapeNewlinesForLogging(text: string): string {\n\treturn text.split(\"\\n\").join(\"\\\\n\")\n}\n\n/**\n * \u683C\u5F0F\u5316\u7C7B\u578B\u540D\u79F0\uFF1A\u5C06\u4E0B\u5212\u7EBF\u5206\u9694\u7684\u7C7B\u578B\u540D\u8F6C\u6362\u4E3A\u6807\u9898\u683C\u5F0F\n * \u4F8B\u5982: \"semantic_element\" -> \"Semantic Element\"\n */\nfunction formatTypeLabel(type: string): string {\n\treturn type\n\t\t.split(\"_\")\n\t\t.map((word) => word.charAt(0).toUpperCase() + word.slice(1).toLowerCase())\n\t\t.join(\" \")\n}\n\n/**\n * \u4ECE\u8282\u70B9\u4E2D\u63D0\u53D6\u6587\u672C\u5185\u5BB9\n */\nfunction getNodeText(node: Parser.SyntaxNode, sourceCode: string): string {\n\treturn sourceCode.substring(node.startIndex, node.endIndex)\n}\n\n/**\n * \u67E5\u627E\u5B50\u8282\u70B9\u6309\u7C7B\u578B\n */\nfunction findChildByType(node: Parser.SyntaxNode, type: string): Parser.SyntaxNode | null {\n\tfor (let i = 0; i < node.childCount; i++) {\n\t\tconst child = node.child(i)\n\t\tif (child && child.type === type) {\n\t\t\treturn child\n\t\t}\n\t}\n\treturn null\n}\n\n/**\n * \u9012\u5F52\u67E5\u627E\u6307\u5B9A\u7C7B\u578B\u7684\u5B50\u8282\u70B9\n */\nfunction findChildByTypeRecursive(node: Parser.SyntaxNode, type: string): Parser.SyntaxNode | null {\n\tif (node.type === type) {\n\t\treturn node\n\t}\n\n\tfor (let i = 0; i < node.childCount; i++) {\n\t\tconst child = node.child(i)\n\t\tif (child) {\n\t\t\tconst found = findChildByTypeRecursive(child, type)\n\t\t\tif (found) return found\n\t\t}\n\t}\n\treturn null\n}\n\n/**\n * \u63D0\u53D6HTML\u5143\u7D20\u7684\u6807\u7B7E\u540D\n */\nfunction extractTagName(node: Parser.SyntaxNode, sourceCode: string): string {\n\t// \u67E5\u627Etag_name\u8282\u70B9\n\tconst tagNameNode = findChildByTypeRecursive(node, \"tag_name\")\n\tif (tagNameNode) {\n\t\treturn getNodeText(tagNameNode, sourceCode)\n\t}\n\n\t// \u56DE\u9000\u5230\u9ED8\u8BA4\u540D\u79F0\n\treturn \"element\"\n}\n\n/**\n * \u63D0\u53D6HTML\u5C5E\u6027\u4FE1\u606F\n */\nfunction extractAttributeInfo(node: Parser.SyntaxNode, sourceCode: string): { name: string; value?: string } {\n\tconst attributeNameNode = findChildByType(node, \"attribute_name\")\n\tconst attributeValueNode =\n\t\tfindChildByType(node, \"attribute_value\") || findChildByType(node, \"quoted_attribute_value\")\n\n\tconst name = attributeNameNode ? getNodeText(attributeNameNode, sourceCode) : \"attribute\"\n\tlet value: string | undefined\n\n\tif (attributeValueNode) {\n\t\tlet rawValue = getNodeText(attributeValueNode, sourceCode)\n\t\t// \u79FB\u9664\u5F15\u53F7\n\t\tif (\n\t\t\t(rawValue.startsWith('\"') && rawValue.endsWith('\"')) ||\n\t\t\t(rawValue.startsWith(\"'\") && rawValue.endsWith(\"'\"))\n\t\t) {\n\t\t\trawValue = rawValue.slice(1, -1)\n\t\t}\n\t\tvalue = rawValue\n\t}\n\n\treturn { name, value }\n}\n\n/**\n * \u5224\u65AD\u662F\u5426\u4E3A\u8BED\u4E49\u5316HTML\u5143\u7D20\n */\nfunction isSemanticElement(tagName: string): boolean {\n\tconst semanticTags = new Set([\n\t\t\"header\",\n\t\t\"nav\",\n\t\t\"main\",\n\t\t\"section\",\n\t\t\"article\",\n\t\t\"aside\",\n\t\t\"footer\",\n\t\t\"figure\",\n\t\t\"figcaption\",\n\t\t\"details\",\n\t\t\"summary\",\n\t\t\"mark\",\n\t\t\"time\",\n\t])\n\treturn semanticTags.has(tagName.toLowerCase())\n}\n\n/**\n * \u5224\u65AD\u662F\u5426\u4E3A\u4EA4\u4E92\u5F0FHTML\u5143\u7D20\n */\nfunction isInteractiveElement(tagName: string): boolean {\n\tconst interactiveTags = new Set([\"button\", \"input\", \"select\", \"textarea\", \"a\", \"form\"])\n\treturn interactiveTags.has(tagName.toLowerCase())\n}\n\n/**\n * \u4E3B\u8981\u7684HTML\u6355\u83B7\u5904\u7406\u51FD\u6570\n * \u4ECEtree-sitter\u7684captures\u4E2D\u63D0\u53D6HTML\u4EE3\u7801\u7247\u6BB5\u4FE1\u606F\n */\nexport async function extractSnippetsFromCapturesForHTML(\n\tcaptures: Parser.QueryCapture[],\n\tsourceCode: string,\n\tfilePath: string,\n\tfileHash: string,\n\tsnippetTypes: SnippetType[],\n\toptions: { maxSnippetLines: number; minSnippetLines: number },\n): Promise {\n\tconst logger = Logger.getDefaultLogger().with(\"[extractSnippetsFromCapturesForHTML]\")\n\tconst snippets: ISnippetMeta[] = []\n\tconst seenHashes = new Set()\n\n\tif (snippetTypes.length === 0) {\n\t\tlogger.warn(`No snippet types provided, skipping`)\n\t\treturn snippets\n\t}\n\n\t// \u5904\u7406\u6355\u83B7\u7684\u6BCF\u4E2A\u8282\u70B9\n\tfor (const capture of captures) {\n\t\tconst node = capture.node\n\t\tconst startLine = node.startPosition.row + 1\n\t\tconst endLine = node.endPosition.row + 1\n\t\tconst rangeText = getNodeText(node, sourceCode)\n\n\t\tconst snippetHash = generateSnippetHash(filePath, startLine, endLine, rangeText) + \"_\" + capture.name\n\t\tif (seenHashes.has(snippetHash)) continue\n\t\tseenHashes.add(snippetHash)\n\n\t\t// DEBUG: Log each capture being processed\n\t\tlogger.info(`Processing capture: ${capture.name} -> \"${escapeNewlinesForLogging(rangeText)}\"`)\n\n\t\t// \u5904\u7406DOCTYPE\u58F0\u660E\n\t\tif (capture.name === \"definition.doctype\" && snippetTypes.includes(SnippetType.ImportOrInclude)) {\n\t\t\tsnippets.push({\n\t\t\t\tname: \"DOCTYPE\",\n\t\t\t\ttype: SnippetType.ImportOrInclude,\n\t\t\t\tfilePath,\n\t\t\t\tstartLine,\n\t\t\t\tendLine,\n\t\t\t\trangeText,\n\t\t\t\tfileHash,\n\t\t\t\tlanguage: CodeLanguageType.HTML,\n\t\t\t\tdefinition: {\n\t\t\t\t\tname: \"DOCTYPE\",\n\t\t\t\t\ttype: \"doctype\",\n\t\t\t\t},\n\t\t\t\tdefinitionText: rangeText,\n\t\t\t\tsignature: \"DOCTYPE html\",\n\t\t\t\tscope: buildScopeChain(node),\n\t\t\t})\n\t\t}\n\n\t\t// \u5904\u7406\u6587\u6863\u6839\u5143\u7D20\n\t\telse if (\n\t\t\tcapture.name === \"definition.document\" &&\n\t\t\tsnippetTypes.includes(SnippetType.ClassOrInterfaceOrStructOrEnum)\n\t\t) {\n\t\t\tsnippets.push({\n\t\t\t\tname: \"document\",\n\t\t\t\ttype: SnippetType.ClassOrInterfaceOrStructOrEnum,\n\t\t\t\tfilePath,\n\t\t\t\tstartLine,\n\t\t\t\tendLine,\n\t\t\t\trangeText,\n\t\t\t\tfileHash,\n\t\t\t\tlanguage: CodeLanguageType.HTML,\n\t\t\t\tdefinition: {\n\t\t\t\t\tname: \"document\",\n\t\t\t\t\ttype: \"document\",\n\t\t\t\t},\n\t\t\t\tdefinitionText: rangeText,\n\t\t\t\tsignature: \"HTML Document\",\n\t\t\t\tscope: buildScopeChain(node),\n\t\t\t})\n\t\t}\n\n\t\t// \u5904\u7406\u5E38\u89C4HTML\u5143\u7D20\n\t\telse if (\n\t\t\tcapture.name === \"definition.element\" &&\n\t\t\tsnippetTypes.includes(SnippetType.ClassOrInterfaceOrStructOrEnum)\n\t\t) {\n\t\t\t// \u67E5\u627E\u5BF9\u5E94\u7684name capture - \u5B83\u5E94\u8BE5\u5728\u76F8\u540C\u8303\u56F4\u5185\n\t\t\tconst nameCapture = captures.find(\n\t\t\t\t(c) =>\n\t\t\t\t\tc.name === \"name.definition\" &&\n\t\t\t\t\tc.node.startIndex >= node.startIndex &&\n\t\t\t\t\tc.node.endIndex <= node.endIndex,\n\t\t\t)\n\n\t\t\tconst elementName = nameCapture\n\t\t\t\t? getNodeText(nameCapture.node, sourceCode)\n\t\t\t\t: extractTagName(node, sourceCode)\n\n\t\t\t// \u786E\u5B9A\u5143\u7D20\u7C7B\u578B\n\t\t\tlet elementType = \"element\"\n\t\t\tif (isSemanticElement(elementName)) {\n\t\t\t\telementType = \"semantic_element\"\n\t\t\t} else if (isInteractiveElement(elementName)) {\n\t\t\t\telementType = \"interactive_element\"\n\t\t\t}\n\n\t\t\tsnippets.push({\n\t\t\t\tname: elementName,\n\t\t\t\ttype: SnippetType.ClassOrInterfaceOrStructOrEnum,\n\t\t\t\tfilePath,\n\t\t\t\tstartLine,\n\t\t\t\tendLine,\n\t\t\t\trangeText,\n\t\t\t\tfileHash,\n\t\t\t\tlanguage: CodeLanguageType.HTML,\n\t\t\t\tdefinition: {\n\t\t\t\t\tname: elementName,\n\t\t\t\t\ttype: elementType,\n\t\t\t\t},\n\t\t\t\tdefinitionText: rangeText,\n\t\t\t\tsignature: `<${elementName}>`,\n\t\t\t\tscope: buildScopeChain(node),\n\t\t\t})\n\t\t}\n\n\t\t// \u5904\u7406\u811A\u672C\u5143\u7D20\n\t\telse if (capture.name === \"definition.script\" && snippetTypes.includes(SnippetType.FunctionOrMethod)) {\n\t\t\t// \u67E5\u627E\u5BF9\u5E94\u7684name capture - \u5E94\u8BE5\u5728\u76F8\u540C\u8303\u56F4\u5185\n\t\t\tconst nameCapture = captures.find(\n\t\t\t\t(c) =>\n\t\t\t\t\tc.name === \"name.definition\" &&\n\t\t\t\t\tc.node.startIndex >= node.startIndex &&\n\t\t\t\t\tc.node.endIndex <= node.endIndex,\n\t\t\t)\n\n\t\t\tconst scriptName = nameCapture ? getNodeText(nameCapture.node, sourceCode) : \"script\"\n\n\t\t\tsnippets.push({\n\t\t\t\tname: scriptName,\n\t\t\t\ttype: SnippetType.FunctionOrMethod,\n\t\t\t\tfilePath,\n\t\t\t\tstartLine,\n\t\t\t\tendLine,\n\t\t\t\trangeText,\n\t\t\t\tfileHash,\n\t\t\t\tlanguage: CodeLanguageType.HTML,\n\t\t\t\tdefinition: {\n\t\t\t\t\tname: scriptName,\n\t\t\t\t\ttype: \"script\",\n\t\t\t\t},\n\t\t\t\tdefinitionText: rangeText,\n\t\t\t\tsignature: `<${scriptName}>`,\n\t\t\t\tscope: buildScopeChain(node),\n\t\t\t})\n\t\t}\n\n\t\t// \u5904\u7406\u6837\u5F0F\u5143\u7D20\n\t\telse if (capture.name === \"definition.style\" && snippetTypes.includes(SnippetType.FunctionOrMethod)) {\n\t\t\tconst nameCapture = captures.find(\n\t\t\t\t(c) =>\n\t\t\t\t\tc.name === \"name.definition\" &&\n\t\t\t\t\tc.node.startIndex >= node.startIndex &&\n\t\t\t\t\tc.node.endIndex <= node.endIndex,\n\t\t\t)\n\n\t\t\tconst styleName = nameCapture ? getNodeText(nameCapture.node, sourceCode) : \"style\"\n\n\t\t\tsnippets.push({\n\t\t\t\tname: styleName,\n\t\t\t\ttype: SnippetType.FunctionOrMethod,\n\t\t\t\tfilePath,\n\t\t\t\tstartLine,\n\t\t\t\tendLine,\n\t\t\t\trangeText,\n\t\t\t\tfileHash,\n\t\t\t\tlanguage: CodeLanguageType.HTML,\n\t\t\t\tdefinition: {\n\t\t\t\t\tname: styleName,\n\t\t\t\t\ttype: \"style\",\n\t\t\t\t},\n\t\t\t\tdefinitionText: rangeText,\n\t\t\t\tsignature: `<${styleName}>`,\n\t\t\t\tscope: buildScopeChain(node),\n\t\t\t})\n\t\t}\n\n\t\t// \u5904\u7406void\u5143\u7D20\uFF08\u81EA\u95ED\u5408\u5143\u7D20\uFF09\n\t\telse if (\n\t\t\tcapture.name === \"definition.void_element\" &&\n\t\t\tsnippetTypes.includes(SnippetType.ClassOrInterfaceOrStructOrEnum)\n\t\t) {\n\t\t\t// \u67E5\u627E\u5BF9\u5E94\u7684void\u5143\u7D20\u7684name capture\n\t\t\tconst nameCapture = captures.find(\n\t\t\t\t(c) =>\n\t\t\t\t\tc.name === \"name.definition.void\" &&\n\t\t\t\t\tc.node.startIndex >= node.startIndex &&\n\t\t\t\t\tc.node.endIndex <= node.endIndex,\n\t\t\t)\n\n\t\t\tconst elementName = nameCapture\n\t\t\t\t? getNodeText(nameCapture.node, sourceCode)\n\t\t\t\t: extractTagName(node, sourceCode)\n\n\t\t\t// \u786E\u5B9A\u5143\u7D20\u7C7B\u578B - \u4F18\u5148\u68C0\u67E5\u662F\u5426\u4E3A\u4EA4\u4E92\u5143\u7D20\n\t\t\tlet elementType = \"void_element\"\n\t\t\tif (isInteractiveElement(elementName)) {\n\t\t\t\telementType = \"interactive_element\"\n\t\t\t} else if (isSemanticElement(elementName)) {\n\t\t\t\telementType = \"semantic_element\"\n\t\t\t}\n\n\t\t\tsnippets.push({\n\t\t\t\tname: elementName,\n\t\t\t\ttype: SnippetType.ClassOrInterfaceOrStructOrEnum,\n\t\t\t\tfilePath,\n\t\t\t\tstartLine,\n\t\t\t\tendLine,\n\t\t\t\trangeText,\n\t\t\t\tfileHash,\n\t\t\t\tlanguage: CodeLanguageType.HTML,\n\t\t\t\tdefinition: {\n\t\t\t\t\tname: elementName,\n\t\t\t\t\ttype: elementType,\n\t\t\t\t},\n\t\t\t\tdefinitionText: rangeText,\n\t\t\t\tsignature: elementType === \"void_element\" ? `<${elementName} />` : `<${elementName}>`,\n\t\t\t\tscope: buildScopeChain(node),\n\t\t\t})\n\t\t}\n\n\t\t// \u5904\u7406\u81EA\u95ED\u5408\u6807\u7B7E\n\t\telse if (\n\t\t\tcapture.name === \"definition.self_closing_tag\" &&\n\t\t\tsnippetTypes.includes(SnippetType.ClassOrInterfaceOrStructOrEnum)\n\t\t) {\n\t\t\tconst nameCapture = captures.find(\n\t\t\t\t(c) =>\n\t\t\t\t\tc.name === \"name.definition\" &&\n\t\t\t\t\tc.node.startIndex >= node.startIndex &&\n\t\t\t\t\tc.node.endIndex <= node.endIndex,\n\t\t\t)\n\n\t\t\tconst tagName = nameCapture ? getNodeText(nameCapture.node, sourceCode) : \"self_closing_tag\"\n\n\t\t\tsnippets.push({\n\t\t\t\tname: tagName,\n\t\t\t\ttype: SnippetType.ClassOrInterfaceOrStructOrEnum,\n\t\t\t\tfilePath,\n\t\t\t\tstartLine,\n\t\t\t\tendLine,\n\t\t\t\trangeText,\n\t\t\t\tfileHash,\n\t\t\t\tlanguage: CodeLanguageType.HTML,\n\t\t\t\tdefinition: {\n\t\t\t\t\tname: tagName,\n\t\t\t\t\ttype: \"self_closing_tag\",\n\t\t\t\t},\n\t\t\t\tdefinitionText: rangeText,\n\t\t\t\tsignature: `<${tagName} />`,\n\t\t\t\tscope: buildScopeChain(node),\n\t\t\t})\n\t\t}\n\n\t\t// \u5904\u7406HTML\u5C5E\u6027\n\t\telse if (capture.name === \"definition.attribute\" && snippetTypes.includes(SnippetType.VariableOrConstant)) {\n\t\t\t// \u67E5\u627E\u5BF9\u5E94\u7684name capture - \u5E94\u8BE5\u5728\u76F8\u540C\u8303\u56F4\u5185\n\t\t\tconst nameCapture = captures.find(\n\t\t\t\t(c) =>\n\t\t\t\t\tc.name === \"name.definition\" &&\n\t\t\t\t\tc.node.startIndex >= node.startIndex &&\n\t\t\t\t\tc.node.endIndex <= node.endIndex,\n\t\t\t)\n\n\t\t\tif (nameCapture) {\n\t\t\t\tconst attributeInfo = extractAttributeInfo(node, sourceCode)\n\t\t\t\tconst attributeName = attributeInfo.name\n\n\t\t\t\t// \u786E\u5B9A\u5C5E\u6027\u7C7B\u578B\n\t\t\t\tlet attributeType = \"attribute\"\n\t\t\t\tif (attributeName.startsWith(\"data-\")) {\n\t\t\t\t\tattributeType = \"data_attribute\"\n\t\t\t\t} else if (attributeName.startsWith(\"aria-\")) {\n\t\t\t\t\tattributeType = \"aria_attribute\"\n\t\t\t\t} else if ([\"id\", \"class\"].includes(attributeName)) {\n\t\t\t\t\tattributeType = \"core_attribute\"\n\t\t\t\t}\n\n\t\t\t\tconst signature = attributeInfo.value ? `${attributeName}=\"${attributeInfo.value}\"` : attributeName\n\n\t\t\t\tsnippets.push({\n\t\t\t\t\tname: attributeName,\n\t\t\t\t\ttype: SnippetType.VariableOrConstant,\n\t\t\t\t\tfilePath,\n\t\t\t\t\tstartLine,\n\t\t\t\t\tendLine,\n\t\t\t\t\trangeText,\n\t\t\t\t\tfileHash,\n\t\t\t\t\tlanguage: CodeLanguageType.HTML,\n\t\t\t\t\tdefinition: {\n\t\t\t\t\t\tname: attributeName,\n\t\t\t\t\t\ttype: attributeType,\n\t\t\t\t\t},\n\t\t\t\t\tdefinitionText: rangeText,\n\t\t\t\t\tsignature,\n\t\t\t\t\tscope: buildScopeChain(node),\n\t\t\t\t})\n\t\t\t}\n\t\t}\n\n\t\t// \u5904\u7406HTML\u6CE8\u91CA\n\t\telse if (capture.name === \"definition.comment\" && snippetTypes.includes(SnippetType.ImportOrInclude)) {\n\t\t\t// \u63D0\u53D6\u6CE8\u91CA\u5185\u5BB9\uFF0C\u79FB\u9664\u6CE8\u91CA\u6807\u8BB0\n\t\t\tlet commentText = rangeText.trim()\n\t\t\tif (commentText.startsWith(\"\")) {\n\t\t\t\tcommentText = commentText.slice(4, -3).trim()\n\t\t\t}\n\n\t\t\t// \u53D6\u6CE8\u91CA\u7684\u7B2C\u4E00\u884C\u4F5C\u4E3A\u540D\u79F0\n\t\t\tconst firstLine = commentText.split(\"\\n\")[0].trim()\n\t\t\tconst commentName = firstLine.length > 0 ? firstLine : \"comment\"\n\n\t\t\tsnippets.push({\n\t\t\t\tname: commentName,\n\t\t\t\ttype: SnippetType.ImportOrInclude,\n\t\t\t\tfilePath,\n\t\t\t\tstartLine,\n\t\t\t\tendLine,\n\t\t\t\trangeText,\n\t\t\t\tfileHash,\n\t\t\t\tlanguage: CodeLanguageType.HTML,\n\t\t\t\tdefinition: {\n\t\t\t\t\tname: commentName,\n\t\t\t\t\ttype: \"comment\",\n\t\t\t\t},\n\t\t\t\tdefinitionText: rangeText,\n\t\t\t\tsignature: ``,\n\t\t\t\tscope: buildScopeChain(node),\n\t\t\t})\n\t\t}\n\n\t\t// \u5904\u7406\u6587\u672C\u5185\u5BB9\uFF08\u6EE1\u8DB3\u6700\u5C0F\u884C\u6570\u8981\u6C42\uFF09\n\t\telse if (capture.name === \"definition.text\" && snippetTypes.includes(SnippetType.VariableOrConstant)) {\n\t\t\tconst lineCount = endLine - startLine + 1\n\t\t\tif (lineCount >= options.minSnippetLines) {\n\t\t\t\t// \u63D0\u53D6\u6587\u672C\u5185\u5BB9\u7684\u7B2C\u4E00\u884C\u4F5C\u4E3A\u540D\u79F0\n\t\t\t\tconst textContent = rangeText.trim()\n\t\t\t\tconst firstLine = textContent.split(\"\\n\")[0].trim()\n\t\t\t\tconst textName = firstLine.length > 0 ? firstLine : \"text\"\n\n\t\t\t\tsnippets.push({\n\t\t\t\t\tname: textName,\n\t\t\t\t\ttype: SnippetType.VariableOrConstant,\n\t\t\t\t\tfilePath,\n\t\t\t\t\tstartLine,\n\t\t\t\t\tendLine,\n\t\t\t\t\trangeText,\n\t\t\t\t\tfileHash,\n\t\t\t\t\tlanguage: CodeLanguageType.HTML,\n\t\t\t\t\tdefinition: {\n\t\t\t\t\t\tname: textName,\n\t\t\t\t\t\ttype: \"text\",\n\t\t\t\t\t},\n\t\t\t\t\tdefinitionText: rangeText,\n\t\t\t\t\tsignature: textName,\n\t\t\t\t\tscope: buildScopeChain(node),\n\t\t\t\t})\n\t\t\t}\n\t\t}\n\n\t\t// \u5904\u7406\u539F\u59CB\u6587\u672C\u5185\u5BB9\n\t\telse if (capture.name === \"definition.raw_text\" && snippetTypes.includes(SnippetType.VariableOrConstant)) {\n\t\t\tconst lineCount = endLine - startLine + 1\n\t\t\tif (lineCount >= options.minSnippetLines) {\n\t\t\t\tconst textContent = rangeText.trim()\n\t\t\t\tconst firstLine = textContent.split(\"\\n\")[0].trim()\n\t\t\t\tconst rawTextName = firstLine.length > 0 ? firstLine : \"raw_text\"\n\n\t\t\t\tsnippets.push({\n\t\t\t\t\tname: rawTextName,\n\t\t\t\t\ttype: SnippetType.VariableOrConstant,\n\t\t\t\t\tfilePath,\n\t\t\t\t\tstartLine,\n\t\t\t\t\tendLine,\n\t\t\t\t\trangeText,\n\t\t\t\t\tfileHash,\n\t\t\t\t\tlanguage: CodeLanguageType.HTML,\n\t\t\t\t\tdefinition: {\n\t\t\t\t\t\tname: rawTextName,\n\t\t\t\t\t\ttype: \"raw_text\",\n\t\t\t\t\t},\n\t\t\t\t\tdefinitionText: rangeText,\n\t\t\t\t\tsignature: rawTextName,\n\t\t\t\t\tscope: buildScopeChain(node),\n\t\t\t\t})\n\t\t\t}\n\t\t}\n\n\t\t// \u5904\u7406\u5D4C\u5957\u5143\u7D20\u7ED3\u6784\n\t\telse if (\n\t\t\tcapture.name === \"definition.nested_elements\" &&\n\t\t\tsnippetTypes.includes(SnippetType.ClassOrInterfaceOrStructOrEnum)\n\t\t) {\n\t\t\tconst tagName = extractTagName(node, sourceCode)\n\n\t\t\tsnippets.push({\n\t\t\t\tname: `${tagName}_container`,\n\t\t\t\ttype: SnippetType.ClassOrInterfaceOrStructOrEnum,\n\t\t\t\tfilePath,\n\t\t\t\tstartLine,\n\t\t\t\tendLine,\n\t\t\t\trangeText,\n\t\t\t\tfileHash,\n\t\t\t\tlanguage: CodeLanguageType.HTML,\n\t\t\t\tdefinition: {\n\t\t\t\t\tname: `${tagName}_container`,\n\t\t\t\t\ttype: \"nested_elements\",\n\t\t\t\t},\n\t\t\t\tdefinitionText: rangeText,\n\t\t\t\tsignature: `<${tagName}> (with children)`,\n\t\t\t\tscope: buildScopeChain(node),\n\t\t\t})\n\t\t}\n\t}\n\n\tlogger.info(`[CodeContext] Extracted ${snippets.length} HTML snippets`)\n\treturn snippets\n}\n\n/**\n * \u6784\u5EFAHTML\u4EE3\u7801\u7684\u6982\u89C8\u6587\u672C\n */\nexport function buildSummaryFromSnippets(snippets: ISnippetMeta[]): {\n\tdoctypes: ISnippetMeta[]\n\telements: ISnippetMeta[]\n\tattributes: ISnippetMeta[]\n\tscripts: ISnippetMeta[]\n\tstyles: ISnippetMeta[]\n\tcomments: ISnippetMeta[]\n\ttextContent: ISnippetMeta[]\n} {\n\tconst summary = {\n\t\tdoctypes: [] as ISnippetMeta[],\n\t\telements: [] as ISnippetMeta[],\n\t\tattributes: [] as ISnippetMeta[],\n\t\tscripts: [] as ISnippetMeta[],\n\t\tstyles: [] as ISnippetMeta[],\n\t\tcomments: [] as ISnippetMeta[],\n\t\ttextContent: [] as ISnippetMeta[],\n\t}\n\n\tfor (const snippet of snippets) {\n\t\tconst defType = snippet.definition?.type || \"\"\n\n\t\tswitch (defType) {\n\t\t\tcase \"doctype\":\n\t\t\t\tsummary.doctypes.push(snippet)\n\t\t\t\tbreak\n\t\t\tcase \"element\":\n\t\t\tcase \"semantic_element\":\n\t\t\tcase \"interactive_element\":\n\t\t\tcase \"void_element\":\n\t\t\tcase \"self_closing_tag\":\n\t\t\tcase \"nested_elements\":\n\t\t\t\tsummary.elements.push(snippet)\n\t\t\t\tbreak\n\t\t\tcase \"attribute\":\n\t\t\tcase \"data_attribute\":\n\t\t\tcase \"aria_attribute\":\n\t\t\tcase \"core_attribute\":\n\t\t\t\tsummary.attributes.push(snippet)\n\t\t\t\tbreak\n\t\t\tcase \"script\":\n\t\t\t\tsummary.scripts.push(snippet)\n\t\t\t\tbreak\n\t\t\tcase \"style\":\n\t\t\t\tsummary.styles.push(snippet)\n\t\t\t\tbreak\n\t\t\tcase \"comment\":\n\t\t\t\tsummary.comments.push(snippet)\n\t\t\t\tbreak\n\t\t\tcase \"text\":\n\t\t\tcase \"raw_text\":\n\t\t\t\tsummary.textContent.push(snippet)\n\t\t\t\tbreak\n\t\t}\n\t}\n\n\treturn summary\n}\n\n/**\n * \u683C\u5F0F\u5316HTML\u6982\u89C8\u6587\u672C\u8F93\u51FA\n */\nexport function formatOutlineText(summary: ReturnType): string {\n\tconst lines: string[] = []\n\n\t// DOCTYPE\u58F0\u660E\n\tif (summary.doctypes.length > 0) {\n\t\tlines.push(\"## Document Type\")\n\t\tsummary.doctypes.forEach((snippet) => {\n\t\t\tlines.push(`- ${snippet.signature || snippet.name}`)\n\t\t})\n\t\tlines.push(\"\")\n\t}\n\n\t// HTML\u5143\u7D20\n\tif (summary.elements.length > 0) {\n\t\tlines.push(\"## HTML Elements\")\n\t\tsummary.elements.forEach((snippet) => {\n\t\t\tconst typeSuffix =\n\t\t\t\tsnippet.definition?.type === \"semantic_element\"\n\t\t\t\t\t? \" (semantic)\"\n\t\t\t\t\t: snippet.definition?.type === \"interactive_element\"\n\t\t\t\t\t\t? \" (interactive)\"\n\t\t\t\t\t\t: \"\"\n\t\t\tlines.push(`- ${snippet.signature || snippet.name}${typeSuffix}`)\n\t\t})\n\t\tlines.push(\"\")\n\t}\n\n\t// \u811A\u672C\u548C\u6837\u5F0F\n\tif (summary.scripts.length > 0 || summary.styles.length > 0) {\n\t\tlines.push(\"## Scripts & Styles\")\n\t\tsummary.scripts.forEach((snippet) => {\n\t\t\tlines.push(`- ${snippet.signature || snippet.name} (script)`)\n\t\t})\n\t\tsummary.styles.forEach((snippet) => {\n\t\t\tlines.push(`- ${snippet.signature || snippet.name} (style)`)\n\t\t})\n\t\tlines.push(\"\")\n\t}\n\n\t// \u5C5E\u6027\n\tif (summary.attributes.length > 0) {\n\t\tlines.push(\"## Attributes\")\n\t\tconst attributesByType: Record = {}\n\t\tsummary.attributes.forEach((snippet) => {\n\t\t\tconst type = snippet.definition?.type || \"attribute\"\n\t\t\tif (!attributesByType[type]) attributesByType[type] = []\n\t\t\tattributesByType[type].push(snippet)\n\t\t})\n\n\t\tObject.keys(attributesByType)\n\t\t\t.sort()\n\t\t\t.forEach((type) => {\n\t\t\t\tconst typeLabel = formatTypeLabel(type)\n\t\t\t\tlines.push(`### ${typeLabel}`)\n\t\t\t\tattributesByType[type].forEach((snippet) => {\n\t\t\t\t\tlines.push(`- ${snippet.signature || snippet.name}`)\n\t\t\t\t})\n\t\t\t})\n\t\tlines.push(\"\")\n\t}\n\n\t// \u6CE8\u91CA\n\tif (summary.comments.length > 0) {\n\t\tlines.push(\"## Comments\")\n\t\tsummary.comments.forEach((snippet) => {\n\t\t\tlines.push(`- ${snippet.name}`)\n\t\t})\n\t\tlines.push(\"\")\n\t}\n\n\t// \u6587\u672C\u5185\u5BB9\n\tif (summary.textContent.length > 0) {\n\t\tlines.push(\"## Text Content\")\n\t\tsummary.textContent.forEach((snippet) => {\n\t\t\tconst preview = snippet.name.length > 50 ? snippet.name.substring(0, 47) + \"...\" : snippet.name\n\t\t\tlines.push(`- ${preview}`)\n\t\t})\n\t\tlines.push(\"\")\n\t}\n\n\treturn lines.join(\"\\n\").trim()\n}\n", "import { Logger } from \"../Logger\"\nimport { CodeLanguageType, ISnippetMeta, SnippetType, ParameterInfo } from \"../types\"\nimport Parser from \"web-tree-sitter\"\nimport * as crypto from \"crypto\"\n\n/**\n * \u63D0\u53D6\u4FEE\u9970\u7B26\uFF08private, protected, internal, public\u7B49\uFF09\n */\nfunction extractModifiers(node: Parser.SyntaxNode, sourceCode: string): string[] {\n\tconst modifiers: string[] = []\n\n\t// \u67E5\u627E\u4FEE\u9970\u7B26\u8282\u70B9\n\tconst modifierNode = node.children.find((child) => child.type === \"modifiers\")\n\tif (modifierNode) {\n\t\tmodifierNode.children.forEach((child) => {\n\t\t\tif (child.type === \"visibility_modifier\" || child.type === \"modifier\") {\n\t\t\t\tconst modifier = sourceCode.substring(child.startIndex, child.endIndex)\n\t\t\t\tmodifiers.push(modifier)\n\t\t\t}\n\t\t})\n\t}\n\n\treturn modifiers\n}\n\n/**\n * \u4ECEimport\u8BED\u53E5\u4E2D\u63D0\u53D6\u5BFC\u5165\u8DEF\u5F84\uFF08\u907F\u514D\u4F7F\u7528\u6B63\u5219\u8868\u8FBE\u5F0F\uFF09\n */\nfunction extractImportPath(importNode: Parser.SyntaxNode, sourceCode: string): string {\n\t// \u5148\u5C1D\u8BD5\u67E5\u627E\u5B8C\u6574\u7684import\u8DEF\u5F84\uFF0C\u5305\u62EC\u901A\u914D\u7B26\n\tconst fullImportText = sourceCode.substring(importNode.startIndex, importNode.endIndex)\n\n\t// \u67E5\u627Eimport\u5173\u952E\u5B57\u7684\u4F4D\u7F6E\n\tconst importKeywordIndex = fullImportText.indexOf(\"import\")\n\tif (importKeywordIndex === -1) return fullImportText.trim()\n\n\t// \u63D0\u53D6import\u540E\u9762\u7684\u5185\u5BB9\n\tconst importKeywordEnd = importKeywordIndex + 6 // \"import\".length\n\tlet pathPart = fullImportText.substring(importKeywordEnd).trim()\n\n\t// \u79FB\u9664\u53EF\u80FD\u7684\u6362\u884C\u7B26\u548C\u5206\u53F7\n\tpathPart = pathPart.split(\"\\n\")[0].split(\"\\r\")[0].split(\";\")[0].trim()\n\n\treturn pathPart\n}\n\n/**\n * \u6839\u636EAST\u8282\u70B9\u786E\u5B9A\u5B9A\u4E49\u7C7B\u578B\uFF08\u907F\u514D\u4F7F\u7528\u5B57\u7B26\u4E32\u5339\u914D\uFF09\n */\nfunction getDefinitionType(node: Parser.SyntaxNode, sourceCode: string): string {\n\t// \u68C0\u67E5\u8282\u70B9\u7C7B\u578B\n\tif (node.type === \"object_declaration\") return \"object\"\n\tif (node.type === \"type_alias\") return \"typealias\"\n\n\tif (node.type === \"class_declaration\") {\n\t\t// \u67E5\u627E\u4FEE\u9970\u7B26\u8282\u70B9\u6765\u786E\u5B9A\u7C7B\u578B\n\t\tconst modifierNode = node.children.find((child) => child.type === \"modifiers\")\n\t\tif (modifierNode) {\n\t\t\tconst modifierTexts = modifierNode.children.map((child) =>\n\t\t\t\tsourceCode.substring(child.startIndex, child.endIndex),\n\t\t\t)\n\n\t\t\t// \u68C0\u67E5\u4FEE\u9970\u7B26\u7EC4\u5408\n\t\t\tif (modifierTexts.includes(\"sealed\")) return \"sealed class\"\n\t\t\tif (modifierTexts.includes(\"data\")) return \"data class\"\n\t\t\tif (modifierTexts.includes(\"enum\")) return \"enum\"\n\t\t\tif (modifierTexts.includes(\"annotation\")) return \"annotation class\"\n\t\t}\n\n\t\t// \u68C0\u67E5\u662F\u5426\u6709enum_class_body\n\t\tconst hasEnumBody = node.children.some((child) => child.type === \"enum_class_body\")\n\t\tif (hasEnumBody) return \"enum\"\n\n\t\t// \u68C0\u67E5\u662F\u5426\u4E3A\u63A5\u53E3\uFF08\u901A\u8FC7\u67E5\u627Einterface\u5173\u952E\u5B57\u8282\u70B9\uFF09\n\t\tconst hasInterfaceKeyword = node.children.some((child) => {\n\t\t\tif (child.type === \"interface\") return true\n\t\t\tconst childText = sourceCode.substring(child.startIndex, child.endIndex)\n\t\t\treturn childText === \"interface\"\n\t\t})\n\t\tif (hasInterfaceKeyword) return \"interface\"\n\n\t\treturn \"class\"\n\t}\n\n\treturn \"class\"\n}\n\n/**\n * \u67E5\u627E\u7236\u7C7B\u6216\u63A5\u53E3\u540D\u79F0\n */\nfunction findParentClassName(\n\tcaptures: Parser.QueryCapture[],\n\tnode: Parser.SyntaxNode,\n\tsourceCode: string,\n): string | undefined {\n\t// \u67E5\u627E\u5305\u542B\u5F53\u524D\u8282\u70B9\u7684\u7C7B\u58F0\u660E\n\tconst classCapture = captures.find(\n\t\t(c) =>\n\t\t\tc.name === \"definition.class\" && c.node.startIndex <= node.startIndex && c.node.endIndex >= node.endIndex,\n\t)\n\n\tif (classCapture) {\n\t\tconst nameNode = classCapture.node.children.find((child) => child.type === \"type_identifier\")\n\t\treturn nameNode ? sourceCode.substring(nameNode.startIndex, nameNode.endIndex) : undefined\n\t}\n\n\treturn undefined\n}\n\n/**\n * \u89E3\u6790\u5355\u4E2A\u53C2\u6570\u7684\u4FE1\u606F\uFF08\u907F\u514D\u4F7F\u7528\u6B63\u5219\u8868\u8FBE\u5F0F\uFF09\n */\nfunction parseParameterInfo(paramNode: Parser.SyntaxNode, sourceCode: string): ParameterInfo {\n\t// \u67E5\u627E\u53C2\u6570\u540D\u79F0\n\tconst nameNode = paramNode.children.find((child) => child.type === \"simple_identifier\")\n\tconst name = nameNode ? sourceCode.substring(nameNode.startIndex, nameNode.endIndex) : \"\"\n\n\t// \u67E5\u627E\u7C7B\u578B\u6CE8\u89E3\n\tconst typeNode = paramNode.children.find((child) => child.type === \"user_type\" || child.type === \"type_identifier\")\n\tconst type = typeNode ? sourceCode.substring(typeNode.startIndex, typeNode.endIndex) : undefined\n\n\t// \u67E5\u627E\u9ED8\u8BA4\u503C\n\tconst defaultValueNode = paramNode.children.find((child) => child.type === \"default_value\")\n\tconst defaultValue = defaultValueNode\n\t\t? sourceCode.substring(defaultValueNode.startIndex, defaultValueNode.endIndex)\n\t\t: undefined\n\n\treturn {\n\t\tname: name.trim(),\n\t\ttype: type?.trim(),\n\t\tdefaultValue: defaultValue?.trim(),\n\t\tisOptional: !!defaultValue,\n\t}\n}\n\n/**\n * \u63D0\u53D6\u51FD\u6570\u53C2\u6570\n */\nfunction extractParameters(node: Parser.SyntaxNode, sourceCode: string): ParameterInfo[] {\n\tconst parameters: ParameterInfo[] = []\n\n\t// \u67E5\u627E\u53C2\u6570\u5217\u8868\n\tconst parameterList = node.children.find((child) => child.type === \"function_value_parameters\")\n\tif (parameterList) {\n\t\t// \u67E5\u627E\u6240\u6709\u53C2\u6570\n\t\tconst paramNodes = parameterList.children.filter((child) => child.type === \"parameter\")\n\t\tparamNodes.forEach((paramNode) => {\n\t\t\tconst paramInfo = parseParameterInfo(paramNode, sourceCode)\n\t\t\tif (paramInfo.name) {\n\t\t\t\tparameters.push(paramInfo)\n\t\t\t}\n\t\t})\n\t}\n\n\treturn parameters\n}\n\n/**\n * \u63D0\u53D6\u51FD\u6570\u8FD4\u56DE\u7C7B\u578B\n */\nfunction extractReturnType(node: Parser.SyntaxNode, sourceCode: string): string {\n\t// \u67E5\u627E\u8FD4\u56DE\u7C7B\u578B\n\tconst returnTypeNode = node.children.find((child) => child.type === \"user_type\" || child.type === \"type_identifier\")\n\tif (returnTypeNode) {\n\t\treturn sourceCode.substring(returnTypeNode.startIndex, returnTypeNode.endIndex)\n\t}\n\n\treturn \"Unit\"\n}\n\n/**\n * \u4ECEKotlin\u4EE3\u7801\u7684AST\u6355\u83B7\u4E2D\u63D0\u53D6\u4EE3\u7801\u7247\u6BB5\n */\nexport async function extractSnippetsFromCapturesForKotlin(\n\tcaptures: Parser.QueryCapture[],\n\tsourceCode: string,\n\tfilePath: string,\n\tfileHash: string,\n\tsnippetTypes: SnippetType[],\n\toptions: { maxSnippetLines: number; minSnippetLines: number },\n): Promise {\n\tconst logger = Logger.getDefaultLogger().with(\"[extractSnippetsFromCapturesForKotlin]\")\n\tconst snippets: ISnippetMeta[] = []\n\tconst seenHashes = new Set()\n\n\tif (snippetTypes.length === 0) {\n\t\tlogger.warn(`No snippet types provided, skipping`)\n\t\treturn snippets\n\t}\n\n\t// \u5904\u7406 import \u548C package\n\tif (snippetTypes.includes(SnippetType.ImportOrInclude)) {\n\t\tcaptures.forEach((capture) => {\n\t\t\tif (capture.name === \"definition.import\") {\n\t\t\t\tconst node = capture.node\n\t\t\t\tconst startLine = node.startPosition.row + 1\n\t\t\t\tconst endLine = node.endPosition.row + 1\n\n\t\t\t\t// \u63D0\u53D6import\u8DEF\u5F84\n\t\t\t\tconst importPath = extractImportPath(node, sourceCode)\n\t\t\t\tconst name = importPath\n\t\t\t\tconst scope = [\"global\"]\n\t\t\t\tconst rangeText = sourceCode.substring(node.startIndex, node.endIndex).trim()\n\n\t\t\t\t// \u751F\u6210\u552F\u4E00\u7684\u54C8\u5E0C\u503C\n\t\t\t\tconst hash = crypto.createHash(\"md5\").update(`${name}-${filePath}-${startLine}`).digest(\"hex\")\n\t\t\t\tif (seenHashes.has(hash)) {\n\t\t\t\t\treturn\n\t\t\t\t}\n\t\t\t\tseenHashes.add(hash)\n\n\t\t\t\tsnippets.push({\n\t\t\t\t\tname,\n\t\t\t\t\ttype: SnippetType.ImportOrInclude,\n\t\t\t\t\tfilePath,\n\t\t\t\t\tstartLine,\n\t\t\t\t\tendLine,\n\t\t\t\t\trangeText,\n\t\t\t\t\tdefinitionText: rangeText,\n\t\t\t\t\tscope,\n\t\t\t\t\tfileHash,\n\t\t\t\t\tlanguage: CodeLanguageType.Kotlin,\n\t\t\t\t\tdefinition: {\n\t\t\t\t\t\tname,\n\t\t\t\t\t\ttype: \"import\",\n\t\t\t\t\t},\n\t\t\t\t})\n\t\t\t}\n\t\t})\n\t}\n\n\t// \u5904\u7406\u7C7B\u3001\u63A5\u53E3\u3001\u5BF9\u8C61\u7B49\u58F0\u660E\n\tif (snippetTypes.includes(SnippetType.ClassOrInterfaceOrStructOrEnum)) {\n\t\tcaptures.forEach((capture) => {\n\t\t\tif (capture.name === \"definition.class\" || capture.name === \"definition.object\") {\n\t\t\t\tconst node = capture.node\n\t\t\t\tconst startLine = node.startPosition.row + 1\n\t\t\t\tconst endLine = node.endPosition.row + 1\n\n\t\t\t\t// \u63D0\u53D6\u540D\u79F0\n\t\t\t\tconst nameNode = node.children.find((child) => child.type === \"type_identifier\")\n\t\t\t\tconst name = nameNode ? sourceCode.substring(nameNode.startIndex, nameNode.endIndex) : \"\"\n\n\t\t\t\tif (!name) return\n\n\t\t\t\tconst scope = [\"global\"]\n\t\t\t\tconst rangeText = sourceCode.substring(node.startIndex, node.endIndex)\n\n\t\t\t\t// \u751F\u6210\u552F\u4E00\u7684\u54C8\u5E0C\u503C\n\t\t\t\tconst hash = crypto.createHash(\"md5\").update(`${name}-${filePath}-${startLine}`).digest(\"hex\")\n\t\t\t\tif (seenHashes.has(hash)) {\n\t\t\t\t\treturn\n\t\t\t\t}\n\t\t\t\tseenHashes.add(hash)\n\n\t\t\t\t// \u63D0\u53D6\u4FEE\u9970\u7B26\u548C\u7C7B\u578B\n\t\t\t\tconst modifiers = extractModifiers(node, sourceCode)\n\t\t\t\tconst definitionType = getDefinitionType(node, sourceCode)\n\n\t\t\t\tsnippets.push({\n\t\t\t\t\tname,\n\t\t\t\t\ttype: SnippetType.ClassOrInterfaceOrStructOrEnum,\n\t\t\t\t\tfilePath,\n\t\t\t\t\tstartLine,\n\t\t\t\t\tendLine,\n\t\t\t\t\trangeText,\n\t\t\t\t\tdefinitionText: rangeText,\n\t\t\t\t\tscope,\n\t\t\t\t\tfileHash,\n\t\t\t\t\tlanguage: CodeLanguageType.Kotlin,\n\t\t\t\t\tdefinition: {\n\t\t\t\t\t\tname,\n\t\t\t\t\t\ttype: definitionType,\n\t\t\t\t\t\tvisibility: modifiers.includes(\"private\")\n\t\t\t\t\t\t\t? \"private\"\n\t\t\t\t\t\t\t: modifiers.includes(\"protected\")\n\t\t\t\t\t\t\t\t? \"protected\"\n\t\t\t\t\t\t\t\t: modifiers.includes(\"internal\")\n\t\t\t\t\t\t\t\t\t? \"internal\"\n\t\t\t\t\t\t\t\t\t: \"public\",\n\t\t\t\t\t},\n\t\t\t\t})\n\t\t\t}\n\t\t})\n\t}\n\n\t// \u5904\u7406\u51FD\u6570\u548C\u65B9\u6CD5\u76F8\u5173\u58F0\u660E\n\tif (snippetTypes.includes(SnippetType.FunctionOrMethod)) {\n\t\tcaptures.forEach((capture) => {\n\t\t\tif (capture.name === \"definition.function\") {\n\t\t\t\tconst node = capture.node\n\t\t\t\tconst startLine = node.startPosition.row + 1\n\t\t\t\tconst endLine = node.endPosition.row + 1\n\n\t\t\t\t// \u63D0\u53D6\u51FD\u6570\u540D\u79F0\n\t\t\t\tconst nameNode = node.children.find((child) => child.type === \"simple_identifier\")\n\t\t\t\tconst name = nameNode ? sourceCode.substring(nameNode.startIndex, nameNode.endIndex) : \"\"\n\n\t\t\t\tif (!name) return\n\n\t\t\t\tconst scope = [\"global\"]\n\t\t\t\tconst rangeText = sourceCode.substring(node.startIndex, node.endIndex)\n\n\t\t\t\t// \u751F\u6210\u552F\u4E00\u7684\u54C8\u5E0C\u503C\n\t\t\t\tconst hash = crypto.createHash(\"md5\").update(`${name}-${filePath}-${startLine}`).digest(\"hex\")\n\t\t\t\tif (seenHashes.has(hash)) {\n\t\t\t\t\treturn\n\t\t\t\t}\n\t\t\t\tseenHashes.add(hash)\n\n\t\t\t\t// \u63D0\u53D6\u51FD\u6570\u53C2\u6570\u548C\u8FD4\u56DE\u7C7B\u578B\n\t\t\t\tconst parameters = extractParameters(node, sourceCode)\n\t\t\t\tconst returnType = extractReturnType(node, sourceCode)\n\t\t\t\tconst modifiers = extractModifiers(node, sourceCode)\n\n\t\t\t\t// \u67E5\u627E\u6240\u5C5E\u7C7B\n\t\t\t\tconst className = findParentClassName(captures, node, sourceCode)\n\n\t\t\t\tsnippets.push({\n\t\t\t\t\tname,\n\t\t\t\t\ttype: SnippetType.FunctionOrMethod,\n\t\t\t\t\tfilePath,\n\t\t\t\t\tstartLine,\n\t\t\t\t\tendLine,\n\t\t\t\t\trangeText,\n\t\t\t\t\tdefinitionText: rangeText,\n\t\t\t\t\tscope,\n\t\t\t\t\tfileHash,\n\t\t\t\t\tlanguage: CodeLanguageType.Kotlin,\n\t\t\t\t\tparameters,\n\t\t\t\t\t...(className && { field: className }),\n\t\t\t\t\tdefinition: {\n\t\t\t\t\t\tname,\n\t\t\t\t\t\ttype: \"function\",\n\t\t\t\t\t\tparameters,\n\t\t\t\t\t\treturnType,\n\t\t\t\t\t\tvisibility: modifiers.includes(\"private\")\n\t\t\t\t\t\t\t? \"private\"\n\t\t\t\t\t\t\t: modifiers.includes(\"protected\")\n\t\t\t\t\t\t\t\t? \"protected\"\n\t\t\t\t\t\t\t\t: modifiers.includes(\"internal\")\n\t\t\t\t\t\t\t\t\t? \"internal\"\n\t\t\t\t\t\t\t\t\t: \"public\",\n\t\t\t\t\t\t...(className && { className }),\n\t\t\t\t\t},\n\t\t\t\t})\n\t\t\t}\n\t\t})\n\t}\n\n\t// \u5904\u7406\u53D8\u91CF\u548C\u5E38\u91CF\u76F8\u5173\u58F0\u660E\n\tif (snippetTypes.includes(SnippetType.VariableOrConstant)) {\n\t\tcaptures.forEach((capture) => {\n\t\t\tif (capture.name === \"definition.property\") {\n\t\t\t\tconst node = capture.node\n\t\t\t\tconst startLine = node.startPosition.row + 1\n\t\t\t\tconst endLine = node.endPosition.row + 1\n\n\t\t\t\t// \u63D0\u53D6\u5C5E\u6027\u540D\u79F0 - \u5C1D\u8BD5\u591A\u79CD\u65B9\u5F0F\u67E5\u627E\u540D\u79F0\n\t\t\t\tlet nameNode = node.children.find((child) => child.type === \"simple_identifier\")\n\t\t\t\tif (!nameNode) {\n\t\t\t\t\t// \u5982\u679C\u6CA1\u6709\u627E\u5230\uFF0C\u5C1D\u8BD5\u5728variable_declaration\u4E2D\u67E5\u627E\n\t\t\t\t\tconst variableDecl = node.children.find((child) => child.type === \"variable_declaration\")\n\t\t\t\t\tif (variableDecl) {\n\t\t\t\t\t\tnameNode = variableDecl.children.find((child) => child.type === \"simple_identifier\")\n\t\t\t\t\t}\n\t\t\t\t}\n\t\t\t\tconst name = nameNode ? sourceCode.substring(nameNode.startIndex, nameNode.endIndex) : \"\"\n\n\t\t\t\tif (!name) return\n\n\t\t\t\tconst scope = [\"global\"]\n\t\t\t\tconst rangeText = sourceCode.substring(node.startIndex, node.endIndex)\n\n\t\t\t\t// \u751F\u6210\u552F\u4E00\u7684\u54C8\u5E0C\u503C\n\t\t\t\tconst hash = crypto.createHash(\"md5\").update(`${name}-${filePath}-${startLine}`).digest(\"hex\")\n\t\t\t\tif (seenHashes.has(hash)) {\n\t\t\t\t\treturn\n\t\t\t\t}\n\t\t\t\tseenHashes.add(hash)\n\n\t\t\t\t// \u63D0\u53D6\u4FEE\u9970\u7B26\n\t\t\t\tconst modifiers = extractModifiers(node, sourceCode)\n\n\t\t\t\t// \u67E5\u627E\u6240\u5C5E\u7C7B\n\t\t\t\tconst className = findParentClassName(captures, node, sourceCode)\n\n\t\t\t\tsnippets.push({\n\t\t\t\t\tname,\n\t\t\t\t\ttype: SnippetType.VariableOrConstant,\n\t\t\t\t\tfilePath,\n\t\t\t\t\tstartLine,\n\t\t\t\t\tendLine,\n\t\t\t\t\trangeText,\n\t\t\t\t\tdefinitionText: rangeText,\n\t\t\t\t\tscope,\n\t\t\t\t\tfileHash,\n\t\t\t\t\tlanguage: CodeLanguageType.Kotlin,\n\t\t\t\t\t...(className && { field: className }),\n\t\t\t\t\tdefinition: {\n\t\t\t\t\t\tname,\n\t\t\t\t\t\ttype: \"property\",\n\t\t\t\t\t\tvisibility: modifiers.includes(\"private\")\n\t\t\t\t\t\t\t? \"private\"\n\t\t\t\t\t\t\t: modifiers.includes(\"protected\")\n\t\t\t\t\t\t\t\t? \"protected\"\n\t\t\t\t\t\t\t\t: modifiers.includes(\"internal\")\n\t\t\t\t\t\t\t\t\t? \"internal\"\n\t\t\t\t\t\t\t\t\t: \"public\",\n\t\t\t\t\t\t...(className && { className }),\n\t\t\t\t\t},\n\t\t\t\t})\n\t\t\t}\n\t\t})\n\t}\n\n\t// \u5904\u7406 typealias \u58F0\u660E\n\tif (snippetTypes.includes(SnippetType.ClassOrInterfaceOrStructOrEnum)) {\n\t\tcaptures.forEach((capture) => {\n\t\t\tif (capture.name === \"definition.type_alias\") {\n\t\t\t\tconst node = capture.node\n\t\t\t\tconst startLine = node.startPosition.row + 1\n\t\t\t\tconst endLine = node.endPosition.row + 1\n\n\t\t\t\t// \u63D0\u53D6 typealias \u540D\u79F0\n\t\t\t\tconst nameNode = node.children.find((child) => child.type === \"type_identifier\")\n\t\t\t\tconst name = nameNode ? sourceCode.substring(nameNode.startIndex, nameNode.endIndex) : \"\"\n\n\t\t\t\tif (!name) return\n\n\t\t\t\tconst scope = [\"global\"]\n\t\t\t\tconst rangeText = sourceCode.substring(node.startIndex, node.endIndex)\n\n\t\t\t\t// \u751F\u6210\u552F\u4E00\u7684\u54C8\u5E0C\u503C\n\t\t\t\tconst hash = crypto.createHash(\"md5\").update(`${name}-${filePath}-${startLine}`).digest(\"hex\")\n\t\t\t\tif (seenHashes.has(hash)) {\n\t\t\t\t\treturn\n\t\t\t\t}\n\t\t\t\tseenHashes.add(hash)\n\n\t\t\t\tsnippets.push({\n\t\t\t\t\tname,\n\t\t\t\t\ttype: SnippetType.ClassOrInterfaceOrStructOrEnum,\n\t\t\t\t\tfilePath,\n\t\t\t\t\tstartLine,\n\t\t\t\t\tendLine,\n\t\t\t\t\trangeText,\n\t\t\t\t\tdefinitionText: rangeText,\n\t\t\t\t\tscope,\n\t\t\t\t\tfileHash,\n\t\t\t\t\tlanguage: CodeLanguageType.Kotlin,\n\t\t\t\t\tdefinition: {\n\t\t\t\t\t\tname,\n\t\t\t\t\t\ttype: \"type_alias\",\n\t\t\t\t\t},\n\t\t\t\t})\n\t\t\t}\n\t\t})\n\t}\n\n\treturn snippets\n}\n\n/**\n * \u6784\u5EFAKotlin\u4EE3\u7801\u7247\u6BB5\u7684\u6458\u8981\n */\nexport function buildSummaryFromSnippets(snippets: ISnippetMeta[]): any {\n\tconst summary = {\n\t\timports: snippets.filter((s) => s.type === SnippetType.ImportOrInclude),\n\t\tclasses: snippets.filter((s) => s.type === SnippetType.ClassOrInterfaceOrStructOrEnum),\n\t\tfunctions: snippets.filter((s) => s.type === SnippetType.FunctionOrMethod),\n\t\tvariables: snippets.filter((s) => s.type === SnippetType.VariableOrConstant),\n\t}\n\n\treturn summary\n}\n\n/**\n * \u683C\u5F0F\u5316\u5927\u7EB2\u6587\u672C\n */\nexport function formatOutlineText(summary: any): string {\n\tconst lines: string[] = []\n\n\t// \u5904\u7406imports\n\tif (summary.imports?.length > 0) {\n\t\tlines.push(\"# Imports\")\n\t\tsummary.imports.forEach((item: ISnippetMeta) => {\n\t\t\tlines.push(` import: ${item.name}`)\n\t\t})\n\t\tlines.push(\"\")\n\t}\n\n\t// \u5904\u7406classes\n\tif (summary.classes?.length > 0) {\n\t\tlines.push(\"# Classes/Interfaces/Objects\")\n\t\tsummary.classes.forEach((item: ISnippetMeta) => {\n\t\t\tconst type = item.definition?.type || \"class\"\n\t\t\tlines.push(` ${type}: ${item.name}`)\n\t\t})\n\t\tlines.push(\"\")\n\t}\n\n\t// \u5904\u7406functions\n\tif (summary.functions?.length > 0) {\n\t\tlines.push(\"# Functions/Methods\")\n\t\tsummary.functions.forEach((item: ISnippetMeta) => {\n\t\t\tconst params = item.definition?.parameters?.map((p) => `${p.name}: ${p.type || \"Any\"}`).join(\", \") || \"\"\n\t\t\tconst returnType = item.definition?.returnType || \"Unit\"\n\t\t\tconst className = item.field\n\t\t\tconst prefix = className ? `[${className}] ` : \"\"\n\t\t\tlines.push(` ${prefix}${item.name}(${params}): ${returnType}`)\n\t\t})\n\t\tlines.push(\"\")\n\t}\n\n\t// \u5904\u7406variables\n\tif (summary.variables?.length > 0) {\n\t\tlines.push(\"# Variables/Properties\")\n\t\tsummary.variables.forEach((item: ISnippetMeta) => {\n\t\t\tconst className = item.field\n\t\t\tconst prefix = className ? `[${className}] ` : \"\"\n\t\t\tlines.push(` ${prefix}property: ${item.name}`)\n\t\t})\n\t\tlines.push(\"\")\n\t}\n\n\treturn lines.join(\"\\n\")\n}\n", "import { SnippetType, ISnippetMeta, ParameterInfo, CodeLanguageType } from \"../types\"\nimport Parser from \"web-tree-sitter\"\nimport { generateSnippetHash, buildScopeChain } from \"./general\"\nimport { Logger } from \"../Logger\"\n\nexport async function extractSnippetsFromCapturesForPHP(\n\tcaptures: Parser.QueryCapture[],\n\tsourceCode: string,\n\tfilePath: string,\n\tfileHash: string,\n\tsnippetTypes: SnippetType[],\n\toptions: { maxSnippetLines: number; minSnippetLines: number },\n): Promise {\n\tconst logger = Logger.getDefaultLogger().with(\"[extractSnippetsFromCapturesForPHP]\")\n\n\tconst snippets: ISnippetMeta[] = []\n\tconst seenHashes = new Set()\n\n\tif (snippetTypes.length === 0) {\n\t\tlogger.warn(`No snippet types provided, skipping`)\n\t\treturn snippets\n\t}\n\n\t// \u6536\u96C6\u6240\u6709\u7C7B\u76F8\u5173\u7684captures\u7528\u4E8E\u786E\u5B9Afield\u5F52\u5C5E\n\tconst classCaptures = captures\n\t\t.filter(\n\t\t\t(c) =>\n\t\t\t\tc.name === \"definition.class\" ||\n\t\t\t\tc.name === \"definition.abstract_class\" ||\n\t\t\t\tc.name === \"definition.final_class\" ||\n\t\t\t\tc.name === \"definition.readonly_class\",\n\t\t)\n\t\t.map((c) => ({\n\t\t\tnode: c.node,\n\t\t\tstart: c.node.startIndex,\n\t\t\tend: c.node.endIndex,\n\t\t\tnameCap: captures.find(\n\t\t\t\t(nc) =>\n\t\t\t\t\t(nc.name === \"name.definition.class\" ||\n\t\t\t\t\t\tnc.name === \"name.definition.abstract_class\" ||\n\t\t\t\t\t\tnc.name === \"name.definition.final_class\" ||\n\t\t\t\t\t\tnc.name === \"name.definition.readonly_class\") &&\n\t\t\t\t\tnc.node.startIndex >= c.node.startIndex &&\n\t\t\t\t\tnc.node.endIndex <= c.node.endIndex,\n\t\t\t),\n\t\t}))\n\n\t// \u6536\u96C6\u63A5\u53E3\u3001trait\u3001\u679A\u4E3E\u7684captures\n\tconst interfaceCaptures = captures\n\t\t.filter((c) => c.name === \"definition.interface\")\n\t\t.map((c) => ({\n\t\t\tnode: c.node,\n\t\t\tstart: c.node.startIndex,\n\t\t\tend: c.node.endIndex,\n\t\t\tnameCap: captures.find(\n\t\t\t\t(nc) =>\n\t\t\t\t\tnc.name === \"name.definition.interface\" &&\n\t\t\t\t\tnc.node.startIndex >= c.node.startIndex &&\n\t\t\t\t\tnc.node.endIndex <= c.node.endIndex,\n\t\t\t),\n\t\t}))\n\n\tconst traitCaptures = captures\n\t\t.filter((c) => c.name === \"definition.trait\")\n\t\t.map((c) => ({\n\t\t\tnode: c.node,\n\t\t\tstart: c.node.startIndex,\n\t\t\tend: c.node.endIndex,\n\t\t\tnameCap: captures.find(\n\t\t\t\t(nc) =>\n\t\t\t\t\tnc.name === \"name.definition.trait\" &&\n\t\t\t\t\tnc.node.startIndex >= c.node.startIndex &&\n\t\t\t\t\tnc.node.endIndex <= c.node.endIndex,\n\t\t\t),\n\t\t}))\n\n\tconst enumCaptures = captures\n\t\t.filter((c) => c.name === \"definition.enum\")\n\t\t.map((c) => ({\n\t\t\tnode: c.node,\n\t\t\tstart: c.node.startIndex,\n\t\t\tend: c.node.endIndex,\n\t\t\tnameCap: captures.find(\n\t\t\t\t(nc) =>\n\t\t\t\t\tnc.name === \"name.definition.enum\" &&\n\t\t\t\t\tnc.node.startIndex >= c.node.startIndex &&\n\t\t\t\t\tnc.node.endIndex <= c.node.endIndex,\n\t\t\t),\n\t\t}))\n\n\t// \u6536\u96C6namespace captures\u7528\u4E8E\u786E\u5B9Anamespace\u5F52\u5C5E\n\tconst namespaceCaptures = captures\n\t\t.filter((c) => c.name === \"definition.namespace\")\n\t\t.map((c) => ({\n\t\t\tnode: c.node,\n\t\t\tstart: c.node.startIndex,\n\t\t\tend: c.node.endIndex,\n\t\t\tnameCap: captures.find(\n\t\t\t\t(nc) =>\n\t\t\t\t\tnc.name === \"name.definition.namespace\" &&\n\t\t\t\t\tnc.node.startIndex >= c.node.startIndex &&\n\t\t\t\t\tnc.node.endIndex <= c.node.endIndex,\n\t\t\t),\n\t\t}))\n\n\t// \u8F85\u52A9\u51FD\u6570\uFF1A\u786E\u5B9A\u8282\u70B9\u6240\u5C5E\u7684namespace\n\tfunction findNamespaceForNode(node: Parser.SyntaxNode): string | undefined {\n\t\t// \u5728PHP\u4E2D\uFF0Cnamespace\u901A\u5E38\u662F\u6587\u4EF6\u7EA7\u522B\u7684\uFF0C\u627E\u5230\u6700\u8FD1\u7684\u524D\u9762\u7684namespace\u58F0\u660E\n\t\tlet closestNamespace: string | undefined = undefined\n\t\tlet closestDistance = Infinity\n\n\t\tfor (const ns of namespaceCaptures) {\n\t\t\t// namespace\u5E94\u8BE5\u5728\u5F53\u524D\u8282\u70B9\u4E4B\u524D\u5B9A\u4E49\n\t\t\tif (ns.start < node.startIndex && ns.nameCap) {\n\t\t\t\tconst distance = node.startIndex - ns.start\n\t\t\t\tif (distance < closestDistance) {\n\t\t\t\t\tclosestDistance = distance\n\t\t\t\t\tclosestNamespace = sourceCode.substring(ns.nameCap.node.startIndex, ns.nameCap.node.endIndex)\n\t\t\t\t}\n\t\t\t}\n\t\t}\n\n\t\treturn closestNamespace\n\t}\n\n\t// \u5904\u7406 use \u8BED\u53E5 (imports)\n\tcaptures.forEach((capture) => {\n\t\tif (capture.name === \"name.definition.use\") {\n\t\t\tconst node = capture.node\n\t\t\tconst startLine = node.startPosition.row + 1\n\t\t\tconst endLine = node.endPosition.row + 1\n\t\t\tconst rangeText = sourceCode.substring(node.startIndex, node.endIndex)\n\t\t\tconst snippetHash = generateSnippetHash(filePath, startLine, endLine, rangeText)\n\t\t\tif (seenHashes.has(snippetHash)) return\n\t\t\tseenHashes.add(snippetHash)\n\t\t\tconst name = sourceCode.substring(node.startIndex, node.endIndex)\n\t\t\tconst scope = buildScopeChain(node)\n\t\t\tconst namespace = findNamespaceForNode(node)\n\t\t\tsnippets.push({\n\t\t\t\tname,\n\t\t\t\ttype: SnippetType.ImportOrInclude,\n\t\t\t\tfilePath,\n\t\t\t\tstartLine,\n\t\t\t\tendLine,\n\t\t\t\trangeText,\n\t\t\t\tdefinitionText: rangeText,\n\t\t\t\tscope,\n\t\t\t\tfileHash,\n\t\t\t\tnamespace,\n\t\t\t})\n\t\t}\n\t})\n\n\t// \u5904\u7406\u51FD\u6570\u548C\u65B9\u6CD5\n\tfor (const capture of captures) {\n\t\tif (\n\t\t\tcapture.name !== \"definition.function\" &&\n\t\t\tcapture.name !== \"definition.method\" &&\n\t\t\tcapture.name !== \"definition.static_method\" &&\n\t\t\tcapture.name !== \"definition.abstract_method\" &&\n\t\t\tcapture.name !== \"definition.final_method\"\n\t\t)\n\t\t\tcontinue\n\n\t\tconst node = capture.node\n\t\tconst startLine = node.startPosition.row + 1\n\t\tconst endLine = node.endPosition.row + 1\n\n\t\t// \u786E\u5B9A\u540D\u79F0capture\u7684\u7C7B\u578B\n\t\tlet nameCapName: string\n\t\tlet paramCapName: string\n\t\tlet bodyCapName: string\n\n\t\tif (capture.name === \"definition.function\") {\n\t\t\tnameCapName = \"name.definition.function\"\n\t\t\tparamCapName = \"parameters.definition.function\"\n\t\t\tbodyCapName = \"body.definition.function\"\n\t\t} else if (capture.name === \"definition.method\") {\n\t\t\tnameCapName = \"name.definition.method\"\n\t\t\tparamCapName = \"parameters.definition.method\"\n\t\t\tbodyCapName = \"body.definition.method\"\n\t\t} else if (capture.name === \"definition.static_method\") {\n\t\t\tnameCapName = \"name.definition.static_method\"\n\t\t\tparamCapName = \"parameters.definition.static_method\"\n\t\t\tbodyCapName = \"body.definition.static_method\"\n\t\t} else if (capture.name === \"definition.abstract_method\") {\n\t\t\tnameCapName = \"name.definition.abstract_method\"\n\t\t\tparamCapName = \"parameters.definition.abstract_method\"\n\t\t\tbodyCapName = \"body.definition.abstract_method\"\n\t\t} else if (capture.name === \"definition.final_method\") {\n\t\t\tnameCapName = \"name.definition.final_method\"\n\t\t\tparamCapName = \"parameters.definition.final_method\"\n\t\t\tbodyCapName = \"body.definition.final_method\"\n\t\t} else {\n\t\t\tcontinue\n\t\t}\n\n\t\t// \u67E5\u627E\u51FD\u6570/\u65B9\u6CD5\u540D\n\t\tconst nameCap = captures.find(\n\t\t\t(c) => c.name === nameCapName && c.node.startIndex >= node.startIndex && c.node.endIndex <= node.endIndex,\n\t\t)\n\t\tif (!nameCap) continue\n\t\tconst name = sourceCode.substring(nameCap.node.startIndex, nameCap.node.endIndex)\n\n\t\t// \u89E3\u6790\u53C2\u6570\n\t\tconst paramCap = captures.find(\n\t\t\t(c) => c.name === paramCapName && c.node.startIndex >= node.startIndex && c.node.endIndex <= node.endIndex,\n\t\t)\n\t\tconst parameters: ParameterInfo[] = []\n\t\tif (paramCap) {\n\t\t\tconst paramText = sourceCode.substring(paramCap.node.startIndex, paramCap.node.endIndex)\n\t\t\tconst cleanText = removeParentheses(paramText).trim()\n\t\t\tif (cleanText) {\n\t\t\t\tconst paramList = parsePHPParameters(cleanText)\n\t\t\t\tparameters.push(...paramList.map((param: string) => ({ name: param })))\n\t\t\t}\n\t\t}\n\n\t\t// \u67E5\u627E\u51FD\u6570/\u65B9\u6CD5\u4F53\n\t\tconst bodyCap = captures.find(\n\t\t\t(c) => c.name === bodyCapName && c.node.startIndex >= node.startIndex && c.node.endIndex <= node.endIndex,\n\t\t)\n\n\t\tlet rangeText: string\n\t\tlet implementText: string | undefined = undefined\n\t\tif (bodyCap) {\n\t\t\trangeText = sourceCode.substring(node.startIndex, bodyCap.node.startIndex).trimEnd()\n\t\t\timplementText = sourceCode.substring(node.startIndex, node.endIndex)\n\t\t} else {\n\t\t\trangeText = sourceCode.substring(node.startIndex, node.endIndex)\n\t\t}\n\n\t\tconst snippetHash = generateSnippetHash(filePath, startLine, endLine, rangeText)\n\t\tif (seenHashes.has(snippetHash)) continue\n\t\tseenHashes.add(snippetHash)\n\n\t\tconst paramStr = parameters.map((p) => p.name).join(\", \")\n\t\tconst signature = `${name}(${paramStr})`\n\t\tconst scope = buildScopeChain(node)\n\n\t\t// \u786E\u5B9A\u5F52\u5C5E\u7684\u7C7B/\u63A5\u53E3/trait/\u679A\u4E3E\n\t\tlet field: string | undefined = undefined\n\t\tconst allParentCaptures = [...classCaptures, ...interfaceCaptures, ...traitCaptures, ...enumCaptures]\n\t\tfor (const parent of allParentCaptures) {\n\t\t\tif (node.startIndex > parent.start && node.endIndex <= parent.end && parent.nameCap) {\n\t\t\t\tfield = sourceCode.substring(parent.nameCap.node.startIndex, parent.nameCap.node.endIndex)\n\t\t\t\tbreak\n\t\t\t}\n\t\t}\n\n\t\tconst namespace = findNamespaceForNode(node)\n\n\t\tsnippets.push({\n\t\t\tname,\n\t\t\ttype: SnippetType.FunctionOrMethod,\n\t\t\tfilePath,\n\t\t\tstartLine,\n\t\t\tendLine,\n\t\t\trangeText,\n\t\t\tdefinitionText: rangeText,\n\t\t\tscope,\n\t\t\tfileHash,\n\t\t\tfield,\n\t\t\tnamespace,\n\t\t\tdefinition: {\n\t\t\t\tname,\n\t\t\t\ttype: capture.name === \"definition.function\" ? \"function\" : \"method\",\n\t\t\t\tparameters,\n\t\t\t\treturnType: \"mixed\", // PHP\u9ED8\u8BA4\u8FD4\u56DE\u7C7B\u578B\n\t\t\t},\n\t\t\tparameters,\n\t\t\tsignature,\n\t\t\tlanguage: CodeLanguageType.PHP,\n\t\t\t...(implementText ? { implementText } : {}),\n\t\t})\n\t}\n\n\t// \u5904\u7406\u5C5E\u6027\uFF08\u5305\u62EC\u9759\u6001\u5C5E\u6027\u3001\u53EA\u8BFB\u5C5E\u6027\u3001\u6784\u9020\u51FD\u6570\u63D0\u5347\u5C5E\u6027\uFF09\n\tfor (const capture of captures) {\n\t\tif (\n\t\t\tcapture.name !== \"definition.property\" &&\n\t\t\tcapture.name !== \"definition.static_property\" &&\n\t\t\tcapture.name !== \"definition.readonly_property\" &&\n\t\t\tcapture.name !== \"definition.promoted_property\"\n\t\t)\n\t\t\tcontinue\n\n\t\tconst node = capture.node\n\t\tconst startLine = node.startPosition.row + 1\n\t\tconst endLine = node.endPosition.row + 1\n\n\t\t// \u786E\u5B9A\u540D\u79F0capture\u7684\u7C7B\u578B\n\t\tlet nameCapName: string\n\t\tif (capture.name === \"definition.property\") {\n\t\t\tnameCapName = \"name.definition.property\"\n\t\t} else if (capture.name === \"definition.static_property\") {\n\t\t\tnameCapName = \"name.definition.static_property\"\n\t\t} else if (capture.name === \"definition.readonly_property\") {\n\t\t\tnameCapName = \"name.definition.readonly_property\"\n\t\t} else if (capture.name === \"definition.promoted_property\") {\n\t\t\tnameCapName = \"name.definition.promoted_property\"\n\t\t} else {\n\t\t\tcontinue\n\t\t}\n\n\t\t// \u67E5\u627E\u5C5E\u6027\u540D\n\t\tconst nameCap = captures.find(\n\t\t\t(c) => c.name === nameCapName && c.node.startIndex >= node.startIndex && c.node.endIndex <= node.endIndex,\n\t\t)\n\t\tif (!nameCap) continue\n\t\tconst name = sourceCode.substring(nameCap.node.startIndex, nameCap.node.endIndex)\n\n\t\tconst rangeText = sourceCode.substring(node.startIndex, node.endIndex)\n\t\tconst snippetHash = generateSnippetHash(filePath, startLine, endLine, rangeText)\n\t\tif (seenHashes.has(snippetHash)) continue\n\t\tseenHashes.add(snippetHash)\n\n\t\tconst scope = buildScopeChain(node)\n\n\t\t// \u786E\u5B9A\u5F52\u5C5E\u7684\u7C7B/\u63A5\u53E3/trait/\u679A\u4E3E\n\t\tlet field: string | undefined = undefined\n\t\tconst allParentCaptures = [...classCaptures, ...interfaceCaptures, ...traitCaptures, ...enumCaptures]\n\t\tfor (const parent of allParentCaptures) {\n\t\t\tif (node.startIndex > parent.start && node.endIndex <= parent.end && parent.nameCap) {\n\t\t\t\tfield = sourceCode.substring(parent.nameCap.node.startIndex, parent.nameCap.node.endIndex)\n\t\t\t\tbreak\n\t\t\t}\n\t\t}\n\n\t\tconst namespace = findNamespaceForNode(node)\n\n\t\tsnippets.push({\n\t\t\tname,\n\t\t\ttype: SnippetType.VariableOrConstant,\n\t\t\tfilePath,\n\t\t\tstartLine,\n\t\t\tendLine,\n\t\t\trangeText,\n\t\t\tdefinitionText: rangeText,\n\t\t\tscope,\n\t\t\tfileHash,\n\t\t\tfield,\n\t\t\tnamespace,\n\t\t\tlanguage: CodeLanguageType.PHP,\n\t\t})\n\t}\n\n\t// \u5904\u7406\u5E38\u91CF\n\tfor (const capture of captures) {\n\t\tif (capture.name !== \"definition.constant\") continue\n\n\t\tconst node = capture.node\n\t\tconst startLine = node.startPosition.row + 1\n\t\tconst endLine = node.endPosition.row + 1\n\n\t\tconst nameCap = captures.find(\n\t\t\t(c) =>\n\t\t\t\tc.name === \"name.definition.constant\" &&\n\t\t\t\tc.node.startIndex >= node.startIndex &&\n\t\t\t\tc.node.endIndex <= node.endIndex,\n\t\t)\n\t\tif (!nameCap) continue\n\t\tconst name = sourceCode.substring(nameCap.node.startIndex, nameCap.node.endIndex)\n\n\t\tconst rangeText = sourceCode.substring(node.startIndex, node.endIndex)\n\t\tconst snippetHash = generateSnippetHash(filePath, startLine, endLine, rangeText)\n\t\tif (seenHashes.has(snippetHash)) continue\n\t\tseenHashes.add(snippetHash)\n\n\t\tconst scope = buildScopeChain(node)\n\n\t\t// \u786E\u5B9A\u5F52\u5C5E\u7684\u7C7B/\u63A5\u53E3/trait/\u679A\u4E3E\n\t\tlet field: string | undefined = undefined\n\t\tconst allParentCaptures = [...classCaptures, ...interfaceCaptures, ...traitCaptures, ...enumCaptures]\n\t\tfor (const parent of allParentCaptures) {\n\t\t\tif (node.startIndex > parent.start && node.endIndex <= parent.end && parent.nameCap) {\n\t\t\t\tfield = sourceCode.substring(parent.nameCap.node.startIndex, parent.nameCap.node.endIndex)\n\t\t\t\tbreak\n\t\t\t}\n\t\t}\n\n\t\tconst namespace = findNamespaceForNode(node)\n\n\t\tsnippets.push({\n\t\t\tname,\n\t\t\ttype: SnippetType.VariableOrConstant,\n\t\t\tfilePath,\n\t\t\tstartLine,\n\t\t\tendLine,\n\t\t\trangeText,\n\t\t\tdefinitionText: rangeText,\n\t\t\tscope,\n\t\t\tfileHash,\n\t\t\tfield,\n\t\t\tnamespace,\n\t\t\tlanguage: CodeLanguageType.PHP,\n\t\t})\n\t}\n\n\t// \u5904\u7406\u7C7B\u3001\u63A5\u53E3\u3001trait\u3001\u679A\u4E3E\u5B9A\u4E49\n\tconst typeDefs = [\n\t\t{ capture: \"name.definition.class\", outlineType: \"class\" },\n\t\t{ capture: \"name.definition.abstract_class\", outlineType: \"abstract_class\" },\n\t\t{ capture: \"name.definition.final_class\", outlineType: \"final_class\" },\n\t\t{ capture: \"name.definition.readonly_class\", outlineType: \"readonly_class\" },\n\t\t{ capture: \"name.definition.interface\", outlineType: \"interface\" },\n\t\t{ capture: \"name.definition.trait\", outlineType: \"trait\" },\n\t\t{ capture: \"name.definition.enum\", outlineType: \"enum\" },\n\t]\n\n\tfor (const { capture, outlineType } of typeDefs) {\n\t\tconst defCaptureName = `definition.${outlineType}`\n\t\tfor (const cap of captures.filter((c) => c.name === capture)) {\n\t\t\tconst node = cap.node\n\t\t\t// \u5224\u65AD\u662F\u5426\u5728\u51FD\u6570/\u65B9\u6CD5\u5185\uFF08\u5C40\u90E8\u7C7B\uFF09\n\t\t\tconst isInMethod = captures.some(\n\t\t\t\t(fc) =>\n\t\t\t\t\t(fc.name === \"definition.function\" ||\n\t\t\t\t\t\tfc.name === \"definition.method\" ||\n\t\t\t\t\t\tfc.name === \"definition.static_method\" ||\n\t\t\t\t\t\tfc.name === \"definition.abstract_method\" ||\n\t\t\t\t\t\tfc.name === \"definition.final_method\") &&\n\t\t\t\t\tfc.node.startIndex < node.startIndex &&\n\t\t\t\t\tnode.endIndex < fc.node.endIndex,\n\t\t\t)\n\t\t\tif (isInMethod) continue\n\n\t\t\t// \u4F18\u5148\u4F7F\u7528 @definition.xxx \u533A\u95F4\n\t\t\tconst defCap = captures.find(\n\t\t\t\t(c) =>\n\t\t\t\t\tc.name === defCaptureName &&\n\t\t\t\t\tc.node.startIndex <= node.startIndex &&\n\t\t\t\t\tnode.endIndex <= c.node.endIndex,\n\t\t\t)\n\t\t\tconst rangeText = defCap\n\t\t\t\t? sourceCode.substring(defCap.node.startIndex, defCap.node.endIndex)\n\t\t\t\t: sourceCode.substring(node.startIndex, node.endIndex)\n\t\t\tconst startLine = node.startPosition.row + 1\n\t\t\tconst endLine = node.endPosition.row + 1\n\t\t\tconst snippetHash = generateSnippetHash(filePath, startLine, endLine, rangeText)\n\t\t\tif (seenHashes.has(snippetHash)) continue\n\t\t\tseenHashes.add(snippetHash)\n\t\t\tconst name = sourceCode.substring(node.startIndex, node.endIndex)\n\t\t\tconst scope = buildScopeChain(node)\n\t\t\tconst namespace = findNamespaceForNode(node)\n\n\t\t\tsnippets.push({\n\t\t\t\tname,\n\t\t\t\ttype: SnippetType.ClassOrInterfaceOrStructOrEnum,\n\t\t\t\tfilePath,\n\t\t\t\tstartLine,\n\t\t\t\tendLine,\n\t\t\t\trangeText,\n\t\t\t\tdefinitionText: rangeText,\n\t\t\t\timplementText: rangeText,\n\t\t\t\tscope,\n\t\t\t\tfileHash,\n\t\t\t\tnamespace,\n\t\t\t\tlanguage: CodeLanguageType.PHP,\n\t\t\t})\n\t\t}\n\t}\n\n\treturn snippets\n}\n\n// \u89E3\u6790PHP\u53C2\u6570\u7684\u8F85\u52A9\u51FD\u6570\nfunction parsePHPParameters(paramText: string): string[] {\n\tconst params: string[] = []\n\tlet current = \"\"\n\tlet depth = 0\n\tlet inString = false\n\tlet stringChar = \"\"\n\n\tfor (let i = 0; i < paramText.length; i++) {\n\t\tconst char = paramText[i]\n\t\tconst prev = i > 0 ? paramText[i - 1] : \"\"\n\n\t\tif (!inString) {\n\t\t\tif (char === '\"' || char === \"'\") {\n\t\t\t\tinString = true\n\t\t\t\tstringChar = char\n\t\t\t} else if (char === \"(\" || char === \"[\" || char === \"{\") {\n\t\t\t\tdepth++\n\t\t\t} else if (char === \")\" || char === \"]\" || char === \"}\") {\n\t\t\t\tdepth--\n\t\t\t} else if (char === \",\" && depth === 0) {\n\t\t\t\tif (current.trim()) {\n\t\t\t\t\tparams.push(extractPHPParamName(current.trim()))\n\t\t\t\t}\n\t\t\t\tcurrent = \"\"\n\t\t\t\tcontinue\n\t\t\t}\n\t\t} else {\n\t\t\tif (char === stringChar && prev !== \"\\\\\") {\n\t\t\t\tinString = false\n\t\t\t\tstringChar = \"\"\n\t\t\t}\n\t\t}\n\n\t\tcurrent += char\n\t}\n\n\tif (current.trim()) {\n\t\tparams.push(extractPHPParamName(current.trim()))\n\t}\n\n\treturn params\n}\n\n// \u4ECEPHP\u53C2\u6570\u5B57\u7B26\u4E32\u4E2D\u63D0\u53D6\u53C2\u6570\u540D\nfunction extractPHPParamName(param: string): string {\n\t// \u79FB\u9664\u7C7B\u578B\u63D0\u793A\u3001\u9ED8\u8BA4\u503C\u7B49\uFF0C\u53EA\u4FDD\u7559\u53C2\u6570\u540D\n\t// \u4F8B\u5982: \"string $name = 'default'\" -> \"$name\"\n\t// \u4F8B\u5982: \"array &$items\" -> \"$items\"\n\t// \u4F8B\u5982: \"...$args\" -> \"$args\"\n\n\t// \u9996\u5148\u5904\u7406\u5F15\u7528\u7B26\u53F7\u548C\u5C55\u5F00\u8FD0\u7B97\u7B26\n\tlet cleaned = removeReferenceAndSplatOperators(param)\n\n\t// \u67E5\u627E\u53D8\u91CF\u540D\uFF08\u4EE5$\u5F00\u5934\uFF09\n\tconst variableName = findPHPVariableName(cleaned)\n\tif (variableName) {\n\t\treturn variableName\n\t}\n\n\t// \u5982\u679C\u6CA1\u6709\u627E\u5230\u53D8\u91CF\u540D\uFF0C\u8FD4\u56DE\u539F\u59CB\u53C2\u6570\n\treturn param\n}\n\n// \u79FB\u9664\u62EC\u53F7\u7684\u8F85\u52A9\u51FD\u6570\nfunction removeParentheses(text: string): string {\n\tif (text.startsWith(\"(\") && text.endsWith(\")\")) {\n\t\treturn text.slice(1, -1)\n\t}\n\treturn text\n}\n\n// \u79FB\u9664\u5F15\u7528\u7B26\u53F7\u548C\u5C55\u5F00\u8FD0\u7B97\u7B26\u7684\u8F85\u52A9\u51FD\u6570\nfunction removeReferenceAndSplatOperators(param: string): string {\n\tlet result = param.trim()\n\n\t// \u79FB\u9664\u5F00\u5934\u7684\u7A7A\u767D\n\twhile (result.startsWith(\" \") || result.startsWith(\"\\t\")) {\n\t\tresult = result.slice(1)\n\t}\n\n\t// \u79FB\u9664\u5F15\u7528\u7B26\u53F7 &\n\tif (result.startsWith(\"&\")) {\n\t\tresult = result.slice(1).trim()\n\t}\n\n\t// \u79FB\u9664\u5C55\u5F00\u8FD0\u7B97\u7B26 ...\n\tif (result.startsWith(\"...\")) {\n\t\tresult = result.slice(3).trim()\n\t}\n\n\treturn result\n}\n\n// \u67E5\u627EPHP\u53D8\u91CF\u540D\u7684\u8F85\u52A9\u51FD\u6570\nfunction findPHPVariableName(text: string): string | null {\n\t// \u67E5\u627E\u4EE5$\u5F00\u5934\u7684\u53D8\u91CF\u540D\n\tfor (let i = 0; i < text.length; i++) {\n\t\tif (text[i] === \"$\") {\n\t\t\tlet variableName = \"$\"\n\t\t\tlet j = i + 1\n\n\t\t\t// \u63D0\u53D6\u53D8\u91CF\u540D\u90E8\u5206\uFF08\u5B57\u6BCD\u3001\u6570\u5B57\u3001\u4E0B\u5212\u7EBF\uFF09\n\t\t\twhile (j < text.length) {\n\t\t\t\tconst char = text[j]\n\t\t\t\tif (isValidPHPVariableChar(char)) {\n\t\t\t\t\tvariableName += char\n\t\t\t\t\tj++\n\t\t\t\t} else {\n\t\t\t\t\tbreak\n\t\t\t\t}\n\t\t\t}\n\n\t\t\tif (variableName.length > 1) {\n\t\t\t\t// \u786E\u4FDD\u4E0D\u53EA\u662F$\u7B26\u53F7\n\t\t\t\treturn variableName\n\t\t\t}\n\t\t}\n\t}\n\n\treturn null\n}\n\n// \u68C0\u67E5\u5B57\u7B26\u662F\u5426\u662F\u6709\u6548\u7684PHP\u53D8\u91CF\u5B57\u7B26\nfunction isValidPHPVariableChar(char: string): boolean {\n\treturn (char >= \"a\" && char <= \"z\") || (char >= \"A\" && char <= \"Z\") || (char >= \"0\" && char <= \"9\") || char === \"_\"\n}\n\n// \u6784\u5EFA\u6982\u8981\u4FE1\u606F\nexport function buildSummaryFromSnippets(snippets: ISnippetMeta[]): OutlineData {\n\tconst outline: OutlineData = {\n\t\timports: [],\n\t\tclasses: [],\n\t\tinterfaces: [],\n\t\ttraits: [],\n\t\tenums: [],\n\t\tfunctions: [],\n\t\tconstants: [],\n\t\tnamespaces: [],\n\t}\n\n\tfor (const snippet of snippets) {\n\t\t// \u6536\u96C6namespace\u4FE1\u606F\n\t\tif (snippet.namespace && !outline.namespaces.includes(snippet.namespace)) {\n\t\t\toutline.namespaces.push(snippet.namespace)\n\t\t}\n\n\t\tswitch (snippet.type) {\n\t\t\tcase SnippetType.ImportOrInclude:\n\t\t\t\toutline.imports.push(snippet.name)\n\t\t\t\tbreak\n\t\t\tcase SnippetType.ClassOrInterfaceOrStructOrEnum:\n\t\t\t\tif (snippet.name.includes(\"interface\")) {\n\t\t\t\t\toutline.interfaces.push(snippet.name)\n\t\t\t\t} else if (snippet.name.includes(\"trait\")) {\n\t\t\t\t\toutline.traits.push(snippet.name)\n\t\t\t\t} else if (snippet.name.includes(\"enum\")) {\n\t\t\t\t\toutline.enums.push(snippet.name)\n\t\t\t\t} else {\n\t\t\t\t\toutline.classes.push(snippet.name)\n\t\t\t\t}\n\t\t\t\tbreak\n\t\t\tcase SnippetType.FunctionOrMethod:\n\t\t\t\toutline.functions.push(snippet.name)\n\t\t\t\tbreak\n\t\t\tcase SnippetType.VariableOrConstant:\n\t\t\t\tif (snippet.name.includes(\"const\")) {\n\t\t\t\t\toutline.constants.push(snippet.name)\n\t\t\t\t}\n\t\t\t\tbreak\n\t\t}\n\t}\n\n\treturn outline\n}\n\n// \u683C\u5F0F\u5316\u6982\u8981\u6587\u672C\nexport function formatOutlineText(outline: OutlineData): string {\n\tconst sections: string[] = []\n\n\tif (outline.namespaces.length > 0) {\n\t\tsections.push(`Namespaces: ${outline.namespaces.join(\", \")}`)\n\t}\n\n\tif (outline.imports.length > 0) {\n\t\tsections.push(`Imports: ${outline.imports.join(\", \")}`)\n\t}\n\n\tif (outline.classes.length > 0) {\n\t\tsections.push(`Classes: ${outline.classes.join(\", \")}`)\n\t}\n\n\tif (outline.interfaces.length > 0) {\n\t\tsections.push(`Interfaces: ${outline.interfaces.join(\", \")}`)\n\t}\n\n\tif (outline.traits.length > 0) {\n\t\tsections.push(`Traits: ${outline.traits.join(\", \")}`)\n\t}\n\n\tif (outline.enums.length > 0) {\n\t\tsections.push(`Enums: ${outline.enums.join(\", \")}`)\n\t}\n\n\tif (outline.functions.length > 0) {\n\t\tsections.push(`Functions: ${outline.functions.join(\", \")}`)\n\t}\n\n\tif (outline.constants.length > 0) {\n\t\tsections.push(`Constants: ${outline.constants.join(\", \")}`)\n\t}\n\n\treturn sections.join(\"\\n\")\n}\n\n// \u5B9A\u4E49\u6982\u8981\u6570\u636E\u7ED3\u6784\ninterface OutlineData {\n\timports: string[]\n\tclasses: string[]\n\tinterfaces: string[]\n\ttraits: string[]\n\tenums: string[]\n\tfunctions: string[]\n\tconstants: string[]\n\tnamespaces: string[]\n}\n", "import { SnippetType, ISnippetMeta, ParameterInfo, CodeLanguageType } from \"../types\"\nimport Parser from \"web-tree-sitter\"\nimport { generateSnippetHash, buildScopeChain } from \"./general\"\nimport { Logger } from \"../Logger\"\n\nexport async function extractSnippetsFromCapturesForRust(\n\tcaptures: Parser.QueryCapture[],\n\tsourceCode: string,\n\tfilePath: string,\n\tfileHash: string,\n\tsnippetTypes: SnippetType[],\n\toptions: { maxSnippetLines: number; minSnippetLines: number },\n): Promise {\n\tconst logger = Logger.getDefaultLogger().with(\"[extractSnippetsFromCapturesForRust]\")\n\n\tconst snippets: ISnippetMeta[] = []\n\tconst seenHashes = new Set()\n\n\tif (snippetTypes.length === 0) {\n\t\tlogger.warn(`No snippet types provided, skipping`)\n\t\treturn snippets\n\t}\n\n\t// \u6536\u96C6\u6240\u6709 struct/enum/trait/impl captures \u7528\u4E8E\u786E\u5B9A field\n\tconst containerCaptures = captures\n\t\t.filter(\n\t\t\t(c) =>\n\t\t\t\tc.name === \"definition.struct\" ||\n\t\t\t\tc.name === \"definition.enum\" ||\n\t\t\t\tc.name === \"definition.trait\" ||\n\t\t\t\tc.name === \"definition.impl\" ||\n\t\t\t\tc.name === \"definition.impl_trait\",\n\t\t)\n\t\t.map((c) => ({\n\t\t\tnode: c.node,\n\t\t\tstart: c.node.startIndex,\n\t\t\tend: c.node.endIndex,\n\t\t\tname: c.name,\n\t\t\tnameCap: findNameCaptureForContainer(c, captures, sourceCode),\n\t\t}))\n\t\t.filter((c) => c.nameCap) // \u53EA\u4FDD\u7559\u6709\u540D\u79F0\u7684containers\n\n\t// \u5904\u7406 use declarations (imports)\n\tif (snippetTypes.includes(SnippetType.ImportOrInclude)) {\n\t\tcaptures.forEach((capture) => {\n\t\t\tif (capture.name === \"definition.use_declaration\") {\n\t\t\t\tconst node = capture.node\n\t\t\t\tconst startLine = node.startPosition.row + 1\n\t\t\t\tconst endLine = node.endPosition.row + 1\n\t\t\t\tconst rangeText = sourceCode.substring(node.startIndex, node.endIndex)\n\t\t\t\tconst snippetHash = generateSnippetHash(filePath, startLine, endLine, rangeText)\n\n\t\t\t\tif (seenHashes.has(snippetHash)) return\n\t\t\t\tseenHashes.add(snippetHash)\n\n\t\t\t\t// \u4ECE use \u8BED\u53E5\u4E2D\u63D0\u53D6\u5BFC\u5165\u7684\u540D\u79F0\n\t\t\t\tconst name = extractUseStatementName(rangeText)\n\t\t\t\tconst scope = buildScopeChain(node)\n\n\t\t\t\tsnippets.push({\n\t\t\t\t\tname,\n\t\t\t\t\ttype: SnippetType.ImportOrInclude,\n\t\t\t\t\tfilePath,\n\t\t\t\t\tstartLine,\n\t\t\t\t\tendLine,\n\t\t\t\t\trangeText,\n\t\t\t\t\tdefinitionText: rangeText,\n\t\t\t\t\tscope,\n\t\t\t\t\tfileHash,\n\t\t\t\t})\n\t\t\t}\n\t\t})\n\t}\n\n\t// \u5904\u7406 functions \u548C methods\n\tif (snippetTypes.includes(SnippetType.FunctionOrMethod)) {\n\t\tfor (const capture of captures) {\n\t\t\tif (capture.name !== \"definition.function\") continue\n\t\t\tconst node = capture.node\n\t\t\tconst startLine = node.startPosition.row + 1\n\t\t\tconst endLine = node.endPosition.row + 1\n\n\t\t\t// \u67E5\u627E\u51FD\u6570\u540D\n\t\t\tconst nameCap = captures.find(\n\t\t\t\t(c) =>\n\t\t\t\t\tc.name === \"name.definition.function\" &&\n\t\t\t\t\tc.node.startIndex >= node.startIndex &&\n\t\t\t\t\tc.node.endIndex <= node.endIndex,\n\t\t\t)\n\t\t\tif (!nameCap) continue\n\t\t\tconst name = sourceCode.substring(nameCap.node.startIndex, nameCap.node.endIndex)\n\n\t\t\t// \u67E5\u627E\u53C2\u6570\n\t\t\tconst paramCap = captures.find(\n\t\t\t\t(c) =>\n\t\t\t\t\tc.name === \"parameters.definition.function\" &&\n\t\t\t\t\tc.node.startIndex >= node.startIndex &&\n\t\t\t\t\tc.node.endIndex <= node.endIndex,\n\t\t\t)\n\n\t\t\tconst parameters: ParameterInfo[] = []\n\t\t\tif (paramCap) {\n\t\t\t\tconst paramText = sourceCode.substring(paramCap.node.startIndex, paramCap.node.endIndex)\n\t\t\t\tconst cleanParams = removeParentheses(paramText).trim()\n\t\t\t\tif (cleanParams) {\n\t\t\t\t\tconst paramList = parseRustParameters(cleanParams)\n\t\t\t\t\tparameters.push(...paramList.map((param) => ({ name: param })))\n\t\t\t\t}\n\t\t\t}\n\n\t\t\t// \u67E5\u627E\u51FD\u6570\u4F53\n\t\t\tconst bodyCap = captures.find(\n\t\t\t\t(c) =>\n\t\t\t\t\tc.name === \"body.definition.function\" &&\n\t\t\t\t\tc.node.startIndex >= node.startIndex &&\n\t\t\t\t\tc.node.endIndex <= node.endIndex,\n\t\t\t)\n\n\t\t\t// \u751F\u6210\u51FD\u6570\u7B7E\u540D\n\t\t\tlet definitionText: string\n\t\t\tlet implementText: string | undefined = undefined\n\n\t\t\tif (bodyCap) {\n\t\t\t\t// \u4ECE\u51FD\u6570\u5F00\u59CB\u5230\u51FD\u6570\u4F53\u5F00\u59CB\uFF08\u4E0D\u5305\u62EC\u51FD\u6570\u4F53\uFF09\n\t\t\t\tconst functionHeader = sourceCode.substring(node.startIndex, bodyCap.node.startIndex).trimEnd()\n\t\t\t\tdefinitionText = functionHeader.endsWith(\"{\") ? functionHeader.slice(0, -1).trim() : functionHeader\n\t\t\t\timplementText = sourceCode.substring(node.startIndex, node.endIndex)\n\t\t\t} else {\n\t\t\t\t// \u5982\u679C\u6CA1\u6709\u51FD\u6570\u4F53\uFF0C\u4F7F\u7528\u6574\u4E2A\u8282\u70B9\u5185\u5BB9\n\t\t\t\tdefinitionText = sourceCode.substring(node.startIndex, node.endIndex)\n\t\t\t}\n\n\t\t\tconst rangeText = sourceCode.substring(node.startIndex, node.endIndex)\n\n\t\t\t// \u786E\u5B9A\u662F\u5426\u5C5E\u4E8E\u67D0\u4E2A\u5BB9\u5668\uFF08\u8BBE\u7F6Efield\uFF09\n\t\t\tlet field: string | undefined = undefined\n\t\t\t// \u4F18\u5148\u5339\u914D impl_trait\uFF0C\u7136\u540E\u624D\u662F\u5176\u4ED6\u5BB9\u5668\n\t\t\tconst sortedContainers = containerCaptures.sort((a, b) => {\n\t\t\t\tif (a.name === \"definition.impl_trait\" && b.name !== \"definition.impl_trait\") return -1\n\t\t\t\tif (a.name !== \"definition.impl_trait\" && b.name === \"definition.impl_trait\") return 1\n\t\t\t\treturn 0\n\t\t\t})\n\t\t\tfor (const container of sortedContainers) {\n\t\t\t\tif (node.startIndex > container.start && node.endIndex <= container.end && container.nameCap) {\n\t\t\t\t\tfield = container.nameCap\n\t\t\t\t\tbreak\n\t\t\t\t}\n\t\t\t}\n\n\t\t\tconst snippetHash = generateSnippetHash(filePath, startLine, endLine, rangeText)\n\t\t\tif (seenHashes.has(snippetHash)) continue\n\t\t\tseenHashes.add(snippetHash)\n\n\t\t\tconst scope = buildScopeChain(node)\n\t\t\tsnippets.push({\n\t\t\t\tname,\n\t\t\t\ttype: SnippetType.FunctionOrMethod,\n\t\t\t\tfilePath,\n\t\t\t\tstartLine,\n\t\t\t\tendLine,\n\t\t\t\trangeText,\n\t\t\t\tdefinitionText,\n\t\t\t\timplementText,\n\t\t\t\tparameters,\n\t\t\t\tfield,\n\t\t\t\tscope,\n\t\t\t\tfileHash,\n\t\t\t})\n\t\t}\n\n\t\t// \u5904\u7406 methods (\u5728 impl \u5757\u4E2D\u7684\u51FD\u6570)\n\t\tfor (const capture of captures) {\n\t\t\tif (capture.name !== \"name.definition.method\") continue\n\t\t\tconst methodNode = capture.node\n\t\t\tconst name = sourceCode.substring(methodNode.startIndex, methodNode.endIndex)\n\n\t\t\t// \u627E\u5230\u5305\u542B\u8FD9\u4E2A method \u7684 impl \u5757\n\t\t\tconst implCapture = captures.find(\n\t\t\t\t(c) =>\n\t\t\t\t\t(c.name === \"definition.impl\" || c.name === \"definition.impl_trait\") &&\n\t\t\t\t\tc.node.startIndex <= methodNode.startIndex &&\n\t\t\t\t\tc.node.endIndex >= methodNode.endIndex,\n\t\t\t)\n\n\t\t\tif (!implCapture) continue\n\n\t\t\t// \u627E\u5230\u5BF9\u5E94\u7684\u51FD\u6570\u8282\u70B9\n\t\t\tconst functionNode = findParentFunctionNode(methodNode, sourceCode)\n\t\t\tif (!functionNode) continue\n\n\t\t\tconst startLine = functionNode.startPosition.row + 1\n\t\t\tconst endLine = functionNode.endPosition.row + 1\n\n\t\t\t// \u67E5\u627E\u53C2\u6570\n\t\t\tconst paramCap = captures.find(\n\t\t\t\t(c) =>\n\t\t\t\t\tc.name === \"parameters.definition.method\" &&\n\t\t\t\t\tc.node.startIndex >= functionNode.startIndex &&\n\t\t\t\t\tc.node.endIndex <= functionNode.endIndex,\n\t\t\t)\n\n\t\t\tconst parameters: ParameterInfo[] = []\n\t\t\tif (paramCap) {\n\t\t\t\tconst paramText = sourceCode.substring(paramCap.node.startIndex, paramCap.node.endIndex)\n\t\t\t\tconst cleanParams = removeParentheses(paramText).trim()\n\t\t\t\tif (cleanParams) {\n\t\t\t\t\tconst paramList = parseRustParameters(cleanParams)\n\t\t\t\t\tparameters.push(...paramList.map((param) => ({ name: param })))\n\t\t\t\t}\n\t\t\t}\n\n\t\t\t// \u67E5\u627E\u65B9\u6CD5\u4F53\n\t\t\tconst bodyCap = captures.find(\n\t\t\t\t(c) =>\n\t\t\t\t\tc.name === \"body.definition.method\" &&\n\t\t\t\t\tc.node.startIndex >= functionNode.startIndex &&\n\t\t\t\t\tc.node.endIndex <= functionNode.endIndex,\n\t\t\t)\n\n\t\t\t// \u751F\u6210\u65B9\u6CD5\u7B7E\u540D\n\t\t\tlet definitionText: string\n\t\t\tlet implementText: string | undefined = undefined\n\n\t\t\tif (bodyCap) {\n\t\t\t\tconst methodHeader = sourceCode.substring(functionNode.startIndex, bodyCap.node.startIndex).trimEnd()\n\t\t\t\tdefinitionText = methodHeader.endsWith(\"{\") ? methodHeader.slice(0, -1).trim() : methodHeader\n\t\t\t\timplementText = sourceCode.substring(functionNode.startIndex, functionNode.endIndex)\n\t\t\t} else {\n\t\t\t\tdefinitionText = sourceCode.substring(functionNode.startIndex, functionNode.endIndex)\n\t\t\t}\n\n\t\t\tconst rangeText = sourceCode.substring(functionNode.startIndex, functionNode.endIndex)\n\n\t\t\t// \u786E\u5B9A\u6240\u5C5E\u7684\u7ED3\u6784\u4F53/\u7279\u5F81\n\t\t\tlet field: string | undefined = undefined\n\t\t\t// \u4F18\u5148\u5339\u914D impl_trait\uFF0C\u7136\u540E\u624D\u662F\u5176\u4ED6\u5BB9\u5668\n\t\t\tconst sortedContainers = containerCaptures.sort((a, b) => {\n\t\t\t\tif (a.name === \"definition.impl_trait\" && b.name !== \"definition.impl_trait\") return -1\n\t\t\t\tif (a.name !== \"definition.impl_trait\" && b.name === \"definition.impl_trait\") return 1\n\t\t\t\treturn 0\n\t\t\t})\n\t\t\tfor (const container of sortedContainers) {\n\t\t\t\tif (\n\t\t\t\t\tfunctionNode.startIndex > container.start &&\n\t\t\t\t\tfunctionNode.endIndex <= container.end &&\n\t\t\t\t\tcontainer.nameCap\n\t\t\t\t) {\n\t\t\t\t\tfield = container.nameCap\n\t\t\t\t\tbreak\n\t\t\t\t}\n\t\t\t}\n\n\t\t\tconst snippetHash = generateSnippetHash(filePath, startLine, endLine, rangeText)\n\t\t\tif (seenHashes.has(snippetHash)) continue\n\t\t\tseenHashes.add(snippetHash)\n\n\t\t\tconst scope = buildScopeChain(functionNode)\n\t\t\tsnippets.push({\n\t\t\t\tname,\n\t\t\t\ttype: SnippetType.FunctionOrMethod,\n\t\t\t\tfilePath,\n\t\t\t\tstartLine,\n\t\t\t\tendLine,\n\t\t\t\trangeText,\n\t\t\t\tdefinitionText,\n\t\t\t\timplementText,\n\t\t\t\tparameters,\n\t\t\t\tfield,\n\t\t\t\tscope,\n\t\t\t\tfileHash,\n\t\t\t})\n\t\t}\n\t}\n\n\t// \u5904\u7406 structs, enums, traits, impls\n\tif (snippetTypes.includes(SnippetType.ClassOrInterfaceOrStructOrEnum)) {\n\t\tconst structureTypes = [\n\t\t\t\"definition.struct\",\n\t\t\t\"definition.enum\",\n\t\t\t\"definition.trait\",\n\t\t\t\"definition.impl\",\n\t\t\t\"definition.impl_trait\",\n\t\t]\n\n\t\t// \u5904\u7406 structs, enums, traits, impls - \u907F\u514D\u91CD\u590D\u5904\u7406\n\t\tconst processedNodes = new Set()\n\n\t\tfor (const capture of captures) {\n\t\t\tif (!structureTypes.includes(capture.name)) continue\n\t\t\tconst node = capture.node\n\t\t\tconst startLine = node.startPosition.row + 1\n\t\t\tconst endLine = node.endPosition.row + 1\n\n\t\t\t// \u907F\u514D\u91CD\u590D\u5904\u7406\u540C\u4E00\u4E2A\u8282\u70B9\n\t\t\tconst nodeKey = `${node.startIndex}:${node.endIndex}`\n\t\t\tif (processedNodes.has(nodeKey)) continue\n\n\t\t\t// \u5BF9\u4E8Eimpl\u5757\uFF0C\u4F18\u5148\u5904\u7406impl_trait\u800C\u4E0D\u662Fimpl\n\t\t\tif (capture.name === \"definition.impl\") {\n\t\t\t\tconst hasImplTrait = captures.some(\n\t\t\t\t\t(c) =>\n\t\t\t\t\t\tc.name === \"definition.impl_trait\" &&\n\t\t\t\t\t\tc.node.startIndex === node.startIndex &&\n\t\t\t\t\t\tc.node.endIndex === node.endIndex,\n\t\t\t\t)\n\t\t\t\tif (hasImplTrait) continue // \u8DF3\u8FC7\uFF0C\u8BA9impl_trait\u5904\u7406\n\t\t\t}\n\n\t\t\tprocessedNodes.add(nodeKey)\n\n\t\t\tlet nameCap: Parser.QueryCapture | undefined\n\t\t\tlet name: string = \"\"\n\n\t\t\t// \u6839\u636E\u4E0D\u540C\u7C7B\u578B\u67E5\u627E\u540D\u79F0\n\t\t\tswitch (capture.name) {\n\t\t\t\tcase \"definition.struct\":\n\t\t\t\t\tnameCap = captures.find(\n\t\t\t\t\t\t(c) =>\n\t\t\t\t\t\t\tc.name === \"name.definition.struct\" &&\n\t\t\t\t\t\t\tc.node.startIndex >= node.startIndex &&\n\t\t\t\t\t\t\tc.node.endIndex <= node.endIndex,\n\t\t\t\t\t)\n\t\t\t\t\tif (nameCap) {\n\t\t\t\t\t\tname = sourceCode.substring(nameCap.node.startIndex, nameCap.node.endIndex)\n\t\t\t\t\t}\n\t\t\t\t\tbreak\n\t\t\t\tcase \"definition.enum\":\n\t\t\t\t\tnameCap = captures.find(\n\t\t\t\t\t\t(c) =>\n\t\t\t\t\t\t\tc.name === \"name.definition.enum\" &&\n\t\t\t\t\t\t\tc.node.startIndex >= node.startIndex &&\n\t\t\t\t\t\t\tc.node.endIndex <= node.endIndex,\n\t\t\t\t\t)\n\t\t\t\t\tif (nameCap) {\n\t\t\t\t\t\tname = sourceCode.substring(nameCap.node.startIndex, nameCap.node.endIndex)\n\t\t\t\t\t}\n\t\t\t\t\tbreak\n\t\t\t\tcase \"definition.trait\":\n\t\t\t\t\tnameCap = captures.find(\n\t\t\t\t\t\t(c) =>\n\t\t\t\t\t\t\tc.name === \"name.definition.trait\" &&\n\t\t\t\t\t\t\tc.node.startIndex >= node.startIndex &&\n\t\t\t\t\t\t\tc.node.endIndex <= node.endIndex,\n\t\t\t\t\t)\n\t\t\t\t\tif (nameCap) {\n\t\t\t\t\t\tname = sourceCode.substring(nameCap.node.startIndex, nameCap.node.endIndex)\n\t\t\t\t\t}\n\t\t\t\t\tbreak\n\t\t\t\tcase \"definition.impl\":\n\t\t\t\t\tnameCap = captures.find(\n\t\t\t\t\t\t(c) =>\n\t\t\t\t\t\t\tc.name === \"name.definition.impl\" &&\n\t\t\t\t\t\t\tc.node.startIndex >= node.startIndex &&\n\t\t\t\t\t\t\tc.node.endIndex <= node.endIndex,\n\t\t\t\t\t)\n\t\t\t\t\tif (nameCap) {\n\t\t\t\t\t\tname = sourceCode.substring(nameCap.node.startIndex, nameCap.node.endIndex)\n\t\t\t\t\t}\n\t\t\t\t\tbreak\n\t\t\t\tcase \"definition.impl_trait\":\n\t\t\t\t\tconst traitCap = captures.find(\n\t\t\t\t\t\t(c) =>\n\t\t\t\t\t\t\tc.name === \"name.definition.impl_trait\" &&\n\t\t\t\t\t\t\tc.node.startIndex >= node.startIndex &&\n\t\t\t\t\t\t\tc.node.endIndex <= node.endIndex,\n\t\t\t\t\t)\n\t\t\t\t\tconst forCap = captures.find(\n\t\t\t\t\t\t(c) =>\n\t\t\t\t\t\t\tc.name === \"name.definition.impl_for\" &&\n\t\t\t\t\t\t\tc.node.startIndex >= node.startIndex &&\n\t\t\t\t\t\t\tc.node.endIndex <= node.endIndex,\n\t\t\t\t\t)\n\t\t\t\t\tif (traitCap && forCap) {\n\t\t\t\t\t\tconst traitName = sourceCode.substring(traitCap.node.startIndex, traitCap.node.endIndex)\n\t\t\t\t\t\tconst forName = sourceCode.substring(forCap.node.startIndex, forCap.node.endIndex)\n\t\t\t\t\t\tname = `${traitName} for ${forName}`\n\t\t\t\t\t}\n\t\t\t\t\tbreak\n\t\t\t}\n\n\t\t\tif (!name) continue\n\n\t\t\tconst rangeText = sourceCode.substring(node.startIndex, node.endIndex)\n\t\t\tconst snippetHash = generateSnippetHash(filePath, startLine, endLine, rangeText)\n\n\t\t\tif (seenHashes.has(snippetHash)) continue\n\t\t\tseenHashes.add(snippetHash)\n\n\t\t\tconst scope = buildScopeChain(node)\n\t\t\tsnippets.push({\n\t\t\t\tname,\n\t\t\t\ttype: SnippetType.ClassOrInterfaceOrStructOrEnum,\n\t\t\t\tfilePath,\n\t\t\t\tstartLine,\n\t\t\t\tendLine,\n\t\t\t\trangeText,\n\t\t\t\tdefinitionText: rangeText,\n\t\t\t\tscope,\n\t\t\t\tfileHash,\n\t\t\t})\n\t\t}\n\t}\n\n\t// \u5904\u7406 variables, constants, statics\n\tif (snippetTypes.includes(SnippetType.VariableOrConstant)) {\n\t\tconst variableTypes = [\n\t\t\t{ captureName: \"definition.variable\", nameCapture: \"name.definition.variable\" },\n\t\t\t{ captureName: \"definition.constant\", nameCapture: \"name.definition.constant\" },\n\t\t\t{ captureName: \"definition.static\", nameCapture: \"name.definition.static\" },\n\t\t]\n\n\t\tfor (const { captureName, nameCapture } of variableTypes) {\n\t\t\tfor (const capture of captures) {\n\t\t\t\tif (capture.name !== captureName) continue\n\t\t\t\tconst node = capture.node\n\t\t\t\tconst startLine = node.startPosition.row + 1\n\t\t\t\tconst endLine = node.endPosition.row + 1\n\n\t\t\t\tconst nameCap = captures.find(\n\t\t\t\t\t(c) =>\n\t\t\t\t\t\tc.name === nameCapture &&\n\t\t\t\t\t\tc.node.startIndex >= node.startIndex &&\n\t\t\t\t\t\tc.node.endIndex <= node.endIndex,\n\t\t\t\t)\n\t\t\t\tif (!nameCap) continue\n\t\t\t\tconst name = sourceCode.substring(nameCap.node.startIndex, nameCap.node.endIndex)\n\n\t\t\t\tconst rangeText = sourceCode.substring(node.startIndex, node.endIndex)\n\t\t\t\tconst snippetHash = generateSnippetHash(filePath, startLine, endLine, rangeText)\n\n\t\t\t\tif (seenHashes.has(snippetHash)) continue\n\t\t\t\tseenHashes.add(snippetHash)\n\n\t\t\t\t// \u786E\u5B9A\u662F\u5426\u5C5E\u4E8E\u67D0\u4E2A\u5BB9\u5668\n\t\t\t\tlet field: string | undefined = undefined\n\t\t\t\tfor (const container of containerCaptures) {\n\t\t\t\t\tif (node.startIndex > container.start && node.endIndex <= container.end && container.nameCap) {\n\t\t\t\t\t\tfield = container.nameCap\n\t\t\t\t\t\tbreak\n\t\t\t\t\t}\n\t\t\t\t}\n\n\t\t\t\tconst scope = buildScopeChain(node)\n\t\t\t\tsnippets.push({\n\t\t\t\t\tname,\n\t\t\t\t\ttype: SnippetType.VariableOrConstant,\n\t\t\t\t\tfilePath,\n\t\t\t\t\tstartLine,\n\t\t\t\t\tendLine,\n\t\t\t\t\trangeText,\n\t\t\t\t\tdefinitionText: rangeText,\n\t\t\t\t\tfield,\n\t\t\t\t\tscope,\n\t\t\t\t\tfileHash,\n\t\t\t\t})\n\t\t\t}\n\t\t}\n\t}\n\n\treturn snippets\n}\n\n// \u8F85\u52A9\u51FD\u6570\uFF1A\u89E3\u6790 Rust \u53C2\u6570\nfunction parseRustParameters(paramText: string): string[] {\n\tconst params: string[] = []\n\tlet current = \"\"\n\tlet depth = 0\n\tlet inString = false\n\tlet escapeNext = false\n\n\tfor (let i = 0; i < paramText.length; i++) {\n\t\tconst char = paramText[i]\n\n\t\tif (escapeNext) {\n\t\t\tcurrent += char\n\t\t\tescapeNext = false\n\t\t\tcontinue\n\t\t}\n\n\t\tif (char === \"\\\\\") {\n\t\t\tescapeNext = true\n\t\t\tcurrent += char\n\t\t\tcontinue\n\t\t}\n\n\t\tif (char === '\"' || char === \"'\") {\n\t\t\tinString = !inString\n\t\t\tcurrent += char\n\t\t\tcontinue\n\t\t}\n\n\t\tif (inString) {\n\t\t\tcurrent += char\n\t\t\tcontinue\n\t\t}\n\n\t\tif (char === \"<\" || char === \"(\" || char === \"[\" || char === \"{\") {\n\t\t\tdepth++\n\t\t} else if (char === \">\" || char === \")\" || char === \"]\" || char === \"}\") {\n\t\t\tdepth--\n\t\t}\n\n\t\tif (char === \",\" && depth === 0) {\n\t\t\tconst param = current.trim()\n\t\t\tif (param) {\n\t\t\t\t// \u63D0\u53D6\u53C2\u6570\u540D\uFF08\u5728 : \u4E4B\u524D\u7684\u90E8\u5206\uFF09\n\t\t\t\tconst colonIndex = param.indexOf(\":\")\n\t\t\t\tconst paramName = colonIndex > -1 ? param.substring(0, colonIndex).trim() : param\n\t\t\t\t// \u5904\u7406 self, &self, &mut self\n\t\t\t\tif (paramName === \"self\" || paramName === \"&self\" || paramName === \"&mut self\") {\n\t\t\t\t\tparams.push(paramName)\n\t\t\t\t} else {\n\t\t\t\t\tparams.push(paramName)\n\t\t\t\t}\n\t\t\t}\n\t\t\tcurrent = \"\"\n\t\t} else {\n\t\t\tcurrent += char\n\t\t}\n\t}\n\n\t// \u5904\u7406\u6700\u540E\u4E00\u4E2A\u53C2\u6570\n\tconst param = current.trim()\n\tif (param) {\n\t\tconst colonIndex = param.indexOf(\":\")\n\t\tconst paramName = colonIndex > -1 ? param.substring(0, colonIndex).trim() : param\n\t\tif (paramName === \"self\" || paramName === \"&self\" || paramName === \"&mut self\") {\n\t\t\tparams.push(paramName)\n\t\t} else {\n\t\t\tparams.push(paramName)\n\t\t}\n\t}\n\n\treturn params\n}\n\n// \u8F85\u52A9\u51FD\u6570\uFF1A\u4ECE use \u8BED\u53E5\u4E2D\u63D0\u53D6\u540D\u79F0\nfunction extractUseStatementName(useStatement: string): string {\n\t// \u79FB\u9664 use \u5173\u952E\u5B57\u548C\u5206\u53F7\n\tlet cleaned = removeUseKeywordAndSemicolon(useStatement).trim()\n\n\t// \u5904\u7406 as \u91CD\u547D\u540D\n\tconst asIndex = cleaned.lastIndexOf(\" as \")\n\tif (asIndex > -1) {\n\t\treturn cleaned.substring(asIndex + 4).trim()\n\t}\n\n\t// \u5904\u7406\u82B1\u62EC\u53F7\u5BFC\u5165 {a, b, c}\n\tif (cleaned.includes(\"{\") && cleaned.includes(\"}\")) {\n\t\tconst braceContent = extractBraceContent(cleaned)\n\t\tif (braceContent) {\n\t\t\tconst items = braceContent.split(\",\").map((s: string) => s.trim())\n\t\t\treturn items.join(\", \")\n\t\t}\n\t}\n\n\t// \u5904\u7406\u8DEF\u5F84\u5BFC\u5165\uFF0C\u53D6\u6700\u540E\u4E00\u4E2A\u90E8\u5206\n\tconst parts = cleaned.split(\"::\")\n\treturn parts[parts.length - 1].trim()\n}\n\n// \u8F85\u52A9\u51FD\u6570\uFF1A\u4E3A\u5BB9\u5668\u67E5\u627E\u540D\u79F0capture\nfunction findNameCaptureForContainer(\n\tcontainer: Parser.QueryCapture,\n\tcaptures: Parser.QueryCapture[],\n\tsourceCode: string,\n): string | undefined {\n\tlet nameCaptureName: string\n\n\tswitch (container.name) {\n\t\tcase \"definition.struct\":\n\t\t\tnameCaptureName = \"name.definition.struct\"\n\t\t\tbreak\n\t\tcase \"definition.enum\":\n\t\t\tnameCaptureName = \"name.definition.enum\"\n\t\t\tbreak\n\t\tcase \"definition.trait\":\n\t\t\tnameCaptureName = \"name.definition.trait\"\n\t\t\tbreak\n\t\tcase \"definition.impl\":\n\t\t\tnameCaptureName = \"name.definition.impl\"\n\t\t\tbreak\n\t\tcase \"definition.impl_trait\":\n\t\t\tconst traitCap = captures.find(\n\t\t\t\t(c) =>\n\t\t\t\t\tc.name === \"name.definition.impl_trait\" &&\n\t\t\t\t\tc.node.startIndex >= container.node.startIndex &&\n\t\t\t\t\tc.node.endIndex <= container.node.endIndex,\n\t\t\t)\n\t\t\tconst forCap = captures.find(\n\t\t\t\t(c) =>\n\t\t\t\t\tc.name === \"name.definition.impl_for\" &&\n\t\t\t\t\tc.node.startIndex >= container.node.startIndex &&\n\t\t\t\t\tc.node.endIndex <= container.node.endIndex,\n\t\t\t)\n\t\t\tif (traitCap && forCap) {\n\t\t\t\tconst traitName = sourceCode.substring(traitCap.node.startIndex, traitCap.node.endIndex)\n\t\t\t\tconst forName = sourceCode.substring(forCap.node.startIndex, forCap.node.endIndex)\n\t\t\t\treturn `${traitName} for ${forName}`\n\t\t\t}\n\t\t\treturn undefined\n\t\tdefault:\n\t\t\treturn undefined\n\t}\n\n\tconst nameCap = captures.find(\n\t\t(c) =>\n\t\t\tc.name === nameCaptureName &&\n\t\t\tc.node.startIndex >= container.node.startIndex &&\n\t\t\tc.node.endIndex <= container.node.endIndex,\n\t)\n\n\treturn nameCap ? sourceCode.substring(nameCap.node.startIndex, nameCap.node.endIndex) : undefined\n}\n\n// \u8F85\u52A9\u51FD\u6570\uFF1A\u67E5\u627E\u7236\u51FD\u6570\u8282\u70B9\nfunction findParentFunctionNode(methodNameNode: Parser.SyntaxNode, sourceCode: string): Parser.SyntaxNode | undefined {\n\tlet current = methodNameNode.parent\n\twhile (current) {\n\t\tif (current.type === \"function_item\") {\n\t\t\treturn current\n\t\t}\n\t\tcurrent = current.parent\n\t}\n\treturn undefined\n}\n\n// \u8F85\u52A9\u51FD\u6570\uFF1A\u79FB\u9664\u5706\u62EC\u53F7\nfunction removeParentheses(text: string): string {\n\tif (text.startsWith(\"(\") && text.endsWith(\")\")) {\n\t\treturn text.slice(1, -1)\n\t}\n\treturn text\n}\n\n// \u8F85\u52A9\u51FD\u6570\uFF1A\u79FB\u9664use\u5173\u952E\u5B57\u548C\u5206\u53F7\nfunction removeUseKeywordAndSemicolon(useStatement: string): string {\n\tlet result = useStatement.trim()\n\n\t// \u79FB\u9664\u5F00\u5934\u7684 \"use\" \u5173\u952E\u5B57\n\tif (result.startsWith(\"use \")) {\n\t\tresult = result.substring(4)\n\t}\n\n\t// \u79FB\u9664\u7ED3\u5C3E\u7684\u5206\u53F7\n\tif (result.endsWith(\";\")) {\n\t\tresult = result.slice(0, -1)\n\t}\n\n\treturn result\n}\n\n// \u8F85\u52A9\u51FD\u6570\uFF1A\u63D0\u53D6\u82B1\u62EC\u53F7\u5185\u5BB9\nfunction extractBraceContent(text: string): string | null {\n\tconst startIndex = text.indexOf(\"{\")\n\tconst endIndex = text.lastIndexOf(\"}\")\n\n\tif (startIndex > -1 && endIndex > startIndex) {\n\t\treturn text.substring(startIndex + 1, endIndex)\n\t}\n\n\treturn null\n}\n\n// \u6784\u5EFA\u6458\u8981\u4FE1\u606F\nexport interface RustSummary {\n\tfunctions: Array<{ name: string; parameters: string[]; field?: string }>\n\tstructs: Array<{ name: string }>\n\tenums: Array<{ name: string }>\n\ttraits: Array<{ name: string }>\n\timpls: Array<{ name: string }>\n\tconstants: Array<{ name: string; field?: string }>\n\tvariables: Array<{ name: string; field?: string }>\n\timports: Array<{ name: string }>\n}\n\nexport function buildSummaryFromSnippets(snippets: ISnippetMeta[]): RustSummary {\n\tconst summary: RustSummary = {\n\t\tfunctions: [],\n\t\tstructs: [],\n\t\tenums: [],\n\t\ttraits: [],\n\t\timpls: [],\n\t\tconstants: [],\n\t\tvariables: [],\n\t\timports: [],\n\t}\n\n\tfor (const snippet of snippets) {\n\t\tswitch (snippet.type) {\n\t\t\tcase SnippetType.FunctionOrMethod:\n\t\t\t\tsummary.functions.push({\n\t\t\t\t\tname: snippet.name,\n\t\t\t\t\tparameters: snippet.parameters?.map((p) => p.name) || [],\n\t\t\t\t\tfield: snippet.field,\n\t\t\t\t})\n\t\t\t\tbreak\n\t\t\tcase SnippetType.ClassOrInterfaceOrStructOrEnum:\n\t\t\t\t// \u6839\u636E\u5B9A\u4E49\u6587\u672C\u5224\u65AD\u662F\u4EC0\u4E48\u7C7B\u578B\u7684\u7ED3\u6784\n\t\t\t\tconst defText = snippet.definitionText || \"\"\n\t\t\t\tif (defText.startsWith(\"struct \")) {\n\t\t\t\t\tsummary.structs.push({ name: snippet.name })\n\t\t\t\t} else if (defText.startsWith(\"enum \")) {\n\t\t\t\t\tsummary.enums.push({ name: snippet.name })\n\t\t\t\t} else if (defText.startsWith(\"trait \")) {\n\t\t\t\t\tsummary.traits.push({ name: snippet.name })\n\t\t\t\t} else if (defText.startsWith(\"impl \")) {\n\t\t\t\t\tsummary.impls.push({ name: snippet.name })\n\t\t\t\t}\n\t\t\t\tbreak\n\t\t\tcase SnippetType.VariableOrConstant:\n\t\t\t\tconst varDefText = snippet.definitionText || \"\"\n\t\t\t\tif (varDefText.startsWith(\"const \") || varDefText.startsWith(\"static \")) {\n\t\t\t\t\tsummary.constants.push({\n\t\t\t\t\t\tname: snippet.name,\n\t\t\t\t\t\tfield: snippet.field,\n\t\t\t\t\t})\n\t\t\t\t} else {\n\t\t\t\t\tsummary.variables.push({\n\t\t\t\t\t\tname: snippet.name,\n\t\t\t\t\t\tfield: snippet.field,\n\t\t\t\t\t})\n\t\t\t\t}\n\t\t\t\tbreak\n\t\t\tcase SnippetType.ImportOrInclude:\n\t\t\t\tsummary.imports.push({ name: snippet.name })\n\t\t\t\tbreak\n\t\t}\n\t}\n\n\treturn summary\n}\n\nexport function formatOutlineText(summary: RustSummary): string {\n\tlet outlineText = \"\"\n\n\tif (summary.imports.length > 0) {\n\t\toutlineText += \"Imports:\\n\"\n\t\tfor (const imp of summary.imports) {\n\t\t\toutlineText += ` - ${imp.name}\\n`\n\t\t}\n\t\toutlineText += \"\\n\"\n\t}\n\n\tif (summary.structs.length > 0) {\n\t\toutlineText += \"Structs:\\n\"\n\t\tfor (const struct of summary.structs) {\n\t\t\toutlineText += ` - ${struct.name}\\n`\n\t\t}\n\t\toutlineText += \"\\n\"\n\t}\n\n\tif (summary.enums.length > 0) {\n\t\toutlineText += \"Enums:\\n\"\n\t\tfor (const enumItem of summary.enums) {\n\t\t\toutlineText += ` - ${enumItem.name}\\n`\n\t\t}\n\t\toutlineText += \"\\n\"\n\t}\n\n\tif (summary.traits.length > 0) {\n\t\toutlineText += \"Traits:\\n\"\n\t\tfor (const trait of summary.traits) {\n\t\t\toutlineText += ` - ${trait.name}\\n`\n\t\t}\n\t\toutlineText += \"\\n\"\n\t}\n\n\tif (summary.impls.length > 0) {\n\t\toutlineText += \"Implementations:\\n\"\n\t\tfor (const impl of summary.impls) {\n\t\t\toutlineText += ` - ${impl.name}\\n`\n\t\t}\n\t\toutlineText += \"\\n\"\n\t}\n\n\tif (summary.functions.length > 0) {\n\t\toutlineText += \"Functions/Methods:\\n\"\n\t\tfor (const func of summary.functions) {\n\t\t\tconst paramStr = func.parameters.length > 0 ? `(${func.parameters.join(\", \")})` : \"()\"\n\t\t\tconst fieldStr = func.field ? ` [in ${func.field}]` : \"\"\n\t\t\toutlineText += ` - ${func.name}${paramStr}${fieldStr}\\n`\n\t\t}\n\t\toutlineText += \"\\n\"\n\t}\n\n\tif (summary.constants.length > 0) {\n\t\toutlineText += \"Constants/Statics:\\n\"\n\t\tfor (const constant of summary.constants) {\n\t\t\tconst fieldStr = constant.field ? ` [in ${constant.field}]` : \"\"\n\t\t\toutlineText += ` - ${constant.name}${fieldStr}\\n`\n\t\t}\n\t\toutlineText += \"\\n\"\n\t}\n\n\tif (summary.variables.length > 0) {\n\t\toutlineText += \"Variables:\\n\"\n\t\tfor (const variable of summary.variables) {\n\t\t\tconst fieldStr = variable.field ? ` [in ${variable.field}]` : \"\"\n\t\t\toutlineText += ` - ${variable.name}${fieldStr}\\n`\n\t\t}\n\t\toutlineText += \"\\n\"\n\t}\n\n\treturn outlineText.trim()\n}\n", "import { SnippetType, ISnippetMeta, ParameterInfo, CodeLanguageType } from \"../types\"\nimport Parser from \"web-tree-sitter\"\nimport { generateSnippetHash, buildScopeChain } from \"./general\"\nimport { Logger } from \"../Logger\"\n\nexport async function extractSnippetsFromCapturesForC(\n\tcaptures: Parser.QueryCapture[],\n\tsourceCode: string,\n\tfilePath: string,\n\tfileHash: string,\n\tsnippetTypes: SnippetType[],\n\toptions: { maxSnippetLines: number; minSnippetLines: number },\n): Promise {\n\tconst logger = Logger.getDefaultLogger().with(\"[extractSnippetsFromCapturesForC]\")\n\n\tconst snippets: ISnippetMeta[] = []\n\tconst seenHashes = new Set()\n\n\tif (snippetTypes.length === 0) {\n\t\tlogger.warn(`No snippet types provided, skipping`)\n\t\treturn snippets\n\t}\n\n\t// \u6536\u96C6\u6240\u6709 struct/union/enum captures \u7528\u4E8E\u786E\u5B9A field\n\tconst containerCaptures = captures\n\t\t.filter((c) => c.name === \"definition.struct\" || c.name === \"definition.union\" || c.name === \"definition.enum\")\n\t\t.map((c) => ({\n\t\t\tnode: c.node,\n\t\t\tstart: c.node.startIndex,\n\t\t\tend: c.node.endIndex,\n\t\t\tname: c.name,\n\t\t\tnameCap: findNameCaptureForContainer(c, captures, sourceCode),\n\t\t}))\n\t\t.filter((c) => c.nameCap) // \u53EA\u4FDD\u7559\u6709\u540D\u79F0\u7684containers\n\n\t// \u5904\u7406 include declarations (imports)\n\tif (snippetTypes.includes(SnippetType.ImportOrInclude)) {\n\t\tcaptures.forEach((capture) => {\n\t\t\tif (capture.name === \"definition.include\") {\n\t\t\t\tconst node = capture.node\n\t\t\t\tconst startLine = node.startPosition.row + 1\n\t\t\t\tconst endLine = node.endPosition.row + 1\n\t\t\t\tconst rangeText = sourceCode.substring(node.startIndex, node.endIndex)\n\t\t\t\tconst snippetHash = generateSnippetHash(filePath, startLine, endLine, rangeText)\n\n\t\t\t\tif (!seenHashes.has(snippetHash)) {\n\t\t\t\t\tseenHashes.add(snippetHash)\n\t\t\t\t\tconst scope = buildScopeChain(node)\n\n\t\t\t\t\tconst includeNameCapture = captures.find(\n\t\t\t\t\t\t(c) =>\n\t\t\t\t\t\t\tc.name === \"name.definition.include\" &&\n\t\t\t\t\t\t\tc.node.startIndex >= node.startIndex &&\n\t\t\t\t\t\t\tc.node.endIndex <= node.endIndex,\n\t\t\t\t\t)\n\t\t\t\t\tconst includeName = includeNameCapture\n\t\t\t\t\t\t? sourceCode.substring(includeNameCapture.node.startIndex, includeNameCapture.node.endIndex)\n\t\t\t\t\t\t: \"\"\n\n\t\t\t\t\tsnippets.push({\n\t\t\t\t\t\ttype: SnippetType.ImportOrInclude,\n\t\t\t\t\t\tname: includeName,\n\t\t\t\t\t\trangeText,\n\t\t\t\t\t\tstartLine,\n\t\t\t\t\t\tendLine,\n\t\t\t\t\t\tfilePath,\n\t\t\t\t\t\tfileHash,\n\t\t\t\t\t\tscope,\n\t\t\t\t\t\tlanguage: CodeLanguageType.C,\n\t\t\t\t\t})\n\t\t\t\t}\n\t\t\t}\n\t\t})\n\t}\n\n\t// \u5904\u7406 function definitions and declarations\n\tif (snippetTypes.includes(SnippetType.FunctionOrMethod)) {\n\t\tconst functionCaptures = captures.filter((c) => c.name === \"definition.function\")\n\n\t\tfunctionCaptures.forEach((capture) => {\n\t\t\tconst node = capture.node\n\t\t\tconst startLine = node.startPosition.row + 1\n\t\t\tconst endLine = node.endPosition.row + 1\n\t\t\tconst rangeText = sourceCode.substring(node.startIndex, node.endIndex)\n\t\t\tconst snippetHash = generateSnippetHash(filePath, startLine, endLine, rangeText)\n\n\t\t\tif (!seenHashes.has(snippetHash)) {\n\t\t\t\tseenHashes.add(snippetHash)\n\t\t\t\tconst scope = buildScopeChain(node)\n\n\t\t\t\tconst functionNameCapture = captures.find(\n\t\t\t\t\t(c) =>\n\t\t\t\t\t\tc.name === \"name.definition.function\" &&\n\t\t\t\t\t\tc.node.startIndex >= node.startIndex &&\n\t\t\t\t\t\tc.node.endIndex <= node.endIndex,\n\t\t\t\t)\n\t\t\t\tconst functionName = functionNameCapture\n\t\t\t\t\t? sourceCode.substring(functionNameCapture.node.startIndex, functionNameCapture.node.endIndex)\n\t\t\t\t\t: \"\"\n\n\t\t\t\tconst parametersCapture = captures.find(\n\t\t\t\t\t(c) =>\n\t\t\t\t\t\tc.name === \"parameters.definition.function\" &&\n\t\t\t\t\t\tc.node.startIndex >= node.startIndex &&\n\t\t\t\t\t\tc.node.endIndex <= node.endIndex,\n\t\t\t\t)\n\t\t\t\tconst parameters = parametersCapture\n\t\t\t\t\t? extractParametersFromNode(parametersCapture.node, sourceCode)\n\t\t\t\t\t: []\n\n\t\t\t\tconst bodyCapture = captures.find(\n\t\t\t\t\t(c) =>\n\t\t\t\t\t\tc.name === \"body.definition.function\" &&\n\t\t\t\t\t\tc.node.startIndex >= node.startIndex &&\n\t\t\t\t\t\tc.node.endIndex <= node.endIndex,\n\t\t\t\t)\n\t\t\t\tconst hasBody = !!bodyCapture\n\n\t\t\t\tsnippets.push({\n\t\t\t\t\ttype: SnippetType.FunctionOrMethod,\n\t\t\t\t\tname: functionName,\n\t\t\t\t\trangeText,\n\t\t\t\t\tstartLine,\n\t\t\t\t\tendLine,\n\t\t\t\t\tfilePath,\n\t\t\t\t\tfileHash,\n\t\t\t\t\tscope,\n\t\t\t\t\tlanguage: CodeLanguageType.C,\n\t\t\t\t\tparameters,\n\t\t\t\t\tdefinition: {\n\t\t\t\t\t\tname: functionName,\n\t\t\t\t\t\ttype: \"function\",\n\t\t\t\t\t\tparameters,\n\t\t\t\t\t},\n\t\t\t\t})\n\t\t\t}\n\t\t})\n\t}\n\n\t// \u5904\u7406 struct definitions\n\tif (snippetTypes.includes(SnippetType.ClassOrInterfaceOrStructOrEnum)) {\n\t\tconst structCaptures = captures.filter((c) => c.name === \"definition.struct\")\n\n\t\tstructCaptures.forEach((capture) => {\n\t\t\tconst node = capture.node\n\t\t\tconst startLine = node.startPosition.row + 1\n\t\t\tconst endLine = node.endPosition.row + 1\n\t\t\tconst rangeText = sourceCode.substring(node.startIndex, node.endIndex)\n\t\t\tconst snippetHash = generateSnippetHash(filePath, startLine, endLine, rangeText)\n\n\t\t\tif (!seenHashes.has(snippetHash)) {\n\t\t\t\tseenHashes.add(snippetHash)\n\t\t\t\tconst scope = buildScopeChain(node)\n\n\t\t\t\tconst structNameCapture = captures.find(\n\t\t\t\t\t(c) =>\n\t\t\t\t\t\tc.name === \"name.definition.struct\" &&\n\t\t\t\t\t\tc.node.startIndex >= node.startIndex &&\n\t\t\t\t\t\tc.node.endIndex <= node.endIndex,\n\t\t\t\t)\n\t\t\t\tconst structName = structNameCapture\n\t\t\t\t\t? sourceCode.substring(structNameCapture.node.startIndex, structNameCapture.node.endIndex)\n\t\t\t\t\t: \"\"\n\n\t\t\t\tconst fields = extractFieldsFromStructNode(node, sourceCode, captures)\n\n\t\t\t\tsnippets.push({\n\t\t\t\t\ttype: SnippetType.ClassOrInterfaceOrStructOrEnum,\n\t\t\t\t\tname: structName,\n\t\t\t\t\trangeText,\n\t\t\t\t\tstartLine,\n\t\t\t\t\tendLine,\n\t\t\t\t\tfilePath,\n\t\t\t\t\tfileHash,\n\t\t\t\t\tscope,\n\t\t\t\t\tlanguage: CodeLanguageType.C,\n\t\t\t\t\tdefinition: {\n\t\t\t\t\t\tname: structName,\n\t\t\t\t\t\ttype: \"struct\",\n\t\t\t\t\t},\n\t\t\t\t})\n\t\t\t}\n\t\t})\n\t}\n\n\t// \u5904\u7406 union definitions\n\tif (snippetTypes.includes(SnippetType.ClassOrInterfaceOrStructOrEnum)) {\n\t\tconst unionCaptures = captures.filter((c) => c.name === \"definition.union\")\n\n\t\tunionCaptures.forEach((capture) => {\n\t\t\tconst node = capture.node\n\t\t\tconst startLine = node.startPosition.row + 1\n\t\t\tconst endLine = node.endPosition.row + 1\n\t\t\tconst rangeText = sourceCode.substring(node.startIndex, node.endIndex)\n\t\t\tconst snippetHash = generateSnippetHash(filePath, startLine, endLine, rangeText)\n\n\t\t\tif (!seenHashes.has(snippetHash)) {\n\t\t\t\tseenHashes.add(snippetHash)\n\t\t\t\tconst scope = buildScopeChain(node)\n\n\t\t\t\tconst unionNameCapture = captures.find(\n\t\t\t\t\t(c) =>\n\t\t\t\t\t\tc.name === \"name.definition.union\" &&\n\t\t\t\t\t\tc.node.startIndex >= node.startIndex &&\n\t\t\t\t\t\tc.node.endIndex <= node.endIndex,\n\t\t\t\t)\n\t\t\t\tconst unionName = unionNameCapture\n\t\t\t\t\t? sourceCode.substring(unionNameCapture.node.startIndex, unionNameCapture.node.endIndex)\n\t\t\t\t\t: \"\"\n\n\t\t\t\tconst fields = extractFieldsFromStructNode(node, sourceCode, captures)\n\n\t\t\t\tsnippets.push({\n\t\t\t\t\ttype: SnippetType.ClassOrInterfaceOrStructOrEnum,\n\t\t\t\t\tname: unionName,\n\t\t\t\t\trangeText,\n\t\t\t\t\tstartLine,\n\t\t\t\t\tendLine,\n\t\t\t\t\tfilePath,\n\t\t\t\t\tfileHash,\n\t\t\t\t\tscope,\n\t\t\t\t\tlanguage: CodeLanguageType.C,\n\t\t\t\t\tdefinition: {\n\t\t\t\t\t\tname: unionName,\n\t\t\t\t\t\ttype: \"union\",\n\t\t\t\t\t},\n\t\t\t\t})\n\t\t\t}\n\t\t})\n\t}\n\n\t// \u5904\u7406 enum definitions\n\tif (snippetTypes.includes(SnippetType.ClassOrInterfaceOrStructOrEnum)) {\n\t\tconst enumCaptures = captures.filter((c) => c.name === \"definition.enum\")\n\n\t\tenumCaptures.forEach((capture) => {\n\t\t\tconst node = capture.node\n\t\t\tconst startLine = node.startPosition.row + 1\n\t\t\tconst endLine = node.endPosition.row + 1\n\t\t\tconst rangeText = sourceCode.substring(node.startIndex, node.endIndex)\n\t\t\tconst snippetHash = generateSnippetHash(filePath, startLine, endLine, rangeText)\n\n\t\t\tif (!seenHashes.has(snippetHash)) {\n\t\t\t\tseenHashes.add(snippetHash)\n\t\t\t\tconst scope = buildScopeChain(node)\n\n\t\t\t\tconst enumNameCapture = captures.find(\n\t\t\t\t\t(c) =>\n\t\t\t\t\t\tc.name === \"name.definition.enum\" &&\n\t\t\t\t\t\tc.node.startIndex >= node.startIndex &&\n\t\t\t\t\t\tc.node.endIndex <= node.endIndex,\n\t\t\t\t)\n\t\t\t\tconst enumName = enumNameCapture\n\t\t\t\t\t? sourceCode.substring(enumNameCapture.node.startIndex, enumNameCapture.node.endIndex)\n\t\t\t\t\t: \"\"\n\n\t\t\t\tconst enumerators = extractEnumeratorsFromEnumNode(node, sourceCode, captures)\n\n\t\t\t\tsnippets.push({\n\t\t\t\t\ttype: SnippetType.ClassOrInterfaceOrStructOrEnum,\n\t\t\t\t\tname: enumName,\n\t\t\t\t\trangeText,\n\t\t\t\t\tstartLine,\n\t\t\t\t\tendLine,\n\t\t\t\t\tfilePath,\n\t\t\t\t\tfileHash,\n\t\t\t\t\tscope,\n\t\t\t\t\tlanguage: CodeLanguageType.C,\n\t\t\t\t\tdefinition: {\n\t\t\t\t\t\tname: enumName,\n\t\t\t\t\t\ttype: \"enum\",\n\t\t\t\t\t},\n\t\t\t\t})\n\t\t\t}\n\t\t})\n\t}\n\n\t// \u5904\u7406 global variables\n\tif (snippetTypes.includes(SnippetType.VariableOrConstant)) {\n\t\tconst variableCaptures = captures.filter((c) => c.name === \"definition.variable\")\n\n\t\tvariableCaptures.forEach((capture) => {\n\t\t\tconst node = capture.node\n\t\t\tconst startLine = node.startPosition.row + 1\n\t\t\tconst endLine = node.endPosition.row + 1\n\t\t\tconst rangeText = sourceCode.substring(node.startIndex, node.endIndex)\n\t\t\tconst snippetHash = generateSnippetHash(filePath, startLine, endLine, rangeText)\n\n\t\t\tif (!seenHashes.has(snippetHash)) {\n\t\t\t\tseenHashes.add(snippetHash)\n\t\t\t\tconst scope = buildScopeChain(node)\n\n\t\t\t\tconst variableNameCapture = captures.find(\n\t\t\t\t\t(c) =>\n\t\t\t\t\t\tc.name === \"name.definition.variable\" &&\n\t\t\t\t\t\tc.node.startIndex >= node.startIndex &&\n\t\t\t\t\t\tc.node.endIndex <= node.endIndex,\n\t\t\t\t)\n\t\t\t\tconst variableName = variableNameCapture\n\t\t\t\t\t? sourceCode.substring(variableNameCapture.node.startIndex, variableNameCapture.node.endIndex)\n\t\t\t\t\t: \"\"\n\n\t\t\t\tsnippets.push({\n\t\t\t\t\ttype: SnippetType.VariableOrConstant,\n\t\t\t\t\tname: variableName,\n\t\t\t\t\trangeText,\n\t\t\t\t\tstartLine,\n\t\t\t\t\tendLine,\n\t\t\t\t\tfilePath,\n\t\t\t\t\tfileHash,\n\t\t\t\t\tscope,\n\t\t\t\t\tlanguage: CodeLanguageType.C,\n\t\t\t\t\tdefinition: {\n\t\t\t\t\t\tname: variableName,\n\t\t\t\t\t\ttype: \"variable\",\n\t\t\t\t\t},\n\t\t\t\t})\n\t\t\t}\n\t\t})\n\t}\n\n\t// \u5904\u7406 static variables\n\tif (snippetTypes.includes(SnippetType.VariableOrConstant)) {\n\t\tconst staticVariableCaptures = captures.filter((c) => c.name === \"definition.static_variable\")\n\n\t\tstaticVariableCaptures.forEach((capture) => {\n\t\t\tconst node = capture.node\n\t\t\tconst startLine = node.startPosition.row + 1\n\t\t\tconst endLine = node.endPosition.row + 1\n\t\t\tconst rangeText = sourceCode.substring(node.startIndex, node.endIndex)\n\t\t\tconst snippetHash = generateSnippetHash(filePath, startLine, endLine, rangeText)\n\n\t\t\tif (!seenHashes.has(snippetHash)) {\n\t\t\t\tseenHashes.add(snippetHash)\n\t\t\t\tconst scope = buildScopeChain(node)\n\n\t\t\t\tconst staticVariableNameCapture = captures.find(\n\t\t\t\t\t(c) =>\n\t\t\t\t\t\tc.name === \"name.definition.variable\" &&\n\t\t\t\t\t\tc.node.startIndex >= node.startIndex &&\n\t\t\t\t\t\tc.node.endIndex <= node.endIndex,\n\t\t\t\t)\n\t\t\t\tconst staticVariableName = staticVariableNameCapture\n\t\t\t\t\t? sourceCode.substring(\n\t\t\t\t\t\t\tstaticVariableNameCapture.node.startIndex,\n\t\t\t\t\t\t\tstaticVariableNameCapture.node.endIndex,\n\t\t\t\t\t\t)\n\t\t\t\t\t: \"\"\n\n\t\t\t\tsnippets.push({\n\t\t\t\t\ttype: SnippetType.VariableOrConstant,\n\t\t\t\t\tname: staticVariableName,\n\t\t\t\t\trangeText,\n\t\t\t\t\tstartLine,\n\t\t\t\t\tendLine,\n\t\t\t\t\tfilePath,\n\t\t\t\t\tfileHash,\n\t\t\t\t\tscope,\n\t\t\t\t\tlanguage: CodeLanguageType.C,\n\t\t\t\t\tdefinition: {\n\t\t\t\t\t\tname: staticVariableName,\n\t\t\t\t\t\ttype: \"static_variable\",\n\t\t\t\t\t},\n\t\t\t\t})\n\t\t\t}\n\t\t})\n\t}\n\n\t// \u5904\u7406 typedef declarations\n\tif (snippetTypes.includes(SnippetType.ClassOrInterfaceOrStructOrEnum)) {\n\t\tconst typedefCaptures = captures.filter((c) => c.name === \"definition.type\")\n\n\t\ttypedefCaptures.forEach((capture) => {\n\t\t\tconst node = capture.node\n\t\t\tconst startLine = node.startPosition.row + 1\n\t\t\tconst endLine = node.endPosition.row + 1\n\t\t\tconst rangeText = sourceCode.substring(node.startIndex, node.endIndex)\n\t\t\tconst snippetHash = generateSnippetHash(filePath, startLine, endLine, rangeText)\n\n\t\t\tif (!seenHashes.has(snippetHash)) {\n\t\t\t\tseenHashes.add(snippetHash)\n\t\t\t\tconst scope = buildScopeChain(node)\n\n\t\t\t\tconst typedefNameCapture = captures.find(\n\t\t\t\t\t(c) =>\n\t\t\t\t\t\tc.name === \"name.definition.type\" &&\n\t\t\t\t\t\tc.node.startIndex >= node.startIndex &&\n\t\t\t\t\t\tc.node.endIndex <= node.endIndex,\n\t\t\t\t)\n\t\t\t\tconst typedefName = typedefNameCapture\n\t\t\t\t\t? sourceCode.substring(typedefNameCapture.node.startIndex, typedefNameCapture.node.endIndex)\n\t\t\t\t\t: \"\"\n\n\t\t\t\tsnippets.push({\n\t\t\t\t\ttype: SnippetType.ClassOrInterfaceOrStructOrEnum,\n\t\t\t\t\tname: typedefName,\n\t\t\t\t\trangeText,\n\t\t\t\t\tstartLine,\n\t\t\t\t\tendLine,\n\t\t\t\t\tfilePath,\n\t\t\t\t\tfileHash,\n\t\t\t\t\tscope,\n\t\t\t\t\tlanguage: CodeLanguageType.C,\n\t\t\t\t\tdefinition: {\n\t\t\t\t\t\tname: typedefName,\n\t\t\t\t\t\ttype: \"typedef\",\n\t\t\t\t\t},\n\t\t\t\t})\n\t\t\t}\n\t\t})\n\t}\n\n\tlogger.info(`Extracted ${snippets.length} C snippets`)\n\treturn snippets\n}\n\n// \u8F85\u52A9\u51FD\u6570\uFF1A\u63D0\u53D6\u51FD\u6570\u53C2\u6570\nfunction extractParametersFromNode(node: Parser.SyntaxNode, sourceCode: string): ParameterInfo[] {\n\tconst parameters: ParameterInfo[] = []\n\n\t// \u904D\u5386\u53C2\u6570\u5217\u8868\u4E2D\u7684\u6BCF\u4E2A\u53C2\u6570\n\tfor (let i = 0; i < node.childCount; i++) {\n\t\tconst child = node.child(i)\n\t\tif (child && child.type === \"parameter_declaration\") {\n\t\t\tconst parameterText = sourceCode.substring(child.startIndex, child.endIndex)\n\t\t\tconst parameterName = extractParameterName(child, sourceCode)\n\n\t\t\tparameters.push({\n\t\t\t\tname: parameterName,\n\t\t\t\ttype: parameterText,\n\t\t\t})\n\t\t}\n\t}\n\n\treturn parameters\n}\n\n// \u8F85\u52A9\u51FD\u6570\uFF1A\u63D0\u53D6\u53C2\u6570\u540D\u79F0\nfunction extractParameterName(node: Parser.SyntaxNode, sourceCode: string): string {\n\t// \u67E5\u627E\u53C2\u6570\u58F0\u660E\u4E2D\u7684\u6807\u8BC6\u7B26\n\tfor (let i = 0; i < node.childCount; i++) {\n\t\tconst child = node.child(i)\n\t\tif (child && child.type === \"identifier\") {\n\t\t\treturn sourceCode.substring(child.startIndex, child.endIndex)\n\t\t}\n\t}\n\treturn \"\"\n}\n\n// \u8F85\u52A9\u51FD\u6570\uFF1A\u63D0\u53D6\u7ED3\u6784\u4F53\u5B57\u6BB5\nfunction extractFieldsFromStructNode(\n\tnode: Parser.SyntaxNode,\n\tsourceCode: string,\n\tcaptures: Parser.QueryCapture[],\n): string[] {\n\tconst fields: string[] = []\n\n\t// \u67E5\u627E\u8BE5\u7ED3\u6784\u4F53\u5185\u7684\u6240\u6709\u5B57\u6BB5\n\tconst fieldCaptures = captures.filter(\n\t\t(c) =>\n\t\t\tc.name === \"name.definition.field\" &&\n\t\t\tc.node.startIndex >= node.startIndex &&\n\t\t\tc.node.endIndex <= node.endIndex,\n\t)\n\n\tfieldCaptures.forEach((capture) => {\n\t\tconst fieldName = sourceCode.substring(capture.node.startIndex, capture.node.endIndex)\n\t\tfields.push(fieldName)\n\t})\n\n\treturn fields\n}\n\n// \u8F85\u52A9\u51FD\u6570\uFF1A\u63D0\u53D6\u679A\u4E3E\u503C\nfunction extractEnumeratorsFromEnumNode(\n\tnode: Parser.SyntaxNode,\n\tsourceCode: string,\n\tcaptures: Parser.QueryCapture[],\n): string[] {\n\tconst enumerators: string[] = []\n\n\t// \u67E5\u627E\u8BE5\u679A\u4E3E\u5185\u7684\u6240\u6709\u679A\u4E3E\u503C\n\tconst enumeratorCaptures = captures.filter(\n\t\t(c) =>\n\t\t\tc.name === \"name.definition.enumerator\" &&\n\t\t\tc.node.startIndex >= node.startIndex &&\n\t\t\tc.node.endIndex <= node.endIndex,\n\t)\n\n\tenumeratorCaptures.forEach((capture) => {\n\t\tconst enumeratorName = sourceCode.substring(capture.node.startIndex, capture.node.endIndex)\n\t\tenumerators.push(enumeratorName)\n\t})\n\n\treturn enumerators\n}\n\n// \u8F85\u52A9\u51FD\u6570\uFF1A\u6839\u636E\u5BB9\u5668\u7C7B\u578B\u751F\u6210\u5BF9\u5E94\u7684\u540D\u79F0capture\u540D\u79F0\nfunction getNameCaptureNameForContainer(containerCaptureName: string): string {\n\tswitch (containerCaptureName) {\n\t\tcase \"definition.struct\":\n\t\t\treturn \"name.definition.struct\"\n\t\tcase \"definition.union\":\n\t\t\treturn \"name.definition.union\"\n\t\tcase \"definition.enum\":\n\t\t\treturn \"name.definition.enum\"\n\t\tdefault:\n\t\t\treturn containerCaptureName\n\t}\n}\n\n// \u8F85\u52A9\u51FD\u6570\uFF1A\u67E5\u627E\u5BB9\u5668\u7684\u540D\u79F0capture\nfunction findNameCaptureForContainer(\n\tcontainerCapture: Parser.QueryCapture,\n\tcaptures: Parser.QueryCapture[],\n\tsourceCode: string,\n): string | null {\n\tconst node = containerCapture.node\n\tconst nameCaptureName = getNameCaptureNameForContainer(containerCapture.name)\n\n\tconst nameCapture = captures.find(\n\t\t(c) => c.name === nameCaptureName && c.node.startIndex >= node.startIndex && c.node.endIndex <= node.endIndex,\n\t)\n\n\treturn nameCapture ? sourceCode.substring(nameCapture.node.startIndex, nameCapture.node.endIndex) : null\n}\n\n// \u7528\u4E8E\u6784\u5EFA\u6982\u89C8\u7684\u51FD\u6570\nexport function buildSummaryFromSnippets(snippets: ISnippetMeta[]): any {\n\tconst summary = {\n\t\tincludes: [] as string[],\n\t\tfunctions: [] as string[],\n\t\tstructs: [] as string[],\n\t\tunions: [] as string[],\n\t\tenums: [] as string[],\n\t\tvariables: [] as string[],\n\t}\n\n\tsnippets.forEach((snippet) => {\n\t\tswitch (snippet.type) {\n\t\t\tcase SnippetType.ImportOrInclude:\n\t\t\t\tsummary.includes.push(snippet.name)\n\t\t\t\tbreak\n\t\t\tcase SnippetType.FunctionOrMethod:\n\t\t\t\tsummary.functions.push(snippet.name)\n\t\t\t\tbreak\n\t\t\tcase SnippetType.ClassOrInterfaceOrStructOrEnum:\n\t\t\t\tif (snippet.rangeText.includes(\"struct\")) {\n\t\t\t\t\tsummary.structs.push(snippet.name)\n\t\t\t\t} else if (snippet.rangeText.includes(\"union\")) {\n\t\t\t\t\tsummary.unions.push(snippet.name)\n\t\t\t\t} else if (snippet.rangeText.includes(\"enum\")) {\n\t\t\t\t\tsummary.enums.push(snippet.name)\n\t\t\t\t}\n\t\t\t\tbreak\n\t\t\tcase SnippetType.VariableOrConstant:\n\t\t\t\tsummary.variables.push(snippet.name)\n\t\t\t\tbreak\n\t\t}\n\t})\n\n\treturn summary\n}\n\n// \u7528\u4E8E\u683C\u5F0F\u5316\u6982\u89C8\u6587\u672C\u7684\u51FD\u6570\nexport function formatOutlineText(summary: any): string {\n\tlet outline = \"\"\n\n\tif (summary.includes.length > 0) {\n\t\toutline += `Includes: ${summary.includes.join(\", \")}\\n`\n\t}\n\n\tif (summary.functions.length > 0) {\n\t\toutline += `Functions: ${summary.functions.join(\", \")}\\n`\n\t}\n\n\tif (summary.structs.length > 0) {\n\t\toutline += `Structs: ${summary.structs.join(\", \")}\\n`\n\t}\n\n\tif (summary.unions.length > 0) {\n\t\toutline += `Unions: ${summary.unions.join(\", \")}\\n`\n\t}\n\n\tif (summary.enums.length > 0) {\n\t\toutline += `Enums: ${summary.enums.join(\", \")}\\n`\n\t}\n\n\tif (summary.variables.length > 0) {\n\t\toutline += `Variables: ${summary.variables.join(\", \")}\\n`\n\t}\n\n\treturn outline\n}\n", "import { SnippetType, ISnippetMeta, ParameterInfo, CodeLanguageType } from \"../types\"\nimport Parser from \"web-tree-sitter\"\nimport { generateSnippetHash, buildScopeChain } from \"./general\"\nimport { Logger } from \"../Logger\"\n\nexport async function extractSnippetsFromCapturesForCPP(\n\tcaptures: Parser.QueryCapture[],\n\tsourceCode: string,\n\tfilePath: string,\n\tfileHash: string,\n\tsnippetTypes: SnippetType[],\n\toptions: { maxSnippetLines: number; minSnippetLines: number },\n): Promise {\n\tconst logger = Logger.getDefaultLogger().with(\"[extractSnippetsFromCapturesForCPP]\")\n\n\tconst snippets: ISnippetMeta[] = []\n\tconst seenHashes = new Set()\n\n\tif (snippetTypes.length === 0) {\n\t\tlogger.warn(`No snippet types provided, skipping`)\n\t\treturn snippets\n\t}\n\n\t// \u6536\u96C6\u6240\u6709 class/struct/union/enum captures \u7528\u4E8E\u786E\u5B9A field \u548C method \u7684\u5F52\u5C5E\n\tconst containerCaptures = captures\n\t\t.filter(\n\t\t\t(c) =>\n\t\t\t\tc.name === \"definition.class\" ||\n\t\t\t\tc.name === \"definition.struct\" ||\n\t\t\t\tc.name === \"definition.union\" ||\n\t\t\t\tc.name === \"definition.enum\" ||\n\t\t\t\tc.name === \"definition.template\",\n\t\t)\n\t\t.map((c) => ({\n\t\t\tnode: c.node,\n\t\t\tstart: c.node.startIndex,\n\t\t\tend: c.node.endIndex,\n\t\t\tname: c.name,\n\t\t\tnameCap: findNameCaptureForContainer(c, captures, sourceCode),\n\t\t}))\n\t\t.filter((c) => c.nameCap) // \u53EA\u4FDD\u7559\u6709\u540D\u79F0\u7684containers\n\n\t// \u5904\u7406 include declarations (imports)\n\tif (snippetTypes.includes(SnippetType.ImportOrInclude)) {\n\t\tcaptures.forEach((capture) => {\n\t\t\tif (capture.name === \"definition.include\") {\n\t\t\t\tconst node = capture.node\n\t\t\t\tconst startLine = node.startPosition.row + 1\n\t\t\t\tconst endLine = node.endPosition.row + 1\n\t\t\t\tconst rangeText = sourceCode.substring(node.startIndex, node.endIndex)\n\t\t\t\tconst snippetHash = generateSnippetHash(filePath, startLine, endLine, rangeText)\n\n\t\t\t\tif (!seenHashes.has(snippetHash)) {\n\t\t\t\t\tseenHashes.add(snippetHash)\n\t\t\t\t\tconst scope = buildScopeChain(node)\n\n\t\t\t\t\tconst includeNameCapture = captures.find(\n\t\t\t\t\t\t(c) =>\n\t\t\t\t\t\t\tc.name === \"name.definition.include\" &&\n\t\t\t\t\t\t\tc.node.startIndex >= node.startIndex &&\n\t\t\t\t\t\t\tc.node.endIndex <= node.endIndex,\n\t\t\t\t\t)\n\t\t\t\t\tconst includeName = includeNameCapture\n\t\t\t\t\t\t? sourceCode.substring(includeNameCapture.node.startIndex, includeNameCapture.node.endIndex)\n\t\t\t\t\t\t: \"\"\n\n\t\t\t\t\tsnippets.push({\n\t\t\t\t\t\ttype: SnippetType.ImportOrInclude,\n\t\t\t\t\t\tname: includeName,\n\t\t\t\t\t\trangeText,\n\t\t\t\t\t\tstartLine,\n\t\t\t\t\t\tendLine,\n\t\t\t\t\t\tfilePath,\n\t\t\t\t\t\tfileHash,\n\t\t\t\t\t\tscope,\n\t\t\t\t\t\tlanguage: CodeLanguageType.CPP,\n\t\t\t\t\t})\n\t\t\t\t}\n\t\t\t}\n\t\t})\n\t}\n\n\t// \u5904\u7406 function definitions and declarations\n\tif (snippetTypes.includes(SnippetType.FunctionOrMethod)) {\n\t\tconst functionCaptures = captures.filter((c) => c.name === \"definition.function\")\n\n\t\tfunctionCaptures.forEach((capture) => {\n\t\t\tconst node = capture.node\n\t\t\tconst startLine = node.startPosition.row + 1\n\t\t\tconst endLine = node.endPosition.row + 1\n\t\t\tconst rangeText = sourceCode.substring(node.startIndex, node.endIndex)\n\t\t\tconst snippetHash = generateSnippetHash(filePath, startLine, endLine, rangeText)\n\n\t\t\tif (!seenHashes.has(snippetHash)) {\n\t\t\t\tseenHashes.add(snippetHash)\n\t\t\t\tconst scope = buildScopeChain(node)\n\n\t\t\t\tconst functionNameCapture = captures.find(\n\t\t\t\t\t(c) =>\n\t\t\t\t\t\tc.name === \"name.definition.function\" &&\n\t\t\t\t\t\tc.node.startIndex >= node.startIndex &&\n\t\t\t\t\t\tc.node.endIndex <= node.endIndex,\n\t\t\t\t)\n\t\t\t\tconst functionName = functionNameCapture\n\t\t\t\t\t? sourceCode.substring(functionNameCapture.node.startIndex, functionNameCapture.node.endIndex)\n\t\t\t\t\t: \"\"\n\n\t\t\t\tconst parametersCapture = captures.find(\n\t\t\t\t\t(c) =>\n\t\t\t\t\t\tc.name === \"parameters.definition.function\" &&\n\t\t\t\t\t\tc.node.startIndex >= node.startIndex &&\n\t\t\t\t\t\tc.node.endIndex <= node.endIndex,\n\t\t\t\t)\n\t\t\t\tconst parameters = parametersCapture\n\t\t\t\t\t? extractParametersFromNode(parametersCapture.node, sourceCode)\n\t\t\t\t\t: []\n\n\t\t\t\tconst bodyCapture = captures.find(\n\t\t\t\t\t(c) =>\n\t\t\t\t\t\tc.name === \"body.definition.function\" &&\n\t\t\t\t\t\tc.node.startIndex >= node.startIndex &&\n\t\t\t\t\t\tc.node.endIndex <= node.endIndex,\n\t\t\t\t)\n\t\t\t\tconst hasBody = !!bodyCapture\n\n\t\t\t\tsnippets.push({\n\t\t\t\t\ttype: SnippetType.FunctionOrMethod,\n\t\t\t\t\tname: functionName,\n\t\t\t\t\trangeText,\n\t\t\t\t\tstartLine,\n\t\t\t\t\tendLine,\n\t\t\t\t\tfilePath,\n\t\t\t\t\tfileHash,\n\t\t\t\t\tscope,\n\t\t\t\t\tlanguage: CodeLanguageType.CPP,\n\t\t\t\t\tparameters,\n\t\t\t\t\tdefinition: {\n\t\t\t\t\t\tname: functionName,\n\t\t\t\t\t\ttype: \"function\",\n\t\t\t\t\t\tparameters,\n\t\t\t\t\t},\n\t\t\t\t})\n\t\t\t}\n\t\t})\n\t}\n\n\t// \u5904\u7406 method definitions and declarations\n\tif (snippetTypes.includes(SnippetType.FunctionOrMethod)) {\n\t\tconst methodCaptures = captures.filter((c) => c.name === \"definition.method\")\n\n\t\tmethodCaptures.forEach((capture) => {\n\t\t\tconst node = capture.node\n\t\t\tconst startLine = node.startPosition.row + 1\n\t\t\tconst endLine = node.endPosition.row + 1\n\t\t\tconst rangeText = sourceCode.substring(node.startIndex, node.endIndex)\n\t\t\tconst snippetHash = generateSnippetHash(filePath, startLine, endLine, rangeText)\n\n\t\t\tif (!seenHashes.has(snippetHash)) {\n\t\t\t\tseenHashes.add(snippetHash)\n\t\t\t\tconst scope = buildScopeChain(node)\n\n\t\t\t\tconst methodNameCapture = captures.find(\n\t\t\t\t\t(c) =>\n\t\t\t\t\t\tc.name === \"name.definition.method\" &&\n\t\t\t\t\t\tc.node.startIndex >= node.startIndex &&\n\t\t\t\t\t\tc.node.endIndex <= node.endIndex,\n\t\t\t\t)\n\t\t\t\tconst methodName = methodNameCapture\n\t\t\t\t\t? sourceCode.substring(methodNameCapture.node.startIndex, methodNameCapture.node.endIndex)\n\t\t\t\t\t: \"\"\n\n\t\t\t\tconst parametersCapture = captures.find(\n\t\t\t\t\t(c) =>\n\t\t\t\t\t\tc.name === \"parameters.definition.method\" &&\n\t\t\t\t\t\tc.node.startIndex >= node.startIndex &&\n\t\t\t\t\t\tc.node.endIndex <= node.endIndex,\n\t\t\t\t)\n\t\t\t\tconst parameters = parametersCapture\n\t\t\t\t\t? extractParametersFromNode(parametersCapture.node, sourceCode)\n\t\t\t\t\t: []\n\n\t\t\t\tconst bodyCapture = captures.find(\n\t\t\t\t\t(c) =>\n\t\t\t\t\t\tc.name === \"body.definition.method\" &&\n\t\t\t\t\t\tc.node.startIndex >= node.startIndex &&\n\t\t\t\t\t\tc.node.endIndex <= node.endIndex,\n\t\t\t\t)\n\t\t\t\tconst hasBody = !!bodyCapture\n\n\t\t\t\t// \u67E5\u627E\u5F52\u5C5E\u7684\u7C7B\u6216\u7ED3\u6784\u4F53\n\t\t\t\tconst parentContainer = findParentContainer(node, containerCaptures)\n\t\t\t\tconst field = parentContainer?.nameCap || undefined\n\n\t\t\t\tsnippets.push({\n\t\t\t\t\ttype: SnippetType.FunctionOrMethod,\n\t\t\t\t\tname: methodName,\n\t\t\t\t\trangeText,\n\t\t\t\t\tstartLine,\n\t\t\t\t\tendLine,\n\t\t\t\t\tfilePath,\n\t\t\t\t\tfileHash,\n\t\t\t\t\tscope,\n\t\t\t\t\tlanguage: CodeLanguageType.CPP,\n\t\t\t\t\tparameters,\n\t\t\t\t\tfield,\n\t\t\t\t\tdefinition: {\n\t\t\t\t\t\tname: methodName,\n\t\t\t\t\t\ttype: \"method\",\n\t\t\t\t\t\tparameters,\n\t\t\t\t\t},\n\t\t\t\t})\n\t\t\t}\n\t\t})\n\t}\n\n\t// \u5904\u7406 constructor definitions\n\tif (snippetTypes.includes(SnippetType.FunctionOrMethod)) {\n\t\tconst constructorCaptures = captures.filter((c) => c.name === \"definition.constructor\")\n\n\t\tconstructorCaptures.forEach((capture) => {\n\t\t\tconst node = capture.node\n\t\t\tconst startLine = node.startPosition.row + 1\n\t\t\tconst endLine = node.endPosition.row + 1\n\t\t\tconst rangeText = sourceCode.substring(node.startIndex, node.endIndex)\n\t\t\tconst snippetHash = generateSnippetHash(filePath, startLine, endLine, rangeText)\n\n\t\t\tif (!seenHashes.has(snippetHash)) {\n\t\t\t\tseenHashes.add(snippetHash)\n\t\t\t\tconst scope = buildScopeChain(node)\n\n\t\t\t\tconst constructorNameCapture = captures.find(\n\t\t\t\t\t(c) =>\n\t\t\t\t\t\tc.name === \"name.definition.constructor\" &&\n\t\t\t\t\t\tc.node.startIndex >= node.startIndex &&\n\t\t\t\t\t\tc.node.endIndex <= node.endIndex,\n\t\t\t\t)\n\t\t\t\tconst constructorName = constructorNameCapture\n\t\t\t\t\t? sourceCode.substring(constructorNameCapture.node.startIndex, constructorNameCapture.node.endIndex)\n\t\t\t\t\t: \"\"\n\n\t\t\t\tconst parametersCapture = captures.find(\n\t\t\t\t\t(c) =>\n\t\t\t\t\t\tc.name === \"parameters.definition.constructor\" &&\n\t\t\t\t\t\tc.node.startIndex >= node.startIndex &&\n\t\t\t\t\t\tc.node.endIndex <= node.endIndex,\n\t\t\t\t)\n\t\t\t\tconst parameters = parametersCapture\n\t\t\t\t\t? extractParametersFromNode(parametersCapture.node, sourceCode)\n\t\t\t\t\t: []\n\n\t\t\t\t// \u67E5\u627E\u5F52\u5C5E\u7684\u7C7B\n\t\t\t\tconst parentContainer = findParentContainer(node, containerCaptures)\n\t\t\t\tconst field = parentContainer?.nameCap || undefined\n\n\t\t\t\tsnippets.push({\n\t\t\t\t\ttype: SnippetType.FunctionOrMethod,\n\t\t\t\t\tname: constructorName,\n\t\t\t\t\trangeText,\n\t\t\t\t\tstartLine,\n\t\t\t\t\tendLine,\n\t\t\t\t\tfilePath,\n\t\t\t\t\tfileHash,\n\t\t\t\t\tscope,\n\t\t\t\t\tlanguage: CodeLanguageType.CPP,\n\t\t\t\t\tparameters,\n\t\t\t\t\tfield,\n\t\t\t\t\tdefinition: {\n\t\t\t\t\t\tname: constructorName,\n\t\t\t\t\t\ttype: \"constructor\",\n\t\t\t\t\t\tparameters,\n\t\t\t\t\t},\n\t\t\t\t})\n\t\t\t}\n\t\t})\n\t}\n\n\t// \u5904\u7406 destructor definitions\n\tif (snippetTypes.includes(SnippetType.FunctionOrMethod)) {\n\t\tconst destructorCaptures = captures.filter((c) => c.name === \"definition.destructor\")\n\n\t\tdestructorCaptures.forEach((capture) => {\n\t\t\tconst node = capture.node\n\t\t\tconst startLine = node.startPosition.row + 1\n\t\t\tconst endLine = node.endPosition.row + 1\n\t\t\tconst rangeText = sourceCode.substring(node.startIndex, node.endIndex)\n\t\t\tconst snippetHash = generateSnippetHash(filePath, startLine, endLine, rangeText)\n\n\t\t\tif (!seenHashes.has(snippetHash)) {\n\t\t\t\tseenHashes.add(snippetHash)\n\t\t\t\tconst scope = buildScopeChain(node)\n\n\t\t\t\tconst destructorNameCapture = captures.find(\n\t\t\t\t\t(c) =>\n\t\t\t\t\t\tc.name === \"name.definition.destructor\" &&\n\t\t\t\t\t\tc.node.startIndex >= node.startIndex &&\n\t\t\t\t\t\tc.node.endIndex <= node.endIndex,\n\t\t\t\t)\n\t\t\t\tconst destructorName = destructorNameCapture\n\t\t\t\t\t? sourceCode.substring(destructorNameCapture.node.startIndex, destructorNameCapture.node.endIndex)\n\t\t\t\t\t: \"\"\n\n\t\t\t\t// \u67E5\u627E\u5F52\u5C5E\u7684\u7C7B\n\t\t\t\tconst parentContainer = findParentContainer(node, containerCaptures)\n\t\t\t\tconst field = parentContainer?.nameCap || undefined\n\n\t\t\t\tsnippets.push({\n\t\t\t\t\ttype: SnippetType.FunctionOrMethod,\n\t\t\t\t\tname: destructorName,\n\t\t\t\t\trangeText,\n\t\t\t\t\tstartLine,\n\t\t\t\t\tendLine,\n\t\t\t\t\tfilePath,\n\t\t\t\t\tfileHash,\n\t\t\t\t\tscope,\n\t\t\t\t\tlanguage: CodeLanguageType.CPP,\n\t\t\t\t\tfield,\n\t\t\t\t\tdefinition: {\n\t\t\t\t\t\tname: destructorName,\n\t\t\t\t\t\ttype: \"destructor\",\n\t\t\t\t\t\tparameters: [],\n\t\t\t\t\t},\n\t\t\t\t})\n\t\t\t}\n\t\t})\n\t}\n\n\t// \u5904\u7406 operator overloads\n\tif (snippetTypes.includes(SnippetType.FunctionOrMethod)) {\n\t\tconst operatorCaptures = captures.filter((c) => c.name === \"definition.operator\")\n\n\t\toperatorCaptures.forEach((capture) => {\n\t\t\tconst node = capture.node\n\t\t\tconst startLine = node.startPosition.row + 1\n\t\t\tconst endLine = node.endPosition.row + 1\n\t\t\tconst rangeText = sourceCode.substring(node.startIndex, node.endIndex)\n\t\t\tconst snippetHash = generateSnippetHash(filePath, startLine, endLine, rangeText)\n\n\t\t\tif (!seenHashes.has(snippetHash)) {\n\t\t\t\tseenHashes.add(snippetHash)\n\t\t\t\tconst scope = buildScopeChain(node)\n\n\t\t\t\tconst operatorNameCapture = captures.find(\n\t\t\t\t\t(c) =>\n\t\t\t\t\t\tc.name === \"name.definition.operator\" &&\n\t\t\t\t\t\tc.node.startIndex >= node.startIndex &&\n\t\t\t\t\t\tc.node.endIndex <= node.endIndex,\n\t\t\t\t)\n\t\t\t\tconst operatorName = operatorNameCapture\n\t\t\t\t\t? sourceCode.substring(operatorNameCapture.node.startIndex, operatorNameCapture.node.endIndex)\n\t\t\t\t\t: \"\"\n\n\t\t\t\tconst parametersCapture = captures.find(\n\t\t\t\t\t(c) =>\n\t\t\t\t\t\tc.name === \"parameters.definition.operator\" &&\n\t\t\t\t\t\tc.node.startIndex >= node.startIndex &&\n\t\t\t\t\t\tc.node.endIndex <= node.endIndex,\n\t\t\t\t)\n\t\t\t\tconst parameters = parametersCapture\n\t\t\t\t\t? extractParametersFromNode(parametersCapture.node, sourceCode)\n\t\t\t\t\t: []\n\n\t\t\t\t// \u67E5\u627E\u5F52\u5C5E\u7684\u7C7B\n\t\t\t\tconst parentContainer = findParentContainer(node, containerCaptures)\n\t\t\t\tconst field = parentContainer?.nameCap || undefined\n\n\t\t\t\tsnippets.push({\n\t\t\t\t\ttype: SnippetType.FunctionOrMethod,\n\t\t\t\t\tname: operatorName,\n\t\t\t\t\trangeText,\n\t\t\t\t\tstartLine,\n\t\t\t\t\tendLine,\n\t\t\t\t\tfilePath,\n\t\t\t\t\tfileHash,\n\t\t\t\t\tscope,\n\t\t\t\t\tlanguage: CodeLanguageType.CPP,\n\t\t\t\t\tparameters,\n\t\t\t\t\tfield,\n\t\t\t\t\tdefinition: {\n\t\t\t\t\t\tname: operatorName,\n\t\t\t\t\t\ttype: \"operator\",\n\t\t\t\t\t\tparameters,\n\t\t\t\t\t},\n\t\t\t\t})\n\t\t\t}\n\t\t})\n\t}\n\n\t// \u5904\u7406 class definitions (\u6392\u9664\u6A21\u677F\u5185\u7684class)\n\tif (snippetTypes.includes(SnippetType.ClassOrInterfaceOrStructOrEnum)) {\n\t\tconst classCaptures = captures.filter((c) => c.name === \"definition.class\")\n\t\tconst templateCaptures = captures.filter((c) => c.name === \"definition.template\")\n\n\t\tclassCaptures.forEach((capture) => {\n\t\t\tconst node = capture.node\n\n\t\t\t// \u68C0\u67E5\u662F\u5426\u88ABtemplate\u5305\u542B\n\t\t\tconst isWithinTemplate = templateCaptures.some((templateCapture) => {\n\t\t\t\treturn (\n\t\t\t\t\ttemplateCapture.node.startIndex <= node.startIndex && node.endIndex <= templateCapture.node.endIndex\n\t\t\t\t)\n\t\t\t})\n\n\t\t\t// \u5982\u679C\u5728template\u5185\uFF0C\u8DF3\u8FC7\uFF08\u7531template\u5904\u7406\uFF09\n\t\t\tif (isWithinTemplate) {\n\t\t\t\treturn\n\t\t\t}\n\n\t\t\tconst startLine = node.startPosition.row + 1\n\t\t\tconst endLine = node.endPosition.row + 1\n\t\t\tconst rangeText = sourceCode.substring(node.startIndex, node.endIndex)\n\t\t\tconst snippetHash = generateSnippetHash(filePath, startLine, endLine, rangeText)\n\n\t\t\tif (!seenHashes.has(snippetHash)) {\n\t\t\t\tseenHashes.add(snippetHash)\n\t\t\t\tconst scope = buildScopeChain(node)\n\n\t\t\t\tconst classNameCapture = captures.find(\n\t\t\t\t\t(c) =>\n\t\t\t\t\t\tc.name === \"name.definition.class\" &&\n\t\t\t\t\t\tc.node.startIndex >= node.startIndex &&\n\t\t\t\t\t\tc.node.endIndex <= node.endIndex,\n\t\t\t\t)\n\t\t\t\tconst className = classNameCapture\n\t\t\t\t\t? sourceCode.substring(classNameCapture.node.startIndex, classNameCapture.node.endIndex)\n\t\t\t\t\t: \"\"\n\n\t\t\t\tconst fields = extractFieldsFromContainerNode(node, sourceCode, captures)\n\n\t\t\t\tsnippets.push({\n\t\t\t\t\ttype: SnippetType.ClassOrInterfaceOrStructOrEnum,\n\t\t\t\t\tname: className,\n\t\t\t\t\trangeText,\n\t\t\t\t\tstartLine,\n\t\t\t\t\tendLine,\n\t\t\t\t\tfilePath,\n\t\t\t\t\tfileHash,\n\t\t\t\t\tscope,\n\t\t\t\t\tlanguage: CodeLanguageType.CPP,\n\t\t\t\t\tdefinition: {\n\t\t\t\t\t\tname: className,\n\t\t\t\t\t\ttype: \"class\",\n\t\t\t\t\t},\n\t\t\t\t})\n\t\t\t}\n\t\t})\n\t}\n\n\t// \u5904\u7406 struct definitions\n\tif (snippetTypes.includes(SnippetType.ClassOrInterfaceOrStructOrEnum)) {\n\t\tconst structCaptures = captures.filter((c) => c.name === \"definition.struct\")\n\n\t\tstructCaptures.forEach((capture) => {\n\t\t\tconst node = capture.node\n\t\t\tconst startLine = node.startPosition.row + 1\n\t\t\tconst endLine = node.endPosition.row + 1\n\t\t\tconst rangeText = sourceCode.substring(node.startIndex, node.endIndex)\n\t\t\tconst snippetHash = generateSnippetHash(filePath, startLine, endLine, rangeText)\n\n\t\t\tif (!seenHashes.has(snippetHash)) {\n\t\t\t\tseenHashes.add(snippetHash)\n\t\t\t\tconst scope = buildScopeChain(node)\n\n\t\t\t\tconst structNameCapture = captures.find(\n\t\t\t\t\t(c) =>\n\t\t\t\t\t\tc.name === \"name.definition.struct\" &&\n\t\t\t\t\t\tc.node.startIndex >= node.startIndex &&\n\t\t\t\t\t\tc.node.endIndex <= node.endIndex,\n\t\t\t\t)\n\t\t\t\tconst structName = structNameCapture\n\t\t\t\t\t? sourceCode.substring(structNameCapture.node.startIndex, structNameCapture.node.endIndex)\n\t\t\t\t\t: \"\"\n\n\t\t\t\tconst fields = extractFieldsFromContainerNode(node, sourceCode, captures)\n\n\t\t\t\tsnippets.push({\n\t\t\t\t\ttype: SnippetType.ClassOrInterfaceOrStructOrEnum,\n\t\t\t\t\tname: structName,\n\t\t\t\t\trangeText,\n\t\t\t\t\tstartLine,\n\t\t\t\t\tendLine,\n\t\t\t\t\tfilePath,\n\t\t\t\t\tfileHash,\n\t\t\t\t\tscope,\n\t\t\t\t\tlanguage: CodeLanguageType.CPP,\n\t\t\t\t\tdefinition: {\n\t\t\t\t\t\tname: structName,\n\t\t\t\t\t\ttype: \"struct\",\n\t\t\t\t\t},\n\t\t\t\t})\n\t\t\t}\n\t\t})\n\t}\n\n\t// \u5904\u7406 union definitions\n\tif (snippetTypes.includes(SnippetType.ClassOrInterfaceOrStructOrEnum)) {\n\t\tconst unionCaptures = captures.filter((c) => c.name === \"definition.union\")\n\n\t\tunionCaptures.forEach((capture) => {\n\t\t\tconst node = capture.node\n\t\t\tconst startLine = node.startPosition.row + 1\n\t\t\tconst endLine = node.endPosition.row + 1\n\t\t\tconst rangeText = sourceCode.substring(node.startIndex, node.endIndex)\n\t\t\tconst snippetHash = generateSnippetHash(filePath, startLine, endLine, rangeText)\n\n\t\t\tif (!seenHashes.has(snippetHash)) {\n\t\t\t\tseenHashes.add(snippetHash)\n\t\t\t\tconst scope = buildScopeChain(node)\n\n\t\t\t\tconst unionNameCapture = captures.find(\n\t\t\t\t\t(c) =>\n\t\t\t\t\t\tc.name === \"name.definition.union\" &&\n\t\t\t\t\t\tc.node.startIndex >= node.startIndex &&\n\t\t\t\t\t\tc.node.endIndex <= node.endIndex,\n\t\t\t\t)\n\t\t\t\tconst unionName = unionNameCapture\n\t\t\t\t\t? sourceCode.substring(unionNameCapture.node.startIndex, unionNameCapture.node.endIndex)\n\t\t\t\t\t: \"\"\n\n\t\t\t\tconst fields = extractFieldsFromContainerNode(node, sourceCode, captures)\n\n\t\t\t\tsnippets.push({\n\t\t\t\t\ttype: SnippetType.ClassOrInterfaceOrStructOrEnum,\n\t\t\t\t\tname: unionName,\n\t\t\t\t\trangeText,\n\t\t\t\t\tstartLine,\n\t\t\t\t\tendLine,\n\t\t\t\t\tfilePath,\n\t\t\t\t\tfileHash,\n\t\t\t\t\tscope,\n\t\t\t\t\tlanguage: CodeLanguageType.CPP,\n\t\t\t\t\tdefinition: {\n\t\t\t\t\t\tname: unionName,\n\t\t\t\t\t\ttype: \"union\",\n\t\t\t\t\t},\n\t\t\t\t})\n\t\t\t}\n\t\t})\n\t}\n\n\t// \u5904\u7406 enum definitions\n\tif (snippetTypes.includes(SnippetType.ClassOrInterfaceOrStructOrEnum)) {\n\t\tconst enumCaptures = captures.filter((c) => c.name === \"definition.enum\")\n\n\t\tenumCaptures.forEach((capture) => {\n\t\t\tconst node = capture.node\n\t\t\tconst startLine = node.startPosition.row + 1\n\t\t\tconst endLine = node.endPosition.row + 1\n\t\t\tconst rangeText = sourceCode.substring(node.startIndex, node.endIndex)\n\t\t\tconst snippetHash = generateSnippetHash(filePath, startLine, endLine, rangeText)\n\n\t\t\tif (!seenHashes.has(snippetHash)) {\n\t\t\t\tseenHashes.add(snippetHash)\n\t\t\t\tconst scope = buildScopeChain(node)\n\n\t\t\t\tconst enumNameCapture = captures.find(\n\t\t\t\t\t(c) =>\n\t\t\t\t\t\tc.name === \"name.definition.enum\" &&\n\t\t\t\t\t\tc.node.startIndex >= node.startIndex &&\n\t\t\t\t\t\tc.node.endIndex <= node.endIndex,\n\t\t\t\t)\n\t\t\t\tconst enumName = enumNameCapture\n\t\t\t\t\t? sourceCode.substring(enumNameCapture.node.startIndex, enumNameCapture.node.endIndex)\n\t\t\t\t\t: \"\"\n\n\t\t\t\tconst enumerators = extractEnumeratorsFromEnumNode(node, sourceCode, captures)\n\n\t\t\t\tsnippets.push({\n\t\t\t\t\ttype: SnippetType.ClassOrInterfaceOrStructOrEnum,\n\t\t\t\t\tname: enumName,\n\t\t\t\t\trangeText,\n\t\t\t\t\tstartLine,\n\t\t\t\t\tendLine,\n\t\t\t\t\tfilePath,\n\t\t\t\t\tfileHash,\n\t\t\t\t\tscope,\n\t\t\t\t\tlanguage: CodeLanguageType.CPP,\n\t\t\t\t\tdefinition: {\n\t\t\t\t\t\tname: enumName,\n\t\t\t\t\t\ttype: \"enum\",\n\t\t\t\t\t},\n\t\t\t\t})\n\t\t\t}\n\t\t})\n\t}\n\n\t// \u5904\u7406 template definitions\n\tif (snippetTypes.includes(SnippetType.ClassOrInterfaceOrStructOrEnum)) {\n\t\tconst templateCaptures = captures.filter((c) => c.name === \"definition.template\")\n\n\t\ttemplateCaptures.forEach((capture) => {\n\t\t\tconst node = capture.node\n\t\t\tconst startLine = node.startPosition.row + 1\n\t\t\tconst endLine = node.endPosition.row + 1\n\t\t\tconst rangeText = sourceCode.substring(node.startIndex, node.endIndex)\n\t\t\tconst snippetHash = generateSnippetHash(filePath, startLine, endLine, rangeText)\n\n\t\t\tif (!seenHashes.has(snippetHash)) {\n\t\t\t\tseenHashes.add(snippetHash)\n\t\t\t\tconst scope = buildScopeChain(node)\n\n\t\t\t\t// \u67E5\u627E\u6A21\u677F\u7684\u540D\u79F0\uFF08\u53EF\u80FD\u662F\u7C7B\u3001\u7ED3\u6784\u4F53\u6216\u51FD\u6570\uFF09\n\t\t\t\tconst templateClassNameCapture = captures.find(\n\t\t\t\t\t(c) =>\n\t\t\t\t\t\tc.name === \"name.definition.template.class\" &&\n\t\t\t\t\t\tc.node.startIndex >= node.startIndex &&\n\t\t\t\t\t\tc.node.endIndex <= node.endIndex,\n\t\t\t\t)\n\t\t\t\tconst templateStructNameCapture = captures.find(\n\t\t\t\t\t(c) =>\n\t\t\t\t\t\tc.name === \"name.definition.template.struct\" &&\n\t\t\t\t\t\tc.node.startIndex >= node.startIndex &&\n\t\t\t\t\t\tc.node.endIndex <= node.endIndex,\n\t\t\t\t)\n\t\t\t\tconst templateFunctionNameCapture = captures.find(\n\t\t\t\t\t(c) =>\n\t\t\t\t\t\tc.name === \"name.definition.template.function\" &&\n\t\t\t\t\t\tc.node.startIndex >= node.startIndex &&\n\t\t\t\t\t\tc.node.endIndex <= node.endIndex,\n\t\t\t\t)\n\n\t\t\t\tlet templateName = \"\"\n\t\t\t\tlet templateType = \"template\"\n\t\t\t\tif (templateClassNameCapture) {\n\t\t\t\t\ttemplateName = sourceCode.substring(\n\t\t\t\t\t\ttemplateClassNameCapture.node.startIndex,\n\t\t\t\t\t\ttemplateClassNameCapture.node.endIndex,\n\t\t\t\t\t)\n\t\t\t\t\ttemplateType = \"template_class\"\n\t\t\t\t} else if (templateStructNameCapture) {\n\t\t\t\t\ttemplateName = sourceCode.substring(\n\t\t\t\t\t\ttemplateStructNameCapture.node.startIndex,\n\t\t\t\t\t\ttemplateStructNameCapture.node.endIndex,\n\t\t\t\t\t)\n\t\t\t\t\ttemplateType = \"template_struct\"\n\t\t\t\t} else if (templateFunctionNameCapture) {\n\t\t\t\t\ttemplateName = sourceCode.substring(\n\t\t\t\t\t\ttemplateFunctionNameCapture.node.startIndex,\n\t\t\t\t\t\ttemplateFunctionNameCapture.node.endIndex,\n\t\t\t\t\t)\n\t\t\t\t\ttemplateType = \"template_function\"\n\t\t\t\t}\n\n\t\t\t\tconst parametersCapture = captures.find(\n\t\t\t\t\t(c) =>\n\t\t\t\t\t\tc.name === \"parameters.definition.template\" &&\n\t\t\t\t\t\tc.node.startIndex >= node.startIndex &&\n\t\t\t\t\t\tc.node.endIndex <= node.endIndex,\n\t\t\t\t)\n\t\t\t\tconst templateParameters = parametersCapture\n\t\t\t\t\t? extractTemplateParametersFromNode(parametersCapture.node, sourceCode)\n\t\t\t\t\t: []\n\n\t\t\t\tif (templateType === \"template_function\") {\n\t\t\t\t\t// \u6A21\u677F\u51FD\u6570\u5F52\u7C7B\u4E3A\u51FD\u6570\n\t\t\t\t\tif (snippetTypes.includes(SnippetType.FunctionOrMethod)) {\n\t\t\t\t\t\tconst functionParametersCapture = captures.find(\n\t\t\t\t\t\t\t(c) =>\n\t\t\t\t\t\t\t\tc.name === \"parameters.definition.template.function\" &&\n\t\t\t\t\t\t\t\tc.node.startIndex >= node.startIndex &&\n\t\t\t\t\t\t\t\tc.node.endIndex <= node.endIndex,\n\t\t\t\t\t\t)\n\t\t\t\t\t\tconst functionParameters = functionParametersCapture\n\t\t\t\t\t\t\t? extractParametersFromNode(functionParametersCapture.node, sourceCode)\n\t\t\t\t\t\t\t: []\n\n\t\t\t\t\t\tsnippets.push({\n\t\t\t\t\t\t\ttype: SnippetType.FunctionOrMethod,\n\t\t\t\t\t\t\tname: templateName,\n\t\t\t\t\t\t\trangeText,\n\t\t\t\t\t\t\tstartLine,\n\t\t\t\t\t\t\tendLine,\n\t\t\t\t\t\t\tfilePath,\n\t\t\t\t\t\t\tfileHash,\n\t\t\t\t\t\t\tscope,\n\t\t\t\t\t\t\tlanguage: CodeLanguageType.CPP,\n\t\t\t\t\t\t\tparameters: functionParameters,\n\t\t\t\t\t\t\tdefinition: {\n\t\t\t\t\t\t\t\tname: templateName,\n\t\t\t\t\t\t\t\ttype: templateType,\n\t\t\t\t\t\t\t\tparameters: functionParameters,\n\t\t\t\t\t\t\t},\n\t\t\t\t\t\t})\n\t\t\t\t\t}\n\t\t\t\t} else {\n\t\t\t\t\t// \u6A21\u677F\u7C7B/\u7ED3\u6784\u4F53\u5F52\u7C7B\u4E3A\u7C7B\n\t\t\t\t\tsnippets.push({\n\t\t\t\t\t\ttype: SnippetType.ClassOrInterfaceOrStructOrEnum,\n\t\t\t\t\t\tname: templateName,\n\t\t\t\t\t\trangeText,\n\t\t\t\t\t\tstartLine,\n\t\t\t\t\t\tendLine,\n\t\t\t\t\t\tfilePath,\n\t\t\t\t\t\tfileHash,\n\t\t\t\t\t\tscope,\n\t\t\t\t\t\tlanguage: CodeLanguageType.CPP,\n\t\t\t\t\t\tdefinition: {\n\t\t\t\t\t\t\tname: templateName,\n\t\t\t\t\t\t\ttype: templateType,\n\t\t\t\t\t\t},\n\t\t\t\t\t})\n\t\t\t\t}\n\t\t\t}\n\t\t})\n\t}\n\n\t// \u5904\u7406 namespace definitions\n\tif (snippetTypes.includes(SnippetType.ClassOrInterfaceOrStructOrEnum)) {\n\t\tconst namespaceCaptures = captures.filter((c) => c.name === \"definition.namespace\")\n\n\t\tnamespaceCaptures.forEach((capture) => {\n\t\t\tconst node = capture.node\n\t\t\tconst startLine = node.startPosition.row + 1\n\t\t\tconst endLine = node.endPosition.row + 1\n\t\t\tconst rangeText = sourceCode.substring(node.startIndex, node.endIndex)\n\t\t\tconst snippetHash = generateSnippetHash(filePath, startLine, endLine, rangeText)\n\n\t\t\tif (!seenHashes.has(snippetHash)) {\n\t\t\t\tseenHashes.add(snippetHash)\n\t\t\t\tconst scope = buildScopeChain(node)\n\n\t\t\t\tconst namespaceNameCapture = captures.find(\n\t\t\t\t\t(c) =>\n\t\t\t\t\t\tc.name === \"name.definition.namespace\" &&\n\t\t\t\t\t\tc.node.startIndex >= node.startIndex &&\n\t\t\t\t\t\tc.node.endIndex <= node.endIndex,\n\t\t\t\t)\n\t\t\t\tconst namespaceName = namespaceNameCapture\n\t\t\t\t\t? sourceCode.substring(namespaceNameCapture.node.startIndex, namespaceNameCapture.node.endIndex)\n\t\t\t\t\t: \"\"\n\n\t\t\t\tsnippets.push({\n\t\t\t\t\ttype: SnippetType.ClassOrInterfaceOrStructOrEnum,\n\t\t\t\t\tname: namespaceName,\n\t\t\t\t\trangeText,\n\t\t\t\t\tstartLine,\n\t\t\t\t\tendLine,\n\t\t\t\t\tfilePath,\n\t\t\t\t\tfileHash,\n\t\t\t\t\tscope,\n\t\t\t\t\tlanguage: CodeLanguageType.CPP,\n\t\t\t\t\tdefinition: {\n\t\t\t\t\t\tname: namespaceName,\n\t\t\t\t\t\ttype: \"namespace\",\n\t\t\t\t\t},\n\t\t\t\t})\n\t\t\t}\n\t\t})\n\t}\n\n\t// \u5904\u7406 typedef definitions\n\tif (snippetTypes.includes(SnippetType.ClassOrInterfaceOrStructOrEnum)) {\n\t\tconst typedefCaptures = captures.filter((c) => c.name === \"definition.typedef\")\n\n\t\ttypedefCaptures.forEach((capture) => {\n\t\t\tconst node = capture.node\n\t\t\tconst startLine = node.startPosition.row + 1\n\t\t\tconst endLine = node.endPosition.row + 1\n\t\t\tconst rangeText = sourceCode.substring(node.startIndex, node.endIndex)\n\t\t\tconst snippetHash = generateSnippetHash(filePath, startLine, endLine, rangeText)\n\n\t\t\tif (!seenHashes.has(snippetHash)) {\n\t\t\t\tseenHashes.add(snippetHash)\n\t\t\t\tconst scope = buildScopeChain(node)\n\n\t\t\t\tconst typedefNameCapture = captures.find(\n\t\t\t\t\t(c) =>\n\t\t\t\t\t\tc.name === \"name.definition.typedef\" &&\n\t\t\t\t\t\tc.node.startIndex >= node.startIndex &&\n\t\t\t\t\t\tc.node.endIndex <= node.endIndex,\n\t\t\t\t)\n\t\t\t\tconst typedefName = typedefNameCapture\n\t\t\t\t\t? sourceCode.substring(typedefNameCapture.node.startIndex, typedefNameCapture.node.endIndex)\n\t\t\t\t\t: \"\"\n\n\t\t\t\tsnippets.push({\n\t\t\t\t\ttype: SnippetType.ClassOrInterfaceOrStructOrEnum,\n\t\t\t\t\tname: typedefName,\n\t\t\t\t\trangeText,\n\t\t\t\t\tstartLine,\n\t\t\t\t\tendLine,\n\t\t\t\t\tfilePath,\n\t\t\t\t\tfileHash,\n\t\t\t\t\tscope,\n\t\t\t\t\tlanguage: CodeLanguageType.CPP,\n\t\t\t\t\tdefinition: {\n\t\t\t\t\t\tname: typedefName,\n\t\t\t\t\t\ttype: \"typedef\",\n\t\t\t\t\t},\n\t\t\t\t})\n\t\t\t}\n\t\t})\n\t}\n\n\t// \u5904\u7406 using declarations\n\tif (snippetTypes.includes(SnippetType.ClassOrInterfaceOrStructOrEnum)) {\n\t\tconst usingCaptures = captures.filter((c) => c.name === \"definition.using\")\n\n\t\tusingCaptures.forEach((capture) => {\n\t\t\tconst node = capture.node\n\t\t\tconst startLine = node.startPosition.row + 1\n\t\t\tconst endLine = node.endPosition.row + 1\n\t\t\tconst rangeText = sourceCode.substring(node.startIndex, node.endIndex)\n\t\t\tconst snippetHash = generateSnippetHash(filePath, startLine, endLine, rangeText)\n\n\t\t\tif (!seenHashes.has(snippetHash)) {\n\t\t\t\tseenHashes.add(snippetHash)\n\t\t\t\tconst scope = buildScopeChain(node)\n\n\t\t\t\tconst usingNameCapture = captures.find(\n\t\t\t\t\t(c) =>\n\t\t\t\t\t\tc.name === \"name.definition.using\" &&\n\t\t\t\t\t\tc.node.startIndex >= node.startIndex &&\n\t\t\t\t\t\tc.node.endIndex <= node.endIndex,\n\t\t\t\t)\n\t\t\t\tconst usingName = usingNameCapture\n\t\t\t\t\t? sourceCode.substring(usingNameCapture.node.startIndex, usingNameCapture.node.endIndex)\n\t\t\t\t\t: \"\"\n\n\t\t\t\tsnippets.push({\n\t\t\t\t\ttype: SnippetType.ClassOrInterfaceOrStructOrEnum,\n\t\t\t\t\tname: usingName,\n\t\t\t\t\trangeText,\n\t\t\t\t\tstartLine,\n\t\t\t\t\tendLine,\n\t\t\t\t\tfilePath,\n\t\t\t\t\tfileHash,\n\t\t\t\t\tscope,\n\t\t\t\t\tlanguage: CodeLanguageType.CPP,\n\t\t\t\t\tdefinition: {\n\t\t\t\t\t\tname: usingName,\n\t\t\t\t\t\ttype: \"using\",\n\t\t\t\t\t},\n\t\t\t\t})\n\t\t\t}\n\t\t})\n\t}\n\n\t// \u5904\u7406 global variables\n\tif (snippetTypes.includes(SnippetType.VariableOrConstant)) {\n\t\tconst variableCaptures = captures.filter((c) => c.name === \"definition.variable\")\n\n\t\tvariableCaptures.forEach((capture) => {\n\t\t\tconst node = capture.node\n\t\t\tconst startLine = node.startPosition.row + 1\n\t\t\tconst endLine = node.endPosition.row + 1\n\t\t\tconst rangeText = sourceCode.substring(node.startIndex, node.endIndex)\n\t\t\tconst snippetHash = generateSnippetHash(filePath, startLine, endLine, rangeText)\n\n\t\t\tif (!seenHashes.has(snippetHash)) {\n\t\t\t\tseenHashes.add(snippetHash)\n\t\t\t\tconst scope = buildScopeChain(node)\n\n\t\t\t\tconst variableNameCapture = captures.find(\n\t\t\t\t\t(c) =>\n\t\t\t\t\t\tc.name === \"name.definition.variable\" &&\n\t\t\t\t\t\tc.node.startIndex >= node.startIndex &&\n\t\t\t\t\t\tc.node.endIndex <= node.endIndex,\n\t\t\t\t)\n\t\t\t\tconst variableName = variableNameCapture\n\t\t\t\t\t? sourceCode.substring(variableNameCapture.node.startIndex, variableNameCapture.node.endIndex)\n\t\t\t\t\t: \"\"\n\n\t\t\t\tsnippets.push({\n\t\t\t\t\ttype: SnippetType.VariableOrConstant,\n\t\t\t\t\tname: variableName,\n\t\t\t\t\trangeText,\n\t\t\t\t\tstartLine,\n\t\t\t\t\tendLine,\n\t\t\t\t\tfilePath,\n\t\t\t\t\tfileHash,\n\t\t\t\t\tscope,\n\t\t\t\t\tlanguage: CodeLanguageType.CPP,\n\t\t\t\t\tdefinition: {\n\t\t\t\t\t\tname: variableName,\n\t\t\t\t\t\ttype: \"variable\",\n\t\t\t\t\t},\n\t\t\t\t})\n\t\t\t}\n\t\t})\n\t}\n\n\tlogger.info(`Extracted ${snippets.length} C++ snippets`)\n\treturn snippets\n}\n\n// \u8F85\u52A9\u51FD\u6570\uFF1A\u63D0\u53D6\u51FD\u6570\u53C2\u6570\nfunction extractParametersFromNode(node: Parser.SyntaxNode, sourceCode: string): ParameterInfo[] {\n\tconst parameters: ParameterInfo[] = []\n\n\t// \u904D\u5386\u53C2\u6570\u5217\u8868\u4E2D\u7684\u6BCF\u4E2A\u53C2\u6570\n\tfor (let i = 0; i < node.childCount; i++) {\n\t\tconst child = node.child(i)\n\t\tif (child && child.type === \"parameter_declaration\") {\n\t\t\tconst parameterText = sourceCode.substring(child.startIndex, child.endIndex)\n\t\t\tconst parameterName = extractParameterName(child, sourceCode)\n\n\t\t\tparameters.push({\n\t\t\t\tname: parameterName,\n\t\t\t\ttype: parameterText,\n\t\t\t})\n\t\t}\n\t}\n\n\treturn parameters\n}\n\n// \u8F85\u52A9\u51FD\u6570\uFF1A\u63D0\u53D6\u53C2\u6570\u540D\u79F0\nfunction extractParameterName(node: Parser.SyntaxNode, sourceCode: string): string {\n\t// \u67E5\u627E\u53C2\u6570\u58F0\u660E\u4E2D\u7684\u6807\u8BC6\u7B26\n\tfor (let i = 0; i < node.childCount; i++) {\n\t\tconst child = node.child(i)\n\t\tif (child && child.type === \"identifier\") {\n\t\t\treturn sourceCode.substring(child.startIndex, child.endIndex)\n\t\t}\n\t}\n\treturn \"\"\n}\n\n// \u8F85\u52A9\u51FD\u6570\uFF1A\u63D0\u53D6\u6A21\u677F\u53C2\u6570\nfunction extractTemplateParametersFromNode(node: Parser.SyntaxNode, sourceCode: string): ParameterInfo[] {\n\tconst parameters: ParameterInfo[] = []\n\n\t// \u904D\u5386\u6A21\u677F\u53C2\u6570\u5217\u8868\u4E2D\u7684\u6BCF\u4E2A\u53C2\u6570\n\tfor (let i = 0; i < node.childCount; i++) {\n\t\tconst child = node.child(i)\n\t\tif (child && (child.type === \"type_parameter_declaration\" || child.type === \"parameter_declaration\")) {\n\t\t\tconst parameterText = sourceCode.substring(child.startIndex, child.endIndex)\n\t\t\tconst parameterName = extractTemplateParameterName(child, sourceCode)\n\n\t\t\tparameters.push({\n\t\t\t\tname: parameterName,\n\t\t\t\ttype: parameterText,\n\t\t\t})\n\t\t}\n\t}\n\n\treturn parameters\n}\n\n// \u8F85\u52A9\u51FD\u6570\uFF1A\u63D0\u53D6\u6A21\u677F\u53C2\u6570\u540D\u79F0\nfunction extractTemplateParameterName(node: Parser.SyntaxNode, sourceCode: string): string {\n\t// \u67E5\u627E\u6A21\u677F\u53C2\u6570\u58F0\u660E\u4E2D\u7684\u6807\u8BC6\u7B26\n\tfor (let i = 0; i < node.childCount; i++) {\n\t\tconst child = node.child(i)\n\t\tif (child && (child.type === \"type_identifier\" || child.type === \"identifier\")) {\n\t\t\treturn sourceCode.substring(child.startIndex, child.endIndex)\n\t\t}\n\t}\n\treturn \"\"\n}\n\n// \u8F85\u52A9\u51FD\u6570\uFF1A\u63D0\u53D6\u7ED3\u6784\u4F53/\u7C7B/\u8054\u5408\u4F53\u5B57\u6BB5\nfunction extractFieldsFromContainerNode(\n\tnode: Parser.SyntaxNode,\n\tsourceCode: string,\n\tcaptures: Parser.QueryCapture[],\n): string[] {\n\tconst fields: string[] = []\n\n\t// \u67E5\u627E\u8BE5\u5BB9\u5668\u5185\u7684\u6240\u6709\u5B57\u6BB5\n\tconst fieldCaptures = captures.filter(\n\t\t(c) =>\n\t\t\tc.name === \"name.definition.field\" &&\n\t\t\tc.node.startIndex >= node.startIndex &&\n\t\t\tc.node.endIndex <= node.endIndex,\n\t)\n\n\tfieldCaptures.forEach((capture) => {\n\t\tconst fieldName = sourceCode.substring(capture.node.startIndex, capture.node.endIndex)\n\t\tfields.push(fieldName)\n\t})\n\n\treturn fields\n}\n\n// \u8F85\u52A9\u51FD\u6570\uFF1A\u63D0\u53D6\u679A\u4E3E\u503C\nfunction extractEnumeratorsFromEnumNode(\n\tnode: Parser.SyntaxNode,\n\tsourceCode: string,\n\tcaptures: Parser.QueryCapture[],\n): string[] {\n\tconst enumerators: string[] = []\n\n\t// \u67E5\u627E\u8BE5\u679A\u4E3E\u5185\u7684\u6240\u6709\u679A\u4E3E\u503C\n\tconst enumeratorCaptures = captures.filter(\n\t\t(c) =>\n\t\t\tc.name === \"name.definition.enumerator\" &&\n\t\t\tc.node.startIndex >= node.startIndex &&\n\t\t\tc.node.endIndex <= node.endIndex,\n\t)\n\n\tenumeratorCaptures.forEach((capture) => {\n\t\tconst enumeratorName = sourceCode.substring(capture.node.startIndex, capture.node.endIndex)\n\t\tenumerators.push(enumeratorName)\n\t})\n\n\treturn enumerators\n}\n\n// \u8F85\u52A9\u51FD\u6570\uFF1A\u67E5\u627E\u7236\u5BB9\u5668\nfunction findParentContainer(\n\tnode: Parser.SyntaxNode,\n\tcontainerCaptures: Array<{\n\t\tnode: Parser.SyntaxNode\n\t\tstart: number\n\t\tend: number\n\t\tname: string\n\t\tnameCap: string | null\n\t}>,\n): { node: Parser.SyntaxNode; start: number; end: number; name: string; nameCap: string | null } | null {\n\tfor (const container of containerCaptures) {\n\t\tif (container.start <= node.startIndex && node.endIndex <= container.end) {\n\t\t\treturn container\n\t\t}\n\t}\n\treturn null\n}\n\n// \u8F85\u52A9\u51FD\u6570\uFF1A\u6839\u636E\u5BB9\u5668\u7C7B\u578B\u751F\u6210\u5BF9\u5E94\u7684\u540D\u79F0capture\u540D\u79F0\nfunction getNameCaptureNameForContainer(containerCaptureName: string): string {\n\tswitch (containerCaptureName) {\n\t\tcase \"definition.class\":\n\t\t\treturn \"name.definition.class\"\n\t\tcase \"definition.struct\":\n\t\t\treturn \"name.definition.struct\"\n\t\tcase \"definition.union\":\n\t\t\treturn \"name.definition.union\"\n\t\tcase \"definition.enum\":\n\t\t\treturn \"name.definition.enum\"\n\t\tcase \"definition.template\":\n\t\t\treturn \"name.definition.template.class\" // \u9ED8\u8BA4\u67E5\u627E\u7C7B\u6A21\u677F\n\t\tdefault:\n\t\t\treturn containerCaptureName\n\t}\n}\n\n// \u8F85\u52A9\u51FD\u6570\uFF1A\u67E5\u627E\u5BB9\u5668\u7684\u540D\u79F0capture\nfunction findNameCaptureForContainer(\n\tcontainerCapture: Parser.QueryCapture,\n\tcaptures: Parser.QueryCapture[],\n\tsourceCode: string,\n): string | null {\n\tconst node = containerCapture.node\n\tconst nameCaptureName = getNameCaptureNameForContainer(containerCapture.name)\n\n\t// \u5BF9\u4E8E\u6A21\u677F\uFF0C\u53EF\u80FD\u9700\u8981\u67E5\u627E\u4E0D\u540C\u7C7B\u578B\u7684\u540D\u79F0\n\tif (containerCapture.name === \"definition.template\") {\n\t\tconst templateClassNameCapture = captures.find(\n\t\t\t(c) =>\n\t\t\t\tc.name === \"name.definition.template.class\" &&\n\t\t\t\tc.node.startIndex >= node.startIndex &&\n\t\t\t\tc.node.endIndex <= node.endIndex,\n\t\t)\n\t\tif (templateClassNameCapture) {\n\t\t\treturn sourceCode.substring(\n\t\t\t\ttemplateClassNameCapture.node.startIndex,\n\t\t\t\ttemplateClassNameCapture.node.endIndex,\n\t\t\t)\n\t\t}\n\n\t\tconst templateStructNameCapture = captures.find(\n\t\t\t(c) =>\n\t\t\t\tc.name === \"name.definition.template.struct\" &&\n\t\t\t\tc.node.startIndex >= node.startIndex &&\n\t\t\t\tc.node.endIndex <= node.endIndex,\n\t\t)\n\t\tif (templateStructNameCapture) {\n\t\t\treturn sourceCode.substring(\n\t\t\t\ttemplateStructNameCapture.node.startIndex,\n\t\t\t\ttemplateStructNameCapture.node.endIndex,\n\t\t\t)\n\t\t}\n\n\t\tconst templateFunctionNameCapture = captures.find(\n\t\t\t(c) =>\n\t\t\t\tc.name === \"name.definition.template.function\" &&\n\t\t\t\tc.node.startIndex >= node.startIndex &&\n\t\t\t\tc.node.endIndex <= node.endIndex,\n\t\t)\n\t\tif (templateFunctionNameCapture) {\n\t\t\treturn sourceCode.substring(\n\t\t\t\ttemplateFunctionNameCapture.node.startIndex,\n\t\t\t\ttemplateFunctionNameCapture.node.endIndex,\n\t\t\t)\n\t\t}\n\t}\n\n\tconst nameCapture = captures.find(\n\t\t(c) => c.name === nameCaptureName && c.node.startIndex >= node.startIndex && c.node.endIndex <= node.endIndex,\n\t)\n\n\treturn nameCapture ? sourceCode.substring(nameCapture.node.startIndex, nameCapture.node.endIndex) : null\n}\n\n// \u7528\u4E8E\u6784\u5EFA\u6982\u89C8\u7684\u51FD\u6570\nexport function buildSummaryFromSnippets(snippets: ISnippetMeta[]): any {\n\tconst summary = {\n\t\tincludes: [] as string[],\n\t\tnamespaces: [] as string[],\n\t\tclasses: [] as string[],\n\t\tstructs: [] as string[],\n\t\tunions: [] as string[],\n\t\tenums: [] as string[],\n\t\ttemplates: [] as string[],\n\t\tfunctions: [] as string[],\n\t\tmethods: [] as string[],\n\t\tconstructors: [] as string[],\n\t\tdestructors: [] as string[],\n\t\toperators: [] as string[],\n\t\tvariables: [] as string[],\n\t\ttypedefs: [] as string[],\n\t\tusings: [] as string[],\n\t}\n\n\tsnippets.forEach((snippet) => {\n\t\tswitch (snippet.type) {\n\t\t\tcase SnippetType.ImportOrInclude:\n\t\t\t\tsummary.includes.push(snippet.name)\n\t\t\t\tbreak\n\t\t\tcase SnippetType.FunctionOrMethod:\n\t\t\t\tif (snippet.definition?.type === \"function\") {\n\t\t\t\t\tsummary.functions.push(snippet.name)\n\t\t\t\t} else if (snippet.definition?.type === \"method\") {\n\t\t\t\t\tsummary.methods.push(snippet.name)\n\t\t\t\t} else if (snippet.definition?.type === \"constructor\") {\n\t\t\t\t\tsummary.constructors.push(snippet.name)\n\t\t\t\t} else if (snippet.definition?.type === \"destructor\") {\n\t\t\t\t\tsummary.destructors.push(snippet.name)\n\t\t\t\t} else if (snippet.definition?.type === \"operator\") {\n\t\t\t\t\tsummary.operators.push(snippet.name)\n\t\t\t\t} else if (snippet.definition?.type === \"template_function\") {\n\t\t\t\t\tsummary.functions.push(snippet.name)\n\t\t\t\t}\n\t\t\t\tbreak\n\t\t\tcase SnippetType.ClassOrInterfaceOrStructOrEnum:\n\t\t\t\tif (snippet.definition?.type === \"class\") {\n\t\t\t\t\tsummary.classes.push(snippet.name)\n\t\t\t\t} else if (snippet.definition?.type === \"struct\") {\n\t\t\t\t\tsummary.structs.push(snippet.name)\n\t\t\t\t} else if (snippet.definition?.type === \"union\") {\n\t\t\t\t\tsummary.unions.push(snippet.name)\n\t\t\t\t} else if (snippet.definition?.type === \"enum\") {\n\t\t\t\t\tsummary.enums.push(snippet.name)\n\t\t\t\t} else if (\n\t\t\t\t\tsnippet.definition?.type === \"template_class\" ||\n\t\t\t\t\tsnippet.definition?.type === \"template_struct\"\n\t\t\t\t) {\n\t\t\t\t\tsummary.templates.push(snippet.name)\n\t\t\t\t} else if (snippet.definition?.type === \"namespace\") {\n\t\t\t\t\tsummary.namespaces.push(snippet.name)\n\t\t\t\t} else if (snippet.definition?.type === \"typedef\") {\n\t\t\t\t\tsummary.typedefs.push(snippet.name)\n\t\t\t\t} else if (snippet.definition?.type === \"using\") {\n\t\t\t\t\tsummary.usings.push(snippet.name)\n\t\t\t\t}\n\t\t\t\tbreak\n\t\t\tcase SnippetType.VariableOrConstant:\n\t\t\t\tsummary.variables.push(snippet.name)\n\t\t\t\tbreak\n\t\t}\n\t})\n\n\treturn summary\n}\n\n// \u7528\u4E8E\u683C\u5F0F\u5316\u6982\u89C8\u6587\u672C\u7684\u51FD\u6570\nexport function formatOutlineText(summary: any): string {\n\tlet outline = \"\"\n\n\tif (summary.includes.length > 0) {\n\t\toutline += `Includes: ${summary.includes.join(\", \")}\\n`\n\t}\n\n\tif (summary.namespaces.length > 0) {\n\t\toutline += `Namespaces: ${summary.namespaces.join(\", \")}\\n`\n\t}\n\n\tif (summary.classes.length > 0) {\n\t\toutline += `Classes: ${summary.classes.join(\", \")}\\n`\n\t}\n\n\tif (summary.structs.length > 0) {\n\t\toutline += `Structs: ${summary.structs.join(\", \")}\\n`\n\t}\n\n\tif (summary.unions.length > 0) {\n\t\toutline += `Unions: ${summary.unions.join(\", \")}\\n`\n\t}\n\n\tif (summary.enums.length > 0) {\n\t\toutline += `Enums: ${summary.enums.join(\", \")}\\n`\n\t}\n\n\tif (summary.templates.length > 0) {\n\t\toutline += `Templates: ${summary.templates.join(\", \")}\\n`\n\t}\n\n\tif (summary.functions.length > 0) {\n\t\toutline += `Functions: ${summary.functions.join(\", \")}\\n`\n\t}\n\n\tif (summary.methods.length > 0) {\n\t\toutline += `Methods: ${summary.methods.join(\", \")}\\n`\n\t}\n\n\tif (summary.constructors.length > 0) {\n\t\toutline += `Constructors: ${summary.constructors.join(\", \")}\\n`\n\t}\n\n\tif (summary.destructors.length > 0) {\n\t\toutline += `Destructors: ${summary.destructors.join(\", \")}\\n`\n\t}\n\n\tif (summary.operators.length > 0) {\n\t\toutline += `Operators: ${summary.operators.join(\", \")}\\n`\n\t}\n\n\tif (summary.variables.length > 0) {\n\t\toutline += `Variables: ${summary.variables.join(\", \")}\\n`\n\t}\n\n\tif (summary.typedefs.length > 0) {\n\t\toutline += `Typedefs: ${summary.typedefs.join(\", \")}\\n`\n\t}\n\n\tif (summary.usings.length > 0) {\n\t\toutline += `Usings: ${summary.usings.join(\", \")}\\n`\n\t}\n\n\treturn outline\n}\n", "import { CodeLanguageType, SnippetType, ISnippetMeta } from \"../types\"\nimport * as go from \"./go\"\nimport * as python from \"./python\"\nimport * as java from \"./java\"\nimport * as javascript from \"./javascript\"\nimport * as jsx from \"./jsx\"\nimport * as typescript from \"./typescript\"\nimport * as tsx from \"./tsx\"\nimport * as swift from \"./swift\"\nimport * as css from \"./css\"\nimport * as html from \"./html\"\nimport * as kotlin from \"./kotlin\"\nimport * as php from \"./php\"\nimport * as rust from \"./rust\"\nimport * as c from \"./c\"\nimport * as cpp from \"./cpp\"\nimport * as general from \"./general\"\n\nimport Parser from \"web-tree-sitter\"\n\nexport const extractSnippetsFromCaptures: Record<\n\tCodeLanguageType,\n\t(\n\t\tcaptures: Parser.QueryCapture[],\n\t\tsourceCode: string,\n\t\tfilePath: string,\n\t\tfileHash: string,\n\t\tsnippetTypes: SnippetType[],\n\t\toptions: { maxSnippetLines: number; minSnippetLines: number },\n\t) => Promise\n> = {\n\t[CodeLanguageType.Go]: go.extractSnippetsFromCapturesForGo,\n\t[CodeLanguageType.Python]: python.extractSnippetsFromCapturesForPython,\n\t[CodeLanguageType.Java]: java.extractSnippetsFromCapturesForJava,\n\t[CodeLanguageType.JavaScript]: javascript.extractSnippetsFromCapturesForJavaScript,\n\t[CodeLanguageType.JSX]: jsx.extractSnippetsFromCapturesForJSX,\n\t[CodeLanguageType.TypeScript]: typescript.extractSnippetsFromCapturesForTypeScript,\n\t[CodeLanguageType.TSX]: tsx.extractSnippetsFromCapturesForTSX,\n\t[CodeLanguageType.Swift]: swift.extractSnippetsFromCapturesForSwift,\n\t[CodeLanguageType.CSS]: css.extractSnippetsFromCapturesForCSS,\n\t[CodeLanguageType.HTML]: html.extractSnippetsFromCapturesForHTML,\n\t[CodeLanguageType.Kotlin]: kotlin.extractSnippetsFromCapturesForKotlin,\n\t[CodeLanguageType.PHP]: php.extractSnippetsFromCapturesForPHP,\n\t[CodeLanguageType.Rust]: rust.extractSnippetsFromCapturesForRust,\n\t[CodeLanguageType.C]: c.extractSnippetsFromCapturesForC,\n\t[CodeLanguageType.CPP]: cpp.extractSnippetsFromCapturesForCPP,\n\t[CodeLanguageType.Unknown]: general.extractSnippetsFromCapturesForGeneral,\n}\n\nexport const generateOverViewFromSnippets: Record string> = {\n\t[CodeLanguageType.Go]: (snippets: ISnippetMeta[]) => {\n\t\treturn go.formatOutlineText(go.buildSummaryFromSnippets(snippets))\n\t},\n\t[CodeLanguageType.Python]: (snippets: ISnippetMeta[]) => {\n\t\treturn python.formatOutlineText(python.buildSummaryFromSnippets(snippets))\n\t},\n\t[CodeLanguageType.Java]: (snippets: ISnippetMeta[]) => {\n\t\treturn java.formatOutlineText(java.buildSummaryFromSnippets(snippets))\n\t},\n\t[CodeLanguageType.JavaScript]: (snippets: ISnippetMeta[]) => {\n\t\treturn \"\"\n\t},\n\t[CodeLanguageType.JSX]: (snippets: ISnippetMeta[]) => {\n\t\treturn jsx.formatOutlineText(jsx.buildSummaryFromSnippets(snippets))\n\t},\n\t[CodeLanguageType.TypeScript]: (snippets: ISnippetMeta[]) => {\n\t\treturn typescript.formatOutlineText(typescript.buildSummaryFromSnippets(snippets))\n\t},\n\t[CodeLanguageType.TSX]: (snippets: ISnippetMeta[]) => {\n\t\treturn tsx.formatOutlineText(tsx.buildSummaryFromSnippets(snippets))\n\t},\n\t[CodeLanguageType.Swift]: (snippets: ISnippetMeta[]) => {\n\t\treturn swift.formatOutlineText(swift.buildSummaryFromSnippets(snippets))\n\t},\n\t[CodeLanguageType.CSS]: (snippets: ISnippetMeta[]) => {\n\t\treturn css.formatOutlineText(css.buildSummaryFromSnippets(snippets))\n\t},\n\t[CodeLanguageType.HTML]: (snippets: ISnippetMeta[]) => {\n\t\treturn html.formatOutlineText(html.buildSummaryFromSnippets(snippets))\n\t},\n\t[CodeLanguageType.Kotlin]: (snippets: ISnippetMeta[]) => {\n\t\treturn kotlin.formatOutlineText(kotlin.buildSummaryFromSnippets(snippets))\n\t},\n\t[CodeLanguageType.PHP]: (snippets: ISnippetMeta[]) => {\n\t\treturn php.formatOutlineText(php.buildSummaryFromSnippets(snippets))\n\t},\n\t[CodeLanguageType.Rust]: (snippets: ISnippetMeta[]) => {\n\t\treturn rust.formatOutlineText(rust.buildSummaryFromSnippets(snippets))\n\t},\n\t[CodeLanguageType.C]: (snippets: ISnippetMeta[]) => {\n\t\treturn c.formatOutlineText(c.buildSummaryFromSnippets(snippets))\n\t},\n\t[CodeLanguageType.CPP]: (snippets: ISnippetMeta[]) => {\n\t\treturn cpp.formatOutlineText(cpp.buildSummaryFromSnippets(snippets))\n\t},\n\t[CodeLanguageType.Unknown]: (snippets: ISnippetMeta[]) => {\n\t\treturn \"\"\n\t},\n}\n", "/**\n * Go \u8BED\u8A00\u51FD\u6570\u8C03\u7528\u67E5\u8BE2 - \u4EC5\u51FD\u6570\u8C03\u7528\n */\nexport default `(call_expression\n function: (identifier) @function.call.direct)\n\n(call_expression\n function: (selector_expression\n operand: (identifier) @method.call.receiver\n field: (field_identifier) @method.call.name))`\n", "/**\n * TypeScript/JavaScript \u8BED\u8A00\u51FD\u6570\u8C03\u7528\u67E5\u8BE2 - \u51FD\u6570\u8C03\u7528\u5206\u6790\n */\nexport default `\n; \u76F4\u63A5\u51FD\u6570\u8C03\u7528 - function()\n(call_expression\n function: (identifier) @function.call.direct)\n\n; \u65B9\u6CD5\u8C03\u7528 - object.method()\n(call_expression\n function: (member_expression\n object: (identifier) @method.call.receiver\n property: (property_identifier) @method.call.name)\n (#not-match? @method.call.receiver \"^[A-Z]\"))\n\n; \u94FE\u5F0F\u65B9\u6CD5\u8C03\u7528 - object.method1().method2()\n(call_expression\n function: (member_expression\n object: (call_expression)\n property: (property_identifier) @method.call.chain))\n\n; \u9759\u6001\u65B9\u6CD5\u8C03\u7528 - Class.staticMethod() (\u9996\u5B57\u6BCD\u5927\u5199\u7684\u6807\u8BC6\u7B26)\n(call_expression\n function: (member_expression\n object: (identifier) @static.call.class\n property: (property_identifier) @static.call.method)\n (#match? @static.call.class \"^[A-Z]\"))\n\n; \u547D\u540D\u7A7A\u95F4/\u6A21\u5757\u8C03\u7528 - namespace.function()\n(call_expression\n function: (member_expression\n object: (identifier) @namespace.call.name\n property: (property_identifier) @namespace.call.function)\n (#match? @namespace.call.name \"^[A-Z]\")\n (#not-match? @namespace.call.function \"^(constructor|new|create|get|set|add|remove|update|delete)$\"))\n\n; \u5D4C\u5957\u5C5E\u6027\u8C03\u7528 - object.nested.method()\n(call_expression\n function: (member_expression\n object: (member_expression\n object: (identifier) @nested.call.root\n property: (property_identifier) @nested.call.intermediate)\n property: (property_identifier) @nested.call.method))\n\n; this \u65B9\u6CD5\u8C03\u7528 - this.method()\n(call_expression\n function: (member_expression\n object: (this) @this.call.receiver\n property: (property_identifier) @this.call.method))\n\n; super \u65B9\u6CD5\u8C03\u7528 - super.method()\n(call_expression\n function: (member_expression\n object: (super) @super.call.receiver\n property: (property_identifier) @super.call.method))\n\n; \u7BAD\u5934\u51FD\u6570\u8C03\u7528 - (() => {})()\n(call_expression\n function: (arrow_function) @arrow.call.function)\n\n; \u51FD\u6570\u8868\u8FBE\u5F0F\u8C03\u7528 - (function() {})()\n(call_expression\n function: (function_expression) @function.call.expression)\n\n; \u6570\u7EC4\u65B9\u6CD5\u8C03\u7528 - array.map(), array.filter()\n(call_expression\n function: (member_expression\n object: (identifier) @array.call.object\n property: (property_identifier) @array.call.method)\n (#match? @array.call.method \"^(map|filter|reduce|forEach|find|some|every|sort|push|pop|shift|unshift|slice|splice|concat|join|indexOf|includes)$\"))\n\n; Promise \u65B9\u6CD5\u8C03\u7528 - promise.then(), promise.catch() (\u660E\u786E\u7684Promise\u65B9\u6CD5)\n(call_expression\n function: (member_expression\n object: (identifier) @promise.call.object\n property: (property_identifier) @promise.call.method)\n (#match? @promise.call.method \"^(then|catch|finally)$\"))\n\n; \u53EF\u9009\u94FE\u8C03\u7528 - object?.method?.()\n(call_expression\n function: (member_expression\n object: (identifier) @optional.call.receiver\n property: (property_identifier) @optional.call.method))\n\n; \u6784\u9020\u51FD\u6570\u8C03\u7528 - new Constructor()\n(new_expression\n constructor: (identifier) @constructor.call.name)\n\n; \u6CDB\u578B\u51FD\u6570\u8C03\u7528 - genericFunction()\n(call_expression\n function: (identifier) @generic.call.function\n type_arguments: (type_arguments))\n\n; \u6A21\u677F\u5B57\u7B26\u4E32\u4E2D\u7684\u8868\u8FBE\u5F0F\u8C03\u7528\n(template_substitution\n (call_expression\n function: (identifier) @template.call.function))\n\n; await \u8868\u8FBE\u5F0F\u4E2D\u7684\u51FD\u6570\u8C03\u7528\n(await_expression\n (call_expression\n function: (identifier) @await.call.function))\n\n; \u5F02\u6B65\u65B9\u6CD5\u8C03\u7528\n(await_expression\n (call_expression\n function: (member_expression\n object: (identifier) @async.call.receiver\n property: (property_identifier) @async.call.method)))\n`\n", "/**\n * JavaScript \u8BED\u8A00\u51FD\u6570\u8C03\u7528\u67E5\u8BE2 - \u51FD\u6570\u8C03\u7528\u5206\u6790\n */\nexport default `\n; \u76F4\u63A5\u51FD\u6570\u8C03\u7528 - function()\n(call_expression\n function: (identifier) @function.call.direct)\n\n; \u65B9\u6CD5\u8C03\u7528 - object.method()\n(call_expression\n function: (member_expression\n object: (identifier) @method.call.receiver\n property: (property_identifier) @method.call.name)\n (#not-match? @method.call.receiver \"^[A-Z]\"))\n\n; \u94FE\u5F0F\u65B9\u6CD5\u8C03\u7528 - object.method1().method2()\n(call_expression\n function: (member_expression\n object: (call_expression)\n property: (property_identifier) @method.call.chain))\n\n; \u9759\u6001\u65B9\u6CD5\u8C03\u7528 - Class.staticMethod() (\u9996\u5B57\u6BCD\u5927\u5199\u7684\u6807\u8BC6\u7B26)\n(call_expression\n function: (member_expression\n object: (identifier) @static.call.class\n property: (property_identifier) @static.call.method)\n (#match? @static.call.class \"^[A-Z]\"))\n\n; \u547D\u540D\u7A7A\u95F4/\u6A21\u5757\u8C03\u7528 - namespace.function()\n(call_expression\n function: (member_expression\n object: (identifier) @namespace.call.name\n property: (property_identifier) @namespace.call.function)\n (#match? @namespace.call.name \"^[A-Z]\")\n (#not-match? @namespace.call.function \"^(constructor|new|create|get|set|add|remove|update|delete)$\"))\n\n; \u5D4C\u5957\u5C5E\u6027\u8C03\u7528 - object.nested.method()\n(call_expression\n function: (member_expression\n object: (member_expression\n object: (identifier) @nested.call.root\n property: (property_identifier) @nested.call.intermediate)\n property: (property_identifier) @nested.call.method))\n\n; this \u65B9\u6CD5\u8C03\u7528 - this.method()\n(call_expression\n function: (member_expression\n object: (this) @this.call.receiver\n property: (property_identifier) @this.call.method))\n\n; super \u65B9\u6CD5\u8C03\u7528 - super.method()\n(call_expression\n function: (member_expression\n object: (super) @super.call.receiver\n property: (property_identifier) @super.call.method))\n\n; \u7BAD\u5934\u51FD\u6570\u8C03\u7528 - (() => {})()\n(call_expression\n function: (arrow_function) @arrow.call.function)\n\n; \u51FD\u6570\u8868\u8FBE\u5F0F\u8C03\u7528 - (function() {})()\n(call_expression\n function: (function_expression) @function.call.expression)\n\n; \u6570\u7EC4\u65B9\u6CD5\u8C03\u7528 - array.map(), array.filter()\n(call_expression\n function: (member_expression\n object: (identifier) @array.call.object\n property: (property_identifier) @array.call.method)\n (#match? @array.call.method \"^(map|filter|reduce|forEach|find|some|every|sort|push|pop|shift|unshift|slice|splice|concat|join|indexOf|includes)$\"))\n\n; Promise \u65B9\u6CD5\u8C03\u7528 - promise.then(), promise.catch() (\u660E\u786E\u7684Promise\u65B9\u6CD5)\n(call_expression\n function: (member_expression\n object: (identifier) @promise.call.object\n property: (property_identifier) @promise.call.method)\n (#match? @promise.call.method \"^(then|catch|finally)$\"))\n\n; \u53EF\u9009\u94FE\u8C03\u7528 - object?.method?.()\n(call_expression\n function: (member_expression\n object: (identifier) @optional.call.receiver\n property: (property_identifier) @optional.call.method))\n\n; \u6784\u9020\u51FD\u6570\u8C03\u7528 - new Constructor()\n(new_expression\n constructor: (identifier) @constructor.call.name)\n\n; \u6A21\u677F\u5B57\u7B26\u4E32\u4E2D\u7684\u8868\u8FBE\u5F0F\u8C03\u7528\n(template_substitution\n (call_expression\n function: (identifier) @template.call.function))\n\n; await \u8868\u8FBE\u5F0F\u4E2D\u7684\u51FD\u6570\u8C03\u7528\n(await_expression\n (call_expression\n function: (identifier) @await.call.function))\n\n; \u5F02\u6B65\u65B9\u6CD5\u8C03\u7528\n(await_expression\n (call_expression\n function: (member_expression\n object: (identifier) @async.call.receiver\n property: (property_identifier) @async.call.method)))\n`\n", "/**\n * Java \u8BED\u8A00\u51FD\u6570\u8C03\u7528\u67E5\u8BE2 - \u51FD\u6570\u8C03\u7528\u5206\u6790\n */\nexport default `\n; \u76F4\u63A5\u65B9\u6CD5\u8C03\u7528 - method()\n(method_invocation\n name: (identifier) @method.call.direct)\n\n; \u5BF9\u8C61\u65B9\u6CD5\u8C03\u7528 - object.method()\n(method_invocation\n object: (identifier) @method.call.receiver\n name: (identifier) @method.call.name)\n\n; \u94FE\u5F0F\u65B9\u6CD5\u8C03\u7528 - object.method1().method2()\n(method_invocation\n object: (method_invocation)\n name: (identifier) @method.call.chain)\n\n; \u9759\u6001\u65B9\u6CD5\u8C03\u7528 - Class.staticMethod()\n(method_invocation\n object: (identifier) @static.call.class\n name: (identifier) @static.call.method\n (#match? @static.call.class \"^[A-Z]\"))\n\n; this \u65B9\u6CD5\u8C03\u7528 - this.method()\n(method_invocation\n object: (this) @this.call.receiver\n name: (identifier) @this.call.method)\n\n; super \u65B9\u6CD5\u8C03\u7528 - super.method()\n(method_invocation\n object: (super) @super.call.receiver\n name: (identifier) @super.call.method)\n\n; \u6784\u9020\u51FD\u6570\u8C03\u7528 - new Constructor()\n(object_creation_expression\n type: (type_identifier) @constructor.call.name)\n`\n", "/**\n * Python \u8BED\u8A00\u51FD\u6570\u8C03\u7528\u67E5\u8BE2 - \u51FD\u6570\u8C03\u7528\u5206\u6790\n */\nexport default `\n; \u76F4\u63A5\u51FD\u6570\u8C03\u7528 - function()\n(call\n function: (identifier) @function.call.direct)\n\n; \u65B9\u6CD5\u8C03\u7528 - object.method()\n(call\n function: (attribute\n object: (identifier) @method.call.receiver\n attribute: (identifier) @method.call.name))\n\n; \u7C7B\u65B9\u6CD5\u8C03\u7528 - ClassName.method() (\u9996\u5B57\u6BCD\u5927\u5199)\n(call\n function: (attribute\n object: (identifier) @class.call.name\n attribute: (identifier) @class.call.method)\n (#match? @class.call.name \"^[A-Z]\"))\n\n; \u94FE\u5F0F\u65B9\u6CD5\u8C03\u7528 - obj.method1().method2()\n(call\n function: (attribute\n object: (call)\n attribute: (identifier) @method.call.chain))\n\n; self\u65B9\u6CD5\u8C03\u7528 - self.method()\n(call\n function: (attribute\n object: (identifier) @self.call.receiver\n attribute: (identifier) @self.call.method)\n (#eq? @self.call.receiver \"self\"))\n\n; super\u65B9\u6CD5\u8C03\u7528 - super().method()\n(call\n function: (attribute\n object: (call\n function: (identifier) @super.call.function)\n attribute: (identifier) @super.call.method)\n (#eq? @super.call.function \"super\"))\n\n; \u5F02\u6B65\u51FD\u6570\u8C03\u7528 - await function()\n(await\n (call\n function: (identifier) @async.call.function))\n\n; \u5F02\u6B65\u65B9\u6CD5\u8C03\u7528 - await obj.method()\n(await\n (call\n function: (attribute\n object: (identifier) @async.call.receiver\n attribute: (identifier) @async.call.method)))\n\n; \u88C5\u9970\u5668\u51FD\u6570\u8C03\u7528 - @decorator\n(decorator\n (identifier) @decorator.call.function)\n\n; \u88C5\u9970\u5668\u65B9\u6CD5\u8C03\u7528 - @obj.decorator\n(decorator\n (attribute\n object: (identifier) @decorator.call.receiver\n attribute: (identifier) @decorator.call.method))\n\n; \u5217\u8868\u63A8\u5BFC\u5F0F\u4E2D\u7684\u51FD\u6570\u8C03\u7528\n(list_comprehension\n (call\n function: (identifier) @comprehension.call.function))\n\n; \u5217\u8868\u63A8\u5BFC\u5F0F\u4E2D\u7684\u65B9\u6CD5\u8C03\u7528\n(list_comprehension\n (call\n function: (attribute\n object: (identifier) @comprehension.call.receiver\n attribute: (identifier) @comprehension.call.method)))\n\n; \u751F\u6210\u5668\u8868\u8FBE\u5F0F\u4E2D\u7684\u51FD\u6570\u8C03\u7528\n(generator_expression\n (call\n function: (identifier) @generator.call.function))\n\n; \u751F\u6210\u5668\u8868\u8FBE\u5F0F\u4E2D\u7684\u65B9\u6CD5\u8C03\u7528\n(generator_expression\n (call\n function: (attribute\n object: (identifier) @generator.call.receiver\n attribute: (identifier) @generator.call.method)))\n\n; Lambda \u8868\u8FBE\u5F0F\u4E2D\u7684\u51FD\u6570\u8C03\u7528\n(lambda\n (call\n function: (identifier) @lambda.call.function))\n\n; Lambda \u8868\u8FBE\u5F0F\u4E2D\u7684\u65B9\u6CD5\u8C03\u7528\n(lambda\n (call\n function: (attribute\n object: (identifier) @lambda.call.receiver\n attribute: (identifier) @lambda.call.method)))\n\n; \u5D4C\u5957\u5C5E\u6027\u8C03\u7528 - obj.attr.method()\n(call\n function: (attribute\n object: (attribute\n object: (identifier) @nested.call.root\n attribute: (identifier) @nested.call.intermediate)\n attribute: (identifier) @nested.call.method))\n\n; \u51FD\u6570\u4F5C\u4E3A\u53C2\u6570\u7684\u8C03\u7528 - func(other_func)\n(call\n function: (identifier) @function.call.direct\n arguments: (argument_list\n (identifier) @function.call.argument))\n\n; \u65B9\u6CD5\u4F5C\u4E3A\u53C2\u6570\u7684\u8C03\u7528 - func(obj.method)\n(call\n function: (identifier) @function.call.direct\n arguments: (argument_list\n (attribute\n object: (identifier) @method.call.receiver\n attribute: (identifier) @method.call.name)))\n`\n", "/**\n * JSX \u8BED\u8A00\u51FD\u6570\u8C03\u7528\u67E5\u8BE2 - React \u7279\u5B9A\u7684\u51FD\u6570\u8C03\u7528\u5206\u6790\n * \u57FA\u4E8E JavaScript/TypeScript \u8BED\u6CD5\u4F46\u9488\u5BF9 React/JSX \u8FDB\u884C\u4F18\u5316\n * \u4F7F\u7528 TypeScript tree-sitter \u517C\u5BB9\u7684\u8282\u70B9\u7C7B\u578B\uFF08\u4E0D\u5305\u542BJSX\u7279\u5B9A\u8282\u70B9\uFF09\n * \u67E5\u8BE2\u6309\u4F18\u5148\u7EA7\u6392\u5E8F\uFF0C\u66F4\u5177\u4F53\u7684\u67E5\u8BE2\u5728\u524D\u9762\n */\nexport default `\n; === React\u7279\u5B9A\u67E5\u8BE2\uFF08\u4F18\u5148\u7EA7\u6700\u9AD8\uFF09===\n\n; \u9AD8\u9636\u7EC4\u4EF6 HOC \u8C03\u7528 - withRouter(Component), memo(Component) - \u5FC5\u987B\u5728\u76F4\u63A5\u51FD\u6570\u8C03\u7528\u4E4B\u524D\n(call_expression\n function: (identifier) @hoc.call.name\n arguments: (arguments\n (identifier) @hoc.call.component)\n (#match? @hoc.call.name \"^(with[A-Z]|connect|memo|forwardRef)\"))\n\n; React.createElement \u8C03\u7528 - \u5FC5\u987B\u5728\u5176\u4ED6\u65B9\u6CD5\u8C03\u7528\u4E4B\u524D\n(call_expression\n function: (member_expression\n object: (identifier) @react.create.namespace\n property: (property_identifier) @react.create.method)\n (#eq? @react.create.namespace \"React\")\n (#eq? @react.create.method \"createElement\"))\n\n; State \u76F8\u5173 hooks - useState, useReducer\n(call_expression\n function: (identifier) @state.hook.call\n (#match? @state.hook.call \"^(useState|useReducer)$\"))\n\n; Effect \u76F8\u5173 hooks - useEffect, useLayoutEffect\n(call_expression\n function: (identifier) @effect.hook.call\n (#match? @effect.hook.call \"^(useEffect|useLayoutEffect|useInsertionEffect)$\"))\n\n; Memo \u76F8\u5173 hooks - useMemo, useCallback\n(call_expression\n function: (identifier) @memo.hook.call\n (#match? @memo.hook.call \"^(useMemo|useCallback)$\"))\n\n; Ref \u8C03\u7528 - useRef, createRef\n(call_expression\n function: (identifier) @ref.hook.call\n (#match? @ref.hook.call \"^(useRef|createRef)$\"))\n\n; Context \u8C03\u7528 - useContext(ThemeContext)\n(call_expression\n function: (identifier) @context.hook.call\n (#eq? @context.hook.call \"useContext\"))\n\n; \u5176\u4ED6 React Hooks \u8C03\u7528 - \u4E0D\u5728\u4E0A\u8FF0\u7279\u5B9A\u5206\u7C7B\u4E2D\u7684hooks\n(call_expression\n function: (identifier) @react.hook.call\n (#match? @react.hook.call \"^use[A-Z]\")\n (#not-match? @react.hook.call \"^(useState|useReducer|useEffect|useLayoutEffect|useInsertionEffect|useMemo|useCallback|useRef|createRef|useContext)$\"))\n\n; Event handlers \u5728\u8C03\u7528\u8868\u8FBE\u5F0F\u4E2D - handleClick()\n(call_expression\n function: (identifier) @event.handler.function\n (#match? @event.handler.function \"^handle[A-Z]\"))\n\n; === \u5F02\u6B65\u8C03\u7528\uFF08\u4F18\u5148\u7EA7\u8F83\u9AD8\uFF09===\n\n; await \u8868\u8FBE\u5F0F\u4E2D\u7684\u51FD\u6570\u8C03\u7528\n(await_expression\n (call_expression\n function: (identifier) @await.call.function))\n\n; \u5F02\u6B65\u65B9\u6CD5\u8C03\u7528\n(await_expression\n (call_expression\n function: (member_expression\n object: (identifier) @async.call.receiver\n property: (property_identifier) @async.call.method)))\n\n; === \u7279\u5B9A\u65B9\u6CD5\u8C03\u7528\uFF08\u4F18\u5148\u7EA7\u9AD8\u4E8E\u901A\u7528\u65B9\u6CD5\u8C03\u7528\uFF09===\n\n; Promise \u65B9\u6CD5\u8C03\u7528 - promise.then(), promise.catch()\n(call_expression\n function: (member_expression\n object: (identifier) @promise.call.object\n property: (property_identifier) @promise.call.method)\n (#match? @promise.call.method \"^(then|catch|finally)$\"))\n\n; \u6570\u7EC4\u65B9\u6CD5\u8C03\u7528 - array.map(), array.filter()\n(call_expression\n function: (member_expression\n object: (identifier) @array.call.object\n property: (property_identifier) @array.call.method)\n (#match? @array.call.method \"^(map|filter|reduce|forEach|find|some|every|sort|push|pop|shift|unshift|slice|splice|concat|join|indexOf|includes)$\"))\n\n; === \u6784\u9020\u51FD\u6570\u548C\u7C7B\u8C03\u7528 ===\n\n; \u6784\u9020\u51FD\u6570\u8C03\u7528 - new Constructor()\n(new_expression\n constructor: (identifier) @constructor.call.name)\n\n; \u9759\u6001\u65B9\u6CD5\u8C03\u7528 - Class.staticMethod() (\u9996\u5B57\u6BCD\u5927\u5199\u7684\u6807\u8BC6\u7B26)\n(call_expression\n function: (member_expression\n object: (identifier) @static.call.class\n property: (property_identifier) @static.call.method)\n (#match? @static.call.class \"^[A-Z]\"))\n\n; === \u5BF9\u8C61\u65B9\u6CD5\u8C03\u7528 ===\n\n; this \u65B9\u6CD5\u8C03\u7528 - this.method()\n(call_expression\n function: (member_expression\n object: (this) @this.call.receiver\n property: (property_identifier) @this.call.method))\n\n; super \u65B9\u6CD5\u8C03\u7528 - super.method()\n(call_expression\n function: (member_expression\n object: (super) @super.call.receiver\n property: (property_identifier) @super.call.method))\n\n; \u53EF\u9009\u94FE\u8C03\u7528 - object?.method?.()\n(call_expression\n function: (member_expression\n object: (identifier) @optional.call.receiver\n property: (property_identifier) @optional.call.method))\n\n; \u94FE\u5F0F\u65B9\u6CD5\u8C03\u7528 - object.method1().method2()\n(call_expression\n function: (member_expression\n object: (call_expression)\n property: (property_identifier) @method.call.chain))\n\n; \u5D4C\u5957\u5C5E\u6027\u8C03\u7528 - object.nested.method()\n(call_expression\n function: (member_expression\n object: (member_expression\n object: (identifier) @nested.call.root\n property: (property_identifier) @nested.call.intermediate)\n property: (property_identifier) @nested.call.method))\n\n; \u65B9\u6CD5\u8C03\u7528 - object.method()\n(call_expression\n function: (member_expression\n object: (identifier) @method.call.receiver\n property: (property_identifier) @method.call.name)\n (#not-match? @method.call.receiver \"^[A-Z]\"))\n\n; === \u547D\u540D\u7A7A\u95F4\u8C03\u7528 ===\n\n; \u547D\u540D\u7A7A\u95F4/\u6A21\u5757\u8C03\u7528 - namespace.function()\n(call_expression\n function: (member_expression\n object: (identifier) @namespace.call.name\n property: (property_identifier) @namespace.call.function)\n (#match? @namespace.call.name \"^[A-Z]\")\n (#not-match? @namespace.call.function \"^(constructor|new|create|get|set|add|remove|update|delete)$\"))\n\n; === \u7279\u6B8A\u51FD\u6570\u8C03\u7528 ===\n\n; \u7BAD\u5934\u51FD\u6570\u8C03\u7528 - (() => {})()\n(call_expression\n function: (arrow_function) @arrow.call.function)\n\n; \u51FD\u6570\u8868\u8FBE\u5F0F\u8C03\u7528 - (function() {})()\n(call_expression\n function: (function_expression) @function.call.expression)\n\n; \u6A21\u677F\u5B57\u7B26\u4E32\u4E2D\u7684\u8868\u8FBE\u5F0F\u8C03\u7528\n(template_substitution\n (call_expression\n function: (identifier) @template.call.function))\n\n; === \u901A\u7528\u76F4\u63A5\u51FD\u6570\u8C03\u7528\uFF08\u4F18\u5148\u7EA7\u6700\u4F4E\uFF09===\n\n; \u76F4\u63A5\u51FD\u6570\u8C03\u7528 - function()\n(call_expression\n function: (identifier) @function.call.direct)\n`\n", "/**\n * TSX \u8BED\u8A00\u51FD\u6570\u8C03\u7528\u67E5\u8BE2 - React + TypeScript \u7279\u5B9A\u7684\u51FD\u6570\u8C03\u7528\u5206\u6790\n * \u57FA\u4E8E JSX \u67E5\u8BE2\u4F46\u9488\u5BF9 TypeScript \u7279\u6027\u8FDB\u884C\u4F18\u5316\n * \u4F7F\u7528 TypeScript tree-sitter \u517C\u5BB9\u7684\u8282\u70B9\u7C7B\u578B\uFF08\u5305\u542BTSX\u7279\u5B9A\u8282\u70B9\uFF09\n * \u67E5\u8BE2\u6309\u4F18\u5148\u7EA7\u6392\u5E8F\uFF0C\u66F4\u5177\u4F53\u7684\u67E5\u8BE2\u5728\u524D\u9762\n */\nexport default `\n; === React\u7279\u5B9A\u67E5\u8BE2\uFF08\u4F18\u5148\u7EA7\u6700\u9AD8\uFF09===\n\n; \u9AD8\u9636\u7EC4\u4EF6 HOC \u8C03\u7528 - withRouter(Component), memo(Component) - \u5FC5\u987B\u5728\u76F4\u63A5\u51FD\u6570\u8C03\u7528\u4E4B\u524D\n(call_expression\n function: (identifier) @hoc.call.name\n arguments: (arguments\n (identifier) @hoc.call.component)\n (#match? @hoc.call.name \"^(with[A-Z]|connect|memo|forwardRef)\"))\n\n; React.createElement \u8C03\u7528 - \u5FC5\u987B\u5728\u5176\u4ED6\u65B9\u6CD5\u8C03\u7528\u4E4B\u524D\n(call_expression\n function: (member_expression\n object: (identifier) @react.create.namespace\n property: (property_identifier) @react.create.method)\n (#eq? @react.create.namespace \"React\")\n (#eq? @react.create.method \"createElement\"))\n\n; State \u76F8\u5173 hooks - useState, useReducer\n(call_expression\n function: (identifier) @state.hook.call\n (#match? @state.hook.call \"^(useState|useReducer)$\"))\n\n; Effect \u76F8\u5173 hooks - useEffect, useLayoutEffect\n(call_expression\n function: (identifier) @effect.hook.call\n (#match? @effect.hook.call \"^(useEffect|useLayoutEffect|useInsertionEffect)$\"))\n\n; Memo \u76F8\u5173 hooks - useMemo, useCallback\n(call_expression\n function: (identifier) @memo.hook.call\n (#match? @memo.hook.call \"^(useMemo|useCallback)$\"))\n\n; Ref \u8C03\u7528 - useRef, createRef\n(call_expression\n function: (identifier) @ref.hook.call\n (#match? @ref.hook.call \"^(useRef|createRef)$\"))\n\n; Context \u8C03\u7528 - useContext(ThemeContext)\n(call_expression\n function: (identifier) @context.hook.call\n (#eq? @context.hook.call \"useContext\"))\n\n; \u5176\u4ED6 React Hooks \u8C03\u7528 - \u4E0D\u5728\u4E0A\u8FF0\u7279\u5B9A\u5206\u7C7B\u4E2D\u7684hooks\n(call_expression\n function: (identifier) @react.hook.call\n (#match? @react.hook.call \"^use[A-Z]\")\n (#not-match? @react.hook.call \"^(useState|useReducer|useEffect|useLayoutEffect|useInsertionEffect|useMemo|useCallback|useRef|createRef|useContext)$\"))\n\n; Event handlers \u5728\u8C03\u7528\u8868\u8FBE\u5F0F\u4E2D - handleClick()\n(call_expression\n function: (identifier) @event.handler.function\n (#match? @event.handler.function \"^handle[A-Z]\"))\n\n; === TypeScript\u7279\u5B9A\u67E5\u8BE2 ===\n\n; \u6CDB\u578B\u51FD\u6570\u8C03\u7528 - function()\n(call_expression\n function: (identifier) @generic.call.function\n type_arguments: (type_arguments))\n\n; \u6CDB\u578B\u65B9\u6CD5\u8C03\u7528 - object.method()\n(call_expression\n function: (member_expression\n object: (identifier) @generic.call.receiver\n property: (property_identifier) @generic.call.method)\n type_arguments: (type_arguments))\n\n; \u6CDB\u578BPromise\u65B9\u6CD5\u8C03\u7528 - promise.then()\n(call_expression\n function: (member_expression\n object: (identifier) @promise.call.object\n property: (property_identifier) @promise.call.method)\n type_arguments: (type_arguments)\n (#match? @promise.call.method \"^(then|catch|finally)$\"))\n\n; \u7C7B\u578B\u65AD\u8A00\u8C03\u7528 - as Type\n(as_expression) @type.assertion\n\n; === \u5F02\u6B65\u8C03\u7528\uFF08\u4F18\u5148\u7EA7\u8F83\u9AD8\uFF09===\n\n; await \u8868\u8FBE\u5F0F\u4E2D\u7684\u51FD\u6570\u8C03\u7528\n(await_expression\n (call_expression\n function: (identifier) @await.call.function))\n\n; \u5F02\u6B65\u65B9\u6CD5\u8C03\u7528\n(await_expression\n (call_expression\n function: (member_expression\n object: (identifier) @async.call.receiver\n property: (property_identifier) @async.call.method)))\n\n; === \u7279\u5B9A\u65B9\u6CD5\u8C03\u7528\uFF08\u4F18\u5148\u7EA7\u9AD8\u4E8E\u901A\u7528\u65B9\u6CD5\u8C03\u7528\uFF09===\n\n; Promise \u65B9\u6CD5\u8C03\u7528 - promise.then(), promise.catch()\n(call_expression\n function: (member_expression\n object: (identifier) @promise.call.object\n property: (property_identifier) @promise.call.method)\n (#match? @promise.call.method \"^(then|catch|finally)$\"))\n\n; \u6570\u7EC4\u65B9\u6CD5\u8C03\u7528 - array.map(), array.filter()\n(call_expression\n function: (member_expression\n object: (identifier) @array.call.object\n property: (property_identifier) @array.call.method)\n (#match? @array.call.method \"^(map|filter|reduce|forEach|find|some|every|sort|push|pop|shift|unshift|slice|splice|concat|join|indexOf|includes)$\"))\n\n; === \u6784\u9020\u51FD\u6570\u548C\u7C7B\u8C03\u7528 ===\n\n; \u6784\u9020\u51FD\u6570\u8C03\u7528 - new Constructor()\n(new_expression\n constructor: (identifier) @constructor.call.name)\n\n; \u6CDB\u578B\u6784\u9020\u51FD\u6570\u8C03\u7528 - new Constructor()\n(new_expression\n constructor: (identifier) @generic.constructor.call.name\n type_arguments: (type_arguments))\n\n; \u9759\u6001\u65B9\u6CD5\u8C03\u7528 - Class.staticMethod() (\u9996\u5B57\u6BCD\u5927\u5199\u7684\u6807\u8BC6\u7B26)\n(call_expression\n function: (member_expression\n object: (identifier) @static.call.class\n property: (property_identifier) @static.call.method)\n (#match? @static.call.class \"^[A-Z]\"))\n\n; === \u5BF9\u8C61\u65B9\u6CD5\u8C03\u7528 ===\n\n; this \u65B9\u6CD5\u8C03\u7528 - this.method()\n(call_expression\n function: (member_expression\n object: (this) @this.call.receiver\n property: (property_identifier) @this.call.method))\n\n; super \u65B9\u6CD5\u8C03\u7528 - super.method()\n(call_expression\n function: (member_expression\n object: (super) @super.call.receiver\n property: (property_identifier) @super.call.method))\n\n; \u53EF\u9009\u94FE\u8C03\u7528 - object?.method?.()\n(call_expression\n function: (member_expression\n object: (identifier) @optional.call.receiver\n property: (property_identifier) @optional.call.method))\n\n; \u94FE\u5F0F\u65B9\u6CD5\u8C03\u7528 - object.method1().method2()\n(call_expression\n function: (member_expression\n object: (call_expression)\n property: (property_identifier) @method.call.chain))\n\n; \u5D4C\u5957\u5C5E\u6027\u8C03\u7528 - object.nested.method()\n(call_expression\n function: (member_expression\n object: (member_expression\n object: (identifier) @nested.call.root\n property: (property_identifier) @nested.call.intermediate)\n property: (property_identifier) @nested.call.method))\n\n; \u65B9\u6CD5\u8C03\u7528 - object.method()\n(call_expression\n function: (member_expression\n object: (identifier) @method.call.receiver\n property: (property_identifier) @method.call.name)\n (#not-match? @method.call.receiver \"^[A-Z]\"))\n\n; === \u547D\u540D\u7A7A\u95F4\u8C03\u7528 ===\n\n; \u547D\u540D\u7A7A\u95F4/\u6A21\u5757\u8C03\u7528 - namespace.function()\n(call_expression\n function: (member_expression\n object: (identifier) @namespace.call.name\n property: (property_identifier) @namespace.call.function)\n (#match? @namespace.call.name \"^[A-Z]\")\n (#not-match? @namespace.call.function \"^(constructor|new|create|get|set|add|remove|update|delete)$\"))\n\n; === \u7279\u6B8A\u51FD\u6570\u8C03\u7528 ===\n\n; \u7BAD\u5934\u51FD\u6570\u8C03\u7528 - (() => {})()\n(call_expression\n function: (arrow_function) @arrow.call.function)\n\n; \u51FD\u6570\u8868\u8FBE\u5F0F\u8C03\u7528 - (function() {})()\n(call_expression\n function: (function_expression) @function.call.expression)\n\n; \u6A21\u677F\u5B57\u7B26\u4E32\u4E2D\u7684\u8868\u8FBE\u5F0F\u8C03\u7528\n(template_substitution\n (call_expression\n function: (identifier) @template.call.function))\n\n; === \u901A\u7528\u76F4\u63A5\u51FD\u6570\u8C03\u7528\uFF08\u4F18\u5148\u7EA7\u6700\u4F4E\uFF09===\n\n; \u76F4\u63A5\u51FD\u6570\u8C03\u7528 - function()\n(call_expression\n function: (identifier) @function.call.direct)\n`\n", "// CTCode/src/autocompletion/v2/capturesProcess/functionQuery/analyzer.ts\n\nimport Parser from \"web-tree-sitter\"\nimport { CodeLanguageType, ISnippetMeta, SnippetType } from \"../types\"\n\nexport interface FunctionCallInfo {\n\tcalledFunctionName: string\n\tcallType: \"direct\" | \"method\" | \"package\" | \"literal\"\n\treceiver?: string // \u5BF9\u4E8E\u65B9\u6CD5\u8C03\u7528\uFF0C\u63A5\u6536\u8005\u7684\u540D\u79F0\n\tpackageQualifier?: string // \u5BF9\u4E8E\u5305\u51FD\u6570\u8C03\u7528\uFF0C\u5305\u7684\u540D\u79F0\n\tline: number\n\tcolumn: number\n}\n\nexport interface FunctionCallAnalysisResult {\n\tfunctionCalls: FunctionCallInfo[]\n\tscopeInfo: {\n\t\tpackageName?: string\n\t\ttypeName?: string // \u5982\u679C\u51FD\u6570\u662F\u67D0\u4E2A\u7C7B\u578B\u7684\u65B9\u6CD5\n\t\tfunctionName: string\n\t}\n}\n\nexport function dependenciesCapturesProcessForGo(captures: Parser.QueryCapture[]): ISnippetMeta[] {\n\tconst result = analyzeGoFunctionCalls(captures)\n\treturn result.functionCalls.map((call) => ({\n\t\tname: call.calledFunctionName,\n\t\ttype: SnippetType.FunctionOrMethod,\n\t\tfilePath: \"\",\n\t\tstartLine: call.line,\n\t\tendLine: call.line,\n\t\tstartPosition: {\n\t\t\trow: call.line,\n\t\t\tcolumn: call.column,\n\t\t},\n\t\tendPosition: {\n\t\t\trow: call.line,\n\t\t\tcolumn: call.column,\n\t\t},\n\t\trangeText: \"\",\n\t\tfileHash: \"\",\n\t}))\n}\n\n/**\n * \u5206\u6790 Go \u8BED\u8A00\u7684\u51FD\u6570\u8C03\u7528\n */\nfunction analyzeGoFunctionCalls(captures: Parser.QueryCapture[]): FunctionCallAnalysisResult {\n\tconst functionCalls: FunctionCallInfo[] = []\n\tconst scopeInfo = {\n\t\tpackageName: undefined as string | undefined,\n\t\ttypeName: undefined as string | undefined,\n\t\tfunctionName: \"unknown\",\n\t}\n\n\tconsole.log(`[analyzeGoFunctionCalls] Processing ${captures.length} captures`)\n\n\t// \u7528\u4E8E\u4E34\u65F6\u5B58\u50A8\u540C\u4E00\u884C\u7684\u65B9\u6CD5\u8C03\u7528\u4FE1\u606F\n\tconst methodCallsByLine = new Map<\n\t\tnumber,\n\t\t{\n\t\t\tfunctionName?: string\n\t\t\treceiver?: string\n\t\t}\n\t>()\n\n\t// \u5904\u7406\u5404\u79CD\u7C7B\u578B\u7684\u6355\u83B7\n\tfor (const capture of captures) {\n\t\tconst node = capture.node\n\t\tconst captureText = node.text.trim()\n\t\tconst line = node.startPosition.row\n\n\t\tconsole.log(`[analyzeGoFunctionCalls] Processing capture: ${capture.name} = \"${captureText}\"`)\n\n\t\tswitch (capture.name) {\n\t\t\tcase \"function.call.direct\":\n\t\t\t\t// \u76F4\u63A5\u51FD\u6570\u8C03\u7528\n\t\t\t\tconsole.log(`[analyzeGoFunctionCalls] Adding direct function call: ${captureText}`)\n\t\t\t\tfunctionCalls.push({\n\t\t\t\t\tcalledFunctionName: captureText,\n\t\t\t\t\tcallType: \"direct\",\n\t\t\t\t\tline: line + 1,\n\t\t\t\t\tcolumn: node.startPosition.column,\n\t\t\t\t})\n\t\t\t\tbreak\n\n\t\t\tcase \"method.call.name\":\n\t\t\t\t// \u65B9\u6CD5\u8C03\u7528\u7684\u65B9\u6CD5\u540D\n\t\t\t\tif (!methodCallsByLine.has(line)) {\n\t\t\t\t\tmethodCallsByLine.set(line, {})\n\t\t\t\t}\n\t\t\t\tmethodCallsByLine.get(line)!.functionName = captureText\n\t\t\t\tbreak\n\n\t\t\tcase \"method.call.receiver\":\n\t\t\t\t// \u65B9\u6CD5\u8C03\u7528\u7684\u63A5\u6536\u8005\n\t\t\t\tif (!methodCallsByLine.has(line)) {\n\t\t\t\t\tmethodCallsByLine.set(line, {})\n\t\t\t\t}\n\t\t\t\tmethodCallsByLine.get(line)!.receiver = captureText\n\t\t\t\tbreak\n\n\t\t\tdefault:\n\t\t\t\tconsole.log(`[analyzeGoFunctionCalls] Unhandled capture type: ${capture.name}`)\n\t\t\t\tbreak\n\t\t}\n\t}\n\n\t// \u5904\u7406\u65B9\u6CD5\u8C03\u7528\u4FE1\u606F\n\tfor (const [line, callInfo] of methodCallsByLine) {\n\t\tif (callInfo.functionName && callInfo.receiver) {\n\t\t\tconsole.log(`[analyzeGoFunctionCalls] Adding method call: ${callInfo.receiver}.${callInfo.functionName}`)\n\t\t\tfunctionCalls.push({\n\t\t\t\tcalledFunctionName: callInfo.functionName,\n\t\t\t\tcallType: \"method\",\n\t\t\t\treceiver: callInfo.receiver,\n\t\t\t\tline: line + 1,\n\t\t\t\tcolumn: 0,\n\t\t\t})\n\t\t}\n\t}\n\n\tconsole.log(\n\t\t`[analyzeGoFunctionCalls] Final result: ${functionCalls.length} function calls, scope: ${JSON.stringify(scopeInfo)}`,\n\t)\n\n\treturn { functionCalls, scopeInfo }\n}\n\nexport function filterRelevantFunctionCalls(\n\tcallAnalysis: FunctionCallAnalysisResult,\n\tallFunctions: ISnippetMeta[],\n\tcurrentFunction: ISnippetMeta,\n\tlanguage: CodeLanguageType,\n): ISnippetMeta[] {\n\tconst relevantFunctions: ISnippetMeta[] = []\n\n\tfor (const call of callAnalysis.functionCalls) {\n\t\t// \u67E5\u627E\u5BF9\u5E94\u7684\u51FD\u6570\u5B9A\u4E49\n\t\tconst targetFunction = findTargetFunction(call, allFunctions, callAnalysis.scopeInfo, language)\n\n\t\tif (targetFunction && targetFunction.name !== currentFunction.name) {\n\t\t\t// \u68C0\u67E5\u662F\u5426\u5DF2\u7ECF\u6DFB\u52A0\u8FC7\n\t\t\tif (!relevantFunctions.find((f) => f.name === targetFunction.name)) {\n\t\t\t\trelevantFunctions.push(targetFunction)\n\t\t\t\tconsole.log(\n\t\t\t\t\t`[FunctionCallAnalyzer] Found relevant function call: ${call.calledFunctionName} (${call.callType})`,\n\t\t\t\t)\n\t\t\t}\n\t\t}\n\t}\n\n\treturn relevantFunctions\n}\n\n/**\n * \u67E5\u627E\u76EE\u6807\u51FD\u6570\u5B9A\u4E49\n */\nfunction findTargetFunction(\n\tcall: FunctionCallInfo,\n\tallFunctions: ISnippetMeta[],\n\tscopeInfo: FunctionCallAnalysisResult[\"scopeInfo\"],\n\tlanguage: CodeLanguageType,\n): ISnippetMeta | null {\n\tswitch (language) {\n\t\tcase CodeLanguageType.Go:\n\t\t\treturn findGoTargetFunction(call, allFunctions, scopeInfo)\n\t\tdefault:\n\t\t\t// \u901A\u7528\u67E5\u627E\u903B\u8F91\n\t\t\treturn allFunctions.find((func) => func.name === call.calledFunctionName) || null\n\t}\n}\n\n/**\n * \u67E5\u627E Go \u8BED\u8A00\u7684\u76EE\u6807\u51FD\u6570\n */\nfunction findGoTargetFunction(\n\tcall: FunctionCallInfo,\n\tallFunctions: ISnippetMeta[],\n\tscopeInfo: FunctionCallAnalysisResult[\"scopeInfo\"],\n): ISnippetMeta | null {\n\tswitch (call.callType) {\n\t\tcase \"direct\":\n\t\t\t// \u76F4\u63A5\u51FD\u6570\u8C03\u7528\uFF1A\u67E5\u627E\u540C\u5305\u7684\u51FD\u6570\n\t\t\treturn (\n\t\t\t\tallFunctions.find(\n\t\t\t\t\t(func) => func.name === call.calledFunctionName && !func.scope?.length, // \u5305\u7EA7\u51FD\u6570\u901A\u5E38\u6CA1\u6709\u989D\u5916\u7684\u4F5C\u7528\u57DF\n\t\t\t\t) || null\n\t\t\t)\n\n\t\tcase \"method\":\n\t\t\t// \u65B9\u6CD5\u8C03\u7528\uFF1A\u67E5\u627E\u540C\u7C7B\u578B\u7684\u65B9\u6CD5\n\t\t\tif (call.receiver === \"this\" || call.receiver === scopeInfo.typeName) {\n\t\t\t\t// \u540C\u7C7B\u578B\u7684\u65B9\u6CD5\u8C03\u7528\n\t\t\t\treturn (\n\t\t\t\t\tallFunctions.find(\n\t\t\t\t\t\t(func) =>\n\t\t\t\t\t\t\tfunc.name === call.calledFunctionName && func.scope?.includes(scopeInfo.typeName || \"\"),\n\t\t\t\t\t) || null\n\t\t\t\t)\n\t\t\t}\n\t\t\tbreak\n\n\t\tcase \"package\":\n\t\t\t// \u5305\u51FD\u6570\u8C03\u7528\uFF1A\u901A\u5E38\u662F\u5916\u90E8\u5305\uFF0C\u4E0D\u5305\u542B\u5728\u540C\u6587\u4EF6\u4E0A\u4E0B\u6587\u4E2D\n\t\t\treturn null\n\n\t\tcase \"literal\":\n\t\t\t// \u51FD\u6570\u5B57\u9762\u91CF\u8C03\u7528\uFF1A\u901A\u5E38\u4E0D\u9700\u8981\u5305\u542B\u5728\u4E0A\u4E0B\u6587\u4E2D\n\t\t\treturn null\n\t}\n\n\treturn null\n}\n", "import Parser from \"web-tree-sitter\"\nimport { CodeLanguageType, ISnippetMeta, SnippetType } from \"../types\"\n\nexport interface TypeScriptFunctionCallInfo {\n\tcalledFunctionName: string\n\tcallType:\n\t\t| \"direct\"\n\t\t| \"method\"\n\t\t| \"static\"\n\t\t| \"namespace\"\n\t\t| \"constructor\"\n\t\t| \"chain\"\n\t\t| \"this\"\n\t\t| \"super\"\n\t\t| \"arrow\"\n\t\t| \"async\"\n\t\t| \"array\"\n\t\t| \"promise\"\n\t\t| \"optional\"\n\t\t| \"generic\"\n\t\t| \"template\"\n\t\t| \"nested\"\n\treceiver?: string // \u5BF9\u4E8E\u65B9\u6CD5\u8C03\u7528\uFF0C\u63A5\u6536\u8005\u7684\u540D\u79F0\n\tclassName?: string // \u5BF9\u4E8E\u9759\u6001\u65B9\u6CD5\u8C03\u7528\uFF0C\u7C7B\u7684\u540D\u79F0\n\tnamespace?: string // \u5BF9\u4E8E\u547D\u540D\u7A7A\u95F4\u8C03\u7528\uFF0C\u547D\u540D\u7A7A\u95F4\u7684\u540D\u79F0\n\tline: number\n\tcolumn: number\n\tisAsync?: boolean // \u662F\u5426\u662F\u5F02\u6B65\u8C03\u7528\n\tisOptional?: boolean // \u662F\u5426\u662F\u53EF\u9009\u94FE\u8C03\u7528\n\tisGeneric?: boolean // \u662F\u5426\u662F\u6CDB\u578B\u8C03\u7528\n}\n\nexport interface TypeScriptFunctionCallAnalysisResult {\n\tfunctionCalls: TypeScriptFunctionCallInfo[]\n\tscopeInfo: {\n\t\tmoduleName?: string\n\t\tclassName?: string // \u5982\u679C\u51FD\u6570\u662F\u67D0\u4E2A\u7C7B\u7684\u65B9\u6CD5\n\t\tfunctionName: string\n\t\tisAsync?: boolean\n\t}\n}\n\nexport function dependenciesCapturesProcessForTypeScript(captures: Parser.QueryCapture[]): ISnippetMeta[] {\n\tconst result = analyzeTypeScriptFunctionCalls(captures)\n\treturn result.functionCalls.map((call) => ({\n\t\tname: call.calledFunctionName,\n\t\ttype: SnippetType.FunctionOrMethod,\n\t\tfilePath: \"\",\n\t\tstartLine: call.line,\n\t\tendLine: call.line,\n\t\tstartPosition: {\n\t\t\trow: call.line,\n\t\t\tcolumn: call.column,\n\t\t},\n\t\tendPosition: {\n\t\t\trow: call.line,\n\t\t\tcolumn: call.column,\n\t\t},\n\t\trangeText: \"\",\n\t\tfileHash: \"\",\n\t\tdefinition: {\n\t\t\tname: call.calledFunctionName,\n\t\t\ttype: call.callType,\n\t\t},\n\t\tfield: call.className || call.namespace,\n\t\tsignature: `${call.calledFunctionName}()`,\n\t\tlanguage: CodeLanguageType.TypeScript,\n\t}))\n}\n\n/**\n * \u5206\u6790 TypeScript/JavaScript \u7684\u51FD\u6570\u8C03\u7528\n */\nfunction analyzeTypeScriptFunctionCalls(captures: Parser.QueryCapture[]): TypeScriptFunctionCallAnalysisResult {\n\tconst functionCalls: TypeScriptFunctionCallInfo[] = []\n\tconst scopeInfo = {\n\t\tmoduleName: undefined as string | undefined,\n\t\tclassName: undefined as string | undefined,\n\t\tfunctionName: \"unknown\",\n\t\tisAsync: false,\n\t}\n\n\t// \u7528\u4E8E\u4E34\u65F6\u5B58\u50A8\u8C03\u7528\u4FE1\u606F\uFF0C\u6309\u4F4D\u7F6E\u5206\u7EC4\n\tconst callGroups = new Map()\n\n\t// \u7528\u4E8E\u4E34\u65F6\u5B58\u50A8\u540C\u4E00\u884C\u7684\u8C03\u7528\u4FE1\u606F\n\tconst callsByLine = new Map<\n\t\tnumber,\n\t\t{\n\t\t\tfunctionName?: string\n\t\t\treceiver?: string\n\t\t\tclassName?: string\n\t\t\tnamespace?: string\n\t\t\tcallType?: TypeScriptFunctionCallInfo[\"callType\"]\n\t\t\tisAsync?: boolean\n\t\t\tisOptional?: boolean\n\t\t\tisGeneric?: boolean\n\t\t}\n\t>()\n\n\t// \u5904\u7406\u5404\u79CD\u7C7B\u578B\u7684\u6355\u83B7\n\tfor (const capture of captures) {\n\t\tconst node = capture.node\n\t\tconst captureText = node.text.trim()\n\t\tconst line = node.startPosition.row\n\n\t\tswitch (capture.name) {\n\t\t\tcase \"function.call.direct\":\n\t\t\t\t// \u76F4\u63A5\u51FD\u6570\u8C03\u7528\n\n\t\t\t\tfunctionCalls.push({\n\t\t\t\t\tcalledFunctionName: captureText,\n\t\t\t\t\tcallType: \"direct\",\n\t\t\t\t\tline: line + 1,\n\t\t\t\t\tcolumn: node.startPosition.column,\n\t\t\t\t})\n\t\t\t\tbreak\n\n\t\t\tcase \"method.call.name\":\n\t\t\t\t// \u65B9\u6CD5\u8C03\u7528\u7684\u65B9\u6CD5\u540D\n\t\t\t\tif (!callsByLine.has(line)) {\n\t\t\t\t\tcallsByLine.set(line, {})\n\t\t\t\t}\n\t\t\t\tconst methodCall = callsByLine.get(line)!\n\t\t\t\tmethodCall.functionName = captureText\n\t\t\t\tmethodCall.callType = \"method\"\n\t\t\t\tbreak\n\n\t\t\tcase \"method.call.receiver\":\n\t\t\t\t// \u65B9\u6CD5\u8C03\u7528\u7684\u63A5\u6536\u8005\n\t\t\t\tif (!callsByLine.has(line)) {\n\t\t\t\t\tcallsByLine.set(line, {})\n\t\t\t\t}\n\t\t\t\tcallsByLine.get(line)!.receiver = captureText\n\t\t\t\tbreak\n\n\t\t\tcase \"static.call.class\":\n\t\t\t\t// \u9759\u6001\u65B9\u6CD5\u8C03\u7528\u7684\u7C7B\u540D\n\t\t\t\tif (!callsByLine.has(line)) {\n\t\t\t\t\tcallsByLine.set(line, {})\n\t\t\t\t}\n\t\t\t\tconst staticCall = callsByLine.get(line)!\n\t\t\t\tstaticCall.className = captureText\n\t\t\t\tstaticCall.callType = \"static\"\n\t\t\t\tbreak\n\n\t\t\tcase \"static.call.method\":\n\t\t\t\t// \u9759\u6001\u65B9\u6CD5\u8C03\u7528\u7684\u65B9\u6CD5\u540D\n\t\t\t\tif (!callsByLine.has(line)) {\n\t\t\t\t\tcallsByLine.set(line, {})\n\t\t\t\t}\n\t\t\t\tcallsByLine.get(line)!.functionName = captureText\n\t\t\t\tbreak\n\n\t\t\tcase \"namespace.call.name\":\n\t\t\t\t// \u547D\u540D\u7A7A\u95F4\u8C03\u7528\u7684\u547D\u540D\u7A7A\u95F4\u540D\n\t\t\t\tif (!callsByLine.has(line)) {\n\t\t\t\t\tcallsByLine.set(line, {})\n\t\t\t\t}\n\t\t\t\tconst namespaceCall = callsByLine.get(line)!\n\t\t\t\tnamespaceCall.namespace = captureText\n\t\t\t\tnamespaceCall.callType = \"namespace\"\n\t\t\t\tbreak\n\n\t\t\tcase \"namespace.call.function\":\n\t\t\t\t// \u547D\u540D\u7A7A\u95F4\u8C03\u7528\u7684\u51FD\u6570\u540D\n\t\t\t\tif (!callsByLine.has(line)) {\n\t\t\t\t\tcallsByLine.set(line, {})\n\t\t\t\t}\n\t\t\t\tcallsByLine.get(line)!.functionName = captureText\n\t\t\t\tbreak\n\n\t\t\tcase \"this.call.method\":\n\t\t\t\t// this\u65B9\u6CD5\u8C03\u7528\n\n\t\t\t\tfunctionCalls.push({\n\t\t\t\t\tcalledFunctionName: captureText,\n\t\t\t\t\tcallType: \"this\",\n\t\t\t\t\treceiver: \"this\",\n\t\t\t\t\tline: line + 1,\n\t\t\t\t\tcolumn: node.startPosition.column,\n\t\t\t\t})\n\t\t\t\tbreak\n\n\t\t\tcase \"super.call.method\":\n\t\t\t\t// super\u65B9\u6CD5\u8C03\u7528\n\n\t\t\t\tfunctionCalls.push({\n\t\t\t\t\tcalledFunctionName: captureText,\n\t\t\t\t\tcallType: \"super\",\n\t\t\t\t\treceiver: \"super\",\n\t\t\t\t\tline: line + 1,\n\t\t\t\t\tcolumn: node.startPosition.column,\n\t\t\t\t})\n\t\t\t\tbreak\n\n\t\t\tcase \"constructor.call.name\":\n\t\t\t\t// \u6784\u9020\u51FD\u6570\u8C03\u7528\n\n\t\t\t\tfunctionCalls.push({\n\t\t\t\t\tcalledFunctionName: captureText,\n\t\t\t\t\tcallType: \"constructor\",\n\t\t\t\t\tline: line + 1,\n\t\t\t\t\tcolumn: node.startPosition.column,\n\t\t\t\t})\n\t\t\t\tbreak\n\n\t\t\tcase \"method.call.chain\":\n\t\t\t\t// \u94FE\u5F0F\u65B9\u6CD5\u8C03\u7528\n\n\t\t\t\tfunctionCalls.push({\n\t\t\t\t\tcalledFunctionName: captureText,\n\t\t\t\t\tcallType: \"chain\",\n\t\t\t\t\tline: line + 1,\n\t\t\t\t\tcolumn: node.startPosition.column,\n\t\t\t\t})\n\t\t\t\tbreak\n\n\t\t\tcase \"array.call.method\":\n\t\t\t\t// \u6570\u7EC4\u65B9\u6CD5\u8C03\u7528\n\t\t\t\tif (!callsByLine.has(line)) {\n\t\t\t\t\tcallsByLine.set(line, {})\n\t\t\t\t}\n\t\t\t\tconst arrayCall = callsByLine.get(line)!\n\t\t\t\tarrayCall.functionName = captureText\n\t\t\t\tarrayCall.callType = \"array\"\n\t\t\t\tbreak\n\n\t\t\tcase \"array.call.object\":\n\t\t\t\t// \u6570\u7EC4\u5BF9\u8C61\n\t\t\t\tif (!callsByLine.has(line)) {\n\t\t\t\t\tcallsByLine.set(line, {})\n\t\t\t\t}\n\t\t\t\tcallsByLine.get(line)!.receiver = captureText\n\t\t\t\tbreak\n\n\t\t\tcase \"promise.call.method\":\n\t\t\t\t// Promise\u65B9\u6CD5\u8C03\u7528 - \u4F7F\u7528\u7B80\u5355\u7684\u6309\u884C\u5206\u7EC4\n\t\t\t\tconst promiseGroupKey = `promise-${line}`\n\t\t\t\tif (!callGroups.has(promiseGroupKey)) {\n\t\t\t\t\tcallGroups.set(promiseGroupKey, {})\n\t\t\t\t}\n\t\t\t\tcallGroups.get(promiseGroupKey)![\"method\"] = captureText\n\t\t\t\tcallGroups.get(promiseGroupKey)![\"line\"] = line.toString()\n\t\t\t\tcallGroups.get(promiseGroupKey)![\"column\"] = node.startPosition.column.toString()\n\t\t\t\tbreak\n\n\t\t\tcase \"promise.call.object\":\n\t\t\t\t// Promise\u5BF9\u8C61\n\t\t\t\tconst promiseObjGroupKey = `promise-${line}`\n\t\t\t\tif (!callGroups.has(promiseObjGroupKey)) {\n\t\t\t\t\tcallGroups.set(promiseObjGroupKey, {})\n\t\t\t\t}\n\t\t\t\tcallGroups.get(promiseObjGroupKey)![\"receiver\"] = captureText\n\t\t\t\tbreak\n\n\t\t\tcase \"await.call.function\":\n\t\t\t\t// await\u51FD\u6570\u8C03\u7528\n\n\t\t\t\tfunctionCalls.push({\n\t\t\t\t\tcalledFunctionName: captureText,\n\t\t\t\t\tcallType: \"async\",\n\t\t\t\t\tisAsync: true,\n\t\t\t\t\tline: line + 1,\n\t\t\t\t\tcolumn: node.startPosition.column,\n\t\t\t\t})\n\t\t\t\tbreak\n\n\t\t\tcase \"async.call.method\":\n\t\t\t\t// \u5F02\u6B65\u65B9\u6CD5\u8C03\u7528\n\t\t\t\tif (!callsByLine.has(line)) {\n\t\t\t\t\tcallsByLine.set(line, {})\n\t\t\t\t}\n\t\t\t\tconst asyncCall = callsByLine.get(line)!\n\t\t\t\tasyncCall.functionName = captureText\n\t\t\t\tasyncCall.callType = \"async\"\n\t\t\t\tasyncCall.isAsync = true\n\t\t\t\tbreak\n\n\t\t\tcase \"async.call.receiver\":\n\t\t\t\t// \u5F02\u6B65\u65B9\u6CD5\u63A5\u6536\u8005\n\t\t\t\tif (!callsByLine.has(line)) {\n\t\t\t\t\tcallsByLine.set(line, {})\n\t\t\t\t}\n\t\t\t\tcallsByLine.get(line)!.receiver = captureText\n\t\t\t\tbreak\n\n\t\t\tcase \"optional.call.method\":\n\t\t\t\t// \u53EF\u9009\u94FE\u65B9\u6CD5\u8C03\u7528\n\t\t\t\tif (!callsByLine.has(line)) {\n\t\t\t\t\tcallsByLine.set(line, {})\n\t\t\t\t}\n\t\t\t\tconst optionalCall = callsByLine.get(line)!\n\t\t\t\toptionalCall.functionName = captureText\n\t\t\t\toptionalCall.callType = \"optional\"\n\t\t\t\toptionalCall.isOptional = true\n\t\t\t\tbreak\n\n\t\t\tcase \"optional.call.receiver\":\n\t\t\t\t// \u53EF\u9009\u94FE\u63A5\u6536\u8005\n\t\t\t\tif (!callsByLine.has(line)) {\n\t\t\t\t\tcallsByLine.set(line, {})\n\t\t\t\t}\n\t\t\t\tcallsByLine.get(line)!.receiver = captureText\n\t\t\t\tbreak\n\n\t\t\tcase \"generic.call.function\":\n\t\t\t\t// \u6CDB\u578B\u51FD\u6570\u8C03\u7528\n\t\t\t\tconsole.log(`[analyzeTypeScriptFunctionCalls] Adding generic function call: ${captureText}`)\n\t\t\t\tfunctionCalls.push({\n\t\t\t\t\tcalledFunctionName: captureText,\n\t\t\t\t\tcallType: \"generic\",\n\t\t\t\t\tisGeneric: true,\n\t\t\t\t\tline: line + 1,\n\t\t\t\t\tcolumn: node.startPosition.column,\n\t\t\t\t})\n\t\t\t\tbreak\n\n\t\t\tcase \"template.call.function\":\n\t\t\t\t// \u6A21\u677F\u5B57\u7B26\u4E32\u4E2D\u7684\u51FD\u6570\u8C03\u7528\n\t\t\t\tconsole.log(`[analyzeTypeScriptFunctionCalls] Adding template function call: ${captureText}`)\n\t\t\t\tfunctionCalls.push({\n\t\t\t\t\tcalledFunctionName: captureText,\n\t\t\t\t\tcallType: \"template\",\n\t\t\t\t\tline: line + 1,\n\t\t\t\t\tcolumn: node.startPosition.column,\n\t\t\t\t})\n\t\t\t\tbreak\n\n\t\t\tcase \"nested.call.root\":\n\t\t\t\t// \u5D4C\u5957\u8C03\u7528\u7684\u6839\u5BF9\u8C61\n\t\t\t\tif (!callsByLine.has(line)) {\n\t\t\t\t\tcallsByLine.set(line, {})\n\t\t\t\t}\n\t\t\t\tconst nestedCall = callsByLine.get(line)!\n\t\t\t\tnestedCall.receiver = captureText\n\t\t\t\tnestedCall.callType = \"nested\"\n\t\t\t\tbreak\n\n\t\t\tcase \"nested.call.method\":\n\t\t\t\t// \u5D4C\u5957\u8C03\u7528\u7684\u65B9\u6CD5\n\t\t\t\tif (!callsByLine.has(line)) {\n\t\t\t\t\tcallsByLine.set(line, {})\n\t\t\t\t}\n\t\t\t\tcallsByLine.get(line)!.functionName = captureText\n\t\t\t\tbreak\n\n\t\t\tdefault:\n\t\t\t\tbreak\n\t\t}\n\t}\n\n\t// \u5904\u7406\u72EC\u7ACB\u7684\u8C03\u7528\u7EC4\n\tfor (const [groupKey, group] of callGroups) {\n\t\tif (groupKey.startsWith(\"promise-\") && group[\"method\"] && group[\"receiver\"]) {\n\t\t\tfunctionCalls.push({\n\t\t\t\tcalledFunctionName: group[\"method\"],\n\t\t\t\tcallType: \"promise\",\n\t\t\t\treceiver: group[\"receiver\"],\n\t\t\t\tline: parseInt(group[\"line\"]) + 1,\n\t\t\t\tcolumn: parseInt(group[\"column\"]),\n\t\t\t})\n\t\t}\n\t}\n\n\t// \u5904\u7406\u590D\u5408\u8C03\u7528\u4FE1\u606F - \u652F\u6301\u591A\u4E2A\u72EC\u7ACB\u7684\u51FD\u6570\u8C03\u7528\n\tconst processedCalls = new Set() // \u9632\u6B62\u91CD\u590D\u5904\u7406\n\n\tfor (const [line, callInfo] of callsByLine) {\n\t\tif (callInfo.functionName) {\n\t\t\t// \u68C0\u67E5\u662F\u5426\u6709\u660E\u786E\u7684\u7279\u6B8A\u7C7B\u578B\u6807\u8BC6\n\t\t\tconst callTypes = []\n\n\t\t\t// Promise\u8C03\u7528\u4F18\u5148\u7EA7\u6700\u9AD8\n\t\t\tif (callInfo.callType === \"promise\") {\n\t\t\t\tcallTypes.push({\n\t\t\t\t\ttype: \"promise\" as TypeScriptFunctionCallInfo[\"callType\"],\n\t\t\t\t\treceiver: callInfo.receiver,\n\t\t\t\t\tfunctionName: callInfo.functionName,\n\t\t\t\t})\n\t\t\t}\n\n\t\t\t// \u6570\u7EC4\u8C03\u7528\n\t\t\tif (callInfo.callType === \"array\") {\n\t\t\t\tcallTypes.push({\n\t\t\t\t\ttype: \"array\" as TypeScriptFunctionCallInfo[\"callType\"],\n\t\t\t\t\treceiver: callInfo.receiver,\n\t\t\t\t\tfunctionName: callInfo.functionName,\n\t\t\t\t})\n\t\t\t}\n\n\t\t\t// \u9759\u6001\u8C03\u7528 (\u6709className)\n\t\t\tif (callInfo.className) {\n\t\t\t\tcallTypes.push({\n\t\t\t\t\ttype: \"static\" as TypeScriptFunctionCallInfo[\"callType\"],\n\t\t\t\t\treceiver: callInfo.className,\n\t\t\t\t\tfunctionName: callInfo.functionName,\n\t\t\t\t\tclassName: callInfo.className,\n\t\t\t\t})\n\t\t\t}\n\n\t\t\t// \u547D\u540D\u7A7A\u95F4\u8C03\u7528\n\t\t\tif (callInfo.namespace) {\n\t\t\t\tcallTypes.push({\n\t\t\t\t\ttype: \"namespace\" as TypeScriptFunctionCallInfo[\"callType\"],\n\t\t\t\t\treceiver: callInfo.namespace,\n\t\t\t\t\tfunctionName: callInfo.functionName,\n\t\t\t\t\tnamespace: callInfo.namespace,\n\t\t\t\t})\n\t\t\t}\n\n\t\t\t// \u5F02\u6B65\u8C03\u7528\n\t\t\tif (callInfo.isAsync) {\n\t\t\t\tcallTypes.push({\n\t\t\t\t\ttype: \"async\" as TypeScriptFunctionCallInfo[\"callType\"],\n\t\t\t\t\treceiver: callInfo.receiver,\n\t\t\t\t\tfunctionName: callInfo.functionName,\n\t\t\t\t\tisAsync: true,\n\t\t\t\t})\n\t\t\t}\n\n\t\t\t// \u5D4C\u5957\u8C03\u7528\n\t\t\tif (callInfo.callType === \"nested\") {\n\t\t\t\tcallTypes.push({\n\t\t\t\t\ttype: \"nested\" as TypeScriptFunctionCallInfo[\"callType\"],\n\t\t\t\t\treceiver: callInfo.receiver,\n\t\t\t\t\tfunctionName: callInfo.functionName,\n\t\t\t\t})\n\t\t\t}\n\n\t\t\t// \u5982\u679C\u6CA1\u6709\u7279\u6B8A\u7C7B\u578B\uFF0C\u9ED8\u8BA4\u4E3A\u666E\u901A\u65B9\u6CD5\u8C03\u7528\n\t\t\tif (callTypes.length === 0 && callInfo.receiver) {\n\t\t\t\tcallTypes.push({\n\t\t\t\t\ttype: \"method\" as TypeScriptFunctionCallInfo[\"callType\"],\n\t\t\t\t\treceiver: callInfo.receiver,\n\t\t\t\t\tfunctionName: callInfo.functionName,\n\t\t\t\t})\n\t\t\t}\n\n\t\t\t// \u4E3A\u6BCF\u4E2A\u8BC6\u522B\u7684\u8C03\u7528\u7C7B\u578B\u521B\u5EFA\u8BB0\u5F55\n\t\t\tfor (const callType of callTypes) {\n\t\t\t\tconst callKey = `${line}-${callType.type}-${callType.functionName}-${callType.receiver || \"\"}`\n\t\t\t\tif (!processedCalls.has(callKey)) {\n\t\t\t\t\tprocessedCalls.add(callKey)\n\n\t\t\t\t\tfunctionCalls.push({\n\t\t\t\t\t\tcalledFunctionName: callType.functionName,\n\t\t\t\t\t\tcallType: callType.type,\n\t\t\t\t\t\treceiver: callType.receiver,\n\t\t\t\t\t\tclassName: callType.className,\n\t\t\t\t\t\tnamespace: callType.namespace,\n\t\t\t\t\t\tline: line + 1,\n\t\t\t\t\t\tcolumn: 0,\n\t\t\t\t\t\tisAsync: callType.isAsync,\n\t\t\t\t\t\tisOptional: callInfo.isOptional,\n\t\t\t\t\t\tisGeneric: callInfo.isGeneric,\n\t\t\t\t\t})\n\t\t\t\t}\n\t\t\t}\n\t\t}\n\t}\n\n\treturn { functionCalls, scopeInfo }\n}\n\nexport function filterRelevantTypeScriptFunctionCalls(\n\tcallAnalysis: TypeScriptFunctionCallAnalysisResult,\n\tallFunctions: ISnippetMeta[],\n\tcurrentFunction: ISnippetMeta,\n\tlanguage: CodeLanguageType,\n): ISnippetMeta[] {\n\tconst relevantFunctions: ISnippetMeta[] = []\n\n\tfor (const call of callAnalysis.functionCalls) {\n\t\t// \u67E5\u627E\u5BF9\u5E94\u7684\u51FD\u6570\u5B9A\u4E49\n\t\tconst targetFunction = findTypeScriptTargetFunction(call, allFunctions, callAnalysis.scopeInfo)\n\n\t\tif (targetFunction && targetFunction.name !== currentFunction.name) {\n\t\t\t// \u68C0\u67E5\u662F\u5426\u5DF2\u7ECF\u6DFB\u52A0\u8FC7\n\t\t\tif (!relevantFunctions.find((f) => f.name === targetFunction.name)) {\n\t\t\t\trelevantFunctions.push(targetFunction)\n\t\t\t\tconsole.log(\n\t\t\t\t\t`[TypeScriptFunctionCallAnalyzer] Found relevant function call: ${call.calledFunctionName} (${call.callType})`,\n\t\t\t\t)\n\t\t\t}\n\t\t}\n\t}\n\n\treturn relevantFunctions\n}\n\n/**\n * \u67E5\u627E TypeScript \u7684\u76EE\u6807\u51FD\u6570\n */\nfunction findTypeScriptTargetFunction(\n\tcall: TypeScriptFunctionCallInfo,\n\tallFunctions: ISnippetMeta[],\n\tscopeInfo: TypeScriptFunctionCallAnalysisResult[\"scopeInfo\"],\n): ISnippetMeta | null {\n\tswitch (call.callType) {\n\t\tcase \"direct\":\n\t\t\t// \u76F4\u63A5\u51FD\u6570\u8C03\u7528\uFF1A\u67E5\u627E\u540C\u6A21\u5757\u7684\u51FD\u6570\n\t\t\treturn (\n\t\t\t\tallFunctions.find(\n\t\t\t\t\t(func) => func.name === call.calledFunctionName && !func.field, // \u6A21\u5757\u7EA7\u51FD\u6570\u901A\u5E38\u6CA1\u6709field\n\t\t\t\t) || null\n\t\t\t)\n\n\t\tcase \"method\":\n\t\tcase \"this\":\n\t\t\t// \u65B9\u6CD5\u8C03\u7528\uFF1A\u67E5\u627E\u540C\u7C7B\u7684\u65B9\u6CD5\n\t\t\tif (call.receiver === \"this\" || call.receiver === scopeInfo.className) {\n\t\t\t\treturn (\n\t\t\t\t\tallFunctions.find(\n\t\t\t\t\t\t(func) => func.name === call.calledFunctionName && func.field === scopeInfo.className,\n\t\t\t\t\t) || null\n\t\t\t\t)\n\t\t\t}\n\t\t\tbreak\n\n\t\tcase \"static\":\n\t\t\t// \u9759\u6001\u65B9\u6CD5\u8C03\u7528\uFF1A\u67E5\u627E\u6307\u5B9A\u7C7B\u7684\u9759\u6001\u65B9\u6CD5\n\t\t\treturn (\n\t\t\t\tallFunctions.find((func) => func.name === call.calledFunctionName && func.field === call.className) ||\n\t\t\t\tnull\n\t\t\t)\n\n\t\tcase \"namespace\":\n\t\t\t// \u547D\u540D\u7A7A\u95F4\u8C03\u7528\uFF1A\u67E5\u627E\u6307\u5B9A\u547D\u540D\u7A7A\u95F4\u7684\u51FD\u6570\n\t\t\treturn (\n\t\t\t\tallFunctions.find((func) => func.name === call.calledFunctionName && func.field === call.namespace) ||\n\t\t\t\tnull\n\t\t\t)\n\n\t\tcase \"constructor\":\n\t\t\t// \u6784\u9020\u51FD\u6570\u8C03\u7528\uFF1A\u67E5\u627E\u7C7B\u5B9A\u4E49\n\t\t\treturn allFunctions.find((func) => func.name === call.calledFunctionName) || null\n\n\t\tcase \"super\":\n\t\t\t// super\u8C03\u7528\uFF1A\u901A\u5E38\u662F\u7236\u7C7B\u65B9\u6CD5\uFF0C\u53EF\u80FD\u4E0D\u5728\u540C\u6587\u4EF6\u4E2D\n\t\t\treturn null\n\n\t\tcase \"chain\":\n\t\tcase \"array\":\n\t\tcase \"promise\":\n\t\tcase \"optional\":\n\t\tcase \"async\":\n\t\tcase \"generic\":\n\t\tcase \"template\":\n\t\tcase \"nested\":\n\t\t\t// \u8FD9\u4E9B\u8C03\u7528\u7C7B\u578B\u901A\u5E38\u662F\u5185\u7F6E\u65B9\u6CD5\u6216\u94FE\u5F0F\u8C03\u7528\uFF0C\u4E0D\u9700\u8981\u5305\u542B\u5728\u4E0A\u4E0B\u6587\u4E2D\n\t\t\treturn null\n\t}\n\n\treturn null\n}\n", "import Parser from \"web-tree-sitter\"\nimport { CodeLanguageType, ISnippetMeta, SnippetType } from \"../types\"\n\nexport interface JavaScriptFunctionCallInfo {\n\tcalledFunctionName: string\n\tcallType:\n\t\t| \"direct\"\n\t\t| \"method\"\n\t\t| \"static\"\n\t\t| \"namespace\"\n\t\t| \"constructor\"\n\t\t| \"chain\"\n\t\t| \"this\"\n\t\t| \"super\"\n\t\t| \"arrow\"\n\t\t| \"async\"\n\t\t| \"array\"\n\t\t| \"promise\"\n\t\t| \"optional\"\n\t\t| \"template\"\n\t\t| \"nested\"\n\treceiver?: string // \u5BF9\u4E8E\u65B9\u6CD5\u8C03\u7528\uFF0C\u63A5\u6536\u8005\u7684\u540D\u79F0\n\tclassName?: string // \u5BF9\u4E8E\u9759\u6001\u65B9\u6CD5\u8C03\u7528\uFF0C\u7C7B\u7684\u540D\u79F0\n\tnamespace?: string // \u5BF9\u4E8E\u547D\u540D\u7A7A\u95F4\u8C03\u7528\uFF0C\u547D\u540D\u7A7A\u95F4\u7684\u540D\u79F0\n\tline: number\n\tcolumn: number\n\tisAsync?: boolean // \u662F\u5426\u662F\u5F02\u6B65\u8C03\u7528\n\tisOptional?: boolean // \u662F\u5426\u662F\u53EF\u9009\u94FE\u8C03\u7528\n}\n\nexport interface JavaScriptFunctionCallAnalysisResult {\n\tfunctionCalls: JavaScriptFunctionCallInfo[]\n\tscopeInfo: {\n\t\tmoduleName?: string\n\t\tclassName?: string // \u5982\u679C\u51FD\u6570\u662F\u67D0\u4E2A\u7C7B\u7684\u65B9\u6CD5\n\t\tfunctionName: string\n\t\tisAsync?: boolean\n\t}\n}\n\nexport function dependenciesCapturesProcessForJavaScript(captures: Parser.QueryCapture[]): ISnippetMeta[] {\n\tconst result = analyzeJavaScriptFunctionCalls(captures)\n\treturn result.functionCalls.map((call) => ({\n\t\tname: call.calledFunctionName,\n\t\ttype: SnippetType.FunctionOrMethod,\n\t\tfilePath: \"\",\n\t\tstartLine: call.line,\n\t\tendLine: call.line,\n\t\tstartPosition: {\n\t\t\trow: call.line,\n\t\t\tcolumn: call.column,\n\t\t},\n\t\tendPosition: {\n\t\t\trow: call.line,\n\t\t\tcolumn: call.column,\n\t\t},\n\t\trangeText: \"\",\n\t\tfileHash: \"\",\n\t\tdefinition: {\n\t\t\tname: call.calledFunctionName,\n\t\t\ttype: call.callType,\n\t\t},\n\t\tfield: call.className || call.namespace,\n\t\tsignature: `${call.calledFunctionName}()`,\n\t\tlanguage: CodeLanguageType.JavaScript,\n\t}))\n}\n\n/**\n * \u5206\u6790 JavaScript \u8BED\u8A00\u7684\u51FD\u6570\u8C03\u7528\n */\nfunction analyzeJavaScriptFunctionCalls(captures: Parser.QueryCapture[]): JavaScriptFunctionCallAnalysisResult {\n\tconst functionCalls: JavaScriptFunctionCallInfo[] = []\n\tconst scopeInfo = {\n\t\tmoduleName: undefined as string | undefined,\n\t\tclassName: undefined as string | undefined,\n\t\tfunctionName: \"unknown\",\n\t\tisAsync: false,\n\t}\n\n\t// \u7528\u4E8E\u4E34\u65F6\u5B58\u50A8\u540C\u4E00\u884C\u7684\u65B9\u6CD5\u8C03\u7528\u4FE1\u606F\n\tconst callsByLine = new Map<\n\t\tnumber,\n\t\t{\n\t\t\tfunctionName?: string\n\t\t\treceiver?: string\n\t\t\tclassName?: string\n\t\t\tnamespace?: string\n\t\t\tcallType?: JavaScriptFunctionCallInfo[\"callType\"]\n\t\t\tisAsync?: boolean\n\t\t\tisOptional?: boolean\n\t\t}\n\t>()\n\n\t// \u5904\u7406\u5404\u79CD\u7C7B\u578B\u7684\u6355\u83B7\n\tfor (const capture of captures) {\n\t\tconst node = capture.node\n\t\tconst captureText = node.text.trim()\n\t\tconst line = node.startPosition.row\n\n\t\tswitch (capture.name) {\n\t\t\tcase \"function.call.direct\":\n\t\t\t\t// \u76F4\u63A5\u51FD\u6570\u8C03\u7528\n\t\t\t\tfunctionCalls.push({\n\t\t\t\t\tcalledFunctionName: captureText,\n\t\t\t\t\tcallType: \"direct\",\n\t\t\t\t\tline: line + 1,\n\t\t\t\t\tcolumn: node.startPosition.column,\n\t\t\t\t})\n\t\t\t\tbreak\n\n\t\t\tcase \"method.call.name\":\n\t\t\t\t// \u65B9\u6CD5\u8C03\u7528\u7684\u65B9\u6CD5\u540D\n\t\t\t\tif (!callsByLine.has(line)) {\n\t\t\t\t\tcallsByLine.set(line, {})\n\t\t\t\t}\n\t\t\t\tconst methodCall = callsByLine.get(line)!\n\t\t\t\tmethodCall.functionName = captureText\n\t\t\t\tmethodCall.callType = \"method\"\n\t\t\t\tbreak\n\n\t\t\tcase \"method.call.receiver\":\n\t\t\t\t// \u65B9\u6CD5\u8C03\u7528\u7684\u63A5\u6536\u8005\n\t\t\t\tif (!callsByLine.has(line)) {\n\t\t\t\t\tcallsByLine.set(line, {})\n\t\t\t\t}\n\t\t\t\tcallsByLine.get(line)!.receiver = captureText\n\t\t\t\tbreak\n\n\t\t\tcase \"static.call.class\":\n\t\t\t\t// \u9759\u6001\u65B9\u6CD5\u8C03\u7528\u7684\u7C7B\u540D\n\t\t\t\tif (!callsByLine.has(line)) {\n\t\t\t\t\tcallsByLine.set(line, {})\n\t\t\t\t}\n\t\t\t\tconst staticCall = callsByLine.get(line)!\n\t\t\t\tstaticCall.className = captureText\n\t\t\t\tstaticCall.callType = \"static\"\n\t\t\t\tbreak\n\n\t\t\tcase \"static.call.method\":\n\t\t\t\t// \u9759\u6001\u65B9\u6CD5\u8C03\u7528\u7684\u65B9\u6CD5\u540D\n\t\t\t\tif (!callsByLine.has(line)) {\n\t\t\t\t\tcallsByLine.set(line, {})\n\t\t\t\t}\n\t\t\t\tcallsByLine.get(line)!.functionName = captureText\n\t\t\t\tbreak\n\n\t\t\tcase \"this.call.method\":\n\t\t\t\t// this\u65B9\u6CD5\u8C03\u7528\n\t\t\t\tfunctionCalls.push({\n\t\t\t\t\tcalledFunctionName: captureText,\n\t\t\t\t\tcallType: \"this\",\n\t\t\t\t\treceiver: \"this\",\n\t\t\t\t\tline: line + 1,\n\t\t\t\t\tcolumn: node.startPosition.column,\n\t\t\t\t})\n\t\t\t\tbreak\n\n\t\t\tcase \"super.call.receiver\":\n\t\t\t\t// super\u65B9\u6CD5\u8C03\u7528\u7684\u63A5\u6536\u8005\n\t\t\t\tif (!callsByLine.has(line)) {\n\t\t\t\t\tcallsByLine.set(line, {})\n\t\t\t\t}\n\t\t\t\tcallsByLine.get(line)!.receiver = \"super\"\n\t\t\t\tbreak\n\n\t\t\tcase \"super.call.method\":\n\t\t\t\t// super\u65B9\u6CD5\u8C03\u7528\u7684\u65B9\u6CD5\u540D\n\t\t\t\tif (!callsByLine.has(line)) {\n\t\t\t\t\tcallsByLine.set(line, {})\n\t\t\t\t}\n\t\t\t\tconst superCall = callsByLine.get(line)!\n\t\t\t\tsuperCall.functionName = captureText\n\t\t\t\tsuperCall.callType = \"super\"\n\t\t\t\tbreak\n\n\t\t\tcase \"constructor.call.name\":\n\t\t\t\t// \u6784\u9020\u51FD\u6570\u8C03\u7528\n\t\t\t\tfunctionCalls.push({\n\t\t\t\t\tcalledFunctionName: captureText,\n\t\t\t\t\tcallType: \"constructor\",\n\t\t\t\t\tline: line + 1,\n\t\t\t\t\tcolumn: node.startPosition.column,\n\t\t\t\t})\n\t\t\t\tbreak\n\n\t\t\tcase \"method.call.chain\":\n\t\t\t\t// \u94FE\u5F0F\u65B9\u6CD5\u8C03\u7528\n\t\t\t\tfunctionCalls.push({\n\t\t\t\t\tcalledFunctionName: captureText,\n\t\t\t\t\tcallType: \"chain\",\n\t\t\t\t\tline: line + 1,\n\t\t\t\t\tcolumn: node.startPosition.column,\n\t\t\t\t})\n\t\t\t\tbreak\n\n\t\t\tcase \"namespace.call.name\":\n\t\t\t\t// \u547D\u540D\u7A7A\u95F4\u8C03\u7528\u7684\u547D\u540D\u7A7A\u95F4\u540D\n\t\t\t\tif (!callsByLine.has(line)) {\n\t\t\t\t\tcallsByLine.set(line, {})\n\t\t\t\t}\n\t\t\t\tconst namespaceCall = callsByLine.get(line)!\n\t\t\t\tnamespaceCall.namespace = captureText\n\t\t\t\tnamespaceCall.callType = \"namespace\"\n\t\t\t\tbreak\n\n\t\t\tcase \"namespace.call.function\":\n\t\t\t\t// \u547D\u540D\u7A7A\u95F4\u8C03\u7528\u7684\u51FD\u6570\u540D\n\t\t\t\tif (!callsByLine.has(line)) {\n\t\t\t\t\tcallsByLine.set(line, {})\n\t\t\t\t}\n\t\t\t\tcallsByLine.get(line)!.functionName = captureText\n\t\t\t\tbreak\n\n\t\t\tcase \"arrow.call.function\":\n\t\t\t\t// \u7BAD\u5934\u51FD\u6570\u8C03\u7528\n\t\t\t\tfunctionCalls.push({\n\t\t\t\t\tcalledFunctionName: \"arrow_function\",\n\t\t\t\t\tcallType: \"arrow\",\n\t\t\t\t\tline: line + 1,\n\t\t\t\t\tcolumn: node.startPosition.column,\n\t\t\t\t})\n\t\t\t\tbreak\n\n\t\t\tcase \"function.call.expression\":\n\t\t\t\t// \u51FD\u6570\u8868\u8FBE\u5F0F\u8C03\u7528\n\t\t\t\tfunctionCalls.push({\n\t\t\t\t\tcalledFunctionName: \"function_expression\",\n\t\t\t\t\tcallType: \"arrow\", // \u5F52\u7C7B\u4E3A\u7BAD\u5934\u51FD\u6570\u7C7B\u578B\n\t\t\t\t\tline: line + 1,\n\t\t\t\t\tcolumn: node.startPosition.column,\n\t\t\t\t})\n\t\t\t\tbreak\n\n\t\t\tcase \"array.call.method\":\n\t\t\t\t// \u6570\u7EC4\u65B9\u6CD5\u8C03\u7528\n\t\t\t\tif (!callsByLine.has(line)) {\n\t\t\t\t\tcallsByLine.set(line, {})\n\t\t\t\t}\n\t\t\t\tconst arrayCall = callsByLine.get(line)!\n\t\t\t\tarrayCall.functionName = captureText\n\t\t\t\tarrayCall.callType = \"array\"\n\t\t\t\tbreak\n\n\t\t\tcase \"array.call.object\":\n\t\t\t\t// \u6570\u7EC4\u65B9\u6CD5\u8C03\u7528\u7684\u5BF9\u8C61\n\t\t\t\tif (!callsByLine.has(line)) {\n\t\t\t\t\tcallsByLine.set(line, {})\n\t\t\t\t}\n\t\t\t\tcallsByLine.get(line)!.receiver = captureText\n\t\t\t\tbreak\n\n\t\t\tcase \"promise.call.method\":\n\t\t\t\t// Promise \u65B9\u6CD5\u8C03\u7528\n\t\t\t\tif (!callsByLine.has(line)) {\n\t\t\t\t\tcallsByLine.set(line, {})\n\t\t\t\t}\n\t\t\t\tconst promiseCall = callsByLine.get(line)!\n\t\t\t\tpromiseCall.functionName = captureText\n\t\t\t\tpromiseCall.callType = \"promise\"\n\t\t\t\tbreak\n\n\t\t\tcase \"promise.call.object\":\n\t\t\t\t// Promise \u65B9\u6CD5\u8C03\u7528\u7684\u5BF9\u8C61\n\t\t\t\tif (!callsByLine.has(line)) {\n\t\t\t\t\tcallsByLine.set(line, {})\n\t\t\t\t}\n\t\t\t\tcallsByLine.get(line)!.receiver = captureText\n\t\t\t\tbreak\n\n\t\t\tcase \"template.call.function\":\n\t\t\t\t// \u6A21\u677F\u5B57\u7B26\u4E32\u4E2D\u7684\u51FD\u6570\u8C03\u7528\n\t\t\t\tfunctionCalls.push({\n\t\t\t\t\tcalledFunctionName: captureText,\n\t\t\t\t\tcallType: \"template\",\n\t\t\t\t\tline: line + 1,\n\t\t\t\t\tcolumn: node.startPosition.column,\n\t\t\t\t})\n\t\t\t\tbreak\n\n\t\t\tcase \"optional.call.receiver\":\n\t\t\t\t// \u53EF\u9009\u94FE\u8C03\u7528\u7684\u63A5\u6536\u8005\n\t\t\t\tif (!callsByLine.has(line)) {\n\t\t\t\t\tcallsByLine.set(line, {})\n\t\t\t\t}\n\t\t\t\tconst optionalCall = callsByLine.get(line)!\n\t\t\t\toptionalCall.receiver = captureText\n\t\t\t\toptionalCall.isOptional = true\n\t\t\t\tbreak\n\n\t\t\tcase \"optional.call.method\":\n\t\t\t\t// \u53EF\u9009\u94FE\u8C03\u7528\u7684\u65B9\u6CD5\u540D\n\t\t\t\tif (!callsByLine.has(line)) {\n\t\t\t\t\tcallsByLine.set(line, {})\n\t\t\t\t}\n\t\t\t\tconst optionalMethodCall = callsByLine.get(line)!\n\t\t\t\toptionalMethodCall.functionName = captureText\n\t\t\t\toptionalMethodCall.callType = \"optional\"\n\t\t\t\tbreak\n\n\t\t\tcase \"await.call.function\":\n\t\t\t\t// await \u8868\u8FBE\u5F0F\u4E2D\u7684\u51FD\u6570\u8C03\u7528\n\t\t\t\tfunctionCalls.push({\n\t\t\t\t\tcalledFunctionName: captureText,\n\t\t\t\t\tcallType: \"async\",\n\t\t\t\t\tisAsync: true,\n\t\t\t\t\tline: line + 1,\n\t\t\t\t\tcolumn: node.startPosition.column,\n\t\t\t\t})\n\t\t\t\tbreak\n\n\t\t\tcase \"async.call.receiver\":\n\t\t\t\t// \u5F02\u6B65\u65B9\u6CD5\u8C03\u7528\u7684\u63A5\u6536\u8005\n\t\t\t\tif (!callsByLine.has(line)) {\n\t\t\t\t\tcallsByLine.set(line, {})\n\t\t\t\t}\n\t\t\t\tconst asyncCall = callsByLine.get(line)!\n\t\t\t\tasyncCall.receiver = captureText\n\t\t\t\tasyncCall.isAsync = true\n\t\t\t\tbreak\n\n\t\t\tcase \"async.call.method\":\n\t\t\t\t// \u5F02\u6B65\u65B9\u6CD5\u8C03\u7528\u7684\u65B9\u6CD5\u540D\n\t\t\t\tif (!callsByLine.has(line)) {\n\t\t\t\t\tcallsByLine.set(line, {})\n\t\t\t\t}\n\t\t\t\tconst asyncMethodCall = callsByLine.get(line)!\n\t\t\t\tasyncMethodCall.functionName = captureText\n\t\t\t\tasyncMethodCall.callType = \"async\"\n\t\t\t\tbreak\n\n\t\t\tcase \"nested.call.method\":\n\t\t\t\t// \u5D4C\u5957\u5C5E\u6027\u8C03\u7528\n\t\t\t\tif (!callsByLine.has(line)) {\n\t\t\t\t\tcallsByLine.set(line, {})\n\t\t\t\t}\n\t\t\t\tconst nestedCall = callsByLine.get(line)!\n\t\t\t\tnestedCall.functionName = captureText\n\t\t\t\tnestedCall.callType = \"nested\"\n\t\t\t\tbreak\n\n\t\t\tcase \"nested.call.root\":\n\t\t\t\t// \u5D4C\u5957\u5C5E\u6027\u8C03\u7528\u7684\u6839\u5BF9\u8C61\n\t\t\t\tif (!callsByLine.has(line)) {\n\t\t\t\t\tcallsByLine.set(line, {})\n\t\t\t\t}\n\t\t\t\tcallsByLine.get(line)!.receiver = captureText\n\t\t\t\tbreak\n\n\t\t\tdefault:\n\t\t\t\t// \u5FFD\u7565\u672A\u77E5\u7684\u6355\u83B7\u7C7B\u578B\n\t\t\t\tbreak\n\t\t}\n\t}\n\n\t// \u5904\u7406\u6309\u884C\u5206\u7EC4\u7684\u590D\u5408\u8C03\u7528\n\tfor (const [line, callInfo] of callsByLine) {\n\t\tif (callInfo.functionName) {\n\t\t\tfunctionCalls.push({\n\t\t\t\tcalledFunctionName: callInfo.functionName,\n\t\t\t\tcallType: callInfo.callType || \"method\",\n\t\t\t\treceiver: callInfo.receiver,\n\t\t\t\tclassName: callInfo.className,\n\t\t\t\tnamespace: callInfo.namespace,\n\t\t\t\tline: line + 1,\n\t\t\t\tcolumn: 0,\n\t\t\t\tisAsync: callInfo.isAsync,\n\t\t\t\tisOptional: callInfo.isOptional,\n\t\t\t})\n\t\t}\n\t}\n\n\treturn {\n\t\tfunctionCalls,\n\t\tscopeInfo,\n\t}\n}\n", "import Parser from \"web-tree-sitter\"\nimport { CodeLanguageType, ISnippetMeta, SnippetType } from \"../types\"\n\nexport interface JavaFunctionCallInfo {\n\tcalledFunctionName: string\n\tcallType:\n\t\t| \"direct\"\n\t\t| \"method\"\n\t\t| \"static\"\n\t\t| \"field\"\n\t\t| \"constructor\"\n\t\t| \"this\"\n\t\t| \"super\"\n\t\t| \"chain\"\n\t\t| \"lambda\"\n\t\t| \"stream\"\n\t\t| \"array\"\n\t\t| \"collection\"\n\t\t| \"inner\"\n\t\t| \"package\"\n\t\t| \"generic\"\n\t\t| \"exception\"\n\treceiver?: string // \u5BF9\u4E8E\u65B9\u6CD5\u8C03\u7528\uFF0C\u63A5\u6536\u8005\u7684\u540D\u79F0\n\tclassName?: string // \u5BF9\u4E8E\u9759\u6001\u65B9\u6CD5\u8C03\u7528\uFF0C\u7C7B\u7684\u540D\u79F0\n\tpackageName?: string // \u5BF9\u4E8E\u5305\u9650\u5B9A\u8C03\u7528\uFF0C\u5305\u7684\u540D\u79F0\n\tfieldName?: string // \u5BF9\u4E8E\u5B57\u6BB5\u8BBF\u95EE\u540E\u7684\u65B9\u6CD5\u8C03\u7528\uFF0C\u5B57\u6BB5\u7684\u540D\u79F0\n\tline: number\n\tcolumn: number\n\tisGeneric?: boolean // \u662F\u5426\u662F\u6CDB\u578B\u8C03\u7528\n\tisException?: boolean // \u662F\u5426\u5728\u5F02\u5E38\u5904\u7406\u4E2D\n}\n\nexport interface JavaFunctionCallAnalysisResult {\n\tfunctionCalls: JavaFunctionCallInfo[]\n\tscopeInfo: {\n\t\tpackageName?: string\n\t\tclassName?: string // \u5982\u679C\u51FD\u6570\u662F\u67D0\u4E2A\u7C7B\u7684\u65B9\u6CD5\n\t\tfunctionName: string\n\t}\n}\n\nexport function dependenciesCapturesProcessForJava(captures: Parser.QueryCapture[]): ISnippetMeta[] {\n\tconst result = analyzeJavaFunctionCalls(captures)\n\treturn result.functionCalls.map((call) => ({\n\t\tname: call.calledFunctionName,\n\t\ttype: SnippetType.FunctionOrMethod,\n\t\tfilePath: \"\",\n\t\tstartLine: call.line,\n\t\tendLine: call.line,\n\t\tstartPosition: {\n\t\t\trow: call.line,\n\t\t\tcolumn: call.column,\n\t\t},\n\t\tendPosition: {\n\t\t\trow: call.line,\n\t\t\tcolumn: call.column,\n\t\t},\n\t\trangeText: \"\",\n\t\tfileHash: \"\",\n\t\tdefinition: {\n\t\t\tname: call.calledFunctionName,\n\t\t\ttype: call.callType,\n\t\t},\n\t\tfield: call.className || call.packageName,\n\t\tsignature: `${call.calledFunctionName}()`,\n\t\tlanguage: CodeLanguageType.Java,\n\t}))\n}\n\n/**\n * \u5206\u6790 Java \u8BED\u8A00\u7684\u51FD\u6570\u8C03\u7528\n */\nfunction analyzeJavaFunctionCalls(captures: Parser.QueryCapture[]): JavaFunctionCallAnalysisResult {\n\tconst functionCalls: JavaFunctionCallInfo[] = []\n\tconst scopeInfo = {\n\t\tpackageName: undefined as string | undefined,\n\t\tclassName: undefined as string | undefined,\n\t\tfunctionName: \"unknown\",\n\t}\n\n\t// \u7528\u4E8E\u4E34\u65F6\u5B58\u50A8\u540C\u4E00\u884C\u7684\u65B9\u6CD5\u8C03\u7528\u4FE1\u606F\n\tconst callsByLine = new Map<\n\t\tnumber,\n\t\t{\n\t\t\tfunctionName?: string\n\t\t\treceiver?: string\n\t\t\tclassName?: string\n\t\t\tpackageName?: string\n\t\t\tfieldName?: string\n\t\t\tcallType?: JavaFunctionCallInfo[\"callType\"]\n\t\t\tisGeneric?: boolean\n\t\t\tisException?: boolean\n\t\t}\n\t>()\n\n\t// \u5904\u7406\u5404\u79CD\u7C7B\u578B\u7684\u6355\u83B7\n\tfor (const capture of captures) {\n\t\tconst node = capture.node\n\t\tconst captureText = node.text.trim()\n\t\tconst line = node.startPosition.row\n\n\t\tswitch (capture.name) {\n\t\t\tcase \"method.call.direct\":\n\t\t\t\t// \u76F4\u63A5\u65B9\u6CD5\u8C03\u7528\n\t\t\t\tfunctionCalls.push({\n\t\t\t\t\tcalledFunctionName: captureText,\n\t\t\t\t\tcallType: \"direct\",\n\t\t\t\t\tline: line + 1,\n\t\t\t\t\tcolumn: node.startPosition.column,\n\t\t\t\t})\n\t\t\t\tbreak\n\n\t\t\tcase \"method.call.name\":\n\t\t\t\t// \u65B9\u6CD5\u8C03\u7528\u7684\u65B9\u6CD5\u540D\n\t\t\t\tif (!callsByLine.has(line)) {\n\t\t\t\t\tcallsByLine.set(line, {})\n\t\t\t\t}\n\t\t\t\tconst methodCall = callsByLine.get(line)!\n\t\t\t\tmethodCall.functionName = captureText\n\t\t\t\tmethodCall.callType = \"method\"\n\t\t\t\tbreak\n\n\t\t\tcase \"method.call.receiver\":\n\t\t\t\t// \u65B9\u6CD5\u8C03\u7528\u7684\u63A5\u6536\u8005\n\t\t\t\tif (!callsByLine.has(line)) {\n\t\t\t\t\tcallsByLine.set(line, {})\n\t\t\t\t}\n\t\t\t\tcallsByLine.get(line)!.receiver = captureText\n\t\t\t\tbreak\n\n\t\t\tcase \"static.call.class\":\n\t\t\t\t// \u9759\u6001\u65B9\u6CD5\u8C03\u7528\u7684\u7C7B\u540D\n\t\t\t\tif (!callsByLine.has(line)) {\n\t\t\t\t\tcallsByLine.set(line, {})\n\t\t\t\t}\n\t\t\t\tconst staticCall = callsByLine.get(line)!\n\t\t\t\tstaticCall.className = captureText\n\t\t\t\tstaticCall.callType = \"static\"\n\t\t\t\tbreak\n\n\t\t\tcase \"static.call.method\":\n\t\t\t\t// \u9759\u6001\u65B9\u6CD5\u8C03\u7528\u7684\u65B9\u6CD5\u540D\n\t\t\t\tif (!callsByLine.has(line)) {\n\t\t\t\t\tcallsByLine.set(line, {})\n\t\t\t\t}\n\t\t\t\tcallsByLine.get(line)!.functionName = captureText\n\t\t\t\tbreak\n\n\t\t\tcase \"this.call.method\":\n\t\t\t\t// this\u65B9\u6CD5\u8C03\u7528\n\t\t\t\tfunctionCalls.push({\n\t\t\t\t\tcalledFunctionName: captureText,\n\t\t\t\t\tcallType: \"this\",\n\t\t\t\t\treceiver: \"this\",\n\t\t\t\t\tline: line + 1,\n\t\t\t\t\tcolumn: node.startPosition.column,\n\t\t\t\t})\n\t\t\t\tbreak\n\n\t\t\tcase \"super.call.method\":\n\t\t\t\t// super\u65B9\u6CD5\u8C03\u7528\n\t\t\t\tfunctionCalls.push({\n\t\t\t\t\tcalledFunctionName: captureText,\n\t\t\t\t\tcallType: \"super\",\n\t\t\t\t\treceiver: \"super\",\n\t\t\t\t\tline: line + 1,\n\t\t\t\t\tcolumn: node.startPosition.column,\n\t\t\t\t})\n\t\t\t\tbreak\n\n\t\t\tcase \"constructor.call.name\":\n\t\t\t\t// \u6784\u9020\u51FD\u6570\u8C03\u7528\n\t\t\t\tfunctionCalls.push({\n\t\t\t\t\tcalledFunctionName: captureText,\n\t\t\t\t\tcallType: \"constructor\",\n\t\t\t\t\tline: line + 1,\n\t\t\t\t\tcolumn: node.startPosition.column,\n\t\t\t\t})\n\t\t\t\tbreak\n\n\t\t\tcase \"method.call.chain\":\n\t\t\t\t// \u94FE\u5F0F\u65B9\u6CD5\u8C03\u7528\n\t\t\t\tfunctionCalls.push({\n\t\t\t\t\tcalledFunctionName: captureText,\n\t\t\t\t\tcallType: \"chain\",\n\t\t\t\t\tline: line + 1,\n\t\t\t\t\tcolumn: node.startPosition.column,\n\t\t\t\t})\n\t\t\t\tbreak\n\n\t\t\tdefault:\n\t\t\t\tbreak\n\t\t}\n\t}\n\n\t// \u5904\u7406\u590D\u5408\u8C03\u7528\u4FE1\u606F\n\tfor (const [line, callInfo] of callsByLine) {\n\t\tif (callInfo.functionName) {\n\t\t\tconst callData: JavaFunctionCallInfo = {\n\t\t\t\tcalledFunctionName: callInfo.functionName,\n\t\t\t\tcallType: callInfo.callType || \"method\",\n\t\t\t\treceiver: callInfo.receiver,\n\t\t\t\tclassName: callInfo.className,\n\t\t\t\tpackageName: callInfo.packageName,\n\t\t\t\tfieldName: callInfo.fieldName,\n\t\t\t\tline: line + 1,\n\t\t\t\tcolumn: 0,\n\t\t\t\tisGeneric: callInfo.isGeneric,\n\t\t\t\tisException: callInfo.isException,\n\t\t\t}\n\n\t\t\tfunctionCalls.push(callData)\n\t\t}\n\t}\n\n\treturn { functionCalls, scopeInfo }\n}\n\nexport function filterRelevantJavaFunctionCalls(\n\tcallAnalysis: JavaFunctionCallAnalysisResult,\n\tallFunctions: ISnippetMeta[],\n\tcurrentFunction: ISnippetMeta,\n\tlanguage: CodeLanguageType,\n): ISnippetMeta[] {\n\tconst relevantFunctions: ISnippetMeta[] = []\n\n\tfor (const call of callAnalysis.functionCalls) {\n\t\t// \u67E5\u627E\u5BF9\u5E94\u7684\u51FD\u6570\u5B9A\u4E49\n\t\tconst targetFunction = findJavaTargetFunction(call, allFunctions, callAnalysis.scopeInfo)\n\n\t\tif (targetFunction && targetFunction.name !== currentFunction.name) {\n\t\t\t// \u68C0\u67E5\u662F\u5426\u5DF2\u7ECF\u6DFB\u52A0\u8FC7\n\t\t\tif (!relevantFunctions.find((f) => f.name === targetFunction.name)) {\n\t\t\t\trelevantFunctions.push(targetFunction)\n\t\t\t}\n\t\t}\n\t}\n\n\treturn relevantFunctions\n}\n\n/**\n * \u67E5\u627E Java \u8BED\u8A00\u7684\u76EE\u6807\u51FD\u6570\n */\nfunction findJavaTargetFunction(\n\tcall: JavaFunctionCallInfo,\n\tallFunctions: ISnippetMeta[],\n\tscopeInfo: JavaFunctionCallAnalysisResult[\"scopeInfo\"],\n): ISnippetMeta | null {\n\tswitch (call.callType) {\n\t\tcase \"direct\":\n\t\t\t// \u76F4\u63A5\u65B9\u6CD5\u8C03\u7528\uFF1A\u67E5\u627E\u540C\u7C7B\u7684\u65B9\u6CD5\n\t\t\treturn (\n\t\t\t\tallFunctions.find(\n\t\t\t\t\t(func) => func.name === call.calledFunctionName && func.field === scopeInfo.className,\n\t\t\t\t) || null\n\t\t\t)\n\n\t\tcase \"method\":\n\t\t\t// \u65B9\u6CD5\u8C03\u7528\uFF1A\u67E5\u627E\u6307\u5B9A\u5BF9\u8C61\u7684\u65B9\u6CD5\n\t\t\tif (call.receiver === scopeInfo.className) {\n\t\t\t\t// \u540C\u7C7B\u5B9E\u4F8B\u65B9\u6CD5\u8C03\u7528\n\t\t\t\treturn (\n\t\t\t\t\tallFunctions.find(\n\t\t\t\t\t\t(func) => func.name === call.calledFunctionName && func.field === scopeInfo.className,\n\t\t\t\t\t) || null\n\t\t\t\t)\n\t\t\t}\n\t\t\tbreak\n\n\t\tcase \"this\":\n\t\t\t// this\u65B9\u6CD5\u8C03\u7528\uFF1A\u67E5\u627E\u540C\u7C7B\u7684\u65B9\u6CD5\n\t\t\treturn (\n\t\t\t\tallFunctions.find(\n\t\t\t\t\t(func) => func.name === call.calledFunctionName && func.field === scopeInfo.className,\n\t\t\t\t) || null\n\t\t\t)\n\n\t\tcase \"static\":\n\t\t\t// \u9759\u6001\u65B9\u6CD5\u8C03\u7528\uFF1A\u67E5\u627E\u6307\u5B9A\u7C7B\u7684\u9759\u6001\u65B9\u6CD5\n\t\t\treturn (\n\t\t\t\tallFunctions.find((func) => func.name === call.calledFunctionName && func.field === call.className) ||\n\t\t\t\tnull\n\t\t\t)\n\n\t\tcase \"field\":\n\t\t\t// \u5B57\u6BB5\u8BBF\u95EE\u540E\u7684\u65B9\u6CD5\u8C03\u7528\uFF1A\u901A\u5E38\u662F\u5176\u4ED6\u7C7B\u7684\u65B9\u6CD5\uFF0C\u53EF\u80FD\u4E0D\u5728\u540C\u6587\u4EF6\u4E2D\n\t\t\treturn null\n\n\t\tcase \"constructor\":\n\t\t\t// \u6784\u9020\u51FD\u6570\u8C03\u7528\uFF1A\u67E5\u627E\u7C7B\u5B9A\u4E49\n\t\t\treturn allFunctions.find((func) => func.name === call.calledFunctionName) || null\n\n\t\tcase \"super\":\n\t\t\t// super\u8C03\u7528\uFF1A\u901A\u5E38\u662F\u7236\u7C7B\u65B9\u6CD5\uFF0C\u53EF\u80FD\u4E0D\u5728\u540C\u6587\u4EF6\u4E2D\n\t\t\treturn null\n\n\t\tcase \"chain\":\n\t\tcase \"lambda\":\n\t\tcase \"stream\":\n\t\tcase \"array\":\n\t\tcase \"collection\":\n\t\tcase \"inner\":\n\t\tcase \"package\":\n\t\tcase \"generic\":\n\t\tcase \"exception\":\n\t\t\t// \u8FD9\u4E9B\u8C03\u7528\u7C7B\u578B\u901A\u5E38\u6D89\u53CA\u5185\u7F6E\u65B9\u6CD5\u3001\u5916\u90E8\u7C7B\u6216\u590D\u6742\u8C03\u7528\u94FE\uFF0C\u4E0D\u9700\u8981\u5305\u542B\u5728\u4E0A\u4E0B\u6587\u4E2D\n\t\t\treturn null\n\t}\n\n\treturn null\n}\n", "import Parser from \"web-tree-sitter\"\nimport { CodeLanguageType, ISnippetMeta, SnippetType } from \"../types\"\n\nexport interface PythonFunctionCallInfo {\n\tcalledFunctionName: string\n\tcallType:\n\t\t| \"direct\"\n\t\t| \"method\"\n\t\t| \"class\"\n\t\t| \"self\"\n\t\t| \"super\"\n\t\t| \"async\"\n\t\t| \"decorator\"\n\t\t| \"chain\"\n\t\t| \"comprehension\"\n\t\t| \"generator\"\n\t\t| \"lambda\"\n\t\t| \"nested\"\n\t\t| \"argument\"\n\treceiver?: string // \u5BF9\u4E8E\u65B9\u6CD5\u8C03\u7528\uFF0C\u63A5\u6536\u8005\u7684\u540D\u79F0\n\tclassName?: string // \u5BF9\u4E8E\u7C7B\u65B9\u6CD5\u8C03\u7528\uFF0C\u7C7B\u7684\u540D\u79F0\n\tline: number\n\tcolumn: number\n\tisAsync?: boolean // \u662F\u5426\u662F\u5F02\u6B65\u8C03\u7528\n\tisDecorator?: boolean // \u662F\u5426\u662F\u88C5\u9970\u5668\u8C03\u7528\n}\n\nexport interface PythonFunctionCallAnalysisResult {\n\tfunctionCalls: PythonFunctionCallInfo[]\n\tscopeInfo: {\n\t\tmoduleName?: string\n\t\tclassName?: string // \u5982\u679C\u51FD\u6570\u662F\u67D0\u4E2A\u7C7B\u7684\u65B9\u6CD5\n\t\tfunctionName: string\n\t\tisAsync?: boolean\n\t}\n}\n\nexport function dependenciesCapturesProcessForPython(captures: Parser.QueryCapture[]): ISnippetMeta[] {\n\tconst result = analyzePythonFunctionCalls(captures)\n\treturn result.functionCalls.map((call) => ({\n\t\tname: call.calledFunctionName,\n\t\ttype: SnippetType.FunctionOrMethod,\n\t\tfilePath: \"\",\n\t\tstartLine: call.line,\n\t\tendLine: call.line,\n\t\tstartPosition: {\n\t\t\trow: call.line,\n\t\t\tcolumn: call.column,\n\t\t},\n\t\tendPosition: {\n\t\t\trow: call.line,\n\t\t\tcolumn: call.column,\n\t\t},\n\t\trangeText: \"\",\n\t\tfileHash: \"\",\n\t\tdefinition: {\n\t\t\tname: call.calledFunctionName,\n\t\t\ttype: call.callType,\n\t\t},\n\t\tfield: call.className,\n\t\tsignature: `${call.calledFunctionName}()`,\n\t\tlanguage: CodeLanguageType.Python,\n\t}))\n}\n\n/**\n * \u5206\u6790 Python \u8BED\u8A00\u7684\u51FD\u6570\u8C03\u7528\n */\nfunction analyzePythonFunctionCalls(captures: Parser.QueryCapture[]): PythonFunctionCallAnalysisResult {\n\tconst functionCalls: PythonFunctionCallInfo[] = []\n\tconst scopeInfo = {\n\t\tmoduleName: undefined as string | undefined,\n\t\tclassName: undefined as string | undefined,\n\t\tfunctionName: \"unknown\",\n\t\tisAsync: false,\n\t}\n\n\tconsole.log(`[analyzePythonFunctionCalls] Processing ${captures.length} captures`)\n\n\t// \u7528\u4E8E\u4E34\u65F6\u5B58\u50A8\u540C\u4E00\u884C\u7684\u8C03\u7528\u4FE1\u606F\n\tconst callsByLine = new Map<\n\t\tnumber,\n\t\t{\n\t\t\tfunctionName?: string\n\t\t\treceiver?: string\n\t\t\tclassName?: string\n\t\t\tcallType?: PythonFunctionCallInfo[\"callType\"]\n\t\t\tisAsync?: boolean\n\t\t\tisDecorator?: boolean\n\t\t\tintermediate?: string // \u7528\u4E8E\u5D4C\u5957\u8C03\u7528\n\t\t\troot?: string // \u7528\u4E8E\u5D4C\u5957\u8C03\u7528\n\t\t}\n\t>()\n\n\t// \u5904\u7406\u5404\u79CD\u7C7B\u578B\u7684\u6355\u83B7\n\tfor (const capture of captures) {\n\t\tconst node = capture.node\n\t\tconst captureText = node.text.trim()\n\t\tconst line = node.startPosition.row\n\n\t\tconsole.log(`[analyzePythonFunctionCalls] Processing capture: ${capture.name} = \"${captureText}\"`)\n\n\t\tswitch (capture.name) {\n\t\t\tcase \"function.call.direct\":\n\t\t\t\t// \u76F4\u63A5\u51FD\u6570\u8C03\u7528\n\t\t\t\tconsole.log(`[analyzePythonFunctionCalls] Adding direct function call: ${captureText}`)\n\t\t\t\tif (!callsByLine.has(line)) {\n\t\t\t\t\tcallsByLine.set(line, {})\n\t\t\t\t}\n\t\t\t\tconst directCall = callsByLine.get(line)!\n\t\t\t\t// \u603B\u662F\u8BBE\u7F6E\u51FD\u6570\u540D\u79F0\uFF0C\u4F46\u53EA\u6709\u5728\u6CA1\u6709\u5176\u4ED6\u7C7B\u578B\u65F6\u624D\u8BBE\u7F6E\u4E3A\u76F4\u63A5\u8C03\u7528\n\t\t\t\tif (!directCall.functionName) {\n\t\t\t\t\tdirectCall.functionName = captureText\n\t\t\t\t}\n\t\t\t\tif (!directCall.callType) {\n\t\t\t\t\tdirectCall.callType = \"direct\"\n\t\t\t\t}\n\t\t\t\tbreak\n\n\t\t\tcase \"method.call.name\":\n\t\t\t\t// \u65B9\u6CD5\u8C03\u7528\u7684\u65B9\u6CD5\u540D\n\t\t\t\tif (!callsByLine.has(line)) {\n\t\t\t\t\tcallsByLine.set(line, {})\n\t\t\t\t}\n\t\t\t\tconst methodCall = callsByLine.get(line)!\n\t\t\t\tmethodCall.functionName = captureText\n\t\t\t\tmethodCall.callType = \"method\"\n\t\t\t\tbreak\n\n\t\t\tcase \"method.call.receiver\":\n\t\t\t\t// \u65B9\u6CD5\u8C03\u7528\u7684\u63A5\u6536\u8005\n\t\t\t\tif (!callsByLine.has(line)) {\n\t\t\t\t\tcallsByLine.set(line, {})\n\t\t\t\t}\n\t\t\t\tcallsByLine.get(line)!.receiver = captureText\n\t\t\t\tbreak\n\n\t\t\tcase \"class.call.name\":\n\t\t\t\t// \u7C7B\u65B9\u6CD5\u8C03\u7528\u7684\u7C7B\u540D\n\t\t\t\tif (!callsByLine.has(line)) {\n\t\t\t\t\tcallsByLine.set(line, {})\n\t\t\t\t}\n\t\t\t\tconst classCall = callsByLine.get(line)!\n\t\t\t\tclassCall.className = captureText\n\t\t\t\tclassCall.callType = \"class\"\n\t\t\t\tbreak\n\n\t\t\tcase \"class.call.method\":\n\t\t\t\t// \u7C7B\u65B9\u6CD5\u8C03\u7528\u7684\u65B9\u6CD5\u540D\n\t\t\t\tif (!callsByLine.has(line)) {\n\t\t\t\t\tcallsByLine.set(line, {})\n\t\t\t\t}\n\t\t\t\tcallsByLine.get(line)!.functionName = captureText\n\t\t\t\tbreak\n\n\t\t\tcase \"self.call.receiver\":\n\t\t\t\t// self\u65B9\u6CD5\u8C03\u7528\u7684\u63A5\u6536\u8005\n\t\t\t\tif (!callsByLine.has(line)) {\n\t\t\t\t\tcallsByLine.set(line, {})\n\t\t\t\t}\n\t\t\t\tconst selfCall = callsByLine.get(line)!\n\t\t\t\tselfCall.receiver = captureText\n\t\t\t\tselfCall.callType = \"self\"\n\t\t\t\tbreak\n\n\t\t\tcase \"self.call.method\":\n\t\t\t\t// self\u65B9\u6CD5\u8C03\u7528\u7684\u65B9\u6CD5\u540D\n\t\t\t\tif (!callsByLine.has(line)) {\n\t\t\t\t\tcallsByLine.set(line, {})\n\t\t\t\t}\n\t\t\t\tcallsByLine.get(line)!.functionName = captureText\n\t\t\t\tbreak\n\n\t\t\tcase \"super.call.function\":\n\t\t\t\t// super\u8C03\u7528\u7684\u51FD\u6570\u540D\n\t\t\t\tif (!callsByLine.has(line)) {\n\t\t\t\t\tcallsByLine.set(line, {})\n\t\t\t\t}\n\t\t\t\tconst superCall = callsByLine.get(line)!\n\t\t\t\tsuperCall.receiver = \"super\"\n\t\t\t\tsuperCall.callType = \"super\"\n\t\t\t\tbreak\n\n\t\t\tcase \"super.call.method\":\n\t\t\t\t// super\u8C03\u7528\u7684\u65B9\u6CD5\u540D\n\t\t\t\tif (!callsByLine.has(line)) {\n\t\t\t\t\tcallsByLine.set(line, {})\n\t\t\t\t}\n\t\t\t\tcallsByLine.get(line)!.functionName = captureText\n\t\t\t\tbreak\n\n\t\t\tcase \"async.call.function\":\n\t\t\t\t// \u5F02\u6B65\u51FD\u6570\u8C03\u7528\n\t\t\t\tconsole.log(`[analyzePythonFunctionCalls] Adding async function call: ${captureText}`)\n\t\t\t\tif (!callsByLine.has(line)) {\n\t\t\t\t\tcallsByLine.set(line, {})\n\t\t\t\t}\n\t\t\t\tconst asyncDirectCall = callsByLine.get(line)!\n\t\t\t\tasyncDirectCall.functionName = captureText\n\t\t\t\tasyncDirectCall.callType = \"async\"\n\t\t\t\tasyncDirectCall.isAsync = true\n\t\t\t\tbreak\n\n\t\t\tcase \"async.call.receiver\":\n\t\t\t\t// \u5F02\u6B65\u65B9\u6CD5\u8C03\u7528\u7684\u63A5\u6536\u8005\n\t\t\t\tif (!callsByLine.has(line)) {\n\t\t\t\t\tcallsByLine.set(line, {})\n\t\t\t\t}\n\t\t\t\tconst asyncCall = callsByLine.get(line)!\n\t\t\t\tasyncCall.receiver = captureText\n\t\t\t\tasyncCall.callType = \"async\"\n\t\t\t\tasyncCall.isAsync = true\n\t\t\t\tbreak\n\n\t\t\tcase \"async.call.method\":\n\t\t\t\t// \u5F02\u6B65\u65B9\u6CD5\u8C03\u7528\u7684\u65B9\u6CD5\u540D\n\t\t\t\tif (!callsByLine.has(line)) {\n\t\t\t\t\tcallsByLine.set(line, {})\n\t\t\t\t}\n\t\t\t\tcallsByLine.get(line)!.functionName = captureText\n\t\t\t\tbreak\n\n\t\t\tcase \"decorator.call.function\":\n\t\t\t\t// \u88C5\u9970\u5668\u51FD\u6570\u8C03\u7528\n\t\t\t\tconsole.log(`[analyzePythonFunctionCalls] Adding decorator function call: ${captureText}`)\n\t\t\t\tif (!callsByLine.has(line)) {\n\t\t\t\t\tcallsByLine.set(line, {})\n\t\t\t\t}\n\t\t\t\tconst decoratorDirectCall = callsByLine.get(line)!\n\t\t\t\tdecoratorDirectCall.functionName = captureText\n\t\t\t\tdecoratorDirectCall.callType = \"decorator\"\n\t\t\t\tdecoratorDirectCall.isDecorator = true\n\t\t\t\tbreak\n\n\t\t\tcase \"decorator.call.receiver\":\n\t\t\t\t// \u88C5\u9970\u5668\u65B9\u6CD5\u8C03\u7528\u7684\u63A5\u6536\u8005\n\t\t\t\tif (!callsByLine.has(line)) {\n\t\t\t\t\tcallsByLine.set(line, {})\n\t\t\t\t}\n\t\t\t\tconst decoratorCall = callsByLine.get(line)!\n\t\t\t\tdecoratorCall.receiver = captureText\n\t\t\t\tdecoratorCall.callType = \"decorator\"\n\t\t\t\tdecoratorCall.isDecorator = true\n\t\t\t\tbreak\n\n\t\t\tcase \"decorator.call.method\":\n\t\t\t\t// \u88C5\u9970\u5668\u65B9\u6CD5\u8C03\u7528\u7684\u65B9\u6CD5\u540D\n\t\t\t\tif (!callsByLine.has(line)) {\n\t\t\t\t\tcallsByLine.set(line, {})\n\t\t\t\t}\n\t\t\t\tcallsByLine.get(line)!.functionName = captureText\n\t\t\t\tbreak\n\n\t\t\tcase \"method.call.chain\":\n\t\t\t\t// \u94FE\u5F0F\u65B9\u6CD5\u8C03\u7528\n\t\t\t\tconsole.log(`[analyzePythonFunctionCalls] Adding chain method call: ${captureText}`)\n\t\t\t\tif (!callsByLine.has(line)) {\n\t\t\t\t\tcallsByLine.set(line, {})\n\t\t\t\t}\n\t\t\t\tconst chainCall = callsByLine.get(line)!\n\t\t\t\tchainCall.functionName = captureText\n\t\t\t\tchainCall.callType = \"chain\"\n\t\t\t\tbreak\n\n\t\t\tcase \"comprehension.call.function\":\n\t\t\t\t// \u63A8\u5BFC\u5F0F\u4E2D\u7684\u51FD\u6570\u8C03\u7528\n\t\t\t\tconsole.log(`[analyzePythonFunctionCalls] Adding comprehension function call: ${captureText}`)\n\t\t\t\tif (!callsByLine.has(line)) {\n\t\t\t\t\tcallsByLine.set(line, {})\n\t\t\t\t}\n\t\t\t\tconst comprehensionDirectCall = callsByLine.get(line)!\n\t\t\t\tcomprehensionDirectCall.functionName = captureText\n\t\t\t\tcomprehensionDirectCall.callType = \"comprehension\"\n\t\t\t\tbreak\n\n\t\t\tcase \"comprehension.call.receiver\":\n\t\t\t\t// \u63A8\u5BFC\u5F0F\u4E2D\u7684\u65B9\u6CD5\u8C03\u7528\u63A5\u6536\u8005\n\t\t\t\tif (!callsByLine.has(line)) {\n\t\t\t\t\tcallsByLine.set(line, {})\n\t\t\t\t}\n\t\t\t\tconst comprehensionCall = callsByLine.get(line)!\n\t\t\t\tcomprehensionCall.receiver = captureText\n\t\t\t\tcomprehensionCall.callType = \"comprehension\"\n\t\t\t\tbreak\n\n\t\t\tcase \"comprehension.call.method\":\n\t\t\t\t// \u63A8\u5BFC\u5F0F\u4E2D\u7684\u65B9\u6CD5\u8C03\u7528\u65B9\u6CD5\u540D\n\t\t\t\tif (!callsByLine.has(line)) {\n\t\t\t\t\tcallsByLine.set(line, {})\n\t\t\t\t}\n\t\t\t\tcallsByLine.get(line)!.functionName = captureText\n\t\t\t\tbreak\n\n\t\t\tcase \"generator.call.function\":\n\t\t\t\t// \u751F\u6210\u5668\u8868\u8FBE\u5F0F\u4E2D\u7684\u51FD\u6570\u8C03\u7528\n\t\t\t\tconsole.log(`[analyzePythonFunctionCalls] Adding generator function call: ${captureText}`)\n\t\t\t\tif (!callsByLine.has(line)) {\n\t\t\t\t\tcallsByLine.set(line, {})\n\t\t\t\t}\n\t\t\t\tconst generatorDirectCall = callsByLine.get(line)!\n\t\t\t\tgeneratorDirectCall.functionName = captureText\n\t\t\t\tgeneratorDirectCall.callType = \"generator\"\n\t\t\t\tbreak\n\n\t\t\tcase \"generator.call.receiver\":\n\t\t\t\t// \u751F\u6210\u5668\u8868\u8FBE\u5F0F\u4E2D\u7684\u65B9\u6CD5\u8C03\u7528\u63A5\u6536\u8005\n\t\t\t\tif (!callsByLine.has(line)) {\n\t\t\t\t\tcallsByLine.set(line, {})\n\t\t\t\t}\n\t\t\t\tconst generatorCall = callsByLine.get(line)!\n\t\t\t\tgeneratorCall.receiver = captureText\n\t\t\t\tgeneratorCall.callType = \"generator\"\n\t\t\t\tbreak\n\n\t\t\tcase \"generator.call.method\":\n\t\t\t\t// \u751F\u6210\u5668\u8868\u8FBE\u5F0F\u4E2D\u7684\u65B9\u6CD5\u8C03\u7528\u65B9\u6CD5\u540D\n\t\t\t\tif (!callsByLine.has(line)) {\n\t\t\t\t\tcallsByLine.set(line, {})\n\t\t\t\t}\n\t\t\t\tcallsByLine.get(line)!.functionName = captureText\n\t\t\t\tbreak\n\n\t\t\tcase \"lambda.call.function\":\n\t\t\t\t// Lambda \u8868\u8FBE\u5F0F\u4E2D\u7684\u51FD\u6570\u8C03\u7528\n\t\t\t\tconsole.log(`[analyzePythonFunctionCalls] Adding lambda function call: ${captureText}`)\n\t\t\t\tif (!callsByLine.has(line)) {\n\t\t\t\t\tcallsByLine.set(line, {})\n\t\t\t\t}\n\t\t\t\tconst lambdaDirectCall = callsByLine.get(line)!\n\t\t\t\tlambdaDirectCall.functionName = captureText\n\t\t\t\tlambdaDirectCall.callType = \"lambda\"\n\t\t\t\tbreak\n\n\t\t\tcase \"lambda.call.receiver\":\n\t\t\t\t// Lambda \u8868\u8FBE\u5F0F\u4E2D\u7684\u65B9\u6CD5\u8C03\u7528\u63A5\u6536\u8005\n\t\t\t\tif (!callsByLine.has(line)) {\n\t\t\t\t\tcallsByLine.set(line, {})\n\t\t\t\t}\n\t\t\t\tconst lambdaCall = callsByLine.get(line)!\n\t\t\t\tlambdaCall.receiver = captureText\n\t\t\t\tlambdaCall.callType = \"lambda\"\n\t\t\t\tbreak\n\n\t\t\tcase \"lambda.call.method\":\n\t\t\t\t// Lambda \u8868\u8FBE\u5F0F\u4E2D\u7684\u65B9\u6CD5\u8C03\u7528\u65B9\u6CD5\u540D\n\t\t\t\tif (!callsByLine.has(line)) {\n\t\t\t\t\tcallsByLine.set(line, {})\n\t\t\t\t}\n\t\t\t\tcallsByLine.get(line)!.functionName = captureText\n\t\t\t\tbreak\n\n\t\t\tcase \"nested.call.root\":\n\t\t\t\t// \u5D4C\u5957\u8C03\u7528\u7684\u6839\u5BF9\u8C61\n\t\t\t\tif (!callsByLine.has(line)) {\n\t\t\t\t\tcallsByLine.set(line, {})\n\t\t\t\t}\n\t\t\t\tconst nestedCall = callsByLine.get(line)!\n\t\t\t\tnestedCall.root = captureText\n\t\t\t\tnestedCall.callType = \"nested\"\n\t\t\t\tbreak\n\n\t\t\tcase \"nested.call.intermediate\":\n\t\t\t\t// \u5D4C\u5957\u8C03\u7528\u7684\u4E2D\u95F4\u5C5E\u6027\n\t\t\t\tif (!callsByLine.has(line)) {\n\t\t\t\t\tcallsByLine.set(line, {})\n\t\t\t\t}\n\t\t\t\tcallsByLine.get(line)!.intermediate = captureText\n\t\t\t\tbreak\n\n\t\t\tcase \"nested.call.method\":\n\t\t\t\t// \u5D4C\u5957\u8C03\u7528\u7684\u65B9\u6CD5\u540D\n\t\t\t\tif (!callsByLine.has(line)) {\n\t\t\t\t\tcallsByLine.set(line, {})\n\t\t\t\t}\n\t\t\t\tcallsByLine.get(line)!.functionName = captureText\n\t\t\t\tbreak\n\n\t\t\tcase \"function.call.argument\":\n\t\t\t\t// \u51FD\u6570\u4F5C\u4E3A\u53C2\u6570\u8C03\u7528\n\t\t\t\tconsole.log(`[analyzePythonFunctionCalls] Adding argument function call: ${captureText}`)\n\t\t\t\tif (!callsByLine.has(line)) {\n\t\t\t\t\tcallsByLine.set(line, {})\n\t\t\t\t}\n\t\t\t\tconst argumentCall = callsByLine.get(line)!\n\t\t\t\targumentCall.functionName = captureText\n\t\t\t\targumentCall.callType = \"argument\"\n\t\t\t\tbreak\n\n\t\t\tdefault:\n\t\t\t\tconsole.log(`[analyzePythonFunctionCalls] Unhandled capture type: ${capture.name}`)\n\t\t\t\tbreak\n\t\t}\n\t}\n\n\t// \u5904\u7406\u590D\u5408\u8C03\u7528\u4FE1\u606F\n\tconst processedCalls = new Set() // \u9632\u6B62\u91CD\u590D\u5904\u7406\n\n\tfor (const [line, callInfo] of callsByLine) {\n\t\tif (callInfo.functionName) {\n\t\t\t// \u786E\u5B9A\u6700\u7EC8\u7684\u8C03\u7528\u7C7B\u578B\uFF0C\u4F18\u5148\u7EA7\u5904\u7406\n\t\t\tlet finalCallType = callInfo.callType!\n\n\t\t\t// \u7279\u6B8A\u5904\u7406\uFF1A\u5982\u679C\u6709\u591A\u79CD\u7C7B\u578B\u6807\u8BB0\uFF0C\u6309\u4F18\u5148\u7EA7\u9009\u62E9\n\t\t\tif (callInfo.isDecorator) {\n\t\t\t\tfinalCallType = \"decorator\"\n\t\t\t} else if (callInfo.isAsync) {\n\t\t\t\tfinalCallType = \"async\"\n\t\t\t} else if (callInfo.receiver === \"self\") {\n\t\t\t\tfinalCallType = \"self\"\n\t\t\t} else if (callInfo.className) {\n\t\t\t\tfinalCallType = \"class\"\n\t\t\t} else if (callInfo.receiver && callInfo.callType === \"method\") {\n\t\t\t\t// \u6709\u63A5\u6536\u8005\u7684\u65B9\u6CD5\u8C03\u7528\n\t\t\t\tfinalCallType = \"method\"\n\t\t\t}\n\n\t\t\t// \u6784\u5EFA\u552F\u4E00\u952E\n\t\t\tconst callKey = `${line}-${finalCallType}-${callInfo.functionName}-${callInfo.receiver || \"\"}-${callInfo.className || \"\"}`\n\n\t\t\tif (!processedCalls.has(callKey)) {\n\t\t\t\tprocessedCalls.add(callKey)\n\n\t\t\t\t// \u6784\u5EFA\u63A5\u6536\u8005\u4FE1\u606F\n\t\t\t\tlet receiver = callInfo.receiver\n\t\t\t\tif (finalCallType === \"nested\" && callInfo.root && callInfo.intermediate) {\n\t\t\t\t\treceiver = `${callInfo.root}.${callInfo.intermediate}`\n\t\t\t\t}\n\n\t\t\t\tfunctionCalls.push({\n\t\t\t\t\tcalledFunctionName: callInfo.functionName,\n\t\t\t\t\tcallType: finalCallType,\n\t\t\t\t\treceiver: receiver,\n\t\t\t\t\tclassName: callInfo.className,\n\t\t\t\t\tline: line + 1,\n\t\t\t\t\tcolumn: 0,\n\t\t\t\t\tisAsync: callInfo.isAsync,\n\t\t\t\t\tisDecorator: callInfo.isDecorator,\n\t\t\t\t})\n\n\t\t\t\tconsole.log(\n\t\t\t\t\t`[analyzePythonFunctionCalls] Adding ${finalCallType} call: ${callInfo.functionName} (receiver: ${receiver || \"none\"})`,\n\t\t\t\t)\n\t\t\t}\n\t\t}\n\t}\n\n\tconsole.log(\n\t\t`[analyzePythonFunctionCalls] Final result: ${functionCalls.length} function calls, scope: ${JSON.stringify(scopeInfo)}`,\n\t)\n\n\treturn { functionCalls, scopeInfo }\n}\n\nexport function filterRelevantPythonFunctionCalls(\n\tcallAnalysis: PythonFunctionCallAnalysisResult,\n\tallFunctions: ISnippetMeta[],\n\tcurrentFunction: ISnippetMeta,\n\tlanguage: CodeLanguageType,\n): ISnippetMeta[] {\n\tconst relevantFunctions: ISnippetMeta[] = []\n\n\tfor (const call of callAnalysis.functionCalls) {\n\t\t// \u67E5\u627E\u5BF9\u5E94\u7684\u51FD\u6570\u5B9A\u4E49\n\t\tconst targetFunction = findPythonTargetFunction(call, allFunctions, callAnalysis.scopeInfo)\n\n\t\tif (targetFunction && targetFunction.name !== currentFunction.name) {\n\t\t\t// \u68C0\u67E5\u662F\u5426\u5DF2\u7ECF\u6DFB\u52A0\u8FC7\n\t\t\tif (!relevantFunctions.find((f) => f.name === targetFunction.name)) {\n\t\t\t\trelevantFunctions.push(targetFunction)\n\t\t\t\tconsole.log(\n\t\t\t\t\t`[PythonFunctionCallAnalyzer] Found relevant function call: ${call.calledFunctionName} (${call.callType})`,\n\t\t\t\t)\n\t\t\t}\n\t\t}\n\t}\n\n\treturn relevantFunctions\n}\n\n/**\n * \u67E5\u627E Python \u7684\u76EE\u6807\u51FD\u6570\n */\nfunction findPythonTargetFunction(\n\tcall: PythonFunctionCallInfo,\n\tallFunctions: ISnippetMeta[],\n\tscopeInfo: PythonFunctionCallAnalysisResult[\"scopeInfo\"],\n): ISnippetMeta | null {\n\tswitch (call.callType) {\n\t\tcase \"direct\":\n\t\t\t// \u76F4\u63A5\u51FD\u6570\u8C03\u7528\uFF1A\u67E5\u627E\u540C\u6A21\u5757\u7684\u51FD\u6570\n\t\t\treturn (\n\t\t\t\tallFunctions.find(\n\t\t\t\t\t(func) => func.name === call.calledFunctionName && !func.field, // \u6A21\u5757\u7EA7\u51FD\u6570\u901A\u5E38\u6CA1\u6709field\n\t\t\t\t) || null\n\t\t\t)\n\n\t\tcase \"method\":\n\t\t\t// \u65B9\u6CD5\u8C03\u7528\uFF1A\u67E5\u627E\u5BF9\u5E94\u63A5\u6536\u8005\u7684\u65B9\u6CD5\n\t\t\tif (call.receiver) {\n\t\t\t\treturn (\n\t\t\t\t\tallFunctions.find(\n\t\t\t\t\t\t(func) => func.name === call.calledFunctionName && func.field === call.receiver,\n\t\t\t\t\t) || null\n\t\t\t\t)\n\t\t\t}\n\t\t\tbreak\n\n\t\tcase \"self\":\n\t\t\t// self\u65B9\u6CD5\u8C03\u7528\uFF1A\u67E5\u627E\u540C\u7C7B\u7684\u65B9\u6CD5\n\t\t\treturn (\n\t\t\t\tallFunctions.find(\n\t\t\t\t\t(func) => func.name === call.calledFunctionName && func.field === scopeInfo.className,\n\t\t\t\t) || null\n\t\t\t)\n\n\t\tcase \"class\":\n\t\t\t// \u7C7B\u65B9\u6CD5\u8C03\u7528\uFF1A\u67E5\u627E\u6307\u5B9A\u7C7B\u7684\u65B9\u6CD5\n\t\t\treturn (\n\t\t\t\tallFunctions.find((func) => func.name === call.calledFunctionName && func.field === call.className) ||\n\t\t\t\tnull\n\t\t\t)\n\n\t\tcase \"super\":\n\t\t\t// super\u8C03\u7528\uFF1A\u901A\u5E38\u662F\u7236\u7C7B\u65B9\u6CD5\uFF0C\u53EF\u80FD\u4E0D\u5728\u540C\u6587\u4EF6\u4E2D\n\t\t\treturn null\n\n\t\tcase \"async\":\n\t\t\t// \u5F02\u6B65\u8C03\u7528\uFF1A\u6309\u7167\u666E\u901A\u51FD\u6570\u6216\u65B9\u6CD5\u5904\u7406\n\t\t\tif (call.receiver) {\n\t\t\t\treturn (\n\t\t\t\t\tallFunctions.find(\n\t\t\t\t\t\t(func) => func.name === call.calledFunctionName && func.field === call.receiver,\n\t\t\t\t\t) || null\n\t\t\t\t)\n\t\t\t} else {\n\t\t\t\treturn allFunctions.find((func) => func.name === call.calledFunctionName && !func.field) || null\n\t\t\t}\n\n\t\tcase \"decorator\":\n\t\t\t// \u88C5\u9970\u5668\u8C03\u7528\uFF1A\u67E5\u627E\u88C5\u9970\u5668\u51FD\u6570\n\t\t\tif (call.receiver) {\n\t\t\t\treturn (\n\t\t\t\t\tallFunctions.find(\n\t\t\t\t\t\t(func) => func.name === call.calledFunctionName && func.field === call.receiver,\n\t\t\t\t\t) || null\n\t\t\t\t)\n\t\t\t} else {\n\t\t\t\treturn allFunctions.find((func) => func.name === call.calledFunctionName && !func.field) || null\n\t\t\t}\n\n\t\tcase \"chain\":\n\t\tcase \"comprehension\":\n\t\tcase \"generator\":\n\t\tcase \"lambda\":\n\t\tcase \"nested\":\n\t\tcase \"argument\":\n\t\t\t// \u8FD9\u4E9B\u8C03\u7528\u7C7B\u578B\u901A\u5E38\u662F\u590D\u6742\u8868\u8FBE\u5F0F\u6216\u5185\u8054\u8C03\u7528\uFF0C\u6839\u636E\u5177\u4F53\u60C5\u51B5\u5904\u7406\n\t\t\tif (call.receiver) {\n\t\t\t\treturn (\n\t\t\t\t\tallFunctions.find(\n\t\t\t\t\t\t(func) => func.name === call.calledFunctionName && func.field === call.receiver,\n\t\t\t\t\t) || null\n\t\t\t\t)\n\t\t\t} else {\n\t\t\t\treturn allFunctions.find((func) => func.name === call.calledFunctionName && !func.field) || null\n\t\t\t}\n\t}\n\n\treturn null\n}\n", "import Parser from \"web-tree-sitter\"\nimport { CodeLanguageType, ISnippetMeta, SnippetType } from \"../types\"\n\nexport interface JSXFunctionCallInfo {\n\tcalledFunctionName: string\n\tcallType:\n\t\t| \"direct\"\n\t\t| \"method\"\n\t\t| \"static\"\n\t\t| \"namespace\"\n\t\t| \"constructor\"\n\t\t| \"chain\"\n\t\t| \"this\"\n\t\t| \"super\"\n\t\t| \"arrow\"\n\t\t| \"async\"\n\t\t| \"array\"\n\t\t| \"promise\"\n\t\t| \"optional\"\n\t\t| \"template\"\n\t\t| \"nested\"\n\t\t| \"react_hook\"\n\t\t| \"react_component\"\n\t\t| \"jsx_component\"\n\t\t| \"event_handler\"\n\t\t| \"react_create\"\n\t\t| \"hoc\"\n\t\t| \"context_hook\"\n\t\t| \"ref_hook\"\n\t\t| \"state_hook\"\n\t\t| \"effect_hook\"\n\t\t| \"memo_hook\"\n\t\t| \"devtools\"\n\treceiver?: string // \u5BF9\u4E8E\u65B9\u6CD5\u8C03\u7528\uFF0C\u63A5\u6536\u8005\u7684\u540D\u79F0\n\tclassName?: string // \u5BF9\u4E8E\u9759\u6001\u65B9\u6CD5\u8C03\u7528\uFF0C\u7C7B\u7684\u540D\u79F0\n\tnamespace?: string // \u5BF9\u4E8E\u547D\u540D\u7A7A\u95F4\u8C03\u7528\uFF0C\u547D\u540D\u7A7A\u95F4\u7684\u540D\u79F0\n\tcomponent?: string // \u5BF9\u4E8EReact\u7EC4\u4EF6\u8C03\u7528\uFF0C\u7EC4\u4EF6\u7684\u540D\u79F0\n\tcontext?: string // \u5BF9\u4E8EContext hooks\uFF0Ccontext\u7684\u540D\u79F0\n\tline: number\n\tcolumn: number\n\tisAsync?: boolean // \u662F\u5426\u662F\u5F02\u6B65\u8C03\u7528\n\tisOptional?: boolean // \u662F\u5426\u662F\u53EF\u9009\u94FE\u8C03\u7528\n\tisReactSpecific?: boolean // \u662F\u5426\u662FReact\u7279\u5B9A\u7684\u8C03\u7528\n}\n\nexport interface JSXFunctionCallAnalysisResult {\n\tfunctionCalls: JSXFunctionCallInfo[]\n\tscopeInfo: {\n\t\tmoduleName?: string\n\t\tcomponentName?: string // \u5982\u679C\u51FD\u6570\u662F\u67D0\u4E2AReact\u7EC4\u4EF6\u7684\u4E00\u90E8\u5206\n\t\tfunctionName: string\n\t\tisAsync?: boolean\n\t\tisReactComponent?: boolean // \u662F\u5426\u662FReact\u7EC4\u4EF6\n\t}\n}\n\nexport function dependenciesCapturesProcessForJSX(captures: Parser.QueryCapture[]): ISnippetMeta[] {\n\tconst result = analyzeJSXFunctionCalls(captures)\n\treturn result.functionCalls.map((call) => ({\n\t\tname: call.calledFunctionName,\n\t\ttype: SnippetType.FunctionOrMethod,\n\t\tfilePath: \"\",\n\t\tstartLine: call.line,\n\t\tendLine: call.line,\n\t\tstartPosition: {\n\t\t\trow: call.line,\n\t\t\tcolumn: call.column,\n\t\t},\n\t\tendPosition: {\n\t\t\trow: call.line,\n\t\t\tcolumn: call.column,\n\t\t},\n\t\trangeText: \"\",\n\t\tfileHash: \"\",\n\t\tdefinition: {\n\t\t\tname: call.calledFunctionName,\n\t\t\ttype: call.callType,\n\t\t\tisAsync: call.isAsync,\n\t\t},\n\t\tfield: call.className || call.namespace || call.component || call.context,\n\t\tsignature: buildSignatureForJSXCall(call),\n\t\tlanguage: CodeLanguageType.JSX,\n\t}))\n}\n\n/**\n * \u4E3AJSX\u51FD\u6570\u8C03\u7528\u6784\u5EFA\u7B7E\u540D\n */\nfunction buildSignatureForJSXCall(call: JSXFunctionCallInfo): string {\n\tswitch (call.callType) {\n\t\tcase \"react_hook\":\n\t\t\treturn `${call.calledFunctionName}() // React Hook`\n\t\tcase \"react_component\":\n\t\t\treturn `${call.calledFunctionName}() // React Component`\n\t\tcase \"event_handler\":\n\t\t\treturn `${call.calledFunctionName}() // Event Handler`\n\t\tcase \"react_create\":\n\t\t\treturn `React.createElement(${call.component}) // React.createElement`\n\t\tcase \"hoc\":\n\t\t\treturn `${call.calledFunctionName}(${call.component}) // Higher-Order Component`\n\t\tcase \"context_hook\":\n\t\t\treturn `useContext(${call.context}) // Context Hook`\n\t\tcase \"ref_hook\":\n\t\t\treturn `${call.calledFunctionName}() // Ref Hook`\n\t\tcase \"state_hook\":\n\t\t\treturn `${call.calledFunctionName}() // State Hook`\n\t\tcase \"effect_hook\":\n\t\t\treturn `${call.calledFunctionName}() // Effect Hook`\n\t\tcase \"memo_hook\":\n\t\t\treturn `${call.calledFunctionName}() // Memo Hook`\n\t\tdefault:\n\t\t\treturn `${call.calledFunctionName}()`\n\t}\n}\n\n/**\n * \u5206\u6790 JSX \u8BED\u8A00\u7684\u51FD\u6570\u8C03\u7528\uFF0C\u5305\u62ECReact\u7279\u6709\u7684\u6A21\u5F0F\n */\nfunction analyzeJSXFunctionCalls(captures: Parser.QueryCapture[]): JSXFunctionCallAnalysisResult {\n\tconst functionCalls: JSXFunctionCallInfo[] = []\n\tconst scopeInfo = {\n\t\tmoduleName: undefined as string | undefined,\n\t\tcomponentName: undefined as string | undefined,\n\t\tfunctionName: \"unknown\",\n\t\tisAsync: false,\n\t\tisReactComponent: false,\n\t}\n\n\t// \u7528\u4E8E\u4E34\u65F6\u5B58\u50A8\u540C\u4E00\u884C\u7684\u65B9\u6CD5\u8C03\u7528\u4FE1\u606F\n\tconst callsByLine = new Map<\n\t\tnumber,\n\t\t{\n\t\t\tfunctionName?: string\n\t\t\treceiver?: string\n\t\t\tclassName?: string\n\t\t\tnamespace?: string\n\t\t\tcomponent?: string\n\t\t\tcontext?: string\n\t\t\tcallType?: JSXFunctionCallInfo[\"callType\"]\n\t\t\tisAsync?: boolean\n\t\t\tisOptional?: boolean\n\t\t\tisReactSpecific?: boolean\n\t\t}\n\t>()\n\n\t// \u7528\u4E8E\u8DDF\u8E2A\u5DF2\u5904\u7406\u7684\u51FD\u6570\u8C03\u7528\uFF0C\u907F\u514D\u91CD\u590D\n\tconst processedCalls = new Set()\n\n\t// \u6309\u7167\u4F18\u5148\u7EA7\u5206\u7EC4\u5904\u7406\u6355\u83B7\n\tconst priorityGroups = {\n\t\thoc: [] as Parser.QueryCapture[],\n\t\treactCreate: [] as Parser.QueryCapture[],\n\t\treactHooks: [] as Parser.QueryCapture[],\n\t\teventHandlers: [] as Parser.QueryCapture[],\n\t\tawaitCalls: [] as Parser.QueryCapture[],\n\t\tarrayMethods: [] as Parser.QueryCapture[],\n\t\tpromiseMethods: [] as Parser.QueryCapture[],\n\t\tdirectCalls: [] as Parser.QueryCapture[],\n\t\tmethodCalls: [] as Parser.QueryCapture[],\n\t\tother: [] as Parser.QueryCapture[],\n\t}\n\n\t// \u5C06\u6355\u83B7\u5206\u7C7B\u5230\u4F18\u5148\u7EA7\u7EC4\n\tfor (const capture of captures) {\n\t\tswitch (capture.name) {\n\t\t\tcase \"hoc.call.name\":\n\t\t\tcase \"hoc.call.component\":\n\t\t\t\tpriorityGroups.hoc.push(capture)\n\t\t\t\tbreak\n\t\t\tcase \"react.create.namespace\":\n\t\t\tcase \"react.create.method\":\n\t\t\t\tpriorityGroups.reactCreate.push(capture)\n\t\t\t\tbreak\n\t\t\tcase \"state.hook.call\":\n\t\t\tcase \"effect.hook.call\":\n\t\t\tcase \"memo.hook.call\":\n\t\t\tcase \"ref.hook.call\":\n\t\t\tcase \"context.hook.call\":\n\t\t\tcase \"react.hook.call\":\n\t\t\t\tpriorityGroups.reactHooks.push(capture)\n\t\t\t\tbreak\n\t\t\tcase \"event.handler.function\":\n\t\t\t\tpriorityGroups.eventHandlers.push(capture)\n\t\t\t\tbreak\n\t\t\tcase \"await.call.function\":\n\t\t\tcase \"async.call.receiver\":\n\t\t\tcase \"async.call.method\":\n\t\t\t\tpriorityGroups.awaitCalls.push(capture)\n\t\t\t\tbreak\n\t\t\tcase \"array.call.method\":\n\t\t\tcase \"array.call.object\":\n\t\t\t\tpriorityGroups.arrayMethods.push(capture)\n\t\t\t\tbreak\n\t\t\tcase \"promise.call.method\":\n\t\t\tcase \"promise.call.object\":\n\t\t\t\tpriorityGroups.promiseMethods.push(capture)\n\t\t\t\tbreak\n\t\t\tcase \"function.call.direct\":\n\t\t\t\tpriorityGroups.directCalls.push(capture)\n\t\t\t\tbreak\n\t\t\tcase \"method.call.name\":\n\t\t\tcase \"method.call.receiver\":\n\t\t\tcase \"method.call.chain\":\n\t\t\tcase \"optional.call.receiver\":\n\t\t\tcase \"optional.call.method\":\n\t\t\tcase \"static.call.class\":\n\t\t\tcase \"static.call.method\":\n\t\t\t\tpriorityGroups.methodCalls.push(capture)\n\t\t\t\tbreak\n\t\t\tdefault:\n\t\t\t\tpriorityGroups.other.push(capture)\n\t\t\t\tbreak\n\t\t}\n\t}\n\n\t// \u6309\u4F18\u5148\u7EA7\u987A\u5E8F\u5904\u7406\u7EC4\n\tconst allGroups = [\n\t\tpriorityGroups.hoc,\n\t\tpriorityGroups.reactCreate,\n\t\tpriorityGroups.reactHooks,\n\t\tpriorityGroups.eventHandlers,\n\t\tpriorityGroups.awaitCalls,\n\t\tpriorityGroups.arrayMethods,\n\t\tpriorityGroups.promiseMethods,\n\t\tpriorityGroups.methodCalls,\n\t\tpriorityGroups.other,\n\t\tpriorityGroups.directCalls, // \u76F4\u63A5\u8C03\u7528\u653E\u6700\u540E\uFF0C\u4F18\u5148\u7EA7\u6700\u4F4E\n\t]\n\n\tfor (const group of allGroups) {\n\t\tfor (const capture of group) {\n\t\t\tconst node = capture.node\n\t\t\tconst captureText = node.text.trim()\n\t\t\tconst line = node.startPosition.row\n\t\t\tconst callKey = `${line}-${node.startPosition.column}-${captureText}-${capture.name}`\n\n\t\t\t// \u8DF3\u8FC7\u5DF2\u7ECF\u5904\u7406\u7684\u8C03\u7528 - \u7528\u66F4\u5177\u4F53\u7684key\u907F\u514D\u51B2\u7A81\n\t\t\tif (processedCalls.has(callKey)) {\n\t\t\t\tcontinue\n\t\t\t}\n\n\t\t\t// \u5BF9\u4E8E\u76F4\u63A5\u51FD\u6570\u8C03\u7528\uFF0C\u68C0\u67E5\u662F\u5426\u5DF2\u7ECF\u88AB\u66F4\u9AD8\u4F18\u5148\u7EA7\u7684\u67E5\u8BE2\u5904\u7406\n\t\t\tif (capture.name === \"function.call.direct\") {\n\t\t\t\tconst generalCallKey = `${line}-${captureText}`\n\t\t\t\tlet isAlreadyProcessed = false\n\n\t\t\t\t// \u68C0\u67E5\u662F\u5426\u5DF2\u7ECF\u6709\u76F8\u540C\u7684\u51FD\u6570\u8C03\u7528\u88AB\u5904\u7406\n\t\t\t\tfor (const existingKey of processedCalls) {\n\t\t\t\t\tif (existingKey.includes(generalCallKey)) {\n\t\t\t\t\t\tisAlreadyProcessed = true\n\t\t\t\t\t\tbreak\n\t\t\t\t\t}\n\t\t\t\t}\n\n\t\t\t\t// \u68C0\u67E5\u662F\u5426\u5728callsByLine\u4E2D\u5DF2\u7ECF\u6709\u540C\u4E00\u884C\u7684\u540C\u540D\u51FD\u6570\n\t\t\t\tconst lineCall = callsByLine.get(line)\n\t\t\t\tif (lineCall?.functionName === captureText) {\n\t\t\t\t\tisAlreadyProcessed = true\n\t\t\t\t}\n\n\t\t\t\tif (isAlreadyProcessed) {\n\t\t\t\t\tcontinue\n\t\t\t\t}\n\t\t\t}\n\n\t\t\tswitch (capture.name) {\n\t\t\t\tcase \"hoc.call.name\":\n\t\t\t\t\t// \u9AD8\u9636\u7EC4\u4EF6\u8C03\u7528\u7684HOC\u540D\n\t\t\t\t\tif (!callsByLine.has(line)) {\n\t\t\t\t\t\tcallsByLine.set(line, {})\n\t\t\t\t\t}\n\t\t\t\t\tconst hocCall = callsByLine.get(line)!\n\t\t\t\t\thocCall.functionName = captureText\n\t\t\t\t\thocCall.callType = \"hoc\"\n\t\t\t\t\thocCall.isReactSpecific = true\n\t\t\t\t\tbreak\n\n\t\t\t\tcase \"hoc.call.component\":\n\t\t\t\t\t// \u9AD8\u9636\u7EC4\u4EF6\u8C03\u7528\u7684\u7EC4\u4EF6\u53C2\u6570\n\t\t\t\t\tif (!callsByLine.has(line)) {\n\t\t\t\t\t\tcallsByLine.set(line, {})\n\t\t\t\t\t}\n\t\t\t\t\tcallsByLine.get(line)!.component = captureText\n\t\t\t\t\tbreak\n\n\t\t\t\tcase \"react.create.method\":\n\t\t\t\t\t// React.createElement \u65B9\u6CD5\n\t\t\t\t\tif (!callsByLine.has(line)) {\n\t\t\t\t\t\tcallsByLine.set(line, {})\n\t\t\t\t\t}\n\t\t\t\t\tconst createCall = callsByLine.get(line)!\n\t\t\t\t\tcreateCall.functionName = captureText\n\t\t\t\t\tcreateCall.callType = \"react_create\"\n\t\t\t\t\tcreateCall.isReactSpecific = true\n\t\t\t\t\tbreak\n\n\t\t\t\tcase \"state.hook.call\":\n\t\t\t\t\t// State Hook \u8C03\u7528\n\t\t\t\t\tfunctionCalls.push({\n\t\t\t\t\t\tcalledFunctionName: captureText,\n\t\t\t\t\t\tcallType: \"state_hook\",\n\t\t\t\t\t\tline: line + 1,\n\t\t\t\t\t\tcolumn: node.startPosition.column,\n\t\t\t\t\t\tisReactSpecific: true,\n\t\t\t\t\t})\n\t\t\t\t\tprocessedCalls.add(callKey)\n\t\t\t\t\tbreak\n\n\t\t\t\tcase \"effect.hook.call\":\n\t\t\t\t\t// Effect Hook \u8C03\u7528\n\t\t\t\t\tfunctionCalls.push({\n\t\t\t\t\t\tcalledFunctionName: captureText,\n\t\t\t\t\t\tcallType: \"effect_hook\",\n\t\t\t\t\t\tline: line + 1,\n\t\t\t\t\t\tcolumn: node.startPosition.column,\n\t\t\t\t\t\tisReactSpecific: true,\n\t\t\t\t\t})\n\t\t\t\t\tprocessedCalls.add(callKey)\n\t\t\t\t\tbreak\n\n\t\t\t\tcase \"memo.hook.call\":\n\t\t\t\t\t// Memo Hook \u8C03\u7528\n\t\t\t\t\tfunctionCalls.push({\n\t\t\t\t\t\tcalledFunctionName: captureText,\n\t\t\t\t\t\tcallType: \"memo_hook\",\n\t\t\t\t\t\tline: line + 1,\n\t\t\t\t\t\tcolumn: node.startPosition.column,\n\t\t\t\t\t\tisReactSpecific: true,\n\t\t\t\t\t})\n\t\t\t\t\tprocessedCalls.add(callKey)\n\t\t\t\t\tbreak\n\n\t\t\t\tcase \"ref.hook.call\":\n\t\t\t\t\t// Ref Hook \u8C03\u7528\n\t\t\t\t\tfunctionCalls.push({\n\t\t\t\t\t\tcalledFunctionName: captureText,\n\t\t\t\t\t\tcallType: \"ref_hook\",\n\t\t\t\t\t\tline: line + 1,\n\t\t\t\t\t\tcolumn: node.startPosition.column,\n\t\t\t\t\t\tisReactSpecific: true,\n\t\t\t\t\t})\n\t\t\t\t\tprocessedCalls.add(callKey)\n\t\t\t\t\tbreak\n\n\t\t\t\tcase \"context.hook.call\":\n\t\t\t\t\t// Context Hook \u8C03\u7528\n\t\t\t\t\tfunctionCalls.push({\n\t\t\t\t\t\tcalledFunctionName: captureText,\n\t\t\t\t\t\tcallType: \"context_hook\",\n\t\t\t\t\t\tline: line + 1,\n\t\t\t\t\t\tcolumn: node.startPosition.column,\n\t\t\t\t\t\tisReactSpecific: true,\n\t\t\t\t\t})\n\t\t\t\t\tprocessedCalls.add(callKey)\n\t\t\t\t\tbreak\n\n\t\t\t\tcase \"react.hook.call\":\n\t\t\t\t\t// React Hook \u8C03\u7528\n\t\t\t\t\tfunctionCalls.push({\n\t\t\t\t\t\tcalledFunctionName: captureText,\n\t\t\t\t\t\tcallType: \"react_hook\",\n\t\t\t\t\t\tline: line + 1,\n\t\t\t\t\t\tcolumn: node.startPosition.column,\n\t\t\t\t\t\tisReactSpecific: true,\n\t\t\t\t\t})\n\t\t\t\t\tprocessedCalls.add(callKey)\n\t\t\t\t\tbreak\n\n\t\t\t\tcase \"event.handler.function\":\n\t\t\t\t\t// \u4E8B\u4EF6\u5904\u7406\u5668\u51FD\u6570\n\t\t\t\t\tfunctionCalls.push({\n\t\t\t\t\t\tcalledFunctionName: captureText,\n\t\t\t\t\t\tcallType: \"event_handler\",\n\t\t\t\t\t\tline: line + 1,\n\t\t\t\t\t\tcolumn: node.startPosition.column,\n\t\t\t\t\t\tisReactSpecific: true,\n\t\t\t\t\t})\n\t\t\t\t\tprocessedCalls.add(callKey)\n\t\t\t\t\tbreak\n\n\t\t\t\tcase \"await.call.function\":\n\t\t\t\t\t// await \u8868\u8FBE\u5F0F\u4E2D\u7684\u51FD\u6570\u8C03\u7528\n\t\t\t\t\tfunctionCalls.push({\n\t\t\t\t\t\tcalledFunctionName: captureText,\n\t\t\t\t\t\tcallType: \"async\",\n\t\t\t\t\t\tisAsync: true,\n\t\t\t\t\t\tline: line + 1,\n\t\t\t\t\t\tcolumn: node.startPosition.column,\n\t\t\t\t\t})\n\t\t\t\t\tprocessedCalls.add(callKey)\n\t\t\t\t\tbreak\n\n\t\t\t\tcase \"promise.call.method\":\n\t\t\t\t\t// Promise \u65B9\u6CD5\u8C03\u7528\n\t\t\t\t\tif (!callsByLine.has(line)) {\n\t\t\t\t\t\tcallsByLine.set(line, {})\n\t\t\t\t\t}\n\t\t\t\t\tconst promiseCall = callsByLine.get(line)!\n\t\t\t\t\tpromiseCall.functionName = captureText\n\t\t\t\t\tpromiseCall.callType = \"promise\"\n\t\t\t\t\tbreak\n\n\t\t\t\tcase \"promise.call.object\":\n\t\t\t\t\t// Promise \u65B9\u6CD5\u8C03\u7528\u7684\u5BF9\u8C61\n\t\t\t\t\tif (!callsByLine.has(line)) {\n\t\t\t\t\t\tcallsByLine.set(line, {})\n\t\t\t\t\t}\n\t\t\t\t\tcallsByLine.get(line)!.receiver = captureText\n\t\t\t\t\tbreak\n\n\t\t\t\tcase \"array.call.method\":\n\t\t\t\t\t// \u6570\u7EC4\u65B9\u6CD5\u8C03\u7528\n\t\t\t\t\tif (!callsByLine.has(line)) {\n\t\t\t\t\t\tcallsByLine.set(line, {})\n\t\t\t\t\t}\n\t\t\t\t\tconst arrayCall = callsByLine.get(line)!\n\t\t\t\t\tarrayCall.functionName = captureText\n\t\t\t\t\tarrayCall.callType = \"array\"\n\t\t\t\t\tbreak\n\n\t\t\t\tcase \"array.call.object\":\n\t\t\t\t\t// \u6570\u7EC4\u65B9\u6CD5\u8C03\u7528\u7684\u5BF9\u8C61\n\t\t\t\t\tif (!callsByLine.has(line)) {\n\t\t\t\t\t\tcallsByLine.set(line, {})\n\t\t\t\t\t}\n\t\t\t\t\tcallsByLine.get(line)!.receiver = captureText\n\t\t\t\t\tbreak\n\n\t\t\t\tcase \"async.call.receiver\":\n\t\t\t\t\t// \u5F02\u6B65\u65B9\u6CD5\u8C03\u7528\u7684\u63A5\u6536\u8005\n\t\t\t\t\tif (!callsByLine.has(line)) {\n\t\t\t\t\t\tcallsByLine.set(line, {})\n\t\t\t\t\t}\n\t\t\t\t\tconst asyncCall = callsByLine.get(line)!\n\t\t\t\t\tasyncCall.receiver = captureText\n\t\t\t\t\tasyncCall.isAsync = true\n\t\t\t\t\tbreak\n\n\t\t\t\tcase \"async.call.method\":\n\t\t\t\t\t// \u5F02\u6B65\u65B9\u6CD5\u8C03\u7528\u7684\u65B9\u6CD5\u540D\n\t\t\t\t\tif (!callsByLine.has(line)) {\n\t\t\t\t\t\tcallsByLine.set(line, {})\n\t\t\t\t\t}\n\t\t\t\t\tconst asyncMethodCall = callsByLine.get(line)!\n\t\t\t\t\tasyncMethodCall.functionName = captureText\n\t\t\t\t\tasyncMethodCall.callType = \"async\"\n\t\t\t\t\tbreak\n\n\t\t\t\tcase \"method.call.name\":\n\t\t\t\t\t// \u65B9\u6CD5\u8C03\u7528\u7684\u65B9\u6CD5\u540D\n\t\t\t\t\tif (!callsByLine.has(line)) {\n\t\t\t\t\t\tcallsByLine.set(line, {})\n\t\t\t\t\t}\n\t\t\t\t\tconst methodCall = callsByLine.get(line)!\n\t\t\t\t\t// \u53EA\u6709\u5F53\u6CA1\u6709\u66F4\u9AD8\u4F18\u5148\u7EA7\u7684callType\u65F6\u624D\u8BBE\u7F6E\u4E3Amethod\n\t\t\t\t\tif (!methodCall.callType) {\n\t\t\t\t\t\tmethodCall.functionName = captureText\n\t\t\t\t\t\tmethodCall.callType = \"method\"\n\t\t\t\t\t}\n\t\t\t\t\tbreak\n\n\t\t\t\tcase \"method.call.receiver\":\n\t\t\t\t\t// \u65B9\u6CD5\u8C03\u7528\u7684\u63A5\u6536\u8005\n\t\t\t\t\tif (!callsByLine.has(line)) {\n\t\t\t\t\t\tcallsByLine.set(line, {})\n\t\t\t\t\t}\n\t\t\t\t\tcallsByLine.get(line)!.receiver = captureText\n\t\t\t\t\tbreak\n\n\t\t\t\tcase \"static.call.class\":\n\t\t\t\t\t// \u9759\u6001\u65B9\u6CD5\u8C03\u7528\u7684\u7C7B\u540D\n\t\t\t\t\tif (!callsByLine.has(line)) {\n\t\t\t\t\t\tcallsByLine.set(line, {})\n\t\t\t\t\t}\n\t\t\t\t\tconst staticClassCall = callsByLine.get(line)!\n\t\t\t\t\t// \u53EA\u6709\u5F53\u6CA1\u6709\u66F4\u9AD8\u4F18\u5148\u7EA7\u7684callType\u65F6\u624D\u8BBE\u7F6E\u4E3Astatic\n\t\t\t\t\tif (!staticClassCall.callType || staticClassCall.callType === \"method\") {\n\t\t\t\t\t\tstaticClassCall.className = captureText\n\t\t\t\t\t\tstaticClassCall.callType = \"static\"\n\t\t\t\t\t}\n\t\t\t\t\tbreak\n\n\t\t\t\tcase \"static.call.method\":\n\t\t\t\t\t// \u9759\u6001\u65B9\u6CD5\u8C03\u7528\u7684\u65B9\u6CD5\u540D\n\t\t\t\t\tif (!callsByLine.has(line)) {\n\t\t\t\t\t\tcallsByLine.set(line, {})\n\t\t\t\t\t}\n\t\t\t\t\tconst staticMethodCall = callsByLine.get(line)!\n\t\t\t\t\t// \u53EA\u6709\u5F53\u6CA1\u6709\u66F4\u9AD8\u4F18\u5148\u7EA7\u7684callType\u65F6\u624D\u8BBE\u7F6E\u4E3Astatic\n\t\t\t\t\tif (!staticMethodCall.callType || staticMethodCall.callType === \"method\") {\n\t\t\t\t\t\tstaticMethodCall.functionName = captureText\n\t\t\t\t\t\tstaticMethodCall.callType = \"static\"\n\t\t\t\t\t}\n\t\t\t\t\tbreak\n\n\t\t\t\tcase \"optional.call.receiver\":\n\t\t\t\t\t// \u53EF\u9009\u94FE\u8C03\u7528\u7684\u63A5\u6536\u8005\n\t\t\t\t\tif (!callsByLine.has(line)) {\n\t\t\t\t\t\tcallsByLine.set(line, {})\n\t\t\t\t\t}\n\t\t\t\t\tconst optionalCall = callsByLine.get(line)!\n\t\t\t\t\toptionalCall.receiver = captureText\n\t\t\t\t\toptionalCall.isOptional = true\n\t\t\t\t\tbreak\n\n\t\t\t\tcase \"optional.call.method\":\n\t\t\t\t\t// \u53EF\u9009\u94FE\u8C03\u7528\u7684\u65B9\u6CD5\u540D - \u53EA\u5728\u5B9E\u9645\u68C0\u6D4B\u5230\u53EF\u9009\u94FE\u65F6\u4F7F\u7528\n\t\t\t\t\tif (!callsByLine.has(line)) {\n\t\t\t\t\t\tcallsByLine.set(line, {})\n\t\t\t\t\t}\n\t\t\t\t\tconst optionalMethodCall = callsByLine.get(line)!\n\t\t\t\t\t// \u6682\u65F6\u7981\u7528\u53EF\u9009\u94FE\u68C0\u6D4B\uFF0C\u56E0\u4E3A\u5B83\u4E0E\u666E\u901A\u65B9\u6CD5\u8C03\u7528\u51B2\u7A81\n\t\t\t\t\t// TODO: \u9700\u8981\u66F4\u7CBE\u786E\u7684\u53EF\u9009\u94FE\u68C0\u6D4B\u903B\u8F91\n\t\t\t\t\t// if (!optionalMethodCall.callType || optionalMethodCall.callType === \"method\") {\n\t\t\t\t\t// optionalMethodCall.functionName = captureText\n\t\t\t\t\t// optionalMethodCall.callType = \"optional\"\n\t\t\t\t\t// }\n\t\t\t\t\tbreak\n\n\t\t\t\tcase \"function.call.direct\":\n\t\t\t\t\t// \u76F4\u63A5\u51FD\u6570\u8C03\u7528 - \u53EA\u6709\u5728\u6CA1\u6709\u88AB\u66F4\u9AD8\u4F18\u5148\u7EA7\u5904\u7406\u65F6\u624D\u5904\u7406\n\t\t\t\t\tfunctionCalls.push({\n\t\t\t\t\t\tcalledFunctionName: captureText,\n\t\t\t\t\t\tcallType: \"direct\",\n\t\t\t\t\t\tline: line + 1,\n\t\t\t\t\t\tcolumn: node.startPosition.column,\n\t\t\t\t\t})\n\t\t\t\t\tprocessedCalls.add(callKey)\n\t\t\t\t\tbreak\n\n\t\t\t\tcase \"method.call.chain\":\n\t\t\t\t\t// \u94FE\u5F0F\u65B9\u6CD5\u8C03\u7528 - \u68C0\u67E5\u662F\u5426\u662Fpromise\u65B9\u6CD5\n\t\t\t\t\tif (!callsByLine.has(line)) {\n\t\t\t\t\t\tcallsByLine.set(line, {})\n\t\t\t\t\t}\n\t\t\t\t\tconst chainCall = callsByLine.get(line)!\n\t\t\t\t\t// \u68C0\u67E5\u662F\u5426\u662Fpromise\u65B9\u6CD5\n\t\t\t\t\tif (captureText.match(/^(then|catch|finally)$/)) {\n\t\t\t\t\t\tchainCall.functionName = captureText\n\t\t\t\t\t\tchainCall.callType = \"promise\"\n\t\t\t\t\t} else {\n\t\t\t\t\t\t// \u53EA\u6709\u5F53\u6CA1\u6709\u66F4\u9AD8\u4F18\u5148\u7EA7\u7684callType\u65F6\u624D\u8BBE\u7F6E\u4E3Achain\n\t\t\t\t\t\tif (!chainCall.callType) {\n\t\t\t\t\t\t\tchainCall.functionName = captureText\n\t\t\t\t\t\t\tchainCall.callType = \"chain\"\n\t\t\t\t\t\t}\n\t\t\t\t\t}\n\t\t\t\t\tbreak\n\n\t\t\t\t// \u5176\u4ED6\u60C5\u51B5\u5904\u7406...\n\t\t\t\tdefault:\n\t\t\t\t\t// \u5904\u7406\u5176\u4ED6\u7C7B\u578B\u7684\u6355\u83B7\n\t\t\t\t\tbreak\n\t\t\t}\n\t\t}\n\t}\n\n\t// \u5904\u7406\u6309\u884C\u5206\u7EC4\u7684\u590D\u5408\u8C03\u7528\n\tfor (const [line, callInfo] of callsByLine) {\n\t\tif (callInfo.functionName) {\n\t\t\tconst callKey = `${line}-0-${callInfo.functionName}-compound`\n\t\t\tif (!processedCalls.has(callKey)) {\n\t\t\t\tfunctionCalls.push({\n\t\t\t\t\tcalledFunctionName: callInfo.functionName,\n\t\t\t\t\tcallType: callInfo.callType || \"method\",\n\t\t\t\t\treceiver: callInfo.receiver,\n\t\t\t\t\tclassName: callInfo.className,\n\t\t\t\t\tnamespace: callInfo.namespace,\n\t\t\t\t\tcomponent: callInfo.component,\n\t\t\t\t\tcontext: callInfo.context,\n\t\t\t\t\tline: line + 1,\n\t\t\t\t\tcolumn: 0,\n\t\t\t\t\tisAsync: callInfo.isAsync,\n\t\t\t\t\tisOptional: callInfo.isOptional,\n\t\t\t\t\tisReactSpecific: callInfo.isReactSpecific,\n\t\t\t\t})\n\t\t\t\tprocessedCalls.add(callKey)\n\t\t\t}\n\t\t}\n\t}\n\n\treturn {\n\t\tfunctionCalls,\n\t\tscopeInfo,\n\t}\n}\n", "import Parser from \"web-tree-sitter\"\nimport { CodeLanguageType, ISnippetMeta, SnippetType } from \"../types\"\n\nexport interface TSXFunctionCallInfo {\n\tcalledFunctionName: string\n\tcallType:\n\t\t| \"direct\"\n\t\t| \"method\"\n\t\t| \"static\"\n\t\t| \"namespace\"\n\t\t| \"constructor\"\n\t\t| \"chain\"\n\t\t| \"this\"\n\t\t| \"super\"\n\t\t| \"arrow\"\n\t\t| \"async\"\n\t\t| \"array\"\n\t\t| \"promise\"\n\t\t| \"optional\"\n\t\t| \"template\"\n\t\t| \"nested\"\n\t\t| \"react_hook\"\n\t\t| \"react_component\"\n\t\t| \"tsx_component\"\n\t\t| \"event_handler\"\n\t\t| \"react_create\"\n\t\t| \"hoc\"\n\t\t| \"context_hook\"\n\t\t| \"ref_hook\"\n\t\t| \"state_hook\"\n\t\t| \"effect_hook\"\n\t\t| \"memo_hook\"\n\t\t| \"generic_call\"\n\t\t| \"generic_method\"\n\t\t| \"type_assertion\"\n\t\t| \"devtools\"\n\treceiver?: string // \u5BF9\u4E8E\u65B9\u6CD5\u8C03\u7528\uFF0C\u63A5\u6536\u8005\u7684\u540D\u79F0\n\tclassName?: string // \u5BF9\u4E8E\u9759\u6001\u65B9\u6CD5\u8C03\u7528\uFF0C\u7C7B\u7684\u540D\u79F0\n\tnamespace?: string // \u5BF9\u4E8E\u547D\u540D\u7A7A\u95F4\u8C03\u7528\uFF0C\u547D\u540D\u7A7A\u95F4\u7684\u540D\u79F0\n\tcomponent?: string // \u5BF9\u4E8EReact\u7EC4\u4EF6\u8C03\u7528\uFF0C\u7EC4\u4EF6\u7684\u540D\u79F0\n\tcontext?: string // \u5BF9\u4E8EContext hooks\uFF0Ccontext\u7684\u540D\u79F0\n\ttypeArgument?: string // \u5BF9\u4E8E\u6CDB\u578B\u8C03\u7528\uFF0C\u7C7B\u578B\u53C2\u6570\n\tline: number\n\tcolumn: number\n\tisAsync?: boolean // \u662F\u5426\u662F\u5F02\u6B65\u8C03\u7528\n\tisOptional?: boolean // \u662F\u5426\u662F\u53EF\u9009\u94FE\u8C03\u7528\n\tisReactSpecific?: boolean // \u662F\u5426\u662FReact\u7279\u5B9A\u7684\u8C03\u7528\n\tisGeneric?: boolean // \u662F\u5426\u662F\u6CDB\u578B\u8C03\u7528\n}\n\nexport interface TSXFunctionCallAnalysisResult {\n\tfunctionCalls: TSXFunctionCallInfo[]\n\tscopeInfo: {\n\t\tmoduleName?: string\n\t\tcomponentName?: string // \u5982\u679C\u51FD\u6570\u662F\u67D0\u4E2AReact\u7EC4\u4EF6\u7684\u4E00\u90E8\u5206\n\t\tfunctionName: string\n\t\tisAsync?: boolean\n\t\tisReactComponent?: boolean // \u662F\u5426\u662FReact\u7EC4\u4EF6\n\t\tisTypeScript?: boolean // \u662F\u5426\u662FTypeScript\u7279\u6027\n\t}\n}\n\nexport function dependenciesCapturesProcessForTSX(captures: Parser.QueryCapture[]): ISnippetMeta[] {\n\tconst result = analyzeTSXFunctionCalls(captures)\n\treturn result.functionCalls.map((call) => {\n\t\tconst def: any = {\n\t\t\tname: call.calledFunctionName,\n\t\t\ttype: call.callType,\n\t\t\tisAsync: call.isAsync,\n\t\t}\n\t\tif (call.isGeneric) def.isGeneric = true\n\t\tif (call.isReactSpecific) def.isReactSpecific = true\n\t\treturn {\n\t\t\tname: call.calledFunctionName,\n\t\t\ttype: SnippetType.FunctionOrMethod,\n\t\t\tfilePath: \"\",\n\t\t\tstartLine: call.line,\n\t\t\tendLine: call.line,\n\t\t\tstartPosition: {\n\t\t\t\trow: call.line,\n\t\t\t\tcolumn: call.column,\n\t\t\t},\n\t\t\tendPosition: {\n\t\t\t\trow: call.line,\n\t\t\t\tcolumn: call.column,\n\t\t\t},\n\t\t\trangeText: \"\",\n\t\t\tfileHash: \"\",\n\t\t\tdefinition: def,\n\t\t\tfield: call.className || call.namespace || call.component || call.context || call.typeArgument,\n\t\t\tsignature: buildSignatureForTSXCall(call),\n\t\t\tlanguage: CodeLanguageType.TSX,\n\t\t}\n\t})\n}\n\n/**\n * \u4E3ATSX\u51FD\u6570\u8C03\u7528\u6784\u5EFA\u7B7E\u540D\n */\nfunction buildSignatureForTSXCall(call: TSXFunctionCallInfo): string {\n\tswitch (call.callType) {\n\t\tcase \"react_hook\":\n\t\t\treturn `${call.calledFunctionName}() // React Hook`\n\t\tcase \"react_component\":\n\t\t\treturn `${call.calledFunctionName}() // React Component`\n\t\tcase \"tsx_component\":\n\t\t\treturn `${call.calledFunctionName}() // TSX Component`\n\t\tcase \"event_handler\":\n\t\t\treturn `${call.calledFunctionName}() // Event Handler`\n\t\tcase \"react_create\":\n\t\t\treturn `React.createElement(${call.component}) // React.createElement`\n\t\tcase \"hoc\":\n\t\t\treturn `${call.calledFunctionName}(${call.component}) // Higher-Order Component`\n\t\tcase \"context_hook\":\n\t\t\treturn `useContext(${call.context}) // Context Hook`\n\t\tcase \"ref_hook\":\n\t\t\treturn `${call.calledFunctionName}() // Ref Hook`\n\t\tcase \"state_hook\":\n\t\t\treturn `${call.calledFunctionName}() // State Hook`\n\t\tcase \"effect_hook\":\n\t\t\treturn `${call.calledFunctionName}() // Effect Hook`\n\t\tcase \"memo_hook\":\n\t\t\treturn `${call.calledFunctionName}() // Memo Hook`\n\t\tcase \"generic_call\":\n\t\t\treturn `${call.calledFunctionName}<${call.typeArgument}>() // Generic Function`\n\t\tcase \"generic_method\":\n\t\t\treturn `${call.receiver}.${call.calledFunctionName}<${call.typeArgument}>() // Generic Method`\n\t\tcase \"type_assertion\":\n\t\t\treturn `as ${call.typeArgument} // Type Assertion`\n\t\tdefault:\n\t\t\treturn `${call.calledFunctionName}()`\n\t}\n}\n\n/**\n * \u5206\u6790 TSX \u8BED\u8A00\u7684\u51FD\u6570\u8C03\u7528\uFF0C\u5305\u62ECReact\u548CTypeScript\u7279\u6709\u7684\u6A21\u5F0F\n */\nfunction analyzeTSXFunctionCalls(captures: Parser.QueryCapture[]): TSXFunctionCallAnalysisResult {\n\tconst functionCalls: TSXFunctionCallInfo[] = []\n\tconst scopeInfo = {\n\t\tmoduleName: undefined as string | undefined,\n\t\tcomponentName: undefined as string | undefined,\n\t\tfunctionName: \"unknown\",\n\t\tisAsync: false,\n\t\tisReactComponent: false,\n\t\tisTypeScript: true,\n\t}\n\n\t// \u7528\u4E8E\u4E34\u65F6\u5B58\u50A8\u540C\u4E00\u884C\u7684\u65B9\u6CD5\u8C03\u7528\u4FE1\u606F\n\tconst callsByLine = new Map<\n\t\tnumber,\n\t\t{\n\t\t\tfunctionName?: string\n\t\t\treceiver?: string\n\t\t\tclassName?: string\n\t\t\tnamespace?: string\n\t\t\tcomponent?: string\n\t\t\tcontext?: string\n\t\t\ttypeArgument?: string\n\t\t\tcallType?: TSXFunctionCallInfo[\"callType\"]\n\t\t\tisAsync?: boolean\n\t\t\tisOptional?: boolean\n\t\t\tisReactSpecific?: boolean\n\t\t\tisGeneric?: boolean\n\t\t}\n\t>()\n\n\t// \u7528\u4E8E\u8DDF\u8E2A\u5DF2\u5904\u7406\u7684\u51FD\u6570\u8C03\u7528\uFF0C\u907F\u514D\u91CD\u590D\n\tconst processedCalls = new Set()\n\n\t// \u6309\u7167\u4F18\u5148\u7EA7\u5206\u7EC4\u5904\u7406\u6355\u83B7\n\tconst priorityGroups = {\n\t\thoc: [] as Parser.QueryCapture[],\n\t\treactCreate: [] as Parser.QueryCapture[],\n\t\treactHooks: [] as Parser.QueryCapture[],\n\t\teventHandlers: [] as Parser.QueryCapture[],\n\t\tgenericCalls: [] as Parser.QueryCapture[],\n\t\ttypeAssertions: [] as Parser.QueryCapture[],\n\t\tawaitCalls: [] as Parser.QueryCapture[],\n\t\tarrayMethods: [] as Parser.QueryCapture[],\n\t\tpromiseMethods: [] as Parser.QueryCapture[],\n\t\tdirectCalls: [] as Parser.QueryCapture[],\n\t\tmethodCalls: [] as Parser.QueryCapture[],\n\t\tother: [] as Parser.QueryCapture[],\n\t}\n\n\t// \u5C06\u6355\u83B7\u5206\u7C7B\u5230\u4F18\u5148\u7EA7\u7EC4\n\tfor (const capture of captures) {\n\t\tswitch (capture.name) {\n\t\t\tcase \"hoc.call.name\":\n\t\t\tcase \"hoc.call.component\":\n\t\t\t\tpriorityGroups.hoc.push(capture)\n\t\t\t\tbreak\n\t\t\tcase \"react.create.namespace\":\n\t\t\tcase \"react.create.method\":\n\t\t\t\tpriorityGroups.reactCreate.push(capture)\n\t\t\t\tbreak\n\t\t\tcase \"state.hook.call\":\n\t\t\tcase \"effect.hook.call\":\n\t\t\tcase \"memo.hook.call\":\n\t\t\tcase \"ref.hook.call\":\n\t\t\tcase \"context.hook.call\":\n\t\t\tcase \"react.hook.call\":\n\t\t\t\tpriorityGroups.reactHooks.push(capture)\n\t\t\t\tbreak\n\t\t\tcase \"event.handler.function\":\n\t\t\t\tpriorityGroups.eventHandlers.push(capture)\n\t\t\t\tbreak\n\t\t\tcase \"generic.call.function\":\n\t\t\tcase \"generic.call.receiver\":\n\t\t\tcase \"generic.call.method\":\n\t\t\tcase \"generic.constructor.call.name\":\n\t\t\t\tpriorityGroups.genericCalls.push(capture)\n\t\t\t\tbreak\n\t\t\tcase \"type.assertion.type\":\n\t\t\t\tpriorityGroups.typeAssertions.push(capture)\n\t\t\t\tbreak\n\t\t\tcase \"await.call.function\":\n\t\t\tcase \"async.call.receiver\":\n\t\t\tcase \"async.call.method\":\n\t\t\t\tpriorityGroups.awaitCalls.push(capture)\n\t\t\t\tbreak\n\t\t\tcase \"array.call.method\":\n\t\t\tcase \"array.call.object\":\n\t\t\t\tpriorityGroups.arrayMethods.push(capture)\n\t\t\t\tbreak\n\t\t\tcase \"promise.call.method\":\n\t\t\tcase \"promise.call.object\":\n\t\t\t\tpriorityGroups.promiseMethods.push(capture)\n\t\t\t\tbreak\n\t\t\tcase \"function.call.direct\":\n\t\t\t\tpriorityGroups.directCalls.push(capture)\n\t\t\t\tbreak\n\t\t\tcase \"method.call.name\":\n\t\t\tcase \"method.call.receiver\":\n\t\t\tcase \"method.call.chain\":\n\t\t\tcase \"optional.call.receiver\":\n\t\t\tcase \"optional.call.method\":\n\t\t\tcase \"static.call.class\":\n\t\t\tcase \"static.call.method\":\n\t\t\t\tpriorityGroups.methodCalls.push(capture)\n\t\t\t\tbreak\n\t\t\tdefault:\n\t\t\t\tpriorityGroups.other.push(capture)\n\t\t\t\tbreak\n\t\t}\n\t}\n\n\t// \u6309\u4F18\u5148\u7EA7\u987A\u5E8F\u5904\u7406\u7EC4\n\tconst allGroups = [\n\t\tpriorityGroups.hoc,\n\t\tpriorityGroups.reactCreate,\n\t\tpriorityGroups.reactHooks,\n\t\tpriorityGroups.eventHandlers,\n\t\tpriorityGroups.genericCalls,\n\t\tpriorityGroups.typeAssertions,\n\t\tpriorityGroups.awaitCalls,\n\t\tpriorityGroups.arrayMethods,\n\t\tpriorityGroups.promiseMethods,\n\t\tpriorityGroups.methodCalls,\n\t\tpriorityGroups.other,\n\t\tpriorityGroups.directCalls, // \u76F4\u63A5\u8C03\u7528\u653E\u6700\u540E\uFF0C\u4F18\u5148\u7EA7\u6700\u4F4E\n\t]\n\n\tfor (const group of allGroups) {\n\t\tfor (const capture of group) {\n\t\t\tconst node = capture.node\n\t\t\tconst captureText = node.text.trim()\n\t\t\tconst line = node.startPosition.row\n\t\t\tconst callKey = `${line}-${node.startPosition.column}-${captureText}-${capture.name}`\n\n\t\t\t// \u8DF3\u8FC7\u5DF2\u7ECF\u5904\u7406\u7684\u8C03\u7528 - \u7528\u66F4\u5177\u4F53\u7684key\u907F\u514D\u51B2\u7A81\n\t\t\tif (processedCalls.has(callKey)) {\n\t\t\t\tcontinue\n\t\t\t}\n\n\t\t\t// \u5BF9\u4E8E\u76F4\u63A5\u51FD\u6570\u8C03\u7528\uFF0C\u68C0\u67E5\u662F\u5426\u5DF2\u7ECF\u88AB\u66F4\u9AD8\u4F18\u5148\u7EA7\u7684\u67E5\u8BE2\u5904\u7406\n\t\t\tif (capture.name === \"function.call.direct\") {\n\t\t\t\tconst generalCallKey = `${line}-${captureText}`\n\t\t\t\tlet isAlreadyProcessed = false\n\n\t\t\t\t// \u68C0\u67E5\u662F\u5426\u5DF2\u7ECF\u6709\u76F8\u540C\u7684\u51FD\u6570\u8C03\u7528\u88AB\u5904\u7406\n\t\t\t\tfor (const existingKey of processedCalls) {\n\t\t\t\t\tif (existingKey.includes(generalCallKey)) {\n\t\t\t\t\t\tisAlreadyProcessed = true\n\t\t\t\t\t\tbreak\n\t\t\t\t\t}\n\t\t\t\t}\n\n\t\t\t\t// \u68C0\u67E5\u662F\u5426\u5728callsByLine\u4E2D\u5DF2\u7ECF\u6709\u540C\u4E00\u884C\u7684\u540C\u540D\u51FD\u6570\n\t\t\t\tconst lineCall = callsByLine.get(line)\n\t\t\t\tif (lineCall?.functionName === captureText) {\n\t\t\t\t\tisAlreadyProcessed = true\n\t\t\t\t}\n\n\t\t\t\tif (isAlreadyProcessed) {\n\t\t\t\t\tcontinue\n\t\t\t\t}\n\t\t\t}\n\n\t\t\tswitch (capture.name) {\n\t\t\t\tcase \"hoc.call.name\":\n\t\t\t\t\t// \u9AD8\u9636\u7EC4\u4EF6\u8C03\u7528\u7684HOC\u540D\n\t\t\t\t\tif (!callsByLine.has(line)) {\n\t\t\t\t\t\tcallsByLine.set(line, {})\n\t\t\t\t\t}\n\t\t\t\t\tconst hocCall = callsByLine.get(line)!\n\t\t\t\t\thocCall.functionName = captureText\n\t\t\t\t\thocCall.callType = \"hoc\"\n\t\t\t\t\thocCall.isReactSpecific = true\n\t\t\t\t\tbreak\n\n\t\t\t\tcase \"hoc.call.component\":\n\t\t\t\t\t// \u9AD8\u9636\u7EC4\u4EF6\u8C03\u7528\u7684\u7EC4\u4EF6\u53C2\u6570\n\t\t\t\t\tif (!callsByLine.has(line)) {\n\t\t\t\t\t\tcallsByLine.set(line, {})\n\t\t\t\t\t}\n\t\t\t\t\tcallsByLine.get(line)!.component = captureText\n\t\t\t\t\tbreak\n\n\t\t\t\tcase \"react.create.method\":\n\t\t\t\t\t// React.createElement \u65B9\u6CD5\n\t\t\t\t\tif (!callsByLine.has(line)) {\n\t\t\t\t\t\tcallsByLine.set(line, {})\n\t\t\t\t\t}\n\t\t\t\t\tconst createCall = callsByLine.get(line)!\n\t\t\t\t\tcreateCall.functionName = captureText\n\t\t\t\t\tcreateCall.callType = \"react_create\"\n\t\t\t\t\tcreateCall.isReactSpecific = true\n\t\t\t\t\tbreak\n\n\t\t\t\tcase \"state.hook.call\":\n\t\t\t\t\t// State Hook \u8C03\u7528\n\t\t\t\t\tfunctionCalls.push({\n\t\t\t\t\t\tcalledFunctionName: captureText,\n\t\t\t\t\t\tcallType: \"state_hook\",\n\t\t\t\t\t\tline: line + 1,\n\t\t\t\t\t\tcolumn: node.startPosition.column,\n\t\t\t\t\t\tisReactSpecific: true,\n\t\t\t\t\t})\n\t\t\t\t\tprocessedCalls.add(callKey)\n\t\t\t\t\tbreak\n\n\t\t\t\tcase \"effect.hook.call\":\n\t\t\t\t\t// Effect Hook \u8C03\u7528\n\t\t\t\t\tfunctionCalls.push({\n\t\t\t\t\t\tcalledFunctionName: captureText,\n\t\t\t\t\t\tcallType: \"effect_hook\",\n\t\t\t\t\t\tline: line + 1,\n\t\t\t\t\t\tcolumn: node.startPosition.column,\n\t\t\t\t\t\tisReactSpecific: true,\n\t\t\t\t\t})\n\t\t\t\t\tprocessedCalls.add(callKey)\n\t\t\t\t\tbreak\n\n\t\t\t\tcase \"memo.hook.call\":\n\t\t\t\t\t// Memo Hook \u8C03\u7528\n\t\t\t\t\tfunctionCalls.push({\n\t\t\t\t\t\tcalledFunctionName: captureText,\n\t\t\t\t\t\tcallType: \"memo_hook\",\n\t\t\t\t\t\tline: line + 1,\n\t\t\t\t\t\tcolumn: node.startPosition.column,\n\t\t\t\t\t\tisReactSpecific: true,\n\t\t\t\t\t})\n\t\t\t\t\tprocessedCalls.add(callKey)\n\t\t\t\t\tbreak\n\n\t\t\t\tcase \"ref.hook.call\":\n\t\t\t\t\t// Ref Hook \u8C03\u7528\n\t\t\t\t\tfunctionCalls.push({\n\t\t\t\t\t\tcalledFunctionName: captureText,\n\t\t\t\t\t\tcallType: \"ref_hook\",\n\t\t\t\t\t\tline: line + 1,\n\t\t\t\t\t\tcolumn: node.startPosition.column,\n\t\t\t\t\t\tisReactSpecific: true,\n\t\t\t\t\t})\n\t\t\t\t\tprocessedCalls.add(callKey)\n\t\t\t\t\tbreak\n\n\t\t\t\tcase \"context.hook.call\":\n\t\t\t\t\t// Context Hook \u8C03\u7528\n\t\t\t\t\tfunctionCalls.push({\n\t\t\t\t\t\tcalledFunctionName: captureText,\n\t\t\t\t\t\tcallType: \"context_hook\",\n\t\t\t\t\t\tline: line + 1,\n\t\t\t\t\t\tcolumn: node.startPosition.column,\n\t\t\t\t\t\tisReactSpecific: true,\n\t\t\t\t\t})\n\t\t\t\t\tprocessedCalls.add(callKey)\n\t\t\t\t\tbreak\n\n\t\t\t\tcase \"react.hook.call\":\n\t\t\t\t\t// React Hook \u8C03\u7528\n\t\t\t\t\tfunctionCalls.push({\n\t\t\t\t\t\tcalledFunctionName: captureText,\n\t\t\t\t\t\tcallType: \"react_hook\",\n\t\t\t\t\t\tline: line + 1,\n\t\t\t\t\t\tcolumn: node.startPosition.column,\n\t\t\t\t\t\tisReactSpecific: true,\n\t\t\t\t\t})\n\t\t\t\t\tprocessedCalls.add(callKey)\n\t\t\t\t\tbreak\n\n\t\t\t\tcase \"event.handler.function\":\n\t\t\t\t\t// \u4E8B\u4EF6\u5904\u7406\u5668\u51FD\u6570\n\t\t\t\t\tconsole.log(\n\t\t\t\t\t\t`[DEBUG] Event handler captured: ${captureText} at line ${line + 1}, column ${node.startPosition.column}`,\n\t\t\t\t\t)\n\t\t\t\t\tfunctionCalls.push({\n\t\t\t\t\t\tcalledFunctionName: captureText,\n\t\t\t\t\t\tcallType: \"event_handler\",\n\t\t\t\t\t\tline: line + 1,\n\t\t\t\t\t\tcolumn: node.startPosition.column,\n\t\t\t\t\t\tisReactSpecific: true,\n\t\t\t\t\t})\n\t\t\t\t\tprocessedCalls.add(callKey)\n\t\t\t\t\tbreak\n\n\t\t\t\tcase \"generic.call.function\":\n\t\t\t\t\t// \u6CDB\u578B\u51FD\u6570\u8C03\u7528\n\t\t\t\t\tif (!callsByLine.has(line)) {\n\t\t\t\t\t\tcallsByLine.set(line, {})\n\t\t\t\t\t}\n\t\t\t\t\tconst genericCall = callsByLine.get(line)!\n\t\t\t\t\tgenericCall.functionName = captureText\n\t\t\t\t\tgenericCall.callType = \"generic_call\"\n\t\t\t\t\tgenericCall.isGeneric = true\n\t\t\t\t\tbreak\n\n\t\t\t\tcase \"generic.call.receiver\":\n\t\t\t\t\t// \u6CDB\u578B\u65B9\u6CD5\u8C03\u7528\u7684\u63A5\u6536\u8005\n\t\t\t\t\tif (!callsByLine.has(line)) {\n\t\t\t\t\t\tcallsByLine.set(line, {})\n\t\t\t\t\t}\n\t\t\t\t\tcallsByLine.get(line)!.receiver = captureText\n\t\t\t\t\tbreak\n\n\t\t\t\tcase \"generic.call.method\":\n\t\t\t\t\t// \u6CDB\u578B\u65B9\u6CD5\u8C03\u7528\u7684\u65B9\u6CD5\u540D\n\t\t\t\t\tif (!callsByLine.has(line)) {\n\t\t\t\t\t\tcallsByLine.set(line, {})\n\t\t\t\t\t}\n\t\t\t\t\tconst genericMethodCall = callsByLine.get(line)!\n\t\t\t\t\tgenericMethodCall.functionName = captureText\n\t\t\t\t\tgenericMethodCall.callType = \"generic_method\"\n\t\t\t\t\tgenericMethodCall.isGeneric = true\n\t\t\t\t\tbreak\n\n\t\t\t\tcase \"generic.constructor.call.name\":\n\t\t\t\t\t// \u6CDB\u578B\u6784\u9020\u51FD\u6570\u8C03\u7528\n\t\t\t\t\tif (!callsByLine.has(line)) {\n\t\t\t\t\t\tcallsByLine.set(line, {})\n\t\t\t\t\t}\n\t\t\t\t\tconst genericConstructorCall = callsByLine.get(line)!\n\t\t\t\t\tgenericConstructorCall.functionName = captureText\n\t\t\t\t\tgenericConstructorCall.callType = \"constructor\"\n\t\t\t\t\tgenericConstructorCall.isGeneric = true\n\t\t\t\t\tbreak\n\n\t\t\t\tcase \"type.assertion.type\":\n\t\t\t\t\t// \u7C7B\u578B\u65AD\u8A00\n\t\t\t\t\tfunctionCalls.push({\n\t\t\t\t\t\tcalledFunctionName: \"as\",\n\t\t\t\t\t\tcallType: \"type_assertion\",\n\t\t\t\t\t\ttypeArgument: captureText,\n\t\t\t\t\t\tline: line + 1,\n\t\t\t\t\t\tcolumn: node.startPosition.column,\n\t\t\t\t\t})\n\t\t\t\t\tprocessedCalls.add(callKey)\n\t\t\t\t\tbreak\n\n\t\t\t\tcase \"await.call.function\":\n\t\t\t\t\t// await \u8868\u8FBE\u5F0F\u4E2D\u7684\u51FD\u6570\u8C03\u7528\n\t\t\t\t\tfunctionCalls.push({\n\t\t\t\t\t\tcalledFunctionName: captureText,\n\t\t\t\t\t\tcallType: \"async\",\n\t\t\t\t\t\tisAsync: true,\n\t\t\t\t\t\tline: line + 1,\n\t\t\t\t\t\tcolumn: node.startPosition.column,\n\t\t\t\t\t})\n\t\t\t\t\tprocessedCalls.add(callKey)\n\t\t\t\t\tbreak\n\n\t\t\t\tcase \"promise.call.method\":\n\t\t\t\t\t// Promise \u65B9\u6CD5\u8C03\u7528\n\t\t\t\t\tconsole.log(\n\t\t\t\t\t\t`[DEBUG] Promise method captured: ${captureText} at line ${line + 1}, column ${node.startPosition.column}`,\n\t\t\t\t\t)\n\t\t\t\t\tif (!callsByLine.has(line)) {\n\t\t\t\t\t\tcallsByLine.set(line, {})\n\t\t\t\t\t}\n\t\t\t\t\tconst promiseCall = callsByLine.get(line)!\n\t\t\t\t\tpromiseCall.functionName = captureText\n\t\t\t\t\tpromiseCall.callType = \"promise\"\n\t\t\t\t\tbreak\n\n\t\t\t\tcase \"promise.call.object\":\n\t\t\t\t\t// Promise \u65B9\u6CD5\u8C03\u7528\u7684\u5BF9\u8C61\n\t\t\t\t\tif (!callsByLine.has(line)) {\n\t\t\t\t\t\tcallsByLine.set(line, {})\n\t\t\t\t\t}\n\t\t\t\t\tcallsByLine.get(line)!.receiver = captureText\n\t\t\t\t\tbreak\n\n\t\t\t\tcase \"array.call.method\":\n\t\t\t\t\t// \u6570\u7EC4\u65B9\u6CD5\u8C03\u7528\n\t\t\t\t\tif (!callsByLine.has(line)) {\n\t\t\t\t\t\tcallsByLine.set(line, {})\n\t\t\t\t\t}\n\t\t\t\t\tconst arrayCall = callsByLine.get(line)!\n\t\t\t\t\tarrayCall.functionName = captureText\n\t\t\t\t\tarrayCall.callType = \"array\"\n\t\t\t\t\tbreak\n\n\t\t\t\tcase \"array.call.object\":\n\t\t\t\t\t// \u6570\u7EC4\u65B9\u6CD5\u8C03\u7528\u7684\u5BF9\u8C61\n\t\t\t\t\tif (!callsByLine.has(line)) {\n\t\t\t\t\t\tcallsByLine.set(line, {})\n\t\t\t\t\t}\n\t\t\t\t\tcallsByLine.get(line)!.receiver = captureText\n\t\t\t\t\tbreak\n\n\t\t\t\tcase \"async.call.receiver\":\n\t\t\t\t\t// \u5F02\u6B65\u65B9\u6CD5\u8C03\u7528\u7684\u63A5\u6536\u8005\n\t\t\t\t\tif (!callsByLine.has(line)) {\n\t\t\t\t\t\tcallsByLine.set(line, {})\n\t\t\t\t\t}\n\t\t\t\t\tconst asyncCall = callsByLine.get(line)!\n\t\t\t\t\tasyncCall.receiver = captureText\n\t\t\t\t\tasyncCall.isAsync = true\n\t\t\t\t\tbreak\n\n\t\t\t\tcase \"async.call.method\":\n\t\t\t\t\t// \u5F02\u6B65\u65B9\u6CD5\u8C03\u7528\u7684\u65B9\u6CD5\u540D\n\t\t\t\t\tif (!callsByLine.has(line)) {\n\t\t\t\t\t\tcallsByLine.set(line, {})\n\t\t\t\t\t}\n\t\t\t\t\tconst asyncMethodCall = callsByLine.get(line)!\n\t\t\t\t\tasyncMethodCall.functionName = captureText\n\t\t\t\t\tasyncMethodCall.callType = \"async\"\n\t\t\t\t\tbreak\n\n\t\t\t\tcase \"method.call.name\":\n\t\t\t\t\t// \u65B9\u6CD5\u8C03\u7528\u7684\u65B9\u6CD5\u540D\n\t\t\t\t\tif (!callsByLine.has(line)) {\n\t\t\t\t\t\tcallsByLine.set(line, {})\n\t\t\t\t\t}\n\t\t\t\t\tconst methodCall = callsByLine.get(line)!\n\t\t\t\t\t// \u53EA\u6709\u5F53\u6CA1\u6709\u66F4\u9AD8\u4F18\u5148\u7EA7\u7684callType\u65F6\u624D\u8BBE\u7F6E\u4E3Amethod\n\t\t\t\t\tif (!methodCall.callType) {\n\t\t\t\t\t\tmethodCall.functionName = captureText\n\t\t\t\t\t\tmethodCall.callType = \"method\"\n\t\t\t\t\t}\n\t\t\t\t\tbreak\n\n\t\t\t\tcase \"method.call.receiver\":\n\t\t\t\t\t// \u65B9\u6CD5\u8C03\u7528\u7684\u63A5\u6536\u8005\n\t\t\t\t\tif (!callsByLine.has(line)) {\n\t\t\t\t\t\tcallsByLine.set(line, {})\n\t\t\t\t\t}\n\t\t\t\t\tcallsByLine.get(line)!.receiver = captureText\n\t\t\t\t\tbreak\n\n\t\t\t\tcase \"static.call.class\":\n\t\t\t\t\t// \u9759\u6001\u65B9\u6CD5\u8C03\u7528\u7684\u7C7B\u540D\n\t\t\t\t\tif (!callsByLine.has(line)) {\n\t\t\t\t\t\tcallsByLine.set(line, {})\n\t\t\t\t\t}\n\t\t\t\t\tconst staticClassCall = callsByLine.get(line)!\n\t\t\t\t\t// \u53EA\u6709\u5F53\u6CA1\u6709\u66F4\u9AD8\u4F18\u5148\u7EA7\u7684callType\u65F6\u624D\u8BBE\u7F6E\u4E3Astatic\n\t\t\t\t\tif (!staticClassCall.callType || staticClassCall.callType === \"method\") {\n\t\t\t\t\t\tstaticClassCall.className = captureText\n\t\t\t\t\t\tstaticClassCall.callType = \"static\"\n\t\t\t\t\t}\n\t\t\t\t\tbreak\n\n\t\t\t\tcase \"static.call.method\":\n\t\t\t\t\t// \u9759\u6001\u65B9\u6CD5\u8C03\u7528\u7684\u65B9\u6CD5\u540D\n\t\t\t\t\tfunctionCalls.push({\n\t\t\t\t\t\tcalledFunctionName: captureText,\n\t\t\t\t\t\tcallType: \"static\",\n\t\t\t\t\t\tline: line + 1,\n\t\t\t\t\t\tcolumn: node.startPosition.column,\n\t\t\t\t\t})\n\t\t\t\t\tprocessedCalls.add(callKey)\n\t\t\t\t\tbreak\n\n\t\t\t\tcase \"optional.call.receiver\":\n\t\t\t\t\t// \u53EF\u9009\u94FE\u8C03\u7528\u7684\u63A5\u6536\u8005\n\t\t\t\t\tif (!callsByLine.has(line)) {\n\t\t\t\t\t\tcallsByLine.set(line, {})\n\t\t\t\t\t}\n\t\t\t\t\tconst optionalCall = callsByLine.get(line)!\n\t\t\t\t\toptionalCall.receiver = captureText\n\t\t\t\t\toptionalCall.isOptional = true\n\t\t\t\t\tbreak\n\n\t\t\t\tcase \"optional.call.method\":\n\t\t\t\t\t// \u53EF\u9009\u94FE\u8C03\u7528\u7684\u65B9\u6CD5\u540D - \u53EA\u5728\u5B9E\u9645\u68C0\u6D4B\u5230\u53EF\u9009\u94FE\u65F6\u4F7F\u7528\n\t\t\t\t\tif (!callsByLine.has(line)) {\n\t\t\t\t\t\tcallsByLine.set(line, {})\n\t\t\t\t\t}\n\t\t\t\t\tconst optionalMethodCall = callsByLine.get(line)!\n\t\t\t\t\t// \u6682\u65F6\u7981\u7528\u53EF\u9009\u94FE\u68C0\u6D4B\uFF0C\u56E0\u4E3A\u5B83\u4E0E\u666E\u901A\u65B9\u6CD5\u8C03\u7528\u51B2\u7A81\n\t\t\t\t\t// TODO: \u9700\u8981\u66F4\u7CBE\u786E\u7684\u53EF\u9009\u94FE\u68C0\u6D4B\u903B\u8F91\n\t\t\t\t\t// if (!optionalMethodCall.callType || optionalMethodCall.callType === \"method\") {\n\t\t\t\t\t// optionalMethodCall.functionName = captureText\n\t\t\t\t\t// optionalMethodCall.callType = \"optional\"\n\t\t\t\t\t// }\n\t\t\t\t\tbreak\n\n\t\t\t\tcase \"function.call.direct\":\n\t\t\t\t\t// \u76F4\u63A5\u51FD\u6570\u8C03\u7528 - \u53EA\u6709\u5728\u6CA1\u6709\u88AB\u66F4\u9AD8\u4F18\u5148\u7EA7\u5904\u7406\u65F6\u624D\u5904\u7406\n\t\t\t\t\tfunctionCalls.push({\n\t\t\t\t\t\tcalledFunctionName: captureText,\n\t\t\t\t\t\tcallType: \"direct\",\n\t\t\t\t\t\tline: line + 1,\n\t\t\t\t\t\tcolumn: node.startPosition.column,\n\t\t\t\t\t})\n\t\t\t\t\tprocessedCalls.add(callKey)\n\t\t\t\t\tbreak\n\n\t\t\t\tcase \"method.call.chain\":\n\t\t\t\t\t// \u94FE\u5F0F\u65B9\u6CD5\u8C03\u7528 - \u68C0\u67E5\u662F\u5426\u662Fpromise\u65B9\u6CD5\n\t\t\t\t\tif (!callsByLine.has(line)) {\n\t\t\t\t\t\tcallsByLine.set(line, {})\n\t\t\t\t\t}\n\t\t\t\t\tconst chainCall = callsByLine.get(line)!\n\t\t\t\t\t// \u68C0\u67E5\u662F\u5426\u662Fpromise\u65B9\u6CD5\n\t\t\t\t\tif (captureText.match(/^(then|catch|finally)$/)) {\n\t\t\t\t\t\tchainCall.functionName = captureText\n\t\t\t\t\t\tchainCall.callType = \"promise\"\n\t\t\t\t\t} else {\n\t\t\t\t\t\t// \u53EA\u6709\u5F53\u6CA1\u6709\u66F4\u9AD8\u4F18\u5148\u7EA7\u7684callType\u65F6\u624D\u8BBE\u7F6E\u4E3Achain\n\t\t\t\t\t\tif (!chainCall.callType) {\n\t\t\t\t\t\t\tchainCall.functionName = captureText\n\t\t\t\t\t\t\tchainCall.callType = \"chain\"\n\t\t\t\t\t\t}\n\t\t\t\t\t}\n\t\t\t\t\tbreak\n\n\t\t\t\t// \u5176\u4ED6\u60C5\u51B5\u5904\u7406...\n\t\t\t\tdefault:\n\t\t\t\t\t// \u5904\u7406\u5176\u4ED6\u7C7B\u578B\u7684\u6355\u83B7\n\t\t\t\t\tbreak\n\t\t\t}\n\t\t}\n\t}\n\n\t// \u5904\u7406\u6309\u884C\u5206\u7EC4\u7684\u590D\u5408\u8C03\u7528\n\tfor (const [line, callInfo] of callsByLine) {\n\t\tif (callInfo.functionName) {\n\t\t\tconst callKey = `${line}-0-${callInfo.functionName}-compound`\n\t\t\tif (!processedCalls.has(callKey)) {\n\t\t\t\tlet callType = callInfo.callType\n\t\t\t\t// 1. event_handler\u7C7B\u578B\u76F4\u63A5\u63A8\u5165\n\t\t\t\tif (callType === \"event_handler\") {\n\t\t\t\t\t// do nothing, \u4FDD\u6301event_handler\n\t\t\t\t} else if (callType === \"promise\") {\n\t\t\t\t\t// 2. promise\u7C7B\u578B\u76F4\u63A5\u63A8\u5165\n\t\t\t\t\t// do nothing, \u4FDD\u6301promise\n\t\t\t\t} else if (callInfo.className && (callType === \"generic_method\" || callType === \"method\")) {\n\t\t\t\t\t// 3. \u53EA\u8981className\u5B58\u5728\u4E14callType\u4E3Ageneric_method\u6216method\u90FD\u8F6C\u4E3Astatic\n\t\t\t\t\tcallType = \"static\"\n\t\t\t\t}\n\t\t\t\tfunctionCalls.push({\n\t\t\t\t\tcalledFunctionName: callInfo.functionName,\n\t\t\t\t\tcallType: callType || \"method\",\n\t\t\t\t\treceiver: callInfo.receiver,\n\t\t\t\t\tclassName: callInfo.className,\n\t\t\t\t\tnamespace: callInfo.namespace,\n\t\t\t\t\tcomponent: callInfo.component,\n\t\t\t\t\tcontext: callInfo.context,\n\t\t\t\t\ttypeArgument: callInfo.typeArgument,\n\t\t\t\t\tline: line + 1,\n\t\t\t\t\tcolumn: 0,\n\t\t\t\t\tisAsync: callInfo.isAsync,\n\t\t\t\t\tisOptional: callInfo.isOptional,\n\t\t\t\t\tisReactSpecific: callInfo.isReactSpecific,\n\t\t\t\t\tisGeneric: callInfo.isGeneric,\n\t\t\t\t})\n\t\t\t\tprocessedCalls.add(callKey)\n\t\t\t}\n\t\t}\n\t}\n\n\t// \u5904\u7406as_expression\u7C7B\u578B\u65AD\u8A00\uFF08@type.assertion\uFF09\n\tfor (const capture of captures) {\n\t\tif (capture.name === \"type.assertion\") {\n\t\t\tconst node = capture.node\n\t\t\tfunctionCalls.push({\n\t\t\t\tcalledFunctionName: \"as\",\n\t\t\t\tcallType: \"type_assertion\",\n\t\t\t\tline: node.startPosition.row + 1,\n\t\t\t\tcolumn: node.startPosition.column,\n\t\t\t})\n\t\t}\n\t}\n\n\treturn {\n\t\tfunctionCalls,\n\t\tscopeInfo,\n\t}\n}\n", "import { CodeLanguageType } from \"../types\"\nimport * as queries from \"./queries\"\nimport Parser from \"web-tree-sitter\"\nimport { ISnippetMeta } from \"../types\"\nimport { dependenciesCapturesProcessForGo } from \"./go\"\nimport { dependenciesCapturesProcessForTypeScript } from \"./typescript\"\nimport { dependenciesCapturesProcessForJavaScript } from \"./javascript\"\nimport { dependenciesCapturesProcessForJava } from \"./java\"\nimport { dependenciesCapturesProcessForPython } from \"./python\"\nimport { dependenciesCapturesProcessForJSX } from \"./jsx\"\nimport { dependenciesCapturesProcessForTSX } from \"./tsx\"\n\nexport const dependenciesCapturesQueries: Record = {\n\t[CodeLanguageType.Go]: queries.goQuery,\n\t[CodeLanguageType.Python]: queries.pythonQuery,\n\t[CodeLanguageType.TypeScript]: queries.typescriptQuery,\n\t[CodeLanguageType.JavaScript]: queries.javascriptQuery,\n\t[CodeLanguageType.Java]: queries.javaQuery,\n\t[CodeLanguageType.JSX]: queries.jsxQuery,\n\t[CodeLanguageType.TSX]: queries.tsxQuery,\n\t[CodeLanguageType.Swift]: null,\n\t[CodeLanguageType.CSS]: null,\n\t[CodeLanguageType.HTML]: null,\n\t[CodeLanguageType.Kotlin]: null,\n\t[CodeLanguageType.PHP]: null,\n\t[CodeLanguageType.Rust]: null,\n\t[CodeLanguageType.C]: null,\n\t[CodeLanguageType.CPP]: null,\n\t[CodeLanguageType.Unknown]: null,\n}\n\nexport const dependenciesProcessors: Record<\n\tCodeLanguageType,\n\t(captures: Parser.QueryCapture[]) => ISnippetMeta[] | null\n> = {\n\t[CodeLanguageType.Go]: dependenciesCapturesProcessForGo,\n\t[CodeLanguageType.Python]: dependenciesCapturesProcessForPython,\n\t[CodeLanguageType.TypeScript]: dependenciesCapturesProcessForTypeScript,\n\t[CodeLanguageType.JavaScript]: dependenciesCapturesProcessForJavaScript,\n\t[CodeLanguageType.Java]: dependenciesCapturesProcessForJava,\n\t[CodeLanguageType.JSX]: dependenciesCapturesProcessForJSX,\n\t[CodeLanguageType.TSX]: dependenciesCapturesProcessForTSX,\n\t[CodeLanguageType.Swift]: (captures: Parser.QueryCapture[]) => [],\n\t[CodeLanguageType.CSS]: (captures: Parser.QueryCapture[]) => [],\n\t[CodeLanguageType.HTML]: (captures: Parser.QueryCapture[]) => [],\n\t[CodeLanguageType.Kotlin]: (captures: Parser.QueryCapture[]) => [],\n\t[CodeLanguageType.PHP]: (captures: Parser.QueryCapture[]) => [],\n\t[CodeLanguageType.Rust]: (captures: Parser.QueryCapture[]) => [],\n\t[CodeLanguageType.C]: (captures: Parser.QueryCapture[]) => [],\n\t[CodeLanguageType.CPP]: (captures: Parser.QueryCapture[]) => [],\n\t[CodeLanguageType.Unknown]: (captures: Parser.QueryCapture[]) => [],\n}\n", "import { CodeLanguageType } from \"../types\"\n\nconst lineCommentSymbols = {\n\t[CodeLanguageType.Go]: \"//\",\n\t[CodeLanguageType.Python]: \"#\",\n\t[CodeLanguageType.TypeScript]: \"//\",\n\t[CodeLanguageType.JavaScript]: \"//\",\n\t[CodeLanguageType.Java]: \"//\",\n\t[CodeLanguageType.Unknown]: \"\",\n}\n\nexport function formatCodeWithLanguageWithLineComment(text: string, language: CodeLanguageType): string {\n\tif (language === CodeLanguageType.Unknown) {\n\t\treturn text\n\t}\n\tconst lineCommentSymbol = lineCommentSymbols[language]\n\tif (!lineCommentSymbol) {\n\t\treturn text\n\t}\n\n\tconst lines = text.split(\"\\n\")\n\tconst formattedLines = lines.map((line) => {\n\t\treturn `${lineCommentSymbol} ${line}`\n\t})\n\treturn formattedLines.join(\"\\n\")\n}\n", "import * as fs from \"fs/promises\"\nimport * as path from \"path\"\nimport type { Dirent } from \"fs\"\n\nexport interface TreeViewOptions {\n\tshowDotDirs?: boolean\n\tallowOtherExtensions?: boolean\n}\n\n// \u7F13\u5B58.gitignore\u89C4\u5219\nconst gitignoreCache = new Map<\n\tstring,\n\t{ mtimeMs: number; rules: string[]; filter: (p: string, isDir: boolean) => boolean }\n>()\n\nasync function getGitignoreFilter(dirPathRoot: string): Promise<(p: string, isDir: boolean) => boolean> {\n\tconst gitignorePath = path.join(dirPathRoot, \".gitignore\")\n\ttry {\n\t\tconst stat = await fs.stat(gitignorePath)\n\t\tconst cached = gitignoreCache.get(gitignorePath)\n\t\tif (cached && cached.mtimeMs === stat.mtimeMs) {\n\t\t\treturn cached.filter\n\t\t}\n\t\tconst content = await fs.readFile(gitignorePath, \"utf8\")\n\t\tconst rules = content\n\t\t\t.split(/\\r?\\n/)\n\t\t\t.map((l) => l.trim())\n\t\t\t.filter((l) => l && !l.startsWith(\"#\"))\n\t\t// \u7B80\u5355\u5B9E\u73B0\uFF1A\u53EA\u652F\u6301\u524D\u7F00\u5339\u914D\u548C\u76EE\u5F55\u5339\u914D\n\t\tconst matchers = rules.map((rule) => {\n\t\t\tif (rule.endsWith(\"/\")) {\n\t\t\t\t// \u76EE\u5F55\n\t\t\t\tconst dirRule = rule.replace(/\\/$/, \"\")\n\t\t\t\treturn (p: string, isDir: boolean) => isDir && p.includes(dirRule)\n\t\t\t} else {\n\t\t\t\treturn (p: string, isDir: boolean) => p.includes(rule)\n\t\t\t}\n\t\t})\n\t\tconst filter = (p: string, isDir: boolean) => !matchers.some((fn) => fn(p, isDir))\n\t\tgitignoreCache.set(gitignorePath, { mtimeMs: stat.mtimeMs, rules, filter })\n\t\treturn filter\n\t} catch {\n\t\t// \u6CA1\u6709.gitignore\n\t\treturn () => true\n\t}\n}\n\n/**\n * \u53D7\u9650tree\u547D\u4EE4\u5B9E\u73B0\n * @param dirPathRoot \u6839\u76EE\u5F55\n * @param filePaths \u9700\u8981\u5C55\u5F00\u7684\u6587\u4EF6\u8DEF\u5F84\uFF08\u7EDD\u5BF9\u6216\u76F8\u5BF9dirPathRoot\uFF09\n * @param limitNum \u6BCF\u5C42\u6700\u591A\u663E\u793A\u591A\u5C11\u9879\n * @param maxDepth \u6700\u5927\u9012\u5F52\u6DF1\u5EA6\n * @param options \u989D\u5916\u9009\u9879\n * @returns tree\u7ED3\u6784\u5B57\u7B26\u4E32\n */\nexport async function treeView(\n\tdirPathRoot: string,\n\tfilePaths: string[],\n\tlimitNum: number,\n\tmaxDepth: number,\n\toptions: TreeViewOptions = {},\n): Promise {\n\tconst { showDotDirs = false, allowOtherExtensions = false } = options\n\t// 1. \u5F52\u4E00\u5316filePaths\u4E3A\u7EDD\u5BF9\u8DEF\u5F84\n\tconst absRoot = path.resolve(dirPathRoot)\n\tconst normFilePaths = filePaths.map((fp) => path.resolve(dirPathRoot, fp))\n\t// 2. \u9700\u8981\u91CD\u70B9\u5C55\u5F00\u7684\u6240\u6709\u76EE\u5F55\u96C6\u5408\uFF08filePaths\u7684\u6240\u6709\u7236\u76EE\u5F55\uFF09\n\tconst expandDirs = new Set()\n\t// 3. \u9700\u8981\u663E\u793A\u6240\u6709\u540C\u7EA7\u6587\u4EF6/\u76EE\u5F55\u7684\u76EE\u5F55\u96C6\u5408\uFF08filePaths\u7684\u7236\u76EE\u5F55\uFF09\n\tconst siblingDirs = new Set()\n\t// 4. \u8BB0\u5F55\u6BCF\u4E2AfilePath\u7684\u540E\u7F00\u540D\u96C6\u5408\n\tconst fileExts = new Map>()\n\tfor (const fileAbs of normFilePaths) {\n\t\tlet cur = path.dirname(fileAbs)\n\t\tsiblingDirs.add(cur) // filePaths\u7684\u7236\u76EE\u5F55\n\t\tif (!fileExts.has(cur)) fileExts.set(cur, new Set())\n\t\tfileExts.get(cur)!.add(path.extname(fileAbs))\n\t\twhile (cur.startsWith(absRoot)) {\n\t\t\texpandDirs.add(cur)\n\t\t\tif (cur === absRoot) break\n\t\t\tcur = path.dirname(cur)\n\t\t}\n\t}\n\n\t// \u83B7\u53D6.gitignore\u8FC7\u6EE4\u5668\n\tconst gitignoreFilter = await getGitignoreFilter(absRoot)\n\n\t// \u9012\u5F52\u904D\u5386\uFF0C\u751F\u6210tree\u98CE\u683C\u7B26\u53F7\n\tasync function walk(dir: string, depth: number, prefix: string, isLast: boolean): Promise {\n\t\tif (depth > maxDepth) {\n\t\t\tconst entries = (await fs.readdir(dir, { withFileTypes: true })) as Dirent[]\n\t\t\treturn [prefix + ellipsisLine(entries.length, \"(\u8D85\u51FA\u6DF1\u5EA6)\")]\n\t\t}\n\t\tlet entries: Dirent[] = []\n\t\ttry {\n\t\t\tentries = (await fs.readdir(dir, { withFileTypes: true })) as Dirent[]\n\t\t} catch {\n\t\t\treturn [prefix + \"[\u65E0\u6CD5\u8BFB\u53D6\u76EE\u5F55]\"]\n\t\t}\n\t\t// \u8FC7\u6EE4.\u5F00\u5934\u7684\u76EE\u5F55\uFF08\u9664\u975EfilePaths\u7684\u67D0\u4E2A\u6587\u4EF6\u5728\u8BE5\u76EE\u5F55\u4E0B\uFF09\n\t\tconst isSiblingDir = siblingDirs.has(dir)\n\t\tif (!showDotDirs && !isSiblingDir) {\n\t\t\tentries = entries.filter((e) => !e.name.startsWith(\".\"))\n\t\t}\n\t\t// \u8FC7\u6EE4.gitignore\n\t\tentries = entries.filter((e) =>\n\t\t\tgitignoreFilter(path.relative(absRoot, path.join(dir, e.name)), e.isDirectory()),\n\t\t)\n\t\t// \u6392\u5E8F\uFF1A\n\t\t// 1. \u9700\u8981\u5C55\u5F00\u7684\u76EE\u5F55\uFF08expandDirs\uFF09\u4F18\u5148\u6587\u4EF6\uFF0C\u518D\u76EE\u5F55\uFF0C\u518D\u540D\u79F0\n\t\t// 2. \u5176\u5B83\u76EE\u5F55\u4F18\u5148\u76EE\u5F55\uFF0C\u518D\u6587\u4EF6\uFF0C\u518D\u540D\u79F0\n\t\tentries.sort((a, b) => {\n\t\t\tconst aPath = path.join(dir, a.name)\n\t\t\tconst bPath = path.join(dir, b.name)\n\t\t\tconst aExpand = expandDirs.has(dir)\n\t\t\tconst bExpand = expandDirs.has(dir)\n\t\t\tif (aExpand && bExpand) {\n\t\t\t\t// \u9700\u8981\u5C55\u5F00\u7684\u76EE\u5F55\uFF0C\u6587\u4EF6\u4F18\u5148\n\t\t\t\tif (a.isDirectory() !== b.isDirectory()) return Number(a.isDirectory()) - Number(b.isDirectory())\n\t\t\t\treturn a.name.localeCompare(b.name)\n\t\t\t} else {\n\t\t\t\t// \u5176\u5B83\u76EE\u5F55\uFF0C\u76EE\u5F55\u4F18\u5148\n\t\t\t\tif (a.isDirectory() !== b.isDirectory()) return Number(b.isDirectory()) - Number(a.isDirectory())\n\t\t\t\treturn a.name.localeCompare(b.name)\n\t\t\t}\n\t\t})\n\t\tconst lines: string[] = []\n\t\tlet shown = 0\n\t\tlet omitted = 0\n\t\t// \u5224\u65AD\u5F53\u524D\u76EE\u5F55\u662F\u5426\u4E3AfilePaths\u7684\u7236\u76EE\u5F55\uFF08\u9700\u8981\u663E\u793A\u6240\u6709\u540C\u7EA7\u6587\u4EF6/\u76EE\u5F55\uFF09\n\t\tconst showAllSiblings = isSiblingDir\n\t\t// \u83B7\u53D6\u5F53\u524D\u76EE\u5F55\u9700\u8981\u7684\u540E\u7F00\u540D\u96C6\u5408\uFF08\u5982\u679C\u6709\uFF09\n\t\tconst requiredExts = fileExts.get(dir)\n\n\t\tif (showAllSiblings) {\n\t\t\t// \u5148\u5206\u7EC4\u6587\u4EF6\u548C\u76EE\u5F55\uFF0C\u4F18\u5148\u663E\u793A\u76EE\u6807\u6587\u4EF6\n\t\t\tconst siblingFiles = entries.filter(\n\t\t\t\t(e) =>\n\t\t\t\t\t!e.isDirectory() &&\n\t\t\t\t\t(allowOtherExtensions || !requiredExts || requiredExts.has(path.extname(e.name))),\n\t\t\t)\n\t\t\tconst siblingDirs = entries.filter((e) => e.isDirectory())\n\t\t\t// \u6587\u4EF6\u4F18\u5148\n\t\t\tfor (let i = 0; i < siblingFiles.length && shown < limitNum; i++, shown++) {\n\t\t\t\tconst entry = siblingFiles[i]\n\t\t\t\tconst isEntryLast =\n\t\t\t\t\tshown === limitNum - 1 ||\n\t\t\t\t\t(i === siblingFiles.length - 1 && shown + siblingDirs.length >= limitNum) ||\n\t\t\t\t\tshown === siblingFiles.length + siblingDirs.length - 1\n\t\t\t\tconst branch = isEntryLast ? \"\u2514\u2500\u2500 \" : \"\u251C\u2500\u2500 \"\n\t\t\t\tlines.push(prefix + branch + entry.name)\n\t\t\t}\n\t\t\t// \u76EE\u5F55\n\t\t\tfor (let i = 0; i < siblingDirs.length && shown < limitNum; i++, shown++) {\n\t\t\t\tconst entry = siblingDirs[i]\n\t\t\t\tconst entryPath = path.join(dir, entry.name)\n\t\t\t\tconst isEntryLast =\n\t\t\t\t\tshown === limitNum - 1 ||\n\t\t\t\t\ti === siblingDirs.length - 1 ||\n\t\t\t\t\tshown === siblingFiles.length + siblingDirs.length - 1\n\t\t\t\tconst branch = isEntryLast ? \"\u2514\u2500\u2500 \" : \"\u251C\u2500\u2500 \"\n\t\t\t\tconst nextPrefix = prefix + (isEntryLast ? \" \" : \"\u2502 \")\n\t\t\t\tif (expandDirs.has(entryPath)) {\n\t\t\t\t\tlines.push(prefix + branch + entry.name + \"/\")\n\t\t\t\t\tconst sub = await walk(entryPath, depth + 1, nextPrefix, isEntryLast)\n\t\t\t\t\tlines.push(...sub)\n\t\t\t\t} else {\n\t\t\t\t\tconst subEntries = (await fs.readdir(entryPath, { withFileTypes: true })) as Dirent[]\n\t\t\t\t\t// \u8FC7\u6EE4.gitignore\n\t\t\t\t\tconst filteredSubEntries = subEntries.filter((e) =>\n\t\t\t\t\t\tgitignoreFilter(path.relative(absRoot, path.join(entryPath, e.name)), e.isDirectory()),\n\t\t\t\t\t)\n\t\t\t\t\tlines.push(prefix + branch + entry.name + `/ ...(${filteredSubEntries.length}\u9879)`)\n\t\t\t\t}\n\t\t\t}\n\t\t\tconst total = siblingFiles.length + siblingDirs.length\n\t\t\tif (shown < total) {\n\t\t\t\tlines.push(prefix + ellipsisLine(total - shown))\n\t\t\t}\n\t\t\treturn lines\n\t\t}\n\t\tfor (let i = 0; i < entries.length; i++) {\n\t\t\tconst entry = entries[i]\n\t\t\tconst entryPath = path.join(dir, entry.name)\n\t\t\tconst isDir = entry.isDirectory()\n\t\t\tconst isEntryLast = shown === limitNum - 1 || i === entries.length - 1 || shown === entries.length - 1\n\t\t\tif (shown >= limitNum) {\n\t\t\t\tomitted = entries.length - shown\n\t\t\t\tlines.push(prefix + ellipsisLine(omitted))\n\t\t\t\tbreak\n\t\t\t}\n\t\t\tconst branch = isEntryLast ? \"\u2514\u2500\u2500 \" : \"\u251C\u2500\u2500 \"\n\t\t\tconst nextPrefix = prefix + (isEntryLast ? \" \" : \"\u2502 \")\n\t\t\tif (isDir) {\n\t\t\t\tif (expandDirs.has(entryPath)) {\n\t\t\t\t\tlines.push(prefix + branch + entry.name + \"/\")\n\t\t\t\t\tconst sub = await walk(entryPath, depth + 1, nextPrefix, isEntryLast)\n\t\t\t\t\tlines.push(...sub)\n\t\t\t\t} else {\n\t\t\t\t\tconst subEntries = (await fs.readdir(entryPath, { withFileTypes: true })) as Dirent[]\n\t\t\t\t\t// \u8FC7\u6EE4.gitignore\n\t\t\t\t\tconst filteredSubEntries = subEntries.filter((e) =>\n\t\t\t\t\t\tgitignoreFilter(path.relative(absRoot, path.join(entryPath, e.name)), e.isDirectory()),\n\t\t\t\t\t)\n\t\t\t\t\tlines.push(prefix + branch + entry.name + `/ ...(${filteredSubEntries.length}\u9879)`)\n\t\t\t\t}\n\t\t\t} else {\n\t\t\t\t// \u5982\u679C\u662FfilePaths\u7684\u7236\u76EE\u5F55\uFF0C\u663E\u793A\u6240\u6709\u540C\u7EA7\u6587\u4EF6\uFF0C\u5426\u5219\u53EA\u663E\u793AfilePaths\u672C\u8EAB\n\t\t\t\tif (showAllSiblings) {\n\t\t\t\t\t// \u53EA\u663E\u793A\u76F8\u540C\u540E\u7F00\uFF0C\u9664\u975EallowOtherExtensions\u4E3Atrue\n\t\t\t\t\tif (allowOtherExtensions || !requiredExts || requiredExts.has(path.extname(entry.name))) {\n\t\t\t\t\t\tlines.push(prefix + branch + entry.name)\n\t\t\t\t\t}\n\t\t\t\t} else if (normFilePaths.includes(entryPath)) {\n\t\t\t\t\tlines.push(prefix + branch + entry.name)\n\t\t\t\t}\n\t\t\t}\n\t\t\tshown++\n\t\t}\n\t\treturn lines\n\t}\n\n\tfunction ellipsisLine(count: number, note?: string) {\n\t\treturn `...(${count}\u9879${note ? note : \"\"})`\n\t}\n\n\t// \u6839\u76EE\u5F55\u540D\n\tconst rootName = path.basename(absRoot) || absRoot\n\tconst lines = await walk(absRoot, 1, \"\", true)\n\treturn [rootName + \"/\", ...lines].join(\"\\n\")\n}\n", "#!/usr/bin/env node\nconst { program } = require(\"commander\") \n\nimport { CodeSnippets } from \"../autocompletion/v2/CodeSnippets\"\nimport { CodeLanguageType, ICodeFiles, SnippetType } from \"../autocompletion/v2/types\";\nimport { CodeContext } from \"../autocompletion/v2/CodeContext\"\n\nconst codeContext = new CodeContext()\n\nfunction getExtension(filePath: string): string {\n return filePath.substring(filePath.lastIndexOf(\".\") + 1, filePath.length) \n}\nasync function index(codeFiles: ICodeFiles, maxSnippetLines?: number): Promise {\n const maxLines = maxSnippetLines || 100 \n const allSnippets = new CodeSnippets() \n\n const indexPromises = codeFiles.files.map(async (file) => {\n try {\n if (file.language === undefined || !Object.values(CodeLanguageType).includes(file.language as CodeLanguageType)) {\n console.log(`Unsupported language: ${file.language}`)\n return new CodeSnippets()\n }\n // \u8BFB\u53D6\u6587\u4EF6\u5185\u5BB9\n const content = file.content\n if (!content) {\n console.log(`Content is empty for file: ${file.filePath}`)\n return new CodeSnippets()\n }\n file.fileExtension = getExtension(file.filePath) \n\n // \u5BF9\u6BCF\u4E2A\u6587\u4EF6\u8FDB\u884C chunk\n const fileSnippets = await codeContext.chunk(content, {\n file: file,\n maxSnippetLines: maxLines,\n snippetTypes: [\n SnippetType.FunctionOrMethod,\n SnippetType.ClassOrInterfaceOrStructOrEnum,\n SnippetType.VariableOrConstant,\n SnippetType.ImportOrInclude,\n ]\n })\n return fileSnippets\n } catch (error) {\n return new CodeSnippets()\n }\n })\n\n // \u7B49\u5F85\u6240\u6709\u6587\u4EF6\u5904\u7406\u5B8C\u6210\n const fileSnippetsArray = await Promise.all(indexPromises)\n\n // \u5408\u5E76\u6240\u6709\u7247\u6BB5\n for (const fileSnippets of fileSnippetsArray) {\n await allSnippets.merge(fileSnippets)\n }\n\n return allSnippets\n}\n\nprogram\n .command(\"index \") \n .option(\"-m \", \"--maxlines \", \"Maximum number of lines for each snippet\")\n .description(\"Index the given files.\") \n .action(async (input: string, cmd: any) => {\n const codeFiles: ICodeFiles = { files: JSON.parse(input) }\n\n const indexResult = await index(\n codeFiles,\n cmd.maxlines ? parseInt(cmd.maxlines, 10) : undefined\n )\n \n console.log(`${JSON.stringify(indexResult.getSnippets(), null, 2)}`)\n })\n\nprogram.parse(process.argv) "], + "mappings": ";;;;;;;;;;;;;;;;;;;;;;;;;;;;;AAAA;AAAA;AAAA,QAAI,SAAO,WAAS,SAAO,SAAO,CAAC;AAAnC,QAAqC,aAAW,WAAU;AAAC,UAAI,aAAY,WAAS,YAAU,OAAO,SAAO,EAAC,eAAc,OAAO,SAAS,cAAa,IAAE;AAAA,MAAK,MAAM,OAAM;AAAA,QAAC,cAAa;AAAC,eAAK,WAAW;AAAA,QAAC;AAAA,QAAC,aAAY;AAAC,gBAAM,IAAI,MAAM,mDAAmD;AAAA,QAAC;AAAA,QAAC,OAAO,KAAK,eAAc;AAAC,iBAAO,gBAAc,SAAO,OAAO,OAAO,CAAC,GAAE,QAAO,aAAa,GAAE,cAAY,IAAI,QAAS,wBAAoB;AAAC,gBAAI,kBAAgB,OAAO,OAAO,CAAC,GAAE,MAAM,GAAE,aAAW,CAAC,GAAE,cAAY,kBAAiB,QAAM,CAAC,GAAE,MAAI;AAAC,oBAAM;AAAA,YAAC,GA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BAAgB,EAAE,SAAS,KAAK,QAA4B,GAAG;AAC7G,gBAAQ,IAAI,yBAAyB,KAAK,QAAQ,EAAE;AACpD,eAAO,IAAI,aAAa;AAAA,MAC5B;AAEA,YAAM,UAAU,KAAK;AACrB,UAAI,CAAC,SAAS;AACV,gBAAQ,IAAI,8BAA8B,KAAK,QAAQ,EAAE;AACzD,eAAO,IAAI,aAAa;AAAA,MAC5B;AACA,WAAK,gBAAgB,aAAa,KAAK,QAAQ;AAG/C,YAAM,eAAe,MAAM,YAAY,MAAM,SAAS;AAAA,QAClD;AAAA,QACA,iBAAiB;AAAA,QACjB,cAAc;AAAA;AAAA;AAAA;AAAA;AAAA,QAKd;AAAA,MACJ,CAAC;AACD,aAAO;AAAA,IACX,SAAS,OAAO;AACZ,aAAO,IAAI,aAAa;AAAA,IAC5B;AAAA,EACJ,CAAC;AAGD,QAAM,oBAAoB,MAAM,QAAQ,IAAI,aAAa;AAGzD,aAAW,gBAAgB,mBAAmB;AAC1C,UAAM,YAAY,MAAM,YAAY;AAAA,EACxC;AAEA,SAAO;AACX;AAEA,QACK,QAAQ,gBAAgB,EACxB,OAAO,eAAe,uBAAuB,0CAA0C,EACvF,YAAY,wBAAwB,EACpC,OAAO,OAAO,OAAe,QAAa;AACvC,QAAM,YAAwB,EAAE,OAAO,KAAK,MAAM,KAAK,EAAE;AAEzD,QAAM,cAAc,MAAM;AAAA,IACtB;AAAA,IACA,IAAI,WAAW,SAAS,IAAI,UAAU,EAAE,IAAI;AAAA,EAChD;AAEA,UAAQ,IAAI,GAAG,KAAK,UAAU,YAAY,YAAY,GAAG,MAAM,CAAC,CAAC,EAAE;AACvE,CAAC;AAEL,QAAQ,MAAM,QAAQ,IAAI;", + "names": ["e", "t", "_", "s", "r", "a", "o", "n", "l", "exports", "exports", "name", "exports", "cmd", "args", "exports", "flags", "name", "str", "exports", "i", "exports", "path", "fs", "process", "name", "args", "err", "flags", "i", "index", "option", "exports", "name", "flags", "name", "i", "CodeLanguageType", "path", "crypto", "Parser", "i", "i", "crypto", "name", "path", "name", "name", "i", "buildSummaryFromSnippets", "formatOutlineText", "name", "buildSummaryFromSnippets", "formatOutlineText", "i", "name", "i", "methodText", "scope", "isInsideFunction", "rangeText", "snippetHash", "field", "variableType", "definitionText", "name", "buildSummaryFromSnippets", "formatOutlineText", "c", "name", "buildSummaryFromSnippets", "formatOutlineText", "out", "name", "buildSummaryFromSnippets", "formatOutlineText", "out", "name", "node", "i", "buildSummaryFromSnippets", "formatOutlineText", "i", "name", "index", "node", "args", "buildSummaryFromSnippets", "formatOutlineText", "func", "getNodeText", "findChildByType", "i", "name", "buildSummaryFromSnippets", "formatOutlineText", "crypto", "name", "buildSummaryFromSnippets", "formatOutlineText", "name", "removeParentheses", "i", "buildSummaryFromSnippets", "formatOutlineText", "name", "removeParentheses", "i", "param", "parts", "buildSummaryFromSnippets", "formatOutlineText", "func", "findNameCaptureForContainer", "i", "buildSummaryFromSnippets", "formatOutlineText", "findNameCaptureForContainer", "extractParametersFromNode", "extractEnumeratorsFromEnumNode", "i", "extractParameterName", "getNameCaptureNameForContainer", "buildSummaryFromSnippets", "formatOutlineText", "formatOutlineText", "buildSummaryFromSnippets", "go_default", "typescript_default", "javascript_default", "java_default", "python_default", "jsx_default", "tsx_default", "go_default", "python_default", "typescript_default", "javascript_default", "java_default", "jsx_default", "tsx_default", "fs", "path", "stat", "entries", "lines", "siblingDirs", "i"] +} diff --git a/backend/pkg/cli/tools/dist/tiktoken_bg.wasm b/backend/pkg/cli/tools/dist/tiktoken_bg.wasm new file mode 100644 index 0000000..8b49519 Binary files /dev/null and b/backend/pkg/cli/tools/dist/tiktoken_bg.wasm differ diff --git a/backend/pkg/cli/tools/dist/tree-sitter-bash.wasm b/backend/pkg/cli/tools/dist/tree-sitter-bash.wasm new file mode 100755 index 0000000..214d0a7 Binary files /dev/null and b/backend/pkg/cli/tools/dist/tree-sitter-bash.wasm differ diff --git a/backend/pkg/cli/tools/dist/tree-sitter-c.wasm b/backend/pkg/cli/tools/dist/tree-sitter-c.wasm new file mode 100755 index 0000000..ceda238 Binary files /dev/null and b/backend/pkg/cli/tools/dist/tree-sitter-c.wasm differ diff --git a/backend/pkg/cli/tools/dist/tree-sitter-c_sharp.wasm b/backend/pkg/cli/tools/dist/tree-sitter-c_sharp.wasm new file mode 100755 index 0000000..5c11b4f Binary files /dev/null and b/backend/pkg/cli/tools/dist/tree-sitter-c_sharp.wasm differ diff --git a/backend/pkg/cli/tools/dist/tree-sitter-cpp.wasm b/backend/pkg/cli/tools/dist/tree-sitter-cpp.wasm new file mode 100755 index 0000000..2d453db Binary files /dev/null and b/backend/pkg/cli/tools/dist/tree-sitter-cpp.wasm differ diff --git a/backend/pkg/cli/tools/dist/tree-sitter-css.wasm b/backend/pkg/cli/tools/dist/tree-sitter-css.wasm new file mode 100755 index 0000000..24f8a26 Binary files /dev/null and b/backend/pkg/cli/tools/dist/tree-sitter-css.wasm differ diff --git a/backend/pkg/cli/tools/dist/tree-sitter-elisp.wasm b/backend/pkg/cli/tools/dist/tree-sitter-elisp.wasm new file mode 100755 index 0000000..98a7243 Binary files /dev/null and b/backend/pkg/cli/tools/dist/tree-sitter-elisp.wasm differ diff --git a/backend/pkg/cli/tools/dist/tree-sitter-elixir.wasm b/backend/pkg/cli/tools/dist/tree-sitter-elixir.wasm new file mode 100755 index 0000000..e4537eb Binary files /dev/null and b/backend/pkg/cli/tools/dist/tree-sitter-elixir.wasm differ diff --git a/backend/pkg/cli/tools/dist/tree-sitter-elm.wasm b/backend/pkg/cli/tools/dist/tree-sitter-elm.wasm new file mode 100755 index 0000000..97c6a30 Binary files /dev/null and b/backend/pkg/cli/tools/dist/tree-sitter-elm.wasm differ diff --git a/backend/pkg/cli/tools/dist/tree-sitter-embedded_template.wasm b/backend/pkg/cli/tools/dist/tree-sitter-embedded_template.wasm new file mode 100755 index 0000000..8b61793 Binary files /dev/null and b/backend/pkg/cli/tools/dist/tree-sitter-embedded_template.wasm differ diff --git a/backend/pkg/cli/tools/dist/tree-sitter-go.wasm b/backend/pkg/cli/tools/dist/tree-sitter-go.wasm new file mode 100755 index 0000000..a20aba8 Binary files /dev/null and b/backend/pkg/cli/tools/dist/tree-sitter-go.wasm differ diff --git a/backend/pkg/cli/tools/dist/tree-sitter-html.wasm b/backend/pkg/cli/tools/dist/tree-sitter-html.wasm new file mode 100755 index 0000000..50a0092 Binary files /dev/null and b/backend/pkg/cli/tools/dist/tree-sitter-html.wasm differ diff --git a/backend/pkg/cli/tools/dist/tree-sitter-java.wasm b/backend/pkg/cli/tools/dist/tree-sitter-java.wasm new file mode 100755 index 0000000..45022a9 Binary files /dev/null and b/backend/pkg/cli/tools/dist/tree-sitter-java.wasm differ diff --git a/backend/pkg/cli/tools/dist/tree-sitter-javascript.wasm b/backend/pkg/cli/tools/dist/tree-sitter-javascript.wasm new file mode 100755 index 0000000..edaeba9 Binary files /dev/null and b/backend/pkg/cli/tools/dist/tree-sitter-javascript.wasm differ diff --git a/backend/pkg/cli/tools/dist/tree-sitter-json.wasm b/backend/pkg/cli/tools/dist/tree-sitter-json.wasm new file mode 100755 index 0000000..7abe88c Binary files /dev/null and b/backend/pkg/cli/tools/dist/tree-sitter-json.wasm differ diff --git a/backend/pkg/cli/tools/dist/tree-sitter-kotlin.wasm b/backend/pkg/cli/tools/dist/tree-sitter-kotlin.wasm new file mode 100755 index 0000000..b0e4db6 Binary files /dev/null and b/backend/pkg/cli/tools/dist/tree-sitter-kotlin.wasm differ diff --git a/backend/pkg/cli/tools/dist/tree-sitter-lua.wasm b/backend/pkg/cli/tools/dist/tree-sitter-lua.wasm new file mode 100755 index 0000000..6783ea0 Binary files /dev/null and b/backend/pkg/cli/tools/dist/tree-sitter-lua.wasm differ diff --git a/backend/pkg/cli/tools/dist/tree-sitter-objc.wasm b/backend/pkg/cli/tools/dist/tree-sitter-objc.wasm new file mode 100755 index 0000000..8a347a6 Binary files /dev/null and b/backend/pkg/cli/tools/dist/tree-sitter-objc.wasm differ diff --git a/backend/pkg/cli/tools/dist/tree-sitter-ocaml.wasm b/backend/pkg/cli/tools/dist/tree-sitter-ocaml.wasm new file mode 100755 index 0000000..6105e8e Binary files /dev/null and b/backend/pkg/cli/tools/dist/tree-sitter-ocaml.wasm differ diff --git a/backend/pkg/cli/tools/dist/tree-sitter-php.wasm b/backend/pkg/cli/tools/dist/tree-sitter-php.wasm new file mode 100755 index 0000000..505fe86 Binary files /dev/null and b/backend/pkg/cli/tools/dist/tree-sitter-php.wasm differ diff --git a/backend/pkg/cli/tools/dist/tree-sitter-python.wasm b/backend/pkg/cli/tools/dist/tree-sitter-python.wasm new file mode 100755 index 0000000..1423763 Binary files /dev/null and b/backend/pkg/cli/tools/dist/tree-sitter-python.wasm differ diff --git a/backend/pkg/cli/tools/dist/tree-sitter-ql.wasm b/backend/pkg/cli/tools/dist/tree-sitter-ql.wasm new file mode 100755 index 0000000..ffe8224 Binary files /dev/null and b/backend/pkg/cli/tools/dist/tree-sitter-ql.wasm differ diff --git a/backend/pkg/cli/tools/dist/tree-sitter-rescript.wasm b/backend/pkg/cli/tools/dist/tree-sitter-rescript.wasm new file mode 100755 index 0000000..5c17ef7 Binary files /dev/null and b/backend/pkg/cli/tools/dist/tree-sitter-rescript.wasm differ diff --git a/backend/pkg/cli/tools/dist/tree-sitter-ruby.wasm b/backend/pkg/cli/tools/dist/tree-sitter-ruby.wasm new file mode 100755 index 0000000..2713e11 Binary files /dev/null and b/backend/pkg/cli/tools/dist/tree-sitter-ruby.wasm differ diff --git a/backend/pkg/cli/tools/dist/tree-sitter-rust.wasm b/backend/pkg/cli/tools/dist/tree-sitter-rust.wasm new file mode 100755 index 0000000..5b3b213 Binary files /dev/null and b/backend/pkg/cli/tools/dist/tree-sitter-rust.wasm differ diff --git a/backend/pkg/cli/tools/dist/tree-sitter-scala.wasm b/backend/pkg/cli/tools/dist/tree-sitter-scala.wasm new file mode 100755 index 0000000..e23c24f Binary files /dev/null and b/backend/pkg/cli/tools/dist/tree-sitter-scala.wasm differ diff --git a/backend/pkg/cli/tools/dist/tree-sitter-solidity.wasm b/backend/pkg/cli/tools/dist/tree-sitter-solidity.wasm new file mode 100755 index 0000000..42c1ceb Binary files /dev/null and b/backend/pkg/cli/tools/dist/tree-sitter-solidity.wasm differ diff --git a/backend/pkg/cli/tools/dist/tree-sitter-swift.wasm b/backend/pkg/cli/tools/dist/tree-sitter-swift.wasm new file mode 100755 index 0000000..87282f2 Binary files /dev/null and b/backend/pkg/cli/tools/dist/tree-sitter-swift.wasm differ diff --git a/backend/pkg/cli/tools/dist/tree-sitter-systemrdl.wasm b/backend/pkg/cli/tools/dist/tree-sitter-systemrdl.wasm new file mode 100755 index 0000000..a90cf49 Binary files /dev/null and b/backend/pkg/cli/tools/dist/tree-sitter-systemrdl.wasm differ diff --git a/backend/pkg/cli/tools/dist/tree-sitter-tlaplus.wasm b/backend/pkg/cli/tools/dist/tree-sitter-tlaplus.wasm new file mode 100755 index 0000000..71d9bc3 Binary files /dev/null and b/backend/pkg/cli/tools/dist/tree-sitter-tlaplus.wasm differ diff --git a/backend/pkg/cli/tools/dist/tree-sitter-toml.wasm b/backend/pkg/cli/tools/dist/tree-sitter-toml.wasm new file mode 100755 index 0000000..f5d6e44 Binary files /dev/null and b/backend/pkg/cli/tools/dist/tree-sitter-toml.wasm differ diff --git a/backend/pkg/cli/tools/dist/tree-sitter-tsx.wasm b/backend/pkg/cli/tools/dist/tree-sitter-tsx.wasm new file mode 100755 index 0000000..1e11feb Binary files /dev/null and b/backend/pkg/cli/tools/dist/tree-sitter-tsx.wasm differ diff --git a/backend/pkg/cli/tools/dist/tree-sitter-typescript.wasm b/backend/pkg/cli/tools/dist/tree-sitter-typescript.wasm new file mode 100755 index 0000000..36c7ae0 Binary files /dev/null and b/backend/pkg/cli/tools/dist/tree-sitter-typescript.wasm differ diff --git a/backend/pkg/cli/tools/dist/tree-sitter-vue.wasm b/backend/pkg/cli/tools/dist/tree-sitter-vue.wasm new file mode 100755 index 0000000..32fa568 Binary files /dev/null and b/backend/pkg/cli/tools/dist/tree-sitter-vue.wasm differ diff --git a/backend/pkg/cli/tools/dist/tree-sitter-yaml.wasm b/backend/pkg/cli/tools/dist/tree-sitter-yaml.wasm new file mode 100755 index 0000000..d9a609a Binary files /dev/null and b/backend/pkg/cli/tools/dist/tree-sitter-yaml.wasm differ diff --git a/backend/pkg/cli/tools/dist/tree-sitter-zig.wasm b/backend/pkg/cli/tools/dist/tree-sitter-zig.wasm new file mode 100755 index 0000000..90ea357 Binary files /dev/null and b/backend/pkg/cli/tools/dist/tree-sitter-zig.wasm differ diff --git a/backend/pkg/cli/tools/dist/tree-sitter.wasm b/backend/pkg/cli/tools/dist/tree-sitter.wasm new file mode 100755 index 0000000..0ac880b Binary files /dev/null and b/backend/pkg/cli/tools/dist/tree-sitter.wasm differ