checker.src.org.checkerframework.checker.compilermsgs.CompilerMessagesAnnotatedTypeFactory Maven / Gradle / Ivy
Go to download
Show more of this group Show more artifacts with this name
Show all versions of checker Show documentation
Show all versions of checker Show documentation
The Checker Framework enhances Java’s type system to
make it more powerful and useful. This lets software developers
detect and prevent errors in their Java programs.
The Checker Framework includes compiler plug-ins ("checkers")
that find bugs or verify their absence. It also permits you to
write your own compiler plug-ins.
package org.checkerframework.checker.compilermsgs;
import com.sun.source.tree.Tree;
import java.lang.annotation.Annotation;
import java.util.Set;
import org.checkerframework.checker.compilermsgs.qual.CompilerMessageKey;
import org.checkerframework.checker.propkey.PropertyKeyAnnotatedTypeFactory;
import org.checkerframework.checker.propkey.qual.PropertyKey;
import org.checkerframework.checker.propkey.qual.PropertyKeyBottom;
import org.checkerframework.checker.propkey.qual.UnknownPropertyKey;
import org.checkerframework.common.basetype.BaseTypeChecker;
import org.checkerframework.framework.type.treeannotator.ImplicitsTreeAnnotator;
import org.checkerframework.framework.type.treeannotator.ListTreeAnnotator;
import org.checkerframework.framework.type.treeannotator.PropagationTreeAnnotator;
import org.checkerframework.framework.type.treeannotator.TreeAnnotator;
/**
* A PropertyKeyATF that uses CompilerMessageKey to annotate the keys.
*
* @author wmdietl
*/
public class CompilerMessagesAnnotatedTypeFactory extends PropertyKeyAnnotatedTypeFactory {
public CompilerMessagesAnnotatedTypeFactory(BaseTypeChecker checker) {
super(checker);
}
@Override
protected Set> createSupportedTypeQualifiers() {
return getBundledTypeQualifiersWithoutPolyAll(
UnknownPropertyKey.class,
PropertyKey.class, PropertyKeyBottom.class);
}
@Override
public TreeAnnotator createTreeAnnotator() {
ImplicitsTreeAnnotator implicitsTreeAnnotator = new ImplicitsTreeAnnotator(this);
implicitsTreeAnnotator.addTreeKind(Tree.Kind.NULL_LITERAL, PROPKEY_BOTTOM);
return new ListTreeAnnotator(
new PropagationTreeAnnotator(this),
implicitsTreeAnnotator,
new KeyLookupTreeAnnotator(this, CompilerMessageKey.class)
);
}
}