@GwtIncompatible(value="com.google.protobuf") public final class CheckConformance extends java.lang.Object implements NodeTraversal.Callback, CompilerPass
Modifier and Type | Class and Description |
---|---|
static class |
CheckConformance.InvalidRequirementSpec |
static interface |
CheckConformance.Rule |
Modifier and Type | Field and Description |
---|---|
private AbstractCompiler |
compiler |
(package private) static DiagnosticType |
CONFORMANCE_POSSIBLE_VIOLATION |
(package private) static DiagnosticType |
CONFORMANCE_VIOLATION |
private static java.util.Set<java.lang.String> |
EXTENDABLE_FIELDS |
(package private) static DiagnosticType |
INVALID_REQUIREMENT_SPEC |
private com.google.common.collect.ImmutableList<CheckConformance.Rule> |
rules |
Constructor and Description |
---|
CheckConformance(AbstractCompiler compiler,
com.google.common.collect.ImmutableList<ConformanceConfig> configs) |
Modifier and Type | Method and Description |
---|---|
private static void |
checkRequirementList(AbstractCompiler compiler,
Requirement requirement,
java.lang.String field) |
private static java.util.List<java.lang.String> |
getRequirementList(Requirement requirement,
java.lang.String field) |
private static CheckConformance.Rule |
initRule(AbstractCompiler compiler,
Requirement requirement) |
private static com.google.common.collect.ImmutableList<CheckConformance.Rule> |
initRules(AbstractCompiler compiler,
com.google.common.collect.ImmutableList<ConformanceConfig> configs)
Build the data structures need by this pass from the provided
configurations.
|
(package private) static java.util.List<Requirement> |
mergeRequirements(AbstractCompiler compiler,
java.util.List<ConformanceConfig> configs)
Gets requirements from all configs.
|
void |
process(Node externs,
Node root)
Process the JS with root node root.
|
private static void |
reportInvalidRequirement(AbstractCompiler compiler,
Requirement requirement,
java.lang.String reason) |
boolean |
shouldTraverse(NodeTraversal t,
Node n,
Node parent)
Visits a node in pre order (before visiting its children) and decides
whether this node's children should be traversed.
|
void |
visit(NodeTraversal t,
Node n,
Node parent)
Visits a node in postorder (after its children have been visited).
|
static final DiagnosticType CONFORMANCE_VIOLATION
static final DiagnosticType CONFORMANCE_POSSIBLE_VIOLATION
static final DiagnosticType INVALID_REQUIREMENT_SPEC
private final AbstractCompiler compiler
private final com.google.common.collect.ImmutableList<CheckConformance.Rule> rules
private static final java.util.Set<java.lang.String> EXTENDABLE_FIELDS
CheckConformance(AbstractCompiler compiler, com.google.common.collect.ImmutableList<ConformanceConfig> configs)
configs
- The rules to check.public void process(Node externs, Node root)
CompilerPass
process
in interface CompilerPass
externs
- Top of external JS treeroot
- Top of JS treepublic final boolean shouldTraverse(NodeTraversal t, Node n, Node parent)
NodeTraversal.Callback
Visits a node in pre order (before visiting its children) and decides
whether this node's children should be traversed. If children are
traversed, they will be visited by
NodeTraversal.Callback.visit(NodeTraversal, Node, Node)
in postorder.
Implementations can have side effects (e.g. modifying the parse tree).
shouldTraverse
in interface NodeTraversal.Callback
public void visit(NodeTraversal t, Node n, Node parent)
NodeTraversal.Callback
Visits a node in postorder (after its children have been visited).
A node is visited only if all its parents should be traversed
(NodeTraversal.Callback.shouldTraverse(NodeTraversal, Node, Node)
).
Implementations can have side effects (e.g. modifying the parse tree).
visit
in interface NodeTraversal.Callback
private static com.google.common.collect.ImmutableList<CheckConformance.Rule> initRules(AbstractCompiler compiler, com.google.common.collect.ImmutableList<ConformanceConfig> configs)
static java.util.List<Requirement> mergeRequirements(AbstractCompiler compiler, java.util.List<ConformanceConfig> configs)
private static void checkRequirementList(AbstractCompiler compiler, Requirement requirement, java.lang.String field)
private static java.util.List<java.lang.String> getRequirementList(Requirement requirement, java.lang.String field)
private static CheckConformance.Rule initRule(AbstractCompiler compiler, Requirement requirement)
private static void reportInvalidRequirement(AbstractCompiler compiler, Requirement requirement, java.lang.String reason)
requirement
-