Skip to content

Commit

Permalink
Only run EDoc diagnostics on .erl files (erlang-ls#1242)
Browse files Browse the repository at this point in the history
  • Loading branch information
robertoaloi committed Mar 10, 2022
1 parent 4e288d3 commit 14d0df8
Show file tree
Hide file tree
Showing 3 changed files with 37 additions and 2 deletions.
14 changes: 14 additions & 0 deletions apps/els_lsp/priv/code_navigation/src/code_navigation.app.src
Original file line number Diff line number Diff line change
@@ -0,0 +1,14 @@
{application, code_navigation, [
{description, "Erlang LS - Test App"},
{vsn, git},
{registered, []},
{applications, [
kernel,
stdlib
]},
{env, []},
{modules, []},
{maintainers, []},
{licenses, ["Apache 2.0"]},
{links, []}
]}.
9 changes: 9 additions & 0 deletions apps/els_lsp/src/els_edoc_diagnostics.erl
Original file line number Diff line number Diff line change
Expand Up @@ -41,6 +41,15 @@ is_default() ->
%% warnings and errors.
-spec run(uri()) -> [els_diagnostics:diagnostic()].
run(Uri) ->
case filename:extension(Uri) of
<<".erl">> ->
do_run(Uri);
_ ->
[]
end.

-spec do_run(uri()) -> [els_diagnostics:diagnostic()].
do_run(Uri) ->
Paths = [els_utils:to_list(els_uri:path(Uri))],
Fun = fun(Dir) ->
Options = edoc_options(Dir),
Expand Down
16 changes: 14 additions & 2 deletions apps/els_lsp/test/els_diagnostics_SUITE.erl
Original file line number Diff line number Diff line change
Expand Up @@ -44,6 +44,7 @@
, module_name_check/1
, module_name_check_whitespace/1
, edoc_main/1
, edoc_skip_app_src/1
]).

%%==============================================================================
Expand Down Expand Up @@ -126,7 +127,8 @@ init_per_testcase(TestCase, Config) when TestCase =:= gradualizer ->
meck:expect(els_gradualizer_diagnostics, is_default, 0, true),
els_mock_diagnostics:setup(),
els_test_utils:init_per_testcase(TestCase, Config);
init_per_testcase(TestCase, Config) when TestCase =:= edoc_main ->
init_per_testcase(TestCase, Config) when TestCase =:= edoc_main;
TestCase =:= edoc_skip_app_src ->
meck:new(els_edoc_diagnostics, [passthrough, no_link]),
meck:expect(els_edoc_diagnostics, is_default, 0, true),
els_mock_diagnostics:setup(),
Expand Down Expand Up @@ -172,7 +174,8 @@ end_per_testcase(TestCase, Config) when TestCase =:= gradualizer ->
els_test_utils:end_per_testcase(TestCase, Config),
els_mock_diagnostics:teardown(),
ok;
end_per_testcase(TestCase, Config) when TestCase =:= edoc_main ->
end_per_testcase(TestCase, Config) when TestCase =:= edoc_main;
TestCase =:= edoc_skip_app_src ->
meck:unload(els_edoc_diagnostics),
els_test_utils:end_per_testcase(TestCase, Config),
els_mock_diagnostics:teardown(),
Expand Down Expand Up @@ -716,6 +719,15 @@ edoc_main(_Config) ->
Hints = [],
els_test:run_diagnostics_test(Path, Source, Errors, Warnings, Hints).

-spec edoc_skip_app_src(config()) -> ok.
edoc_skip_app_src(_Config) ->
Path = src_path("code_navigation.app.src"),
Source = <<"Edoc">>,
Errors = [],
Warnings = [],
Hints = [],
els_test:run_diagnostics_test(Path, Source, Errors, Warnings, Hints).

%%==============================================================================
%% Internal Functions
%%==============================================================================
Expand Down

0 comments on commit 14d0df8

Please sign in to comment.