Initial support for lang items.
This commit is contained in:
@@ -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"]] ),
|
||||
|
||||
Reference in New Issue
Block a user