use of javax.lang.model.element.Element in project androidannotations by androidannotations.
the class AppHandler method validate.
@Override
public void validate(Element element, ElementValidation validation) {
injectHelper.validate(App.class, element, validation);
if (!validation.isValid()) {
return;
}
validatorHelper.isNotPrivate(element, validation);
Element param = injectHelper.getParam(element);
validatorHelper.typeHasAnnotation(EApplication.class, param, validation);
}
use of javax.lang.model.element.Element in project androidannotations by androidannotations.
the class InjectMenuHandler method validate.
@Override
public void validate(Element element, ElementValidation valid) {
injectHelper.validate(InjectMenu.class, element, valid);
if (!valid.isValid()) {
return;
}
Element param = injectHelper.getParam(element);
validatorHelper.isDeclaredType(param, valid);
validatorHelper.extendsMenu(param, valid);
validatorHelper.isNotPrivate(element, valid);
}
use of javax.lang.model.element.Element in project androidannotations by androidannotations.
the class RootContextHandler method validate.
@Override
public void validate(Element element, ElementValidation validation) {
injectHelper.validate(RootContext.class, element, validation);
if (!validation.isValid()) {
return;
}
Element param = injectHelper.getParam(element);
validatorHelper.extendsContext(param, validation);
validatorHelper.isNotPrivate(element, validation);
}
use of javax.lang.model.element.Element in project androidannotations by androidannotations.
the class CoreValidatorHelper method isSharedPreference.
public void isSharedPreference(Element element, ElementValidation valid) {
TypeMirror type = element.asType();
if (element instanceof ExecutableElement) {
element = ((ExecutableElement) element).getParameters().get(0);
type = element.asType();
}
/*
* The type is not available yet because it has just been generated
*/
if (type instanceof ErrorType || type.getKind() == TypeKind.ERROR) {
String elementTypeName = type.toString();
boolean sharedPrefValidatedInRound = false;
if (elementTypeName.endsWith(classSuffix())) {
String prefTypeName = elementTypeName.substring(0, elementTypeName.length() - classSuffix().length());
prefTypeName = prefTypeName.replace(classSuffix() + ".", ".");
Set<? extends Element> sharedPrefElements = validatedModel().getRootAnnotatedElements(SharedPref.class.getName());
for (Element sharedPrefElement : sharedPrefElements) {
TypeElement sharedPrefTypeElement = (TypeElement) sharedPrefElement;
String sharedPrefQualifiedName = sharedPrefTypeElement.getQualifiedName().toString();
if (sharedPrefQualifiedName.endsWith(prefTypeName)) {
sharedPrefValidatedInRound = true;
break;
}
}
}
if (!sharedPrefValidatedInRound) {
valid.invalidate();
}
} else {
extendsType(element, SharedPreferencesHelper.class.getName(), valid);
}
}
use of javax.lang.model.element.Element in project androidannotations by androidannotations.
the class ModelProcessor method generateElements.
@SuppressWarnings({ "unchecked", "rawtypes" })
private boolean generateElements(AnnotationElements validatedModel, ProcessHolder processHolder) throws Exception {
boolean isElementRemaining = false;
for (GeneratingAnnotationHandler generatingAnnotationHandler : environment.getGeneratingHandlers()) {
if (!generatingAnnotationHandler.isEnabled()) {
continue;
}
String annotationName = generatingAnnotationHandler.getTarget();
Set<? extends Element> annotatedElements = validatedModel.getRootAnnotatedElements(annotationName);
if (!annotatedElements.isEmpty()) {
LOGGER.debug("Processing root elements {}: {}", generatingAnnotationHandler.getClass().getSimpleName(), annotatedElements);
}
for (Element annotatedElement : annotatedElements) {
/*
* We do not generate code for abstract classes, because the
* generated classes are final anyway (we do not want anyone to
* extend them).
*/
if (!isAbstractClass(annotatedElement)) {
if (processHolder.getGeneratedClassHolder(annotatedElement) == null) {
TypeElement typeElement = (TypeElement) annotatedElement;
Element enclosingElement = annotatedElement.getEnclosingElement();
if (typeElement.getNestingKind() == NestingKind.MEMBER && processHolder.getGeneratedClassHolder(enclosingElement) == null) {
isElementRemaining = true;
} else {
GeneratedClassHolder generatedClassHolder = generatingAnnotationHandler.createGeneratedClassHolder(environment, typeElement);
processHolder.put(annotatedElement, generatedClassHolder);
generatingAnnotationHandler.process(annotatedElement, generatedClassHolder);
}
}
} else {
LOGGER.trace("Skip element {} because it's abstract", annotatedElement);
}
}
/*
* We currently do not take into account class annotations from
* ancestors. We should careful design the priority rules first.
*/
}
return isElementRemaining;
}
Aggregations