aboutsummaryrefslogtreecommitdiff
path: root/crates/ide/src/syntax_highlighting
diff options
context:
space:
mode:
authorLukas Wirth <[email protected]>2020-10-14 21:21:58 +0100
committerLukas Wirth <[email protected]>2020-10-14 21:50:26 +0100
commitbab29e65eb87f4765fb22d58bff723780980eeb6 (patch)
treede74eb9ddc59fd542c6aa5c14e778e1f3560cccf /crates/ide/src/syntax_highlighting
parent8c6dc5f28a5550acffbbb063335833304dac266d (diff)
Default::default the highlighters
Diffstat (limited to 'crates/ide/src/syntax_highlighting')
-rw-r--r--crates/ide/src/syntax_highlighting/format.rs4
-rw-r--r--crates/ide/src/syntax_highlighting/macro_rules.rs15
2 files changed, 4 insertions, 15 deletions
diff --git a/crates/ide/src/syntax_highlighting/format.rs b/crates/ide/src/syntax_highlighting/format.rs
index 3ab01295a..71bde24f0 100644
--- a/crates/ide/src/syntax_highlighting/format.rs
+++ b/crates/ide/src/syntax_highlighting/format.rs
@@ -12,10 +12,6 @@ pub(super) struct FormatStringHighlighter {
12} 12}
13 13
14impl FormatStringHighlighter { 14impl FormatStringHighlighter {
15 pub(super) fn reset(&mut self) {
16 self.format_string = None;
17 }
18
19 pub(super) fn check_for_format_string(&mut self, parent: &SyntaxNode) { 15 pub(super) fn check_for_format_string(&mut self, parent: &SyntaxNode) {
20 // Check if macro takes a format string and remember it for highlighting later. 16 // Check if macro takes a format string and remember it for highlighting later.
21 // The macros that accept a format string expand to a compiler builtin macros 17 // The macros that accept a format string expand to a compiler builtin macros
diff --git a/crates/ide/src/syntax_highlighting/macro_rules.rs b/crates/ide/src/syntax_highlighting/macro_rules.rs
index 0676e0972..4462af47e 100644
--- a/crates/ide/src/syntax_highlighting/macro_rules.rs
+++ b/crates/ide/src/syntax_highlighting/macro_rules.rs
@@ -3,21 +3,14 @@ use syntax::{SyntaxElement, SyntaxKind, SyntaxToken, TextRange, T};
3 3
4use crate::{HighlightTag, HighlightedRange}; 4use crate::{HighlightTag, HighlightedRange};
5 5
6#[derive(Default)]
6pub(super) struct MacroRulesHighlighter { 7pub(super) struct MacroRulesHighlighter {
7 state: Option<MacroMatcherParseState>, 8 state: Option<MacroMatcherParseState>,
8} 9}
9 10
10impl MacroRulesHighlighter { 11impl MacroRulesHighlighter {
11 pub(super) fn new() -> Self {
12 MacroRulesHighlighter { state: None }
13 }
14
15 pub(super) fn init(&mut self) { 12 pub(super) fn init(&mut self) {
16 self.state = Some(MacroMatcherParseState::new()); 13 self.state = Some(MacroMatcherParseState::default());
17 }
18
19 pub(super) fn reset(&mut self) {
20 self.state = None;
21 } 14 }
22 15
23 pub(super) fn advance(&mut self, token: &SyntaxToken) { 16 pub(super) fn advance(&mut self, token: &SyntaxToken) {
@@ -51,8 +44,8 @@ struct MacroMatcherParseState {
51 in_invoc_body: bool, 44 in_invoc_body: bool,
52} 45}
53 46
54impl MacroMatcherParseState { 47impl Default for MacroMatcherParseState {
55 fn new() -> Self { 48 fn default() -> Self {
56 MacroMatcherParseState { 49 MacroMatcherParseState {
57 paren_ty: None, 50 paren_ty: None,
58 paren_level: 0, 51 paren_level: 0,