Java Code Examples for org.eclipse.xtext.generator.OutputConfiguration#isCleanUpDerivedResources()
The following examples show how to use
org.eclipse.xtext.generator.OutputConfiguration#isCleanUpDerivedResources() .
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 File: CleanInstruction.java From n4js with Eclipse Public License 1.0 | 6 votes |
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 File: N4JSBuilderParticipant.java From n4js with Eclipse Public License 1.0 | 6 votes |
@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 File: XStatefulIncrementalBuilder.java From n4js with Eclipse Public License 1.0 | 6 votes |
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 4
Source File: BuilderParticipant.java From xtext-eclipse with Eclipse Public License 2.0 | 6 votes |
/** * @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 5
Source File: BuilderParticipant.java From xtext-eclipse with Eclipse Public License 2.0 | 6 votes |
/** * @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 6
Source File: BuilderParticipant.java From xtext-eclipse with Eclipse Public License 2.0 | 6 votes |
/** * @since 2.7 */ protected Set<IFile> getDerivedResources(Delta delta, final Map<String, OutputConfiguration> outputConfigurations, Map<OutputConfiguration, Iterable<IMarker>> generatorMarkers) { String uri = delta.getUri().toString(); if (generatorMarkers instanceof DerivedResourcesLookupMap) { return ((DerivedResourcesLookupMap) generatorMarkers).getDerivedResources(uri); } Set<IFile> derivedResources = newLinkedHashSet(); for (OutputConfiguration config : outputConfigurations.values()) { if (config.isCleanUpDerivedResources()) { Iterable<IMarker> markers = generatorMarkers.get(config); for (IMarker marker : markers) { String source = derivedResourceMarkers.getSource(marker); if (source != null && source.equals(uri)) derivedResources.add((IFile) marker.getResource()); } } } return derivedResources; }
Example 7
Source File: BuildInstruction.java From n4js with Eclipse Public License 1.0 | 5 votes |
private void recordDerivedResources(final String uri) { for (OutputConfiguration config : outputConfigurations.values()) { if (config.isCleanUpDerivedResources()) { Iterable<IMarker> markers = generatorMarkers.get(config); if (null != markers) { for (IMarker marker : markers) { String source = derivedResourceMarkers.getSource(marker); if (source != null && source.equals(uri)) { derivedResources.add((IFile) marker.getResource()); } } } } } }
Example 8
Source File: XtendParallelBuilderParticipant.java From xtext-xtend with Eclipse Public License 2.0 | 5 votes |
@Override protected Map<OutputConfiguration, Iterable<IMarker>> getGeneratorMarkers(IProject builtProject, Collection<OutputConfiguration> outputConfigurations) throws CoreException { Map<OutputConfiguration, Iterable<IMarker>> generatorMarkers = newHashMap(); List<IPath> sourcePath = getSourceFolderPathes(builtProject); for (OutputConfiguration config : outputConfigurations) { if (config.isCleanUpDerivedResources()) { List<IContainer> containerToSearchIn = Lists.newArrayList(); for (IPath sourceFolder : sourcePath) { if (sourceFolder.segmentCount() == 1) { containerToSearchIn.add(builtProject); } else { IContainer sourcePathBasedContainer = builtProject.getWorkspace().getRoot() .getFolder(sourceFolder); containerToSearchIn.add(sourcePathBasedContainer); } } Collection<IMarker> markers = Lists.newArrayList(); for (IContainer container : containerToSearchIn) { Iterables.addAll(markers, getDerivedResourceMarkers().findDerivedResourceMarkers(container, getGeneratorIdProvider().getGeneratorIdentifier())); } generatorMarkers.put(config, markers); } } return buildGeneratorMarkersReverseLookupMap(generatorMarkers); }