ST6RI-894 Inconsistent name resolution for qualified name as target of redefinition#714
Conversation
- Nested redefinition case is expected to fail.
Updated checkConstructorExpressionResultSpecialization in ConstructorExpressionAdapter.
Member
Author
|
Closed in preference for PR #717. |
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.
This PR fixes a bug that could case inconsistent name resolution for a qualified name used as the target of a nested redefinition.
Background
Consider the following SysML model:
When a file with this model is initially opened in the Eclipse Xtext editor, and the attribute usage nested in
B::x(commented) is viewed in the outline, the targetx::yof the redefinition is shown as resolving to the attribute usage itself (that isB::x::y). Previously, however, if a space was typed so that the model was re-parsed and validated, the outline then showed that the target of the redefinition had resolved instead to the attribute usageA::x::y. On the other hand, if the model is entered in Jupyter, the attribute usage in question generates the error “Featuring types of redefining feature and redefined feature cannot be the same”, indicating thatx::yhas resolved toB::x::y, making the redefinition invalid.Cause
x::yhas to be resolved as the target of a redefinition.x::ytoA::x::y, which determines that the effective name of the redefining attribute isy.B(the parent ofB::x),x::ythen resolves toB::x::y, and the resolution is updated to this element (i.e., the redefining attribute usage itself).Redefinitionrelationship, it checks the generalRelationship::targetvalue before theRedefinition::redefinedFeaturevalue.sourceandtargetfor any kind ofSpecializationare lists containing the single values of thespecificandgeneralproperties of theSpecialization, respectively. ThegetSourceandgetTargetmethods inSpecializationImplimplement this by creating a list and then inserting thespecificorgeneralvalues into the list.getSpecificandgetGeneralmethods are used, which will resolve proxies if necessary, so the returned lists never contain (resolvable) proxies. However, Previously, these calls had been replaced by calls tobasicGetSpecificandbasicGetGeneral, which do not do proxy resolution.targetof theRedefinitionwas found to be a proxy, Xtext resolved the proxy and then updated thetargetlist with the resolved element. However, since the list was created in thegetTargetmethod, this did not result in theredefinedFeatureproperty value actually being updated for theRedefinition, so the value was left as the earlier resolution toA::x::y.Changes
SpecializationImpl.java– Replaced the non-generated versions ofgetSourceandgetTargetwith the generated versions. This resolves the bug, so, in the example model above,x::yalways resolves toB::x::y. (A comment in the code indicated that the changes had been made to these methods to prevent circular name resolution. However, testing indicated that the generated version without the changes no longer caused circular resolution errors.)ConstructorExpressionAdapter.java– Revised the adding of the implied result type to the result parameter of a constructor expression so that it is added immediately when the result parameter is added. Otherwise, the above change resulting named arguments of constructor expressions having spurious validation errors.Redefinition_Scoping.kerml.xt– Added a KerML Xpect test using a KerML version of the above example model, to check that the nested redefinition causes the expected error (i.e., that the redefining feature redefines itself).SpecializationImplwas made. These were corrected by adding further qualification to the redefinition target names.Domain Libraries/Geometry/ShapeItems.sysmlkerml/src/examples/KerML Spec Annex A Examples/A-3-8-ChangingFeatureValues.kermlNote
This PR corrects the bug in the implementation that caused name resolution to be inconsistent in the specific case of cross-reference link resolution after a text change in the Xtext editor. See KERML12-140 on the wider issue of what the proper resolution should be according to the specification. Depending on the ultimate resolution of KERML12-140, the implementation may be updated again in this area in the future.