Search in sources :

Example 21 with ProjectViewSet

use of com.google.idea.blaze.base.projectview.ProjectViewSet in project intellij by bazelbuild.

the class BlazeJavascriptSyncPluginTest method testJavascriptLanguageAvailableForUltimateEdition.

@Test
public void testJavascriptLanguageAvailableForUltimateEdition() {
    TestUtils.setPlatformPrefix(testDisposable, PlatformUtils.IDEA_PREFIX);
    ProjectViewSet projectViewSet = ProjectViewSet.builder().add(ProjectView.builder().add(ScalarSection.builder(WorkspaceTypeSection.KEY).set(WorkspaceType.JAVASCRIPT)).add(ListSection.builder(AdditionalLanguagesSection.KEY).add(LanguageClass.JAVASCRIPT)).build()).build();
    WorkspaceLanguageSettings workspaceLanguageSettings = LanguageSupport.createWorkspaceLanguageSettings(projectViewSet);
    errorCollector.assertNoIssues();
    assertThat(workspaceLanguageSettings).isEqualTo(new WorkspaceLanguageSettings(WorkspaceType.JAVASCRIPT, ImmutableSet.of(LanguageClass.JAVASCRIPT, LanguageClass.GENERIC)));
}
Also used : ProjectViewSet(com.google.idea.blaze.base.projectview.ProjectViewSet) WorkspaceLanguageSettings(com.google.idea.blaze.base.sync.projectview.WorkspaceLanguageSettings) Test(org.junit.Test)

Example 22 with ProjectViewSet

use of com.google.idea.blaze.base.projectview.ProjectViewSet in project intellij by bazelbuild.

the class BlazeTypescriptSyncPluginTest method testTypescriptNotLanguageAvailableInCommunityEdition.

@Test
public void testTypescriptNotLanguageAvailableInCommunityEdition() {
    TestUtils.setPlatformPrefix(testDisposable, PlatformUtils.IDEA_CE_PREFIX);
    ProjectViewSet projectViewSet = ProjectViewSet.builder().add(ProjectView.builder().add(ScalarSection.builder(WorkspaceTypeSection.KEY).set(WorkspaceType.JAVA)).add(ListSection.builder(AdditionalLanguagesSection.KEY).add(LanguageClass.TYPESCRIPT)).build()).build();
    WorkspaceLanguageSettings workspaceLanguageSettings = LanguageSupport.createWorkspaceLanguageSettings(projectViewSet);
    LanguageSupport.validateLanguageSettings(context, workspaceLanguageSettings);
    errorCollector.assertIssues("Language 'typescript' is not supported by this plugin");
}
Also used : ProjectViewSet(com.google.idea.blaze.base.projectview.ProjectViewSet) WorkspaceLanguageSettings(com.google.idea.blaze.base.sync.projectview.WorkspaceLanguageSettings) Test(org.junit.Test)

Example 23 with ProjectViewSet

use of com.google.idea.blaze.base.projectview.ProjectViewSet in project intellij by bazelbuild.

the class BlazeAndroidBinaryRunConfigurationHandler method createRunner.

@Override
public BlazeCommandRunConfigurationRunner createRunner(Executor executor, ExecutionEnvironment environment) throws ExecutionException {
    Project project = environment.getProject();
    Module module = getModule();
    AndroidFacet facet = module != null ? AndroidFacet.getInstance(module) : null;
    ProjectViewSet projectViewSet = ProjectViewManager.getInstance(project).getProjectViewSet();
    BlazeAndroidRunConfigurationValidationUtil.validateExecution(module, facet, projectViewSet);
    ImmutableList<String> blazeFlags = configState.getCommonState().getExpandedBuildFlags(project, projectViewSet, BlazeCommandName.RUN);
    ImmutableList<String> exeFlags = ImmutableList.copyOf(configState.getCommonState().getExeFlagsState().getExpandedFlags());
    BlazeAndroidRunContext runContext = createRunContext(project, facet, environment, blazeFlags, exeFlags);
    return new BlazeAndroidRunConfigurationRunner(module, runContext, getCommonState().getDeployTargetManager(), getCommonState().getDebuggerManager(), configuration.getUniqueID());
}
Also used : ProjectViewSet(com.google.idea.blaze.base.projectview.ProjectViewSet) Project(com.intellij.openapi.project.Project) BlazeAndroidRunConfigurationRunner(com.google.idea.blaze.android.run.runner.BlazeAndroidRunConfigurationRunner) Module(com.intellij.openapi.module.Module) BlazeAndroidRunContext(com.google.idea.blaze.android.run.runner.BlazeAndroidRunContext) AndroidFacet(org.jetbrains.android.facet.AndroidFacet)

