Sparx Systems Forum
Enterprise Architect => Suggestions and Requests => Topic started by: qwerty on February 10, 2016, 02:46:37 am
-
When you create a new operation, EA obviously can parse the parameter string. You can just paste the C++ parameter string as from the source and it will find names and types. So why not take that one step further and parse the whole signature? Assuming blanks in the name could lead EA to parse the string to find return type, name and parameters.
Similarly attributes could be treated.
q.
-
EA has done that for years. F2 on a selected operation on the diagram to edit it. Ctrl+Shift+F10 to create a new operation. (F9 for attributes)
-
No, that's no what I mean. Assume you have the following text in the paste board:
void setExtruderAutoFanState(int pin, bool state) and I paste this into (say the name) field of an operation then EA could recognize "Oh a whole signature, because it contains spaces" and start parsing it to get the return value void, the name setExtruderAutoFanState and the two parameters.
q.
-
EA could recognize "Oh a whole signature, because it contains spaces"
I see what you're after, and it would be very useful but I would make it an explicit function rather than a magic one. In other words, I wouldn't make it the default.
While spaces are not allowed in identifiers in code, there's no restriction in models in general, so you can use spaces in names of operations as well as classes (which can be used as parameter types and return types). So if I'm doing a conceptual, rather than an implementation, model, I don't want EA to override me if I use spaces (or commas, or parentheses) in the name field.
Here's a suggestion:
Add a Parse button near the Notes field of the Operations (and Attributes) dialog. When you hit that button, EA takes whatever's in the Notes field and tries to parse that as an attribute / operation declaration, using its regular parser for the class' language. If the text parses, it is removed from the Notes field and the Name, Return Type, and Parameters fields (plus Scope, Abstract and Static) are filled instead.
This way, after hitting New in the Operations dialog, you can paste/write your declaration into the Notes field and then hit Parse. But I can still create an operation with a name which would be illegal in C++ if I want.
In fact, you could add a Parse button to the Class dialog as well, and parse a whole class declaration with attributes, operations, comments and all.
/Uffe
-
Since EA has so many keyboard shortcuts, how about one for this? Crtl-Shift-V inside the name? I would not like the notes to be used for that since the notes shall take a description, not the signature.
q.
-
I like Uffe's suggestion.
Geert
PS. Uffe, will I see you at the next EAUG event in Göteborg on the 14th of April?
-
Yes, I'll be there. I thought I'd do a presentation but I just realized I missed the submission deadline. I've asked if they can squeeze me in; if not I'll just hang back and enjoy the show. :)
Back OnT:
I would not like the notes to be used for that since the notes shall take a description, not the signature.
My thinking was for this to be primarily a way to create a new operation, in which case there's nothing in the Notes field when you begin. When the text is parsed, the result is moved to the relevant fields and the Notes field is cleared (unless there's a comment in the text).
I prefer the Notes field to Name because it's multi-line. So you can fit more in there, see the whole declaration and edit it more easily in case it doesn't parse.
/U