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

org.checkerframework.checker.nullness.NullnessNoInitSubchecker 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.checker.nullness;

import com.sun.source.tree.ClassTree;
import com.sun.source.tree.MethodTree;

import org.checkerframework.checker.initialization.InitializationChecker;
import org.checkerframework.checker.initialization.InitializationFieldAccessSubchecker;
import org.checkerframework.checker.nullness.qual.NonNull;
import org.checkerframework.common.basetype.BaseTypeChecker;
import org.checkerframework.common.basetype.BaseTypeVisitor;

import java.util.NavigableSet;
import java.util.Set;

/**
 * The subchecker of the {@link NullnessChecker} which actually checks {@link NonNull} and related
 * qualifiers.
 *
 * 

The {@link NullnessChecker} uses this checker as the target (see {@link * InitializationChecker#getTargetCheckerClass()}) for its initialization type system. */ public class NullnessNoInitSubchecker extends BaseTypeChecker { /** Default constructor for NonNullChecker. */ public NullnessNoInitSubchecker() {} @Override public NullnessNoInitAnnotatedTypeFactory getTypeFactory() { return (NullnessNoInitAnnotatedTypeFactory) super.getTypeFactory(); } @Override protected Set> getImmediateSubcheckerClasses() { Set> checkers = super.getImmediateSubcheckerClasses(); if (!hasOption("assumeKeyFor")) { checkers.add(KeyForSubchecker.class); } checkers.add(InitializationFieldAccessSubchecker.class); return checkers; } @Override public NavigableSet getSuppressWarningsPrefixes() { NavigableSet result = super.getSuppressWarningsPrefixes(); result.add("nullness"); return result; } @Override protected String getWarningMessagePrefix() { return "nullness"; } @Override protected BaseTypeVisitor createSourceVisitor() { return new NullnessNoInitVisitor(this); } // The NullnessNoInitChecker should also skip defs skipped by the NullnessChecker @Override public boolean shouldSkipDefs(ClassTree tree) { return super.shouldSkipDefs(tree) || parentChecker.shouldSkipDefs(tree); } @Override public boolean shouldSkipDefs(ClassTree cls, MethodTree meth) { return super.shouldSkipDefs(cls, meth) || parentChecker.shouldSkipDefs(cls, meth); } }





© 2015 - 2024 Weber Informatics LLC | Privacy Policy