Example 24 with ProjectViewSet

use of com.google.idea.blaze.base.projectview.ProjectViewSet in project intellij by bazelbuild.

the class BlazeIdeInterfaceAspectsImpl method getIdeInfo.

private static IdeInfoResult getIdeInfo(Project project, BlazeContext parentContext, WorkspaceRoot workspaceRoot, ProjectViewSet projectViewSet, ImmutableSet<LanguageClass> activeLanguages, ShardedTargetList shardedTargets, AspectStrategy aspectStrategy) {
    return Scope.push(parentContext, context -> {
        context.push(new TimingScope(String.format("Execute%sCommand", Blaze.buildSystemName(project)), EventType.BlazeInvocation));
        Set<File> ideInfoFiles = new LinkedHashSet<>();
        Function<Integer, String> progressMessage = count -> String.format("Building IDE info files for shard %s of %s...", count, shardedTargets.shardedTargets.size());
        Function<List<TargetExpression>, BuildResult> invocation = targets -> {
            IdeInfoResult result = getIdeInfoForTargets(project, context, workspaceRoot, projectViewSet, activeLanguages, targets, aspectStrategy);
            ideInfoFiles.addAll(result.files);
            return result.buildResult;
        };
        BuildResult result = shardedTargets.runShardedCommand(project, context, progressMessage, invocation);
        return new IdeInfoResult(ideInfoFiles, result);
    });
}
Also used : LinkedHashSet(java.util.LinkedHashSet) ExternalTask(com.google.idea.blaze.base.async.process.ExternalTask) AdditionalLanguagesHelper(com.google.idea.blaze.base.lang.AdditionalLanguagesHelper) Result(com.google.idea.blaze.base.scope.Result) LanguageSupport(com.google.idea.blaze.base.sync.projectview.LanguageSupport) PrefetchService(com.google.idea.blaze.base.prefetch.PrefetchService) ScopedFunction(com.google.idea.blaze.base.scope.ScopedFunction) Map(java.util.Map) TargetExpression(com.google.idea.blaze.base.model.primitives.TargetExpression) FileUtil(com.intellij.openapi.util.io.FileUtil) Logger(com.intellij.openapi.diagnostic.Logger) IntellijIdeInfo(com.google.devtools.intellij.ideinfo.IntellijIdeInfo) FileDiffer(com.google.idea.blaze.base.filecache.FileDiffer) BlazeConsoleLineProcessorProvider(com.google.idea.blaze.base.console.BlazeConsoleLineProcessorProvider) Blaze(com.google.idea.blaze.base.settings.Blaze) BiMap(com.google.common.collect.BiMap) ImmutableSet(com.google.common.collect.ImmutableSet) ImmutableMap(com.google.common.collect.ImmutableMap) AspectStrategy(com.google.idea.blaze.base.sync.aspects.strategy.AspectStrategy) Predicate(java.util.function.Predicate) Collection(java.util.Collection) BuildSystemProvider(com.google.idea.blaze.base.bazel.BuildSystemProvider) FutureUtil(com.google.idea.blaze.base.async.FutureUtil) Set(java.util.Set) WorkspaceLanguageSettings(com.google.idea.blaze.base.sync.projectview.WorkspaceLanguageSettings) BuildResultHelper(com.google.idea.blaze.base.command.buildresult.BuildResultHelper) PrintOutput(com.google.idea.blaze.base.scope.output.PrintOutput) Sets(com.google.common.collect.Sets) Serializable(java.io.Serializable) BlazeCommandName(com.google.idea.blaze.base.command.BlazeCommandName) Objects(java.util.Objects) List(java.util.List) LineProcessingOutputStream(com.google.idea.blaze.base.async.process.LineProcessingOutputStream) Status(com.google.idea.blaze.base.sync.aspects.BuildResult.Status) ProjectViewSet(com.google.idea.blaze.base.projectview.ProjectViewSet) WorkspaceRoot(com.google.idea.blaze.base.model.primitives.WorkspaceRoot) TargetKey(com.google.idea.blaze.base.ideinfo.TargetKey) ShardedTargetList(com.google.idea.blaze.base.sync.sharding.ShardedTargetList) ArtifactLocationDecoder(com.google.idea.blaze.base.sync.workspace.ArtifactLocationDecoder) TargetMap(com.google.idea.blaze.base.ideinfo.TargetMap) Joiner(com.google.common.base.Joiner) ListeningExecutorService(com.google.common.util.concurrent.ListeningExecutorService) BlazeContext(com.google.idea.blaze.base.scope.BlazeContext) ListenableFuture(com.google.common.util.concurrent.ListenableFuture) AspectStrategyProvider(com.google.idea.blaze.base.sync.aspects.strategy.AspectStrategyProvider) Function(java.util.function.Function) ArrayList(java.util.ArrayList) NavigatableAdapter(com.intellij.pom.NavigatableAdapter) HashSet(java.util.HashSet) Kind(com.google.idea.blaze.base.model.primitives.Kind) Lists(com.google.common.collect.Lists) ImmutableList(com.google.common.collect.ImmutableList) BuildSystem(com.google.idea.blaze.base.settings.Blaze.BuildSystem) Scope(com.google.idea.blaze.base.scope.Scope) OutputGroup(com.google.idea.blaze.base.sync.aspects.strategy.AspectStrategy.OutputGroup) IssueOutput(com.google.idea.blaze.base.scope.output.IssueOutput) TargetIdeInfo(com.google.idea.blaze.base.ideinfo.TargetIdeInfo) Project(com.intellij.openapi.project.Project) LinkedHashSet(java.util.LinkedHashSet) Nullable(javax.annotation.Nullable) LanguageClass(com.google.idea.blaze.base.model.primitives.LanguageClass) PerformanceWarning(com.google.idea.blaze.base.scope.output.PerformanceWarning) ImportRoots(com.google.idea.blaze.base.sync.projectview.ImportRoots) PrefetchFileSource(com.google.idea.blaze.base.prefetch.PrefetchFileSource) SyncState(com.google.idea.blaze.base.model.SyncState) Maps(com.google.common.collect.Maps) File(java.io.File) ExecutionException(java.util.concurrent.ExecutionException) BlazeExecutor(com.google.idea.blaze.base.async.executor.BlazeExecutor) AtomicLong(java.util.concurrent.atomic.AtomicLong) HashBiMap(com.google.common.collect.HashBiMap) Futures(com.google.common.util.concurrent.Futures) Ordering(com.google.common.collect.Ordering) BlazeVersionData(com.google.idea.blaze.base.model.BlazeVersionData) BlazeConfigurationHandler(com.google.idea.blaze.base.command.info.BlazeConfigurationHandler) TimingScope(com.google.idea.blaze.base.scope.scopes.TimingScope) BlazeFlags(com.google.idea.blaze.base.command.BlazeFlags) BlazeInvocationContext(com.google.idea.blaze.base.command.BlazeInvocationContext) BlazeCommand(com.google.idea.blaze.base.command.BlazeCommand) EventType(com.google.idea.blaze.base.scope.scopes.TimingScope.EventType) TimingScope(com.google.idea.blaze.base.scope.scopes.TimingScope) List(java.util.List) ShardedTargetList(com.google.idea.blaze.base.sync.sharding.ShardedTargetList) ArrayList(java.util.ArrayList) ImmutableList(com.google.common.collect.ImmutableList) File(java.io.File)

