Search in sources :

Example 11 with WorkspaceLanguageSettings

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

the class BlazeIdeInterfaceAspectsImpl method updateState.

@Nullable
static State updateState(Project project, BlazeContext parentContext, @Nullable State prevState, ImmutableMap<File, Long> fileState, BlazeConfigurationHandler configHandler, WorkspaceLanguageSettings workspaceLanguageSettings, ImportRoots importRoots, AspectStrategy aspectStrategy, List<File> newFiles, List<File> removedFiles, boolean mergeWithOldState) {
    Result<State> result = Scope.push(parentContext, (ScopedFunction<Result<State>>) context -> {
        context.push(new TimingScope("UpdateTargetMap", EventType.Other));
        ImmutableMap<File, Long> nextFileState = fileState;
        if (mergeWithOldState && prevState != null) {
            ImmutableMap.Builder<File, Long> fileStateBuilder = ImmutableMap.<File, Long>builder().putAll(fileState);
            for (Map.Entry<File, Long> entry : prevState.fileState.entrySet()) {
                if (!fileState.containsKey(entry.getKey())) {
                    fileStateBuilder.put(entry);
                }
            }
            nextFileState = fileStateBuilder.build();
        }
        State state = new State();
        state.fileState = nextFileState;
        state.workspaceLanguageSettings = workspaceLanguageSettings;
        state.aspectStrategyName = aspectStrategy.getName();
        Map<TargetKey, TargetIdeInfo> targetMap = Maps.newHashMap();
        if (prevState != null) {
            targetMap.putAll(prevState.targetMap.map());
            state.fileToTargetMapKey.putAll(prevState.fileToTargetMapKey);
        }
        if (!mergeWithOldState) {
            for (File removedFile : removedFiles) {
                TargetKey key = state.fileToTargetMapKey.remove(removedFile);
                if (key != null) {
                    targetMap.remove(key);
                }
            }
        }
        AtomicLong totalSizeLoaded = new AtomicLong(0);
        Set<LanguageClass> ignoredLanguages = Sets.newConcurrentHashSet();
        ListeningExecutorService executor = BlazeExecutor.getInstance().getExecutor();
        List<ListenableFuture<TargetFilePair>> futures = Lists.newArrayList();
        for (File file : newFiles) {
            futures.add(executor.submit(() -> {
                totalSizeLoaded.addAndGet(file.length());
                IntellijIdeInfo.TargetIdeInfo message = aspectStrategy.readAspectFile(file);
                TargetIdeInfo target = protoToTarget(workspaceLanguageSettings, importRoots, message, ignoredLanguages);
                return new TargetFilePair(file, target);
            }));
        }
        Set<TargetKey> newTargets = new HashSet<>();
        Set<String> configurations = new LinkedHashSet<>();
        configurations.add(configHandler.defaultConfigurationPathComponent);
        int duplicateTargetLabels = 0;
        try {
            for (TargetFilePair targetFilePair : Futures.allAsList(futures).get()) {
                if (targetFilePair.target != null) {
                    File file = targetFilePair.file;
                    String config = configHandler.getConfigurationPathComponent(file);
                    configurations.add(config);
                    TargetKey key = targetFilePair.target.key;
                    if (targetMap.putIfAbsent(key, targetFilePair.target) == null) {
                        state.fileToTargetMapKey.forcePut(file, key);
                    } else {
                        if (!newTargets.add(key)) {
                            duplicateTargetLabels++;
                        }
                        if (Objects.equals(config, configHandler.defaultConfigurationPathComponent)) {
                            targetMap.put(key, targetFilePair.target);
                            state.fileToTargetMapKey.forcePut(file, key);
                        }
                    }
                }
            }
        } catch (InterruptedException e) {
            Thread.currentThread().interrupt();
            return Result.error(null);
        } catch (ExecutionException e) {
            return Result.error(e);
        }
        context.output(PrintOutput.log(String.format("Loaded %d aspect files, total size %dkB", newFiles.size(), totalSizeLoaded.get() / 1024)));
        if (duplicateTargetLabels > 0) {
            context.output(new PerformanceWarning(String.format("There were %d duplicate rules, built with the following " + "configurations: %s.\nYour IDE sync is slowed down by ~%d%%.", duplicateTargetLabels, configurations, (100 * duplicateTargetLabels / targetMap.size()))));
        }
        ignoredLanguages.retainAll(LanguageSupport.availableAdditionalLanguages(workspaceLanguageSettings.getWorkspaceType()));
        warnIgnoredLanguages(project, context, ignoredLanguages);
        state.targetMap = new TargetMap(ImmutableMap.copyOf(targetMap));
        return Result.of(state);
    });
    if (result.error != null) {
        logger.error(result.error);
        return null;
    }
    return result.result;
}
Also used : 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) ImmutableSet(com.google.common.collect.ImmutableSet) Set(java.util.Set) ProjectViewSet(com.google.idea.blaze.base.projectview.ProjectViewSet) HashSet(java.util.HashSet) LinkedHashSet(java.util.LinkedHashSet) PerformanceWarning(com.google.idea.blaze.base.scope.output.PerformanceWarning) Result(com.google.idea.blaze.base.scope.Result) 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) ExecutionException(java.util.concurrent.ExecutionException) ImmutableMap(com.google.common.collect.ImmutableMap) TargetIdeInfo(com.google.idea.blaze.base.ideinfo.TargetIdeInfo) AtomicLong(java.util.concurrent.atomic.AtomicLong) SyncState(com.google.idea.blaze.base.model.SyncState) IntellijIdeInfo(com.google.devtools.intellij.ideinfo.IntellijIdeInfo) AtomicLong(java.util.concurrent.atomic.AtomicLong) ListeningExecutorService(com.google.common.util.concurrent.ListeningExecutorService) TargetKey(com.google.idea.blaze.base.ideinfo.TargetKey) File(java.io.File) Map(java.util.Map) BiMap(com.google.common.collect.BiMap) ImmutableMap(com.google.common.collect.ImmutableMap) TargetMap(com.google.idea.blaze.base.ideinfo.TargetMap) HashBiMap(com.google.common.collect.HashBiMap) TargetMap(com.google.idea.blaze.base.ideinfo.TargetMap) Nullable(javax.annotation.Nullable)

