use of com.sun.tools.javac.processing.JavacProcessingEnvironment in project bazel by bazelbuild.
the class TypesUtils method wildUpperBound.
// Version of com.sun.tools.javac.code.Types.wildUpperBound(Type)
// that works with both jdk8 (called upperBound there) and jdk8u.
// TODO: contrast to upperBound.
public static Type wildUpperBound(ProcessingEnvironment env, TypeMirror tm) {
Type t = (Type) tm;
if (t.hasTag(TypeTag.WILDCARD)) {
Context context = ((JavacProcessingEnvironment) env).getContext();
Type.WildcardType w = (Type.WildcardType) TypeAnnotationUtils.unannotatedType(t);
if (w.isSuperBound()) {
Symtab syms = Symtab.instance(context);
return w.bound == null ? syms.objectType : w.bound.bound;
} else {
return wildUpperBound(env, w.type);
}
} else {
return TypeAnnotationUtils.unannotatedType(t);
}
}
use of com.sun.tools.javac.processing.JavacProcessingEnvironment in project error-prone by google.
the class RestrictedApiChecker method anyAnnotation.
private static Matcher<Tree> anyAnnotation(List<? extends TypeMirror> mirrors, VisitorState state) {
JavacProcessingEnvironment javacEnv = JavacProcessingEnvironment.instance(state.context);
ArrayList<Matcher<Tree>> matchers = new ArrayList<>(mirrors.size());
for (TypeMirror mirror : mirrors) {
TypeElement typeElem = (TypeElement) javacEnv.getTypeUtils().asElement(mirror);
String name = mirror.toString();
if (typeElem != null) {
// Get the binary name if possible ($ to separate nested members). See b/36160747
name = javacEnv.getElementUtils().getBinaryName(typeElem).toString();
}
matchers.add(Matchers.hasAnnotation(name));
}
return Matchers.anyOf(matchers);
}
use of com.sun.tools.javac.processing.JavacProcessingEnvironment in project antlr4 by antlr.
the class CommentHasStringValueProcessor method init.
@Override
public synchronized void init(ProcessingEnvironment processingEnv) {
super.init(processingEnv);
// Messager messager = processingEnv.getMessager();
// messager.printMessage(Diagnostic.Kind.NOTE, "WOW INIT--------------------");
JavacProcessingEnvironment javacProcessingEnv = (JavacProcessingEnvironment) processingEnv;
utilities = javacProcessingEnv.getElementUtils();
treeMaker = TreeMaker.instance(javacProcessingEnv.getContext());
}
use of com.sun.tools.javac.processing.JavacProcessingEnvironment in project com.revolsys.open by revolsys.
the class DocumentationProcessor method init.
@Override
public void init(final ProcessingEnvironment environment) {
super.init(environment);
if (environment instanceof JavacProcessingEnvironment) {
final JavacProcessingEnvironment javacProcessingEnv = (JavacProcessingEnvironment) environment;
this.elementUtils = javacProcessingEnv.getElementUtils();
final Context context = javacProcessingEnv.getContext();
this.maker = TreeMaker.instance(context);
this.names = Names.instance(context);
}
}
use of com.sun.tools.javac.processing.JavacProcessingEnvironment in project checker-framework by typetools.
the class AggregateChecker method typeProcess.
// AbstractTypeProcessor delegation
@Override
public final void typeProcess(TypeElement element, TreePath tree) {
Context context = ((JavacProcessingEnvironment) processingEnv).getContext();
Log log = Log.instance(context);
if (log.nerrors > this.errsOnLastExit) {
// If there is a Java error, do not perform any of the component type checks, but come back
// for the next compilation unit.
this.errsOnLastExit = log.nerrors;
return;
}
if (!allCheckersInited) {
// error was already output. Just quit.
return;
}
for (SourceChecker checker : checkers) {
checker.errsOnLastExit = this.errsOnLastExit;
checker.typeProcess(element, tree);
if (checker.javacErrored) {
this.javacErrored = true;
return;
}
this.errsOnLastExit = checker.errsOnLastExit;
}
}
Aggregations