-
Notifications
You must be signed in to change notification settings - Fork 317
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 features to JvmGenericType to express the expected semantics of supertypes #2899
Closed
Conversation
This file contains 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
Otherwise the "Generator" class cannot be found.
only a white space difference
only a white space difference
in JvmGenericType
using the new API classToExtend, interfacesToImplement/Extend
This reverts commit f2521d8. The check would break code that scans all the features, e.g., org.eclipse.xtext.findReferences.ReferenceFinder.findLocalReferencesFromElement(Predicate<URI>, EObject, Resource, Acceptor)
originally added also to this branch
I prefer the option with the adapter. |
Superseeded by #2924 |
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.
Closes #2880
I haven't introduced
JvmGenericClass
andJvmGenericInterface
. Instead, I enrichedJvmGenericType
.The new features are
classToExtend
and the (non-containment) listsinterfacesToImplement
andinterfacesToExtend
.I chose new names not to mix them with the get methods like
getExtendedClass
. In fact, these features are meant for expressing the intentions (class to extend and interfaces to implement for classes and interfaces to extend for interfaces) to better perform validation (#2349).The getter and setter for
classToExtend
and the getters for the lists are customized to keep the new features consistent with whatgetSuperTypes
returns. This way, this extension will be backward compatible. It is not a complete synchronization, see the Javadoc https://github.com/eclipse/xtext/compare/main...LorenzoBettini:xtext:lb_2880-2?expand=1#diff-0243bd309c39347e67704b49bdd4b374c1a1a475fefb6beb2ceb1268c5f8a273R20but it should be enough for the proposed extension.
In particular, adding something directly to
getSuperTypes
does not change the new features because there would be no way to know which one to update.On the contrary, adding a type with the new features will update the list returned by
getSuperTypes
.Removing that type from
getSuperTypes
would remove it from the original place as well.I have added several tests in that respect in
JvmGenericTypeTest
.I then applied these new features in the
XtendJvmModelInferrer
and the build is still green.I added a few more tests to
JvmModelGeneratorTest
as wellFinally, I applied that to Domainmodel example and added a test (we were never testing with a superclass)
Unfortunately, I could not add a check for proper usages of the new features:
classToExtend
andinterfacesToImplement
should not be used whenisInterface
is true; accordingly forinterfacesToExtend
.Actually, I had added such checks but had to revert them because such a check would break code that scans all the features, e.g.,
org.eclipse.xtext.findReferences.ReferenceFinder.findLocalReferencesFromElement(Predicate,
EObject, Resource, Acceptor).