Search in sources :

Example 1 with ProjectConfigSnapshot

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()));
        }
    }
}
Also used : Stopwatch(com.google.common.base.Stopwatch) XLanguageServerImpl(org.eclipse.n4js.xtext.ide.server.XLanguageServerImpl) LanguageServerFrontend(org.eclipse.n4js.xtext.ide.server.LanguageServerFrontend) N4jscFactory(org.eclipse.n4js.cli.N4jscFactory) URIUtils(org.eclipse.n4js.utils.URIUtils) Logger(org.apache.log4j.Logger) N4jscOptions(org.eclipse.n4js.cli.N4jscOptions) N4jscException(org.eclipse.n4js.cli.N4jscException) Path(java.nio.file.Path) InitializedParams(org.eclipse.lsp4j.InitializedParams) N4jscExitState(org.eclipse.n4js.cli.N4jscExitState) N4JSDataCollectors(org.eclipse.n4js.smith.N4JSDataCollectors) Set(java.util.Set) N4jscExitCode(org.eclipse.n4js.cli.N4jscExitCode) ProjectConfigSnapshot(org.eclipse.n4js.xtext.workspace.ProjectConfigSnapshot) DefaultBuildRequestFactory(org.eclipse.n4js.xtext.ide.server.build.DefaultBuildRequestFactory) File(java.io.File) Measurement(org.eclipse.n4js.smith.Measurement) Injector(com.google.inject.Injector) TreeMap(java.util.TreeMap) WorkspaceFolder(org.eclipse.lsp4j.WorkspaceFolder) XWorkspaceManager(org.eclipse.n4js.xtext.ide.server.build.XWorkspaceManager) InitializeParams(org.eclipse.lsp4j.InitializeParams) N4jscConsole(org.eclipse.n4js.cli.N4jscConsole) LogManager(org.apache.log4j.LogManager) ProjectStatePersisterConfig(org.eclipse.n4js.xtext.ide.server.ProjectStatePersisterConfig) Collections(java.util.Collections) SortedMap(java.util.SortedMap) Path(java.nio.file.Path) ProjectConfigSnapshot(org.eclipse.n4js.xtext.workspace.ProjectConfigSnapshot) TreeMap(java.util.TreeMap)

Example 2 with ProjectConfigSnapshot

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;
}
Also used : LinkedHashSet(java.util.LinkedHashSet) WorkspaceConfigSnapshot(org.eclipse.n4js.xtext.workspace.WorkspaceConfigSnapshot) ProjectConfigSnapshot(org.eclipse.n4js.xtext.workspace.ProjectConfigSnapshot)

Example 3 with ProjectConfigSnapshot

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);
        }
    }
}
Also used : N4JSProjectConfigSnapshot(org.eclipse.n4js.workspace.N4JSProjectConfigSnapshot) ProjectConfigSnapshot(org.eclipse.n4js.xtext.workspace.ProjectConfigSnapshot) File(java.io.File) IOException(java.io.IOException)

Example 4 with ProjectConfigSnapshot

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);
}
Also used : ProjectConfigSnapshot(org.eclipse.n4js.xtext.workspace.ProjectConfigSnapshot) IResourceDescription(org.eclipse.xtext.resource.IResourceDescription)

Example 5 with ProjectConfigSnapshot

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();
        }
    }
}
Also used : ProjectConfigSnapshot(org.eclipse.n4js.xtext.workspace.ProjectConfigSnapshot)

Aggregations

ProjectConfigSnapshot (org.eclipse.n4js.xtext.workspace.ProjectConfigSnapshot)25 URI (org.eclipse.emf.common.util.URI)9 WorkspaceConfigSnapshot (org.eclipse.n4js.xtext.workspace.WorkspaceConfigSnapshot)9 Stopwatch (com.google.common.base.Stopwatch)4 Path (java.nio.file.Path)4 ArrayList (java.util.ArrayList)4 LinkedHashSet (java.util.LinkedHashSet)4 FileURI (org.eclipse.n4js.workspace.locations.FileURI)4 WorkspaceChanges (org.eclipse.n4js.xtext.workspace.WorkspaceChanges)4 IResourceDescription (org.eclipse.xtext.resource.IResourceDescription)4 HashSet (java.util.HashSet)3 Set (java.util.Set)3 ImmutableSet (com.google.common.collect.ImmutableSet)2 Injector (com.google.inject.Injector)2 File (java.io.File)2 Collections (java.util.Collections)2 TreeMap (java.util.TreeMap)2 N4JSProjectConfigSnapshot (org.eclipse.n4js.workspace.N4JSProjectConfigSnapshot)2 ResourceChangeSet (org.eclipse.n4js.xtext.ide.server.ResourceChangeSet)2 XIProjectConfig (org.eclipse.n4js.xtext.workspace.XIProjectConfig)2