use of javax.lang.model.element.Element in project immutables by immutables.
the class Round method enclosingTypeOf.
private TypeElement enclosingTypeOf(Element element) {
for (Element e = element; e != null; ) {
ElementKind kind = e.getKind();
if (kind.isClass() || kind.isInterface()) {
return (TypeElement) e;
}
e = e.getEnclosingElement();
}
throw new NoSuchElementException();
}
use of javax.lang.model.element.Element in project immutables by immutables.
the class AccessorAttributesCollector method collectGeneratedCandidateMethods.
private void collectGeneratedCandidateMethods(TypeElement type) {
TypeElement originalType = CachingElements.getDelegate(type);
List<? extends Element> accessorsInSourceOrder;
if (originalType.getKind() == ElementKind.ANNOTATION_TYPE) {
accessorsInSourceOrder = SourceOrdering.getEnclosedElements(originalType);
} else {
AccessorProvider provider = SourceOrdering.getAllAccessorsProvider(processing.getElementUtils(), processing.getTypeUtils(), originalType);
accessorsInSourceOrder = provider.get();
accessorMapping = provider.accessorMapping();
}
for (ExecutableElement element : ElementFilter.methodsIn(accessorsInSourceOrder)) {
if (isElegibleAccessorMethod(element)) {
processGenerationCandidateMethod(element, originalType);
}
}
// inform use during checking for warnings.
for (Element element : processing.getElementUtils().getAllMembers(originalType)) {
if (element.getKind() == ElementKind.METHOD) {
switch(element.getSimpleName().toString()) {
case HASH_CODE_METHOD:
case TO_STRING_METHOD:
case EQUALS_METHOD:
processUtilityCandidateMethod((ExecutableElement) element, originalType);
break;
default:
}
}
}
}
use of javax.lang.model.element.Element in project immutables by immutables.
the class Round method allAnnotatedElements.
private Set<Element> allAnnotatedElements() {
Set<Element> elements = Sets.newHashSetWithExpectedSize(100);
for (TypeElement annotation : annotations()) {
Set<? extends Element> annotatedElements = round().getElementsAnnotatedWith(annotation);
checkAnnotation(annotation, annotatedElements);
elements.addAll(annotatedElements);
}
return elements;
}
use of javax.lang.model.element.Element in project hibernate-orm by hibernate.
the class TypeUtils method determineAnnotationSpecifiedAccessType.
public static AccessType determineAnnotationSpecifiedAccessType(Element element) {
final AnnotationMirror accessAnnotationMirror = TypeUtils.getAnnotationMirror(element, Constants.ACCESS);
AccessType forcedAccessType = null;
if (accessAnnotationMirror != null) {
Element accessElement = (Element) TypeUtils.getAnnotationValue(accessAnnotationMirror, DEFAULT_ANNOTATION_PARAMETER_NAME);
if (accessElement.getKind().equals(ElementKind.ENUM_CONSTANT)) {
if (accessElement.getSimpleName().toString().equals(AccessType.PROPERTY.toString())) {
forcedAccessType = AccessType.PROPERTY;
} else if (accessElement.getSimpleName().toString().equals(AccessType.FIELD.toString())) {
forcedAccessType = AccessType.FIELD;
}
}
}
return forcedAccessType;
}
use of javax.lang.model.element.Element in project hibernate-orm by hibernate.
the class JPAMetaModelEntityProcessor method process.
@Override
public boolean process(final Set<? extends TypeElement> annotations, final RoundEnvironment roundEnvironment) {
// see also METAGEN-45
if (roundEnvironment.processingOver() || annotations.size() == 0) {
return ALLOW_OTHER_PROCESSORS_TO_CLAIM_ANNOTATIONS;
}
if (context.isFullyXmlConfigured()) {
context.logMessage(Diagnostic.Kind.OTHER, "Skipping the processing of annotations since persistence unit is purely xml configured.");
return ALLOW_OTHER_PROCESSORS_TO_CLAIM_ANNOTATIONS;
}
Set<? extends Element> elements = roundEnvironment.getRootElements();
for (Element element : elements) {
if (isJPAEntity(element)) {
context.logMessage(Diagnostic.Kind.OTHER, "Processing annotated class " + element.toString());
handleRootElementAnnotationMirrors(element);
}
}
createMetaModelClasses();
return ALLOW_OTHER_PROCESSORS_TO_CLAIM_ANNOTATIONS;
}
Aggregations