summaryrefslogtreecommitdiff
path: root/src
diff options
context:
space:
mode:
authorGravatar Thiakil2018-07-23 12:41:19 +0800
committerGravatar Thiakil2018-07-23 12:41:19 +0800
commit49e696255e9b623535679f228384ea45d4f89cfd (patch)
tree148cf6dbc3e8d52354b835e12f7fb60f305a12dc /src
parentMake rebuildMethodNames use parallelStream's should improve the speed a lot (diff)
downloadenigma-49e696255e9b623535679f228384ea45d4f89cfd.tar.gz
enigma-49e696255e9b623535679f228384ea45d4f89cfd.tar.xz
enigma-49e696255e9b623535679f228384ea45d4f89cfd.zip
fix source index tokens for inner classes that are not mapped
Diffstat (limited to 'src')
-rw-r--r--src/main/java/cuchaz/enigma/analysis/SourceIndex.java12
1 files changed, 12 insertions, 0 deletions
diff --git a/src/main/java/cuchaz/enigma/analysis/SourceIndex.java b/src/main/java/cuchaz/enigma/analysis/SourceIndex.java
index 14b2e768..78195cb7 100644
--- a/src/main/java/cuchaz/enigma/analysis/SourceIndex.java
+++ b/src/main/java/cuchaz/enigma/analysis/SourceIndex.java
@@ -17,15 +17,19 @@ import com.google.common.collect.Maps;
17import com.google.common.collect.Multimap; 17import com.google.common.collect.Multimap;
18import com.strobel.decompiler.languages.Region; 18import com.strobel.decompiler.languages.Region;
19import com.strobel.decompiler.languages.java.ast.AstNode; 19import com.strobel.decompiler.languages.java.ast.AstNode;
20import com.strobel.decompiler.languages.java.ast.ConstructorDeclaration;
20import com.strobel.decompiler.languages.java.ast.Identifier; 21import com.strobel.decompiler.languages.java.ast.Identifier;
22import com.strobel.decompiler.languages.java.ast.TypeDeclaration;
21import cuchaz.enigma.mapping.entry.Entry; 23import cuchaz.enigma.mapping.entry.Entry;
22 24
23import java.util.Collection; 25import java.util.Collection;
24import java.util.List; 26import java.util.List;
25import java.util.Map; 27import java.util.Map;
26import java.util.TreeMap; 28import java.util.TreeMap;
29import java.util.regex.Pattern;
27 30
28public class SourceIndex { 31public class SourceIndex {
32 private static Pattern ANONYMOUS_INNER = Pattern.compile("\\$\\d+$");
29 33
30 private String source; 34 private String source;
31 private TreeMap<Token, EntryReference<Entry, Entry>> tokenToReference; 35 private TreeMap<Token, EntryReference<Entry, Entry>> tokenToReference;
@@ -81,6 +85,14 @@ public class SourceIndex {
81 return null; 85 return null;
82 } 86 }
83 87
88 if (node instanceof Identifier && name.indexOf('$') >=0 && node.getParent() instanceof ConstructorDeclaration && name.lastIndexOf('$') >= 0 && !ANONYMOUS_INNER.matcher(name).matches()){
89 TypeDeclaration type = node.getParent().getParent() instanceof TypeDeclaration ? (TypeDeclaration) node.getParent().getParent() : null;
90 if (type != null){
91 name = type.getName();
92 token.end = token.start + name.length();
93 }
94 }
95
84 // DEBUG 96 // DEBUG
85 // System.out.println( String.format( "%s \"%s\" region: %s", node.getNodeType(), name, region ) ); 97 // System.out.println( String.format( "%s \"%s\" region: %s", node.getNodeType(), name, region ) );
86 98