mirror of
https://github.com/NationalSecurityAgency/ghidra.git
synced 2026-06-01 06:05:12 +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"));
|
setHelpLocation(new HelpLocation("DataTypeManagerPlugin", "merge_datatypes"));
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
|
||||||
public boolean isAddToPopup(ActionContext context) {
|
|
||||||
DataTypeTreeNode node = getSelectedDataTypeTreeNode(context);
|
|
||||||
return node instanceof DataTypeNode;
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public boolean isEnabledForContext(ActionContext context) {
|
public boolean isEnabledForContext(ActionContext context) {
|
||||||
DataTypeTreeNode node = getSelectedDataTypeTreeNode(context);
|
DataTypeTreeNode node = getSelectedDataTypeTreeNode(context);
|
||||||
@@ -75,6 +69,10 @@ public class MergeDataTypeAction extends DockingAction {
|
|||||||
}
|
}
|
||||||
|
|
||||||
DataType dataType = dtNode.getDataType();
|
DataType dataType = dtNode.getDataType();
|
||||||
|
if (!DataTypeUtilities.supportsMerge(dataType)) {
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
|
||||||
DataTypeManager dataTypeManager = dataType.getDataTypeManager();
|
DataTypeManager dataTypeManager = dataType.getDataTypeManager();
|
||||||
|
|
||||||
// for now, only allow merging on program datatypes.
|
// for now, only allow merging on program datatypes.
|
||||||
|
|||||||
+10
@@ -1106,6 +1106,16 @@ public class DataTypeUtilities {
|
|||||||
return getNameWithoutConflict(name1).equals(getNameWithoutConflict(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
|
* Convenience method for getting the appropriate datatype merger or throwing an exception
|
||||||
* if the two datatypes are not eligible to be merged.
|
* if the two datatypes are not eligible to be merged.
|
||||||
|
|||||||
Reference in New Issue
Block a user