本文整理汇总了Java中com.intellij.openapi.vfs.VirtualFileManager.findFileByUrl方法的典型用法代码示例。如果您正苦于以下问题:Java VirtualFileManager.findFileByUrl方法的具体用法?Java VirtualFileManager.findFileByUrl怎么用?Java VirtualFileManager.findFileByUrl使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类com.intellij.openapi.vfs.VirtualFileManager
的用法示例。
在下文中一共展示了VirtualFileManager.findFileByUrl方法的10个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: loadState
import com.intellij.openapi.vfs.VirtualFileManager; //导入方法依赖的package包/类
@Override
public void loadState(Element state) {
final VirtualFileManager vfManager = VirtualFileManager.getInstance();
for (Object child : state.getChildren(FILE_ELEMENT)) {
if (child instanceof Element) {
final Element fileElement = (Element)child;
final Attribute filePathAttr = fileElement.getAttribute(PATH_ATTR);
if (filePathAttr != null) {
final String filePath = filePathAttr.getValue();
VirtualFile vf = vfManager.findFileByUrl(filePath);
if (vf != null) {
myFiles.add(vf);
}
}
}
}
}
示例2: createPath
import com.intellij.openapi.vfs.VirtualFileManager; //导入方法依赖的package包/类
@Override
public Object[] createPath(final Project project) {
if (moduleName != null) {
final Module module = ApplicationManager.getApplication().runReadAction(new Computable<Module>() {
@Nullable
@Override
public Module compute() {
return ModuleManager.getInstance(project).findModuleByName(moduleName);
}
});
if (module == null) return null;
}
final VirtualFileManager virtualFileManager = VirtualFileManager.getInstance();
final VirtualFile file = virtualFileManager.findFileByUrl(url);
if (file == null) return null;
final PsiDirectory directory = ApplicationManager.getApplication().runReadAction(new Computable<PsiDirectory>() {
@Nullable
@Override
public PsiDirectory compute() {
return PsiManager.getInstance(project).findDirectory(file);
}
});
if (directory == null) return null;
return new Object[]{directory};
}
示例3: attachJdkAnnotations
import com.intellij.openapi.vfs.VirtualFileManager; //导入方法依赖的package包/类
public static void attachJdkAnnotations(@NotNull SdkModificator modificator) {
String homePath = FileUtil.toSystemIndependentName(PathManager.getHomePath());
VirtualFileManager fileManager = VirtualFileManager.getInstance();
// release build?
String releaseLocation = homePath + "/plugins/android/lib/androidAnnotations.jar";
VirtualFile root = fileManager.findFileByUrl("jar://" + releaseLocation + "!/");
for (String relativePath : DEVELOPMENT_ANNOTATIONS_PATHS) {
if (root != null) break;
String developmentLocation = homePath + relativePath;
root = LocalFileSystem.getInstance().findFileByPath(FileUtil.toSystemIndependentName(developmentLocation));
}
if (root == null) {
// error message tailored for release build file layout
LOG.error("jdk annotations not found in: " + releaseLocation);
return;
}
OrderRootType annoType = AnnotationOrderRootType.getInstance();
modificator.removeRoot(root, annoType);
modificator.addRoot(root, annoType);
}
示例4: getGoToDefinitionCallback
import com.intellij.openapi.vfs.VirtualFileManager; //导入方法依赖的package包/类
@Override
public ActionListener getGoToDefinitionCallback() {
EditedStyleItem item = (EditedStyleItem)getValueAt(1);
if (getCellClass(1) == ThemeEditorStyle.class) {
myGoToDefinitionAction.setItem(item);
return myGoToDefinitionAction;
}
VirtualFileManager manager = VirtualFileManager.getInstance();
ResourceValue resourceValue = myResourceResolver.resolveResValue(item.getItemResourceValue());
final File file = new File(resourceValue.getValue());
final VirtualFile virtualFile = file.exists() ? manager.findFileByUrl("file://" + file.getAbsolutePath()) : null;
if (virtualFile != null) {
myOpenFileAction.setFile(virtualFile);
return myOpenFileAction;
}
return null;
}
示例5: removeNonExistentFiles
import com.intellij.openapi.vfs.VirtualFileManager; //导入方法依赖的package包/类
public ResourceBundleManagerState removeNonExistentFiles() {
final ResourceBundleManagerState newState = new ResourceBundleManagerState();
final VirtualFileManager virtualFileManager = VirtualFileManager.getInstance();
for (final String dissociatedFileUrl : myDissociatedFiles) {
if (virtualFileManager.findFileByUrl(dissociatedFileUrl) != null) {
newState.myDissociatedFiles.add(dissociatedFileUrl);
}
}
for (CustomResourceBundleState customResourceBundle : myCustomResourceBundles) {
final CustomResourceBundleState updatedCustomResourceBundle = customResourceBundle.removeNonExistentFiles(virtualFileManager);
if (updatedCustomResourceBundle != null) {
newState.myCustomResourceBundles.add(updatedCustomResourceBundle);
}
}
return newState;
}
示例6: loadState
import com.intellij.openapi.vfs.VirtualFileManager; //导入方法依赖的package包/类
@Override
public void loadState(State state) {
synchronized (myStatus) {
myStatus.clear();
if (ContainerUtil.isEmpty(state.entries)) {
return;
}
final VirtualFileManager fileManager = VirtualFileManager.getInstance();
for (Entry entry : state.entries) {
if (entry.url == null || entry.status == null) continue;
final VirtualFile file = fileManager.findFileByUrl(entry.url);
if (file != null) {
myStatus.put(file, entry);
}
}
}
}
示例7: isUpToDate
import com.intellij.openapi.vfs.VirtualFileManager; //导入方法依赖的package包/类
public boolean isUpToDate(@NotNull VirtualFile sourceFile) {
if (sourceFile.getTimeStamp() != mySourceTimestamp) {
return false;
}
VirtualFileManager manager = VirtualFileManager.getInstance();
for (Map.Entry<String, Long> entry : myDependencies.entrySet()) {
final VirtualFile file = manager.findFileByUrl(entry.getKey());
if (file == null || file.getTimeStamp() != entry.getValue()) {
return false;
}
}
return true;
}
示例8: convertToFiles
import com.intellij.openapi.vfs.VirtualFileManager; //导入方法依赖的package包/类
public static List<VirtualFile> convertToFiles(Collection<SimpleClasspathElement> cpeList)
{
VirtualFileManager fileManager = VirtualFileManager.getInstance();
List<VirtualFile> files = new ArrayList<VirtualFile>();
for (SimpleClasspathElement cpe : cpeList) {
for (String fileUrl : cpe.getClassesRootUrls()) {
VirtualFile file = fileManager.findFileByUrl(fileUrl);
if (file != null) {
files.add(file);
}
}
}
return files;
}
示例9: createClassLoader
import com.intellij.openapi.vfs.VirtualFileManager; //导入方法依赖的package包/类
private static ClassLoader createClassLoader(final String runClasspath, final String moduleName) {
final ArrayList<URL> urls = new ArrayList<URL>();
final VirtualFileManager manager = VirtualFileManager.getInstance();
final JarFileSystemImpl fileSystem = (JarFileSystemImpl)JarFileSystem.getInstance();
final StringTokenizer tokenizer = new StringTokenizer(runClasspath, File.pathSeparator);
while (tokenizer.hasMoreTokens()) {
final String s = tokenizer.nextToken();
try {
VirtualFile vFile = manager.findFileByUrl(VfsUtil.pathToUrl(s));
final File realFile = fileSystem.getMirroredFile(vFile);
urls.add(realFile != null ? realFile.toURI().toURL() : new File(s).toURI().toURL());
}
catch (Exception e) {
// ignore ?
}
}
try {
urls.add(new File(PathUtil.getJarPathForClass(Spacer.class)).toURI().toURL());
}
catch (MalformedURLException ignored) {
// ignore
}
final URL[] _urls = urls.toArray(new URL[urls.size()]);
return new DesignTimeClassLoader(Arrays.asList(_urls), LoaderFactory.class.getClassLoader(), moduleName);
}
示例10: describe
import com.intellij.openapi.vfs.VirtualFileManager; //导入方法依赖的package包/类
public void describe(LuaInterpreter interpreter) {
final String exePath = interpreter.path;
if (exePath == null || exePath.isEmpty() || exePath.trim().isEmpty()) {
setAsInvalid(interpreter);
return;
}
// Locate the virtual file
final VirtualFileManager vfsManager = VirtualFileManager.getInstance();
final VirtualFile interpreterExeFile = vfsManager.findFileByUrl("file://" + exePath.trim());
if (interpreterExeFile == null) {
setAsInvalid(interpreter);
return;
}
// Launch the process
final ProcessOutput processOutput;
if ("jar".equals(interpreterExeFile.getExtension())) {
processOutput = getJarProcessOutput(
interpreterExeFile,
interpreterExeFile.getParent()
);
} else {
processOutput = getBinaryProcessOutput(
interpreterExeFile,
interpreterExeFile.getParent()
);
}
if (processOutput == null) {
setAsInvalid(interpreter);
return;
}
String outputText = processOutput.getStderr().trim();
if (outputText.isEmpty())
outputText = processOutput.getStdout().trim();
if (outputText.contains("\n")) {
String[] lines = outputText.split("\n");
outputText = lines[0];
}
if (outputText.isEmpty()) {
setAsInvalid(interpreter);
return;
}
// Find the name and version number
final Pattern versionPattern = Pattern.compile("^(\\S+)\\s+(\\S+).*");
final Matcher m = versionPattern.matcher(outputText);
if (!m.matches()) {
setAsInvalid(interpreter);
return;
}
// Find a matching family
String familyMatch = m.group(1);
LuaInterpreterFamily interpreterFamily = LuaInterpreterFamily.findByMatch(
familyMatch,
interpreterExeFile.getName()
);
if (interpreterFamily == null) {
setAsInvalid(interpreter);
return;
}
// Success
interpreter.setFamily(interpreterFamily);
interpreter.setVersion(m.group(2));
interpreter.path = exePath.trim();
}