[jbosstools-issues] [JBoss JIRA] (ERT-568) [JDT] New API for organize imports

Roland Grunberg (JIRA) issues at jboss.org
Thu Dec 14 11:44:00 EST 2017


    [ https://issues.jboss.org/browse/ERT-568?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel&focusedCommentId=13505602#comment-13505602 ] 

Roland Grunberg edited comment on ERT-568 at 12/14/17 11:43 AM:
----------------------------------------------------------------

I've proposed some changes for this, and improved them to reduce amount that is being exposed as API.

The downside is there's quite a bit of code that has had to be copied over into internal spots of OrganizeImportsOperation.

Trickiest spots have mainly been de-coupling OrganizeImportsOperation from JDT UI :
* Dependence on JDT UI Plugin for the workspace preferences with respect to how imports are organized. The preference lookup is really part of org.eclipse.core.runtime so moving some code around handled this (eg. JavaUIPlugin.getInstance().getPreferences() vs. InstanceScope.getNode(..).get(..))
* Code depended on global ASTProvider stored in the JavaUIPlugin which hooked into various UI events (eg. editor opened/close). Resolved by moving all non-UI code into a new CoreASTProvider. This handles all calls that would have gone from SharedASTProvider -> ASTProvider
* StringMatcher is used in so many spots across Eclipse ecosystem, and exposing it is no-go, so we use some crappy approximation using java.util.regex.

I still need to confirm that taking this implementation will work for org.eclipse.jdt.ls, as their implementation may have hard-coded various things to work their way, while this proposed upstream implementation attempts to preserve how things worked in the JDT originally.


was (Author: rgrunber):
I've proposed some changes for this, and improved them to reduce amount that is being exposed as API.

The downside is there's quite a bit of code that has had to be copied over into internal spots of OrganizeImportsOperation.

Trickiest spots have been de-coupling OrganizeImportsOperation from JDT UI. Two cases existed :
* Dependence on JDT UI Plugin for the workspace preferences with respect to how imports are organized. The preference lookup is really part of org.eclipse.core.runtime so moving some code around handled this (eg. JavaUIPlugin.getInstance().getPreferences() vs. InstanceScope.getNode(..).get(..))
* Code depended on global ASTProvider stored in the JavaUIPlugin which hooked into various UI events (eg. editor opened/close). Resolved by moving all non-UI code into a new CoreASTProvider. This handles all calls that would have gone from SharedASTProvider -> ASTProvider

I still need to confirm that taking this implementation will work for org.eclipse.jdt.ls, as their implementation may have hard-coded various things to work their way, while this proposed upstream implementation attempts to preserve how things worked in the JDT originally.

> [JDT] New API for organize imports
> ----------------------------------
>
>                 Key: ERT-568
>                 URL: https://issues.jboss.org/browse/ERT-568
>             Project: Eclipse Release Train
>          Issue Type: Task
>          Components: Platform
>            Reporter: Roland Grunberg
>            Assignee: Roland Grunberg
>
> See https://bugs.eclipse.org/bugs/show_bug.cgi?id=506239 for full details.



--
This message was sent by Atlassian JIRA
(v7.5.0#75005)


More information about the jbosstools-issues mailing list