@aroman22/codegraph-vba 1.5.2 → 1.6.1
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/README.md +11 -11
- package/dist/bin/codegraph.d.ts +1 -1
- package/dist/bin/command-supervision.d.ts +38 -1
- package/dist/db/index.d.ts +84 -5
- package/dist/db/migrations.d.ts +1 -1
- package/dist/db/queries.d.ts +116 -4
- package/dist/db/wal-valve.d.ts +106 -0
- package/dist/directory.d.ts +9 -5
- package/dist/extraction/cfml-extractor.d.ts +107 -0
- package/dist/extraction/grammars.d.ts +25 -1
- package/dist/extraction/index.d.ts +47 -2
- package/dist/extraction/languages/arkts.d.ts +3 -0
- package/dist/extraction/languages/c-cpp.d.ts +98 -0
- package/dist/extraction/languages/cfquery.d.ts +12 -0
- package/dist/extraction/languages/cfscript.d.ts +3 -0
- package/dist/extraction/languages/cobol.d.ts +33 -0
- package/dist/extraction/languages/erlang.d.ts +3 -0
- package/dist/extraction/languages/nix.d.ts +3 -0
- package/dist/extraction/languages/solidity.d.ts +3 -0
- package/dist/extraction/languages/terraform.d.ts +3 -0
- package/dist/extraction/languages/vbnet.d.ts +11 -0
- package/dist/extraction/mybatis-extractor.d.ts +30 -10
- package/dist/extraction/parse-pool.d.ts +28 -1
- package/dist/extraction/tree-sitter-types.d.ts +20 -1
- package/dist/extraction/tree-sitter.d.ts +60 -1
- package/dist/extraction/vba/call-sweep.d.ts +3 -0
- package/dist/extraction/vba/calls.d.ts +55 -0
- package/dist/extraction/vba/constants.d.ts +42 -0
- package/dist/extraction/vba/context.d.ts +175 -0
- package/dist/extraction/vba/controls.d.ts +24 -0
- package/dist/extraction/vba/declarations.d.ts +3 -0
- package/dist/extraction/vba/dims.d.ts +3 -0
- package/dist/extraction/vba/docmd.d.ts +16 -0
- package/dist/extraction/vba/enums-consts.d.ts +15 -0
- package/dist/extraction/vba/implements.d.ts +3 -0
- package/dist/extraction/vba/procedures.d.ts +3 -0
- package/dist/extraction/vba/sql-wrapper.d.ts +17 -0
- package/dist/extraction/vba/tempvars.d.ts +10 -0
- package/dist/extraction/vba/text-utils.d.ts +73 -0
- package/dist/extraction/vba-extractor.d.ts +3 -951
- package/dist/extraction/vba-preprocess.d.ts +1 -1
- package/dist/index.d.ts +81 -1
- package/dist/installer/index.d.ts +42 -0
- package/dist/mcp/daemon.d.ts +35 -3
- package/dist/mcp/early-ppid.d.ts +26 -0
- package/dist/mcp/liveness-watchdog.d.ts +18 -1
- package/dist/mcp/query-pool.d.ts +14 -0
- package/dist/mcp/session.d.ts +14 -0
- package/dist/mcp/startup-handshake.d.ts +44 -0
- package/dist/mcp/tools.d.ts +22 -0
- package/dist/project-config.d.ts +44 -0
- package/dist/resolution/c-fnptr-synthesizer.d.ts +2 -1
- package/dist/resolution/callback-synthesizer.d.ts +1 -1
- package/dist/resolution/cooperative-yield.d.ts +32 -0
- package/dist/resolution/frameworks/cics.d.ts +20 -0
- package/dist/resolution/frameworks/terraform.d.ts +38 -0
- package/dist/resolution/goframe-synthesizer.d.ts +2 -1
- package/dist/resolution/import-resolver.d.ts +7 -0
- package/dist/resolution/index.d.ts +64 -2
- package/dist/resolution/name-matcher.d.ts +22 -3
- package/dist/resolution/strip-comments.d.ts +1 -1
- package/dist/resolution/types.d.ts +29 -0
- package/dist/resolution/workspace-packages.d.ts +10 -0
- package/dist/search/identifier-segments.d.ts +60 -0
- package/dist/sync/watcher.d.ts +10 -5
- package/dist/sync/worktree.d.ts +9 -0
- package/dist/types.d.ts +25 -2
- package/dist/upgrade/index.d.ts +34 -2
- package/dist/upgrade/remove-binary.d.ts +87 -0
- package/dist/upgrade/update-check.d.ts +92 -0
- package/npm-shim.js +33 -4
- package/package.json +7 -7
- package/dist/reasoning/config.d.ts +0 -45
- package/dist/reasoning/credentials.d.ts +0 -5
- package/dist/reasoning/login.d.ts +0 -21
- package/dist/reasoning/reasoner.d.ts +0 -43
|
@@ -0,0 +1,107 @@
|
|
|
1
|
+
import { ExtractionResult, Language } from '../types';
|
|
2
|
+
/**
|
|
3
|
+
* CfmlExtractor - Extracts code relationships from CFML source (.cfc/.cfm).
|
|
4
|
+
*
|
|
5
|
+
* tree-sitter-cfml splits CFML into two related grammars: `cfml` (tag-based —
|
|
6
|
+
* `<cfcomponent>`/`<cffunction>`/HTML) and `cfscript` (modern bare-script
|
|
7
|
+
* `component { ... }` syntax). The `cfml` grammar's own injections.scm treats
|
|
8
|
+
* bare-script content as an opaque blob meant to be re-parsed by `cfscript` —
|
|
9
|
+
* that re-parsing only happens at the editor/highlighting layer, not in the
|
|
10
|
+
* raw AST, so this extractor replicates it: a file whose first real token
|
|
11
|
+
* isn't `<` is delegated wholesale to the cfscript grammar (the dominant
|
|
12
|
+
* modern style); otherwise the file is walked tag-by-tag with the cfml
|
|
13
|
+
* grammar, delegating any `<cfscript>` tag bodies the same way.
|
|
14
|
+
*/
|
|
15
|
+
export declare class CfmlExtractor {
|
|
16
|
+
private filePath;
|
|
17
|
+
private source;
|
|
18
|
+
private language;
|
|
19
|
+
private nodes;
|
|
20
|
+
private edges;
|
|
21
|
+
private unresolvedReferences;
|
|
22
|
+
private errors;
|
|
23
|
+
/** `language` is the file's detected language — `'cfml'` for `.cfc`/`.cfm`, `'cfscript'` for `.cfs`. Both dialect-switch internally; this only controls the language tag stamped onto emitted nodes/refs. */
|
|
24
|
+
constructor(filePath: string, source: string, language?: Language);
|
|
25
|
+
extract(): ExtractionResult;
|
|
26
|
+
/** Modern bare-script `.cfc`/`.cfm`: delegate the whole file to the cfscript grammar. */
|
|
27
|
+
private extractBareScript;
|
|
28
|
+
/** Legacy tag-based CFML: walk `<cfcomponent>`/`<cffunction>`, delegating `<cfscript>` bodies. */
|
|
29
|
+
private extractTagBased;
|
|
30
|
+
/** Build the file's own `kind:'file'` node, spanning the whole source. Tag-based files need this explicitly — unlike `extractBareScript` (which delegates the whole file to `TreeSitterExtractor` and inherits its file node), `extractTagBased` walks the tree itself and has no other source of one. */
|
|
31
|
+
private createFileNode;
|
|
32
|
+
/**
|
|
33
|
+
* Walks `program`'s named children with a single forward cursor (not an
|
|
34
|
+
* index loop) — `extractComponent` consumes a variable run of FOLLOWING
|
|
35
|
+
* siblings as the component body (see its doc comment), so this must
|
|
36
|
+
* resume from whatever it last consumed rather than revisiting those same
|
|
37
|
+
* cffunction/cfscript siblings a second time as bogus top-level symbols.
|
|
38
|
+
*/
|
|
39
|
+
private walkProgram;
|
|
40
|
+
/**
|
|
41
|
+
* `<cfcomponent extends="Base" implements="IFoo,IBar">...</cfcomponent>`.
|
|
42
|
+
* The grammar's implicit-end-tag scanner means component body content
|
|
43
|
+
* (cffunction tags, cfscript tags, etc.) appears as the open tag's FOLLOWING
|
|
44
|
+
* siblings in `program`, not nested children — walk forward to the matching
|
|
45
|
+
* cf_component_close_tag.
|
|
46
|
+
*/
|
|
47
|
+
private extractComponent;
|
|
48
|
+
/**
|
|
49
|
+
* `<cffunction name="..." access="..." returntype="...">...</cffunction>`.
|
|
50
|
+
* `parentClassId` decides `method` vs top-level `function`; `containerId` is
|
|
51
|
+
* the `contains`-edge target (the class when inside one, otherwise the file
|
|
52
|
+
* node for a bare top-level cffunction) — kept separate so a top-level
|
|
53
|
+
* function still gets a containment edge without being misclassified as a
|
|
54
|
+
* method of the file. A method's qualifiedName is scoped under
|
|
55
|
+
* `parentClassName` (`TagService::save`, the same `Class::member` shape the
|
|
56
|
+
* generic extractor produces) so type-validated method resolution can match.
|
|
57
|
+
*/
|
|
58
|
+
private extractFunctionTag;
|
|
59
|
+
/**
|
|
60
|
+
* Recursively delegates any `cf_script_tag`/`cf_query_tag` found within
|
|
61
|
+
* `node`'s subtree — e.g. a `<cfscript>`/`<cfquery>` nested inside
|
|
62
|
+
* `<cfif>`/`<cfloop>`/`<cftry>` control-flow tags, which (unlike
|
|
63
|
+
* `<cfcomponent>`'s body — see the implicit-end-tag note on `extractComponent`)
|
|
64
|
+
* ARE normal children, just possibly several levels deep, so a direct-children
|
|
65
|
+
* check misses them. Does not descend into a nested `cf_function_tag` — that
|
|
66
|
+
* has its own scope and is walked separately. `parentClassName` rides along
|
|
67
|
+
* so a `<cfscript>` at component scope classifies its functions as methods
|
|
68
|
+
* scoped under the component.
|
|
69
|
+
*/
|
|
70
|
+
private delegateNestedTags;
|
|
71
|
+
/**
|
|
72
|
+
* Delegate a `<cfscript>...</cfscript>` tag body to the cfscript grammar.
|
|
73
|
+
* With `parentClassName` set (the block sits at component scope), functions
|
|
74
|
+
* declared at the script's top level are the component's methods
|
|
75
|
+
* (`<cfcomponent><cfscript>function configure(){}` — the standard ColdBox
|
|
76
|
+
* ModuleConfig shape): they're re-kinded `function` → `method`, and every
|
|
77
|
+
* merged symbol's qualifiedName is prefixed with the component scope
|
|
78
|
+
* (`configure` → `ModuleConfig::configure`) so type-validated method
|
|
79
|
+
* resolution can match them. Functions nested inside another function
|
|
80
|
+
* (closures) keep kind `function`.
|
|
81
|
+
*/
|
|
82
|
+
private delegateScriptTag;
|
|
83
|
+
/**
|
|
84
|
+
* Delegate a `<cfquery>...</cfquery>` tag's SQL body to the `cfquery` grammar.
|
|
85
|
+
* `#hash#` expressions inside the SQL (e.g. `#getCurrentUser().getId()#` in a
|
|
86
|
+
* WHERE clause) are real CFML calls/references — tree-sitter-cfml's `cfquery`
|
|
87
|
+
* grammar parses them structurally (same `call_expression`/`member_expression`
|
|
88
|
+
* shape as cfscript), so without this delegation they're silently dropped as
|
|
89
|
+
* opaque SQL text. The grammar models no other symbols, so only call/reference
|
|
90
|
+
* extraction is relevant here — unlike `delegateScriptTag`, there are no nodes
|
|
91
|
+
* or contains-edges to merge.
|
|
92
|
+
*/
|
|
93
|
+
private delegateQueryTag;
|
|
94
|
+
/** Read a `cf_attribute`'s value by name from a tag node's direct `cf_attribute`/`cf_tag_attributes` children. */
|
|
95
|
+
private tagAttr;
|
|
96
|
+
private componentNameFromPath;
|
|
97
|
+
}
|
|
98
|
+
/**
|
|
99
|
+
* Sniff whether CFML source is bare-script (`component { ... }`, modern style)
|
|
100
|
+
* vs tag-based (`<cfcomponent>`, `<cfif>`, HTML). Skips a leading UTF-8 BOM
|
|
101
|
+
* (endemic in CFML's Windows-editor history — 17% of ColdBox's files carry
|
|
102
|
+
* one; both grammars parse fine with it once routed correctly), whitespace,
|
|
103
|
+
* and `//`/`/* *\/` comments to find the first real token; tag-based files
|
|
104
|
+
* start with `<`, script-based files don't.
|
|
105
|
+
*/
|
|
106
|
+
export declare function isBareScriptCfml(source: string): boolean;
|
|
107
|
+
//# sourceMappingURL=cfml-extractor.d.ts.map
|
|
@@ -28,6 +28,15 @@ export declare function isSourceFile(filePath: string, overrides?: Record<string
|
|
|
28
28
|
* extractor links them. (config/ + locales/ JSON have no section refs.)
|
|
29
29
|
*/
|
|
30
30
|
export declare function isShopifyLiquidJson(filePath: string): boolean;
|
|
31
|
+
/**
|
|
32
|
+
* OTP application resource file: `<app>.app.src` (checked into every rebar3/
|
|
33
|
+
* erlang.mk app) or its compiled `<app>.app`. Erlang TERMS, not forms — the
|
|
34
|
+
* grammar parses them as top-level expressions, and the Erlang extractor's
|
|
35
|
+
* application-tuple handler turns `{mod, {Mod, _}}` and `{applications, […]}`
|
|
36
|
+
* into entry-module and dependency edges. Routed by full suffix because the
|
|
37
|
+
* last-dot extension (`.src`) is far too generic for EXTENSION_MAP.
|
|
38
|
+
*/
|
|
39
|
+
export declare function isErlangAppFile(filePath: string): boolean;
|
|
31
40
|
/**
|
|
32
41
|
* Play Framework routes file: the extensionless `conf/routes` (and included
|
|
33
42
|
* `conf/*.routes`). No grammar — route extraction is done by the Play framework
|
|
@@ -54,12 +63,27 @@ export declare function detectVbaFormFile(filePath: string): boolean;
|
|
|
54
63
|
* Idempotent — safe to call multiple times.
|
|
55
64
|
*/
|
|
56
65
|
export declare function initGrammars(): Promise<void>;
|
|
66
|
+
/**
|
|
67
|
+
* Pre-read the grammar WASM bytes for an index set, keyed by language. The
|
|
68
|
+
* orchestrator reads each grammar ONCE and hands the bytes to every parse
|
|
69
|
+
* worker via its `load-grammars` message, so worker spawns/respawns load
|
|
70
|
+
* grammars from memory instead of re-reading them from disk — on slow storage
|
|
71
|
+
* (HDD, issue #1231) each respawn's grammar re-read otherwise amplifies the
|
|
72
|
+
* I/O contention that caused the respawn. Best-effort: a language whose WASM
|
|
73
|
+
* can't be read here is simply omitted, and the worker falls back to its own
|
|
74
|
+
* disk load (which surfaces the real error/warning path).
|
|
75
|
+
*/
|
|
76
|
+
export declare function readGrammarWasmBytes(languages: Language[]): Promise<Record<string, Uint8Array>>;
|
|
57
77
|
/**
|
|
58
78
|
* Load grammar WASM files for specific languages only.
|
|
59
79
|
* Skips languages that are already loaded or have no WASM grammar.
|
|
60
80
|
* Must be called after initGrammars().
|
|
81
|
+
*
|
|
82
|
+
* `wasmBytes` (optional) holds pre-read grammar bytes keyed by language (from
|
|
83
|
+
* {@link readGrammarWasmBytes}, forwarded through the parse pool); when a
|
|
84
|
+
* language's bytes are present they're loaded from memory instead of disk.
|
|
61
85
|
*/
|
|
62
|
-
export declare function loadGrammarsForLanguages(languages: Language[]): Promise<void>;
|
|
86
|
+
export declare function loadGrammarsForLanguages(languages: Language[], wasmBytes?: Record<string, Uint8Array>): Promise<void>;
|
|
63
87
|
/**
|
|
64
88
|
* Load ALL grammar WASM files. Convenience function for tests and
|
|
65
89
|
* backward compatibility. Prefer loadGrammarsForLanguages() in production.
|
|
@@ -24,6 +24,14 @@ export interface IndexResult {
|
|
|
24
24
|
filesIndexed: number;
|
|
25
25
|
filesSkipped: number;
|
|
26
26
|
filesErrored: number;
|
|
27
|
+
/**
|
|
28
|
+
* How many indexable files the scan discovered — the ground truth the
|
|
29
|
+
* indexed/skipped/errored tallies must add up to. A shortfall means files
|
|
30
|
+
* were silently dropped mid-pipeline (e.g. a killed worker under load) and
|
|
31
|
+
* the index is PARTIAL; callers surface that rather than trusting the
|
|
32
|
+
* counts. Only set by full-index runs (indexAll), not indexFiles/sync.
|
|
33
|
+
*/
|
|
34
|
+
filesDiscovered?: number;
|
|
27
35
|
nodesCreated: number;
|
|
28
36
|
edgesCreated: number;
|
|
29
37
|
errors: ExtractionError[];
|
|
@@ -72,6 +80,17 @@ export declare class ScopeIgnore {
|
|
|
72
80
|
* exclude applies even to tracked files and even inside embedded repos.
|
|
73
81
|
*/
|
|
74
82
|
private exclude;
|
|
83
|
+
/**
|
|
84
|
+
* Project `codegraph.json` `include` patterns — first-party source forced
|
|
85
|
+
* INTO the index despite `.gitignore`. When a path matches, it is NOT
|
|
86
|
+
* ignored (so the watcher watches it), overriding `.gitignore`/`rootMatcher`
|
|
87
|
+
* — but never `exclude` (checked first) and never a built-in default-ignored
|
|
88
|
+
* dir. `includeRoots` are the static prefixes so a gitignored ANCESTOR
|
|
89
|
+
* directory of an included subtree still isn't pruned by the directory
|
|
90
|
+
* walker/watcher.
|
|
91
|
+
*/
|
|
92
|
+
private include;
|
|
93
|
+
private includeRoots;
|
|
75
94
|
private embedded;
|
|
76
95
|
private defaults;
|
|
77
96
|
constructor(rootMatcher: Ignore, embedded: Array<{
|
|
@@ -83,7 +102,17 @@ export declare class ScopeIgnore {
|
|
|
83
102
|
* full root-relative path. Wins over everything else — an explicit user
|
|
84
103
|
* exclude applies even to tracked files and even inside embedded repos.
|
|
85
104
|
*/
|
|
86
|
-
exclude?: Ignore | null
|
|
105
|
+
exclude?: Ignore | null,
|
|
106
|
+
/**
|
|
107
|
+
* Project `codegraph.json` `include` patterns — first-party source forced
|
|
108
|
+
* INTO the index despite `.gitignore`. When a path matches, it is NOT
|
|
109
|
+
* ignored (so the watcher watches it), overriding `.gitignore`/`rootMatcher`
|
|
110
|
+
* — but never `exclude` (checked first) and never a built-in default-ignored
|
|
111
|
+
* dir. `includeRoots` are the static prefixes so a gitignored ANCESTOR
|
|
112
|
+
* directory of an included subtree still isn't pruned by the directory
|
|
113
|
+
* walker/watcher.
|
|
114
|
+
*/
|
|
115
|
+
include?: Ignore | null, includeRoots?: string[]);
|
|
87
116
|
ignores(rel: string): boolean;
|
|
88
117
|
}
|
|
89
118
|
/**
|
|
@@ -102,6 +131,22 @@ export declare function buildScopeIgnore(rootDir: string, embeddedRoots?: Iterab
|
|
|
102
131
|
* there already.
|
|
103
132
|
*/
|
|
104
133
|
export declare function discoverEmbeddedRepoRoots(rootDir: string): string[];
|
|
134
|
+
/**
|
|
135
|
+
* The INVERSE of the gitignored side of {@link discoverEmbeddedRepoRoots}:
|
|
136
|
+
* nested git repositories under a gitignored directory that the project has NOT
|
|
137
|
+
* opted into via `codegraph.json` `includeIgnored`. These are real repos the
|
|
138
|
+
* default `init`/`index` deliberately skips because `.gitignore` excludes them
|
|
139
|
+
* (#970, #976) — most visibly the "super-repo `.gitignore`s its child repos"
|
|
140
|
+
* layout (#1156), where `init` at the parent correctly indexes ~nothing while
|
|
141
|
+
* `init` inside each child works. The CLI uses this to turn that silent empty
|
|
142
|
+
* index into an actionable hint: it names the skipped repos and offers to opt
|
|
143
|
+
* them in. Paths are `rootDir`-relative and trailing-slashed (valid
|
|
144
|
+
* `includeIgnored` patterns as-is). Returns `[]` for a non-git root (a
|
|
145
|
+
* filesystem walk already descends into nested repos there), skips built-in
|
|
146
|
+
* default-ignored dirs (`node_modules`, …), and is bounded so it never stalls
|
|
147
|
+
* on a giant ignored tree.
|
|
148
|
+
*/
|
|
149
|
+
export declare function findUnindexedIgnoredRepos(rootDir: string): string[];
|
|
105
150
|
/**
|
|
106
151
|
* Recursively scan a directory for source files.
|
|
107
152
|
*
|
|
@@ -145,7 +190,7 @@ export declare class ExtractionOrchestrator {
|
|
|
145
190
|
/**
|
|
146
191
|
* Index all files in the project
|
|
147
192
|
*/
|
|
148
|
-
indexAll(onProgress?: (progress: IndexProgress) => void, signal?: AbortSignal, verbose?: boolean): Promise<IndexResult>;
|
|
193
|
+
indexAll(onProgress?: (progress: IndexProgress) => void, signal?: AbortSignal, verbose?: boolean, walBackpressure?: () => Promise<void> | null): Promise<IndexResult>;
|
|
149
194
|
/**
|
|
150
195
|
* Index specific files
|
|
151
196
|
*/
|
|
@@ -7,6 +7,104 @@ import type { LanguageExtractor } from '../tree-sitter-types';
|
|
|
7
7
|
* template args. Returns undefined for primitives / void / `auto` / empty.
|
|
8
8
|
*/
|
|
9
9
|
export declare function normalizeCppReturnType(raw: string): string | undefined;
|
|
10
|
+
/**
|
|
11
|
+
* Strip C++ template arguments from a base-type reference name so it matches the
|
|
12
|
+
* bare class/struct the template was DEFINED as. `template<typename T> class
|
|
13
|
+
* Base { … }` is indexed as a node named `Base`, but a derived class
|
|
14
|
+
* `class D : public Base<int>` records its base as the full `Base<int>` (and
|
|
15
|
+
* `class Q : public ns::Tpl<int>` as `ns::Tpl<int>`) — neither name-matches
|
|
16
|
+
* `Base` / `ns::Tpl`, so the `extends` edge never resolves and the derived class
|
|
17
|
+
* looks like it inherits from nothing (#1043).
|
|
18
|
+
*
|
|
19
|
+
* Removes every balanced `<…>` group regardless of nesting or position, so
|
|
20
|
+
* `Base<int>` → `Base`, `ns::Tpl<Foo<int>>` → `ns::Tpl`, and the rare
|
|
21
|
+
* `Outer<int>::Inner` → `Outer::Inner`. The remaining qualified head is exactly
|
|
22
|
+
* what the non-templated base case already produces, so resolution treats them
|
|
23
|
+
* identically. A name with no template args passes through unchanged.
|
|
24
|
+
*/
|
|
25
|
+
export declare function stripCppTemplateArgs(name: string): string;
|
|
10
26
|
export declare const cExtractor: LanguageExtractor;
|
|
27
|
+
/**
|
|
28
|
+
* Blank an export/visibility macro in a `class/struct EXPORT_MACRO Name …`
|
|
29
|
+
* *definition* header before parsing. Not knowing the macro, tree-sitter reads
|
|
30
|
+
* `class EXPORT_MACRO` as an elaborated type specifier and the rest as a
|
|
31
|
+
* function, so the whole class — its name, base clause, and members — drops out
|
|
32
|
+
* of the index (#946 catches the resulting phantom function but can't recover
|
|
33
|
+
* the class), which silently breaks type-hierarchy / inheritance-impact queries
|
|
34
|
+
* for effectively every Unreal-Engine (`*_API`), Qt/Boost (`*_EXPORT`), LLVM
|
|
35
|
+
* (`*_ABI`), … class. Replacing the macro with equal-length spaces preserves
|
|
36
|
+
* every byte offset (and thus line/column), so the declaration then parses as a
|
|
37
|
+
* normal class_specifier and the existing extraction emits the node, members,
|
|
38
|
+
* and `extends` edge. (#1061, follow-up to #946.)
|
|
39
|
+
*
|
|
40
|
+
* Matched tightly so it can't touch the same macro used as an ordinary value
|
|
41
|
+
* elsewhere (`int x = SOME_API;`): the macro is the ALL-CAPS token sitting
|
|
42
|
+
* *between* `class`/`struct` and the type name, and the trailing `[:{]`
|
|
43
|
+
* definition-guard fires only when a base clause or body follows — the only
|
|
44
|
+
* shape that misparses. That guard also leaves elaborated-type variable
|
|
45
|
+
* declarations (`struct FOO var;`, `class FOO obj = …`) untouched, since those
|
|
46
|
+
* end in `;` / `=` / `[`, never `:` / `{`. C++-only (wired into cppExtractor),
|
|
47
|
+
* so C's heavier use of `struct TAG var;` never reaches it.
|
|
48
|
+
*/
|
|
49
|
+
export declare function blankCppExportMacros(source: string): string;
|
|
50
|
+
export declare function blankCppInlineMacros(source: string): string;
|
|
51
|
+
/**
|
|
52
|
+
* Universal fallback (any macro, no list) for a C/C++ function name still mangled
|
|
53
|
+
* because a macro we don't blank sat in front of the return type: `MACRO Ret
|
|
54
|
+
* name(…)` / `Ret MACRO name(…)` misparse so the return type is glued onto the
|
|
55
|
+
* name ("Ret name", "char_t* to_str(double v)"). Recover the real identifier —
|
|
56
|
+
* the token immediately before the parameter list (or the last token). This runs
|
|
57
|
+
* AFTER the curated pre-parse blank, so it only ever sees the residual tail that
|
|
58
|
+
* blanking didn't already fix cleanly (which also recovers the return type).
|
|
59
|
+
*
|
|
60
|
+
* Safe by construction: only touches an ALREADY-mangled name — one with an
|
|
61
|
+
* internal space that isn't a legit `operator …`/destructor — so a well-formed
|
|
62
|
+
* name is returned unchanged. Guarded against the two ways it could mis-pick:
|
|
63
|
+
* the `Ret (name)` parenthesized-name idiom (left as-is, ambiguous), and a token
|
|
64
|
+
* that is a bare primitive/keyword rather than a real identifier.
|
|
65
|
+
*/
|
|
66
|
+
export declare function recoverMangledCppName(name: string): string;
|
|
67
|
+
export declare function blankMetalAttributes(source: string): string;
|
|
68
|
+
/**
|
|
69
|
+
* Blank annotation-style macro invocations that decorate a declaration but carry
|
|
70
|
+
* NO terminating semicolon — the pervasive Unreal-Engine reflection markup
|
|
71
|
+
* (`UPROPERTY(...)`, `UFUNCTION(...)`, `UCLASS(...)`, `GENERATED_BODY()`,
|
|
72
|
+
* `UE_DEPRECATED_FORGAME(...)`, `DECLARE_DELEGATE_*(...)`, …) that sits on its
|
|
73
|
+
* own line right before a member/type. tree-sitter's C++ grammar doesn't know
|
|
74
|
+
* these are macros, so each one drops into error recovery; in a big reflected
|
|
75
|
+
* class (`CharacterMovementComponent.h` has ~240 of them) the errors accumulate
|
|
76
|
+
* until the enclosing `class_specifier` can't close and collapses into an ERROR
|
|
77
|
+
* node — the whole class definition, its members, and its `extends` edges vanish
|
|
78
|
+
* from the graph. Neither `blankCppExportMacros` (class-header export macros) nor
|
|
79
|
+
* `blankCppInlineMacros` (return-type inline specifiers) touches these in-body
|
|
80
|
+
* markup macros. Replacing each with equal-length spaces preserves every byte
|
|
81
|
+
* offset (so line/column stay exact) and the class then parses normally.
|
|
82
|
+
*
|
|
83
|
+
* Deliberately name-list-FREE — UE alone has hundreds of such macros and projects
|
|
84
|
+
* add their own — so it keys on structure, not a curated list, matched tightly to
|
|
85
|
+
* avoid touching legitimate C++:
|
|
86
|
+
* - the macro must be the FIRST non-whitespace token on its line (`^[ \t]*`),
|
|
87
|
+
* which is where declaration markup lives — so a macro used inside an
|
|
88
|
+
* expression or condition (`if (CHECK(x))`, `x = MACRO(a) + b`) is never
|
|
89
|
+
* matched (it isn't line-leading);
|
|
90
|
+
* - the name must be ALL-CAPS (`[A-Z][A-Z0-9_]{2,}`), since ordinary
|
|
91
|
+
* function/type names called at line start are lower/mixed case;
|
|
92
|
+
* - the char after the balanced `(...)` must START A DECLARATION — a letter,
|
|
93
|
+
* `_`, `~` (destructor), or `#` (a following directive). Declaration markup is
|
|
94
|
+
* always followed by the thing it decorates (`UPROPERTY(...)\n float X;`,
|
|
95
|
+
* `UE_DEPRECATED(...) UPROPERTY(...)`), whereas a statement call is followed by
|
|
96
|
+
* `;` (`FOO(x);`), an init-list item by `,`/`{`, and an expression fragment by
|
|
97
|
+
* an operator (`MAKE(a) + 1`) — all rejected. String/char literals inside the
|
|
98
|
+
* args are skipped so an embedded `)` can't mis-close the balance.
|
|
99
|
+
*
|
|
100
|
+
* C++-only (wired into cppExtractor). A blanked macro inside a block comment is
|
|
101
|
+
* harmless (comments don't parse), and the rare line-leading no-semicolon
|
|
102
|
+
* ALL-CAPS call that isn't markup only loses that one annotation, never a whole
|
|
103
|
+
* class.
|
|
104
|
+
*/
|
|
105
|
+
export declare function blankCppAnnotationMacroCalls(source: string): string;
|
|
106
|
+
export declare function blankCppApiPrefixMacros(source: string): string;
|
|
107
|
+
export declare function blankCppInlineAnnotationMacros(source: string): string;
|
|
108
|
+
export declare function blankCudaConstructs(source: string): string;
|
|
11
109
|
export declare const cppExtractor: LanguageExtractor;
|
|
12
110
|
//# sourceMappingURL=c-cpp.d.ts.map
|
|
@@ -0,0 +1,12 @@
|
|
|
1
|
+
import type { LanguageExtractor } from '../tree-sitter-types';
|
|
2
|
+
/**
|
|
3
|
+
* `<cfquery>` SQL bodies: `#hash#` expressions inside the SQL text are real
|
|
4
|
+
* CFML expressions (tree-sitter-cfml's `cfquery` grammar parses them
|
|
5
|
+
* structurally — `call_expression`/`member_expression`, same shape as
|
|
6
|
+
* cfscript's), so a call like `#getCurrentUser().getId()#` embedded in a
|
|
7
|
+
* WHERE clause is a genuine call edge. The surrounding SQL keywords/
|
|
8
|
+
* identifiers aren't symbols CodeGraph models — only `call_expression` is
|
|
9
|
+
* mapped, so extraction yields call references and nothing else.
|
|
10
|
+
*/
|
|
11
|
+
export declare const cfqueryExtractor: LanguageExtractor;
|
|
12
|
+
//# sourceMappingURL=cfquery.d.ts.map
|
|
@@ -0,0 +1,33 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* COBOL Language Extractor
|
|
3
|
+
*
|
|
4
|
+
* COBOL's AST (vendored, patched build of yutaro-sakamoto/tree-sitter-cobol)
|
|
5
|
+
* is fundamentally different from block-structured languages, so extraction
|
|
6
|
+
* runs almost entirely through the custom visitNode hook (the Pascal pattern):
|
|
7
|
+
*
|
|
8
|
+
* - A program (PROGRAM-ID) becomes a `module` node.
|
|
9
|
+
* - PROCEDURE DIVISION sections and paragraphs become `function` nodes. The
|
|
10
|
+
* grammar emits them FLAT — a section_header/paragraph_header followed by
|
|
11
|
+
* sibling statements — so extents are reconstructed here: a paragraph runs
|
|
12
|
+
* from its header to the next header, a section to the next section header.
|
|
13
|
+
* - PERFORM (including THRU ranges), GO TO, and CALL 'literal' become `calls`
|
|
14
|
+
* references. A dynamic CALL through a data name is skipped — announce,
|
|
15
|
+
* don't guess. EXEC CICS LINK/XCTL PROGRAM('X') with a literal target also
|
|
16
|
+
* becomes a `calls` reference; EXEC SQL INCLUDE X becomes an `imports`
|
|
17
|
+
* reference (DB2's COPY).
|
|
18
|
+
* - COPY statements become `import` nodes + `imports` references.
|
|
19
|
+
* - DATA DIVISION entries become `variable` (01/77 levels), `field` (nested
|
|
20
|
+
* levels, contained in their group item), or `constant` (88-level condition
|
|
21
|
+
* names) nodes, so impact queries on working-storage names work.
|
|
22
|
+
* - Standalone copybooks (.cpy) parse via the grammar's copybook_fragment
|
|
23
|
+
* entry point: data copybooks yield their record structure, procedure
|
|
24
|
+
* copybooks yield paragraphs.
|
|
25
|
+
*
|
|
26
|
+
* The grammar is fixed-format (code area columns 8-72). preParse detects a
|
|
27
|
+
* free-format file (division header or level number starting before column 8)
|
|
28
|
+
* and indents every line by 7 spaces: line numbers are preserved, columns
|
|
29
|
+
* drift by 7 — acceptable for line-oriented consumers.
|
|
30
|
+
*/
|
|
31
|
+
import type { LanguageExtractor } from '../tree-sitter-types';
|
|
32
|
+
export declare const cobolExtractor: LanguageExtractor;
|
|
33
|
+
//# sourceMappingURL=cobol.d.ts.map
|
|
@@ -0,0 +1,11 @@
|
|
|
1
|
+
import type { LanguageExtractor } from '../tree-sitter-types';
|
|
2
|
+
/**
|
|
3
|
+
* The vendored VB.NET grammar has no true end-of-file token (its `_eof` rule is
|
|
4
|
+
* a literal-`$` placeholder that never matches real input), so a file whose
|
|
5
|
+
* last line lacks a trailing newline ends every parse with a MISSING-newline
|
|
6
|
+
* error on the final statement. Appending a newline is offset-preserving for
|
|
7
|
+
* all existing content.
|
|
8
|
+
*/
|
|
9
|
+
export declare function ensureTrailingNewline(source: string): string;
|
|
10
|
+
export declare const vbnetExtractor: LanguageExtractor;
|
|
11
|
+
//# sourceMappingURL=vbnet.d.ts.map
|
|
@@ -12,15 +12,21 @@ import { ExtractionResult } from '../types';
|
|
|
12
12
|
*
|
|
13
13
|
* This extractor emits one method-shaped node per `<select|insert|update|
|
|
14
14
|
* delete>` and per `<sql>` fragment, qualified as `<namespace>::<id>` so the
|
|
15
|
-
* MyBatis framework synthesizer
|
|
16
|
-
*
|
|
17
|
-
*
|
|
18
|
-
*
|
|
15
|
+
* MyBatis framework synthesizer can link the matching Java method → XML
|
|
16
|
+
* statement by suffix-matching qualified names. `<include refid="...">` inside
|
|
17
|
+
* a statement yields an unresolved reference to the SQL fragment, also keyed
|
|
18
|
+
* by `<namespace>::<refid>`.
|
|
19
|
+
*
|
|
20
|
+
* Both dialects are covered: MyBatis 3 `<mapper namespace="...">` and the
|
|
21
|
+
* legacy iBatis 2 `<sqlMap>` (namespaced, or namespace-less with `Map.stmt`
|
|
22
|
+
* ids, plus its extra `<statement>`/`<procedure>` verbs). Attribute values may
|
|
23
|
+
* use either quote style, and statements commented out with `<!-- ... -->` are
|
|
24
|
+
* ignored (see the constructor's comment-stripping pre-pass).
|
|
19
25
|
*
|
|
20
26
|
* Non-mapper XML (Maven `pom.xml`, Spring beans XML, `web.xml`, log4j config,
|
|
21
|
-
* etc.) is detected by the absence of a `<mapper namespace="...">`
|
|
22
|
-
* returns just a file node — we still need the file row so
|
|
23
|
-
* track it, but we emit no symbols.
|
|
27
|
+
* etc.) is detected by the absence of a `<mapper namespace="...">` /
|
|
28
|
+
* `<sqlMap>` root and returns just a file node — we still need the file row so
|
|
29
|
+
* the watcher can track it, but we emit no symbols.
|
|
24
30
|
*/
|
|
25
31
|
export declare class MyBatisExtractor {
|
|
26
32
|
private filePath;
|
|
@@ -31,16 +37,30 @@ export declare class MyBatisExtractor {
|
|
|
31
37
|
private errors;
|
|
32
38
|
private lineStarts;
|
|
33
39
|
constructor(filePath: string, source: string);
|
|
40
|
+
private static stripXmlComments;
|
|
34
41
|
extract(): ExtractionResult;
|
|
35
42
|
private createFileNode;
|
|
36
43
|
/**
|
|
37
|
-
* Find the
|
|
38
|
-
*
|
|
39
|
-
*
|
|
44
|
+
* Find the mapper root and its dialect. Two shapes are recognized:
|
|
45
|
+
* - MyBatis 3: `<mapper namespace="com.foo.Bar">` — namespace required.
|
|
46
|
+
* - iBatis 2: `<sqlMap namespace="Account">`, or a namespace-less
|
|
47
|
+
* `<sqlMap>` whose statement ids carry the qualifier as `Map.statement`.
|
|
48
|
+
* Returns the namespace, the dialect, and the byte offsets of the body
|
|
49
|
+
* (between the opening and closing tag) so statement extraction is scoped to
|
|
50
|
+
* the root's contents. Either quote style is accepted for the namespace
|
|
51
|
+
* (`namespace='X'` is legal XML and common in older mappers).
|
|
40
52
|
*/
|
|
41
53
|
private findMapperRoot;
|
|
42
54
|
private extractMapper;
|
|
43
55
|
private buildSignature;
|
|
56
|
+
/**
|
|
57
|
+
* Build the `<namespace>::<id>` qualified name the MyBatis synthesizer
|
|
58
|
+
* suffix-matches against a Java `<Class>::<method>`, and the display name.
|
|
59
|
+
* For a namespace-less iBatis `<sqlMap>`, the statement id carries the
|
|
60
|
+
* qualifier as `Map.statement`, so split on the last dot to reach the same
|
|
61
|
+
* shape (`Account.getById` → `Account::getById`, name `getById`).
|
|
62
|
+
*/
|
|
63
|
+
private qualifyStatement;
|
|
44
64
|
private previewSql;
|
|
45
65
|
private computeLineStarts;
|
|
46
66
|
private getLineNumber;
|
|
@@ -47,6 +47,7 @@ export interface ParseTask {
|
|
|
47
47
|
content: string;
|
|
48
48
|
language: Language;
|
|
49
49
|
frameworkNames?: string[];
|
|
50
|
+
vbaTargets?: Record<string, boolean>;
|
|
50
51
|
}
|
|
51
52
|
/**
|
|
52
53
|
* Resolve the pool size from the `CODEGRAPH_PARSE_WORKERS` override and the
|
|
@@ -56,6 +57,12 @@ export interface ParseTask {
|
|
|
56
57
|
* - unset / blank / non-numeric → `clamp(cores - 1, 1, 8)` (leave a core for
|
|
57
58
|
* the main thread + UI; never zero — parsing always needs a worker).
|
|
58
59
|
*/
|
|
60
|
+
/**
|
|
61
|
+
* Resolve the base per-parse timeout from the `CODEGRAPH_PARSE_TIMEOUT_MS`
|
|
62
|
+
* override. Slow storage (HDD, network folders) can need a larger budget; a
|
|
63
|
+
* non-numeric / non-positive value falls back to the default (10s).
|
|
64
|
+
*/
|
|
65
|
+
export declare function resolveParseTimeoutMs(envVal: string | undefined): number;
|
|
59
66
|
export declare function resolveParsePoolSize(envVal: string | undefined, cpuCount: number): number;
|
|
60
67
|
export interface ParseWorkerPoolOptions {
|
|
61
68
|
/** Languages to load grammars for in every worker at spawn. */
|
|
@@ -72,6 +79,15 @@ export interface ParseWorkerPoolOptions {
|
|
|
72
79
|
createWorker?: () => ParsePoolWorker;
|
|
73
80
|
/** Optional verbose logger (the orchestrator's `[worker] …` logger). */
|
|
74
81
|
log?: (msg: string) => void;
|
|
82
|
+
/**
|
|
83
|
+
* Pre-read grammar WASM bytes keyed by language, forwarded to every worker's
|
|
84
|
+
* `load-grammars` message so a spawn/respawn loads grammars from memory
|
|
85
|
+
* instead of re-reading them from disk — on slow storage each respawn's
|
|
86
|
+
* grammar re-read otherwise amplifies the very I/O contention that caused
|
|
87
|
+
* the respawn (issue #1231). Best-effort: a missing language falls back to
|
|
88
|
+
* the worker's own disk read.
|
|
89
|
+
*/
|
|
90
|
+
grammarBuffers?: Record<string, Uint8Array>;
|
|
75
91
|
}
|
|
76
92
|
export declare class ParseWorkerPool {
|
|
77
93
|
private idle;
|
|
@@ -89,6 +105,7 @@ export declare class ParseWorkerPool {
|
|
|
89
105
|
private readonly parseTimeoutMs;
|
|
90
106
|
private readonly createWorker;
|
|
91
107
|
private readonly log;
|
|
108
|
+
private readonly grammarBuffers?;
|
|
92
109
|
constructor(opts: ParseWorkerPoolOptions);
|
|
93
110
|
/** Pool size cap (for logging). */
|
|
94
111
|
get size(): number;
|
|
@@ -99,7 +116,7 @@ export declare class ParseWorkerPool {
|
|
|
99
116
|
/**
|
|
100
117
|
* Parse one file on the pool. Resolves with the extraction result, or REJECTS
|
|
101
118
|
* if the parse times out or its worker crashes — the caller records the error
|
|
102
|
-
* and (for worker-exit/OOM rejections) re-attempts in its retry pass.
|
|
119
|
+
* and (for worker-exit/OOM/timeout rejections) re-attempts in its retry pass.
|
|
103
120
|
*/
|
|
104
121
|
requestParse(task: ParseTask): Promise<ExtractionResult>;
|
|
105
122
|
private spawnOne;
|
|
@@ -112,7 +129,17 @@ export declare class ParseWorkerPool {
|
|
|
112
129
|
private recycle;
|
|
113
130
|
private removeWorker;
|
|
114
131
|
private dispatch;
|
|
132
|
+
/**
|
|
133
|
+
* The base timer fired with no result processed yet. Do NOT kill or settle:
|
|
134
|
+
* the timer firing doesn't prove the parse is still running — after a long
|
|
135
|
+
* synchronous main-thread stretch Node services the timers phase before the
|
|
136
|
+
* poll phase, so an already-delivered `parse-result` is still queued behind
|
|
137
|
+
* this callback. Mark the job late (onMessage accepts a result that shows up)
|
|
138
|
+
* and arm the hard-kill backstop for workers that are genuinely hung.
|
|
139
|
+
*/
|
|
115
140
|
private onTimeout;
|
|
141
|
+
/** No result after the full hard-kill window — the worker really is hung. */
|
|
142
|
+
private onHardTimeout;
|
|
116
143
|
private drain;
|
|
117
144
|
private settle;
|
|
118
145
|
/**
|
|
@@ -76,8 +76,10 @@ export interface LanguageExtractor {
|
|
|
76
76
|
* grammar mis-parses inside enum bodies). MUST preserve byte offsets (replace
|
|
77
77
|
* removed text with spaces, keep newlines) so node positions and getNodeText
|
|
78
78
|
* stay correct; the returned string is used for both parsing and extraction.
|
|
79
|
+
* `filePath` lets a transform key off the concrete file extension when one
|
|
80
|
+
* language id serves several dialects (C++ also parses `.metal` shaders).
|
|
79
81
|
*/
|
|
80
|
-
preParse?: (source: string) => string;
|
|
82
|
+
preParse?: (source: string, filePath?: string) => string;
|
|
81
83
|
/** Node types that represent functions */
|
|
82
84
|
functionTypes: string[];
|
|
83
85
|
/** Node types that represent classes */
|
|
@@ -114,6 +116,15 @@ export interface LanguageExtractor {
|
|
|
114
116
|
returnField?: string;
|
|
115
117
|
/** Override symbol name extraction (e.g. ObjC multi-part selectors). */
|
|
116
118
|
resolveName?: (node: SyntaxNode, source: string) => string | undefined;
|
|
119
|
+
/**
|
|
120
|
+
* Post-process an already-extracted name to recover a real identifier from a
|
|
121
|
+
* name still mangled by a macro the pre-parse didn't blank (C/C++:
|
|
122
|
+
* `MACRO Ret name(` misparses to the name "Ret name"). Applied to every name
|
|
123
|
+
* this extractor produces, so it MUST be a no-op on a well-formed name — only
|
|
124
|
+
* C/C++ set it, because a mangled name there is unambiguous (an internal space),
|
|
125
|
+
* whereas e.g. Kotlin/Scala backtick identifiers legitimately contain spaces.
|
|
126
|
+
*/
|
|
127
|
+
recoverMangledName?: (name: string) => string;
|
|
117
128
|
/** Extract property name when the generic name walk fails (e.g. ObjC @property). */
|
|
118
129
|
extractPropertyName?: (node: SyntaxNode, source: string) => string | null;
|
|
119
130
|
/** Extract signature from node */
|
|
@@ -140,6 +151,14 @@ export interface LanguageExtractor {
|
|
|
140
151
|
extraClassNodeTypes?: string[];
|
|
141
152
|
/** Whether methods can be top-level without enclosing class (Go: true) */
|
|
142
153
|
methodsAreTopLevel?: boolean;
|
|
154
|
+
/**
|
|
155
|
+
* Skip a bodiless class node as a forward declaration / elaborated type,
|
|
156
|
+
* mirroring the bodiless-struct/enum skip. Set only for languages where a
|
|
157
|
+
* bodiless `class` specifier is NOT a complete definition — C/C++
|
|
158
|
+
* (`class Foo;` is a forward decl). Leave unset for languages where a
|
|
159
|
+
* bodiless class IS complete (Kotlin `class Empty`, Scala `case object`). (#1093)
|
|
160
|
+
*/
|
|
161
|
+
skipBodilessClass?: boolean;
|
|
143
162
|
/** NodeKind to use for interface-like declarations (Rust: 'trait'). Default: 'interface' */
|
|
144
163
|
interfaceKind?: NodeKind;
|
|
145
164
|
/**
|