From dbbc2d91e517d7b8c7d2c5d2644dcd58ee48f1f8 Mon Sep 17 00:00:00 2001 From: dragonmacher <48328597+dragonmacher@users.noreply.github.com> Date: Wed, 12 Jun 2019 14:38:49 -0400 Subject: [PATCH] Updated 'Apply Enum...' action to only work when there is a program selection in order to reduce confusion about the correct context for this action. --- Ghidra/Features/Base/certification.manifest | 1 - .../help/help/topics/EquatePlugin/Equates.htm | 7 ++- .../app/plugin/core/equate/EquatePlugin.java | 2 +- .../plugin/core/equate/EquatePlugin2Test.java | 45 ------------------- 4 files changed, 4 insertions(+), 51 deletions(-) delete mode 100644 Ghidra/Features/Base/src/test.slow/java/ghidra/app/plugin/core/equate/EquatePlugin2Test.java diff --git a/Ghidra/Features/Base/certification.manifest b/Ghidra/Features/Base/certification.manifest index 8e3b8a2462..c7b52bb143 100644 --- a/Ghidra/Features/Base/certification.manifest +++ b/Ghidra/Features/Base/certification.manifest @@ -842,7 +842,6 @@ src/main/java/ghidra/app/cmd/package.html||GHIDRA||reviewed||END| src/main/java/ghidra/app/cmd/refs/package.html||GHIDRA||||END| src/main/java/ghidra/app/cmd/register/package.html||GHIDRA||||END| src/main/java/ghidra/app/events/package.html||GHIDRA||reviewed||END| -src/main/java/ghidra/app/plugin/core/compositeeditor/BITFIELDS_HELP_NOTES.txt||GHIDRA||||END| src/main/java/ghidra/app/plugin/core/disassembler/package.html||GHIDRA||reviewed||END| src/main/java/ghidra/app/services/package.html||GHIDRA||reviewed||END| src/main/java/ghidra/app/util/bin/format/elf/package.html||GHIDRA||||END| diff --git a/Ghidra/Features/Base/src/main/help/help/topics/EquatePlugin/Equates.htm b/Ghidra/Features/Base/src/main/help/help/topics/EquatePlugin/Equates.htm index 08205a6e5d..a3dbeb780d 100644 --- a/Ghidra/Features/Base/src/main/help/help/topics/EquatePlugin/Equates.htm +++ b/Ghidra/Features/Base/src/main/help/help/topics/EquatePlugin/Equates.htm @@ -279,8 +279,9 @@

Apply Enum

-

The Apply Enum action will apply enum member names to scalars in the current - selection if any of the enum values match scalars in the current selection.

+

The Apply Enum action (only available when there is a selection), will apply + enum member names to scalars in the current selection if any of the enum values match + those scalars.

To apply an enum to the selection:

@@ -288,8 +289,6 @@
  1. Make a selection and then Right-mouse-click, then choose Apply Enum. - Note that the Apply Enum action will only appear in the Right-mouse menu - if there is a selection and if there are scalars within the selection.


    Apply Enum Popup

    diff --git a/Ghidra/Features/Base/src/main/java/ghidra/app/plugin/core/equate/EquatePlugin.java b/Ghidra/Features/Base/src/main/java/ghidra/app/plugin/core/equate/EquatePlugin.java index d6cecc4b51..2c1e0cf16b 100644 --- a/Ghidra/Features/Base/src/main/java/ghidra/app/plugin/core/equate/EquatePlugin.java +++ b/Ghidra/Features/Base/src/main/java/ghidra/app/plugin/core/equate/EquatePlugin.java @@ -802,7 +802,7 @@ public class EquatePlugin extends Plugin { @Override protected boolean isEnabledForContext(ListingActionContext context) { - return context.hasSelection() || isEquatePermitted(context); + return context.hasSelection(); } }; applyEnumAction.setHelpLocation(new HelpLocation("EquatePlugin", "Apply_Enum")); diff --git a/Ghidra/Features/Base/src/test.slow/java/ghidra/app/plugin/core/equate/EquatePlugin2Test.java b/Ghidra/Features/Base/src/test.slow/java/ghidra/app/plugin/core/equate/EquatePlugin2Test.java deleted file mode 100644 index aab2cc24d9..0000000000 --- a/Ghidra/Features/Base/src/test.slow/java/ghidra/app/plugin/core/equate/EquatePlugin2Test.java +++ /dev/null @@ -1,45 +0,0 @@ -/* ### - * IP: GHIDRA - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ -package ghidra.app.plugin.core.equate; - -import static org.junit.Assert.assertFalse; -import static org.junit.Assert.assertTrue; - -import org.junit.Test; - -/** - * Tests the Equate Plugin functionality. - */ -public class EquatePlugin2Test extends AbstractEquatePluginTest { - - @Test - public void testApplyEnumActionEnabled() { - - assertFalse(applyEnumAction.isEnabledForContext(getListingContext())); - - putCursorOnOperand(0x010064c5, 1); - assertFalse(applyEnumAction.isEnabledForContext(getListingContext())); // existing equate exists - - removeAction.actionPerformed(getListingContext()); // remove existing equate - waitForBusyTool(tool); - - assertTrue(applyEnumAction.isEnabledForContext(getListingContext())); - - selectRange(addr(0x0100644c), addr(0x01006458)); - assertTrue(applyEnumAction.isEnabledForContext(getListingContext())); - } - -}