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
BodyFieldNamestring- Field name holding a declaration's body, used for body-only extraction. Defaults to
body. DeclarationNodeTypesIReadOnlySet<string>- requiredNode types that count as named declarations (e.g.
class_declaration,method_declaration). DefaultNameFieldstring- Field name holding a declaration's name node. Defaults to
name. ImportNodeTypesIReadOnlySet<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.
NameFieldOverridesIReadOnlyDictionary<string, string>- Per-node-type overrides for the name field (e.g. Rust
impl_itemis identified by itstypefield). TransparentNodeTypesIReadOnlySet<string>- Structural wrapper node types the walker descends through transparently (e.g. C#
declaration_list, Pythonblock), so name matching is not tripped up by grammar container nodes. TreeSitterLanguageNamestring- requiredLanguage 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
nodeTypestring
Returns
stringPennington.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; }
}