Skip to content

Commit 965a79d

Browse files
Copybara Botfortenforge
Copybara Bot
authored andcommitted
Project import generated by Copybara.
GitOrigin-RevId: 27bf28e3d21a7b969b280acb713a692b6a2e2d2d
1 parent 17bb4a1 commit 965a79d

12 files changed

+382
-68
lines changed

Diff for: README.md

+17-17
Original file line numberDiff line numberDiff line change
@@ -74,23 +74,23 @@ Queries try to follow the [conventions established by tree-sitter.](https://tree
7474

7575
Most captures also include documentation as `@doc`. `@definition.function` and `@definition.method` also capture `@codeium.parameters`.
7676

77-
| Top-level capture | Python | TypeScript | JavaScript | Go | Java | C++ | PHP | Ruby | C# |
78-
| ------------------------- | ------ | ---------- | ---------- | --- | ---- | ----- | --- | ---- | --- |
79-
| `@definition.class` ||||||||||
80-
| `@definition.function` ||[^3] ||| N/A ||| N/A | N/A |
81-
| `@definition.method` |[^1] |[^3] ||||[^1] ||||
82-
| `@definition.constructor` |||| N/A ||||||
83-
| `@definition.interface` | N/A || N/A ||| N/A ||| |
84-
| `@definition.namespace` | N/A || N/A | N/A | N/A ||| N/A ||
85-
| `@definition.module` | N/A || N/A | N/A | N/A || N/A || N/A |
86-
| `@definition.type` | N/A || N/A || N/A ||| N/A | N/A |
87-
| `@definition.constant` ||||||||||
88-
| `@definition.enum` |||||||| N/A ||
89-
| `@definition.import` ||||||| N/A |||
90-
| `@definition.include` | N/A | N/A | N/A | N/A | N/A ||| N/A | N/A |
91-
| `@definition.package` | N/A | N/A | N/A ||| N/A | N/A | N/A | N/A |
92-
| `@reference.call` ||||||||||
93-
| `@reference.class` |[^2] |||||||||
77+
| Top-level capture | Python | TypeScript | JavaScript | Go | Java | C++ | PHP | Ruby | C# | Perl | Kotlin |
78+
| ------------------------- | ------ | ---------- | ---------- | --- | ---- | ----- | --- | ---- | --- | ----- | ------ |
79+
| `@definition.class` ||||||||||||
80+
| `@definition.function` ||[^3] ||| N/A ||| N/A | N/A |||
81+
| `@definition.method` |[^1] |[^3] ||||[^1] ||||[^1] ||
82+
| `@definition.constructor` |||| N/A ||||||||
83+
| `@definition.interface` | N/A || N/A ||| N/A ||| | N/A | |
84+
| `@definition.namespace` | N/A || N/A | N/A | N/A ||| N/A ||||
85+
| `@definition.module` | N/A || N/A | N/A | N/A || N/A || N/A | N/A | N/A |
86+
| `@definition.type` | N/A || N/A || N/A ||| N/A | N/A | N/A | N/A |
87+
| `@definition.constant` ||||||||||||
88+
| `@definition.enum` |||||||| N/A || N/A ||
89+
| `@definition.import` ||||||| N/A |||||
90+
| `@definition.include` | N/A | N/A | N/A | N/A | N/A ||| N/A | N/A | N/A | N/A |
91+
| `@definition.package` | N/A | N/A | N/A ||| N/A | N/A | N/A | N/A | N/A | N/A |
92+
| `@reference.call` ||||||||||||
93+
| `@reference.class` |[^2] |||||||||||
9494

9595
| Language | Supported injections |
9696
| -------- | ---------------------- |

Diff for: goldens/test.cpp.golden

+18
Original file line numberDiff line numberDiff line change
@@ -41,6 +41,24 @@ class Foo {
4141
}
4242
}
4343

44+
Name: Foo
45+
Parameters: ()
46+
Doc:
47+
// Constructor comment.
48+
Declaration (definition.function):
49+
Foo() = default;
50+
Lineage: [Foo]
51+
Lineage types: [class]
52+
53+
Name: Foo
54+
Parameters: (int /*unused*/)
55+
Doc:
56+
// Constructor comment.
57+
Definition (definition.function):
58+
explicit Foo(int /*unused*/) {}
59+
Lineage: [Foo]
60+
Lineage types: [class]
61+
4462
Name: foo
4563
Parameters: ()
4664
Return type: void

Diff for: goldens/test.cs.golden

