Skip to content

Commit

Permalink
doc(lens): Add doc strings for how code lenses are built
Browse files Browse the repository at this point in the history
  • Loading branch information
claytonrcarter committed Jan 11, 2023
1 parent 116755d commit 27de89a
Showing 1 changed file with 15 additions and 3 deletions.
18 changes: 15 additions & 3 deletions lapce-core/src/language.rs
Original file line number Diff line number Diff line change
Expand Up @@ -86,9 +86,16 @@ struct SyntaxProperties {
comment: &'static str,
/// The indent unit. " " for javascript, " " for rust, for example.
indent: &'static str,
/// TODO: someone more knowledgeable please describe what the two lists are.
/// Anyway, the second element of the tuple is a "ignore list". See
/// `walk_tree`. If unsure, use `DEFAULT_CODE_LENS_LIST` and
/// Lists of tree-sitter node types that control how code lenses are built.
/// The first is a list of nodes that should be traversed and included in
/// the lens, along with thier children. The second is a list of nodes that
/// should be excluded from the lens, though they will still be traversed.
/// See `walk_tree` for more details.
///
/// The tree-sitter playground may be useful when creating these lists:
/// https://tree-sitter.github.io/tree-sitter/playground
///
/// If unsure, use `DEFAULT_CODE_LENS_LIST` and
/// `DEFAULT_CODE_LENS_IGNORE_LIST`.
code_lens: (&'static [&'static str], &'static [&'static str]),
/// the tree sitter tag names that can be put in sticky headers
Expand Down Expand Up @@ -711,6 +718,7 @@ const LANGUAGES: &[SyntaxProperties] = &[
"namespace_definition",
"namespace_use_declaration",
"use_declaration",
"const_declaration",
"property_declaration",
"expression_statement",
],
Expand Down Expand Up @@ -1070,6 +1078,10 @@ impl LapceLanguage {
}
}

/// Walk an AST and determine which lines to include in the code lens.
///
/// Node types listed in `list` will be walked, along with their children. All
/// nodes encountered will be included, unless they are listed in `ignore_list`.
fn walk_tree(
cursor: &mut TreeCursor,
normal_lines: &mut HashSet<usize>,
Expand Down

0 comments on commit 27de89a

Please sign in to comment.