Skip to content

Commit

Permalink
Project import generated by Copybara.
Browse files Browse the repository at this point in the history
GitOrigin-RevId: 27bf28e3d21a7b969b280acb713a692b6a2e2d2d
  • Loading branch information
Copybara Bot authored and fortenforge committed Feb 23, 2024
1 parent 17bb4a1 commit 965a79d
Show file tree
Hide file tree
Showing 12 changed files with 382 additions and 68 deletions.
34 changes: 17 additions & 17 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -74,23 +74,23 @@ Queries try to follow the [conventions established by tree-sitter.](https://tree

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

| Top-level capture | Python | TypeScript | JavaScript | Go | Java | C++ | PHP | Ruby | C# |
| ------------------------- | ------ | ---------- | ---------- | --- | ---- | ----- | --- | ---- | --- |
| `@definition.class` ||||||||||
| `@definition.function` ||[^3] ||| N/A ||| N/A | N/A |
| `@definition.method` |[^1] |[^3] ||||[^1] ||||
| `@definition.constructor` |||| N/A ||||||
| `@definition.interface` | N/A || N/A ||| N/A ||| |
| `@definition.namespace` | N/A || N/A | N/A | N/A ||| N/A ||
| `@definition.module` | N/A || N/A | N/A | N/A || N/A || N/A |
| `@definition.type` | N/A || N/A || N/A ||| N/A | N/A |
| `@definition.constant` ||||||||||
| `@definition.enum` |||||||| N/A ||
| `@definition.import` ||||||| N/A |||
| `@definition.include` | N/A | N/A | N/A | N/A | N/A ||| N/A | N/A |
| `@definition.package` | N/A | N/A | N/A ||| N/A | N/A | N/A | N/A |
| `@reference.call` ||||||||||
| `@reference.class` |[^2] |||||||||
| Top-level capture | Python | TypeScript | JavaScript | Go | Java | C++ | PHP | Ruby | C# | Perl | Kotlin |
| ------------------------- | ------ | ---------- | ---------- | --- | ---- | ----- | --- | ---- | --- | ----- | ------ |
| `@definition.class` ||||||||||||
| `@definition.function` ||[^3] ||| N/A ||| N/A | N/A |||
| `@definition.method` |[^1] |[^3] ||||[^1] ||||[^1] ||
| `@definition.constructor` |||| N/A ||||||||
| `@definition.interface` | N/A || N/A ||| N/A ||| | N/A | |
| `@definition.namespace` | N/A || N/A | N/A | N/A ||| N/A ||||
| `@definition.module` | N/A || N/A | N/A | N/A || N/A || N/A | N/A | N/A |
| `@definition.type` | N/A || N/A || N/A ||| N/A | N/A | N/A | N/A |
| `@definition.constant` ||||||||||||
| `@definition.enum` |||||||| N/A || N/A ||
| `@definition.import` ||||||| N/A |||||
| `@definition.include` | N/A | N/A | N/A | N/A | N/A ||| N/A | N/A | N/A | N/A |
| `@definition.package` | N/A | N/A | N/A ||| N/A | N/A | N/A | N/A | N/A | N/A |
| `@reference.call` ||||||||||||
| `@reference.class` |[^2] |||||||||||

| Language | Supported injections |
| -------- | ---------------------- |
Expand Down
18 changes: 18 additions & 0 deletions goldens/test.cpp.golden
Original file line number Diff line number Diff line change
Expand Up @@ -41,6 +41,24 @@ class Foo {
}
}

Name: Foo
Parameters: ()
Doc:
// Constructor comment.
Declaration (definition.function):
Foo() = default;
Lineage: [Foo]
Lineage types: [class]

Name: Foo
Parameters: (int /*unused*/)
Doc:
// Constructor comment.
Definition (definition.function):
explicit Foo(int /*unused*/) {}
Lineage: [Foo]
Lineage types: [class]

Name: foo
Parameters: ()
Return type: void
Expand Down
10 changes: 10 additions & 0 deletions goldens/test.cs.golden
Original file line number Diff line number Diff line change
Expand Up @@ -34,6 +34,8 @@ namespace Namespace {
// Comment Bar
public void Bar() => bar = 0;
}
// Comment IFoo.
public interface IFoo {}
}

Name: F
Expand Down Expand Up @@ -136,3 +138,11 @@ Definition (definition.method):
public void Bar() => bar = 0;
Lineage: [Namespace Class]
Lineage types: [namespace class]

Name: IFoo
Doc:
// Comment IFoo.
Definition (definition.interface):
public interface IFoo {}
Lineage: [Namespace]
Lineage types: [namespace]
55 changes: 55 additions & 0 deletions goldens/test.kt.golden
Original file line number Diff line number Diff line change
@@ -0,0 +1,55 @@
Name: kotlinx.coroutines
Named imports:
kotlinx.coroutines

Name: kotlinx.coroutines.sync
Named imports:
kotlinx.coroutines.sync

Name: Foo
Definition (definition.class):
class Foo(param1: Int, param2: Int) {
/**
* Constructor docstring
*
* @param param1
* @param param2
*/
constructor(param1: Int, param2: Int) {}

/** Method docstring */
fun methodWithDocstring(): void {}
}

Name: constructor
Parameters: (param1: Int, param2: Int)
Doc:
/**
* Constructor docstring
*
* @param param1
* @param param2
*/
Declaration (definition.constructor):
constructor(param1: Int, param2: Int) {}
Lineage: [Foo]
Lineage types: [class]

Name: methodWithDocstring
Parameters: ()
Doc:
/** Method docstring */
Definition (definition.function):
fun methodWithDocstring(): void {}
Lineage: [Foo]
Lineage types: [class]

Name: fib
Parameters: (n: Int)
Definition (definition.function):
fun fib(n: Int): Int {
if (n == 0 || n == 1) {
return n
}
return fib(n - 1) + fib(n - 2)
}
62 changes: 62 additions & 0 deletions goldens/test.pl.golden
Original file line number Diff line number Diff line change
@@ -0,0 +1,62 @@
Name: strict
Definition (definition.import):
use strict 1.0;

Name: feature
Definition (definition.import):
use feature 'class';

Name: FooClass
Definition (definition.class):
class FooClass {
field $someField = 42;

method bar {
say "The answer is $someField";
}
}

Name: bar
Definition (definition.function):
method bar {
say "The answer is $someField";
}
Lineage: [FooClass]
Lineage types: [class]

Name: foo2
Parameters: ()
Doc:
# foo2 comment
Definition (definition.function):
sub foo2 () {
my $foo = Foo.new;
$foo.bar
}

Name: new
Parameters: ($class, $firstName, $lastName)
Definition (definition.function):
sub new ($class, $firstName, $lastName) {
bless { firstName => $firstName, lastName => $lastName }, $class
}

Name: getFirstName
Parameters: ($self)
Definition (definition.function):
sub getFirstName($self) {
$self->{firstName}
}

Name: Average
Definition (definition.function):
sub Average {
# get total number of arguments passed.
$n = scalar(@_);
$sum = 0;
foreach $item (@_) {
$sum += $item;
}
$average = $sum / $n;
return $average;
}
6 changes: 3 additions & 3 deletions queries/cpp_tags.scm
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@
(comment)* @doc
.
(_
(_type_specifier) @codeium.return_type
type: (_)? @codeium.return_type
declarator: [
(function_declarator
declarator: (_) @name
Expand Down Expand Up @@ -64,7 +64,7 @@
.
(template_declaration
(_
(_type_specifier) @codeium.return_type
type: (_)? @codeium.return_type
declarator: [
(function_declarator
declarator: (_) @name
Expand Down Expand Up @@ -110,7 +110,7 @@
(template_declaration
(template_declaration
(_
(_type_specifier) @codeium.return_type
type: (_)? @codeium.return_type
declarator: [
(function_declarator
declarator: (_) @name
Expand Down
105 changes: 57 additions & 48 deletions queries/csharp_tags.scm
Original file line number Diff line number Diff line change
Expand Up @@ -4,73 +4,82 @@
name: (identifier) @name) @definition.namespace

(
(comment)* @doc
.
(struct_declaration
name: (identifier) @name
body: (declaration_list) @body) @definition.class
(#select-adjacent! @doc @definition.class)
(comment)* @doc
.
(struct_declaration
name: (identifier) @name
body: (declaration_list) @body) @definition.class
(#select-adjacent! @doc @definition.class)
)

(
(comment)* @doc
.
(record_declaration
name: (identifier) @name
body: (declaration_list)? @body) @definition.class
(#select-adjacent! @doc @definition.class)
(comment)* @doc
.
(record_declaration
name: (identifier) @name
body: (declaration_list)? @body) @definition.class
(#select-adjacent! @doc @definition.class)
)

(
(comment)* @doc
.
(enum_declaration
name: (identifier) @name
body: (enum_member_declaration_list) @body) @definition.enum
(#select-adjacent! @doc @definition.enum)
(comment)* @doc
.
(enum_declaration
name: (identifier) @name
body: (enum_member_declaration_list) @body) @definition.enum
(#select-adjacent! @doc @definition.enum)
)

(
(comment)* @doc
.
(class_declaration
name: (identifier) @name
body: (declaration_list) @body) @definition.class
(#select-adjacent! @doc @definition.class)
(comment)* @doc
.
(class_declaration
name: (identifier) @name
body: (declaration_list) @body) @definition.class
(#select-adjacent! @doc @definition.class)
)

(
(comment)* @doc
.
(operator_declaration
operator: _ @name
body: (_) @body) @definition.method
(#select-adjacent! @doc @definition.method)
(comment)* @doc
.
(interface_declaration
name: (identifier) @name
body: (declaration_list) @body) @definition.interface
(#select-adjacent! @doc @definition.interface)
)

(
(comment)* @doc
.
(constructor_declaration
name: (identifier) @name
body: (_) @body) @definition.constructor
(#select-adjacent! @doc @definition.constructor)
(comment)* @doc
.
(operator_declaration
operator: _ @name
body: (_) @body) @definition.method
(#select-adjacent! @doc @definition.method)
)

(
(comment)* @doc
.
(destructor_declaration
name: (identifier) @name
body: (_) @body) @definition.destructor
(#select-adjacent! @doc @definition.destructor)
(comment)* @doc
.
(constructor_declaration
name: (identifier) @name
body: (_) @body) @definition.constructor
(#select-adjacent! @doc @definition.constructor)
)

(
(comment)* @doc
.
(method_declaration
name: (identifier) @name
body: (_) @body) @definition.method
(#select-adjacent! @doc @definition.method)
(comment)* @doc
.
(destructor_declaration
name: (identifier) @name
body: (_) @body) @definition.destructor
(#select-adjacent! @doc @definition.destructor)
)

(
(comment)* @doc
.
(method_declaration
name: (identifier) @name
body: (_) @body) @definition.method
(#select-adjacent! @doc @definition.method)
)
Loading

0 comments on commit 965a79d

Please sign in to comment.