Example 12 with WorkspaceLanguageSettings

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

the class BlazeAndroidWorkspaceImporterTest method testIdlClassJarIsAddedAsLibrary.

@Test
public void testIdlClassJarIsAddedAsLibrary() {
    ProjectView projectView = ProjectView.builder().add(ListSection.builder(DirectorySection.KEY).add(DirectoryEntry.include(new WorkspacePath("example")))).build();
    TargetMapBuilder targetMapBuilder = TargetMapBuilder.builder().addTarget(TargetIdeInfo.builder().setLabel("//example:lib").setBuildFile(source("example/BUILD")).setKind("android_binary").addSource(source("example/MainActivity.java")).setAndroidInfo(AndroidIdeInfo.builder().setResourceJavaPackage("example").setIdlJar(LibraryArtifact.builder().setInterfaceJar(gen("example/libidl.jar")).addSourceJar(gen("example/libidl.srcjar")).build()).setHasIdlSources(true)));
    TargetMap targetMap = targetMapBuilder.build();
    BlazeAndroidJavaSyncAugmenter syncAugmenter = new BlazeAndroidJavaSyncAugmenter();
    List<BlazeJarLibrary> jars = Lists.newArrayList();
    List<BlazeJarLibrary> genJars = Lists.newArrayList();
    ImportRoots importRoots = ImportRoots.builder(workspaceRoot, BuildSystem.Blaze).add(ProjectViewSet.builder().add(projectView).build()).build();
    ProjectViewSet projectViewSet = ProjectViewSet.builder().add(projectView).build();
    for (TargetIdeInfo target : targetMap.targets()) {
        if (importRoots.importAsSource(target.key.label)) {
            syncAugmenter.addJarsForSourceTarget(workspaceLanguageSettings, projectViewSet, target, jars, genJars);
        }
    }
    assertThat(genJars.stream().map(library -> library.libraryArtifact.interfaceJar).map(artifactLocation -> new File(artifactLocation.relativePath).getName()).collect(Collectors.toList())).containsExactly("libidl.jar");
}
Also used : WorkspacePath(com.google.idea.blaze.base.model.primitives.WorkspacePath) ProjectViewSet(com.google.idea.blaze.base.projectview.ProjectViewSet) TargetIdeInfo(com.google.idea.blaze.base.ideinfo.TargetIdeInfo) GeneratedAndroidResourcesSection(com.google.idea.blaze.android.projectview.GeneratedAndroidResourcesSection) BlazeAndroidJavaSyncAugmenter(com.google.idea.blaze.android.sync.BlazeAndroidJavaSyncAugmenter) PrefetchService(com.google.idea.blaze.base.prefetch.PrefetchService) JavaWorkingSet(com.google.idea.blaze.java.sync.workingset.JavaWorkingSet) WorkingSet(com.google.idea.blaze.base.sync.workspace.WorkingSet) JavaLikeLanguage(com.google.idea.blaze.java.sync.source.JavaLikeLanguage) BlazeAndroidLibrarySource(com.google.idea.blaze.android.sync.BlazeAndroidLibrarySource) JavaSourceFilter(com.google.idea.blaze.java.sync.importer.JavaSourceFilter) ImmutableSet(com.google.common.collect.ImmutableSet) AndroidResourceModule(com.google.idea.blaze.android.sync.model.AndroidResourceModule) Predicate(java.util.function.Predicate) ProjectView(com.google.idea.blaze.base.projectview.ProjectView) WorkspaceLanguageSettings(com.google.idea.blaze.base.sync.projectview.WorkspaceLanguageSettings) Collectors(java.util.stream.Collectors) FileOperationProvider(com.google.idea.blaze.base.io.FileOperationProvider) BlazeAndroidImportResult(com.google.idea.blaze.android.sync.model.BlazeAndroidImportResult) SourceArtifact(com.google.idea.blaze.java.sync.source.SourceArtifact) List(java.util.List) ErrorCollector(com.google.idea.blaze.base.scope.ErrorCollector) 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) ArtifactLocationDecoder(com.google.idea.blaze.base.sync.workspace.ArtifactLocationDecoder) TargetMap(com.google.idea.blaze.base.ideinfo.TargetMap) TargetMapBuilder(com.google.idea.blaze.base.ideinfo.TargetMapBuilder) BlazeContext(com.google.idea.blaze.base.scope.BlazeContext) JavaSourcePackageReader(com.google.idea.blaze.java.sync.source.JavaSourcePackageReader) PackageManifestReader(com.google.idea.blaze.java.sync.source.PackageManifestReader) LibraryArtifact(com.google.idea.blaze.base.ideinfo.LibraryArtifact) DirectorySection(com.google.idea.blaze.base.projectview.section.sections.DirectorySection) RunWith(org.junit.runner.RunWith) BlazeJavaWorkspaceImporter(com.google.idea.blaze.java.sync.importer.BlazeJavaWorkspaceImporter) MockJdepsMap(com.google.idea.blaze.java.sync.jdeps.MockJdepsMap) JavaIdeInfo(com.google.idea.blaze.base.ideinfo.JavaIdeInfo) BlazeJavaImportResult(com.google.idea.blaze.java.sync.model.BlazeJavaImportResult) ExperimentService(com.google.idea.common.experiments.ExperimentService) BlazeResourceLibrary(com.google.idea.blaze.android.sync.model.BlazeResourceLibrary) MockBlazeExecutor(com.google.idea.blaze.base.async.executor.MockBlazeExecutor) AndroidIdeInfo(com.google.idea.blaze.base.ideinfo.AndroidIdeInfo) Kind(com.google.idea.blaze.base.model.primitives.Kind) BlazeJarLibrary(com.google.idea.blaze.java.sync.model.BlazeJarLibrary) WorkspaceType(com.google.idea.blaze.base.model.primitives.WorkspaceType) Lists(com.google.common.collect.Lists) ImmutableList(com.google.common.collect.ImmutableList) BuildSystem(com.google.idea.blaze.base.settings.Blaze.BuildSystem) AarLibrary(com.google.idea.blaze.android.sync.model.AarLibrary) IssueOutput(com.google.idea.blaze.base.scope.output.IssueOutput) TargetIdeInfo(com.google.idea.blaze.base.ideinfo.TargetIdeInfo) Nullable(javax.annotation.Nullable) LanguageClass(com.google.idea.blaze.base.model.primitives.LanguageClass) ImportRoots(com.google.idea.blaze.base.sync.projectview.ImportRoots) ArtifactLocation(com.google.idea.blaze.base.ideinfo.ArtifactLocation) BlazeTestCase(com.google.idea.blaze.base.BlazeTestCase) BlazeImportSettingsManager(com.google.idea.blaze.base.settings.BlazeImportSettingsManager) Test(org.junit.Test) JUnit4(org.junit.runners.JUnit4) Truth.assertThat(com.google.common.truth.Truth.assertThat) AndroidAarIdeInfo(com.google.idea.blaze.base.ideinfo.AndroidAarIdeInfo) MockPrefetchService(com.google.idea.blaze.base.prefetch.MockPrefetchService) BlazeJavaSyncAugmenter(com.google.idea.blaze.java.sync.BlazeJavaSyncAugmenter) File(java.io.File) BlazeImportSettings(com.google.idea.blaze.base.settings.BlazeImportSettings) BlazeExecutor(com.google.idea.blaze.base.async.executor.BlazeExecutor) DirectoryEntry(com.google.idea.blaze.base.projectview.section.sections.DirectoryEntry) Label(com.google.idea.blaze.base.model.primitives.Label) MockExperimentService(com.google.idea.common.experiments.MockExperimentService) GenfilesPath(com.google.idea.blaze.android.projectview.GenfilesPath) WorkspacePath(com.google.idea.blaze.base.model.primitives.WorkspacePath) ListSection(com.google.idea.blaze.base.projectview.section.ListSection) ImportRoots(com.google.idea.blaze.base.sync.projectview.ImportRoots) BlazeAndroidJavaSyncAugmenter(com.google.idea.blaze.android.sync.BlazeAndroidJavaSyncAugmenter) TargetMapBuilder(com.google.idea.blaze.base.ideinfo.TargetMapBuilder) BlazeJarLibrary(com.google.idea.blaze.java.sync.model.BlazeJarLibrary) ProjectView(com.google.idea.blaze.base.projectview.ProjectView) File(java.io.File) TargetMap(com.google.idea.blaze.base.ideinfo.TargetMap) Test(org.junit.Test)

