UML Lab, Refactoring and Javadoc comments

I faced a problem using UML lab. My aim is to create a model from Java source code and then refactor the model, and finally writing back the model as source code. However, it seems UML lab does not support comments at source code level.

As an example, if a method is moved from a class to another one, its comment still remains in the first class. The process works correctly if comments are added to the method at design level. However, as mentioned if comments are defined at source code then because they are not supported at design level they are not moved with the method during code sync.

Probably, I miss some things during extracting model from source code. Actually, it seems if I have comments at design level, then every things will be fine.

Thanks in advance for any help.



  • Hello Iman,

    it is true, that there are cases where comments remain in the original class if you move members to a new class. Comments within the method body are moved, comments generated by a template (visible on "design level"/uml model) are moved; comments outside and within the declaration of a method or attribute are not moved.

    What kind of comments do you have which need to be moved as well? Do you have an example?

    Best regards,
  • Hello Christian,
    Thanks for your response.

    I found some cases that UML Lab does not generate visible comments at design level during code generation. This problem happens mostly for fields.

    If you define a new field at design level and set a comment to that, then during code generation the comment is vanished. However, this problem does not happen for methods.

    I also find during model generation some comments are moved to design level while some are not. I defined two methods at source code then generated a model from them. While one method has its comment at design level other one does not. It seems that is a bug.

    Comments are very important in my work. Is any way to improve this part of UML lab?
    I guess UML lab uses AST to generate model from code. Therefore, it seems almost straightforward to fix this bug.


  • Hello Iman,

    UML Lab uses templates to generate code from a model. And it uses templates to reverse engineer a model from code as well.
    Additionally templates are chosen by a CodeStyle which can be different for each model element.
    The latter fact explains why you sometimes get no comment in the code from a comment in the model: If the template for the CodeStyle of the property does not explicitly generate some text for a UML comment, you won't see anything in the code. The same applies for the other way round: if a template does not care for comments in the code they won't appear in the model after reverse engineering.
    As everything relies on templates you can modify the behavior yourself: introduce a new CodeStyle which matches your needs.
    Maybe you can bring up some examples here where it works like you expect it to and where you would like to change it.


    P.S. sorry for the late reply, I forgot to turn on notifications...
Sign In or Register to comment.