Skip to content

Commit

Permalink
format
Browse files Browse the repository at this point in the history
  • Loading branch information
lukaszsamson committed Jan 1, 2024
1 parent 019426d commit 46c8766
Show file tree
Hide file tree
Showing 3 changed files with 29 additions and 19 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -3,23 +3,27 @@ defmodule ElixirLS.LanguageServer.Dialyzer.SuccessTypings do
require Logger

def suggest_contracts(plt, files) do
{us, results} = :timer.tc(fn ->
modules =
plt
|> :dialyzer_plt.all_modules()
|> :sets.to_list()
{us, results} =
:timer.tc(fn ->
modules =
plt
|> :dialyzer_plt.all_modules()
|> :sets.to_list()

for mod <- modules,
file = source(mod),
file in files,
docs = ElixirSense.Core.Normalized.Code.get_docs(mod, :docs),
{{^mod, fun, arity} = mfa, success_typing} <- success_typings(plt, mod),
:dialyzer_plt.lookup_contract(plt, mfa) == :none,
{stripped_fun, stripped_arity} = SourceFile.strip_macro_prefix({fun, arity}),
line = SourceFile.function_line(mod, stripped_fun, stripped_arity, docs),
is_integer(line) and line > 0,
do:
{file, line, {mod, stripped_fun, stripped_arity}, success_typing,
stripped_fun != fun}
end)

for mod <- modules,
file = source(mod),
file in files,
docs = ElixirSense.Core.Normalized.Code.get_docs(mod, :docs),
{{^mod, fun, arity} = mfa, success_typing} <- success_typings(plt, mod),
:dialyzer_plt.lookup_contract(plt, mfa) == :none,
{stripped_fun, stripped_arity} = SourceFile.strip_macro_prefix({fun, arity}),
line = SourceFile.function_line(mod, stripped_fun, stripped_arity, docs),
is_integer(line) and line > 0,
do: {file, line, {mod, stripped_fun, stripped_arity}, success_typing, stripped_fun != fun}
end)
Logger.info("Success typings computed in #{div(us, 1000)}ms")
results
end
Expand Down
3 changes: 2 additions & 1 deletion apps/language_server/lib/language_server/parser.ex
Original file line number Diff line number Diff line change
Expand Up @@ -97,6 +97,7 @@ defmodule ElixirLS.LanguageServer.Parser do
_other ->
ElixirLS.LanguageServer.Server.do_sanity_check()
message = Exception.format_exit(reason)

JsonRpc.telemetry(
"lsp_server_error",
%{
Expand Down Expand Up @@ -152,7 +153,7 @@ defmodule ElixirLS.LanguageServer.Parser do
when current_version > old_version ->
%Context{old_file | source_file: source_file}

%Context{source_file: %SourceFile{version: old_version}} = old_file ->
%Context{} = old_file ->
old_file
end)

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -421,7 +421,10 @@ defmodule ElixirLS.LanguageServer.Providers.WorkspaceSymbols do
|> do_process_chunked(fn chunk ->
for {module, path} <- chunk,
Code.ensure_loaded?(module),
docs = if(not String.ends_with?(path, ".erl"), do: ElixirSense.Core.Normalized.Code.get_docs(module, :docs)),
docs =
if(not String.ends_with?(path, ".erl"),
do: ElixirSense.Core.Normalized.Code.get_docs(module, :docs)
),
{function, arity} <- module.module_info(:exports) do
{function, arity} = SourceFile.strip_macro_prefix({function, arity})
location = find_function_location(module, function, arity, path, docs)
Expand Down Expand Up @@ -473,7 +476,9 @@ defmodule ElixirLS.LanguageServer.Providers.WorkspaceSymbols do

send(self, {:indexing_complete, key, results})

Logger.info("[ElixirLS WorkspaceSymbols] #{length(results)} #{key} added to index in #{div(us, 1000)}ms")
Logger.info(
"[ElixirLS WorkspaceSymbols] #{length(results)} #{key} added to index in #{div(us, 1000)}ms"
)
end)

:ok
Expand Down

0 comments on commit 46c8766

Please sign in to comment.