Skip to content

Commit

Permalink
optimize version check in complete
Browse files Browse the repository at this point in the history
  • Loading branch information
lukaszsamson committed Jan 2, 2024
1 parent 9498693 commit 60f1d1e
Showing 1 changed file with 11 additions and 8 deletions.
19 changes: 11 additions & 8 deletions lib/elixir_sense/providers/suggestion/complete.ex
Original file line number Diff line number Diff line change
Expand Up @@ -756,15 +756,18 @@ defmodule ElixirSense.Providers.Suggestion.Complete do

## Helpers

defp usable_as_unquoted_module?(name) do
# Conversion to atom is not a problem because
# it is only called with existing modules names.
# credo:disable-for-lines:7
if Version.match?(System.version(), ">= 1.14.0-dev") do
apply(Macro, :classify_atom, [String.to_atom(name)]) in [:identifier, :unquoted] and
# Version.match? is slow, we need to avoid it in a hot loop
if Version.match?(System.version(), ">= 1.14.0-dev") do
defp usable_as_unquoted_module?(name) do
# Conversion to atom is not a problem because
# it is only called with existing modules names.
# credo:disable-for-lines:7
Macro.classify_atom(String.to_atom(name)) in [:identifier, :unquoted] and
not String.starts_with?(name, "Elixir.")
else
apply(Code.Identifier, :classify, [String.to_atom(name)]) != :other and
end
else
defp usable_as_unquoted_module?(name) do
Code.Identifier.classify(String.to_atom(name)) != :other and
not String.starts_with?(name, "Elixir.")
end
end
Expand Down

0 comments on commit 60f1d1e

Please sign in to comment.