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.42.0-eisop4
Show newest version
package org.checkerframework.common.subtyping;

import org.checkerframework.common.basetype.BaseTypeChecker;
import org.checkerframework.common.basetype.BaseTypeVisitor;
import org.checkerframework.framework.source.SourceVisitor;

import java.lang.annotation.Annotation;
import java.util.Locale;
import java.util.NavigableSet;
import java.util.Set;
import java.util.TreeSet;

import javax.annotation.processing.SupportedOptions;

/**
 * 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 NavigableSet getSuppressWarningsPrefixes( SourceVisitor visitor, NavigableSet 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(Locale.ROOT)); } } return result; } @Override public NavigableSet getSuppressWarningsPrefixes() { return getSuppressWarningsPrefixes(this.visitor, super.getSuppressWarningsPrefixes()); } }




© 2015 - 2024 Weber Informatics LLC | Privacy Policy