use of org.eclipse.n4js.xtext.workspace.ProjectConfigSnapshot in project n4js by eclipse.
the class XWorkspaceManager method applyWorkspaceChanges.
/**
* Apply the given workspace changes to this manager's internal state and notify the workspace index.
*/
protected UpdateResult applyWorkspaceChanges(WorkspaceChanges changes) {
// collects contents of removed projects before actually removing anything
List<IResourceDescription> removedProjectsContents = collectAllResourceDescriptions(changes.getRemovedProjects());
removeProjects(changes.getRemovedProjects());
updateProjects(changes.getChangedProjects());
addProjects(changes.getAddedProjects());
WorkspaceConfigSnapshot oldWCS = workspaceConfigSnapshot;
Collection<ImmutableList<String>> oldCycles = oldWCS.getBuildOrderInfo().getProjectCycles();
workspaceConfigSnapshot = workspaceIndex.changeOrRemoveProjects(Iterables.concat(changes.getAddedProjects(), changes.getChangedProjects()), Iterables.transform(changes.getRemovedProjects(), ProjectConfigSnapshot::getName));
Collection<ImmutableList<String>> newCycles = workspaceConfigSnapshot.getBuildOrderInfo().getProjectCycles();
Set<String> cyclicProjectChanges = new HashSet<>();
for (List<String> cycle : Iterables.concat(oldCycles, newCycles)) {
for (String projectName : cycle) {
cyclicProjectChanges.add(projectName);
}
}
return new UpdateResult(oldWCS, changes, removedProjectsContents, cyclicProjectChanges);
}
use of org.eclipse.n4js.xtext.workspace.ProjectConfigSnapshot in project n4js by eclipse.
the class XWorkspaceManager method addProjects.
/**
* Adds a project to the workspace
*/
protected void addProjects(Iterable<? extends ProjectConfigSnapshot> projectConfigs) {
for (ProjectConfigSnapshot projectConfig : withoutDuplicates(projectConfigs)) {
ProjectBuilder projectBuilder = projectBuilderProvider.get();
projectBuilder.initialize(projectConfig);
projectID2ProjectBuilder.put(projectConfig.getName(), projectBuilder);
}
}
use of org.eclipse.n4js.xtext.workspace.ProjectConfigSnapshot in project n4js by eclipse.
the class XWorkspaceManager method getProjectBuilder.
/**
* @param nestedURI
* the contained uri
* @return the project builder.
*/
public ProjectBuilder getProjectBuilder(URI nestedURI) {
ProjectConfigSnapshot projectConfig = getProjectConfig(nestedURI);
String projectID = null;
if (projectConfig != null) {
projectID = projectConfig.getName();
}
return getProjectBuilder(projectID);
}
use of org.eclipse.n4js.xtext.workspace.ProjectConfigSnapshot in project n4js by eclipse.
the class XStatefulIncrementalBuilder method isResourceInOutputDirectory.
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();
ProjectConfigSnapshot 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;
}
use of org.eclipse.n4js.xtext.workspace.ProjectConfigSnapshot in project n4js by eclipse.
the class XWorkspaceBuilder method doInitialBuild.
/**
* Run a full build on the entire workspace, i.e. build all projects.
*
* @return the delta.
*/
private IResourceDescription.Event doInitialBuild() {
lspLogger.log("Initial build ...");
Stopwatch stopwatch = Stopwatch.createStarted();
WorkspaceConfigSnapshot workspaceConfig = workspaceManager.getWorkspaceConfig();
boolean hasDependencyCycle = workspaceConfig.hasDependencyCycle();
try {
Collection<? extends ProjectConfigSnapshot> allProjects = workspaceManager.getProjectConfigs();
BuildOrderIterator pboIterator = buildOrderFactory.createBuildOrderIterator(workspaceConfig, allProjects);
logBuildOrder(workspaceConfig);
List<IResourceDescription.Delta> allDeltas = new ArrayList<>();
while (pboIterator.hasNext()) {
ProjectConfigSnapshot projectConfig = pboIterator.next();
String projectID = projectConfig.getName();
ProjectBuilder projectBuilder = workspaceManager.getProjectBuilder(projectID);
XBuildResult partialresult = projectBuilder.doInitialBuild(buildRequestFactory, allDeltas);
allDeltas.addAll(partialresult.getAffectedResources());
}
onBuildDone(true, false, hasDependencyCycle, Optional.absent());
stopwatch.stop();
lspLogger.log("... initial build done (" + stopwatch.toString() + ").");
return new ResourceDescriptionChangeEvent(allDeltas);
} catch (Throwable th) {
boolean wasCanceled = operationCanceledManager.isOperationCanceledException(th);
onBuildDone(true, wasCanceled, hasDependencyCycle, Optional.of(th));
if (wasCanceled) {
lspLogger.log("... initial build canceled.");
operationCanceledManager.propagateIfCancelException(th);
}
lspLogger.error("... initial build ABORTED due to exception:", th);
throw th;
}
}
Aggregations