use of com.intellij.openapi.vfs.LocalFileSystem in project android by JetBrains.
the class AndroidJniFolderNode method contains.
@Override
public boolean contains(@NotNull VirtualFile file) {
Collection<File> sourceFolders = getModel().getSelectedVariant().getSourceFolders();
LocalFileSystem fileSystem = LocalFileSystem.getInstance();
for (File folder : sourceFolders) {
VirtualFile virtualFile = fileSystem.findFileByIoFile(folder);
if (virtualFile != null && isAncestor(virtualFile, file, false)) {
return true;
}
}
return false;
}
use of com.intellij.openapi.vfs.LocalFileSystem in project android by JetBrains.
the class TemplateTest method ignored_testTemplateFormatting.
// This test is broken after the IntelliJ 2016.2.4 merge; investigate
// whether this is legitimate or whether it's due to changed formatting
// preferences in the platform
public void ignored_testTemplateFormatting() throws Exception {
Template template = Template.createFromPath(new File(getTestDataPath(), FileUtil.join("templates", "TestTemplate")).getCanonicalFile());
RenderingContext context = RenderingContext.Builder.newContext(template, myFixture.getProject()).withOutputRoot(new File(myFixture.getTempDirPath())).withModuleRoot(new File("dummy")).build();
template.render(context);
FileDocumentManager.getInstance().saveAllDocuments();
LocalFileSystem fileSystem = LocalFileSystem.getInstance();
VirtualFile desired = fileSystem.findFileByIoFile(new File(getTestDataPath(), FileUtil.join("templates", "TestTemplate", "MergedStringsFile.xml")));
VirtualFile actual = fileSystem.findFileByIoFile(new File(myFixture.getTempDirPath(), FileUtil.join("values", "TestTargetResourceFile.xml")));
desired.refresh(false, false);
actual.refresh(false, false);
PlatformTestUtil.assertFilesEqual(desired, actual);
}
use of com.intellij.openapi.vfs.LocalFileSystem in project android by JetBrains.
the class GradleEditorParserTest method purgeGradleConfig.
/**
* Recursively removes all gradle config files from the given dir.
*
* @param rootDir target root dir
* @throws IOException in case of unexpected I/O exception occurred during processing
*/
private void purgeGradleConfig(@NotNull VirtualFile rootDir) throws IOException {
final List<VirtualFile> toRemove = Lists.newArrayList();
VfsUtil.processFileRecursivelyWithoutIgnored(rootDir, new Processor<VirtualFile>() {
@Override
public boolean process(VirtualFile file) {
if (file.getName().endsWith(SdkConstants.DOT_GRADLE)) {
toRemove.add(file);
}
return true;
}
});
if (toRemove.isEmpty()) {
return;
}
LocalFileSystem fileSystem = LocalFileSystem.getInstance();
for (VirtualFile file : toRemove) {
fileSystem.deleteFile(this, file);
}
}
use of com.intellij.openapi.vfs.LocalFileSystem in project intellij-plugins by JetBrains.
the class JstdDebuggingFileFinderProvider method addAllRemoteUrlMappings.
private void addAllRemoteUrlMappings(@NotNull Collection<FileInfo> filesInfo, @NotNull BiMap<String, VirtualFile> map) {
LocalFileSystem fileSystem = LocalFileSystem.getInstance();
for (FileInfo fileInfo : filesInfo) {
String displayPath = fileInfo.getDisplayPath();
File file = fileInfo.toFile();
if (StringUtil.isNotEmpty(displayPath) && file.isFile()) {
VirtualFile virtualFile = fileSystem.findFileByIoFile(file);
if (virtualFile != null) {
String url = "http://127.0.0.1:" + myServer.getSettings().getPort() + "/test/" + UriUtil.trimLeadingSlashes(displayPath);
map.forcePut(url, virtualFile);
}
}
}
}
use of com.intellij.openapi.vfs.LocalFileSystem in project intellij-community by JetBrains.
the class JarDirectoryWatcherImpl method updateWatchedRoots.
@Override
public void updateWatchedRoots() {
final LocalFileSystem fs = LocalFileSystem.getInstance();
if (!myJarDirectories.isEmpty()) {
final Set<String> recursiveRoots = new HashSet<>();
final Set<String> flatRoots = new HashSet<>();
final VirtualFileManager fm = VirtualFileManager.getInstance();
for (OrderRootType rootType : myJarDirectories.getRootTypes()) {
for (String url : myJarDirectories.getDirectories(rootType)) {
if (fm.getFileSystem(VirtualFileManager.extractProtocol(url)) instanceof LocalFileSystem) {
final boolean watchRecursively = myJarDirectories.isRecursive(rootType, url);
final String path = VirtualFileManager.extractPath(url);
(watchRecursively ? recursiveRoots : flatRoots).add(path);
}
}
}
myWatchRequests = fs.replaceWatchedRoots(myWatchRequests, recursiveRoots, flatRoots);
if (myBusConnection == null) {
myBusConnection = ApplicationManager.getApplication().getMessageBus().connect();
myBusConnection.subscribe(VirtualFileManager.VFS_CHANGES, new BulkFileListener() {
@Override
public void after(@NotNull final List<? extends VFileEvent> events) {
boolean changesDetected = false;
for (VFileEvent event : events) {
if (event instanceof VFileCopyEvent) {
final VFileCopyEvent copyEvent = (VFileCopyEvent) event;
final VirtualFile file = copyEvent.getFile();
if (isUnderJarDirectory(copyEvent.getNewParent() + "/" + copyEvent.getNewChildName()) || file != null && isUnderJarDirectory(file.getUrl())) {
changesDetected = true;
break;
}
} else if (event instanceof VFileMoveEvent) {
final VFileMoveEvent moveEvent = (VFileMoveEvent) event;
final VirtualFile file = moveEvent.getFile();
if (file != null && (isUnderJarDirectory(file.getUrl()) || isUnderJarDirectory(moveEvent.getOldParent().getUrl() + "/" + file.getName()))) {
changesDetected = true;
break;
}
} else if (event instanceof VFileDeleteEvent) {
final VFileDeleteEvent deleteEvent = (VFileDeleteEvent) event;
if (isUnderJarDirectory(deleteEvent.getFile().getUrl())) {
changesDetected = true;
break;
}
} else if (event instanceof VFileCreateEvent) {
final VFileCreateEvent createEvent = (VFileCreateEvent) event;
if (isUnderJarDirectory(createEvent.getParent().getUrl() + "/" + createEvent.getChildName())) {
changesDetected = true;
break;
}
}
}
if (changesDetected) {
fireRootSetChanged();
}
}
private boolean isUnderJarDirectory(String url) {
for (String rootUrl : myJarDirectories.getAllDirectories()) {
if (FileUtil.startsWith(url, rootUrl)) {
return true;
}
}
return false;
}
});
}
} else {
cleanup();
}
}
Aggregations