mirror of
https://github.com/NationalSecurityAgency/ghidra.git
synced 2026-05-10 14:21:00 +08:00
GP-6475 follow up on datatype merge action to only popup on supported
datatypes.
This commit is contained in:
+4
-6
@@ -57,12 +57,6 @@ public class MergeDataTypeAction extends DockingAction {
|
||||
setHelpLocation(new HelpLocation("DataTypeManagerPlugin", "merge_datatypes"));
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean isAddToPopup(ActionContext context) {
|
||||
DataTypeTreeNode node = getSelectedDataTypeTreeNode(context);
|
||||
return node instanceof DataTypeNode;
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean isEnabledForContext(ActionContext context) {
|
||||
DataTypeTreeNode node = getSelectedDataTypeTreeNode(context);
|
||||
@@ -75,6 +69,10 @@ public class MergeDataTypeAction extends DockingAction {
|
||||
}
|
||||
|
||||
DataType dataType = dtNode.getDataType();
|
||||
if (!DataTypeUtilities.supportsMerge(dataType)) {
|
||||
return false;
|
||||
}
|
||||
|
||||
DataTypeManager dataTypeManager = dataType.getDataTypeManager();
|
||||
|
||||
// for now, only allow merging on program datatypes.
|
||||
|
||||
+10
@@ -1105,7 +1105,17 @@ public class DataTypeUtilities {
|
||||
public static boolean equalsIgnoreConflict(String name1, String name2) {
|
||||
return getNameWithoutConflict(name1).equals(getNameWithoutConflict(name2));
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* Returns true if there is a {@link DataTypeMerger} that can handle the given datatype. Currently, only structures
|
||||
* unions, and enums are supported.
|
||||
* @param dataType the dataType to check
|
||||
* @return true if there is support for merging that dataType
|
||||
*/
|
||||
public static boolean supportsMerge(DataType dataType) {
|
||||
return dataType instanceof Composite || dataType instanceof Enum;
|
||||
}
|
||||
/**
|
||||
* Convenience method for getting the appropriate datatype merger or throwing an exception
|
||||
* if the two datatypes are not eligible to be merged.
|
||||
|
||||
Reference in New Issue
Block a user