Package com.google.javascript.jscomp
Class ImplicitNullabilityCheck
- java.lang.Object
-
- com.google.javascript.jscomp.NodeTraversal.AbstractPostOrderCallback
-
- com.google.javascript.jscomp.ImplicitNullabilityCheck
-
- All Implemented Interfaces:
CompilerPass
,NodeTraversal.Callback
public final class ImplicitNullabilityCheck extends NodeTraversal.AbstractPostOrderCallback implements CompilerPass
Warn about types in JSDoc that are implicitly nullable.
-
-
Nested Class Summary
Nested Classes Modifier and Type Class Description static class
ImplicitNullabilityCheck.Nullability
Represents the types of implicit nullability errors caught by this pass: a) implicitly nonnull (missing a "!"), and b) implicitly nullable (missing a "?").static class
ImplicitNullabilityCheck.Result
Information to represent a single "implicit nullability result", including the JSDoc string node that needs a "!" or "?" to be explicit, as well as an enum indicating which of the two nullability cases were found ("!" or "?").
-
Field Summary
Fields Modifier and Type Field Description static DiagnosticType
IMPLICITLY_NONNULL_JSDOC
static DiagnosticType
IMPLICITLY_NULLABLE_JSDOC
-
Constructor Summary
Constructors Constructor Description ImplicitNullabilityCheck(AbstractCompiler compiler)
-
Method Summary
All Methods Static Methods Instance Methods Concrete Methods Modifier and Type Method Description static com.google.common.collect.ImmutableList<ImplicitNullabilityCheck.Result>
findImplicitNullabilityResults(JSDocInfo info, NodeTraversal t)
Finds and returns all the JSDoc nodes inside the given JSDoc object whose nullability is not explict, using the NodeTraversal the necessary state (current scope, etc.)void
process(Node externs, Node root)
Process the JS with root node root.void
visit(NodeTraversal t, Node n, Node p)
Crawls the JSDoc of the given node to find any names in JSDoc that are implicitly null.-
Methods inherited from class com.google.javascript.jscomp.NodeTraversal.AbstractPostOrderCallback
shouldTraverse
-
-
-
-
Field Detail
-
IMPLICITLY_NULLABLE_JSDOC
public static final DiagnosticType IMPLICITLY_NULLABLE_JSDOC
-
IMPLICITLY_NONNULL_JSDOC
public static final DiagnosticType IMPLICITLY_NONNULL_JSDOC
-
-
Constructor Detail
-
ImplicitNullabilityCheck
public ImplicitNullabilityCheck(AbstractCompiler compiler)
-
-
Method Detail
-
process
public void process(Node externs, Node root)
Description copied from interface:CompilerPass
Process the JS with root node root. Can modify the contents of each Node tree- Specified by:
process
in interfaceCompilerPass
- Parameters:
externs
- Top of external JS treeroot
- Top of JS tree
-
findImplicitNullabilityResults
public static com.google.common.collect.ImmutableList<ImplicitNullabilityCheck.Result> findImplicitNullabilityResults(JSDocInfo info, NodeTraversal t)
Finds and returns all the JSDoc nodes inside the given JSDoc object whose nullability is not explict, using the NodeTraversal the necessary state (current scope, etc.)
-
visit
public void visit(NodeTraversal t, Node n, Node p)
Crawls the JSDoc of the given node to find any names in JSDoc that are implicitly null.- Specified by:
visit
in interfaceNodeTraversal.Callback
- Parameters:
t
- The current traversal.n
- The current node.p
- The parent of the current node.
-
-