on master help sign in
Fix clippy warnings.
593f33dBlaž Hrastnik
helix-core/src/syntax.rs+62−56
@@ -1,52 +1,52 @@
1−pub struct LanguageMode {
1+// pub struct Syntax {
2− parser: Parser,
2+// parser: Parser,
3−}
4−
5−impl LanguageMode {
6− // buffer, grammar, config, grammars, sync_timeout?
7− pub fn new() -> Self {
8− unimplemented!()
9− // make a new root layer
10− // track markers of injections
11− //
12− // track scope_descriptor: a Vec of scopes for item in tree
13− //
14− // fetch grammar for parser based on language string
15− // update root layer
16− }
3+// }
17
4
5+//impl Syntax {
6+// // buffer, grammar, config, grammars, sync_timeout?
7+// pub fn new() -> Self {
8+// unimplemented!()
9+// // make a new root layer
10+// // track markers of injections
11+// //
12+// // track scope_descriptor: a Vec of scopes for item in tree
13+// //
14+// // fetch grammar for parser based on language string
15+// // update root layer
16+// }
17+
18− // fn buffer_changed -> call layer.update(range, new_text) on root layer and then all marker layers
18+// // fn buffer_changed -> call layer.update(range, new_text) on root layer and then all marker layers
19−
19+
20− // call this on transaction.apply() -> buffer_changed(changes)
20+// // call this on transaction.apply() -> buffer_changed(changes)
21− //
21+// //
22− // fn parse(language, old_tree, ranges)
22+// // fn parse(language, old_tree, ranges)
23− //
23+// //
24− // fn tree() -> Tree
24+// // fn tree() -> Tree
25− //
25+// //
26− // <!--update_for_injection(grammar)-->
26+// // <!--update_for_injection(grammar)-->
27−
27+
28− // Highlighting
28+// // Highlighting
29− // fn highlight_iter() -> iterates over all the scopes
29+// // fn highlight_iter() -> iterates over all the scopes
30− // on_tokenize
30+// // on_tokenize
31− // on_change_highlighting
31+// // on_change_highlighting
32−
32+
33− // Commenting
33+// // Commenting
34− // comment_strings_for_pos
34+// // comment_strings_for_pos
35− // is_commented
35+// // is_commented
36−
36+
37− // Indentation
37+// // Indentation
38− // suggested_indent_for_line_at_buffer_row
38+// // suggested_indent_for_line_at_buffer_row
39− // suggested_indent_for_buffer_row
39+// // suggested_indent_for_buffer_row
40− // indent_level_for_line
40+// // indent_level_for_line
41−
41+
42− // TODO: Folding
42+// // TODO: Folding
43−
43+
44− // Syntax APIs
44+// // Syntax APIs
45− // get_syntax_node_containing_range ->
45+// // get_syntax_node_containing_range ->
46− // ...
46+// // ...
47− // get_syntax_node_at_pos
47+// // get_syntax_node_at_pos
48− // buffer_range_for_scope_at_pos
48+// // buffer_range_for_scope_at_pos
49−}
49+//}
50
50
51pub struct LanguageLayer {
51pub struct LanguageLayer {
52 // mode
52 // mode
@@ -55,12 +55,12 @@ pub struct LanguageLayer {
55// tree: Tree,
55// tree: Tree,
56}
56}
57
57
58−impl LanguageLayer {
58+// impl LanguageLayer {
59− // fn highlight_iter() -> same as Mode but for this layer. Mode composits these
59+// // fn highlight_iter() -> same as Mode but for this layer. Mode composits these
60− // fn buffer_changed
60+// // fn buffer_changed
61− // fn update(range)
61+// // fn update(range)
62− // fn update_injections()
62+// // fn update_injections()
63−}
63+// }
64
64
65// -- refactored from tree-sitter-highlight to be able to retain state
65// -- refactored from tree-sitter-highlight to be able to retain state
66// TODO: add seek() to iter
66// TODO: add seek() to iter
@@ -189,13 +189,19 @@ struct HighlightIterLayer<'a> {
189 depth: usize,
189 depth: usize,
190}
190}
191
191
192−impl Highlighter {
192+impl Default for Highlighter {
193− pub fn new() -> Self {
193+ fn default() -> Self {
194 Highlighter {
194 Highlighter {
195 parser: Parser::new(),
195 parser: Parser::new(),
196 cursors: Vec::new(),
196 cursors: Vec::new(),
197 }
197 }
198 }
198 }
199+}
200+
201+impl Highlighter {
202+ pub fn new() -> Self {
203+ Self::default()
204+ }
199
205
200 pub fn parser(&mut self) -> &mut Parser {
206 pub fn parser(&mut self) -> &mut Parser {
201 &mut self.parser
207 &mut self.parser