Example 13 with WorkspaceLanguageSettings

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

the class KotlinSyncTest method testSimpleSync.

@Test
public void testSimpleSync() {
    setProjectView("directories:", "  src/main/kotlin/com/google", "targets:", "  //src/main/kotlin/com/google:lib", "additional_languages:", "  kotlin");
    workspace.createFile(new WorkspacePath("src/main/kotlin/com/google/Source.kt"), "package com.google;", "public class Source {}");
    workspace.createFile(new WorkspacePath("src/main/kotlin/com/google/Other.kt"), "package com.google;", "public class Other {}");
    workspace.createDirectory(new WorkspacePath("external/com_github_jetbrains_kotlin"));
    TargetMap targetMap = TargetMapBuilder.builder().addTarget(TargetIdeInfo.builder().setBuildFile(sourceRoot("src/main/kotlin/com/google/BUILD")).setLabel("//src/main/kotlin/com/google:lib").setKind("kt_jvm_library").addSource(sourceRoot("src/main/kotlin/com/google/Source.kotlin")).addSource(sourceRoot("src/main/kotlin/com/google/Other.kotlin")).setJavaInfo(JavaIdeInfo.builder())).build();
    setTargetMap(targetMap);
    runBlazeSync(new BlazeSyncParams.Builder("Sync", BlazeSyncParams.SyncMode.INCREMENTAL).addProjectViewTargets(true).build());
    BlazeProjectData blazeProjectData = BlazeProjectDataManager.getInstance(getProject()).getBlazeProjectData();
    assertThat(blazeProjectData).isNotNull();
    assertThat(blazeProjectData.targetMap).isEqualTo(targetMap);
    assertThat(blazeProjectData.workspaceLanguageSettings).isEqualTo(new WorkspaceLanguageSettings(WorkspaceType.JAVA, ImmutableSet.of(LanguageClass.GENERIC, LanguageClass.KOTLIN, LanguageClass.JAVA)));
}
Also used : WorkspacePath(com.google.idea.blaze.base.model.primitives.WorkspacePath) BlazeProjectData(com.google.idea.blaze.base.model.BlazeProjectData) WorkspaceLanguageSettings(com.google.idea.blaze.base.sync.projectview.WorkspaceLanguageSettings) TargetMap(com.google.idea.blaze.base.ideinfo.TargetMap) BlazeSyncParams(com.google.idea.blaze.base.sync.BlazeSyncParams) Test(org.junit.Test)

