This documentation is also published as Markdown for efficient machine reading: the whole site is indexed at /llms.txt, and every page has a clean Markdown copy under /_llms/. These are generated from the same source and cost far fewer tokens to read than this rendered HTML.

Skip to main content Skip to navigation

LanguageDeclarationConfig Pennington.TreeSitter.Resolution

Describes, for one language, which syntax-tree node types are named declarations and how to read a declaration's name, so a single generic walker can resolve a dotted member path across languages.

Properties

BodyFieldName string
Field name holding a declaration's body, used for body-only extraction. Defaults to body.
DeclarationNodeTypes IReadOnlySet<string>
required
Node types that count as named declarations (e.g. class_declaration, method_declaration).
DefaultNameField string
Field name holding a declaration's name node. Defaults to name.
ImportNodeTypes IReadOnlySet<string>
File-level node types that count as import/using/require statements, used to prepend a snippet's import context. Empty when the language has no syntactic import form the walker can collect.
NameFieldOverrides IReadOnlyDictionary<string, string>
Per-node-type overrides for the name field (e.g. Rust impl_item is identified by its type field).
TransparentNodeTypes IReadOnlySet<string>
Structural wrapper node types the walker descends through transparently (e.g. C# declaration_list, Python block), so name matching is not tripped up by grammar container nodes.
TreeSitterLanguageName string
required
Language identifier passed to the tree-sitter binding (e.g. C#, Python, Rust).

Methods

NameFieldFor

#
public string NameFieldFor(string nodeType)

Returns the field name to read for the given declaration node type's name.

Parameters

nodeType string

Returns

string

Pennington.TreeSitter.Resolution.LanguageDeclarationConfig

namespace Pennington.TreeSitter.Resolution;

/// Describes, for one language, which syntax-tree node types are named declarations and how to read a declaration's name, so a single generic walker can resolve a dotted member path across languages.
public record LanguageDeclarationConfig
{
    /// Field name holding a declaration's body, used for body-only extraction. Defaults to body.
    
public string BodyFieldName { get; set; }
/// Node types that count as named declarations (e.g. class_declaration, method_declaration).
public IReadOnlySet<string> DeclarationNodeTypes { get; set; }
/// Field name holding a declaration's name node. Defaults to name.
public string DefaultNameField { get; set; }
/// File-level node types that count as import/using/require statements, used to prepend a snippet's import context. Empty when the language has no syntactic import form the walker can collect.
public IReadOnlySet<string> ImportNodeTypes { get; set; }
/// Returns the field name to read for the given declaration node type's name.
public string NameFieldFor(string nodeType)
; /// Per-node-type overrides for the name field (e.g. Rust impl_item is identified by its type field).
public IReadOnlyDictionary<string, string> NameFieldOverrides { get; set; }
/// Structural wrapper node types the walker descends through transparently (e.g. C# declaration_list, Python block), so name matching is not tripped up by grammar container nodes.
public IReadOnlySet<string> TransparentNodeTypes { get; set; }
/// Language identifier passed to the tree-sitter binding (e.g. C#, Python, Rust).
public string TreeSitterLanguageName { get; set; }
}