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

checker.src.org.checkerframework.checker.fenum.FenumChecker 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
Show newest version
package org.checkerframework.checker.fenum;

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;
import org.checkerframework.common.subtyping.SubtypingChecker;
import org.checkerframework.framework.qual.StubFiles;

/**
 * The main checker class for the Fake Enum Checker.
 *
 * There are two options to distinguish different enumerators:
 *
 * 
    *
  1. {@code @Fenum("Name")}: introduces a fake enumerator with the name * "Name". Enumerators with different names are distinct. The default name is * empty, but you are encouraged to use a unique name for your purpose. *
  2. * *
  3. Alternatively, you can specify the annotation to use with the * {@code -Aqual} command line argument. *
  4. *
* * @author wmdietl * @checker_framework.manual #fenum-checker Fake Enum Checker */ @StubFiles("jdnc.astub") @SupportedOptions( { "quals", "qualDirs" } ) public class FenumChecker extends BaseTypeChecker { /* @Override public void initChecker() { super.initChecker(); } */ /** Copied from SubtypingChecker; cannot reuse it, because SubtypingChecker is final. * @see SubtypingChecker#getSuppressWarningsKeys() */ @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; } }




© 2015 - 2024 Weber Informatics LLC | Privacy Policy