diff options
Diffstat (limited to 'plugins/org.eclipse.qvtd.xtext.qvtimperative/src/org/eclipse')
5 files changed, 88 insertions, 138 deletions
diff --git a/plugins/org.eclipse.qvtd.xtext.qvtimperative/src/org/eclipse/qvtd/xtext/qvtimperative/as2cs/QVTimperativeDeclarationVisitor.java b/plugins/org.eclipse.qvtd.xtext.qvtimperative/src/org/eclipse/qvtd/xtext/qvtimperative/as2cs/QVTimperativeDeclarationVisitor.java index 116ffde04..208fb1c02 100644 --- a/plugins/org.eclipse.qvtd.xtext.qvtimperative/src/org/eclipse/qvtd/xtext/qvtimperative/as2cs/QVTimperativeDeclarationVisitor.java +++ b/plugins/org.eclipse.qvtd.xtext.qvtimperative/src/org/eclipse/qvtd/xtext/qvtimperative/as2cs/QVTimperativeDeclarationVisitor.java @@ -71,8 +71,8 @@ import org.eclipse.qvtd.pivot.qvtbase.utilities.QVTbaseUtil; import org.eclipse.qvtd.pivot.qvtimperative.AddStatement; import org.eclipse.qvtd.pivot.qvtimperative.CheckStatement; import org.eclipse.qvtd.pivot.qvtimperative.ConnectionVariable; +import org.eclipse.qvtd.pivot.qvtimperative.DeclareStatement; import org.eclipse.qvtd.pivot.qvtimperative.GuardVariable; -import org.eclipse.qvtd.pivot.qvtimperative.ImperativeDomain; import org.eclipse.qvtd.pivot.qvtimperative.ImperativeModel; import org.eclipse.qvtd.pivot.qvtimperative.ImperativeTypedModel; import org.eclipse.qvtd.pivot.qvtimperative.InConnectionVariable; @@ -83,8 +83,8 @@ import org.eclipse.qvtd.pivot.qvtimperative.MappingCallBinding; import org.eclipse.qvtd.pivot.qvtimperative.MappingLoop; import org.eclipse.qvtd.pivot.qvtimperative.MappingStatement; import org.eclipse.qvtd.pivot.qvtimperative.NewStatement; +import org.eclipse.qvtd.pivot.qvtimperative.ObservableStatement; import org.eclipse.qvtd.pivot.qvtimperative.OutConnectionVariable; -import org.eclipse.qvtd.pivot.qvtimperative.DeclareStatement; import org.eclipse.qvtd.pivot.qvtimperative.SetStatement; import org.eclipse.qvtd.pivot.qvtimperative.Statement; import org.eclipse.qvtd.pivot.qvtimperative.VariableStatement; @@ -96,8 +96,8 @@ import org.eclipse.qvtd.xtext.qvtbasecs.QVTbaseCSPackage; import org.eclipse.qvtd.xtext.qvtbasecs.QualifiedPackageCS; import org.eclipse.qvtd.xtext.qvtimperativecs.AddStatementCS; import org.eclipse.qvtd.xtext.qvtimperativecs.CheckStatementCS; +import org.eclipse.qvtd.xtext.qvtimperativecs.DeclareStatementCS; import org.eclipse.qvtd.xtext.qvtimperativecs.DirectionCS; -import org.eclipse.qvtd.xtext.qvtimperativecs.DomainCS; import org.eclipse.qvtd.xtext.qvtimperativecs.GuardVariableCS; import org.eclipse.qvtd.xtext.qvtimperativecs.InoutVariableCS; import org.eclipse.qvtd.xtext.qvtimperativecs.MappingCS; @@ -108,7 +108,6 @@ import org.eclipse.qvtd.xtext.qvtimperativecs.MappingStatementCS; import org.eclipse.qvtd.xtext.qvtimperativecs.NewStatementCS; import org.eclipse.qvtd.xtext.qvtimperativecs.OutVariableCS; import org.eclipse.qvtd.xtext.qvtimperativecs.ParamDeclarationCS; -import org.eclipse.qvtd.xtext.qvtimperativecs.DeclareStatementCS; import org.eclipse.qvtd.xtext.qvtimperativecs.QVTimperativeCSPackage; import org.eclipse.qvtd.xtext.qvtimperativecs.QueryCS; import org.eclipse.qvtd.xtext.qvtimperativecs.SetStatementCS; @@ -236,10 +235,6 @@ public class QVTimperativeDeclarationVisitor extends QVTbaseDeclarationVisitor i } } - protected @NonNull DomainCS createCoreDomain(@NonNull ImperativeDomain asCoreDomain) { - return context.refreshElement(DomainCS.class, QVTimperativeCSPackage.Literals.DOMAIN_CS, asCoreDomain); - } - protected void gatherTransformations(@NonNull List<Transformation> asTransformations, @NonNull List<Package> ownedPackages) { for (org.eclipse.ocl.pivot.Package asPackage : ownedPackages) { for (org.eclipse.ocl.pivot.Class asClass : asPackage.getOwnedClasses()) { @@ -298,6 +293,16 @@ public class QVTimperativeDeclarationVisitor extends QVTbaseDeclarationVisitor i } } + protected void refreshObservedProperties(@NonNull ObservableStatement asStatement, /*@NonNull*/ List<PathNameCS> csPathNames, /*@NonNull*/ List<@NonNull Property> asProperties) { + List<PathNameCS> pathNames = new ArrayList<PathNameCS>(); + for (@NonNull Property asProperty : asProperties) { + @NonNull PathNameCS csPathName = BaseCSFactory.eINSTANCE.createPathNameCS(); + pathNames.add(csPathName); + context.refreshPathName(csPathName, asProperty, PivotUtil.getContainingNamespace(asStatement)); + } + context.refreshList(csPathNames, pathNames); + } + protected void refreshOwnedInTransformation(@NonNull MappingCS csMapping, @NonNull Mapping asMapping) { Transformation asTransformation = asMapping.getTransformation(); if (asTransformation != null) { @@ -348,7 +353,8 @@ public class QVTimperativeDeclarationVisitor extends QVTbaseDeclarationVisitor i ConnectionVariable asVariable = asAddStatement.getTargetVariable(); assert asVariable != null; csStatement.setTargetVariable(asVariable); - csStatement.setOwnedExpression(context.visitDeclaration(ExpCS.class, asAddStatement.getOwnedInit())); + csStatement.setOwnedExpression(context.visitDeclaration(ExpCS.class, asAddStatement.getOwnedExpression())); + refreshObservedProperties(asAddStatement, csStatement.getObservedProperties(), ClassUtil.nullFree(asAddStatement.getObservedProperties())); return csStatement; } @@ -362,7 +368,8 @@ public class QVTimperativeDeclarationVisitor extends QVTbaseDeclarationVisitor i assert asPredicate.eContainer() instanceof Mapping; CheckStatementCS csPredicate = context.refreshElement(CheckStatementCS.class, QVTimperativeCSPackage.Literals.CHECK_STATEMENT_CS, asPredicate); csPredicate.setPivot(asPredicate); - csPredicate.setOwnedCondition(createExpCS(asPredicate.getOwnedCondition())); + csPredicate.setOwnedCondition(createExpCS(asPredicate.getOwnedExpression())); + refreshObservedProperties(asPredicate, csPredicate.getObservedProperties(), ClassUtil.nullFree(asPredicate.getObservedProperties())); return csPredicate; } @@ -374,8 +381,9 @@ public class QVTimperativeDeclarationVisitor extends QVTbaseDeclarationVisitor i @Override public ElementCS visitDeclareStatement(@NonNull DeclareStatement asVariable) { DeclareStatementCS csVariable = refreshTypedElement(DeclareStatementCS.class, QVTimperativeCSPackage.Literals.DECLARE_STATEMENT_CS, asVariable); - csVariable.setOwnedInit(context.visitDeclaration(ExpCS.class, asVariable.getOwnedInit())); + csVariable.setOwnedExpression(context.visitDeclaration(ExpCS.class, asVariable.getOwnedExpression())); csVariable.setIsChecked(asVariable.isIsChecked()); + refreshObservedProperties(asVariable, csVariable.getObservedProperties(), ClassUtil.nullFree(asVariable.getObservedProperties())); return csVariable; } @@ -414,19 +422,6 @@ public class QVTimperativeDeclarationVisitor extends QVTbaseDeclarationVisitor i } @Override - public ElementCS visitImperativeDomain(@NonNull ImperativeDomain asCoreDomain) { - DomainCS csDomain = createCoreDomain(asCoreDomain); - csDomain.setPivot(asCoreDomain); - csDomain.setIsCheck(asCoreDomain.isIsCheckable()); - csDomain.setDirection((ImperativeTypedModel) asCoreDomain.getTypedModel()); - csDomain.setIsEnforce(asCoreDomain.isIsEnforceable()); - Transformation asTransformation = QVTbaseUtil.getContainingTransformation(asCoreDomain); - assert asTransformation != null; - refreshUsedProperties(asTransformation, csDomain.getCheckedProperties(), ClassUtil.nullFree(asCoreDomain.getCheckedProperties())); - return csDomain; - } - - @Override public ElementCS visitImperativeModel(@NonNull ImperativeModel asModel) { assert asModel.eContainer() == null; TopLevelCS csDocument = context.refreshElement(TopLevelCS.class, QVTimperativeCSPackage.Literals.TOP_LEVEL_CS, asModel); @@ -555,7 +550,6 @@ public class QVTimperativeDeclarationVisitor extends QVTbaseDeclarationVisitor i refreshOwnedInTransformation(csMapping, asMapping); context.refreshList(csMapping.getOwnedGuardVariables(), context.visitDeclarations(GuardVariableCS.class, asMapping.getOwnedGuardVariables(), null)); context.refreshList(csMapping.getOwnedInoutVariables(), context.visitDeclarations(InoutVariableCS.class, asMapping.getInoutVariables(), null)); - context.refreshList(csMapping.getOwnedDomains(), context.visitDeclarations(DomainCS.class, asMapping.getDomain(), null)); context.refreshList(csMapping.getOwnedStatements(), context.visitDeclarations(StatementCS.class, asMapping.getOwnedStatements(), null)); return csMapping; } @@ -574,7 +568,6 @@ public class QVTimperativeDeclarationVisitor extends QVTbaseDeclarationVisitor i public ElementCS visitMappingCallBinding(@NonNull MappingCallBinding asMappingCallBinding) { MappingCallBindingCS csMappingCallBinding = context.refreshElement(MappingCallBindingCS.class, QVTimperativeCSPackage.Literals.MAPPING_CALL_BINDING_CS, asMappingCallBinding); csMappingCallBinding.setPivot(asMappingCallBinding); - csMappingCallBinding.setIsPolled(asMappingCallBinding.isIsPolled()); csMappingCallBinding.setReferredVariable(asMappingCallBinding.getBoundVariable()); csMappingCallBinding.setOwnedValue(createExpCS(asMappingCallBinding.getValue())); return csMappingCallBinding; @@ -585,8 +578,9 @@ public class QVTimperativeDeclarationVisitor extends QVTbaseDeclarationVisitor i MappingLoopCS csMappingLoop = context.refreshElement(MappingLoopCS.class, QVTimperativeCSPackage.Literals.MAPPING_LOOP_CS, asMappingLoop); csMappingLoop.setPivot(asMappingLoop); csMappingLoop.setOwnedIterator(context.visitDeclaration(VariableCS.class, asMappingLoop.getOwnedIterators().get(0))); - csMappingLoop.setOwnedInExpression(createExpCS(asMappingLoop.getOwnedSource())); + csMappingLoop.setOwnedInExpression(createExpCS(asMappingLoop.getOwnedExpression())); context.refreshList(csMappingLoop.getOwnedMappingStatements(), context.visitDeclarations(MappingStatementCS.class, asMappingLoop.getOwnedMappingStatements(), null)); + refreshObservedProperties(asMappingLoop, csMappingLoop.getObservedProperties(), ClassUtil.nullFree(asMappingLoop.getObservedProperties())); return csMappingLoop; } @@ -602,11 +596,17 @@ public class QVTimperativeDeclarationVisitor extends QVTbaseDeclarationVisitor i NewStatementCS csNewStatement = context.refreshNamedElement(NewStatementCS.class, QVTimperativeCSPackage.Literals.NEW_STATEMENT_CS, asNewStatement); csNewStatement.setOwnedType(createTypeRefCS(asNewStatement.getType(), asUsedPackage)); csNewStatement.setReferredTypedModel(asTypedModel); - csNewStatement.setOwnedInit(context.visitDeclaration(ExpCS.class, asNewStatement.getOwnedInit())); + csNewStatement.setOwnedExpression(context.visitDeclaration(ExpCS.class, asNewStatement.getOwnedExpression())); + refreshObservedProperties(asNewStatement, csNewStatement.getObservedProperties(), ClassUtil.nullFree(asNewStatement.getObservedProperties())); return csNewStatement; } @Override + public ElementCS visitObservableStatement(@NonNull ObservableStatement object) { + return visiting(object); + } + + @Override public ElementCS visitOutConnectionVariable(@NonNull OutConnectionVariable asVariable) { OutVariableCS csVariable = context.refreshNamedElement(OutVariableCS.class, QVTimperativeCSPackage.Literals.OUT_VARIABLE_CS, asVariable); csVariable.setPivot(asVariable); @@ -657,8 +657,9 @@ public class QVTimperativeDeclarationVisitor extends QVTbaseDeclarationVisitor i SetStatementCS csStatement = context.refreshElement(SetStatementCS.class, QVTimperativeCSPackage.Literals.SET_STATEMENT_CS, asSetStatement); csStatement.setReferredVariable(asSetStatement.getTargetVariable()); csStatement.setReferredProperty(QVTimperativeUtil.getTargetProperty(asSetStatement)); - csStatement.setOwnedInit(createExpCS(asSetStatement.getOwnedInit())); + csStatement.setOwnedExpression(createExpCS(asSetStatement.getOwnedExpression())); csStatement.setIsNotify(asSetStatement.isIsNotify()); + refreshObservedProperties(asSetStatement, csStatement.getObservedProperties(), ClassUtil.nullFree(asSetStatement.getObservedProperties())); return csStatement; } @@ -699,11 +700,11 @@ public class QVTimperativeDeclarationVisitor extends QVTbaseDeclarationVisitor i if (asPredicate instanceof VariablePredicate) { VariablePredicate asVariablePredicate = (VariablePredicate)asPredicate; if (asVariablePredicate.getTargetVariable() == asVariable) { - OCLExpression ownedInit = asVariablePredicate.getConditionExpression(); + OCLExpression ownedExpression = asVariablePredicate.getConditionExpression(); PredicateVariableCS csUnrealizedVariable = context.refreshNamedElement(PredicateVariableCS.class, QVTimperativeCSPackage.Literals.PREDICATE_VARIABLE_CS, asVariable); csUnrealizedVariable.setPivot(asVariable); csUnrealizedVariable.setOwnedType(createTypeRefCS(asVariable.getType(), getScope(asVariable))); - csUnrealizedVariable.setOwnedInitExpression(context.visitDeclaration(ExpCS.class, ownedInit)); + csUnrealizedVariable.setOwnedExpressionExpression(context.visitDeclaration(ExpCS.class, ownedExpression)); return csUnrealizedVariable; } } diff --git a/plugins/org.eclipse.qvtd.xtext.qvtimperative/src/org/eclipse/qvtd/xtext/qvtimperative/cs2as/QVTimperativeCSContainmentVisitor.java b/plugins/org.eclipse.qvtd.xtext.qvtimperative/src/org/eclipse/qvtd/xtext/qvtimperative/cs2as/QVTimperativeCSContainmentVisitor.java index 910f37b15..2226176a0 100644 --- a/plugins/org.eclipse.qvtd.xtext.qvtimperative/src/org/eclipse/qvtd/xtext/qvtimperative/cs2as/QVTimperativeCSContainmentVisitor.java +++ b/plugins/org.eclipse.qvtd.xtext.qvtimperative/src/org/eclipse/qvtd/xtext/qvtimperative/cs2as/QVTimperativeCSContainmentVisitor.java @@ -43,7 +43,6 @@ import org.eclipse.qvtd.pivot.qvtimperative.AddStatement; import org.eclipse.qvtd.pivot.qvtimperative.CheckStatement; import org.eclipse.qvtd.pivot.qvtimperative.DeclareStatement; import org.eclipse.qvtd.pivot.qvtimperative.GuardVariable; -import org.eclipse.qvtd.pivot.qvtimperative.ImperativeDomain; import org.eclipse.qvtd.pivot.qvtimperative.ImperativeModel; import org.eclipse.qvtd.pivot.qvtimperative.ImperativeTypedModel; import org.eclipse.qvtd.pivot.qvtimperative.InConnectionVariable; @@ -62,7 +61,6 @@ import org.eclipse.qvtd.xtext.qvtimperativecs.AddStatementCS; import org.eclipse.qvtd.xtext.qvtimperativecs.CheckStatementCS; import org.eclipse.qvtd.xtext.qvtimperativecs.DeclareStatementCS; import org.eclipse.qvtd.xtext.qvtimperativecs.DirectionCS; -import org.eclipse.qvtd.xtext.qvtimperativecs.DomainCS; import org.eclipse.qvtd.xtext.qvtimperativecs.GuardVariableCS; import org.eclipse.qvtd.xtext.qvtimperativecs.InoutVariableCS; import org.eclipse.qvtd.xtext.qvtimperativecs.MappingCS; @@ -96,29 +94,6 @@ public class QVTimperativeCSContainmentVisitor extends AbstractQVTimperativeCSCo } } - protected static class DomainContentContinuation extends SingleContinuation<DomainCS> - { - private DomainContentContinuation(@NonNull CS2ASConversion context, @NonNull DomainCS csElement) { - super(context, null, null, csElement); - } - - @Override - public BasicContinuation<?> execute() { - ImperativeDomain pDomain = PivotUtil.getPivot(ImperativeDomain.class, csElement); - if (pDomain != null) { - TypedModel direction = csElement.getDirection(); - if (direction == null) { - Transformation transformation = QVTbaseUtil.getContainingTransformation(pDomain); - if (transformation != null) { - direction = transformation.getModelParameter(null); - } - } - pDomain.setTypedModel(direction); - } - return null; - } - } - public static class GuardVariableCompletion extends SingleContinuation<@NonNull GuardVariableCS> { public GuardVariableCompletion(@NonNull CS2ASConversion context, @NonNull GuardVariableCS csElement) { @@ -244,15 +219,6 @@ public class QVTimperativeCSContainmentVisitor extends AbstractQVTimperativeCSCo } @Override - public Continuation<?> visitDomainCS(@NonNull DomainCS csElement) { - ImperativeDomain pivotElement = context.refreshModelElement(ImperativeDomain.class, QVTimperativePackage.Literals.IMPERATIVE_DOMAIN, csElement); - pivotElement.setIsCheckable(csElement.isIsCheck()); - pivotElement.setIsEnforceable(csElement.isIsEnforce()); - context.refreshComments(pivotElement, csElement); - return new DomainContentContinuation(context, csElement); - } - - @Override public Continuation<?> visitGuardVariableCS(@NonNull GuardVariableCS csElement) { refreshNamedElement(GuardVariable.class, QVTimperativePackage.Literals.GUARD_VARIABLE, csElement); return new GuardVariableCompletion(context, csElement); @@ -269,7 +235,6 @@ public class QVTimperativeCSContainmentVisitor extends AbstractQVTimperativeCSCo Mapping pivotElement = refreshNamedElement(Mapping.class, QVTimperativePackage.Literals.MAPPING, csElement); context.refreshPivotList(GuardVariable.class, pivotElement.getOwnedGuardVariables(), csElement.getOwnedGuardVariables()); context.refreshPivotList(InConnectionVariable.class, pivotElement.getInoutVariables(), csElement.getOwnedInoutVariables()); - context.refreshPivotList(ImperativeDomain.class, pivotElement.getDomain(), csElement.getOwnedDomains()); context.refreshPivotList(Statement.class, pivotElement.getOwnedStatements(), csElement.getOwnedStatements()); return null; } @@ -286,7 +251,6 @@ public class QVTimperativeCSContainmentVisitor extends AbstractQVTimperativeCSCo @Override public Continuation<?> visitMappingCallBindingCS(@NonNull MappingCallBindingCS csElement) { @NonNull MappingCallBinding pivotElement = context.refreshModelElement(MappingCallBinding.class, QVTimperativePackage.Literals.MAPPING_CALL_BINDING, csElement); - pivotElement.setIsPolled(csElement.isIsPolled()); context.refreshComments(pivotElement, csElement); return null; } diff --git a/plugins/org.eclipse.qvtd.xtext.qvtimperative/src/org/eclipse/qvtd/xtext/qvtimperative/cs2as/QVTimperativeCSPostOrderVisitor.java b/plugins/org.eclipse.qvtd.xtext.qvtimperative/src/org/eclipse/qvtd/xtext/qvtimperative/cs2as/QVTimperativeCSPostOrderVisitor.java index 4a5450927..f606001a8 100644 --- a/plugins/org.eclipse.qvtd.xtext.qvtimperative/src/org/eclipse/qvtd/xtext/qvtimperative/cs2as/QVTimperativeCSPostOrderVisitor.java +++ b/plugins/org.eclipse.qvtd.xtext.qvtimperative/src/org/eclipse/qvtd/xtext/qvtimperative/cs2as/QVTimperativeCSPostOrderVisitor.java @@ -29,17 +29,17 @@ import org.eclipse.ocl.xtext.essentialoclcs.ExpCS; import org.eclipse.qvtd.pivot.qvtbase.Function; import org.eclipse.qvtd.pivot.qvtimperative.AddStatement; import org.eclipse.qvtd.pivot.qvtimperative.CheckStatement; +import org.eclipse.qvtd.pivot.qvtimperative.DeclareStatement; import org.eclipse.qvtd.pivot.qvtimperative.GuardVariable; import org.eclipse.qvtd.pivot.qvtimperative.LoopVariable; import org.eclipse.qvtd.pivot.qvtimperative.MappingCallBinding; import org.eclipse.qvtd.pivot.qvtimperative.MappingLoop; import org.eclipse.qvtd.pivot.qvtimperative.NewStatement; -import org.eclipse.qvtd.pivot.qvtimperative.DeclareStatement; import org.eclipse.qvtd.pivot.qvtimperative.SetStatement; import org.eclipse.qvtd.xtext.qvtimperativecs.AddStatementCS; import org.eclipse.qvtd.xtext.qvtimperativecs.CheckStatementCS; +import org.eclipse.qvtd.xtext.qvtimperativecs.DeclareStatementCS; import org.eclipse.qvtd.xtext.qvtimperativecs.DirectionCS; -import org.eclipse.qvtd.xtext.qvtimperativecs.DomainCS; import org.eclipse.qvtd.xtext.qvtimperativecs.GuardVariableCS; import org.eclipse.qvtd.xtext.qvtimperativecs.MappingCS; import org.eclipse.qvtd.xtext.qvtimperativecs.MappingCallBindingCS; @@ -47,7 +47,6 @@ import org.eclipse.qvtd.xtext.qvtimperativecs.MappingLoopCS; import org.eclipse.qvtd.xtext.qvtimperativecs.NewStatementCS; import org.eclipse.qvtd.xtext.qvtimperativecs.OutVariableCS; import org.eclipse.qvtd.xtext.qvtimperativecs.ParamDeclarationCS; -import org.eclipse.qvtd.xtext.qvtimperativecs.DeclareStatementCS; import org.eclipse.qvtd.xtext.qvtimperativecs.QueryCS; import org.eclipse.qvtd.xtext.qvtimperativecs.SetStatementCS; import org.eclipse.qvtd.xtext.qvtimperativecs.TopLevelCS; @@ -106,7 +105,7 @@ public class QVTimperativeCSPostOrderVisitor extends AbstractQVTimperativeCSPost ExpCS csInitialiser = csElement.getOwnedExpression(); if (csInitialiser != null) { OCLExpression initialiser = context.visitLeft2Right(OCLExpression.class, csInitialiser); - asAddStatement.setOwnedInit(initialiser); + asAddStatement.setOwnedExpression(initialiser); } } return null; @@ -121,7 +120,7 @@ public class QVTimperativeCSPostOrderVisitor extends AbstractQVTimperativeCSPost if (csCondition != null) { asCondition = context.visitLeft2Right(OCLExpression.class, csCondition); } - asPredicate.setOwnedCondition(asCondition); + asPredicate.setOwnedExpression(asCondition); } return null; } @@ -135,10 +134,10 @@ public class QVTimperativeCSPostOrderVisitor extends AbstractQVTimperativeCSPost public Continuation<?> visitDeclareStatementCS(@NonNull DeclareStatementCS csElement) { DeclareStatement asVariable = PivotUtil.getPivot(DeclareStatement.class, csElement); if (asVariable != null) { - ExpCS expression = csElement.getOwnedInit(); + ExpCS expression = csElement.getOwnedExpression(); if (expression != null) { OCLExpression target = context.visitLeft2Right(OCLExpression.class, expression); - asVariable.setOwnedInit(target); + asVariable.setOwnedExpression(target); if ((csElement.getOwnedType() == null) && (target != null)) { context.setType(asVariable, target.getType(), target.isIsRequired(), target.getTypeValue()); } @@ -152,7 +151,7 @@ public class QVTimperativeCSPostOrderVisitor extends AbstractQVTimperativeCSPost ExpCS csTarget = csElement.getOwnedTarget(); assert csTarget != null; OCLExpression target = context.visitLeft2Right(OCLExpression.class, csTarget); - ExpCS csInitialiser = csElement.getOwnedInit(); + ExpCS csInitialiser = csElement.getOwnedExpression(); assert csInitialiser != null; CheckVariableStatement assignment = null; if (target instanceof NavigationCallExp) { @@ -169,7 +168,7 @@ public class QVTimperativeCSPostOrderVisitor extends AbstractQVTimperativeCSPost } if (assignment != null) { OCLExpression initialiser = context.visitLeft2Right(OCLExpression.class, csInitialiser); - assignment.setOwnedInit(initialiser); + assignment.setOwnedExpression(initialiser); // pAssignments.add(assignment); } return null; @@ -181,11 +180,6 @@ public class QVTimperativeCSPostOrderVisitor extends AbstractQVTimperativeCSPost } @Override - public Continuation<?> visitDomainCS(@NonNull DomainCS csElement) { - return null; - } - - @Override public Continuation<?> visitGuardVariableCS(@NonNull GuardVariableCS csElement) { GuardVariable asGuardVariable = PivotUtil.getPivot(GuardVariable.class, csElement); if (asGuardVariable != null) { @@ -212,7 +206,7 @@ public class QVTimperativeCSPostOrderVisitor extends AbstractQVTimperativeCSPost if (expression != null) { OCLExpression target = context.visitLeft2Right(OCLExpression.class, expression); if (target != null) { - pMappingLoop.setOwnedSource(target); + pMappingLoop.setOwnedExpression(target); List<LoopVariable> iterators = pMappingLoop.getOwnedIterators(); if (iterators.size() > 0) { LoopVariable iterator = iterators.get(0); @@ -235,10 +229,10 @@ public class QVTimperativeCSPostOrderVisitor extends AbstractQVTimperativeCSPost NewStatement asNewStatement = PivotUtil.getPivot(NewStatement.class, csElement); if (asNewStatement != null) { asNewStatement.setReferredTypedModel(csElement.getReferredTypedModel()); - ExpCS expression = csElement.getOwnedInit(); + ExpCS expression = csElement.getOwnedExpression(); if (expression != null) { OCLExpression target = context.visitLeft2Right(OCLExpression.class, expression); - asNewStatement.setOwnedInit(target); + asNewStatement.setOwnedExpression(target); } } return null; @@ -278,11 +272,11 @@ public class QVTimperativeCSPostOrderVisitor extends AbstractQVTimperativeCSPost boolean isImplicit = targetProperty.isIsImplicit(); setStatement.setTargetProperty(isImplicit ? targetProperty.getOpposite() : targetProperty); setStatement.setIsOpposite(isImplicit); - ExpCS csInitialiser = csElement.getOwnedInit(); + ExpCS csInitialiser = csElement.getOwnedExpression(); OCLExpression target = csInitialiser != null ? context.visitLeft2Right(OCLExpression.class, csInitialiser) : null; setStatement.setTargetProperty(targetProperty); // propertyAssignment.setIsOpposite(target instanceof FeatureCallExp); // FIXME isOpposite - setStatement.setOwnedInit(target); + setStatement.setOwnedExpression(target); // pAssignments.add(assignment); } return null; diff --git a/plugins/org.eclipse.qvtd.xtext.qvtimperative/src/org/eclipse/qvtd/xtext/qvtimperative/cs2as/QVTimperativeCSPreOrderVisitor.java b/plugins/org.eclipse.qvtd.xtext.qvtimperative/src/org/eclipse/qvtd/xtext/qvtimperative/cs2as/QVTimperativeCSPreOrderVisitor.java index a61c09d2e..e4db4c055 100644 --- a/plugins/org.eclipse.qvtd.xtext.qvtimperative/src/org/eclipse/qvtd/xtext/qvtimperative/cs2as/QVTimperativeCSPreOrderVisitor.java +++ b/plugins/org.eclipse.qvtd.xtext.qvtimperative/src/org/eclipse/qvtd/xtext/qvtimperative/cs2as/QVTimperativeCSPreOrderVisitor.java @@ -29,6 +29,7 @@ import org.eclipse.ocl.xtext.base.cs2as.PivotDependency; import org.eclipse.ocl.xtext.base.cs2as.SingleContinuation; import org.eclipse.ocl.xtext.basecs.ElementCS; import org.eclipse.ocl.xtext.basecs.PathNameCS; +import org.eclipse.ocl.xtext.basecs.PivotableElementCS; import org.eclipse.ocl.xtext.basecs.TypedRefCS; import org.eclipse.ocl.xtext.essentialoclcs.VariableCS; import org.eclipse.qvtd.pivot.qvtbase.Function; @@ -36,7 +37,6 @@ import org.eclipse.qvtd.pivot.qvtbase.FunctionParameter; import org.eclipse.qvtd.pivot.qvtbase.Transformation; import org.eclipse.qvtd.pivot.qvtimperative.DeclareStatement; import org.eclipse.qvtd.pivot.qvtimperative.GuardVariable; -import org.eclipse.qvtd.pivot.qvtimperative.ImperativeDomain; import org.eclipse.qvtd.pivot.qvtimperative.InConnectionVariable; import org.eclipse.qvtd.pivot.qvtimperative.LoopVariable; import org.eclipse.qvtd.pivot.qvtimperative.Mapping; @@ -44,12 +44,13 @@ import org.eclipse.qvtd.pivot.qvtimperative.MappingCall; import org.eclipse.qvtd.pivot.qvtimperative.MappingCallBinding; import org.eclipse.qvtd.pivot.qvtimperative.MappingLoop; import org.eclipse.qvtd.pivot.qvtimperative.NewStatement; +import org.eclipse.qvtd.pivot.qvtimperative.ObservableStatement; import org.eclipse.qvtd.pivot.qvtimperative.OutConnectionVariable; import org.eclipse.qvtd.pivot.qvtimperative.QVTimperativePackage; +import org.eclipse.qvtd.xtext.qvtimperativecs.AddStatementCS; import org.eclipse.qvtd.xtext.qvtimperativecs.CheckStatementCS; import org.eclipse.qvtd.xtext.qvtimperativecs.DeclareStatementCS; import org.eclipse.qvtd.xtext.qvtimperativecs.DirectionCS; -import org.eclipse.qvtd.xtext.qvtimperativecs.DomainCS; import org.eclipse.qvtd.xtext.qvtimperativecs.GuardVariableCS; import org.eclipse.qvtd.xtext.qvtimperativecs.InoutVariableCS; import org.eclipse.qvtd.xtext.qvtimperativecs.MappingCS; @@ -252,27 +253,36 @@ public class QVTimperativeCSPreOrderVisitor extends AbstractQVTimperativeCSPreOr } } - private void refreshUsedProperties(@NonNull DomainCS csDomain, - /*@NonNull*/ List<Property> asProperties, /*@NonNull*/ List<PathNameCS> csProperties) { + private void refreshObservedProperties(@NonNull PivotableElementCS csElement, /*@NonNull*/ List<PathNameCS> csProperties) { + ObservableStatement asElement = PivotUtil.getPivot(ObservableStatement.class, csElement); + assert asElement != null; List<Property> properties = new ArrayList<Property>(); for (PathNameCS csPathName : csProperties) { if (csPathName != null) { - Property asProperty = lookupProperty(csDomain, csPathName, null); + Property asProperty = lookupProperty(csElement, csPathName, null); if (asProperty != null) { properties.add(asProperty); } } } - context.refreshList(asProperties, properties); + context.refreshList(asElement.getObservedProperties(), properties); + } + + @Override + public Continuation<?> visitAddStatementCS(@NonNull AddStatementCS csElement) { + refreshObservedProperties(csElement, csElement.getObservedProperties()); + return null; } @Override public Continuation<?> visitCheckStatementCS(@NonNull CheckStatementCS csElement) { + refreshObservedProperties(csElement, csElement.getObservedProperties()); return null; } @Override public @Nullable Continuation<?> visitDeclareStatementCS(@NonNull DeclareStatementCS csElement) { + refreshObservedProperties(csElement, csElement.getObservedProperties()); return new DeclareStatementCompletion(context, csElement); } @@ -282,15 +292,6 @@ public class QVTimperativeCSPreOrderVisitor extends AbstractQVTimperativeCSPreOr } @Override - public @Nullable Continuation<?> visitDomainCS(@NonNull DomainCS csDomain) { - ImperativeDomain asArea = PivotUtil.getPivot(ImperativeDomain.class, csDomain); - if (asArea != null) { - refreshUsedProperties(csDomain, asArea.getCheckedProperties(), csDomain.getCheckedProperties()); - } - return null; - } - - @Override public @Nullable Continuation<?> visitGuardVariableCS(@NonNull GuardVariableCS csElement) { return new GuardVariableCompletion(context, csElement); } @@ -329,11 +330,13 @@ public class QVTimperativeCSPreOrderVisitor extends AbstractQVTimperativeCSPreOr @Override public Continuation<?> visitMappingLoopCS(@NonNull MappingLoopCS csElement) { + refreshObservedProperties(csElement, csElement.getObservedProperties()); return new MappingLoopIteratorCompletion(context, csElement); } @Override public Continuation<?> visitNewStatementCS(@NonNull NewStatementCS csElement) { + refreshObservedProperties(csElement, csElement.getObservedProperties()); return new NewStatementCompletion(context, csElement); } @@ -354,6 +357,7 @@ public class QVTimperativeCSPreOrderVisitor extends AbstractQVTimperativeCSPreOr @Override public Continuation<?> visitSetStatementCS(@NonNull SetStatementCS csElement) { + refreshObservedProperties(csElement, csElement.getObservedProperties()); return null; } diff --git a/plugins/org.eclipse.qvtd.xtext.qvtimperative/src/org/eclipse/qvtd/xtext/qvtimperative/formatting/QVTimperativeFormatter.java b/plugins/org.eclipse.qvtd.xtext.qvtimperative/src/org/eclipse/qvtd/xtext/qvtimperative/formatting/QVTimperativeFormatter.java index 08e93cb76..2cfdcf4bc 100644 --- a/plugins/org.eclipse.qvtd.xtext.qvtimperative/src/org/eclipse/qvtd/xtext/qvtimperative/formatting/QVTimperativeFormatter.java +++ b/plugins/org.eclipse.qvtd.xtext.qvtimperative/src/org/eclipse/qvtd/xtext/qvtimperative/formatting/QVTimperativeFormatter.java @@ -29,8 +29,6 @@ import org.eclipse.qvtd.xtext.qvtimperative.services.QVTimperativeGrammarAccess. import org.eclipse.qvtd.xtext.qvtimperative.services.QVTimperativeGrammarAccess.QueryCSElements; import org.eclipse.qvtd.xtext.qvtimperative.services.QVTimperativeGrammarAccess.ScopeNameCSElements; import org.eclipse.qvtd.xtext.qvtimperative.services.QVTimperativeGrammarAccess.SetStatementCSElements; -import org.eclipse.qvtd.xtext.qvtimperative.services.QVTimperativeGrammarAccess.SourceDomainCSElements; -import org.eclipse.qvtd.xtext.qvtimperative.services.QVTimperativeGrammarAccess.TargetDomainCSElements; import org.eclipse.qvtd.xtext.qvtimperative.services.QVTimperativeGrammarAccess.TransformationCSElements; import org.eclipse.xtext.formatting.impl.FormattingConfig; @@ -79,8 +77,10 @@ public class QVTimperativeFormatter extends AbstractEssentialOCLFormatter { AddStatementCSElements a = f.getAddStatementCSAccess(); - c.setLinewrap(1).before(a.getAddKeyword_0()); - c.setNoSpace().before(a.getSemicolonKeyword_4()); + c.setLinewrap(1).before(a.getObserveKeyword_0_0()); + c.setNoSpace().before(a.getCommaKeyword_0_2_0()); + c.setLinewrap(1).before(a.getAddKeyword_1()); + c.setNoSpace().before(a.getSemicolonKeyword_5()); } { CheckStatementCSElements a = f.getCheckStatementCSAccess(); @@ -90,14 +90,15 @@ public class QVTimperativeFormatter extends AbstractEssentialOCLFormatter } { DeclareStatementCSElements a = f.getDeclareStatementCSAccess(); - c.setLinewrap(1).before(a.getIsCheckedAssignment_0()); - setNoSpaceLineWrap(c, a.getSemicolonKeyword_6()); + c.setLinewrap(1).before(a.getObserveKeyword_0_0()); + c.setNoSpace().before(a.getCommaKeyword_0_2_0()); + c.setLinewrap(1).before(a.getIsCheckedAssignment_1()); + setNoSpaceLineWrap(c, a.getSemicolonKeyword_7()); } { DirectionCSElements a = f.getDirectionCSAccess(); c.setLinewrap(1).before(a.getAlternatives_1()); c.setNoSpace().before(a.getCommaKeyword_5_0()); - c.setNoSpace().before(a.getCommaKeyword_6_2_0()); } { GuardVariableCSElements a = f.getGuardVariableCSAccess(); @@ -117,10 +118,10 @@ public class QVTimperativeFormatter extends AbstractEssentialOCLFormatter { MappingCSElements a = f.getMappingCSAccess(); c.setLinewrap(2).before(a.getMapKeyword_1()); - c.setNoSpace().between(a.getLeftCurlyBracketKeyword_4(), a.getRightCurlyBracketKeyword_10()); - setBraces(c, a.getLeftCurlyBracketKeyword_4(), a.getRightCurlyBracketKeyword_10()); + c.setNoSpace().between(a.getLeftCurlyBracketKeyword_4(), a.getRightCurlyBracketKeyword_9()); + setBraces(c, a.getLeftCurlyBracketKeyword_4(), a.getRightCurlyBracketKeyword_9()); // c.setLinewrap(2).between(a.getDomainsAssignment_5(), a.getDomainsAssignment_5()); - c.setLinewrap(1).before(a.getOwnedDomainsAssignment_5()); + // c.setLinewrap(1).before(a.getOwnedDomainsAssignment_5()); } { MappingCallCSElements a = f.getMappingCallCSAccess(); @@ -136,13 +137,17 @@ public class QVTimperativeFormatter extends AbstractEssentialOCLFormatter } { MappingLoopCSElements a = f.getMappingLoopCSAccess(); - setAppendedBraces(c, a.getLeftCurlyBracketKeyword_4(), a.getRightCurlyBracketKeyword_6()); + c.setLinewrap(1).before(a.getObserveKeyword_0_0()); + c.setNoSpace().before(a.getCommaKeyword_0_2_0()); + setAppendedBraces(c, a.getLeftCurlyBracketKeyword_5(), a.getRightCurlyBracketKeyword_7()); } { NewStatementCSElements a = f.getNewStatementCSAccess(); - c.setLinewrap(1).before(a.getNewKeyword_0()); - c.setNoSpace().around(a.getColonKeyword_1()); - c.setNoSpace().before(a.getSemicolonKeyword_7()); + c.setLinewrap(1).before(a.getObserveKeyword_0_0()); + c.setNoSpace().before(a.getCommaKeyword_0_2_0()); + c.setLinewrap(1).before(a.getNewKeyword_1()); + c.setNoSpace().around(a.getColonKeyword_2()); + c.setNoSpace().before(a.getSemicolonKeyword_8()); } { OutVariableCSElements a = f.getOutVariableCSAccess(); @@ -175,29 +180,11 @@ public class QVTimperativeFormatter extends AbstractEssentialOCLFormatter } { SetStatementCSElements a = f.getSetStatementCSAccess(); - c.setLinewrap(1).before(a.getIsNotifyAssignment_0()); - c.setNoSpace().around(a.getFullStopKeyword_3()); - c.setNoSpace().before(a.getSemicolonKeyword_7()); - } - { - SourceDomainCSElements a = f.getSourceDomainCSAccess(); - c.setNoLinewrap().before(a.getLeftCurlyBracketKeyword_2_0()); - c.setLinewrap().after(a.getLeftCurlyBracketKeyword_2_0()); - c.setNoSpace().before(a.getCommaKeyword_2_1_2_0()); - c.setLinewrap().after(a.getCommaKeyword_2_1_2_0()); - c.setLinewrap().after(a.getRightCurlyBracketKeyword_2_2()); - c.setNoSpace().between(a.getLeftCurlyBracketKeyword_2_0(), a.getRightCurlyBracketKeyword_2_2()); - c.setIndentation(a.getLeftCurlyBracketKeyword_2_0(), a.getRightCurlyBracketKeyword_2_2()); - } - { - TargetDomainCSElements a = f.getTargetDomainCSAccess(); - c.setNoLinewrap().before(a.getLeftCurlyBracketKeyword_2_0()); - c.setLinewrap().after(a.getLeftCurlyBracketKeyword_2_0()); - c.setNoSpace().before(a.getCommaKeyword_2_1_2_0()); - c.setLinewrap().after(a.getCommaKeyword_2_1_2_0()); - c.setLinewrap().after(a.getRightCurlyBracketKeyword_2_2()); - c.setNoSpace().between(a.getLeftCurlyBracketKeyword_2_0(), a.getRightCurlyBracketKeyword_2_2()); - c.setIndentation(a.getLeftCurlyBracketKeyword_2_0(), a.getRightCurlyBracketKeyword_2_2()); + c.setLinewrap(1).before(a.getObserveKeyword_0_0()); + c.setNoSpace().before(a.getCommaKeyword_0_2_0()); + c.setLinewrap(1).before(a.getIsNotifyAssignment_1()); + c.setNoSpace().around(a.getFullStopKeyword_4()); + c.setNoSpace().before(a.getSemicolonKeyword_8()); } // { // TopLevelCSElements a = f.getTopLevelCSAccess(); |