Skip to content

Commit

Permalink
Merge pull request #1063 from umple/myNewFM
Browse files Browse the repository at this point in the history
Enhancements to some code generators
  • Loading branch information
opeyemiAdesina committed Jun 23, 2017
2 parents d7c049e + f82f7b5 commit a2086ef
Show file tree
Hide file tree
Showing 16 changed files with 60 additions and 34 deletions.
3 changes: 3 additions & 0 deletions cruise.umple/src/Generator_CodeYuml.ump
Expand Up @@ -101,6 +101,9 @@ class YumlGenerator
{
direction = "->";
}
else if (aAssoc.getIsLeftComposition() || aAssoc.getIsRightComposition()){
direction = "<>";
}
yuml.append(StringFormatter.format("[{0}]{5}{2}{4}{6}{3}[{1}],",c1.getName(),c2.getName(),mult1,mult2,direction,roleName1.getRoleName()+" ",roleName2.getRoleName()+" "));
}

Expand Down
8 changes: 4 additions & 4 deletions cruise.umple/src/NuSMVCoordinationUnit.ump
Expand Up @@ -66,7 +66,7 @@ class NuSMVCoordinator
ivdec.addVariableSpecifier( specifiers.get(i) );
body.addModuleElement( ivdec );

System.out.println("I am here!");
//System.out.println("I am here!");
}

//Adding define declaration to module body
Expand Down Expand Up @@ -1049,7 +1049,7 @@ class NuSMVCoordinator
List<AssignConstraint> constraints = new ArrayList<AssignConstraint>();

