Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

complete with parens if there are remote calls #916

Merged
merged 2 commits into from
Jun 26, 2023

Conversation

oo6
Copy link
Contributor

@oo6 oo6 commented Jun 23, 2023

resolve #902

@@ -1038,7 +1039,9 @@ defmodule ElixirLS.LanguageServer.Providers.Completion do
locals_without_parens = Keyword.get(options, :locals_without_parens)
signature_help_supported? = Keyword.get(options, :signature_help_supported, false)
signature_after_complete? = Keyword.get(options, :signature_after_complete, true)
with_parens? = function_name_with_parens?(name, arity, locals_without_parens)

remote_calls? = String.contains?(prefix, ".")
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Please move this to context so the check is done once and not for every completion. Also consider using match?({:dot, _, _}, Code.Fragment.cursor_context(prefix))

iex(2)> Code.Fragment.cursor_context("a.")
{:dot, {:var, ~c"a"}, []}
iex(3)> Code.Fragment.cursor_context("a.a")
{:dot, {:var, ~c"a"}, ~c"a"}
iex(4)> Code.Fragment.cursor_context("A.a")
{:dot, {:alias, ~c"A"}, ~c"a"}
iex(5)> Code.Fragment.cursor_context("A.") 
{:dot, {:alias, ~c"A"}, []}

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

TIL, do we need to exclude a. or A.... ?

remote_calls? = match?({:dot, _, [_ | _]}, Code.Fragment.cursor_context(prefix))

Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

IMO it's good now

@lukaszsamson
Copy link
Collaborator

Thanks

@lukaszsamson lukaszsamson merged commit 5ae6425 into elixir-lsp:master Jun 26, 2023
19 checks passed
@oo6 oo6 deleted the complete-with-parens branch June 27, 2023 12:57
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Complete Map.drop inserts it without parens
2 participants