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;
originalHTMLData = buildHTMLText(headerContent, bodyHtml, footerContent, false);
String trimmedBodyHtml = buildBodyHTML(true);
truncatedHtmlData = buildHTMLText(headerContent, trimmedBodyHtml, footerContent, true);
}
private DataType getBaseDataType() {

View file

@ -16,6 +16,7 @@
package ghidra.app.util.html;
import java.awt.Color;
import java.util.Objects;
import ghidra.program.model.data.DataType;
import ghidra.util.StringUtilities;
@ -43,12 +44,8 @@ public class DataTypeLine implements ValidatableLine {
name = "";
}
if (type == null) {
throw new NullPointerException("Type of data type cannot be null");
}
this.name = name;
this.type = type;
this.type = Objects.requireNonNull(type, "Type of data type cannot be null");
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 final Enum enumDataType;
protected List<ValidatableLine> headerContent;
protected List<ValidatableLine> bodyContent;
protected TextLine footerLine;
@ -37,26 +39,34 @@ public class EnumDataTypeHTMLRepresentation extends HTMLDataTypeRepresentation {
private static String truncatedHtmlData;
// 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) {
this.enumDataType = enumDataType;
this.headerContent = headerLines;
this.displayName = displayName;
this.bodyContent = bodyContent;
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) {
this.enumDataType = enumDataType;
headerContent = buildHeaderText(enumDataType);
bodyContent = buildContent(enumDataType, false);
bodyContent = buildContent(false);
footerLine = buildFooterText(enumDataType);
displayName = new TextLine("enum " + enumDataType.getDisplayName());
originalHTMLData =
buildHTMLText(headerContent, displayName, bodyContent, footerLine, false);
List<ValidatableLine> trimmedBodyContent = buildContent(enumDataType, true);
List<ValidatableLine> trimmedBodyContent = buildContent(true);
truncatedHtmlData =
buildHTMLText(headerContent, displayName, trimmedBodyContent, footerLine, true);
}
@ -83,7 +93,7 @@ public class EnumDataTypeHTMLRepresentation extends HTMLDataTypeRepresentation {
return new EmptyTextLine(stringLength);
}
private List<ValidatableLine> buildContent(Enum enumDataType, boolean trim) {
private List<ValidatableLine> buildContent(boolean trim) {
long[] values = enumDataType.getValues();
Arrays.sort(values);
@ -213,16 +223,16 @@ public class EnumDataTypeHTMLRepresentation extends HTMLDataTypeRepresentation {
return completelyDifferentDiff(otherRepresentation);
}
EnumDataTypeHTMLRepresentation compositeRepresentation =
EnumDataTypeHTMLRepresentation enumRepresentation =
(EnumDataTypeHTMLRepresentation) otherRepresentation;
List<ValidatableLine> header = copyLines(headerContent);
List<ValidatableLine> body = copyLines(bodyContent);
TextLine diffDisplayName = new TextLine(displayName.getText());
List<ValidatableLine> otherHeader = copyLines(compositeRepresentation.headerContent);
List<ValidatableLine> otherBody = copyLines(compositeRepresentation.bodyContent);
TextLine otherDiffDisplayName = new TextLine(compositeRepresentation.displayName.getText());
List<ValidatableLine> otherHeader = copyLines(enumRepresentation.headerContent);
List<ValidatableLine> otherBody = copyLines(enumRepresentation.bodyContent);
TextLine otherDiffDisplayName = new TextLine(enumRepresentation.displayName.getText());
DataTypeDiff headerDiff =
DataTypeDiffBuilder.diffHeader(getDiffInput(header), getDiffInput(otherHeader));
@ -233,10 +243,12 @@ public class EnumDataTypeHTMLRepresentation extends HTMLDataTypeRepresentation {
diffTextLine(diffDisplayName, otherDiffDisplayName);
return new HTMLDataTypeRepresentation[] {
new EnumDataTypeHTMLRepresentation(headerDiff.getLeftLines(), diffDisplayName,
bodyDiff.getLeftLines(), footerLine),
new EnumDataTypeHTMLRepresentation(headerDiff.getRightLines(), otherDiffDisplayName,
bodyDiff.getRightLines(), compositeRepresentation.footerLine), };
new EnumDataTypeHTMLRepresentation(enumDataType, headerDiff.getLeftLines(),
diffDisplayName, bodyDiff.getLeftLines(), footerLine),
new EnumDataTypeHTMLRepresentation(enumRepresentation.enumDataType,
headerDiff.getRightLines(), otherDiffDisplayName, bodyDiff.getRightLines(),
enumRepresentation.footerLine)
};
}
}

View file

@ -30,7 +30,6 @@ import ghidra.util.exception.AssertException;
public class FunctionDataTypeHTMLRepresentation extends HTMLDataTypeRepresentation {
private static final int MAX_CHAR_COUNT = 30;
private static final int MAX_LINE_COUNT = 10;
protected TextLine returnType;
@ -50,7 +49,10 @@ public class FunctionDataTypeHTMLRepresentation extends HTMLDataTypeRepresentati
this.arguments = arguments;
this.varArgs = varArgs;
this.voidArgs = voidArgs;
originalHTMLData =
buildHTMLText(returnType, functionName, arguments, varArgs, voidArgs, false);
truncatedHtmlData =
buildHTMLText(returnType, functionName, arguments, varArgs, voidArgs, true);
}
@ -236,19 +238,6 @@ public class FunctionDataTypeHTMLRepresentation extends HTMLDataTypeRepresentati
fullHtml.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) {

View file

@ -1,6 +1,5 @@
/* ###
* IP: GHIDRA
* REVIEWED: YES
*
* Licensed under the Apache License, Version 2.0 (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 */
public interface PlaceHolderLine extends ValidatableLine {
// marker interface
}

View file

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

View file

@ -43,7 +43,10 @@ public class TypeDefDataTypeHTMLRepresentation extends HTMLDataTypeRepresentatio
this.headerContent = headerLines;
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) {
@ -249,14 +252,14 @@ public class TypeDefDataTypeHTMLRepresentation extends HTMLDataTypeRepresentatio
List<ValidatableLine> body = new ArrayList<>();
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> otherBody = new ArrayList<>();
if (diffs != null) {
otherBody.add(new TextLine(diffs[1].getHTMLContentString()));
otherBody.add(new TextLine(diffs[1].getFullHTMLContentString()));
}
DataTypeDiff headerDiff =

View file

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