protected IFileSystemAccess2 getFileSystemAccess(final IProject project, final IProgressMonitor monitor) { EclipseResourceFileSystemAccess2 access = fileSystemAccessProvider.get(); access.setContext(project); access.setMonitor(monitor); OutputConfiguration defaultOutput = new OutputConfiguration(IFileSystemAccess.DEFAULT_OUTPUT); defaultOutput.setDescription("Output Folder"); defaultOutput.setOutputDirectory("./"); defaultOutput.setOverrideExistingResources(true); defaultOutput.setCreateOutputDirectory(true); defaultOutput.setCleanUpDerivedResources(false); defaultOutput.setSetDerivedProperty(false); defaultOutput.setKeepLocalHistory(false); HashMap<String, OutputConfiguration> outputConfigurations = new HashMap<String, OutputConfiguration>(); outputConfigurations.put(IFileSystemAccess.DEFAULT_OUTPUT, defaultOutput); access.setOutputConfigurations(outputConfigurations); return access; }
/** * 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; }
/** * 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; }
@Override protected void handleChangedContents(final Delta delta, final IBuildContext context, final EclipseResourceFileSystemAccess2 fsa) throws CoreException { if (isAffected(delta, resourceServiceProvider)) { Resource resource = context.getResourceSet().getResource(delta.getUri(), true); if (shouldGenerate(resource, context) && resource.getContents().get(0) instanceof FormatConfiguration) { generator.doGenerate(resource, fsa); } } }
/** * Avoid unnecessary overhead for trace file lookup. */ public Class<? extends EclipseResourceFileSystemAccess2> bindEclipseResourceFileSystemAccess2() { return FileSystemAccessWithoutTraceFileSupport.class; }