Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion download_parse.sh
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@
set -euo pipefail

cd "$(dirname "${BASH_SOURCE[0]}")"
VERSION="v0.0.10"
VERSION="v0.0.11"
rm -f parse.gz parse
curl -Lo parse.gz "https://github.com/Exafunction/codeium-parse/releases/download/$VERSION/parse.gz"
gzip -d parse.gz
Expand Down
29 changes: 28 additions & 1 deletion goldens/test.cpp.golden
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,7 @@ struct Foo2;

Name: baz
Parameters: (const std::string& bing)
Return type: bool
Doc:
// Declaration.
Declaration (definition.function):
Expand Down Expand Up @@ -38,6 +39,7 @@ class Foo {

Name: foo
Parameters: ()
Return type: void
Doc:
// foo
// foo2
Expand All @@ -62,9 +64,34 @@ Lineage types: [unknown unknown]

Name: baz
Parameters: (const std::string& bing)
Return type: bool
Doc:
// baz
Definition (definition.function):
bool bar::baz(const std::string& bing) { return bing.empty(); }
bool bar::baz(const std::string& bing) {
// This shouldn't be recognized as a function.
Foo dist();
return bing.empty();
}
Lineage: [bar]
Lineage types: [unknown]

Name: one_pointer
Parameters: ()
Return type: bool
Doc:
// one_pointer comment
Definition (definition.function):
bool* one_pointer() { return nullptr; }
Metadata:
return_type_suffix = *

Name: two_pointer
Parameters: ()
Return type: bool
Doc:
// two_pointer comment
Definition (definition.function):
bool** two_pointer() { return nullptr; }
Metadata:
return_type_suffix = **
2 changes: 2 additions & 0 deletions goldens/test.go.golden
Original file line number Diff line number Diff line change
Expand Up @@ -25,6 +25,7 @@ Lineage types: [package]

Name: a
Parameters: ()
Return type: string
Doc:
// Hi
Declaration (definition.method):
Expand All @@ -51,6 +52,7 @@ Lineage types: [package class]

Name: Method2
Parameters: (a string)
Return type: string
Definition (definition.method):
func (p Pattern0) Method2(a string) string {
Pattern2()
Expand Down
2 changes: 1 addition & 1 deletion goldens/test.java.golden
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@ Lineage types: [package]
Name: Foo
Doc:
// Class Foo.
Declaration (definition.class):
Definition (definition.class):
public class Foo {
/** Foo1. */
static public void foo1(int x) {}
Expand Down
19 changes: 19 additions & 0 deletions queries/cpp_class_fields.scm
Original file line number Diff line number Diff line change
@@ -0,0 +1,19 @@
(
(class_specifier
body: (
(field_declaration_list
(_) @field
)
)
)
)

(
(struct_specifier
body: (
(field_declaration_list
_ @field
)
)
)
)
51 changes: 45 additions & 6 deletions queries/cpp_tags.scm
Original file line number Diff line number Diff line change
@@ -1,12 +1,17 @@
(
(comment)* @doc
.
(_
[
"struct"
"class"
]
.
(class_specifier
name: (_) @name
body: (field_declaration_list) @body
) @definition.class
(#select-adjacent! @doc @definition.class)
(#lineage-from-name! "::")
)
(
(comment)* @doc
.
(struct_specifier
name: (_) @name
body: (field_declaration_list) @body
) @definition.class
Expand All @@ -18,6 +23,7 @@
(comment)* @doc
.
(_
(_type_specifier) @codeium.return_type
declarator: (function_declarator
declarator: (_) @name
parameters: (parameter_list) @codeium.parameters)
Expand All @@ -27,6 +33,39 @@
(#lineage-from-name! "::")
)

(
(comment)* @doc
.
(_
(_type_specifier) @codeium.return_type
declarator: (pointer_declarator
(function_declarator
declarator: (_) @name
parameters: (parameter_list) @codeium.parameters))
body: (_)? @body) @definition.function
(#has-type? @definition.function function_definition declaration)
(#select-adjacent! @doc @definition.function)
(#lineage-from-name! "::")
(#set! return_type_suffix "*")
)

(
(comment)* @doc
.
(_
(_type_specifier) @codeium.return_type
declarator: (pointer_declarator
(pointer_declarator
(function_declarator
declarator: (_) @name
parameters: (parameter_list) @codeium.parameters)))
body: (_)? @body) @definition.function
(#has-type? @definition.function function_definition declaration)
(#select-adjacent! @doc @definition.function)
(#lineage-from-name! "::")
(#set! return_type_suffix "**")
)

(namespace_definition
name: (_) @name
(#lineage-from-name! "::")
Expand Down
9 changes: 9 additions & 0 deletions queries/go_class_fields.scm
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
(type_declaration
(type_spec
type: (struct_type
(field_declaration_list
(field_declaration) @field
)
)
)
)
6 changes: 5 additions & 1 deletion queries/go_tags.scm
Original file line number Diff line number Diff line change
Expand Up @@ -31,6 +31,7 @@
(function_declaration
name: (identifier) @name
parameters: (parameter_list) @codeium.parameters
result: _? @codeium.return_type
body: (_)? @body) @definition.function
(#select-adjacent! @doc @definition.function)
)
Expand All @@ -45,6 +46,7 @@
type: (_) @_))
name: (field_identifier) @name
parameters: (parameter_list) @codeium.parameters
result: _? @codeium.return_type
body: (_)? @body) @definition.method
(#select-adjacent! @doc @definition.method)
(#set! codeium.lineage @_)
Expand Down Expand Up @@ -78,5 +80,7 @@
.
(method_spec
name: (field_identifier) @name
parameters: (parameter_list) @codeium.parameters) @definition.method
parameters: (parameter_list) @codeium.parameters
result: _? @codeium.return_type
) @definition.method
)
26 changes: 26 additions & 0 deletions queries/java_class_fields.scm
Original file line number Diff line number Diff line change
@@ -0,0 +1,26 @@
(class_declaration
(class_body
(field_declaration) @field
)
)
(class_declaration
(class_body
([
(constructor_declaration)
]) @codeium.constructor
)
)

(record_declaration
(formal_parameters
(formal_parameter) @field
)
)
(record_declaration
(class_body
([
(constructor_declaration)
(compact_constructor_declaration)
]) @codeium.constructor
)
)
20 changes: 19 additions & 1 deletion queries/java_tags.scm
Original file line number Diff line number Diff line change
Expand Up @@ -8,17 +8,35 @@
(#lineage-from-name! ".")
) @codeium.lineage_node

;; Class and record
(
[
(line_comment)
(block_comment)
]* @doc
.
(class_declaration
name: (identifier) @name) @definition.class
name: (identifier) @name
body: (class_body)? @body
) @definition.class
(#select-adjacent! @doc @definition.class)
)

(
[
(line_comment)
(block_comment)
]* @doc
.
(record_declaration
name: (identifier) @name
parameters: (formal_parameters) @body
body: (class_body)? @body
) @definition.class
(#select-adjacent! @doc @definition.class)
)


(
[
(line_comment)
Expand Down
19 changes: 19 additions & 0 deletions queries/javascript_class_fields.scm
Original file line number Diff line number Diff line change
@@ -0,0 +1,19 @@
(
(class_body
([
(field_definition)
]) @field
)
)

(
(comment)* @doc
.
(_
name: (property_identifier) @name
parameters: (formal_parameters) @codeium.parameters
body: (_)? @body) @codeium.constructor
(#eq? @name "constructor")
(#has-type? @codeium.constructor method_definition method_signature abstract_method_signature)
(#select-adjacent! @doc @codeium.constructor)
)
12 changes: 12 additions & 0 deletions queries/python_class_fields.scm
Original file line number Diff line number Diff line change
@@ -0,0 +1,12 @@
(class_definition
body: (block (expression_statement
(assignment) @field
))
)
(
(function_definition
name: (identifier) @name
parameters: (parameters) @codeium.parameters
body: (block . (expression_statement . (string) @doc .)?) @body) @codeium.constructor
(#eq? @name "__init__")
)
1 change: 1 addition & 0 deletions queries/python_tags.scm
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,7 @@
parameters: (parameters) @codeium.parameters
body: (block . (expression_statement . (string) @doc .)?) @body) @definition.function
(#not-has-parent? @definition.function decorated_definition)
(#not-eq? @name "__init__")
)

;; 2. Pattern 2 from tags.scm.
Expand Down
35 changes: 35 additions & 0 deletions queries/typescript_class_fields.scm
Original file line number Diff line number Diff line change
@@ -0,0 +1,35 @@
;; For class_declaration
(
(class_body
([
(public_field_definition)
]) @field
)
)
;; For type_alias_declaration and interface_declaration, whose body is an object_type
(
(object_type
[
(property_signature) @field
(construct_signature) @codeium.constructor
(_)
]
)
)

(
(comment)* @doc
.
(_
name: (property_identifier) @name
parameters: (formal_parameters) @codeium.parameters
return_type: ([
(type_annotation (_) @codeium.return_type)
(asserts (_) @codeium.return_type)
(type_predicate_annotation (_) @codeium.return_type)
])?
body: (_)? @body) @codeium.constructor
(#eq? @name "constructor")
(#has-type? @codeium.constructor method_definition method_signature abstract_method_signature)
(#select-adjacent! @doc @codeium.constructor)
)
Loading