package de.japkit.annotations;

import de.japkit.annotations.RuntimeMetadata.Element;
import de.japkit.annotations.RuntimeMetadata.List;
import de.japkit.metaannotations.AV;
import de.japkit.metaannotations.AVMode;
import de.japkit.metaannotations.Annotation;
import de.japkit.metaannotations.AnnotationMode;
import de.japkit.metaannotations.Clazz;
import de.japkit.metaannotations.Trigger;
import de.japkit.metaannotations.Var;

@Trigger(layer=-1, vars=@Var(name="srcClass", ifEmpty=true, expr="#{annotatedClass.asType()}"))
@Clazz(nameSuffixToAppend=RuntimeMetadata.CLASS_SUFFIX, annotations={
	@Annotation(id="elementMetadata", targetAnnotation=Element.class, 
			values={
				@AV(name="id", expr="#{elements.uniqueNameWithinTopLevelEnclosingTypeElement(src)}"), 
				@AV(name="comment", expr="#{elements.getDocComment(src)}"),
				@AV(cond="#{src.kind.name()=='METHOD' || src.kind.name()=='CONSTRUCTOR'}", name="paramNames", expr="#{src.parameters}")
		}),
	@Annotation(targetAnnotation=List.class, mode=AnnotationMode.MERGE, 
		values=@AV(name = "value", expr="#{elements.elementAndAllEnclosedElements(src)}", mode=AVMode.JOIN_LIST, annotationMappingId="elementMetadata"))
})

public @interface RuntimeMetadata {
	public static final String CLASS_SUFFIX = "_RuntimeMetadata";
	
	boolean shadow() default false;
	
	Class<?>[] srcClass() default {};
	
	@interface Element {

		String id();
		String comment() default "";
		String[] paramNames() default {};
		
		
	}
	
	@interface List{
		Element[] value();
	}
}

@@ -25,16 +25,140 @@
 tions;%0A%0A
+import static javax.lang.model.element.ElementKind.CONSTRUCTOR;%0Aimport static javax.lang.model.element.ElementKind.METHOD;%0A%0A
 import d
@@ -203,16 +203,16 @@
 lement;%0A
-
 import d
@@ -466,16 +466,58 @@
 .Clazz;%0A
+import de.japkit.metaannotations.Matcher;%0A
 import d
@@ -1006,73 +1006,53 @@
 cond
-=%22#%7Bsrc.kind.name()=='METHOD' %7C%7C src.kind.name()=='CONSTRUCTOR'%7D%22
+Fun=RuntimeMetadata.methodOrConstructor.class
 , na
@@ -1321,16 +1321,16 @@
 %22))%0A%7D)%0A%0A
-
 public @
@@ -1357,16 +1357,85 @@
 adata %7B%0A
+%09@Matcher(kind=%7BMETHOD, CONSTRUCTOR%7D)%0A%09class methodOrConstructor%7B%7D%0A%09%0A
 %09public 

Revert "Workaround for Eclipse Luna bug: The class methodOrConstructor has no annotations (probably since it does not get resolved by jdt apt)"