Cleanup (duplicates extracted; formatting; typos)

This commit is contained in:
Roman Shevchenko
2016-04-11 20:32:26 +02:00
parent 404783c874
commit a57e42690b
4 changed files with 134 additions and 186 deletions

View File

@@ -33,19 +33,14 @@ import static org.jetbrains.java.decompiler.struct.attr.StructGeneralAttribute.A
* @since March 07, 2016
*/
public final class StructUtils {
private StructUtils() {
}
private StructUtils() { }
/**
* @return the local variables of the current method
*/
public static List<String> getCurrentMethodLocalVariableNames() {
final MethodWrapper method = (MethodWrapper) DecompilerContext.getProperty(CURRENT_METHOD_WRAPPER);
if (null == method) {
return Collections.emptyList();
}
return getLocalVariables(method.methodStruct);
return method == null ? Collections.emptyList() : getLocalVariables(method.methodStruct);
}
/**
@@ -56,10 +51,9 @@ public final class StructUtils {
final VBStyleCollection<StructGeneralAttribute, String> methodStruct = structMember.getAttributes();
final StructGeneralAttribute generalAttribute = methodStruct.getWithKey(ATTRIBUTE_LOCAL_VARIABLE_TABLE);
if (generalAttribute instanceof StructLocalVariableTableAttribute) {
final StructLocalVariableTableAttribute table = (StructLocalVariableTableAttribute) generalAttribute;
final StructLocalVariableTableAttribute table = (StructLocalVariableTableAttribute)generalAttribute;
return Collections.unmodifiableList(new ArrayList<>(table.getMapVarNames().values()));
}
return Collections.emptyList();
}
}
}