Skip to content

Commit 8fdd057

Browse files
committed
Code folding for bytecode
1 parent e91cdc0 commit 8fdd057

File tree

5 files changed

+1292
-5615
lines changed

5 files changed

+1292
-5615
lines changed

src/main/java/the/bytecode/club/jda/JDA.java

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -3,13 +3,16 @@
33
import org.apache.commons.io.FileUtils;
44
import org.fife.ui.rsyntaxtextarea.AbstractTokenMakerFactory;
55
import org.fife.ui.rsyntaxtextarea.TokenMakerFactory;
6+
import org.fife.ui.rsyntaxtextarea.folding.CurlyFoldParser;
7+
import org.fife.ui.rsyntaxtextarea.folding.FoldParserManager;
68
import org.objectweb.asm.ClassReader;
79
import org.objectweb.asm.ClassWriter;
810
import org.objectweb.asm.tree.ClassNode;
911
import the.bytecode.club.jda.api.ExceptionUI;
1012
import the.bytecode.club.jda.api.Plugin;
1113
import the.bytecode.club.jda.api.PluginLoader;
1214
import the.bytecode.club.jda.gui.MainViewerGUI;
15+
import the.bytecode.club.jda.gui.fileviewer.BytecodeFoldParser;
1316
import the.bytecode.club.jda.gui.fileviewer.BytecodeTokenizer;
1417
import the.bytecode.club.jda.gui.navigation.FileNavigationPane;
1518
import the.bytecode.club.jda.settings.Settings;
@@ -102,7 +105,8 @@ else if (!pluginsDir.isDirectory())
102105

103106
public static void onGUILoad() {
104107
AbstractTokenMakerFactory atmf = (AbstractTokenMakerFactory)TokenMakerFactory.getDefaultInstance();
105-
atmf.putMapping(BytecodeTokenizer.SYNTAX_STYLE_BYTECODE, "the.bytecode.club.jda.gui.fileviewer.BytecodeTokenizer");
108+
atmf.putMapping(BytecodeTokenizer.SYNTAX_STYLE_BYTECODE, BytecodeTokenizer.class.getName());
109+
FoldParserManager.get().addFoldParserMapping(BytecodeTokenizer.SYNTAX_STYLE_BYTECODE, new BytecodeFoldParser());
106110

107111
plugins.forEach(Plugin::onGUILoad);
108112
}

