Java Code Examples for org.eclipse.xtext.generator.OutputConfiguration

The following examples show how to use org.eclipse.xtext.generator.OutputConfiguration. These examples are extracted from open source projects. You can vote up the ones you like or vote down the ones you don't like, and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example 1
Source Project: n4js   Source File: CleanInstruction.java    License: Eclipse Public License 1.0 6 votes vote down vote up
private void cleanOutput(IProject aProject, OutputConfiguration config, IProgressMonitor monitor)
		throws CoreException {
	IContainer container = getContainer(aProject, config.getOutputDirectory());
	if (!container.exists()) {
		return;
	}
	if (config.isCanClearOutputDirectory()) {
		for (IResource resource : container.members()) {
			resource.delete(IResource.KEEP_HISTORY, monitor);
		}
	} else if (config.isCleanUpDerivedResources()) {
		List<IFile> resources = derivedResourceMarkers.findDerivedResources(container, null);
		for (IFile iFile : resources) {
			iFile.delete(IResource.KEEP_HISTORY, monitor);
		}
	}
}
 
Example 2
Source Project: n4js   Source File: N4JSBuilderParticipant.java    License: Eclipse Public License 1.0 6 votes vote down vote up
@Override
protected Map<OutputConfiguration, Iterable<IMarker>> getGeneratorMarkers(IProject builtProject,
		Collection<OutputConfiguration> outputConfigurations) throws CoreException {

	if (builtProject instanceof ExternalProject) {
		return emptyMap();
	}

	Map<OutputConfiguration, Iterable<IMarker>> generatorMarkers = newHashMap();
	for (OutputConfiguration config : outputConfigurations) {
		if (config.isCleanUpDerivedResources()) {
			List<IMarker> markers = Lists.newArrayList();
			for (IContainer container : getOutputs(builtProject, config)) {
				Iterables.addAll(
						markers,
						getDerivedResourceMarkers().findDerivedResourceMarkers(container,
								getGeneratorIdProvider().getGeneratorIdentifier()));
			}
			generatorMarkers.put(config, markers);
		}
	}
	return generatorMarkers;
}
 
Example 3
Source Project: n4js   Source File: N4IDLSubGenerator.java    License: Eclipse Public License 1.0 6 votes vote down vote up
private static CompilerDescriptor createDescriptor() {
	final CompilerDescriptor result = new CompilerDescriptor();
	result.setIdentifier(COMPILER_ID);
	result.setName("N4IDL to ECMAScript transpiler");
	result.setDescription(
			"Transpiles N4IDL to ECMAScript, currently ES5 plus some selected ES6 features supported by V8.");
	result.setActive(true);
	result.setCompiledFileExtension("js");
	result.setCompiledFileSourceMapExtension("map");
	final OutputConfiguration outCfg = new OutputConfiguration(COMPILER_ID);
	outCfg.setDescription("N4IDL to ECMAScript transpiler");
	outCfg.setOutputDirectory(N4JSLanguageConstants.DEFAULT_PROJECT_OUTPUT);
	outCfg.setOverrideExistingResources(true);
	outCfg.setCreateOutputDirectory(true);
	outCfg.setCleanUpDerivedResources(true);
	outCfg.setSetDerivedProperty(true);
	outCfg.setKeepLocalHistory(true);
	outCfg.setCanClearOutputDirectory(true);
	result.setOutputConfiguration(outCfg);
	return result;
}
 
Example 4
/** Create a new URIBasedFileSystemAccess. */
public URIBasedFileSystemAccess newFileSystemAccess(Resource resource, XBuildRequest request) {
	URIBasedFileSystemAccess uriBasedFileSystemAccess = new URIBasedFileSystemAccess();
	uriBasedFileSystemAccess.setOutputConfigurations(IterableExtensions.toMap(
			this.outputConfigurationProvider.getOutputConfigurations(resource),
			OutputConfiguration::getName));
	uriBasedFileSystemAccess.setPostProcessor(this.postProcessor);
	if (this.encodingProvider != null) {
		uriBasedFileSystemAccess.setEncodingProvider(this.encodingProvider);
	}
	uriBasedFileSystemAccess.setTraceFileNameProvider(this.traceFileNameProvider);
	uriBasedFileSystemAccess.setTraceRegionSerializer(this.traceRegionSerializer);
	uriBasedFileSystemAccess.setGenerateTraces(true);
	uriBasedFileSystemAccess.setBaseDir(request.getBaseDir());
	if (this.projectConfigProvider != null) {
		IProjectConfig projectConfig = this.projectConfigProvider.getProjectConfig(resource.getResourceSet());
		if (projectConfig != null) {
			ISourceFolder sourceFolder = projectConfig.findSourceFolderContaining(resource.getURI());
			if (sourceFolder != null) {
				uriBasedFileSystemAccess.setCurrentSource(sourceFolder.getName());
			}
		}
	}
	uriBasedFileSystemAccess.setConverter(resource.getResourceSet().getURIConverter());
	return uriBasedFileSystemAccess;
}
 
Example 5
Source Project: n4js   Source File: XStatefulIncrementalBuilder.java    License: Eclipse Public License 1.0 6 votes vote down vote up
private void removeGeneratedFiles(URI source, XSource2GeneratedMapping source2GeneratedMapping) {
	Map<URI, String> outputConfigMap = source2GeneratedMapping.deleteSourceAndGetOutputConfigs(source);
	IResourceServiceProvider serviceProvider = context.getResourceServiceProvider(source);
	IContextualOutputConfigurationProvider2 outputConfigurationProvider = serviceProvider
			.get(IContextualOutputConfigurationProvider2.class);
	XtextResourceSet resourceSet = request.getResourceSet();
	Set<OutputConfiguration> outputConfigs = outputConfigurationProvider.getOutputConfigurations(resourceSet);
	Map<String, OutputConfiguration> outputConfigsMap = Maps.uniqueIndex(outputConfigs,
			OutputConfiguration::getName);
	URIConverter uriConverter = resourceSet.getURIConverter();
	for (URI generated : outputConfigMap.keySet()) {
		OutputConfiguration config = outputConfigsMap.get(outputConfigMap.get(generated));
		if (config != null && config.isCleanUpDerivedResources()) {
			try {
				uriConverter.delete(generated, CollectionLiterals.emptyMap());
				request.setResultDeleteFile(generated);
			} catch (IOException e) {
				Exceptions.sneakyThrow(e);
			}
		}
	}
}
 
Example 6
Source Project: n4js   Source File: XStatefulIncrementalBuilder.java    License: Eclipse Public License 1.0 6 votes vote down vote up
private boolean isResourceInOutputDirectory(Resource resource, IResourceServiceProvider serviceProvider) {
	XWorkspaceManager workspaceManager = serviceProvider.get(XWorkspaceManager.class);
	if (workspaceManager == null) {
		return false;
	}
	OutputConfigurationProvider outputConfProvider = serviceProvider.get(OutputConfigurationProvider.class);
	URI resourceUri = resource.getURI();
	IProjectConfig projectConfig = workspaceManager.getProjectConfig(resourceUri);
	Set<OutputConfiguration> outputConfigurations = outputConfProvider.getOutputConfigurations(resource);
	URI projectBaseUri = projectConfig.getPath();
	Path resourcePath = URIUtils.toPath(resourceUri);

	for (OutputConfiguration outputConf : outputConfigurations) {
		for (String outputDir : outputConf.getOutputDirectories()) {
			URI outputUri = projectBaseUri.appendSegment(outputDir);
			Path outputPath = URIUtils.toPath(outputUri);
			if (resourcePath.startsWith(outputPath)) {
				return true;
			}
		}
	}
	return false;
}
 
Example 7
Source Project: xtext-xtend   Source File: TestBatchCompiler.java    License: Eclipse Public License 2.0 6 votes vote down vote up
@Test
public void testProjectConfig() {
  try {
    this.batchCompiler.compile();
    final FileProjectConfig project = this.batchCompiler.getProjectConfig();
    final String projectPath = new File(".").getCanonicalFile().getName();
    Assert.assertEquals(projectPath, project.getName());
    final OutputConfiguration output = this.batchCompiler.getOutputConfiguration();
    final String src = IterableExtensions.<FileSourceFolder>head(project.getSourceFolders()).getName();
    Assert.assertEquals("batch-compiler-data/test data", src.toString());
    final String target = output.getOutputDirectory(src);
    Assert.assertEquals("test-result", target.toString());
  } catch (Throwable _e) {
    throw Exceptions.sneakyThrow(_e);
  }
}
 
