import com.intellij.openapi.util.io.FileUtil;
import com.intellij.openapi.util.text.StringUtil;
import com.intellij.openapi.vfs.LocalFileSystem;
-import com.intellij.openapi.vfs.VfsUtil;
import com.intellij.openapi.vfs.VfsUtilCore;
import com.intellij.openapi.vfs.VirtualFile;
import com.intellij.psi.JavaPsiFacade;
}
}
}
- return VfsUtil.copyFile(this, file, tempDir);
+ return VfsUtilCore.copyFile(this, file, tempDir);
}
private VirtualFile getTempDir(Module module) throws IOException {
import com.intellij.openapi.util.io.FileUtil;
import com.intellij.openapi.vfs.LocalFileSystem;
import com.intellij.openapi.vfs.VfsUtil;
+import com.intellij.openapi.vfs.VfsUtilCore;
import com.intellij.openapi.vfs.VirtualFile;
import com.intellij.testFramework.PsiTestCase;
VirtualFile file1 = myDir.createChildData(null, "A.java");
VfsUtil.saveText(file1, "package p; public class A{ public void foo(); }");
- VfsUtil.copyFile(null, getClassFile(), myDir);
+ VfsUtilCore.copyFile(null, getClassFile(), myDir);
final ModifiableRootModel rootModel = ModuleRootManager.getInstance(myModule).getModifiableModel();
final ContentEntry contentEntry1 = rootModel.addContentEntry(myDir);
import com.intellij.openapi.components.ServiceManager;
import com.intellij.pom.Navigatable;
+import com.intellij.psi.PsiDirectory;
import com.intellij.psi.PsiElement;
import org.jetbrains.annotations.Nullable;
@Nullable
public abstract Navigatable getDescriptor(final PsiElement element);
public abstract boolean canNavigate(final PsiElement element);
+ public abstract void navigateToDirectory(PsiDirectory psiDirectory, boolean requestFocus);
}
*/
package com.intellij.openapi.vfs;
+import org.jetbrains.annotations.NonNls;
import org.jetbrains.annotations.NotNull;
import org.jetbrains.annotations.Nullable;
+import java.io.IOException;
+
public class VfsUtilCore {
/**
* Checks whether the <code>ancestor {@link com.intellij.openapi.vfs.VirtualFile}</code> is parent of <code>file
String localPath = path.substring(0, separatorIndex);
return VirtualFileManager.getInstance().findFileByUrl("file://" + localPath);
}
+
+ /**
+ * Makes a copy of the <code>file</code> in the <code>toDir</code> folder and returns it.
+ *
+ * @param requestor any object to control who called this method. Note that
+ * it is considered to be an external change if <code>requestor</code> is <code>null</code>.
+ * See {@link com.intellij.openapi.vfs.VirtualFileEvent#getRequestor}
+ * @param file file to make a copy of
+ * @param toDir directory to make a copy in
+ * @return a copy of the file
+ * @throws java.io.IOException if file failed to be copied
+ */
+ public static VirtualFile copyFile(Object requestor, @NotNull VirtualFile file, @NotNull VirtualFile toDir) throws IOException {
+ return copyFile(requestor, file, toDir, file.getName());
+ }
+
+ /**
+ * Makes a copy of the <code>file</code> in the <code>toDir</code> folder with the <code>newName</code> and returns it.
+ *
+ * @param requestor any object to control who called this method. Note that
+ * it is considered to be an external change if <code>requestor</code> is <code>null</code>.
+ * See {@link com.intellij.openapi.vfs.VirtualFileEvent#getRequestor}
+ * @param file file to make a copy of
+ * @param toDir directory to make a copy in
+ * @param newName new name of the file
+ * @return a copy of the file
+ * @throws java.io.IOException if file failed to be copied
+ */
+ public static VirtualFile copyFile(Object requestor, @NotNull VirtualFile file, @NotNull VirtualFile toDir, @NotNull @NonNls String newName)
+ throws IOException {
+ final VirtualFile newChild = toDir.createChildData(requestor, newName);
+ // [jeka] TODO: to be discussed if the copy should have the same timestamp as the original
+ //OutputStream out = newChild.getOutputStream(requestor, -1, file.getActualTimeStamp());
+ newChild.setBinaryContent(file.contentsToByteArray());
+ return newChild;
+ }
}
package com.intellij.psi.impl.file;
-import com.intellij.ide.impl.ProjectViewSelectInTarget;
-import com.intellij.ide.projectView.impl.ProjectViewPane;
+import com.intellij.ide.util.PsiNavigationSupport;
import com.intellij.lang.ASTNode;
import com.intellij.lang.Language;
import com.intellij.openapi.diagnostic.Logger;
import com.intellij.openapi.editor.Document;
import com.intellij.openapi.fileEditor.FileDocumentManager;
import com.intellij.openapi.fileEditor.impl.LoadTextUtil;
-import com.intellij.openapi.progress.ProgressManager;
+import com.intellij.openapi.progress.ProgressIndicatorProvider;
import com.intellij.openapi.ui.Queryable;
import com.intellij.openapi.util.Comparing;
import com.intellij.openapi.util.SystemInfo;
import com.intellij.openapi.util.TextRange;
import com.intellij.openapi.util.text.StringUtil;
-import com.intellij.openapi.vfs.VfsBundle;
-import com.intellij.openapi.vfs.VfsUtil;
-import com.intellij.openapi.vfs.VirtualFile;
-import com.intellij.openapi.vfs.ex.dummy.DummyFileSystem;
-import com.intellij.openapi.vfs.ex.temp.TempFileSystem;
+import com.intellij.openapi.vfs.*;
import com.intellij.psi.*;
import com.intellij.psi.impl.CheckUtil;
import com.intellij.psi.impl.PsiElementBase;
import com.intellij.psi.impl.source.tree.TreeElement;
import com.intellij.psi.search.PsiElementProcessor;
import com.intellij.psi.search.PsiFileSystemItemProcessor;
-import com.intellij.psi.util.PsiUtilBase;
import com.intellij.psi.util.PsiUtilCore;
import com.intellij.util.ArrayUtil;
import com.intellij.util.IncorrectOperationException;
public boolean processChildren(PsiElementProcessor<PsiFileSystemItem> processor) {
checkValid();
- ProgressManager.checkCanceled();
+ ProgressIndicatorProvider.checkCanceled();
for (VirtualFile vFile : myFile.getChildren()) {
if (processor instanceof PsiFileSystemItemProcessor &&
}
});
- return PsiUtilBase.toPsiElementArray(children);
+ return PsiUtilCore.toPsiElementArray(children);
}
private void checkValid() {
}
public boolean isPhysical() {
- return !(myFile.getFileSystem() instanceof DummyFileSystem) && !(myFile.getFileSystem() instanceof TempFileSystem);
+ return !(myFile.getFileSystem() instanceof NonPhysicalFileSystem) && !(myFile.getFileSystem().getProtocol().equals("temp"));
}
/**
copyVFile = vFile.copy(this, parent, newName);
}
else {
- copyVFile = VfsUtil.copyFile(this, vFile, parent, newName);
+ copyVFile = VfsUtilCore.copyFile(this, vFile, parent, newName);
}
final PsiFile copyPsi = myManager.findFile(copyVFile);
if (copyPsi == null) {
newVFile.setBinaryContent(storedContents);
}
else {
- newVFile = VfsUtil.copyFile(null, originalFile.getVirtualFile(), myFile);
+ newVFile = VfsUtilCore.copyFile(null, originalFile.getVirtualFile(), myFile);
}
}
psiDocumentManager.commitAllDocuments();
}
public void navigate(boolean requestFocus) {
- ProjectViewSelectInTarget.select(getProject(), this, ProjectViewPane.ID, null, getVirtualFile(), requestFocus);
+ PsiNavigationSupport.getInstance().navigateToDirectory(this, false);
}
protected Icon getElementIcon(final int flags) {
*/
package com.intellij.ide.util;
+import com.intellij.ide.impl.ProjectViewSelectInTarget;
+import com.intellij.ide.projectView.impl.ProjectViewPane;
import com.intellij.pom.Navigatable;
+import com.intellij.psi.PsiDirectory;
import com.intellij.psi.PsiElement;
import org.jetbrains.annotations.Nullable;
public boolean canNavigate(PsiElement element) {
return EditSourceUtil.canNavigate(element);
}
+
+ @Override
+ public void navigateToDirectory(PsiDirectory psiDirectory, boolean requestFocus) {
+ ProjectViewSelectInTarget.select(psiDirectory.getProject(), this, ProjectViewPane.ID, null, psiDirectory.getVirtualFile(), requestFocus);
+ }
}
import com.intellij.psi.PsiDirectory;
import com.intellij.psi.PsiDirectoryContainer;
import com.intellij.psi.impl.PsiManagerImpl;
-import com.intellij.util.PlatformUtils;
import org.jetbrains.annotations.NotNull;
/**
}
}
- /**
- * Makes a copy of the <code>file</code> in the <code>toDir</code> folder and returns it.
- *
- * @param requestor any object to control who called this method. Note that
- * it is considered to be an external change if <code>requestor</code> is <code>null</code>.
- * See {@link VirtualFileEvent#getRequestor}
- * @param file file to make a copy of
- * @param toDir directory to make a copy in
- * @return a copy of the file
- * @throws IOException if file failed to be copied
- */
- public static VirtualFile copyFile(Object requestor, @NotNull VirtualFile file, @NotNull VirtualFile toDir) throws IOException {
- return copyFile(requestor, file, toDir, file.getName());
- }
-
- /**
- * Makes a copy of the <code>file</code> in the <code>toDir</code> folder with the <code>newName</code> and returns it.
- *
- * @param requestor any object to control who called this method. Note that
- * it is considered to be an external change if <code>requestor</code> is <code>null</code>.
- * See {@link VirtualFileEvent#getRequestor}
- * @param file file to make a copy of
- * @param toDir directory to make a copy in
- * @param newName new name of the file
- * @return a copy of the file
- * @throws IOException if file failed to be copied
- */
- public static VirtualFile copyFile(Object requestor, @NotNull VirtualFile file, @NotNull VirtualFile toDir, @NotNull @NonNls String newName)
- throws IOException {
- final VirtualFile newChild = toDir.createChildData(requestor, newName);
- // [jeka] TODO: to be discussed if the copy should have the same timestamp as the original
- //OutputStream out = newChild.getOutputStream(requestor, -1, file.getActualTimeStamp());
- newChild.setBinaryContent(file.contentsToByteArray());
- return newChild;
- }
-
/**
* Copies content of resource to the given file
*
package com.intellij.openapi.vfs.ex.temp;
import com.intellij.openapi.application.ApplicationManager;
-import com.intellij.openapi.vfs.VfsUtil;
+import com.intellij.openapi.vfs.VfsUtilCore;
import com.intellij.openapi.vfs.VirtualFile;
import com.intellij.openapi.vfs.newvfs.ManagingFS;
import com.intellij.openapi.vfs.newvfs.NewVirtualFileSystem;
public VirtualFile copyFile(final Object requestor, @NotNull final VirtualFile file, @NotNull final VirtualFile newParent, @NotNull final String copyName)
throws IOException {
- return VfsUtil.copyFile(requestor, file, newParent, copyName);
+ return VfsUtilCore.copyFile(requestor, file, newParent, copyName);
}
@NotNull
return existing;
}
- return VfsUtil.copyFile(this, file, targetDir, newName);
+ return VfsUtilCore.copyFile(this, file, targetDir, newName);
}
catch (IOException e) {
throw new RuntimeException(e);
import com.intellij.openapi.util.Computable;
import com.intellij.openapi.util.Ref;
import com.intellij.openapi.util.io.FileUtil;
-import com.intellij.openapi.vfs.LocalFileSystem;
-import com.intellij.openapi.vfs.VfsUtil;
-import com.intellij.openapi.vfs.VirtualFile;
-import com.intellij.openapi.vfs.VirtualFileFilter;
+import com.intellij.openapi.vfs.*;
import com.intellij.testFramework.fixtures.TempDirTestFixture;
import org.jetbrains.annotations.NotNull;
import org.jetbrains.annotations.Nullable;
createTempDirectory();
VirtualFile tempDir =
LocalFileSystem.getInstance().refreshAndFindFileByPath(myTempDir.getCanonicalPath().replace(File.separatorChar, '/'));
- return VfsUtil.copyFile(this, file, tempDir);
+ return VfsUtilCore.copyFile(this, file, tempDir);
}
catch (IOException e) {
throw new RuntimeException("Cannot copy " + file, e);