MCPcopy Create free account
hub / github.com/PHPantom-dev/phpantom_lsp / classify_variable

Method classify_variable

src/semantic_tokens.rs:544–575  ·  view source on GitHub ↗

Classify a variable as parameter, property, or regular variable.

(
        &self,
        name: &str,
        offset: u32,
        symbol_map: &SymbolMap,
        _uri: &str,
        _ctx: &crate::types::FileContext,
    )

Source from the content-addressed store, hash-verified

542
543 /// Classify a variable as parameter, property, or regular variable.
544 fn classify_variable(
545 &self,
546 name: &str,
547 offset: u32,
548 symbol_map: &SymbolMap,
549 _uri: &str,
550 _ctx: &crate::types::FileContext,
551 ) -> (u32, u32) {
552 // Check if this is a property declaration.
553 if let Some(kind) = symbol_map.var_def_kind_at(name, offset) {
554 match kind {
555 VarDefKind::Property => return (TT_PROPERTY, TM_DECLARATION),
556 VarDefKind::Parameter => return (TT_PARAMETER, 0),
557 _ => {}
558 }
559 }
560
561 // Check if any VarDefSite marks this variable as a parameter
562 // in the current scope.
563 let scope = symbol_map.find_enclosing_scope(offset);
564 for def in &symbol_map.var_defs {
565 if def.name == name && def.scope_start == scope {
566 match def.kind {
567 VarDefKind::Parameter => return (TT_PARAMETER, 0),
568 VarDefKind::Property => return (TT_PROPERTY, 0),
569 _ => {}
570 }
571 }
572 }
573
574 (TT_VARIABLE, 0)
575 }
576
577 /// Check whether a `ClassReference` name is actually a `@template`
578 /// parameter that is in scope at the given offset.

Callers 1

collect_tokensMethod · 0.80

Calls 2

var_def_kind_atMethod · 0.80
find_enclosing_scopeMethod · 0.80

Tested by

no test coverage detected