+10
Original file line numberDiff line numberDiff line change
@@ -34,6 +34,8 @@ namespace Namespace {
3434
// Comment Bar
3535
public void Bar() => bar = 0;
3636
}
37+
// Comment IFoo.
38+
public interface IFoo {}
3739
}
3840

3941
Name: F
@@ -136,3 +138,11 @@ Definition (definition.method):
136138
public void Bar() => bar = 0;
137139
Lineage: [Namespace Class]
138140
Lineage types: [namespace class]
141+
142+
Name: IFoo
143+
Doc:
144+
// Comment IFoo.
145+
Definition (definition.interface):
146+
public interface IFoo {}
147+
Lineage: [Namespace]
148+
Lineage types: [namespace]

Diff for: goldens/test.kt.golden

+55
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,55 @@
1+
Name: kotlinx.coroutines
2+
Named imports:
3+
kotlinx.coroutines
4+
5+
Name: kotlinx.coroutines.sync
6+
Named imports:
7+
kotlinx.coroutines.sync
8+
9+
Name: Foo
10+
Definition (definition.class):
11+
class Foo(param1: Int, param2: Int) {
12+
/**
13+
* Constructor docstring
14+
*
15+
* @param param1
16+
* @param param2
17+
*/
18+
constructor(param1: Int, param2: Int) {}
19+
20+
/** Method docstring */
21+
fun methodWithDocstring(): void {}
22+
}
23+
24+
Name: constructor
25+
Parameters: (param1: Int, param2: Int)
26+
Doc:
27+
/**
28+
* Constructor docstring
29+
*
30+
* @param param1
31+
* @param param2
32+
*/
33+
Declaration (definition.constructor):
34+
constructor(param1: Int, param2: Int) {}
35+
Lineage: [Foo]
36+
Lineage types: [class]
37+
38+
Name: methodWithDocstring
39+
Parameters: ()
40+
Doc:
41+
/** Method docstring */
42+
Definition (definition.function):
43+
fun methodWithDocstring(): void {}
44+
Lineage: [Foo]
45+
Lineage types: [class]
46+
47+
Name: fib
48+
Parameters: (n: Int)
49+
Definition (definition.function):
50+
fun fib(n: Int): Int {
51+
if (n == 0 || n == 1) {
52+
return n
53+
}
54+
return fib(n - 1) + fib(n - 2)
55+
}

Diff for: goldens/test.pl.golden

+62
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,62 @@
1+
Name: strict
2+
Definition (definition.import):
3+
use strict 1.0;
4+
5+
Name: feature
6+
Definition (definition.import):
7+
use feature 'class';
8+
9+
Name: FooClass
10+
Definition (definition.class):
11+
class FooClass {
12+
field $someField = 42;
13+
14+
method bar {
15+
say "The answer is $someField";
16+
}
17+
}
18+
19+
Name: bar
20+
Definition (definition.function):
21+
method bar {
22+
say "The answer is $someField";
23+
}
24+
Lineage: [FooClass]
25+
Lineage types: [class]
26+
27+
Name: foo2
28+
Parameters: ()
29+
Doc:
30+
# foo2 comment
31+
Definition (definition.function):
32+
sub foo2 () {
33+
my $foo = Foo.new;
34+
$foo.bar
35+
}
36+
37+
Name: new
38+
Parameters: ($class, $firstName, $lastName)
39+
Definition (definition.function):
40+
sub new ($class, $firstName, $lastName) {
41+
bless { firstName => $firstName, lastName => $lastName }, $class
42+
}
43+
44+
Name: getFirstName
45+
Parameters: ($self)
46+
Definition (definition.function):
47+
sub getFirstName($self) {
48+
$self->{firstName}
49+
}
50+
51+
Name: Average
52+
Definition (definition.function):
53+
sub Average {
54+
# get total number of arguments passed.
55+
$n = scalar(@_);
56+
$sum = 0;
57+
foreach $item (@_) {
58+
$sum += $item;
59+
}
60+
$average = $sum / $n;
61+
return $average;
62+
}

Diff for: queries/cpp_tags.scm

