Comments (7)
This process works when I only put either of the 'unique' or 'immutable' keywords: the code generates and compiles as expected.
from umple.
I have replicated this issue in Eclipse Version: 2023-06 (4.28.0), Build id: 20230608-1333
I was generating the code using the Umple plugin from http://cruise.eecs.uottawa.ca/org.cruise.umple.eclipse.plugin.update.site and compiling using
javac MyClass.java
from the /unique_immutable/src/java/
directory.
Here again, I was able to make this work if I only put either of 'unique' or 'immutable'.
from umple.
Thanks for this. I will assign it for fixing right away.
I confirm that if I paste your code into UmpleOnline, and hit 'Execute it', the same result appears.
Tijm
from umple.
Design option 1: In the generator, detect the combined case of immutable+unique and put the relevant code from the set method in the constructor in ONLY that case. This may make the generation template a bit more complex. I think this option should be tried first. New tests will have to be generated, but this should not break many (if any) existing tests.
Design option 2: For ALL unique attributes, instead of calling the set method, put the relevant code from the set method in the constructor. Drawback: Would slightly bloat the code of cases where the attribute is unique but not immutable, which may be common. This change will break all existing tests for generation of unique; those tests would have to be changed, which involves some risk that they are changed incorrectly.
Option 3. Disallow unique immutable with an error. This would not be reasonable.
from umple.
We discovered that if one uses 'unique lazy immutable' the code generated is much better ... the only issue is a missing argument to the constructor. So the suggested design approach (we can now call option 4) is this:
All 'lazy' does when combined with 'immutable' is that it gives one chance to set an immutable attribute.
With three keywords together the lazy create a setter method, even when the attribute is immutable, but that setter can only be used once. And the constructor in the case of unique would make that call. ... except that the constructor does not currently have the aruemnt
-
In the parser, identify unique and immutable both being used together and set the relevant flag as though 'lazy' had been present, even if it was not. This can be done at umpleInternalParser_CodeClass.ump analyzeAttribute line 4717
-
The relevant template is
UmpleToJava/UmpleTLTemplates/constructor_AttributeAssignUnique.ump -
We need to ensure the template generates the argument for the unique immutable attribute is adding an argument in the following code <<=gen.translate("parameterOne", av)>> Normally this will generate an argument, but it seems it is not doing so perhaps because of the presence of 'lazy' (which if used alone suppresses the presence of an argument on the constructor to allow it to be set later). We need to work out the logic to ensure the argument is not suppressed ... perhaps we need to add a new variable for this special sort of 'lazy' status.
-
The we need to add tests to make sure this works properly.
from umple.
This was solved with PR #2055
from umple.
Solved by PR #2055
from umple.
Related Issues (20)
- Consider creating a GLSP editor for Umple
- Create equivalent to dev-tools core commands for those developing Umple on windows dev-tools-windows HOT 2
- Requirements parsing crashes in certain cases when a requirement indsicated in an implementsReq statement does not have a matching req statement HOT 2
- Requirements problems should raise warnings rather than printing to standard output
- Requirements with the same name should be combined as mixins HOT 1
- Fix and improve the default requirements generator
- displayColour syntax not checked well and can give false error messages HOT 2
- StateTable statemachine test - concurrentAutoTransitionStateTable - test fails due to non-determinism
- Hyperlink Error on Warning 1016
- Requirements should not have to precede req implementation, so implementations should only be checked in second pass
- "Synchronized" keyword translation from Java to Python is incomplete
- Declare usage of PHP dynamic properties in UmpleOnline
- Improve UmpleOnline editing of classes and state machines HOT 1
- Add setup.bat to build and run docker on umpleCodeExecution for windows development
- Make Java code execution available on windows host development environment
- Develop Python execution
- Some Python code generated contains error HOT 2
- Ensure requirements (req) and requirements implementation (implementsReq) statements work coherently across all features
- Enums Not Generated Correctly in Ecore HOT 7
Recommend Projects
-
React
A declarative, efficient, and flexible JavaScript library for building user interfaces.
-
Vue.js
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
-
Typescript
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
-
TensorFlow
An Open Source Machine Learning Framework for Everyone
-
Django
The Web framework for perfectionists with deadlines.
-
Laravel
A PHP framework for web artisans
-
D3
Bring data to life with SVG, Canvas and HTML. 📊📈🎉
-
Recommend Topics
-
javascript
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
-
web
Some thing interesting about web. New door for the world.
-
server
A server is a program made to process requests and deliver data to clients.
-
Machine learning
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
-
Visualization
Some thing interesting about visualization, use data art
-
Game
Some thing interesting about game, make everyone happy.
Recommend Org
-
Facebook
We are working to build community through open source technology. NB: members must have two-factor auth.
-
Microsoft
Open source projects and samples from Microsoft.
-
Google
Google ❤️ Open Source for everyone.
-
Alibaba
Alibaba Open Source for everyone
-
D3
Data-Driven Documents codes.
-
Tencent
China tencent open source team.
from umple.