当前位置: 首页>>代码示例>>Java>>正文


Java VirtualFileManager.findFileByUrl方法代码示例

本文整理汇总了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);
        }
      }
    }
  }
}
 
开发者ID:jskierbi,项目名称:intellij-ce-playground,代码行数:18,代码来源:PersistentFileSetManager.java

示例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};
}
 
开发者ID:jskierbi,项目名称:intellij-ce-playground,代码行数:26,代码来源:DirectoryUrl.java

示例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);
}
 
开发者ID:jskierbi,项目名称:intellij-ce-playground,代码行数:25,代码来源:ExternalAnnotationsSupport.java

示例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;
}
 
开发者ID:jskierbi,项目名称:intellij-ce-playground,代码行数:21,代码来源:AttributesTableModel.java

示例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;
}
 
开发者ID:jskierbi,项目名称:intellij-ce-playground,代码行数:21,代码来源:ResourceBundleManagerState.java

示例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);
      }
    }
  }
}
 
开发者ID:jskierbi,项目名称:intellij-ce-playground,代码行数:19,代码来源:DslActivationStatus.java

示例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;
}
 
开发者ID:jskierbi,项目名称:intellij-ce-playground,代码行数:15,代码来源:VirtualFileWithDependenciesState.java

示例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;
}
 
开发者ID:jskierbi,项目名称:intellij-ce-playground,代码行数:15,代码来源:SimpleClasspathElementFactory.java

示例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);
}
 
开发者ID:jskierbi,项目名称:intellij-ce-playground,代码行数:28,代码来源:LoaderFactory.java

示例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();
}
 
开发者ID:internetisalie,项目名称:lua-for-idea,代码行数:75,代码来源:LuaInterpreterFinder.java


注:本文中的com.intellij.openapi.vfs.VirtualFileManager.findFileByUrl方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。