-
Notifications
You must be signed in to change notification settings - Fork 136
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Better support for goto definition when parsing is incomplete (#1224)
* Better support for goto definition when parsing is incomplete * Remove els_code_actions * Use els_parser:parse_incomplete_text to preserve ranges * Fix invalid spec * Break out functions to els_incomplete_parser
- Loading branch information
Showing
9 changed files
with
150 additions
and
4 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
19 changes: 19 additions & 0 deletions
19
apps/els_lsp/priv/code_navigation/src/code_navigation_broken.erl
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,19 @@ | ||
-module(code_navigation_broken). | ||
|
||
function_a() -> | ||
ok. | ||
|
||
function_b() -> | ||
function_a() % missing comma, breaks parsing of this function! | ||
function_a(), | ||
case function_a() of | ||
ok -> | ||
function_a(), | ||
case function_a() of | ||
ok -> | ||
ok | ||
end | ||
end, | ||
function_a( | ||
), | ||
function_a(). |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,30 @@ | ||
-module(els_incomplete_parser). | ||
-export([parse_after/2]). | ||
-export([parse_line/2]). | ||
|
||
-include("els_lsp.hrl"). | ||
-include_lib("kernel/include/logger.hrl"). | ||
|
||
-spec parse_after(binary(), integer()) -> [poi()]. | ||
parse_after(Text, Line) -> | ||
{_, AfterText} = els_text:split_at_line(Text, Line), | ||
{ok, POIs} = els_parser:parse(AfterText), | ||
POIs. | ||
|
||
-spec parse_line(binary(), integer()) -> [poi()]. | ||
parse_line(Text, Line) -> | ||
LineText0 = string:trim(els_text:line(Text, Line), trailing, ",;"), | ||
case els_parser:parse(LineText0) of | ||
{ok, []} -> | ||
LineStr = els_utils:to_list(LineText0), | ||
case lists:reverse(LineStr) of | ||
"fo " ++ _ -> %% Kludge to parse "case foo() of" | ||
LineText1 = <<LineText0/binary, " _ -> _ end">>, | ||
{ok, POIs} = els_parser:parse(LineText1), | ||
POIs; | ||
_ -> | ||
[] | ||
end; | ||
{ok, POIs} -> | ||
POIs | ||
end. |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters