use of com.axellience.vuegwt.processors.component.ComponentJsTypeGenerator in project vue-gwt by Axellience.
the class VueGwtProcessor method processComponentAnnotations.
private void processComponentAnnotations(RoundEnvironment roundEnv) {
Set<? extends Element> componentElements = roundEnv.getElementsAnnotatedWith(Component.class);
ComponentJsTypeGenerator componentJsTypeGenerator = new ComponentJsTypeGenerator(processingEnv);
VueComponentFactoryGenerator vueFactoryGenerator = new VueComponentFactoryGenerator(processingEnv);
for (TypeElement componentType : ElementFilter.typesIn(componentElements)) {
ComponentInjectedDependenciesBuilder dependenciesBuilder = new ComponentInjectedDependenciesBuilder(processingEnv, componentType);
vueFactoryGenerator.generate(componentType, dependenciesBuilder.hasInjectedDependencies());
componentJsTypeGenerator.generate(componentType, dependenciesBuilder);
}
}
use of com.axellience.vuegwt.processors.component.ComponentJsTypeGenerator in project vue-gwt by Axellience.
the class ComponentTemplateProcessor method registerFieldsAndMethodsInContext.
/**
* Process the ComponentJsType class to register all the fields and methods visible in
* the context.
* TODO: Improve this method by putting things together with {@link ComponentJsTypeGenerator}
* @param componentTypeElement The class to process
*/
private void registerFieldsAndMethodsInContext(TemplateParserContext templateParserContext, TypeElement componentTypeElement, Set<String> alreadyDoneVariable, Set<String> alreadyDoneMethods) {
ElementFilter.fieldsIn(componentTypeElement.getEnclosedElements()).stream().filter(ComponentGeneratorsUtil::isFieldVisibleInJS).forEach(field -> {
String name = field.getSimpleName().toString();
if (alreadyDoneVariable.contains(name))
return;
alreadyDoneVariable.add(name);
templateParserContext.addRootVariable(ClassName.get(field.asType()), name);
});
ElementFilter.methodsIn(componentTypeElement.getEnclosedElements()).stream().filter(method -> hasAnnotation(method, Computed.class)).filter(method -> !"void".equals(method.getReturnType().toString())).forEach(method -> {
String name = getComputedPropertyName(method);
if (alreadyDoneVariable.contains(name))
return;
alreadyDoneVariable.add(name);
TypeMirror propertyType;
if ("void".equals(method.getReturnType().toString()))
propertyType = method.getParameters().get(0).asType();
else
propertyType = method.getReturnType();
templateParserContext.addRootVariable(ClassName.get(propertyType), name);
});
ElementFilter.methodsIn(componentTypeElement.getEnclosedElements()).stream().filter(ComponentGeneratorsUtil::isMethodVisibleInTemplate).map(ExecutableElement::getSimpleName).map(Object::toString).forEach(methodName -> {
if (alreadyDoneMethods.contains(methodName))
return;
alreadyDoneMethods.add(methodName);
templateParserContext.addRootMethod(methodName);
});
getSuperComponentType(componentTypeElement).ifPresent(superComponent -> registerFieldsAndMethodsInContext(templateParserContext, superComponent, alreadyDoneVariable, alreadyDoneMethods));
}
Aggregations