Skip to content

Commit

Permalink
Fixed ExpressionStatement AQL if and let serialization.
Browse files Browse the repository at this point in the history
  • Loading branch information
ylussaud committed Jan 4, 2024
1 parent c202fca commit 0b0c314
Show file tree
Hide file tree
Showing 11 changed files with 44 additions and 1 deletion.
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
/*******************************************************************************
* Copyright (c) 2020, 2023 Obeo.
* Copyright (c) 2020, 2024 Obeo.
* All rights reserved. This program and the accompanying materials
* are made available under the terms of the Eclipse Public License v2.0
* which accompanies this distribution, and is available at
Expand Down Expand Up @@ -39,6 +39,8 @@
import org.eclipse.acceleo.Template;
import org.eclipse.acceleo.TextStatement;
import org.eclipse.acceleo.Variable;
import org.eclipse.acceleo.query.ast.Conditional;
import org.eclipse.acceleo.query.ast.Let;
import org.eclipse.acceleo.query.parser.AstBuilder;
import org.eclipse.acceleo.query.parser.AstSerializer;
import org.eclipse.acceleo.util.AcceleoSwitch;
Expand Down Expand Up @@ -206,6 +208,11 @@ public Object caseExpression(Expression expression) {
@Override
public Object caseExpressionStatement(ExpressionStatement expressionStatement) {
builder.append(AcceleoParser.EXPRESSION_STATEMENT_START);
if (expressionStatement.getExpression() != null && (expressionStatement.getExpression()
.getAql() instanceof Conditional || expressionStatement.getExpression()
.getAql() instanceof Let)) {
builder.append(SPACE);
}
doSwitch(expressionStatement.getExpression());
builder.append(AcceleoParser.EXPRESSION_STATEMENT_END);
if (expressionStatement.isNewLineNeeded()) {
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@

header position 0..59
module myModule
metamodel http://www.eclipse.org/emf/2002/Ecore (18..56)

public template myTemplate(myParam : EPackage (89..114))
[if (.equals(.aqlFeatureAccess(myParam, 'name'), '')) then 'No name' else .aqlFeatureAccess(myParam, 'name') endif (121..180)/] (newLineNeeded (119..183) (116..183)
[/template] (61..194) (0..194)
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
[module myModule('http://www.eclipse.org/emf/2002/Ecore')/]

[template public myTemplate(myParam : ecore::EPackage)]
[ if myParam.name = '' then 'No name' else myParam.name endif/]
[/template]
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@

header position 0..59
module myModule
metamodel http://www.eclipse.org/emf/2002/Ecore (18..56)

public template myTemplate(myParam : EPackage (89..114))
[p = myParamnull, in .aqlFeatureAccess(p, 'name') (121..146)/] (newLineNeeded (119..149) (116..149)
[/template] (61..160) (0..160)
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
[module myModule('http://www.eclipse.org/emf/2002/Ecore')/]

[template public myTemplate(myParam : ecore::EPackage)]
[ let p = myParam in p.name/]
[/template]
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
[module myModule('http://www.eclipse.org/emf/2002/Ecore')/]

[template public myTemplate(myParam : ecore::EPackage)]
[ if myParam.name = '' then 'No name' else myParam.name endif/]
[/template]
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
[module myModule('http://www.eclipse.org/emf/2002/Ecore')/]

[template public myTemplate(myParam : ecore::EPackage)]
[ let p = myParam in p.name/]
[/template]

0 comments on commit 0b0c314

Please sign in to comment.