checker.src.org.checkerframework.checker.tainting.TaintingQualChecker 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.tainting;
import org.checkerframework.qualframework.poly.QualifierParameterChecker;
import org.checkerframework.qualframework.poly.format.SurfaceSyntaxFormatterConfiguration;
import org.checkerframework.qualframework.poly.format.SurfaceSyntaxQualParamsFormatter.AnnotationParts;
public class TaintingQualChecker extends QualifierParameterChecker {
@Override
protected TaintingQualifiedTypeFactory createTypeFactory() {
return new TaintingQualifiedTypeFactory(this);
}
@Override
protected SurfaceSyntaxFormatterConfiguration createSurfaceSyntaxFormatterConfiguration() {
return new TaintingSurfaceSyntaxConfiguration();
}
private class TaintingSurfaceSyntaxConfiguration extends SurfaceSyntaxFormatterConfiguration {
public TaintingSurfaceSyntaxConfiguration() {
super(Tainting.TAINTED, Tainting.UNTAINTED,
TaintingQualChecker.this.getContext().getTypeFactory().getQualifierHierarchy().getTop(),
TaintingQualChecker.this.getContext().getTypeFactory().getQualifierHierarchy().getBottom());
}
@Override
protected boolean shouldPrintAnnotation(AnnotationParts anno, boolean printInvisibleQualifiers) {
return printInvisibleQualifiers;
}
@Override
protected AnnotationParts getTargetTypeSystemAnnotation(Tainting qual) {
switch (qual) {
case TAINTED:
return new AnnotationParts("Tainted");
case UNTAINTED:
return new AnnotationParts("Untainted");
default:
return null; // Dead code
}
}
}
}