Fixes to dump
This commit is contained in:
parent
e202a31d62
commit
80234688a6
2 changed files with 22 additions and 8 deletions
|
@ -422,7 +422,7 @@ public abstract class BaseDumpDirective implements TemplateDirectiveModel {
|
|||
}
|
||||
// Else display method name, parameter types, and return type
|
||||
} else {
|
||||
String returnTypeName = getTypeName(method.getReturnType());
|
||||
String returnTypeName = getReturnTypeName(method);
|
||||
Map<String, String> methodValue = new HashMap<String, String>();
|
||||
if ( ! returnTypeName.equals("void") ) {
|
||||
methodValue.put(Key.TYPE.toString(), returnTypeName);
|
||||
|
@ -460,14 +460,26 @@ public abstract class BaseDumpDirective implements TemplateDirectiveModel {
|
|||
List<String> paramTypeList = new ArrayList<String>(paramTypes.length);
|
||||
if (paramTypes.length > 0) {
|
||||
for (Class<?> cls : paramTypes) {
|
||||
paramTypeList.add(getTypeName(cls));
|
||||
paramTypeList.add(getSimpleTypeName(cls));
|
||||
}
|
||||
}
|
||||
methodName += "(" + StringUtils.join(paramTypeList, ", ") + ")";
|
||||
return methodName;
|
||||
}
|
||||
|
||||
private String getTypeName(Class<?> cls) {
|
||||
private String getReturnTypeName(Method method) {
|
||||
Class<?> cls = method.getReturnType();
|
||||
Package pkg = cls.getPackage();
|
||||
if (pkg != null) { // void return type has null package
|
||||
String packageName = pkg.getName();
|
||||
if (packageName.startsWith("java")) {
|
||||
return getSimpleTypeName(cls);
|
||||
}
|
||||
}
|
||||
return cls.getName();
|
||||
}
|
||||
|
||||
private String getSimpleTypeName(Class<?> cls) {
|
||||
return cls.getSimpleName().replace("[]", "s");
|
||||
}
|
||||
|
||||
|
|
|
@ -63,7 +63,7 @@ div.dump {
|
|||
</#if>
|
||||
</#macro>
|
||||
|
||||
<#macro doTypeAndValue map>
|
||||
<#macro doTypeAndValue map isMethod=false>
|
||||
<#local type = map.type!>
|
||||
<#if type?has_content>
|
||||
<p><strong>Type:</strong> ${type}</p>
|
||||
|
@ -75,8 +75,9 @@ div.dump {
|
|||
|
||||
<#local value = map.value!>
|
||||
<#-- Not value?has_content: we want to print [empty] for empty strings.
|
||||
See doScalarValue macro. -->
|
||||
<#if value??>
|
||||
See doScalarValue macro. For methods, we don't show a list of values
|
||||
unless there is a value. -->
|
||||
<#if value?? && (value?has_content || ! isMethod)>
|
||||
<div class="values">
|
||||
<#if type?contains(".")><@doObjectValue value />
|
||||
<#elseif value?is_sequence><@doSequenceValue value type />
|
||||
|
@ -84,7 +85,7 @@ div.dump {
|
|||
<#else><@doScalarValue value />
|
||||
</#if>
|
||||
</div>
|
||||
</#if>
|
||||
</#if>
|
||||
</#macro>
|
||||
|
||||
<#macro doObjectValue obj>
|
||||
|
@ -110,7 +111,8 @@ div.dump {
|
|||
<#elseif value?is_string> <#-- value is return type -->
|
||||
${method} => ${value}
|
||||
<#else> <#-- no-arg method: value is result of method invocation -->
|
||||
${method} => <@divValue><@doTypeAndValue value /></@divValue>
|
||||
<#local isMethod = true>
|
||||
${method} => <@divValue><@doTypeAndValue value isMethod /></@divValue>
|
||||
</#if>
|
||||
</@liItem>
|
||||
</#list>
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue