【发布时间】:2020-07-19 18:16:33
【问题描述】:
我正在使用 Eclipse 插件来处理 OCL。我有一个包含一些操作和派生属性的 Ecore 模型,我还有一个单独的 OCL 文件,其中包含表达式。我制作了一个genmodel文件并添加了:
<genAnnotations source="http://www.eclipse.org/OCL/GenModel">
<details key="Use Delegates" value="false"/>
</genAnnotations>
我还检查了嵌入在 ecore 模型中的 OCL 的首选项实现以生成代码。但是当我尝试使用这个 genmodel 生成代码时,它只会生成没有 OCL 表达式的代码。我还应该怎么做才能从一个单独的文件为所有 OCL 表达式生成代码?
这是我的模型文件:ecore file
这是我的 genmodel 文件:.genmodel file
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 中的模型文件:
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 };
}
...
}
【问题讨论】: