Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

feat(syntax): add boolean check methods for typescript-related symbol flags #4426

Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
20 changes: 20 additions & 0 deletions crates/oxc_syntax/src/symbol.rs
Original file line number Diff line number Diff line change
Expand Up @@ -94,6 +94,10 @@ impl SymbolFlags {
self.intersects(Self::Variable)
}

pub fn is_type_parameter(&self) -> bool {
self.contains(Self::TypeParameter)
}

/// If true, then the symbol is a type, such as a TypeAlias, Interface, or Enum
pub fn is_type(&self) -> bool {
self.intersects((Self::TypeImport | Self::Type) - Self::Value)
Expand All @@ -116,6 +120,18 @@ impl SymbolFlags {
self.contains(Self::Class)
}

pub fn is_interface(&self) -> bool {
self.contains(Self::Interface)
}

pub fn is_type_alias(&self) -> bool {
self.contains(Self::TypeAlias)
}

pub fn is_enum(&self) -> bool {
self.intersects(Self::Enum)
}

pub fn is_catch_variable(&self) -> bool {
self.contains(Self::CatchVariable)
}
Expand All @@ -132,6 +148,10 @@ impl SymbolFlags {
self.intersects(Self::Import | Self::TypeImport)
}

pub fn is_type_import(&self) -> bool {
self.contains(Self::TypeImport)
}

/// If true, then the symbol can be referenced by a type
pub fn can_be_referenced_by_type(&self) -> bool {
self.intersects(Self::Type | Self::TypeImport | Self::Import)
Expand Down