Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #1301 from umple/Issue_689
Fixes #689 Adds multivalued attribute initialization implementation
- Loading branch information
Showing
21 changed files
with
497 additions
and
10 deletions.
There are no files selected for viewing
9 changes: 8 additions & 1 deletion
9
UmpleToJava/UmpleTLTemplates/constructor_AttributeAssignList.ump
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,4 +1,11 @@ | ||
class UmpleToJava { | ||
constructor_AttributeAssignList <<!<</*constructor_AttributeAssignList*/>> | ||
<<=gen.translate("attributeMany",av)>> = new ArrayList<<<=gen.translate("typeMany",av)>>>();!>> | ||
<<=gen.translate("attributeMany",av)>> = new ArrayList<<<=gen.translate("typeMany",av)>>>();<<# | ||
if (av.getValue() != null && av.getValue() != "") { | ||
String[] values = av.getValue().split(","); | ||
if (values[0] != av.getValue()) { | ||
for (String value : values) { | ||
value = value.replaceAll("(?<!new)\\s+","");#>> | ||
<<=gen.translate("attributeMany",av)>>.add(<<=value>>); | ||
<<#}}}#>>!>> | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
8 changes: 7 additions & 1 deletion
8
UmpleToPhp/UmpleTLTemplates/constructor_AttributeAssignList.ump
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,4 +1,10 @@ | ||
class UmpleToPhp { | ||
constructor_AttributeAssignList <<!<</*constructor_AttributeAssignList*/>> | ||
$<<=instanceIdentifier>>-><<=gen.translate("attributeMany",av)>> = array();!>> | ||
$<<=instanceIdentifier>>-><<=gen.translate("attributeMany",av)>> = array(<<# | ||
if (av.getValue() != null && av.getValue() != "") { | ||
String[] values = av.getValue().split(","); | ||
if (values[0] != av.getValue()) { | ||
for (int i = 0; i < values.length; i++) { | ||
String addingComma = (i == values.length-1) ? "" : ","; | ||
String value = values[i].replaceAll("(?<!new)\\s+","");#>><<=value>><<=addingComma>><<#}}}#>>);!>> | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
21 changes: 21 additions & 0 deletions
21
build/reference/9081InvalidMultivaluedAttributeAssignment.txt
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,21 @@ | ||
E081 Invalid Multivalued Attribute Assignment | ||
Errors and Warnings 51-99 | ||
noreferences | ||
|
||
@@description | ||
|
||
<h2>Umple semantic error raised when initializing multivalued attributes with invalid values</h2> | ||
|
||
<p>When indicating initial values for a multivalued attribute, an error is raised if the values to | ||
assign cannot be parsed properly. <br/> | ||
The error might be caused by a typographical mistake. | ||
</p> | ||
|
||
|
||
@@example | ||
@@source manualexamples/E081InvalidMultivaluedAttributeAssignment1.ump | ||
@@endexample | ||
|
||
@@example | ||
@@source manualexamples/E081InvalidMultivaluedAttributeAssignment2.ump | ||
@@endexample |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
3 changes: 3 additions & 0 deletions
3
cruise.umple/test/cruise/umple/compiler/008_attributeTypeValueMismatch2.ump
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,3 @@ | ||
class A { | ||
String[] attr = {"str", 20, "str2"}; | ||
} |
3 changes: 3 additions & 0 deletions
3
cruise.umple/test/cruise/umple/compiler/008_multivaluedAttributeAssignment1.ump
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,3 @@ | ||
class MultivaluedAttributeAssignment { | ||
String[] attr = {invalid.values}; | ||
} |
3 changes: 3 additions & 0 deletions
3
cruise.umple/test/cruise/umple/compiler/008_multivaluedAttributeAssignment2.ump
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,3 @@ | ||
class MultivaluedAttributeAssignment { | ||
String[] attr = {arbitraryCode();}; | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
9 changes: 9 additions & 0 deletions
9
...le/test/cruise/umple/implementation/ClassTemplateTest_MultivaluedAttributesAssignment.ump
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,9 @@ | ||
class Foo { | ||
String[] someStrings = {"a","b","c"}; | ||
Integer[] numbers = {1,2,3,10}; | ||
Token[] objects = {new Token("first"),new Token("second")}; | ||
} | ||
|
||
class Token { | ||
attr; | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -5,6 +5,6 @@ class X { | |
displayColor "#FFCCCC"; | ||
Float x; | ||
Float y; | ||
Float sum = {x + y}; | ||
Float sum = {x + y} | ||
} | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -8,5 +8,5 @@ class X { | |
|
||
Float x; | ||
Float y; | ||
Float sum = {x + y}; | ||
Float sum = {x + y} | ||
} |
Oops, something went wrong.