framework.src.org.checkerframework.common.subtyping.SubtypingChecker 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.common.subtyping;
import java.lang.annotation.Annotation;
import java.util.Collection;
import java.util.HashSet;
import java.util.Set;
import javax.annotation.processing.SupportedOptions;
import org.checkerframework.common.basetype.BaseTypeChecker;
import org.checkerframework.common.basetype.BaseTypeVisitor;
/**
* A checker for type qualifier systems that only checks subtyping
* relationships.
*
*
*
* The annotation(s) are specified on the command line, using an annotation
* processor argument:
*
*
* - {@code -Aquals}: specifies the annotations in the qualifier hierarchy
* (as a comma-separated list of fully-qualified annotation names with no
* spaces in between). Only the annotation for one qualified subtype
* hierarchy can be passed.
*
*
* @checker_framework.manual #subtyping-checker Subtying Checker
*/
@SupportedOptions( { "quals", "qualDirs" })
public final class SubtypingChecker extends BaseTypeChecker {
@Override
public Collection getSuppressWarningsKeys() {
Set> annos = ((BaseTypeVisitor)visitor).getTypeFactory().getSupportedTypeQualifiers();
if (annos.isEmpty()) {
return super.getSuppressWarningsKeys();
}
Set swKeys = new HashSet<>();
swKeys.add(SUPPRESS_ALL_KEY);
for (Class anno : annos) {
swKeys.add(anno.getSimpleName().toLowerCase());
}
return swKeys;
}
}