use of com.google.idea.blaze.base.io.FileOperationProvider in project intellij by bazelbuild.
the class PrefetchServiceImpl method prefetchFiles.
private ListenableFuture<?> prefetchFiles(Project project, Set<File> excludeDirectories, Collection<File> files, boolean refetchCachedFiles, boolean fetchFileTypes) {
if (files.isEmpty() || !enabled(project)) {
return Futures.immediateFuture(null);
}
if (!refetchCachedFiles) {
long startTime = System.currentTimeMillis();
// ignore recently fetched files
files = files.stream().filter(file -> shouldPrefetch(file, startTime)).collect(Collectors.toList());
}
FileOperationProvider provider = FileOperationProvider.getInstance();
List<ListenableFuture<File>> canonicalFiles = files.stream().map(file -> FetchExecutor.EXECUTOR.submit(() -> toCanonicalFile(provider, file))).collect(Collectors.toList());
List<ListenableFuture<?>> futures = Lists.newArrayList();
for (Prefetcher prefetcher : Prefetcher.EP_NAME.getExtensions()) {
futures.add(prefetcher.prefetchFiles(project, excludeDirectories, canonicalFiles, FetchExecutor.EXECUTOR, fetchFileTypes));
}
return Futures.allAsList(futures);
}
use of com.google.idea.blaze.base.io.FileOperationProvider in project intellij by bazelbuild.
the class BlazeIdeInterfaceAspectsImplTest method initTest.
@Override
protected void initTest(Container applicationServices, Container projectServices) {
super.initTest(applicationServices, projectServices);
applicationServices.register(ExperimentService.class, new MockExperimentService());
applicationServices.register(FileOperationProvider.class, new FileOperationProvider());
}
use of com.google.idea.blaze.base.io.FileOperationProvider in project intellij by bazelbuild.
the class UnpackedAars method clearCache.
private void clearCache() {
FileOperationProvider fileOperationProvider = FileOperationProvider.getInstance();
if (fileOperationProvider.exists(cacheDir)) {
try {
fileOperationProvider.deleteRecursively(cacheDir);
} catch (IOException e) {
logger.warn("Failed to clear unpacked AAR directory: " + cacheDir, e);
}
}
aarTraits = null;
jarTraits = null;
}
use of com.google.idea.blaze.base.io.FileOperationProvider in project intellij by bazelbuild.
the class UnpackedAars method refresh.
private void refresh(@Nullable BlazeContext context, boolean removeMissingFiles) {
if (!enabled || jarTraits == null || aarTraits == null) {
return;
}
FileOperationProvider fileOpProvider = FileOperationProvider.getInstance();
// Ensure the cache dir exists
if (!fileOpProvider.exists(cacheDir)) {
if (!fileOpProvider.mkdirs(cacheDir)) {
logger.warn("Could not create unpacked AAR directory: " + cacheDir);
return;
}
}
FileCacheSynchronizer aarSynchronizer = new FileCacheSynchronizer(aarTraits);
if (!aarSynchronizer.synchronize(context, removeMissingFiles)) {
logger.warn("Unpacked AAR synchronization didn't complete");
}
FileCacheSynchronizer aarJarSynchronizer = new FileCacheSynchronizer(jarTraits);
if (!aarJarSynchronizer.synchronize(context, removeMissingFiles)) {
logger.warn("Unpacked AAR jar synchronization didn't complete");
}
}
use of com.google.idea.blaze.base.io.FileOperationProvider in project intellij by bazelbuild.
the class BuildReferenceManager method findBuildFile.
@Nullable
public BuildFile findBuildFile(@Nullable File packageDirectory) {
FileOperationProvider provider = FileOperationProvider.getInstance();
if (packageDirectory == null || !provider.isDirectory(packageDirectory)) {
return null;
}
VirtualFile vf = VirtualFileSystemProvider.getInstance().getSystem().findFileByPath(packageDirectory.getPath());
if (vf == null) {
return null;
}
VirtualFile buildFile = Blaze.getBuildSystemProvider(project).findBuildFileInDirectory(vf);
if (buildFile == null) {
return null;
}
PsiFile psiFile = PsiManager.getInstance(project).findFile(buildFile);
return psiFile instanceof BuildFile ? (BuildFile) psiFile : null;
}
Aggregations