Merge remote-tracking branch 'origin/GP-6475_ghidragon_merge_action_only_on_supported_types'

This commit is contained in:
Ryan Kurtz
2026-02-23 14:32:13 -05:00
2 changed files with 14 additions and 6 deletions

View File

@@ -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.

View File

@@ -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.