mirror of
https://github.com/livebook-dev/livebook.git
synced 2025-01-11 01:18:12 +08:00
Completion adjustments (#740)
* Show exceptions at the end of completion list * Don't complete hidden functions
This commit is contained in:
parent
18d8eccc9e
commit
ab0a237ab6
2 changed files with 13 additions and 15 deletions
|
@ -118,6 +118,12 @@ defmodule Livebook.Intellisense do
|
||||||
end
|
end
|
||||||
|
|
||||||
defp include_in_completion?({:module, _module, _display_name, :hidden}), do: false
|
defp include_in_completion?({:module, _module, _display_name, :hidden}), do: false
|
||||||
|
|
||||||
|
defp include_in_completion?(
|
||||||
|
{:function, _module, _name, _arity, _display_name, :hidden, _signatures, _specs}
|
||||||
|
),
|
||||||
|
do: false
|
||||||
|
|
||||||
defp include_in_completion?(_), do: true
|
defp include_in_completion?(_), do: true
|
||||||
|
|
||||||
defp format_completion_item({:variable, name, value}),
|
defp format_completion_item({:variable, name, value}),
|
||||||
|
@ -201,12 +207,16 @@ defmodule Livebook.Intellisense do
|
||||||
insert_text: name
|
insert_text: name
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ordered_kinds [:field, :variable, :module, :struct, :interface, :function, :type]
|
||||||
|
|
||||||
|
defp completion_item_priority(%{kind: :struct, detail: "exception"} = completion_item) do
|
||||||
|
{length(@ordered_kinds), completion_item.label}
|
||||||
|
end
|
||||||
|
|
||||||
defp completion_item_priority(completion_item) do
|
defp completion_item_priority(completion_item) do
|
||||||
{completion_item_kind_priority(completion_item.kind), completion_item.label}
|
{completion_item_kind_priority(completion_item.kind), completion_item.label}
|
||||||
end
|
end
|
||||||
|
|
||||||
@ordered_kinds [:field, :variable, :module, :struct, :interface, :function, :type]
|
|
||||||
|
|
||||||
defp completion_item_kind_priority(kind) when kind in @ordered_kinds do
|
defp completion_item_kind_priority(kind) when kind in @ordered_kinds do
|
||||||
Enum.find_index(@ordered_kinds, &(&1 == kind))
|
Enum.find_index(@ordered_kinds, &(&1 == kind))
|
||||||
end
|
end
|
||||||
|
|
|
@ -273,13 +273,6 @@ defmodule Livebook.IntellisenseTest do
|
||||||
{binding, env} = eval(do: nil)
|
{binding, env} = eval(do: nil)
|
||||||
|
|
||||||
assert [
|
assert [
|
||||||
%{
|
|
||||||
detail: "Livebook.TestModules.Hidden.hidden()",
|
|
||||||
documentation: "This is a private API",
|
|
||||||
insert_text: "hidden()",
|
|
||||||
kind: :function,
|
|
||||||
label: "hidden/0"
|
|
||||||
},
|
|
||||||
%{
|
%{
|
||||||
detail: "Livebook.TestModules.Hidden.visible()",
|
detail: "Livebook.TestModules.Hidden.visible()",
|
||||||
documentation: "No documentation available",
|
documentation: "No documentation available",
|
||||||
|
@ -287,12 +280,7 @@ defmodule Livebook.IntellisenseTest do
|
||||||
kind: :function,
|
kind: :function,
|
||||||
label: "visible/0"
|
label: "visible/0"
|
||||||
}
|
}
|
||||||
] =
|
] = Intellisense.get_completion_items("Livebook.TestModules.Hidden.", binding, env)
|
||||||
Intellisense.get_completion_items(
|
|
||||||
"Livebook.TestModules.Hidden.",
|
|
||||||
binding,
|
|
||||||
env
|
|
||||||
)
|
|
||||||
end
|
end
|
||||||
|
|
||||||
test "Elixir root submodule completion" do
|
test "Elixir root submodule completion" do
|
||||||
|
|
Loading…
Reference in a new issue