Skip to content

Commit 5825e24

Browse files
committed
style: wrap comments
1 parent b35efa8 commit 5825e24

File tree

13 files changed

+246
-220
lines changed

13 files changed

+246
-220
lines changed

cli/config/src/lib.rs

+2-2
Original file line numberDiff line numberDiff line change
@@ -62,8 +62,8 @@ impl Config {
6262
///
6363
/// - Location specified by the path parameter if provided
6464
/// - `$TREE_SITTER_DIR/config.json`, if the `TREE_SITTER_DIR` environment variable is set
65-
/// - `tree-sitter/config.json` in your default user configuration directory, as determined
66-
/// by [`dirs::config_dir`](https://docs.rs/dirs/*/dirs/fn.config_dir.html)
65+
/// - `tree-sitter/config.json` in your default user configuration directory, as determined by
66+
/// [`dirs::config_dir`](https://docs.rs/dirs/*/dirs/fn.config_dir.html)
6767
/// - `$HOME/.tree-sitter/config.json` as a fallback from where tree-sitter _used_ to store
6868
/// its configuration
6969
pub fn load(path: Option<PathBuf>) -> Result<Self> {

cli/loader/src/lib.rs

+2-1
Original file line numberDiff line numberDiff line change
@@ -503,7 +503,8 @@ impl Loader {
503503
if let Ok(lock_file) = fs::OpenOptions::new().write(true).open(&lock_path) {
504504
recompile = false;
505505
if lock_file.try_lock_exclusive().is_err() {
506-
// if we can't acquire the lock, another process is compiling the parser, wait for it and don't recompile
506+
// if we can't acquire the lock, another process is compiling the parser, wait for
507+
// it and don't recompile
507508
lock_file.lock_exclusive()?;
508509
recompile = false;
509510
} else {

cli/src/generate/build_tables/item_set_builder.rs

+7-7
Original file line numberDiff line numberDiff line change
@@ -75,8 +75,8 @@ impl<'a> ParseItemSetBuilder<'a> {
7575

7676
// The FIRST set of a non-terminal `i` is the union of the following sets:
7777
// * the set of all terminals that appear at the beginnings of i's productions
78-
// * the FIRST sets of all the non-terminals that appear at the beginnings
79-
// of i's productions
78+
// * the FIRST sets of all the non-terminals that appear at the beginnings of i's
79+
// productions
8080
//
8181
// Rather than computing these sets using recursion, we use an explicit stack
8282
// called `symbols_to_process`.
@@ -135,11 +135,11 @@ impl<'a> ParseItemSetBuilder<'a> {
135135
// item set when `i` occurs as the next symbol in one if its core items. The
136136
// structure of an *addition* is as follows:
137137
// * `item` - the new item that must be added as part of the expansion of `i`
138-
// * `lookaheads` - lookahead tokens that can always come after that item in
139-
// the expansion of `i`
140-
// * `propagates_lookaheads` - a boolean indicating whether or not `item` can
141-
// occur at the *end* of the expansion of `i`, so that i's own current
142-
// lookahead tokens can occur after `item`.
138+
// * `lookaheads` - lookahead tokens that can always come after that item in the expansion
139+
// of `i`
140+
// * `propagates_lookaheads` - a boolean indicating whether or not `item` can occur at the
141+
// *end* of the expansion of `i`, so that i's own current lookahead tokens can occur
142+
// after `item`.
143143
//
144144
// Again, rather than computing these additions recursively, we use an explicit
145145
// stack called `entries_to_process`.

cli/src/generate/node_types.rs

+12-12
Original file line numberDiff line numberDiff line change
@@ -140,18 +140,17 @@ impl ChildQuantity {
140140
/// * `types` - The types of visible children the field can contain.
141141
/// * `optional` - Do `N` nodes always have this field?
142142
/// * `multiple` - Can `N` nodes have multiple children for this field?
143-
/// 3. `children_without_fields` - The *other* named children of `N` that are
144-
/// not associated with fields. Data regarding these children:
143+
/// 3. `children_without_fields` - The *other* named children of `N` that are not associated with
144+
/// fields. Data regarding these children:
145145
/// * `types` - The types of named children with no field.
146146
/// * `optional` - Do `N` nodes always have at least one named child with no field?
147147
/// * `multiple` - Can `N` nodes have multiple named children with no field?
148148
///
149149
/// Each summary must account for some indirect factors:
150-
/// 1. hidden nodes. When a parent node `N` has a hidden child `C`, the visible
151-
/// children of `C` *appear* to be direct children of `N`.
152-
/// 2. aliases. If a parent node type `M` is aliased as some other type `N`,
153-
/// then nodes which *appear* to have type `N` may have internal structure based
154-
/// on `M`.
150+
/// 1. hidden nodes. When a parent node `N` has a hidden child `C`, the visible children of `C`
151+
/// *appear* to be direct children of `N`.
152+
/// 2. aliases. If a parent node type `M` is aliased as some other type `N`, then nodes which
153+
/// *appear* to have type `N` may have internal structure based on `M`.
155154
pub fn get_variable_info(
156155
syntax_grammar: &SyntaxGrammar,
157156
lexical_grammar: &LexicalGrammar,
@@ -224,7 +223,8 @@ pub fn get_variable_info(
224223
.entry(field_name)
225224
.or_insert_with(ChildQuantity::zero);
226225

227-
// Inherit the types and quantities of hidden children associated with fields.
226+
// Inherit the types and quantities of hidden children associated with
227+
// fields.
228228
if child_is_hidden && child_symbol.is_non_terminal() {
229229
let child_variable_info = &result[child_symbol.index];
230230
did_change |= extend_sorted(
@@ -529,8 +529,8 @@ pub fn generate_node_types_json(
529529
let fields_json = node_type_json.fields.as_mut().unwrap();
530530
for (new_field, field_info) in &info.fields {
531531
let field_json = fields_json.entry(new_field.clone()).or_insert_with(|| {
532-
// If another rule is aliased with the same name, and does *not* have this field,
533-
// then this field cannot be required.
532+
// If another rule is aliased with the same name, and does *not* have this
533+
// field, then this field cannot be required.
534534
let mut field_json = FieldInfoJSON::default();
535535
if node_type_existed {
536536
field_json.required = false;
@@ -540,8 +540,8 @@ pub fn generate_node_types_json(
540540
populate_field_info_json(field_json, field_info);
541541
}
542542

543-
// If another rule is aliased with the same name, any fields that aren't present in this
544-
// cannot be required.
543+
// If another rule is aliased with the same name, any fields that aren't present in
544+
// this cannot be required.
545545
for (existing_field, field_json) in fields_json.iter_mut() {
546546
if !info.fields.contains_key(existing_field) {
547547
field_json.required = false;

cli/src/generate/prepare_grammar/extract_default_aliases.rs

+5-5
Original file line numberDiff line numberDiff line change
@@ -16,8 +16,8 @@ struct SymbolStatus {
1616
// This has two benefits:
1717
// * It reduces the overhead of storing production-specific alias info in the parse table.
1818
// * Within an `ERROR` node, no context-specific aliases will be applied. This transformation
19-
// ensures that the children of an `ERROR` node have symbols that are consistent with the
20-
// way that they would appear in a valid syntax tree.
19+
// ensures that the children of an `ERROR` node have symbols that are consistent with the way that
20+
// they would appear in a valid syntax tree.
2121
pub(super) fn extract_default_aliases(
2222
syntax_grammar: &mut SyntaxGrammar,
2323
lexical_grammar: &LexicalGrammar,
@@ -164,10 +164,10 @@ pub(super) fn extract_default_aliases(
164164
#[cfg(test)]
165165
mod tests {
166166
use super::*;
167-
use crate::generate::grammars::{
168-
LexicalVariable, Production, ProductionStep, SyntaxVariable, VariableType,
167+
use crate::generate::{
168+
grammars::{LexicalVariable, Production, ProductionStep, SyntaxVariable, VariableType},
169+
nfa::Nfa,
169170
};
170-
use crate::generate::nfa::Nfa;
171171

172172
#[test]
173173
fn test_extract_simple_aliases() {

cli/src/generate/render.rs

+11-11
Original file line numberDiff line numberDiff line change
@@ -178,8 +178,8 @@ impl Generator {
178178
}
179179
// Two anonymous tokens with different flags but the same string value
180180
// should be represented with the same symbol in the public API. Examples:
181-
// * "<" and token(prec(1, "<"))
182-
// * "(" and token.immediate("(")
181+
// * "<" and token(prec(1, "<"))
182+
// * "(" and token.immediate("(")
183183
else if symbol.is_terminal() {
184184
let metadata = self.metadata_for_symbol(*symbol);
185185
for other_symbol in &self.parse_table.symbols {
@@ -225,7 +225,8 @@ impl Generator {
225225
if let Some(existing_symbol) = existing_symbol {
226226
alias_id = self.symbol_ids[&self.symbol_map[&existing_symbol]].clone();
227227
}
228-
// Other aliases don't match any existing symbol, and need their own identifiers.
228+
// Other aliases don't match any existing symbol, and need their own
229+
// identifiers.
229230
else {
230231
if let Err(i) = self.unique_aliases.binary_search(alias) {
231232
self.unique_aliases.insert(i, alias.clone());
@@ -1674,16 +1675,15 @@ impl Generator {
16741675
/// * `parse_table` - The generated parse table for the language
16751676
/// * `main_lex_table` - The generated lexing table for the language
16761677
/// * `keyword_lex_table` - The generated keyword lexing table for the language
1677-
/// * `keyword_capture_token` - A symbol indicating which token is used
1678-
/// for keyword capture, if any.
1678+
/// * `keyword_capture_token` - A symbol indicating which token is used for keyword capture, if any.
16791679
/// * `syntax_grammar` - The syntax grammar extracted from the language's grammar
16801680
/// * `lexical_grammar` - The lexical grammar extracted from the language's grammar
1681-
/// * `default_aliases` - A map describing the global rename rules that should apply.
1682-
/// the keys are symbols that are *always* aliased in the same way, and the values
1683-
/// are the aliases that are applied to those symbols.
1684-
/// * `abi_version` - The language ABI version that should be generated. Usually
1685-
/// you want Tree-sitter's current version, but right after making an ABI
1686-
/// change, it may be useful to generate code with the previous ABI.
1681+
/// * `default_aliases` - A map describing the global rename rules that should apply. the keys are
1682+
/// symbols that are *always* aliased in the same way, and the values are the aliases that are
1683+
/// applied to those symbols.
1684+
/// * `abi_version` - The language ABI version that should be generated. Usually you want
1685+
/// Tree-sitter's current version, but right after making an ABI change, it may be useful to
1686+
/// generate code with the previous ABI.
16871687
#[allow(clippy::too_many_arguments)]
16881688
pub fn render_c_code(
16891689
name: &str,

cli/src/test.rs

+5-3
Original file line numberDiff line numberDiff line change
@@ -306,13 +306,15 @@ fn run_tests(
306306
let expected_output = format_sexp(&output, 0);
307307
let actual_output = format_sexp(&actual, 0);
308308

309-
// Only bail early before updating if the actual is not the output, sometimes
310-
// users want to test cases that are intended to have errors, hence why this
309+
// Only bail early before updating if the actual is not the output,
310+
// sometimes users want to test cases that
311+
// are intended to have errors, hence why this
311312
// check isn't shown above
312313
if actual.contains("ERROR") || actual.contains("MISSING") {
313314
*has_parse_errors = true;
314315

315-
// keep the original `expected` output if the actual output has an error
316+
// keep the original `expected` output if the actual output has an
317+
// error
316318
corrected_entries.push((
317319
name.clone(),
318320
input,

cli/src/tests/node_test.rs

+8-7
Original file line numberDiff line numberDiff line change
@@ -850,10 +850,11 @@ fn test_node_numeric_symbols_respect_simple_aliases() {
850850
parser.set_language(&get_language("python")).unwrap();
851851

852852
// Example 1:
853-
// Python argument lists can contain "splat" arguments, which are not allowed within
854-
// other expressions. This includes `parenthesized_list_splat` nodes like `(*b)`. These
855-
// `parenthesized_list_splat` nodes are aliased as `parenthesized_expression`. Their numeric
856-
// `symbol`, aka `kind_id` should match that of a normal `parenthesized_expression`.
853+
// Python argument lists can contain "splat" arguments, which are not allowed
854+
// within other expressions. This includes `parenthesized_list_splat` nodes
855+
// like `(*b)`. These `parenthesized_list_splat` nodes are aliased as
856+
// `parenthesized_expression`. Their numeric `symbol`, aka `kind_id` should
857+
// match that of a normal `parenthesized_expression`.
857858
let tree = parser.parse("(a((*b)))", None).unwrap();
858859
let root = tree.root_node();
859860
assert_eq!(
@@ -875,9 +876,9 @@ fn test_node_numeric_symbols_respect_simple_aliases() {
875876
assert_eq!(inner_expr_node.kind_id(), outer_expr_node.kind_id());
876877

877878
// Example 2:
878-
// Ruby handles the unary (negative) and binary (minus) `-` operators using two different
879-
// tokens. One or more of these is an external token that's aliased as `-`. Their numeric
880-
// kind ids should match.
879+
// Ruby handles the unary (negative) and binary (minus) `-` operators using two
880+
// different tokens. One or more of these is an external token that's
881+
// aliased as `-`. Their numeric kind ids should match.
881882
parser.set_language(&get_language("ruby")).unwrap();
882883
let tree = parser.parse("-a - b", None).unwrap();
883884
let root = tree.root_node();

cli/src/tests/query_test.rs

+8-7
Original file line numberDiff line numberDiff line change
@@ -891,12 +891,12 @@ fn test_query_matches_with_immediate_siblings() {
891891
let language = get_language("python");
892892

893893
// The immediate child operator '.' can be used in three similar ways:
894-
// 1. Before the first child node in a pattern, it means that there cannot be any
895-
// named siblings before that child node.
894+
// 1. Before the first child node in a pattern, it means that there cannot be any named
895+
// siblings before that child node.
896896
// 2. After the last child node in a pattern, it means that there cannot be any named
897897
// sibling after that child node.
898-
// 2. Between two child nodes in a pattern, it specifies that there cannot be any
899-
// named siblings between those two child snodes.
898+
// 2. Between two child nodes in a pattern, it specifies that there cannot be any named
899+
// siblings between those two child snodes.
900900
let query = Query::new(
901901
&language,
902902
"
@@ -1425,7 +1425,8 @@ fn test_query_matches_with_nested_optional_nodes() {
14251425
allocations::record(|| {
14261426
let language = get_language("javascript");
14271427

1428-
// A function call, optionally containing a function call, which optionally contains a number
1428+
// A function call, optionally containing a function call, which optionally contains a
1429+
// number
14291430
let query = Query::new(
14301431
&language,
14311432
"
@@ -3269,8 +3270,8 @@ fn test_query_captures_with_too_many_nested_results() {
32693270
// appearance.
32703271
// 2. This pattern captures the root `call_expression`.
32713272
// 3. This pattern's result also depends on the final child (the template string).
3272-
// 4. In between the `call_expression` and the possible `template_string`, there can
3273-
// be an arbitrarily deep subtree.
3273+
// 4. In between the `call_expression` and the possible `template_string`, there can be an
3274+
// arbitrarily deep subtree.
32743275
//
32753276
// This means that, if any patterns match *after* the initial `call_expression` is
32763277
// captured, but before the final `template_string` is found, those matches must

highlight/src/c_lib.rs

+10-9
Original file line numberDiff line numberDiff line change
@@ -72,8 +72,8 @@ pub unsafe extern "C" fn ts_highlighter_new(
7272
/// `this` must be non-null and must be a valid pointer to a [`TSHighlighter`] instance
7373
/// created by [`ts_highlighter_new`].
7474
///
75-
/// The caller must ensure that any `*const c_char` (C-style string) parameters are valid for the lifetime of
76-
/// the [`TSHighlighter`] instance, and are non-null.
75+
/// The caller must ensure that any `*const c_char` (C-style string) parameters are valid for the
76+
/// lifetime of the [`TSHighlighter`] instance, and are non-null.
7777
#[no_mangle]
7878
pub unsafe extern "C" fn ts_highlighter_add_language(
7979
this: *mut TSHighlighter,
@@ -188,8 +188,8 @@ pub unsafe extern "C" fn ts_highlight_buffer_delete(this: *mut TSHighlightBuffer
188188
/// `this` must be non-null and must be a valid pointer to a [`TSHighlightBuffer`] instance
189189
/// created by [`ts_highlight_buffer_new`].
190190
///
191-
/// The returned pointer, a C-style string, must not outlive the [`TSHighlightBuffer`] instance, else the
192-
/// data will point to garbage.
191+
/// The returned pointer, a C-style string, must not outlive the [`TSHighlightBuffer`] instance,
192+
/// else the data will point to garbage.
193193
///
194194
/// To get the length of the HTML content, use [`ts_highlight_buffer_len`].
195195
#[no_mangle]
@@ -205,8 +205,8 @@ pub unsafe extern "C" fn ts_highlight_buffer_content(this: *const TSHighlightBuf
205205
/// `this` must be non-null and must be a valid pointer to a [`TSHighlightBuffer`] instance
206206
/// created by [`ts_highlight_buffer_new`].
207207
///
208-
/// The returned pointer, a C-style array of [`u32`]s, must not outlive the [`TSHighlightBuffer`] instance, else the
209-
/// data will point to garbage.
208+
/// The returned pointer, a C-style array of [`u32`]s, must not outlive the [`TSHighlightBuffer`]
209+
/// instance, else the data will point to garbage.
210210
///
211211
/// To get the length of the array, use [`ts_highlight_buffer_line_count`].
212212
#[no_mangle]
@@ -245,10 +245,11 @@ pub unsafe extern "C" fn ts_highlight_buffer_line_count(this: *const TSHighlight
245245
///
246246
/// # Safety
247247
///
248-
/// The caller must ensure that `scope_name`, `source_code`, `output`, and `cancellation_flag` are valid for
249-
/// the lifetime of the [`TSHighlighter`] instance, and are non-null.
248+
/// The caller must ensure that `scope_name`, `source_code`, `output`, and `cancellation_flag` are
249+
/// valid for the lifetime of the [`TSHighlighter`] instance, and are non-null.
250250
///
251-
/// `this` must be a non-null pointer to a [`TSHighlighter`] instance created by [`ts_highlighter_new`]
251+
/// `this` must be a non-null pointer to a [`TSHighlighter`] instance created by
252+
/// [`ts_highlighter_new`]
252253
#[no_mangle]
253254
pub unsafe extern "C" fn ts_highlighter_highlight(
254255
this: *const TSHighlighter,

0 commit comments

Comments
 (0)