All Downloads are FREE. Search and download functionalities are using the official Maven repository.

org.checkerframework.common.subtyping.SubtypingChecker Maven / Gradle / Ivy

Go to download

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.

There is a newer version: 3.44.0
Show newest version
package org.checkerframework.common.subtyping;

import java.lang.annotation.Annotation;
import java.util.Set;
import java.util.SortedSet;
import java.util.TreeSet;
import javax.annotation.processing.SupportedOptions;
import org.checkerframework.common.basetype.BaseTypeChecker;
import org.checkerframework.common.basetype.BaseTypeVisitor;
import org.checkerframework.framework.source.SourceVisitor;

/**
 * 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 annotations * for one qualified subtype hierarchy can be passed. *
* * @checker_framework.manual #subtyping-checker Subtying Checker */ @SupportedOptions({"quals", "qualDirs"}) public final class SubtypingChecker extends BaseTypeChecker { /** * Compute SuppressWarnings prefixes, based on the names of all the qualifiers. * *

Provided for the convenience of checkers that do not subclass {@code SubtypingChecker} * (because it is final). Clients should call it like: * *

{@code
   * SubtypingChecker.getSuppressWarningsPrefixes(this.visitor, super.getSuppressWarningsPrefixes());
   * }
* * @param visitor the visitor * @param superSupportedTypeQualifiers the result of super.getSuppressWarningsPrefixes(), as * executed by checker * @return SuppressWarnings prefixes, based on the names of all the qualifiers */ public static SortedSet getSuppressWarningsPrefixes( SourceVisitor visitor, SortedSet superSupportedTypeQualifiers) { TreeSet result = new TreeSet<>(superSupportedTypeQualifiers); // visitor can be null if there was an error when calling the visitor class's constructor -- // that is, when there is a bug in a checker implementation. if (visitor != null) { Set> annos = ((BaseTypeVisitor) visitor).getTypeFactory().getSupportedTypeQualifiers(); for (Class anno : annos) { result.add(anno.getSimpleName().toLowerCase()); } } return result; } @Override public SortedSet getSuppressWarningsPrefixes() { return getSuppressWarningsPrefixes(this.visitor, super.getSuppressWarningsPrefixes()); } }




© 2015 - 2024 Weber Informatics LLC | Privacy Policy