From 302a354720e9bef94b26d1e708412d2155f8e35d Mon Sep 17 00:00:00 2001 From: Stiver Date: Sun, 8 Mar 2015 08:43:57 +0100 Subject: [PATCH] Hiding synthetic fields (IDEA-132625) --- .../java/decompiler/main/DecompilerContext.java | 1 + .../java/decompiler/main/rels/ClassWrapper.java | 1 + .../decompiler/SimplifyExprentsHelper.java | 16 +++++++++++++--- .../FastExtendedPostdominanceHelper.java | 2 +- 4 files changed, 16 insertions(+), 4 deletions(-) diff --git a/src/org/jetbrains/java/decompiler/main/DecompilerContext.java b/src/org/jetbrains/java/decompiler/main/DecompilerContext.java index f1fddac..d672ddc 100644 --- a/src/org/jetbrains/java/decompiler/main/DecompilerContext.java +++ b/src/org/jetbrains/java/decompiler/main/DecompilerContext.java @@ -30,6 +30,7 @@ import java.util.Map; public class DecompilerContext { public static final String CURRENT_CLASS = "CURRENT_CLASS"; + public static final String CURRENT_CLASS_WRAPPER = "CURRENT_CLASS_WRAPPER"; public static final String CURRENT_CLASS_NODE = "CURRENT_CLASS_NODE"; public static final String CURRENT_METHOD = "CURRENT_METHOD"; public static final String CURRENT_METHOD_DESCRIPTOR = "CURRENT_METHOD_DESCRIPTOR"; diff --git a/src/org/jetbrains/java/decompiler/main/rels/ClassWrapper.java b/src/org/jetbrains/java/decompiler/main/rels/ClassWrapper.java index 55f7dd3..9388cf0 100644 --- a/src/org/jetbrains/java/decompiler/main/rels/ClassWrapper.java +++ b/src/org/jetbrains/java/decompiler/main/rels/ClassWrapper.java @@ -52,6 +52,7 @@ public class ClassWrapper { public void init() throws IOException { DecompilerContext.setProperty(DecompilerContext.CURRENT_CLASS, classStruct); + DecompilerContext.setProperty(DecompilerContext.CURRENT_CLASS_WRAPPER, this); DecompilerContext.getLogger().startClass(classStruct.qualifiedName); // collect field names diff --git a/src/org/jetbrains/java/decompiler/modules/decompiler/SimplifyExprentsHelper.java b/src/org/jetbrains/java/decompiler/modules/decompiler/SimplifyExprentsHelper.java index 26e9ceb..a855ffe 100644 --- a/src/org/jetbrains/java/decompiler/modules/decompiler/SimplifyExprentsHelper.java +++ b/src/org/jetbrains/java/decompiler/modules/decompiler/SimplifyExprentsHelper.java @@ -27,11 +27,13 @@ import org.jetbrains.java.decompiler.code.CodeConstants; import org.jetbrains.java.decompiler.main.ClassesProcessor.ClassNode; import org.jetbrains.java.decompiler.main.DecompilerContext; import org.jetbrains.java.decompiler.main.extern.IFernflowerPreferences; +import org.jetbrains.java.decompiler.main.rels.ClassWrapper; import org.jetbrains.java.decompiler.modules.decompiler.exps.ArrayExprent; import org.jetbrains.java.decompiler.modules.decompiler.exps.AssignmentExprent; import org.jetbrains.java.decompiler.modules.decompiler.exps.ConstExprent; import org.jetbrains.java.decompiler.modules.decompiler.exps.ExitExprent; import org.jetbrains.java.decompiler.modules.decompiler.exps.Exprent; +import org.jetbrains.java.decompiler.modules.decompiler.exps.FieldExprent; import org.jetbrains.java.decompiler.modules.decompiler.exps.FunctionExprent; import org.jetbrains.java.decompiler.modules.decompiler.exps.InvocationExprent; import org.jetbrains.java.decompiler.modules.decompiler.exps.MonitorExprent; @@ -45,6 +47,7 @@ import org.jetbrains.java.decompiler.struct.StructClass; import org.jetbrains.java.decompiler.struct.gen.VarType; import org.jetbrains.java.decompiler.struct.match.MatchEngine; import org.jetbrains.java.decompiler.util.FastSparseSetFactory.FastSparseSet; +import org.jetbrains.java.decompiler.util.InterpreterUtil; public class SimplifyExprentsHelper { @@ -882,12 +885,12 @@ public class SimplifyExprentsHelper { "statement type:if iftype:if exprsize:-1\n" + " exprent position:head type:if\n" + " exprent type:function functype:eq\n" + - " exprent type:field name:$field$\n" + + " exprent type:field name:$fieldname$\n" + " exprent type:constant consttype:null\n" + " statement type:basicblock\n" + " exprent position:-1 type:assignment ret:$assignfield$\n" + " exprent type:var index:$var$\n" + - " exprent type:field name:$field$\n" + + " exprent type:field name:$fieldname$\n" + " statement type:sequence statsize:2\n" + " statement type:trycatch\n" + " statement type:basicblock exprsize:1\n" + @@ -899,7 +902,7 @@ public class SimplifyExprentsHelper { " exprent type:exit exittype:throw\n" + " statement type:basicblock exprsize:1\n" + " exprent type:assignment\n" + - " exprent type:field name:$field$\n" + + " exprent type:field name:$fieldname$ ret:$field$\n" + " exprent type:var index:$var$" ); } @@ -911,6 +914,7 @@ public class SimplifyExprentsHelper { String class_name = (String)class14Builder.getVariableValue("$classname$"); AssignmentExprent assfirst = (AssignmentExprent)class14Builder.getVariableValue("$assignfield$"); + FieldExprent fieldexpr = (FieldExprent)class14Builder.getVariableValue("$field$"); assfirst.replaceExprent(assfirst.getRight(), new ConstExprent(VarType.VARTYPE_CLASS, class_name, null)); @@ -920,6 +924,12 @@ public class SimplifyExprentsHelper { stat.setExprents(data); SequenceHelper.destroyAndFlattenStatement(stat); + + ClassWrapper wrapper = (ClassWrapper)DecompilerContext.getProperty(DecompilerContext.CURRENT_CLASS_WRAPPER); + if (wrapper != null) { + wrapper.getHiddenMembers().add(InterpreterUtil.makeUniqueKey(fieldexpr.getName(), fieldexpr.getDescriptor().descriptorString)); + } + } return ret; diff --git a/src/org/jetbrains/java/decompiler/modules/decompiler/decompose/FastExtendedPostdominanceHelper.java b/src/org/jetbrains/java/decompiler/modules/decompiler/decompose/FastExtendedPostdominanceHelper.java index d9f3eff..b3c4806 100644 --- a/src/org/jetbrains/java/decompiler/modules/decompiler/decompose/FastExtendedPostdominanceHelper.java +++ b/src/org/jetbrains/java/decompiler/modules/decompiler/decompose/FastExtendedPostdominanceHelper.java @@ -114,7 +114,7 @@ public class FastExtendedPostdominanceHelper { Statement edge_destination = edge.getDestination(); - if(!setVisited.contains(edge_destination) /*&& !setStack.contains(edge_destination)*/) { + if(!setVisited.contains(edge_destination)) { stack.add(edge_destination); stackPath.add(path.getCopy());