我有这样的要求用XText开发
我有一组POJO类,(无法为此绘制图表,希望这是明确的enf)
( A_POJO ) ------- Level 1
( B_POJO extends A_POJO ) ------- Level 2
( C_POJO extends A_POJO ) ------- Level 2
( D_POJO extends C_POJO ) ------- Level 3
( E_POJO extends C_POJO ) ------- Level 3
( F_POJO extends C_POJO ) ------- Level 3
然后我将在Eclipse的类路径中使用这个POJO类来开发这个DSL。我的支持是开发语法文件,如
(B_POJO or child class of it) name=ID {
[
(C_POJO or child class of it) name=ID {Attribute of (C_POJO)}
(C_POJO or child class of it) name=ID {Attribute of (C_POJO)}
(C_POJO or child class of it) name=ID {Attribute of (C_POJO)}
(C_POJO or child class of it) name=ID {Attribute of (C_POJO)}
(C_POJO or child class of it) name=ID {Attribute of (C_POJO)}
]
}
示例看起来像
User xx {
[
vField userName {length=25}
vField firstName {length:50}
vField otherNames {length:100}
vField password {length:25}
vField email {length:100}
]
}
对于如何为这种动态工作做xText语法会有任何想法,这些动态工作将来自给定的POJO。
答案 0 :(得分:0)
你的问题不是很清楚,但如果你所谓的“POJO类”是,或者可以变成,EMF生成的代码,来自“元模型”,用XCore表示,这是一个DSL for EMF Ecore模型(您可以从现有的Java模型中导入...)然后我可能会对https://github.com/vorburger/efactory的EMF简单对象表示法ESON(ex-EFactory)感兴趣吗?