Home » Modeling » Papyrus » How to edit myHelloWorld class code from example in C/C++ editor?
How to edit myHelloWorld class code from example in C/C++ editor? [message #1834724] |
Mon, 16 November 2020 16:21  |
Eclipse User |
|
|
|
I'm following the Hello World example found in https://wiki.eclipse.org/Papyrus/Codegen/CppHelloWorld and I'd like to know if there is a way of editing code in the C/C++ text editor instead of the hideous "body" text box in the "Profile" section of "myMainClass".
I can't insert code using that "body" box. It doesn't let me press enter so I can only write:
int main (int argc, char* argv[])
And I can't see any right-click option for using the C/C++ text editor to enter the code for main. Is there a way of doing this?
Also, that makes me wonder how that code in the example was put there in the first place.
|
|
| | | |
Re: How to edit myHelloWorld class code from example in C/C++ editor? [message #1834924 is a reply to message #1834919] |
Fri, 20 November 2020 12:49   |
Eclipse User |
|
|
|
Ansgar Radermacher wrote on Fri, 20 November 2020 09:16Did you use a nightly build of Designer? (probably yes, since you had the option to generate C code which is not part of the build). Which Eclipse version?
Version: 2020-09 (4.17.0)
Ansgar Radermacher wrote on Fri, 20 November 2020 09:16The C/C++ view appears in the same area where the property view is, it can easily be overlooked.
Assuming that you used a nightly build: did you see the C/C++ tab in the property view when you select a class already having the "Include" stereotype? The appearance of the tab depends on the selected element and is currently only supported for some elements already having the stereotype (such as "Include").
Yes, I can see the C/C++ tab showing up when selecting a class with the <<Include>> stereotype.
Ansgar Radermacher wrote on Fri, 20 November 2020 09:16Concerning the CDT integration. The idea is that the tool generates code and then opening the editor on the generated code. In order to do so, it needs to know which generator to use, as both the C and C++ generator are eligible for models applying the C/C++ profile. Therefore, the tool uses a hint (in form of a stereotype of a common code-generation profile) in order to store the generator choice. If the hint is not present, the popup is invoked. Normally, you should choose Standard C++ (you'll be asked only once) and a CDT editor should open. As this is apparently not the case, can you please observe the error-log for eventual exceptions (empty the log before invoking the CDT editor).
Well, now that you mention this. in order to use CDT editor I had to generate the code first which in turn creates a CDT project. After generating the CDT project, right-clicking on the class and selecting Designer and Open a CDT Editor causes the C/C++ editor to open the CDT project cpp file created by the code generation step.
But I thought that when creating a diagram I could edit code using the normal C/C++ editor within the papyrus project, without having to create the CDT project first, and not using the C/C++ tab. The tab is fine for a couple of lines of code, but as code grows that becomes a big problem, especially with the plain text editing and lack of code navigation in the tab that the C/C++ CDT editor provides.
[Updated on: Fri, 20 November 2020 13:38] by Moderator
|
|
|
Re: How to edit myHelloWorld class code from example in C/C++ editor? [message #1834989 is a reply to message #1834924] |
Mon, 23 November 2020 02:42   |
Eclipse User |
|
|
|
Hi,
> But I thought that when creating a diagram I could edit code using the normal C/C++ editor within the papyrus project, without having to create the CDT project first, and not using the C/C++ tab. The tab is fine for a couple of lines of code, but as code grows that becomes a big problem, especially with the plain text editing and lack of code navigation in the tab that the C/C++ CDT editor provides.
when I said that you have to generate code first, I described what happens internally. The end user should not have to care about it. However, the project into which the generated code will be stored, needs to exist. This is a bug, see https://bugs.eclipse.org/bugs/show_bug.cgi?id=569052 (as the project already existed in my tests, I did not notice that). It will be corrected as soon as possible.
But code synchronization should work, see how it's done for the Robotics customization in this video: https://www.youtube.com/watch?v=P61COtOuUm0 (even if used in a different context, the approach is based on the same synchronizing CDT editor as in base SW designer)
|
|
| | |
Re: How to edit myHelloWorld class code from example in C/C++ editor? [message #1835152 is a reply to message #1835144] |
Wed, 25 November 2020 13:43  |
Eclipse User |
|
|
|
Ansgar Radermacher wrote on Wed, 25 November 2020 10:30It seems that you did not open a synchronizing editor, but a "normal" CDT editor. The synchronizing editor has a green bar on the left, if synchronization is active (it will turn orange, if you close for instance the model).
Do not open the CDT editor on the generated file using the project or package editor, use the context menu in the model to open the editor.
Awesome!! That did the trick!
You are right, I opened the file directly from the CDT project, but if I use the context menu then it synchronizes well.
|
|
|
Goto Forum:
Current Time: Tue Jul 08 22:04:49 EDT 2025
Powered by FUDForum. Page generated in 0.09048 seconds
|