Top Description Inners Fields Constructors Methods
org.antlr.v4.runtime.misc

public Class RuleDependencyProcessor

extends AbstractProcessor
Class Inheritance
Annotations
@SupportedAnnotationTypes:RuleDependency, RuleDependencies, RuleVersion
Imports
org.antlr.v4.runtime.Dependents, .RuleDependencies, .RuleDependency, .RuleVersion, org.antlr.v4.runtime.atn.ATN, .ATNDeserializer, .ATNSimulator, .ATNState, .RuleTransition, .Transition, javax.annotation.processing.AbstractProcessor, .RoundEnvironment, .SupportedAnnotationTypes, javax.lang.model.SourceVersion, javax.lang.model.element.AnnotationMirror, .AnnotationValue, .Element, .ElementKind, .ExecutableElement, .Modifier, .TypeElement, .VariableElement, javax.lang.model.type.MirroredTypeException, .TypeMirror, javax.tools.Diagnostic, java.lang.annotation.AnnotationTypeMismatchException, java.util.ArrayList, .BitSet, .EnumSet, .HashMap, .List, .Map, .Set

A compile-time validator for rule dependencies.
Author
Sam Harwell
See Also
RuleDependency, RuleDependencies

Nested and Inner Type Summary

Modifier and TypeClass and Description
public static enum
private static class

Field Summary

Modifier and TypeField and Description
private static final Set<Dependents>
public static final String
public static final String
public static final String
Inherited from javax.annotation.processing.AbstractProcessor:
processingEnv

Constructor Summary

AccessConstructor and Description
public

Method Summary

Modifier and TypeMethod and Description
private boolean
checkClassNameConstant(String className, Class<?> clazz)

private boolean
private void
checkDependencies(List<Tuple2<RuleDependency, Element>> dependencies, TypeMirror recognizerType)

private int
checkDependencyVersion(Tuple2<RuleDependency, Element> dependency, String[] ruleNames, int[] ruleVersions, int relatedRule, String relation)

private RuleDependencyProcessor.RuleRelations
private Tuple2<AnnotationMirror, AnnotationValue>
private AnnotationValue
public static List<Tuple2<RuleDependency, Element>>
private static TypeMirror
private ExecutableElement
getRuleMethod(TypeMirror recognizerClass, String name)

private String[]
getRuleNames(TypeMirror recognizerClass)

private int[]
getRuleVersions(TypeMirror recognizerClass, String[] ruleNames)

private String
getSerializedATN(TypeMirror recognizerClass)

public SourceVersion
private boolean
public boolean
process(Set<? extends TypeElement>
the annotation interfaces requested to be processed
annotations
,
RoundEnvironment
environment for information about the current and prior round
roundEnv
)

Implements abstract javax.annotation.processing.AbstractProcessor.process.

Implements javax.annotation.processing.Processor.process.

Processes a set of annotation interfaces on root elements originating from the prior round and returns whether or not these annotation interfaces are claimed by this processor.
private void
Inherited from javax.annotation.processing.AbstractProcessor:
getCompletionsgetSupportedAnnotationTypesgetSupportedOptionsinitisInitialized

Field Detail

IMPLEMENTED_DEPENDENTSback to summary
private static final Set<Dependents> IMPLEMENTED_DEPENDENTS
RuleDependenciesClassNameback to summary
public static final String RuleDependenciesClassName
RuleDependencyClassNameback to summary
public static final String RuleDependencyClassName
RuleVersionClassNameback to summary
public static final String RuleVersionClassName

Constructor Detail

RuleDependencyProcessorback to summary
public RuleDependencyProcessor()

Method Detail

checkClassNameConstantback to summary
private boolean checkClassNameConstant(String className, Class<?> clazz)
checkClassNameConstantsback to summary
private boolean checkClassNameConstants()
checkDependenciesback to summary
private void checkDependencies(List<Tuple2<RuleDependency, Element>> dependencies, TypeMirror recognizerType)
checkDependencyVersionback to summary
private int checkDependencyVersion(Tuple2<RuleDependency, Element> dependency, String[] ruleNames, int[] ruleVersions, int relatedRule, String relation)
extractRuleRelationsback to summary
private RuleDependencyProcessor.RuleRelations extractRuleRelations(TypeMirror recognizer)
findRuleDependencyPropertyback to summary
private Tuple2<AnnotationMirror, AnnotationValue> findRuleDependencyProperty(Tuple2<RuleDependency, Element> dependency, RuleDependencyProcessor.RuleDependencyProperty property)
Annotations
@Nullable
findRuleDependencyPropertyback to summary
private AnnotationValue findRuleDependencyProperty(Tuple2<RuleDependency, Element> dependency, AnnotationMirror annotationMirror, RuleDependencyProcessor.RuleDependencyProperty property)
Annotations
@Nullable
getDependenciesback to summary
public static List<Tuple2<RuleDependency, Element>> getDependencies(RoundEnvironment roundEnv)
getRecognizerTypeback to summary
private static TypeMirror getRecognizerType(RuleDependency dependency)
getRuleMethodback to summary
private ExecutableElement getRuleMethod(TypeMirror recognizerClass, String name)
getRuleNamesback to summary
private String[] getRuleNames(TypeMirror recognizerClass)
getRuleVersionsback to summary
private int[] getRuleVersions(TypeMirror recognizerClass, String[] ruleNames)
getSerializedATNback to summary
private String getSerializedATN(TypeMirror recognizerClass)
getSupportedSourceVersionback to summary
public SourceVersion getSupportedSourceVersion()

