diff options
author | Egor.Ushakov <egor.ushakov@jetbrains.com> | 2017-04-26 19:58:55 +0300 |
---|---|---|
committer | md_5 <git@md-5.net> | 2018-06-25 17:18:19 +1000 |
commit | 93b2c6d59bd82283cf2f7221e02481ba2fd7f5c2 (patch) | |
tree | a937af1843785ff94c17c0e10bc830d2579292f2 /src/org | |
parent | 883035d097d1234f517e4418cb7328991f6df508 (diff) | |
download | fernflower-93b2c6d59bd82283cf2f7221e02481ba2fd7f5c2.tar fernflower-93b2c6d59bd82283cf2f7221e02481ba2fd7f5c2.tar.gz fernflower-93b2c6d59bd82283cf2f7221e02481ba2fd7f5c2.tar.lz fernflower-93b2c6d59bd82283cf2f7221e02481ba2fd7f5c2.tar.xz fernflower-93b2c6d59bd82283cf2f7221e02481ba2fd7f5c2.zip |
fixed lambda parameter names already used in the context
# Conflicts:
# src/org/jetbrains/java/decompiler/main/collectors/VarNamesCollector.java
# src/org/jetbrains/java/decompiler/main/rels/NestedClassProcessor.java
# src/org/jetbrains/java/decompiler/modules/decompiler/vars/VarProcessor.java
# test/org/jetbrains/java/decompiler/SingleClassesTest.java
Diffstat (limited to 'src/org')
3 files changed, 17 insertions, 10 deletions
diff --git a/src/org/jetbrains/java/decompiler/main/collectors/VarNamesCollector.java b/src/org/jetbrains/java/decompiler/main/collectors/VarNamesCollector.java index dfde971..8d9d5c0 100644 --- a/src/org/jetbrains/java/decompiler/main/collectors/VarNamesCollector.java +++ b/src/org/jetbrains/java/decompiler/main/collectors/VarNamesCollector.java @@ -15,6 +15,7 @@ */ package org.jetbrains.java.decompiler.main.collectors; +import java.util.Collection; import java.util.HashSet; public class VarNamesCollector { @@ -24,7 +25,7 @@ public class VarNamesCollector { public VarNamesCollector() { } - public VarNamesCollector(HashSet<String> setNames) { + public VarNamesCollector(Collection<String> setNames) { usedNames.addAll(setNames); } diff --git a/src/org/jetbrains/java/decompiler/main/rels/NestedClassProcessor.java b/src/org/jetbrains/java/decompiler/main/rels/NestedClassProcessor.java index 6e40fcb..c4a4ff5 100644 --- a/src/org/jetbrains/java/decompiler/main/rels/NestedClassProcessor.java +++ b/src/org/jetbrains/java/decompiler/main/rels/NestedClassProcessor.java @@ -44,6 +44,7 @@ import org.jetbrains.java.decompiler.util.InterpreterUtil; import java.util.*; import java.util.Map.Entry; +import org.jetbrains.java.decompiler.modules.decompiler.ExprProcessor; public class NestedClassProcessor { @@ -277,6 +278,7 @@ public class NestedClassProcessor { if (expr.type == Exprent.EXPRENT_NEW) { NewExprent new_expr = (NewExprent)expr; + VarNamesCollector enclosingCollector = new VarNamesCollector(encmeth.varproc.getVarNames()); if (new_expr.isLambda() && lambda_class_type.equals(new_expr.getNewtype())) { InvocationExprent inv_dynamic = new_expr.getConstructor(); @@ -284,16 +286,16 @@ public class NestedClassProcessor { int param_index = is_static_lambda_content ? 0 : 1; int varindex = is_static_lambda_content ? 0 : 1; - for (int i = 0; i < vars_count; ++i) { + for (int i = 0; i < md_content.params.length; ++i) { + VarVersionPaar varVersion = new VarVersionPaar(varindex, 0, ExprProcessor.getCastTypeName(md_content.params[i].copy()), false); + if (i < vars_count) { + Exprent param = inv_dynamic.getLstParameters().get(param_index + i); - Exprent param = inv_dynamic.getLstParameters().get(param_index + i); - - if (param.type == Exprent.EXPRENT_VAR) { - VarVersionPaar enc_varpaar = new VarVersionPaar((VarExprent)param); - String enc_varname = encmeth.varproc.getVarName(enc_varpaar); - - //meth.varproc.setVarName(new VarVersionPaar(varindex, 0), enc_varname); - mapNewNames.put(new VarVersionPaar(varindex, 0), enc_varname); + if (param.type == Exprent.EXPRENT_VAR) { + mapNewNames.put(varVersion, encmeth.varproc.getVarName(new VarVersionPaar((VarExprent) param))); + } + } else { + mapNewNames.put(varVersion, enclosingCollector.getFreeName(meth.varproc.getVarName(varVersion))); } varindex += md_content.params[i].stack_size; diff --git a/src/org/jetbrains/java/decompiler/modules/decompiler/vars/VarProcessor.java b/src/org/jetbrains/java/decompiler/modules/decompiler/vars/VarProcessor.java index 4d4dabb..18314d8 100644 --- a/src/org/jetbrains/java/decompiler/modules/decompiler/vars/VarProcessor.java +++ b/src/org/jetbrains/java/decompiler/modules/decompiler/vars/VarProcessor.java @@ -120,6 +120,10 @@ public class VarProcessor { mapVarNames.put(varpaar, name); } + public Collection<String> getVarNames() { + return mapVarNames != null ? mapVarNames.values() : Collections.EMPTY_SET; + } + public int getVarFinal(VarVersionPaar varpaar) { return varvers == null ? VarTypeProcessor.VAR_FINAL : varvers.getVarFinal(varpaar); } |