Skip to content
Generated from the .d.ts files published in guardlink@2.2.0. Report problems against guardlink, not this page.

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.

Property Type Description
language string | null Grammar used, or null when every line resolves to file scope.

anchorForLine(line): Anchor

Parameter Type
line number

Anchor

dispose(): void

Release the syntax tree. Safe to call twice; anchorForLine and symbolNamed throw after this.

void

symbolNamed(name): Anchor | null

External mode: resolve a @source … symbol:<name> by declaration name.

Parameter Type
name string

Anchor | null

const ANCHOR_HASH_VERSION: 1 = 1

Bump when token selection or the separator changes. Part of every emitted hash.


const EXTENSION_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.


const GRAMMARS: Record<string, GrammarSource>


const GRAMMARS_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).

parseStructure(filePath, content): Promise<FileStructure>

Parameter Type
filePath string
content string

Promise<FileStructure>

Re-exports Anchor


Re-exports AnchorReason


Re-exports AnchorScope


Re-exports languageForExtension