Example 14 with WorkspaceLanguageSettings

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

the class MockBlazeProjectDataBuilder method build.

public BlazeProjectData build() {
    TargetMap targetMap = this.targetMap != null ? this.targetMap : new TargetMap(ImmutableMap.of());
    BlazeInfo blazeInfo = this.blazeInfo;
    if (blazeInfo == null) {
        String outputBase = this.outputBase != null ? this.outputBase : "/usr/workspace/1234";
        blazeInfo = BlazeInfo.createMockBlazeInfo(outputBase, outputBase + "/execroot", outputBase + "/execroot/bin", outputBase + "/execroot/gen");
    }
    BlazeVersionData blazeVersionData = this.blazeVersionData != null ? this.blazeVersionData : BlazeVersionData.builder().build();
    WorkspacePathResolver workspacePathResolver = this.workspacePathResolver != null ? this.workspacePathResolver : new WorkspacePathResolverImpl(workspaceRoot);
    ArtifactLocationDecoder artifactLocationDecoder = this.artifactLocationDecoder != null ? this.artifactLocationDecoder : new ArtifactLocationDecoderImpl(blazeInfo, workspacePathResolver);
    WorkspaceLanguageSettings workspaceLanguageSettings = this.workspaceLanguageSettings != null ? this.workspaceLanguageSettings : new WorkspaceLanguageSettings(WorkspaceType.JAVA, ImmutableSet.of());
    SyncState syncState = this.syncState != null ? this.syncState : new SyncState(ImmutableMap.of());
    ImmutableMultimap<TargetKey, TargetKey> reverseDependencies = this.reverseDependencies != null ? this.reverseDependencies : ImmutableMultimap.of();
    return new BlazeProjectData(syncTime, targetMap, blazeInfo, blazeVersionData, workspacePathResolver, artifactLocationDecoder, workspaceLanguageSettings, syncState, reverseDependencies);
}
Also used : BlazeInfo(com.google.idea.blaze.base.command.info.BlazeInfo) WorkspacePathResolverImpl(com.google.idea.blaze.base.sync.workspace.WorkspacePathResolverImpl) ArtifactLocationDecoder(com.google.idea.blaze.base.sync.workspace.ArtifactLocationDecoder) WorkspacePathResolver(com.google.idea.blaze.base.sync.workspace.WorkspacePathResolver) ArtifactLocationDecoderImpl(com.google.idea.blaze.base.sync.workspace.ArtifactLocationDecoderImpl) WorkspaceLanguageSettings(com.google.idea.blaze.base.sync.projectview.WorkspaceLanguageSettings) TargetKey(com.google.idea.blaze.base.ideinfo.TargetKey) TargetMap(com.google.idea.blaze.base.ideinfo.TargetMap)

