Skip to content

Commit

Permalink
fix: add missing symbol children cases
Browse files Browse the repository at this point in the history
  • Loading branch information
SpontanCombust committed Jun 13, 2024
1 parent 788dc50 commit 51cc3ce
Show file tree
Hide file tree
Showing 2 changed files with 46 additions and 4 deletions.
39 changes: 35 additions & 4 deletions crates/analysis/src/symbol_analysis/symbol_table/iter.rs
Original file line number Diff line number Diff line change
Expand Up @@ -63,12 +63,14 @@ pub trait ChildrenSymbolsFilter<'a>: Symbol {
type ChildRef: TryFrom<&'a SymbolVariant> + 'a;
}

//FIXME missing this, super

pub enum ClassSymbolChild<'st> {
Var(&'st MemberVarSymbol),
Autobind(&'st AutobindSymbol),
Method(&'st MemberFunctionSymbol),
Event(&'st EventSymbol)
Event(&'st EventSymbol),
ThisVar(&'st ThisVarSymbol),
SuperVar(&'st SuperVarSymbol)
}

impl<'a> TryFrom<&'a SymbolVariant> for ClassSymbolChild<'a> {
Expand All @@ -80,6 +82,8 @@ impl<'a> TryFrom<&'a SymbolVariant> for ClassSymbolChild<'a> {
SymbolVariant::Autobind(s) => Ok(ClassSymbolChild::Autobind(s)),
SymbolVariant::MemberFunc(s) => Ok(ClassSymbolChild::Method(s)),
SymbolVariant::Event(s) => Ok(ClassSymbolChild::Event(s)),
SymbolVariant::ThisVar(s) => Ok(ClassSymbolChild::ThisVar(s)),
SymbolVariant::SuperVar(s) => Ok(ClassSymbolChild::SuperVar(s)),
_ => Err(())
}
}
Expand All @@ -89,8 +93,35 @@ impl<'a> ChildrenSymbolsFilter<'a> for ClassSymbol {
type ChildRef = ClassSymbolChild<'a>;
}

//FIXME missing this, super, parent, virtual_parent
pub type StateSymbolChild<'st> = ClassSymbolChild<'st>;

pub enum StateSymbolChild<'st> {
Var(&'st MemberVarSymbol),
Autobind(&'st AutobindSymbol),
Method(&'st MemberFunctionSymbol),
Event(&'st EventSymbol),
ThisVar(&'st ThisVarSymbol),
SuperVar(&'st SuperVarSymbol),
ParentVar(&'st ParentVarSymbol),
VirtualParentVar(&'st VirtualParentVarSymbol)
}

impl<'a> TryFrom<&'a SymbolVariant> for StateSymbolChild<'a> {
type Error = ();

fn try_from(value: &'a SymbolVariant) -> Result<Self, Self::Error> {
match value {
SymbolVariant::MemberVar(s) => Ok(StateSymbolChild::Var(s)),
SymbolVariant::Autobind(s) => Ok(StateSymbolChild::Autobind(s)),
SymbolVariant::MemberFunc(s) => Ok(StateSymbolChild::Method(s)),
SymbolVariant::Event(s) => Ok(StateSymbolChild::Event(s)),
SymbolVariant::ThisVar(s) => Ok(StateSymbolChild::ThisVar(s)),
SymbolVariant::SuperVar(s) => Ok(StateSymbolChild::SuperVar(s)),
SymbolVariant::ParentVar(s) => Ok(StateSymbolChild::ParentVar(s)),
SymbolVariant::VirtualParentVar(s) => Ok(StateSymbolChild::VirtualParentVar(s)),
_ => Err(())
}
}
}

impl<'a> ChildrenSymbolsFilter<'a> for StateSymbol {
type ChildRef = StateSymbolChild<'a>;
Expand Down
11 changes: 11 additions & 0 deletions crates/analysis/src/symbol_analysis/unqualified_name_lookup.rs
Original file line number Diff line number Diff line change
Expand Up @@ -216,6 +216,9 @@ impl<'a> UnqualifiedNameLookupBuilder<'a> {
ClassSymbolChild::Event(s) => {
unl.insert(s.path().to_owned());
},
// these are special reserved names, they cannot be overshadowed
ClassSymbolChild::ThisVar(_)
| ClassSymbolChild::SuperVar(_) => { }
}
}
}
Expand Down Expand Up @@ -273,6 +276,9 @@ impl SyntaxNodeVisitor for UnqualifiedNameLookupBuilder<'_> {
ClassSymbolChild::Event(s) => {
unl.insert(s.path().to_owned());
},
// these are special reserved names, they cannot be overshadowed
ClassSymbolChild::ThisVar(_)
| ClassSymbolChild::SuperVar(_) => { }
}
}
}
Expand Down Expand Up @@ -306,6 +312,11 @@ impl SyntaxNodeVisitor for UnqualifiedNameLookupBuilder<'_> {
StateSymbolChild::Event(s) => {
unl.insert(s.path().to_owned());
},
// these are special reserved names, they cannot be overshadowed
StateSymbolChild::ThisVar(_)
| StateSymbolChild::SuperVar(_)
| StateSymbolChild::ParentVar(_)
| StateSymbolChild::VirtualParentVar(_) => { }
}
}
}
Expand Down

0 comments on commit 51cc3ce

Please sign in to comment.