Java 类com.intellij.openapi.vfs.ex.http.HttpFileSystem 实例源码

项目:intellij-ce-playground    文件:FileAppearanceServiceImpl.java   
@NotNull
@Override
public CellAppearanceEx forVirtualFile(@NotNull final VirtualFile file) {
  if (!file.isValid()) {
    return forInvalidUrl(file.getPresentableUrl());
  }

  final VirtualFileSystem fileSystem = file.getFileSystem();
  if (fileSystem.getProtocol().equals(JarFileSystem.PROTOCOL)) {
    return new JarSubfileCellAppearance(file);
  }
  if (fileSystem instanceof HttpFileSystem) {
    return new HttpUrlCellAppearance(file);
  }
  if (file.isDirectory()) {
    return SimpleTextCellAppearance.regular(file.getPresentableUrl(), PlatformIcons.FOLDER_ICON);
  }
  return new ValidFileCellAppearance(file);
}
项目:intellij-ce-playground    文件:PathEditor.java   
private static Icon getIconForRoot(Object projectRoot) {
  if (projectRoot instanceof VirtualFile) {
    VirtualFile file = (VirtualFile)projectRoot;
    if (!file.isValid()) {
      return AllIcons.Nodes.PpInvalid;
    }
    else if (file.getFileSystem() instanceof HttpFileSystem) {
      return PlatformIcons.WEB_ICON;
    }
    else if (isJarFile(file)) {
      return PlatformIcons.JAR_ICON;
    }
    return PlatformIcons.FILE_ICON;
  }

  return AllIcons.Nodes.EmptyNode;
}
项目:intellij-ce-playground    文件:PlatformDocumentationUtil.java   
@Nullable
public static List<String> getHttpRoots(@NotNull String[] roots, String relPath) {
  List<String> result = new SmartList<String>();
  for (String root : roots) {
    VirtualFile virtualFile = VirtualFileManager.getInstance().findFileByUrl(root);
    if (virtualFile != null) {
      if (virtualFile.getFileSystem() instanceof HttpFileSystem) {
        String url = virtualFile.getUrl();
        if (!url.endsWith("/")) {
          url += "/";
        }
        result.add(url + relPath);
      }
      else {
        VirtualFile file = virtualFile.findFileByRelativePath(relPath);
        if (file != null) {
          result.add(file.getUrl());
        }
      }
    }
  }

  return result.isEmpty() ? null : result;
}
项目:intellij-ce-playground    文件:XBreakpointManagerImpl.java   
public XBreakpointManagerImpl(final Project project, final XDebuggerManagerImpl debuggerManager, StartupManager startupManager) {
  myProject = project;
  myDebuggerManager = debuggerManager;
  myAllBreakpointsDispatcher = EventDispatcher.create(XBreakpointListener.class);
  myDependentBreakpointManager = new XDependentBreakpointManager(this);
  myLineBreakpointManager = new XLineBreakpointManager(project, myDependentBreakpointManager, startupManager);
  if (!project.isDefault()) {
    if (!ApplicationManager.getApplication().isUnitTestMode()) {
      HttpVirtualFileListener httpVirtualFileListener = new HttpVirtualFileListener() {
        @Override
        public void fileDownloaded(@NotNull final VirtualFile file) {
          updateBreakpointInFile(file);
        }
      };
      HttpFileSystem.getInstance().addFileListener(httpVirtualFileListener, project);
    }
    for (XBreakpointType<?, ?> type : XBreakpointUtil.getBreakpointTypes()) {
      addDefaultBreakpoint(type);
    }
  }
}
项目:tools-idea    文件:FileAppearanceServiceImpl.java   
@NotNull
@Override
public CellAppearanceEx forVirtualFile(@NotNull final VirtualFile file) {
  if (!file.isValid()) {
    return forInvalidUrl(file.getPresentableUrl());
  }

  final VirtualFileSystem fileSystem = file.getFileSystem();
  if (fileSystem.getProtocol().equals(JarFileSystem.PROTOCOL)) {
    return new JarSubfileCellAppearance(file);
  }
  if (fileSystem instanceof HttpFileSystem) {
    return new HttpUrlCellAppearance(file);
  }
  if (file.isDirectory()) {
    return SimpleTextCellAppearance.regular(file.getPresentableUrl(), PlatformIcons.FOLDER_ICON);
  }
  return new ValidFileCellAppearance(file);
}
项目:tools-idea    文件:PlatformDocumentationUtil.java   
@Nullable
public static List<String> getHttpRoots(final String[] roots, String relPath) {
  final ArrayList<String> result = new ArrayList<String>();
  for (String root : roots) {
    final VirtualFile virtualFile = VirtualFileManager.getInstance().findFileByUrl(root);
    if (virtualFile != null) {
      if (virtualFile.getFileSystem() instanceof HttpFileSystem) {
        String url = virtualFile.getUrl();
        if (!url.endsWith("/")) url += "/";
        result.add(url + relPath);
      }
      else {
        VirtualFile file = virtualFile.findFileByRelativePath(relPath);
        if (file != null) result.add(file.getUrl());
      }
    }
  }

  return result.isEmpty() ? null : result;
}
项目:tools-idea    文件:XBreakpointManagerImpl.java   
public XBreakpointManagerImpl(final Project project, final XDebuggerManagerImpl debuggerManager, StartupManager startupManager) {
  myProject = project;
  myDebuggerManager = debuggerManager;
  myAllBreakpointsDispatcher = EventDispatcher.create(XBreakpointListener.class);
  myDependentBreakpointManager = new XDependentBreakpointManager(this);
  myLineBreakpointManager = new XLineBreakpointManager(project, myDependentBreakpointManager, startupManager);
  if (!project.isDefault() && !ApplicationManager.getApplication().isUnitTestMode()) {
    HttpVirtualFileListener httpVirtualFileListener = new HttpVirtualFileListener() {
      @Override
      public void fileDownloaded(@NotNull final VirtualFile file) {
        updateBreakpointInFile(file);
      }
    };
    HttpFileSystem.getInstance().addFileListener(httpVirtualFileListener, project);
    for (XBreakpointType<?, ?> type : XBreakpointUtil.getBreakpointTypes()) {
      addDefaultBreakpoint(type);
    }
  }
}
项目:consulo    文件:PlatformDocumentationUtil.java   
@Nullable
public static List<String> getHttpRoots(final String[] roots, String relPath) {
  final ArrayList<String> result = new ArrayList<String>();
  for (String root : roots) {
    final VirtualFile virtualFile = VirtualFileManager.getInstance().findFileByUrl(root);
    if (virtualFile != null) {
      if (virtualFile.getFileSystem() instanceof HttpFileSystem) {
        String url = virtualFile.getUrl();
        if (!url.endsWith("/")) url += "/";
        result.add(url + relPath);
      }
      else {
        VirtualFile file = virtualFile.findFileByRelativePath(relPath);
        if (file != null) result.add(file.getUrl());
      }
    }
  }

  return result.isEmpty() ? null : result;
}
项目:consulo    文件:XBreakpointManagerImpl.java   
public XBreakpointManagerImpl(final Project project, final XDebuggerManagerImpl debuggerManager, StartupManager startupManager) {
  myProject = project;
  myDebuggerManager = debuggerManager;
  myAllBreakpointsDispatcher = EventDispatcher.create(XBreakpointListener.class);
  myDependentBreakpointManager = new XDependentBreakpointManager(this);
  myLineBreakpointManager = new XLineBreakpointManager(project, myDependentBreakpointManager, startupManager);
  if (!project.isDefault()) {
    if (!ApplicationManager.getApplication().isUnitTestMode()) {
      HttpVirtualFileListener httpVirtualFileListener = this::updateBreakpointInFile;
      HttpFileSystem.getInstance().addFileListener(httpVirtualFileListener, project);
    }
    for (XBreakpointType<?, ?> type : XBreakpointUtil.getBreakpointTypes()) {
      addDefaultBreakpoint(type);
    }
  }
}
项目:consulo    文件:FileAppearanceServiceImpl.java   
@Nonnull
@Override
public CellAppearanceEx forVirtualFile(@Nonnull final VirtualFile file) {
  if (!file.isValid()) {
    return forInvalidUrl(file.getPresentableUrl());
  }

  final VirtualFileSystem fileSystem = file.getFileSystem();
  if (fileSystem instanceof ArchiveFileSystem) {
    return new JarSubfileCellAppearance(file);
  }
  if (fileSystem instanceof HttpFileSystem) {
    return new HttpUrlCellAppearance(file);
  }
  if (file.isDirectory()) {
    return SimpleTextCellAppearance.regular(file.getPresentableUrl(), AllIcons.Nodes.Folder);
  }
  return new ValidFileCellAppearance(file);
}
项目:intellij-ce-playground    文件:ItemElement.java   
private static Icon getIconForUrl(final String url, final boolean isValid, final boolean isJarDirectory) {
  final Icon icon;
  if (isValid) {
    VirtualFile presentableFile;
    if (isJarFileRoot(url)) {
      presentableFile = LocalFileSystem.getInstance().findFileByPath(getPresentablePath(url));
    }
    else {
      presentableFile = VirtualFileManager.getInstance().findFileByUrl(url);
    }
    if (presentableFile != null && presentableFile.isValid()) {
      if (presentableFile.getFileSystem() instanceof HttpFileSystem) {
        icon = PlatformIcons.WEB_ICON;
      }
      else {
        if (presentableFile.isDirectory()) {
          if (isJarDirectory) {
            icon = AllIcons.Nodes.JarDirectory;
          }
          else {
            icon = PlatformIcons.DIRECTORY_CLOSED_ICON;
          }
        }
        else {
          icon = IconUtilEx.getIcon(presentableFile, 0, null);
        }
      }
    }
    else {
      icon = AllIcons.Nodes.PpInvalid;
    }
  }
  else {
    icon = AllIcons.Nodes.PpInvalid;
  }
  return icon;
}
项目:intellij-ce-playground    文件:XmlResourceResolver.java   
private PsiFile getBaseFile(String baseSystemId) {

    PsiFile baseFile = resolve(null, baseSystemId);
    if (baseFile != null) return baseFile;

    // Find relative to myFile
    File workingFile = new File("");
    String workingDir = workingFile.getAbsoluteFile().getAbsolutePath().replace(File.separatorChar, '/');
    String id = StringUtil.replace(baseSystemId, workingDir, myFile.getVirtualFile().getParent().getPath());
    VirtualFile vFile = UriUtil.findRelative(id, myFile);

    if (vFile == null) {
      vFile = UriUtil.findRelative(baseSystemId, myFile);
    }
    if (vFile == null) {
      try {
        vFile = VirtualFileManager.getInstance().findFileByUrl(VfsUtilCore.convertFromUrl(new URL(baseSystemId)));
      }
      catch (MalformedURLException ignore) {
      }
    }

    if (vFile != null && !vFile.isDirectory() && !(vFile.getFileSystem() instanceof HttpFileSystem)) {
      baseFile = PsiManager.getInstance(myProject).findFile(vFile);
    }
    return baseFile;
  }
项目:intellij-ce-playground    文件:HtmlFileImpl.java   
@Nullable
@Override
public PsiFileSystemItem resolveFileReference(@NotNull FileReference reference, @NotNull String name) {
  VirtualFile file = getVirtualFile();
  if (!(file instanceof HttpVirtualFile)) {
    return null;
  }

  VirtualFile parent = file;
  if (!parent.isDirectory()) {
    parent = parent.getParent();
    if (parent == null) {
      parent = file;
    }
  }

  VirtualFile childFile = parent.findChild(name);
  HttpFileSystem fileSystem = (HttpFileSystem)parent.getFileSystem();
  if (childFile == null) {
    childFile = fileSystem.createChild(parent, name, !reference.isLast());
  }
  if (childFile.isDirectory()) {
    // pre create children
    VirtualFile childParent = childFile;
    FileReference[] references = reference.getFileReferenceSet().getAllReferences();
    for (int i = reference.getIndex() + 1, n = references.length; i < n; i++) {
      FileReference childReference = references[i];
      childParent = fileSystem.createChild(childParent, childReference.decode(childReference.getText()), i != (n - 1));
    }
    return getManager().findDirectory(childFile);
  }
  else {
    return getManager().findFile(childFile);
  }
}
项目:tools-idea    文件:ItemElementDescriptor.java   
private static Icon getIconForUrl(final String url, final boolean isValid, final boolean isJarDirectory) {
  final Icon icon;
  if (isValid) {
    VirtualFile presentableFile;
    if (isJarFileRoot(url)) {
      presentableFile = LocalFileSystem.getInstance().findFileByPath(getPresentablePath(url));
    }
    else {
      presentableFile = VirtualFileManager.getInstance().findFileByUrl(url);
    }
    if (presentableFile != null && presentableFile.isValid()) {
      if (presentableFile.getFileSystem() instanceof HttpFileSystem) {
        icon = PlatformIcons.WEB_ICON;
      }
      else {
        if (presentableFile.isDirectory()) {
          if (isJarDirectory) {
            icon = AllIcons.Nodes.JarDirectory;
          }
          else {
            icon = PlatformIcons.DIRECTORY_CLOSED_ICON;
          }
        }
        else {
          icon = IconUtilEx.getIcon(presentableFile, 0, null);
        }
      }
    }
    else {
      icon = AllIcons.Nodes.PpInvalid;
    }
  }
  else {
    icon = AllIcons.Nodes.PpInvalid;
  }
  return icon;
}
项目:tools-idea    文件:PluginHostsConfigurable.java   
private static String correctRepositoryRule(String input) {
  String protocol = VirtualFileManager.extractProtocol(input);
  if (protocol == null) {
    input = VirtualFileManager.constructUrl(HttpFileSystem.PROTOCOL, input);
  }
  return input;
}
项目:consulo    文件:ItemElement.java   
private static Icon getIconForUrl(final String url, final boolean isValid, final boolean isJarDirectory) {
  final Icon icon;
  if (isValid) {
    VirtualFile presentableFile;
    if (isArchiveFileRoot(url)) {
      presentableFile = LocalFileSystem.getInstance().findFileByPath(getPresentablePath(url));
    }
    else {
      presentableFile = VirtualFileManager.getInstance().findFileByUrl(url);
    }
    if (presentableFile != null && presentableFile.isValid()) {
      if (presentableFile.getFileSystem() instanceof HttpFileSystem) {
        icon = AllIcons.Nodes.PpWeb;
      }
      else {
        if (presentableFile.isDirectory()) {
          if (isJarDirectory) {
            icon = AllIcons.Nodes.JarDirectory;
          }
          else {
            icon = AllIcons.Nodes.TreeClosed;
          }
        }
        else {
          icon = IconUtilEx.getIcon(presentableFile, 0, null);
        }
      }
    }
    else {
      icon = AllIcons.Nodes.PpInvalid;
    }
  }
  else {
    icon = AllIcons.Nodes.PpInvalid;
  }
  return icon;
}
项目:consulo-xml    文件:XmlResourceResolver.java   
private PsiFile getBaseFile(String baseSystemId)
{

    PsiFile baseFile = resolve(null, baseSystemId);
    if(baseFile != null)
    {
        return baseFile;
    }

    // Find relative to myFile
    File workingFile = new File("");
    String workingDir = workingFile.getAbsoluteFile().getAbsolutePath().replace(File.separatorChar, '/');
    String id = StringUtil.replace(baseSystemId, workingDir, myFile.getVirtualFile().getParent().getPath());
    VirtualFile vFile = UriUtil.findRelative(id, myFile);

    if(vFile == null)
    {
        vFile = UriUtil.findRelative(baseSystemId, myFile);
    }
    if(vFile == null)
    {
        try
        {
            vFile = VirtualFileManager.getInstance().findFileByUrl(VfsUtilCore.convertFromUrl(new URL(baseSystemId)));
        }
        catch(MalformedURLException ignore)
        {
        }
    }

    if(vFile != null && !vFile.isDirectory() && !(vFile.getFileSystem() instanceof HttpFileSystem))
    {
        baseFile = PsiManager.getInstance(myProject).findFile(vFile);
    }
    return baseFile;
}
项目:intellij-ce-playground    文件:PathEditor.java   
protected boolean isUrlInserted() {
  if (getRowCount() > 0) {
    return ((VirtualFile)getListModel().lastElement()).getFileSystem() instanceof HttpFileSystem;
  }
  return false;
}
项目:intellij-ce-playground    文件:EJavadocUtil.java   
private static String toEclipseJavadocPath(ModuleRootModel model, String javadocPath) {
  final String protocol = VirtualFileManager.extractProtocol(javadocPath);
  if (!Comparing.strEqual(protocol, HttpFileSystem.getInstance().getProtocol())) {
    final String path = VfsUtil.urlToPath(javadocPath);
    final VirtualFile contentRoot = getContentRoot(model);
    final Project project = model.getModule().getProject();
    final VirtualFile baseDir = contentRoot != null ? contentRoot.getParent() : project.getBaseDir();
    if (Comparing.strEqual(protocol, JarFileSystem.getInstance().getProtocol())) {
      final VirtualFile javadocFile =
        JarFileSystem.getInstance().getVirtualFileForJar(VirtualFileManager.getInstance().findFileByUrl(javadocPath));
      if (javadocFile != null) {
        final String relativeUrl;
        if (contentRoot != null && VfsUtilCore.isAncestor(contentRoot, javadocFile, false)) {
          relativeUrl = "/" + VfsUtilCore.getRelativePath(javadocFile, baseDir, '/');
        } else {
          relativeUrl = collapse2eclipseRelative2OtherModule(project, javadocFile);
        }
        if (relativeUrl != null) {
          if (!javadocPath.contains(JarFileSystem.JAR_SEPARATOR)) {
            javadocPath = StringUtil.trimEnd(javadocPath, "/") + JarFileSystem.JAR_SEPARATOR;
          }
          javadocPath = JAR_PREFIX +
                        PLATFORM_PROTOCOL +
                        "resource" +
                        relativeUrl +
                        javadocPath.substring(javadocFile.getUrl().length() - 1);
        }
        else {
          LOG.info("Javadoc path: " + javadocPath);
          final Module module = ModuleUtil.findModuleForFile(javadocFile, project);
          LOG.info("Module: " + (module != null ? module.getName() : "not found"));
          if (module != null) {
            LOG.info("Content roots: " + Arrays.toString(ModuleRootManager.getInstance(module).getContentRoots()));
          }
          javadocPath = JAR_PREFIX + FILE_PROTOCOL + StringUtil.trimStart(path, "/");
        }
      }
      else {
        javadocPath = JAR_PREFIX + FILE_PROTOCOL + StringUtil.trimStart(path, "/");
      }
    }
    else if (new File(path).exists()) {
      javadocPath = FILE_PROTOCOL + StringUtil.trimStart(path, "/");
    }
  }
  return javadocPath;
}
项目:tools-idea    文件:PathEditor.java   
protected boolean isUrlInserted() {
  if (getRowCount() > 0) {
    return ((VirtualFile)getListModel().lastElement()).getFileSystem() instanceof HttpFileSystem;
  }
  return false;
}
项目:tools-idea    文件:PathEditor.java   
private static boolean isHttpRoot(VirtualFile virtualFileOrProjectRoot) {
  if (virtualFileOrProjectRoot != null) {
    return (virtualFileOrProjectRoot.getFileSystem() instanceof HttpFileSystem);
  }
  return false;
}
项目:tools-idea    文件:EJavadocUtil.java   
private static String toEclipseJavadocPath(ModuleRootModel model, String javadocPath) {
  final String protocol = VirtualFileManager.extractProtocol(javadocPath);
  if (!Comparing.strEqual(protocol, HttpFileSystem.getInstance().getProtocol())) {
    final String path = VfsUtil.urlToPath(javadocPath);
    final VirtualFile contentRoot = getContentRoot(model);
    final Project project = model.getModule().getProject();
    final VirtualFile baseDir = contentRoot != null ? contentRoot.getParent() : project.getBaseDir();
    if (Comparing.strEqual(protocol, JarFileSystem.getInstance().getProtocol())) {
      final VirtualFile javadocFile =
        JarFileSystem.getInstance().getVirtualFileForJar(VirtualFileManager.getInstance().findFileByUrl(javadocPath));
      if (javadocFile != null) {
        final String relativeUrl;
        if (contentRoot != null && VfsUtilCore.isAncestor(contentRoot, javadocFile, false)) {
          relativeUrl = "/" + VfsUtilCore.getRelativePath(javadocFile, baseDir, '/');
        } else {
          relativeUrl = collapse2eclipseRelative2OtherModule(project, javadocFile);
        }
        if (relativeUrl != null) {
          if (!javadocPath.contains(JarFileSystem.JAR_SEPARATOR)) {
            javadocPath = StringUtil.trimEnd(javadocPath, "/") + JarFileSystem.JAR_SEPARATOR;
          }
          javadocPath = JAR_PREFIX +
                        PLATFORM_PROTOCOL +
                        "resource" +
                        relativeUrl +
                        javadocPath.substring(javadocFile.getUrl().length() - 1);
        }
        else {
          LOG.info("Javadoc path: " + javadocPath);
          final Module module = ModuleUtil.findModuleForFile(javadocFile, project);
          LOG.info("Module: " + (module != null ? module.getName() : "not found"));
          if (module != null) {
            LOG.info("Content roots: " + Arrays.toString(ModuleRootManager.getInstance(module).getContentRoots()));
          }
          javadocPath = JAR_PREFIX + FILE_PROTOCOL + StringUtil.trimStart(path, "/");
        }
      }
      else {
        javadocPath = JAR_PREFIX + FILE_PROTOCOL + StringUtil.trimStart(path, "/");
      }
    }
    else if (new File(path).exists()) {
      javadocPath = FILE_PROTOCOL + StringUtil.trimStart(path, "/");
    }
  }
  return javadocPath;
}
项目:consulo    文件:PathEditor.java   
protected boolean isUrlInserted() {
  if (getRowCount() > 0) {
    return ((VirtualFile)getListModel().lastElement()).getFileSystem() instanceof HttpFileSystem;
  }
  return false;
}
项目:consulo    文件:PathEditor.java   
private static boolean isHttpRoot(VirtualFile virtualFileOrProjectRoot) {
  if (virtualFileOrProjectRoot != null) {
    return (virtualFileOrProjectRoot.getFileSystem() instanceof HttpFileSystem);
  }
  return false;
}