use of org.kie.workbench.common.stunner.svg.annotation.SVGSource in project kie-wb-common by kiegroup.
the class SVGShapeProcessor method processSvgShapeViewFactory.
private boolean processSvgShapeViewFactory(final Set<? extends TypeElement> set, final Element e, final RoundEnvironment roundEnv) throws Exception {
final boolean isIface = e.getKind() == ElementKind.INTERFACE;
if (isIface) {
final TypeElement classElement = (TypeElement) e;
final PackageElement packageElement = (PackageElement) classElement.getEnclosingElement();
final String name = classElement.getSimpleName().toString();
// Obtain type element information and create a new generation request into the processor's context.
String packageName = packageElement.getQualifiedName().toString();
String fqcn = packageName + "." + name;
String absPkgPath = packageName.replaceAll("\\.", "/");
note("Discovered @SVGViewFactory for type [" + fqcn + "]");
SVGViewFactory svgViewFactoryAnn = classElement.getAnnotation(SVGViewFactory.class);
final SVGGeneratorRequest request = new SVGGeneratorRequest(name + GENERATED_TYPE_SUFFIX, packageName, fqcn, absPkgPath + "/" + svgViewFactoryAnn.value(), processingEnv.getMessager());
context.setGeneratorRequest(request);
// Find and process method annotation as @SVGSource.
List<ExecutableElement> methodElements = ElementFilter.methodsIn(classElement.getEnclosedElements());
methodElements.forEach(methodElement -> {
SVGSource svgSourceAnnotation = methodElement.getAnnotation(SVGSource.class);
if (null != svgSourceAnnotation) {
String fileName = svgSourceAnnotation.value();
String absPath = absPkgPath + "/" + fileName;
final String fieldName = methodElement.getSimpleName().toString();
note("Discovered @SVGSource to be processed at path [" + absPath + "]");
context.getGeneratorRequest().getViewSources().put(fieldName, absPath);
}
});
}
return true;
}
Aggregations