-
Notifications
You must be signed in to change notification settings - Fork 456
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
"Add all imports" is inefficient when resolving static imports #3383
Comments
#3186 should be fixed in 1.24.0. I tried calling the "Add all missing imports" option in a project with ~50 imports and the response is almost instant. However, I then tried on a file containing ~100 imports and there was a clear reduction in performance :
So it went from "instant" to ~7s . That's definitely odd. If I had to guess I'd say it might be that certain kind of imports add significantly more time to the action but I'd have to investigate. |
Looks like the problem is the static import favourite resolution. If I disable the favourite static imports, then regular performance returns. Unforunately, it's difficult to do on the client-side because even when the list is made empty, we provide some values from the server-side. This portion of code is what is taking nearly all the time : https://github.com/eclipse-jdt/eclipse.jdt.ui/blob/34f6473dbf659c47714111393ea2b085902af54f/org.eclipse.jdt.core.manipulation/core%20extension/org/eclipse/jdt/internal/corext/util/JavaModelUtil.java#L1327-L1369 . The code is creating a new compilation unit of the form :
, triggering auto-completion to the right of [identifer], and collecting all method/field imports that match. [identifier] represents an unresolved static reference. There were ~300 static import references in the file. Some performance improvements that come to mind :
These will need to be done upstream in JDT though |
The paste event handling also performs "organize imports" : https://github.com/eclipse-jdtls/eclipse.jdt.ls/blob/45aeb8db2655847ee4efad7f97de7e7926c3007b/org.eclipse.jdt.ls.core/src/org/eclipse/jdt/ls/core/internal/handlers/PasteEventHandler.java#L324 . So basically, the behaviour in this issue may also extend to problems of the form "pasting text is slow", when paste support is enabled. |
This was fixed upstream. As soon as JDT-LS updates to say the 4.31 I-builds (eg. |
The "Add all imports" context menu option is not functioning in most cases. Sometimes, it just takes very long to become active.
Issues such as this and #
3186
are the reason why I need to keep rolling the extension's version back tov1.18.0
.Environment
jdk-17.0.7+7
1.84.1
v1.24.0
The text was updated successfully, but these errors were encountered: