Java 类org.eclipse.xtext.generator.IGenerator 实例源码

项目:xtext-extras    文件:JavaSourceLanguageRuntimeModule.java   
@Override
protected void configure() {
  this.<Resource.Factory>bind(Resource.Factory.class).to(JavaResource.Factory.class);
  this.<IResourceValidator>bind(IResourceValidator.class).toInstance(IResourceValidator.NULL);
  this.<IGenerator>bind(IGenerator.class).to(IGenerator.NullGenerator.class);
  this.<IEncodingProvider>bind(IEncodingProvider.class).to(IEncodingProvider.Runtime.class);
  this.<IResourceServiceProvider>bind(IResourceServiceProvider.class).to(JavaResourceServiceProvider.class);
  this.<IContainer.Manager>bind(IContainer.Manager.class).to(SimpleResourceDescriptionsBasedContainerManager.class);
  this.<IResourceDescription.Manager>bind(IResourceDescription.Manager.class).to(JavaResourceDescriptionManager.class);
  this.<IQualifiedNameProvider>bind(IQualifiedNameProvider.class).to(JvmIdentifiableQualifiedNameProvider.class);
  this.<String>bind(String.class).annotatedWith(Names.named(Constants.FILE_EXTENSIONS)).toInstance("java");
  this.<String>bind(String.class).annotatedWith(Names.named(Constants.LANGUAGE_NAME)).toInstance("org.eclipse.xtext.java.Java");
  this.<IJvmTypeProvider.Factory>bind(IJvmTypeProvider.Factory.class).to(ClasspathTypeProviderFactory.class);
  this.<ClassLoader>bind(ClassLoader.class).toInstance(JavaSourceLanguageRuntimeModule.class.getClassLoader());
  this.<IReferableElementsUnloader>bind(IReferableElementsUnloader.class).to(IReferableElementsUnloader.GenericUnloader.class);
  final IResourceDescriptionsProvider _function = (ResourceSet it) -> {
    return ChunkedResourceDescriptions.findInEmfObject(it);
  };
  this.<IResourceDescriptionsProvider>bind(IResourceDescriptionsProvider.class).toInstance(_function);
}
项目:joynr    文件:GeneratorTask.java   
public void printHelp(Log log) {
    IGenerator generator = executor.getGenerator();
    if (generator instanceof IJoynrGenerator) {
        IJoynrGenerator joynrGenerator = (IJoynrGenerator) generator;
        Set<String> parameters = joynrGenerator.supportedParameters();
        StringBuffer sb = new StringBuffer();
        sb.append("Supported configuration parameters by the generator: ");
        if (parameters != null && parameters.size() > 0) {
            for (String parameter : parameters) {
                sb.append(parameter + ",");
            }
            sb.deleteCharAt(sb.length() - 1);
        } else {
            sb.append("none");
        }
        log.info(sb.toString());
    } else {
        log.info("no additional information available for the provider generator");
    }
}
项目:joynr    文件:Executor.java   
private IGenerator createGenerator(Injector injector) throws ClassNotFoundException, InstantiationException,
                                                     IllegalAccessException {
    String rootGenerator = arguments.getRootGenerator();
    Class<?> rootGeneratorClass = Class.forName(rootGenerator, true, Thread.currentThread().getContextClassLoader());
    Object templateRootInstance = rootGeneratorClass.newInstance();

    if (templateRootInstance instanceof IGenerator) {
        // This is a standard generator
        IGenerator generator = (IGenerator) templateRootInstance;
        if (generator instanceof IJoynrGenerator) {
            IJoynrGenerator joynrGenerator = (IJoynrGenerator) generator;
            if (joynrGenerator.getGeneratorModule() != null) {
                injector = injector.createChildInjector(joynrGenerator.getGeneratorModule());
            }
            injector.injectMembers(generator);
            joynrGenerator.setParameters(arguments.getParameter());
        } else {
            injector.injectMembers(generator);
        }
        return generator;
    } else {
        throw new IllegalStateException("Root generator \"" + "\" is not implementing interface \""
                + IGenerator.class.getName() + "\"");
    }

}
项目:joynr    文件:AbstractGeneratorTest.java   
protected void invokeGenerator(IGenerator generator,
                               String fileName,
                               String outputDirectory,
                               String... referencedResources) {
    final IFileSystemAccess fileSystemAccess = createFileSystemAccess(outputDirectory);

    final URI uri = URI.createFileURI(new File(fileName).getAbsolutePath());
    final Set<URI> uris = new HashSet<URI>();
    uris.add(uri);
    for (String refRes : referencedResources) {
        uris.add(URI.createFileURI(new File(refRes).getAbsolutePath()));
    }
    File file = new File(fileName);
    IUriProvider uriProvider = null;
    if (file.isDirectory()) {
        uriProvider = new FolderUriProvider(Sets.newHashSet("fidl"), file);
    } else {
        uriProvider = new IUriProvider() {

            @Override
            public Iterable<URI> allUris() {
                return Lists.newArrayList(uris);
            }
        };
    }

    ModelStore modelStore = ModelStore.modelsIn(uriProvider);

    for (URI foundUri : uriProvider.allUris()) {
        final Resource r = modelStore.getResource(foundUri);
        generator.doGenerate(r, fileSystemAccess);
    }

}
项目:xtext-extras    文件:DefaultXbaseRuntimeModule.java   
public Class<? extends IGenerator> bindIGenerator() {
    return JvmModelGenerator.class;
}
项目:xtext-extras    文件:ContentAssistTestLanguageRuntimeModule.java   
public Class<? extends IGenerator> bindIGenerator() {
    return ContentAssistTestLanguageGenerator.class;
}
项目:xtext-extras    文件:BuilderTestLanguageRuntimeModule.java   
public Class<? extends IGenerator> bindIGenerator() {
    return MyGenerator.class;
}
项目:xtext-extras    文件:GeneratorFragment.java   
@Override
public Set<Binding> getGuiceBindingsRt(Grammar grammar) {
    if (isGenerateStub(grammar))
        return new BindFactory().addTypeToType(IGenerator.class.getName(), getGeneratorName(grammar, getNaming())).getBindings();
    return Collections.emptySet();
}
项目:dsl-devkit    文件:CheckCfgRuntimeModule.java   
/** Creates a properties file in the .settings folder. {@inheritDoc} */
@Override
public Class<? extends IGenerator> bindIGenerator() {
  return CheckCfgGenerator.class;
}
项目:chariot    文件:DatatypesRuntimeModule.java   
@Override
public Class<? extends IGenerator> bindIGenerator() {
    return DataTypesGenerator.class;
}
项目:Tupi    文件:TupiRuntimeModule.java   
@Override
public Class<? extends IGenerator> bindIGenerator() {
    return AuxGenerator.class;
}
项目:txtUML    文件:XtxtUMLRuntimeModule.java   
public Class<? extends IGenerator> bindIGenerator() {
    return XtxtUMLGenerator.class;
}
项目:XRobot    文件:XRobotDSLRuntimeModule.java   
public Class<? extends IGenerator> bindIGenerator() {
    return IGenerator.NullGenerator.class;
}
项目:jkind-xtext    文件:JKindRuntimeModule.java   
public Class<? extends IGenerator> bindIGenerator() {
    return IGenerator.NullGenerator.class;
}
项目:XObjects    文件:XObjectsRuntimeModule.java   
@Override
public Class<? extends IGenerator> bindIGenerator() {
    return ch.vorburger.xobjects.generator.XObjectsJavaGenerator.class;
}
项目:joynr    文件:Executor.java   
public IGenerator getGenerator() {
    return generator;
}
项目:smaccm    文件:ResoluteRuntimeModule.java   
public Class<? extends IGenerator> bindIGenerator() {
    return NullGenerator.class;
}
项目:smaccm    文件:AgreeRuntimeModule.java   
public Class<? extends IGenerator> bindIGenerator() {
    return NullGenerator.class;
}
项目:chariot    文件:ChariotRuntimeModule.java   
/**
 * Avoids to use the default org.eclipse.xtext.xbase.compiler.JvmModelGenerator
 * when using xbase.
 * @see org.xtext.example.helloxbase.AbstractHelloXbaseRuntimeModule#bindIGenerator()
 */
@Override
public Class<? extends IGenerator> bindIGenerator() {
    return ChariotGenerator.class;
}
项目:mm-dsl    文件:MMDSLRuntimeModule.java   
/**
 * Avoids to use the default org.eclipse.xtext.xbase.compiler.JvmModelGenerator
 * when using xbase.
 * @see org.xtext.example.helloxbase.AbstractHelloXbaseRuntimeModule#bindIGenerator()
 */
@Override
public Class<? extends IGenerator> bindIGenerator() {
    return MMDSLGenerator.class;
}