Search in sources :

Example 6 with ProjectDescription

use of org.eclipse.n4js.packagejson.projectDescription.ProjectDescription in project n4js by eclipse.

the class N4JSProjectConfig method updateProjectStateFromDisk.

/**
 * Re-reads the project state from disk and notifies the parent workspace (if a change occurred).
 */
protected void updateProjectStateFromDisk() {
    ProjectDescription pdOld = projectDescription;
    projectDescription = projectDescriptionLoader.loadProjectDescriptionAtLocation(path, pdOld.getRelatedRootLocation());
    if (projectDescription == null) {
        projectDescription = ProjectDescription.builder().build();
    }
    // a project is not allowed to change its name
    String nameOld = pdOld.getPackageName();
    if (!Objects.equals(projectDescription.getPackageName(), nameOld)) {
        // projectDescription = projectDescription.change().setName(nameOld).build();
        System.out.println();
    }
    if (projectDescription.equals(pdOld)) {
        // nothing changed
        return;
    }
    sourceFolders = createSourceFolders(projectDescription);
    semanticDependencies = null;
    packageNameToProjectIds = null;
    workspace.onProjectChanged(path, pdOld, projectDescription);
}
Also used : ProjectDescription(org.eclipse.n4js.packagejson.projectDescription.ProjectDescription)

Example 7 with ProjectDescription

use of org.eclipse.n4js.packagejson.projectDescription.ProjectDescription in project n4js by eclipse.

the class N4JSWorkspaceConfig method reloadAllProjectInformationFromDisk.

/**
 * Clears this workspace and re-initializes it by searching the file system for projects.
 */
protected void reloadAllProjectInformationFromDisk() {
    deregisterAllProjects();
    Path baseDir = getPathAsFileURI().toPath();
    Map<Path, ProjectDescription> projects = projectDiscoveryHelper.collectAllProjectDirs(Collections.singleton(baseDir));
    for (Path newProjectPath : projects.keySet()) {
        FileURI newProjectPathAsFileURI = new FileURI(newProjectPath);
        ProjectDescription pd = projects.get(newProjectPath);
        registerProject(newProjectPathAsFileURI, pd);
    }
}
Also used : Path(java.nio.file.Path) FileURI(org.eclipse.n4js.workspace.locations.FileURI) ProjectDescription(org.eclipse.n4js.packagejson.projectDescription.ProjectDescription)

Example 8 with ProjectDescription

use of org.eclipse.n4js.packagejson.projectDescription.ProjectDescription in project n4js by eclipse.

the class MockWorkspaceSupplier method createProjectDescription.

/**
 * See {@link #createWorkspaceConfig()}. Only invoked if {@link #loadProjectDescription()} returns absent value.
 */
protected Pair<FileURI, ProjectDescription> createProjectDescription() {
    VersionNumber versionNumber = SemverUtils.createVersionNumber(0, 0, 1);
    Iterable<SourceContainerDescription> sourceContainers = createSourceContainerDescriptions();
    ProjectDescription pd = ProjectDescription.builder().setPackageName(TEST_PROJECT__NAME).setVersion(versionNumber).setType(TEST_PROJECT__TYPE).setVendorId(TEST_PROJECT__VENDOR_ID).setVendorName(TEST_PROJECT__VENDOR_NAME).addSourceContainers(sourceContainers).build();
    return Pair.of(TEST_PROJECT__PATH, pd);
}
Also used : SourceContainerDescription(org.eclipse.n4js.packagejson.projectDescription.SourceContainerDescription) ProjectDescription(org.eclipse.n4js.packagejson.projectDescription.ProjectDescription) VersionNumber(org.eclipse.n4js.semver.Semver.VersionNumber)

Example 9 with ProjectDescription

use of org.eclipse.n4js.packagejson.projectDescription.ProjectDescription in project n4js by eclipse.

the class MockWorkspaceSupplier method createProjectConfig.

/**
 * See {@link #createWorkspaceConfig()}.
 */
protected N4JSProjectConfigSnapshot createProjectConfig() {
    // try to load a test package.json from disk, otherwise create a project configuration from default values
    Pair<FileURI, ProjectDescription> loadedOrCreated = loadProjectDescription().or(this::createProjectDescription);
    FileURI projectPath = loadedOrCreated.getKey();
    ProjectDescription pd = loadedOrCreated.getValue();
    List<N4JSSourceFolderSnapshot> sourceFolders = createSourceFolders(projectPath, pd);
    return new N4JSProjectConfigSnapshot(pd, projectPath.withTrailingPathDelimiter().toURI(), false, true, Collections.emptyList(), sourceFolders, Map.of());
}
Also used : FileURI(org.eclipse.n4js.workspace.locations.FileURI) N4JSProjectConfigSnapshot(org.eclipse.n4js.workspace.N4JSProjectConfigSnapshot) N4JSSourceFolderSnapshot(org.eclipse.n4js.workspace.N4JSSourceFolderSnapshot) ProjectDescription(org.eclipse.n4js.packagejson.projectDescription.ProjectDescription)

Example 10 with ProjectDescription

use of org.eclipse.n4js.packagejson.projectDescription.ProjectDescription in project n4js by eclipse.

the class ProjectSetTest method createProjectConfig.

private N4JSProjectConfigSnapshot createProjectConfig(URI path) {
    String name = ProjectDescriptionUtils.deriveN4JSPackageNameFromURI(path);
    ProjectDescription pd = ProjectDescription.builder().setPackageName(name).setType(ProjectType.LIBRARY).setVersion(SemverUtils.createVersionNumber(0, 0, 1)).build();
    N4JSSourceFolderSnapshot srcFolder = new N4JSSourceFolderSnapshot("src", path.appendSegment("src"), SourceContainerType.SOURCE, "src");
    return new N4JSProjectConfigSnapshot(pd, path, false, true, Collections.emptyList(), Collections.singleton(srcFolder), Map.of());
}
Also used : N4JSProjectConfigSnapshot(org.eclipse.n4js.workspace.N4JSProjectConfigSnapshot) N4JSSourceFolderSnapshot(org.eclipse.n4js.workspace.N4JSSourceFolderSnapshot) ProjectDescription(org.eclipse.n4js.packagejson.projectDescription.ProjectDescription)

Aggregations

ProjectDescription (org.eclipse.n4js.packagejson.projectDescription.ProjectDescription)19 Path (java.nio.file.Path)8 FileURI (org.eclipse.n4js.workspace.locations.FileURI)6 N4JSProjectConfigSnapshot (org.eclipse.n4js.workspace.N4JSProjectConfigSnapshot)4 ArrayList (java.util.ArrayList)3 LinkedHashMap (java.util.LinkedHashMap)3 File (java.io.File)2 HashMap (java.util.HashMap)2 LinkedHashSet (java.util.LinkedHashSet)2 ProjectDependency (org.eclipse.n4js.packagejson.projectDescription.ProjectDependency)2 ProjectDescriptionBuilder (org.eclipse.n4js.packagejson.projectDescription.ProjectDescriptionBuilder)2 ProjectType (org.eclipse.n4js.packagejson.projectDescription.ProjectType)2 N4JSSourceFolderSnapshot (org.eclipse.n4js.workspace.N4JSSourceFolderSnapshot)2 FluentIterable (com.google.common.collect.FluentIterable)1 HashMultimap (com.google.common.collect.HashMultimap)1 ImmutableSet (com.google.common.collect.ImmutableSet)1 Iterables (com.google.common.collect.Iterables)1 Sets (com.google.common.collect.Sets)1 IOException (java.io.IOException)1 FileVisitOption (java.nio.file.FileVisitOption)1