Example 25 with ProjectViewSet

use of com.google.idea.blaze.base.projectview.ProjectViewSet in project intellij by bazelbuild.

the class BlazeSyncTask method computeWorkspacePathResolverAndProjectView.

private WorkspacePathResolverAndProjectView computeWorkspacePathResolverAndProjectView(BlazeContext context, BlazeVcsHandler vcsHandler, ListeningExecutorService executor) {
    context.output(new StatusOutput("Updating VCS..."));
    for (int i = 0; i < 3; ++i) {
        WorkspacePathResolver vcsWorkspacePathResolver = null;
        BlazeVcsHandler.BlazeVcsSyncHandler vcsSyncHandler = vcsHandler.createSyncHandler(project, workspaceRoot);
        if (vcsSyncHandler != null) {
            boolean ok = Scope.push(context, (childContext) -> {
                childContext.push(new TimingScope("UpdateVcs", EventType.Other));
                return vcsSyncHandler.update(context, executor);
            });
            if (!ok) {
                return null;
            }
            vcsWorkspacePathResolver = vcsSyncHandler.getWorkspacePathResolver();
        }
        WorkspacePathResolver workspacePathResolver = vcsWorkspacePathResolver != null ? vcsWorkspacePathResolver : new WorkspacePathResolverImpl(workspaceRoot);
        ProjectViewSet projectViewSet = ProjectViewManager.getInstance(project).reloadProjectView(context, workspacePathResolver);
        if (projectViewSet == null) {
            return null;
        }
        if (vcsSyncHandler != null) {
            BlazeVcsHandler.BlazeVcsSyncHandler.ValidationResult validationResult = vcsSyncHandler.validateProjectView(context, projectViewSet);
            switch(validationResult) {
                case OK:
                    // Fall-through and return
                    break;
                case Error:
                    return null;
                case RestartSync:
                    continue;
                default:
                    // Cannot happen
                    return null;
            }
        }
        return new WorkspacePathResolverAndProjectView(workspacePathResolver, projectViewSet);
    }
    return null;
}
Also used : ProjectViewSet(com.google.idea.blaze.base.projectview.ProjectViewSet) TimingScope(com.google.idea.blaze.base.scope.scopes.TimingScope) WorkspacePathResolverImpl(com.google.idea.blaze.base.sync.workspace.WorkspacePathResolverImpl) StatusOutput(com.google.idea.blaze.base.scope.output.StatusOutput) WorkspacePathResolver(com.google.idea.blaze.base.sync.workspace.WorkspacePathResolver) BlazeVcsHandler(com.google.idea.blaze.base.vcs.BlazeVcsHandler)

