Show function parameters in elixir outline view

Introduce a new capture in the outline query called 'context.extra', which
causes text to appear in the outline, but not in the breadcrumbs.
This commit is contained in:
Max Brunsfeld 2023-06-06 16:06:01 -07:00
parent 7aeaa84657
commit 4b9a3c66e6
6 changed files with 76 additions and 11 deletions

View file

@ -1,6 +1,4 @@
[
(call)
] @indent
(call) @indent
(_ "[" "]" @end) @indent
(_ "{" "}" @end) @indent

View file

@ -8,9 +8,19 @@
(arguments
[
(identifier) @name
(call target: (identifier) @name)
(call
target: (identifier) @name
(arguments
"(" @context.extra
_* @context.extra
")" @context.extra))
(binary_operator
left: (call target: (identifier) @name)
left: (call
target: (identifier) @name
(arguments
"(" @context.extra
_* @context.extra
")" @context.extra))
operator: "when")
])
(#match? @context "^(def|defp|defdelegate|defguard|defguardp|defmacro|defmacrop|defn|defnp)$")) @item

View file

@ -327,10 +327,10 @@ mod tests {
.map(|item| (item.text.as_str(), item.depth))
.collect::<Vec<_>>(),
&[
("function a ( )", 0),
("async function a2 ( )", 1),
("function a()", 0),
("async function a2()", 1),
("let b", 0),
("function getB ( )", 0),
("function getB()", 0),
("const d", 0),
]
);