@@ -856,19 +856,20 @@ defmodule ElixirLS.Utils.CompletionEngine do
856
856
857
857
## Helpers
858
858
859
- # Version.match? is slow, we need to avoid it in a hot loop
860
- if Version . match? ( System . version ( ) , ">= 1.14.0-dev" ) do
861
- defp usable_as_unquoted_module? ( name ) do
862
- # Conversion to atom is not a problem because
863
- # it is only called with existing modules names.
864
- # credo:disable-for-lines:7
865
- Macro . classify_atom ( String . to_atom ( name ) ) in [ :identifier , :unquoted ] and
866
- not String . starts_with? ( name , "Elixir." )
867
- end
868
- else
869
- defp usable_as_unquoted_module? ( name ) do
870
- Code.Identifier . classify ( String . to_atom ( name ) ) != :other and
871
- not String . starts_with? ( name , "Elixir." )
859
+ defp usable_as_unquoted_module? ( name ) do
860
+ unquoted_atom_or_identifier? ( String . to_atom ( name ) ) and
861
+ not String . starts_with? ( name , "Elixir." )
862
+ end
863
+
864
+ defp unquoted_atom_or_identifier? ( atom ) when is_atom ( atom ) do
865
+ # Version.match? is slow, we need to avoid it in a hot loop
866
+ # TODO remove this when we require elixir 1.14
867
+ # Macro.classify_atom/1 was introduced in 1.14.0. If it's not available,
868
+ # assume we're on an older version and fall back to a private API.
869
+ if function_exported? ( Macro , :classify_atom , 1 ) do
870
+ apply ( Macro , :classify_atom , [ atom ] ) in [ :identifier , :unquoted ]
871
+ else
872
+ apply ( Code.Identifier , :classify , [ atom ] ) != :other
872
873
end
873
874
end
874
875
0 commit comments