Merge remote-tracking branch 'origin/GP-0-dragonamcher-test-fixes-6-08-21' into Ghidra_10.0

This commit is contained in:
ghidra1 2021-06-08 12:10:42 -04:00
commit 4be9db7356
8 changed files with 45 additions and 45 deletions

View file

@ -54,6 +54,9 @@ public class ArrayDataTypeHTMLRepresentation extends HTMLDataTypeRepresentation
this.footerContent = footerContent; this.footerContent = footerContent;
originalHTMLData = buildHTMLText(headerContent, bodyHtml, footerContent, false); originalHTMLData = buildHTMLText(headerContent, bodyHtml, footerContent, false);
String trimmedBodyHtml = buildBodyHTML(true);
truncatedHtmlData = buildHTMLText(headerContent, trimmedBodyHtml, footerContent, true);
} }
private DataType getBaseDataType() { private DataType getBaseDataType() {

View file

@ -16,6 +16,7 @@
package ghidra.app.util.html; package ghidra.app.util.html;
import java.awt.Color; import java.awt.Color;
import java.util.Objects;
import ghidra.program.model.data.DataType; import ghidra.program.model.data.DataType;
import ghidra.util.StringUtilities; import ghidra.util.StringUtilities;
@ -43,12 +44,8 @@ public class DataTypeLine implements ValidatableLine {
name = ""; name = "";
} }
if (type == null) {
throw new NullPointerException("Type of data type cannot be null");
}
this.name = name; this.name = name;
this.type = type; this.type = Objects.requireNonNull(type, "Type of data type cannot be null");
this.comment = comment == null ? "" : comment; this.comment = comment == null ? "" : comment;
} }

View file

