Search in sources :

Example 1 with BlazeContext

use of com.google.idea.blaze.base.scope.BlazeContext 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;
}
Also used : WorkspacePath(com.google.idea.blaze.base.model.primitives.WorkspacePath) ProjectViewFile(com.google.idea.blaze.base.projectview.ProjectViewSet.ProjectViewFile) SectionParser(com.google.idea.blaze.base.projectview.section.SectionParser) BlazeSyncPlugin(com.google.idea.blaze.base.sync.BlazeSyncPlugin) BlazeContext(com.google.idea.blaze.base.scope.BlazeContext) LanguageSupport(com.google.idea.blaze.base.sync.projectview.LanguageSupport) DirectorySection(com.google.idea.blaze.base.projectview.section.sections.DirectorySection) WorkspaceLanguageSettings(com.google.idea.blaze.base.sync.projectview.WorkspaceLanguageSettings) Sections(com.google.idea.blaze.base.projectview.section.sections.Sections) FileOperationProvider(com.google.idea.blaze.base.io.FileOperationProvider) File(java.io.File) Collectors.toList(java.util.stream.Collectors.toList) List(java.util.List) Lists(com.google.common.collect.Lists) DirectoryEntry(com.google.idea.blaze.base.projectview.section.sections.DirectoryEntry) IssueOutput(com.google.idea.blaze.base.scope.output.IssueOutput) Project(com.intellij.openapi.project.Project) WorkspacePath(com.google.idea.blaze.base.model.primitives.WorkspacePath) WorkspacePathResolver(com.google.idea.blaze.base.sync.workspace.WorkspacePathResolver) FileUtil(com.intellij.openapi.util.io.FileUtil) ListSection(com.google.idea.blaze.base.projectview.section.ListSection) Nullable(javax.annotation.Nullable) DirectoryEntry(com.google.idea.blaze.base.projectview.section.sections.DirectoryEntry) ProjectViewFile(com.google.idea.blaze.base.projectview.ProjectViewSet.ProjectViewFile)

Example 2 with BlazeContext

use of com.google.idea.blaze.base.scope.BlazeContext in project intellij by bazelbuild.

the class ProjectViewVerifierTest method initTest.

@Override
protected void initTest(@NotNull Container applicationServices, @NotNull Container projectServices) {
    super.initTest(applicationServices, projectServices);
    ExtensionPointImpl<BlazeSyncPlugin> ep = registerExtensionPoint(BlazeSyncPlugin.EP_NAME, BlazeSyncPlugin.class);
    ep.registerExtension(new BlazeSyncPlugin() {

        @Override
        public ImmutableList<WorkspaceType> getSupportedWorkspaceTypes() {
            return ImmutableList.of(WorkspaceType.JAVA);
        }

        @Override
        public Set<LanguageClass> getSupportedLanguagesInWorkspace(WorkspaceType workspaceType) {
            return ImmutableSet.of(LanguageClass.JAVA);
        }
    });
    fileOperationProvider = new MockFileOperationProvider(workspaceRoot);
    applicationServices.register(FileOperationProvider.class, fileOperationProvider);
    context = new BlazeContext();
    context.addOutputSink(IssueOutput.class, errorCollector);
}
Also used : BlazeContext(com.google.idea.blaze.base.scope.BlazeContext) WorkspaceType(com.google.idea.blaze.base.model.primitives.WorkspaceType) ImmutableSet(com.google.common.collect.ImmutableSet) Set(java.util.Set) ImmutableList(com.google.common.collect.ImmutableList) BlazeSyncPlugin(com.google.idea.blaze.base.sync.BlazeSyncPlugin)

Example 3 with BlazeContext

use of com.google.idea.blaze.base.scope.BlazeContext in project intellij by bazelbuild.

the class ProjectViewParserTest method initTest.

@Override
protected void initTest(@NotNull Container applicationServices, @NotNull Container projectServices) {
    super.initTest(applicationServices, projectServices);
    context = new BlazeContext();
    errorCollector = new ErrorCollector();
    context.addOutputSink(IssueOutput.class, errorCollector);
    projectViewParser = new ProjectViewParser(context, new WorkspacePathResolverImpl(workspaceRoot));
    projectViewStorageManager = new MockProjectViewStorageManager();
    applicationServices.register(ProjectViewStorageManager.class, projectViewStorageManager);
    applicationServices.register(ExperimentService.class, new MockExperimentService());
    registerExtensionPoint(BlazeSyncPlugin.EP_NAME, BlazeSyncPlugin.class);
}
Also used : MockExperimentService(com.google.idea.common.experiments.MockExperimentService) BlazeContext(com.google.idea.blaze.base.scope.BlazeContext) WorkspacePathResolverImpl(com.google.idea.blaze.base.sync.workspace.WorkspacePathResolverImpl) ErrorCollector(com.google.idea.blaze.base.scope.ErrorCollector)