Example 15 with WorkspaceLanguageSettings

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

the class LanguageSupportTest method testSimpleCase.

@Test
public void testSimpleCase() {
    syncPlugins.registerExtension(new BlazeSyncPlugin() {

        @Override
        public Set<LanguageClass> getSupportedLanguagesInWorkspace(WorkspaceType workspaceType) {
            return ImmutableSet.of(LanguageClass.C);
        }

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

        @Override
        public WorkspaceType getDefaultWorkspaceType() {
            return WorkspaceType.C;
        }
    });
    ProjectViewSet projectViewSet = ProjectViewSet.builder().add(ProjectView.builder().add(ScalarSection.builder(WorkspaceTypeSection.KEY).set(WorkspaceType.C)).build()).build();
    WorkspaceLanguageSettings workspaceLanguageSettings = LanguageSupport.createWorkspaceLanguageSettings(projectViewSet);
    errorCollector.assertNoIssues();
    assertThat(workspaceLanguageSettings).isEqualTo(new WorkspaceLanguageSettings(WorkspaceType.C, ImmutableSet.of(LanguageClass.C, LanguageClass.GENERIC)));
}
Also used : ProjectViewSet(com.google.idea.blaze.base.projectview.ProjectViewSet) WorkspaceType(com.google.idea.blaze.base.model.primitives.WorkspaceType) ImmutableSet(com.google.common.collect.ImmutableSet) Set(java.util.Set) ProjectViewSet(com.google.idea.blaze.base.projectview.ProjectViewSet) ImmutableList(com.google.common.collect.ImmutableList) WorkspaceLanguageSettings(com.google.idea.blaze.base.sync.projectview.WorkspaceLanguageSettings) Test(org.junit.Test)

