Skip to content
This repository was archived by the owner on Feb 26, 2023. It is now read-only.
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -109,7 +109,6 @@
import com.googlecode.androidannotations.model.AndroidSystemServices;
import com.googlecode.androidannotations.model.AnnotationElements;
import com.googlecode.androidannotations.model.AnnotationElementsHolder;
import com.googlecode.androidannotations.model.EmptyAnnotationElements;
import com.googlecode.androidannotations.model.ModelExtractor;
import com.googlecode.androidannotations.processing.AfterInjectProcessor;
import com.googlecode.androidannotations.processing.AfterTextChangeProcessor;
Expand Down Expand Up @@ -340,9 +339,11 @@ private void processThrowing(Set<? extends TypeElement> annotations, RoundEnviro

AnnotationElements validatedModel = validateAnnotations(extractedModel, rClass, androidSystemServices, androidManifest);

JCodeModel codeModel = processAnnotations(validatedModel, rClass, androidSystemServices, androidManifest);
if (validatedModel != null) {
JCodeModel codeModel = processAnnotations(validatedModel, rClass, androidSystemServices, androidManifest);

generateSources(codeModel);
generateSources(codeModel);
}
}

private boolean nothingToDo(Set<? extends TypeElement> annotations, RoundEnvironment roundEnv) {
Expand All @@ -351,7 +352,7 @@ private boolean nothingToDo(Set<? extends TypeElement> annotations, RoundEnviron

private AnnotationElementsHolder extractAnnotations(Set<? extends TypeElement> annotations, RoundEnvironment roundEnv) {
timeStats.start("Extract Annotations");
ModelExtractor modelExtractor = new ModelExtractor();
ModelExtractor modelExtractor = new ModelExtractor(processingEnv, getSupportedAnnotationClasses());
AnnotationElementsHolder extractedModel = modelExtractor.extract(annotations, roundEnv);
timeStats.stop("Extract Annotations");
return extractedModel;
Expand Down Expand Up @@ -388,7 +389,7 @@ private AnnotationElements validateAnnotations(AnnotationElementsHolder extracte
ModelValidator modelValidator = buildModelValidator(rClass, androidSystemServices, androidManifest);
validatedAnnotations = modelValidator.validate(extractedModel);
} else {
validatedAnnotations = EmptyAnnotationElements.INSTANCE;
validatedAnnotations = null;
}
timeStats.stop("Validate Annotations");
return validatedAnnotations;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -44,18 +44,42 @@ public abstract class AnnotatedAbstractProcessor extends AbstractProcessor {
* or {@link AbstractProcessor#getSupportedAnnotationTypes()} result
* if none
*/
@Override
public Set<String> getSupportedAnnotationTypes() {
SupportedAnnotationClasses sac = this.getClass().getAnnotation(SupportedAnnotationClasses.class);
if (sac == null) {
if (isInitialized())
Class<? extends Annotation>[] annotationClassesArray = readSupportedAnnotationClasses();
if (annotationClassesArray == null) {
if (isInitialized()) {
processingEnv.getMessager().printMessage(Diagnostic.Kind.WARNING, "No " + SupportedAnnotationClasses.class.getSimpleName() + " annotation " + "found on " + this.getClass().getName() + ", returning parent method result.");
}
return super.getSupportedAnnotationTypes();
} else
return arrayToSet(sac.value());
} else {
return arrayToSet(annotationClassesArray);
}
}

private Class<? extends Annotation>[] readSupportedAnnotationClasses() {
SupportedAnnotationClasses sac = this.getClass().getAnnotation(SupportedAnnotationClasses.class);
if (sac != null) {
return sac.value();
} else {
return null;
}
}

public Set<Class<? extends Annotation>> getSupportedAnnotationClasses() {
Class<? extends Annotation>[] annotationClassesArray = readSupportedAnnotationClasses();
if (annotationClassesArray == null) {
return Collections.emptySet();
} else {
Set<Class<? extends Annotation>> set = new HashSet<Class<? extends Annotation>>(annotationClassesArray.length);
for (Class<? extends Annotation> c : annotationClassesArray) {
set.add(c);
}
return Collections.unmodifiableSet(set);
}
}

private static Set<String> arrayToSet(Class<? extends Annotation>[] array) {
assert array != null;
Set<String> set = new HashSet<String>(array.length);
for (Class<? extends Annotation> c : array) {
set.add(c.getName());
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -33,7 +33,7 @@
* class.
*
*/
@Retention(RetentionPolicy.SOURCE)
@Retention(RetentionPolicy.CLASS)
@Target(ElementType.METHOD)
public @interface AfterInject {
}
Original file line number Diff line number Diff line change
Expand Up @@ -74,7 +74,7 @@
* // Something Here
* }
*/
@Retention(RetentionPolicy.SOURCE)
@Retention(RetentionPolicy.CLASS)
@Target(ElementType.METHOD)
public @interface AfterTextChange {

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -35,7 +35,7 @@
* activity.
*
*/
@Retention(RetentionPolicy.SOURCE)
@Retention(RetentionPolicy.CLASS)
@Target(ElementType.METHOD)
public @interface AfterViews {
}
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,7 @@
* Injects the application. Please check that your registered the application in
* the AndroidManifest.xml class prior to using this annotation.
*/
@Retention(RetentionPolicy.SOURCE)
@Retention(RetentionPolicy.CLASS)
@Target(ElementType.FIELD)
public @interface App {
}
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,7 @@
* must belong to an activity annotated with @Layout.
*
*/
@Retention(RetentionPolicy.SOURCE)
@Retention(RetentionPolicy.CLASS)
@Target(ElementType.METHOD)
public @interface Background {
}
Original file line number Diff line number Diff line change
Expand Up @@ -81,7 +81,7 @@
*
* </blockquote>
*/
@Retention(RetentionPolicy.SOURCE)
@Retention(RetentionPolicy.CLASS)
@Target(ElementType.METHOD)
public @interface BeforeTextChange {

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -30,7 +30,7 @@
* name will be used as the R.id.* field name.
*
*/
@Retention(RetentionPolicy.SOURCE)
@Retention(RetentionPolicy.CLASS)
@Target(ElementType.METHOD)
public @interface Click {

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -41,7 +41,7 @@
* AndroidAnnotations.
*
*/
@Retention(RetentionPolicy.SOURCE)
@Retention(RetentionPolicy.CLASS)
@Target(ElementType.TYPE)
public @interface EActivity {
int value() default ResId.DEFAULT_VALUE;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -27,7 +27,7 @@
* to handle the view creation by yourself.
*
*/
@Retention(RetentionPolicy.SOURCE)
@Retention(RetentionPolicy.CLASS)
@Target(ElementType.TYPE)
public @interface EFragment {
int value() default ResId.DEFAULT_VALUE;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,7 @@
/**
* Use this annotation to enhance an Android ContentProvider
*/
@Retention(RetentionPolicy.SOURCE)
@Retention(RetentionPolicy.CLASS)
@Target(ElementType.TYPE)
public @interface EProvider {
}
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,7 @@
/**
* Use this annotation to enhance an Android BroadcastReceiver
*/
@Retention(RetentionPolicy.SOURCE)
@Retention(RetentionPolicy.CLASS)
@Target(ElementType.TYPE)
public @interface EReceiver {
}
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,7 @@
/**
* Use this annotation to enhance an Android Service
*/
@Retention(RetentionPolicy.SOURCE)
@Retention(RetentionPolicy.CLASS)
@Target(ElementType.TYPE)
public @interface EService {
}
Original file line number Diff line number Diff line change
Expand Up @@ -46,7 +46,7 @@
* to build a custom component.</a>
*
*/
@Retention(RetentionPolicy.SOURCE)
@Retention(RetentionPolicy.CLASS)
@Target(ElementType.TYPE)
public @interface EView {
}
Original file line number Diff line number Diff line change
Expand Up @@ -46,7 +46,7 @@
* to build a custom component.</a>
*
*/
@Retention(RetentionPolicy.SOURCE)
@Retention(RetentionPolicy.CLASS)
@Target(ElementType.TYPE)
public @interface EViewGroup {
int value() default ResId.DEFAULT_VALUE;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -30,7 +30,7 @@
* annotated extras.
*
*/
@Retention(RetentionPolicy.SOURCE)
@Retention(RetentionPolicy.CLASS)
@Target(ElementType.FIELD)
public @interface Extra {

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -27,7 +27,7 @@
* name will be used as the R.id.* field name.
*
*/
@Retention(RetentionPolicy.SOURCE)
@Retention(RetentionPolicy.CLASS)
@Target(ElementType.FIELD)
public @interface FragmentById {
int value() default ResId.DEFAULT_VALUE;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -27,7 +27,7 @@
* field name will be used as tag name name.
*
*/
@Retention(RetentionPolicy.SOURCE)
@Retention(RetentionPolicy.CLASS)
@Target(ElementType.FIELD)
public @interface FragmentByTag {
String value() default "";
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,7 @@
import java.lang.annotation.RetentionPolicy;
import java.lang.annotation.Target;

@Retention(RetentionPolicy.SOURCE)
@Retention(RetentionPolicy.CLASS)
@Target(ElementType.FIELD)
public @interface FromHtml {
int value() default ResId.DEFAULT_VALUE;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,7 @@
* The activity must be annotated with {@link EActivity}.
*
*/
@Retention(RetentionPolicy.SOURCE)
@Retention(RetentionPolicy.CLASS)
@Target(ElementType.TYPE)
public @interface Fullscreen {
}
Original file line number Diff line number Diff line change
Expand Up @@ -56,7 +56,7 @@
*
* @author Nabil Hachicha
*/
@Retention(RetentionPolicy.SOURCE)
@Retention(RetentionPolicy.CLASS)
@Target(ElementType.FIELD)
public @interface HttpsClient {
public static final String DEFAULT_PASSWD = "changeit";
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,7 @@
* Use on activity fields to save and restore their values when the
* system calls onSaveInstanceState(Bundle) and onCreate(Bundle).
*/
@Retention(RetentionPolicy.SOURCE)
@Retention(RetentionPolicy.CLASS)
@Target(ElementType.FIELD)
public @interface InstanceState {
}
Original file line number Diff line number Diff line change
Expand Up @@ -37,7 +37,7 @@
* @author Mathieu Boniface
*
*/
@Retention(RetentionPolicy.SOURCE)
@Retention(RetentionPolicy.CLASS)
@Target(ElementType.METHOD)
public @interface ItemClick {
int[] value() default ResId.DEFAULT_VALUE;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -41,7 +41,7 @@
* @author Mathieu Boniface
*
*/
@Retention(RetentionPolicy.SOURCE)
@Retention(RetentionPolicy.CLASS)
@Target(ElementType.METHOD)
public @interface ItemLongClick {
int[] value() default ResId.DEFAULT_VALUE;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -38,7 +38,7 @@
* @author Pierre-Yves Ricau
* @author Mathieu Boniface
*/
@Retention(RetentionPolicy.SOURCE)
@Retention(RetentionPolicy.CLASS)
@Target(ElementType.METHOD)
public @interface ItemSelect {
int[] value() default ResId.DEFAULT_VALUE;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -38,7 +38,7 @@
* @author Mathieu Boniface
*
*/
@Retention(RetentionPolicy.SOURCE)
@Retention(RetentionPolicy.CLASS)
@Target(ElementType.METHOD)
public @interface LongClick {
int[] value() default ResId.DEFAULT_VALUE;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,7 @@
* The activity must be annotated with {@link EActivity}.
*
*/
@Retention(RetentionPolicy.SOURCE)
@Retention(RetentionPolicy.CLASS)
@Target(ElementType.TYPE)
public @interface NoTitle {
}
Original file line number Diff line number Diff line change
Expand Up @@ -38,7 +38,7 @@
* This caution doesn't apply to beans annotated with {@link Bean}, because
* AndroidAnnotations automatically takes care of rebinding their context.
*/
@Retention(RetentionPolicy.SOURCE)
@Retention(RetentionPolicy.CLASS)
@Target(ElementType.FIELD)
public @interface NonConfigurationInstance {
}
Original file line number Diff line number Diff line change
Expand Up @@ -30,7 +30,7 @@
* name will be used as the R.id.* field name.
*
*/
@Retention(RetentionPolicy.SOURCE)
@Retention(RetentionPolicy.CLASS)
@Target(ElementType.METHOD)
public @interface OptionsItem {

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -28,7 +28,7 @@
* The annotation value should be one of R.menu.* fields.
*
*/
@Retention(RetentionPolicy.SOURCE)
@Retention(RetentionPolicy.CLASS)
@Target(ElementType.TYPE)
public @interface OptionsMenu {
int[] value() default ResId.DEFAULT_VALUE;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,7 @@
/**
* Should be used on Activity classes that use the RoboGuice framework
*/
@Retention(RetentionPolicy.SOURCE)
@Retention(RetentionPolicy.CLASS)
@Target(ElementType.TYPE)
public @interface RoboGuice {
/**
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -31,7 +31,7 @@
* on a field that extends Activity, this field will be null at runtime.
*
*/
@Retention(RetentionPolicy.SOURCE)
@Retention(RetentionPolicy.CLASS)
@Target(ElementType.FIELD)
public @interface RootContext {
}
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,7 @@
* Use it on manager fields in activity classes
*
*/
@Retention(RetentionPolicy.SOURCE)
@Retention(RetentionPolicy.CLASS)
@Target(ElementType.FIELD)
public @interface SystemService {
}
Original file line number Diff line number Diff line change
Expand Up @@ -77,7 +77,7 @@
* // Something Here
* }
*/
@Retention(RetentionPolicy.SOURCE)
@Retention(RetentionPolicy.CLASS)
@Target(ElementType.METHOD)
public @interface TextChange {

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -35,7 +35,7 @@
*
* @author Mathieu Boniface
*/
@Retention(RetentionPolicy.SOURCE)
@Retention(RetentionPolicy.CLASS)
@Target(ElementType.METHOD)
public @interface Touch {
int[] value() default ResId.DEFAULT_VALUE;
Expand Down
Loading