Skip to content

Commit 5302215

Browse files
fortenforgeCopybara Bot
andauthored
Project import generated by Copybara. (#28)
GitOrigin-RevId: 9509a8e193e25d7a4668eab40f36ecd22c7390ed Co-authored-by: Copybara Bot <[email protected]>
1 parent 17bb4a1 commit 5302215

28 files changed

+810
-70
lines changed

README.md

Lines changed: 17 additions & 17 deletions
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 | Dart | Bash | C |
78+
| ------------------------- | ------ | ---------- | ---------- | --- | ---- | ----- | --- | ---- | --- | ----- | ------ | ----- | ---- | --- |
79+
| `@definition.class` |||||||||||||||
80+
| `@definition.function` ||[^3] ||| N/A ||| N/A | N/A ||||||
81+
| `@definition.method` |[^1] |[^3] ||||[^1] ||||[^1] ||[^1] |||
82+
| `@definition.constructor` |||| N/A ||||||||| N/A | N/A |
83+
| `@definition.interface` | N/A || N/A ||| N/A ||| | N/A | || N/A | N/A |
84+
| `@definition.namespace` | N/A || N/A | N/A | 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 || N/A | N/A |
86+
| `@definition.type` | N/A || N/A || N/A ||| N/A | N/A | N/A | N/A || N/A | N/A |
87+
| `@definition.constant` ||||||||||||| N/A ||
88+
| `@definition.enum` |||||||| N/A || N/A ||| N/A ||
89+
| `@definition.import` ||||||| N/A |||||| N/A ||
90+
| `@definition.include` | N/A | N/A | N/A | 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 | N/A | N/A | N/A |
92+
| `@reference.call` |||||||||||||||
93+
| `@reference.class` |[^2] |||||||||||| N/A | N/A |
9494

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

download_parse.sh

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@
22
set -euo pipefail
33

44
cd "$(dirname "${BASH_SOURCE[0]}")"
5-
VERSION="v0.0.14"
5+
VERSION="v0.0.15"
66
rm -f parse.gz parse
77
curl -Lo parse.gz "https://github.com/Exafunction/codeium-parse/releases/download/$VERSION/parse.gz"
88
gzip -d parse.gz

goldens/test.c.golden

Lines changed: 26 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,26 @@
1+
Name: "runtime/parser.h"
2+
Definition (definition.import):
3+
#include "runtime/parser.h"
4+
5+
6+
7+
Name: parser__push
8+
Parameters: (Parser* self, StackVersion version, Tree* tree,
9+
TSStateId state)
10+
Return type: void
11+
Definition (definition.function):
12+
static void parser__push(Parser* self, StackVersion version, Tree* tree,
13+
TSStateId state) {
14+
ts_stack_push(self->stack, version, tree, false, state);
15+
ts_tree_release(tree);
16+
}
17+
18+
Name: parser__lex
19+
Parameters: (Parser* self, StackVersion version)
20+
Return type: Tree
21+
Definition (definition.function):
22+
static Tree* parser__lex(Parser* self, StackVersion version) {
23+
TSStateId parse_state = ts_stack_top_state(self->stack, version);
24+
Length start_position = ts_stack_top_position(self->stack, version);
25+
TSLexMode lex_mode = self->language->lex_modes[parse_state];
26+
}

goldens/test.cpp.golden

Lines changed: 18 additions & 0 deletions
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

goldens/test.cs.golden

Lines changed: 10 additions & 0 deletions
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]

goldens/test.dart.golden

Lines changed: 71 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,71 @@
1+
Name: foo
2+
Parameters: ()
3+
Definition (definition.function):
4+
void foo()
5+
6+
Name: bar
7+
Parameters: ()
8+
Doc:
9+
/// bar is a docstring
10+
Definition (definition.function):
11+
int bar()
12+
13+
Name: fooClassBar
14+
Parameters: ()
15+
Doc:
16+
/// FCB docstring
17+
Definition (definition.function):
18+
int fooClassBar()
19+
Lineage: [FooClass]
20+
Lineage types: [class]
21+
22+
Name: FooClass
23+
Definition (definition.class):
24+
class FooClass {
25+
int someField = 0;
26+
27+
// Constructor
28+
FooClass() {
29+
this.someField = 0;
30+
}
31+
32+
/// FCB docstring
33+
int fooClassBar() {
34+
return 0;
35+
}
36+
}
37+
38+
Name: FooMixin
39+
Definition (definition.class):
40+
mixin FooMixin {
41+
int barMixin() {
42+
return 0;
43+
}
44+
}
45+
46+
Name: barMixin
47+
Parameters: ()
48+
Definition (definition.function):
49+
int barMixin()
50+
Lineage: [FooMixin]
51+
Lineage types: [class]
52+
53+
Name: bar
54+
Parameters: ()
55+
Definition (definition.function):
56+
int bar()
57+
Lineage: [FooBar]
58+
Lineage types: [class]
59+
60+
Name: FooBar
61+
Definition (definition.class):
62+
class FooBar extends FooClass with Foo {
63+
int bar() {
64+
return 0;
65+
}
66+
}
67+
68+
Name: main
69+
Parameters: ()
70+
Definition (definition.function):
71+
void main()

goldens/test.kt.golden

Lines changed: 55 additions & 0 deletions
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+
}

goldens/test.pl.golden

Lines changed: 62 additions & 0 deletions
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+
}

goldens/test.proto.golden

Lines changed: 39 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,39 @@
1+
Name: b
2+
Definition (definition.package):
3+
package a.b;
4+
Lineage: [a]
5+
Lineage types: [package]
6+
7+
Name: TestService
8+
Declaration (definition.class):
9+
service TestService {
10+
rpc Echo(EchoRequest) returns (EchoResponse) {}
11+
}
12+
Lineage: [a b]
13+
Lineage types: [package package]
14+
15+
Name: Echo
16+
Declaration (definition.function):
17+
rpc Echo(EchoRequest) returns (EchoResponse) {}
18+
Lineage: [a b TestService]
19+
Lineage types: [package package class]
20+
21+
Name: EchoRequest
22+
Doc:
23+
// EchoRequest comment.
24+
Definition (definition.class):
25+
message EchoRequest {
26+
string message = 1;
27+
}
28+
Lineage: [a b]
29+
Lineage types: [package package]
30+
31+
Name: EchoResponse
32+
Doc:
33+
// EchoResponse comment.
34+
Definition (definition.class):
35+
message EchoResponse {
36+
string message = 1;
37+
}
38+
Lineage: [a b]
39+
Lineage types: [package package]

goldens/test.sh.golden

Lines changed: 16 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,16 @@
1+
Name: do_something
2+
Definition (definition.function):
3+
do_something() {
4+
echo ok
5+
}
6+
7+
Name: do_nothing
8+
Definition (definition.function):
9+
do_nothing() { return 0; }
10+
11+
Name: add
12+
Definition (definition.function):
13+
add() {
14+
sum=$(($1 + $2))
15+
echo $sum
16+
}

0 commit comments

Comments
 (0)