Search in sources :

Example 1 with SyncMode

use of com.google.idea.blaze.base.sync.BlazeSyncParams.SyncMode in project intellij by bazelbuild.

the class JarCache 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;
    boolean enabled = updateEnabled();
    if (!enabled || fullRefresh) {
        clearCache();
    }
    if (!enabled) {
        return;
    }
    List<BlazeJarLibrary> jarLibraries = libraries.stream().filter(library -> library instanceof BlazeJarLibrary).map(library -> (BlazeJarLibrary) library).collect(Collectors.toList());
    ArtifactLocationDecoder artifactLocationDecoder = projectData.artifactLocationDecoder;
    BiMap<File, String> sourceFileToCacheKey = HashBiMap.create(jarLibraries.size());
    for (BlazeJarLibrary library : jarLibraries) {
        File jarFile = artifactLocationDecoder.decode(library.libraryArtifact.jarForIntellijLibrary());
        sourceFileToCacheKey.put(jarFile, cacheKeyForJar(jarFile));
        for (ArtifactLocation sourceJar : library.libraryArtifact.sourceJars) {
            File srcJarFile = artifactLocationDecoder.decode(sourceJar);
            sourceFileToCacheKey.put(srcJarFile, cacheKeyForSourceJar(srcJarFile));
        }
    }
    this.traits = new JarCacheSynchronizerTraits(cacheDir, sourceFileToCacheKey);
    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) 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) BlazeJarLibrary(com.google.idea.blaze.java.sync.model.BlazeJarLibrary) BlazeProjectData(com.google.idea.blaze.base.model.BlazeProjectData) Future(java.util.concurrent.Future) Lists(com.google.common.collect.Lists) ImmutableList(com.google.common.collect.ImmutableList) BlazeDataStorage(com.google.idea.blaze.base.sync.data.BlazeDataStorage) Map(java.util.Map) Project(com.intellij.openapi.project.Project) BlazeJavaUserSettings(com.google.idea.blaze.java.settings.BlazeJavaUserSettings) FileUtil(com.intellij.openapi.util.io.FileUtil) FileSizeScanner(com.google.idea.blaze.base.io.FileSizeScanner) Logger(com.intellij.openapi.diagnostic.Logger) Nullable(javax.annotation.Nullable) BiMap(com.google.common.collect.BiMap) ArtifactLocation(com.google.idea.blaze.base.ideinfo.ArtifactLocation) ImmutableMap(com.google.common.collect.ImmutableMap) 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) 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) ListeningExecutorService(com.google.common.util.concurrent.ListeningExecutorService) FileCacheSynchronizer(com.google.idea.blaze.base.filecache.FileCacheSynchronizer) BlazeJarLibrary(com.google.idea.blaze.java.sync.model.BlazeJarLibrary) BlazeLibrary(com.google.idea.blaze.base.model.BlazeLibrary) ArtifactLocation(com.google.idea.blaze.base.ideinfo.ArtifactLocation) ArtifactLocationDecoder(com.google.idea.blaze.base.sync.workspace.ArtifactLocationDecoder) File(java.io.File)

Example 2 with SyncMode

use of com.google.idea.blaze.base.sync.BlazeSyncParams.SyncMode 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)

Aggregations

Preconditions (com.google.common.base.Preconditions)2 BiMap (com.google.common.collect.BiMap)2 HashBiMap (com.google.common.collect.HashBiMap)2 ImmutableList (com.google.common.collect.ImmutableList)2 ListenableFuture (com.google.common.util.concurrent.ListenableFuture)2 ListeningExecutorService (com.google.common.util.concurrent.ListeningExecutorService)2 FileCache (com.google.idea.blaze.base.filecache.FileCache)2 FileCacheSynchronizer (com.google.idea.blaze.base.filecache.FileCacheSynchronizer)2 FileCacheSynchronizerTraits (com.google.idea.blaze.base.filecache.FileCacheSynchronizerTraits)2 BlazeLibrary (com.google.idea.blaze.base.model.BlazeLibrary)2 BlazeProjectData (com.google.idea.blaze.base.model.BlazeProjectData)2 ProjectViewSet (com.google.idea.blaze.base.projectview.ProjectViewSet)2 BlazeContext (com.google.idea.blaze.base.scope.BlazeContext)2 PrintOutput (com.google.idea.blaze.base.scope.output.PrintOutput)2 BlazeImportSettings (com.google.idea.blaze.base.settings.BlazeImportSettings)2 BlazeImportSettingsManager (com.google.idea.blaze.base.settings.BlazeImportSettingsManager)2 BlazeSyncParams (com.google.idea.blaze.base.sync.BlazeSyncParams)2 SyncMode (com.google.idea.blaze.base.sync.BlazeSyncParams.SyncMode)2 BlazeDataStorage (com.google.idea.blaze.base.sync.data.BlazeDataStorage)2 BlazeLibraryCollector (com.google.idea.blaze.base.sync.libraries.BlazeLibraryCollector)2