PageRenderTime 49ms CodeModel.GetById 11ms RepoModel.GetById 1ms app.codeStats 0ms

/bundles/plugins-trunk/JavaInsight/javainsight/JasminVFS.java

#
Java | 90 lines | 42 code | 21 blank | 27 comment | 2 complexity | 32dd6b90efea814fb0d6805b753bd702 MD5 | raw file
Possible License(s): BSD-3-Clause, AGPL-1.0, Apache-2.0, LGPL-2.0, LGPL-3.0, GPL-2.0, CC-BY-SA-3.0, LGPL-2.1, GPL-3.0, MPL-2.0-no-copyleft-exception, IPL-1.0
  1. /*
  2. * JasminVFS.java
  3. * Copyright (c) 2001, 2002 Andre Kaplan
  4. *
  5. * This program is free software; you can redistribute it and/or
  6. * modify it under the terms of the GNU General Public License
  7. * as published by the Free Software Foundation; either version 2
  8. * of the License, or any later version.
  9. *
  10. * This program is distributed in the hope that it will be useful,
  11. * but WITHOUT ANY WARRANTY; without even the implied warranty of
  12. * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
  13. * GNU General Public License for more details.
  14. *
  15. * You should have received a copy of the GNU General Public License
  16. * along with this program; if not, write to the Free Software
  17. * Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
  18. */
  19. package javainsight;
  20. import java.awt.Component;
  21. import java.io.*;
  22. import org.apache.bcel.classfile.ClassParser;
  23. import org.apache.bcel.classfile.JavaClass;
  24. import org.gjt.sp.jedit.io.VFS;
  25. import org.gjt.sp.jedit.io.VFSManager;
  26. import org.gjt.sp.util.Log;
  27. public class JasminVFS extends ByteCodeVFS
  28. {
  29. public static final String PROTOCOL = "jasmin";
  30. public JasminVFS() {
  31. super(PROTOCOL);
  32. }
  33. /**
  34. * Creates an input stream. This method is called from the I/O
  35. * thread.
  36. * @param session the VFS session
  37. * @param path The path
  38. * @param ignoreErrors If true, file not found errors should be
  39. * ignored
  40. * @param comp The component that will parent error dialog boxes
  41. */
  42. @Override
  43. public InputStream _createInputStream(Object session,
  44. String path, boolean ignoreErrors, Component comp)
  45. {
  46. String clazzPath = path;
  47. if (path.startsWith(PROTOCOL + ':')) {
  48. clazzPath = clazzPath.substring(PROTOCOL.length() + 1);
  49. }
  50. VFS vfs = VFSManager.getVFSForPath(clazzPath);
  51. if (clazzPath.endsWith(".marks")) {
  52. return null;
  53. }
  54. try {
  55. InputStream in = vfs._createInputStream(session, clazzPath, ignoreErrors, comp);
  56. JavaClass java_class = new ClassParser(in, clazzPath).parse();
  57. StringWriter out = new StringWriter();
  58. new JasminVisitor(java_class, out).disassemble();
  59. out.close();
  60. return new BufferedInputStream(new ByteArrayInputStream(
  61. out.toString().replace("\r", "").getBytes()));
  62. } catch (IOException ioe) {
  63. Log.log(Log.ERROR, this, ioe);
  64. } catch (Exception e) {
  65. Log.log(Log.ERROR, this, e);
  66. }
  67. return null;
  68. }
  69. }