use of com.axellience.vuegwt.processors.utils.GeneratorsNameUtil in project vue-gwt by Axellience.
the class VueComponentFactoryGenerator method createInitMethod.
@Override
protected List<CodeBlock> createInitMethod(TypeElement component, Builder vueFactoryClassBuilder) {
MethodSpec.Builder initBuilder = MethodSpec.methodBuilder("init").addModifiers(Modifier.PROTECTED).addAnnotation(Inject.class);
List<CodeBlock> initParametersCall = new LinkedList<>();
// Get options
initBuilder.addStatement("$T<$T> componentOptions = $T.getOptions()", VueComponentOptions.class, component.asType(), componentJsTypeName(component));
processCustomizeOptions(component, initBuilder, initParametersCall);
// Extend the parent Component
Optional<ClassName> superFactoryType = getSuperComponentType(component).map(GeneratorsNameUtil::componentFactoryName);
if (superFactoryType.isPresent()) {
initBuilder.addParameter(superFactoryType.get(), "superFactory");
initBuilder.addStatement("jsConstructor = superFactory.getJsConstructor().extendJavaComponent($L)", "componentOptions");
initParametersCall.add(CodeBlock.of("$T.get()", superFactoryType.get()));
} else {
initBuilder.addStatement("jsConstructor = $T.extendJavaComponent($L)", Vue.class, "componentOptions");
}
Component componentAnnotation = component.getAnnotation(Component.class);
if (hasInjectedDependencies)
registerDependenciesProvider(component, initBuilder, initParametersCall);
registerLocalComponents(component, initBuilder, initParametersCall);
registerLocalDirectives(componentAnnotation, initBuilder);
MethodSpec initMethod = initBuilder.build();
vueFactoryClassBuilder.addMethod(initMethod);
return initParametersCall;
}
Aggregations