mirror of
https://github.com/rust-lang/rust-analyzer.git
synced 2025-08-22 11:24:24 +00:00
Cleanup API
This commit is contained in:
parent
7f12a1f225
commit
5db789df9c
5 changed files with 84 additions and 96 deletions
|
@ -4,7 +4,7 @@ mod block;
|
|||
|
||||
use crate::{
|
||||
algo, ast, match_ast, AstNode, SyntaxError,
|
||||
SyntaxKind::{BYTE, CHAR, CONST, FN, INT_NUMBER, TYPE_ALIAS},
|
||||
SyntaxKind::{CONST, FN, INT_NUMBER, TYPE_ALIAS},
|
||||
SyntaxNode, SyntaxToken, TextSize, T,
|
||||
};
|
||||
use rowan::Direction;
|
||||
|
@ -121,41 +121,42 @@ fn validate_literal(literal: ast::Literal, acc: &mut Vec<SyntaxError>) {
|
|||
acc.push(SyntaxError::new_at_offset(rustc_unescape_error_to_string(err), off));
|
||||
};
|
||||
|
||||
if let Some(s) = literal.as_string() {
|
||||
if !s.is_raw() {
|
||||
if let Some(without_quotes) = unquote(text, 1, '"') {
|
||||
unescape_literal(without_quotes, Mode::Str, &mut |range, char| {
|
||||
if let Err(err) = char {
|
||||
push_err(1, (range.start, err));
|
||||
}
|
||||
})
|
||||
match literal.kind() {
|
||||
ast::LiteralKind::String(s) => {
|
||||
if !s.is_raw() {
|
||||
if let Some(without_quotes) = unquote(text, 1, '"') {
|
||||
unescape_literal(without_quotes, Mode::Str, &mut |range, char| {
|
||||
if let Err(err) = char {
|
||||
push_err(1, (range.start, err));
|
||||
}
|
||||
})
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
if let Some(s) = literal.as_byte_string() {
|
||||
if !s.is_raw() {
|
||||
if let Some(without_quotes) = unquote(text, 2, '"') {
|
||||
unescape_byte_literal(without_quotes, Mode::ByteStr, &mut |range, char| {
|
||||
if let Err(err) = char {
|
||||
push_err(2, (range.start, err));
|
||||
}
|
||||
})
|
||||
ast::LiteralKind::ByteString(s) => {
|
||||
if !s.is_raw() {
|
||||
if let Some(without_quotes) = unquote(text, 2, '"') {
|
||||
unescape_byte_literal(without_quotes, Mode::ByteStr, &mut |range, char| {
|
||||
if let Err(err) = char {
|
||||
push_err(2, (range.start, err));
|
||||
}
|
||||
})
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
match token.kind() {
|
||||
BYTE => {
|
||||
if let Some(Err(e)) = unquote(text, 2, '\'').map(unescape_byte) {
|
||||
push_err(2, e);
|
||||
}
|
||||
}
|
||||
CHAR => {
|
||||
ast::LiteralKind::Char => {
|
||||
if let Some(Err(e)) = unquote(text, 1, '\'').map(unescape_char) {
|
||||
push_err(1, e);
|
||||
}
|
||||
}
|
||||
_ => (),
|
||||
ast::LiteralKind::Byte => {
|
||||
if let Some(Err(e)) = unquote(text, 2, '\'').map(unescape_byte) {
|
||||
push_err(2, e);
|
||||
}
|
||||
}
|
||||
ast::LiteralKind::IntNumber(_)
|
||||
| ast::LiteralKind::FloatNumber(_)
|
||||
| ast::LiteralKind::Bool(_) => {}
|
||||
}
|
||||
}
|
||||
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue