Search in sources :

Example 1 with RuleDependencies

use of org.antlr.v4.runtime.RuleDependencies in project antlr4 by tunnelvisionlabs.

the class RuleDependencyChecker method getElementDependencies.

private static void getElementDependencies(AnnotatedElement annotatedElement, List<Tuple2<RuleDependency, AnnotatedElement>> result) {
    RuleDependency dependency = annotatedElement.getAnnotation(RuleDependency.class);
    if (dependency != null) {
        result.add(Tuple.create(dependency, annotatedElement));
    }
    RuleDependencies dependencies = annotatedElement.getAnnotation(RuleDependencies.class);
    if (dependencies != null) {
        for (RuleDependency d : dependencies.value()) {
            if (d != null) {
                result.add(Tuple.create(d, annotatedElement));
            }
        }
    }
}
Also used : RuleDependencies(org.antlr.v4.runtime.RuleDependencies) RuleDependency(org.antlr.v4.runtime.RuleDependency)

Example 2 with RuleDependencies

use of org.antlr.v4.runtime.RuleDependencies in project antlr4 by tunnelvisionlabs.

the class RuleDependencyProcessor method getDependencies.

public static List<Tuple2<RuleDependency, Element>> getDependencies(RoundEnvironment roundEnv) {
    List<Tuple2<RuleDependency, Element>> result = new ArrayList<Tuple2<RuleDependency, Element>>();
    Set<? extends Element> elements = roundEnv.getElementsAnnotatedWith(RuleDependency.class);
    for (Element element : elements) {
        RuleDependency dependency = element.getAnnotation(RuleDependency.class);
        if (dependency == null) {
            continue;
        }
        result.add(Tuple.create(dependency, element));
    }
    elements = roundEnv.getElementsAnnotatedWith(RuleDependencies.class);
    for (Element element : elements) {
        RuleDependencies dependencies = element.getAnnotation(RuleDependencies.class);
        if (dependencies == null || dependencies.value() == null) {
            continue;
        }
        for (RuleDependency dependency : dependencies.value()) {
            result.add(Tuple.create(dependency, element));
        }
    }
    return result;
}
Also used : RuleDependencies(org.antlr.v4.runtime.RuleDependencies) VariableElement(javax.lang.model.element.VariableElement) TypeElement(javax.lang.model.element.TypeElement) ExecutableElement(javax.lang.model.element.ExecutableElement) Element(javax.lang.model.element.Element) ArrayList(java.util.ArrayList) RuleDependency(org.antlr.v4.runtime.RuleDependency)

Aggregations

RuleDependencies (org.antlr.v4.runtime.RuleDependencies)2 RuleDependency (org.antlr.v4.runtime.RuleDependency)2 ArrayList (java.util.ArrayList)1 Element (javax.lang.model.element.Element)1 ExecutableElement (javax.lang.model.element.ExecutableElement)1 TypeElement (javax.lang.model.element.TypeElement)1 VariableElement (javax.lang.model.element.VariableElement)1