Restore the type from class file input in the background#2380
Restore the type from class file input in the background#2380iloveeclipse merged 1 commit intoeclipse-jdt:masterfrom
Conversation
iloveeclipse
left a comment
There was a problem hiding this comment.
I had finally time to look at that. This should solve the original problem to 90% (shows the code if type is on classpath, shows disassembled code if not and shows some error otherwise).
There is a bug in case the type is on classpath but in another jar file, because editor tries to re-set the input from the wrong thread. That must be fixed, see below where.
Remaining 10% could be done later on, these would be mostly side-effects after re-init & editor input change:
- the Java editor breadcrumb is disconnected (shows empty space)
- link with ediktor doesn't work and activating restored class file editor does not expand/navigate to the right packages in the jar file in the Package explorer
- same as above: opening type from restored editor opens new class file editor
These issues could be fixed later on, I assume.
This comment was marked as outdated.
This comment was marked as outdated.
This is a ticket, not a PR. Do you mean first commit of this PR? |
|
Sorry that should be this one: |
e16a615 to
03ac39b
Compare
I've fixed & merged that PR and rebased this PR unchanged (just squashed) on top of master. I will try to review this PR soon. |
iloveeclipse
left a comment
There was a problem hiding this comment.
Unfortunately I've not tested good enough #2379, the case where the class is missing because jar is deleted, not just updated (like IBuild update to next one but without keeping the old one on the disk) is not handled properly and results again in an ugly error shown in the editor.
I will push some changes now, where I'm unhappy because it reports too many errors to the log while JDT UI is trying to access missing class file before the input is updated and right class file is found.
03ac39b to
4f60232
Compare
If ClassFileEditor is restored, underlined class file might be moved in the meantime (e.g. library on classpath changed version so the type is still there but the absolute class file path changed). To check if the type is still on the classpath of the project might freeze UI for some time, so move this check to a job. If the job is running very early on startup, project classpath might be not yet updated (see RequiredPluginsInitializer and UpdateClasspathsJob in PDE which initialize classpath container lazily). In the case the type is not found, listen to JDT model changes and refresh the input in case the project classpath is updated. Fixes eclipse-jdt#2245
4f60232 to
6d2a728
Compare
|
@iloveeclipse if you want I can try to split up some parts already to make the PR smaller, for example the change in org.eclipse.jdt.ui/ui/org/eclipse/jdt/internal/ui/javaeditor/ClassFileDocumentProvider.java seems isolated enough to be merged independently together with: |
|
With latest patch set I've adressed the problems:
|
|
@iloveeclipse good to see you are making good progress here, I initially opened it as a POC because it really only showed a very rough idea and I'm not familiar with all the JDT details it looks much better now already.
I think this is actually the right approach anyways, as classpath changes can happen anytime, e.g. target platform gets reloaded, Manifests change (either by user or due to switching branches), so if this can be detected (and handled) that's really great. I can't tell ho often I have to manually fixup things (closed projects, broken editor states also sometimes failed target resolutions) when switching / syncing branches. |
|
By the way with latest ibuild is see zero "async" changes when restarting the Eclipse SDK workbench, but is see different component access the java model what leads to loading the container from different threads (before the for one observed case, I also have seen this for |
This still happens if the target platform is modified, so jar on PDE classpath changes the version for example. |
Yes this is expected. PDE always restore the last state from where it shut down and then check if anything has changed in the background. |
laeubi
left a comment
There was a problem hiding this comment.
It all looks good to me.
This is just a draft to show the code.