Faktor-IPS代码生成器删除了注释 [英] Annotations are removed by Faktor-IPS Code Generator

查看:64
本文介绍了Faktor-IPS代码生成器删除了注释的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我需要注释一些由Faktor-IPS生成的方法.最常见的情况是@ Override-annotation,因为我还有其他接口或实现的基类:

I need to annotate some methods which are generated by Faktor-IPS. The most common case is the @Override-annotation, because I have additional interfaces or a base class I implement:

     * Gibt den Wert des Attributs beschreibung zurueck.
     * 
     * @generated
     */
    @IpsAttribute(name = "beschreibung", kind = AttributeKind.CHANGEABLE, valueSetKind = ValueSetKind.AllValues)
    @Override // <- manually added
    public String getBeschreibung() {
        return beschreibung;
    }

问题是,Faktor-IPS的代码生成器删除了附加注释.

Problem is, that the additional annotation is removed by the code generator of Faktor-IPS.

我知道在类注释中使用的特殊标记("@implements abcMyInterface"),以使类实现接口abcMyInterface-注释是否有类似的东西,尤其是在生成的方法上?

I know about the special tags to use in the class-comment ( "@implements a.b.c.MyInterface" ) to keep the class implement the interface a.b.c.MyInterface - is there something similar for annotations, especially on generated methods?

推荐答案

Faktor-IPS使用Eclipse EMF项目创建的JMerge工具来组合生成的代码和手写的代码.在

Faktor-IPS uses the JMerge tool created by the Eclipse EMF project to combine generated and handwritten code. There is a (German) description of the ways you can control how the code is merged at https://www.faktorzehn.org/de/en/dokumentation/manuelle-anpassungen-des-generieten-codes/.

要保留其他注释,同时仍允许代码生成器更新其余代码,请添加Javadoc标记(在Javadoc内,而不是注释,尽管也以'@'开头)'@customizedAnnotations ADDED'.

To keep additional annotations while still letting the code generator update the rest of the code, add the Javadoc tag (inside the Javadoc, not an annotation, although also beginning with '@') '@customizedAnnotations ADDED'.

如果要在许多地方添加某些批注,则此替代方法会很麻烦,因此Faktor-IPS允许您定义批注的列表,这些批注永远不会在.ipsproject生成器设置"retainAnnotations"中删除.:只需在其中添加覆盖",生成器就不会删除您手动放置的任何"@覆盖"注释.

If you have certain annotations that you want to add in many places, that workaround is too much work, so Faktor-IPS allows you to define a list of annotations that will never be removed in the .ipsproject generator setting 'retainAnnotations': just add 'Override' there and any '@Override' annotation you manually place won't be removed by the generator.

这篇关于Faktor-IPS代码生成器删除了注释的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