use of javax.lang.model.element.Element in project androidannotations by androidannotations.
the class NonConfigurationInstanceHandler method rebindContextIfBean.
private void rebindContextIfBean(Element element, JBlock initIfNonConfigurationNotNullBlock, JFieldVar field) {
boolean hasBeanAnnotation = element.getAnnotation(Bean.class) != null;
if (hasBeanAnnotation) {
TypeMirror elementType = annotationHelper.extractAnnotationClassParameter(element, Bean.class.getName());
if (elementType == null) {
elementType = element.asType();
}
String typeQualifiedName = elementType.toString();
AbstractJClass fieldGeneratedBeanClass = getJClass(typeQualifiedName + classSuffix());
// do not generate rebind call for singleton beans
Element eBeanTypeElement = annotationHelper.getTypeUtils().asElement(elementType);
EBean eBean = eBeanTypeElement.getAnnotation(EBean.class);
if (eBean != null && eBean.scope() != EBean.Scope.Singleton) {
initIfNonConfigurationNotNullBlock.invoke(cast(fieldGeneratedBeanClass, field), "rebind").arg(_this());
}
}
}
use of javax.lang.model.element.Element in project androidannotations by androidannotations.
the class ExtraHandler method afterAllParametersInjected.
@Override
public void afterAllParametersInjected(EActivityHolder holder, ExecutableElement method, List<InjectHelper.ParamHelper> parameterList) {
List<IntentBuilder.IntentExtra> params = new ArrayList<>();
for (InjectHelper.ParamHelper paramHelper : parameterList) {
Element param = paramHelper.getParameterElement();
String fieldName = param.getSimpleName().toString();
String extraKey = extractExtraKey(param, fieldName);
JFieldVar extraKeyStaticField = getOrCreateStaticExtraField(holder, extraKey, fieldName);
params.add(new IntentBuilder.IntentExtra(param.asType(), fieldName, extraKeyStaticField));
}
holder.getIntentBuilder().getPutExtraMethod(method, params);
}
use of javax.lang.model.element.Element in project androidannotations by androidannotations.
the class FragmentArgHandler method afterAllParametersInjected.
@Override
public void afterAllParametersInjected(EFragmentHolder holder, ExecutableElement method, List<InjectHelper.ParamHelper> parameterList) {
List<ArgHelper> argHelpers = new ArrayList<>();
for (InjectHelper.ParamHelper paramHelper : parameterList) {
Element param = paramHelper.getParameterElement();
String fieldName = param.getSimpleName().toString();
String argKey = extractArgKey(param, fieldName);
argHelpers.add(new ArgHelper(param, argKey));
}
createBuilderInjectMethod(holder, method, argHelpers);
}
use of javax.lang.model.element.Element in project androidannotations by androidannotations.
the class AndroidAnnotationProcessor method handleException.
private void handleException(Set<? extends TypeElement> annotations, RoundEnvironment roundEnv, ProcessingException e) {
String errorMessage = errorHelper.getErrorMessage(processingEnv, e, coreVersion);
/*
* Printing exception as an error on a random element. The exception is
* not related to this element, but otherwise it wouldn't show up in
* eclipse.
*/
Iterator<? extends TypeElement> iterator = annotations.iterator();
if (iterator.hasNext()) {
Element element = roundEnv.getElementsAnnotatedWith(iterator.next()).iterator().next();
LOGGER.error("Something went wrong: {}", element, errorMessage);
} else {
LOGGER.error("Something went wrong: {}", errorMessage);
}
}
use of javax.lang.model.element.Element in project androidannotations by androidannotations.
the class AbstractResHandler method validate.
@Override
public final void validate(Element element, ElementValidation validation) {
injectHelper.validate(androidRes.getAnnotationClass(), element, validation);
if (!validation.isValid()) {
return;
}
validatorHelper.allowedType(element, androidRes.getAllowedTypes(), validation);
validatorHelper.resIdsExist(element, androidRes.getRInnerClass(), IdValidatorHelper.FallbackStrategy.USE_ELEMENT_NAME, validation);
Element enclosingElement = element.getEnclosingElement();
if (element instanceof VariableElement && enclosingElement instanceof ExecutableElement) {
validatorHelper.isNotPrivate(enclosingElement, validation);
} else {
validatorHelper.isNotPrivate(element, validation);
}
}
Aggregations