IDEA-184560 Java decompiler doesn't use stored parameter names
This commit is contained in:
@@ -1,5 +1,5 @@
|
||||
/*
|
||||
* Copyright 2000-2017 JetBrains s.r.o. Use of this source code is governed by the Apache 2.0 license that can be found in the LICENSE file.
|
||||
* Copyright 2000-2018 JetBrains s.r.o. Use of this source code is governed by the Apache 2.0 license that can be found in the LICENSE file.
|
||||
*/
|
||||
package org.jetbrains.java.decompiler.main;
|
||||
|
||||
@@ -697,6 +697,15 @@ public class ClassWriter {
|
||||
}
|
||||
}
|
||||
|
||||
List<StructMethodParametersAttribute.Entry> methodParameters = null;
|
||||
if (DecompilerContext.getOption(IFernflowerPreferences.USE_METHOD_PARAMETERS)) {
|
||||
StructMethodParametersAttribute attr =
|
||||
(StructMethodParametersAttribute)mt.getAttribute(StructGeneralAttribute.ATTRIBUTE_METHOD_PARAMETERS);
|
||||
if (attr != null) {
|
||||
methodParameters = attr.getEntries();
|
||||
}
|
||||
}
|
||||
|
||||
int index = isEnum && init ? 3 : thisVar ? 1 : 0;
|
||||
int start = isEnum && init ? 2 : 0;
|
||||
for (int i = start; i < md.params.length; i++) {
|
||||
@@ -707,7 +716,10 @@ public class ClassWriter {
|
||||
|
||||
appendParameterAnnotations(buffer, mt, paramCount);
|
||||
|
||||
if (methodWrapper.varproc.getVarFinal(new VarVersionPair(index, 0)) == VarTypeProcessor.VAR_EXPLICIT_FINAL) {
|
||||
if (methodParameters != null && paramCount < methodParameters.size()) {
|
||||
appendModifiers(buffer, methodParameters.get(paramCount).myAccessFlags, CodeConstants.ACC_FINAL, isInterface, 0);
|
||||
}
|
||||
else if (methodWrapper.varproc.getVarFinal(new VarVersionPair(index, 0)) == VarTypeProcessor.VAR_EXPLICIT_FINAL) {
|
||||
buffer.append("final ");
|
||||
}
|
||||
|
||||
@@ -741,7 +753,14 @@ public class ClassWriter {
|
||||
}
|
||||
|
||||
buffer.append(' ');
|
||||
String parameterName = methodWrapper.varproc.getVarName(new VarVersionPair(index, 0));
|
||||
|
||||
String parameterName;
|
||||
if (methodParameters != null && paramCount < methodParameters.size()) {
|
||||
parameterName = methodParameters.get(paramCount).myName;
|
||||
}
|
||||
else {
|
||||
parameterName = methodWrapper.varproc.getVarName(new VarVersionPair(index, 0));
|
||||
}
|
||||
buffer.append(parameterName == null ? "param" + index : parameterName); // null iff decompiled with errors
|
||||
|
||||
paramCount++;
|
||||
|
||||
Reference in New Issue
Block a user