Skip to content

Commit

Permalink
clean up is_enabled/0 callbacks
Browse files Browse the repository at this point in the history
  • Loading branch information
the-mikedavis committed Jun 17, 2022
1 parent c955e9e commit 93f27ca
Show file tree
Hide file tree
Showing 17 changed files with 17 additions and 113 deletions.
4 changes: 0 additions & 4 deletions apps/els_lsp/src/els_call_hierarchy_provider.erl
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,6 @@
-behaviour(els_provider).

-export([
is_enabled/0,
handle_request/1
]).

Expand All @@ -16,9 +15,6 @@
%%==============================================================================
%% els_provider functions
%%==============================================================================
-spec is_enabled() -> boolean().
is_enabled() -> true.

-spec handle_request(any()) -> {response, any()}.
handle_request({prepare, Params}) ->
{Uri, Line, Char} =
Expand Down
4 changes: 0 additions & 4 deletions apps/els_lsp/src/els_code_action_provider.erl
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,6 @@
-behaviour(els_provider).

-export([
is_enabled/0,
handle_request/1
]).

Expand All @@ -12,9 +11,6 @@
%%==============================================================================
%% els_provider functions
%%==============================================================================
-spec is_enabled() -> boolean().
is_enabled() -> true.

-spec handle_request(any()) -> {response, any()}.
handle_request({document_codeaction, Params}) ->
#{
Expand Down
4 changes: 0 additions & 4 deletions apps/els_lsp/src/els_code_lens_provider.erl
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,6 @@

-behaviour(els_provider).
-export([
is_enabled/0,
options/0,
handle_request/1
]).
Expand All @@ -13,9 +12,6 @@
%%==============================================================================
%% els_provider functions
%%==============================================================================
-spec is_enabled() -> boolean().
is_enabled() -> true.

-spec options() -> map().
options() ->
#{resolveProvider => false}.
Expand Down
4 changes: 0 additions & 4 deletions apps/els_lsp/src/els_definition_provider.erl
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,6 @@
-behaviour(els_provider).

-export([
is_enabled/0,
handle_request/1
]).

Expand All @@ -12,9 +11,6 @@
%%==============================================================================
%% els_provider functions
%%==============================================================================
-spec is_enabled() -> boolean().
is_enabled() -> true.

-spec handle_request(any()) -> {response, any()}.
handle_request({definition, Params}) ->
#{
Expand Down
4 changes: 0 additions & 4 deletions apps/els_lsp/src/els_diagnostics_provider.erl
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,6 @@
-behaviour(els_provider).

-export([
is_enabled/0,
options/0,
handle_request/1
]).
Expand All @@ -22,9 +21,6 @@
%%==============================================================================
%% els_provider functions
%%==============================================================================
-spec is_enabled() -> boolean().
is_enabled() -> true.

-spec options() -> map().
options() ->
#{}.
Expand Down
4 changes: 0 additions & 4 deletions apps/els_lsp/src/els_document_highlight_provider.erl
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,6 @@
-behaviour(els_provider).

-export([
is_enabled/0,
handle_request/1
]).

Expand All @@ -15,9 +14,6 @@
%%==============================================================================
%% els_provider functions
%%==============================================================================
-spec is_enabled() -> boolean().
is_enabled() -> true.

-spec handle_request(any()) -> {response, any()}.
handle_request({document_highlight, Params}) ->
#{
Expand Down
4 changes: 0 additions & 4 deletions apps/els_lsp/src/els_document_symbol_provider.erl
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,6 @@
-behaviour(els_provider).

-export([
is_enabled/0,
handle_request/1
]).

Expand All @@ -12,9 +11,6 @@
%%==============================================================================
%% els_provider functions
%%==============================================================================
-spec is_enabled() -> boolean().
is_enabled() -> true.

-spec handle_request(any()) -> {response, any()}.
handle_request({document_symbol, Params}) ->
#{<<"textDocument">> := #{<<"uri">> := Uri}} = Params,
Expand Down
4 changes: 0 additions & 4 deletions apps/els_lsp/src/els_execute_command_provider.erl
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,6 @@
-behaviour(els_provider).

-export([
is_enabled/0,
options/0,
handle_request/1
]).
Expand All @@ -17,9 +16,6 @@
%%==============================================================================
%% els_provider functions
%%==============================================================================
-spec is_enabled() -> boolean().
is_enabled() -> true.

-spec options() -> map().
options() ->
#{
Expand Down
4 changes: 0 additions & 4 deletions apps/els_lsp/src/els_folding_range_provider.erl
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,6 @@
-include("els_lsp.hrl").

-export([
is_enabled/0,
handle_request/1
]).

Expand All @@ -17,9 +16,6 @@
%%==============================================================================
%% els_provider functions
%%==============================================================================
-spec is_enabled() -> boolean().
is_enabled() -> true.

-spec handle_request(tuple()) -> {response, folding_range_result()}.
handle_request({document_foldingrange, Params}) ->
#{<<"textDocument">> := #{<<"uri">> := Uri}} = Params,
Expand Down
26 changes: 4 additions & 22 deletions apps/els_lsp/src/els_formatting_provider.erl
Original file line number Diff line number Diff line change
Expand Up @@ -3,11 +3,7 @@
-behaviour(els_provider).

-export([
handle_request/1,
is_enabled/0,
is_enabled_document/0,
is_enabled_range/0,
is_enabled_on_type/0
handle_request/1
]).

%%==============================================================================
Expand All @@ -23,23 +19,6 @@
%%==============================================================================
%% els_provider functions
%%==============================================================================
%% Keep the behaviour happy
-spec is_enabled() -> boolean().
is_enabled() -> is_enabled_document().

-spec is_enabled_document() -> boolean().
is_enabled_document() -> true.

-spec is_enabled_range() -> boolean().
is_enabled_range() ->
false.

%% NOTE: because erlang_ls does not send incremental document changes
%% via `textDocument/didChange`, this kind of formatting does not
%% make sense.
-spec is_enabled_on_type() -> document_ontypeformatting_options().
is_enabled_on_type() -> false.

-spec handle_request(any()) -> {response, any()}.
handle_request({document_formatting, Params}) ->
#{
Expand All @@ -66,6 +45,9 @@ handle_request({document_rangeformatting, Params}) ->
{ok, Document} = els_utils:lookup_document(Uri),
{ok, TextEdit} = rangeformat_document(Uri, Document, Range, Options),
{response, TextEdit};
%% NOTE: because erlang_ls does not send incremental document changes
%% via `textDocument/didChange`, this kind of formatting does not
%% make sense.
handle_request({document_ontypeformatting, Params}) ->
#{
<<"position">> := #{
Expand Down
40 changes: 12 additions & 28 deletions apps/els_lsp/src/els_general_provider.erl
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,6 @@

-behaviour(els_provider).
-export([
is_enabled/0,
default_providers/0,
enabled_providers/0,
handle_request/1
Expand Down Expand Up @@ -51,9 +50,6 @@
%%==============================================================================
%% els_provider functions
%%==============================================================================
-spec is_enabled() -> boolean().
is_enabled() -> true.

-spec handle_request(
initialize_request()
| initialized_request()
Expand Down Expand Up @@ -183,34 +179,22 @@ server_capabilities() ->
triggerCharacters =>
els_signature_help_provider:trigger_characters()
},
definitionProvider =>
els_definition_provider:is_enabled(),
referencesProvider =>
els_references_provider:is_enabled(),
documentHighlightProvider =>
els_document_highlight_provider:is_enabled(),
documentSymbolProvider =>
els_document_symbol_provider:is_enabled(),
workspaceSymbolProvider =>
els_workspace_symbol_provider:is_enabled(),
codeActionProvider =>
els_code_action_provider:is_enabled(),
documentFormattingProvider =>
els_formatting_provider:is_enabled_document(),
documentRangeFormattingProvider =>
els_formatting_provider:is_enabled_range(),
foldingRangeProvider =>
els_folding_range_provider:is_enabled(),
implementationProvider =>
els_implementation_provider:is_enabled(),
definitionProvider => true,
referencesProvider => true,
documentHighlightProvider => true,
documentSymbolProvider => true,
workspaceSymbolProvider => true,
codeActionProvider => true,
documentFormattingProvider => true,
documentRangeFormattingProvider => false,
foldingRangeProvider => true,
implementationProvider => true,
executeCommandProvider =>
els_execute_command_provider:options(),
codeLensProvider =>
els_code_lens_provider:options(),
renameProvider =>
els_rename_provider:is_enabled(),
callHierarchyProvider =>
els_call_hierarchy_provider:is_enabled()
renameProvider => true,
callHierarchyProvider => true
},
EnabledProviders = enabled_providers(),
ConfiguredCapabilities =
Expand Down
5 changes: 0 additions & 5 deletions apps/els_lsp/src/els_hover_provider.erl
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,6 @@
-behaviour(els_provider).

-export([
is_enabled/0,
handle_request/1
]).

Expand All @@ -20,10 +19,6 @@
%%==============================================================================
%% els_provider functions
%%==============================================================================
-spec is_enabled() -> boolean().
is_enabled() ->
true.

-spec handle_request(any()) -> {async, uri(), pid()}.
handle_request({hover, Params}) ->
#{
Expand Down
4 changes: 0 additions & 4 deletions apps/els_lsp/src/els_implementation_provider.erl
Original file line number Diff line number Diff line change
Expand Up @@ -5,16 +5,12 @@
-include("els_lsp.hrl").

-export([
is_enabled/0,
handle_request/1
]).

%%==============================================================================
%% els_provider functions
%%==============================================================================
-spec is_enabled() -> boolean().
is_enabled() -> true.

-spec handle_request(tuple()) -> {response, [location()]}.
handle_request({implementation, Params}) ->
#{
Expand Down
4 changes: 0 additions & 4 deletions apps/els_lsp/src/els_references_provider.erl
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,6 @@
-behaviour(els_provider).

-export([
is_enabled/0,
handle_request/1
]).

Expand All @@ -26,9 +25,6 @@
%%==============================================================================
%% els_provider functions
%%==============================================================================
-spec is_enabled() -> boolean().
is_enabled() -> true.

-spec handle_request(any()) -> {response, [location()] | null}.
handle_request({references, Params}) ->
#{
Expand Down
6 changes: 1 addition & 5 deletions apps/els_lsp/src/els_rename_provider.erl
Original file line number Diff line number Diff line change
Expand Up @@ -3,8 +3,7 @@
-behaviour(els_provider).

-export([
handle_request/1,
is_enabled/0
handle_request/1
]).

%%==============================================================================
Expand All @@ -24,9 +23,6 @@
%%==============================================================================
%% els_provider functions
%%==============================================================================
-spec is_enabled() -> boolean().
is_enabled() -> true.

-spec handle_request(any()) -> {response, any()}.
handle_request({rename, Params}) ->
#{
Expand Down
5 changes: 0 additions & 5 deletions apps/els_lsp/src/els_signature_help_provider.erl
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,6 @@
-include_lib("kernel/include/logger.hrl").

-export([
is_enabled/0,
handle_request/1,
trigger_characters/0
]).
Expand All @@ -22,10 +21,6 @@ trigger_characters() ->
%%==============================================================================
%% els_provider functions
%%==============================================================================
-spec is_enabled() -> boolean().
is_enabled() ->
false.

-spec handle_request(els_provider:provider_request()) ->
{response, signature_help() | null}.
handle_request({signature_help, Params}) ->
Expand Down
4 changes: 0 additions & 4 deletions apps/els_lsp/src/els_workspace_symbol_provider.erl
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,6 @@
-behaviour(els_provider).

-export([
is_enabled/0,
handle_request/1
]).

Expand All @@ -14,9 +13,6 @@
%%==============================================================================
%% els_provider functions
%%==============================================================================
-spec is_enabled() -> boolean().
is_enabled() -> true.

-spec handle_request(any()) -> {response, any()}.
handle_request({symbol, Params}) ->
%% TODO: Version 3.15 of the protocol introduces a much nicer way of
Expand Down

0 comments on commit 93f27ca

Please sign in to comment.