Search in sources :

Example 46 with ProjectViewSet

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

the class BlazeAndroidTestRunConfigurationHandler 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.TEST);
    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 47 with ProjectViewSet

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

the class UnpackedAars method onSync.

void onSync(BlazeContext context, ProjectViewSet projectViewSet, BlazeProjectData projectData, BlazeSyncParams.SyncMode syncMode) {
    Collection<BlazeLibrary> libraries = BlazeLibraryCollector.getLibraries(projectViewSet, projectData);
    boolean fullRefresh = syncMode == SyncMode.FULL;
    boolean removeMissingFiles = syncMode == SyncMode.INCREMENTAL;
    if (!enabled || fullRefresh) {
        clearCache();
    }
    if (!enabled) {
        return;
    }
    List<AarLibrary> aarLibraries = libraries.stream().filter(library -> library instanceof AarLibrary).map(library -> (AarLibrary) library).collect(Collectors.toList());
    ArtifactLocationDecoder artifactLocationDecoder = projectData.artifactLocationDecoder;
    BiMap<File, String> sourceAarFileToCacheKey = HashBiMap.create(aarLibraries.size());
    BiMap<File, String> sourceJarFileToCacheKey = HashBiMap.create(aarLibraries.size());
    for (AarLibrary library : aarLibraries) {
        File aarFile = artifactLocationDecoder.decode(library.aarArtifact);
        String cacheKey = cacheKeyForAar(aarFile);
        sourceAarFileToCacheKey.put(aarFile, cacheKey);
        File jarFile = artifactLocationDecoder.decode(library.libraryArtifact.jarForIntellijLibrary());
        // Use the aar key for the jar as well.
        sourceJarFileToCacheKey.put(jarFile, cacheKey);
    }
    this.aarTraits = new AarTraits(cacheDir, sourceAarFileToCacheKey);
    this.jarTraits = new JarTraits(cacheDir, sourceJarFileToCacheKey);
    refresh(context, removeMissingFiles);
}
Also used : SyncMode(com.google.idea.blaze.base.sync.BlazeSyncParams.SyncMode) BlazeContext(com.google.idea.blaze.base.scope.BlazeContext) ListenableFuture(com.google.common.util.concurrent.ListenableFuture) SdkConstants(com.android.SdkConstants) BlazeLibrary(com.google.idea.blaze.base.model.BlazeLibrary) StandardCopyOption(java.nio.file.StandardCopyOption) ArrayList(java.util.ArrayList) FileCache(com.google.idea.blaze.base.filecache.FileCache) BlazeSyncParams(com.google.idea.blaze.base.sync.BlazeSyncParams) BlazeProjectData(com.google.idea.blaze.base.model.BlazeProjectData) ImmutableList(com.google.common.collect.ImmutableList) BlazeDataStorage(com.google.idea.blaze.base.sync.data.BlazeDataStorage) Map(java.util.Map) AarLibrary(com.google.idea.blaze.android.sync.model.AarLibrary) Project(com.intellij.openapi.project.Project) FileUtil(com.intellij.openapi.util.io.FileUtil) Logger(com.intellij.openapi.diagnostic.Logger) Nullable(javax.annotation.Nullable) BiMap(com.google.common.collect.BiMap) Files(java.nio.file.Files) BlazeLibraryCollector(com.google.idea.blaze.base.sync.libraries.BlazeLibraryCollector) Collection(java.util.Collection) BlazeImportSettingsManager(com.google.idea.blaze.base.settings.BlazeImportSettingsManager) IOException(java.io.IOException) PrintOutput(com.google.idea.blaze.base.scope.output.PrintOutput) Collectors(java.util.stream.Collectors) FileOperationProvider(com.google.idea.blaze.base.io.FileOperationProvider) File(java.io.File) BlazeImportSettings(com.google.idea.blaze.base.settings.BlazeImportSettings) HashBiMap(com.google.common.collect.HashBiMap) List(java.util.List) ServiceManager(com.intellij.openapi.components.ServiceManager) FileCacheSynchronizerTraits(com.google.idea.blaze.base.filecache.FileCacheSynchronizerTraits) Paths(java.nio.file.Paths) ProjectViewSet(com.google.idea.blaze.base.projectview.ProjectViewSet) ApplicationManager(com.intellij.openapi.application.ApplicationManager) Preconditions(com.google.common.base.Preconditions) ArtifactLocationDecoder(com.google.idea.blaze.base.sync.workspace.ArtifactLocationDecoder) ZipUtil(com.intellij.util.io.ZipUtil) ListeningExecutorService(com.google.common.util.concurrent.ListeningExecutorService) FileCacheSynchronizer(com.google.idea.blaze.base.filecache.FileCacheSynchronizer) AarLibrary(com.google.idea.blaze.android.sync.model.AarLibrary) BlazeLibrary(com.google.idea.blaze.base.model.BlazeLibrary) ArtifactLocationDecoder(com.google.idea.blaze.base.sync.workspace.ArtifactLocationDecoder) File(java.io.File)