Aggregations

ProjectViewSet (com.google.idea.blaze.base.projectview.ProjectViewSet)74 File (java.io.File)30 Test (org.junit.Test)29 WorkspaceLanguageSettings (com.google.idea.blaze.base.sync.projectview.WorkspaceLanguageSettings)21 WorkspacePath (com.google.idea.blaze.base.model.primitives.WorkspacePath)17 WorkspaceRoot (com.google.idea.blaze.base.model.primitives.WorkspaceRoot)17 ImmutableList (com.google.common.collect.ImmutableList)16 BlazeContext (com.google.idea.blaze.base.scope.BlazeContext)16 Project (com.intellij.openapi.project.Project)16 BlazeProjectData (com.google.idea.blaze.base.model.BlazeProjectData)15 Nullable (javax.annotation.Nullable)15 List (java.util.List)14 DirectoryEntry (com.google.idea.blaze.base.projectview.section.sections.DirectoryEntry)12 TargetIdeInfo (com.google.idea.blaze.base.ideinfo.TargetIdeInfo)11 TargetMap (com.google.idea.blaze.base.ideinfo.TargetMap)11 Kind (com.google.idea.blaze.base.model.primitives.Kind)11 ArtifactLocationDecoder (com.google.idea.blaze.base.sync.workspace.ArtifactLocationDecoder)11 Set (java.util.Set)11 Lists (com.google.common.collect.Lists)10 Collectors (java.util.stream.Collectors)10