src/main/java/the/bytecode/club/jda/decompilers/bytecode/InstructionPrinter.java

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -109,7 +109,7 @@ public ArrayList<String> createPrint() {
109109
if (parent.createLabelBrackets()) {
110110
if (!firstLabel)
111111
firstLabel = true;
112-
line += " { // http://google.com";
112+
line += " {";
113113
}
114114

115115
if (parent.appendHandlerComments()) {
Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,6 @@
1+
package the.bytecode.club.jda.gui.fileviewer;
2+
3+
import org.fife.ui.rsyntaxtextarea.folding.CurlyFoldParser;
4+
5+
public class BytecodeFoldParser extends CurlyFoldParser {
6+
}

src/main/java/the/bytecode/club/jda/gui/fileviewer/BytecodeTokenizer.flex

Lines changed: 2 additions & 320 deletions
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,7 @@ import org.fife.ui.rsyntaxtextarea.*;
77

88

99
/**
10-
* Scanner for the JDA Bytecode.<p>
10+
* Scanner the JDA Bytecode.<p>
1111
*
1212
* This implementation was created using
1313
* <a href="http://www.jflex.de/">JFlex</a> 1.4.1; however, the generated file
@@ -525,325 +525,7 @@ URL = (((https?|f(tp|ile))"://"|"www.")({URLCharacters}{URLEndCharacter})?)
525525
/* Booleans. */
526526
{BooleanLiteral} { addToken(Token.LITERAL_BOOLEAN); }
527527

528-
/* java.lang classes */
529-
"Appendable" |
530-
"AutoCloseable" |
531-
"CharSequence" |
532-
"Cloneable" |
533-
"Comparable" |
534-
"Iterable" |
535-
"Readable" |
536-
"Runnable" |
537-
"Thread.UncaughtExceptionHandler" |
538-
"Boolean" |
539-
"Byte" |
540-
"Character" |
541-
"Character.Subset" |
542-
"Character.UnicodeBlock" |
543-
"Class" |
544-
"ClassLoader" |
545-
"ClassValue" |
546-
"Compiler" |
547-
"Double" |
548-
"Enum" |
549-
"Float" |
550-
"InheritableThreadLocal" |
551-
"Integer" |
552-
"Long" |
553-
"Math" |
554-
"Number" |
555-
"Object" |
556-
"Package" |
557-
"Process" |
558-
"ProcessBuilder" |
559-
"ProcessBuilder.Redirect" |
560-
"Runtime" |
561-
"RuntimePermission" |
562-
"SecurityManager" |
563-
"Short" |
564-
"StackTraceElement" |
565-
"StrictMath" |
566-
"String" |
567-
"StringBuffer" |
568-
"StringBuilder" |
569-
"System" |
570-
"Thread" |
571-
"ThreadGroup" |
572-
"ThreadLocal" |
573-
"Throwable" |
574-
"Void" |
575-
"Character.UnicodeScript" |
576-
"ProcessBuilder.Redirect.Type" |
577-
"Thread.State" |
578-
"ArithmeticException" |
579-
"ArrayIndexOutOfBoundsException" |
580-
"ArrayStoreException" |
581-
"ClassCastException" |
582-
"ClassNotFoundException" |
583-
"CloneNotSupportedException" |
584-
"EnumConstantNotPresentException" |
585-
"Exception" |
586-
"IllegalAccessException" |
587-
"IllegalArgumentException" |
588-
"IllegalMonitorStateException" |
589-
"IllegalStateException" |
590-
"IllegalThreadStateException" |
591-
"IndexOutOfBoundsException" |
592-
"InstantiationException" |
593-
"InterruptedException" |
594-
"NegativeArraySizeException" |
595-
"NoSuchFieldException" |
596-
"NoSuchMethodException" |
597-
"NullPointerException" |
598-
"NumberFormatException" |
599-
"RuntimeException" |
600-
"SecurityException" |
601-
"StringIndexOutOfBoundsException" |
602-
"TypeNotPresentException" |
603-
"UnsupportedOperationException" |
604-
"AbstractMethodError" |
605-
"AssertionError" |
606-
"BootstrapMethodError" |
607-
"ClassCircularityError" |
608-
"ClassFormatError" |
609-
"Error" |
610-
"ExceptionInInitializerError" |
611-
"IllegalAccessError" |
612-
"IncompatibleClassChangeError" |
613-
"InstantiationError" |
614-
"InternalError" |
615-
"LinkageError" |
616-
"NoClassDefFoundError" |
617-
"NoSuchFieldError" |
618-
"NoSuchMethodError" |
619-
"OutOfMemoryError" |
620-
"StackOverflowError" |
621-
"ThreadDeath" |
622-
"UnknownError" |
623-
"UnsatisfiedLinkError" |
624-
"UnsupportedClassVersionError" |
625-
"VerifyError" |
626-
"VirtualMachineError" |
627-
628-
/* java.io classes*/
629-
"Closeable" |
630-
"DataInput" |
631-
"DataOutput" |
632-
"Externalizable" |
633-
"FileFilter" |
634-
"FilenameFilter" |
635-
"Flushable" |
636-
"ObjectInput" |
637-
"ObjectInputValidation" |
638-
"ObjectOutput" |
639-
"ObjectStreamConstants" |
640-
"Serializable" |
641-
642-
"BufferedInputStream" |
643-
"BufferedOutputStream" |
644-
"BufferedReader" |
645-
"BufferedWriter" |
646-
"ByteArrayInputStream" |
647-
"ByteArrayOutputStream" |
648-
"CharArrayReader" |
649-
"CharArrayWriter" |
650-
"Console" |
651-
"DataInputStream" |
652-
"DataOutputStream" |
653-
"File" |
654-
"FileDescriptor" |
655-
"FileInputStream" |
656-
"FileOutputStream" |
657-
"FilePermission" |
658-
"FileReader" |
659-
"FileWriter" |
660-
"FilterInputStream" |
661-
"FilterOutputStream" |
662-
"FilterReader" |
663-
"FilterWriter" |
664-
"InputStream" |
665-
"InputStreamReader" |
666-
"LineNumberInputStream" |
667-
"LineNumberReader" |
668-
"ObjectInputStream" |
669-
"ObjectInputStream.GetField" |
670-
"ObjectOutputStream" |
671-
"ObjectOutputStream.PutField" |
672-
"ObjectStreamClass" |
673-
"ObjectStreamField" |
674-
"OutputStream" |
675-
"OutputStreamWriter" |
676-
"PipedInputStream" |
677-
"PipedOutputStream" |
678-
"PipedReader" |
679-
"PipedWriter" |
680-
"PrintStream" |
681-
"PrintWriter" |
682-
"PushbackInputStream" |
683-
"PushbackReader" |
684-
"RandomAccessFile" |
685-
"Reader" |
686-
"SequenceInputStream" |
687-
"SerializablePermission" |
688-
"StreamTokenizer" |
689-
"StringBufferInputStream" |
690-
"StringReader" |
691-
"StringWriter" |
692-
"Writer" |
693-
694-
"CharConversionException" |
695-
"EOFException" |
696-
"FileNotFoundException" |
697-
"InterruptedIOException" |
698-
"InvalidClassException" |
699-
"InvalidObjectException" |
700-
"IOException" |
701-
"NotActiveException" |
702-
"NotSerializableException" |
703-
"ObjectStreamException" |
704-
"OptionalDataException" |
705-
"StreamCorruptedException" |
706-
"SyncFailedException" |
707-
"UncheckedIOException" |
708-
"UnsupportedEncodingException" |
709-
"UTFDataFormatException" |
710-
"WriteAbortedException" |
711-
712-
"IOError" |
713-
714-
/* java.util classes */
715-
"Collection" |
716-
"Comparator" |
717-
"Deque" |
718-
"Enumeration" |
719-
"EventListener" |
720-
"Formattable" |
721-
"Iterator" |
722-
"List" |
723-
"ListIterator" |
724-
"Map" |
725-
"Map.Entry" |
726-
"NavigableMap" |
727-
"NavigableSet" |
728-
"Observer" |
729-
"PrimitiveIterator" |
730-
"PrimitiveIterator.OfDouble" |
731-
"PrimitiveIterator.OfInt" |
732-
"PrimitiveIterator.OfLong" |
733-
"Queue" |
734-
"RandomAccess" |
735-
"Set" |
736-
"SortedMap" |
737-
"SortedSet" |
738-
"Spliterator" |
739-
"Spliterator.OfDouble" |
740-
"Spliterator.OfInt" |
741-
"Spliterator.OfLong" |
742-
"Spliterator.OfPrimitive" |
743-
744-
"AbstractCollection" |
745-
"AbstractList" |
746-
"AbstractMap" |
747-
"AbstractMap.SimpleEntry" |
748-
"AbstractMap.SimpleImmutableEntry" |
749-
"AbstractQueue" |
750-
"AbstractSequentialList" |
751-
"AbstractSet" |
752-
"ArrayDeque" |
753-
"ArrayList" |
754-
"Arrays" |
755-
"Base64" |
756-
"Base64.Decoder" |
757-
"Base64.Encoder" |
758-
"BitSet" |
759-
"Calendar" |
760-
"Calendar.Builder" |
761-
"Collections" |
762-
"Currency" |
763-
"Date" |
764-
"Dictionary" |
765-
"DoubleSummaryStatistics" |
766-
"EnumMap" |
767-
"EnumSet" |
768-
"EventListenerProxy" |
769-
"EventObject" |
770-
"FormattableFlags" |
771-
"Formatter" |
772-
"GregorianCalendar" |
773-
"HashMap" |
774-
"HashSet" |
775-
"Hashtable" |
776-
"IdentityHashMap" |
777-
"IntSummaryStatistics" |
778-
"LinkedHashMap" |
779-
"LinkedHashSet" |
780-
"LinkedList" |
781-
"ListResourceBundle" |
782-
"Locale" |
783-
"Locale.Builder" |
784-
"Locale.LanguageRange" |
785-
"LongSummaryStatistics" |
786-
"Objects" |
787-
"Observable" |
788-
"Optional" |
789-
"OptionalDouble" |
790-
"OptionalInt" |
791-
"OptionalLong" |
792-
"PriorityQueue" |
793-
"Properties" |
794-
"PropertyPermission" |
795-
"PropertyResourceBundle" |
796-
"Random" |
797-
"ResourceBundle" |
798-
"ResourceBundle.Control" |
799-
"Scanner" |
800-
"ServiceLoader" |
801-
"SimpleTimeZone" |
802-
"Spliterators" |
803-
"Spliterators.AbstractDoubleSpliterator" |
804-
"Spliterators.AbstractIntSpliterator" |
805-
"Spliterators.AbstractLongSpliterator" |
806-
"Spliterators.AbstractSpliterator" |
807-
"SpliteratorRandom" |
808-
"Stack" |
809-
"StringJoiner" |
810-
"StringTokenizer" |
811-
"Timer" |
812-
"TimerTask" |
813-
"TimeZone" |
814-
"TreeMap" |
815-
"TreeSet" |
816-
"UUID" |
817-
"Vector" |
818-
"WeakHashMap" |
819-
820-
"Formatter.BigDecimalLayoutForm" |
821-
"Locale.Category" |
822-
"Locale.FilteringMode" |
823-
824-
"ConcurrentModificationException" |
825-
"DuplicateFormatFlagsException" |
826-
"EmptyStackException" |
827-
"FormatFlagsConversionMismatchException" |
828-
"FormatterClosedException" |
829-
"IllegalFormatCodePointException" |
830-
"IllegalFormatConversionException" |
831-
"IllegalFormatException" |
832-
"IllegalFormatFlagsException" |
833-
"IllegalFormatPrecisionException" |
834-
"IllegalFormatWidthException" |
835-
"IllformedLocaleException" |
836-
"InputMismatchException" |
837-
"InvalidPropertiesFormatException" |
838-
"MissingFormatArgumentException" |
839-
"MissingFormatWidthException" |
840-
"MissingResourceException" |
841-
"NoSuchElementException" |
842-
"TooManyListenersException" |
843-
"UnknownFormatConversionException" |
844-
"UnknownFormatFlagsException" |
845-
846-
"ServiceConfigurationError" { addToken(Token.FUNCTION); }
528+
// "TODO" { addToken(Token.FUNCTION); }
847529

848530
{LineTerminator} { addNullToken(); return firstToken; }
849531

0 commit comments

Comments
 (0)