Acceleo Undefined“Let”表达式

时间:2015-07-22 00:32:21

标签: java eclipse acceleo

我收到错误: Acceleo评估异常:未定义“允许”表达式在行中...在...中用于块...

这是我的模板:

[comment encoding = UTF-8 /]
[module generate('http://www.eclipse.org/emf/2002/Ecore', 'http://www.eclipse.org/emf/compare', 'http://www.workingmouse.com/mdsaas/featuremodel')]

[template public generateElement(comparison : Comparison)]
[comment @main/]
[file ('update.sql', false, 'UTF-8')]
/*SQL UPDATE SCRIPT TEST*/
[for (difference : Diff | comparison.getDifferences())]
    [let rc : ReferenceChange = difference.oclAsType(ReferenceChange)]
        [let dc : DomainClass = rc.value.oclAsType(DomainClass)]
[printTodo(difference.kind.toString(), 'DomainClass', dc.name.toString())/]
        [elselet da : DomainAttribute = rc.value.oclAsType(DomainAttribute)]
[printTodo(difference.kind.toString(), 'DomainAttribute', da.name.toString())/]
        [elselet t : Tile = rc.value.oclAsType(Tile)]
[printTodo(difference.kind.toString(), 'Tile', t.name.toString())/]
        [elselet dcr : DomainClassReference = rc.oclAsType(DomainClassReference)]
[printTodo(difference.kind.toString(), 'DomainClassReference', dcr.name.toString())/]
        [else]
ELSE
        [/let]
    [/let]
[/for]
[/file]
[/template]

[template public printTodo(kind : String, type : String, name : String)]
//TODO: [kind.toLowerCase().toUpperFirst()/] the [type/] '[name/]'
[/template] 

这是输出:

/*SQL UPDATE SCRIPT TEST*/
//TODO: Add the DomainClass 'null'

在控制台中使用此堆栈跟踪:

