use of com.google.idea.blaze.base.projectview.section.ListSection in project intellij by bazelbuild.
the class ProjectViewVerifier method verifyIncludedPackagesAreNotExcluded.
private static boolean verifyIncludedPackagesAreNotExcluded(BlazeContext context, ProjectViewSet projectViewSet) {
boolean ok = true;
List<WorkspacePath> includedDirectories = projectViewSet.listItems(DirectorySection.KEY).stream().filter(entry -> entry.included).map(entry -> entry.directory).collect(toList());
for (WorkspacePath includedDirectory : includedDirectories) {
for (ProjectViewSet.ProjectViewFile projectViewFile : projectViewSet.getProjectViewFiles()) {
List<DirectoryEntry> directoryEntries = Lists.newArrayList();
for (ListSection<DirectoryEntry> section : projectViewFile.projectView.getSectionsOfType(DirectorySection.KEY)) {
directoryEntries.addAll(section.items());
}
for (DirectoryEntry entry : directoryEntries) {
if (entry.included) {
continue;
}
WorkspacePath excludedDirectory = entry.directory;
if (FileUtil.isAncestor(excludedDirectory.relativePath(), includedDirectory.relativePath(), false)) {
IssueOutput.error(String.format("%s is included, but that contradicts %s which was excluded", includedDirectory.toString(), excludedDirectory.toString())).inFile(projectViewFile.projectViewFile).submit(context);
ok = false;
}
}
}
}
return ok;
}
use of com.google.idea.blaze.base.projectview.section.ListSection in project intellij by bazelbuild.
the class AddGeneratedResourceDirectoryNavigatable method addDirectoryToProjectView.
private static void addDirectoryToProjectView(Project project, File projectViewFile, ArtifactLocation generatedResDir) {
ProjectViewEdit edit = ProjectViewEdit.editLocalProjectView(project, builder -> {
ListSection<GenfilesPath> existingSection = builder.getLast(GeneratedAndroidResourcesSection.KEY);
ListSection.Builder<GenfilesPath> directoryBuilder = ListSection.update(GeneratedAndroidResourcesSection.KEY, existingSection);
directoryBuilder.add(new GenfilesPath(generatedResDir.getRelativePath()));
builder.replace(existingSection, directoryBuilder);
return true;
});
if (edit == null) {
Messages.showErrorDialog("Could not modify project view. Check for errors in your project view and try again", "Error");
return;
}
edit.apply();
VirtualFile projectView = VfsUtil.findFileByIoFile(projectViewFile, false);
if (projectView != null) {
FileEditorManager.getInstance(project).openEditor(new OpenFileDescriptor(project, projectView), true);
}
}
use of com.google.idea.blaze.base.projectview.section.ListSection in project intellij by bazelbuild.
the class AddLibraryTargetDirectoryToProjectViewAction method addDirectoriesToProjectView.
static void addDirectoriesToProjectView(Project project, List<Library> libraries) {
Set<WorkspacePath> workspacePaths = Sets.newHashSet();
for (Library library : libraries) {
WorkspacePath workspacePath = getDirectoryToAddForLibrary(project, library);
if (workspacePath != null) {
workspacePaths.add(workspacePath);
}
}
ProjectViewEdit edit = ProjectViewEdit.editLocalProjectView(project, builder -> {
ListSection<DirectoryEntry> existingSection = builder.getLast(DirectorySection.KEY);
ListSection.Builder<DirectoryEntry> directoryBuilder = ListSection.update(DirectorySection.KEY, existingSection);
for (WorkspacePath workspacePath : workspacePaths) {
directoryBuilder.add(new DirectoryEntry(workspacePath, true));
}
builder.replace(existingSection, directoryBuilder);
return true;
});
if (edit == null) {
Messages.showErrorDialog("Could not modify project view. Check for errors in your project view and try again", "Error");
return;
}
edit.apply();
BlazeSyncManager.getInstance(project).requestProjectSync(new BlazeSyncParams.Builder("Adding Library", BlazeSyncParams.SyncMode.INCREMENTAL).addProjectViewTargets(true).addWorkingSet(BlazeUserSettings.getInstance().getExpandSyncToWorkingSet()).build());
}
Aggregations