use of javax.lang.model.type.DeclaredType in project tiger by google.
the class NewScopeCalculator method getExplicitScopes.
private Map<NewBindingKey, ? extends NewScopeCalculatingInfo> getExplicitScopes() {
Map<NewBindingKey, NewScopeCalculatingInfo> result = new HashMap<>();
for (NewDependencyInfo info : dependencyInfos) {
NewBindingKey key = info.getDependant();
Element ele = info.getProvisionMethodElement() != null ? info.getProvisionMethodElement() : info.getSourceClassElement();
DeclaredType scopeType = Utils.getScopeType(ele);
if (scopeType != null) {
if (!info.isUnique()) {
messager.printMessage(Kind.ERROR, String.format("Non-unique binding must be unscoped: %s", info));
}
TypeElement scope = (TypeElement) scopeType.asElement();
int scopeSize = scopeSizer.getScopeSize(scope);
result.put(key, new NewScopeCalculatingInfo(scope, scopeSize, new ArrayList<NewBindingKey>()));
}
}
return result;
}
use of javax.lang.model.type.DeclaredType in project tiger by google.
the class TigerDaggerGeneratorProcessor method getComponentDependencies.
/**
* Returns dependency components of the give component, empty set if none.
*/
private Set<TypeElement> getComponentDependencies(TypeElement component) {
Set<TypeElement> result = new HashSet<>();
AnnotationMirror componentAnnotationMirror = Preconditions.checkNotNull(Utils.getAnnotationMirror(component, Component.class), String.format("@Component not found for %s", component));
AnnotationValue dependenciesAnnotationValue = Utils.getAnnotationValue(componentAnnotationMirror, "dependencies");
if (dependenciesAnnotationValue == null) {
return result;
}
List<? extends AnnotationValue> dependencies = (List<? extends AnnotationValue>) dependenciesAnnotationValue.getValue();
for (AnnotationValue dependency : dependencies) {
result.add((TypeElement) ((DeclaredType) dependency.getValue()).asElement());
}
return result;
}
use of javax.lang.model.type.DeclaredType in project tiger by google.
the class TigerDaggerGeneratorProcessor method getAllModulesOfComponentRecursively.
private Set<TypeElement> getAllModulesOfComponentRecursively(TypeElement component) {
Set<TypeElement> result = new HashSet<>();
AnnotationMirror componentAnnotationMirror = Utils.getAnnotationMirror(component, Component.class);
for (AnnotationValue annotationValue : (List<AnnotationValue>) Utils.getAnnotationValue(componentAnnotationMirror, "modules").getValue()) {
result.add((TypeElement) ((DeclaredType) annotationValue.getValue()).asElement());
}
result = Utils.findAllModulesRecursively(result);
return result;
}
use of javax.lang.model.type.DeclaredType in project tiger by google.
the class Utils method isSingletonScoped.
public static boolean isSingletonScoped(Elements elementUtils, Element element) {
DeclaredType scopeType = Utils.getScopeType(element);
boolean result = scopeType != null && scopeType.asElement().equals(elementUtils.getTypeElement(Singleton.class.getCanonicalName()));
return result;
}
use of javax.lang.model.type.DeclaredType in project tiger by google.
the class Utils method hasAnonymousParentClass.
public static boolean hasAnonymousParentClass(TypeElement cls) {
Preconditions.checkNotNull(cls);
do {
if (cls.getSimpleName().length() == 0) {
return true;
}
TypeMirror parentClass = cls.getSuperclass();
if (parentClass.getKind().equals(TypeKind.NONE)) {
return false;
}
cls = (TypeElement) ((DeclaredType) parentClass).asElement();
} while (true);
}
Aggregations