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

Populate CodeAction if its parent should also be modified. #26

Open
kenkangxgwe opened this issue Mar 22, 2021 · 1 comment
Open

Populate CodeAction if its parent should also be modified. #26

kenkangxgwe opened this issue Mar 22, 2021 · 1 comment

Comments

@kenkangxgwe
Copy link
Contributor

Currently, ApplyCodeAction deletes the very node that the CodeAction specifies, but this is not sound enough.
Given

Module[{a, b = 2 (* b is unused *)}, a]

The symbol b is marked, but in fact, we want to remove b = 2. So I think a code action can be populated up until it reaches the node that can actually fix the problem. Moreover, the trailing comment seems easy to be removed if we treat it as the same as the trailing comma, but it will still be convenient to provide an additional list of nodes that can be removed as well.

I know that CodeParser`CodeAction` is not ready yet, so I am just sharing the idea.

@bostick
Copy link
Contributor

bostick commented Mar 22, 2021

It would be good to handle stray commas in cases like this.

I don't know about handling comments. People may want to keep them.

A related problem that I am running into in some cases related to CodeActions is the mixing of abstract vs. concrete syntax.

For example, I have a rule to catch code like this: a_ -> a and I want to give the suggestion of changing the -> to :>

The problem is that the rule is working on abstract syntax where there is no longer the concept of -> or :> operators.

Currently, to give the suggestion, I would have to have a CodeAction to replace the entire a_ -> a node.

But all I really want to replace is the single -> operator.

So I am trying to think about this.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants