Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Bug fixes #227

Merged
merged 3 commits into from
Feb 3, 2022
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
8 changes: 5 additions & 3 deletions apps/erlangbridge/src/lsp_handlers.erl
Original file line number Diff line number Diff line change
Expand Up @@ -89,7 +89,9 @@ textDocument_didChange(Socket, Params) ->
case filename:extension(File) of
".erl" ->
[ContentChange] = maps:get(contentChanges, Params),

gen_lsp_doc_server:set_document_attribute(File, contents, maps:get(text, ContentChange));
".hrl" ->
[ContentChange] = maps:get(contentChanges, Params),
gen_lsp_doc_server:set_document_attribute(File, contents, maps:get(text, ContentChange));
_ ->
ok
Expand Down Expand Up @@ -270,8 +272,8 @@ formatting(Contents) ->
file:delete(TempFile),
UpdatedContents.

-endif
-else
-endif.
-else.

formatting(Contents) ->
TempFile = mktemp(Contents),
Expand Down
8 changes: 4 additions & 4 deletions apps/erlangbridge/src/vscode_erlfmt_parse.yrl
Original file line number Diff line number Diff line change
Expand Up @@ -1005,13 +1005,13 @@ Erlang code.
-define(val(Tok), element(1, Tok)).

-define(range_anno(Tok1, Tok2), #{
location => map_get(location, ?anno(Tok1)),
end_location => map_get(end_location, ?anno(Tok2))
location => maps:get(location, ?anno(Tok1)),
end_location => maps:get(end_location, ?anno(Tok2))
}).

-define(range_upto_anno(Tok1, Tok2), #{
location => map_get(location, ?anno(Tok1)),
end_location => decrement_location(map_get(location, ?anno(Tok2)))
location => maps:get(location, ?anno(Tok1)),
end_location => decrement_location(maps:get(location, ?anno(Tok2)))
}).

%% Entry points compatible to old erl_parse.
Expand Down
6 changes: 3 additions & 3 deletions apps/erlangbridge/src/vscode_erlfmt_scan.erl
Original file line number Diff line number Diff line change
Expand Up @@ -347,17 +347,17 @@ get_inner_end_line(Anno) ->
element(1, get_anno(inner_end_location, Anno, get_anno(end_location, Anno))).

get_anno(Key, Anno) when is_map(Anno) ->
map_get(Key, Anno);
maps:get(Key, Anno);
get_anno(Key, Node) when is_tuple(Node) ->
map_get(Key, element(2, Node)).
maps:get(Key, element(2, Node)).

get_anno(Key, Anno, Default) when is_map(Anno) ->
maps:get(Key, Anno, Default);
get_anno(Key, Node, Default) when is_tuple(Node) ->
maps:get(Key, element(2, Node), Default).

update_anno(Key, Fun, Anno) when is_map(Anno) ->
Anno#{Key => Fun(map_get(Key, Anno))};
Anno#{Key => Fun(maps:get(Key, Anno))};
update_anno(Key, Fun, Node) when is_tuple(Node) ->
setelement(2, Node, update_anno(Key, Fun, element(2, Node))).

Expand Down