Overrides javax.annotation.processing.AbstractProcessor.getSupportedSourceVersion.

Implements javax.annotation.processing.Processor.getSupportedSourceVersion.

Doc from javax.annotation.processing.AbstractProcessor.getSupportedSourceVersion.

If the processor class is annotated with SupportedSourceVersion, return the source version in the annotation. If the class is not so annotated, SourceVersion#RELEASE_6 is returned.

Returns:SourceVersion

the latest source version supported by this processor

Annotations
@Override
hasRuleVersionAnnotationback to summary
private boolean hasRuleVersionAnnotation(ExecutableElement method)
processback to summary
public boolean process(Set<? extends TypeElement> annotations, RoundEnvironment roundEnv)

Implements abstract javax.annotation.processing.AbstractProcessor.process.

Implements javax.annotation.processing.Processor.process.

Doc from javax.annotation.processing.AbstractProcessor.process.

Processes a set of annotation interfaces on root elements originating from the prior round and returns whether or not these annotation interfaces are claimed by this processor. If true is returned, the annotation interfaces are claimed and subsequent processors will not be asked to process them; if false is returned, the annotation interfaces are unclaimed and subsequent processors may be asked to process them. A processor may always return the same boolean value or may vary the result based on its own chosen criteria.

The input set will be empty if the processor supports "*" and the root elements have no annotations. A Processor must gracefully handle an empty set of annotations.

Parameters
annotations:Set<? extends TypeElement>

Doc from javax.annotation.processing.Processor.process.

the annotation interfaces requested to be processed

roundEnv:RoundEnvironment

Doc from javax.annotation.processing.Processor.process.

environment for information about the current and prior round

Returns:boolean

Doc from javax.annotation.processing.Processor.process.

whether or not the set of annotation interfaces are claimed by this processor

Annotations
@Override
reportUnimplementedDependentsback to summary
private void reportUnimplementedDependents(Tuple2<RuleDependency, Element> dependency, EnumSet<Dependents> dependents)
org.antlr.v4.runtime.misc back to summary

public final Enum RuleDependencyProcessor.RuleDependencyProperty

extends Enum<RuleDependencyProcessor.RuleDependencyProperty>
Class Inheritance

Field Summary

Modifier and TypeField and Description
public static final RuleDependencyProcessor.RuleDependencyProperty
public static final RuleDependencyProcessor.RuleDependencyProperty
public static final RuleDependencyProcessor.RuleDependencyProperty
public static final RuleDependencyProcessor.RuleDependencyProperty

Constructor Summary

AccessConstructor and Description
private

Method Summary

Modifier and TypeMethod and Description
public static RuleDependencyProcessor.RuleDependencyProperty
public static RuleDependencyProcessor.RuleDependencyProperty[]
Inherited from java.lang.Enum:
clonecompareTodescribeConstableequalsfinalizegetDeclaringClasshashCodenameordinaltoStringvalueOf

Field Detail

DEPENDENTSback to summary
public static final RuleDependencyProcessor.RuleDependencyProperty DEPENDENTS
RECOGNIZERback to summary
public static final RuleDependencyProcessor.RuleDependencyProperty RECOGNIZER
RULEback to summary
public static final RuleDependencyProcessor.RuleDependencyProperty RULE
VERSIONback to summary
public static final RuleDependencyProcessor.RuleDependencyProperty VERSION

Constructor Detail

RuleDependencyPropertyback to summary
private RuleDependencyProperty()

Method Detail

valueOfback to summary
public static RuleDependencyProcessor.RuleDependencyProperty valueOf(String name)
valuesback to summary
public static RuleDependencyProcessor.RuleDependencyProperty[] values()
org.antlr.v4.runtime.misc back to summary

private final Class RuleDependencyProcessor.RuleRelations

extends Object
Class Inheritance
  • java.lang.Object
  • org.antlr.v4.runtime.misc.RuleDependencyProcessor.RuleRelations

Field Summary

Modifier and TypeField and Description
private final BitSet[]
private final BitSet[]

Constructor Summary

AccessConstructor and Description
public
RuleRelations(int ruleCount)

Method Summary

Modifier and TypeMethod and Description
public boolean
addRuleInvocation(int caller, int callee)

public BitSet
getAncestors(int rule)

public BitSet
getDescendants(int rule)

Inherited from java.lang.Object:
cloneequalsfinalizegetClasshashCodenotifynotifyAlltoStringwaitwaitwait

Field Detail

childrenback to summary
private final BitSet[] children
parentsback to summary
private final BitSet[] parents

Constructor Detail

RuleRelationsback to summary
public RuleRelations(int ruleCount)

Method Detail

addRuleInvocationback to summary
public boolean addRuleInvocation(int caller, int callee)
getAncestorsback to summary
public BitSet getAncestors(int rule)
getDescendantsback to summary
public BitSet getDescendants(int rule)