diff options
| -rw-r--r-- | src/main/java/cuchaz/enigma/analysis/SourceIndex.java | 12 |
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; | |||
| 17 | import com.google.common.collect.Multimap; | 17 | import com.google.common.collect.Multimap; |
| 18 | import com.strobel.decompiler.languages.Region; | 18 | import com.strobel.decompiler.languages.Region; |
| 19 | import com.strobel.decompiler.languages.java.ast.AstNode; | 19 | import com.strobel.decompiler.languages.java.ast.AstNode; |
| 20 | import com.strobel.decompiler.languages.java.ast.ConstructorDeclaration; | ||
| 20 | import com.strobel.decompiler.languages.java.ast.Identifier; | 21 | import com.strobel.decompiler.languages.java.ast.Identifier; |
| 22 | import com.strobel.decompiler.languages.java.ast.TypeDeclaration; | ||
| 21 | import cuchaz.enigma.mapping.entry.Entry; | 23 | import cuchaz.enigma.mapping.entry.Entry; |
| 22 | 24 | ||
| 23 | import java.util.Collection; | 25 | import java.util.Collection; |
| 24 | import java.util.List; | 26 | import java.util.List; |
| 25 | import java.util.Map; | 27 | import java.util.Map; |
| 26 | import java.util.TreeMap; | 28 | import java.util.TreeMap; |
| 29 | import java.util.regex.Pattern; | ||
| 27 | 30 | ||
| 28 | public class SourceIndex { | 31 | public 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 | ||