for( Attribute attribute : uClass.getAllAttributes() ) {
if( !attribute.isConstant() && !attribute.isIsInput() ) {
if( !attribute.isConstant() && !attribute.isIsIvar() ) {
BasicExpression bexp = new BasicExpression("");

if( attribute.getValue() != null ){
Expand Down Expand Up @@ -1500,7 +1500,7 @@ class NuSMVCoordinator
List<VariableSpecifier> attributes = new ArrayList<VariableSpecifier>();

for( Attribute attribute : uClass.getAllAttributes() ){
if( attribute.isIsInput() ) {
if( attribute.isIsIvar() ) {
VariableSpecifier vs = new VariableSpecifier( attribute.getName() );
String type = attribute.getFullType();
generateSpecifier( type, vs, attributes );
Expand All @@ -1513,7 +1513,7 @@ class NuSMVCoordinator
List<VariableSpecifier> attributes = new ArrayList<VariableSpecifier>();

for( Attribute attribute : uClass.getAllAttributes() ){
if( !attribute.isConstant() && !attribute.isIsInput() ) {
if( !attribute.isConstant() && !attribute.isIsIvar() ) {
VariableSpecifier vs = new VariableSpecifier( attribute.getName() );
String type = attribute.getFullType();
generateSpecifier( type, vs, attributes );
Expand Down
10 changes: 5 additions & 5 deletions cruise.umple/src/Umple.ump
Expand Up @@ -259,8 +259,8 @@ class MethodParameter
// Specifies whether or not the method parameter is lazy.
Boolean isLazy = false;

// Specifies whether or not the method parameter is input.
Boolean isInput = false;
// Specifies whether or not the method parameter is ivar.
Boolean isIvar = false;
}

/*
Expand Down Expand Up @@ -858,8 +858,8 @@ class Attribute
Boolean isLazy = false;
Boolean isRefinement = false;

// Specifies whether or not the method parameter is input.
Boolean isInput = false;
// Specifies whether or not the method parameter is ivar.
Boolean isIvar = false;

//This supposed to show from where this method came.
//fTrait means it comes from traits.
Expand Down Expand Up @@ -1114,4 +1114,4 @@ use UmpleVersion.ump;
use UmpleDiagram.ump;
use StateMachine.ump;
use Umple_Code.ump;
use UmpleEnumeration_Code.ump;
use UmpleEnumeration_Code.ump;
4 changes: 2 additions & 2 deletions cruise.umple/src/UmpleInternalParser_CodeClass.ump
Expand Up @@ -3824,7 +3824,7 @@ private Boolean checkIsDistributed(UmpleInterface uInterface)
boolean isAutounique = attributeToken.getValue("autounique") != null;
boolean isUnique = attributeToken.getValue("unique") != null;
boolean isLazy = attributeToken.getValue("lazy") != null;
boolean isInput = attributeToken.getValue("input") != null;
boolean isIvar = attributeToken.getValue("ivar") != null;
boolean isConstant = "const".equals(attributeToken.getValue("modifier"));
boolean validName = Token.isValidIdentifier(attributeToken.getValue("name"));
boolean properName = !Token.isValidIdentifier(attributeToken.getValue("name"), "[A-Z]");
Expand Down Expand Up @@ -3976,7 +3976,7 @@ private Boolean checkIsDistributed(UmpleInterface uInterface)
Attribute attribute = new Attribute(name,type,modifier,value,isAutounique,aClass);
attribute.setIsUnique(isUnique);
attribute.setIsLazy(isLazy);
attribute.setIsInput(isInput);
attribute.setIsIvar(isIvar);
boolean isList = attributeToken.getValue("list") != null;

if (name == null)
Expand Down
4 changes: 2 additions & 2 deletions cruise.umple/src/UmpleInternalParser_CodeTrait.ump
Expand Up @@ -287,7 +287,7 @@ class UmpleInternalParser
boolean isAutounique = attributeToken.getValue("autounique") != null;
boolean isUnique = attributeToken.getValue("unique") != null;
boolean isLazy = attributeToken.getValue("lazy") != null;
boolean isInput = attributeToken.getValue("input") != null;
boolean isIvar = attributeToken.getValue("ivar") != null;
boolean isConstant = "const".equals(attributeToken.getValue("modifier"));
boolean validName = Token.isValidIdentifier(attributeToken.getValue("name"));
boolean properName = !Token.isValidIdentifier(attributeToken.getValue("name"), "[A-Z]");
Expand Down Expand Up @@ -436,7 +436,7 @@ class UmpleInternalParser
Attribute attribute = new Attribute(name,type,modifier,value,isAutounique,aTrait);
attribute.setIsUnique(isUnique);
attribute.setIsLazy(isLazy);
attribute.setIsInput(isInput);
attribute.setIsIvar(isIvar);
boolean isList = attributeToken.getValue("list") != null;

if (name == null)
Expand Down
Expand Up @@ -1935,7 +1935,7 @@ class MethodParameter{
mp.isList = getIsList();
mp.isDerived = getIsDerived();
mp.isLazy = getIsLazy();
mp.isInput = getIsInput();
mp.isIvar = getIsIvar();
return mp;
}
}
Expand Down
2 changes: 1 addition & 1 deletion cruise.umple/src/umple_classes.grammar
Expand Up @@ -78,7 +78,7 @@ attribute : [[simpleAttribute]] | [[autouniqueAttribute]] | [[derivedAttribute]]
simpleAttribute- : [~name] ;
autouniqueAttribute- : [=autounique] [~name] ;
derivedAttribute- : [=modifier:immutable|settable|internal|defaulted|const|fixml]? [[typedName]] = ( [[moreCode]] )+
complexAttribute- : [=unique]? [=lazy]? [=input]? [=modifier:immutable|settable|internal|defaulted|const|fixml]? [[typedName]] (= [**value])? ;
complexAttribute- : [=unique]? [=lazy]? [=ivar]? [=modifier:immutable|settable|internal|defaulted|const|fixml]? [[typedName]] (= [**value])? ;


// Keys are used to define quality and hash codes, plus Sql keys.
Expand Down
@@ -1,5 +1,5 @@
class X
{
input Double iDoub;
ivar Double iDoub;
Double xDoub;
}
}
18 changes: 9 additions & 9 deletions cruise.umple/test/cruise/umple/compiler/UmpleParserTest.java
Expand Up @@ -2681,12 +2681,12 @@ public void autoGeneratedGetSetInputAttribute()
assertSimpleParse("008_autogeneratedMethodsInputAttribute.ump");
UmpleClass uClass = model.getUmpleClass("X");

// input attributes should have both a set and a get method.
Method inputGet = new Method("", "getIDoub", "Double", false);
Method inputSet = new Method("", "setIDoub", "Boolean", false);
inputSet.addMethodParameter(new MethodParameter("aIDoub", "Double", "", "", false));
Assert.assertTrue(uClass.hasMethod(inputGet));
Assert.assertTrue(uClass.hasMethod(inputSet));
// ivar attributes should have both a set and a get method.
Method ivarGet = new Method("", "getIDoub", "Double", false);
Method ivarSet = new Method("", "setIDoub", "Boolean", false);
ivarSet.addMethodParameter(new MethodParameter("aIDoub", "Double", "", "", false));
Assert.assertTrue(uClass.hasMethod(ivarGet));
Assert.assertTrue(uClass.hasMethod(ivarSet));
}


Expand All @@ -2696,13 +2696,13 @@ public void inputModifierCheck()
assertSimpleParse("008_autogeneratedMethodsInputAttribute.ump");
UmpleClass uClass = model.getUmpleClass("X");

//input attribute should be qualified as "input"
//ivar attribute should be qualified as "ivar"
Assert.assertEquals(uClass.getAllAttributes().size(), 2);
Attribute attr = uClass.getAllAttributes().get(0);
Assert.assertTrue( attr.isIsInput() );
Assert.assertTrue( attr.isIsIvar() );

Attribute nattr = uClass.getAllAttributes().get(1);
Assert.assertTrue( !nattr.isIsInput() );
Assert.assertTrue( !nattr.isIsIvar() );
}

@Test
Expand Down
Expand Up @@ -4,13 +4,13 @@ class CruiseControlSystem
const int bb = 5;
const float cc = 5.00;
Integer c;
input Integer ayo;
input Float bayo;
input Boolean baro;
ivar Integer ayo;
ivar Float bayo;
ivar Boolean baro;

sm {
s1 {
a ->/{ b = aa + 2; } s2;
}
}
}
}
Expand Up @@ -4,9 +4,9 @@ class CruiseControlSystem
const int bb = 10;
const float cc = 5.00;
Integer c;
input Integer ayo;
input Float bayo;
input Boolean baro;
ivar Integer ayo;
ivar Float bayo;
ivar Boolean baro;

[ayo >= aa]
[ayo <= bb]
Expand All @@ -16,4 +16,4 @@ class CruiseControlSystem
a ->/{ b = aa + 2; } s2;
}
}
}
}
@@ -0,0 +1,5 @@
class Vehicle {
* <@>- 2..4 Wheel;
}

class Wheel{ }
@@ -0,0 +1 @@
[Vehicle],[Wheel],[Vehicle]vehicles *<>wheels 2..4[Wheel],
@@ -0,0 +1,4 @@
class Vehicle { }
class Wheel{
2..4 -<@> * Vehicle;
}
@@ -0,0 +1 @@
[Vehicle],[Wheel],[Wheel]wheels 2..4<>vehicles *[Vehicle],
Expand Up @@ -73,6 +73,18 @@ public void RoleNameWithMultiplicity()
{
assertUmpleTemplateFor("yuml/RoleNameWithMultiplicity.ump","yuml/RoleNameWithMultiplicity.yuml.txt");
}

@Test
public void CompositionEnds()
{
assertUmpleTemplateFor("yuml/CompositionEnds.ump","yuml/CompositionEnds.yuml.txt");
}

@Test
public void CompositionEndsLHS()
{
assertUmpleTemplateFor("yuml/CompositionEndsLHS.ump","yuml/CompositionEndsLHS.yuml.txt");
}

@Test
public void InterfaceInheritanceTest()
Expand Down

0 comments on commit a2086ef

Please sign in to comment.