Java Code Examples for com.intellij.openapi.vfs.VfsUtilCore#pathToUrl()
The following examples show how to use
com.intellij.openapi.vfs.VfsUtilCore#pathToUrl() .
You can vote up the ones you like or vote down the ones you don't like,
and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example 1
Source File: RefManagerImpl.java From consulo with Apache License 2.0 | 6 votes |
@Nullable @Override public RefEntity getReference(final String type, final String fqName) { for (RefManagerExtension extension : myExtensions.values()) { final RefEntity refEntity = extension.getReference(type, fqName); if (refEntity != null) return refEntity; } if (SmartRefElementPointer.FILE.equals(type)) { return RefFileImpl.fileFromExternalName(this, fqName); } if (SmartRefElementPointer.MODULE.equals(type)) { return RefModuleImpl.moduleFromName(this, fqName); } if (SmartRefElementPointer.PROJECT.equals(type)) { return getRefProject(); } if (SmartRefElementPointer.DIR.equals(type)) { String url = VfsUtilCore.pathToUrl(PathMacroManager.getInstance(getProject()).expandPath(fqName)); VirtualFile vFile = VirtualFileManager.getInstance().findFileByUrl(url); if (vFile != null) { final PsiDirectory dir = PsiManager.getInstance(getProject()).findDirectory(vFile); return getReference(dir); } } return null; }
Example 2
Source File: BuildElementsEditor.java From consulo with Apache License 2.0 | 6 votes |
@Nullable public String getUrl() { final String path = getText().trim(); if (path.length() == 0) { return null; } else { // should set only absolute paths String canonicalPath; try { canonicalPath = FileUtil.resolveShortWindowsName(path); } catch (IOException e) { canonicalPath = path; } return VfsUtilCore.pathToUrl(FileUtil.toSystemIndependentName(canonicalPath)); } }
Example 3
Source File: ExternalSystemImportingTestCase.java From intellij-quarkus with Eclipse Public License 2.0 | 5 votes |
protected void assertContentRoots(String moduleName, String... expectedRoots) { List<String> actual = new ArrayList<>(); for (ContentEntry e : getContentRoots(moduleName)) { actual.add(e.getUrl()); } for (int i = 0; i < expectedRoots.length; i++) { expectedRoots[i] = VfsUtilCore.pathToUrl(expectedRoots[i]); } assertUnorderedPathsAreEqual(actual, Arrays.asList(expectedRoots)); }
Example 4
Source File: MavenImportingTestCase.java From intellij-quarkus with Eclipse Public License 2.0 | 5 votes |
protected void assertContentRoots(String moduleName, String... expectedRoots) { List<String> actual = new ArrayList<>(); for (ContentEntry e : getContentRoots(moduleName)) { actual.add(e.getUrl()); } for (int i = 0; i < expectedRoots.length; i++) { expectedRoots[i] = VfsUtilCore.pathToUrl(expectedRoots[i]); } assertUnorderedPathsAreEqual(actual, Arrays.asList(expectedRoots)); }
Example 5
Source File: ResourceModuleContentRootCustomizer.java From intellij with Apache License 2.0 | 5 votes |
@NotNull private static String pathToUrl(@NotNull String filePath) { filePath = FileUtil.toSystemIndependentName(filePath); if (filePath.endsWith(".srcjar") || filePath.endsWith(".jar")) { return URLUtil.JAR_PROTOCOL + URLUtil.SCHEME_SEPARATOR + filePath + URLUtil.JAR_SEPARATOR; } else if (filePath.contains("src.jar!")) { return URLUtil.JAR_PROTOCOL + URLUtil.SCHEME_SEPARATOR + filePath; } else { return VfsUtilCore.pathToUrl(filePath); } }
Example 6
Source File: PersistentFileSetManager.java From consulo with Apache License 2.0 | 5 votes |
@Override public Element getState() { final Element root = new Element("root"); for (VirtualFile vf : getSortedFiles()) { final Element vfElement = new Element(FILE_ELEMENT); final Attribute filePathAttr = new Attribute(PATH_ATTR, VfsUtilCore.pathToUrl(vf.getPath())); vfElement.setAttribute(filePathAttr); root.addContent(vfElement); } return root; }