Java 类com.intellij.openapi.vfs.StandardFileSystems 实例源码

项目:intellij-ce-playground    文件:ModuleManagerImpl.java   
@NotNull
private Module loadModuleInternal(@NotNull String filePath) throws ModuleWithNameAlreadyExists, IOException {
  filePath = resolveShortWindowsName(filePath);
  final VirtualFile moduleFile = StandardFileSystems.local().findFileByPath(filePath);
  if (moduleFile == null || !moduleFile.exists()) {
    throw new FileNotFoundException(ProjectBundle.message("module.file.does.not.exist.error", filePath));
  }

  String path = moduleFile.getPath();
  ModuleEx module = getModuleByFilePath(path);
  if (module == null) {
    ApplicationManager.getApplication().invokeAndWait(new Runnable() {
      @Override
      public void run() {
        moduleFile.refresh(false, false);
      }
    }, ModalityState.any());
    module = createAndLoadModule(path);
    initModule(module, path, null);
  }
  return module;
}
项目:intellij-ce-playground    文件:PyUserSkeletonsUtil.java   
@Nullable
public static VirtualFile getUserSkeletonsDirectory() {
  if (ourUserSkeletonsDirectory == null) {
    for (String path : getPossibleUserSkeletonsPaths()) {
      ourUserSkeletonsDirectory = StandardFileSystems.local().findFileByPath(path);
      if (ourUserSkeletonsDirectory != null) {
        break;
      }
    }
  }
  if (!ourNoSkeletonsErrorReported && ourUserSkeletonsDirectory == null) {
    ourNoSkeletonsErrorReported = true;
    LOG.warn("python-skeletons directory not found in paths: " + getPossibleUserSkeletonsPaths());
  }
  return ourUserSkeletonsDirectory;
}
项目:intellij-ce-playground    文件:XmlUtil.java   
@Nullable
public static XmlFile findXmlFile(PsiFile base, @NotNull String uri) {
  PsiFile result = null;

  if (ApplicationManager.getApplication().isUnitTestMode()) {
    String data = base.getOriginalFile().getUserData(TEST_PATH);

    if (data != null) {
      String filePath = data + "/" + uri;
      final VirtualFile path = StandardFileSystems.local().findFileByPath(filePath.replace(File.separatorChar, '/'));
      if (path != null) {
        result = base.getManager().findFile(path);
      }
    }
  }
  if (result == null) {
    result = findRelativeFile(uri, base);
  }

  if (result instanceof XmlFile) {
    return (XmlFile)result;
  }

  return null;
}
项目:intellij-ce-playground    文件:SdkHomeSettings.java   
private static List<VirtualFile> calcRoots(@Nullable VirtualFile home) {
  if (home == null) {
    return Collections.emptyList();
  }

  final VirtualFile lib = home.findChild("lib");
  if (lib == null) {
    return Collections.emptyList();
  }

  List<VirtualFile> result = new ArrayList<VirtualFile>();
  for (VirtualFile file : lib.getChildren()) {
    if ("jar".equals(file.getExtension())) {
      ContainerUtil.addIfNotNull(StandardFileSystems.getJarRootForLocalFile(file), result);
    }
  }
  return result;
}
项目:intellij    文件:BlazeLibrary.java   
protected static String pathToUrl(File path) {
  String name = path.getName();
  boolean isJarFile =
      FileUtilRt.extensionEquals(name, "jar") || FileUtilRt.extensionEquals(name, "zip");
  // .jar files require an URL with "jar" protocol.
  String protocol =
      isJarFile
          ? StandardFileSystems.JAR_PROTOCOL
          : VirtualFileSystemProvider.getInstance().getSystem().getProtocol();
  String filePath = FileUtil.toSystemIndependentName(path.getPath());
  String url = VirtualFileManager.constructUrl(protocol, filePath);
  if (isJarFile) {
    url += URLUtil.JAR_SEPARATOR;
  }
  return url;
}
项目:consulo-unity3d    文件:Unity3dProjectChangeListener.java   
public Unity3dProjectChangeListener(@NotNull Project project, @NotNull StartupManager startupManager)
{
    myProject = project;

    for(Unity3dProjectSourceFileTypeFactory factory : Unity3dProjectSourceFileTypeFactory.EP_NAME.getExtensions())
    {
        factory.registerFileTypes(mySourceFileTypes::add);
    }

    myProject.getMessageBus().connect().subscribe(ProjectTopics.PROJECT_ROOTS, new ModuleRootListener()
    {
        @Override
        @RequiredReadAction
        public void rootsChanged(ModuleRootEvent event)
        {
            checkAndRunIfNeed();
        }
    });

    VirtualFileManager.getInstance().addVirtualFileListener(this, this);

    myAssetsDirPointer = VirtualFilePointerManager.getInstance().create(StandardFileSystems.FILE_PROTOCOL_PREFIX + myProject.getPresentableUrl() + "/" + Unity3dProjectImportUtil
            .ASSETS_DIRECTORY, this, null);

    startupManager.registerPostStartupActivity(this::checkAndRunIfNeed);
}
项目:tools-idea    文件:XmlUtil.java   
@Nullable
public static XmlFile findXmlFile(PsiFile base, @NotNull String uri) {
  PsiFile result = null;

  if (ApplicationManager.getApplication().isUnitTestMode()) {
    String data = base.getOriginalFile().getUserData(TEST_PATH);

    if (data != null) {
      String filePath = data + "/" + uri;
      final VirtualFile path = StandardFileSystems.local().findFileByPath(filePath.replace(File.separatorChar, '/'));
      if (path != null) {
        result = base.getManager().findFile(path);
      }
    }
  }
  if (result == null) {
    result = findRelativeFile(uri, base);
  }

  if (result instanceof XmlFile) {
    return (XmlFile)result;
  }

  return null;
}
项目:consulo    文件:ModuleManagerImpl.java   
@Override
@Nonnull
public Module newModule(@Nonnull @NonNls String name, @Nullable @NonNls String dirPath) {
  assertWritable();

  final String dirUrl = dirPath == null ? null : VirtualFileManager.constructUrl(StandardFileSystems.FILE_PROTOCOL, dirPath);

  ModuleEx moduleEx = null;
  if (dirUrl != null) {
    moduleEx = getModuleByDirUrl(dirUrl);
  }

  if (moduleEx == null) {
    moduleEx = createModule(name, dirUrl, null);
    initModule(moduleEx);
  }
  return moduleEx;
}
项目:consulo    文件:PersistentFSTest.java   
public void testFindRootShouldNotBeFooledByRelativePath() throws IOException {
  File tmp = createTempDirectory();
  File x = new File(tmp, "x.jar");
  x.createNewFile();
  LocalFileSystem lfs = LocalFileSystem.getInstance();
  VirtualFile vx = lfs.refreshAndFindFileByIoFile(x);
  assertNotNull(vx);
  ArchiveFileSystem jfs = (ArchiveFileSystem)StandardFileSystems.jar();
  VirtualFile root = ArchiveVfsUtil.getArchiveRootForLocalFile(vx);

  PersistentFS fs = PersistentFS.getInstance();

  String path = vx.getPath() + "/../" + vx.getName() + ArchiveFileSystem.ARCHIVE_SEPARATOR;
  NewVirtualFile root1 = fs.findRoot(path, (NewVirtualFileSystem)jfs);

  assertSame(root1, root);
}
项目:intellij-ce-playground    文件:ClsMirrorBuildingTest.java   
public void testDocumentReuse() throws IOException {
  File classFile = new File(FileUtil.getTempDirectory(), "ReuseTest.class");
  FileUtil.writeToFile(classFile, "");
  VirtualFile vFile = StandardFileSystems.local().findFileByPath(classFile.getPath());
  assertNotNull(classFile.getPath(), vFile);
  PsiFile psiFile = PsiManager.getInstance(getProject()).findFile(vFile);
  assertNotNull(psiFile);
  String testDir = getTestDataDir();

  FileUtil.copy(new File(testDir, "pkg/ReuseTestV1.class"), classFile);
  vFile.refresh(false, false);
  PsiDocumentManager.getInstance(getProject()).commitAllDocuments();
  String text1 = psiFile.getText();
  assertTrue(text1, text1.contains("private int f1"));
  assertFalse(text1, text1.contains("private int f2"));
  Document doc1 = FileDocumentManager.getInstance().getCachedDocument(vFile);
  assertNotNull(doc1);
  assertSame(doc1, PsiDocumentManager.getInstance(getProject()).getDocument(psiFile));

  FileUtil.copy(new File(testDir, "pkg/ReuseTestV2.class"), classFile);
  vFile.refresh(false, false);
  PsiDocumentManager.getInstance(getProject()).commitAllDocuments();
  String text2 = psiFile.getText();
  assertTrue(text2, text2.contains("private int f1"));
  assertTrue(text2, text2.contains("private int f2"));
  Document doc2 = FileDocumentManager.getInstance().getCachedDocument(vFile);
  assertNotNull(doc2);
  assertSame(doc2, PsiDocumentManager.getInstance(getProject()).getDocument(psiFile));
}
项目:intellij-ce-playground    文件:ClsMirrorBuildingTest.java   
public void testElementAt() {
  String path = getTestDataDir() + "/pkg/SimpleEnum.class";
  VirtualFile vFile = StandardFileSystems.local().findFileByPath(path);
  assertNotNull(path, vFile);
  PsiFile psiFile = PsiManager.getInstance(getProject()).findFile(vFile);
  assertNotNull(path, psiFile);
  for (int i = 0; i < psiFile.getTextLength(); i++) {
    PsiElement element = psiFile.findElementAt(i);
    assertTrue(i + ":" + element, element == null || element instanceof ClsElementImpl && !(element instanceof PsiFile));
  }
}
项目:intellij-ce-playground    文件:ClsMirrorBuildingTest.java   
private static void doTest(String clsPath, String txtPath) {
  VirtualFile file = (clsPath.contains("!/") ? StandardFileSystems.jar() : StandardFileSystems.local()).findFileByPath(clsPath);
  assertNotNull(clsPath, file);

  String expected;
  try {
    expected = StringUtil.trimTrailing(PlatformTestUtil.loadFileText(txtPath));
  }
  catch (IOException e) {
    throw new RuntimeException(e);
  }

  assertEquals(expected, ClsFileImpl.decompile(file).toString());
}
项目:intellij-ce-playground    文件:SourceResolver.java   
protected Url canonicalizeUrl(@NotNull String url, @Nullable Url baseUrl, boolean trimFileScheme, int sourceIndex, boolean baseUrlIsFile) {
  if (trimFileScheme && url.startsWith(StandardFileSystems.FILE_PROTOCOL_PREFIX)) {
    return Urls.newLocalFileUrl(FileUtil.toCanonicalPath(VfsUtilCore.toIdeaUrl(url, true).substring(StandardFileSystems.FILE_PROTOCOL_PREFIX.length()), '/'));
  }
  else if (baseUrl == null || url.contains(URLUtil.SCHEME_SEPARATOR) || url.startsWith("data:") || url.startsWith("blob:") || url.startsWith("javascript:")) {
    return Urls.parseEncoded(url);
  }

  String path = canonicalizePath(url, baseUrl, baseUrlIsFile);
  if (baseUrl.getScheme() == null && baseUrl.isInLocalFileSystem()) {
    return Urls.newLocalFileUrl(path);
  }

  // browserify produces absolute path in the local filesystem
  if (isAbsolute(path)) {
    VirtualFile file = LocalFileFinder.findFile(path);
    if (file != null) {
      if (absoluteLocalPathToSourceIndex == null) {
        // must be linked, on iterate original path must be first
        absoluteLocalPathToSourceIndex = createStringIntMap(rawSources.size());
        sourceIndexToAbsoluteLocalPath = new String[rawSources.size()];
      }
      absoluteLocalPathToSourceIndex.put(path, sourceIndex);
      sourceIndexToAbsoluteLocalPath[sourceIndex] = path;
      String canonicalPath = file.getCanonicalPath();
      if (canonicalPath != null && !canonicalPath.equals(path)) {
        absoluteLocalPathToSourceIndex.put(canonicalPath, sourceIndex);
      }
      return Urls.newLocalFileUrl(path);
    }
  }
  return new UrlImpl(baseUrl.getScheme(), baseUrl.getAuthority(), path, null);
}
项目:intellij-ce-playground    文件:ProjectJdkImpl.java   
@Override
public VirtualFile getHomeDirectory() {
  if (myHomePath == null) {
    return null;
  }
  return StandardFileSystems.local().findFileByPath(myHomePath);
}
项目:intellij-ce-playground    文件:LibraryImpl.java   
public static void collectJarFiles(final VirtualFile dir, final List<VirtualFile> container, final boolean recursively) {
  VfsUtilCore.visitChildrenRecursively(dir, new VirtualFileVisitor(SKIP_ROOT, recursively ? null : ONE_LEVEL_DEEP) {
    @Override
    public boolean visitFile(@NotNull VirtualFile file) {
      final VirtualFile jarRoot = file.isDirectory() ? null : StandardFileSystems.getJarRootForLocalFile(file);
      if (jarRoot != null) {
        container.add(jarRoot);
        return false;
      }
      return true;
    }
  });
}
项目:intellij-ce-playground    文件:PathsList.java   
@Override
public VirtualFile fun(String s) {
  final FileType fileType = FileTypeRegistry.getInstance().getFileTypeByFileName(s);
  final VirtualFile localFile = PATH_TO_LOCAL_VFILE.fun(s);
  if (localFile == null) return null;

  if (ArchiveFileType.INSTANCE.equals(fileType) && !localFile.isDirectory()) {
    return StandardFileSystems.getJarRootForLocalFile(localFile);
  }
  return localFile;
}
项目:intellij-ce-playground    文件:ExternalSystemUtil.java   
@Nullable
public static VirtualFile findLocalFileByPath(String path) {
  VirtualFile result = StandardFileSystems.local().findFileByPath(path);
  if (result != null) return result;

  return !ApplicationManager.getApplication().isReadAccessAllowed()
         ? findLocalFileByPathUnderWriteAction(path)
         : findLocalFileByPathUnderReadAction(path);
}
项目:intellij-ce-playground    文件:ExternalSystemUtil.java   
@Nullable
private static VirtualFile findLocalFileByPathUnderWriteAction(final String path) {
  return doWriteAction(new Computable<VirtualFile>() {
    @Override
    public VirtualFile compute() {
      return StandardFileSystems.local().refreshAndFindFileByPath(path);
    }
  });
}
项目:intellij-ce-playground    文件:ExternalSystemUtil.java   
@Nullable
private static VirtualFile findLocalFileByPathUnderReadAction(final String path) {
  return ApplicationManager.getApplication().runReadAction(new Computable<VirtualFile>() {
    @Override
    public VirtualFile compute() {
      return StandardFileSystems.local().findFileByPath(path);
    }
  });
}
项目:intellij-ce-playground    文件:Urls.java   
@Nullable
private static Url parseUrl(@NotNull CharSequence url) {
  CharSequence urlToParse;
  if (StringUtil.startsWith(url, "jar:file://")) {
    urlToParse = url.subSequence("jar:".length(), url.length());
  }
  else {
    urlToParse = url;
  }

  Matcher matcher = URI_PATTERN.matcher(urlToParse);
  if (!matcher.matches()) {
    return null;
  }
  String scheme = matcher.group(1);
  if (urlToParse != url) {
    scheme = "jar:" + scheme;
  }

  String authority = StringUtil.nullize(matcher.group(3));
  String path = StringUtil.nullize(matcher.group(4));
  boolean hasUrlSeparator = !StringUtil.isEmpty(matcher.group(2));
  if (authority == null) {
    if (hasUrlSeparator) {
      authority = "";
    }
  }
  else if (StandardFileSystems.FILE_PROTOCOL.equals(scheme) || !hasUrlSeparator) {
    path = path == null ? authority : (authority + path);
    authority = hasUrlSeparator ? "" : null;
  }

  // canonicalize only if authority is not empty or file url - we should not canonicalize URL with unknown scheme (webpack:///./modules/flux-orion-plugin/fluxPlugin.ts)
  if (path != null && (!StringUtil.isEmpty(authority) || StandardFileSystems.FILE_PROTOCOL.equals(scheme))) {
    path = FileUtil.toCanonicalUriPath(path);
  }
  return new UrlImpl(scheme, authority, path, matcher.group(5));
}
项目:intellij-ce-playground    文件:PythonSdkUpdater.java   
/**
 * Updates binary skeletons path in the Python SDK table.
 */
private static void updateBinarySkeletonsPath(@NotNull PySdkUpdater sdkUpdater) {
  final String skeletonsPath = PythonSdkType.getSkeletonsPath(PathManager.getSystemPath(), sdkUpdater.getHomePath());
  if (skeletonsPath != null) {
    final VirtualFile skeletonsDir = StandardFileSystems.local().refreshAndFindFileByPath(skeletonsPath);
    if (skeletonsDir != null) {
      updateSkeletonsPath(sdkUpdater, skeletonsDir, PythonSdkType.SKELETON_DIR_NAME, "Binary skeletons");
    }
  }
}
项目:intellij-ce-playground    文件:SdkHomeSettings.java   
@Nullable
private static VirtualFile calcHome(final SdkHomeBean state) {
  if (state == null) {
    return null;
  }

  @SuppressWarnings({"NonPrivateFieldAccessedInSynchronizedContext"}) final String sdk_home = state.SDK_HOME;
  if (StringUtil.isEmpty(sdk_home)) {
    return null;
  }

  return StandardFileSystems.local().findFileByPath(sdk_home);
}
项目:spoofax-intellij    文件:DefaultIntelliJResourceService.java   
/**
 * Returns the IntelliJ virtual file system for the specified URI.
 *
 * @param uri The URI.
 * @return The file system; or <code>null</code> if not found.
 */
@Nullable
private VirtualFileSystem getFileSystem(final URI uri) {
    switch (uri.getScheme()) {
        case "file":
            return StandardFileSystems.local();
        case "zip":
        case "jar":
            return StandardFileSystems.jar();
        default:
            return null;
    }
}
项目:tools-idea    文件:ProjectJdkImpl.java   
@Override
public VirtualFile getHomeDirectory() {
  if (myHomePath == null) {
    return null;
  }
  return StandardFileSystems.local().findFileByPath(myHomePath);
}
项目:tools-idea    文件:SimpleProjectRoot.java   
@Override
@NotNull
public String getPresentableString() {
  String path = VirtualFileManager.extractPath(myUrl);
  if (path.endsWith(StandardFileSystems.JAR_SEPARATOR)) {
    path = path.substring(0, path.length() - StandardFileSystems.JAR_SEPARATOR.length());
  }
  return path.replace('/', File.separatorChar);
}
项目:tools-idea    文件:ModuleManagerImpl.java   
public final void writeExternal(Element parentElement) {
  Element moduleElement = new Element(ELEMENT_MODULE);
  final String moduleFilePath = getModuleFilePath();
  final String url = VirtualFileManager.constructUrl(StandardFileSystems.FILE_PROTOCOL, moduleFilePath);
  moduleElement.setAttribute(ATTRIBUTE_FILEURL, url);
  // [dsl] support for older builds
  moduleElement.setAttribute(ATTRIBUTE_FILEPATH, moduleFilePath);

  final String groupPath = getGroupPathString();
  if (groupPath != null) {
    moduleElement.setAttribute(ATTRIBUTE_GROUP, groupPath);
  }
  parentElement.addContent(moduleElement);
}
项目:tools-idea    文件:LibraryImpl.java   
public static void collectJarFiles(final VirtualFile dir, final List<VirtualFile> container, final boolean recursively) {
  VfsUtilCore.visitChildrenRecursively(dir, new VirtualFileVisitor(SKIP_ROOT, (recursively ? null : ONE_LEVEL_DEEP)) {
    @Override
    public boolean visitFile(@NotNull VirtualFile file) {
      final VirtualFile jarRoot = StandardFileSystems.getJarRootForLocalFile(file);
      if (jarRoot != null) {
        container.add(jarRoot);
        return false;
      }
      return true;
    }
  });
}
项目:tools-idea    文件:ProjectRootManagerImpl.java   
public static String extractLocalPath(final String url) {
  final String path = VfsUtilCore.urlToPath(url);
  final int jarSeparatorIndex = path.indexOf(StandardFileSystems.JAR_SEPARATOR);
  if (jarSeparatorIndex > 0) {
    return path.substring(0, jarSeparatorIndex);
  }
  return path;
}
项目:tools-idea    文件:PathsList.java   
@Override
public VirtualFile fun(String s) {
  final FileType fileType = FileTypeRegistry.getInstance().getFileTypeByFileName(s);
  final VirtualFile localFile = PATH_TO_LOCAL_VFILE.fun(s);
  if (localFile == null) return null;

  if (ArchiveFileType.INSTANCE.equals(fileType) && !localFile.isDirectory()) {
    return StandardFileSystems.getJarRootForLocalFile(localFile);
  }
  return localFile;
}
项目:tools-idea    文件:PathUtil.java   
@Nullable
public static String getLocalPath(@Nullable VirtualFile file) {
  if (file == null || !file.isValid()) {
    return null;
  }
  if (file.getFileSystem().getProtocol().equals(StandardFileSystems.JAR_PROTOCOL) && file.getParent() != null) {
    return null;
  }
  return getLocalPath(file.getPath());
}
项目:tools-idea    文件:BaseFilterLexerUtil.java   
public static ScanContent scanContent(FileContent content, IdAndToDoScannerBasedOnFilterLexer indexer) {
  ScanContent data = content.getUserData(scanContentKey);
  if (data != null) {
    content.putUserData(scanContentKey, null);
    return data;
  }

  final boolean needTodo = content.getFile().getFileSystem().getProtocol().equals(StandardFileSystems.FILE_PROTOCOL);
  final boolean needIdIndex = IdTableBuilding.getFileTypeIndexer(content.getFileType()) instanceof LexerBasedIdIndexer;

  final IdDataConsumer consumer = needIdIndex? new IdDataConsumer():null;
  final OccurrenceConsumer todoOccurrenceConsumer = new OccurrenceConsumer(consumer, needTodo);
  final Lexer filterLexer = indexer.createLexer(todoOccurrenceConsumer);
  filterLexer.start(content.getContentAsText());

  while (filterLexer.getTokenType() != null) filterLexer.advance();

  Map<TodoIndexEntry,Integer> todoMap = null;
  if (needTodo) {
    for (IndexPattern indexPattern : IndexPatternUtil.getIndexPatterns()) {
        final int count = todoOccurrenceConsumer.getOccurrenceCount(indexPattern);
        if (count > 0) {
          if (todoMap == null) todoMap = new THashMap<TodoIndexEntry, Integer>();
          todoMap.put(new TodoIndexEntry(indexPattern.getPatternString(), indexPattern.isCaseSensitive()), count);
        }
      }
  }

  data = new ScanContent(
    consumer != null? consumer.getResult():Collections.<IdIndexEntry, Integer>emptyMap(),
    todoMap != null ? todoMap: Collections.<TodoIndexEntry,Integer>emptyMap()
  );
  if (needIdIndex && needTodo) content.putUserData(scanContentKey, data);
  return data;
}
项目:tools-idea    文件:Urls.java   
@Nullable
private static Url parseUrl(@NotNull String url, boolean urlAsRaw) {
  String urlToParse;
  if (url.startsWith("jar:file://")) {
    urlToParse = url.substring("jar:".length());
  }
  else {
    urlToParse = url;
  }

  Matcher matcher = URI_PATTERN.matcher(urlToParse);
  if (!matcher.matches()) {
    LOG.warn("Cannot parse url " + url);
    return null;
  }
  String scheme = matcher.group(1);
  if (urlToParse != url) {
    scheme = "jar:" + scheme;
  }

  String authority = StringUtil.nullize(matcher.group(2));

  String path = StringUtil.nullize(matcher.group(3));
  if (path != null) {
    path = FileUtil.toCanonicalUriPath(path);
  }

  String parameters = matcher.group(4);
  if (authority != null && StandardFileSystems.FILE_PROTOCOL.equals(scheme)) {
    path = path == null ? authority : (authority + path);
    authority = null;
  }
  return new UrlImpl(urlAsRaw ? url : null, scheme, authority, path, parameters);
}
项目:consulo    文件:SdkImpl.java   
@Override
public VirtualFile getHomeDirectory() {
  if (myHomePath == null) {
    return null;
  }
  return StandardFileSystems.local().findFileByPath(myHomePath);
}
项目:consulo    文件:BasicsTest.java   
public void testDoNotRegisterChangesNotInLocalFS() throws Exception {
  File f = new File(myRoot.getPath(), "f.jar");
  JarOutputStream jar = new JarOutputStream(new FileOutputStream(f));

  jar.putNextEntry(new JarEntry("file.txt"));
  jar.write(1);
  jar.closeEntry();
  jar.close();

  VirtualFile vfile = LocalFileSystem.getInstance().refreshAndFindFileByIoFile(f);
  assertNotNull(vfile);

  VirtualFile jarRoot = ArchiveVfsUtil.getArchiveRootForLocalFile(vfile);
  assertEquals(1, jarRoot.findChild("file.txt").contentsToByteArray()[0]);

  assertEquals(2, getRevisionsFor(myRoot).size());

  jar = new JarOutputStream(new FileOutputStream(f));

  JarEntry e = new JarEntry("file.txt");
  e.setTime(f.lastModified() + 10000);
  jar.putNextEntry(e);
  jar.write(2);
  jar.closeEntry();
  jar.close();
  f.setLastModified(f.lastModified() + 10000);

  LocalFileSystem.getInstance().refreshWithoutFileWatcher(false);
  StandardFileSystems.jar().refresh(false);
  jarRoot = ArchiveVfsUtil.getArchiveRootForLocalFile(vfile);
  assertEquals(2, jarRoot.findChild("file.txt").contentsToByteArray()[0]);

  assertEquals(2, getRevisionsFor(myRoot).size());
  assertEquals(1, getRevisionsFor(jarRoot).size());
}
项目:consulo    文件:Urls.java   
@Nullable
private static Url parseUrl(@Nonnull String url) {
  String urlToParse;
  if (url.startsWith("jar:file://")) {
    urlToParse = url.substring("jar:".length());
  }
  else {
    urlToParse = url;
  }

  Matcher matcher = URI_PATTERN.matcher(urlToParse);
  if (!matcher.matches()) {
    return null;
  }
  String scheme = matcher.group(1);
  if (urlToParse != url) {
    scheme = "jar:" + scheme;
  }

  String authority = StringUtil.nullize(matcher.group(3));

  String path = StringUtil.nullize(matcher.group(4));
  if (path != null) {
    path = FileUtil.toCanonicalUriPath(path);
  }

  if (authority != null && (StandardFileSystems.FILE_PROTOCOL.equals(scheme) || StringUtil.isEmpty(matcher.group(2)))) {
    path = path == null ? authority : (authority + path);
    authority = null;
  }
  return new UrlImpl(scheme, authority, path, matcher.group(5));
}
项目:consulo-xml    文件:XmlUtil.java   
@Nullable
public static XmlFile findXmlFile(PsiFile base, @NotNull String uri)
{
    PsiFile result = null;

    if(ApplicationManager.getApplication().isUnitTestMode())
    {
        String data = base.getOriginalFile().getUserData(TEST_PATH);

        if(data != null)
        {
            String filePath = data + "/" + uri;
            final VirtualFile path = StandardFileSystems.local().findFileByPath(filePath.replace(File.separatorChar, '/'));
            if(path != null)
            {
                result = base.getManager().findFile(path);
            }
        }
    }
    if(result == null)
    {
        result = findRelativeFile(uri, base);
    }

    if(result instanceof XmlFile)
    {
        return (XmlFile) result;
    }

    return null;
}
项目:intellij-ce-playground    文件:BasePathMacroManager.java   
@NotNull
private static VirtualFileSystem getLocalFileSystem() {
  // Use VFM directly because of mocks in tests.
  return VirtualFileManager.getInstance().getFileSystem(StandardFileSystems.FILE_PROTOCOL);
}
项目:intellij-ce-playground    文件:PathsList.java   
@Override
public VirtualFile fun(String path) {
  return StandardFileSystems.local().findFileByPath(path.replace(File.separatorChar, '/'));
}
项目:intellij-ce-playground    文件:UrlImpl.java   
@Override
public boolean isInLocalFileSystem() {
  return StandardFileSystems.FILE_PROTOCOL.equals(scheme);
}
项目:intellij-ce-playground    文件:CoreLocalFileSystem.java   
@NotNull
@Override
public String getProtocol() {
  return StandardFileSystems.FILE_PROTOCOL;
}