Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
8 changes: 4 additions & 4 deletions crates/liyi/src/markers.rs.liyi.jsonc
Original file line number Diff line number Diff line change
Expand Up @@ -43,7 +43,7 @@
"source_anchor": "const ALIAS_TABLE: &[(&str, &str)] = &[",
"related": {
"marker-normalization": "sha256:f1786541ac9be4533a36924a80c578a749024a4980fbc323417c2d5640ed6306",
"quine-escape-in-source": null
"quine-escape-in-source": "sha256:b929750d0d3c9ce24a6f814d7a1db15f2fc03983efa2647cfcf6a7462d2c8b81"
}
},
{
Expand Down Expand Up @@ -125,7 +125,7 @@
"source_anchor": "fn is_fence_delimiter(line: &str) -> bool {",
"confidence": 0.95,
"related": {
"markdown-fenced-block-skip": null
"markdown-fenced-block-skip": "sha256:0bdd7d1ad747e2a826adfe2eca5652c7a9f382e1089ff12dd2c9b8d88f3920b7"
}
},
{
Expand Down Expand Up @@ -164,8 +164,8 @@
"source_hash": "sha256:882dc8ffe044cfd565123f41aa19ad94b6ec641f829f96a3c7b02565beb43de3",
"source_anchor": "pub fn scan_markers(content: &str) -> Vec<SourceMarker> {",
"related": {
"markdown-fenced-block-skip": null,
"quine-escape-in-source": null
"markdown-fenced-block-skip": "sha256:0bdd7d1ad747e2a826adfe2eca5652c7a9f382e1089ff12dd2c9b8d88f3920b7",
"quine-escape-in-source": "sha256:b929750d0d3c9ce24a6f814d7a1db15f2fc03983efa2647cfcf6a7462d2c8b81"
}
}
]
Expand Down
2 changes: 1 addition & 1 deletion crates/liyi/src/prompt.rs.liyi.jsonc
Original file line number Diff line number Diff line change
Expand Up @@ -51,7 +51,7 @@
"source_hash": "sha256:4b58abb88e8267fb636eae6727230d6f4c90fdaab97f0125c916e5a55985851e",
"source_anchor": "pub fn build_prompt_output(",
"related": {
"quine-escape-in-source": null
"quine-escape-in-source": "sha256:b929750d0d3c9ce24a6f814d7a1db15f2fc03983efa2647cfcf6a7462d2c8b81"
}
},
{
Expand Down
22 changes: 21 additions & 1 deletion crates/liyi/src/tree_path/lang_c.rs
Original file line number Diff line number Diff line change
Expand Up @@ -46,6 +46,26 @@ fn c_node_name(node: &Node, source: &str) -> Option<String> {
}

/// C language configuration.
/// Detect C doc comments (`/** ... */` and `/// ...`).
///
/// C's tree-sitter grammar uses a uniform `comment` kind for all comments.
/// We distinguish doc comments by prefix: `/**` for block doc and `///`
/// for line doc. Previous siblings that are not comments are skipped.
fn c_has_doc_comment(node: &Node, source: &str) -> bool {
let mut sibling = node.prev_sibling();
while let Some(s) = sibling {
if s.kind() == "comment" {
let text = &source[s.byte_range()];
if text.starts_with("/**") || text.starts_with("///") {
return true;
}
sibling = s.prev_sibling();
} else {
break;
}
}
false
}
pub(super) static CONFIG: LanguageConfig = LanguageConfig {
ts_language: || tree_sitter_c::LANGUAGE.into(),
extensions: &["c"],
Expand All @@ -59,7 +79,7 @@ pub(super) static CONFIG: LanguageConfig = LanguageConfig {
name_overrides: &[],
body_fields: &["body"],
custom_name: Some(c_node_name),
doc_comment_detector: None,
doc_comment_detector: Some(c_has_doc_comment),
transparent_kinds: &[],
};

Expand Down
6 changes: 3 additions & 3 deletions crates/liyi/src/tree_path/lang_c.rs.liyi.jsonc
Original file line number Diff line number Diff line change
Expand Up @@ -44,11 +44,11 @@
"reviewed": true,
"intent": "Define the C language configuration for tree_path resolution: register tree-sitter-c grammar, .c extension only, kind mappings for fn/struct/enum/typedef, wire the custom c_node_name callback for name extraction, and no doc comment detector.",
"source_span": [
49,
64
69,
84
],
"tree_path": "static.CONFIG",
"source_hash": "sha256:896b0b51a031e70d135ee3c4f5c5fec8e24548e376d24f3551c1bcf865815c16",
"source_hash": "sha256:bc2b8ed39645ec4e16137afa87b145349dde8c1ff38d950953bfc843eedfedfe",
"source_anchor": "pub(super) static CONFIG: LanguageConfig = LanguageConfig {"
}
]
Expand Down
26 changes: 25 additions & 1 deletion crates/liyi/src/tree_path/lang_cpp.rs
Original file line number Diff line number Diff line change
Expand Up @@ -41,6 +41,30 @@ fn cpp_node_name(node: &Node, source: &str) -> Option<String> {
}