@ -29,6 +29,8 @@ public class EnumDataTypeHTMLRepresentation extends HTMLDataTypeRepresentation {
private static final int MAX_LINE_COUNT = 15; private static final int MAX_LINE_COUNT = 15;
private final Enum enumDataType;
protected List<ValidatableLine> headerContent; protected List<ValidatableLine> headerContent;
protected List<ValidatableLine> bodyContent; protected List<ValidatableLine> bodyContent;
protected TextLine footerLine; protected TextLine footerLine;
@ -37,26 +39,34 @@ public class EnumDataTypeHTMLRepresentation extends HTMLDataTypeRepresentation {
private static String truncatedHtmlData; private static String truncatedHtmlData;
// private constructor for making diff copies // private constructor for making diff copies
private EnumDataTypeHTMLRepresentation(List<ValidatableLine> headerLines, TextLine displayName, private EnumDataTypeHTMLRepresentation(Enum enumDataType, List<ValidatableLine> headerLines,
TextLine displayName,
List<ValidatableLine> bodyContent, TextLine footerLine) { List<ValidatableLine> bodyContent, TextLine footerLine) {
this.enumDataType = enumDataType;
this.headerContent = headerLines; this.headerContent = headerLines;
this.displayName = displayName; this.displayName = displayName;
this.bodyContent = bodyContent; this.bodyContent = bodyContent;
this.footerLine = footerLine; this.footerLine = footerLine;
originalHTMLData = buildHTMLText(headerLines, displayName, bodyContent, footerLine, false); originalHTMLData =
buildHTMLText(headerContent, displayName, bodyContent, footerLine, false);
List<ValidatableLine> trimmedBodyContent = buildContent(true);
truncatedHtmlData =
buildHTMLText(headerContent, displayName, trimmedBodyContent, footerLine, true);
} }
public EnumDataTypeHTMLRepresentation(Enum enumDataType) { public EnumDataTypeHTMLRepresentation(Enum enumDataType) {
this.enumDataType = enumDataType;
headerContent = buildHeaderText(enumDataType); headerContent = buildHeaderText(enumDataType);
bodyContent = buildContent(enumDataType, false); bodyContent = buildContent(false);
footerLine = buildFooterText(enumDataType); footerLine = buildFooterText(enumDataType);
displayName = new TextLine("enum " + enumDataType.getDisplayName()); displayName = new TextLine("enum " + enumDataType.getDisplayName());
originalHTMLData = originalHTMLData =
buildHTMLText(headerContent, displayName, bodyContent, footerLine, false); buildHTMLText(headerContent, displayName, bodyContent, footerLine, false);
List<ValidatableLine> trimmedBodyContent = buildContent(enumDataType, true); List<ValidatableLine> trimmedBodyContent = buildContent(true);
truncatedHtmlData = truncatedHtmlData =
buildHTMLText(headerContent, displayName, trimmedBodyContent, footerLine, true); buildHTMLText(headerContent, displayName, trimmedBodyContent, footerLine, true);
} }
@ -83,7 +93,7 @@ public class EnumDataTypeHTMLRepresentation extends HTMLDataTypeRepresentation {
return new EmptyTextLine(stringLength); return new EmptyTextLine(stringLength);
} }
private List<ValidatableLine> buildContent(Enum enumDataType, boolean trim) { private List<ValidatableLine> buildContent(boolean trim) {
long[] values = enumDataType.getValues(); long[] values = enumDataType.getValues();
Arrays.sort(values); Arrays.sort(values);
@ -213,16 +223,16 @@ public class EnumDataTypeHTMLRepresentation extends HTMLDataTypeRepresentation {
return completelyDifferentDiff(otherRepresentation); return completelyDifferentDiff(otherRepresentation);
} }
EnumDataTypeHTMLRepresentation compositeRepresentation = EnumDataTypeHTMLRepresentation enumRepresentation =
(EnumDataTypeHTMLRepresentation) otherRepresentation; (EnumDataTypeHTMLRepresentation) otherRepresentation;
List<ValidatableLine> header = copyLines(headerContent); List<ValidatableLine> header = copyLines(headerContent);
List<ValidatableLine> body = copyLines(bodyContent); List<ValidatableLine> body = copyLines(bodyContent);
TextLine diffDisplayName = new TextLine(displayName.getText()); TextLine diffDisplayName = new TextLine(displayName.getText());
List<ValidatableLine> otherHeader = copyLines(compositeRepresentation.headerContent); List<ValidatableLine> otherHeader = copyLines(enumRepresentation.headerContent);
List<ValidatableLine> otherBody = copyLines(compositeRepresentation.bodyContent); List<ValidatableLine> otherBody = copyLines(enumRepresentation.bodyContent);
TextLine otherDiffDisplayName = new TextLine(compositeRepresentation.displayName.getText()); TextLine otherDiffDisplayName = new TextLine(enumRepresentation.displayName.getText());
DataTypeDiff headerDiff = DataTypeDiff headerDiff =
DataTypeDiffBuilder.diffHeader(getDiffInput(header), getDiffInput(otherHeader)); DataTypeDiffBuilder.diffHeader(getDiffInput(header), getDiffInput(otherHeader));
@ -233,10 +243,12 @@ public class EnumDataTypeHTMLRepresentation extends HTMLDataTypeRepresentation {
diffTextLine(diffDisplayName, otherDiffDisplayName); diffTextLine(diffDisplayName, otherDiffDisplayName);
return new HTMLDataTypeRepresentation[] { return new HTMLDataTypeRepresentation[] {
new EnumDataTypeHTMLRepresentation(headerDiff.getLeftLines(), diffDisplayName, new EnumDataTypeHTMLRepresentation(enumDataType, headerDiff.getLeftLines(),
bodyDiff.getLeftLines(), footerLine), diffDisplayName, bodyDiff.getLeftLines(), footerLine),
new EnumDataTypeHTMLRepresentation(headerDiff.getRightLines(), otherDiffDisplayName, new EnumDataTypeHTMLRepresentation(enumRepresentation.enumDataType,
bodyDiff.getRightLines(), compositeRepresentation.footerLine), }; headerDiff.getRightLines(), otherDiffDisplayName, bodyDiff.getRightLines(),
enumRepresentation.footerLine)
};
} }
} }

View file

