[英]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.