use of javax.lang.model.element.ElementKind in project spring-framework by spring-projects.
the class IndexedStereotypesProvider method getStereotypes.
@Override
public Set<String> getStereotypes(Element element) {
Set<String> stereotypes = new LinkedHashSet<>();
ElementKind kind = element.getKind();
if (kind != ElementKind.CLASS && kind != ElementKind.INTERFACE) {
return stereotypes;
}
Set<Element> seen = new HashSet<>();
collectStereotypesOnAnnotations(seen, stereotypes, element);
seen = new HashSet<>();
collectStereotypesOnTypes(seen, stereotypes, element);
return stereotypes;
}
use of javax.lang.model.element.ElementKind in project androidannotations by androidannotations.
the class ModelExtractor method extractAncestorsAnnotations.
private void extractAncestorsAnnotations(AnnotationElementsHolder extractedModel, Set<String> annotationTypesToCheck, Set<TypeElement> rootTypeElements) {
for (TypeElement rootTypeElement : rootTypeElements) {
Set<TypeElement> ancestors = new LinkedHashSet<>();
addAncestorsElements(ancestors, rootTypeElement);
if (!ancestors.isEmpty()) {
for (TypeElement ancestor : ancestors) {
extractAnnotations(extractedModel, annotationTypesToCheck, rootTypeElement, ancestor);
for (Element ancestorEnclosedElement : ancestor.getEnclosedElements()) {
ElementKind enclosedKind = ancestorEnclosedElement.getKind();
if (enclosedKind == ElementKind.FIELD || enclosedKind == ElementKind.METHOD) {
extractAnnotations(extractedModel, annotationTypesToCheck, rootTypeElement, ancestorEnclosedElement);
}
}
}
}
}
}
use of javax.lang.model.element.ElementKind in project dagger by square.
the class InjectAdapterProcessor method validateInjectable.
private boolean validateInjectable(Element injectable) {
Element injectableType = injectable.getEnclosingElement();
if (injectable.getKind() == ElementKind.CLASS) {
error("@Inject is not valid on a class: " + elementToString(injectable), injectable);
return false;
}
if (injectable.getKind() == ElementKind.METHOD) {
error("Method injection is not supported: " + elementToString(injectable), injectable);
return false;
}
if (injectable.getKind() == ElementKind.FIELD && injectable.getModifiers().contains(FINAL)) {
error("Can't inject a final field: " + elementToString(injectable), injectable);
return false;
}
if (injectable.getKind() == ElementKind.FIELD && injectable.getModifiers().contains(PRIVATE)) {
error("Can't inject a private field: " + elementToString(injectable), injectable);
return false;
}
if (injectable.getKind() == ElementKind.CONSTRUCTOR && injectable.getModifiers().contains(PRIVATE)) {
error("Can't inject a private constructor: " + elementToString(injectable), injectable);
return false;
}
ElementKind elementKind = injectableType.getEnclosingElement().getKind();
boolean isClassOrInterface = elementKind.isClass() || elementKind.isInterface();
boolean isStatic = injectableType.getModifiers().contains(STATIC);
if (isClassOrInterface && !isStatic) {
error("Can't inject a non-static inner class: " + elementToString(injectable), injectableType);
return false;
}
return true;
}
use of javax.lang.model.element.ElementKind in project tiger by google.
the class Utils method getPackage.
public static PackageElement getPackage(TypeElement typeElement) {
Element result = typeElement.getEnclosingElement();
ElementKind elementKind = result.getKind();
while (!elementKind.equals(ElementKind.PACKAGE)) {
Preconditions.checkState(elementKind.isClass() || elementKind.isInterface(), String.format("Utils.getPackage: unexpected kind: %s for type: %s", elementKind, typeElement));
result = result.getEnclosingElement();
elementKind = result.getKind();
}
return (PackageElement) result;
}
use of javax.lang.model.element.ElementKind in project tiger by google.
the class NewBindingKey method get.
public static NewBindingKey get(Element element) {
ElementKind elementKind = element.getKind();
Preconditions.checkArgument(elementKind.equals(ElementKind.CLASS) || elementKind.equals(ElementKind.PARAMETER), String.format("Unexpected element %s of Kind %s", element, elementKind));
return get(element.asType(), Utils.getQualifier(element));
}
Aggregations