use of org.eclipse.n4js.xtext.workspace.ProjectConfigSnapshot in project n4js by eclipse.
the class N4jscCompiler method verbosePrintAllProjects.
private void verbosePrintAllProjects() {
if (options.isVerbose()) {
Set<? extends ProjectConfigSnapshot> projects = workspaceManager.getProjectConfigs();
int maxPrjNameLength = projects.stream().filter(p -> p.getName() != null).mapToInt(p -> p.getName().length()).max().orElse(10);
String prjNameWithPadding = "%-" + maxPrjNameLength + "s";
if (!projects.isEmpty()) {
Path workspace = options.getDir().toPath();
SortedMap<String, String> projectList = new TreeMap<>();
for (ProjectConfigSnapshot prj : projects) {
String prjID = prj.getName() == null ? "[no_name]" : prj.getName();
String locationStr = null;
if (prj.getPath() == null) {
locationStr = "[no_location]";
} else {
locationStr = workspace.relativize(URIUtils.toPath(prj.getPath())).toString();
if (locationStr.isBlank()) {
locationStr = ".";
}
}
String outputLine = String.format(prjNameWithPadding + " at %s", prjID, locationStr);
projectList.put(locationStr, outputLine);
}
LOG.info(projects.size() + " projects: \n " + String.join("\n ", projectList.values()));
}
}
}
use of org.eclipse.n4js.xtext.workspace.ProjectConfigSnapshot in project n4js by eclipse.
the class N4JSClusteringStorageAwareResourceLoader method sort.
/**
* The given list of load results is sorted by this method to improve the post processing of N4JS started by the
* {@link N4JSPostProcessor}. During post processing, other dependency resources will be processed too in a
* recursive fashion. However, by sorting load results beforehand here, that will not be necessary since
* dependencies already have been processed. Note however that in case of dependency cycles, sorting cannot avoid
* the recursive post processing of dependencies.
*/
@Override
protected List<LoadResult> sort(XBuildContext context, List<LoadResult> results) {
if (results.isEmpty()) {
return results;
}
WorkspaceConfigSnapshot wcs = WorkspaceConfigAdapter.getWorkspaceConfig(context.getResourceSet());
ProjectConfigSnapshot pcs = wcs.findProjectContaining(results.get(0).uri);
if (pcs == null) {
return results;
}
Set<LoadResult> noDeps = new LinkedHashSet<>();
Multimap<LoadResult, LoadResult> dependsOn = HashMultimap.create();
Multimap<LoadResult, LoadResult> dependsOnInverse = HashMultimap.create();
initDependencyMaps(results, pcs, noDeps, dependsOn, dependsOnInverse);
List<LoadResult> sortedResults = sortLoadResults(results, noDeps, dependsOn, dependsOnInverse);
return sortedResults;
}
use of org.eclipse.n4js.xtext.workspace.ProjectConfigSnapshot in project n4js by eclipse.
the class N4JSProjectBuilder method removeTestCatalog.
/**
* Removes the test catalog for the project.
*/
private void removeTestCatalog() {
ProjectConfigSnapshot projectConfig = getProjectConfig();
File testCatalog = getTestCatalogFile(projectConfig);
if (testCatalog.isFile()) {
try {
testCatalog.delete();
} catch (Exception e) {
LOG.error("Error while deleting test catalog file: " + testCatalog);
}
}
}
use of org.eclipse.n4js.xtext.workspace.ProjectConfigSnapshot in project n4js by eclipse.
the class ResourceTaskContext method updateSharedDirtyState.
/**
* Send dirty state index update to parent. Ignored for {@link #isTemporary() temporary} contexts.
*/
protected void updateSharedDirtyState() {
if (isTemporary()) {
// temporarily opened files do not contribute to the parent's shared dirty state index
return;
}
IResourceDescription newDesc = createResourceDescription();
ProjectConfigSnapshot project = workspaceConfig != null ? workspaceConfig.findProjectContaining(mainURI) : null;
if (project != null) {
indexSnapshot.addDescription(project.getName(), newDesc);
}
parent.updateSharedDirtyState(newDesc.getURI(), newDesc);
}
use of org.eclipse.n4js.xtext.workspace.ProjectConfigSnapshot in project n4js by eclipse.
the class XWorkspaceManager method removeProjects.
/**
* Removes a project from the workspace
*/
protected void removeProjects(Iterable<? extends ProjectConfigSnapshot> projectConfigs) {
for (ProjectConfigSnapshot projectConfig : projectConfigs) {
// no need for #withoutDuplicates() here
String projectID = projectConfig.getName();
ProjectBuilder projectBuilder = projectID2ProjectBuilder.remove(projectID);
if (projectBuilder != null) {
projectBuilder.doClearWithoutNotification();
}
}
}
Aggregations