Aggregations

WorkspaceLanguageSettings (com.google.idea.blaze.base.sync.projectview.WorkspaceLanguageSettings)33 Test (org.junit.Test)28 ProjectViewSet (com.google.idea.blaze.base.projectview.ProjectViewSet)20 TargetMap (com.google.idea.blaze.base.ideinfo.TargetMap)17 BlazeProjectData (com.google.idea.blaze.base.model.BlazeProjectData)13 WorkspacePath (com.google.idea.blaze.base.model.primitives.WorkspacePath)13 ImmutableList (com.google.common.collect.ImmutableList)7 ImmutableSet (com.google.common.collect.ImmutableSet)7 WorkspaceType (com.google.idea.blaze.base.model.primitives.WorkspaceType)7 MockBlazeProjectDataManager (com.google.idea.blaze.base.model.MockBlazeProjectDataManager)6 LanguageClass (com.google.idea.blaze.base.model.primitives.LanguageClass)6 ArtifactLocationDecoder (com.google.idea.blaze.base.sync.workspace.ArtifactLocationDecoder)6 WorkspacePathResolverImpl (com.google.idea.blaze.base.sync.workspace.WorkspacePathResolverImpl)6 TargetIdeInfo (com.google.idea.blaze.base.ideinfo.TargetIdeInfo)5 TargetKey (com.google.idea.blaze.base.ideinfo.TargetKey)5 TargetMapBuilder (com.google.idea.blaze.base.ideinfo.TargetMapBuilder)5 GoFile (com.goide.psi.GoFile)4 LibraryArtifact (com.google.idea.blaze.base.ideinfo.LibraryArtifact)4 WorkspaceRoot (com.google.idea.blaze.base.model.primitives.WorkspaceRoot)4 PrefetchService (com.google.idea.blaze.base.prefetch.PrefetchService)4