mirror of
https://github.com/NationalSecurityAgency/ghidra.git
synced 2025-10-04 18:29:37 +02:00
GP-4661 - Added the structure member comment to the tooltip
This commit is contained in:
parent
c19facf226
commit
3bf5dcfbb3
1 changed files with 18 additions and 1 deletions
|
@ -17,6 +17,8 @@ package ghidra.app.decompiler.component.hover;
|
|||
|
||||
import javax.swing.JComponent;
|
||||
|
||||
import org.apache.commons.lang3.StringUtils;
|
||||
|
||||
import docking.widgets.fieldpanel.field.Field;
|
||||
import docking.widgets.fieldpanel.support.FieldLocation;
|
||||
import ghidra.GhidraOptions;
|
||||
|
@ -97,10 +99,19 @@ public class DataTypeDecompilerHover extends AbstractConfigurableHover
|
|||
int offset = fieldToken.getOffset();
|
||||
DataType fieldType = getFieldDataType(fieldToken);
|
||||
|
||||
String comment = null;
|
||||
if (parentType instanceof Structure structure) {
|
||||
DataTypeComponent dtc = structure.getComponentAt(offset);
|
||||
if (dtc != null) {
|
||||
comment = StringUtils.truncate(dtc.getComment(), 80); // arbitrary limit
|
||||
}
|
||||
}
|
||||
|
||||
//
|
||||
// Parent: BarBar
|
||||
// Offset: 0x8
|
||||
// Field Name: fooField
|
||||
// Comment: This is a comment
|
||||
//
|
||||
|
||||
StringBuilder buffy = new StringBuilder(HTMLUtilities.HTML);
|
||||
|
@ -113,6 +124,12 @@ public class DataTypeDecompilerHover extends AbstractConfigurableHover
|
|||
row("Offset: ", NumericUtilities.toHexString(offset)));
|
||||
buffy.append(
|
||||
row("Field Name: ", HTMLUtilities.friendlyEncodeHTML(token.getText())));
|
||||
|
||||
if (comment != null) {
|
||||
buffy.append(
|
||||
row("Comment: ", HTMLUtilities.friendlyEncodeHTML(comment)));
|
||||
}
|
||||
|
||||
buffy.append("</TABLE>");
|
||||
//@formatter:on
|
||||
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue