Search in sources :

Example 1 with JavacTypes

use of com.sun.tools.javac.model.JavacTypes in project ceylon-compiler by ceylon.

the class TestSymtabItems method run.

void run() throws Exception {
    Context c = new Context();
    JavacFileManager.preRegister(c);
    Symtab syms = Symtab.instance(c);
    JavacTypes types = JavacTypes.instance(c);
    // will init ClassReader.sourceCompleter
    JavaCompiler.instance(c);
    for (Field f : Symtab.class.getDeclaredFields()) {
        // during API evolution
        if (f.getName().toLowerCase().contains("methodhandle"))
            continue;
        Class<?> ft = f.getType();
        if (TypeMirror.class.isAssignableFrom(ft))
            print(f.getName(), (TypeMirror) f.get(syms), types);
        else if (Element.class.isAssignableFrom(ft))
            print(f.getName(), (Element) f.get(syms));
    }
    if (errors > 0)
        throw new Exception(errors + " errors occurred");
}
Also used : Context(com.sun.tools.javac.util.Context) Symtab(com.sun.tools.javac.code.Symtab) JavacTypes(com.sun.tools.javac.model.JavacTypes) Field(java.lang.reflect.Field) TypeMirror(javax.lang.model.type.TypeMirror) PackageElement(javax.lang.model.element.PackageElement) ExecutableElement(javax.lang.model.element.ExecutableElement) VariableElement(javax.lang.model.element.VariableElement) Element(javax.lang.model.element.Element) TypeElement(javax.lang.model.element.TypeElement) TypeParameterElement(javax.lang.model.element.TypeParameterElement) UnknownTypeException(javax.lang.model.type.UnknownTypeException) UnknownElementException(javax.lang.model.element.UnknownElementException)

Aggregations

Symtab (com.sun.tools.javac.code.Symtab)1 JavacTypes (com.sun.tools.javac.model.JavacTypes)1 Context (com.sun.tools.javac.util.Context)1 Field (java.lang.reflect.Field)1 Element (javax.lang.model.element.Element)1 ExecutableElement (javax.lang.model.element.ExecutableElement)1 PackageElement (javax.lang.model.element.PackageElement)1 TypeElement (javax.lang.model.element.TypeElement)1 TypeParameterElement (javax.lang.model.element.TypeParameterElement)1 UnknownElementException (javax.lang.model.element.UnknownElementException)1 VariableElement (javax.lang.model.element.VariableElement)1 TypeMirror (javax.lang.model.type.TypeMirror)1 UnknownTypeException (javax.lang.model.type.UnknownTypeException)1