mirror of
https://github.com/rust-lang/rust-analyzer.git
synced 2025-08-30 23:27:24 +00:00
Update ungrammar
This commit is contained in:
parent
80b3b74018
commit
1d6eef1350
43 changed files with 801 additions and 676 deletions
|
@ -144,19 +144,20 @@ impl AttrKind {
|
|||
|
||||
impl ast::Attr {
|
||||
pub fn as_simple_atom(&self) -> Option<SmolStr> {
|
||||
if self.eq_token().is_some() || self.token_tree().is_some() {
|
||||
let meta = self.meta()?;
|
||||
if meta.eq_token().is_some() || meta.token_tree().is_some() {
|
||||
return None;
|
||||
}
|
||||
self.simple_name()
|
||||
}
|
||||
|
||||
pub fn as_simple_call(&self) -> Option<(SmolStr, ast::TokenTree)> {
|
||||
let tt = self.token_tree()?;
|
||||
let tt = self.meta()?.token_tree()?;
|
||||
Some((self.simple_name()?, tt))
|
||||
}
|
||||
|
||||
pub fn simple_name(&self) -> Option<SmolStr> {
|
||||
let path = self.path()?;
|
||||
let path = self.meta()?.path()?;
|
||||
match (path.segment(), path.qualifier()) {
|
||||
(Some(segment), None) => Some(segment.syntax().first_token()?.text().into()),
|
||||
_ => None,
|
||||
|
@ -174,6 +175,18 @@ impl ast::Attr {
|
|||
_ => AttrKind::Outer,
|
||||
}
|
||||
}
|
||||
|
||||
pub fn path(&self) -> Option<ast::Path> {
|
||||
self.meta()?.path()
|
||||
}
|
||||
|
||||
pub fn expr(&self) -> Option<ast::Expr> {
|
||||
self.meta()?.expr()
|
||||
}
|
||||
|
||||
pub fn token_tree(&self) -> Option<ast::TokenTree> {
|
||||
self.meta()?.token_tree()
|
||||
}
|
||||
}
|
||||
|
||||
#[derive(Debug, Clone, PartialEq, Eq)]
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue