Merge remote-tracking branch 'origin/GP-2217_ghidra1_DataTypePreviewFix'

This commit is contained in:
Ryan Kurtz 2022-06-22 17:15:36 -04:00
commit e66e5b70e9
3 changed files with 13 additions and 47 deletions

View File

@ -125,13 +125,11 @@ public class CompositeDataTypeHTMLRepresentation extends HTMLDataTypeRepresentat
DataType dataType = dataTypeComponent.getDataType();
String type = "<unknown type>";
DataType locatableType = null;
if (dataType != null) {
type = dataType.getDisplayName();
locatableType = getLocatableDataType(dataType);
}
list.add(new DataTypeLine(fieldName, type, comment, locatableType));
list.add(new DataTypeLine(fieldName, type, comment, dataType));
if (count++ >= MAX_COMPONENT_COUNT) {
// Prevent a ridiculous number of components from consuming all memory.
list.add(
@ -344,7 +342,7 @@ public class CompositeDataTypeHTMLRepresentation extends HTMLDataTypeRepresentat
String type = truncateAsNecessary(line.getType());
type = friendlyEncodeHTML(type);
return wrapStringInColor(type, line.getTypeColor());
return wrapStringInColor(type, color);
}
// overridden to return truncated text by default

View File

@ -15,11 +15,13 @@
*/
package ghidra.app.util.html;
import static ghidra.util.HTMLUtilities.*;
import java.awt.Color;
import java.util.ArrayList;
import java.util.List;
import ghidra.app.util.ToolTipUtils;
import ghidra.app.util.datatype.DataTypeUrl;
import ghidra.app.util.html.diff.DataTypeDiff;
import ghidra.app.util.html.diff.DataTypeDiffBuilder;
import ghidra.program.model.data.*;
@ -130,9 +132,8 @@ public class FunctionDataTypeHTMLRepresentation extends HTMLDataTypeRepresentati
String displayName = dataType.getDisplayName();
String name = var.getName();
DataType locatableType = getLocatableDataType(dataType);
lines.add(new VariableTextLine(HTMLUtilities.friendlyEncodeHTML(displayName),
HTMLUtilities.friendlyEncodeHTML(name), locatableType));
HTMLUtilities.friendlyEncodeHTML(name), dataType));
}
return lines;
@ -242,23 +243,15 @@ public class FunctionDataTypeHTMLRepresentation extends HTMLDataTypeRepresentati
private static String generateTypeText(VariableTextLine line, boolean trim) {
String type = line.getVariableType();
if (trim) {
type = StringUtilities.trimMiddle(type, ToolTipUtils.LINE_LENGTH);
}
type = wrapStringInColor(type, line.getVariableTypeColor());
if (!line.hasUniversalId()) {
return type;
Color color = line.getVariableTypeColor();
DataType dt = line.getDataType();
if (dt != null) {
return generateTypeName(dt, color, trim);
}
//
// Markup the name with info for later hyperlink capability, as needed by the client
//
DataType dataType = line.getDataType();
DataTypeUrl url = new DataTypeUrl(dataType);
String wrapped = HTMLUtilities.wrapWithLinkPlaceholder(type, url.toString());
return wrapped;
String type = truncateAsNecessary(line.getVariableType());
type = friendlyEncodeHTML(type);
return wrapStringInColor(type, color);
}
@Override

View File

@ -288,31 +288,6 @@ public abstract class HTMLDataTypeRepresentation {
return newList;
}
/* Returns a data type that can later be located */
protected static DataType getLocatableDataType(DataType type) {
if (type instanceof DefaultDataType) {
return null; // special case; for some reason this type has a universal ID
}
UniversalID id = type.getUniversalID();
if (id == null) {
type = DataTypeUtils.getNamedBaseDataType(type);
id = type.getUniversalID();
}
if (id == null) {
return null;
}
DataTypeManager manager = type.getDataTypeManager();
if (manager == null) {
return null;
}
return type;
}
protected String originalHTMLData;
/** Default constructor for those who promise to later set the HTML text */