package org.checkerframework.framework.type;

import com.sun.source.tree.ClassTree;
import javax.lang.model.element.TypeElement;
import org.checkerframework.javacutil.TreeUtils;

/**
 * Converts ClassTrees into AnnotatedDeclaredType.
 *
 * @see org.checkerframework.framework.type.TypeFromTree
 */
class TypeFromClassVisitor extends TypeFromTreeVisitor {

  @Override
  public AnnotatedTypeMirror visitClass(ClassTree tree, AnnotatedTypeFactory f) {
    TypeElement elt = TreeUtils.elementFromDeclaration(tree);
    AnnotatedTypeMirror result = f.toAnnotatedType(elt.asType(), true);

    ElementAnnotationApplier.apply(result, elt, f);

    return result;
  }
}
