Inheritance from non-grammar java class [message #1791714] |
Wed, 04 July 2018 08:46  |
Eclipse User |
|
|
|
Within our project we have the scenario that your generated classes shall extend a "provided" Java class.
More specific the class that should be the root of the generated code (lets call it: "BaseClass") is shipped as a jar. The jar is already available on the classpath and can be referenced within the xtext project.
Since this is part of a bigger project within a company I can't provide a complete example.
My first goal is to understand if I'm heading towards a solution or if I need to use another approach.
As an example for the XBase-Grammar:
Entity:
'entity' name=ValidID '{'
(features+=Feature)*
'}';
Within the Inferrer my first attempt was:
def dispatch void infer(Entity element, IJvmDeclaredTypeAcceptor acceptor, boolean isPreIndexingPhase) {
acceptor.accept(element.toClass(element.name)) [
packageName = element.packageName
superTypes += typeRef(BaseClass)
]
}
This leads to a Nullpointer Exception. I know that I need to bind/provide the "BaseClass" but my problem is that I don't understand how and where.
There are many examples explaining how to handle cross-reference and handling grammar-related references but I couldn't find a more detailed example for reference resolution from "external" resources like jars.
I admit that I most likely missed a basic point from the Xtext docs about "JDT-Based Container Manager". At the moment I'm not even sure what Provider would be the correct one.
The ultimate goal is to get a generated class like this:
EntityXY extends BaseClass {
//happyVariables
}
In advance, thats for your support!
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
Powered by
FUDForum. Page generated in 0.27591 seconds