@@ -850,19 +850,18 @@ defmodule ElixirSense.Providers.Completion.CompletionEngine do
850850
851851 ## Helpers
852852
853- # Version.match? is slow, we need to avoid it in a hot loop
854- if Version . match? ( System . version ( ) , ">= 1.14.0-dev" ) do
855- defp usable_as_unquoted_module? ( name ) do
856- # Conversion to atom is not a problem because
857- # it is only called with existing modules names.
858- # credo:disable-for-lines:7
859- Macro . classify_atom ( String . to_atom ( name ) ) in [ :identifier , :unquoted ] and
860- not String . starts_with? ( name , "Elixir." )
861- end
862- else
863- defp usable_as_unquoted_module? ( name ) do
864- Code.Identifier . classify ( String . to_atom ( name ) ) != :other and
865- not String . starts_with? ( name , "Elixir." )
853+ defp usable_as_unquoted_module? ( name ) do
854+ unquoted_atom_or_identifier? ( String . to_atom ( name ) ) and
855+ not String . starts_with? ( name , "Elixir." )
856+ end
857+
858+ defp unquoted_atom_or_identifier? ( atom ) when is_atom ( atom ) do
859+ # Macro.classify_atom/1 was introduced in 1.14.0. If it's not available,
860+ # assume we're on an older version and fall back to a private API.
861+ if function_exported? ( Macro , :classify_atom , 1 ) do
862+ apply ( Macro , :classify_atom , [ atom ] ) in [ :identifier , :unquoted ]
863+ else
864+ apply ( Code.Identifier , :classify , [ atom ] ) != :other
866865 end
867866 end
868867
0 commit comments