From 373ca99e373562071e77d19de1421fd9cf1156ad Mon Sep 17 00:00:00 2001 From: Roman Shevchenko Date: Tue, 14 Oct 2014 14:14:49 +0200 Subject: [PATCH] Cleanup (formatting; naming) --- .../java/decompiler/main/ClassWriter.java | 24 +++++------ .../decompiler/main/ClassesProcessor.java | 43 +++++++------------ .../decompiler/main/rels/LambdaProcessor.java | 2 +- .../main/rels/NestedClassProcessor.java | 28 ++++++------ 4 files changed, 41 insertions(+), 56 deletions(-) diff --git a/src/org/jetbrains/java/decompiler/main/ClassWriter.java b/src/org/jetbrains/java/decompiler/main/ClassWriter.java index ea78c72..6de5933 100644 --- a/src/org/jetbrains/java/decompiler/main/ClassWriter.java +++ b/src/org/jetbrains/java/decompiler/main/ClassWriter.java @@ -99,31 +99,31 @@ public class ClassWriter { DecompilerContext.getLogger().startWriteClass(node.simpleName); - if (node.lambda_information.is_method_reference) { - if (!node.lambda_information.is_content_method_static && method_object != null) { + if (node.lambdaInformation.is_method_reference) { + if (!node.lambdaInformation.is_content_method_static && method_object != null) { // reference to a virtual method buffer.append(method_object.toJava(indent, tracer)); } else { // reference to a static method - buffer.append(ExprProcessor.getCastTypeName(new VarType(node.lambda_information.content_class_name, false))); + buffer.append(ExprProcessor.getCastTypeName(new VarType(node.lambdaInformation.content_class_name, false))); } buffer.append("::"); - buffer.append(node.lambda_information.content_method_name); + buffer.append(node.lambdaInformation.content_method_name); } else { // lambda method - StructMethod mt = cl.getMethod(node.lambda_information.content_method_key); + StructMethod mt = cl.getMethod(node.lambdaInformation.content_method_key); MethodWrapper methodWrapper = wrapper.getMethodWrapper(mt.getName(), mt.getDescriptor()); - MethodDescriptor md_content = MethodDescriptor.parseDescriptor(node.lambda_information.content_method_descriptor); - MethodDescriptor md_lambda = MethodDescriptor.parseDescriptor(node.lambda_information.method_descriptor); + MethodDescriptor md_content = MethodDescriptor.parseDescriptor(node.lambdaInformation.content_method_descriptor); + MethodDescriptor md_lambda = MethodDescriptor.parseDescriptor(node.lambdaInformation.method_descriptor); if (!lambdaToAnonymous) { buffer.append('('); boolean firstParameter = true; - int index = node.lambda_information.is_content_method_static ? 0 : 1; + int index = node.lambdaInformation.is_content_method_static ? 0 : 1; int start_index = md_content.params.length - md_lambda.params.length; for (int i = 0; i < md_content.params.length; i++) { @@ -485,9 +485,9 @@ public class ClassWriter { DecompilerContext.setProperty(DecompilerContext.CURRENT_METHOD_WRAPPER, methodWrapper); try { - String method_name = lambdaNode.lambda_information.method_name; - MethodDescriptor md_content = MethodDescriptor.parseDescriptor(lambdaNode.lambda_information.content_method_descriptor); - MethodDescriptor md_lambda = MethodDescriptor.parseDescriptor(lambdaNode.lambda_information.method_descriptor); + String method_name = lambdaNode.lambdaInformation.method_name; + MethodDescriptor md_content = MethodDescriptor.parseDescriptor(lambdaNode.lambdaInformation.content_method_descriptor); + MethodDescriptor md_lambda = MethodDescriptor.parseDescriptor(lambdaNode.lambdaInformation.method_descriptor); if (!codeOnly) { buffer.appendIndent(indent); @@ -496,7 +496,7 @@ public class ClassWriter { buffer.append("("); boolean firstParameter = true; - int index = lambdaNode.lambda_information.is_content_method_static ? 0 : 1; + int index = lambdaNode.lambdaInformation.is_content_method_static ? 0 : 1; int start_index = md_content.params.length - md_lambda.params.length; for (int i = 0; i < md_content.params.length; i++) { diff --git a/src/org/jetbrains/java/decompiler/main/ClassesProcessor.java b/src/org/jetbrains/java/decompiler/main/ClassesProcessor.java index 987c1a5..32470e0 100644 --- a/src/org/jetbrains/java/decompiler/main/ClassesProcessor.java +++ b/src/org/jetbrains/java/decompiler/main/ClassesProcessor.java @@ -347,30 +347,18 @@ public class ClassesProcessor { public static final int CLASS_LAMBDA = 8; public int type; - public int access; - public String simpleName; - public StructClass classStruct; - public ClassWrapper wrapper; - public String enclosingMethod; - public InvocationExprent superInvocation; - - public HashMap mapFieldsToVars = new HashMap(); - + public Map mapFieldsToVars = new HashMap(); public VarType anonymousClassType; - public List nested = new ArrayList(); - public Set enclosingClasses = new HashSet(); - public ClassNode parent; - - public LambdaInformation lambda_information; + public LambdaInformation lambdaInformation; public ClassNode(String content_class_name, String content_method_name, @@ -383,19 +371,19 @@ public class ClassesProcessor { this.type = CLASS_LAMBDA; this.classStruct = classStruct; // 'parent' class containing the static function - lambda_information = new LambdaInformation(); + lambdaInformation = new LambdaInformation(); - lambda_information.class_name = lambda_class_name; - lambda_information.method_name = lambda_method_name; - lambda_information.method_descriptor = lambda_method_descriptor; + lambdaInformation.class_name = lambda_class_name; + lambdaInformation.method_name = lambda_method_name; + lambdaInformation.method_descriptor = lambda_method_descriptor; - lambda_information.content_class_name = content_class_name; - lambda_information.content_method_name = content_method_name; - lambda_information.content_method_descriptor = content_method_descriptor; - lambda_information.content_method_invocation_type = content_method_invocation_type; + lambdaInformation.content_class_name = content_class_name; + lambdaInformation.content_method_name = content_method_name; + lambdaInformation.content_method_descriptor = content_method_descriptor; + lambdaInformation.content_method_invocation_type = content_method_invocation_type; - lambda_information.content_method_key = - InterpreterUtil.makeUniqueKey(lambda_information.content_method_name, lambda_information.content_method_descriptor); + lambdaInformation.content_method_key = + InterpreterUtil.makeUniqueKey(lambdaInformation.content_method_name, lambdaInformation.content_method_descriptor); anonymousClassType = new VarType(lambda_class_name, true); @@ -405,9 +393,9 @@ public class ClassesProcessor { is_method_reference = !mt.isSynthetic(); // if not synthetic -> method reference } - lambda_information.is_method_reference = is_method_reference; - lambda_information.is_content_method_static = - (lambda_information.content_method_invocation_type == CodeConstants.CONSTANT_MethodHandle_REF_invokeStatic); // FIXME: redundant? + lambdaInformation.is_method_reference = is_method_reference; + lambdaInformation.is_content_method_static = + (lambdaInformation.content_method_invocation_type == CodeConstants.CONSTANT_MethodHandle_REF_invokeStatic); // FIXME: redundant? } public ClassNode(int type, StructClass classStruct) { @@ -435,7 +423,6 @@ public class ClassesProcessor { public String content_method_name; public String content_method_descriptor; public int content_method_invocation_type; // values from CONSTANT_MethodHandle_REF_* - public String content_method_key; public boolean is_method_reference; diff --git a/src/org/jetbrains/java/decompiler/main/rels/LambdaProcessor.java b/src/org/jetbrains/java/decompiler/main/rels/LambdaProcessor.java index 743ce12..398fedb 100644 --- a/src/org/jetbrains/java/decompiler/main/rels/LambdaProcessor.java +++ b/src/org/jetbrains/java/decompiler/main/rels/LambdaProcessor.java @@ -122,7 +122,7 @@ public class LambdaProcessor { node_lambda.parent = node; clprocessor.getMapRootClasses().put(node_lambda.simpleName, node_lambda); - mapMethodsLambda.put(node_lambda.lambda_information.content_method_key, node_lambda.simpleName); + mapMethodsLambda.put(node_lambda.lambdaInformation.content_method_key, node_lambda.simpleName); } } } diff --git a/src/org/jetbrains/java/decompiler/main/rels/NestedClassProcessor.java b/src/org/jetbrains/java/decompiler/main/rels/NestedClassProcessor.java index 25ff812..6218319 100644 --- a/src/org/jetbrains/java/decompiler/main/rels/NestedClassProcessor.java +++ b/src/org/jetbrains/java/decompiler/main/rels/NestedClassProcessor.java @@ -47,10 +47,10 @@ public class NestedClassProcessor { public void processClass(ClassNode root, ClassNode node) { // hide synthetic lambda content methods - if (node.type == ClassNode.CLASS_LAMBDA && !node.lambda_information.is_method_reference) { + if (node.type == ClassNode.CLASS_LAMBDA && !node.lambdaInformation.is_method_reference) { ClassNode node_content = DecompilerContext.getClassProcessor().getMapRootClasses().get(node.classStruct.qualifiedName); if (node_content != null && node_content.wrapper != null) { - node_content.wrapper.getHiddenMembers().add(node.lambda_information.content_method_key); + node_content.wrapper.getHiddenMembers().add(node.lambdaInformation.content_method_key); } } @@ -75,8 +75,8 @@ public class NestedClassProcessor { child.simpleName = "SyntheticClass_" + (++synthetics); } else { - DecompilerContext.getLogger().writeMessage("Nameless local or member class " + cl.qualifiedName + "!", - IFernflowerLogger.Severity.WARN); + String message = "Nameless local or member class " + cl.qualifiedName + "!"; + DecompilerContext.getLogger().writeMessage(message, IFernflowerLogger.Severity.WARN); child.simpleName = "NamelessClass_" + (++nameless); } } @@ -86,13 +86,11 @@ public class NestedClassProcessor { if (child.type == ClassNode.CLASS_LAMBDA) { setLambdaVars(node, child); } - else { - if (child.type != ClassNode.CLASS_MEMBER || (child.access & CodeConstants.ACC_STATIC) == 0) { - insertLocalVars(node, child); + else if (child.type != ClassNode.CLASS_MEMBER || (child.access & CodeConstants.ACC_STATIC) == 0) { + insertLocalVars(node, child); - if (child.type == ClassNode.CLASS_LOCAL) { - setLocalClassDefinition(node.wrapper.getMethods().getWithKey(child.enclosingMethod), child); - } + if (child.type == ClassNode.CLASS_LOCAL) { + setLocalClassDefinition(node.wrapper.getMethods().getWithKey(child.enclosingMethod), child); } } } @@ -104,22 +102,22 @@ public class NestedClassProcessor { private static void setLambdaVars(ClassNode parent, ClassNode child) { - if (child.lambda_information.is_method_reference) { // method reference, no code and no parameters + if (child.lambdaInformation.is_method_reference) { // method reference, no code and no parameters return; } - final MethodWrapper meth = parent.wrapper.getMethods().getWithKey(child.lambda_information.content_method_key); + final MethodWrapper meth = parent.wrapper.getMethods().getWithKey(child.lambdaInformation.content_method_key); final MethodWrapper encmeth = parent.wrapper.getMethods().getWithKey(child.enclosingMethod); - MethodDescriptor md_lambda = MethodDescriptor.parseDescriptor(child.lambda_information.method_descriptor); - final MethodDescriptor md_content = MethodDescriptor.parseDescriptor(child.lambda_information.content_method_descriptor); + MethodDescriptor md_lambda = MethodDescriptor.parseDescriptor(child.lambdaInformation.method_descriptor); + final MethodDescriptor md_content = MethodDescriptor.parseDescriptor(child.lambdaInformation.content_method_descriptor); final int vars_count = md_content.params.length - md_lambda.params.length; // if(vars_count < 0) { // should not happen, but just in case... // vars_count = 0; // } - final boolean is_static_lambda_content = child.lambda_information.is_content_method_static; + final boolean is_static_lambda_content = child.lambdaInformation.is_content_method_static; final String parent_class_name = parent.wrapper.getClassStruct().qualifiedName; final String lambda_class_name = child.simpleName;