!ENTRY org.eclipse.acceleo.engine 2 2 2015-07-22 10:17:00.066
!MESSAGE Undefined "Let" expression at line 10 in Module generate for block let dc : DomainClass = rc.value.oclAsType(featuremodel::DomainClass). Last recorded value of self was ReferenceChangeSpec{reference=AbstractWithAttributes.attributes, value=Integer@4f72078d Test, parentMatch=MatchSpec{left=DomainClass@2262bc86 Text, right=DomainClass@4c4be9d8 Text, origin=<null>, #differences=3, #submatches=3}, match of value=MatchSpec{left=Integer@4f72078d Test, right=<null>, origin=<null>, #differences=0, #submatches=0}, kind=ADD, source=LEFT, state=UNRESOLVED}. Problem found while generating the file 'C:\Users\Samuel\Desktop\Workspace\VersionSandbox\models\update.sql'.
!STACK 0
org.eclipse.acceleo.engine.AcceleoEvaluationException: Undefined "Let" expression at line 10 in Module generate for block let dc : DomainClass = rc.value.oclAsType(featuremodel::DomainClass). Last recorded value of self was ReferenceChangeSpec{reference=AbstractWithAttributes.attributes, value=Integer@4f72078d Test, parentMatch=MatchSpec{left=DomainClass@2262bc86 Text, right=DomainClass@4c4be9d8 Text, origin=<null>, #differences=3, #submatches=3}, match of value=MatchSpec{left=Integer@4f72078d Test, right=<null>, origin=<null>, #differences=0, #submatches=0}, kind=ADD, source=LEFT, state=UNRESOLVED}. Problem found while generating the file 'C:\Users\Samuel\Desktop\Workspace\VersionSandbox\models\update.sql'.
    at generate.generateElement(Comparison)(generate.mtl:10)
    at generate.generateElement(Comparison)(generate.mtl:9)
    at generate.generateElement(Comparison)(generate.mtl:8)
    at generate.generateElement(Comparison)(generate.mtl:6)
    at generate.generateElement(Comparison)(generate.mtl:4)

!ENTRY org.eclipse.acceleo.engine 2 2 2015-07-22 10:17:00.073
!MESSAGE Undefined "Let" expression at line 10 in Module generate for block let dc : DomainClass = rc.value.oclAsType(featuremodel::DomainClass). Last recorded value of self was ReferenceChangeSpec{reference=AbstractWithAttributes.attributes, value=Stringg@21dd91da Title, parentMatch=MatchSpec{left=DomainClass@2262bc86 Text, right=DomainClass@4c4be9d8 Text, origin=<null>, #differences=3, #submatches=3}, match of value=MatchSpec{left=<null>, right=Stringg@21dd91da Title, origin=<null>, #differences=0, #submatches=0}, kind=DELETE, source=LEFT, state=UNRESOLVED}. Problem found while generating the file 'C:\Users\Samuel\Desktop\Workspace\VersionSandbox\models\update.sql'.
!STACK 0
org.eclipse.acceleo.engine.AcceleoEvaluationException: Undefined "Let" expression at line 10 in Module generate for block let dc : DomainClass = rc.value.oclAsType(featuremodel::DomainClass). Last recorded value of self was ReferenceChangeSpec{reference=AbstractWithAttributes.attributes, value=Stringg@21dd91da Title, parentMatch=MatchSpec{left=DomainClass@2262bc86 Text, right=DomainClass@4c4be9d8 Text, origin=<null>, #differences=3, #submatches=3}, match of value=MatchSpec{left=<null>, right=Stringg@21dd91da Title, origin=<null>, #differences=0, #submatches=0}, kind=DELETE, source=LEFT, state=UNRESOLVED}. Problem found while generating the file 'C:\Users\Samuel\Desktop\Workspace\VersionSandbox\models\update.sql'.
    at generate.generateElement(Comparison)(generate.mtl:10)
    at generate.generateElement(Comparison)(generate.mtl:9)
    at generate.generateElement(Comparison)(generate.mtl:8)
    at generate.generateElement(Comparison)(generate.mtl:6)
    at generate.generateElement(Comparison)(generate.mtl:4)

!ENTRY org.eclipse.acceleo.engine 2 2 2015-07-22 10:17:00.077
!MESSAGE Undefined "Let" expression at line 10 in Module generate for block let dc : DomainClass = rc.value.oclAsType(featuremodel::DomainClass). Last recorded value of self was ReferenceChangeSpec{reference=DomainClass.display, value=Stringg@21dd91da Title, parentMatch=MatchSpec{left=DomainClass@2262bc86 Text, right=DomainClass@4c4be9d8 Text, origin=<null>, #differences=3, #submatches=3}, match of value=MatchSpec{left=<null>, right=Stringg@21dd91da Title, origin=<null>, #differences=0, #submatches=0}, kind=CHANGE, source=LEFT, state=UNRESOLVED}. Problem found while generating the file 'C:\Users\Samuel\Desktop\Workspace\VersionSandbox\models\update.sql'.
!STACK 0
org.eclipse.acceleo.engine.AcceleoEvaluationException: Undefined "Let" expression at line 10 in Module generate for block let dc : DomainClass = rc.value.oclAsType(featuremodel::DomainClass). Last recorded value of self was ReferenceChangeSpec{reference=DomainClass.display, value=Stringg@21dd91da Title, parentMatch=MatchSpec{left=DomainClass@2262bc86 Text, right=DomainClass@4c4be9d8 Text, origin=<null>, #differences=3, #submatches=3}, match of value=MatchSpec{left=<null>, right=Stringg@21dd91da Title, origin=<null>, #differences=0, #submatches=0}, kind=CHANGE, source=LEFT, state=UNRESOLVED}. Problem found while generating the file 'C:\Users\Samuel\Desktop\Workspace\VersionSandbox\models\update.sql'.
    at generate.generateElement(Comparison)(generate.mtl:10)
    at generate.generateElement(Comparison)(generate.mtl:9)
    at generate.generateElement(Comparison)(generate.mtl:8)
    at generate.generateElement(Comparison)(generate.mtl:6)
    at generate.generateElement(Comparison)(generate.mtl:4)

我还在第10行用[code] [rc.value.toString()/] [/ code]打印了rc.value用于调试目的,输出为:

/*SQL UPDATE SCRIPT TEST*/
featuremodel.impl.IntegerImpl@7b1d2f65 (versionID: -1) (docoDescription: :), name: Test, listOrderable: false, indexed: NONE, label: true, allowCreate: true, allowUpdate: YES, isDashboard: false, defaultValue: null, tooltip: null, importType: OVERWRITE, required: false) (display: SPINNER) (DBType: INT)
featuremodel.impl.StringgImpl@4536a09a (versionID: 5) (docoDescription: The heading or title for the content text, name: Title, listOrderable: false, indexed: NONE, label: true, allowCreate: true, allowUpdate: YES, isDashboard: false, defaultValue: null, tooltip: The heading or title for the content text, importType: OVERWRITE, required: true) (DBType: VARCHAR, display: TEXTFIELD, i18n: true)
featuremodel.impl.StringgImpl@4536a09a (versionID: 5) (docoDescription: The heading or title for the content text, name: Title, listOrderable: false, indexed: NONE, label: true, allowCreate: true, allowUpdate: YES, isDashboard: false, defaultValue: null, tooltip: The heading or title for the content text, importType: OVERWRITE, required: true) (DBType: VARCHAR, display: TEXTFIELD, i18n: true)
featuremodel.impl.DomainClassImpl@7c857e8f (versionID: -1) (docoDescription: Demo, docoVideoURL: null, name: null) (isDashboard: false) (isMember: false, isOrderable: false, contributeToQuestionTile: NO, allowPermissions: false, hasContent: NO, hasCost: false, hasQuestions: NONE, hasReminder: false, hasTimeline: false, hasWorkflow: false, sharableOn: null, allowCreate: true, allowUpdate: YES, allowDelete: true, allowInactive: false, allowImport: NONE, allowDuplicate: false, allowExport: NONE, contributeToMenu: true)
//TODO: Add the DomainClass 'null'

我不知道该怎么办? 任何帮助将不胜感激

1 个答案:

答案 0 :(得分:0)

如果当前启动失败,则Acceleo Let函数会尝试转换并移动到下一个块。因此,删除所有 .oclAsType()调用,它应该可以正常工作。