mirror of
https://github.com/NationalSecurityAgency/ghidra.git
synced 2026-05-27 21:15:32 +08:00
GP-537 - documented the odd check in the EditLabelAction
Let EditLabelAction act on LabelFieldLocation function symbols
This commit is contained in:
+19
-23
@@ -23,11 +23,10 @@ import docking.action.KeyBindingData;
|
|||||||
import docking.action.MenuData;
|
import docking.action.MenuData;
|
||||||
import ghidra.app.context.ListingActionContext;
|
import ghidra.app.context.ListingActionContext;
|
||||||
import ghidra.app.context.ListingContextAction;
|
import ghidra.app.context.ListingContextAction;
|
||||||
import ghidra.program.database.symbol.CodeSymbol;
|
|
||||||
import ghidra.program.model.symbol.Symbol;
|
import ghidra.program.model.symbol.Symbol;
|
||||||
import ghidra.program.model.symbol.SymbolType;
|
import ghidra.program.model.symbol.SymbolType;
|
||||||
import ghidra.program.util.LabelFieldLocation;
|
|
||||||
import ghidra.program.util.OperandFieldLocation;
|
import ghidra.program.util.OperandFieldLocation;
|
||||||
|
import ghidra.program.util.ProgramLocation;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* <CODE>AddLabelAction</CODE> allows the user to add a label.
|
* <CODE>AddLabelAction</CODE> allows the user to add a label.
|
||||||
@@ -60,34 +59,31 @@ class EditLabelAction extends ListingContextAction {
|
|||||||
|
|
||||||
@Override
|
@Override
|
||||||
protected boolean isEnabledForContext(ListingActionContext context) {
|
protected boolean isEnabledForContext(ListingActionContext context) {
|
||||||
Symbol symbol = plugin.getSymbol(context);
|
|
||||||
if (symbol != null) {
|
|
||||||
if (symbol.isExternal()) {
|
|
||||||
return false;
|
|
||||||
}
|
|
||||||
if (symbol.getSymbolType() == SymbolType.FUNCTION) {
|
|
||||||
// let the rename function action handle this
|
|
||||||
return false;
|
|
||||||
}
|
|
||||||
getPopupMenuData().setMenuItemName(EDIT_LABEL);
|
|
||||||
return true;
|
|
||||||
}
|
|
||||||
if (LabelMgrPlugin.getComponent(context) != null) {
|
if (LabelMgrPlugin.getComponent(context) != null) {
|
||||||
getPopupMenuData().setMenuItemName(EDIT_FIELDNAME);
|
getPopupMenuData().setMenuItemName(EDIT_FIELDNAME);
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
return false;
|
|
||||||
}
|
|
||||||
|
|
||||||
boolean isOnSymbol(ListingActionContext context) {
|
Symbol symbol = plugin.getSymbol(context);
|
||||||
if (context.getLocation() instanceof LabelFieldLocation) {
|
if (symbol == null) {
|
||||||
return plugin.isOnSymbol(context);
|
return false;
|
||||||
}
|
}
|
||||||
else if (context.getLocation() instanceof OperandFieldLocation) {
|
|
||||||
Symbol s = plugin.getSymbol(context);
|
if (symbol.isExternal()) {
|
||||||
return (s instanceof CodeSymbol);
|
return false;
|
||||||
}
|
}
|
||||||
return false;
|
|
||||||
|
if (symbol.getSymbolType() == SymbolType.FUNCTION) {
|
||||||
|
ProgramLocation location = context.getLocation();
|
||||||
|
if (location instanceof OperandFieldLocation) {
|
||||||
|
// Functions in operand fields are handled by the EditNameAction. Return false
|
||||||
|
// here to prevent 2 popup actions from appearing in the menu.
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
getPopupMenuData().setMenuItemName(EDIT_LABEL);
|
||||||
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
|
|||||||
Reference in New Issue
Block a user