diff options
author | Adolfo OchagavĂa <[email protected]> | 2018-11-05 17:38:34 +0000 |
---|---|---|
committer | Adolfo OchagavĂa <[email protected]> | 2018-11-05 17:38:34 +0000 |
commit | fda8ddc5fe8a764c0dc91fecb92af1bdf3078485 (patch) | |
tree | 1de03cfa42f40bb5ca19956534f53d0b92d271d5 /crates/ra_syntax/src/validation.rs | |
parent | 3b42ddae601fbd73f672e82028e04c3abdf1252d (diff) |
Introduce Location and make SyntaxError fields private
Diffstat (limited to 'crates/ra_syntax/src/validation.rs')
-rw-r--r-- | crates/ra_syntax/src/validation.rs | 25 |
1 files changed, 5 insertions, 20 deletions
diff --git a/crates/ra_syntax/src/validation.rs b/crates/ra_syntax/src/validation.rs index 06e6e7505..009f5052f 100644 --- a/crates/ra_syntax/src/validation.rs +++ b/crates/ra_syntax/src/validation.rs | |||
@@ -33,17 +33,11 @@ fn validate_char(node: ast::Char, errors: &mut Vec<SyntaxError>) { | |||
33 | AsciiEscape => { | 33 | AsciiEscape => { |
34 | if text.len() == 1 { | 34 | if text.len() == 1 { |
35 | // Escape sequence consists only of leading `\` | 35 | // Escape sequence consists only of leading `\` |
36 | errors.push(SyntaxError { | 36 | errors.push(SyntaxError::new(EmptyAsciiEscape, range)); |
37 | kind: EmptyAsciiEscape, | ||
38 | range: range, | ||
39 | }); | ||
40 | } else { | 37 | } else { |
41 | let escape_code = text.chars().skip(1).next().unwrap(); | 38 | let escape_code = text.chars().skip(1).next().unwrap(); |
42 | if !is_ascii_escape(escape_code) { | 39 | if !is_ascii_escape(escape_code) { |
43 | errors.push(SyntaxError { | 40 | errors.push(SyntaxError::new(InvalidAsciiEscape, range)); |
44 | kind: InvalidAsciiEscape, | ||
45 | range: range, | ||
46 | }); | ||
47 | } | 41 | } |
48 | } | 42 | } |
49 | } | 43 | } |
@@ -64,24 +58,15 @@ fn validate_char(node: ast::Char, errors: &mut Vec<SyntaxError>) { | |||
64 | } | 58 | } |
65 | 59 | ||
66 | if !components.has_closing_quote { | 60 | if !components.has_closing_quote { |
67 | errors.push(SyntaxError { | 61 | errors.push(SyntaxError::new(UnclosedChar, node.syntax().range())); |
68 | kind: UnclosedChar, | ||
69 | range: node.syntax().range(), | ||
70 | }); | ||
71 | } | 62 | } |
72 | 63 | ||
73 | if len == 0 { | 64 | if len == 0 { |
74 | errors.push(SyntaxError { | 65 | errors.push(SyntaxError::new(EmptyChar, node.syntax().range())); |
75 | kind: EmptyChar, | ||
76 | range: node.syntax().range(), | ||
77 | }); | ||
78 | } | 66 | } |
79 | 67 | ||
80 | if len > 1 { | 68 | if len > 1 { |
81 | errors.push(SyntaxError { | 69 | errors.push(SyntaxError::new(LongChar, node.syntax().range())); |
82 | kind: LongChar, | ||
83 | range: node.syntax().range(), | ||
84 | }); | ||
85 | } | 70 | } |
86 | } | 71 | } |
87 | 72 | ||