Skip to content

Commit

Permalink
Merge pull request stevearc#154 from fnix2/master
Browse files Browse the repository at this point in the history
Add support for properties and fields for C# in treesitter backend
  • Loading branch information
stevearc authored Sep 29, 2022
2 parents 8709932 + 17174a1 commit 888b672
Show file tree
Hide file tree
Showing 4 changed files with 35 additions and 5 deletions.
2 changes: 2 additions & 0 deletions lua/aerial/backends/treesitter/language_kind_map.lua
Original file line number Diff line number Diff line change
Expand Up @@ -20,6 +20,8 @@ return {
struct_declaration = "Struct",
enum_declaration = "Enum",
constructor_declaration = "Constructor",
property_declaration = "Property",
field_declaration = "Field",
},
dart = {
class_definition = "Class",
Expand Down
8 changes: 8 additions & 0 deletions queries/c_sharp/aerial.scm
Original file line number Diff line number Diff line change
Expand Up @@ -15,3 +15,11 @@

(constructor_declaration
name: (identifier) @name) @type

(property_declaration
name: (identifier) @name) @type

(field_declaration
(variable_declaration
(variable_declarator
(identifier) @name))) @type
28 changes: 23 additions & 5 deletions tests/treesitter/csharp_spec.lua
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@ describe("treesitter csharp", function()
level = 0,
lnum = 1,
col = 0,
end_lnum = 4,
end_lnum = 6,
end_col = 1,
children = {
{
Expand All @@ -30,24 +30,42 @@ describe("treesitter csharp", function()
end_lnum = 3,
end_col = 25,
},
{
kind = "Property",
name = "Pr_1",
level = 1,
lnum = 4,
col = 2,
end_lnum = 4,
end_col = 24,
},
{
kind = "Field",
name = "Fl_1",
level = 1,
lnum = 5,
col = 2,
end_lnum = 5,
end_col = 18,
},
},
},
{
kind = "Enum",
name = "En_1",
level = 0,
lnum = 5,
lnum = 7,
col = 0,
end_lnum = 5,
end_lnum = 7,
end_col = 20,
},
{
kind = "Struct",
name = "St_1",
level = 0,
lnum = 6,
lnum = 8,
col = 0,
end_lnum = 6,
end_lnum = 8,
end_col = 22,
},
})
Expand Down
2 changes: 2 additions & 0 deletions tests/treesitter/csharp_test.cs
Original file line number Diff line number Diff line change
@@ -1,6 +1,8 @@
public class Cl_1 {
public Cl_1() {}
public void meth_1() {}
public int Pr_1 {get;}
public int Fl_1;
}
public enum En_1 { }
public struct St_1 { }

0 comments on commit 888b672

Please sign in to comment.