本文整理汇总了Java中com.intellij.openapi.vfs.VfsUtil.findFileByURL方法的典型用法代码示例。如果您正苦于以下问题:Java VfsUtil.findFileByURL方法的具体用法?Java VfsUtil.findFileByURL怎么用?Java VfsUtil.findFileByURL使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类com.intellij.openapi.vfs.VfsUtil
的用法示例。
在下文中一共展示了VfsUtil.findFileByURL方法的10个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: getRecentImportFile
import com.intellij.openapi.vfs.VfsUtil; //导入方法依赖的package包/类
@Nullable
public static VirtualFile getRecentImportFile() {
CodeStyleSchemesUIConfiguration configuration = getInstance();
if (configuration != null) {
String fileLocation = configuration.RECENT_IMPORT_FILE_LOCATION;
if (fileLocation == null || fileLocation.trim().isEmpty()) return null;
try {
URL url = new URL(fileLocation);
return VfsUtil.findFileByURL(url);
}
catch (MalformedURLException e) {
// Ignore
}
}
return null;
}
示例2: doCreateDescriptor
import com.intellij.openapi.vfs.VfsUtil; //导入方法依赖的package包/类
@Nullable
private XmlNSDescriptorImpl doCreateDescriptor(FileKind kind) {
String schemaUrl = kind.getSchemaUrl();
String location = ExternalResourceManager.getInstance().getResourceLocation(schemaUrl);
if (schemaUrl.equals(location)) return null;
VirtualFile schema;
try {
schema = VfsUtil.findFileByURL(new URL(location));
}
catch (MalformedURLException ignore) {
return null;
}
if (schema == null) return null;
PsiFile psiFile = PsiManager.getInstance(myProject).findFile(schema);
if (!(psiFile instanceof XmlFile)) return null;
XmlNSDescriptorImpl result = new XmlNSDescriptorImpl();
result.init(psiFile);
return result;
}
示例3: resolve
import com.intellij.openapi.vfs.VfsUtil; //导入方法依赖的package包/类
@Nullable
public PsiElement resolve() {
final String value = myAttribute.getValue();
final String resourceLocation = myResourceManager.getResourceLocation(value);
//noinspection StringEquality
if (resourceLocation != value) {
VirtualFile file;
try {
file = VfsUtil.findFileByURL(new URL(resourceLocation));
}
catch (MalformedURLException e) {
try {
file = VfsUtil.findFileByURL(new File(resourceLocation).toURI().toURL());
}
catch (MalformedURLException e1) {
file = null;
}
}
if (file != null) {
return myAttribute.getManager().findFile(file);
}
}
return null;
}
示例4: _customizePresentation
import com.intellij.openapi.vfs.VfsUtil; //导入方法依赖的package包/类
private void _customizePresentation(ColoredTextContainer component) {
final Debugger.Frame frame = myFrame;
if (frame instanceof Debugger.StyleFrame) {
component.append(((Debugger.StyleFrame)frame).getInstruction(), SimpleTextAttributes.REGULAR_BOLD_ATTRIBUTES);
} else if (frame instanceof Debugger.SourceFrame) {
component.append(((Debugger.SourceFrame)frame).getXPath(), SimpleTextAttributes.REGULAR_BOLD_ATTRIBUTES);
}
component.append(" ", SimpleTextAttributes.REGULAR_ATTRIBUTES);
try {
final VirtualFile file = VfsUtil.findFileByURL(new URI(frame.getURI()).toURL());
if (file != null) {
component.append(file.getName(), SimpleTextAttributes.REGULAR_ATTRIBUTES);
if (frame.getLineNumber() > 0) {
component.append(":" + frame.getLineNumber(), SimpleTextAttributes.REGULAR_ATTRIBUTES);
}
component.setToolTipText(file.getPresentableUrl());
} else {
component.append(frame.getURI() + ":" + frame.getLineNumber(), SimpleTextAttributes.REGULAR_ATTRIBUTES);
}
} catch (Exception ignored) {
component.append(frame.getURI() + ":" + frame.getLineNumber(), SimpleTextAttributes.REGULAR_ATTRIBUTES);
}
}
示例5: getReference
import com.intellij.openapi.vfs.VfsUtil; //导入方法依赖的package包/类
private static XmlFile getReference(@NotNull @NonNls String url, @NotNull Module module) {
if (url.equalsIgnoreCase("http://bpmn.sourceforge.net")) {
return null;
}
final URL resource = BPMNFileSchemaProvider.class.getResource(BPMNModelConstants.BPMN_SCHEMA_BASEURI + BPMNModelConstants.BPMN_SYSTEM_ID);
final VirtualFile fileByURL = VfsUtil.findFileByURL(resource);
if (fileByURL == null) {
return null;
}
PsiFile psiFile = PsiManager.getInstance(module.getProject()).findFile(fileByURL);
return (XmlFile) psiFile.copy();
}
示例6: createSdkByExecutable
import com.intellij.openapi.vfs.VfsUtil; //导入方法依赖的package包/类
/**
* Create SDK by path to python exectuable
*
* @param executable path executable
* @return sdk or null if there is no sdk on this path
* @throws InvalidSdkException bad sdk
*/
@Nullable
private static Sdk createSdkByExecutable(@NotNull final String executable) throws InvalidSdkException, IOException {
final URL rootUrl = new URL(String.format("file:///%s", executable));
final VirtualFile url = VfsUtil.findFileByURL(rootUrl);
if (url == null) {
return null;
}
return PyTestSdkTools.createTempSdk(url, SdkCreationType.SDK_PACKAGES_AND_SKELETONS, null);
}
示例7: findVirtualFile
import com.intellij.openapi.vfs.VfsUtil; //导入方法依赖的package包/类
public static VirtualFile findVirtualFile(String systemId) {
try {
return VfsUtil.findFileByURL(new URL(systemId));
} catch (Exception e) {
LOG.warn("Failed to build file from uri <" + systemId + ">", e);
return VirtualFileManager.getInstance().findFileByUrl(VfsUtilCore.fixURLforIDEA(systemId));
}
}
示例8: createOpenFileHyperlink
import com.intellij.openapi.vfs.VfsUtil; //导入方法依赖的package包/类
protected HyperlinkInfo createOpenFileHyperlink(String fileName, final int line, int column) {
if ((fileName == null || fileName.length() == 0)) {
if (myBase != null) {
fileName = myBase.getPresentableUrl();
} else {
return null;
}
}
fileName = fileName.replace(File.separatorChar, '/');
VirtualFile file;
// try to interpret the filename as URL
if (URLUtil.containsScheme(fileName)) {
try {
file = VfsUtil.findFileByURL(new URL(fileName));
} catch (MalformedURLException e) {
file = VirtualFileManager.getInstance().findFileByUrl(VfsUtil.pathToUrl(fileName));
}
} else {
file = VfsUtil.findRelativeFile(fileName, myBase);
}
if (file == null) {
//noinspection ConstantConditions
return null;
}
final FileType fileType = file.getFileType();
if (fileType != null && column > 0) {
final Document document = FileDocumentManager.getInstance().getDocument(file);
final int start = document.getLineStartOffset(line);
final int max = document.getLineEndOffset(line);
final int tabSize = CodeStyleSettingsManager.getInstance(myProject).getCurrentSettings().getTabSize(fileType);
column = EditorUtil.calcColumnNumber(null, document.getCharsSequence(), start, Math.min(start + column, max), tabSize);
}
return new OpenFileHyperlinkInfo(myProject, file, line, column);
}
示例9: create
import com.intellij.openapi.vfs.VfsUtil; //导入方法依赖的package包/类
@Nullable
public static XSourcePosition create(Debugger.Locatable location) {
final VirtualFile file;
try {
file = VfsUtil.findFileByURL(new URI(location.getURI()).toURL());
} catch (Exception e) {
// TODO log
return null;
}
final int line = location.getLineNumber() - 1;
final XSourcePosition position = XDebuggerUtil.getInstance().createPosition(file, line);
return line >= 0 && position != null ? new XsltSourcePosition(location, position) : null;
}
示例10: getReference
import com.intellij.openapi.vfs.VfsUtil; //导入方法依赖的package包/类
private static XmlFile getReference(@NotNull Module module) {
final URL resource = JavaFXSchemaHandler.class.getResource("fx.xsd");
final VirtualFile fileByURL = VfsUtil.findFileByURL(resource);
PsiFile psiFile = PsiManager.getInstance(module.getProject()).findFile(fileByURL);
LOG.assertTrue(psiFile != null);
return (XmlFile)psiFile.copy();
}