Example 4 with BlazeContext

use of com.google.idea.blaze.base.scope.BlazeContext in project intellij by bazelbuild.

the class LanguageSupportTest method initTest.

@Override
protected void initTest(@NotNull Container applicationServices, @NotNull Container projectServices) {
    super.initTest(applicationServices, projectServices);
    syncPlugins = registerExtensionPoint(BlazeSyncPlugin.EP_NAME, BlazeSyncPlugin.class);
    context = new BlazeContext();
    context.addOutputSink(IssueOutput.class, errorCollector);
}
Also used : BlazeContext(com.google.idea.blaze.base.scope.BlazeContext)

Example 5 with BlazeContext

use of com.google.idea.blaze.base.scope.BlazeContext in project intellij by bazelbuild.

the class AlwaysPresentPythonSyncPlugin method validate.

@Override
public boolean validate(Project project, BlazeContext context, BlazeProjectData blazeProjectData) {
    ImportRoots importRoots = ImportRoots.forProjectSafe(project);
    if (importRoots == null) {
        return true;
    }
    boolean hasPythonTarget = blazeProjectData.targetMap.targets().stream().filter(target -> importRoots.importAsSource(target.key.label)).anyMatch(target -> target.kindIsOneOf(Kind.allKindsForLanguage(LanguageClass.PYTHON)));
    if (!hasPythonTarget) {
        return true;
    }
    String pluginId = PythonPluginUtils.getPythonPluginId();
    if (!PluginUtils.isPluginEnabled(pluginId)) {
        IssueOutput.warn("Your project appears to contain Python targets. To enable Python support, " + "install/enable the JetBrains python plugin, then restart the IDE").navigatable(PluginUtils.installOrEnablePluginNavigable(pluginId)).submit(context);
        return false;
    }
    return true;
}
Also used : BlazeSyncPlugin(com.google.idea.blaze.base.sync.BlazeSyncPlugin) PythonPluginUtils(com.google.idea.blaze.python.PythonPluginUtils) LanguageClass(com.google.idea.blaze.base.model.primitives.LanguageClass) ImportRoots(com.google.idea.blaze.base.sync.projectview.ImportRoots) ImmutableSet(com.google.common.collect.ImmutableSet) BlazeContext(com.google.idea.blaze.base.scope.BlazeContext) PluginUtils(com.google.idea.blaze.base.plugin.PluginUtils) Collection(java.util.Collection) Set(java.util.Set) Kind(com.google.idea.blaze.base.model.primitives.Kind) BlazeProjectData(com.google.idea.blaze.base.model.BlazeProjectData) WorkspaceType(com.google.idea.blaze.base.model.primitives.WorkspaceType) ImmutableList(com.google.common.collect.ImmutableList) IssueOutput(com.google.idea.blaze.base.scope.output.IssueOutput) Project(com.intellij.openapi.project.Project) ImportRoots(com.google.idea.blaze.base.sync.projectview.ImportRoots)

Aggregations

BlazeContext (com.google.idea.blaze.base.scope.BlazeContext)42 ImmutableList (com.google.common.collect.ImmutableList)18 Nullable (javax.annotation.Nullable)18 ProjectViewSet (com.google.idea.blaze.base.projectview.ProjectViewSet)17 List (java.util.List)16 WorkspaceRoot (com.google.idea.blaze.base.model.primitives.WorkspaceRoot)15 Project (com.intellij.openapi.project.Project)15 File (java.io.File)15 Set (java.util.Set)15 Lists (com.google.common.collect.Lists)13 BlazeSyncPlugin (com.google.idea.blaze.base.sync.BlazeSyncPlugin)12 ArtifactLocationDecoder (com.google.idea.blaze.base.sync.workspace.ArtifactLocationDecoder)12 Logger (com.intellij.openapi.diagnostic.Logger)12 Collection (java.util.Collection)12 ListenableFuture (com.google.common.util.concurrent.ListenableFuture)11 BlazeProjectData (com.google.idea.blaze.base.model.BlazeProjectData)10 Map (java.util.Map)10 ImmutableSet (com.google.common.collect.ImmutableSet)9 BlazeCommand (com.google.idea.blaze.base.command.BlazeCommand)9 Collectors (java.util.stream.Collectors)9