use of com.intellij.openapi.vfs.newvfs.NewVirtualFile in project intellij-community by JetBrains.
the class UnixPythonSdkFlavor method collectUnixPythons.
public static void collectUnixPythons(String path, Set<String> candidates) {
VirtualFile rootDir = LocalFileSystem.getInstance().findFileByPath(path);
if (rootDir != null) {
if (rootDir instanceof NewVirtualFile) {
((NewVirtualFile) rootDir).markDirty();
}
rootDir.refresh(true, false);
VirtualFile[] suspects = rootDir.getChildren();
for (VirtualFile child : suspects) {
if (!child.isDirectory()) {
final String childName = child.getName().toLowerCase();
for (String name : NAMES) {
if (childName.startsWith(name) || PYTHON_RE.matcher(childName).matches()) {
String childPath = child.getPath();
if (FileSystemUtil.isSymLink(childPath)) {
childPath = FileSystemUtil.resolveSymLink(childPath);
}
if (childPath != null && !childName.endsWith("-config") && !childName.startsWith("pythonw") && !childName.endsWith("m") && !candidates.contains(childPath)) {
candidates.add(childPath);
}
break;
}
}
}
}
}
}
use of com.intellij.openapi.vfs.newvfs.NewVirtualFile in project intellij-community by JetBrains.
the class StudyProjectGenerator method openFirstTask.
public static void openFirstTask(@NotNull final Course course, @NotNull final Project project) {
LocalFileSystem.getInstance().refresh(false);
final Lesson firstLesson = StudyUtils.getFirst(course.getLessons());
if (firstLesson == null)
return;
final Task firstTask = StudyUtils.getFirst(firstLesson.getTaskList());
if (firstTask == null)
return;
final VirtualFile taskDir = firstTask.getTaskDir(project);
if (taskDir == null)
return;
final Map<String, TaskFile> taskFiles = firstTask.getTaskFiles();
VirtualFile activeVirtualFile = null;
for (Map.Entry<String, TaskFile> entry : taskFiles.entrySet()) {
final String relativePath = entry.getKey();
final TaskFile taskFile = entry.getValue();
taskDir.refresh(false, true);
final VirtualFile virtualFile = taskDir.findFileByRelativePath(relativePath);
if (virtualFile != null) {
if (!taskFile.getActivePlaceholders().isEmpty()) {
activeVirtualFile = virtualFile;
}
}
}
if (activeVirtualFile != null) {
final PsiFile file = PsiManager.getInstance(project).findFile(activeVirtualFile);
ProjectView.getInstance(project).select(file, activeVirtualFile, false);
final FileEditor[] editors = FileEditorManager.getInstance(project).openFile(activeVirtualFile, true);
if (editors.length == 0) {
return;
}
final FileEditor studyEditor = editors[0];
if (studyEditor instanceof StudyEditor) {
StudyUtils.selectFirstAnswerPlaceholder((StudyEditor) studyEditor, project);
}
FileEditorManager.getInstance(project).openFile(activeVirtualFile, true);
} else {
String first = StudyUtils.getFirst(taskFiles.keySet());
if (first != null) {
NewVirtualFile firstFile = ((VirtualDirectoryImpl) taskDir).refreshAndFindChild(first);
if (firstFile != null) {
FileEditorManager.getInstance(project).openFile(firstFile, true);
}
}
}
}
use of com.intellij.openapi.vfs.newvfs.NewVirtualFile in project intellij-community by JetBrains.
the class DumpVfsInfoForExcludedFilesAction method dumpChildrenInDbRecursively.
private static void dumpChildrenInDbRecursively(VirtualFile dir, int depth) {
if (!(dir instanceof NewVirtualFile)) {
System.out.println(dir.getPresentableUrl() + ": not in db (" + dir.getClass().getName() + ")");
return;
}
List<VirtualFile> dirs = new ArrayList<>();
int inDb = 0, contentInDb = 0, nullChildren = 0;
PersistentFS persistentFS = PersistentFS.getInstance();
if (persistentFS.wereChildrenAccessed(dir)) {
for (String name : persistentFS.listPersisted(dir)) {
inDb++;
NewVirtualFile child = ((NewVirtualFile) dir).refreshAndFindChild(name);
if (child == null) {
nullChildren++;
continue;
}
if (child.isDirectory()) {
dirs.add(child);
} else if (FSRecords.getContentId(child.getId()) != 0) {
contentInDb++;
}
}
}
System.out.print(dir.getPresentableUrl() + ": " + inDb + " children in db");
if (contentInDb > 0) {
System.out.print(", content of " + contentInDb + " files in db");
}
if (nullChildren > 0) {
System.out.print(", " + nullChildren + " invalid files in db");
}
System.out.println();
if (depth > 10) {
System.out.println("too deep, skipping children");
} else {
for (VirtualFile childDir : dirs) {
dumpChildrenInDbRecursively(childDir, depth + 1);
}
}
}
use of com.intellij.openapi.vfs.newvfs.NewVirtualFile in project intellij-community by JetBrains.
the class LoadAllVfsStoredContentsAction method iterateCached.
private void iterateCached(VirtualFile root) {
processFile((NewVirtualFile) root);
Collection<VirtualFile> children = ((NewVirtualFile) root).getCachedChildren();
for (VirtualFile child : children) {
iterateCached(child);
}
}
use of com.intellij.openapi.vfs.newvfs.NewVirtualFile in project intellij-community by JetBrains.
the class PsiFileGistImpl method shouldUseMemoryStorage.
private static boolean shouldUseMemoryStorage(PsiFile file) {
if (!(file.getVirtualFile() instanceof NewVirtualFile))
return true;
PsiDocumentManager pdm = PsiDocumentManager.getInstance(file.getProject());
Document document = pdm.getCachedDocument(file);
return document != null && (pdm.isUncommited(document) || FileDocumentManager.getInstance().isDocumentUnsaved(document));
}
Aggregations