/// C++ language configuration.
/// Detect C++ doc comments (`/** ... */` and `/// ...`).
///
/// C++'s tree-sitter grammar uses a uniform `comment` kind. We distinguish
/// doc comments by prefix: `/**` for block doc and `///` for line doc.
/// Skips `access_specifier` siblings (public/private/protected).
fn cpp_has_doc_comment(node: &Node, source: &str) -> bool {
let mut sibling = node.prev_sibling();
while let Some(s) = sibling {
match s.kind() {
"comment" => {
let text = &source[s.byte_range()];
if text.starts_with("/**") || text.starts_with("///") {
return true;
}
sibling = s.prev_sibling();
}
"access_specifier" => {
sibling = s.prev_sibling();
}
_ => break,
}
}
false
}
pub(super) static CONFIG: LanguageConfig = LanguageConfig {
ts_language: || tree_sitter_cpp::LANGUAGE.into(),
extensions: &["cpp", "cc", "cxx", "h", "hpp", "hh", "hxx", "h++", "c++"],
Expand All @@ -58,7 +82,7 @@ pub(super) static CONFIG: LanguageConfig = LanguageConfig {
name_overrides: &[],
body_fields: &["body", "declaration_list"],
custom_name: Some(cpp_node_name),
doc_comment_detector: None,
doc_comment_detector: Some(cpp_has_doc_comment),
transparent_kinds: &[],
};

Expand Down
6 changes: 3 additions & 3 deletions crates/liyi/src/tree_path/lang_cpp.rs.liyi.jsonc
Original file line number Diff line number Diff line change
Expand Up @@ -20,11 +20,11 @@
"reviewed": true,
"intent": "Define the C++ language configuration for tree_path resolution: register tree-sitter-cpp grammar, C++ file extensions (.cpp/.cc/.cxx/.hpp etc.), kind mappings for fn/class/struct/namespace/enum/template/typedef/using, wire the custom cpp_node_name callback, and no doc comment detector.",
"source_span": [
44,
63
68,
87
],
"tree_path": "static.CONFIG",
"source_hash": "sha256:435f6f5356bbbd674a5b9c72860141710adb9e43fbdaaec09fe98584eaff1e34",
"source_hash": "sha256:9214c791323abe5ab620f8622089e719f4f0f8e7966cce114cc8a3936208c458",
"source_anchor": "pub(super) static CONFIG: LanguageConfig = LanguageConfig {"
}
]
Expand Down
30 changes: 29 additions & 1 deletion crates/liyi/src/tree_path/lang_csharp.rs
Original file line number Diff line number Diff line change
@@ -1,6 +1,34 @@
use super::LanguageConfig;

use tree_sitter::Node;

/// C# language configuration.
/// Detect C# XML doc comments (`/// ...`).
///
/// C#'s tree-sitter grammar uses a uniform `comment` kind. The C# convention
/// is `///` for XML documentation comments. We also check for `/**` as some
/// projects use Javadoc-style. `attribute_list` and `modifier` siblings are
/// skipped since attributes and access modifiers may appear between the doc
/// comment and the declaration.
fn csharp_has_doc_comment(node: &Node, source: &str) -> bool {
let mut sibling = node.prev_sibling();
while let Some(s) = sibling {
match s.kind() {
"comment" => {
let text = &source[s.byte_range()];
if text.starts_with("///") || text.starts_with("/**") {
return true;
}
sibling = s.prev_sibling();
}
"attribute_list" | "modifier" => {
sibling = s.prev_sibling();
}
_ => break,
}
}
false
}
pub(super) static CONFIG: LanguageConfig = LanguageConfig {
ts_language: || tree_sitter_c_sharp::LANGUAGE.into(),
extensions: &["cs"],
Expand All @@ -20,7 +48,7 @@ pub(super) static CONFIG: LanguageConfig = LanguageConfig {
name_overrides: &[],
body_fields: &["body"],
custom_name: None,
doc_comment_detector: None,
doc_comment_detector: Some(csharp_has_doc_comment),
transparent_kinds: &[],
};

Expand Down
6 changes: 3 additions & 3 deletions crates/liyi/src/tree_path/lang_csharp.rs.liyi.jsonc
Original file line number Diff line number Diff line change
Expand Up @@ -8,11 +8,11 @@
"reviewed": true,
"intent": "Define the C# language configuration for tree_path resolution: register tree-sitter-c-sharp grammar, .cs extension, kind mappings for fn/class/interface/enum/struct/namespace/constructor/property/record/delegate, using standard name field with no custom name extraction and no doc comment detector.",
"source_span": [
4,
25
32,
53
],
"tree_path": "static.CONFIG",
"source_hash": "sha256:6c0a47b592b0b8db93bcf44a875e7e2ba199ecbf1dbf767894797972b290398b",
"source_hash": "sha256:c95d3244ecb954bd82a2f3df065dda6f2d58c18a11c277fd9600990ef4127b48",
"source_anchor": "pub(super) static CONFIG: LanguageConfig = LanguageConfig {"
}
]
Expand Down
35 changes: 34 additions & 1 deletion crates/liyi/src/tree_path/lang_kotlin.rs
Original file line number Diff line number Diff line change
Expand Up @@ -39,6 +39,39 @@ fn kotlin_node_name(node: &Node, source: &str) -> Option<String> {
}

/// Kotlin language configuration.
/// Detect Kotlin doc comments (`/** ... */` and `/// ...`).
///
/// Kotlin's tree-sitter-grammar distinguishes `block_comment` (for `/* */`
/// and `/** */`) from `line_comment` (for `//` and `///`). We check for
/// `/**` in block_comment and `///` in line_comment. `modifiers` and
/// `annotation` siblings are skipped since they may appear between the
/// doc comment and the declaration.
fn kotlin_has_doc_comment(node: &Node, source: &str) -> bool {
let mut sibling = node.prev_sibling();
while let Some(s) = sibling {
match s.kind() {
"block_comment" => {
let text = &source[s.byte_range()];
if text.starts_with("/**") {
return true;
}
sibling = s.prev_sibling();
}
"line_comment" => {
let text = &source[s.byte_range()];
if text.starts_with("///") {
return true;
}
sibling = s.prev_sibling();
}
"modifiers" | "annotation" | "annotation_list" => {
sibling = s.prev_sibling();
}
_ => break,
}
}
false
}
pub(super) static CONFIG: LanguageConfig = LanguageConfig {
ts_language: || tree_sitter_kotlin_ng::LANGUAGE.into(),
extensions: &["kt", "kts"],
Expand All @@ -53,7 +86,7 @@ pub(super) static CONFIG: LanguageConfig = LanguageConfig {
name_overrides: &[],
body_fields: &["body", "class_body"],
custom_name: Some(kotlin_node_name),
doc_comment_detector: None,
doc_comment_detector: Some(kotlin_has_doc_comment),
transparent_kinds: &[],
};

Expand Down
6 changes: 3 additions & 3 deletions crates/liyi/src/tree_path/lang_kotlin.rs.liyi.jsonc
Original file line number Diff line number Diff line change
Expand Up @@ -20,11 +20,11 @@
"reviewed": true,
"intent": "Define the Kotlin language configuration for tree_path resolution: register tree-sitter-kotlin-ng grammar, .kt/.kts extensions, kind mappings for fn/class/object/property/typealias, wire the custom kotlin_node_name callback, and no doc comment detector.",
"source_span": [
42,
58
75,
91
],
"tree_path": "static.CONFIG",
"source_hash": "sha256:c44502301bfedb32c49eb543da976a65e3dbe9b4c4d5fc7323a8c6541fe64423",
"source_hash": "sha256:868044c379a7f1e4d25d0ff81df7a26b4714d926b08b6cd708f8dbd0c292d325",
"source_anchor": "pub(super) static CONFIG: LanguageConfig = LanguageConfig {"
}
]
Expand Down
21 changes: 20 additions & 1 deletion crates/liyi/src/tree_path/lang_objc.rs
Original file line number Diff line number Diff line change
Expand Up @@ -68,6 +68,25 @@ fn objc_node_name(node: &Node, source: &str) -> Option<String> {
}

/// Objective-C language configuration.
/// Detect Objective-C doc comments (`/** ... */` and `/// ...`).
///
/// ObjC's tree-sitter grammar uses a uniform `comment` kind. We check for
/// `/**` (HeaderDoc/Javadoc) and `///` (Doxygen) prefixes.
fn objc_has_doc_comment(node: &Node, source: &str) -> bool {
let mut sibling = node.prev_sibling();
while let Some(s) = sibling {
if s.kind() == "comment" {
let text = &source[s.byte_range()];
if text.starts_with("/**") || text.starts_with("///") {
return true;
}
sibling = s.prev_sibling();
} else {
break;
}
}
false
}
pub(super) static CONFIG: LanguageConfig = LanguageConfig {
ts_language: || tree_sitter_objc::LANGUAGE.into(),
extensions: &["m", "mm"],
Expand All @@ -86,7 +105,7 @@ pub(super) static CONFIG: LanguageConfig = LanguageConfig {
name_overrides: &[],
body_fields: &["body"],
custom_name: Some(objc_node_name),
doc_comment_detector: None,
doc_comment_detector: Some(objc_has_doc_comment),
transparent_kinds: &[],
};

Expand Down
6 changes: 3 additions & 3 deletions crates/liyi/src/tree_path/lang_objc.rs.liyi.jsonc
Original file line number Diff line number Diff line change
Expand Up @@ -20,11 +20,11 @@
"reviewed": true,
"intent": "Define the Objective-C language configuration for tree_path resolution: register tree-sitter-objc grammar, .m/.mm extensions, kind mappings for fn/class/impl/protocol/method/method_decl/struct/enum/typedef, wire the custom objc_node_name callback, and no doc comment detector.",
"source_span": [
71,
91
90,
110
],
"tree_path": "static.CONFIG",
"source_hash": "sha256:34d6d1ac114bde885324b53fac1aaf04e217c62dac9f14c49c31582a51461770",
"source_hash": "sha256:036f2978cd0e40f1afde4dbca4940dac761e74bc316c96151dd1ead978b691ba",
"source_anchor": "pub(super) static CONFIG: LanguageConfig = LanguageConfig {"
}
]
Expand Down
26 changes: 25 additions & 1 deletion crates/liyi/src/tree_path/lang_php.rs
Original file line number Diff line number Diff line change
Expand Up @@ -20,6 +20,30 @@ fn php_node_name(node: &Node, source: &str) -> Option<String> {
}

/// PHP language configuration (PHP-only grammar, no HTML interleaving).
/// Detect PHPDoc comments (`/** ... */`).
///
/// PHP's tree-sitter grammar uses a uniform `comment` kind. The PHP
/// convention for documentation is `/**` (PHPDoc). `attribute_list`
/// and `modifier` siblings are skipped.
fn php_has_doc_comment(node: &Node, source: &str) -> bool {
let mut sibling = node.prev_sibling();
while let Some(s) = sibling {
match s.kind() {
"comment" => {
let text = &source[s.byte_range()];
if text.starts_with("/**") {
return true;
}
sibling = s.prev_sibling();
}
"attribute_list" | "modifier" | "visibility_modifier" => {
sibling = s.prev_sibling();
}
_ => break,
}
}
false
}
pub(super) static CONFIG: LanguageConfig = LanguageConfig {
ts_language: || tree_sitter_php::LANGUAGE_PHP_ONLY.into(),
extensions: &["php"],
Expand All @@ -37,7 +61,7 @@ pub(super) static CONFIG: LanguageConfig = LanguageConfig {
name_overrides: &[],
body_fields: &["body"],
custom_name: Some(php_node_name),
doc_comment_detector: None,
doc_comment_detector: Some(php_has_doc_comment),
transparent_kinds: &[],
};

Expand Down
6 changes: 3 additions & 3 deletions crates/liyi/src/tree_path/lang_php.rs.liyi.jsonc
Original file line number Diff line number Diff line change
Expand Up @@ -20,11 +20,11 @@
"reviewed": true,
"intent": "Define the PHP language configuration for tree_path resolution: register tree-sitter-php PHP-only grammar (no HTML interleaving), .php extension, kind mappings for fn/class/method/interface/enum/trait/namespace/const, wire the custom php_node_name callback, and no doc comment detector.",
"source_span": [
23,
42
47,
66
],
"tree_path": "static.CONFIG",
"source_hash": "sha256:834be3bf9acb078c50e1628c4053e5bb63c524b36ca61a0fadee5ddbd2e75bc4",
"source_hash": "sha256:4d7ce38edb66173371fb985d94ec5b41be0eda73de3680b4cbbe36c3e7b2477d",
"source_anchor": "pub(super) static CONFIG: LanguageConfig = LanguageConfig {"
}
]
Expand Down
Loading
Loading