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);
}
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);
}
}
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);
}
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());
}
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());
}
Aggregations