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

Organize Imports doesn't work #1142

Closed
testforstephen opened this issue Nov 15, 2019 · 3 comments · Fixed by eclipse-jdtls/eclipse.jdt.ls#1275
Closed

Organize Imports doesn't work #1142

testforstephen opened this issue Nov 15, 2019 · 3 comments · Fixed by eclipse-jdtls/eclipse.jdt.ls#1275

Comments

@testforstephen
Copy link
Collaborator

In the latest 0.53.0, "Organize Imports" doesn't work any more. It should be a regression bug.

@fbricon
Copy link
Collaborator

fbricon commented Nov 15, 2019

Yeah that's a pretty big regression. Can you provide a fix so that we can release a new version ASAP?

@testforstephen
Copy link
Collaborator Author

@Eskibear is working on it.

@Eskibear
Copy link
Contributor

Investigated. Part of the entries are blocked:

  • Not Working: trigger "organize imports" from command palette / keyboard shortcut
  • Working: trigger from right click -> "Source Action..." -> organize imports

I'm providing a fix for it.

Root cause

When you trigger "organize imports" from command palette, or keyboard shortcut, the client sends request, thus the SourceActionProcessor is not working accoring to current logic.

[Trace - 下午4:38:44] Sending request 'textDocument/codeAction - (24)'.
Params: {
... 
    "context": {
        "diagnostics": [],
        "only": [
            "source.organizeImports"
        ]
    }
}

When you right click and "Source Action..."

[Trace - 下午4:38:53] Sending request 'textDocument/codeAction - (25)'.
Params: {
...
    "context": {
        "diagnostics": [],
        "only": [
            "source"
        ]
    }
}

I used codeActionKinds.contains(baseKind) as the condition to call each processor. Should match the prefix.

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

Successfully merging a pull request may close this issue.

3 participants