Java 类com.intellij.openapi.vfs.impl.jar.JarFileSystemImpl 实例源码

项目:manifold-ij    文件:IjResource.java   
public VirtualFile resolveVirtualFile()
{
  if( _virtualFile == null )
  {
    //try re-resolve virtual file if it null
    _virtualFile = LocalFileSystemImpl.getInstance().findFileByPath( _path );
    if( _virtualFile == null && _path.contains( ".jar!" ) )
    {
      _virtualFile = JarFileSystemImpl.getInstance().findFileByPath( _path );
    }
  }
  return _virtualFile;
}
项目:manifold-ij    文件:IjFileSystem.java   
IFile getIFile( String pathString )
{
  VirtualFile file = LocalFileSystemImpl.getInstance().findFileByPath( pathString );
  if( file == null && pathString.contains( ".jar!" ) )
  {
    file = JarFileSystemImpl.getInstance().findFileByPath( pathString );
  }
  return file != null ? new IjFile( this, file ) : new IjFile( this, pathString );
}
项目:intellij-ce-playground    文件:LoaderFactory.java   
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);
}
项目:tools-idea    文件:LoaderFactory.java   
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);
}
项目:spoofax-intellij    文件:MetaborgSdkType.java   
/**
     * Returns a list of SDK files.
     *
     * @param sdkHomePath The SDK home path.
     * @return A list of pairs of SDK jar filenames and files. A file can be <code>null</code> if it doesn't exist.
     * Otherwise, a file's {@link VirtualFile#exists()} may return <code>false</code>.
     */
    private List<Pair<String, VirtualFile>> getSdkJars(final String sdkHomePath) {

        // Specify the Metaborg SDK dependencies in this file.
        final URL url = Resources.getResource(SpoofaxIdeaPlugin.class, "/sdk_libraries.txt");

        // The JARs mentioned must be in the plugin's lib folder (plugins/org.metaborg.intellij/lib)
        // at runtime. To get them there, the JAR must either be a dependency of this plugin (as plugin
        // dependencies are automatically copied to the lib folder), or it must be copied or
        // downloaded to the lib folder at runtime (e.g. from a Maven repository). The LibraryService
        // can help you download stuff to the lib folder.

        final String text;
        try {
            text = Resources.toString(url, Charsets.UTF_8);
        } catch (final IOException e) {
            throw LoggerUtils2.exception(this.logger, UnhandledException.class,
                    "Cannot get resource content of resource: {}", e, url);
        }

        final String[] filenames = text.split("\\r?\\n");

        final List<Pair<String, VirtualFile>> files = new ArrayList<>(filenames.length);
        for (final String filename : filenames) {
            final String finalFilename = filename.replace("${version}", SpoofaxPlugin.INSTANCE.getVersion());

            final File file = new File(sdkHomePath, finalFilename);

            @Nullable final VirtualFile virtualFile = LocalFileSystem.getInstance().findFileByIoFile(file);
//            if (virtualFile == null) {
//                files.add(null);
//                continue;
//            }

            @Nullable final VirtualFile jarFile = virtualFile != null ? JarFileSystemImpl.getInstance().getJarRootForLocalFile(virtualFile) : null;
//            if (jarFile == null) {
//                files.add(null);
//                continue;
//            }

            files.add(Pair.of(filename, jarFile));
        }

        return files;
    }