-
Notifications
You must be signed in to change notification settings - Fork 3.4k
Code.Fragment.container_cursor_to_quoted/1
can't return aliases when cursor at alias line.
#12673
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
Comments
Can you tell me the macro task you are trying to do? The container cursor to quoted returns the parent, in this case the parent is the do block. |
o, I see; thanks for the quick reply. I'm trying to build an |
Building the mapping is not something the Elixir tools will help, unfortunately. We want to tackle that in #12645. if you want the AST until the current cursor, then you can always append a new line and call container_cursor_to_quoted. But using Elixir sense and private APIs may still be the best way to achieve that :( |
Yes, I have noticed this. I cannot handle this |
@josevalim iex(1)> Code.Fragment.container_cursor_to_quoted("%Struct{field: 1, fie\n")
{:error,
{[line: 1, column: 17],
"unexpected expression after keyword list. Keyword lists must always come last in lists and maps. Therefore, this is not allowed:\n\n [some: :value, :another]\n %{some: :value, another => value}\n\nInstead, reorder it to be the last entry:\n\n [:another, some: :value]\n %{another => value, some: :value}\n\nSyntax error after: ",
"','"}}
|
I think %{field : 1} %{field
: 1} |
Added to the syntax reference. |
IIRC, the new line is a temporary solution until #12645 is in place. My suggestion is for you to add a newline and then, if it fails to parse, try again without the newline. |
Is this a bug?
I'm trying to copy some code to the Lexical repo: lexical-lsp/lexical#217
But I can't extract the aliases with this line:
"defmodule MyModule do\n alias Project.Structs.User"
The text was updated successfully, but these errors were encountered: