Skip to content
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
wants to merge 25 commits into from

Conversation

LorenzoBettini
Copy link
Contributor

Closes #2880

I haven't introduced JvmGenericClass and JvmGenericInterface. Instead, I enriched JvmGenericType.
The new features are classToExtend and the (non-containment) lists interfacesToImplement and interfacesToExtend.
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 what getSuperTypes 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-0243bd309c39347e67704b49bdd4b374c1a1a475fefb6beb2ceb1268c5f8a273R20
but 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 well

Finally, 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 and interfacesToImplement should not be used when isInterface is true; accordingly for interfacesToExtend.
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).

@szarnekow
Copy link
Contributor

I prefer the option with the adapter.

@LorenzoBettini
Copy link
Contributor Author

Superseeded by #2924

@LorenzoBettini LorenzoBettini deleted the lb_2880-2 branch February 6, 2024 12:23
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Xbase proposal: Add features to express the expected semantics of supertypes
2 participants