public override bool Visit(CollectionLiteralExp node) { /* For simplicity we do not allow this yet */ violatingExpression = node; isSuitable = false; return(false); }
public override OclExpression Visit(CollectionLiteralExp node) { /* For simplicity we do not allow this yet */ notSupportedExpression = node; isSuitable = false; throw new OclConstructNotAvailableInPSM(node); }
public void testOperationCallExp() { AstOclModelElementFactory factory1 = AstOclModelElementFactoryManager.getInstance(umlModel.getOclPackage()); VariableDeclaration variable = factory1.createVariableDeclaration("abc", getClassifier("Film"), null); VariableExp source = factory1.createVariableExp(variable); List <object> paramTypes = new List <object> (); paramTypes.Add(getClassifier("Integer")); CoreOperation operation = getClassifier("Film").lookupOperation("getRentalFee", paramTypes); List <object> arguments = new List <object> (); arguments.Add(factory1.createIntegerLiteralExp(100, getClassifier("Integer"))); OperationCallExp exp = factory1.createOperationCallExp(source, operation, arguments, operation.getReturnType(), false); Assert.AreEqual("abc.getRentalFee(100)", exp.ToString()); Assert.AreEqual("Real", exp.getType().getName()); CollectionLiteralExp literalCollection = factory1.createCollectionLiteralExp(createCollectionParts(), factory1.createSetType( getClassifier("Integer"))); CollectionTypeImpl type1 = (CollectionTypeImpl)factory1.createSetType(getClassifier("Integer")); CoreOperation collectionOper = type1.lookupOperation("size", new List <object>()); OperationCallExp exp1 = factory1.createOperationCallExp(literalCollection, collectionOper, new List <object>(), getClassifier("Integer"), false); Assert.IsNotNull(exp1); }
protected CollectionLiteralExp checkCollectionLiteralExp(OclExpression oclExpression, String type) { Assert.IsTrue(oclExpression is CollectionLiteralExp); CollectionLiteralExp exp = (CollectionLiteralExp)oclExpression; Assert.AreEqual(type, exp.getType().getName()); return(exp); }
public void testCollectionLiteral(String expression, String expectedElementTypeName, String collectionName, int partsSize, CollectionKindEnum collectionKind) { CollectionLiteralExp literalExp = doTestOK(expression); Assert.IsTrue(literalExp.getType() is CollectionType); CollectionType collectionType = (CollectionType)literalExp.getType(); Assert.AreEqual(collectionName, collectionType.getName()); Assert.AreEqual(expectedElementTypeName, collectionType.getElementType().getName()); Assert.AreEqual(partsSize, literalExp.getParts().Count); Assert.AreEqual(collectionKind, literalExp.getKind()); }
public void testSetLiteral_07() { CollectionLiteralExp literalExp = doTestOK("Bag{ Set{1, 2}, Set{4, 8} } "); CoreClassifier expectedType = (CoreClassifier)environment.lookup("Integer"); Assert.IsNotNull(expectedType); Assert.IsTrue(literalExp.getType() is BagType); CollectionType collectionType = (CollectionType)literalExp.getType(); Assert.IsTrue(collectionType.getElementType() is SetType); Assert.AreEqual(2, literalExp.getParts().Count); Assert.AreEqual(CollectionKindEnum.BAG, literalExp.getKind()); }
public void testCollectionLiteralExp() { AstOclModelElementFactory factory1 = AstOclModelElementFactoryManager.getInstance(umlModel.getOclPackage()); CollectionLiteralExp exp = factory1.createCollectionLiteralExp(createCollectionParts(), factory1.createSetType( getClassifier("Integer"))); Assert.AreEqual("Set{ 100, 200, 300 }", exp.ToString()); Assert.AreEqual("Set(Integer)", exp.getType().getName()); CollectionLiteralExp exp2 = factory1.createCollectionLiteralExp(createCollectionParts(), factory1.createSetType( getClassifier("Integer"))); Assert.AreEqual("Set{ 100, 200, 300 }", exp2.ToString()); Assert.AreEqual("Set(Integer)", exp2.getType().getName()); exp = factory1.createCollectionLiteralExp(createCollectionParts(), factory1.createBagType(getClassifier("Integer"))); Assert.AreEqual("Bag{ 100, 200, 300 }", exp.ToString()); Assert.AreEqual("Bag(Integer)", exp.getType().getName()); exp = factory1.createCollectionLiteralExp(createCollectionParts(), factory1.createSequenceType(getClassifier("Integer"))); Assert.AreEqual("Sequence{ 100, 200, 300 }", exp.ToString()); Assert.AreEqual("Sequence(Integer)", exp.getType().getName()); exp = factory1.createCollectionLiteralExp(createCollectionParts(), factory1.createOrderedSetType(getClassifier("Integer"))); Assert.AreEqual("OrderedSet{ 100, 200, 300 }", exp.ToString()); Assert.AreEqual("OrderedSet(Integer)", exp.getType().getName()); OclExpression elem1 = factory1.createIntegerLiteralExp(100, getClassifier("Integer")); OclExpression elem2 = factory1.createIntegerLiteralExp(200, getClassifier("Integer")); CollectionRange range = factory1.createCollectionRange(elem1, elem2); List <object> parts = new List <object> (); parts.Add(range); exp = factory1.createCollectionLiteralExp(parts, factory1.createSetType(getClassifier("Integer"))); Assert.AreEqual("Set{ 100 .. 200 }", exp.ToString()); Assert.AreEqual("Set(Integer)", exp.getType().getName()); }
public void Visit(CollectionLiteralExp node) { foreach (CollectionLiteralPart collectionLiteralPart in node.Parts) { CollectionItem item = collectionLiteralPart as CollectionItem; if (item != null) { Expressions.Add(item.Item); item.Item.Accept(this); } CollectionRange range = collectionLiteralPart as CollectionRange; if (range != null) { Expressions.Add(range.First); Expressions.Add(range.Last); range.First.Accept(this); range.Last.Accept(this); } } }
private void doTestSameCollectionTypeInstance(String expression1, String expression2, bool isEqual) { CollectionLiteralExp literalExp1 = doTestOK(expression1); Assert.IsTrue(literalExp1.getType() is CollectionType); CollectionType collectionType1 = (CollectionType)literalExp1.getType(); CollectionLiteralExp literalExp2 = doTestOK(expression2); Assert.IsTrue(literalExp2.getType() is CollectionType); CollectionType collectionType2 = (CollectionType)literalExp2.getType(); if (isEqual) { Assert.AreEqual(collectionType1.getName(), collectionType2.getName()); } else { Assert.IsFalse(collectionType1.getName().Equals(collectionType2.getName())); } }
public void Visit(CollectionLiteralExp node) { CollectionType col = (CollectionType)node.Type; sb.AppendFormat("{0} ", col.Name); PrintArgs(node.Parts, ",", part => { if (part is CollectionRange) { CollectionRange range = (CollectionRange)part; range.First.Accept(this); sb.Append(".."); range.Last.Accept(this); } else if (part is CollectionItem) { CollectionItem item = (CollectionItem)part; item.Item.Accept(this); } }); sb.Append("}"); }
public virtual void Visit(CollectionLiteralExp node) { AssignIsPartOfIteratorBody(node); StringBuilder formatBuilder = new StringBuilder(); List <OclExpression> subExpressions = new List <OclExpression>(); // opening parenthesis of xpath sequence literal formatBuilder.Append("("); foreach (CollectionLiteralPart clp in node.Parts) { #region helper function Action <OclExpression> appendOne = delegate(OclExpression exp) { if (exp is LiteralExp) { formatBuilder.Append("{"); formatBuilder.Append(subExpressions.Count); formatBuilder.Append("}"); } else { formatBuilder.Append("{("); formatBuilder.Append(subExpressions.Count); formatBuilder.Append(")}"); } }; #endregion if (clp is CollectionRange) { CollectionRange range = ((CollectionRange)clp); range.First.Accept(this); range.Last.Accept(this); appendOne(range.First); subExpressions.Add(range.First); formatBuilder.Append(" to "); appendOne(range.Last); subExpressions.Add(range.Last); } if (clp is CollectionItem) { CollectionItem collectionItem = (CollectionItem)clp; collectionItem.Item.Accept(this); appendOne(collectionItem.Item); subExpressions.Add(collectionItem.Item); } formatBuilder.Append(", "); } if (formatBuilder.Length > 1) // remove last comma { formatBuilder.Length = formatBuilder.Length - 2; } // closing parenthesis of xpath sequence literal formatBuilder.Append(")"); TranslationOption option = new TranslationOption(); option.FormatString = formatBuilder.ToString(); SubexpressionTranslations.AddTranslationOption(node, option, subExpressions.ToArray()); }
/** * @param literalExp The literalExp to set. */ public void setLiteralExp(CollectionLiteralExp literalExp) { this.literalExp = literalExp; }
public void Visit(CollectionLiteralExp node) { sb.Append("CollectionLiteral(" + node.Type.Name + ")"); }
public abstract TType Visit(CollectionLiteralExp node);
public void visitCollectionLiteralExp(CollectionLiteralExp exp) { }