+3-3
Original file line numberDiff line numberDiff line change
@@ -15,7 +15,7 @@
1515
(comment)* @doc
1616
.
1717
(_
18-
(_type_specifier) @codeium.return_type
18+
type: (_)? @codeium.return_type
1919
declarator: [
2020
(function_declarator
2121
declarator: (_) @name
@@ -64,7 +64,7 @@
6464
.
6565
(template_declaration
6666
(_
67-
(_type_specifier) @codeium.return_type
67+
type: (_)? @codeium.return_type
6868
declarator: [
6969
(function_declarator
7070
declarator: (_) @name
@@ -110,7 +110,7 @@
110110
(template_declaration
111111
(template_declaration
112112
(_
113-
(_type_specifier) @codeium.return_type
113+
type: (_)? @codeium.return_type
114114
declarator: [
115115
(function_declarator
116116
declarator: (_) @name

Diff for: queries/csharp_tags.scm

+57-48
Original file line numberDiff line numberDiff line change
@@ -4,73 +4,82 @@
44
name: (identifier) @name) @definition.namespace
55

66
(
7-
(comment)* @doc
8-
.
9-
(struct_declaration
10-
name: (identifier) @name
11-
body: (declaration_list) @body) @definition.class
12-
(#select-adjacent! @doc @definition.class)
7+
(comment)* @doc
8+
.
9+
(struct_declaration
10+
name: (identifier) @name
11+
body: (declaration_list) @body) @definition.class
12+
(#select-adjacent! @doc @definition.class)
1313
)
1414

1515
(
16-
(comment)* @doc
17-
.
18-
(record_declaration
19-
name: (identifier) @name
20-
body: (declaration_list)? @body) @definition.class
21-
(#select-adjacent! @doc @definition.class)
16+
(comment)* @doc
17+
.
18+
(record_declaration
19+
name: (identifier) @name
20+
body: (declaration_list)? @body) @definition.class
21+
(#select-adjacent! @doc @definition.class)
2222
)
2323

2424
(
25-
(comment)* @doc
26-
.
27-
(enum_declaration
28-
name: (identifier) @name
29-
body: (enum_member_declaration_list) @body) @definition.enum
30-
(#select-adjacent! @doc @definition.enum)
25+
(comment)* @doc
26+
.
27+
(enum_declaration
28+
name: (identifier) @name
29+
body: (enum_member_declaration_list) @body) @definition.enum
30+
(#select-adjacent! @doc @definition.enum)
3131
)
3232

3333
(
34-
(comment)* @doc
35-
.
36-
(class_declaration
37-
name: (identifier) @name
38-
body: (declaration_list) @body) @definition.class
39-
(#select-adjacent! @doc @definition.class)
34+
(comment)* @doc
35+
.
36+
(class_declaration
37+
name: (identifier) @name
38+
body: (declaration_list) @body) @definition.class
39+
(#select-adjacent! @doc @definition.class)
4040
)
4141

4242
(
43-
(comment)* @doc
44-
.
45-
(operator_declaration
46-
operator: _ @name
47-
body: (_) @body) @definition.method
48-
(#select-adjacent! @doc @definition.method)
43+
(comment)* @doc
44+
.
45+
(interface_declaration
46+
name: (identifier) @name
47+
body: (declaration_list) @body) @definition.interface
48+
(#select-adjacent! @doc @definition.interface)
4949
)
5050

5151
(
52-
(comment)* @doc
53-
.
54-
(constructor_declaration
55-
name: (identifier) @name
56-
body: (_) @body) @definition.constructor
57-
(#select-adjacent! @doc @definition.constructor)
52+
(comment)* @doc
53+
.
54+
(operator_declaration
55+
operator: _ @name
56+
body: (_) @body) @definition.method
57+
(#select-adjacent! @doc @definition.method)
5858
)
5959

6060
(
61-
(comment)* @doc
62-
.
63-
(destructor_declaration
64-
name: (identifier) @name
65-
body: (_) @body) @definition.destructor
66-
(#select-adjacent! @doc @definition.destructor)
61+
(comment)* @doc
62+
.
63+
(constructor_declaration
64+
name: (identifier) @name
65+
body: (_) @body) @definition.constructor
66+
(#select-adjacent! @doc @definition.constructor)
6767
)
6868

6969
(
70-
(comment)* @doc
71-
.
72-
(method_declaration
73-
name: (identifier) @name
74-
body: (_) @body) @definition.method
75-
(#select-adjacent! @doc @definition.method)
70+
(comment)* @doc
71+
.
72+
(destructor_declaration
73+
name: (identifier) @name
74+
body: (_) @body) @definition.destructor
75+
(#select-adjacent! @doc @definition.destructor)
76+
)
77+
78+
(
79+
(comment)* @doc
80+
.
81+
(method_declaration
82+
name: (identifier) @name
83+
body: (_) @body) @definition.method
84+
(#select-adjacent! @doc @definition.method)
7685
)

0 commit comments

Comments
 (0)