本文整理汇总了Java中com.intellij.openapi.vfs.VfsUtilCore.urlToPath方法的典型用法代码示例。如果您正苦于以下问题:Java VfsUtilCore.urlToPath方法的具体用法?Java VfsUtilCore.urlToPath怎么用?Java VfsUtilCore.urlToPath使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类com.intellij.openapi.vfs.VfsUtilCore
的用法示例。
在下文中一共展示了VfsUtilCore.urlToPath方法的13个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: JpsContentEntry
import com.intellij.openapi.vfs.VfsUtilCore; //导入方法依赖的package包/类
public JpsContentEntry(JpsModule module, JpsRootModel rootModel, String rootUrl) {
myModule = module;
myRootModel = rootModel;
myRoot = VirtualFilePointerManager.getInstance().create(rootUrl, this, null);
mySourceFolders = new ArrayList<JpsSourceFolder>();
String rootPath = VfsUtilCore.urlToPath(getUrl());
for (JpsModuleSourceRoot root : myModule.getSourceRoots()) {
if (FileUtil.isAncestor(rootPath, VfsUtilCore.urlToPath(root.getUrl()), false)) {
mySourceFolders.add(new JpsSourceFolder(root, this));
}
}
myExcludeFolders = new ArrayList<JpsExcludeFolder>();
for (String excludedUrl : myModule.getExcludeRootsList().getUrls()) {
if (FileUtil.isAncestor(rootPath, VfsUtilCore.urlToPath(excludedUrl), false)) {
myExcludeFolders.add(new JpsExcludeFolder(excludedUrl, this));
}
}
}
示例2: getClassRoots
import com.intellij.openapi.vfs.VfsUtilCore; //导入方法依赖的package包/类
@NotNull
public List<File> getClassRoots(Element libraryElement, @Nullable ModuleSettingsImpl moduleSettings) {
List<File> files = new ArrayList<File>();
//todo[nik] support jar directories
final Element classesChild = libraryElement.getChild("CLASSES");
if (classesChild != null) {
final List<Element> roots = JDOMUtil.getChildren(classesChild, "root");
final ExpandMacroToPathMap pathMap = createExpandMacroMap(moduleSettings);
for (Element root : roots) {
final String url = root.getAttributeValue("url");
final String path = VfsUtilCore.urlToPath(url);
files.add(new File(PathUtil.getLocalPath(pathMap.substitute(path, true))));
}
}
return files;
}
示例3: areUrlsPointTheSame
import com.intellij.openapi.vfs.VfsUtilCore; //导入方法依赖的package包/类
public static boolean areUrlsPointTheSame(String ideaUrl, String eclipseUrl) {
final String path = VfsUtilCore.urlToPath(eclipseUrl);
if (ideaUrl.contains(path)) {
return true;
}
else {
final String relativeToModulePath = EPathCommonUtil.getRelativeToModulePath(path);
final int relativeIdx = relativeToModulePath != null ? ideaUrl.indexOf(relativeToModulePath) : -1;
if (relativeIdx != -1) {
final String pathToProjectFile = VfsUtilCore.urlToPath(ideaUrl.substring(0, relativeIdx));
if (Comparing.strEqual(EPathCommonUtil.getRelativeModuleName(path),
EclipseProjectFinder.findProjectName(pathToProjectFile))) {
return true;
}
}
}
return false;
}
示例4: getDefaultArtifactOutputPath
import com.intellij.openapi.vfs.VfsUtilCore; //导入方法依赖的package包/类
@Nullable
public static String getDefaultArtifactOutputPath(@NotNull String artifactName, final @NotNull Project project) {
final CompilerProjectExtension extension = CompilerProjectExtension.getInstance(project);
if (extension == null) return null;
String outputUrl = extension.getCompilerOutputUrl();
if (outputUrl == null || outputUrl.length() == 0) {
final VirtualFile baseDir = project.getBaseDir();
if (baseDir == null) return null;
outputUrl = baseDir.getUrl() + "/out";
}
return VfsUtilCore.urlToPath(outputUrl) + "/artifacts/" + FileUtil.sanitizeFileName(artifactName);
}
示例5: migrateJdkAnnotationsToCommunityForDevIdea
import com.intellij.openapi.vfs.VfsUtilCore; //导入方法依赖的package包/类
private static String migrateJdkAnnotationsToCommunityForDevIdea(String url) {
File root = new File(VfsUtilCore.urlToPath(url) + "/..");
boolean isOldJdkAnnotations = new File(root, "community/java/jdkAnnotations").exists()
&& new File(root, "idea.iml").exists()
&& new File(root, "testData").exists();
if (isOldJdkAnnotations) {
return VfsUtilCore.pathToUrl(PathUtil.getCanonicalPath(VfsUtilCore.urlToPath(url + "/../community/java/jdkAnnotations")));
}
return url;
}
示例6: assertFolderUnderMe
import com.intellij.openapi.vfs.VfsUtilCore; //导入方法依赖的package包/类
private void assertFolderUnderMe(@NotNull String url) {
final String path = VfsUtilCore.urlToPath(url);
final String rootPath = VfsUtilCore.urlToPath(getUrl());
if (!FileUtil.isAncestor(rootPath, path, false)) {
LOG.error("The file '" + path + "' is not under content entry root '" + rootPath + "'");
}
}
示例7: extractLocalPath
import com.intellij.openapi.vfs.VfsUtilCore; //导入方法依赖的package包/类
public static String extractLocalPath(final String url) {
final String path = VfsUtilCore.urlToPath(url);
final int jarSeparatorIndex = path.indexOf(URLUtil.JAR_SEPARATOR);
if (jarSeparatorIndex > 0) {
return path.substring(0, jarSeparatorIndex);
}
return path;
}
示例8: getClassRoots
import com.intellij.openapi.vfs.VfsUtilCore; //导入方法依赖的package包/类
private static String[] getClassRoots(URL[] urls) {
final String[] classLoaderRoots = new String[urls.length];
for (int i = 0; i < urls.length; i++) {
classLoaderRoots[i] = VfsUtilCore.urlToPath(VfsUtilCore.convertFromUrl(urls[i]));
}
System.out.println("Collecting tests from " + Arrays.toString(classLoaderRoots));
return classLoaderRoots;
}
示例9: visitRoot
import com.intellij.openapi.vfs.VfsUtilCore; //导入方法依赖的package包/类
public boolean visitRoot(@NotNull VirtualFile root, Module module, Sdk sdk, boolean isModuleSource) {
final String vpath = VfsUtilCore.urlToPath(root.getUrl());
if (myPath.startsWith(vpath)) {
myResult = vpath;
return false;
}
else {
return true;
}
}
示例10: getSkeletonFile
import com.intellij.openapi.vfs.VfsUtilCore; //导入方法依赖的package包/类
@Nullable
public static PyFile getSkeletonFile(final @NotNull Project project, @NotNull Sdk sdk, @NotNull String name) {
SdkTypeId sdkType = sdk.getSdkType();
if (sdkType instanceof PythonSdkType) {
// dig out the builtins file, create an instance based on it
final String[] urls = sdk.getRootProvider().getUrls(PythonSdkType.BUILTIN_ROOT_TYPE);
for (String url : urls) {
if (url.contains(PythonSdkType.SKELETON_DIR_NAME)) {
final String builtins_url = url + "/" + name;
File builtins = new File(VfsUtilCore.urlToPath(builtins_url));
if (builtins.isFile() && builtins.canRead()) {
final VirtualFile builtins_vfile = LocalFileSystem.getInstance().findFileByIoFile(builtins);
if (builtins_vfile != null) {
final Ref<PyFile> result = Ref.create();
ApplicationManager.getApplication().runReadAction(new Runnable() {
@Override
public void run() {
PsiFile file = PsiManager.getInstance(project).findFile(builtins_vfile);
if (file instanceof PyFile) {
result.set((PyFile)file);
}
}
});
return result.get();
}
}
}
}
}
return null;
}
示例11: ensureInitialized
import com.intellij.openapi.vfs.VfsUtilCore; //导入方法依赖的package包/类
private synchronized static void ensureInitialized() {
if (ourInitialized) return;
ourInitialized = true;
final Html5SchemaProvider[] providers = EP_NAME.getExtensions();
final URL htmlSchemaLocationURL;
final URL xhtmlSchemaLocationURL;
final URL dtdCharsLocationURL;
if (providers.length > 1) {
LOG.error("More than one HTML5 schema providers found: " + getClassesListString(providers));
}
if (providers.length > 0) {
htmlSchemaLocationURL = providers[0].getHtmlSchemaLocation();
xhtmlSchemaLocationURL = providers[0].getXhtmlSchemaLocation();
dtdCharsLocationURL = providers[0].getCharsLocation();
}
else {
LOG.info("RelaxNG based schema for HTML5 is not supported. Old XSD schema will be used");
htmlSchemaLocationURL = Html5SchemaProvider.class.getResource(ExternalResourceManagerEx.STANDARD_SCHEMAS + "html5/xhtml5.xsd");
xhtmlSchemaLocationURL = htmlSchemaLocationURL;
dtdCharsLocationURL = htmlSchemaLocationURL;
}
HTML5_SCHEMA_LOCATION = VfsUtilCore.urlToPath(VfsUtilCore.fixURLforIDEA(
URLUtil.unescapePercentSequences(htmlSchemaLocationURL.toExternalForm())));
LOG.info("HTML5_SCHEMA_LOCATION = " + getHtml5SchemaLocation());
XHTML5_SCHEMA_LOCATION = VfsUtilCore.urlToPath(VfsUtilCore.fixURLforIDEA(
URLUtil.unescapePercentSequences(xhtmlSchemaLocationURL.toExternalForm())));
LOG.info("XHTML5_SCHEMA_LOCATION = " + getXhtml5SchemaLocation());
CHARS_DTD_LOCATION = VfsUtilCore.urlToPath(VfsUtilCore.fixURLforIDEA(
URLUtil.unescapePercentSequences(dtdCharsLocationURL.toExternalForm())));
LOG.info("CHARS_DTD_LOCATION = " + getCharsDtdLocation());
}
示例12: assertOneContentRoot
import com.intellij.openapi.vfs.VfsUtilCore; //导入方法依赖的package包/类
protected void assertOneContentRoot(@NotNull Module module, String relativePath) {
File expected = new File(myRootDir, relativePath);
String url = assertOneElement(ModuleRootManager.getInstance(module).getContentRootUrls());
File actual = new File(VfsUtilCore.urlToPath(url));
assertEquals(expected.getAbsolutePath(), actual.getAbsolutePath());
}
示例13: createFileFromTemplate
import com.intellij.openapi.vfs.VfsUtilCore; //导入方法依赖的package包/类
@Nullable
private VirtualFile createFileFromTemplate(@Nullable final Project project, String url, final String templateName, final boolean forceNew) {
final LocalFileSystem fileSystem = LocalFileSystem.getInstance();
final File file = new File(VfsUtilCore.urlToPath(url));
VirtualFile existingFile = fileSystem.refreshAndFindFileByIoFile(file);
if (existingFile != null) {
existingFile.refresh(false, false);
if (!existingFile.isValid()) {
existingFile = null;
}
}
if (existingFile != null && !forceNew) {
return existingFile;
}
try {
String text = getText(templateName, project);
final VirtualFile childData;
if (existingFile == null || existingFile.isDirectory()) {
final VirtualFile virtualFile;
if (!FileUtil.createParentDirs(file) ||
(virtualFile = fileSystem.refreshAndFindFileByIoFile(file.getParentFile())) == null) {
throw new IOException(IdeBundle.message("error.message.unable.to.create.file", file.getPath()));
}
childData = virtualFile.createChildData(this, file.getName());
}
else {
childData = existingFile;
}
VfsUtil.saveText(childData, text);
return childData;
}
catch (final IOException e) {
LOG.info(e);
ApplicationManager.getApplication().invokeLater(new Runnable() {
@Override
public void run() {
Messages.showErrorDialog(IdeBundle.message("message.text.error.creating.deployment.descriptor", e.getLocalizedMessage()),
IdeBundle.message("message.text.creating.deployment.descriptor"));
}
});
}
return null;
}