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
Provide a JvmGenericTypeValidator #2349
Comments
@LorenzoBettini Yes that does make a lot of sense. Having sensible and efficient impl for this and relieving clients from the burden to implement these manually sounds very good. |
@szarnekow thank you for the feedback! |
Seems the only things we have are in org.eclipse.xtext.xbase.testlanguages. |
The validators should be language specific (as in: not registered only for the EPackage but also enabled for the language at hand). See |
@szarnekow I started to work on this; I was planning to factor many parts of That's the very first experimental commit on my fork: LorenzoBettini@c490251 I set However, by debugging, my validator never kicks in for inferred elements like |
@szarnekow, I pushed an updated commit tests are green. It looks like a small hack because I need to intercept an EObject, which is the root of the Resource's contents, because, as you said, only the first element of the Resource is currently validated. The abstract declarative validator does not provide anything else to override, at least, in my understanding. |
@szarnekow Going back to what we discussed, Line 166 in 2b19d66
The method filters the supertypes based on whether the referenced type is an interface or not. However, in our case, during validation, we need to make sure that what is specified as a superclass is indeed a class and not an interface. For example, in the following invalid program class Foo extends Serializable implements Object
Thus, besides my current solution based on the multiplicity of the containing feature: |
@szarnekow for some Xtend-specific validations, I was thinking of letting the |
Oh I think I meant the opposite (might have been confusing rambling from my end). If the composed injectors are instantiated from the correct injector, inheriting from them and overriding some rules is absolutely ok. |
I'd like to propose an idea I've been thinking of for a while.
When implementing an Xbase language you have to repeat several typical checks, like no duplicate fields, no duplicate methods (according to Java overriding and overloading rules), cyclic hierarchy, etc., like we recently did in eclipse/xtext-eclipse#1205 and eclipse/xtext-eclipse#1205 . I seem to understand that the best way of doing that is by performing checks directly on the inferred JvmModel, like we did in the issues above and like Xtend itself does. After all, it does not make sense to have an inferred JvmModel which then produces incorrect Java code...
So why not providing some kind of
JvmGenericTypeValidator
that does all these checks automatically on the inferred JvmModel and then generating issues the original elements in the program (by means ofIJvmModelAssociations
)? With that respect the starting point could be theXtendValidator
itself, from where we can extract most of the logic of typical JvmModel validations in the reusableJvmGenericTypeValidator
(and thenXtendValidator
could be refactored accordingly). TheJvmGenericTypeValidator
could follow the same strategy ofJvmTypeReferencesValidator
which is automatically enabled (by relying ongetEPackages
).All Xbase languages would then benefit from such automatic validations.
@szarnekow do you think it is feasible, makes sense, could be useful?
The text was updated successfully, but these errors were encountered: