mirror of
https://github.com/rust-lang/rust-analyzer.git
synced 2025-09-27 04:19:13 +00:00
Merge branch 'master' into feature/issue/1856
# Conflicts: # crates/ra_assists/src/ast_editor.rs
This commit is contained in:
commit
81efd696cc
53 changed files with 1180 additions and 957 deletions
|
@ -166,11 +166,52 @@ impl AstNode for Attr {
|
|||
}
|
||||
}
|
||||
impl Attr {
|
||||
pub fn value(&self) -> Option<TokenTree> {
|
||||
pub fn path(&self) -> Option<Path> {
|
||||
AstChildren::new(&self.syntax).next()
|
||||
}
|
||||
pub fn input(&self) -> Option<AttrInput> {
|
||||
AstChildren::new(&self.syntax).next()
|
||||
}
|
||||
}
|
||||
#[derive(Debug, Clone, PartialEq, Eq, Hash)]
|
||||
pub enum AttrInput {
|
||||
Literal(Literal),
|
||||
TokenTree(TokenTree),
|
||||
}
|
||||
impl From<Literal> for AttrInput {
|
||||
fn from(node: Literal) -> AttrInput {
|
||||
AttrInput::Literal(node)
|
||||
}
|
||||
}
|
||||
impl From<TokenTree> for AttrInput {
|
||||
fn from(node: TokenTree) -> AttrInput {
|
||||
AttrInput::TokenTree(node)
|
||||
}
|
||||
}
|
||||
impl AstNode for AttrInput {
|
||||
fn can_cast(kind: SyntaxKind) -> bool {
|
||||
match kind {
|
||||
LITERAL | TOKEN_TREE => true,
|
||||
_ => false,
|
||||
}
|
||||
}
|
||||
fn cast(syntax: SyntaxNode) -> Option<Self> {
|
||||
let res = match syntax.kind() {
|
||||
LITERAL => AttrInput::Literal(Literal { syntax }),
|
||||
TOKEN_TREE => AttrInput::TokenTree(TokenTree { syntax }),
|
||||
_ => return None,
|
||||
};
|
||||
Some(res)
|
||||
}
|
||||
fn syntax(&self) -> &SyntaxNode {
|
||||
match self {
|
||||
AttrInput::Literal(it) => &it.syntax,
|
||||
AttrInput::TokenTree(it) => &it.syntax,
|
||||
}
|
||||
}
|
||||
}
|
||||
impl AttrInput {}
|
||||
#[derive(Debug, Clone, PartialEq, Eq, Hash)]
|
||||
pub struct AwaitExpr {
|
||||
pub(crate) syntax: SyntaxNode,
|
||||
}
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue