-
Notifications
You must be signed in to change notification settings - Fork 196
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
Bump sourceror dependency to v0.12.2 #841
Changes from all commits
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,86 @@ | ||
defmodule ElixirLS.LanguageServer.Experimental.CodeMod.AstTest do | ||
alias ElixirLS.LanguageServer.Experimental.CodeMod.Ast | ||
|
||
use ExUnit.Case | ||
|
||
describe "ast" do | ||
test "from\2 / to_string\1" do | ||
string = """ | ||
defmodule Bar do | ||
def foo(baz) do | ||
# TODO | ||
end | ||
end | ||
""" | ||
|
||
{:ok, ast} = Ast.from(string, include_comments: true) | ||
assert string == Ast.to_string(ast) <> "\n" | ||
|
||
{:ok, ast_missing_comments} = Ast.from(string) | ||
|
||
assert """ | ||
defmodule Bar do | ||
def foo(baz) do | ||
end | ||
end | ||
""" == Ast.to_string(ast_missing_comments) <> "\n" | ||
end | ||
|
||
test "from\1" do | ||
assert {:ok, | ||
{:def, [do: [line: 1, column: 16], end: [line: 3, column: 3], line: 1, column: 3], | ||
[ | ||
{:foo, [closing: [line: 1, column: 14], line: 1, column: 7], | ||
[{:baz, [line: 1, column: 11], nil}]}, | ||
[do: {:__block__, [], []}] | ||
]}} = | ||
Ast.from(""" | ||
def foo(baz) do | ||
# TODO | ||
end | ||
""") | ||
Comment on lines
+29
to
+41
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. these assertions are pretty hard core, and are really testing the calls to elixir sense / sourceror Perhaps instead, just ensure we're calling the two libs correctly in each case by using There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. The sourceror github page says to expect "frequent breaking changes". Perhaps we leave the assertion of the returned AST structure -- at least for the I depend on the AST returned by sourceror for the extract function refactoring code I'm writing in a separate branch. |
||
end | ||
|
||
test "from\2" do | ||
assert {:ok, | ||
{:def, | ||
[ | ||
trailing_comments: [ | ||
%{column: 5, line: 2, next_eol_count: 1, previous_eol_count: 1, text: "# TODO"} | ||
], | ||
leading_comments: [], | ||
do: [line: 1, column: 16], | ||
end: [line: 3, column: 3], | ||
line: 1, | ||
column: 3 | ||
], | ||
[ | ||
{:foo, | ||
[ | ||
trailing_comments: [], | ||
leading_comments: [], | ||
closing: [line: 1, column: 14], | ||
line: 1, | ||
column: 7 | ||
], | ||
[ | ||
{:baz, [trailing_comments: [], leading_comments: [], line: 1, column: 11], | ||
nil} | ||
]}, | ||
[ | ||
{{:__block__, | ||
[trailing_comments: [], leading_comments: [], line: 1, column: 16], [:do]}, | ||
{:__block__, [trailing_comments: [], leading_comments: []], []}} | ||
] | ||
]}} = | ||
Ast.from( | ||
""" | ||
def foo(baz) do | ||
# TODO | ||
end | ||
""", | ||
include_comments: true | ||
) | ||
end | ||
end | ||
end |
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -31,7 +31,7 @@ defmodule ElixirLS.Mixfile do | |
|
||
defp aliases do | ||
[ | ||
test: "cmd mix test" | ||
test: "cmd mix test --color" | ||
] | ||
end | ||
end |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Does sourceror fix errors like ElixirSense does?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I don't know. I'm not familar with how
ElixirSense
fixes errors. Do you have examples or tests that check for this? We could extend those to test Sourceror's behaviour.