diff options
| author | 2014-08-10 19:29:43 -0400 | |
|---|---|---|
| committer | 2014-08-10 19:29:43 -0400 | |
| commit | e7febe4549c9fcdf1e82239959b3c6a83fad8934 (patch) | |
| tree | 05cfbef04ee0839fe6fc5937d764044dcfa65e13 /src | |
| parent | filter out tokens that are not obfuscated (diff) | |
| download | enigma-fork-e7febe4549c9fcdf1e82239959b3c6a83fad8934.tar.gz enigma-fork-e7febe4549c9fcdf1e82239959b3c6a83fad8934.tar.xz enigma-fork-e7febe4549c9fcdf1e82239959b3c6a83fad8934.zip | |
added go to entry feature
Diffstat (limited to 'src')
| -rw-r--r-- | src/cuchaz/enigma/analysis/SourceIndex.java | 11 | ||||
| -rw-r--r-- | src/cuchaz/enigma/analysis/SourceIndexVisitor.java | 48 | ||||
| -rw-r--r-- | src/cuchaz/enigma/analysis/TreeDumpVisitor.java | 550 | ||||
| -rw-r--r-- | src/cuchaz/enigma/gui/Gui.java | 52 | ||||
| -rw-r--r-- | src/cuchaz/enigma/gui/GuiController.java | 47 | ||||
| -rw-r--r-- | src/cuchaz/enigma/mapping/ArgumentEntry.java | 1 | ||||
| -rw-r--r-- | src/cuchaz/enigma/mapping/ClassEntry.java | 6 | ||||
| -rw-r--r-- | src/cuchaz/enigma/mapping/Entry.java | 1 | ||||
| -rw-r--r-- | src/cuchaz/enigma/mapping/FieldEntry.java | 1 | ||||
| -rw-r--r-- | src/cuchaz/enigma/mapping/MethodEntry.java | 1 |
10 files changed, 621 insertions, 97 deletions
diff --git a/src/cuchaz/enigma/analysis/SourceIndex.java b/src/cuchaz/enigma/analysis/SourceIndex.java index 7981f87..ad94cf0 100644 --- a/src/cuchaz/enigma/analysis/SourceIndex.java +++ b/src/cuchaz/enigma/analysis/SourceIndex.java | |||
| @@ -25,12 +25,14 @@ public class SourceIndex | |||
| 25 | { | 25 | { |
| 26 | private String m_source; | 26 | private String m_source; |
| 27 | private TreeMap<Token,Entry> m_tokens; | 27 | private TreeMap<Token,Entry> m_tokens; |
| 28 | private Map<Entry,Token> m_declarations; | ||
| 28 | private List<Integer> m_lineOffsets; | 29 | private List<Integer> m_lineOffsets; |
| 29 | 30 | ||
| 30 | public SourceIndex( String source ) | 31 | public SourceIndex( String source ) |
| 31 | { | 32 | { |
| 32 | m_source = source; | 33 | m_source = source; |
| 33 | m_tokens = Maps.newTreeMap(); | 34 | m_tokens = Maps.newTreeMap(); |
| 35 | m_declarations = Maps.newHashMap(); | ||
| 34 | m_lineOffsets = Lists.newArrayList(); | 36 | m_lineOffsets = Lists.newArrayList(); |
| 35 | 37 | ||
| 36 | // count the lines | 38 | // count the lines |
| @@ -82,9 +84,11 @@ public class SourceIndex | |||
| 82 | m_tokens.put( getToken( node ), entry ); | 84 | m_tokens.put( getToken( node ), entry ); |
| 83 | } | 85 | } |
| 84 | 86 | ||
| 85 | public void add( Token token, Entry entry ) | 87 | public void addDeclaration( AstNode node, Entry entry ) |
| 86 | { | 88 | { |
| 89 | Token token = getToken( node ); | ||
| 87 | m_tokens.put( token, entry ); | 90 | m_tokens.put( token, entry ); |
| 91 | m_declarations.put( entry, token ); | ||
| 88 | } | 92 | } |
| 89 | 93 | ||
| 90 | public Token getToken( int pos ) | 94 | public Token getToken( int pos ) |
| @@ -116,6 +120,11 @@ public class SourceIndex | |||
| 116 | return m_tokens.keySet(); | 120 | return m_tokens.keySet(); |
| 117 | } | 121 | } |
| 118 | 122 | ||
| 123 | public Token getDeclarationToken( Entry entry ) | ||
| 124 | { | ||
| 125 | return m_declarations.get( entry ); | ||
| 126 | } | ||
| 127 | |||
| 119 | private int toPos( int line, int col ) | 128 | private int toPos( int line, int col ) |
| 120 | { | 129 | { |
| 121 | // line and col are 1-based | 130 | // line and col are 1-based |
diff --git a/src/cuchaz/enigma/analysis/SourceIndexVisitor.java b/src/cuchaz/enigma/analysis/SourceIndexVisitor.java index 5a64e4e..0ba5996 100644 --- a/src/cuchaz/enigma/analysis/SourceIndexVisitor.java +++ b/src/cuchaz/enigma/analysis/SourceIndexVisitor.java | |||
| @@ -16,7 +16,6 @@ import com.strobel.assembler.metadata.MethodDefinition; | |||
| 16 | import com.strobel.assembler.metadata.ParameterDefinition; | 16 | import com.strobel.assembler.metadata.ParameterDefinition; |
| 17 | import com.strobel.assembler.metadata.TypeDefinition; | 17 | import com.strobel.assembler.metadata.TypeDefinition; |
| 18 | import com.strobel.assembler.metadata.TypeReference; | 18 | import com.strobel.assembler.metadata.TypeReference; |
| 19 | import com.strobel.componentmodel.Key; | ||
| 20 | import com.strobel.decompiler.languages.TextLocation; | 19 | import com.strobel.decompiler.languages.TextLocation; |
| 21 | import com.strobel.decompiler.languages.java.ast.Annotation; | 20 | import com.strobel.decompiler.languages.java.ast.Annotation; |
| 22 | import com.strobel.decompiler.languages.java.ast.AnonymousObjectCreationExpression; | 21 | import com.strobel.decompiler.languages.java.ast.AnonymousObjectCreationExpression; |
| @@ -149,7 +148,7 @@ public class SourceIndexVisitor implements IAstVisitor<SourceIndex, Void> | |||
| 149 | { | 148 | { |
| 150 | ClassEntry classEntry = new ClassEntry( def.getDeclaringType().getInternalName() ); | 149 | ClassEntry classEntry = new ClassEntry( def.getDeclaringType().getInternalName() ); |
| 151 | MethodEntry methodEntry = new MethodEntry( classEntry, def.getName(), def.getSignature() ); | 150 | MethodEntry methodEntry = new MethodEntry( classEntry, def.getName(), def.getSignature() ); |
| 152 | index.add( node.getNameToken(), methodEntry ); | 151 | index.addDeclaration( node.getNameToken(), methodEntry ); |
| 153 | } | 152 | } |
| 154 | 153 | ||
| 155 | return recurse( node, index ); | 154 | return recurse( node, index ); |
| @@ -172,7 +171,7 @@ public class SourceIndexVisitor implements IAstVisitor<SourceIndex, Void> | |||
| 172 | MethodDefinition methodDef = (MethodDefinition)def.getMethod(); | 171 | MethodDefinition methodDef = (MethodDefinition)def.getMethod(); |
| 173 | MethodEntry methodEntry = new MethodEntry( classEntry, methodDef.getName(), methodDef.getSignature() ); | 172 | MethodEntry methodEntry = new MethodEntry( classEntry, methodDef.getName(), methodDef.getSignature() ); |
| 174 | ArgumentEntry argumentEntry = new ArgumentEntry( methodEntry, def.getPosition(), def.getName() ); | 173 | ArgumentEntry argumentEntry = new ArgumentEntry( methodEntry, def.getPosition(), def.getName() ); |
| 175 | index.add( node.getNameToken(), argumentEntry ); | 174 | index.addDeclaration( node.getNameToken(), argumentEntry ); |
| 176 | 175 | ||
| 177 | return recurse( node, index ); | 176 | return recurse( node, index ); |
| 178 | } | 177 | } |
| @@ -185,7 +184,7 @@ public class SourceIndexVisitor implements IAstVisitor<SourceIndex, Void> | |||
| 185 | FieldEntry fieldEntry = new FieldEntry( classEntry, def.getName() ); | 184 | FieldEntry fieldEntry = new FieldEntry( classEntry, def.getName() ); |
| 186 | assert( node.getVariables().size() == 1 ); | 185 | assert( node.getVariables().size() == 1 ); |
| 187 | VariableInitializer variable = node.getVariables().firstOrNullObject(); | 186 | VariableInitializer variable = node.getVariables().firstOrNullObject(); |
| 188 | index.add( variable.getNameToken(), fieldEntry ); | 187 | index.addDeclaration( variable.getNameToken(), fieldEntry ); |
| 189 | 188 | ||
| 190 | return recurse( node, index ); | 189 | return recurse( node, index ); |
| 191 | } | 190 | } |
| @@ -194,16 +193,13 @@ public class SourceIndexVisitor implements IAstVisitor<SourceIndex, Void> | |||
| 194 | public Void visitTypeDeclaration( TypeDeclaration node, SourceIndex index ) | 193 | public Void visitTypeDeclaration( TypeDeclaration node, SourceIndex index ) |
| 195 | { | 194 | { |
| 196 | TypeDefinition def = node.getUserData( Keys.TYPE_DEFINITION ); | 195 | TypeDefinition def = node.getUserData( Keys.TYPE_DEFINITION ); |
| 197 | index.add( node.getNameToken(), new ClassEntry( def.getInternalName() ) ); | 196 | index.addDeclaration( node.getNameToken(), new ClassEntry( def.getInternalName() ) ); |
| 198 | 197 | ||
| 199 | return recurse( node, index ); | 198 | return recurse( node, index ); |
| 200 | } | 199 | } |
| 201 | 200 | ||
| 202 | private Void recurse( AstNode node, SourceIndex index ) | 201 | private Void recurse( AstNode node, SourceIndex index ) |
| 203 | { | 202 | { |
| 204 | // TEMP: show the tree | ||
| 205 | System.out.println( getIndent( node ) + node.getClass().getSimpleName() + dumpUserData( node ) + " " + node.getRegion() ); | ||
| 206 | |||
| 207 | for( final AstNode child : node.getChildren() ) | 203 | for( final AstNode child : node.getChildren() ) |
| 208 | { | 204 | { |
| 209 | child.acceptVisitor( this, index ); | 205 | child.acceptVisitor( this, index ); |
| @@ -211,42 +207,6 @@ public class SourceIndexVisitor implements IAstVisitor<SourceIndex, Void> | |||
| 211 | return null; | 207 | return null; |
| 212 | } | 208 | } |
| 213 | 209 | ||
| 214 | private String dumpUserData( AstNode node ) | ||
| 215 | { | ||
| 216 | StringBuilder buf = new StringBuilder(); | ||
| 217 | for( Key<?> key : Keys.ALL_KEYS ) | ||
| 218 | { | ||
| 219 | Object val = node.getUserData( key ); | ||
| 220 | if( val != null ) | ||
| 221 | { | ||
| 222 | buf.append( String.format( " [%s=%s]", key, val ) ); | ||
| 223 | } | ||
| 224 | } | ||
| 225 | return buf.toString(); | ||
| 226 | } | ||
| 227 | |||
| 228 | private String getIndent( AstNode node ) | ||
| 229 | { | ||
| 230 | StringBuilder buf = new StringBuilder(); | ||
| 231 | int depth = getDepth( node ); | ||
| 232 | for( int i = 0; i < depth; i++ ) | ||
| 233 | { | ||
| 234 | buf.append( "\t" ); | ||
| 235 | } | ||
| 236 | return buf.toString(); | ||
| 237 | } | ||
| 238 | |||
| 239 | private int getDepth( AstNode node ) | ||
| 240 | { | ||
| 241 | int depth = -1; | ||
| 242 | while( node != null ) | ||
| 243 | { | ||
| 244 | depth++; | ||
| 245 | node = node.getParent(); | ||
| 246 | } | ||
| 247 | return depth; | ||
| 248 | } | ||
| 249 | |||
| 250 | // OVERRIDES WE DON'T CARE ABOUT | 210 | // OVERRIDES WE DON'T CARE ABOUT |
| 251 | 211 | ||
| 252 | @Override | 212 | @Override |
diff --git a/src/cuchaz/enigma/analysis/TreeDumpVisitor.java b/src/cuchaz/enigma/analysis/TreeDumpVisitor.java new file mode 100644 index 0000000..32607db --- /dev/null +++ b/src/cuchaz/enigma/analysis/TreeDumpVisitor.java | |||
| @@ -0,0 +1,550 @@ | |||
| 1 | package cuchaz.enigma.analysis; | ||
| 2 | |||
| 3 | import com.strobel.componentmodel.Key; | ||
| 4 | import com.strobel.decompiler.languages.java.ast.Annotation; | ||
| 5 | import com.strobel.decompiler.languages.java.ast.AnonymousObjectCreationExpression; | ||
| 6 | import com.strobel.decompiler.languages.java.ast.ArrayCreationExpression; | ||
| 7 | import com.strobel.decompiler.languages.java.ast.ArrayInitializerExpression; | ||
| 8 | import com.strobel.decompiler.languages.java.ast.ArraySpecifier; | ||
| 9 | import com.strobel.decompiler.languages.java.ast.AssertStatement; | ||
| 10 | import com.strobel.decompiler.languages.java.ast.AssignmentExpression; | ||
| 11 | import com.strobel.decompiler.languages.java.ast.AstNode; | ||
| 12 | import com.strobel.decompiler.languages.java.ast.BinaryOperatorExpression; | ||
| 13 | import com.strobel.decompiler.languages.java.ast.BlockStatement; | ||
| 14 | import com.strobel.decompiler.languages.java.ast.BreakStatement; | ||
| 15 | import com.strobel.decompiler.languages.java.ast.CaseLabel; | ||
| 16 | import com.strobel.decompiler.languages.java.ast.CastExpression; | ||
| 17 | import com.strobel.decompiler.languages.java.ast.CatchClause; | ||
| 18 | import com.strobel.decompiler.languages.java.ast.ClassOfExpression; | ||
| 19 | import com.strobel.decompiler.languages.java.ast.Comment; | ||
| 20 | import com.strobel.decompiler.languages.java.ast.CompilationUnit; | ||
| 21 | import com.strobel.decompiler.languages.java.ast.ComposedType; | ||
| 22 | import com.strobel.decompiler.languages.java.ast.ConditionalExpression; | ||
| 23 | import com.strobel.decompiler.languages.java.ast.ConstructorDeclaration; | ||
| 24 | import com.strobel.decompiler.languages.java.ast.ContinueStatement; | ||
| 25 | import com.strobel.decompiler.languages.java.ast.DoWhileStatement; | ||
| 26 | import com.strobel.decompiler.languages.java.ast.EmptyStatement; | ||
| 27 | import com.strobel.decompiler.languages.java.ast.EnumValueDeclaration; | ||
| 28 | import com.strobel.decompiler.languages.java.ast.ExpressionStatement; | ||
| 29 | import com.strobel.decompiler.languages.java.ast.FieldDeclaration; | ||
| 30 | import com.strobel.decompiler.languages.java.ast.ForEachStatement; | ||
| 31 | import com.strobel.decompiler.languages.java.ast.ForStatement; | ||
| 32 | import com.strobel.decompiler.languages.java.ast.GotoStatement; | ||
| 33 | import com.strobel.decompiler.languages.java.ast.IAstVisitor; | ||
| 34 | import com.strobel.decompiler.languages.java.ast.Identifier; | ||
| 35 | import com.strobel.decompiler.languages.java.ast.IdentifierExpression; | ||
| 36 | import com.strobel.decompiler.languages.java.ast.IfElseStatement; | ||
| 37 | import com.strobel.decompiler.languages.java.ast.ImportDeclaration; | ||
| 38 | import com.strobel.decompiler.languages.java.ast.IndexerExpression; | ||
| 39 | import com.strobel.decompiler.languages.java.ast.InstanceInitializer; | ||
| 40 | import com.strobel.decompiler.languages.java.ast.InstanceOfExpression; | ||
| 41 | import com.strobel.decompiler.languages.java.ast.InvocationExpression; | ||
| 42 | import com.strobel.decompiler.languages.java.ast.JavaTokenNode; | ||
| 43 | import com.strobel.decompiler.languages.java.ast.Keys; | ||
| 44 | import com.strobel.decompiler.languages.java.ast.LabelStatement; | ||
| 45 | import com.strobel.decompiler.languages.java.ast.LabeledStatement; | ||
| 46 | import com.strobel.decompiler.languages.java.ast.LambdaExpression; | ||
| 47 | import com.strobel.decompiler.languages.java.ast.LocalTypeDeclarationStatement; | ||
| 48 | import com.strobel.decompiler.languages.java.ast.MemberReferenceExpression; | ||
| 49 | import com.strobel.decompiler.languages.java.ast.MethodDeclaration; | ||
| 50 | import com.strobel.decompiler.languages.java.ast.MethodGroupExpression; | ||
| 51 | import com.strobel.decompiler.languages.java.ast.NewLineNode; | ||
| 52 | import com.strobel.decompiler.languages.java.ast.NullReferenceExpression; | ||
| 53 | import com.strobel.decompiler.languages.java.ast.ObjectCreationExpression; | ||
| 54 | import com.strobel.decompiler.languages.java.ast.PackageDeclaration; | ||
| 55 | import com.strobel.decompiler.languages.java.ast.ParameterDeclaration; | ||
| 56 | import com.strobel.decompiler.languages.java.ast.ParenthesizedExpression; | ||
| 57 | import com.strobel.decompiler.languages.java.ast.PrimitiveExpression; | ||
| 58 | import com.strobel.decompiler.languages.java.ast.ReturnStatement; | ||
| 59 | import com.strobel.decompiler.languages.java.ast.SimpleType; | ||
| 60 | import com.strobel.decompiler.languages.java.ast.SuperReferenceExpression; | ||
| 61 | import com.strobel.decompiler.languages.java.ast.SwitchSection; | ||
| 62 | import com.strobel.decompiler.languages.java.ast.SwitchStatement; | ||
| 63 | import com.strobel.decompiler.languages.java.ast.SynchronizedStatement; | ||
| 64 | import com.strobel.decompiler.languages.java.ast.TextNode; | ||
| 65 | import com.strobel.decompiler.languages.java.ast.ThisReferenceExpression; | ||
| 66 | import com.strobel.decompiler.languages.java.ast.ThrowStatement; | ||
| 67 | import com.strobel.decompiler.languages.java.ast.TryCatchStatement; | ||
| 68 | import com.strobel.decompiler.languages.java.ast.TypeDeclaration; | ||
| 69 | import com.strobel.decompiler.languages.java.ast.TypeParameterDeclaration; | ||
| 70 | import com.strobel.decompiler.languages.java.ast.TypeReferenceExpression; | ||
| 71 | import com.strobel.decompiler.languages.java.ast.UnaryOperatorExpression; | ||
| 72 | import com.strobel.decompiler.languages.java.ast.VariableDeclarationStatement; | ||
| 73 | import com.strobel.decompiler.languages.java.ast.VariableInitializer; | ||
| 74 | import com.strobel.decompiler.languages.java.ast.WhileStatement; | ||
| 75 | import com.strobel.decompiler.languages.java.ast.WildcardType; | ||
| 76 | import com.strobel.decompiler.patterns.Pattern; | ||
| 77 | |||
| 78 | public class TreeDumpVisitor implements IAstVisitor<Void, Void> | ||
| 79 | { | ||
| 80 | private Void recurse( AstNode node, Void ignored ) | ||
| 81 | { | ||
| 82 | // show the tree | ||
| 83 | System.out.println( getIndent( node ) + node.getClass().getSimpleName() + dumpUserData( node ) + " " + node.getRegion() ); | ||
| 84 | |||
| 85 | // recurse | ||
| 86 | for( final AstNode child : node.getChildren() ) | ||
| 87 | { | ||
| 88 | child.acceptVisitor( this, ignored ); | ||
| 89 | } | ||
| 90 | return null; | ||
| 91 | } | ||
| 92 | |||
| 93 | private String dumpUserData( AstNode node ) | ||
| 94 | { | ||
| 95 | StringBuilder buf = new StringBuilder(); | ||
| 96 | for( Key<?> key : Keys.ALL_KEYS ) | ||
| 97 | { | ||
| 98 | Object val = node.getUserData( key ); | ||
| 99 | if( val != null ) | ||
| 100 | { | ||
| 101 | buf.append( String.format( " [%s=%s]", key, val ) ); | ||
| 102 | } | ||
| 103 | } | ||
| 104 | return buf.toString(); | ||
| 105 | } | ||
| 106 | |||
| 107 | private String getIndent( AstNode node ) | ||
| 108 | { | ||
| 109 | StringBuilder buf = new StringBuilder(); | ||
| 110 | int depth = getDepth( node ); | ||
| 111 | for( int i = 0; i < depth; i++ ) | ||
| 112 | { | ||
| 113 | buf.append( "\t" ); | ||
| 114 | } | ||
| 115 | return buf.toString(); | ||
| 116 | } | ||
| 117 | |||
| 118 | private int getDepth( AstNode node ) | ||
| 119 | { | ||
| 120 | int depth = -1; | ||
| 121 | while( node != null ) | ||
| 122 | { | ||
| 123 | depth++; | ||
| 124 | node = node.getParent(); | ||
| 125 | } | ||
| 126 | return depth; | ||
| 127 | } | ||
| 128 | |||
| 129 | // OVERRIDES WE DON'T CARE ABOUT | ||
| 130 | |||
| 131 | @Override | ||
| 132 | public Void visitInvocationExpression( InvocationExpression node, Void ignored ) | ||
| 133 | { | ||
| 134 | return recurse( node, ignored ); | ||
| 135 | } | ||
| 136 | |||
| 137 | @Override | ||
| 138 | public Void visitMemberReferenceExpression( MemberReferenceExpression node, Void ignored ) | ||
| 139 | { | ||
| 140 | return recurse( node, ignored ); | ||
| 141 | } | ||
| 142 | |||
| 143 | @Override | ||
| 144 | public Void visitSimpleType( SimpleType node, Void ignored ) | ||
| 145 | { | ||
| 146 | return recurse( node, ignored ); | ||
| 147 | } | ||
| 148 | |||
| 149 | @Override | ||
| 150 | public Void visitMethodDeclaration( MethodDeclaration node, Void ignored ) | ||
| 151 | { | ||
| 152 | return recurse( node, ignored ); | ||
| 153 | } | ||
| 154 | |||
| 155 | @Override | ||
| 156 | public Void visitConstructorDeclaration( ConstructorDeclaration node, Void ignored ) | ||
| 157 | { | ||
| 158 | return recurse( node, ignored ); | ||
| 159 | } | ||
| 160 | |||
| 161 | @Override | ||
| 162 | public Void visitParameterDeclaration( ParameterDeclaration node, Void ignored ) | ||
| 163 | { | ||
| 164 | return recurse( node, ignored ); | ||
| 165 | } | ||
| 166 | |||
| 167 | @Override | ||
| 168 | public Void visitFieldDeclaration( FieldDeclaration node, Void ignored ) | ||
| 169 | { | ||
| 170 | return recurse( node, ignored ); | ||
| 171 | } | ||
| 172 | |||
| 173 | @Override | ||
| 174 | public Void visitTypeDeclaration( TypeDeclaration node, Void ignored ) | ||
| 175 | { | ||
| 176 | return recurse( node, ignored ); | ||
| 177 | } | ||
| 178 | |||
| 179 | @Override | ||
| 180 | public Void visitComment( Comment node, Void ignored ) | ||
| 181 | { | ||
| 182 | return recurse( node, ignored ); | ||
| 183 | } | ||
| 184 | |||
| 185 | @Override | ||
| 186 | public Void visitPatternPlaceholder( AstNode node, Pattern pattern, Void ignored ) | ||
| 187 | { | ||
| 188 | return recurse( node, ignored ); | ||
| 189 | } | ||
| 190 | |||
| 191 | @Override | ||
| 192 | public Void visitTypeReference( TypeReferenceExpression node, Void ignored ) | ||
| 193 | { | ||
| 194 | return recurse( node, ignored ); | ||
| 195 | } | ||
| 196 | |||
| 197 | @Override | ||
| 198 | public Void visitJavaTokenNode( JavaTokenNode node, Void ignored ) | ||
| 199 | { | ||
| 200 | return recurse( node, ignored ); | ||
| 201 | } | ||
| 202 | |||
| 203 | @Override | ||
| 204 | public Void visitIdentifier( Identifier node, Void ignored ) | ||
| 205 | { | ||
| 206 | return recurse( node, ignored ); | ||
| 207 | } | ||
| 208 | |||
| 209 | @Override | ||
| 210 | public Void visitNullReferenceExpression( NullReferenceExpression node, Void ignored ) | ||
| 211 | { | ||
| 212 | return recurse( node, ignored ); | ||
| 213 | } | ||
| 214 | |||
| 215 | @Override | ||
| 216 | public Void visitThisReferenceExpression( ThisReferenceExpression node, Void ignored ) | ||
| 217 | { | ||
| 218 | return recurse( node, ignored ); | ||
| 219 | } | ||
| 220 | |||
| 221 | @Override | ||
| 222 | public Void visitSuperReferenceExpression( SuperReferenceExpression node, Void ignored ) | ||
| 223 | { | ||
| 224 | return recurse( node, ignored ); | ||
| 225 | } | ||
| 226 | |||
| 227 | @Override | ||
| 228 | public Void visitClassOfExpression( ClassOfExpression node, Void ignored ) | ||
| 229 | { | ||
| 230 | return recurse( node, ignored ); | ||
| 231 | } | ||
| 232 | |||
| 233 | @Override | ||
| 234 | public Void visitBlockStatement( BlockStatement node, Void ignored ) | ||
| 235 | { | ||
| 236 | return recurse( node, ignored ); | ||
| 237 | } | ||
| 238 | |||
| 239 | @Override | ||
| 240 | public Void visitExpressionStatement( ExpressionStatement node, Void ignored ) | ||
| 241 | { | ||
| 242 | return recurse( node, ignored ); | ||
| 243 | } | ||
| 244 | |||
| 245 | @Override | ||
| 246 | public Void visitBreakStatement( BreakStatement node, Void ignored ) | ||
| 247 | { | ||
| 248 | return recurse( node, ignored ); | ||
| 249 | } | ||
| 250 | |||
| 251 | @Override | ||
| 252 | public Void visitContinueStatement( ContinueStatement node, Void ignored ) | ||
| 253 | { | ||
| 254 | return recurse( node, ignored ); | ||
| 255 | } | ||
| 256 | |||
| 257 | @Override | ||
| 258 | public Void visitDoWhileStatement( DoWhileStatement node, Void ignored ) | ||
| 259 | { | ||
| 260 | return recurse( node, ignored ); | ||
| 261 | } | ||
| 262 | |||
| 263 | @Override | ||
| 264 | public Void visitEmptyStatement( EmptyStatement node, Void ignored ) | ||
| 265 | { | ||
| 266 | return recurse( node, ignored ); | ||
| 267 | } | ||
| 268 | |||
| 269 | @Override | ||
| 270 | public Void visitIfElseStatement( IfElseStatement node, Void ignored ) | ||
| 271 | { | ||
| 272 | return recurse( node, ignored ); | ||
| 273 | } | ||
| 274 | |||
| 275 | @Override | ||
| 276 | public Void visitLabelStatement( LabelStatement node, Void ignored ) | ||
| 277 | { | ||
| 278 | return recurse( node, ignored ); | ||
| 279 | } | ||
| 280 | |||
| 281 | @Override | ||
| 282 | public Void visitLabeledStatement( LabeledStatement node, Void ignored ) | ||
| 283 | { | ||
| 284 | return recurse( node, ignored ); | ||
| 285 | } | ||
| 286 | |||
| 287 | @Override | ||
| 288 | public Void visitReturnStatement( ReturnStatement node, Void ignored ) | ||
| 289 | { | ||
| 290 | return recurse( node, ignored ); | ||
| 291 | } | ||
| 292 | |||
| 293 | @Override | ||
| 294 | public Void visitSwitchStatement( SwitchStatement node, Void ignored ) | ||
| 295 | { | ||
| 296 | return recurse( node, ignored ); | ||
| 297 | } | ||
| 298 | |||
| 299 | @Override | ||
| 300 | public Void visitSwitchSection( SwitchSection node, Void ignored ) | ||
| 301 | { | ||
| 302 | return recurse( node, ignored ); | ||
| 303 | } | ||
| 304 | |||
| 305 | @Override | ||
| 306 | public Void visitCaseLabel( CaseLabel node, Void ignored ) | ||
| 307 | { | ||
| 308 | return recurse( node, ignored ); | ||
| 309 | } | ||
| 310 | |||
| 311 | @Override | ||
| 312 | public Void visitThrowStatement( ThrowStatement node, Void ignored ) | ||
| 313 | { | ||
| 314 | return recurse( node, ignored ); | ||
| 315 | } | ||
| 316 | |||
| 317 | @Override | ||
| 318 | public Void visitCatchClause( CatchClause node, Void ignored ) | ||
| 319 | { | ||
| 320 | return recurse( node, ignored ); | ||
| 321 | } | ||
| 322 | |||
| 323 | @Override | ||
| 324 | public Void visitAnnotation( Annotation node, Void ignored ) | ||
| 325 | { | ||
| 326 | return recurse( node, ignored ); | ||
| 327 | } | ||
| 328 | |||
| 329 | @Override | ||
| 330 | public Void visitNewLine( NewLineNode node, Void ignored ) | ||
| 331 | { | ||
| 332 | return recurse( node, ignored ); | ||
| 333 | } | ||
| 334 | |||
| 335 | @Override | ||
| 336 | public Void visitVariableDeclaration( VariableDeclarationStatement node, Void ignored ) | ||
| 337 | { | ||
| 338 | return recurse( node, ignored ); | ||
| 339 | } | ||
| 340 | |||
| 341 | @Override | ||
| 342 | public Void visitVariableInitializer( VariableInitializer node, Void ignored ) | ||
| 343 | { | ||
| 344 | return recurse( node, ignored ); | ||
| 345 | } | ||
| 346 | |||
| 347 | @Override | ||
| 348 | public Void visitText( TextNode node, Void ignored ) | ||
| 349 | { | ||
| 350 | return recurse( node, ignored ); | ||
| 351 | } | ||
| 352 | |||
| 353 | @Override | ||
| 354 | public Void visitImportDeclaration( ImportDeclaration node, Void ignored ) | ||
| 355 | { | ||
| 356 | return recurse( node, ignored ); | ||
| 357 | } | ||
| 358 | |||
| 359 | @Override | ||
| 360 | public Void visitInitializerBlock( InstanceInitializer node, Void ignored ) | ||
| 361 | { | ||
| 362 | return recurse( node, ignored ); | ||
| 363 | } | ||
| 364 | |||
| 365 | @Override | ||
| 366 | public Void visitTypeParameterDeclaration( TypeParameterDeclaration node, Void ignored ) | ||
| 367 | { | ||
| 368 | return recurse( node, ignored ); | ||
| 369 | } | ||
| 370 | |||
| 371 | @Override | ||
| 372 | public Void visitCompilationUnit( CompilationUnit node, Void ignored ) | ||
| 373 | { | ||
| 374 | return recurse( node, ignored ); | ||
| 375 | } | ||
| 376 | |||
| 377 | @Override | ||
| 378 | public Void visitPackageDeclaration( PackageDeclaration node, Void ignored ) | ||
| 379 | { | ||
| 380 | return recurse( node, ignored ); | ||
| 381 | } | ||
| 382 | |||
| 383 | @Override | ||
| 384 | public Void visitArraySpecifier( ArraySpecifier node, Void ignored ) | ||
| 385 | { | ||
| 386 | return recurse( node, ignored ); | ||
| 387 | } | ||
| 388 | |||
| 389 | @Override | ||
| 390 | public Void visitComposedType( ComposedType node, Void ignored ) | ||
| 391 | { | ||
| 392 | return recurse( node, ignored ); | ||
| 393 | } | ||
| 394 | |||
| 395 | @Override | ||
| 396 | public Void visitWhileStatement( WhileStatement node, Void ignored ) | ||
| 397 | { | ||
| 398 | return recurse( node, ignored ); | ||
| 399 | } | ||
| 400 | |||
| 401 | @Override | ||
| 402 | public Void visitPrimitiveExpression( PrimitiveExpression node, Void ignored ) | ||
| 403 | { | ||
| 404 | return recurse( node, ignored ); | ||
| 405 | } | ||
| 406 | |||
| 407 | @Override | ||
| 408 | public Void visitCastExpression( CastExpression node, Void ignored ) | ||
| 409 | { | ||
| 410 | return recurse( node, ignored ); | ||
| 411 | } | ||
| 412 | |||
| 413 | @Override | ||
| 414 | public Void visitBinaryOperatorExpression( BinaryOperatorExpression node, Void ignored ) | ||
| 415 | { | ||
| 416 | return recurse( node, ignored ); | ||
| 417 | } | ||
| 418 | |||
| 419 | @Override | ||
| 420 | public Void visitInstanceOfExpression( InstanceOfExpression node, Void ignored ) | ||
| 421 | { | ||
| 422 | return recurse( node, ignored ); | ||
| 423 | } | ||
| 424 | |||
| 425 | @Override | ||
| 426 | public Void visitIndexerExpression( IndexerExpression node, Void ignored ) | ||
| 427 | { | ||
| 428 | return recurse( node, ignored ); | ||
| 429 | } | ||
| 430 | |||
| 431 | @Override | ||
| 432 | public Void visitIdentifierExpression( IdentifierExpression node, Void ignored ) | ||
| 433 | { | ||
| 434 | return recurse( node, ignored ); | ||
| 435 | } | ||
| 436 | |||
| 437 | @Override | ||
| 438 | public Void visitUnaryOperatorExpression( UnaryOperatorExpression node, Void ignored ) | ||
| 439 | { | ||
| 440 | return recurse( node, ignored ); | ||
| 441 | } | ||
| 442 | |||
| 443 | @Override | ||
| 444 | public Void visitConditionalExpression( ConditionalExpression node, Void ignored ) | ||
| 445 | { | ||
| 446 | return recurse( node, ignored ); | ||
| 447 | } | ||
| 448 | |||
| 449 | @Override | ||
| 450 | public Void visitArrayInitializerExpression( ArrayInitializerExpression node, Void ignored ) | ||
| 451 | { | ||
| 452 | return recurse( node, ignored ); | ||
| 453 | } | ||
| 454 | |||
| 455 | @Override | ||
| 456 | public Void visitObjectCreationExpression( ObjectCreationExpression node, Void ignored ) | ||
| 457 | { | ||
| 458 | return recurse( node, ignored ); | ||
| 459 | } | ||
| 460 | |||
| 461 | @Override | ||
| 462 | public Void visitArrayCreationExpression( ArrayCreationExpression node, Void ignored ) | ||
| 463 | { | ||
| 464 | return recurse( node, ignored ); | ||
| 465 | } | ||
| 466 | |||
| 467 | @Override | ||
| 468 | public Void visitAssignmentExpression( AssignmentExpression node, Void ignored ) | ||
| 469 | { | ||
| 470 | return recurse( node, ignored ); | ||
| 471 | } | ||
| 472 | |||
| 473 | @Override | ||
| 474 | public Void visitForStatement( ForStatement node, Void ignored ) | ||
| 475 | { | ||
| 476 | return recurse( node, ignored ); | ||
| 477 | } | ||
| 478 | |||
| 479 | @Override | ||
| 480 | public Void visitForEachStatement( ForEachStatement node, Void ignored ) | ||
| 481 | { | ||
| 482 | return recurse( node, ignored ); | ||
| 483 | } | ||
| 484 | |||
| 485 | @Override | ||
| 486 | public Void visitTryCatchStatement( TryCatchStatement node, Void ignored ) | ||
| 487 | { | ||
| 488 | return recurse( node, ignored ); | ||
| 489 | } | ||
| 490 | |||
| 491 | @Override | ||
| 492 | public Void visitGotoStatement( GotoStatement node, Void ignored ) | ||
| 493 | { | ||
| 494 | return recurse( node, ignored ); | ||
| 495 | } | ||
| 496 | |||
| 497 | @Override | ||
| 498 | public Void visitParenthesizedExpression( ParenthesizedExpression node, Void ignored ) | ||
| 499 | { | ||
| 500 | return recurse( node, ignored ); | ||
| 501 | } | ||
| 502 | |||
| 503 | @Override | ||
| 504 | public Void visitSynchronizedStatement( SynchronizedStatement node, Void ignored ) | ||
| 505 | { | ||
| 506 | return recurse( node, ignored ); | ||
| 507 | } | ||
| 508 | |||
| 509 | @Override | ||
| 510 | public Void visitAnonymousObjectCreationExpression( AnonymousObjectCreationExpression node, Void ignored ) | ||
| 511 | { | ||
| 512 | return recurse( node, ignored ); | ||
| 513 | } | ||
| 514 | |||
| 515 | @Override | ||
| 516 | public Void visitWildcardType( WildcardType node, Void ignored ) | ||
| 517 | { | ||
| 518 | return recurse( node, ignored ); | ||
| 519 | } | ||
| 520 | |||
| 521 | @Override | ||
| 522 | public Void visitMethodGroupExpression( MethodGroupExpression node, Void ignored ) | ||
| 523 | { | ||
| 524 | return recurse( node, ignored ); | ||
| 525 | } | ||
| 526 | |||
| 527 | @Override | ||
| 528 | public Void visitEnumValueDeclaration( EnumValueDeclaration node, Void ignored ) | ||
| 529 | { | ||
| 530 | return recurse( node, ignored ); | ||
| 531 | } | ||
| 532 | |||
| 533 | @Override | ||
| 534 | public Void visitAssertStatement( AssertStatement node, Void ignored ) | ||
| 535 | { | ||
| 536 | return recurse( node, ignored ); | ||
| 537 | } | ||
| 538 | |||
| 539 | @Override | ||
| 540 | public Void visitLambdaExpression( LambdaExpression node, Void ignored ) | ||
| 541 | { | ||
| 542 | return recurse( node, ignored ); | ||
| 543 | } | ||
| 544 | |||
| 545 | @Override | ||
| 546 | public Void visitLocalTypeDeclarationStatement( LocalTypeDeclarationStatement node, Void ignored ) | ||
| 547 | { | ||
| 548 | return recurse( node, ignored ); | ||
| 549 | } | ||
| 550 | } | ||
diff --git a/src/cuchaz/enigma/gui/Gui.java b/src/cuchaz/enigma/gui/Gui.java index 79becf8..bf72c85 100644 --- a/src/cuchaz/enigma/gui/Gui.java +++ b/src/cuchaz/enigma/gui/Gui.java | |||
| @@ -63,7 +63,6 @@ import javax.swing.tree.TreeNode; | |||
| 63 | import javax.swing.tree.TreePath; | 63 | import javax.swing.tree.TreePath; |
| 64 | 64 | ||
| 65 | import jsyntaxpane.DefaultSyntaxKit; | 65 | import jsyntaxpane.DefaultSyntaxKit; |
| 66 | import jsyntaxpane.SyntaxDocument; | ||
| 67 | 66 | ||
| 68 | import com.google.common.collect.Lists; | 67 | import com.google.common.collect.Lists; |
| 69 | 68 | ||
| @@ -257,6 +256,10 @@ public class Gui | |||
| 257 | startRename(); | 256 | startRename(); |
| 258 | break; | 257 | break; |
| 259 | 258 | ||
| 259 | case KeyEvent.VK_I: | ||
| 260 | showInheritance(); | ||
| 261 | break; | ||
| 262 | |||
| 260 | case KeyEvent.VK_O: | 263 | case KeyEvent.VK_O: |
| 261 | openEntry(); | 264 | openEntry(); |
| 262 | break; | 265 | break; |
| @@ -296,10 +299,11 @@ public class Gui | |||
| 296 | } | 299 | } |
| 297 | } ); | 300 | } ); |
| 298 | popupMenu.add( menu ); | 301 | popupMenu.add( menu ); |
| 302 | menu.setAccelerator( KeyStroke.getKeyStroke( KeyEvent.VK_I, 0 ) ); | ||
| 299 | m_inheritanceMenu = menu; | 303 | m_inheritanceMenu = menu; |
| 300 | } | 304 | } |
| 301 | { | 305 | { |
| 302 | JMenuItem menu = new JMenuItem( "Open Class" ); | 306 | JMenuItem menu = new JMenuItem( "Go to Declaration" ); |
| 303 | menu.addActionListener( new ActionListener( ) | 307 | menu.addActionListener( new ActionListener( ) |
| 304 | { | 308 | { |
| 305 | @Override | 309 | @Override |
| @@ -598,34 +602,13 @@ public class Gui | |||
| 598 | 602 | ||
| 599 | public void setSource( String source ) | 603 | public void setSource( String source ) |
| 600 | { | 604 | { |
| 601 | setSource( source, 0 ); | 605 | m_editor.getHighlighter().removeAllHighlights(); |
| 606 | m_editor.setText( source ); | ||
| 602 | } | 607 | } |
| 603 | 608 | ||
| 604 | public void setSource( String source, int lineNum ) | 609 | public void showToken( Token token ) |
| 605 | { | 610 | { |
| 606 | // remove any old highlighters | 611 | m_editor.setCaretPosition( token.start ); |
| 607 | m_editor.getHighlighter().removeAllHighlights(); | ||
| 608 | |||
| 609 | m_editor.setText( source ); | ||
| 610 | |||
| 611 | // count the offset of the target line | ||
| 612 | String text = m_editor.getText(); | ||
| 613 | int pos = 0; | ||
| 614 | int numLines = 0; | ||
| 615 | for( ; pos < text.length(); pos++ ) | ||
| 616 | { | ||
| 617 | if( numLines == lineNum ) | ||
| 618 | { | ||
| 619 | break; | ||
| 620 | } | ||
| 621 | if( text.charAt( pos ) == '\n' ) | ||
| 622 | { | ||
| 623 | numLines++; | ||
| 624 | } | ||
| 625 | } | ||
| 626 | |||
| 627 | // put the caret at the line number | ||
| 628 | m_editor.setCaretPosition( pos ); | ||
| 629 | m_editor.grabFocus(); | 612 | m_editor.grabFocus(); |
| 630 | } | 613 | } |
| 631 | 614 | ||
| @@ -760,12 +743,13 @@ public class Gui | |||
| 760 | 743 | ||
| 761 | m_selectedEntryPair = m_controller.getEntryPair( token ); | 744 | m_selectedEntryPair = m_controller.getEntryPair( token ); |
| 762 | boolean isClassEntry = m_selectedEntryPair.obf instanceof ClassEntry; | 745 | boolean isClassEntry = m_selectedEntryPair.obf instanceof ClassEntry; |
| 746 | boolean isFieldEntry = m_selectedEntryPair.obf instanceof FieldEntry; | ||
| 763 | boolean isMethodEntry = m_selectedEntryPair.obf instanceof MethodEntry; | 747 | boolean isMethodEntry = m_selectedEntryPair.obf instanceof MethodEntry; |
| 764 | 748 | ||
| 765 | showEntryPair( m_selectedEntryPair ); | 749 | showEntryPair( m_selectedEntryPair ); |
| 766 | 750 | ||
| 767 | m_inheritanceMenu.setEnabled( isClassEntry || isMethodEntry ); | 751 | m_inheritanceMenu.setEnabled( isClassEntry || isMethodEntry ); |
| 768 | m_openEntryMenu.setEnabled( isClassEntry ); | 752 | m_openEntryMenu.setEnabled( isClassEntry || isFieldEntry || isMethodEntry ); |
| 769 | } | 753 | } |
| 770 | 754 | ||
| 771 | private void startRename( ) | 755 | private void startRename( ) |
| @@ -807,12 +791,9 @@ public class Gui | |||
| 807 | String newName = text.getText(); | 791 | String newName = text.getText(); |
| 808 | if( saveName && newName != null && newName.length() > 0 ) | 792 | if( saveName && newName != null && newName.length() > 0 ) |
| 809 | { | 793 | { |
| 810 | SyntaxDocument doc = (SyntaxDocument)m_editor.getDocument(); | ||
| 811 | int lineNum = doc.getLineNumberAt( m_editor.getCaretPosition() ); | ||
| 812 | try | 794 | try |
| 813 | { | 795 | { |
| 814 | // TODO: give token to the controller so we can put the caret back there | 796 | m_controller.rename( m_selectedEntryPair.obf, newName ); |
| 815 | m_controller.rename( m_selectedEntryPair.obf, newName, lineNum ); | ||
| 816 | } | 797 | } |
| 817 | catch( IllegalNameException ex ) | 798 | catch( IllegalNameException ex ) |
| 818 | { | 799 | { |
| @@ -869,12 +850,7 @@ public class Gui | |||
| 869 | { | 850 | { |
| 870 | return; | 851 | return; |
| 871 | } | 852 | } |
| 872 | 853 | m_controller.openEntry( m_selectedEntryPair.obf ); | |
| 873 | // get the current class | ||
| 874 | if( m_selectedEntryPair.obf instanceof ClassEntry ) | ||
| 875 | { | ||
| 876 | m_controller.deobfuscateClass( new ClassFile( m_selectedEntryPair.obf.getName() ) ); | ||
| 877 | } | ||
| 878 | } | 854 | } |
| 879 | 855 | ||
| 880 | private void close( ) | 856 | private void close( ) |
diff --git a/src/cuchaz/enigma/gui/GuiController.java b/src/cuchaz/enigma/gui/GuiController.java index e0aad86..834afec 100644 --- a/src/cuchaz/enigma/gui/GuiController.java +++ b/src/cuchaz/enigma/gui/GuiController.java | |||
| @@ -77,7 +77,7 @@ public class GuiController | |||
| 77 | m_isDirty = false; | 77 | m_isDirty = false; |
| 78 | m_gui.setMappingsFile( file ); | 78 | m_gui.setMappingsFile( file ); |
| 79 | refreshClasses(); | 79 | refreshClasses(); |
| 80 | refreshOpenFiles(); | 80 | refreshCurrentClass(); |
| 81 | } | 81 | } |
| 82 | 82 | ||
| 83 | public void saveMappings( File file ) | 83 | public void saveMappings( File file ) |
| @@ -94,7 +94,7 @@ public class GuiController | |||
| 94 | m_deobfuscator.setMappings( null ); | 94 | m_deobfuscator.setMappings( null ); |
| 95 | m_gui.setMappingsFile( null ); | 95 | m_gui.setMappingsFile( null ); |
| 96 | refreshClasses(); | 96 | refreshClasses(); |
| 97 | refreshOpenFiles(); | 97 | refreshCurrentClass(); |
| 98 | } | 98 | } |
| 99 | 99 | ||
| 100 | public void deobfuscateClass( ClassFile classFile ) | 100 | public void deobfuscateClass( ClassFile classFile ) |
| @@ -157,12 +157,26 @@ public class GuiController | |||
| 157 | return thisNode; | 157 | return thisNode; |
| 158 | } | 158 | } |
| 159 | 159 | ||
| 160 | public void rename( Entry obfsEntry, String newName, int lineNum ) | 160 | public void rename( Entry obfEntry, String newName ) |
| 161 | { | 161 | { |
| 162 | m_deobfuscator.rename( obfsEntry, newName ); | 162 | m_deobfuscator.rename( obfEntry, newName ); |
| 163 | m_isDirty = true; | 163 | m_isDirty = true; |
| 164 | refreshClasses(); | 164 | refreshClasses(); |
| 165 | refreshOpenFiles( lineNum ); | 165 | refreshCurrentClass( m_deobfuscator.deobfuscateEntry( obfEntry ) ); |
| 166 | } | ||
| 167 | |||
| 168 | public void openEntry( Entry obfEntry ) | ||
| 169 | { | ||
| 170 | Entry deobfEntry = m_deobfuscator.deobfuscateEntry( obfEntry ); | ||
| 171 | if( !m_currentFile.getName().equals( obfEntry.getClassName() ) ) | ||
| 172 | { | ||
| 173 | m_currentFile = new ClassFile( obfEntry.getClassName() ); | ||
| 174 | deobfuscate( m_currentFile, deobfEntry ); | ||
| 175 | } | ||
| 176 | else | ||
| 177 | { | ||
| 178 | m_gui.showToken( m_index.getDeclarationToken( deobfEntry ) ); | ||
| 179 | } | ||
| 166 | } | 180 | } |
| 167 | 181 | ||
| 168 | private void refreshClasses( ) | 182 | private void refreshClasses( ) |
| @@ -173,27 +187,28 @@ public class GuiController | |||
| 173 | m_gui.setObfClasses( obfClasses ); | 187 | m_gui.setObfClasses( obfClasses ); |
| 174 | m_gui.setDeobfClasses( deobfClasses ); | 188 | m_gui.setDeobfClasses( deobfClasses ); |
| 175 | } | 189 | } |
| 176 | 190 | ||
| 177 | private void refreshOpenFiles( ) | 191 | private void refreshCurrentClass( ) |
| 178 | { | 192 | { |
| 179 | refreshOpenFiles( 0 ); | 193 | refreshCurrentClass( null ); |
| 180 | } | 194 | } |
| 181 | 195 | ||
| 182 | private void refreshOpenFiles( int lineNum ) | 196 | private void refreshCurrentClass( Entry entryToShow ) |
| 183 | { | 197 | { |
| 184 | if( m_currentFile != null ) | 198 | if( m_currentFile != null ) |
| 185 | { | 199 | { |
| 186 | deobfuscate( m_currentFile, lineNum ); | 200 | deobfuscate( m_currentFile, entryToShow ); |
| 187 | } | 201 | } |
| 188 | } | 202 | } |
| 189 | 203 | ||
| 190 | private void deobfuscate( final ClassFile classFile ) | 204 | private void deobfuscate( final ClassFile classFile ) |
| 191 | { | 205 | { |
| 192 | deobfuscate( classFile, 0 ); | 206 | deobfuscate( classFile, null ); |
| 193 | } | 207 | } |
| 194 | 208 | ||
| 195 | private void deobfuscate( final ClassFile classFile, final int lineNum ) | 209 | private void deobfuscate( final ClassFile classFile, final Entry entryToShow ) |
| 196 | { | 210 | { |
| 211 | m_currentFile = classFile; | ||
| 197 | m_gui.setSource( "(deobfuscating...)" ); | 212 | m_gui.setSource( "(deobfuscating...)" ); |
| 198 | 213 | ||
| 199 | // run the deobfuscator in a separate thread so we don't block the GUI event queue | 214 | // run the deobfuscator in a separate thread so we don't block the GUI event queue |
| @@ -202,9 +217,13 @@ public class GuiController | |||
| 202 | @Override | 217 | @Override |
| 203 | public void run( ) | 218 | public void run( ) |
| 204 | { | 219 | { |
| 205 | // decopmile,deobfuscate the bytecode | 220 | // decompile,deobfuscate the bytecode |
| 206 | m_index = m_deobfuscator.getSource( classFile ); | 221 | m_index = m_deobfuscator.getSource( classFile ); |
| 207 | m_gui.setSource( m_index.getSource(), lineNum ); | 222 | m_gui.setSource( m_index.getSource() ); |
| 223 | if( entryToShow != null ) | ||
| 224 | { | ||
| 225 | m_gui.showToken( m_index.getDeclarationToken( entryToShow ) ); | ||
| 226 | } | ||
| 208 | 227 | ||
| 209 | // set the highlighted tokens | 228 | // set the highlighted tokens |
| 210 | List<Token> obfuscatedTokens = Lists.newArrayList(); | 229 | List<Token> obfuscatedTokens = Lists.newArrayList(); |
diff --git a/src/cuchaz/enigma/mapping/ArgumentEntry.java b/src/cuchaz/enigma/mapping/ArgumentEntry.java index c1624a8..0c25c4d 100644 --- a/src/cuchaz/enigma/mapping/ArgumentEntry.java +++ b/src/cuchaz/enigma/mapping/ArgumentEntry.java | |||
| @@ -70,6 +70,7 @@ public class ArgumentEntry implements Entry, Serializable | |||
| 70 | return m_methodEntry.getClassEntry(); | 70 | return m_methodEntry.getClassEntry(); |
| 71 | } | 71 | } |
| 72 | 72 | ||
| 73 | @Override | ||
| 73 | public String getClassName( ) | 74 | public String getClassName( ) |
| 74 | { | 75 | { |
| 75 | return m_methodEntry.getClassName(); | 76 | return m_methodEntry.getClassName(); |
diff --git a/src/cuchaz/enigma/mapping/ClassEntry.java b/src/cuchaz/enigma/mapping/ClassEntry.java index 0968e95..513862d 100644 --- a/src/cuchaz/enigma/mapping/ClassEntry.java +++ b/src/cuchaz/enigma/mapping/ClassEntry.java | |||
| @@ -45,6 +45,12 @@ public class ClassEntry implements Entry, Serializable | |||
| 45 | } | 45 | } |
| 46 | 46 | ||
| 47 | @Override | 47 | @Override |
| 48 | public String getClassName( ) | ||
| 49 | { | ||
| 50 | return m_name; | ||
| 51 | } | ||
| 52 | |||
| 53 | @Override | ||
| 48 | public int hashCode( ) | 54 | public int hashCode( ) |
| 49 | { | 55 | { |
| 50 | return m_name.hashCode(); | 56 | return m_name.hashCode(); |
diff --git a/src/cuchaz/enigma/mapping/Entry.java b/src/cuchaz/enigma/mapping/Entry.java index 1443532..3ff8027 100644 --- a/src/cuchaz/enigma/mapping/Entry.java +++ b/src/cuchaz/enigma/mapping/Entry.java | |||
| @@ -13,4 +13,5 @@ package cuchaz.enigma.mapping; | |||
| 13 | public interface Entry | 13 | public interface Entry |
| 14 | { | 14 | { |
| 15 | String getName( ); | 15 | String getName( ); |
| 16 | String getClassName( ); | ||
| 16 | } | 17 | } |
diff --git a/src/cuchaz/enigma/mapping/FieldEntry.java b/src/cuchaz/enigma/mapping/FieldEntry.java index eefc4c4..6148c84 100644 --- a/src/cuchaz/enigma/mapping/FieldEntry.java +++ b/src/cuchaz/enigma/mapping/FieldEntry.java | |||
| @@ -60,6 +60,7 @@ public class FieldEntry implements Entry, Serializable | |||
| 60 | return m_name; | 60 | return m_name; |
| 61 | } | 61 | } |
| 62 | 62 | ||
| 63 | @Override | ||
| 63 | public String getClassName( ) | 64 | public String getClassName( ) |
| 64 | { | 65 | { |
| 65 | return m_classEntry.getName(); | 66 | return m_classEntry.getName(); |
diff --git a/src/cuchaz/enigma/mapping/MethodEntry.java b/src/cuchaz/enigma/mapping/MethodEntry.java index 9ea2d08..ff232c5 100644 --- a/src/cuchaz/enigma/mapping/MethodEntry.java +++ b/src/cuchaz/enigma/mapping/MethodEntry.java | |||
| @@ -72,6 +72,7 @@ public class MethodEntry implements Entry, Serializable | |||
| 72 | return m_signature; | 72 | return m_signature; |
| 73 | } | 73 | } |
| 74 | 74 | ||
| 75 | @Override | ||
| 75 | public String getClassName( ) | 76 | public String getClassName( ) |
| 76 | { | 77 | { |
| 77 | return m_classEntry.getName(); | 78 | return m_classEntry.getName(); |