|
1 | 1 | use std::ops::Deref;
|
2 | 2 | use tree_sitter::{Language as TsLanguage, Node, Query, QueryError, Range};
|
3 | 3 | // TODO: better api less boxing and more results
|
| 4 | +// TODO: better way to do variable assigned to function or just abondon it? (the problem is with |
| 5 | +// languages that allow mutliple assignments how do you match up only the identifiers that |
| 6 | +// corespond to functions) |
| 7 | +// TODO: we could probably use tree sitter tags? |
4 | 8 |
|
5 | 9 | #[allow(missing_debug_implementations)]
|
6 | 10 | pub struct InstatiatedLanguage<'a> {
|
@@ -290,6 +294,41 @@ construct_language!(C(tree_sitter_c::language()).[c h]?=
|
290 | 294 | (#eq? @method-name {name}))"
|
291 | 295 | );
|
292 | 296 |
|
| 297 | +#[cfg(feature = "ruby")] |
| 298 | +// TODO: also query for anonymous functions assigned to variables |
| 299 | +construct_language!(Ruby(tree_sitter_ruby::language()).[rb] ?= "method-name" => |
| 300 | +"((method name: (identifier) @method-name) @method-definition)"); |
| 301 | + |
| 302 | +#[cfg(feature = "c-sharp")] |
| 303 | +// TODO: also query for anonymous functions assigned to variables |
| 304 | +construct_language!(CSharp(tree_sitter_c_sharp::language()).[cs] ?= "method-name" => |
| 305 | +"((local_function_statement name: (identifier) @method-name) @method) |
| 306 | +((method_declaration name: (identifier) @method-name) @method)" |
| 307 | + |
| 308 | +); |
| 309 | +#[cfg(feature = "go")] |
| 310 | +// TODO: also query for anonymous functions assigned to variables |
| 311 | +// var f,y integer = func(x int) int { |
| 312 | +// return x * x |
| 313 | +// }, y |
| 314 | +// x, y := 5 |
| 315 | +// fmt.Println(foo(10)) |
| 316 | +// const f f = 5; |
| 317 | +// func main() { |
| 318 | +// empty_test(1, 2, "3") |
| 319 | +// fmt.Println("Hello World!") |
| 320 | +// } |
| 321 | +// |
| 322 | +// // doc comment |
| 323 | +// |
| 324 | +// func empty_test(c, a int, b string) { |
| 325 | +// fmt.Println("Hello World!") |
| 326 | +// } |
| 327 | +// ((var_declaration (var_spec name: (identifier) @method-name ))) |
| 328 | +// ((const_declaration)) |
| 329 | +// ((short_var_declaration)) |
| 330 | +construct_language!(Go(tree_sitter_go::language()).[go] ?= "method-name" => |
| 331 | +"((function_declaration name: (identifier) @method-name) @method-definition)"); |
293 | 332 | #[cfg(feature = "rust")]
|
294 | 333 | construct_language!(Rust(tree_sitter_rust::language()).[rs] ?= "method-name" =>
|
295 | 334 |
|
@@ -379,5 +418,11 @@ pub fn predefined_languages() -> &'static [&'static dyn SupportedLanguage] {
|
379 | 418 | &Java,
|
380 | 419 | #[cfg(feature = "ocaml")]
|
381 | 420 | &OCaml,
|
| 421 | + #[cfg(feature = "c-sharp")] |
| 422 | + &CSharp, |
| 423 | + #[cfg(feature = "go")] |
| 424 | + &Go, |
| 425 | + #[cfg(feature = "ruby")] |
| 426 | + &Ruby, |
382 | 427 | ]
|
383 | 428 | }
|
0 commit comments