Skip to content

Commit 2ac0dca

Browse files
pqnCopybara Bot
andauthored
Project import generated by Copybara. (#19)
GitOrigin-RevId: b6543158eaf5d247afad402a2b2f583721bec226 Co-authored-by: Copybara Bot <[email protected]>
1 parent dba2dc9 commit 2ac0dca

16 files changed

+250
-19
lines changed

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.10"
5+
VERSION="v0.0.11"
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: 28 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -10,6 +10,7 @@ struct Foo2;
1010

1111
Name: baz
1212
Parameters: (const std::string& bing)
13+
Return type: bool
1314
Doc:
1415
// Declaration.
1516
Declaration (definition.function):
@@ -38,6 +39,7 @@ class Foo {
3839

3940
Name: foo
4041
Parameters: ()
42+
Return type: void
4143
Doc:
4244
// foo
4345
// foo2
@@ -62,9 +64,34 @@ Lineage types: [unknown unknown]
6264

6365
Name: baz
6466
Parameters: (const std::string& bing)
67+
Return type: bool
6568
Doc:
6669
// baz
6770
Definition (definition.function):
68-
bool bar::baz(const std::string& bing) { return bing.empty(); }
71+
bool bar::baz(const std::string& bing) {
72+
// This shouldn't be recognized as a function.
73+
Foo dist();
74+
return bing.empty();
75+
}
6976
Lineage: [bar]
7077
Lineage types: [unknown]
78+
79+
Name: one_pointer
80+
Parameters: ()
81+
Return type: bool
82+
Doc:
83+
// one_pointer comment
84+
Definition (definition.function):
85+
bool* one_pointer() { return nullptr; }
86+
Metadata:
87+
return_type_suffix = *
88+
89+
Name: two_pointer
90+
Parameters: ()
91+
Return type: bool
92+
Doc:
93+
// two_pointer comment
94+
Definition (definition.function):
95+
bool** two_pointer() { return nullptr; }
96+
Metadata:
97+
return_type_suffix = **

goldens/test.go.golden

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -25,6 +25,7 @@ Lineage types: [package]
2525

2626
Name: a
2727
Parameters: ()
28+
Return type: string
2829
Doc:
2930
// Hi
3031
Declaration (definition.method):
@@ -51,6 +52,7 @@ Lineage types: [package class]
5152

5253
Name: Method2
5354
Parameters: (a string)
55+
Return type: string
5456
Definition (definition.method):
5557
func (p Pattern0) Method2(a string) string {
5658
Pattern2()

goldens/test.java.golden

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,7 @@ Lineage types: [package]
77
Name: Foo
88
Doc:
99
// Class Foo.
10-
Declaration (definition.class):
10+
Definition (definition.class):
1111
public class Foo {
1212
/** Foo1. */
1313
static public void foo1(int x) {}

queries/cpp_class_fields.scm

Lines changed: 19 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,19 @@
1+
(
2+
(class_specifier
3+
body: (
4+
(field_declaration_list
5+
(_) @field
6+
)
7+
)
8+
)
9+
)
10+
11+
(
12+
(struct_specifier
13+
body: (
14+
(field_declaration_list
15+
_ @field
16+
)
17+
)
18+
)
19+
)

queries/cpp_tags.scm

Lines changed: 45 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -1,12 +1,17 @@
11
(
22
(comment)* @doc
33
.
4-
(_
5-
[
6-
"struct"
7-
"class"
8-
]
9-
.
4+
(class_specifier
5+
name: (_) @name
6+
body: (field_declaration_list) @body
7+
) @definition.class
8+
(#select-adjacent! @doc @definition.class)
9+
(#lineage-from-name! "::")
10+
)
11+
(
12+
(comment)* @doc
13+
.
14+
(struct_specifier
1015
name: (_) @name
1116
body: (field_declaration_list) @body
1217
) @definition.class
@@ -18,6 +23,7 @@
1823
(comment)* @doc
1924
.
2025
(_
26+
(_type_specifier) @codeium.return_type
2127
declarator: (function_declarator
2228
declarator: (_) @name
2329
parameters: (parameter_list) @codeium.parameters)
@@ -27,6 +33,39 @@
2733
(#lineage-from-name! "::")
2834
)
2935

36+
(
37+
(comment)* @doc
38+
.
39+
(_
40+
(_type_specifier) @codeium.return_type
41+
declarator: (pointer_declarator
42+
(function_declarator
43+
declarator: (_) @name
44+
parameters: (parameter_list) @codeium.parameters))
45+
body: (_)? @body) @definition.function
46+
(#has-type? @definition.function function_definition declaration)
47+
(#select-adjacent! @doc @definition.function)
48+
(#lineage-from-name! "::")
49+
(#set! return_type_suffix "*")
50+
)
51+
52+
(
53+
(comment)* @doc
54+
.
55+
(_
56+
(_type_specifier) @codeium.return_type
57+
declarator: (pointer_declarator
58+
(pointer_declarator
59+
(function_declarator
60+
declarator: (_) @name
61+
parameters: (parameter_list) @codeium.parameters)))
62+
body: (_)? @body) @definition.function
63+
(#has-type? @definition.function function_definition declaration)
64+
(#select-adjacent! @doc @definition.function)
65+
(#lineage-from-name! "::")
66+
(#set! return_type_suffix "**")
67+
)
68+
3069
(namespace_definition
3170
name: (_) @name
3271
(#lineage-from-name! "::")

queries/go_class_fields.scm

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,9 @@
1+
(type_declaration
2+
(type_spec
3+
type: (struct_type
4+
(field_declaration_list
5+
(field_declaration) @field
6+
)
7+
)
8+
)
9+
)

queries/go_tags.scm

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -31,6 +31,7 @@
3131
(function_declaration
3232
name: (identifier) @name
3333
parameters: (parameter_list) @codeium.parameters
34+
result: _? @codeium.return_type
3435
body: (_)? @body) @definition.function
3536
(#select-adjacent! @doc @definition.function)
3637
)
@@ -45,6 +46,7 @@
4546
type: (_) @_))
4647
name: (field_identifier) @name
4748
parameters: (parameter_list) @codeium.parameters
49+
result: _? @codeium.return_type
4850
body: (_)? @body) @definition.method
4951
(#select-adjacent! @doc @definition.method)
5052
(#set! codeium.lineage @_)
@@ -78,5 +80,7 @@
7880
.
7981
(method_spec
8082
name: (field_identifier) @name
81-
parameters: (parameter_list) @codeium.parameters) @definition.method
83+
parameters: (parameter_list) @codeium.parameters
84+
result: _? @codeium.return_type
85+
) @definition.method
8286
)

queries/java_class_fields.scm

Lines changed: 26 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,26 @@
1+
(class_declaration
2+
(class_body
3+
(field_declaration) @field
4+
)
5+
)
6+
(class_declaration
7+
(class_body
8+
([
9+
(constructor_declaration)
10+
]) @codeium.constructor
11+
)
12+
)
13+
14+
(record_declaration
15+
(formal_parameters
16+
(formal_parameter) @field
17+
)
18+
)
19+
(record_declaration
20+
(class_body
21+
([
22+
(constructor_declaration)
23+
(compact_constructor_declaration)
24+
]) @codeium.constructor
25+
)
26+
)

queries/java_tags.scm

Lines changed: 19 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -8,17 +8,35 @@
88
(#lineage-from-name! ".")
99
) @codeium.lineage_node
1010

11+
;; Class and record
1112
(
1213
[
1314
(line_comment)
1415
(block_comment)
1516
]* @doc
1617
.
1718
(class_declaration
18-
name: (identifier) @name) @definition.class
19+
name: (identifier) @name
20+
body: (class_body)? @body
21+
) @definition.class
22+
(#select-adjacent! @doc @definition.class)
23+
)
24+
25+
(
26+
[
27+
(line_comment)
28+
(block_comment)
29+
]* @doc
30+
.
31+
(record_declaration
32+
name: (identifier) @name
33+
parameters: (formal_parameters) @body
34+
body: (class_body)? @body
35+
) @definition.class
1936
(#select-adjacent! @doc @definition.class)
2037
)
2138

39+
2240
(
2341
[
2442
(line_comment)

0 commit comments

Comments
 (0)