Search in sources :

Example 1 with JavaIoFileSystemAccess

use of org.eclipse.xtext.generator.JavaIoFileSystemAccess in project xtext-xtend by eclipse.

the class XtendBatchCompiler method createStubs.

protected File createStubs(ResourceSet resourceSet) {
    File outputDirectory = createTempDir("stubs");
    JavaIoFileSystemAccess fileSystemAccess = javaIoFileSystemAccessProvider.get();
    fileSystemAccess.setOutputPath(outputDirectory.toString());
    List<Resource> resources = Lists.newArrayList(resourceSet.getResources());
    for (Resource resource : resources) {
        IResourceDescription description = resourceDescriptionManager.getResourceDescription(resource);
        stubGenerator.doGenerateStubs(fileSystemAccess, description);
    }
    return outputDirectory;
}
Also used : JavaIoFileSystemAccess(org.eclipse.xtext.generator.JavaIoFileSystemAccess) IResourceDescription(org.eclipse.xtext.resource.IResourceDescription) Resource(org.eclipse.emf.ecore.resource.Resource) StorageAwareResource(org.eclipse.xtext.resource.persistence.StorageAwareResource) XtextResource(org.eclipse.xtext.resource.XtextResource) BatchLinkableResource(org.eclipse.xtext.xbase.resource.BatchLinkableResource) XtendFile(org.eclipse.xtend.core.xtend.XtendFile) File(java.io.File)

Example 2 with JavaIoFileSystemAccess

use of org.eclipse.xtext.generator.JavaIoFileSystemAccess in project xtext-xtend by eclipse.

the class XtendBatchCompiler method generateJavaFiles.

protected void generateJavaFiles(ResourceSet resourceSet) {
    JavaIoFileSystemAccess javaIoFileSystemAccess = javaIoFileSystemAccessProvider.get();
    javaIoFileSystemAccess.setOutputPath(outputPath);
    javaIoFileSystemAccess.setWriteTrace(writeTraceFiles);
    GeneratorContext context = new GeneratorContext();
    context.setCancelIndicator(CancelIndicator.NullImpl);
    for (Resource resource : newArrayList(resourceSet.getResources())) {
        if (isSourceFile(resource)) {
            if (isWriteStorageFiles()) {
                StorageAwareResource storageAwareResource = (StorageAwareResource) resource;
                storageAwareResource.getResourceStorageFacade().saveResource(storageAwareResource, javaIoFileSystemAccess);
            }
            generator.generate(resource, javaIoFileSystemAccess, context);
        }
    }
}
Also used : JavaIoFileSystemAccess(org.eclipse.xtext.generator.JavaIoFileSystemAccess) Resource(org.eclipse.emf.ecore.resource.Resource) StorageAwareResource(org.eclipse.xtext.resource.persistence.StorageAwareResource) XtextResource(org.eclipse.xtext.resource.XtextResource) BatchLinkableResource(org.eclipse.xtext.xbase.resource.BatchLinkableResource) StorageAwareResource(org.eclipse.xtext.resource.persistence.StorageAwareResource) GeneratorContext(org.eclipse.xtext.generator.GeneratorContext)

Aggregations

Resource (org.eclipse.emf.ecore.resource.Resource)2 JavaIoFileSystemAccess (org.eclipse.xtext.generator.JavaIoFileSystemAccess)2 XtextResource (org.eclipse.xtext.resource.XtextResource)2 StorageAwareResource (org.eclipse.xtext.resource.persistence.StorageAwareResource)2 BatchLinkableResource (org.eclipse.xtext.xbase.resource.BatchLinkableResource)2 File (java.io.File)1 XtendFile (org.eclipse.xtend.core.xtend.XtendFile)1 GeneratorContext (org.eclipse.xtext.generator.GeneratorContext)1 IResourceDescription (org.eclipse.xtext.resource.IResourceDescription)1