VfsUtilCore.fileToUrl API: VfsUtilCore.pathToUrl should also path convert to system-independent name

This commit is contained in:
Anton Makeev
2019-03-28 16:12:19 +01:00
parent e2520e973f
commit ceb1bbb2d1
11 changed files with 13 additions and 14 deletions

View File

@@ -118,7 +118,7 @@ public class NewProjectUtil {
canonicalPath = FileUtil.resolveShortWindowsName(compileOutput);
}
catch (IOException ignored) { }
extension.setCompilerOutputUrl(VfsUtilCore.pathToUrl(FileUtil.toSystemIndependentName(canonicalPath)));
extension.setCompilerOutputUrl(VfsUtilCore.pathToUrl(canonicalPath));
}
}), null, null);

View File

@@ -559,7 +559,7 @@ public class JarRepositoryManager {
}
}
// search for jar file first otherwise lib root won't be found!
manager.refreshAndFindFileByUrl(VfsUtilCore.pathToUrl(FileUtil.toSystemIndependentName(toFile.getPath())));
manager.refreshAndFindFileByUrl(VfsUtilCore.pathToUrl(toFile.getPath()));
final String url = VfsUtil.getUrlForLibraryRoot(toFile);
final VirtualFile file = manager.refreshAndFindFileByUrl(url);
if (file != null) {

View File

@@ -198,7 +198,7 @@ public class BuildElementsEditor extends ModuleElementsEditor {
catch (IOException e) {
canonicalPath = path;
}
commitPathRunnable.saveUrl(VfsUtilCore.pathToUrl(FileUtil.toSystemIndependentName(canonicalPath)));
commitPathRunnable.saveUrl(VfsUtilCore.pathToUrl(canonicalPath));
}
};

View File

@@ -248,6 +248,6 @@ public abstract class ProjectOpenProcessorBase<T extends ProjectImportBuilder> e
path = FileUtil.resolveShortWindowsName(path);
}
catch (IOException ignored) { }
return VfsUtilCore.pathToUrl(FileUtil.toSystemIndependentName(path));
return VfsUtilCore.pathToUrl(path);
}
}

View File

@@ -9,7 +9,6 @@ import com.intellij.openapi.projectRoots.Sdk;
import com.intellij.openapi.roots.ContentEntry;
import com.intellij.openapi.roots.JavaModuleExternalPaths;
import com.intellij.openapi.roots.ModifiableRootModel;
import com.intellij.openapi.util.io.FileUtil;
import com.intellij.openapi.vfs.VfsUtilCore;
import com.intellij.testFramework.IdeaTestUtil;
import com.intellij.testFramework.InspectionTestCase;
@@ -27,7 +26,7 @@ public class DeprecationInspectionTest extends InspectionTestCase {
public void configureModule(@NotNull Module module, @NotNull ModifiableRootModel model, @NotNull ContentEntry contentEntry) {
super.configureModule(module, model, contentEntry);
model.getModuleExtension(JavaModuleExternalPaths.class)
.setExternalAnnotationUrls(new String[]{VfsUtilCore.pathToUrl(FileUtil.toSystemIndependentName(getTestDataPath() + "/deprecation/" + getTestName(true) + "/extAnnotations"))});
.setExternalAnnotationUrls(new String[]{VfsUtilCore.pathToUrl(getTestDataPath() + "/deprecation/" + getTestName(true) + "/extAnnotations")});
}
@Override

View File

@@ -123,7 +123,7 @@ public class JavaModuleBuilder extends ModuleBuilder implements SourcePathsBuild
canonicalPath = myCompilerOutputPath;
}
compilerModuleExtension
.setCompilerOutputPath(VfsUtilCore.pathToUrl(FileUtil.toSystemIndependentName(canonicalPath)));
.setCompilerOutputPath(VfsUtilCore.pathToUrl(canonicalPath));
}
else {
compilerModuleExtension.inheritCompilerOutputPath(true);

View File

@@ -87,7 +87,7 @@ public abstract class ExecutionTestCase extends IdeaTestCase {
PsiTestUtil.addContentRoot(myModule, moduleDir);
PsiTestUtil.addSourceRoot(myModule, srcDir);
IdeaTestUtil.setModuleLanguageLevel(myModule, LanguageLevel.JDK_1_8);
PsiTestUtil.setCompilerOutputPath(myModule, VfsUtilCore.pathToUrl(FileUtil.toSystemIndependentName(myModuleOutputDir.getAbsolutePath())), false);
PsiTestUtil.setCompilerOutputPath(myModule, VfsUtilCore.pathToUrl(myModuleOutputDir.getAbsolutePath()), false);
});
}

