mirror of
https://github.com/rust-lang/rust-analyzer.git
synced 2025-09-28 12:54:58 +00:00
correct hover for items with doc attribute with raw strings
This commit is contained in:
parent
8b3c851dd3
commit
4e76e884bd
2 changed files with 38 additions and 3 deletions
|
@ -7,7 +7,7 @@ use itertools::Itertools;
|
|||
use parser::SyntaxKind;
|
||||
|
||||
use crate::{
|
||||
ast::{self, support, AstNode, NameOwner, SyntaxNode},
|
||||
ast::{self, support, token_ext::HasStringValue, AstNode, AstToken, NameOwner, SyntaxNode},
|
||||
SmolStr, SyntaxElement, SyntaxToken, T,
|
||||
};
|
||||
|
||||
|
@ -53,8 +53,16 @@ impl ast::Attr {
|
|||
pub fn as_simple_key_value(&self) -> Option<(SmolStr, SmolStr)> {
|
||||
let lit = self.literal()?;
|
||||
let key = self.simple_name()?;
|
||||
// FIXME: escape? raw string?
|
||||
let value = lit.syntax().first_token()?.text().trim_matches('"').into();
|
||||
let value_token = lit.syntax().first_token()?;
|
||||
|
||||
let value: SmolStr = if let Some(s) = ast::String::cast(value_token.clone()) {
|
||||
s.value()?.into()
|
||||
} else if let Some(s) = ast::RawString::cast(value_token) {
|
||||
s.value()?.into()
|
||||
} else {
|
||||
return None;
|
||||
};
|
||||
|
||||
Some((key, value))
|
||||
}
|
||||
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue