mirror of
https://github.com/stevearc/aerial.nvim
synced 2024-09-16 14:34:08 +02:00
feat(ts): support for more solidity symbols (#290)
This commit is contained in:
parent
9bcfbaf7a7
commit
bed048ddef
3 changed files with 112 additions and 22 deletions
|
@ -1,15 +1,31 @@
|
|||
(contract_declaration
|
||||
name: (identifier) @name
|
||||
(#set! "kind" "Class")
|
||||
) @type
|
||||
|
||||
(contract_declaration (_
|
||||
(function_definition
|
||||
name: (identifier) @name
|
||||
(#set! "kind" "Method")
|
||||
) @type))
|
||||
|
||||
(contract_declaration (_
|
||||
(modifier_definition
|
||||
name: (identifier) @name
|
||||
(#set! "kind" "Method")
|
||||
) @type))
|
||||
|
||||
(library_declaration (_
|
||||
(function_definition
|
||||
name: (identifier) @name
|
||||
(#set! "kind" "Function")
|
||||
) @type))
|
||||
|
||||
(interface_declaration
|
||||
name: (identifier) @name
|
||||
(#set! "kind" "Interface")
|
||||
) @type
|
||||
|
||||
(interface_declaration (_
|
||||
(function_definition
|
||||
name: (identifier) @name
|
||||
|
@ -22,22 +38,31 @@
|
|||
(#set! "kind" "Function")
|
||||
) @type)
|
||||
|
||||
(contract_declaration
|
||||
name: (identifier) @name
|
||||
(#set! "kind" "Class")
|
||||
) @type
|
||||
|
||||
(interface_declaration
|
||||
name: (identifier) @name
|
||||
(#set! "kind" "Interface")
|
||||
) @type
|
||||
|
||||
(library_declaration
|
||||
name: (identifier) @name
|
||||
(#set! "kind" "Module")
|
||||
) @type
|
||||
|
||||
(event_definition
|
||||
(enum_declaration
|
||||
name: (identifier) @name
|
||||
(#set! "kind" "Function")
|
||||
(#set! "kind" "Enum")
|
||||
) @type
|
||||
|
||||
(event_definition
|
||||
name: (identifier) @name
|
||||
(#set! "kind" "Event")
|
||||
) @type
|
||||
|
||||
(struct_declaration
|
||||
name: (identifier) @name
|
||||
(#set! "kind" "Struct")
|
||||
) @type
|
||||
|
||||
(constructor_definition
|
||||
("constructor") @name
|
||||
(#set! "kind" "Constructor")
|
||||
) @type
|
||||
|
||||
(state_variable_declaration
|
||||
name: (identifier) @name @type
|
||||
(#set! "kind" "Field"))
|
||||
|
|
|
@ -29,25 +29,52 @@ describe("treesitter solidity", function()
|
|||
level = 0,
|
||||
lnum = 11,
|
||||
col = 0,
|
||||
end_lnum = 16,
|
||||
end_lnum = 25,
|
||||
end_col = 1,
|
||||
children = {
|
||||
{
|
||||
kind = "Function",
|
||||
name = "Log",
|
||||
kind = "Field",
|
||||
name = "flag",
|
||||
level = 1,
|
||||
lnum = 12,
|
||||
col = 4,
|
||||
col = 9,
|
||||
end_lnum = 12,
|
||||
end_col = 13,
|
||||
},
|
||||
{
|
||||
kind = "Event",
|
||||
name = "Log",
|
||||
level = 1,
|
||||
lnum = 13,
|
||||
col = 4,
|
||||
end_lnum = 13,
|
||||
end_col = 54,
|
||||
},
|
||||
{
|
||||
kind = "Constructor",
|
||||
name = "constructor",
|
||||
level = 1,
|
||||
lnum = 15,
|
||||
col = 4,
|
||||
end_lnum = 15,
|
||||
end_col = 27,
|
||||
},
|
||||
{
|
||||
kind = "Method",
|
||||
name = "m",
|
||||
level = 1,
|
||||
lnum = 13,
|
||||
lnum = 17,
|
||||
col = 4,
|
||||
end_lnum = 15,
|
||||
end_lnum = 19,
|
||||
end_col = 5,
|
||||
},
|
||||
{
|
||||
kind = "Method",
|
||||
name = "never",
|
||||
level = 1,
|
||||
lnum = 21,
|
||||
col = 4,
|
||||
end_lnum = 24,
|
||||
end_col = 5,
|
||||
},
|
||||
},
|
||||
|
@ -56,22 +83,40 @@ describe("treesitter solidity", function()
|
|||
kind = "Interface",
|
||||
name = "I",
|
||||
level = 0,
|
||||
lnum = 18,
|
||||
lnum = 27,
|
||||
col = 0,
|
||||
end_lnum = 20,
|
||||
end_lnum = 29,
|
||||
end_col = 1,
|
||||
children = {
|
||||
{
|
||||
kind = "Function",
|
||||
name = "f",
|
||||
level = 1,
|
||||
lnum = 19,
|
||||
lnum = 28,
|
||||
col = 4,
|
||||
end_lnum = 19,
|
||||
end_lnum = 28,
|
||||
end_col = 17,
|
||||
},
|
||||
},
|
||||
},
|
||||
{
|
||||
kind = "Struct",
|
||||
name = "S",
|
||||
level = 0,
|
||||
lnum = 31,
|
||||
col = 0,
|
||||
end_lnum = 34,
|
||||
end_col = 1,
|
||||
},
|
||||
{
|
||||
kind = "Enum",
|
||||
name = "E",
|
||||
level = 0,
|
||||
lnum = 36,
|
||||
col = 0,
|
||||
end_lnum = 40,
|
||||
end_col = 1,
|
||||
},
|
||||
})
|
||||
end)
|
||||
end)
|
||||
|
|
|
@ -9,12 +9,32 @@ library a {
|
|||
}
|
||||
|
||||
contract A {
|
||||
bool flag;
|
||||
event Log(address indexed sender, string message);
|
||||
|
||||
constructor() public {}
|
||||
|
||||
function m() {
|
||||
uint x = 3 < 0 ? 2 > 1 ? 2 : 1 : 7 > 2 ? 7 : 6;
|
||||
}
|
||||
|
||||
modifier never() {
|
||||
require(false);
|
||||
_;
|
||||
}
|
||||
}
|
||||
|
||||
interface I {
|
||||
function f();
|
||||
}
|
||||
|
||||
struct S {
|
||||
uint x;
|
||||
uint y;
|
||||
}
|
||||
|
||||
enum E {
|
||||
A,
|
||||
B,
|
||||
C
|
||||
}
|
||||
|
|
Loading…
Reference in a new issue