structure
Everything exported by guardlink/structure, from the .d.ts files published in guardlink@2.2.0. See the entry points for the other subpaths, and use guardlink as a library for worked examples.
Interfaces
Section titled “Interfaces”FileStructure
Section titled “FileStructure”Properties
Section titled “Properties”| Property | Type | Description |
|---|---|---|
language |
string | null |
Grammar used, or null when every line resolves to file scope. |
Methods
Section titled “Methods”anchorForLine()
Section titled “anchorForLine()”anchorForLine(
line):Anchor
Parameters
Section titled “Parameters”| Parameter | Type |
|---|---|
line |
number |
Returns
Section titled “Returns”dispose()
Section titled “dispose()”dispose():
void
Release the syntax tree. Safe to call twice; anchorForLine and symbolNamed throw after this.
Returns
Section titled “Returns”void
symbolNamed()
Section titled “symbolNamed()”symbolNamed(
name):Anchor|null
External mode: resolve a @source … symbol:<name> by declaration name.
Parameters
Section titled “Parameters”| Parameter | Type |
|---|---|
name |
string |
Returns
Section titled “Returns”Anchor | null
Variables
Section titled “Variables”ANCHOR_HASH_VERSION
Section titled “ANCHOR_HASH_VERSION”
constANCHOR_HASH_VERSION:1=1
Bump when token selection or the separator changes. Part of every emitted hash.
EXTENSION_LANGUAGE
Section titled “EXTENSION_LANGUAGE”
constEXTENSION_LANGUAGE:Record<string,string|null>
Lower-case extension (with dot) → language id, or null for file scope.
Covers every extension in parser/languages.ts, which is the list the scan
glob is built from. null is a real answer, not a gap: the anchor layer
resolves that file to file scope with reason no-grammar, and an annotation
in it still parses and still lands in the model — it just anchors to the file
rather than to the enclosing declaration.
Most of the languages SPEC §2.9 names have no prebuilt tree-sitter WASM worth
pinning, so they are null by necessity rather than by design. They are
listed anyway, because the alternative — undefined — is the difference
between “this file anchors to file scope” and “the table forgot this
language”, and only one of those is a bug.
GRAMMARS
Section titled “GRAMMARS”
constGRAMMARS:Record<string,GrammarSource>
GRAMMARS_UNAVAILABLE
Section titled “GRAMMARS_UNAVAILABLE”
constGRAMMARS_UNAVAILABLE: readonly ["swift","kotlin","dart"]
Languages GuardLink scans with no WASM the pinned runtime can load. Swift
and Kotlin ship no tree-sitter WASM package at all. Dart’s only published
package — tree-sitter-dart@1.0.0, the sole version npm has ever carried —
ships a WASM built with a pre-“dylink.0” Emscripten toolchain; web-tree-sitter
0.27 only recognizes the newer dylink.0 custom section and rejects it on
load. There is no newer version of the package to pin instead, and no other
npm package ships a trustworthy prebuilt Dart WASM as of this writing. All
three resolve to file scope with reason no-grammar until a working WASM is
placed at grammars/<language>.wasm by hand (the build script keeps any
file it finds).
Functions
Section titled “Functions”parseStructure()
Section titled “parseStructure()”parseStructure(
filePath,content):Promise<FileStructure>
Parameters
Section titled “Parameters”| Parameter | Type |
|---|---|
filePath |
string |
content |
string |
Returns
Section titled “Returns”Promise<FileStructure>
References
Section titled “References”Anchor
Section titled “Anchor”Re-exports Anchor
AnchorReason
Section titled “AnchorReason”Re-exports AnchorReason
AnchorScope
Section titled “AnchorScope”Re-exports AnchorScope
languageForExtension
Section titled “languageForExtension”Re-exports languageForExtension

