Do not return null editor input from the ClassFileEditorInputFactory#2349
Do not return null editor input from the ClassFileEditorInputFactory#2349laeubi wants to merge 1 commit into
Conversation
| type= project.findType(type.getFullyQualifiedName()); | ||
| if (type == null) | ||
| return null; | ||
| return new InternalClassFileEditorInput(cf); |
There was a problem hiding this comment.
If one wants, here we can pass a boolean to Indicate that the type was not found on the project if that's useful for anything later on.
Currently ClassFileEditorInputFactory return null in some cases when restoring an editor input from an IMemento. While this is legal in general for IElementFactory it is not very useful for factories that restore editor inputs because this will fail to instantiate the editor with a nasty exception without any way for the editor to handle or the user to understand the underlying problem. This now changes two things: 1) In case of an error, a special ExceptionalEditorInput is created, that when later used to gather its underlying data will rethrow the original exception so we get a useful message about the cause. 2) In case of an element not found by the project an InternalClassFileEditorInput is returned as we actually have the class data already there.
79d6555 to
66378bc
Compare
|
@iloveeclipse would you mind merging this PR as it already improves the situation? I then plan to do another smaller PR and then continue with |
I will try to review this afternoon. |
|
If one would test this it would better be to do it at The testcase #2348 is very specific to the implementation details and does not very well covers the case we see here. If there are concerns I can reduce the change to a much simpler one I just though to cover the other cases as well is maybe nice, see: Currently it looks like that but I plan to add another PR for fix this but better want to do smaller steps that are easy to review and merge:
|
|
For the test he needs to adjust the ClassFileEditor getAdapter method, because in original case it wasn't possible to gather the parent composite of that editor.. Maybe in that state he could just implement simple unit test and skip the UI test.. The UI test could be done in the other PR (otherwise he has to adjust the UI Test again in the other PR) |
|
I don't see any difference to the original behavior in the use case below (original one from #2245).
I test it by creating a breakpoint at org.eclipse.pde.internal.core.RequiredPluginsInitializer.DeferredClasspathContainerInitializerJob.run(IProgressMonitor). Can you please provide steps to verify what the patch is doing? |
|
|
||
| @Override | ||
| public String getToolTipText() { | ||
| return String.format("Error while gathering input for %s: %s", fIdentifier, fException); //$NON-NLS-1$ |
There was a problem hiding this comment.
Is there not an externalization necessary?
There was a problem hiding this comment.
I don't know if there is a separation inbetween UI and Exception messages. But this could be used in the UI
|
|
||
| import org.eclipse.jdt.core.IOrdinaryClassFile; | ||
|
|
||
| public class OrdinaryClassFileEditorInput extends InternalClassFileEditorInput { |
There was a problem hiding this comment.
Why don't we use directly the InternalClassFileEditorInput and create a new class without any additional functionality or marking (Checked also against the check_incomplete_input branch but couldn't find the use of it)
There was a problem hiding this comment.
The idea was to make this case distinguishable from an "normal" input, but might not be strictly needed. In the meantime I cane to the conclusion that maybe the whole checks here can be omitted and everything is better handled in the editor, but one should not change to much at once ... so I would like to wait if we can agree at least on something that should be merged.
There was a problem hiding this comment.
In overall the solution looks good. The second PR has no issues from my side.. The last PR (load the Sources when it is available) worked only once and then never again.. I will try to understand the problem, did you pushed your latest changes there?
There was a problem hiding this comment.
Lets first finish this ones
- If there is no source show the raw class file content #2357
- (simplified) Do not return null editor input from the ClassFileEditorInputFactory #2353
before further proceed, it all gets to much complicate to have even more PRs inflight. Once this is done I can rebase and we can easier discuss on possible improvements or increments.
There was a problem hiding this comment.
There was a problem hiding this comment.
2349 contains already the change from 2353 ..
The order might be:
2353
2349
2357
|
Closing as not enough interest from JDT maintainers and is simpler. |

Currently
ClassFileEditorInputFactoryreturn null in some cases when restoring an editor input from anIMemento. While this is legal in general forIElementFactoryit is not very useful for factories that restore editor inputs because this will fail to instantiate the editor with a nasty exception without any way for the editor to handle or the user to understand the underlying problem.This now changes two things:
ExceptionalEditorInputis created, that when later used to gather its underlying data will rethrow the original exception so we get a useful message about the cause.InternalClassFileEditorInputis returned as we actually have the class data already there.