From 5ba4f949c23dcf53f34995c90b7c01e6c641b1f0 Mon Sep 17 00:00:00 2001 From: Aleksey Kladov Date: Fri, 6 Nov 2020 22:21:56 +0100 Subject: Kill RAW_ literals Syntactically, they are indistinguishable from non-raw versions, so it doesn't make sense to separate then *at the syntax* level. --- crates/ide/src/extend_selection.rs | 2 +- crates/ide/src/syntax_highlighting.rs | 16 +++++++--------- crates/ide/src/syntax_highlighting/format.rs | 4 +--- crates/ide/src/syntax_highlighting/injection.rs | 2 +- crates/ide/src/syntax_tree.rs | 6 ++---- 5 files changed, 12 insertions(+), 18 deletions(-) (limited to 'crates/ide/src') diff --git a/crates/ide/src/extend_selection.rs b/crates/ide/src/extend_selection.rs index 3ee0af8ad..0971f7701 100644 --- a/crates/ide/src/extend_selection.rs +++ b/crates/ide/src/extend_selection.rs @@ -35,7 +35,7 @@ fn try_extend_selection( ) -> Option { let range = frange.range; - let string_kinds = [COMMENT, STRING, RAW_STRING, BYTE_STRING, RAW_BYTE_STRING]; + let string_kinds = [COMMENT, STRING, BYTE_STRING]; let list_kinds = [ RECORD_PAT_FIELD_LIST, MATCH_ARM_LIST, diff --git a/crates/ide/src/syntax_highlighting.rs b/crates/ide/src/syntax_highlighting.rs index efcc8ecfe..05bafe9c8 100644 --- a/crates/ide/src/syntax_highlighting.rs +++ b/crates/ide/src/syntax_highlighting.rs @@ -179,10 +179,12 @@ pub(crate) fn highlight( element.clone() }; - if let Some(token) = element.as_token().cloned().and_then(ast::RawString::cast) { - let expanded = element_to_highlight.as_token().unwrap().clone(); - if injection::highlight_injection(&mut stack, &sema, token, expanded).is_some() { - continue; + if let Some(token) = element.as_token().cloned().and_then(ast::String::cast) { + if token.is_raw() { + let expanded = element_to_highlight.as_token().unwrap().clone(); + if injection::highlight_injection(&mut stack, &sema, token, expanded).is_some() { + continue; + } } } @@ -214,10 +216,6 @@ pub(crate) fn highlight( } stack.pop_and_inject(None); } - } else if let Some(string) = - element_to_highlight.as_token().cloned().and_then(ast::RawString::cast) - { - format_string_highlighter.highlight_format_string(&mut stack, &string, range); } } } @@ -532,7 +530,7 @@ fn highlight_element( None => h.into(), } } - STRING | RAW_STRING | RAW_BYTE_STRING | BYTE_STRING => HighlightTag::StringLiteral.into(), + STRING | BYTE_STRING => HighlightTag::StringLiteral.into(), ATTR => HighlightTag::Attribute.into(), INT_NUMBER | FLOAT_NUMBER => HighlightTag::NumericLiteral.into(), BYTE => HighlightTag::ByteLiteral.into(), diff --git a/crates/ide/src/syntax_highlighting/format.rs b/crates/ide/src/syntax_highlighting/format.rs index 71bde24f0..42f27df5d 100644 --- a/crates/ide/src/syntax_highlighting/format.rs +++ b/crates/ide/src/syntax_highlighting/format.rs @@ -29,9 +29,7 @@ impl FormatStringHighlighter { .children_with_tokens() .filter(|t| t.kind() != SyntaxKind::WHITESPACE) .nth(1) - .filter(|e| { - ast::String::can_cast(e.kind()) || ast::RawString::can_cast(e.kind()) - }) + .filter(|e| ast::String::can_cast(e.kind())) } _ => {} } diff --git a/crates/ide/src/syntax_highlighting/injection.rs b/crates/ide/src/syntax_highlighting/injection.rs index 59a74bc02..79f6b5359 100644 --- a/crates/ide/src/syntax_highlighting/injection.rs +++ b/crates/ide/src/syntax_highlighting/injection.rs @@ -15,7 +15,7 @@ use super::HighlightedRangeStack; pub(super) fn highlight_injection( acc: &mut HighlightedRangeStack, sema: &Semantics, - literal: ast::RawString, + literal: ast::String, expanded: SyntaxToken, ) -> Option<()> { let active_parameter = ActiveParameter::at_token(&sema, expanded)?; diff --git a/crates/ide/src/syntax_tree.rs b/crates/ide/src/syntax_tree.rs index 7941610d6..6dd05c05d 100644 --- a/crates/ide/src/syntax_tree.rs +++ b/crates/ide/src/syntax_tree.rs @@ -1,9 +1,7 @@ use ide_db::base_db::{FileId, SourceDatabase}; use ide_db::RootDatabase; use syntax::{ - algo, AstNode, NodeOrToken, SourceFile, - SyntaxKind::{RAW_STRING, STRING}, - SyntaxToken, TextRange, TextSize, + algo, AstNode, NodeOrToken, SourceFile, SyntaxKind::STRING, SyntaxToken, TextRange, TextSize, }; // Feature: Show Syntax Tree @@ -46,7 +44,7 @@ fn syntax_tree_for_string(token: &SyntaxToken, text_range: TextRange) -> Option< // we'll attempt parsing it as rust syntax // to provide the syntax tree of the contents of the string match token.kind() { - STRING | RAW_STRING => syntax_tree_for_token(token, text_range), + STRING => syntax_tree_for_token(token, text_range), _ => None, } } -- cgit v1.2.3