Example 48 with ProjectViewSet

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

the class ProjectViewParserTest method testRootDirectory.

@Test
public void testRootDirectory() throws Exception {
    projectViewStorageManager.add(".blazeproject", "directories:", "  .", "  -java/com/google/android/notme", "", "targets:", "  //java/com/google:all");
    projectViewParser.parseProjectView(new File(".blazeproject"));
    errorCollector.assertNoIssues();
    ProjectViewSet projectViewSet = projectViewParser.getResult();
    ProjectViewSet.ProjectViewFile projectViewFile = projectViewSet.getTopLevelProjectViewFile();
    assertThat(projectViewFile).isNotNull();
    assertThat(projectViewFile.projectViewFile).isEqualTo(new File(".blazeproject"));
    assertThat(projectViewSet.getProjectViewFiles()).containsExactly(projectViewFile);
    ProjectView projectView = projectViewFile.projectView;
    assertThat(projectView.getSectionsOfType(DirectorySection.KEY).get(0).items()).containsExactly(new DirectoryEntry(new WorkspacePath(""), true), new DirectoryEntry(new WorkspacePath("java/com/google/android/notme"), false));
    assertThat(projectView.getSectionsOfType(TargetSection.KEY).get(0).items()).containsExactly(TargetExpression.fromStringSafe("//java/com/google:all"));
    String text = ProjectViewParser.projectViewToString(projectView);
    assertThat(text).isEqualTo(Joiner.on('\n').join("directories:", "  .", "  -java/com/google/android/notme", "", "targets:", "  //java/com/google:all"));
}
Also used : ProjectViewSet(com.google.idea.blaze.base.projectview.ProjectViewSet) WorkspacePath(com.google.idea.blaze.base.model.primitives.WorkspacePath) ProjectView(com.google.idea.blaze.base.projectview.ProjectView) DirectoryEntry(com.google.idea.blaze.base.projectview.section.sections.DirectoryEntry) File(java.io.File) Test(org.junit.Test)

Example 49 with ProjectViewSet

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

the class ProjectViewParserTest method testTestSources.

@Test
public void testTestSources() throws Exception {
    projectViewStorageManager.add(".blazeproject", "test_sources:", "  javatests/com/google", "  javatests/com/google/android/*");
    projectViewParser.parseProjectView(new File(".blazeproject"));
    errorCollector.assertNoIssues();
    ProjectViewSet projectViewSet = projectViewParser.getResult();
    Collection<Glob> entries = projectViewSet.listItems(TestSourceSection.KEY);
    assertThat(entries).containsExactly(new Glob("javatests/com/google"), new Glob("javatests/com/google/android/*")).inOrder();
}
Also used : ProjectViewSet(com.google.idea.blaze.base.projectview.ProjectViewSet) Glob(com.google.idea.blaze.base.projectview.section.Glob) File(java.io.File) Test(org.junit.Test)

Example 50 with ProjectViewSet

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

the class ProjectViewParserTest method testImport.

@Test
public void testImport() {
    projectViewStorageManager.add("/parent.blazeproject", "directories:", "  parent", "");
    projectViewStorageManager.add(".blazeproject", "import parent.blazeproject", "directories:", "  child", "");
    projectViewParser.parseProjectView(new File(".blazeproject"));
    errorCollector.assertNoIssues();
    ProjectViewSet projectViewSet = projectViewParser.getResult();
    assertThat(projectViewSet.getProjectViewFiles()).hasSize(2);
    Collection<DirectoryEntry> entries = projectViewSet.listItems(DirectorySection.KEY);
    assertThat(entries).containsExactly(new DirectoryEntry(new WorkspacePath("parent"), true), new DirectoryEntry(new WorkspacePath("child"), true));
}
Also used : ProjectViewSet(com.google.idea.blaze.base.projectview.ProjectViewSet) WorkspacePath(com.google.idea.blaze.base.model.primitives.WorkspacePath) DirectoryEntry(com.google.idea.blaze.base.projectview.section.sections.DirectoryEntry) File(java.io.File) Test(org.junit.Test)

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