[英]How to generate code from ecore model with OCL expressions in the separate file?
我正在使用 Eclipse 插件与 OCL 一起工作。 我有一个带有一些操作和派生属性的 Ecore model 我还有一个单独的 OCL 文件,其中包含表达式。 我制作了一个 genmodel 文件并添加了:
<genAnnotations source="http://www.eclipse.org/OCL/GenModel">
<details key="Use Delegates" value="false"/>
</genAnnotations>
我还检查了嵌入在 ecore 模型集中生成代码的 OCL 的首选项实现。 但是当我尝试使用这个 genmodel 生成代码时,它只会生成没有 OCL 表达式的代码。 我还应该怎么做才能从单独的文件中为所有 OCL 表达式生成代码?
这是我的 model 文件: ecore 文件
这是我的 genmodel 文件: .genmodel 文件
OCL 文件的开头:
import 'CarRental.ecore#/'
package CarRental
context Person
inv Person3:
age > 0 and age < 80
context Person::fullName : String
derive: self.firstname.concat(' ').concat(self.lastname)
...
endpackage
OCLinEcore 中的 Model 文件:
package CarRental : CarRental = 'http:///CarRental.ecore'
{
class Person
{
operation email() : String[*|1];
operation updateAge(newAge : ecore::EInt[1]);
attribute firstname : String[?];
attribute lastname : String[?];
attribute age : ecore::EInt[1];
attribute isMarried : Boolean[1];
attribute fullName : String[?] { derived };
}
...
}
应在 Eclipse OCL 新闻组上提出一个彻底的 Eclipse 问题。
https://www.eclipse.org/forums/index.php/f/26/
您的 Ecore/GenModel 文件不是 Ecore/GenModel 文件; 它们是顶级声明的快照。 快照很少能很好地替代文件。
您的 genmodel 片段看起来不错,但是如果没有项目的 rest,很难评论您可能犯的许多错误。
我最好的猜测是,鉴于您发布的是示例 Ecore Model 编辑器快照而不是 OCLinEcore 编辑器快照,您未能合成注册 OCL 附加组件所需的所有 EAnnotation。 OCLinEcore 编辑器会自动完成这一切。
我建议您将压缩项目发布到 Eclipse OCL 新闻组。
一旦在 Eclipse OCL 论坛上提供了详细信息,就会发现没有可用于生成代码的 OCLExpressions。 零输入 => 零输出。
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.