Module: TreeSitterLanguagePack::StructureKind
- Extended by:
- T::Helpers, T::Sig
- Included in:
- StructureKindClass, StructureKindEnum, StructureKindFunction, StructureKindImpl, StructureKindInterface, StructureKindMethod, StructureKindModule, StructureKindNamespace, StructureKindOther, StructureKindStruct, StructureKindTrait
- Defined in:
- lib/tree_sitter_language_pack/native.rb
Overview
The kind of structural item found in source code.
Categorizes top-level and nested declarations such as functions, classes, structs, enums, traits, and more. Use [‘Other`](StructureKind::Other) for language-specific constructs that do not fit a standard category.
Class Method Summary collapse
Class Method Details
.from_hash(hash) ⇒ Object
26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 |
# File 'lib/tree_sitter_language_pack/native.rb', line 26 def self.from_hash(hash) discriminator = hash[:kind] || hash["kind"] case discriminator when "function" then StructureKindFunction.from_hash(hash) when "method" then StructureKindMethod.from_hash(hash) when "class" then StructureKindClass.from_hash(hash) when "struct" then StructureKindStruct.from_hash(hash) when "interface" then StructureKindInterface.from_hash(hash) when "enum" then StructureKindEnum.from_hash(hash) when "module" then StructureKindModule.from_hash(hash) when "trait" then StructureKindTrait.from_hash(hash) when "impl" then StructureKindImpl.from_hash(hash) when "namespace" then StructureKindNamespace.from_hash(hash) when "other" then StructureKindOther.from_hash(hash) else raise "Unknown discriminator: #{discriminator}" end end |