Skip to content

Commit

Permalink
increase timeout
Browse files Browse the repository at this point in the history
return dummy metadata for not supported language ids (e.g. phoenix-heex)
  • Loading branch information
lukaszsamson committed Dec 24, 2023
1 parent c7c26b2 commit e3ac554
Showing 1 changed file with 13 additions and 8 deletions.
21 changes: 13 additions & 8 deletions apps/language_server/lib/language_server/parser.ex
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,11 @@ defmodule ElixirLS.LanguageServer.Parser do
require Logger

@debounce_timeout 300
@parse_timeout 30_000

@dummy_source ""
@dummy_ast Code.string_to_quoted!(@dummy_source)
@dummy_metadata ElixirSense.Core.Metadata.fill(@dummy_source, MetadataBuilder.build(@dummy_ast))

defmodule Context do
defstruct [
Expand All @@ -38,11 +43,11 @@ defmodule ElixirLS.LanguageServer.Parser do
end

def parse_immediate(uri, source_file = %SourceFile{}) do
GenServer.call(__MODULE__, {:parse_immediate, uri, source_file}, 30_000)
GenServer.call(__MODULE__, {:parse_immediate, uri, source_file}, @parse_timeout)
end

def parse_immediate(uri, source_file = %SourceFile{}, position) do
GenServer.call(__MODULE__, {:parse_immediate, uri, source_file, position}, 30_000)
GenServer.call(__MODULE__, {:parse_immediate, uri, source_file, position}, @parse_timeout)
end

@impl true
Expand Down Expand Up @@ -168,7 +173,9 @@ defmodule ElixirLS.LanguageServer.Parser do
# not parsing - respond with empty struct
reply = %Context{
source_file: source_file,
path: get_path(uri)
path: get_path(uri),
ast: @dummy_ast,
metadata: @dummy_metadata
}

{reply, state}
Expand Down Expand Up @@ -224,7 +231,9 @@ defmodule ElixirLS.LanguageServer.Parser do
# not parsing - respond with empty struct
reply = %Context{
source_file: source_file,
path: get_path(uri)
path: get_path(uri),
ast: @dummy_ast,
metadata: @dummy_metadata
}

{reply, state}
Expand Down Expand Up @@ -259,10 +268,6 @@ defmodule ElixirLS.LanguageServer.Parser do
source_file.language_id in ["elixir", "eex", "html-eex"]
end

@dummy_source ""
@dummy_ast Code.string_to_quoted!(@dummy_source)
@dummy_metadata ElixirSense.Core.Metadata.fill(@dummy_source, MetadataBuilder.build(@dummy_ast))

defp maybe_fix_missing_env(
%Context{metadata: metadata, flag: flag, source_file: source_file = %SourceFile{}} =
file,
Expand Down

0 comments on commit e3ac554

Please sign in to comment.