@ -30,7 +30,6 @@ import ghidra.util.exception.AssertException;
public class FunctionDataTypeHTMLRepresentation extends HTMLDataTypeRepresentation { public class FunctionDataTypeHTMLRepresentation extends HTMLDataTypeRepresentation {
private static final int MAX_CHAR_COUNT = 30;
private static final int MAX_LINE_COUNT = 10; private static final int MAX_LINE_COUNT = 10;
protected TextLine returnType; protected TextLine returnType;
@ -50,7 +49,10 @@ public class FunctionDataTypeHTMLRepresentation extends HTMLDataTypeRepresentati
this.arguments = arguments; this.arguments = arguments;
this.varArgs = varArgs; this.varArgs = varArgs;
this.voidArgs = voidArgs; this.voidArgs = voidArgs;
originalHTMLData = originalHTMLData =
buildHTMLText(returnType, functionName, arguments, varArgs, voidArgs, false);
truncatedHtmlData =
buildHTMLText(returnType, functionName, arguments, varArgs, voidArgs, true); buildHTMLText(returnType, functionName, arguments, varArgs, voidArgs, true);
} }
@ -236,19 +238,6 @@ public class FunctionDataTypeHTMLRepresentation extends HTMLDataTypeRepresentati
fullHtml.append(string); fullHtml.append(string);
truncatedHtml.append(string); truncatedHtml.append(string);
} }
//maybeAppend(truncatedHtml, lineCount, content);
}
private static void maybeAppend(StringBuilder buffer, int charCount, String... content) {
if (charCount > MAX_LINE_COUNT) {
return;
}
for (String string : content) {
String trimmed = StringUtilities.trimMiddle(string, MAX_CHAR_COUNT);
buffer.append(trimmed);
}
} }
private static String generateTypeText(VariableTextLine line, boolean trim) { private static String generateTypeText(VariableTextLine line, boolean trim) {

View file

@ -1,6 +1,5 @@
/* ### /* ###
* IP: GHIDRA * IP: GHIDRA
* REVIEWED: YES
* *
* Licensed under the Apache License, Version 2.0 (the "License"); * Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License. * you may not use this file except in compliance with the License.
@ -19,4 +18,5 @@ package ghidra.app.util.html;
/** Marker interface for lines that are generic place holders for diffing */ /** Marker interface for lines that are generic place holders for diffing */
public interface PlaceHolderLine extends ValidatableLine { public interface PlaceHolderLine extends ValidatableLine {
// marker interface
} }

View file

@ -16,6 +16,7 @@
package ghidra.app.util.html; package ghidra.app.util.html;
import java.awt.Color; import java.awt.Color;
import java.util.Objects;
import ghidra.util.exception.AssertException; import ghidra.util.exception.AssertException;
@ -27,11 +28,7 @@ public class TextLine implements ValidatableLine {
private ValidatableLine validationLine; private ValidatableLine validationLine;
public TextLine(String text) { public TextLine(String text) {
if (text == null) { this.text = Objects.requireNonNull(text);
throw new NullPointerException("Text cannot be null.");
}
this.text = text;
} }
@Override @Override

View file

@ -43,7 +43,10 @@ public class TypeDefDataTypeHTMLRepresentation extends HTMLDataTypeRepresentatio
this.headerContent = headerLines; this.headerContent = headerLines;
this.bodyContent = bodyLines; this.bodyContent = bodyLines;
originalHTMLData = buildHTMLText(typeDef, warningLines, headerLines, bodyLines, false); List<ValidatableLine> trimmedHeaderContent = buildHeaderText(typeDef, true);
List<ValidatableLine> trimmedBodyContent = buildBodyText(getBaseDataType(), true);
truncatedHtmlData =
buildHTMLText(typeDef, warningLines, trimmedHeaderContent, trimmedBodyContent, true);
} }
public TypeDefDataTypeHTMLRepresentation(TypeDef typeDef) { public TypeDefDataTypeHTMLRepresentation(TypeDef typeDef) {
@ -249,14 +252,14 @@ public class TypeDefDataTypeHTMLRepresentation extends HTMLDataTypeRepresentatio
List<ValidatableLine> body = new ArrayList<>(); List<ValidatableLine> body = new ArrayList<>();
if (diffs != null) { if (diffs != null) {
body.add(new TextLine(diffs[0].getHTMLContentString())); body.add(new TextLine(diffs[0].getFullHTMLContentString()));
} }
List<ValidatableLine> otherHeader = new ArrayList<>(typeDefRepresentation.headerContent); List<ValidatableLine> otherHeader = new ArrayList<>(typeDefRepresentation.headerContent);
List<ValidatableLine> otherBody = new ArrayList<>(); List<ValidatableLine> otherBody = new ArrayList<>();
if (diffs != null) { if (diffs != null) {
otherBody.add(new TextLine(diffs[1].getHTMLContentString())); otherBody.add(new TextLine(diffs[1].getFullHTMLContentString()));
} }
DataTypeDiff headerDiff = DataTypeDiff headerDiff =

View file

@ -16,6 +16,7 @@
package ghidra.app.util.html; package ghidra.app.util.html;
import java.awt.Color; import java.awt.Color;
import java.util.Objects;
import ghidra.program.model.data.DataType; import ghidra.program.model.data.DataType;
import ghidra.util.UniversalID; import ghidra.util.UniversalID;
@ -33,9 +34,6 @@ public class VariableTextLine implements ValidatableLine {
private ValidatableLine validationLine; private ValidatableLine validationLine;
public VariableTextLine(String variableType, String variableName, DataType dataType) { public VariableTextLine(String variableType, String variableName, DataType dataType) {
if (variableType == null) {
throw new NullPointerException("variable type cannot be null");
}
if (variableName == null) { if (variableName == null) {
//throw new NullPointerException( "variable name cannot be null" ); //throw new NullPointerException( "variable name cannot be null" );
@ -45,7 +43,8 @@ public class VariableTextLine implements ValidatableLine {
variableName = ""; variableName = "";
} }
this.variableType = variableType; this.variableType =
Objects.requireNonNull(variableType, "Variable type cannot be null");
this.variableName = variableName; this.variableName = variableName;
this.dataType = dataType; this.dataType = dataType;
} }