return writerVisitor;
}
@SuppressWarnings("unchecked")
public GenerationPlugins<JS> forClass(Class<?> clazz) {
UsePlugin usePlugins = clazz.getAnnotation(UsePlugin.class);
if (usePlugins == null || usePlugins.value() == null || usePlugins.value().length == 0) {
// this class uses the default plugins - no need to create a new one
return this;
}
// TODO - here I can add a cache using the list of plugin names as key
GenerationPlugins<JS> newPlugins = new GenerationPlugins<JS>();
newPlugins.checkVisitor = new CheckVisitor(checkVisitor);
newPlugins.writerVisitor = new WriterVisitor<JS>(writerVisitor);
for (String pluginName : usePlugins.value()) {
STJSGenerationPlugin<JS> plugin = optionalPlugins.get(pluginName);
if (plugin == null) {
throw new STJSRuntimeException("The class:" + clazz.getName() + " need an unknown Generation Plugin :" + pluginName);
}
plugin.contributeCheckVisitor(newPlugins.checkVisitor);