Skip to content

Experimental project structure #773

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

Merged
merged 21 commits into from
Jan 20, 2023
Merged
Show file tree
Hide file tree
Changes from 1 commit
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
Prev Previous commit
Encapsulated sourceror
  • Loading branch information
scohen committed Jan 20, 2023
commit f33cb191b65f5842f726320f226a43d6e8e057a3
Original file line number Diff line number Diff line change
@@ -1,19 +1,28 @@
defmodule ElixirLS.LanguageServer.Experimental.CodeMod.Ast do
alias ElixirLS.LanguageServer.Experimental.SourceFile

@type t :: any()
@type source :: SourceFile.t() | String.t()
@type t ::
atom()
| binary()
| [any()]
| number()
| {any(), any()}
| {atom() | {any(), [any()], atom() | [any()]}, Keyword.t(), atom() | [any()]}

@spec from(source) :: t
def from(%SourceFile{} = source_file) do
source_file
|> SourceFile.to_string()
|> from()
end

def from(s) when is_binary(s) do
parse(s)
ElixirSense.string_to_quoted(s, 1, 6, token_metadata: true)
end

defp parse(s) when is_binary(s) do
ElixirSense.string_to_quoted(s, 1, 6, token_metadata: true)
@spec to_string(t()) :: String.t()
def to_string(ast) do
Sourceror.to_string(ast)
end
end
Original file line number Diff line number Diff line change
Expand Up @@ -37,7 +37,7 @@ defmodule ElixirLS.LanguageServer.Experimental.CodeMod.ReplaceWithUnderscore do
other ->
other
end)
|> Sourceror.to_string()
|> Ast.to_string()
# We're dealing with a single error on a single line.
# If the line doesn't compile (like it has a do with no end), ElixirSense
# adds additional lines do documents with errors, so take the first line, as it's
Expand Down