Example 8
/**
 * @since 2.4
 */
protected boolean ensureOutputConfigurationDirectoryExists(OutputConfiguration outputConfig) {
	IContainer container = getContainer(outputConfig);
	if (container == null) {
		return false;
	}
	if (!container.exists()) {
		if (outputConfig.isCreateOutputDirectory()) {
			try {
				createContainer(container);
				return true;
			} catch (CoreException e) {
				throw new RuntimeIOException(e);
			}
		} else {
			return false;
		}
	}
	return true;
}
 
Example 9
Source Project: xtext-core   Source File: IncrementalBuilder.java    License: Eclipse Public License 2.0 6 votes vote down vote up
public URIBasedFileSystemAccess newFileSystemAccess(Resource resource, BuildRequest request) {
	URIBasedFileSystemAccess uriBasedFileSystemAccess = new URIBasedFileSystemAccess();
	uriBasedFileSystemAccess.setOutputConfigurations(IterableExtensions.toMap(
			outputConfigurationProvider.getOutputConfigurations(resource), OutputConfiguration::getName));
	uriBasedFileSystemAccess.setPostProcessor(postProcessor);
	if (encodingProvider != null) {
		uriBasedFileSystemAccess.setEncodingProvider(encodingProvider);
	}
	uriBasedFileSystemAccess.setTraceFileNameProvider(traceFileNameProvider);
	uriBasedFileSystemAccess.setTraceRegionSerializer(traceRegionSerializer);
	uriBasedFileSystemAccess.setGenerateTraces(true);
	uriBasedFileSystemAccess.setBaseDir(request.getBaseDir());
	if (projectConfigProvider != null) {
		IProjectConfig projectConfig = projectConfigProvider.getProjectConfig(resource.getResourceSet());
		if (projectConfig != null) {
			ISourceFolder sourceFolder = projectConfig.findSourceFolderContaining(resource.getURI());
			if (sourceFolder != null) {
				uriBasedFileSystemAccess.setCurrentSource(sourceFolder.getName());
			}
		}
	}
	uriBasedFileSystemAccess.setConverter(resource.getResourceSet().getURIConverter());
	return uriBasedFileSystemAccess;
}
 
Example 10
protected OutputConfiguration findOutputConfiguration(SourceRelativeURI dslSourceFile, IFile generatedJavaFile) {
	IResourceServiceProvider serviceProvider = serviceProviderRegistry.getResourceServiceProvider(dslSourceFile.getURI());
	if (serviceProvider == null)
		return null;
	EclipseOutputConfigurationProvider cfgProvider = serviceProvider.get(EclipseOutputConfigurationProvider.class);
	IProject project = generatedJavaFile.getProject();
	Set<OutputConfiguration> configurations = cfgProvider.getOutputConfigurations(project);
	if (!configurations.isEmpty()) {
		if (configurations.size() == 1)
			return configurations.iterator().next();
		for (OutputConfiguration out : configurations) {
			for (String source : out.getSourceFolders()) {
				IContainer container = ResourceUtil.getContainer(project, out.getOutputDirectory(source));
				if (container != null && container.getFullPath().isPrefixOf(generatedJavaFile.getFullPath()))
					return out;
			}
		}
	}
	log.error("Could not find output configuration for file " + generatedJavaFile.getFullPath());
	return null;
}
 
Example 11
Source Project: xtext-eclipse   Source File: BuilderParticipant.java    License: Eclipse Public License 2.0 6 votes vote down vote up
/**
 * @since 2.4
 */
protected Map<OutputConfiguration, Iterable<IMarker>> getGeneratorMarkers(IProject builtProject,
		Collection<OutputConfiguration> outputConfigurations) throws CoreException {
	Map<OutputConfiguration, Iterable<IMarker>> generatorMarkers = newHashMap();
	for (OutputConfiguration config : outputConfigurations) {
		if (config.isCleanUpDerivedResources()) {
			List<IMarker> markers = Lists.newArrayList();
			for (IContainer container : getOutputs(builtProject, config)) {
				Iterables.addAll(
						markers,
						derivedResourceMarkers.findDerivedResourceMarkers(container,
								generatorIdProvider.getGeneratorIdentifier()));
			}
			generatorMarkers.put(config, markers);
		}
	}
	return buildGeneratorMarkersReverseLookupMap(generatorMarkers);
}
 
Example 12
Source Project: xtext-eclipse   Source File: BuilderParticipant.java    License: Eclipse Public License 2.0 6 votes vote down vote up
/**
 * @since 2.12
 */
protected Map<OutputConfiguration, Iterable<IMarker>> buildGeneratorMarkersReverseLookupMap(Map<OutputConfiguration, Iterable<IMarker>> generatorMarkers) {
	SetMultimap<String, IFile> reverseLookupMap = HashMultimap.create();
	for (java.util.Map.Entry<OutputConfiguration, Iterable<IMarker>> entry : generatorMarkers.entrySet()) {
		OutputConfiguration outputConfiguration = entry.getKey();
		if (outputConfiguration.isCleanUpDerivedResources()) {
			for (IMarker marker : entry.getValue()) {
				String source = derivedResourceMarkers.getSource(marker);
				if (source != null) {
					reverseLookupMap.put(source, (IFile) marker.getResource());
				}
			}
		}
	}
	return new DerivedResourcesLookupMap(generatorMarkers, reverseLookupMap);
}
 
Example 13
Source Project: xtext-eclipse   Source File: BuilderParticipant.java    License: Eclipse Public License 2.0 6 votes vote down vote up
private void delete(IResource resource, OutputConfiguration config, EclipseResourceFileSystemAccess2 access,
		IProgressMonitor monitor) throws CoreException {
	if (monitor.isCanceled()) {
		throw new OperationCanceledException();
	}
	if (resource instanceof IContainer) {
		IContainer container = (IContainer) resource;
		for (IResource child : container.members()) {
			delete(child, config, access, monitor);
		}
		container.delete(IResource.FORCE | IResource.KEEP_HISTORY, monitor);
	} else if (resource instanceof IFile) {
		IFile file = (IFile) resource;
		access.deleteFile(file, config.getName(), monitor);
	} else {
		resource.delete(IResource.FORCE | IResource.KEEP_HISTORY, monitor);
	}
}
 
Example 14
Source Project: xtext-eclipse   Source File: BuilderParticipant.java    License: Eclipse Public License 2.0 6 votes vote down vote up
/**
 * @since 2.7
 */
protected String getCurrentSourceFolder(IBuildContext context, Delta delta) {
	Iterable<org.eclipse.xtext.util.Pair<IStorage, IProject>> storages = storage2UriMapper.getStorages(delta.getUri());
	for (org.eclipse.xtext.util.Pair<IStorage, IProject> pair : storages) {
		if (pair.getFirst() instanceof IResource) {
			final IResource resource = (IResource) pair.getFirst();
			IProject project = pair.getSecond();
			for (OutputConfiguration output : getOutputConfigurations(context).values()) {
				for (SourceMapping sourceMapping : output.getSourceMappings()) {
					IContainer folder = ResourceUtil.getContainer(project, sourceMapping.getSourceFolder());
					if (folder.contains(resource)) {
						return sourceMapping.getSourceFolder();
					}
				}
			}
		}
	}
	return null;
}
 
Example 15
Source Project: xtext-eclipse   Source File: BuilderParticipant.java    License: Eclipse Public License 2.0 6 votes vote down vote up
protected Map<String, OutputConfiguration> getOutputConfigurations(IBuildContext context) {
	IProject builtProject = context.getBuiltProject();
	Map<String, OutputConfiguration> result = outputConfigurationCache.get(builtProject.getName());
	if (result != null) {
		return result;
	}
	Set<OutputConfiguration> configurations = outputConfigurationProvider.getOutputConfigurations(builtProject);
	result = uniqueIndex(configurations, new Function<OutputConfiguration, String>() {
		@Override
		public String apply(OutputConfiguration from) {
			return from.getName();
		}
	});
	outputConfigurationCache.put(builtProject.getName(), result);
	return result;
}
 
Example 16
Source Project: xtext-xtend   Source File: FileLocationsImpl.java    License: Eclipse Public License 2.0 6 votes vote down vote up
@Override
public Path getTargetFolder(final Path path) {
  Path _xblockexpression = null;
  {
    final Path projectFolder = this.getProjectFolder(path);
    if ((projectFolder == null)) {
      return null;
    }
    final OutputConfiguration outputConfiguration = IterableExtensions.<OutputConfiguration>head(this.outputConfigurationProvider.getOutputConfigurations(this.context));
    final Path sourceFolder = this.getSourceFolder(path);
    String _xifexpression = null;
    if ((sourceFolder == null)) {
      _xifexpression = outputConfiguration.getOutputDirectory();
    } else {
      String _xblockexpression_1 = null;
      {
        final String projectRelativeSourceFolder = IterableExtensions.join(IterableExtensions.<String>tail(sourceFolder.getSegments()), "/");
        _xblockexpression_1 = outputConfiguration.getOutputDirectory(projectRelativeSourceFolder);
      }
      _xifexpression = _xblockexpression_1;
    }
    final String outputFolder = _xifexpression;
    _xblockexpression = projectFolder.append(outputFolder);
  }
  return _xblockexpression;
}
 
Example 17
Source Project: n4js   Source File: BuildInstruction.java    License: Eclipse Public License 1.0 5 votes vote down vote up
/**
 * Create a build instruction for the given project.
 */
public BuildInstruction(IProject project,
		Map<String, OutputConfiguration> outputConfigurations,
		IDerivedResourceMarkers derivedResourceMarkers,
		EclipseResourceFileSystemAccess2 access,
		Map<OutputConfiguration, Iterable<IMarker>> generatorMarkers,
		IStorage2UriMapper storage2UriMapper, ICompositeGenerator compositeGenerator,
		Injector injector) {
	super(project, outputConfigurations, derivedResourceMarkers);
	this.access = access;
	this.generatorMarkers = generatorMarkers;
	this.storage2UriMapper = storage2UriMapper;
	this.compositeGenerator = compositeGenerator;
	this.injector = injector;
}
 
Example 18
Source Project: sarl   Source File: AbstractExtraLanguageGeneratorTest.java    License: Apache License 2.0 5 votes vote down vote up
protected OutputConfiguration getOutputConfiguration() {
	Iterable<? extends OutputConfiguration> configurations = this.outputConfigurationProvider.getOutputConfigurations();
	OutputConfiguration defaultConfiguration = null;
	for (final OutputConfiguration configuration : configurations) {
		if (Strings.equal(IFileSystemAccess.DEFAULT_OUTPUT, configuration.getName())) {
			defaultConfiguration = configuration;
		} else if (Strings.equal(getOutputConfigurationName(), configuration.getName())) {
			return configuration;
		}
	}
	return defaultConfiguration;
}
 
Example 19
Source Project: sarl   Source File: PyOutputConfigurationProvider.java    License: Apache License 2.0 5 votes vote down vote up
@Override
public Set<OutputConfiguration> getOutputConfigurations() {
	final OutputConfiguration pythonOutput = new OutputConfiguration(OUTPUT_CONFIGURATION_NAME);
	pythonOutput.setDescription(Messages.PyOutputConfigurationProvider_0);
	pythonOutput.setOutputDirectory(OUTPUT_FOLDER);
	pythonOutput.setOverrideExistingResources(true);
	pythonOutput.setCreateOutputDirectory(true);
	pythonOutput.setCanClearOutputDirectory(true);
	pythonOutput.setCleanUpDerivedResources(true);
	pythonOutput.setSetDerivedProperty(true);
	pythonOutput.setKeepLocalHistory(false);
	return newHashSet(pythonOutput);
}
 
Example 20
/**
 * Creates output configuration for generated stubs.
 *
 * @return output configuration
 */
