pub enum SymbolKind {
Package,
Class,
Role,
Subroutine,
Method,
Variable(VarKind),
Constant,
Import,
Export,
Label,
Format,
}Expand description
Symbol extraction, table, and reference types for navigation. Unified Perl symbol classification for LSP tooling.
This enum represents all meaningful symbol types in Perl code, designed to be the canonical taxonomy across all crates in the perl-lsp ecosystem.
§LSP Protocol Mapping
Each variant maps to an LSP SymbolKind number via Self::to_lsp_kind():
| Variant | LSP Kind | Number | Description |
|---|---|---|---|
Package | Module | 2 | Package declaration |
Class | Class | 5 | OO class (Moose, Moo, class keyword) |
Role | Interface | 8 | Role definition (Moose::Role) |
Subroutine | Function | 12 | Standalone subroutine |
Method | Method | 6 | OO method |
Variable(_) | Variable | 13 | Variables (scalar, array, hash) |
Constant | Constant | 14 | use constant or Readonly |
Import | Module | 2 | Imported symbol |
Export | Function | 12 | Exported symbol |
Label | Key | 20 | Loop/block label |
Format | Struct | 23 | format declaration |
Variants§
Package
Package declaration (package Foo;)
Class
OO class declaration (class keyword, Moose, Moo)
Role
Role definition (role keyword, Moose::Role)
Subroutine
Subroutine definition (sub name { })
Method
Method definition in OO context
Variable(VarKind)
Variable declaration with sigil-based container type
Constant
Constant value (use constant NAME => value)
Import
Imported symbol from use statement
Export
Exported symbol via Exporter
Label
Loop/block label (LABEL: while ...)
Format
Format declaration (format STDOUT =)
Implementations§
Source§impl SymbolKind
impl SymbolKind
Sourcepub const fn to_lsp_kind(self) -> u32
pub const fn to_lsp_kind(self) -> u32
Convert to LSP-compliant symbol kind number (workspace profile).
Maps Perl symbol types to the closest LSP protocol equivalents. This is the default mapping used for workspace symbols where a generic “Variable” kind is appropriate for all variable types.
See the enum documentation for the full mapping table.
Sourcepub const fn to_lsp_kind_document_symbol(self) -> u32
pub const fn to_lsp_kind_document_symbol(self) -> u32
Convert to LSP symbol kind with richer variable type distinctions.
This mapping provides a richer UI experience for document symbols by distinguishing between scalar, array, and hash variables:
| Variable Type | LSP Kind | Number | Icon |
|---|---|---|---|
Scalar ($) | Variable | 13 | generic variable |
Array (@) | Array | 18 | array/list icon |
Hash (%) | Object | 19 | object/dict icon |
Use this for document symbol providers where visual distinction of variable types improves navigation.
Sourcepub const fn sigil(self) -> Option<&'static str>
pub const fn sigil(self) -> Option<&'static str>
Returns the sigil for this symbol kind if applicable.
Only variable symbols have sigils; all other symbols return None.
§Examples
use perl_symbol_types::{SymbolKind, VarKind};
assert_eq!(SymbolKind::Variable(VarKind::Scalar).sigil(), Some("$"));
assert_eq!(SymbolKind::Variable(VarKind::Array).sigil(), Some("@"));
assert_eq!(SymbolKind::Subroutine.sigil(), None);Sourcepub const fn is_variable(self) -> bool
pub const fn is_variable(self) -> bool
Returns true if this is any variable type.
Sourcepub const fn is_callable(self) -> bool
pub const fn is_callable(self) -> bool
Returns true if this is a callable type (subroutine or method).
Sourcepub const fn is_namespace(self) -> bool
pub const fn is_namespace(self) -> bool
Returns true if this is a namespace type (package, class, or role).
Sourcepub const fn scalar() -> SymbolKind
pub const fn scalar() -> SymbolKind
Create a scalar variable symbol kind.
Sourcepub const fn array() -> SymbolKind
pub const fn array() -> SymbolKind
Create an array variable symbol kind.
Sourcepub const fn hash() -> SymbolKind
pub const fn hash() -> SymbolKind
Create a hash variable symbol kind.
Trait Implementations§
Source§impl Clone for SymbolKind
impl Clone for SymbolKind
Source§fn clone(&self) -> SymbolKind
fn clone(&self) -> SymbolKind
1.0.0 · Source§fn clone_from(&mut self, source: &Self)
fn clone_from(&mut self, source: &Self)
source. Read moreSource§impl Debug for SymbolKind
impl Debug for SymbolKind
Source§impl<'de> Deserialize<'de> for SymbolKind
impl<'de> Deserialize<'de> for SymbolKind
Source§fn deserialize<__D>(
__deserializer: __D,
) -> Result<SymbolKind, <__D as Deserializer<'de>>::Error>where
__D: Deserializer<'de>,
fn deserialize<__D>(
__deserializer: __D,
) -> Result<SymbolKind, <__D as Deserializer<'de>>::Error>where
__D: Deserializer<'de>,
Source§impl Hash for SymbolKind
impl Hash for SymbolKind
Source§impl PartialEq for SymbolKind
impl PartialEq for SymbolKind
Source§impl Serialize for SymbolKind
impl Serialize for SymbolKind
Source§fn serialize<__S>(
&self,
__serializer: __S,
) -> Result<<__S as Serializer>::Ok, <__S as Serializer>::Error>where
__S: Serializer,
fn serialize<__S>(
&self,
__serializer: __S,
) -> Result<<__S as Serializer>::Ok, <__S as Serializer>::Error>where
__S: Serializer,
impl Copy for SymbolKind
impl Eq for SymbolKind
impl StructuralPartialEq for SymbolKind
Auto Trait Implementations§
impl Freeze for SymbolKind
impl RefUnwindSafe for SymbolKind
impl Send for SymbolKind
impl Sync for SymbolKind
impl Unpin for SymbolKind
impl UnsafeUnpin for SymbolKind
impl UnwindSafe for SymbolKind
Blanket Implementations§
Source§impl<T> BorrowMut<T> for Twhere
T: ?Sized,
impl<T> BorrowMut<T> for Twhere
T: ?Sized,
Source§fn borrow_mut(&mut self) -> &mut T
fn borrow_mut(&mut self) -> &mut T
Source§impl<T> CloneToUninit for Twhere
T: Clone,
impl<T> CloneToUninit for Twhere
T: Clone,
Source§impl<Q, K> Equivalent<K> for Q
impl<Q, K> Equivalent<K> for Q
Source§fn equivalent(&self, key: &K) -> bool
fn equivalent(&self, key: &K) -> bool
key and return true if they are equal.