eclipse / xtext

Eclipse Xtext™ is a language development framework
http://www.eclipse.org/Xtext
Eclipse Public License 2.0
768 stars 321 forks source link

Annotation with static member generates annotation property #2317

Open marciodel opened 5 years ago

marciodel commented 5 years ago

The xtend code:

import java.lang.annotation.Retention

@Retention(RUNTIME)
annotation TemplateTag {
    static val String SAME = "*"

    String tag = ""
} 

Generates:

import java.lang.annotation.Retention;
import java.lang.annotation.RetentionPolicy;

@Retention(RetentionPolicy.RUNTIME)
public @interface TemplateTag {
  public String SAME() default "*";
  public String tag() default "";
}

Expected result:

import java.lang.annotation.Retention;
import java.lang.annotation.RetentionPolicy;

@Retention(RetentionPolicy.RUNTIME)
public @interface TemplateTag {
  public static final String SAME =  "*";
  public String tag() default "";
}
cdietrich commented 5 years ago

From XtendFieldImplCustom

    @Override
    public boolean isStatic() {
        return super.isStatic() ? true 
                : getDeclaringType() instanceof XtendInterface || getDeclaringType() instanceof XtendAnnotationType;
    }

also the Inferrer and likely JvmModelGenerator may need adoption