use of com.google.idea.blaze.base.projectview.ProjectViewSet.ProjectViewFile in project intellij by bazelbuild.
the class ProjectViewHelper method openProjectViewFile.
static void openProjectViewFile(Project project, ProjectViewFile projectViewFile) {
File file = projectViewFile.projectViewFile;
if (file != null) {
VirtualFile virtualFile = VfsUtil.findFileByIoFile(file, true);
if (virtualFile != null) {
OpenFileDescriptor descriptor = new OpenFileDescriptor(project, virtualFile);
FileEditorManager.getInstance(project).openTextEditor(descriptor, true);
}
}
}
use of com.google.idea.blaze.base.projectview.ProjectViewSet.ProjectViewFile in project intellij by bazelbuild.
the class BlazePythonSyncPlugin method validateProjectView.
@Override
public boolean validateProjectView(@Nullable Project project, BlazeContext context, ProjectViewSet projectViewSet, WorkspaceLanguageSettings workspaceLanguageSettings) {
ProjectViewFile topLevelProjectViewFile = projectViewSet.getTopLevelProjectViewFile();
if (!supportsPythonWorkspaceType() && workspaceLanguageSettings.isWorkspaceType(WorkspaceType.PYTHON)) {
String msg = "Python workspace type is not supported (and is unnecessary) for this IDE. ";
boolean fixable = topLevelProjectViewFile != null && topLevelProjectViewFile.projectView.getScalarValue(WorkspaceTypeSection.KEY) == WorkspaceType.PYTHON;
msg += fixable ? "Click here to remove it, retaining python support" : "Please remove it and resync.";
IssueOutput.error(msg).navigatable(project == null || !fixable ? null : new NavigatableAdapter() {
@Override
public void navigate(boolean requestFocus) {
fixLanguageSupport(project, true);
}
}).submit(context);
return false;
}
return true;
}
use of com.google.idea.blaze.base.projectview.ProjectViewSet.ProjectViewFile in project intellij by bazelbuild.
the class ExportRunConfigurationDialog method defaultExportDirectory.
/**
* Try to find a checked-in project view file. Otherwise, fall back to the workspace root.
*/
@Nullable
private static File defaultExportDirectory(Project project) {
WorkspaceRoot workspaceRoot = WorkspaceRoot.fromProjectSafe(project);
if (workspaceRoot == null) {
return null;
}
ProjectViewSet projectViewSet = ProjectViewManager.getInstance(project).getProjectViewSet();
if (projectViewSet != null) {
for (ProjectViewFile projectViewFile : projectViewSet.getProjectViewFiles()) {
File file = projectViewFile.projectViewFile;
if (file != null && FileUtil.isAncestor(workspaceRoot.directory(), file, false)) {
return file.getParentFile();
}
}
}
return workspaceRoot.directory();
}
use of com.google.idea.blaze.base.projectview.ProjectViewSet.ProjectViewFile in project intellij by bazelbuild.
the class ProjectViewVerifier method warnAboutDeprecatedSections.
private static void warnAboutDeprecatedSections(BlazeContext context, ProjectViewSet projectViewSet) {
List<SectionParser> deprecatedParsers = Sections.getParsers().stream().filter(SectionParser::isDeprecated).collect(toList());
for (SectionParser sectionParser : deprecatedParsers) {
for (ProjectViewFile projectViewFile : projectViewSet.getProjectViewFiles()) {
ProjectView projectView = projectViewFile.projectView;
if (projectView.getSections().stream().anyMatch(section -> section.isSectionType(sectionParser.getSectionKey()))) {
String deprecationMessage = sectionParser.getDeprecationMessage();
if (deprecationMessage == null) {
deprecationMessage = String.format("%s is deprecated", sectionParser.getName());
}
IssueOutput.warn(deprecationMessage).inFile(projectViewFile.projectViewFile).submit(context);
}
}
}
}
use of com.google.idea.blaze.base.projectview.ProjectViewSet.ProjectViewFile in project intellij by bazelbuild.
the class ProjectViewVerifier method verifyIncludedPackagesExistOnDisk.
private static boolean verifyIncludedPackagesExistOnDisk(BlazeContext context, WorkspacePathResolver workspacePathResolver, ProjectViewSet projectViewSet) {
boolean ok = true;
FileOperationProvider fileOperationProvider = FileOperationProvider.getInstance();
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 workspacePath = entry.directory;
File file = workspacePathResolver.resolveToFile(workspacePath);
if (!fileOperationProvider.exists(file)) {
IssueOutput.error(String.format("Directory '%s' specified in project view not found.", workspacePath)).inFile(projectViewFile.projectViewFile).submit(context);
ok = false;
} else if (!fileOperationProvider.isDirectory(file)) {
IssueOutput.error(String.format("Directory '%s' specified in project view is a file.", workspacePath)).inFile(projectViewFile.projectViewFile).submit(context);
ok = false;
}
}
}
return ok;
}
Aggregations