mirror of
https://github.com/rust-lang/rust-analyzer.git
synced 2025-09-27 12:29:21 +00:00
Initial support for lang items.
This commit is contained in:
parent
d55f1136d6
commit
e85ee60c42
11 changed files with 204 additions and 41 deletions
|
@ -65,6 +65,20 @@ impl ast::Attr {
|
|||
None
|
||||
}
|
||||
}
|
||||
|
||||
pub fn as_key_value(&self) -> Option<(SmolStr, SmolStr)> {
|
||||
let tt = self.value()?;
|
||||
let tt_node = tt.syntax();
|
||||
let attr = tt_node.children_with_tokens().nth(1)?;
|
||||
if attr.kind() == IDENT {
|
||||
let key = attr.as_token()?.text().clone();
|
||||
let val_node = tt_node.children_with_tokens().find(|t| t.kind() == STRING)?;
|
||||
let val = val_node.as_token()?.text().trim_start_matches("\"").trim_end_matches("\"");
|
||||
Some((key, SmolStr::new(val)))
|
||||
} else {
|
||||
None
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
#[derive(Debug, Clone, Copy, PartialEq, Eq)]
|
||||
|
|
|
@ -1325,6 +1325,7 @@ impl ToOwned for ImplBlock {
|
|||
|
||||
|
||||
impl ast::TypeParamsOwner for ImplBlock {}
|
||||
impl ast::AttrsOwner for ImplBlock {}
|
||||
impl ImplBlock {
|
||||
pub fn item_list(&self) -> Option<&ItemList> {
|
||||
super::child_opt(self)
|
||||
|
|
|
@ -341,7 +341,7 @@ Grammar(
|
|||
],
|
||||
options: ["TypeRef"]
|
||||
),
|
||||
"ImplBlock": (options: ["ItemList"], traits: ["TypeParamsOwner"]),
|
||||
"ImplBlock": (options: ["ItemList"], traits: ["TypeParamsOwner", "AttrsOwner"]),
|
||||
|
||||
"ParenType": (options: ["TypeRef"]),
|
||||
"TupleType": ( collections: [["fields", "TypeRef"]] ),
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue