fix: AvanteShowRepoMap failed to parse query for c (#2629)
Co-authored-by: pre-commit-ci-lite[bot] <117423508+pre-commit-ci-lite[bot]@users.noreply.github.com>
This commit is contained in:
@@ -2,10 +2,13 @@
|
|||||||
(function_definition
|
(function_definition
|
||||||
(storage_class_specifier) @extern
|
(storage_class_specifier) @extern
|
||||||
) @function
|
) @function
|
||||||
(class_specifier
|
(struct_specifier) @struct
|
||||||
(public) @class
|
(struct_specifier
|
||||||
(function_definition) @method
|
body: (field_declaration_list
|
||||||
) @class
|
(field_declaration
|
||||||
|
declarator: (field_identifier))? @class_variable
|
||||||
|
)
|
||||||
|
)
|
||||||
(declaration
|
(declaration
|
||||||
(storage_class_specifier) @extern
|
(storage_class_specifier) @extern
|
||||||
) @variable
|
) @variable
|
||||||
|
|||||||
@@ -1714,6 +1714,31 @@ mod tests {
|
|||||||
assert_eq!(stringified, expected);
|
assert_eq!(stringified, expected);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
#[test]
|
||||||
|
fn test_c() {
|
||||||
|
let source = r#"
|
||||||
|
#include <stdio.h>
|
||||||
|
|
||||||
|
int test_var = 2;
|
||||||
|
extern int extern_test_var;
|
||||||
|
|
||||||
|
int TestFunc(bool b) { return b ? 42 : -1; }
|
||||||
|
extern void ExternTestFunc();
|
||||||
|
|
||||||
|
struct Foo {
|
||||||
|
int a;
|
||||||
|
int b;
|
||||||
|
};
|
||||||
|
|
||||||
|
typedef int my_int;
|
||||||
|
"#;
|
||||||
|
let definitions = extract_definitions("c", source).unwrap();
|
||||||
|
let stringified = stringify_definitions(&definitions);
|
||||||
|
println!("{stringified}");
|
||||||
|
let expected = "var extern int extern_test_var;:int;var extern void ExternTestFunc();:void;class Foo{var int a;:int;var int b;:int;};";
|
||||||
|
assert_eq!(stringified, expected);
|
||||||
|
}
|
||||||
|
|
||||||
#[test]
|
#[test]
|
||||||
fn test_cpp() {
|
fn test_cpp() {
|
||||||
let source = r#"
|
let source = r#"
|
||||||
|
|||||||
Reference in New Issue
Block a user