Skip type-incompatible imports in ModelAssembler.resolveImports#4150
Draft
vogella wants to merge 1 commit into
Draft
Skip type-incompatible imports in ModelAssembler.resolveImports#4150vogella wants to merge 1 commit into
vogella wants to merge 1 commit into
Conversation
Contributor
Author
|
The new test is supposed to fail, this is to demo the problem. |
Contributor
resolveImports resolves fragment <imports> by elementId via ModelUtils.findElementById, which returns the first match regardless of type, and then eSets it onto the target reference. When the model contains a different-typed element sharing the imported id, the eSet fails with a ClassCastException and aborts assembly of the whole application model. For example ResourceHandlerTest fails in the I-builds with "BindingTableImpl cannot be cast to MBindingContext", because BindingToModelProcessor.createTable() gives each generated BindingTable the binding-context id as its own elementId, so a fragment importing that BindingContext resolves to the same-id BindingTable. Skip such an import with a warning instead: an import that resolves to an incompatible element is a contribution error, not a reason to abort assembly. The reference is left unset and every other fragment still applies. Also skip, rather than NPE, an unresolved import on a many-valued feature. Add a regression test covering the type mismatch. Fixes eclipse-platform#4148
0236660 to
7cba137
Compare
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
ModelAssembler.resolveImportsresolves fragment<imports>byelementIdonly, ignoring the element type, then sets whatever it finds on the target reference. When a fragment imports an element whose id collides with a different-typed element already in the model, the resolved element is not assignable to the reference and model assembly aborts with aClassCastException. This is what breaksResourceHandlerTestin the I-builds (BindingTableImpl cannot be cast to MBindingContext).The import is now skipped with a warning instead of aborting the whole application model: an import that resolves to an incompatible element is a contribution error, so the reference is left unset and every other fragment still applies. Unresolved imports on many-valued features are skipped rather than throwing an NPE. A regression test in
ModelAssemblerTestscovers the type mismatch.Fixes #4148