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

org.checkerframework.checker.i18n.LocalizableKeyAnnotatedTypeFactory 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.checker.i18n;

import java.lang.annotation.Annotation;
import java.util.Arrays;
import java.util.LinkedHashSet;
import java.util.Set;
import org.checkerframework.checker.i18n.qual.LocalizableKey;
import org.checkerframework.checker.i18n.qual.LocalizableKeyBottom;
import org.checkerframework.checker.i18n.qual.UnknownLocalizableKey;
import org.checkerframework.checker.propkey.PropertyKeyAnnotatedTypeFactory;
import org.checkerframework.common.basetype.BaseTypeChecker;
import org.checkerframework.framework.type.treeannotator.ListTreeAnnotator;
import org.checkerframework.framework.type.treeannotator.TreeAnnotator;

/** A PropertyKeyATF that uses LocalizableKey to annotate the keys. */
public class LocalizableKeyAnnotatedTypeFactory extends PropertyKeyAnnotatedTypeFactory {

  public LocalizableKeyAnnotatedTypeFactory(BaseTypeChecker checker) {
    super(checker);
    // Does not call postInit() because its superclass does.
    // If we ever add code to this constructor, it needs to:
    //   * call a superclass constructor that does not call postInit(), and
    //   * call postInit() itself.
  }

  @Override
  protected Set> createSupportedTypeQualifiers() {
    return new LinkedHashSet<>(
        Arrays.asList(
            LocalizableKey.class, LocalizableKeyBottom.class, UnknownLocalizableKey.class));
  }

  @Override
  public TreeAnnotator createTreeAnnotator() {
    return new ListTreeAnnotator(
        super.createBasicTreeAnnotator(), new KeyLookupTreeAnnotator(this, LocalizableKey.class));
  }
}




© 2015 - 2024 Weber Informatics LLC | Privacy Policy