Search in sources :

Example 1 with SourceFolderProvider

use of com.google.idea.blaze.base.sync.SourceFolderProvider in project intellij by bazelbuild.

the class ContentEntryEditor method createContentEntries.

public static void createContentEntries(Project project, WorkspaceRoot workspaceRoot, ProjectViewSet projectViewSet, BlazeProjectData blazeProjectData, DirectoryStructure rootDirectoryStructure, ModifiableRootModel modifiableRootModel) {
    ImportRoots importRoots = ImportRoots.builder(workspaceRoot, Blaze.getBuildSystem(project)).add(projectViewSet).build();
    Collection<WorkspacePath> rootDirectories = importRoots.rootDirectories();
    Collection<WorkspacePath> excludeDirectories = importRoots.excludeDirectories();
    Multimap<WorkspacePath, WorkspacePath> excludesByRootDirectory = sortExcludesByRootDirectory(rootDirectories, excludeDirectories);
    SourceTestConfig testConfig = new SourceTestConfig(projectViewSet);
    SourceFolderProvider provider = SourceFolderProvider.getSourceFolderProvider(blazeProjectData);
    for (WorkspacePath rootDirectory : rootDirectories) {
        File rootFile = workspaceRoot.fileForPath(rootDirectory);
        ContentEntry contentEntry = modifiableRootModel.addContentEntry(UrlUtil.pathToUrl(rootFile.getPath()));
        for (WorkspacePath exclude : excludesByRootDirectory.get(rootDirectory)) {
            File excludeFolder = workspaceRoot.fileForPath(exclude);
            contentEntry.addExcludeFolder(UrlUtil.fileToIdeaUrl(excludeFolder));
        }
        ImmutableMap<File, SourceFolder> sourceFolders = provider.initializeSourceFolders(contentEntry);
        SourceFolder rootSource = sourceFolders.get(rootFile);
        walkFileSystem(workspaceRoot, testConfig, excludesByRootDirectory.get(rootDirectory), contentEntry, provider, sourceFolders, rootSource, rootDirectory, rootDirectoryStructure.directories.get(rootDirectory));
    }
}
Also used : WorkspacePath(com.google.idea.blaze.base.model.primitives.WorkspacePath) SourceFolder(com.intellij.openapi.roots.SourceFolder) ImportRoots(com.google.idea.blaze.base.sync.projectview.ImportRoots) ContentEntry(com.intellij.openapi.roots.ContentEntry) SourceTestConfig(com.google.idea.blaze.base.sync.projectview.SourceTestConfig) SourceFolderProvider(com.google.idea.blaze.base.sync.SourceFolderProvider) File(java.io.File)

Aggregations

WorkspacePath (com.google.idea.blaze.base.model.primitives.WorkspacePath)1 SourceFolderProvider (com.google.idea.blaze.base.sync.SourceFolderProvider)1 ImportRoots (com.google.idea.blaze.base.sync.projectview.ImportRoots)1 SourceTestConfig (com.google.idea.blaze.base.sync.projectview.SourceTestConfig)1 ContentEntry (com.intellij.openapi.roots.ContentEntry)1 SourceFolder (com.intellij.openapi.roots.SourceFolder)1 File (java.io.File)1