Search in sources :

Example 1 with N4JSProjectConfig

use of org.eclipse.n4js.workspace.N4JSProjectConfig in project n4js by eclipse.

the class SemanticDependencySupplier method computePackageName2ProjectIdMap.

/**
 * Computes a map from package names to project ids. The context of the given project is taken into account, i.e. in
 * case there exist multiple projects in the workspace with the same package name, the id of that project is mapped
 * that would bind to the given project as a dependency.
 */
public Map<String, String> computePackageName2ProjectIdMap(N4JSWorkspaceConfig workspace, ProjectDescription projectDescription, Path relatedRootLocation, Iterable<String> packageNames) {
    Path projectLocation = projectDescription.getLocation().toPath();
    NodeModulesFolder nodeModulesFolder = nodeModulesDiscoveryHelper.getNodeModulesFolder(projectLocation);
    Map<String, String> packageName2projectIds = new HashMap<>();
    for (String packageName : packageNames) {
        Set<N4JSProjectConfig> candidates = workspace.findProjectsByPackageName(packageName);
        String qualifiedName = getQualifiedName(relatedRootLocation, projectLocation, candidates, nodeModulesFolder, packageName);
        qualifiedName = qualifiedName == null ? packageName : qualifiedName;
        packageName2projectIds.put(packageName, qualifiedName);
    }
    return packageName2projectIds;
}
Also used : Path(java.nio.file.Path) NodeModulesFolder(org.eclipse.n4js.utils.NodeModulesDiscoveryHelper.NodeModulesFolder) HashMap(java.util.HashMap) N4JSProjectConfig(org.eclipse.n4js.workspace.N4JSProjectConfig)

Example 2 with N4JSProjectConfig

use of org.eclipse.n4js.workspace.N4JSProjectConfig in project n4js by eclipse.

the class N4JSConfigSnapshotFactory method createProjectConfigSnapshot.

@Override
public N4JSProjectConfigSnapshot createProjectConfigSnapshot(XIProjectConfig projectConfig) {
    N4JSProjectConfig projectConfigCasted = (N4JSProjectConfig) projectConfig;
    List<String> semanticDependencies = Lists.transform(projectConfigCasted.getSemanticDependencies(), ProjectDependency::getPackageName);
    return new N4JSProjectConfigSnapshot(projectConfigCasted.getProjectDescription(), projectConfig.getPath(), projectConfig.indexOnly(), projectConfig.isGeneratorEnabled(), semanticDependencies, Iterables.transform(projectConfig.getSourceFolders(), this::createSourceFolderSnapshot), projectConfigCasted.getPackageNameForProjectIdMap());
}
Also used : N4JSProjectConfigSnapshot(org.eclipse.n4js.workspace.N4JSProjectConfigSnapshot) ProjectDependency(org.eclipse.n4js.packagejson.projectDescription.ProjectDependency) N4JSProjectConfig(org.eclipse.n4js.workspace.N4JSProjectConfig)

Aggregations

N4JSProjectConfig (org.eclipse.n4js.workspace.N4JSProjectConfig)2 Path (java.nio.file.Path)1 HashMap (java.util.HashMap)1 ProjectDependency (org.eclipse.n4js.packagejson.projectDescription.ProjectDependency)1 NodeModulesFolder (org.eclipse.n4js.utils.NodeModulesDiscoveryHelper.NodeModulesFolder)1 N4JSProjectConfigSnapshot (org.eclipse.n4js.workspace.N4JSProjectConfigSnapshot)1