Skip to content
This repository was archived by the owner on Nov 2, 2025. It is now read-only.

Commit 22f6c58

Browse files
pqnCopybara Bot
andauthored
Project import generated by Copybara. (#14)
GitOrigin-RevId: 6badc2cdd96138fded2ac21bd11d6cc0ad4d7a28 Co-authored-by: Copybara Bot <[email protected]>
1 parent c02228d commit 22f6c58

20 files changed

+707
-133
lines changed

README.md

Lines changed: 25 additions & 17 deletions
Original file line numberDiff line numberDiff line change
@@ -73,22 +73,24 @@ Queries try to follow the [conventions established by tree-sitter.](https://tree
7373

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

76-
| | Python | TypeScript | JavaScript | Go |
77-
| ---------------------- | ------ | ---------- | ---------- | --- |
78-
| `@definition.class` |||||
79-
| `@definition.function` ||[^3] |||
80-
| `@definition.method` |[^1] |[^3] |||
81-
| `@definition.interface` | N/A || N/A ||
82-
| `@definition.namespace` | N/A || N/A | N/A |
83-
| `@definition.module` | N/A || N/A | N/A |
84-
| `@definition.type` | N/A || N/A ||
85-
| `@definition.constant` |||||
86-
| `@definition.enum` |||||
87-
| `@definition.import` |||||
88-
| `@reference.call` |||||
89-
| `@reference.class` |[^2] ||||
90-
91-
[^1]: Currently functions and methods are not distinguished in Python.
76+
| | Python | TypeScript | JavaScript | Go | Java | C++ | PHP |
77+
| ---------------------- | ------ | ---------- | ---------- | --- | ---- | ------ | --- |
78+
| `@definition.class` ||||||||
79+
| `@definition.function` ||[^3] ||| N/A |||
80+
| `@definition.method` |[^1] |[^3] ||||[^1] ||
81+
| `@definition.interface` | N/A || N/A ||| N/A ||
82+
| `@definition.namespace` | N/A || N/A | N/A | N/A |||
83+
| `@definition.module` | N/A || N/A | N/A | N/A || N/A |
84+
| `@definition.type` | N/A || N/A || N/A |||
85+
| `@definition.constant` ||||||||
86+
| `@definition.enum` ||||||||
87+
| `@definition.import` ||||||| N/A |
88+
| `@definition.include` | N/A | N/A | N/A | N/A | N/A |||
89+
| `@definition.package` | N/A | N/A | N/A ||| N/A | N/A |
90+
| `@reference.call` ||||||||
91+
| `@reference.class` |[^2] |||||||
92+
93+
[^1]: Currently functions and methods are not distinguished.
9294
[^2]: Function calls and class instantiation are indistinguishable in Python.
9395
[^3]: Function and method signatures are captured individually in TypeScript. Therefore, the `@doc` capture may not exist on all nodes.
9496

@@ -110,6 +112,11 @@ $ ./parse -supported_predicates
110112
(#has-type? @capture node_type...)
111113
Checks if @capture has a node of any of the given types.
112114

115+
#lineage-from-name!
116+
(#lineage-from-name! "literal")
117+
If the name captures scopes, split by "literal" and retain the last element
118+
as the name. The other elements are appended to the lineage.
119+
113120
#match?/#not-match?
114121
(#match? @capture "regex")
115122
Checks if the text for @capture matches the given regular expression.
@@ -120,7 +127,7 @@ $ ./parse -supported_predicates
120127
adjacent lines).
121128

122129
#set!
123-
(#set! key value)
130+
(#set! key <@capture|"literal">)
124131
Store metadata as a side effect of a match.
125132

126133
#strip!
@@ -161,6 +168,7 @@ shell
161168
svelte
162169
swift
163170
toml
171+
tree_sitter_query
164172
tsx
165173
typescript
166174
vue

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.7"
5+
VERSION="v0.0.8"
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.cpp.golden

Lines changed: 49 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,49 @@
1+
Name: bar::bar2
2+
Definition (definition.namespace):
3+
namespace bar::bar2 {
4+
struct Foo3;
5+
}
6+
7+
Name: Foo
8+
Definition (definition.class):
9+
class Foo {
10+
public:
11+
// foo
12+
// foo2
13+
void foo() {
14+
// Do nothing.
15+
}
16+
}
17+
18+
Name: foo
19+
Parameters: ()
20+
Doc:
21+
// foo
22+
// foo2
23+
Definition (definition.function):
24+
void foo() {
25+
// Do nothing.
26+
}
27+
Lineage: [Foo]
28+
Lineage types: [class]
29+
30+
Name: Foo2
31+
Definition (definition.class):
32+
struct bar::Foo2 {}
33+
Lineage: [bar]
34+
Lineage types: [unknown]
35+
36+
Name: Foo3
37+
Definition (definition.class):
38+
struct bar::bar2::Foo3 {}
39+
Lineage: [bar bar2]
40+
Lineage types: [unknown unknown]
41+
42+
Name: baz
43+
Parameters: (const std::string& bing)
44+
Doc:
45+
// baz
46+
Definition (definition.function):
47+
bool bar::baz(const std::string& bing) { return bing.empty(); }
48+
Lineage: [bar]
49+
Lineage types: [unknown]

goldens/test.go.golden

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -27,6 +27,7 @@ Doc:
2727
Definition (definition.method):
2828
func (p *Pattern0) Method(string) {}
2929
Lineage: [*Pattern0]
30+
Lineage types: [class]
3031

3132
Name: Method2
3233
Parameters: (a string)
@@ -41,6 +42,7 @@ func (p Pattern0) Method2(a string) string {
4142
return a
4243
}
4344
Lineage: [Pattern0]
45+
Lineage types: [class]
4446

4547
Name: Pattern2
4648
Parameters: ()

goldens/test.java.golden

Lines changed: 46 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,46 @@
1+
Name: p2
2+
Definition (definition.package):
3+
package p1.p2;
4+
Lineage: [p1]
5+
Lineage types: [package]
6+
7+
Name: Foo
8+
Doc:
9+
// Class Foo.
10+
Definition (definition.class):
11+
public class Foo {
12+
/** Foo1. */
13+
static public void foo1(int x) {}
14+
}
15+
Lineage: [p1 p2]
16+
Lineage types: [package package]
17+
18+
Name: foo1
19+
Parameters: (int x)
20+
Doc:
21+
/** Foo1. */
22+
Definition (definition.method):
23+
static public void foo1(int x) {}
24+
Lineage: [p1 p2 Foo]
25+
Lineage types: [package package class]
26+
27+
Name: Bar
28+
Doc:
29+
// Interface Bar.
30+
Definition (definition.interface):
31+
interface Bar {
32+
void declarationOnly();
33+
// implementation.
34+
void implementation(float y) {}
35+
}
36+
Lineage: [p1 p2]
37+
Lineage types: [package package]
38+
39+
Name: implementation
40+
Parameters: (float y)
41+
Doc:
42+
// implementation.
43+
Definition (definition.method):
44+
void implementation(float y) {}
45+
Lineage: [p1 p2 Bar]
46+
Lineage types: [package package interface]

goldens/test.js.golden

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -56,6 +56,7 @@ pattern0(param1) {
5656
return param1;
5757
}
5858
Lineage: [Pattern1a]
59+
Lineage types: [class]
5960

6061
Name: Pattern1b
6162
Doc:

goldens/test.php.golden

Lines changed: 44 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,44 @@
1+
Name: foo
2+
Parameters: ()
3+
Definition (definition.function):
4+
function foo()
5+
{
6+
}
7+
8+
Name: FooInterface
9+
Doc:
10+
// FooInterface.
11+
Definition (definition.interface):
12+
interface FooInterface
13+
{
14+
public function encode(...$numbers);
15+
}
16+
17+
Name: FooClass
18+
Doc:
19+
// FooClass.
20+
Definition (definition.class):
21+
class FooClass implements FooInterface
22+
{
23+
/**
24+
* @param mixed $numbers
25+
* @return string
26+
*/
27+
public function encode(...$numbers)
28+
{
29+
}
30+
}
31+
32+
Name: encode
33+
Parameters: (...$numbers)
34+
Doc:
35+
/**
36+
* @param mixed $numbers
37+
* @return string
38+
*/
39+
Definition (definition.method):
40+
public function encode(...$numbers)
41+
{
42+
}
43+
Lineage: [FooClass]
44+
Lineage types: [class]

goldens/test.py.golden

Lines changed: 30 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,31 @@
1+
Name: foo
2+
Definition (definition.import):
3+
from foo import decorated1
4+
Default import: foo
5+
Named imports:
6+
decorated1
7+
8+
Name: foo
9+
Definition (definition.import):
10+
from foo import decorated2
11+
Default import: foo
12+
Named imports:
13+
decorated2
14+
15+
Name: foo
16+
Definition (definition.import):
17+
from foo import Pattern2a
18+
Default import: foo
19+
Named imports:
20+
Pattern2a
21+
22+
Name: foo
23+
Definition (definition.import):
24+
from foo import pattern2b
25+
Default import: foo
26+
Named imports:
27+
pattern2b
28+
129
Name: Pattern0
230
Doc:
331
"""Pattern 0 docstring."""
@@ -18,6 +46,7 @@ Definition (definition.function):
1846
def pattern1(self):
1947
pass
2048
Lineage: [Pattern0NoDoc]
49+
Lineage types: [class]
2150

2251
Name: pattern1
2352
Parameters: (param1)
@@ -63,6 +92,7 @@ Definition (definition.function):
6392
def decorated_method(self):
6493
"""Decorated method docstring."""
6594
Lineage: [DecoratedClass]
95+
Lineage types: [class]
6696

6797
Name: decorated_function
6898
Parameters: ()

0 commit comments

Comments
 (0)