diff options
Diffstat (limited to 'src/cuchaz/enigma/analysis/MethodCallsTreeNode.java')
| -rw-r--r-- | src/cuchaz/enigma/analysis/MethodCallsTreeNode.java | 144 |
1 files changed, 0 insertions, 144 deletions
diff --git a/src/cuchaz/enigma/analysis/MethodCallsTreeNode.java b/src/cuchaz/enigma/analysis/MethodCallsTreeNode.java deleted file mode 100644 index b5cf4c3..0000000 --- a/src/cuchaz/enigma/analysis/MethodCallsTreeNode.java +++ /dev/null | |||
| @@ -1,144 +0,0 @@ | |||
| 1 | /******************************************************************************* | ||
| 2 | * Copyright (c) 2014 Jeff Martin. | ||
| 3 | * All rights reserved. This program and the accompanying materials | ||
| 4 | * are made available under the terms of the GNU Public License v3.0 | ||
| 5 | * which accompanies this distribution, and is available at | ||
| 6 | * http://www.gnu.org/licenses/gpl.html | ||
| 7 | * | ||
| 8 | * Contributors: | ||
| 9 | * Jeff Martin - initial API and implementation | ||
| 10 | ******************************************************************************/ | ||
| 11 | package cuchaz.enigma.analysis; | ||
| 12 | |||
| 13 | import java.util.Set; | ||
| 14 | |||
| 15 | import javax.swing.tree.DefaultMutableTreeNode; | ||
| 16 | import javax.swing.tree.TreeNode; | ||
| 17 | |||
| 18 | import com.google.common.collect.Sets; | ||
| 19 | |||
| 20 | import cuchaz.enigma.mapping.ConstructorEntry; | ||
| 21 | import cuchaz.enigma.mapping.Entry; | ||
| 22 | import cuchaz.enigma.mapping.MethodEntry; | ||
| 23 | import cuchaz.enigma.mapping.Translator; | ||
| 24 | |||
| 25 | public class MethodCallsTreeNode extends DefaultMutableTreeNode | ||
| 26 | { | ||
| 27 | private static final long serialVersionUID = -3658163700783307520L; | ||
| 28 | |||
| 29 | private Translator m_deobfuscatingTranslator; | ||
| 30 | private MethodEntry m_methodEntry; | ||
| 31 | private ConstructorEntry m_constructorEntry; | ||
| 32 | |||
| 33 | public MethodCallsTreeNode( Translator deobfuscatingTranslator, MethodEntry entry ) | ||
| 34 | { | ||
| 35 | m_deobfuscatingTranslator = deobfuscatingTranslator; | ||
| 36 | m_methodEntry = entry; | ||
| 37 | m_constructorEntry = null; | ||
| 38 | } | ||
| 39 | |||
| 40 | public MethodCallsTreeNode( Translator deobfuscatingTranslator, ConstructorEntry entry ) | ||
| 41 | { | ||
| 42 | m_deobfuscatingTranslator = deobfuscatingTranslator; | ||
| 43 | m_methodEntry = null; | ||
| 44 | m_constructorEntry = entry; | ||
| 45 | } | ||
| 46 | |||
| 47 | public MethodEntry getMethodEntry( ) | ||
| 48 | { | ||
| 49 | return m_methodEntry; | ||
| 50 | } | ||
| 51 | |||
| 52 | public ConstructorEntry getConstructorEntry( ) | ||
| 53 | { | ||
| 54 | return m_constructorEntry; | ||
| 55 | } | ||
| 56 | |||
| 57 | public Entry getEntry( ) | ||
| 58 | { | ||
| 59 | if( m_methodEntry != null ) | ||
| 60 | { | ||
| 61 | return m_methodEntry; | ||
| 62 | } | ||
| 63 | else if( m_constructorEntry != null ) | ||
| 64 | { | ||
| 65 | return m_constructorEntry; | ||
| 66 | } | ||
| 67 | throw new Error( "Illegal state!" ); | ||
| 68 | } | ||
| 69 | |||
| 70 | @Override | ||
| 71 | public String toString( ) | ||
| 72 | { | ||
| 73 | if( m_methodEntry != null ) | ||
| 74 | { | ||
| 75 | String className = m_deobfuscatingTranslator.translateClass( m_methodEntry.getClassName() ); | ||
| 76 | if( className == null ) | ||
| 77 | { | ||
| 78 | className = m_methodEntry.getClassName(); | ||
| 79 | } | ||
| 80 | |||
| 81 | String methodName = m_deobfuscatingTranslator.translate( m_methodEntry ); | ||
| 82 | if( methodName == null ) | ||
| 83 | { | ||
| 84 | methodName = m_methodEntry.getName(); | ||
| 85 | } | ||
| 86 | return className + "." + methodName + "()"; | ||
| 87 | } | ||
| 88 | else if( m_constructorEntry != null ) | ||
| 89 | { | ||
| 90 | String className = m_deobfuscatingTranslator.translateClass( m_constructorEntry.getClassName() ); | ||
| 91 | if( className == null ) | ||
| 92 | { | ||
| 93 | className = m_constructorEntry.getClassName(); | ||
| 94 | } | ||
| 95 | return className + "()"; | ||
| 96 | } | ||
| 97 | throw new Error( "Illegal state!" ); | ||
| 98 | } | ||
| 99 | |||
| 100 | public void load( JarIndex index, boolean recurse ) | ||
| 101 | { | ||
| 102 | // get all the child nodes | ||
| 103 | for( Entry entry : index.getMethodCallers( getEntry() ) ) | ||
| 104 | { | ||
| 105 | if( entry instanceof MethodEntry ) | ||
| 106 | { | ||
| 107 | add( new MethodCallsTreeNode( m_deobfuscatingTranslator, (MethodEntry)entry ) ); | ||
| 108 | } | ||
| 109 | else if( entry instanceof ConstructorEntry ) | ||
| 110 | { | ||
| 111 | add( new MethodCallsTreeNode( m_deobfuscatingTranslator, (ConstructorEntry)entry ) ); | ||
| 112 | } | ||
| 113 | } | ||
| 114 | |||
| 115 | if( recurse && children != null ) | ||
| 116 | { | ||
| 117 | for( Object child : children ) | ||
| 118 | { | ||
| 119 | if( child instanceof MethodCallsTreeNode ) | ||
| 120 | { | ||
| 121 | MethodCallsTreeNode node = (MethodCallsTreeNode)child; | ||
| 122 | |||
| 123 | // don't recurse into ancestor | ||
| 124 | Set<Entry> ancestors = Sets.newHashSet(); | ||
| 125 | TreeNode n = (TreeNode)node; | ||
| 126 | while( n.getParent() != null ) | ||
| 127 | { | ||
| 128 | n = n.getParent(); | ||
| 129 | if( n instanceof MethodCallsTreeNode ) | ||
| 130 | { | ||
| 131 | ancestors.add( ((MethodCallsTreeNode)n).getEntry() ); | ||
| 132 | } | ||
| 133 | } | ||
| 134 | if( ancestors.contains( node.getEntry() ) ) | ||
| 135 | { | ||
| 136 | continue; | ||
| 137 | } | ||
| 138 | |||
| 139 | node.load( index, true ); | ||
| 140 | } | ||
| 141 | } | ||
| 142 | } | ||
| 143 | } | ||
| 144 | } | ||