View File

@@ -408,12 +408,12 @@ public class VfsUtilCore {
@NotNull
public static String pathToUrl(@NotNull String path) {
return VirtualFileManager.constructUrl(URLUtil.FILE_PROTOCOL, path);
return VirtualFileManager.constructUrl(URLUtil.FILE_PROTOCOL, FileUtil.toSystemIndependentName(path));
}
@NotNull
public static String fileToUrl(@NotNull File file) {
return pathToUrl(FileUtil.toSystemIndependentName(file.getPath()));
return pathToUrl(file.getPath());
}
public static List<File> virtualToIoFiles(@NotNull Collection<? extends VirtualFile> files) {

View File

@@ -181,7 +181,7 @@ public abstract class IntegrationTestCase extends PlatformTestCase {
ModifiableRootModel m = rm.getModifiableModel();
for (ContentEntry e : m.getContentEntries()) {
if (!Comparing.equal(e.getFile(), myRoot)) continue;
e.addExcludeFolder(VfsUtilCore.pathToUrl(FileUtil.toSystemIndependentName(path)));
e.addExcludeFolder(VfsUtilCore.pathToUrl(path));
}
m.commit();
});

View File

@@ -608,7 +608,7 @@ public class DirectoryIndexTest extends DirectoryIndexTestCase {
ApplicationManager.getApplication().runWriteAction(() -> {
ModifiableRootModel rootModel = ModuleRootManager.getInstance(myModule).getModifiableModel();
rootModel.getContentEntries()[0]
.addExcludeFolder(VfsUtilCore.pathToUrl(FileUtil.toSystemIndependentName(f.getParentFile().getParent())));
.addExcludeFolder(VfsUtilCore.pathToUrl(f.getParentFile().getParent()));
rootModel.commit();
ModuleRootModificationUtil.addContentRoot(myModule2, FileUtil.toSystemIndependentName(f.getPath()));

View File

@@ -149,7 +149,7 @@ public class PluginBuildConfiguration implements PersistentStateComponent<Plugin
public void setPluginXmlPathAndCreateDescriptorIfDoesntExist(final String pluginXmlPath) {
myPluginXmlContainer.getConfiguration().removeConfigFiles(PluginDescriptorConstants.META_DATA);
WriteAction.runAndWait(() -> createDescriptor(VfsUtilCore.pathToUrl(FileUtil.toSystemIndependentName(pluginXmlPath))));
WriteAction.runAndWait(() -> createDescriptor(VfsUtilCore.pathToUrl(pluginXmlPath)));
}
public void setManifestPath(@Nullable String manifestPath) {
@@ -162,7 +162,7 @@ public class PluginBuildConfiguration implements PersistentStateComponent<Plugin
if (manifest == null) {
Messages.showErrorDialog(myModule.getProject(), DevKitBundle.message("error.file.not.found.message", manifestPath), DevKitBundle.message("error.file.not.found"));
ReadAction.run(()-> myManifestFilePointer = VirtualFilePointerManager.getInstance().create(
VfsUtilCore.pathToUrl(FileUtil.toSystemIndependentName(manifestPath)), myModule, null));
VfsUtilCore.pathToUrl(manifestPath), myModule, null));
}
else {
WriteAction.run(()-> myManifestFilePointer = VirtualFilePointerManager.getInstance().create(manifest, myModule, null));