Search in sources :

Example 6 with ProjectViewFile

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);
        }
    }
}
Also used : VirtualFile(com.intellij.openapi.vfs.VirtualFile) OpenFileDescriptor(com.intellij.openapi.fileEditor.OpenFileDescriptor) ProjectViewFile(com.google.idea.blaze.base.projectview.ProjectViewSet.ProjectViewFile) VirtualFile(com.intellij.openapi.vfs.VirtualFile) File(java.io.File)

Example 7 with ProjectViewFile

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;
}
Also used : ProjectViewFile(com.google.idea.blaze.base.projectview.ProjectViewSet.ProjectViewFile) NavigatableAdapter(com.intellij.pom.NavigatableAdapter)

Example 8 with ProjectViewFile

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();
}
Also used : ProjectViewSet(com.google.idea.blaze.base.projectview.ProjectViewSet) ProjectViewFile(com.google.idea.blaze.base.projectview.ProjectViewSet.ProjectViewFile) WorkspaceRoot(com.google.idea.blaze.base.model.primitives.WorkspaceRoot) VirtualFile(com.intellij.openapi.vfs.VirtualFile) ProjectViewFile(com.google.idea.blaze.base.projectview.ProjectViewSet.ProjectViewFile) File(java.io.File) Nullable(javax.annotation.Nullable)

Example 9 with ProjectViewFile

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);
            }
        }
    }
}
Also used : ProjectViewFile(com.google.idea.blaze.base.projectview.ProjectViewSet.ProjectViewFile) SectionParser(com.google.idea.blaze.base.projectview.section.SectionParser)

Example 10 with ProjectViewFile

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;
}
Also used : WorkspacePath(com.google.idea.blaze.base.model.primitives.WorkspacePath) FileOperationProvider(com.google.idea.blaze.base.io.FileOperationProvider) DirectoryEntry(com.google.idea.blaze.base.projectview.section.sections.DirectoryEntry) ProjectViewFile(com.google.idea.blaze.base.projectview.ProjectViewSet.ProjectViewFile) File(java.io.File) ProjectViewFile(com.google.idea.blaze.base.projectview.ProjectViewSet.ProjectViewFile)

Aggregations

ProjectViewFile (com.google.idea.blaze.base.projectview.ProjectViewSet.ProjectViewFile)10 File (java.io.File)6 Nullable (javax.annotation.Nullable)4 WorkspacePath (com.google.idea.blaze.base.model.primitives.WorkspacePath)3 ProjectViewSet (com.google.idea.blaze.base.projectview.ProjectViewSet)3 SectionParser (com.google.idea.blaze.base.projectview.section.SectionParser)3 DirectoryEntry (com.google.idea.blaze.base.projectview.section.sections.DirectoryEntry)3 Lists (com.google.common.collect.Lists)2 FileOperationProvider (com.google.idea.blaze.base.io.FileOperationProvider)2 WorkspaceRoot (com.google.idea.blaze.base.model.primitives.WorkspaceRoot)2 ProjectView (com.google.idea.blaze.base.projectview.ProjectView)2 DirectorySection (com.google.idea.blaze.base.projectview.section.sections.DirectorySection)2 Sections (com.google.idea.blaze.base.projectview.section.sections.Sections)2 BlazeContext (com.google.idea.blaze.base.scope.BlazeContext)2 IssueOutput (com.google.idea.blaze.base.scope.output.IssueOutput)2 BlazeSyncPlugin (com.google.idea.blaze.base.sync.BlazeSyncPlugin)2 LanguageSupport (com.google.idea.blaze.base.sync.projectview.LanguageSupport)2 WorkspaceLanguageSettings (com.google.idea.blaze.base.sync.projectview.WorkspaceLanguageSettings)2 WorkspacePathResolver (com.google.idea.blaze.base.sync.workspace.WorkspacePathResolver)2 BlazeSelectProjectViewOption (com.google.idea.blaze.base.wizard2.BlazeSelectProjectViewOption)2