private OutputConfiguration getStubConfig() {
  OutputConfiguration config = new OutputConfiguration(STUB_OUTPUT);
  config.setDescription("Output configuration for stubs"); //$NON-NLS-1$
  config.setOverrideExistingResources(false);
  config.setCanClearOutputDirectory(false);
  config.setCleanUpDerivedResources(false);
  config.setOutputDirectory("src"); //$NON-NLS-1$
  return config;
}
 
Example 21
Source Project: sarl   Source File: SarlOutputConfigurationProvider.java    License: Apache License 2.0 5 votes vote down vote up
/** Create the unit test output configuration.
 *
 * @return the configuration, never {@code null}.
 * @since 0.8
 */
@SuppressWarnings("static-method")
protected OutputConfiguration createTestOutputConfiguration() {
	final OutputConfiguration testOutput = new OutputConfiguration(SARLConfig.TEST_OUTPUT_CONFIGURATION);
	testOutput.setDescription(Messages.SarlOutputConfigurationProvider_1);
	testOutput.setOutputDirectory(SARLConfig.FOLDER_TEST_SOURCE_GENERATED);
	testOutput.setOverrideExistingResources(true);
	testOutput.setCreateOutputDirectory(true);
	testOutput.setCanClearOutputDirectory(false);
	testOutput.setCleanUpDerivedResources(true);
	testOutput.setSetDerivedProperty(true);
	testOutput.setKeepLocalHistory(false);
	return testOutput;
}
 
Example 22
@Override
protected IFile getFile(String fileName, String outputName, IProgressMonitor progressMonitor) {
	OutputConfiguration configuration = getOutputConfig(outputName);
	IContainer container = getContainer(configuration);
	if (container != null) {
		// no need to refresh again - it was already done in
		// org.eclipse.n4js.ui.building.N4JSBuilderParticipant#refreshOutputFolders
		// not a life changer, but shaves off approx 5% from the build time and progress monitor flickering is
		// reduced
		return container.getFile(new Path(fileName));
	}
	return null;
}
 
Example 23
Source Project: n4js   Source File: N4JSBuilderParticipant.java    License: Eclipse Public License 1.0 5 votes vote down vote up
/**
 * Intentionally package visible producer for the {@link IBuildParticipantInstruction}.
 *
 * @param project
 *            the currently build project
 * @param buildType
 *            the current build type
 * @return a StatefulBuilderParticipant. Never <code>null</code>.
 */
IBuildParticipantInstruction prepareBuild(IProject project, IXtextBuilderParticipant.BuildType buildType)
		throws CoreException {

	if (!isEnabled(project)) {
		return IBuildParticipantInstruction.NOOP;
	}
	EclipseResourceFileSystemAccess2 access = fileSystemAccessProvider.get();
	access.setProject(project);
	final Map<String, OutputConfiguration> outputConfigurations = getOutputConfigurations(project);
	refreshOutputFolders(project, outputConfigurations, null);
	access.setOutputConfigurations(outputConfigurations);
	if (buildType == BuildType.CLEAN || buildType == BuildType.RECOVERY) {
		IBuildParticipantInstruction clean = new CleanInstruction(project, outputConfigurations,
				getDerivedResourceMarkers());
		if (buildType == BuildType.RECOVERY) {
			clean.finish(Collections.<Delta> emptyList(), null);
		} else {
			return clean;
		}
	}
	Map<OutputConfiguration, Iterable<IMarker>> generatorMarkers = getGeneratorMarkers(project,
			outputConfigurations.values());
	BuildInstruction buildInstruction = new BuildInstruction(project, outputConfigurations,
			getDerivedResourceMarkers(), access,
			generatorMarkers, storage2UriMapper, compositeGenerator, injector);
	return buildInstruction;
}
 
Example 24
Source Project: n4js   Source File: N4JSBuilderParticipant.java    License: Eclipse Public License 1.0 5 votes vote down vote up
/**
 * @see #refreshOutputFolders(org.eclipse.xtext.builder.IXtextBuilderParticipant.IBuildContext, Map,
 *      IProgressMonitor)
 */
protected void refreshOutputFolders(IProject project, Map<String, OutputConfiguration> outputConfigurations,
		IProgressMonitor monitor) throws CoreException {
	SubMonitor subMonitor = SubMonitor.convert(monitor, outputConfigurations.size());
	for (OutputConfiguration config : outputConfigurations.values()) {
		SubMonitor child = subMonitor.newChild(1);
		IContainer container = getContainer(project, config.getOutputDirectory());
		if (null != container) {
			container.refreshLocal(IResource.DEPTH_INFINITE, child);
		}
	}
}
 
Example 25
Source Project: n4js   Source File: N4JSBuilderParticipant.java    License: Eclipse Public License 1.0 5 votes vote down vote up
/**
 * @see #getOutputConfigurations(org.eclipse.xtext.builder.IXtextBuilderParticipant.IBuildContext)
 */
protected Map<String, OutputConfiguration> getOutputConfigurations(IProject project) {
	Set<OutputConfiguration> configurations = getOutputConfigurationProvider().getOutputConfigurations(project);
	return uniqueIndex(getNonNullOutputConfigurations(configurations), new Function<OutputConfiguration, String>() {
		@Override
		public String apply(OutputConfiguration from) {
			return from.getName();
		}
	});
}
 
Example 26
Source Project: n4js   Source File: N4JSBuilderParticipant.java    License: Eclipse Public License 1.0 5 votes vote down vote up
private/* @Nonnull */
Iterable<OutputConfiguration> getNonNullOutputConfigurations(Set<OutputConfiguration> configurations) {
	if (configurations == null) {
		return new HashSet<>();
	} else {
		return configurations;
	}
}
 
Example 27
/**
 * @since 2.4
 */
@Override
public void generateFile(String fileName, String outputName, InputStream content) {
	if (monitor.isCanceled())
		throw new OperationCanceledException();
	OutputConfiguration outputConfig = getOutputConfig(outputName);

	if (!ensureOutputConfigurationDirectoryExists(outputConfig))
		return;

	IFile file = getFile(fileName, outputName);
	generateFile(file, content, null, null, outputConfig);
}
 
Example 28
Source Project: n4js   Source File: EcmaScriptSubGenerator.java    License: Eclipse Public License 1.0 5 votes vote down vote up
/** Creates a default OutputConfiguration */
public static OutputConfiguration createDefaultOutputConfiguration() {
	final OutputConfiguration outCfg = new OutputConfiguration(COMPILER_ID);
	outCfg.setDescription("N4JS to ECMAScript transpiler");
	outCfg.setOutputDirectory(N4JSLanguageConstants.DEFAULT_PROJECT_OUTPUT);
	outCfg.setOverrideExistingResources(true);
	outCfg.setCreateOutputDirectory(true);
	outCfg.setCleanUpDerivedResources(true);
	outCfg.setSetDerivedProperty(true);
	outCfg.setKeepLocalHistory(true);
	outCfg.setCanClearOutputDirectory(true);
	return outCfg;
}
 
Example 29
Source Project: n4js   Source File: XProjectManager.java    License: Eclipse Public License 1.0 5 votes vote down vote up
/** @return list of output directories of this project */
public List<File> getOutputDirectories() {
	List<File> outputDirs = new ArrayList<>();
	Set<OutputConfiguration> outputConfigurations = outputConfigProvider.getOutputConfigurations(resourceSet);
	URI projectBaseUri = projectConfig.getPath();
	for (OutputConfiguration outputConf : outputConfigurations) {
		for (String outputDirName : outputConf.getOutputDirectories()) {
			URI outputUri = projectBaseUri.appendSegment(outputDirName);
			File outputDirectory = URIUtils.toFile(outputUri);
			outputDirs.add(outputDirectory);
		}
	}
	return outputDirs;
}
 
Example 30
@Override
public Set<OutputConfiguration> getOutputConfigurations() {
	Set<OutputConfiguration> outputConfs = new HashSet<>();

	for (IN4JSProject prj : n4jsCore.findAllProjects()) {
		OutputConfiguration outputConfiguration = getOutputConfiguration(prj);
		outputConfs.add(outputConfiguration);
	}

	return outputConfs;
}