@Override protected void doProcess(Set<? extends TypeElement> annotations, RoundEnvironment roundEnv) { if (count.getAndIncrement() == 0) { ElementHandle.Field index = ElementHandle.Field.create("plugin.template.completion.A", "index"); VariableElement indexElt = index.get(processingEnv); AnnotationMirror pathAnn = indexElt.getAnnotationMirrors().get(0); TypeElement annotationTypeElement = (TypeElement)pathAnn.getAnnotationType().asElement(); ExecutableElement value = (ExecutableElement)annotationTypeElement.getEnclosedElements().get(0); for (Completion completion : getCompletions(indexElt, pathAnn, value, test[0])) { completions.add(completion.getValue()); } } } });
@Override protected void doProcess(Set<? extends TypeElement> annotations, RoundEnvironment roundEnv) { if (count.getAndIncrement() == 0) { ElementHandle.Field index = ElementHandle.Field.create("plugin.template.completion.A", "index"); VariableElement indexElt = index.get(processingEnv); AnnotationMirror pathAnn = indexElt.getAnnotationMirrors().get(0); TypeElement annotationTypeElement = (TypeElement)pathAnn.getAnnotationType().asElement(); ExecutableElement value = (ExecutableElement)annotationTypeElement.getEnclosedElements().get(0); for (Completion completion : getCompletions(indexElt, pathAnn, value, test[0])) { completions.add(completion.getValue()); } } } });
public static ElementHandle<?> create(Element elt) { ElementKind kind = elt.getKind(); switch (kind) { case FIELD: { VariableElement variableElt = (VariableElement)elt; return Field.create(variableElt); } case CLASS: { TypeElement typeElt = (TypeElement)elt; return Type.create(typeElt); } case PACKAGE: { PackageElement packageElt = (PackageElement)elt; return Package.create(packageElt); } case METHOD: { ExecutableElement packageElt = (ExecutableElement)elt; return Method.create(packageElt); } default: throw new UnsupportedOperationException("Element " + elt + " with kind " + kind + " not supported"); } }
@Test public void testReferences() throws Exception { ElementHandle.Field templateField = ElementHandle.Field.create("metamodel.template.A", "template"); CompilerAssert<File, File> helper = compiler("metamodel.template"); File templates = helper.getSourcePath().getPath("metamodel", "template", "templates");
@Test public void testReferences() throws Exception { ElementHandle.Field templateField = ElementHandle.Field.create("metamodel.template.A", "template"); CompilerAssert<File, File> helper = compiler("metamodel.template"); File templates = helper.getSourcePath().getPath("metamodel", "template", "templates");
public static ElementHandle<?> create(Element elt) { ElementKind kind = elt.getKind(); switch (kind) { case FIELD: { VariableElement variableElt = (VariableElement)elt; return Field.create(variableElt); } case CLASS: { TypeElement typeElt = (TypeElement)elt; return Type.create(typeElt); } case PACKAGE: { PackageElement packageElt = (PackageElement)elt; return Package.create(packageElt); } case METHOD: { ExecutableElement packageElt = (ExecutableElement)elt; return Method.create(packageElt); } default: throw new UnsupportedOperationException("Element " + elt + " with kind " + kind + " not supported"); } }