Skip to content

Ghidra is a software reverse engineering (SRE) framework

GP-3329 - Search Highlights - Major update and refactor of the way Listing highlights work. Highlights are now more closely coupled with the fields that will paint them.

dragonmacher84650030d0c8
diff --git a/Ghidra/Debug/TaintAnalysis/src/main/java/ghidra/taint/gui/field/TaintFieldFactory.java b/Ghidra/Debug/TaintAnalysis/src/main/java/ghidra/taint/gui/field/TaintFieldFactory.java
index 4e44965edf..a3cb5b9b41 100644
--- a/Ghidra/Debug/TaintAnalysis/src/main/java/ghidra/taint/gui/field/TaintFieldFactory.java
+++ b/Ghidra/Debug/TaintAnalysis/src/main/java/ghidra/taint/gui/field/TaintFieldFactory.java
@@ -21,7 +21,7 @@ import docking.widgets.fieldpanel.field.AttributedString;
import docking.widgets.fieldpanel.field.TextFieldElement;
import docking.widgets.fieldpanel.support.FieldLocation;
import generic.theme.GColor;
-import ghidra.app.util.HighlightProvider;
+import ghidra.app.util.ListingHighlightProvider;
import ghidra.app.util.viewer.field.*;
import ghidra.app.util.viewer.format.FieldFormatModel;
import ghidra.app.util.viewer.proxy.ProxyObj;
@@ -50,14 +50,14 @@ public class TaintFieldFactory extends FieldFactory {
super(FIELD_NAME);
}
- protected TaintFieldFactory(FieldFormatModel formatModel, HighlightProvider highlightProvider,
+ protected TaintFieldFactory(FieldFormatModel formatModel, ListingHighlightProvider highlightProvider,
Options displayOptions, Options fieldOptions) {
super(FIELD_NAME, formatModel, highlightProvider, displayOptions, fieldOptions);
}
@Override
public FieldFactory newInstance(FieldFormatModel formatModel,
- HighlightProvider highlightProvider, ToolOptions displayOptions,
+ ListingHighlightProvider highlightProvider, ToolOptions displayOptions,
ToolOptions fieldOptions) {
return new TaintFieldFactory(formatModel, highlightProvider, displayOptions, fieldOptions);
}
diff --git a/Ghidra/Extensions/SleighDevTools/src/main/java/ghidra/app/util/disassemble/ExternalDisassemblyFieldFactory.java b/Ghidra/Extensions/SleighDevTools/src/main/java/ghidra/app/util/disassemble/ExternalDisassemblyFieldFactory.java
index ab78eb369d..2aae3e659c 100644
--- a/Ghidra/Extensions/SleighDevTools/src/main/java/ghidra/app/util/disassemble/ExternalDisassemblyFieldFactory.java
+++ b/Ghidra/Extensions/SleighDevTools/src/main/java/ghidra/app/util/disassemble/ExternalDisassemblyFieldFactory.java
@@ -23,7 +23,7 @@ import docking.widgets.fieldpanel.field.*;
import docking.widgets.fieldpanel.support.FieldLocation;
import generic.theme.GColor;
import generic.theme.GThemeDefaults.Colors.Messages;
-import ghidra.app.util.HighlightProvider;
+import ghidra.app.util.ListingHighlightProvider;
import ghidra.app.util.viewer.field.*;
import ghidra.app.util.viewer.format.FieldFormatModel;
import ghidra.app.util.viewer.proxy.ProxyObj;
@@ -61,7 +61,7 @@ public class ExternalDisassemblyFieldFactory extends FieldFactory {
super(FIELD_NAME);
}
- private ExternalDisassemblyFieldFactory(FieldFormatModel model, HighlightProvider hlProvider,
+ private ExternalDisassemblyFieldFactory(FieldFormatModel model, ListingHighlightProvider hlProvider,
Options displayOptions, Options fieldOptions) {
super(FIELD_NAME, model, hlProvider, displayOptions, fieldOptions);
}
@@ -96,7 +96,7 @@ public class ExternalDisassemblyFieldFactory extends FieldFactory {
@Override
public FieldFactory newInstance(FieldFormatModel formatModel,
- HighlightProvider highlightProvider, ToolOptions options, ToolOptions fieldOptions) {
+ ListingHighlightProvider highlightProvider, ToolOptions options, ToolOptions fieldOptions) {
return new ExternalDisassemblyFieldFactory(formatModel, highlightProvider, options,
fieldOptions);
}
diff --git a/Ghidra/Extensions/sample/src/main/java/ghidra/examples/EntropyFieldFactory.java b/Ghidra/Extensions/sample/src/main/java/ghidra/examples/EntropyFieldFactory.java
index c5dfc43960..6e552a84d7 100644
--- a/Ghidra/Extensions/sample/src/main/java/ghidra/examples/EntropyFieldFactory.java
+++ b/Ghidra/Extensions/sample/src/main/java/ghidra/examples/EntropyFieldFactory.java
@@ -21,7 +21,7 @@ import java.math.BigInteger;
import docking.widgets.fieldpanel.field.*;
import docking.widgets.fieldpanel.support.FieldLocation;
import generic.theme.GColor;
-import ghidra.app.util.HighlightProvider;
+import ghidra.app.util.ListingHighlightProvider;
import ghidra.app.util.viewer.field.*;
import ghidra.app.util.viewer.format.FieldFormatModel;
import ghidra.app.util.viewer.listingpanel.ListingModel;
@@ -52,7 +52,7 @@ public class EntropyFieldFactory extends FieldFactory {
* @param displayOptions the Options for display properties.
* @param fieldOptions the Options for field specific properties.
*/
- private EntropyFieldFactory(FieldFormatModel model, HighlightProvider hlProvider,
+ private EntropyFieldFactory(FieldFormatModel model, ListingHighlightProvider hlProvider,
Options displayOptions, Options fieldOptions) {
super(FIELD_NAME, model, hlProvider, displayOptions, fieldOptions);
}
@@ -154,7 +154,7 @@ public class EntropyFieldFactory extends FieldFactory {
}
@Override
- public FieldFactory newInstance(FieldFormatModel myModel, HighlightProvider myHlProvider,
+ public FieldFactory newInstance(FieldFormatModel myModel, ListingHighlightProvider myHlProvider,
ToolOptions displayOptions1, ToolOptions fieldOptions) {
return new EntropyFieldFactory(myModel, myHlProvider, displayOptions1, fieldOptions);
}
diff --git a/Ghidra/Features/Base/src/main/java/ghidra/app/merge/ProgramMultiUserMergeManager.java b/Ghidra/Features/Base/src/main/java/ghidra/app/merge/ProgramMultiUserMergeManager.java
index 31e59c1e23..6f18ff7fcd 100644
--- a/Ghidra/Features/Base/src/main/java/ghidra/app/merge/ProgramMultiUserMergeManager.java
+++ b/Ghidra/Features/Base/src/main/java/ghidra/app/merge/ProgramMultiUserMergeManager.java
@@ -29,7 +29,7 @@ import ghidra.app.merge.tool.ListingMergePanelPlugin;
import ghidra.app.merge.tree.ProgramTreeMergeManager;
import ghidra.app.nav.*;
import ghidra.app.plugin.core.navigation.GoToAddressLabelPlugin;
-import ghidra.app.util.HighlightProvider;
+import ghidra.app.util.ListingHighlightProvider;
import ghidra.app.util.viewer.util.FieldNavigator;
import ghidra.framework.model.UndoableDomainObject;
import ghidra.framework.plugintool.ModalPluginTool;
@@ -516,12 +516,12 @@ class MergeNavigatable implements Navigatable {
}
@Override
- public void removeHighlightProvider(HighlightProvider highlightProvider, Program program) {
+ public void removeHighlightProvider(ListingHighlightProvider highlightProvider, Program program) {
// currently unsupported
}
@Override
- public void setHighlightProvider(HighlightProvider highlightProvider, Program program) {
+ public void setHighlightProvider(ListingHighlightProvider highlightProvider, Program program) {
// currently unsupported
}
diff --git a/Ghidra/Features/Base/src/main/java/ghidra/app/nav/Navigatable.java b/Ghidra/Features/Base/src/main/java/ghidra/app/nav/Navigatable.java
index caba88008c..a731f0bcca 100644
--- a/Ghidra/Features/Base/src/main/java/ghidra/app/nav/Navigatable.java
+++ b/Ghidra/Features/Base/src/main/java/ghidra/app/nav/Navigatable.java
@@ -17,7 +17,7 @@ package ghidra.app.nav;
import javax.swing.Icon;
-import ghidra.app.util.HighlightProvider;
+import ghidra.app.util.ListingHighlightProvider;
import ghidra.program.model.listing.Program;
import ghidra.program.util.ProgramLocation;
import ghidra.program.util.ProgramSelection;
@@ -185,7 +185,7 @@ public interface Navigatable {
* @param highlightProvider the provider
* @param program the program
*/
- public void setHighlightProvider(HighlightProvider highlightProvider, Program program);
+ public void setHighlightProvider(ListingHighlightProvider highlightProvider, Program program);
/**
* Removes the given highlight provider for the given program
@@ -193,5 +193,5 @@ public interface Navigatable {
* @param highlightProvider the provider
* @param program the program
*/
- public void removeHighlightProvider(HighlightProvider highlightProvider, Program program);
+ public void removeHighlightProvider(ListingHighlightProvider highlightProvider, Program program);
}
diff --git a/Ghidra/Features/Base/src/main/java/ghidra/app/plugin/core/codebrowser/AbstractCodeBrowserPlugin.java b/Ghidra/Features/Base/src/main/java/ghidra/app/plugin/core/codebrowser/AbstractCodeBrowserPlugin.java
index 81fc0e79d1..5f2f1e6f86 100644
--- a/Ghidra/Features/Base/src/main/java/ghidra/app/plugin/core/codebrowser/AbstractCodeBrowserPlugin.java
+++ b/Ghidra/Features/Base/src/main/java/ghidra/app/plugin/core/codebrowser/AbstractCodeBrowserPlugin.java
@@ -38,7 +38,7 @@ import ghidra.app.events.ProgramSelectionPluginEvent;
import ghidra.app.nav.Navigatable;
import ghidra.app.plugin.core.codebrowser.hover.ListingHoverService;
import ghidra.app.services.*;
-import ghidra.app.util.HighlightProvider;
+import ghidra.app.util.ListingHighlightProvider;
import ghidra.app.util.ProgramDropProvider;
import ghidra.app.util.viewer.field.*;
import ghidra.app.util.viewer.format.*;
@@ -322,13 +322,13 @@ public abstract class AbstractCodeBrowserPlugin<P extends CodeViewerProvider> ex
}
@Override
- public void removeHighlightProvider(HighlightProvider highlightProvider,
+ public void removeHighlightProvider(ListingHighlightProvider highlightProvider,
Program highlightProgram) {
connectedProvider.removeHighlightProvider(highlightProvider, highlightProgram);
}
@Override
- public void setHighlightProvider(HighlightProvider highlightProvider,
+ public void setHighlightProvider(ListingHighlightProvider highlightProvider,
Program highlightProgram) {
connectedProvider.setHighlightProvider(highlightProvider, highlightProgram);
}
diff --git a/Ghidra/Features/Base/src/main/java/ghidra/app/plugin/core/codebrowser/CodeViewerProvider.java b/Ghidra/Features/Base/src/main/java/ghidra/app/plugin/core/codebrowser/CodeViewerProvider.java
index 7bd990cc9d..5f5bfd76d6 100644
--- a/Ghidra/Features/Base/src/main/java/ghidra/app/plugin/core/codebrowser/CodeViewerProvider.java
+++ b/Ghidra/Features/Base/src/main/java/ghidra/app/plugin/core/codebrowser/CodeViewerProvider.java
@@ -4,9 +4,9 @@
* 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.
@@ -44,7 +44,7 @@ import ghidra.app.plugin.core.codebrowser.actions.*;
import ghidra.app.plugin.core.codebrowser.hover.ListingHoverService;
import ghidra.app.services.*;
import ghidra.app.util.*;
-import ghidra.app.util.viewer.field.FieldFactory;
+import ghidra.app.util.viewer.field.ListingField;
import ghidra.app.util.viewer.format.*;
import ghidra.app.util.viewer.listingpanel.*;
import ghidra.app.util.viewer.multilisting.MultiListingLayoutModel;
@@ -79,7 +79,7 @@ public class CodeViewerProvider extends NavigatableComponentProviderAdapter
private static final String DIVIDER_LOCATION = "DividerLocation";
private ImageIcon navigatableIcon;
- private Map<Program, HighlightProvider> programHighlighterMap = new HashMap<>();
+ private Map<Program, ListingHighlightProvider> programHighlighterMap = new HashMap<>();
private ProgramHighlighterProvider highlighterAdapter;
private ListingPanel listingPanel;
@@ -144,7 +144,7 @@ public class CodeViewerProvider extends NavigatableComponentProviderAdapter
listingPanel = new ListingPanel(formatMgr);
listingPanel.enablePropertyBasedColorModel(true);
decorationPanel = new ListingPanelContainer(listingPanel, isConnected);
- ListingHighlightProvider listingHighlighter =
+ ListingMiddleMouseHighlightProvider listingHighlighter =
createListingHighlighter(listingPanel, tool, decorationPanel);
highlighterAdapter = new ProgramHighlighterProvider(listingHighlighter);
listingPanel.addHighlightProvider(highlighterAdapter);
@@ -194,10 +194,10 @@ public class CodeViewerProvider extends NavigatableComponentProviderAdapter
return false;
}
- private ListingHighlightProvider createListingHighlighter(ListingPanel panel,
+ private ListingMiddleMouseHighlightProvider createListingHighlighter(ListingPanel panel,
PluginTool pluginTool, Component repaintComponent) {
- ListingHighlightProvider listingHighlighter =
- new ListingHighlightProvider(pluginTool, repaintComponent);
+ ListingMiddleMouseHighlightProvider listingHighlighter =
+ new ListingMiddleMouseHighlightProvider(pluginTool, repaintComponent);
panel.addButtonPressedListener(listingHighlighter);
return listingHighlighter;
}
@@ -398,14 +398,14 @@ public class CodeViewerProvider extends NavigatableComponentProviderAdapter
}
@Override
- public void removeHighlightProvider(HighlightProvider highlightProvider,
+ public void removeHighlightProvider(ListingHighlightProvider highlightProvider,
Program highlightProgram) {
programHighlighterMap.remove(highlightProgram);
updateHighlightProvider();
}
@Override
- public void setHighlightProvider(HighlightProvider highlightProvider,
+ public void setHighlightProvider(ListingHighlightProvider highlightProvider,
Program highlightProgram) {
programHighlighterMap.put(highlightProgram, highlightProvider);
updateHighlightProvider();
@@ -1105,23 +1105,23 @@ public class CodeViewerProvider extends NavigatableComponentProviderAdapter
* A class that allows clients to install transient highlighters while keeping the middle-mouse
* highlighting on at the same time.
*/
- private class ProgramHighlighterProvider implements HighlightProvider {
+ private class ProgramHighlighterProvider implements ListingHighlightProvider {
- private final ListingHighlightProvider listingHighlighter;
+ private final ListingMiddleMouseHighlightProvider listingHighlighter;
- ProgramHighlighterProvider(ListingHighlightProvider listingHighlighter) {
+ ProgramHighlighterProvider(ListingMiddleMouseHighlightProvider listingHighlighter) {
this.listingHighlighter = listingHighlighter;
}
@Override
- public Highlight[] getHighlights(String text, Object obj,
- Class<? extends FieldFactory> fieldFactoryClass, int cursorTextOffset) {
+ public Highlight[] createHighlights(String text, ListingField field, int cursorTextOffset) {
List<Highlight> list = new ArrayList<>();
- HighlightProvider currentExternalHighligter = programHighlighterMap.get(program);
+ ListingHighlightProvider currentExternalHighligter =
+ programHighlighterMap.get(program);
if (currentExternalHighligter != null) {
- Highlight[] highlights = currentExternalHighligter.getHighlights(text, obj,
- fieldFactoryClass, cursorTextOffset);
+ Highlight[] highlights = currentExternalHighligter.createHighlights(text, field,
+ cursorTextOffset);
for (Highlight highlight : highlights) {
list.add(highlight);
}
@@ -1130,7 +1130,7 @@ public class CodeViewerProvider extends NavigatableComponentProviderAdapter
// always call the listing highlighter last so the middle-mouse highlight will always
// be on top of other highlights
Highlight[] highlights =
- listingHighlighter.getHighlights(text, obj, fieldFactoryClass, cursorTextOffset);
+ listingHighlighter.createHighlights(text, field, cursorTextOffset);
for (Highlight highlight : highlights) {
list.add(highlight);
}
diff --git a/Ghidra/Features/Base/src/main/java/ghidra/app/plugin/core/codebrowser/ListingHighlightProvider.java b/Ghidra/Features/Base/src/main/java/ghidra/app/plugin/core/codebrowser/ListingMiddleMouseHighlightProvider.java
similarity index 98%
rename from Ghidra/Features/Base/src/main/java/ghidra/app/plugin/core/codebrowser/ListingHighlightProvider.java
rename to Ghidra/Features/Base/src/main/java/ghidra/app/plugin/core/codebrowser/ListingMiddleMouseHighlightProvider.java
index 1519099b2d..0996849560 100644
--- a/Ghidra/Features/Base/src/main/java/ghidra/app/plugin/core/codebrowser/ListingHighlightProvider.java
+++ b/Ghidra/Features/Base/src/main/java/ghidra/app/plugin/core/codebrowser/ListingMiddleMouseHighlightProvider.java
@@ -34,8 +34,9 @@ import ghidra.GhidraOptions;
import ghidra.GhidraOptions.CURSOR_MOUSE_BUTTON_NAMES;
import ghidra.app.plugin.processors.generic.PcodeFieldFactory;
import ghidra.app.services.ButtonPressedListener;
-import ghidra.app.util.HighlightProvider;
+import ghidra.app.util.ListingHighlightProvider;
import ghidra.app.util.viewer.field.*;
+import ghidra.app.util.viewer.proxy.ProxyObj;
import ghidra.framework.options.OptionsChangeListener;
import ghidra.framework.options.ToolOptions;
import ghidra.framework.plugintool.PluginTool;
@@ -50,8 +51,8 @@ import ghidra.program.util.*;
import ghidra.util.*;
import ghidra.util.datastruct.Stack;
-public class ListingHighlightProvider
- implements ButtonPressedListener, OptionsChangeListener, HighlightProvider {
+public class ListingMiddleMouseHighlightProvider
+ implements ButtonPressedListener, OptionsChangeListener, ListingHighlightProvider {
//@formatter:off
private static final GColor DEFAULT_HIGHLIGHT_COLOR = new GColor("color.bg.listing.highlighter.default");
private static final GColor DEFAULT_SCOPED_READ_COLOR = new GColor("color.bg.listing.highlighter.scoped.read");
@@ -87,7 +88,7 @@ public class ListingHighlightProvider
private final Component repaintComponent;
private final PluginTool tool;
- public ListingHighlightProvider(PluginTool tool, Component repaintComponent) {
+ public ListingMiddleMouseHighlightProvider(PluginTool tool, Component repaintComponent) {
this.tool = tool;
this.repaintComponent = repaintComponent;
@@ -102,8 +103,11 @@ public class ListingHighlightProvider
}
@Override
- public Highlight[] getHighlights(String text, Object obj,
- Class<? extends FieldFactory> fieldFactoryClass, int cursorTextOffset) {
+ public Highlight[] createHighlights(String text, ListingField field, int cursorTextOffset) {
+
+ Class<? extends FieldFactory> fieldFactoryClass = field.getFieldFactory().getClass();
+ ProxyObj<?> proxy = field.getProxy();
+ Object obj = proxy.getObject();
if (scopeRegisterHighlight && scope != null) {
if (fieldFactoryClass == VariableNameFieldFactory.class ||
fieldFactoryClass == VariableLocFieldFactory.class) {
diff --git a/Ghidra/Features/Base/src/main/java/ghidra/app/plugin/core/function/StackDepthFieldFactory.java b/Ghidra/Features/Base/src/main/java/ghidra/app/plugin/core/function/StackDepthFieldFactory.java
index 0f1e8a5daa..689b62c3e9 100644
--- a/Ghidra/Features/Base/src/main/java/ghidra/app/plugin/core/function/StackDepthFieldFactory.java
+++ b/Ghidra/Features/Base/src/main/java/ghidra/app/plugin/core/function/StackDepthFieldFactory.java
@@ -22,7 +22,7 @@ import docking.widgets.fieldpanel.support.FieldLocation;
import generic.theme.GColor;
import generic.theme.GThemeDefaults.Colors;
import ghidra.app.cmd.function.CallDepthChangeInfo;
-import ghidra.app.util.HighlightProvider;
+import ghidra.app.util.ListingHighlightProvider;
import ghidra.app.util.viewer.field.*;
import ghidra.app.util.viewer.format.FieldFormatModel;
import ghidra.app.util.viewer.proxy.ProxyObj;
@@ -44,13 +44,13 @@ public class StackDepthFieldFactory extends FieldFactory {
super(FIELD_NAME);
}
- private StackDepthFieldFactory(FieldFormatModel model, HighlightProvider hsProvider,
+ private StackDepthFieldFactory(FieldFormatModel model, ListingHighlightProvider hsProvider,
Options displayOptions, Options fieldOptions) {
super(FIELD_NAME, model, hsProvider, displayOptions, fieldOptions);
}
@Override
- public FieldFactory newInstance(FieldFormatModel newModel, HighlightProvider highlightProvider,
+ public FieldFactory newInstance(FieldFormatModel newModel, ListingHighlightProvider highlightProvider,
ToolOptions toolDisplayOptions, ToolOptions fieldOptions) {
return new StackDepthFieldFactory(newModel, highlightProvider, toolDisplayOptions,
fieldOptions);
diff --git a/Ghidra/Features/Base/src/main/java/ghidra/app/plugin/core/gotoquery/GoToServicePlugin.java b/Ghidra/Features/Base/src/main/java/ghidra/app/plugin/core/gotoquery/GoToServicePlugin.java
index abe5715358..4ee5e7f21c 100644
--- a/Ghidra/Features/Base/src/main/java/ghidra/app/plugin/core/gotoquery/GoToServicePlugin.java
+++ b/Ghidra/Features/Base/src/main/java/ghidra/app/plugin/core/gotoquery/GoToServicePlugin.java
@@ -24,7 +24,7 @@ import ghidra.app.nav.*;
import ghidra.app.plugin.PluginCategoryNames;
import ghidra.app.plugin.ProgramPlugin;
import ghidra.app.services.*;
-import ghidra.app.util.HighlightProvider;
+import ghidra.app.util.ListingHighlightProvider;
import ghidra.app.util.PluginConstants;
import ghidra.app.util.navigation.GoToServiceImpl;
import ghidra.app.util.query.TableService;
@@ -225,7 +225,7 @@ public final class GoToServicePlugin extends ProgramPlugin {
}
@Override
- public void removeHighlightProvider(HighlightProvider highlightProvider, Program program) {
+ public void removeHighlightProvider(ListingHighlightProvider highlightProvider, Program program) {
CodeViewerService service = tool.getService(CodeViewerService.class);
if (service != null) {
service.removeHighlightProvider(highlightProvider, program);
@@ -233,7 +233,7 @@ public final class GoToServicePlugin extends ProgramPlugin {
}
@Override
- public void setHighlightProvider(HighlightProvider highlightProvider, Program program) {
+ public void setHighlightProvider(ListingHighlightProvider highlightProvider, Program program) {
CodeViewerService service = tool.getService(CodeViewerService.class);
if (service != null) {
service.setHighlightProvider(highlightProvider, program);
diff --git a/Ghidra/Features/Base/src/main/java/ghidra/app/plugin/core/navigation/locationreferences/LocationReferencesHighlighter.java b/Ghidra/Features/Base/src/main/java/ghidra/app/plugin/core/navigation/locationreferences/LocationReferencesHighlighter.java
index db1fd6dd2c..3bc0899214 100644
--- a/Ghidra/Features/Base/src/main/java/ghidra/app/plugin/core/navigation/locationreferences/LocationReferencesHighlighter.java
+++ b/Ghidra/Features/Base/src/main/java/ghidra/app/plugin/core/navigation/locationreferences/LocationReferencesHighlighter.java
@@ -22,8 +22,9 @@ import generic.theme.GColor;
import ghidra.GhidraOptions;
import ghidra.app.nav.Navigatable;
import ghidra.app.services.*;
-import ghidra.app.util.HighlightProvider;
-import ghidra.app.util.viewer.field.FieldFactory;
+import ghidra.app.util.ListingHighlightProvider;
+import ghidra.app.util.viewer.field.ListingField;
+import ghidra.app.util.viewer.proxy.ProxyObj;
import ghidra.framework.options.OptionsChangeListener;
import ghidra.framework.options.ToolOptions;
import ghidra.framework.plugintool.PluginTool;
@@ -51,7 +52,7 @@ class LocationReferencesHighlighter {
private LocationReferencesProvider provider;
private LocationReferencesPlugin locationReferencesPlugin;
- private HighlightProvider highlightProvider;
+ private ListingHighlightProvider highlightProvider;
private MarkerRemover markerRemover;
private Color highlightColor;
private OptionsChangeListener optionsListener = (options, name, oldValue, newValue) -> {
@@ -211,19 +212,20 @@ class LocationReferencesHighlighter {
// Inner Classes
//==================================================================================================
- private class LocationReferencesHighlightProvider implements HighlightProvider {
+ private class LocationReferencesHighlightProvider implements ListingHighlightProvider {
private final Highlight[] NO_HIGHLIGHTS = new Highlight[0];
- // for the Class parameter
@Override
- public Highlight[] getHighlights(String text, Object obj,
- Class<? extends FieldFactory> fieldFactoryClass, int cursorTextOffset) {
+ public Highlight[] createHighlights(String text, ListingField field, int cursorTextOffset) {
if (text == null) {
return NO_HIGHLIGHTS;
}
LocationDescriptor locationDescriptor = provider.getLocationDescriptor();
- return locationDescriptor.getHighlights(text, obj, fieldFactoryClass, highlightColor);
+ ProxyObj<?> proxy = field.getProxy();
+ Object obj = proxy.getObject();
+ return locationDescriptor.getHighlights(text, obj, field.getFieldFactory().getClass(),
+ highlightColor);
}
}
diff --git a/Ghidra/Features/Base/src/main/java/ghidra/app/plugin/core/searchmem/MemSearchPlugin.java b/Ghidra/Features/Base/src/main/java/ghidra/app/plugin/core/searchmem/MemSearchPlugin.java
index dbca8c83a7..d0bdb6ffc1 100644
--- a/Ghidra/Features/Base/src/main/java/ghidra/app/plugin/core/searchmem/MemSearchPlugin.java
+++ b/Ghidra/Features/Base/src/main/java/ghidra/app/plugin/core/searchmem/MemSearchPlugin.java
@@ -40,8 +40,8 @@ import ghidra.app.plugin.core.table.TableComponentProvider;
import ghidra.app.services.*;
import ghidra.app.util.*;
import ghidra.app.util.query.TableService;
-import ghidra.app.util.viewer.field.BytesFieldFactory;
-import ghidra.app.util.viewer.field.FieldFactory;
+import ghidra.app.util.viewer.field.*;
+import ghidra.app.util.viewer.proxy.ProxyObj;
import ghidra.framework.model.DomainObject;
import ghidra.framework.options.*;
import ghidra.framework.plugintool.*;
@@ -83,8 +83,6 @@ public class MemSearchPlugin extends Plugin implements OptionsChangeListener,
/** Constant for read/writeConfig() for dialog options */
private static final String SHOW_ADVANCED_OPTIONS = "Show Advanced Options";
- final static Highlight[] NO_HIGHLIGHTS = new Highlight[0];
-
private static final int MAX_PRE_POPULTATE_BYTE_COUNT = 20;
private DockingAction searchAction;
@@ -334,7 +332,6 @@ public class MemSearchPlugin extends Plugin implements OptionsChangeListener,
@Override
public void setSearchText(String maskedString) {
- //sets the search value to a bit string provided by the MnemonicSearchPlugin
searchDialog.setSearchText(maskedString);
}
@@ -613,7 +610,7 @@ public class MemSearchPlugin extends Plugin implements OptionsChangeListener,
}
private abstract class SearchResultsHighlighter
- implements HighlightProvider, ComponentProviderActivationListener {
+ implements ListingHighlightProvider, ComponentProviderActivationListener {
private TableComponentProvider<MemSearchResult> provider;
private Program highlightProgram;
@@ -688,16 +685,20 @@ public class MemSearchPlugin extends Plugin implements OptionsChangeListener,
}
@Override
- public Highlight[] getHighlights(String text, Object obj,
- Class<? extends FieldFactory> fieldFactoryClass, int cursorTextOffset) {
+ public Highlight[] createHighlights(String text, ListingField field, int cursorTextOffset) {
+
Program program = navigatable != null ? navigatable.getProgram() : null;
+ Class<? extends FieldFactory> fieldFactoryClass = field.getFieldFactory().getClass();
if (fieldFactoryClass != BytesFieldFactory.class) {
return NO_HIGHLIGHTS;
}
if (checkRemoveHighlights()) {
return NO_HIGHLIGHTS;
}
- if (!(obj instanceof CodeUnit)) {
+
+ ProxyObj<?> proxy = field.getProxy();
+ Object obj = proxy.getObject();
+ if (!(obj instanceof CodeUnit cu)) {
return NO_HIGHLIGHTS;
}
if (!doHighlight) {
@@ -708,7 +709,6 @@ public class MemSearchPlugin extends Plugin implements OptionsChangeListener,
return NO_HIGHLIGHTS;
}
- CodeUnit cu = (CodeUnit) obj;
Address minAddr = cu.getMinAddress();
Address maxAddr = cu.getMaxAddress();
List<MemSearchResult> results = getAddressesFoundInRange(minAddr, maxAddr);
diff --git a/Ghidra/Features/Base/src/main/java/ghidra/app/plugin/core/searchtext/AbstractSearchTableModel.java b/Ghidra/Features/Base/src/main/java/ghidra/app/plugin/core/searchtext/AbstractSearchTableModel.java
index 54725c99fd..b6908d23f2 100644
--- a/Ghidra/Features/Base/src/main/java/ghidra/app/plugin/core/searchtext/AbstractSearchTableModel.java
+++ b/Ghidra/Features/Base/src/main/java/ghidra/app/plugin/core/searchtext/AbstractSearchTableModel.java
@@ -16,6 +16,7 @@
package ghidra.app.plugin.core.searchtext;
import ghidra.GhidraOptions;
+import ghidra.app.plugin.core.searchtext.Searcher.TextSearchResult;
import ghidra.app.util.PluginConstants;
import ghidra.app.util.query.ProgramLocationPreviewTableModel;
import ghidra.framework.options.Options;
@@ -58,11 +59,11 @@ public abstract class AbstractSearchTableModel extends ProgramLocationPreviewTab
throws CancelledException {
Searcher searcher = getSearcher(tool, monitor);
monitor.checkCanceled();
- ProgramLocation loc = searcher.search();
- while (loc != null && accumulator.size() < searchLimit) {
- accumulator.add(loc);
+ TextSearchResult result = searcher.search();
+ while (result != null && accumulator.size() < searchLimit) {
+ accumulator.add(result.programLocation());
monitor.checkCanceled();
- loc = searcher.search();
+ result = searcher.search();
}
}
diff --git a/Ghidra/Features/Base/src/main/java/ghidra/app/plugin/core/searchtext/ListingDisplaySearcher.java b/Ghidra/Features/Base/src/main/java/ghidra/app/plugin/core/searchtext/ListingDisplaySearcher.java
index 77a05d2995..d452c2bbcc 100644
--- a/Ghidra/Features/Base/src/main/java/ghidra/app/plugin/core/searchtext/ListingDisplaySearcher.java
+++ b/Ghidra/Features/Base/src/main/java/ghidra/app/plugin/core/searchtext/ListingDisplaySearcher.java
@@ -63,8 +63,8 @@ class ListingDisplaySearcher implements Searcher {
private AddressSetView searchAddresses;
private TaskMonitor monitor;
- private List<ProgramLocation> locationList;
- private ListIterator<ProgramLocation> locationIterator;
+ private List<TextSearchResult> results;
+ private ListIterator<TextSearchResult> locationIterator;
private ProgramLocation startLocation;
private int startIndex;
@@ -103,8 +103,8 @@ class ListingDisplaySearcher implements Searcher {
searchPattern =
UserSearchUtils.createSearchPattern(options.getText(), options.isCaseSensitive());
- locationList = new ArrayList<>();
- locationIterator = locationList.listIterator();
+ results = new ArrayList<>();
+ locationIterator = results.listIterator();
CodeViewerService service = tool.getService(CodeViewerService.class);
listingModel = service.getListingModel();
@@ -175,34 +175,34 @@ class ListingDisplaySearcher implements Searcher {
return iterators.toArray(new AddressIterator[iterators.size()]);
}
- ProgramLocation next() {
- if (locationList.size() == 0) {
+ TextSearchResult next() {
+ if (results.size() == 0) {
findNext();
}
boolean isForward = options.isForward();
if (isForward && locationIterator.hasNext()) {
- ProgramLocation loc = locationIterator.next();
+ TextSearchResult result = locationIterator.next();
if (!locationIterator.hasNext()) {
- locationList.clear();
- locationIterator = locationList.listIterator();
+ results.clear();
+ locationIterator = results.listIterator();
}
- return loc;
+ return result;
}
if (!isForward && locationIterator.hasPrevious()) {
- ProgramLocation loc = locationIterator.previous();
+ TextSearchResult result = locationIterator.previous();
if (!locationIterator.hasPrevious()) {
- locationList.clear();
- locationIterator = locationList.listIterator();
+ results.clear();
+ locationIterator = results.listIterator();
}
- return loc;
+ return result;
}
return null;
}
boolean hasNext() {
- if (locationList.size() == 0) {
+ if (results.size() == 0) {
findNext();
}
return options.isForward() ? locationIterator.hasNext() : locationIterator.hasPrevious();
@@ -214,7 +214,7 @@ class ListingDisplaySearcher implements Searcher {
}
@Override
- public ProgramLocation search() {
+ public TextSearchResult search() {
try {
if (hasNext()) {
return next();
@@ -245,7 +245,7 @@ class ListingDisplaySearcher implements Searcher {
private void findNext() {
if (currentLayout != null) {
findNextMatch();
- if (locationList.size() > 0) {
+ if (results.size() > 0) {
return;
}
}
@@ -256,7 +256,7 @@ class ListingDisplaySearcher implements Searcher {
currentCodeUnit = null;
Listing listing = program.getListing();
while (!monitor.isCancelled() && currentLayout == null && addressIterator.hasNext() &&
- locationList.size() == 0) {
+ results.size() == 0) {
currentAddress = addressIterator.next();
monitor.setMessage("Checking address " + currentAddress);
@@ -287,14 +287,14 @@ class ListingDisplaySearcher implements Searcher {
}
if (options.isForward()) {
- while (!monitor.isCancelled() && locationList.size() == 0 &&
+ while (!monitor.isCancelled() && results.size() == 0 &&
currentLayout != null && currentFieldIndex < currentLayout.getNumFields()) {
findNextMatch();
}
}
else {
currentFieldIndex = currentLayout.getNumFields() - 1;
- while (!monitor.isCancelled() && locationList.size() == 0 &&
+ while (!monitor.isCancelled() && results.size() == 0 &&
currentLayout != null && currentFieldIndex >= 0) {
findNextMatch();
}
@@ -372,7 +372,7 @@ class ListingDisplaySearcher implements Searcher {
findLocations(field);
}
- if (locationList.size() > 0) {
+ if (results.size() > 0) {
// we found a match!
return fieldCount;
}
@@ -529,7 +529,9 @@ class ListingDisplaySearcher implements Searcher {
if (index == mnemonicLength) {
col++;
}
- locationList.add(fieldFactory.getProgramLocation(rc.row(), col, mnemonicField));
+
+ ProgramLocation loc = fieldFactory.getProgramLocation(rc.row(), col, mnemonicField);
+ results.add(new TextSearchResult(loc, index));
}
adjustIterator();
@@ -559,8 +561,8 @@ class ListingDisplaySearcher implements Searcher {
RowColLocation rc = field.textOffsetToScreenLocation(index);
FieldFactory fieldFactory = field.getFieldFactory();
ProgramLocation loc = fieldFactory.getProgramLocation(rc.row(), rc.col(), field);
- if ((loc != null) && !isSameLocation(loc)) { // loc will be null if field is clipped.
- locationList.add(loc);
+ if ((loc != null) && !isSameLocation(loc)) { // loc will be null if field is clipped.
+ results.add(new TextSearchResult(loc, index));
}
}
@@ -570,7 +572,7 @@ class ListingDisplaySearcher implements Searcher {
}
private void adjustIterator() {
- locationIterator = locationList.listIterator();
+ locationIterator = results.listIterator();
if (!options.isForward()) {
// position iterator to end so that previous() will work
while (locationIterator.hasNext()) {
diff --git a/Ghidra/Features/Base/src/main/java/ghidra/app/plugin/core/searchtext/SearchTask.java b/Ghidra/Features/Base/src/main/java/ghidra/app/plugin/core/searchtext/SearchTask.java
index af53a430ea..96d42ad907 100644
--- a/Ghidra/Features/Base/src/main/java/ghidra/app/plugin/core/searchtext/SearchTask.java
+++ b/Ghidra/Features/Base/src/main/java/ghidra/app/plugin/core/searchtext/SearchTask.java
@@ -16,9 +16,9 @@
package ghidra.app.plugin.core.searchtext;
import ghidra.app.nav.Navigatable;
+import ghidra.app.plugin.core.searchtext.Searcher.TextSearchResult;
import ghidra.framework.model.DomainObjectException;
import ghidra.program.model.listing.Program;
-import ghidra.program.util.ProgramLocation;
import ghidra.util.Msg;
import ghidra.util.task.Task;
import ghidra.util.task.TaskMonitor;
@@ -30,7 +30,7 @@ class SearchTask extends Task {
private Searcher textSearcher;
private Navigatable navigatable;
- private ProgramLocation loc;
+ private TextSearchResult result;
private boolean isCanceled;
private Program program;
@@ -59,7 +59,7 @@ class SearchTask extends Task {
monitor.setMessage("Searching...");
textSearcher.setMonitor(monitor);
try {
- loc = textSearcher.search();
+ result = textSearcher.search();
}
catch (Exception e) {
if (!(e instanceof DomainObjectException)) {
@@ -76,8 +76,8 @@ class SearchTask extends Task {
return navigatable;
}
- ProgramLocation getSearchLocation() {
- return loc;
+ TextSearchResult getSearchLocation() {
+ return result;
}
/**
diff --git a/Ghidra/Features/Base/src/main/java/ghidra/app/plugin/core/searchtext/SearchTextPlugin.java b/Ghidra/Features/Base/src/main/java/ghidra/app/plugin/core/searchtext/SearchTextPlugin.java
index 003ea99e99..4c8b54bd8b 100644
--- a/Ghidra/Features/Base/src/main/java/ghidra/app/plugin/core/searchtext/SearchTextPlugin.java
+++ b/Ghidra/Features/Base/src/main/java/ghidra/app/plugin/core/searchtext/SearchTextPlugin.java
@@ -15,8 +15,7 @@
*/
package ghidra.app.plugin.core.searchtext;
-import java.awt.Component;
-import java.awt.KeyboardFocusManager;
+import java.awt.*;
import java.util.ArrayList;
import java.util.List;
import java.util.regex.Matcher;
@@ -24,6 +23,8 @@ import java.util.regex.Pattern;
import javax.swing.Icon;
+import org.apache.commons.lang3.StringUtils;
+
import docking.*;
import docking.action.builder.ActionBuilder;
import docking.tool.ToolConstants;
@@ -37,13 +38,16 @@ import ghidra.app.nav.Navigatable;
import ghidra.app.nav.NavigatableRemovalListener;
import ghidra.app.plugin.PluginCategoryNames;
import ghidra.app.plugin.ProgramPlugin;
+import ghidra.app.plugin.core.searchtext.Searcher.TextSearchResult;
import ghidra.app.plugin.core.searchtext.databasesearcher.ProgramDatabaseSearchTableModel;
import ghidra.app.plugin.core.searchtext.databasesearcher.ProgramDatabaseSearcher;
import ghidra.app.plugin.core.table.TableComponentProvider;
-import ghidra.app.services.*;
+import ghidra.app.services.GoToService;
+import ghidra.app.services.ProgramManager;
import ghidra.app.util.*;
import ghidra.app.util.query.TableService;
import ghidra.app.util.viewer.field.*;
+import ghidra.app.util.viewer.proxy.ProxyObj;
import ghidra.framework.model.DomainObject;
import ghidra.framework.options.OptionsChangeListener;
import ghidra.framework.options.ToolOptions;
@@ -83,7 +87,7 @@ import ghidra.util.task.*;
"on the entire program. Multiple matches are displayed " +
"in a query results table. An option allows the search results " +
"to be highlighted in the Code Browser.",
- servicesRequired = { ProgramManager.class, GoToService.class, CodeViewerService.class /*, TableService.class */ }
+ servicesRequired = { ProgramManager.class, GoToService.class }
)
//@formatter:on
public class SearchTextPlugin extends ProgramPlugin implements OptionsChangeListener, TaskListener,
@@ -92,7 +96,6 @@ public class SearchTextPlugin extends ProgramPlugin implements OptionsChangeList
private static final Icon SEARCH_MARKER_ICON = new GIcon("icon.base.search.marker");
private static final String DESCRIPTION = "Search program text for string";
- private final static Highlight[] NO_HIGHLIGHTS = new Highlight[0];
private boolean waitingForSearchAll;
private SearchTextDialog searchDialog;
@@ -142,21 +145,23 @@ public class SearchTextPlugin extends ProgramPlugin implements OptionsChangeList
return;
}
- ProgramLocation loc = searchTask.getSearchLocation();
+ TextSearchResult result = searchTask.getSearchLocation();
Searcher textSearcher = searchTask.getTextSearcher();
SearchOptions searchOptions = textSearcher.getSearchOptions();
- if (loc != null && loc.equals(currentLocation)) {
+ if (result == null) {
+ searchDialog.setStatusText("Not found");
+ }
+ else if (result.programLocation().equals(currentLocation)) {
searchNext(searchTask.getProgram(), searchNavigatable, textSearcher);
}
- else if (loc != null) {
+ else {
searchDialog.setStatusText("");
+ ProgramLocation loc = result.programLocation();
if (goToService.goTo(searchNavigatable, loc, program)) {
- new HighlightHandler(searchNavigatable, searchOptions, null, program, loc);
+ new SearchTextHighlightProvider(searchNavigatable, searchOptions, null, program,
+ result);
}
}
- else {
- searchDialog.setStatusText("Not found");
- }
lastSearchedText = searchOptions.getText();
if (task == currentTask) {
@@ -324,7 +329,8 @@ public class SearchTextPlugin extends ProgramPlugin implements OptionsChangeList
searchAllTaskMonitor = tablePanel.getTaskMonitor();
tableProvider.setHelpLocation(new HelpLocation(HelpTopics.SEARCH, "SearchAllResults"));
- new HighlightHandler(searchNavigatable, searchOptions, tableProvider, searchProgram, null);
+ new SearchTextHighlightProvider(searchNavigatable, searchOptions, tableProvider,
+ searchProgram, null);
}
private TableComponentProvider<ProgramLocation> getTableResultsProvider(
@@ -593,20 +599,26 @@ public class SearchTextPlugin extends ProgramPlugin implements OptionsChangeList
}
}
- class HighlightHandler implements HighlightProvider, ComponentProviderActivationListener {
+ private class SearchTextHighlightProvider
+ implements ListingHighlightProvider, ComponentProviderActivationListener {
private SearchOptions searchOptions;
private TableComponentProvider<?> provider;
private Program highlightProgram;
private final Navigatable highlightNavigatable;
- private ProgramLocation loc;
+ private boolean showAllResults;
- HighlightHandler(Navigatable navigatable, SearchOptions searchOptions,
- TableComponentProvider<?> provider, Program program, ProgramLocation loc) {
+ // this is non-null for a single search
+ private TextSearchResult searchResult;
+
+ SearchTextHighlightProvider(Navigatable navigatable, SearchOptions searchOptions,
+ TableComponentProvider<?> provider, Program program,
+ TextSearchResult searchResult) {
highlightNavigatable = navigatable;
this.searchOptions = searchOptions;
this.provider = provider;
this.highlightProgram = program;
- this.loc = loc;
+ this.searchResult = searchResult;
+ this.showAllResults = searchResult == null;
if (provider != null) {
provider.addActivationListener(this);
@@ -615,8 +627,10 @@ public class SearchTextPlugin extends ProgramPlugin implements OptionsChangeList
}
@Override
- public Highlight[] getHighlights(String text, Object obj,
- Class<? extends FieldFactory> fieldFactoryClass, int cursorTextOffset) {
+ public Highlight[] createHighlights(String text, ListingField field, int cursorTextOffset) {
+
+ Class<? extends FieldFactory> fieldFactoryClass = field.getFieldFactory().getClass();
+
if (!doHighlight) {
return NO_HIGHLIGHTS;
}
@@ -625,7 +639,7 @@ public class SearchTextPlugin extends ProgramPlugin implements OptionsChangeList
return NO_HIGHLIGHTS;
}
- if (!shouldHighlight(fieldFactoryClass, obj)) {
+ if (!shouldHighlight(field)) {
return NO_HIGHLIGHTS;
}
@@ -634,50 +648,93 @@ public class SearchTextPlugin extends ProgramPlugin implements OptionsChangeList
return NO_HIGHLIGHTS;
}
- return getHighlights(text, cursorTextOffset);
+ if (showAllResults) {
+ return getAllHighlights(text, cursorTextOffset);
+ }
+
+ Address address = searchResult.programLocation().getAddress();
+ ProxyObj<?> proxy = field.getProxy();
+ if (proxy.contains(address)) {
+ return getSingleSearchHighlight(text, field, cursorTextOffset);
+ }
+
+ return NO_HIGHLIGHTS;
}
- private Highlight[] getHighlights(String text, int cursorTextOffset) {
+ private Highlight[] getAllHighlights(String text, int cursorTextOffset) {
- String matchStr = searchOptions.getText().trim();
- if (matchStr == null || text == null) {
+ String searchText = searchOptions.getText();
+ if (StringUtils.isBlank(searchText) || StringUtils.isBlank(text)) {
return NO_HIGHLIGHTS;
}
List<Highlight> list = new ArrayList<>();
Pattern regexp =
- UserSearchUtils.createSearchPattern(matchStr, searchOptions.isCaseSensitive());
+ UserSearchUtils.createSearchPattern(searchText, searchOptions.isCaseSensitive());
Matcher matcher = regexp.matcher(text);
while (matcher.find()) {
int start = matcher.start();
int end = matcher.end() - 1;
+ Color hlColor = PluginConstants.SEARCH_HIGHLIGHT_COLOR;
if (start <= cursorTextOffset && end >= cursorTextOffset) {
- list.add(new Highlight(start, end,
- PluginConstants.SEARCH_HIGHLIGHT_CURRENT_ADDR_COLOR));
- }
- else if (loc == null) { // only add in matches around current match if loc is null
- // meaning that this is a one at a time search and not a table
- // of results.
- list.add(new Highlight(start, end,
- PluginConstants.SEARCH_HIGHLIGHT_CURRENT_ADDR_COLOR));
+ // change the highlight color when in the field so it stands out
+ hlColor = PluginConstants.SEARCH_HIGHLIGHT_CURRENT_ADDR_COLOR;
}
+ list.add(new Highlight(start, end, hlColor));
+ }
+
+ if (list.isEmpty()) {
+ return NO_HIGHLIGHTS;
+ }
+ return list.toArray(Highlight[]::new);
+ }
+
+ private Highlight[] getSingleSearchHighlight(String text, ListingField field,
+ int cursorTextOffset) {
+
+ String searchText = searchOptions.getText();
+ if (StringUtils.isBlank(searchText) || StringUtils.isBlank(text)) {
+ return NO_HIGHLIGHTS;
}
- if (list.size() == 0) {
+ FieldFactory fieldFactory = field.getFieldFactory();
+ ProgramLocation loc = searchResult.programLocation();
+ if (!fieldFactory.supportsLocation(field, loc)) {
return NO_HIGHLIGHTS;
}
- Highlight[] h = new Highlight[list.size()];
- return list.toArray(h);
+
+ int charOffset = searchResult.offset();
+ int searchStart = charOffset;
+ int searchEnd = searchStart + searchText.length();
+
+ Pattern regexp =
+ UserSearchUtils.createSearchPattern(searchText, searchOptions.isCaseSensitive());
+ Matcher matcher = regexp.matcher(text);
+ while (matcher.find()) {
+ int start = matcher.start();
+ int end = matcher.end();
+
+ // ensure the particular regex match is the actual search result
+ if (start == searchStart && end == searchEnd) {
+
+ Color hlColor = PluginConstants.SEARCH_HIGHLIGHT_COLOR;
+ if (start <= cursorTextOffset && end >= cursorTextOffset) {
+ // change the highlight color when in the field so it stands out
+ hlColor = PluginConstants.SEARCH_HIGHLIGHT_CURRENT_ADDR_COLOR;
+ }
+
+ // this is the matching search hit for a single search
+ int endEx = end - 1;
+ return new Highlight[] { new Highlight(start, endEx, hlColor) };
+ }
+ }
+ return NO_HIGHLIGHTS;
}
- /**
- * Return whether the field for the given factory class should be highlighted; compare
- * against the search options
- *
- * @param factoryClass field factory class
- * @param obj object associated with the field, e.g. CodeUnit
- */
- private boolean shouldHighlight(Class<?> factoryClass, Object obj) {
+ private boolean shouldHighlight(ListingField field) {
+
+ ProxyObj<?> proxy = field.getProxy();
+ Object obj = proxy.getObject();
Program navigatableProgram = navigatable == null ? null : navigatable.getProgram();
if (navigatableProgram != highlightProgram) {
return false;
@@ -686,6 +743,8 @@ public class SearchTextPlugin extends ProgramPlugin implements OptionsChangeList
if (searchOptions.searchAllFields()) {
return true;
}
+
+ Class<? extends FieldFactory> factoryClass = field.getFieldFactory().getClass();
if (searchOptions.searchComments()) {
if (factoryClass == PreCommentFieldFactory.class ||
factoryClass == PlateFieldFactory.class ||
diff --git a/Ghidra/Features/Base/src/main/java/ghidra/app/plugin/core/searchtext/Searcher.java b/Ghidra/Features/Base/src/main/java/ghidra/app/plugin/core/searchtext/Searcher.java
index 98e54e038f..bf88f4bbc8 100644
--- a/Ghidra/Features/Base/src/main/java/ghidra/app/plugin/core/searchtext/Searcher.java
+++ b/Ghidra/Features/Base/src/main/java/ghidra/app/plugin/core/searchtext/Searcher.java
@@ -27,7 +27,7 @@ public interface Searcher {
* Get the next program location.
* @return null if there is no next program location.
*/
- public ProgramLocation search();
+ public TextSearchResult search();
/**
* Set the task monitor.
@@ -40,4 +40,15 @@ public interface Searcher {
* @return the search option
*/
public SearchOptions getSearchOptions();
+
+ /**
+ * A record object that represents a single search result
+ *
+ * @param programLocation the program location of the search result.
+ * @param offset the offset in the *model*'s text of the search result; this value will be from
+ * 0 to text.length(), where text is a single string for all text in the given field.
+ */
+ public record TextSearchResult(ProgramLocation programLocation, int offset) {
+ // stub
+ }
}
diff --git a/Ghidra/Features/Base/src/main/java/ghidra/app/plugin/core/searchtext/databasesearcher/CommentFieldSearcher.java b/Ghidra/Features/Base/src/main/java/ghidra/app/plugin/core/searchtext/databasesearcher/CommentFieldSearcher.java
index 92f0db7140..4bd0d5312c 100644
--- a/Ghidra/Features/Base/src/main/java/ghidra/app/plugin/core/searchtext/databasesearcher/CommentFieldSearcher.java
+++ b/Ghidra/Features/Base/src/main/java/ghidra/app/plugin/core/searchtext/databasesearcher/CommentFieldSearcher.java
@@ -19,6 +19,7 @@ import java.util.List;
import java.util.regex.Matcher;
import java.util.regex.Pattern;
+import ghidra.app.plugin.core.searchtext.Searcher.TextSearchResult;
import ghidra.program.model.address.*;
import ghidra.program.model.listing.*;
import ghidra.program.util.*;
@@ -52,7 +53,7 @@ public class CommentFieldSearcher extends ProgramDatabaseFieldSearcher {
}
@Override
- protected Address advance(List<ProgramLocation> currentMatches) {
+ protected Address advance(List<TextSearchResult> currentMatches) {
Address nextAddress = iterator.next();
if (nextAddress != null) {
findMatchesForCurrentAddress(nextAddress, currentMatches);
@@ -61,7 +62,7 @@ public class CommentFieldSearcher extends ProgramDatabaseFieldSearcher {
}
private void findMatchesForCurrentAddress(Address address,
- List<ProgramLocation> currentMatches) {
+ List<TextSearchResult> currentMatches) {
String comment = program.getListing().getComment(commentType, address);
if (comment == null) {
return;
@@ -70,14 +71,15 @@ public class CommentFieldSearcher extends ProgramDatabaseFieldSearcher {
Matcher matcher = pattern.matcher(cleanedUpComment);
while (matcher.find()) {
int index = matcher.start();
- currentMatches.add(getCommentLocation(comment, index, address));
+ currentMatches
+ .add(new TextSearchResult(getCommentLocation(comment, index, address), index));
}
}
private ProgramLocation getCommentLocation(String commentStr, int index, Address address) {
String[] comments = StringUtilities.toLines(commentStr);
int rowIndex = findRowIndex(comments, index);
- int charOffset = findCharOffset(index, rowIndex, comments);
+ int charOffset = getRelativeCharOffset(index, rowIndex, comments);
int[] dataPath = getDataComponentPath(address);
switch (commentType) {
case CodeUnit.EOL_COMMENT:
@@ -114,12 +116,12 @@ public class CommentFieldSearcher extends ProgramDatabaseFieldSearcher {
return null;
}
- private int findCharOffset(int index, int rowIndex, String[] opStrings) {
- int totalBeforeOpIndex = 0;
+ private int getRelativeCharOffset(int index, int rowIndex, String[] comments) {
+ int preceding = 0;
for (int i = 0; i < rowIndex; i++) {
- totalBeforeOpIndex += opStrings[i].length();
+ preceding += comments[i].length();
}
- return index - totalBeforeOpIndex;
+ return index - preceding;
}
private int findRowIndex(String[] commentStrings, int index) {
diff --git a/Ghidra/Features/Base/src/main/java/ghidra/app/plugin/core/searchtext/databasesearcher/DataMnemonicOperandFieldSearcher.java b/Ghidra/Features/Base/src/main/java/ghidra/app/plugin/core/searchtext/databasesearcher/DataMnemonicOperandFieldSearcher.java
index cf1b66b5ad..e78342b979 100644
--- a/Ghidra/Features/Base/src/main/java/ghidra/app/plugin/core/searchtext/databasesearcher/DataMnemonicOperandFieldSearcher.java
+++ b/Ghidra/Features/Base/src/main/java/ghidra/app/plugin/core/searchtext/databasesearcher/DataMnemonicOperandFieldSearcher.java
@@ -15,15 +15,16 @@
*/
package ghidra.app.plugin.core.searchtext.databasesearcher;
+import java.util.List;
+import java.util.regex.Matcher;
+import java.util.regex.Pattern;
+
+import ghidra.app.plugin.core.searchtext.Searcher.TextSearchResult;
import ghidra.program.model.address.Address;
import ghidra.program.model.address.AddressSetView;
import ghidra.program.model.listing.*;
import ghidra.program.util.*;
-import java.util.List;
-import java.util.regex.Matcher;
-import java.util.regex.Pattern;
-
public class DataMnemonicOperandFieldSearcher extends ProgramDatabaseFieldSearcher {
private DataIterator iterator;
private CodeUnitFormat format;
@@ -75,7 +76,7 @@ public class DataMnemonicOperandFieldSearcher extends ProgramDatabaseFieldSearch
}
@Override
- protected Address advance(List<ProgramLocation> currentMatches) {
+ protected Address advance(List<TextSearchResult> currentMatches) {
Data data = iterator.next();
Address nextAddress = null;
if (data != null) {
@@ -85,7 +86,7 @@ public class DataMnemonicOperandFieldSearcher extends ProgramDatabaseFieldSearch
return nextAddress;
}
- private void findMatchesForCurrentAddress(Data data, List<ProgramLocation> currentMatches) {
+ private void findMatchesForCurrentAddress(Data data, List<TextSearchResult> currentMatches) {
StringBuffer searchStrBuf = new StringBuffer();
String mnemonicString = "";
String operandString = "";
@@ -122,16 +123,17 @@ public class DataMnemonicOperandFieldSearcher extends ProgramDatabaseFieldSearch
}
}
- private void addOperandMatch(Data data, List<ProgramLocation> currentMatches,
+ private void addOperandMatch(Data data, List<TextSearchResult> currentMatches,
String mnemonicString, String operandString, Address address, int index) {
if (!doOperands) {
return;
}
- currentMatches.add(new OperandFieldLocation(program, address, data.getComponentPath(),
- null, operandString, 0, index - mnemonicString.length() - 1));
+ currentMatches.add(
+ new TextSearchResult(new OperandFieldLocation(program, address, data.getComponentPath(),
+ null, operandString, 0, index - mnemonicString.length() - 1), index));
}
- private void addMnemonicMatch(List<ProgramLocation> currentMatches, String mnemonicString,
+ private void addMnemonicMatch(List<TextSearchResult> currentMatches, String mnemonicString,
Address address, int index, int endIndex) {
if (!doMnemonics) {
return;
@@ -140,7 +142,7 @@ public class DataMnemonicOperandFieldSearcher extends ProgramDatabaseFieldSearch
if (endIndex > mnemonicString.length()) {
return;
}
- currentMatches.add(new MnemonicFieldLocation(program, address, null, null, mnemonicString,
- index));
+ currentMatches.add(new TextSearchResult(
+ new MnemonicFieldLocation(program, address, null, null, mnemonicString, index), index));
}
}
diff --git a/Ghidra/Features/Base/src/main/java/ghidra/app/plugin/core/searchtext/databasesearcher/FunctionFieldSearcher.java b/Ghidra/Features/Base/src/main/java/ghidra/app/plugin/core/searchtext/databasesearcher/FunctionFieldSearcher.java
index b3ca811b6d..3052526bb7 100644
--- a/Ghidra/Features/Base/src/main/java/ghidra/app/plugin/core/searchtext/databasesearcher/FunctionFieldSearcher.java
+++ b/Ghidra/Features/Base/src/main/java/ghidra/app/plugin/core/searchtext/databasesearcher/FunctionFieldSearcher.java
@@ -20,6 +20,7 @@ import java.util.regex.Matcher;
import java.util.regex.Pattern;
import ghidra.app.plugin.core.navigation.FunctionUtils;
+import ghidra.app.plugin.core.searchtext.Searcher.TextSearchResult;
import ghidra.program.model.address.Address;
import ghidra.program.model.address.AddressSetView;
import ghidra.program.model.data.DataType;
@@ -46,7 +47,7 @@ public class FunctionFieldSearcher extends ProgramDatabaseFieldSearcher {
}
@Override
- protected Address advance(List<ProgramLocation> currentMatches) {
+ protected Address advance(List<TextSearchResult> currentMatches) {
if (iterator.hasNext()) {
Function function = iterator.next();
Address nextAddress = null;
@@ -62,34 +63,34 @@ public class FunctionFieldSearcher extends ProgramDatabaseFieldSearcher {
}
private void findMatchesForCurrentFunction(Function function,
- List<ProgramLocation> currentMatches) {
+ List<TextSearchResult> currentMatches) {
findCommentMatches(function, currentMatches);
findSignatureMatches(function, currentMatches);
findVariableMatches(function, currentMatches);
}
- private void findVariableMatches(Function function, List<ProgramLocation> currentMatches) {
+ private void findVariableMatches(Function function, List<TextSearchResult> currentMatches) {
Parameter[] parameters = function.getParameters();
- for (int i = 0; i < parameters.length; i++) {
- checkTypeString(parameters[i], currentMatches);
- checkName(parameters[i], currentMatches);
- checkStorage(parameters[i], currentMatches);
- checkComment(parameters[i], currentMatches);
+ for (Parameter parameter : parameters) {
+ checkTypeString(parameter, currentMatches);
+ checkName(parameter, currentMatches);
+ checkStorage(parameter, currentMatches);
+ checkComment(parameter, currentMatches);
}
Variable[] localVariables = function.getLocalVariables();
- for (int i = 0; i < localVariables.length; i++) {
- checkTypeString(localVariables[i], currentMatches);
- checkName(localVariables[i], currentMatches);
- checkStorage(localVariables[i], currentMatches);
- checkComment(localVariables[i], currentMatches);
+ for (Variable localVariable : localVariables) {
+ checkTypeString(localVariable, currentMatches);
+ checkName(localVariable, currentMatches);
+ checkStorage(localVariable, currentMatches);
+ checkComment(localVariable, currentMatches);
}
}
- private void checkTypeString(Variable variable, List<ProgramLocation> currentMatches) {
+ private void checkTypeString(Variable variable, List<TextSearchResult> currentMatches) {
DataType dt;
if (variable instanceof Parameter) {
- dt = ((Parameter)variable).getFormalDataType();
+ dt = ((Parameter) variable).getFormalDataType();
}
else {
dt = variable.getDataType();
@@ -102,29 +103,32 @@ public class FunctionFieldSearcher extends ProgramDatabaseFieldSearcher {
Matcher matcher = pattern.matcher(searchString);
while (matcher.find()) {
int index = matcher.start();
- currentMatches.add(new VariableTypeFieldLocation(program, variable, index));
+ currentMatches.add(new TextSearchResult(
+ new VariableTypeFieldLocation(program, variable, index), index));
}
}
- private void checkName(Variable variable, List<ProgramLocation> currentMatches) {
+ private void checkName(Variable variable, List<TextSearchResult> currentMatches) {
String searchString = variable.getName();
Matcher matcher = pattern.matcher(searchString);
while (matcher.find()) {
int index = matcher.start();
- currentMatches.add(new VariableNameFieldLocation(program, variable, index));
+ currentMatches.add(new TextSearchResult(
+ new VariableNameFieldLocation(program, variable, index), index));
}
}
- private void checkStorage(Variable var, List<ProgramLocation> currentMatches) {
+ private void checkStorage(Variable var, List<TextSearchResult> currentMatches) {
String searchString = var.getVariableStorage().toString();
Matcher matcher = pattern.matcher(searchString);
while (matcher.find()) {
int index = matcher.start();
- currentMatches.add(new VariableLocFieldLocation(program, var, index));
+ currentMatches.add(
+ new TextSearchResult(new VariableLocFieldLocation(program, var, index), index));
}
}
- private void checkComment(Variable variable, List<ProgramLocation> currentMatches) {
+ private void checkComment(Variable variable, List<TextSearchResult> currentMatches) {
String searchString = variable.getComment();
if (searchString == null) {
return;
@@ -132,23 +136,27 @@ public class FunctionFieldSearcher extends ProgramDatabaseFieldSearcher {
Matcher matcher = pattern.matcher(searchString);
while (matcher.find()) {
int index = matcher.start();
- currentMatches.add(new VariableCommentFieldLocation(program, variable, index));
+ currentMatches.add(
+ new TextSearchResult(new VariableCommentFieldLocation(program, variable, index),
+ index));
}
}
- private void findSignatureMatches(Function function, List<ProgramLocation> currentMatches) {
+ private void findSignatureMatches(Function function, List<TextSearchResult> currentMatches) {
String signature = function.getPrototypeString(false, false);
Matcher matcher = pattern.matcher(signature);
Address address = function.getEntryPoint();
int callingConventionOffset = FunctionUtils.getCallingConventionSignatureOffset(function);
while (matcher.find()) {
int index = matcher.start();
- currentMatches.add(new FunctionSignatureFieldLocation(program, address, null, index +
- callingConventionOffset, signature));
+ currentMatches.add(new TextSearchResult(
+ new FunctionSignatureFieldLocation(program, address, null, index +
+ callingConventionOffset, signature),
+ index));
}
}
- private void findCommentMatches(Function function, List<ProgramLocation> currentMatches) {
+ private void findCommentMatches(Function function, List<TextSearchResult> currentMatches) {
String functionComment = function.getRepeatableComment();
if (functionComment == null) {
@@ -159,7 +167,8 @@ public class FunctionFieldSearcher extends ProgramDatabaseFieldSearcher {
Address address = function.getEntryPoint();
while (matcher.find()) {
int index = matcher.start();
- currentMatches.add(getFunctionCommentLocation(functionComment, index, address));
+ currentMatches.add(new TextSearchResult(
+ getFunctionCommentLocation(functionComment, index, address), index));
}
}
diff --git a/Ghidra/Features/Base/src/main/java/ghidra/app/plugin/core/searchtext/databasesearcher/InstructionMnemonicOperandFieldSearcher.java b/Ghidra/Features/Base/src/main/java/ghidra/app/plugin/core/searchtext/databasesearcher/InstructionMnemonicOperandFieldSearcher.java
index 99a2ea80a9..16a4e1a454 100644
--- a/Ghidra/Features/Base/src/main/java/ghidra/app/plugin/core/searchtext/databasesearcher/InstructionMnemonicOperandFieldSearcher.java
+++ b/Ghidra/Features/Base/src/main/java/ghidra/app/plugin/core/searchtext/databasesearcher/InstructionMnemonicOperandFieldSearcher.java
@@ -19,6 +19,7 @@ import java.util.List;
import java.util.regex.Matcher;
import java.util.regex.Pattern;
+import ghidra.app.plugin.core.searchtext.Searcher.TextSearchResult;
import ghidra.program.model.address.Address;
import ghidra.program.model.address.AddressSetView;
import ghidra.program.model.listing.*;
@@ -74,7 +75,7 @@ public class InstructionMnemonicOperandFieldSearcher extends ProgramDatabaseFiel
}
@Override
- protected Address advance(List<ProgramLocation> currentMatches) {
+ protected Address advance(List<TextSearchResult> currentMatches) {
Instruction instruction = iterator.hasNext() ? iterator.next() : null;
Address nextAddress = null;
if (instruction != null) {
@@ -85,7 +86,7 @@ public class InstructionMnemonicOperandFieldSearcher extends ProgramDatabaseFiel
}
private void findMatchesForCurrentAddress(Instruction instruction,
- List<ProgramLocation> currentMatches) {
+ List<TextSearchResult> currentMatches) {
String mnemonicString = instruction.getMnemonicString();
String[] opStrings = getOperandStrings(instruction);
Matcher matcher = pattern.matcher(combineStrings(mnemonicString, opStrings));
@@ -103,18 +104,18 @@ public class InstructionMnemonicOperandFieldSearcher extends ProgramDatabaseFiel
}
}
- private void addOperandMatch(Instruction instruction, List<ProgramLocation> currentMatches,
+ private void addOperandMatch(Instruction instruction, List<TextSearchResult> currentMatches,
String[] opStrings, Address address, int index) {
if (!doOperands) {
return;
}
int opIndex = findOpIndex(opStrings, index);
int charOffset = findCharOffset(index, opIndex, opStrings);
- currentMatches.add(new OperandFieldLocation(program, address, null,
- instruction.getAddress(opIndex), opStrings[opIndex], opIndex, charOffset));
+ currentMatches.add(new TextSearchResult(new OperandFieldLocation(program, address, null,
+ instruction.getAddress(opIndex), opStrings[opIndex], opIndex, charOffset), index));
}
- private void addMnemonicMatch(List<ProgramLocation> currentMatches, Address address,
+ private void addMnemonicMatch(List<TextSearchResult> currentMatches, Address address,
String mnemonicString, int startIndex, int endIndex) {
if (!doMnemonics) {
return;
@@ -124,7 +125,9 @@ public class InstructionMnemonicOperandFieldSearcher extends ProgramDatabaseFiel
return;
}
- currentMatches.add(new MnemonicFieldLocation(program, address, null, null, mnemonicString,
+ currentMatches.add(new TextSearchResult(
+ new MnemonicFieldLocation(program, address, null, null, mnemonicString,
+ startIndex),
startIndex));
}
diff --git a/Ghidra/Features/Base/src/main/java/ghidra/app/plugin/core/searchtext/databasesearcher/LabelFieldSearcher.java b/Ghidra/Features/Base/src/main/java/ghidra/app/plugin/core/searchtext/databasesearcher/LabelFieldSearcher.java
index 08791f5f1d..05d71eb14f 100644
--- a/Ghidra/Features/Base/src/main/java/ghidra/app/plugin/core/searchtext/databasesearcher/LabelFieldSearcher.java
+++ b/Ghidra/Features/Base/src/main/java/ghidra/app/plugin/core/searchtext/databasesearcher/LabelFieldSearcher.java
@@ -20,6 +20,7 @@ import java.util.List;
import java.util.regex.Matcher;
import java.util.regex.Pattern;
+import ghidra.app.plugin.core.searchtext.Searcher.TextSearchResult;
import ghidra.program.model.address.*;
import ghidra.program.model.listing.Program;
import ghidra.program.model.symbol.*;
@@ -29,13 +30,11 @@ import ghidra.program.util.ProgramLocation;
public class LabelFieldSearcher extends ProgramDatabaseFieldSearcher {
private AddressIterator iterator;
private SymbolTable symbolTable;
- private Program program;
public LabelFieldSearcher(Program program, ProgramLocation startLoc, AddressSetView set,
boolean forward, Pattern pattern) {
super(pattern, forward, startLoc, set);
- this.program = program;
this.symbolTable = program.getSymbolTable();
SymbolIterator symbolIterator;
@@ -48,15 +47,15 @@ public class LabelFieldSearcher extends ProgramDatabaseFieldSearcher {
else {
symbolIterator =
program.getSymbolTable().getPrimarySymbolIterator(startLoc.getAddress(), forward);
- refIterator = program.getReferenceManager().getReferenceDestinationIterator(
- startLoc.getAddress(), forward);
+ refIterator = program.getReferenceManager()
+ .getReferenceDestinationIterator(
+ startLoc.getAddress(), forward);
}
iterator = new SymbolAddressIterator(symbolIterator, refIterator, forward);
-
}
@Override
- protected Address advance(List<ProgramLocation> currentMatches) {
+ protected Address advance(List<TextSearchResult> currentMatches) {
Address nextAddress = iterator.next();
if (nextAddress == null) {
return null;
@@ -66,14 +65,15 @@ public class LabelFieldSearcher extends ProgramDatabaseFieldSearcher {
}
private void findMatchesForCurrentAddress(Address address,
- List<ProgramLocation> currentMatches) {
+ List<TextSearchResult> currentMatches) {
Symbol[] symbols = symbolTable.getSymbols(address);
makePrimaryLastItem(symbols);
for (Symbol symbol : symbols) {
Matcher matcher = pattern.matcher(symbol.getName());
while (matcher.find()) {
int charOffset = matcher.start();
- currentMatches.add(new LabelFieldLocation(symbol, 0, charOffset));
+ currentMatches.add(new TextSearchResult(
+ new LabelFieldLocation(symbol, 0, charOffset), charOffset));
}
}
}
@@ -110,9 +110,6 @@ public class LabelFieldSearcher extends ProgramDatabaseFieldSearcher {
nextRefAddress = getNextRefAddress();
}
- /**
- * @see java.util.Iterator#remove()
- */
@Override
public void remove() {
throw new UnsupportedOperationException();
diff --git a/Ghidra/Features/Base/src/main/java/ghidra/app/plugin/core/searchtext/databasesearcher/ProgramDatabaseFieldSearcher.java b/Ghidra/Features/Base/src/main/java/ghidra/app/plugin/core/searchtext/databasesearcher/ProgramDatabaseFieldSearcher.java
index afd0052961..9b3f05247b 100644
--- a/Ghidra/Features/Base/src/main/java/ghidra/app/plugin/core/searchtext/databasesearcher/ProgramDatabaseFieldSearcher.java
+++ b/Ghidra/Features/Base/src/main/java/ghidra/app/plugin/core/searchtext/databasesearcher/ProgramDatabaseFieldSearcher.java
@@ -15,49 +15,54 @@
*/
package ghidra.app.plugin.core.searchtext.databasesearcher;
+import java.util.*;
+import java.util.regex.Pattern;
+
+import ghidra.app.plugin.core.searchtext.Searcher.TextSearchResult;
import ghidra.program.model.address.Address;
import ghidra.program.model.address.AddressSetView;
import ghidra.program.util.ProgramLocation;
-import java.util.*;
-import java.util.regex.Pattern;
-
public abstract class ProgramDatabaseFieldSearcher {
protected final Pattern pattern;
protected final boolean forward;
private Address currentAddress;
private ProgramLocation startLocation;
- private List<ProgramLocation> matchesForCurrentAddress = new LinkedList<ProgramLocation>();
+ private List<TextSearchResult> matchesForCurrentAddress = new LinkedList<>();
- protected ProgramDatabaseFieldSearcher(Pattern pattern, boolean forward, ProgramLocation startLoc, AddressSetView set) {
+ protected ProgramDatabaseFieldSearcher(Pattern pattern, boolean forward,
+ ProgramLocation startLoc, AddressSetView set) {
this.pattern = pattern;
this.forward = forward;
this.startLocation = startLoc;
-
- if (forward && set != null && !set.isEmpty() && startLoc != null &&
- !set.getMinAddress().equals(startLoc.getAddress())) {
+
+ if (forward && set != null && !set.isEmpty() && startLoc != null &&
+ !set.getMinAddress().equals(startLoc.getAddress())) {
throw new IllegalArgumentException("Start location and addressSet are inconsistent!");
}
- if (!forward && set != null && !set.isEmpty() && startLoc != null &&
- !set.getMaxAddress().equals(startLoc.getAddress())) {
+ if (!forward && set != null && !set.isEmpty() && startLoc != null &&
+ !set.getMaxAddress().equals(startLoc.getAddress())) {
throw new IllegalArgumentException("Start location and addressSet are inconsistent!");
}
}
+
private void initialize() {
currentAddress = doAdvance(matchesForCurrentAddress);
- trimMatchesForStartLocation( );
+ trimMatchesForStartLocation();
}
- private Address doAdvance(List<ProgramLocation> currentMatches) {
+
+ private Address doAdvance(List<TextSearchResult> currentMatches) {
Address address = advance(matchesForCurrentAddress);
- if (!forward) {
- Collections.reverse( matchesForCurrentAddress );
- }
- return address;
+ if (!forward) {
+ Collections.reverse(matchesForCurrentAddress);
+ }
+ return address;
}
- protected abstract Address advance(List<ProgramLocation> currentMatches);
-
- public Address getNextSignificantAddress( Address address ) {
+
+ protected abstract Address advance(List<TextSearchResult> currentMatches);
+
+ public Address getNextSignificantAddress(Address address) {
if (address == null) {
initialize();
return currentAddress;
@@ -65,37 +70,37 @@ public abstract class ProgramDatabaseFieldSearcher {
if (currentAddress == null) { // we have no more records in our iterator.
return null;
}
- if (currentAddress.equals( address )) { // we need to move to the next record
+ if (currentAddress.equals(address)) { // we need to move to the next record
currentAddress = doAdvance(matchesForCurrentAddress);
}
return currentAddress;
}
- public ProgramLocation getMatch() {
- return matchesForCurrentAddress.remove( 0 );
+ public TextSearchResult getMatch() {
+ return matchesForCurrentAddress.remove(0);
}
-
- public boolean hasMatch( Address address ) {
+
+ public boolean hasMatch(Address address) {
if (!address.equals(currentAddress)) {
return false;
}
return !matchesForCurrentAddress.isEmpty();
- }
+ }
- private void trimMatchesForStartLocation( ) {
+ private void trimMatchesForStartLocation() {
if (startLocation == null) {
return;
}
- if (!startLocation.getAddress().equals( currentAddress )) {
+ if (!startLocation.getAddress().equals(currentAddress)) {
return;
}
- Iterator<ProgramLocation> it = matchesForCurrentAddress.iterator();
- while(it.hasNext()) {
- ProgramLocation programLoc = it.next();
- int compareVal = startLocation.compareTo( programLoc );
- if ((forward && compareVal >=0) ||
- (!forward && compareVal <=0 )) {
- it.remove();
+ Iterator<TextSearchResult> it = matchesForCurrentAddress.iterator();
+ while (it.hasNext()) {
+ ProgramLocation programLoc = it.next().programLocation();
+ int compareVal = startLocation.compareTo(programLoc);
+ if ((forward && compareVal >= 0) ||
+ (!forward && compareVal <= 0)) {
+ it.remove();
}
}
}
diff --git a/Ghidra/Features/Base/src/main/java/ghidra/app/plugin/core/searchtext/databasesearcher/ProgramDatabaseSearcher.java b/Ghidra/Features/Base/src/main/java/ghidra/app/plugin/core/searchtext/databasesearcher/ProgramDatabaseSearcher.java
index 2c4511599b..934290d80c 100644
--- a/Ghidra/Features/Base/src/main/java/ghidra/app/plugin/core/searchtext/databasesearcher/ProgramDatabaseSearcher.java
+++ b/Ghidra/Features/Base/src/main/java/ghidra/app/plugin/core/searchtext/databasesearcher/ProgramDatabaseSearcher.java
@@ -82,7 +82,7 @@ public class ProgramDatabaseSearcher implements Searcher {
}
@Override
- public ProgramLocation search() {
+ public TextSearchResult search() {
List<ProgramDatabaseFieldSearcher> orderedSearchers = searchers;
if (!searchOptions.isForward()) {
orderedSearchers = new ArrayList<>(searchers);
@@ -210,8 +210,9 @@ public class ProgramDatabaseSearcher implements Searcher {
}
if (options.searchBothInstructionMnemonicAndOperands()) {
searchers.add(
- InstructionMnemonicOperandFieldSearcher.createInstructionMnemonicAndOperandFieldSearcher(
- program, adjustedStart, trimmedSet, forward, pattern, format));
+ InstructionMnemonicOperandFieldSearcher
+ .createInstructionMnemonicAndOperandFieldSearcher(
+ program, adjustedStart, trimmedSet, forward, pattern, format));
}
if (options.searchOnlyInstructionMnemonics()) {
searchers.add(
diff --git a/Ghidra/Features/Base/src/main/java/ghidra/app/plugin/processors/generic/PcodeFieldFactory.java b/Ghidra/Features/Base/src/main/java/ghidra/app/plugin/processors/generic/PcodeFieldFactory.java
index 14069949e0..bc2996c9bd 100644
--- a/Ghidra/Features/Base/src/main/java/ghidra/app/plugin/processors/generic/PcodeFieldFactory.java
+++ b/Ghidra/Features/Base/src/main/java/ghidra/app/plugin/processors/generic/PcodeFieldFactory.java
@@ -21,7 +21,7 @@ import java.util.*;
import docking.widgets.fieldpanel.field.*;
import docking.widgets.fieldpanel.support.FieldLocation;
import ghidra.GhidraOptions;
-import ghidra.app.util.HighlightProvider;
+import ghidra.app.util.ListingHighlightProvider;
import ghidra.app.util.pcode.AttributedStringPcodeFormatter;
import ghidra.app.util.viewer.field.*;
import ghidra.app.util.viewer.format.FieldFormatModel;
@@ -55,7 +55,7 @@ public class PcodeFieldFactory extends FieldFactory {
}
public PcodeFieldFactory(String name, FieldFormatModel model,
- HighlightProvider highlightProvider, Options displayOptions, Options fieldOptions) {
+ ListingHighlightProvider highlightProvider, Options displayOptions, Options fieldOptions) {
super(name, model, highlightProvider, displayOptions, fieldOptions);
setWidth(300);
@@ -67,7 +67,7 @@ public class PcodeFieldFactory extends FieldFactory {
}
@Override
- public FieldFactory newInstance(FieldFormatModel myModel, HighlightProvider highlightProvider,
+ public FieldFactory newInstance(FieldFormatModel myModel, ListingHighlightProvider highlightProvider,
ToolOptions options, ToolOptions fieldOptions) {
return new PcodeFieldFactory(FIELD_NAME, myModel, highlightProvider, options, fieldOptions);
}
diff --git a/Ghidra/Features/Base/src/main/java/ghidra/app/services/CodeViewerService.java b/Ghidra/Features/Base/src/main/java/ghidra/app/services/CodeViewerService.java
index afca51f92f..ea5235609c 100644
--- a/Ghidra/Features/Base/src/main/java/ghidra/app/services/CodeViewerService.java
+++ b/Ghidra/Features/Base/src/main/java/ghidra/app/services/CodeViewerService.java
@@ -22,7 +22,7 @@ import docking.widgets.fieldpanel.FieldPanel;
import docking.widgets.fieldpanel.field.Field;
import ghidra.app.nav.Navigatable;
import ghidra.app.plugin.core.codebrowser.CodeBrowserPlugin;
-import ghidra.app.util.HighlightProvider;
+import ghidra.app.util.ListingHighlightProvider;
import ghidra.app.util.ProgramDropProvider;
import ghidra.app.util.viewer.format.FormatManager;
import ghidra.app.util.viewer.listingpanel.*;
@@ -105,14 +105,14 @@ public interface CodeViewerService {
* @param provider The provider to set.
* @param program The program with which to associate the given provider.
*/
- public void setHighlightProvider(HighlightProvider provider, Program program);
+ public void setHighlightProvider(ListingHighlightProvider provider, Program program);
/**
* Remove the highlight provider.
* @param provider the provider to remove.
* @param program the program associated with the given provider.
*/
- public void removeHighlightProvider(HighlightProvider provider, Program program);
+ public void removeHighlightProvider(ListingHighlightProvider provider, Program program);
/**
* Set a listing panel on the code viewer.
diff --git a/Ghidra/Features/Base/src/main/java/ghidra/app/util/HighlightProvider.java b/Ghidra/Features/Base/src/main/java/ghidra/app/util/ListingHighlightProvider.java
similarity index 53%
rename from Ghidra/Features/Base/src/main/java/ghidra/app/util/HighlightProvider.java
rename to Ghidra/Features/Base/src/main/java/ghidra/app/util/ListingHighlightProvider.java
index 2e09064e31..b73145db40 100644
--- a/Ghidra/Features/Base/src/main/java/ghidra/app/util/HighlightProvider.java
+++ b/Ghidra/Features/Base/src/main/java/ghidra/app/util/ListingHighlightProvider.java
@@ -1,6 +1,5 @@
/* ###
* IP: GHIDRA
- * REVIEWED: YES
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
@@ -16,28 +15,27 @@
*/
package ghidra.app.util;
-import ghidra.app.util.viewer.field.FieldFactory;
import docking.widgets.fieldpanel.support.Highlight;
+import ghidra.app.util.viewer.field.ListingField;
+import ghidra.program.model.listing.CodeUnit;
/**
- * Provider of Highlight objects appropriate for the text, object, and FieldFactory class.
- *
+ * Provider of Highlight objects appropriate {@link ListingField}s.
*/
-public interface HighlightProvider {
+public interface ListingHighlightProvider {
- public static final Highlight[] EMPTY_HIGHLIGHT = new Highlight[0];
+ public static final Highlight[] NO_HIGHLIGHTS = new Highlight[0];
/**
- * Get the highlights appropriate for the given text, object, and FieldFactory class.
+ * Get the highlights appropriate for the given text
+ *
* @param text the entire text contained in the field, regardless of layout.
- * @param obj object that provides the information to be rendered (usually a code unit)
- * @param fieldFactoryClass the class that indicates what type of field is being rendered.
- * For Example, address fields would have the AddressFieldFactory class.
- * @param cursorTextOffset the cursor position within the given text or -1 if no cursor in this field.
+ * @param field the field being rendered. From this field you can get the field factory and
+ * the proxy object, which is usually a {@link CodeUnit}.
+ * @param cursorTextOffset the cursor position within the given text or -1 if no cursor in this
+ * field.
* @return an array of highlight objects that indicate the location within the text string to
- * be highlighted.
+ * be highlighted.
*/
- public Highlight[] getHighlights(String text, Object obj,
- Class<? extends FieldFactory> fieldFactoryClass, int cursorTextOffset);
-
+ public Highlight[] createHighlights(String text, ListingField field, int cursorTextOffset);
}
diff --git a/Ghidra/Features/Base/src/main/java/ghidra/app/util/viewer/field/AbstractVariableFieldFactory.java b/Ghidra/Features/Base/src/main/java/ghidra/app/util/viewer/field/AbstractVariableFieldFactory.java
index d50a0b08b0..761ffc325f 100644
--- a/Ghidra/Features/Base/src/main/java/ghidra/app/util/viewer/field/AbstractVariableFieldFactory.java
+++ b/Ghidra/Features/Base/src/main/java/ghidra/app/util/viewer/field/AbstractVariableFieldFactory.java
@@ -17,7 +17,7 @@ package ghidra.app.util.viewer.field;
import java.awt.*;
-import ghidra.app.util.HighlightProvider;
+import ghidra.app.util.ListingHighlightProvider;
import ghidra.app.util.viewer.field.ListingColors.FunctionColors;
import ghidra.app.util.viewer.format.FieldFormatModel;
import ghidra.app.util.viewer.options.OptionsGui;
@@ -65,7 +65,7 @@ public abstract class AbstractVariableFieldFactory extends FieldFactory {
* @param fieldOptions the Options for field specific properties.
*/
protected AbstractVariableFieldFactory(String name, FieldFormatModel model,
- HighlightProvider highlightProvider, Options displayOptions, Options fieldOptions) {
+ ListingHighlightProvider highlightProvider, Options displayOptions, Options fieldOptions) {
super(name, model, highlightProvider, displayOptions, fieldOptions);
}
diff --git a/Ghidra/Features/Base/src/main/java/ghidra/app/util/viewer/field/AddressFieldFactory.java b/Ghidra/Features/Base/src/main/java/ghidra/app/util/viewer/field/AddressFieldFactory.java
index db806c8b03..89b1d31480 100644
--- a/Ghidra/Features/Base/src/main/java/ghidra/app/util/viewer/field/AddressFieldFactory.java
+++ b/Ghidra/Features/Base/src/main/java/ghidra/app/util/viewer/field/AddressFieldFactory.java
@@ -20,7 +20,7 @@ import java.math.BigInteger;
import docking.widgets.fieldpanel.field.*;
import docking.widgets.fieldpanel.support.FieldLocation;
-import ghidra.app.util.HighlightProvider;
+import ghidra.app.util.ListingHighlightProvider;
import ghidra.app.util.viewer.format.FieldFormatModel;
import ghidra.app.util.viewer.proxy.ProxyObj;
import ghidra.framework.options.*;
@@ -63,7 +63,7 @@ public class AddressFieldFactory extends FieldFactory {
* @param displayOptions the Options for display properties.
* @param fieldOptions the Options for field specific properties.
*/
- private AddressFieldFactory(FieldFormatModel model, HighlightProvider hlProvider,
+ private AddressFieldFactory(FieldFormatModel model, ListingHighlightProvider hlProvider,
Options displayOptions, Options fieldOptions) {
super(FIELD_NAME, model, hlProvider, displayOptions, fieldOptions);
initOptions(fieldOptions);
@@ -198,7 +198,7 @@ public class AddressFieldFactory extends FieldFactory {
@Override
public FieldFactory newInstance(FieldFormatModel newModel,
- HighlightProvider highlightStringProvider, ToolOptions toolOptions,
+ ListingHighlightProvider highlightStringProvider, ToolOptions toolOptions,
ToolOptions fieldOptions) {
return new AddressFieldFactory(newModel, highlightStringProvider, toolOptions,
fieldOptions);
diff --git a/Ghidra/Features/Base/src/main/java/ghidra/app/util/viewer/field/ArrayValuesFieldFactory.java b/Ghidra/Features/Base/src/main/java/ghidra/app/util/viewer/field/ArrayValuesFieldFactory.java
index a03438a55a..3f83282ad9 100644
--- a/Ghidra/Features/Base/src/main/java/ghidra/app/util/viewer/field/ArrayValuesFieldFactory.java
+++ b/Ghidra/Features/Base/src/main/java/ghidra/app/util/viewer/field/ArrayValuesFieldFactory.java
@@ -21,7 +21,7 @@ import java.math.BigInteger;
import docking.widgets.fieldpanel.field.*;
import docking.widgets.fieldpanel.support.FieldLocation;
import docking.widgets.fieldpanel.support.RowColLocation;
-import ghidra.app.util.HighlightProvider;
+import ghidra.app.util.ListingHighlightProvider;
import ghidra.app.util.viewer.format.FieldFormatModel;
import ghidra.app.util.viewer.format.FormatManager;
import ghidra.app.util.viewer.proxy.ProxyObj;
@@ -43,7 +43,7 @@ public class ArrayValuesFieldFactory extends FieldFactory {
@Override
public FieldFactory newInstance(FieldFormatModel formatModel,
- HighlightProvider highlightProvider, ToolOptions toolOptions,
+ ListingHighlightProvider highlightProvider, ToolOptions toolOptions,
ToolOptions fieldOptions) {
return new ArrayValuesFieldFactory(formatModel, highlightProvider, toolOptions,
fieldOptions);
@@ -56,7 +56,7 @@ public class ArrayValuesFieldFactory extends FieldFactory {
* @param displayOptions the Options for display properties.
* @param fieldOptions the Options for field specific properties.
*/
- private ArrayValuesFieldFactory(FieldFormatModel model, HighlightProvider hlProvider,
+ private ArrayValuesFieldFactory(FieldFormatModel model, ListingHighlightProvider hlProvider,
Options displayOptions, Options fieldOptions) {
super(FIELD_NAME, model, hlProvider, displayOptions, fieldOptions);
setupOptions(fieldOptions);
diff --git a/Ghidra/Features/Base/src/main/java/ghidra/app/util/viewer/field/AssignedVariableFieldFactory.java b/Ghidra/Features/Base/src/main/java/ghidra/app/util/viewer/field/AssignedVariableFieldFactory.java
index 4dd04dce1b..41e30d1c11 100644
--- a/Ghidra/Features/Base/src/main/java/ghidra/app/util/viewer/field/AssignedVariableFieldFactory.java
+++ b/Ghidra/Features/Base/src/main/java/ghidra/app/util/viewer/field/AssignedVariableFieldFactory.java
@@ -20,7 +20,7 @@ import java.util.ArrayList;
import docking.widgets.fieldpanel.field.*;
import docking.widgets.fieldpanel.support.FieldLocation;
-import ghidra.app.util.HighlightProvider;
+import ghidra.app.util.ListingHighlightProvider;
import ghidra.app.util.viewer.field.ListingColors.FunctionColors;
import ghidra.app.util.viewer.format.FieldFormatModel;
import ghidra.app.util.viewer.proxy.ProxyObj;
@@ -50,7 +50,7 @@ public class AssignedVariableFieldFactory extends FieldFactory {
* @param displayOptions the Options for display properties.
* @param fieldOptions the Options for field specific properties.
*/
- private AssignedVariableFieldFactory(FieldFormatModel model, HighlightProvider hsProvider,
+ private AssignedVariableFieldFactory(FieldFormatModel model, ListingHighlightProvider hsProvider,
Options displayOptions, Options fieldOptions) {
super(FIELD_NAME, model, hsProvider, displayOptions, fieldOptions);
}
@@ -134,7 +134,7 @@ public class AssignedVariableFieldFactory extends FieldFactory {
}
@Override
- public FieldFactory newInstance(FieldFormatModel formatModel, HighlightProvider hsProvider,
+ public FieldFactory newInstance(FieldFormatModel formatModel, ListingHighlightProvider hsProvider,
ToolOptions displayOptions, ToolOptions fieldOptions) {
return new AssignedVariableFieldFactory(formatModel, hsProvider, displayOptions,
fieldOptions);
diff --git a/Ghidra/Features/Base/src/main/java/ghidra/app/util/viewer/field/BytesFieldFactory.java b/Ghidra/Features/Base/src/main/java/ghidra/app/util/viewer/field/BytesFieldFactory.java
index c2146192b3..77873dfa1d 100644
--- a/Ghidra/Features/Base/src/main/java/ghidra/app/util/viewer/field/BytesFieldFactory.java
+++ b/Ghidra/Features/Base/src/main/java/ghidra/app/util/viewer/field/BytesFieldFactory.java
@@ -27,7 +27,7 @@ import java.math.BigInteger;
import docking.widgets.fieldpanel.field.*;
import docking.widgets.fieldpanel.support.FieldLocation;
import docking.widgets.fieldpanel.support.RowColLocation;
-import ghidra.app.util.HighlightProvider;
+import ghidra.app.util.ListingHighlightProvider;
import ghidra.app.util.viewer.format.FieldFormatModel;
import ghidra.app.util.viewer.proxy.ProxyObj;
import ghidra.framework.options.Options;
@@ -35,10 +35,12 @@ import ghidra.framework.options.ToolOptions;
import ghidra.program.model.data.DataType;
import ghidra.program.model.data.Structure;
import ghidra.program.model.listing.*;
+import ghidra.program.model.mem.Memory;
import ghidra.program.model.mem.MemoryAccessException;
import ghidra.program.util.BytesFieldLocation;
import ghidra.program.util.ProgramLocation;
import ghidra.util.HelpLocation;
+import ghidra.util.Msg;
/**
* Generates Bytes Fields.
@@ -81,7 +83,7 @@ public class BytesFieldFactory extends FieldFactory {
* @param displayOptions the Options for display properties.
* @param fieldOptions the Options for field specific properties.
*/
- private BytesFieldFactory(FieldFormatModel model, HighlightProvider hlProvider,
+ private BytesFieldFactory(FieldFormatModel model, ListingHighlightProvider hlProvider,
Options displayOptions, Options fieldOptions) {
super(FIELD_NAME, model, hlProvider, displayOptions, fieldOptions);
@@ -171,22 +173,23 @@ public class BytesFieldFactory extends FieldFactory {
if (!enabled || !(obj instanceof CodeUnit)) {
return null;
}
- CodeUnit cu = (CodeUnit) obj;
+ CodeUnit cu = (CodeUnit) obj;
int length = Math.min(cu.getLength(), 100);
byte[] bytes = new byte[length];
+ Memory memory = cu.getProgram().getMemory();
try {
- length = cu.getProgram().getMemory().getBytes(cu.getAddress(), bytes);
+ length = memory.getBytes(cu.getAddress(), bytes);
}
catch (MemoryAccessException e) {
return null;
}
+
if (length == 0) {
return null;
}
- if ((cu instanceof Instruction) && reverseInstByteOrdering &&
- !cu.getProgram().getMemory().isBigEndian()) {
+ if ((cu instanceof Instruction) && reverseInstByteOrdering && !memory.isBigEndian()) {
int i = 0;
int j = length - 1;
while (j > i) {
@@ -196,26 +199,24 @@ public class BytesFieldFactory extends FieldFactory {
}
}
- int fieldElementLength = length / byteGroupSize;
+ int groupLength = length / byteGroupSize;
int residual = length % byteGroupSize;
if (residual != 0) {
- fieldElementLength++;
+ groupLength++;
}
- boolean wasTruncated = length != cu.getLength();
+ boolean wasTruncated = length != cu.getLength();
byte[] alignmentBytes = getAlignmentBytes(cu, wasTruncated);
- int extraLen = getLengthForAlignmentBytes(alignmentBytes, residual);
-
- FieldElement[] aStrings = new FieldElement[fieldElementLength + extraLen];
-
- buildAttributedByteValues(aStrings, 0, bytes, length, 0, ListingColors.BYTES,
- extraLen != 0);
- if (extraLen != 0) {
- buildAttributedByteValues(aStrings, fieldElementLength, alignmentBytes,
+ int extraLength = getLengthForAlignmentBytes(alignmentBytes, residual);
+ FieldElement[] elements = new FieldElement[groupLength + extraLength];
+ boolean addDelimiter = extraLength != 0;
+ buildAttributedByteValues(elements, 0, bytes, length, 0, ListingColors.BYTES, addDelimiter);
+ if (addDelimiter) {
+ buildAttributedByteValues(elements, groupLength, alignmentBytes,
alignmentBytes.length, residual, ListingColors.BYTES_ALIGNMENT, false);
}
- return ListingTextField.createPackedTextField(this, proxy, aStrings, startX + varWidth,
+ return ListingTextField.createPackedTextField(this, proxy, elements, startX + varWidth,
width, maxDisplayLines, hlProvider);
}
@@ -242,9 +243,9 @@ public class BytesFieldFactory extends FieldFactory {
return null;
}
- private int buildAttributedByteValues(FieldElement[] aStrings, int pos, byte[] bytes, int size,
- int residual, Color c, boolean addDelimToLastGroup) {
- StringBuffer buffer = new StringBuffer();
+ private int buildAttributedByteValues(FieldElement[] elements, int pos, byte[] bytes, int size,
+ int residual, Color color, boolean addDelimiter) {
+ StringBuilder buffer = new StringBuilder();
int groupSize = byteGroupSize - residual;
int tempGroupSize = 0;
for (int i = 0; i < size; ++i) {
@@ -263,19 +264,20 @@ public class BytesFieldFactory extends FieldFactory {
if (tempGroupSize == groupSize) {
tempGroupSize = 0;
groupSize = byteGroupSize;
- if (i < size - 1 || addDelimToLastGroup) {
+ if (i < size - 1 || addDelimiter) {
buffer.append(delim);
}
- AttributedString as = new AttributedString(buffer.toString(), c, getMetrics());
- aStrings[pos] = new TextFieldElement(as, pos, 0);
+ AttributedString as = new AttributedString(buffer.toString(), color, getMetrics());
+ elements[pos] = new TextFieldElement(as, pos, 0);
pos++;
- buffer = new StringBuffer();
+ buffer = new StringBuilder();
}
}
+
// append incomplete byte group...
if (tempGroupSize > 0) {
- AttributedString as = new AttributedString(buffer.toString(), c, getMetrics());
- aStrings[pos] = new TextFieldElement(as, pos, 0);
+ AttributedString as = new AttributedString(buffer.toString(), color, getMetrics());
+ elements[pos] = new TextFieldElement(as, pos, 0);
}
return tempGroupSize;
}
@@ -310,8 +312,8 @@ public class BytesFieldFactory extends FieldFactory {
if (alignSize <= 0) {
return null;
}
- int alignmentOffset = data.getParentOffset() + data.getLength();
+ int alignmentOffset = data.getParentOffset() + data.getLength();
byte[] bytes = new byte[alignSize];
parent.getBytes(bytes, alignmentOffset);
return bytes;
@@ -319,13 +321,15 @@ public class BytesFieldFactory extends FieldFactory {
@Override
public ProgramLocation getProgramLocation(int row, int col, ListingField bf) {
+
+ Msg.debug(this, "Bytes - getProgLoc() - row / col: " + row + " / " + col);
+
Object obj = bf.getProxy().getObject();
if (!(obj instanceof CodeUnit) || row < 0 || col < 0) {
return null;
}
CodeUnit cu = (CodeUnit) obj;
-
int[] cpath = null;
if (cu instanceof Data) {
cpath = ((Data) cu).getComponentPath();
@@ -354,16 +358,15 @@ public class BytesFieldFactory extends FieldFactory {
int byteIndex = tokenIndex * byteGroupSize + getByteIndexInToken(tokenCharPos);
int charOffset = computeCharOffset(tokenCharPos);
-
return new BytesFieldLocation(cu.getProgram(), cu.getMinAddress(),
cu.getMinAddress().add(byteIndex), cpath, charOffset);
}
/**
- * Computes how many bytes the the given column position represents. Normally
- * this is just the column position / 2 (since each byte consists of two chars). There
- * is a special case when the col position is just past the last char of the token. In
- * this case, we want to return the number of bytes in a token - 1;
+ * Computes how many bytes the the given column position represents. Normally this is just the
+ * column position / 2 (since each byte consists of two chars). There is a special case when
+ * the col position is just past the last char of the token. In this case, we want to return
+ * the number of bytes in a token - 1;
*/
private int getByteIndexInToken(int col) {
if (col >= byteGroupSize * CHARS_IN_BYTE) {
@@ -374,11 +377,10 @@ public class BytesFieldFactory extends FieldFactory {
/**
* Computes the character offset for a BytesFieldLocation based on the character column the
- * cursor is at in the token. BytesFieldLocation character offsets are always as if the group size is 1.
- * So for all positions except the last byte, it is just the column modulo 2. For the last byte, we have
- * to account for any columns past the last char. In this case, we have to subtract off
- * 2 for every byte before the last byte.
- *
+ * cursor is at in the token. BytesFieldLocation character offsets are always as if the group
+ * size is 1. So for all positions except the last byte, it is just the column modulo 2. For
+ * the last byte, we have to account for any columns past the last char. In this case, we have
+ * to subtract off 2 for every byte before the last byte.
*/
private int computeCharOffset(int col) {
if (col >= byteGroupSize * CHARS_IN_BYTE) {
@@ -390,17 +392,16 @@ public class BytesFieldFactory extends FieldFactory {
@Override
public FieldLocation getFieldLocation(ListingField bf, BigInteger index, int fieldNum,
ProgramLocation loc) {
+
if (!(loc instanceof BytesFieldLocation)) {
return null;
}
-
Object obj = bf.getProxy().getObject();
if (!(obj instanceof CodeUnit)) {
return null;
}
CodeUnit cu = (CodeUnit) obj;
-
BytesFieldLocation bytesLoc = (BytesFieldLocation) loc;
int byteIndex = bytesLoc.getByteIndex();
int columnInByte = bytesLoc.getColumnInByte();
@@ -442,7 +443,8 @@ public class BytesFieldFactory extends FieldFactory {
}
@Override
- public FieldFactory newInstance(FieldFormatModel formatModel, HighlightProvider provider,
+ public FieldFactory newInstance(FieldFormatModel formatModel,
+ ListingHighlightProvider provider,
ToolOptions displayOptions, ToolOptions fieldOptions) {
return new BytesFieldFactory(formatModel, provider, displayOptions, fieldOptions);
}
diff --git a/Ghidra/Features/Base/src/main/java/ghidra/app/util/viewer/field/DummyFieldFactory.java b/Ghidra/Features/Base/src/main/java/ghidra/app/util/viewer/field/DummyFieldFactory.java
index 3ff530313d..ad79d8bf9a 100644
--- a/Ghidra/Features/Base/src/main/java/ghidra/app/util/viewer/field/DummyFieldFactory.java
+++ b/Ghidra/Features/Base/src/main/java/ghidra/app/util/viewer/field/DummyFieldFactory.java
@@ -19,7 +19,7 @@ import java.math.BigInteger;
import docking.widgets.fieldpanel.field.*;
import docking.widgets.fieldpanel.support.FieldLocation;
-import ghidra.app.util.HighlightProvider;
+import ghidra.app.util.ListingHighlightProvider;
import ghidra.app.util.viewer.format.FieldFormatModel;
import ghidra.app.util.viewer.format.FormatManager;
import ghidra.app.util.viewer.proxy.ProxyObj;
@@ -79,7 +79,7 @@ public class DummyFieldFactory extends FieldFactory {
}
@Override
- public FieldFactory newInstance(FieldFormatModel formatModel, HighlightProvider hlProvdier,
+ public FieldFactory newInstance(FieldFormatModel formatModel, ListingHighlightProvider hlProvdier,
ToolOptions options, ToolOptions fieldOptions) {
return this;
}
diff --git a/Ghidra/Features/Base/src/main/java/ghidra/app/util/viewer/field/EolCommentFieldFactory.java b/Ghidra/Features/Base/src/main/java/ghidra/app/util/viewer/field/EolCommentFieldFactory.java
index f9c68055dd..5e754da173 100644
--- a/Ghidra/Features/Base/src/main/java/ghidra/app/util/viewer/field/EolCommentFieldFactory.java
+++ b/Ghidra/Features/Base/src/main/java/ghidra/app/util/viewer/field/EolCommentFieldFactory.java
@@ -98,7 +98,7 @@ public class EolCommentFieldFactory extends FieldFactory {
* @param displayOptions the Options for display properties.
* @param fieldOptions the Options for field specific properties.
*/
- private EolCommentFieldFactory(FieldFormatModel model, HighlightProvider hlProvider,
+ private EolCommentFieldFactory(FieldFormatModel model, ListingHighlightProvider hlProvider,
ToolOptions displayOptions, ToolOptions fieldOptions) {
super(FIELD_NAME, model, hlProvider, displayOptions, fieldOptions);
HelpLocation hl = new HelpLocation("CodeBrowserPlugin", "EOL_Comments_Field");
@@ -522,13 +522,13 @@ public class EolCommentFieldFactory extends FieldFactory {
if (!(obj instanceof CodeUnit)) {
return null;
}
+
DisplayableEol displayableEol =
new DisplayableEol((CodeUnit) obj, alwaysShowRepeatable, alwaysShowRefRepeatables,
alwaysShowAutomatic, codeUnitFormatOptions.followReferencedPointers(),
maxDisplayLines, useAbbreviatedAutomatic, showAutomaticFunctions);
ListingTextField btf = (ListingTextField) bf;
-
RowColLocation eolRowCol = displayableEol.getRowCol((CommentFieldLocation) loc);
RowColLocation rcl = btf.dataToScreenLocation(eolRowCol.row(), eolRowCol.col());
if (!hasSamePath(bf, loc)) {
@@ -548,7 +548,7 @@ public class EolCommentFieldFactory extends FieldFactory {
@Override
public FieldFactory newInstance(FieldFormatModel fieldFormatModel,
- HighlightProvider highlightProvider, ToolOptions newDisplayOptions,
+ ListingHighlightProvider highlightProvider, ToolOptions newDisplayOptions,
ToolOptions newFieldOptions) {
return new EolCommentFieldFactory(fieldFormatModel, highlightProvider, newDisplayOptions,
newFieldOptions);
diff --git a/Ghidra/Features/Base/src/main/java/ghidra/app/util/viewer/field/ErrorFieldMouseHandler.java b/Ghidra/Features/Base/src/main/java/ghidra/app/util/viewer/field/ErrorFieldMouseHandler.java
index 6ce1304f2a..040b62ae61 100644
--- a/Ghidra/Features/Base/src/main/java/ghidra/app/util/viewer/field/ErrorFieldMouseHandler.java
+++ b/Ghidra/Features/Base/src/main/java/ghidra/app/util/viewer/field/ErrorFieldMouseHandler.java
@@ -16,7 +16,6 @@
package ghidra.app.util.viewer.field;
import ghidra.app.nav.Navigatable;
-import ghidra.app.util.viewer.format.ErrorListingField;
import ghidra.framework.plugintool.ServiceProvider;
import ghidra.program.util.ProgramLocation;
import ghidra.util.Msg;
diff --git a/Ghidra/Features/Base/src/main/java/ghidra/app/util/viewer/format/ErrorListingField.java b/Ghidra/Features/Base/src/main/java/ghidra/app/util/viewer/field/ErrorListingField.java
similarity index 67%
rename from Ghidra/Features/Base/src/main/java/ghidra/app/util/viewer/format/ErrorListingField.java
rename to Ghidra/Features/Base/src/main/java/ghidra/app/util/viewer/field/ErrorListingField.java
index be66cbb585..a351f21f83 100644
--- a/Ghidra/Features/Base/src/main/java/ghidra/app/util/viewer/format/ErrorListingField.java
+++ b/Ghidra/Features/Base/src/main/java/ghidra/app/util/viewer/field/ErrorListingField.java
@@ -13,16 +13,16 @@
* See the License for the specific language governing permissions and
* limitations under the License.
*/
-package ghidra.app.util.viewer.format;
+package ghidra.app.util.viewer.field;
import java.awt.Color;
import docking.widgets.fieldpanel.field.*;
-import docking.widgets.fieldpanel.support.*;
+import docking.widgets.fieldpanel.support.FieldLocation;
+import docking.widgets.fieldpanel.support.Highlight;
import generic.theme.GColor;
import generic.theme.GThemeDefaults.Colors;
-import ghidra.app.util.HighlightProvider;
-import ghidra.app.util.viewer.field.*;
+import ghidra.app.util.ListingHighlightProvider;
import ghidra.app.util.viewer.proxy.ProxyObj;
public class ErrorListingField extends ListingTextField {
@@ -31,21 +31,25 @@ public class ErrorListingField extends ListingTextField {
private Throwable t;
- private static HighlightProvider myProvider =
- (text, obj, fieldFactoryClass, cursorTextOffset) -> new Highlight[] {
+ private static ListingHighlightProvider myProvider =
+ (text, field, cursorTextOffset) -> new Highlight[] {
new Highlight(0, text.length() - 1, BG_ERROR_COLOR) };
public ErrorListingField(FieldFactory ff, ProxyObj<?> proxy, int varWidth, Throwable t) {
- super(ff, proxy, createField(ff, proxy, varWidth, t));
+ super(ff, proxy, null, createHighlightFactory());
+ this.field = createField(ff, proxy, varWidth);
this.t = t;
}
- private static TextField createField(FieldFactory ff, ProxyObj<?> proxy, int varWidth,
- Throwable t) {
- HighlightFactory hlFactory =
- new FieldHighlightFactory(myProvider, ff.getClass(), proxy.getObject());
- return new ClippingTextField(ff.getStartX() + varWidth, ff.getWidth(),
- createElement(ff, t), hlFactory);
+ private static ListingFieldHighlightFactoryAdapter createHighlightFactory() {
+ return new ListingFieldHighlightFactoryAdapter(myProvider);
+ }
+
+ private ClippingTextField createField(FieldFactory ff, ProxyObj<?> proxy, int varWidth) {
+ ClippingTextField textField =
+ new ClippingTextField(ff.getStartX() + varWidth, ff.getWidth(),
+ createElement(ff, t), hlFactory);
+ return textField;
}
private static FieldElement createElement(FieldFactory ff, Throwable t) {
diff --git a/Ghidra/Features/Base/src/main/java/ghidra/app/util/viewer/field/FieldFactory.java b/Ghidra/Features/Base/src/main/java/ghidra/app/util/viewer/field/FieldFactory.java
index fdb75bf461..ddc49fcf29 100644
--- a/Ghidra/Features/Base/src/main/java/ghidra/app/util/viewer/field/FieldFactory.java
+++ b/Ghidra/Features/Base/src/main/java/ghidra/app/util/viewer/field/FieldFactory.java
@@ -20,7 +20,7 @@ import java.math.BigInteger;
import docking.widgets.fieldpanel.support.FieldLocation;
import generic.theme.Gui;
-import ghidra.app.util.HighlightProvider;
+import ghidra.app.util.ListingHighlightProvider;
import ghidra.app.util.template.TemplateSimplifier;
import ghidra.app.util.viewer.format.FieldFormatModel;
import ghidra.app.util.viewer.proxy.ProxyObj;
@@ -51,7 +51,7 @@ public abstract class FieldFactory implements ExtensionPoint {
protected Font baseFont;
protected int style = -1;
protected boolean enabled = true;
- protected HighlightProvider hlProvider;
+ protected ListingHighlightProvider hlProvider;
protected String colorOptionName;
protected String styleOptionName;
@@ -65,7 +65,8 @@ public abstract class FieldFactory implements ExtensionPoint {
* @param displayOptions the Options for display properties.
* @param fieldOptions the Options for field specific properties.
*/
- protected FieldFactory(String name, FieldFormatModel model, HighlightProvider highlightProvider,
+ protected FieldFactory(String name, FieldFormatModel model,
+ ListingHighlightProvider highlightProvider,
Options displayOptions, Options fieldOptions) {
this.name = name;
this.model = model;
@@ -81,7 +82,7 @@ public abstract class FieldFactory implements ExtensionPoint {
protected void initFieldOptions(Options fieldOptions) {
fieldOptions.getOptions(name)
- .setOptionsHelpLocation(new HelpLocation("CodeBrowserPlugin", name));
+ .setOptionsHelpLocation(new HelpLocation("CodeBrowserPlugin", name));
}
protected void initDisplayOptions(Options displayOptions) {
@@ -121,7 +122,8 @@ public abstract class FieldFactory implements ExtensionPoint {
* @return the factory
*/
public abstract FieldFactory newInstance(FieldFormatModel formatModel,
- HighlightProvider highlightProvider, ToolOptions options, ToolOptions fieldOptions);
+ ListingHighlightProvider highlightProvider, ToolOptions options,
+ ToolOptions fieldOptions);
/**
* Notifications that the display options changed.
@@ -220,6 +222,19 @@ public abstract class FieldFactory implements ExtensionPoint {
model.modelChanged();
}
+ /**
+ * Returns true if this given field represents the given location
+ * @param listingField the field
+ * @param location the location
+ * @return true if this given field represents the given location
+ */
+ public boolean supportsLocation(ListingField listingField, ProgramLocation location) {
+ BigInteger dummyIndex = BigInteger.ZERO;
+ int dummyFieldNumber = 0;
+ FieldLocation f = getFieldLocation(listingField, dummyIndex, dummyFieldNumber, location);
+ return f != null;
+ }
+
/**
* Generates a Field based on the given information.
* @param obj The object that the generated field will report some information about.
diff --git a/Ghidra/Features/Base/src/main/java/ghidra/app/util/viewer/field/FieldHighlightFactory.java b/Ghidra/Features/Base/src/main/java/ghidra/app/util/viewer/field/FieldHighlightFactory.java
deleted file mode 100644
index 7f340dc38f..0000000000
--- a/Ghidra/Features/Base/src/main/java/ghidra/app/util/viewer/field/FieldHighlightFactory.java
+++ /dev/null
@@ -1,51 +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.util.viewer.field;
-
-import docking.widgets.fieldpanel.field.Field;
-import docking.widgets.fieldpanel.support.Highlight;
-import docking.widgets.fieldpanel.support.HighlightFactory;
-import ghidra.app.util.HighlightProvider;
-
-/**
- * Wrapper class to hold field factory information in the text field to be provided to the
- * highlightProvider to get highlights just before the field is painted.
- *
- */
-public class FieldHighlightFactory implements HighlightFactory {
-
- private HighlightProvider provider;
- private Class<? extends FieldFactory> fieldFactoryClass;
- private Object obj;
-
- /**
- * Constructs a new FieldHighlightFactory.
- * @param provider the HighlightProvider that will actually compute the highlights.
- * @param fieldFactoryClass the class of the field factory that generated the field to be rendered.
- * @param obj the object that holds the information that will be rendered (usually a code unit)
- */
- public FieldHighlightFactory(HighlightProvider provider,
- Class<? extends FieldFactory> fieldFactoryClass, Object obj) {
- this.provider = provider;
- this.fieldFactoryClass = fieldFactoryClass;
- this.obj = obj;
- }
-
- @Override
- public Highlight[] getHighlights(Field field, String text, int cursorTextOffset) {
- return provider.getHighlights(text, obj, fieldFactoryClass, cursorTextOffset);
- }
-}
diff --git a/Ghidra/Features/Base/src/main/java/ghidra/app/util/viewer/field/FieldNameFieldFactory.java b/Ghidra/Features/Base/src/main/java/ghidra/app/util/viewer/field/FieldNameFieldFactory.java
index e5f2053006..531e58ce48 100644
--- a/Ghidra/Features/Base/src/main/java/ghidra/app/util/viewer/field/FieldNameFieldFactory.java
+++ b/Ghidra/Features/Base/src/main/java/ghidra/app/util/viewer/field/FieldNameFieldFactory.java
@@ -20,7 +20,7 @@ import java.math.BigInteger;
import docking.widgets.fieldpanel.field.*;
import docking.widgets.fieldpanel.support.FieldLocation;
import ghidra.GhidraOptions;
-import ghidra.app.util.HighlightProvider;
+import ghidra.app.util.ListingHighlightProvider;
import ghidra.app.util.viewer.format.FieldFormatModel;
import ghidra.app.util.viewer.format.FormatManager;
import ghidra.app.util.viewer.proxy.ProxyObj;
@@ -70,7 +70,7 @@ public class FieldNameFieldFactory extends FieldFactory {
* @param displayOptions the Options for display properties.
* @param fieldOptions the Options for field specific properties.
*/
- private FieldNameFieldFactory(FieldFormatModel model, HighlightProvider hlProvider,
+ private FieldNameFieldFactory(FieldFormatModel model, ListingHighlightProvider hlProvider,
Options displayOptions, ToolOptions fieldOptions) {
super(FIELD_NAME, model, hlProvider, displayOptions, fieldOptions);
fieldOptions.registerOption(ARRAY_INDEX_FORMAT_NAME, IndexFormat.decimal, null,
@@ -155,7 +155,7 @@ public class FieldNameFieldFactory extends FieldFactory {
}
@Override
- public FieldFactory newInstance(FieldFormatModel formatModel, HighlightProvider provider,
+ public FieldFactory newInstance(FieldFormatModel formatModel, ListingHighlightProvider provider,
ToolOptions toolOptions, ToolOptions fieldOptions) {
return new FieldNameFieldFactory(formatModel, provider, toolOptions, fieldOptions);
}
diff --git a/Ghidra/Features/Base/src/main/java/ghidra/app/util/viewer/field/FileOffsetFieldFactory.java b/Ghidra/Features/Base/src/main/java/ghidra/app/util/viewer/field/FileOffsetFieldFactory.java
index c4feb95930..07a2c376dd 100644
--- a/Ghidra/Features/Base/src/main/java/ghidra/app/util/viewer/field/FileOffsetFieldFactory.java
+++ b/Ghidra/Features/Base/src/main/java/ghidra/app/util/viewer/field/FileOffsetFieldFactory.java
@@ -21,7 +21,7 @@ import java.math.BigInteger;
import docking.widgets.fieldpanel.field.*;
import docking.widgets.fieldpanel.support.FieldLocation;
import generic.theme.GColor;
-import ghidra.app.util.HighlightProvider;
+import ghidra.app.util.ListingHighlightProvider;
import ghidra.app.util.viewer.format.FieldFormatModel;
import ghidra.app.util.viewer.proxy.ProxyObj;
import ghidra.framework.options.*;
@@ -66,7 +66,7 @@ public class FileOffsetFieldFactory extends FieldFactory {
* @param displayOptions the Options for display properties.
* @param fieldOptions the Options for field specific properties.
*/
- private FileOffsetFieldFactory(FieldFormatModel model, HighlightProvider hlProvider,
+ private FileOffsetFieldFactory(FieldFormatModel model, ListingHighlightProvider hlProvider,
Options displayOptions, Options fieldOptions) {
super(FIELD_NAME, model, hlProvider, displayOptions, fieldOptions);
initOptions(fieldOptions);
@@ -97,7 +97,7 @@ public class FileOffsetFieldFactory extends FieldFactory {
@Override
public FieldFactory newInstance(FieldFormatModel formatModel,
- HighlightProvider highlightProvider, ToolOptions options, ToolOptions fieldOptions) {
+ ListingHighlightProvider highlightProvider, ToolOptions options, ToolOptions fieldOptions) {
return new FileOffsetFieldFactory(formatModel, highlightProvider, options, fieldOptions);
}
diff --git a/Ghidra/Features/Base/src/main/java/ghidra/app/util/viewer/field/FunctionCallFixupFieldFactory.java b/Ghidra/Features/Base/src/main/java/ghidra/app/util/viewer/field/FunctionCallFixupFieldFactory.java
index 1eb1b3fc51..d7bda51ec9 100644
--- a/Ghidra/Features/Base/src/main/java/ghidra/app/util/viewer/field/FunctionCallFixupFieldFactory.java
+++ b/Ghidra/Features/Base/src/main/java/ghidra/app/util/viewer/field/FunctionCallFixupFieldFactory.java
@@ -20,7 +20,7 @@ import java.util.ArrayList;
import docking.widgets.fieldpanel.field.*;
import docking.widgets.fieldpanel.support.FieldLocation;
-import ghidra.app.util.HighlightProvider;
+import ghidra.app.util.ListingHighlightProvider;
import ghidra.app.util.viewer.field.ListingColors.FunctionColors;
import ghidra.app.util.viewer.format.FieldFormatModel;
import ghidra.app.util.viewer.proxy.FunctionProxy;
@@ -52,7 +52,7 @@ public class FunctionCallFixupFieldFactory extends FieldFactory {
* @param displayOptions the Options for display properties.
* @param fieldOptions the Options for field specific properties.
*/
- public FunctionCallFixupFieldFactory(FieldFormatModel model, HighlightProvider hlProvider,
+ public FunctionCallFixupFieldFactory(FieldFormatModel model, ListingHighlightProvider hlProvider,
Options displayOptions, Options fieldOptions) {
super(FIELD_NAME, model, hlProvider, displayOptions, fieldOptions);
@@ -118,7 +118,7 @@ public class FunctionCallFixupFieldFactory extends FieldFactory {
}
@Override
- public FieldFactory newInstance(FieldFormatModel formatModel, HighlightProvider provider,
+ public FieldFactory newInstance(FieldFormatModel formatModel, ListingHighlightProvider provider,
ToolOptions displayOptions, ToolOptions fieldOptions) {
return new FunctionCallFixupFieldFactory(formatModel, provider, displayOptions,
fieldOptions);
diff --git a/Ghidra/Features/Base/src/main/java/ghidra/app/util/viewer/field/FunctionPurgeFieldFactory.java b/Ghidra/Features/Base/src/main/java/ghidra/app/util/viewer/field/FunctionPurgeFieldFactory.java
index 63db9fab68..039ae5d571 100644
--- a/Ghidra/Features/Base/src/main/java/ghidra/app/util/viewer/field/FunctionPurgeFieldFactory.java
+++ b/Ghidra/Features/Base/src/main/java/ghidra/app/util/viewer/field/FunctionPurgeFieldFactory.java
@@ -20,7 +20,7 @@ import java.math.BigInteger;
import docking.widgets.fieldpanel.field.*;
import docking.widgets.fieldpanel.support.FieldLocation;
import generic.theme.GColor;
-import ghidra.app.util.HighlightProvider;
+import ghidra.app.util.ListingHighlightProvider;
import ghidra.app.util.viewer.format.FieldFormatModel;
import ghidra.app.util.viewer.proxy.ProxyObj;
import ghidra.framework.options.Options;
@@ -37,14 +37,14 @@ public class FunctionPurgeFieldFactory extends FieldFactory {
super(FIELD_NAME);
}
- private FunctionPurgeFieldFactory(FieldFormatModel model, HighlightProvider hlProvider,
+ private FunctionPurgeFieldFactory(FieldFormatModel model, ListingHighlightProvider hlProvider,
Options displayOptions, Options fieldOptions) {
super(FIELD_NAME, model, hlProvider, displayOptions, fieldOptions);
}
@Override
- public FieldFactory newInstance(FieldFormatModel newModel, HighlightProvider newHlProvider,
+ public FieldFactory newInstance(FieldFormatModel newModel, ListingHighlightProvider newHlProvider,
ToolOptions toolOptions, ToolOptions fieldOptions) {
return new FunctionPurgeFieldFactory(newModel, newHlProvider, toolOptions, fieldOptions);
}
diff --git a/Ghidra/Features/Base/src/main/java/ghidra/app/util/viewer/field/FunctionRepeatableCommentFieldFactory.java b/Ghidra/Features/Base/src/main/java/ghidra/app/util/viewer/field/FunctionRepeatableCommentFieldFactory.java
index 0c1b90f3ca..53d2c7bed4 100644
--- a/Ghidra/Features/Base/src/main/java/ghidra/app/util/viewer/field/FunctionRepeatableCommentFieldFactory.java
+++ b/Ghidra/Features/Base/src/main/java/ghidra/app/util/viewer/field/FunctionRepeatableCommentFieldFactory.java
@@ -21,7 +21,7 @@ import docking.widgets.fieldpanel.field.AttributedString;
import docking.widgets.fieldpanel.field.FieldElement;
import docking.widgets.fieldpanel.support.FieldLocation;
import generic.theme.GColor;
-import ghidra.app.util.HighlightProvider;
+import ghidra.app.util.ListingHighlightProvider;
import ghidra.app.util.viewer.field.ListingColors.CommentColors;
import ghidra.app.util.viewer.format.FieldFormatModel;
import ghidra.app.util.viewer.proxy.FunctionProxy;
@@ -55,7 +55,7 @@ public class FunctionRepeatableCommentFieldFactory extends FieldFactory {
* @param fieldOptions the Options for field specific properties.
*/
public FunctionRepeatableCommentFieldFactory(FieldFormatModel model,
- HighlightProvider hlProvider, Options displayOptions, Options fieldOptions) {
+ ListingHighlightProvider hlProvider, Options displayOptions, Options fieldOptions) {
super(FIELD_NAME, model, hlProvider, displayOptions, fieldOptions);
}
@@ -121,7 +121,7 @@ public class FunctionRepeatableCommentFieldFactory extends FieldFactory {
}
@Override
- public FieldFactory newInstance(FieldFormatModel formatModel, HighlightProvider provider,
+ public FieldFactory newInstance(FieldFormatModel formatModel, ListingHighlightProvider provider,
ToolOptions options, ToolOptions fieldOptions) {
return new FunctionRepeatableCommentFieldFactory(formatModel, provider, options,
diff --git a/Ghidra/Features/Base/src/main/java/ghidra/app/util/viewer/field/FunctionSignatureFieldFactory.java b/Ghidra/Features/Base/src/main/java/ghidra/app/util/viewer/field/FunctionSignatureFieldFactory.java
index 77bda1c845..9de54f33f2 100644
--- a/Ghidra/Features/Base/src/main/java/ghidra/app/util/viewer/field/FunctionSignatureFieldFactory.java
+++ b/Ghidra/Features/Base/src/main/java/ghidra/app/util/viewer/field/FunctionSignatureFieldFactory.java
@@ -24,7 +24,7 @@ import docking.widgets.fieldpanel.field.*;
import docking.widgets.fieldpanel.support.FieldLocation;
import docking.widgets.fieldpanel.support.RowColLocation;
import ghidra.GhidraOptions;
-import ghidra.app.util.HighlightProvider;
+import ghidra.app.util.ListingHighlightProvider;
import ghidra.app.util.viewer.field.ListingColors.FunctionColors;
import ghidra.app.util.viewer.format.FieldFormatModel;
import ghidra.app.util.viewer.proxy.FunctionProxy;
@@ -58,7 +58,7 @@ public class FunctionSignatureFieldFactory extends FieldFactory {
* @param displayOptions the Options for display properties.
* @param fieldOptions the Options for field specific properties.
*/
- public FunctionSignatureFieldFactory(FieldFormatModel model, HighlightProvider hlProvider,
+ public FunctionSignatureFieldFactory(FieldFormatModel model, ListingHighlightProvider hlProvider,
ToolOptions displayOptions, ToolOptions fieldOptions) {
super(FIELD_NAME, model, hlProvider, displayOptions, fieldOptions);
@@ -375,7 +375,7 @@ public class FunctionSignatureFieldFactory extends FieldFactory {
}
@Override
- public FieldFactory newInstance(FieldFormatModel formatModel, HighlightProvider provider,
+ public FieldFactory newInstance(FieldFormatModel formatModel, ListingHighlightProvider provider,
ToolOptions toolOptions, ToolOptions fieldOptions) {
return new FunctionSignatureFieldFactory(formatModel, provider, toolOptions, fieldOptions);
}
diff --git a/Ghidra/Features/Base/src/main/java/ghidra/app/util/viewer/field/FunctionSignatureSourceFieldFactory.java b/Ghidra/Features/Base/src/main/java/ghidra/app/util/viewer/field/FunctionSignatureSourceFieldFactory.java
index 57d7b26b10..b9461e0f68 100644
--- a/Ghidra/Features/Base/src/main/java/ghidra/app/util/viewer/field/FunctionSignatureSourceFieldFactory.java
+++ b/Ghidra/Features/Base/src/main/java/ghidra/app/util/viewer/field/FunctionSignatureSourceFieldFactory.java
@@ -20,7 +20,7 @@ import java.math.BigInteger;
import docking.widgets.fieldpanel.field.AttributedString;
import docking.widgets.fieldpanel.field.TextFieldElement;
import docking.widgets.fieldpanel.support.FieldLocation;
-import ghidra.app.util.HighlightProvider;
+import ghidra.app.util.ListingHighlightProvider;
import ghidra.app.util.viewer.field.ListingColors.FunctionColors;
import ghidra.app.util.viewer.format.FieldFormatModel;
import ghidra.app.util.viewer.proxy.FunctionProxy;
@@ -55,7 +55,7 @@ public class FunctionSignatureSourceFieldFactory extends FieldFactory {
* @param displayOptions the Options for display properties.
* @param fieldOptions the Options for field specific properties.
*/
- public FunctionSignatureSourceFieldFactory(FieldFormatModel model, HighlightProvider hlProvider,
+ public FunctionSignatureSourceFieldFactory(FieldFormatModel model, ListingHighlightProvider hlProvider,
Options displayOptions, Options fieldOptions) {
super(FIELD_NAME, model, hlProvider, displayOptions, fieldOptions);
}
@@ -112,7 +112,7 @@ public class FunctionSignatureSourceFieldFactory extends FieldFactory {
}
@Override
- public FieldFactory newInstance(FieldFormatModel formatModel, HighlightProvider provider,
+ public FieldFactory newInstance(FieldFormatModel formatModel, ListingHighlightProvider provider,
ToolOptions toolOptions, ToolOptions fieldOptions) {
return new FunctionSignatureSourceFieldFactory(formatModel, provider, toolOptions,
fieldOptions);
diff --git a/Ghidra/Features/Base/src/main/java/ghidra/app/util/viewer/field/FunctionTagFieldFactory.java b/Ghidra/Features/Base/src/main/java/ghidra/app/util/viewer/field/FunctionTagFieldFactory.java
index e44c1be15a..6e3b3066d7 100644
--- a/Ghidra/Features/Base/src/main/java/ghidra/app/util/viewer/field/FunctionTagFieldFactory.java
+++ b/Ghidra/Features/Base/src/main/java/ghidra/app/util/viewer/field/FunctionTagFieldFactory.java
@@ -23,7 +23,7 @@ import org.apache.commons.lang3.StringUtils;
import docking.widgets.fieldpanel.field.*;
import docking.widgets.fieldpanel.support.FieldLocation;
-import ghidra.app.util.HighlightProvider;
+import ghidra.app.util.ListingHighlightProvider;
import ghidra.app.util.viewer.field.ListingColors.FunctionColors;
import ghidra.app.util.viewer.format.FieldFormatModel;
import ghidra.app.util.viewer.proxy.FunctionProxy;
@@ -59,7 +59,7 @@ public class FunctionTagFieldFactory extends FieldFactory {
* @param displayOptions the Options for display properties.
* @param fieldOptions the Options for field specific properties.
*/
- private FunctionTagFieldFactory(FieldFormatModel model, HighlightProvider hlProvider,
+ private FunctionTagFieldFactory(FieldFormatModel model, ListingHighlightProvider hlProvider,
Options displayOptions, Options fieldOptions) {
super(FIELD_NAME, model, hlProvider, displayOptions, fieldOptions);
}
@@ -125,7 +125,7 @@ public class FunctionTagFieldFactory extends FieldFactory {
}
@Override
- public FieldFactory newInstance(FieldFormatModel formatModel, HighlightProvider provider,
+ public FieldFactory newInstance(FieldFormatModel formatModel, ListingHighlightProvider provider,
ToolOptions toolOptions, ToolOptions fieldOptions) {
return new FunctionTagFieldFactory(formatModel, provider, toolOptions, fieldOptions);
}
diff --git a/Ghidra/Features/Base/src/main/java/ghidra/app/util/viewer/field/ImageFactoryField.java b/Ghidra/Features/Base/src/main/java/ghidra/app/util/viewer/field/ImageFactoryField.java
index 4aa0f249f6..96402a42dc 100644
--- a/Ghidra/Features/Base/src/main/java/ghidra/app/util/viewer/field/ImageFactoryField.java
+++ b/Ghidra/Features/Base/src/main/java/ghidra/app/util/viewer/field/ImageFactoryField.java
@@ -21,7 +21,6 @@ import javax.swing.Icon;
import docking.widgets.fieldpanel.field.SimpleImageField;
import docking.widgets.fieldpanel.support.FieldLocation;
-import ghidra.app.util.viewer.format.FieldFormatModel;
import ghidra.app.util.viewer.proxy.EmptyProxy;
import ghidra.app.util.viewer.proxy.ProxyObj;
@@ -79,11 +78,6 @@ public class ImageFactoryField extends SimpleImageField implements ListingField
return factory;
}
- @Override
- public FieldFormatModel getFieldModel() {
- return factory.getFieldModel();
- }
-
@Override
public ProxyObj<?> getProxy() {
if (proxy == null) {
diff --git a/Ghidra/Features/Base/src/main/java/ghidra/app/util/viewer/field/IndentField.java b/Ghidra/Features/Base/src/main/java/ghidra/app/util/viewer/field/IndentField.java
index 6446826ed4..55ed45f763 100644
--- a/Ghidra/Features/Base/src/main/java/ghidra/app/util/viewer/field/IndentField.java
+++ b/Ghidra/Features/Base/src/main/java/ghidra/app/util/viewer/field/IndentField.java
@@ -23,7 +23,6 @@ import docking.widgets.fieldpanel.internal.FieldBackgroundColorManager;
import docking.widgets.fieldpanel.internal.PaintContext;
import docking.widgets.fieldpanel.support.*;
import generic.theme.GThemeDefaults.Colors.Palette;
-import ghidra.app.util.viewer.format.FieldFormatModel;
import ghidra.app.util.viewer.proxy.EmptyProxy;
import ghidra.app.util.viewer.proxy.ProxyObj;
@@ -80,15 +79,6 @@ public class IndentField implements ListingField {
return factory;
}
- /**
- * Returns the FieldModel that contains the FieldFactory that generated this
- * field.
- */
- @Override
- public FieldFormatModel getFieldModel() {
- return factory.getFieldModel();
- }
-
/**
* Returns the object associated with this field instance.
*/
diff --git a/Ghidra/Features/Base/src/main/java/ghidra/app/util/viewer/field/InstructionMaskValueFieldFactory.java b/Ghidra/Features/Base/src/main/java/ghidra/app/util/viewer/field/InstructionMaskValueFieldFactory.java
index a9827594ef..52f4c23d7f 100644
--- a/Ghidra/Features/Base/src/main/java/ghidra/app/util/viewer/field/InstructionMaskValueFieldFactory.java
+++ b/Ghidra/Features/Base/src/main/java/ghidra/app/util/viewer/field/InstructionMaskValueFieldFactory.java
@@ -20,7 +20,7 @@ import java.math.BigInteger;
import docking.widgets.fieldpanel.field.*;
import docking.widgets.fieldpanel.support.FieldLocation;
-import ghidra.app.util.HighlightProvider;
+import ghidra.app.util.ListingHighlightProvider;
import ghidra.app.util.viewer.field.ListingColors.MaskColors;
import ghidra.app.util.viewer.format.FieldFormatModel;
import ghidra.app.util.viewer.proxy.ProxyObj;
@@ -52,7 +52,7 @@ public class InstructionMaskValueFieldFactory extends FieldFactory {
* @param displayOptions the Options for display properties.
* @param fieldOptions the Options for field specific properties.
*/
- private InstructionMaskValueFieldFactory(FieldFormatModel model, HighlightProvider hsProvider,
+ private InstructionMaskValueFieldFactory(FieldFormatModel model, ListingHighlightProvider hsProvider,
Options displayOptions, Options fieldOptions) {
super(FIELD_NAME, model, hsProvider, displayOptions, fieldOptions);
}
@@ -165,7 +165,7 @@ public class InstructionMaskValueFieldFactory extends FieldFactory {
}
@Override
- public FieldFactory newInstance(FieldFormatModel formatModel, HighlightProvider hsProvider,
+ public FieldFactory newInstance(FieldFormatModel formatModel, ListingHighlightProvider hsProvider,
ToolOptions toolOptions, ToolOptions fieldOptions) {
return new InstructionMaskValueFieldFactory(formatModel, hsProvider, toolOptions,
fieldOptions);
diff --git a/Ghidra/Features/Base/src/main/java/ghidra/app/util/viewer/field/LabelFieldFactory.java b/Ghidra/Features/Base/src/main/java/ghidra/app/util/viewer/field/LabelFieldFactory.java
index 09b596932c..2ce12bc367 100644
--- a/Ghidra/Features/Base/src/main/java/ghidra/app/util/viewer/field/LabelFieldFactory.java
+++ b/Ghidra/Features/Base/src/main/java/ghidra/app/util/viewer/field/LabelFieldFactory.java
@@ -83,7 +83,7 @@ public class LabelFieldFactory extends FieldFactory {
* @param displayOptions the Options for display properties.
* @param fieldOptions the Options for field specific properties.
*/
- private LabelFieldFactory(FieldFormatModel model, HighlightProvider hlProvider,
+ private LabelFieldFactory(FieldFormatModel model, ListingHighlightProvider hlProvider,
ToolOptions displayOptions, ToolOptions fieldOptions) {
super(FIELD_NAME, model, hlProvider, displayOptions, fieldOptions);
@@ -449,7 +449,7 @@ public class LabelFieldFactory extends FieldFactory {
}
@Override
- public FieldFactory newInstance(FieldFormatModel formatModel, HighlightProvider provider,
+ public FieldFactory newInstance(FieldFormatModel formatModel, ListingHighlightProvider provider,
ToolOptions pDisplayOptions, ToolOptions fieldOptions) {
return new LabelFieldFactory(formatModel, provider, pDisplayOptions, fieldOptions);
}
diff --git a/Ghidra/Features/Base/src/main/java/ghidra/app/util/viewer/field/ListingField.java b/Ghidra/Features/Base/src/main/java/ghidra/app/util/viewer/field/ListingField.java
index 1e125ca794..bf2a381348 100644
--- a/Ghidra/Features/Base/src/main/java/ghidra/app/util/viewer/field/ListingField.java
+++ b/Ghidra/Features/Base/src/main/java/ghidra/app/util/viewer/field/ListingField.java
@@ -17,7 +17,6 @@ package ghidra.app.util.viewer.field;
import docking.widgets.fieldpanel.field.Field;
import docking.widgets.fieldpanel.support.FieldLocation;
-import ghidra.app.util.viewer.format.FieldFormatModel;
import ghidra.app.util.viewer.proxy.ProxyObj;
/**
@@ -31,24 +30,6 @@ public interface ListingField extends Field {
*/
public FieldFactory getFieldFactory();
- /**
- * Returns the height above the imaginary base line used for alignment of fields.
- */
- @Override
- public int getHeightAbove();
-
- /**
- * Returns the height below the imaginary base line used for alignment of fields.
- */
- @Override
- public int getHeightBelow();
-
- /**
- * Returns the fieldModel that has the FieldFactory that generated this field.
- * @return the fieldModel that has the FieldFactory that generated this field.
- */
- public FieldFormatModel getFieldModel();
-
/**
* Returns the object that the fieldFactory used to generate the information in this field.
* @return the object that the fieldFactory used to generate the information in this field.
diff --git a/Ghidra/Features/Base/src/main/java/ghidra/app/util/viewer/field/ListingFieldHighlightFactoryAdapter.java b/Ghidra/Features/Base/src/main/java/ghidra/app/util/viewer/field/ListingFieldHighlightFactoryAdapter.java
new file mode 100644
index 0000000000..908790da85
--- /dev/null
+++ b/Ghidra/Features/Base/src/main/java/ghidra/app/util/viewer/field/ListingFieldHighlightFactoryAdapter.java
@@ -0,0 +1,61 @@
+/* ###
+ * 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.util.viewer.field;
+
+import docking.widgets.fieldpanel.field.Field;
+import docking.widgets.fieldpanel.support.FieldHighlightFactory;
+import docking.widgets.fieldpanel.support.Highlight;
+import ghidra.app.util.ListingHighlightProvider;
+import ghidra.app.util.viewer.listingpanel.ListingPanel;
+import ghidra.util.Msg;
+import utilities.util.reflection.ReflectionUtilities;
+
+/**
+ * Wrapper class to translate calls to {@link FieldHighlightFactory} into a call needed by the
+ * {@link ListingHighlightProvider}. This class holds field factory information in the text
+ * field to be provided to the highlightProvider to get highlights just before the field is painted.
+ * <p>
+ * This class is needed to allow the basic {@link Field} API to be used with more richness at the
+ * {@link ListingPanel} level.
+ */
+public class ListingFieldHighlightFactoryAdapter implements FieldHighlightFactory {
+
+ private ListingHighlightProvider provider;
+ private ListingField listingField;
+
+ /**
+ * Constructor
+ * @param provider the HighlightProvider that will actually compute the highlights.
+ */
+ public ListingFieldHighlightFactoryAdapter(ListingHighlightProvider provider) {
+ this.provider = provider;
+ }
+
+ void setListingField(ListingField listingField) {
+ this.listingField = listingField;
+ }
+
+ @Override
+ public Highlight[] createHighlights(Field field, String text, int cursorTextOffset) {
+ if (listingField == null) {
+ Msg.error(this,
+ "Listing highlight factory not correctly setup; ListingField must be set",
+ ReflectionUtilities.createJavaFilteredThrowable());
+ return NO_HIGHLIGHTS;
+ }
+ return provider.createHighlights(text, listingField, cursorTextOffset);
+ }
+}
diff --git a/Ghidra/Features/Base/src/main/java/ghidra/app/util/viewer/field/ListingTextField.java b/Ghidra/Features/Base/src/main/java/ghidra/app/util/viewer/field/ListingTextField.java
index 502041cf1b..777f8bc923 100644
--- a/Ghidra/Features/Base/src/main/java/ghidra/app/util/viewer/field/ListingTextField.java
+++ b/Ghidra/Features/Base/src/main/java/ghidra/app/util/viewer/field/ListingTextField.java
@@ -25,9 +25,9 @@ import javax.swing.JComponent;
import docking.widgets.fieldpanel.field.*;
import docking.widgets.fieldpanel.internal.FieldBackgroundColorManager;
import docking.widgets.fieldpanel.internal.PaintContext;
-import docking.widgets.fieldpanel.support.*;
-import ghidra.app.util.HighlightProvider;
-import ghidra.app.util.viewer.format.FieldFormatModel;
+import docking.widgets.fieldpanel.support.FieldLocation;
+import docking.widgets.fieldpanel.support.RowColLocation;
+import ghidra.app.util.ListingHighlightProvider;
import ghidra.app.util.viewer.proxy.EmptyProxy;
import ghidra.app.util.viewer.proxy.ProxyObj;
@@ -39,6 +39,7 @@ public class ListingTextField implements ListingField, TextField {
private ProxyObj<?> proxy;
private FieldFactory factory;
protected TextField field;
+ protected ListingFieldHighlightFactoryAdapter hlFactory;
/**
* Creates a new ListingTextField that displays the text on a single line, clipping as needed.
@@ -53,21 +54,24 @@ public class ListingTextField implements ListingField, TextField {
*/
public static ListingTextField createSingleLineTextField(FieldFactory factory,
ProxyObj<?> proxy, FieldElement fieldElement, int startX, int width,
- HighlightProvider provider) {
+ ListingHighlightProvider provider) {
- HighlightFactory hlFactory =
- new FieldHighlightFactory(provider, factory.getClass(), proxy.getObject());
+ ListingFieldHighlightFactoryAdapter hlFactory =
+ new ListingFieldHighlightFactoryAdapter(provider);
TextField field = new ClippingTextField(startX, width, fieldElement, hlFactory);
- return new ListingTextField(factory, proxy, field);
+ ListingTextField listingField = new ListingTextField(factory, proxy, field, hlFactory);
+ return listingField;
}
public static ListingTextField createSingleLineTextFieldWithReverseClipping(
AddressFieldFactory factory, ProxyObj<?> proxy, FieldElement fieldElement, int startX,
- int width, HighlightProvider provider) {
- HighlightFactory hlFactory =
- new FieldHighlightFactory(provider, factory.getClass(), proxy.getObject());
+ int width, ListingHighlightProvider provider) {
+
+ ListingFieldHighlightFactoryAdapter hlFactory =
+ new ListingFieldHighlightFactoryAdapter(provider);
TextField field = new ReverseClippingTextField(startX, width, fieldElement, hlFactory);
- return new ListingTextField(factory, proxy, field);
+ ListingTextField listingField = new ListingTextField(factory, proxy, field, hlFactory);
+ return listingField;
}
/**
@@ -85,13 +89,14 @@ public class ListingTextField implements ListingField, TextField {
*/
public static ListingTextField createWordWrappedTextField(FieldFactory factory,
ProxyObj<?> proxy, FieldElement fieldElement, int startX, int width, int maxLines,
- HighlightProvider provider) {
+ ListingHighlightProvider provider) {
- HighlightFactory hlFactory =
- new FieldHighlightFactory(provider, factory.getClass(), proxy.getObject());
+ ListingFieldHighlightFactoryAdapter hlFactory =
+ new ListingFieldHighlightFactoryAdapter(provider);
TextField field =
new WrappingVerticalLayoutTextField(fieldElement, startX, width, maxLines, hlFactory);
- return new ListingTextField(factory, proxy, field);
+ ListingTextField listingField = new ListingTextField(factory, proxy, field, hlFactory);
+ return listingField;
}
/**
@@ -109,13 +114,14 @@ public class ListingTextField implements ListingField, TextField {
*/
public static ListingTextField createPackedTextField(FieldFactory factory, ProxyObj<?> proxy,
FieldElement[] textElements, int startX, int width, int maxLines,
- HighlightProvider provider) {
+ ListingHighlightProvider provider) {
- HighlightFactory hlFactory =
- new FieldHighlightFactory(provider, factory.getClass(), proxy.getObject());
+ ListingFieldHighlightFactoryAdapter hlFactory =
+ new ListingFieldHighlightFactoryAdapter(provider);
List<FieldElement> list = Arrays.asList(textElements);
TextField field = new FlowLayoutTextField(list, startX, width, maxLines, hlFactory);
- return new ListingTextField(factory, proxy, field);
+ ListingTextField listingField = new ListingTextField(factory, proxy, field, hlFactory);
+ return listingField;
}
/**
@@ -132,20 +138,24 @@ public class ListingTextField implements ListingField, TextField {
*/
public static ListingTextField createMultilineTextField(FieldFactory factory, ProxyObj<?> proxy,
FieldElement[] textElements, int startX, int width, int maxLines,
- HighlightProvider provider) {
+ ListingHighlightProvider provider) {
- HighlightFactory hlFactory =
- new FieldHighlightFactory(provider, factory.getClass(), proxy.getObject());
+ ListingFieldHighlightFactoryAdapter hlFactory =
+ new ListingFieldHighlightFactoryAdapter(provider);
List<FieldElement> list = Arrays.asList(textElements);
TextField field =
new VerticalLayoutTextField(list, startX, width, maxLines, hlFactory);
- return new ListingTextField(factory, proxy, field);
+ ListingTextField listingField = new ListingTextField(factory, proxy, field, hlFactory);
+ return listingField;
}
- protected ListingTextField(FieldFactory factory, ProxyObj<?> proxy, TextField field) {
+ protected ListingTextField(FieldFactory factory, ProxyObj<?> proxy, TextField field,
+ ListingFieldHighlightFactoryAdapter hlFactory) {
this.factory = factory;
this.proxy = proxy;
this.field = field;
+ this.hlFactory = hlFactory;
+ hlFactory.setListingField(this);
}
@Override
@@ -303,11 +313,6 @@ public class ListingTextField implements ListingField, TextField {
return proxy;
}
- @Override
- public FieldFormatModel getFieldModel() {
- return factory.getFieldModel();
- }
-
@Override
public boolean isClipped() {
return field.isClipped();
diff --git a/Ghidra/Features/Base/src/main/java/ghidra/app/util/viewer/field/MemoryBlockStartFieldFactory.java b/Ghidra/Features/Base/src/main/java/ghidra/app/util/viewer/field/MemoryBlockStartFieldFactory.java
index da1b90aabb..f90778b0f0 100644
--- a/Ghidra/Features/Base/src/main/java/ghidra/app/util/viewer/field/MemoryBlockStartFieldFactory.java
+++ b/Ghidra/Features/Base/src/main/java/ghidra/app/util/viewer/field/MemoryBlockStartFieldFactory.java
@@ -23,7 +23,7 @@ import java.util.List;
import docking.widgets.fieldpanel.field.*;
import docking.widgets.fieldpanel.support.FieldLocation;
import docking.widgets.fieldpanel.support.RowColLocation;
-import ghidra.app.util.HighlightProvider;
+import ghidra.app.util.ListingHighlightProvider;
import ghidra.app.util.viewer.format.FieldFormatModel;
import ghidra.app.util.viewer.proxy.ProxyObj;
import ghidra.framework.options.Options;
@@ -56,7 +56,7 @@ public class MemoryBlockStartFieldFactory extends FieldFactory {
* @param displayOptions the Options for display properties.
* @param fieldOptions the Options for field specific properties.
*/
- private MemoryBlockStartFieldFactory(FieldFormatModel model, HighlightProvider hlProvider,
+ private MemoryBlockStartFieldFactory(FieldFormatModel model, ListingHighlightProvider hlProvider,
Options displayOptions, Options fieldOptions) {
super(FIELD_NAME, model, hlProvider, displayOptions, fieldOptions);
}
@@ -177,7 +177,7 @@ public class MemoryBlockStartFieldFactory extends FieldFactory {
}
@Override
- public FieldFactory newInstance(FieldFormatModel formatModel, HighlightProvider provider,
+ public FieldFactory newInstance(FieldFormatModel formatModel, ListingHighlightProvider provider,
ToolOptions displayOptions, ToolOptions fieldOptions) {
return new MemoryBlockStartFieldFactory(formatModel, provider, displayOptions,
fieldOptions);
diff --git a/Ghidra/Features/Base/src/main/java/ghidra/app/util/viewer/field/MnemonicFieldFactory.java b/Ghidra/Features/Base/src/main/java/ghidra/app/util/viewer/field/MnemonicFieldFactory.java
index b3af3ab501..ceb054f35d 100644
--- a/Ghidra/Features/Base/src/main/java/ghidra/app/util/viewer/field/MnemonicFieldFactory.java
+++ b/Ghidra/Features/Base/src/main/java/ghidra/app/util/viewer/field/MnemonicFieldFactory.java
@@ -24,7 +24,7 @@ import docking.widgets.fieldpanel.field.*;
import docking.widgets.fieldpanel.support.FieldLocation;
import generic.theme.GThemeDefaults.Colors.Messages;
import ghidra.GhidraOptions;
-import ghidra.app.util.HighlightProvider;
+import ghidra.app.util.ListingHighlightProvider;
import ghidra.app.util.viewer.field.ListingColors.MnemonicColors;
import ghidra.app.util.viewer.format.FieldFormatModel;
import ghidra.app.util.viewer.proxy.ProxyObj;
@@ -68,7 +68,7 @@ public class MnemonicFieldFactory extends FieldFactory {
* @param displayOptions the Options for display properties.
* @param fieldOptions the Options for field specific properties.
*/
- private MnemonicFieldFactory(FieldFormatModel model, HighlightProvider hsProvider,
+ private MnemonicFieldFactory(FieldFormatModel model, ListingHighlightProvider hsProvider,
Options displayOptions, ToolOptions fieldOptions) {
super(FIELD_NAME, model, hsProvider, displayOptions, fieldOptions);
@@ -202,7 +202,7 @@ public class MnemonicFieldFactory extends FieldFactory {
}
@Override
- public FieldFactory newInstance(FieldFormatModel formatModel, HighlightProvider hsProvider,
+ public FieldFactory newInstance(FieldFormatModel formatModel, ListingHighlightProvider hsProvider,
ToolOptions displayOptions, ToolOptions fieldOptions) {
return new MnemonicFieldFactory(formatModel, hsProvider, displayOptions, fieldOptions);
}
diff --git a/Ghidra/Features/Base/src/main/java/ghidra/app/util/viewer/field/OpenCloseField.java b/Ghidra/Features/Base/src/main/java/ghidra/app/util/viewer/field/OpenCloseField.java
index 29557cd47e..12896ee1f9 100644
--- a/Ghidra/Features/Base/src/main/java/ghidra/app/util/viewer/field/OpenCloseField.java
+++ b/Ghidra/Features/Base/src/main/java/ghidra/app/util/viewer/field/OpenCloseField.java
@@ -24,7 +24,6 @@ import docking.widgets.fieldpanel.internal.PaintContext;
import docking.widgets.fieldpanel.support.*;
import generic.theme.GIcon;
import generic.theme.GThemeDefaults.Colors.Palette;
-import ghidra.app.util.viewer.format.FieldFormatModel;
import ghidra.app.util.viewer.proxy.EmptyProxy;
import ghidra.app.util.viewer.proxy.ProxyObj;
import ghidra.program.model.listing.Data;
@@ -82,11 +81,6 @@ public class OpenCloseField implements ListingField {
return factory;
}
- @Override
- public FieldFormatModel getFieldModel() {
- return factory.getFieldModel();
- }
-
@Override
public ProxyObj<?> getProxy() {
if (proxy == null) {
diff --git a/Ghidra/Features/Base/src/main/java/ghidra/app/util/viewer/field/OpenCloseFieldFactory.java b/Ghidra/Features/Base/src/main/java/ghidra/app/util/viewer/field/OpenCloseFieldFactory.java
index f8d80eb218..b80cb54981 100644
--- a/Ghidra/Features/Base/src/main/java/ghidra/app/util/viewer/field/OpenCloseFieldFactory.java
+++ b/Ghidra/Features/Base/src/main/java/ghidra/app/util/viewer/field/OpenCloseFieldFactory.java
@@ -18,7 +18,7 @@ package ghidra.app.util.viewer.field;
import java.math.BigInteger;
import docking.widgets.fieldpanel.support.FieldLocation;
-import ghidra.app.util.HighlightProvider;
+import ghidra.app.util.ListingHighlightProvider;
import ghidra.app.util.viewer.format.FieldFormatModel;
import ghidra.app.util.viewer.proxy.ProxyObj;
import ghidra.framework.options.Options;
@@ -46,7 +46,7 @@ public class OpenCloseFieldFactory extends FieldFactory {
* @param displayOptions the Options for display properties.
* @param fieldOptions the Options for field specific properties.
*/
- private OpenCloseFieldFactory(FieldFormatModel model, HighlightProvider hlProvider,
+ private OpenCloseFieldFactory(FieldFormatModel model, ListingHighlightProvider hlProvider,
Options displayOptions, Options fieldOptions) {
super(FIELD_NAME, model, hlProvider, displayOptions, fieldOptions);
servicesChanged();
@@ -154,7 +154,7 @@ public class OpenCloseFieldFactory extends FieldFactory {
}
@Override
- public FieldFactory newInstance(FieldFormatModel fieldModel, HighlightProvider provider,
+ public FieldFactory newInstance(FieldFormatModel fieldModel, ListingHighlightProvider provider,
ToolOptions displayOptions, ToolOptions fieldOptions) {
return new OpenCloseFieldFactory(fieldModel, provider, displayOptions, fieldOptions);
}
diff --git a/Ghidra/Features/Base/src/main/java/ghidra/app/util/viewer/field/OperandFieldFactory.java b/Ghidra/Features/Base/src/main/java/ghidra/app/util/viewer/field/OperandFieldFactory.java
index 67ab4cfd80..10ad68c0c0 100644
--- a/Ghidra/Features/Base/src/main/java/ghidra/app/util/viewer/field/OperandFieldFactory.java
+++ b/Ghidra/Features/Base/src/main/java/ghidra/app/util/viewer/field/OperandFieldFactory.java
@@ -18,7 +18,7 @@ package ghidra.app.util.viewer.field;
import java.math.BigInteger;
import docking.widgets.fieldpanel.support.FieldLocation;
-import ghidra.app.util.HighlightProvider;
+import ghidra.app.util.ListingHighlightProvider;
import ghidra.app.util.viewer.format.FieldFormatModel;
import ghidra.app.util.viewer.proxy.ProxyObj;
import ghidra.framework.options.ToolOptions;
@@ -43,7 +43,7 @@ public class OperandFieldFactory extends OperandFieldHelper {
* @param displayOptions the Options for display properties.
* @param fieldOptions the Options for field specific properties.
*/
- protected OperandFieldFactory(FieldFormatModel model, HighlightProvider hlProvider,
+ protected OperandFieldFactory(FieldFormatModel model, ListingHighlightProvider hlProvider,
ToolOptions displayOptions, ToolOptions fieldOptions) {
super(FIELD_NAME, model, hlProvider, displayOptions, fieldOptions);
}
@@ -89,7 +89,7 @@ public class OperandFieldFactory extends OperandFieldHelper {
}
@Override
- public FieldFactory newInstance(FieldFormatModel formatModel, HighlightProvider hsProvider,
+ public FieldFactory newInstance(FieldFormatModel formatModel, ListingHighlightProvider hsProvider,
ToolOptions displayOptions, ToolOptions fieldOptions) {
return new OperandFieldFactory(formatModel, hsProvider, displayOptions, fieldOptions);
}
diff --git a/Ghidra/Features/Base/src/main/java/ghidra/app/util/viewer/field/OperandFieldHelper.java b/Ghidra/Features/Base/src/main/java/ghidra/app/util/viewer/field/OperandFieldHelper.java
index b0b61c3fe3..f2510b9126 100644
--- a/Ghidra/Features/Base/src/main/java/ghidra/app/util/viewer/field/OperandFieldHelper.java
+++ b/Ghidra/Features/Base/src/main/java/ghidra/app/util/viewer/field/OperandFieldHelper.java
@@ -96,7 +96,7 @@ abstract class OperandFieldHelper extends FieldFactory {
* @param displayOptions the Options for display properties.
* @param fieldOptions the Options for field specific properties.
*/
- OperandFieldHelper(String name, FieldFormatModel model, HighlightProvider hlProvider,
+ OperandFieldHelper(String name, FieldFormatModel model, ListingHighlightProvider hlProvider,
ToolOptions displayOptions, ToolOptions fieldOptions) {
super(name, model, hlProvider, displayOptions, fieldOptions);
diff --git a/Ghidra/Features/Base/src/main/java/ghidra/app/util/viewer/field/ParallelInstructionFieldFactory.java b/Ghidra/Features/Base/src/main/java/ghidra/app/util/viewer/field/ParallelInstructionFieldFactory.java
index f5814473e6..7faa933b5e 100644
--- a/Ghidra/Features/Base/src/main/java/ghidra/app/util/viewer/field/ParallelInstructionFieldFactory.java
+++ b/Ghidra/Features/Base/src/main/java/ghidra/app/util/viewer/field/ParallelInstructionFieldFactory.java
@@ -19,7 +19,7 @@ import java.math.BigInteger;
import docking.widgets.fieldpanel.field.*;
import docking.widgets.fieldpanel.support.FieldLocation;
-import ghidra.app.util.HighlightProvider;
+import ghidra.app.util.ListingHighlightProvider;
import ghidra.app.util.viewer.format.FieldFormatModel;
import ghidra.app.util.viewer.proxy.ProxyObj;
import ghidra.framework.options.Options;
@@ -52,7 +52,7 @@ public class ParallelInstructionFieldFactory extends FieldFactory {
* @param displayOptions the Options for display properties.
* @param fieldOptions the Options for field specific properties.
*/
- private ParallelInstructionFieldFactory(FieldFormatModel model, HighlightProvider hsProvider,
+ private ParallelInstructionFieldFactory(FieldFormatModel model, ListingHighlightProvider hsProvider,
Options displayOptions, Options fieldOptions) {
super(FIELD_NAME, model, hsProvider, displayOptions, fieldOptions);
}
@@ -117,7 +117,7 @@ public class ParallelInstructionFieldFactory extends FieldFactory {
}
@Override
- public FieldFactory newInstance(FieldFormatModel formatModel, HighlightProvider hsProvider,
+ public FieldFactory newInstance(FieldFormatModel formatModel, ListingHighlightProvider hsProvider,
ToolOptions toolOptinos, ToolOptions fieldOptions) {
return new ParallelInstructionFieldFactory(formatModel, hsProvider, toolOptinos,
fieldOptions);
diff --git a/Ghidra/Features/Base/src/main/java/ghidra/app/util/viewer/field/PlateFieldFactory.java b/Ghidra/Features/Base/src/main/java/ghidra/app/util/viewer/field/PlateFieldFactory.java
index 5c5e1c68f1..7eae77c9b5 100644
--- a/Ghidra/Features/Base/src/main/java/ghidra/app/util/viewer/field/PlateFieldFactory.java
+++ b/Ghidra/Features/Base/src/main/java/ghidra/app/util/viewer/field/PlateFieldFactory.java
@@ -26,7 +26,7 @@ import docking.widgets.fieldpanel.field.*;
import docking.widgets.fieldpanel.support.*;
import generic.theme.GThemeDefaults.Colors.Palette;
import ghidra.app.util.HelpTopics;
-import ghidra.app.util.HighlightProvider;
+import ghidra.app.util.ListingHighlightProvider;
import ghidra.app.util.viewer.field.ListingColors.CommentColors;
import ghidra.app.util.viewer.format.FieldFormatModel;
import ghidra.app.util.viewer.listingpanel.ListingModel;
@@ -112,7 +112,7 @@ public class PlateFieldFactory extends FieldFactory {
* @param displayOptions the Options for display properties.
* @param fieldOptions the Options for field specific properties.
*/
- private PlateFieldFactory(FieldFormatModel model, HighlightProvider hlProvider,
+ private PlateFieldFactory(FieldFormatModel model, ListingHighlightProvider hlProvider,
Options displayOptions, Options fieldOptions) {
super(FIELD_NAME, model, hlProvider, displayOptions, fieldOptions);
init(fieldOptions);
@@ -161,9 +161,13 @@ public class PlateFieldFactory extends FieldFactory {
return null;
}
+ ListingFieldHighlightFactoryAdapter hlFactory =
+ new ListingFieldHighlightFactoryAdapter(hlProvider);
PlateFieldTextField textField =
- new PlateFieldTextField(elements, this, proxy, startX, width, commentText, isClipped);
- return new PlateListingTextField(proxy, textField);
+ new PlateFieldTextField(elements, this, proxy, startX, width, commentText, isClipped,
+ hlFactory);
+ PlateListingTextField listingField = new PlateListingTextField(proxy, textField, hlFactory);
+ return listingField;
}
private boolean getFormattedFieldElements(CodeUnit cu, List<FieldElement> elements) {
@@ -567,7 +571,8 @@ public class PlateFieldFactory extends FieldFactory {
}
@Override
- public FieldFactory newInstance(FieldFormatModel formatModel, HighlightProvider hsProvider,
+ public FieldFactory newInstance(FieldFormatModel formatModel,
+ ListingHighlightProvider hsProvider,
ToolOptions toolOptions, ToolOptions fieldOptions) {
return new PlateFieldFactory(formatModel, hsProvider, toolOptions, fieldOptions);
}
@@ -718,8 +723,9 @@ public class PlateFieldFactory extends FieldFactory {
class PlateListingTextField extends ListingTextField {
- PlateListingTextField(ProxyObj<?> proxy, PlateFieldTextField field) {
- super(PlateFieldFactory.this, proxy, field);
+ PlateListingTextField(ProxyObj<?> proxy, PlateFieldTextField field,
+ ListingFieldHighlightFactoryAdapter hlFactory) {
+ super(PlateFieldFactory.this, proxy, field, hlFactory);
}
PlateFieldTextField getPlateTextField() {
@@ -734,9 +740,8 @@ public class PlateFieldFactory extends FieldFactory {
PlateFieldTextField(List<FieldElement> textElements, PlateFieldFactory factory,
ProxyObj<?> proxy, int startX, int width, String commentText,
- boolean isCommentClipped) {
- super(textElements, startX, width, Integer.MAX_VALUE,
- new FieldHighlightFactory(hlProvider, factory.getClass(), proxy.getObject()));
+ boolean isCommentClipped, FieldHighlightFactory hlFactory) {
+ super(textElements, startX, width, Integer.MAX_VALUE, hlFactory);
this.commentText = commentText;
this.isCommentClipped = isCommentClipped;
}
diff --git a/Ghidra/Features/Base/src/main/java/ghidra/app/util/viewer/field/PostCommentFieldFactory.java b/Ghidra/Features/Base/src/main/java/ghidra/app/util/viewer/field/PostCommentFieldFactory.java
index 672b99efc3..f414f78533 100644
--- a/Ghidra/Features/Base/src/main/java/ghidra/app/util/viewer/field/PostCommentFieldFactory.java
+++ b/Ghidra/Features/Base/src/main/java/ghidra/app/util/viewer/field/PostCommentFieldFactory.java
@@ -24,7 +24,7 @@ import org.apache.commons.lang3.StringUtils;
import docking.widgets.fieldpanel.field.*;
import docking.widgets.fieldpanel.support.FieldLocation;
import docking.widgets.fieldpanel.support.FieldUtils;
-import ghidra.app.util.HighlightProvider;
+import ghidra.app.util.ListingHighlightProvider;
import ghidra.app.util.viewer.field.ListingColors.CommentColors;
import ghidra.app.util.viewer.format.FieldFormatModel;
import ghidra.app.util.viewer.options.OptionsGui;
@@ -89,7 +89,7 @@ public class PostCommentFieldFactory extends FieldFactory {
* @param displayOptions the Options for display properties.
* @param fieldOptions the Options for field specific properties.
*/
- private PostCommentFieldFactory(FieldFormatModel model, HighlightProvider hlProvider,
+ private PostCommentFieldFactory(FieldFormatModel model, ListingHighlightProvider hlProvider,
Options displayOptions, Options fieldOptions) {
super(FIELD_NAME, model, hlProvider, displayOptions, fieldOptions);
@@ -323,7 +323,7 @@ public class PostCommentFieldFactory extends FieldFactory {
}
@Override
- public FieldFactory newInstance(FieldFormatModel formatModel, HighlightProvider provider,
+ public FieldFactory newInstance(FieldFormatModel formatModel, ListingHighlightProvider provider,
ToolOptions toolOptions, ToolOptions fieldOptions) {
return new PostCommentFieldFactory(formatModel, provider, toolOptions, fieldOptions);
}
diff --git a/Ghidra/Features/Base/src/main/java/ghidra/app/util/viewer/field/PreCommentFieldFactory.java b/Ghidra/Features/Base/src/main/java/ghidra/app/util/viewer/field/PreCommentFieldFactory.java
index e0bde83c4c..6b3de481e8 100644
--- a/Ghidra/Features/Base/src/main/java/ghidra/app/util/viewer/field/PreCommentFieldFactory.java
+++ b/Ghidra/Features/Base/src/main/java/ghidra/app/util/viewer/field/PreCommentFieldFactory.java
@@ -24,7 +24,7 @@ import org.apache.commons.lang3.StringUtils;
import docking.widgets.fieldpanel.field.*;
import docking.widgets.fieldpanel.support.FieldLocation;
import docking.widgets.fieldpanel.support.FieldUtils;
-import ghidra.app.util.HighlightProvider;
+import ghidra.app.util.ListingHighlightProvider;
import ghidra.app.util.viewer.field.ListingColors.CommentColors;
import ghidra.app.util.viewer.format.FieldFormatModel;
import ghidra.app.util.viewer.options.OptionsGui;
@@ -82,7 +82,7 @@ public class PreCommentFieldFactory extends FieldFactory {
* @param displayOptions the Options for display properties.
* @param fieldOptions the Options for field specific properties.
*/
- private PreCommentFieldFactory(FieldFormatModel model, HighlightProvider hlProvider,
+ private PreCommentFieldFactory(FieldFormatModel model, ListingHighlightProvider hlProvider,
Options displayOptions, Options fieldOptions) {
super(FIELD_NAME, model, hlProvider, displayOptions, fieldOptions);
@@ -179,7 +179,7 @@ public class PreCommentFieldFactory extends FieldFactory {
}
@Override
- public FieldFactory newInstance(FieldFormatModel formatModel, HighlightProvider provider,
+ public FieldFactory newInstance(FieldFormatModel formatModel, ListingHighlightProvider provider,
ToolOptions toolOptions, ToolOptions fieldOptions) {
return new PreCommentFieldFactory(formatModel, provider, toolOptions, fieldOptions);
}
diff --git a/Ghidra/Features/Base/src/main/java/ghidra/app/util/viewer/field/RegisterFieldFactory.java b/Ghidra/Features/Base/src/main/java/ghidra/app/util/viewer/field/RegisterFieldFactory.java
index 0a1c3e7bd8..117db23d66 100644
--- a/Ghidra/Features/Base/src/main/java/ghidra/app/util/viewer/field/RegisterFieldFactory.java
+++ b/Ghidra/Features/Base/src/main/java/ghidra/app/util/viewer/field/RegisterFieldFactory.java
@@ -20,7 +20,7 @@ import java.util.*;
import docking.widgets.fieldpanel.field.*;
import docking.widgets.fieldpanel.support.FieldLocation;
-import ghidra.app.util.HighlightProvider;
+import ghidra.app.util.ListingHighlightProvider;
import ghidra.app.util.viewer.format.FieldFormatModel;
import ghidra.app.util.viewer.proxy.ProxyObj;
import ghidra.framework.options.Options;
@@ -52,7 +52,7 @@ public class RegisterFieldFactory extends FieldFactory {
super(FIELD_NAME);
}
- private RegisterFieldFactory(FieldFormatModel model, HighlightProvider highlightProvider,
+ private RegisterFieldFactory(FieldFormatModel model, ListingHighlightProvider highlightProvider,
Options displayOptions, Options fieldOptions) {
super(FIELD_NAME, model, highlightProvider, displayOptions, fieldOptions);
regComp = new RegComparator();
@@ -73,7 +73,7 @@ public class RegisterFieldFactory extends FieldFactory {
@Override
public FieldFactory newInstance(FieldFormatModel formatModel,
- HighlightProvider highlightProvider, ToolOptions toolOptions,
+ ListingHighlightProvider highlightProvider, ToolOptions toolOptions,
ToolOptions fieldOptions) {
return new RegisterFieldFactory(formatModel, highlightProvider, toolOptions, fieldOptions);
}
diff --git a/Ghidra/Features/Base/src/main/java/ghidra/app/util/viewer/field/RegisterTransitionFieldFactory.java b/Ghidra/Features/Base/src/main/java/ghidra/app/util/viewer/field/RegisterTransitionFieldFactory.java
index 663c87346c..b2714290b4 100644
--- a/Ghidra/Features/Base/src/main/java/ghidra/app/util/viewer/field/RegisterTransitionFieldFactory.java
+++ b/Ghidra/Features/Base/src/main/java/ghidra/app/util/viewer/field/RegisterTransitionFieldFactory.java
@@ -22,7 +22,7 @@ import java.util.List;
import docking.widgets.fieldpanel.field.*;
import docking.widgets.fieldpanel.support.FieldLocation;
import ghidra.app.cmd.function.CallDepthChangeInfo;
-import ghidra.app.util.HighlightProvider;
+import ghidra.app.util.ListingHighlightProvider;
import ghidra.app.util.viewer.format.FieldFormatModel;
import ghidra.app.util.viewer.proxy.ProxyObj;
import ghidra.framework.options.Options;
@@ -55,7 +55,7 @@ public class RegisterTransitionFieldFactory extends FieldFactory {
* @param displayOptions the Options for display properties.
* @param fieldOptions the Options for field specific properties.
*/
- private RegisterTransitionFieldFactory(FieldFormatModel model, HighlightProvider hsProvider,
+ private RegisterTransitionFieldFactory(FieldFormatModel model, ListingHighlightProvider hsProvider,
Options displayOptions, Options fieldOptions) {
super(FIELD_NAME, model, hsProvider, displayOptions, fieldOptions);
initOptions(displayOptions, fieldOptions);
@@ -242,7 +242,7 @@ public class RegisterTransitionFieldFactory extends FieldFactory {
}
@Override
- public FieldFactory newInstance(FieldFormatModel fieldFormatModel, HighlightProvider hsProvider,
+ public FieldFactory newInstance(FieldFormatModel fieldFormatModel, ListingHighlightProvider hsProvider,
ToolOptions displayOptions, ToolOptions fieldOptions) {
return new RegisterTransitionFieldFactory(fieldFormatModel, hsProvider, displayOptions,
fieldOptions);
diff --git a/Ghidra/Features/Base/src/main/java/ghidra/app/util/viewer/field/SeparatorFieldFactory.java b/Ghidra/Features/Base/src/main/java/ghidra/app/util/viewer/field/SeparatorFieldFactory.java
index 1823c5e1cd..f190364001 100644
--- a/Ghidra/Features/Base/src/main/java/ghidra/app/util/viewer/field/SeparatorFieldFactory.java
+++ b/Ghidra/Features/Base/src/main/java/ghidra/app/util/viewer/field/SeparatorFieldFactory.java
@@ -19,7 +19,7 @@ import java.math.BigInteger;
import docking.widgets.fieldpanel.field.*;
import docking.widgets.fieldpanel.support.FieldLocation;
-import ghidra.app.util.HighlightProvider;
+import ghidra.app.util.ListingHighlightProvider;
import ghidra.app.util.viewer.format.FieldFormatModel;
import ghidra.app.util.viewer.listingpanel.ListingModel;
import ghidra.app.util.viewer.proxy.ProxyObj;
@@ -52,7 +52,7 @@ public class SeparatorFieldFactory extends FieldFactory {
* @param displayOptions the Options for display properties.
* @param fieldOptions the Options for field specific properties.
*/
- private SeparatorFieldFactory(FieldFormatModel model, HighlightProvider hlProvider,
+ private SeparatorFieldFactory(FieldFormatModel model, ListingHighlightProvider hlProvider,
Options displayOptions, Options fieldOptions) {
super(FIELD_NAME, model, hlProvider, displayOptions, fieldOptions);
}
@@ -115,7 +115,7 @@ public class SeparatorFieldFactory extends FieldFactory {
}
@Override
- public FieldFactory newInstance(FieldFormatModel formatModel, HighlightProvider provider,
+ public FieldFactory newInstance(FieldFormatModel formatModel, ListingHighlightProvider provider,
ToolOptions displayOptions, ToolOptions fieldOptions) {
return new SeparatorFieldFactory(formatModel, provider, displayOptions, fieldOptions);
}
diff --git a/Ghidra/Features/Base/src/main/java/ghidra/app/util/viewer/field/SpaceFieldFactory.java b/Ghidra/Features/Base/src/main/java/ghidra/app/util/viewer/field/SpaceFieldFactory.java
index 76cffda75f..039103994b 100644
--- a/Ghidra/Features/Base/src/main/java/ghidra/app/util/viewer/field/SpaceFieldFactory.java
+++ b/Ghidra/Features/Base/src/main/java/ghidra/app/util/viewer/field/SpaceFieldFactory.java
@@ -20,7 +20,7 @@ import java.math.BigInteger;
import docking.widgets.fieldpanel.field.*;
import docking.widgets.fieldpanel.support.FieldLocation;
import generic.theme.GThemeDefaults.Colors;
-import ghidra.app.util.HighlightProvider;
+import ghidra.app.util.ListingHighlightProvider;
import ghidra.app.util.viewer.format.FieldFormatModel;
import ghidra.app.util.viewer.proxy.ProxyObj;
import ghidra.framework.options.Options;
@@ -51,7 +51,7 @@ public class SpaceFieldFactory extends FieldFactory {
* @param displayOptions the Options for display properties.
* @param fieldOptions the Options for field specific properties.
*/
- private SpaceFieldFactory(FieldFormatModel model, HighlightProvider hlProvider,
+ private SpaceFieldFactory(FieldFormatModel model, ListingHighlightProvider hlProvider,
Options displayOptions, Options fieldOptions) {
super(FIELD_NAME, model, hlProvider, displayOptions, fieldOptions);
@@ -146,10 +146,10 @@ public class SpaceFieldFactory extends FieldFactory {
}
/**
- * @see ghidra.app.util.viewer.field.FieldFactory#newInstance(ghidra.app.util.viewer.format.FieldFormatModel, ghidra.app.util.HighlightProvider, ghidra.framework.options.ToolOptions, ghidra.framework.options.ToolOptions)
+ * @see ghidra.app.util.viewer.field.FieldFactory#newInstance(ghidra.app.util.viewer.format.FieldFormatModel, ghidra.app.util.ListingHighlightProvider, ghidra.framework.options.ToolOptions, ghidra.framework.options.ToolOptions)
*/
@Override
- public FieldFactory newInstance(FieldFormatModel formatModel, HighlightProvider provider,
+ public FieldFactory newInstance(FieldFormatModel formatModel, ListingHighlightProvider provider,
ToolOptions displayOptions, ToolOptions fieldOptions) {
return new SpaceFieldFactory(formatModel, provider, displayOptions, fieldOptions);
}
diff --git a/Ghidra/Features/Base/src/main/java/ghidra/app/util/viewer/field/SpacerFieldFactory.java b/Ghidra/Features/Base/src/main/java/ghidra/app/util/viewer/field/SpacerFieldFactory.java
index 1d2d149542..5327a79265 100644
--- a/Ghidra/Features/Base/src/main/java/ghidra/app/util/viewer/field/SpacerFieldFactory.java
+++ b/Ghidra/Features/Base/src/main/java/ghidra/app/util/viewer/field/SpacerFieldFactory.java
@@ -20,7 +20,7 @@ import java.math.BigInteger;
import docking.widgets.OptionDialog;
import docking.widgets.fieldpanel.field.*;
import docking.widgets.fieldpanel.support.FieldLocation;
-import ghidra.app.util.HighlightProvider;
+import ghidra.app.util.ListingHighlightProvider;
import ghidra.app.util.viewer.format.FieldFormatModel;
import ghidra.app.util.viewer.proxy.ProxyObj;
import ghidra.framework.options.Options;
@@ -52,7 +52,7 @@ public class SpacerFieldFactory extends FieldFactory {
* @param displayOptions the Options for display properties.
* @param fieldOptions the Options for field specific properties.
*/
- private SpacerFieldFactory(FieldFormatModel model, HighlightProvider hsProvider,
+ private SpacerFieldFactory(FieldFormatModel model, ListingHighlightProvider hsProvider,
Options displayOptions, Options fieldOptions) {
super(FIELD_NAME, model, hsProvider, displayOptions, fieldOptions);
}
@@ -65,7 +65,7 @@ public class SpacerFieldFactory extends FieldFactory {
* @param displayOptions the Options for display properties.
* @param fieldOptions the Options for field specific properties.
*/
- public SpacerFieldFactory(String text, FieldFormatModel model, HighlightProvider hsProvider,
+ public SpacerFieldFactory(String text, FieldFormatModel model, ListingHighlightProvider hsProvider,
Options displayOptions, Options fieldOptions) {
super(FIELD_NAME, model, hsProvider, displayOptions, fieldOptions);
@@ -179,7 +179,7 @@ public class SpacerFieldFactory extends FieldFactory {
}
@Override
- public FieldFactory newInstance(FieldFormatModel formatModel, HighlightProvider provider,
+ public FieldFactory newInstance(FieldFormatModel formatModel, ListingHighlightProvider provider,
ToolOptions options, ToolOptions fieldOptions) {
return new SpacerFieldFactory(formatModel, provider, options, fieldOptions);
}
diff --git a/Ghidra/Features/Base/src/main/java/ghidra/app/util/viewer/field/SubDataFieldFactory.java b/Ghidra/Features/Base/src/main/java/ghidra/app/util/viewer/field/SubDataFieldFactory.java
index 5fd5703ddb..8b8f9551ac 100644
--- a/Ghidra/Features/Base/src/main/java/ghidra/app/util/viewer/field/SubDataFieldFactory.java
+++ b/Ghidra/Features/Base/src/main/java/ghidra/app/util/viewer/field/SubDataFieldFactory.java
@@ -18,7 +18,7 @@ package ghidra.app.util.viewer.field;
import java.math.BigInteger;
import docking.widgets.fieldpanel.support.FieldLocation;
-import ghidra.app.util.HighlightProvider;
+import ghidra.app.util.ListingHighlightProvider;
import ghidra.app.util.viewer.format.FieldFormatModel;
import ghidra.app.util.viewer.proxy.ProxyObj;
import ghidra.framework.options.ToolOptions;
@@ -48,7 +48,7 @@ public class SubDataFieldFactory extends OperandFieldFactory {
}
private SubDataFieldFactory(String name, int[] componentPath, FieldFormatModel model,
- HighlightProvider hlProvider, ToolOptions displayOptions, ToolOptions fieldOptions) {
+ ListingHighlightProvider hlProvider, ToolOptions displayOptions, ToolOptions fieldOptions) {
super(model, hlProvider, displayOptions, fieldOptions);
this.name = name;
this.componentPath = componentPath;
@@ -125,7 +125,7 @@ public class SubDataFieldFactory extends OperandFieldFactory {
}
@Override
- public FieldFactory newInstance(FieldFormatModel formatModel, HighlightProvider provider,
+ public FieldFactory newInstance(FieldFormatModel formatModel, ListingHighlightProvider provider,
ToolOptions options, ToolOptions fieldOptions) {
return new SubDataFieldFactory(name, componentPath, formatModel, provider, options,
fieldOptions);
diff --git a/Ghidra/Features/Base/src/main/java/ghidra/app/util/viewer/field/ThunkedFunctionFieldFactory.java b/Ghidra/Features/Base/src/main/java/ghidra/app/util/viewer/field/ThunkedFunctionFieldFactory.java
index 47b2694eb9..1ee0583422 100644
--- a/Ghidra/Features/Base/src/main/java/ghidra/app/util/viewer/field/ThunkedFunctionFieldFactory.java
+++ b/Ghidra/Features/Base/src/main/java/ghidra/app/util/viewer/field/ThunkedFunctionFieldFactory.java
@@ -21,7 +21,7 @@ import java.util.ArrayList;
import docking.widgets.fieldpanel.field.*;
import docking.widgets.fieldpanel.support.FieldLocation;
-import ghidra.app.util.HighlightProvider;
+import ghidra.app.util.ListingHighlightProvider;
import ghidra.app.util.viewer.format.FieldFormatModel;
import ghidra.app.util.viewer.proxy.FunctionProxy;
import ghidra.app.util.viewer.proxy.ProxyObj;
@@ -54,7 +54,7 @@ public class ThunkedFunctionFieldFactory extends FieldFactory {
* @param displayOptions the Options for display properties.
* @param fieldOptions the Options for field specific properties.
*/
- public ThunkedFunctionFieldFactory(FieldFormatModel model, HighlightProvider hlProvider,
+ public ThunkedFunctionFieldFactory(FieldFormatModel model, ListingHighlightProvider hlProvider,
ToolOptions displayOptions, ToolOptions fieldOptions) {
super(FIELD_NAME, model, hlProvider, displayOptions, fieldOptions);
}
@@ -139,7 +139,7 @@ public class ThunkedFunctionFieldFactory extends FieldFactory {
}
@Override
- public FieldFactory newInstance(FieldFormatModel formatModel, HighlightProvider provider,
+ public FieldFactory newInstance(FieldFormatModel formatModel, ListingHighlightProvider provider,
ToolOptions pDisplayOptions, ToolOptions fieldOptions) {
return new ThunkedFunctionFieldFactory(formatModel, provider, pDisplayOptions,
fieldOptions);
diff --git a/Ghidra/Features/Base/src/main/java/ghidra/app/util/viewer/field/VariableCommentFieldFactory.java b/Ghidra/Features/Base/src/main/java/ghidra/app/util/viewer/field/VariableCommentFieldFactory.java
index 8b48c21920..d523cd4ad7 100644
--- a/Ghidra/Features/Base/src/main/java/ghidra/app/util/viewer/field/VariableCommentFieldFactory.java
+++ b/Ghidra/Features/Base/src/main/java/ghidra/app/util/viewer/field/VariableCommentFieldFactory.java
@@ -19,7 +19,7 @@ import java.math.BigInteger;
import docking.widgets.fieldpanel.field.*;
import docking.widgets.fieldpanel.support.FieldLocation;
-import ghidra.app.util.HighlightProvider;
+import ghidra.app.util.ListingHighlightProvider;
import ghidra.app.util.viewer.format.FieldFormatModel;
import ghidra.app.util.viewer.proxy.ProxyObj;
import ghidra.app.util.viewer.proxy.VariableProxy;
@@ -50,7 +50,7 @@ public class VariableCommentFieldFactory extends AbstractVariableFieldFactory {
* @param displayOptions the Options for display properties.
* @param fieldOptions the Options for field specific properties.
*/
- private VariableCommentFieldFactory(FieldFormatModel model, HighlightProvider hlProvider,
+ private VariableCommentFieldFactory(FieldFormatModel model, ListingHighlightProvider hlProvider,
Options displayOptions, Options fieldOptions) {
super(FIELD_NAME, model, hlProvider, displayOptions, fieldOptions);
}
@@ -175,7 +175,7 @@ public class VariableCommentFieldFactory extends AbstractVariableFieldFactory {
}
@Override
- public FieldFactory newInstance(FieldFormatModel formatModel, HighlightProvider provider,
+ public FieldFactory newInstance(FieldFormatModel formatModel, ListingHighlightProvider provider,
ToolOptions displayOptions, ToolOptions fieldOptions) {
return new VariableCommentFieldFactory(formatModel, provider, displayOptions, fieldOptions);
}
diff --git a/Ghidra/Features/Base/src/main/java/ghidra/app/util/viewer/field/VariableLocFieldFactory.java b/Ghidra/Features/Base/src/main/java/ghidra/app/util/viewer/field/VariableLocFieldFactory.java
index 41d054c1e7..0984235843 100644
--- a/Ghidra/Features/Base/src/main/java/ghidra/app/util/viewer/field/VariableLocFieldFactory.java
+++ b/Ghidra/Features/Base/src/main/java/ghidra/app/util/viewer/field/VariableLocFieldFactory.java
@@ -24,7 +24,7 @@ import docking.widgets.fieldpanel.field.*;
import docking.widgets.fieldpanel.support.FieldLocation;
import generic.theme.GIcon;
import generic.theme.GThemeDefaults.Colors.Messages;
-import ghidra.app.util.HighlightProvider;
+import ghidra.app.util.ListingHighlightProvider;
import ghidra.app.util.viewer.format.FieldFormatModel;
import ghidra.app.util.viewer.proxy.ProxyObj;
import ghidra.app.util.viewer.proxy.VariableProxy;
@@ -59,7 +59,7 @@ public class VariableLocFieldFactory extends AbstractVariableFieldFactory {
* @param displayOptions the Options for display properties.
* @param fieldOptions the Options for field specific properties.
*/
- private VariableLocFieldFactory(FieldFormatModel model, HighlightProvider hlProvider,
+ private VariableLocFieldFactory(FieldFormatModel model, ListingHighlightProvider hlProvider,
Options displayOptions, Options fieldOptions) {
super(FIELD_NAME, model, hlProvider, displayOptions, fieldOptions);
@@ -145,7 +145,7 @@ public class VariableLocFieldFactory extends AbstractVariableFieldFactory {
}
@Override
- public FieldFactory newInstance(FieldFormatModel formatModel, HighlightProvider provider,
+ public FieldFactory newInstance(FieldFormatModel formatModel, ListingHighlightProvider provider,
ToolOptions toolOptions, ToolOptions fieldOptions) {
return new VariableLocFieldFactory(formatModel, provider, toolOptions, fieldOptions);
}
diff --git a/Ghidra/Features/Base/src/main/java/ghidra/app/util/viewer/field/VariableNameFieldFactory.java b/Ghidra/Features/Base/src/main/java/ghidra/app/util/viewer/field/VariableNameFieldFactory.java
index 29fc07f729..83325c27ab 100644
--- a/Ghidra/Features/Base/src/main/java/ghidra/app/util/viewer/field/VariableNameFieldFactory.java
+++ b/Ghidra/Features/Base/src/main/java/ghidra/app/util/viewer/field/VariableNameFieldFactory.java
@@ -19,7 +19,7 @@ import java.math.BigInteger;
import docking.widgets.fieldpanel.field.*;
import docking.widgets.fieldpanel.support.FieldLocation;
-import ghidra.app.util.HighlightProvider;
+import ghidra.app.util.ListingHighlightProvider;
import ghidra.app.util.viewer.format.FieldFormatModel;
import ghidra.app.util.viewer.proxy.ProxyObj;
import ghidra.app.util.viewer.proxy.VariableProxy;
@@ -49,7 +49,7 @@ public class VariableNameFieldFactory extends AbstractVariableFieldFactory {
* @param displayOptions the Options for display properties.
* @param fieldOptions the Options for field specific properties.
*/
- private VariableNameFieldFactory(FieldFormatModel model, HighlightProvider hlProvider,
+ private VariableNameFieldFactory(FieldFormatModel model, ListingHighlightProvider hlProvider,
Options displayOptions, Options fieldOptions) {
super(FIELD_NAME, model, hlProvider, displayOptions, fieldOptions);
}
@@ -123,7 +123,7 @@ public class VariableNameFieldFactory extends AbstractVariableFieldFactory {
}
@Override
- public FieldFactory newInstance(FieldFormatModel formatModel, HighlightProvider provider,
+ public FieldFactory newInstance(FieldFormatModel formatModel, ListingHighlightProvider provider,
ToolOptions displayOptions, ToolOptions fieldOptions) {
return new VariableNameFieldFactory(formatModel, provider, displayOptions, fieldOptions);
}
diff --git a/Ghidra/Features/Base/src/main/java/ghidra/app/util/viewer/field/VariableTypeFieldFactory.java b/Ghidra/Features/Base/src/main/java/ghidra/app/util/viewer/field/VariableTypeFieldFactory.java
index 97962c8ded..b9b1be81d8 100644
--- a/Ghidra/Features/Base/src/main/java/ghidra/app/util/viewer/field/VariableTypeFieldFactory.java
+++ b/Ghidra/Features/Base/src/main/java/ghidra/app/util/viewer/field/VariableTypeFieldFactory.java
@@ -19,7 +19,7 @@ import java.math.BigInteger;
import docking.widgets.fieldpanel.field.*;
import docking.widgets.fieldpanel.support.FieldLocation;
-import ghidra.app.util.HighlightProvider;
+import ghidra.app.util.ListingHighlightProvider;
import ghidra.app.util.viewer.format.FieldFormatModel;
import ghidra.app.util.viewer.proxy.ProxyObj;
import ghidra.app.util.viewer.proxy.VariableProxy;
@@ -50,7 +50,7 @@ public class VariableTypeFieldFactory extends AbstractVariableFieldFactory {
* @param displayOptions the Options for display properties.
* @param fieldOptions the Options for field specific properties.
*/
- private VariableTypeFieldFactory(FieldFormatModel model, HighlightProvider hlProvider,
+ private VariableTypeFieldFactory(FieldFormatModel model, ListingHighlightProvider hlProvider,
ToolOptions displayOptions, ToolOptions fieldOptions) {
super(FIELD_NAME, model, hlProvider, displayOptions, fieldOptions);
}
@@ -139,7 +139,7 @@ public class VariableTypeFieldFactory extends AbstractVariableFieldFactory {
}
@Override
- public FieldFactory newInstance(FieldFormatModel formatModel, HighlightProvider provider,
+ public FieldFactory newInstance(FieldFormatModel formatModel, ListingHighlightProvider provider,
ToolOptions displayOptions, ToolOptions fieldOptions) {
return new VariableTypeFieldFactory(formatModel, provider, displayOptions, fieldOptions);
}
diff --git a/Ghidra/Features/Base/src/main/java/ghidra/app/util/viewer/field/VariableXRefFieldFactory.java b/Ghidra/Features/Base/src/main/java/ghidra/app/util/viewer/field/VariableXRefFieldFactory.java
index d2e7827800..202f13fb38 100644
--- a/Ghidra/Features/Base/src/main/java/ghidra/app/util/viewer/field/VariableXRefFieldFactory.java
+++ b/Ghidra/Features/Base/src/main/java/ghidra/app/util/viewer/field/VariableXRefFieldFactory.java
@@ -22,7 +22,7 @@ import docking.widgets.fieldpanel.field.*;
import docking.widgets.fieldpanel.support.FieldLocation;
import docking.widgets.fieldpanel.support.RowColLocation;
import generic.theme.GThemeDefaults.Colors;
-import ghidra.app.util.HighlightProvider;
+import ghidra.app.util.ListingHighlightProvider;
import ghidra.app.util.XReferenceUtils;
import ghidra.app.util.viewer.field.ListingColors.XrefColors;
import ghidra.app.util.viewer.format.FieldFormatModel;
@@ -62,13 +62,13 @@ public class VariableXRefFieldFactory extends XRefFieldFactory {
* @param displayOptions the Options for display properties.
* @param fieldOptions the Options for field specific properties.
*/
- public VariableXRefFieldFactory(FieldFormatModel model, HighlightProvider hlProvider,
+ public VariableXRefFieldFactory(FieldFormatModel model, ListingHighlightProvider hlProvider,
Options displayOptions, ToolOptions fieldOptions) {
this(FIELD_NAME, model, hlProvider, displayOptions, fieldOptions);
}
protected VariableXRefFieldFactory(String name, FieldFormatModel model,
- HighlightProvider hlProvider, Options displayOptions, ToolOptions fieldOptions) {
+ ListingHighlightProvider hlProvider, Options displayOptions, ToolOptions fieldOptions) {
super(name, model, hlProvider, displayOptions, fieldOptions);
}
@@ -229,7 +229,7 @@ public class VariableXRefFieldFactory extends XRefFieldFactory {
}
@Override
- public FieldFactory newInstance(FieldFormatModel formatModel, HighlightProvider provider,
+ public FieldFactory newInstance(FieldFormatModel formatModel, ListingHighlightProvider provider,
ToolOptions options, ToolOptions fieldOptions) {
return new VariableXRefFieldFactory(formatModel, provider, options, fieldOptions);
}
diff --git a/Ghidra/Features/Base/src/main/java/ghidra/app/util/viewer/field/VariableXRefHeaderFieldFactory.java b/Ghidra/Features/Base/src/main/java/ghidra/app/util/viewer/field/VariableXRefHeaderFieldFactory.java
index 41593bd61d..b8506a5373 100644
--- a/Ghidra/Features/Base/src/main/java/ghidra/app/util/viewer/field/VariableXRefHeaderFieldFactory.java
+++ b/Ghidra/Features/Base/src/main/java/ghidra/app/util/viewer/field/VariableXRefHeaderFieldFactory.java
@@ -19,7 +19,7 @@ import java.math.BigInteger;
import docking.widgets.fieldpanel.field.*;
import docking.widgets.fieldpanel.support.FieldLocation;
-import ghidra.app.util.HighlightProvider;
+import ghidra.app.util.ListingHighlightProvider;
import ghidra.app.util.viewer.field.ListingColors.XrefColors;
import ghidra.app.util.viewer.format.FieldFormatModel;
import ghidra.app.util.viewer.proxy.ProxyObj;
@@ -55,7 +55,7 @@ public class VariableXRefHeaderFieldFactory extends VariableXRefFieldFactory {
* @param displayOptions the Options for display properties.
* @param fieldOptions the Options for field specific properties.
*/
- public VariableXRefHeaderFieldFactory(FieldFormatModel model, HighlightProvider hlProvider,
+ public VariableXRefHeaderFieldFactory(FieldFormatModel model, ListingHighlightProvider hlProvider,
Options displayOptions, ToolOptions fieldOptions) {
super(FIELD_NAME, model, hlProvider, displayOptions, fieldOptions);
colorOptionName = "XRef Color";
@@ -176,7 +176,7 @@ public class VariableXRefHeaderFieldFactory extends VariableXRefFieldFactory {
}
@Override
- public FieldFactory newInstance(FieldFormatModel formatModel, HighlightProvider provider,
+ public FieldFactory newInstance(FieldFormatModel formatModel, ListingHighlightProvider provider,
ToolOptions displayOptions, ToolOptions fieldOptions) {
return new VariableXRefHeaderFieldFactory(formatModel, provider, displayOptions,
fieldOptions);
diff --git a/Ghidra/Features/Base/src/main/java/ghidra/app/util/viewer/field/XRefFieldFactory.java b/Ghidra/Features/Base/src/main/java/ghidra/app/util/viewer/field/XRefFieldFactory.java
index 7d5164b752..0da5697ab9 100644
--- a/Ghidra/Features/Base/src/main/java/ghidra/app/util/viewer/field/XRefFieldFactory.java
+++ b/Ghidra/Features/Base/src/main/java/ghidra/app/util/viewer/field/XRefFieldFactory.java
@@ -28,7 +28,7 @@ import javax.swing.event.ChangeListener;
import docking.widgets.fieldpanel.field.*;
import docking.widgets.fieldpanel.support.*;
import generic.theme.GThemeDefaults.Colors;
-import ghidra.app.util.HighlightProvider;
+import ghidra.app.util.ListingHighlightProvider;
import ghidra.app.util.XReferenceUtils;
import ghidra.app.util.viewer.field.ListingColors.XrefColors;
import ghidra.app.util.viewer.format.FieldFormatModel;
@@ -106,7 +106,7 @@ public class XRefFieldFactory extends FieldFactory {
* @param displayOptions the Options for display properties.
* @param fieldOptions the Options for field specific properties.
*/
- public XRefFieldFactory(FieldFormatModel model, HighlightProvider hlProvider,
+ public XRefFieldFactory(FieldFormatModel model, ListingHighlightProvider hlProvider,
Options displayOptions, ToolOptions fieldOptions) {
this(FIELD_NAME, model, hlProvider, displayOptions, fieldOptions);
@@ -121,7 +121,8 @@ public class XRefFieldFactory extends FieldFactory {
* @param displayOptions the Options for display properties.
* @param fieldOptions the Options for field specific properties.
*/
- protected XRefFieldFactory(String name, FieldFormatModel model, HighlightProvider hlProvider,
+ protected XRefFieldFactory(String name, FieldFormatModel model,
+ ListingHighlightProvider hlProvider,
Options displayOptions, ToolOptions fieldOptions) {
super(name, model, hlProvider, displayOptions, fieldOptions);
@@ -322,8 +323,8 @@ public class XRefFieldFactory extends FieldFactory {
//
Set<Reference> offcutSet = new HashSet<>(offcuts);
Predicate<Reference> isOffcut = r -> offcutSet.contains(r);
- HighlightFactory hlFactory =
- new FieldHighlightFactory(hlProvider, getClass(), proxy.getObject());
+ ListingFieldHighlightFactoryAdapter hlFactory =
+ new ListingFieldHighlightFactoryAdapter(hlProvider);
Function currentFunction = functionManager.getFunctionContaining(cu.getMinAddress());
List<TextField> functionRows = createXrefRowsByFunction(program, currentFunction,
xrefsByFunction, isOffcut, varWidth, hlFactory);
@@ -372,12 +373,14 @@ public class XRefFieldFactory extends FieldFactory {
CompositeVerticalLayoutTextField compositefield =
new CompositeVerticalLayoutTextField(allFields, newStartX, width, maxXRefs, hlFactory);
- return new XrefListingField(this, proxy, compositefield);
+ XrefListingField listingField =
+ new XrefListingField(this, proxy, compositefield, hlFactory);
+ return listingField;
}
private List<TextField> createXrefRowsByFunction(Program program, Function currentFunction,
TreeMap<Function, List<Reference>> xrefsByFunction, Predicate<Reference> isOffcut,
- int varWidth, HighlightFactory hlFactory) {
+ int varWidth, FieldHighlightFactory hlFactory) {
FontMetrics metrics = getMetrics();
AttributedString delimiter = new AttributedString(delim, Colors.FOREGROUND, metrics);
@@ -436,7 +439,7 @@ public class XRefFieldFactory extends FieldFactory {
private TextField createWrappingXrefRow(Program program, int startRow, List<Reference> xrefs,
Function currentFunction, Predicate<Reference> isOffcut, int availableLines,
- HighlightFactory hlFactory) {
+ FieldHighlightFactory hlFactory) {
FontMetrics metrics = getMetrics();
AttributedString delimiter = new AttributedString(delim, Colors.FOREGROUND, metrics);
@@ -531,10 +534,11 @@ public class XRefFieldFactory extends FieldFactory {
// assumption: the given array has been limited to the maxXref size already
int n = list.size();
- HighlightFactory hlFactory =
- new FieldHighlightFactory(hlProvider, getClass(), proxy.getObject());
+ ListingFieldHighlightFactoryAdapter hlFactory =
+ new ListingFieldHighlightFactoryAdapter(hlProvider);
TextField field = new FlowLayoutTextField(list, startX + varWidth, width, n, hlFactory);
- return new XrefListingField(this, proxy, field);
+ XrefListingField listingField = new XrefListingField(this, proxy, field, hlFactory);
+ return listingField;
}
private List<FieldElement> toFieldElements(List<XrefFieldElement> list, boolean showEllipses) {
@@ -816,7 +820,8 @@ public class XRefFieldFactory extends FieldFactory {
}
@Override
- public FieldFactory newInstance(FieldFormatModel formatModel, HighlightProvider provider,
+ public FieldFactory newInstance(FieldFormatModel formatModel,
+ ListingHighlightProvider provider,
ToolOptions toolOptions, ToolOptions fieldOptions) {
return new XRefFieldFactory(formatModel, provider, toolOptions, fieldOptions);
}
@@ -887,8 +892,9 @@ public class XRefFieldFactory extends FieldFactory {
private class XrefListingField extends ListingTextField {
- XrefListingField(XRefFieldFactory factory, ProxyObj<?> proxy, TextField field) {
- super(factory, proxy, field);
+ XrefListingField(XRefFieldFactory factory, ProxyObj<?> proxy, TextField field,
+ ListingFieldHighlightFactoryAdapter hlFactory) {
+ super(factory, proxy, field, hlFactory);
}
}
diff --git a/Ghidra/Features/Base/src/main/java/ghidra/app/util/viewer/field/XRefHeaderFieldFactory.java b/Ghidra/Features/Base/src/main/java/ghidra/app/util/viewer/field/XRefHeaderFieldFactory.java
index f52c673993..cde7804861 100644
--- a/Ghidra/Features/Base/src/main/java/ghidra/app/util/viewer/field/XRefHeaderFieldFactory.java
+++ b/Ghidra/Features/Base/src/main/java/ghidra/app/util/viewer/field/XRefHeaderFieldFactory.java
@@ -20,7 +20,7 @@ import java.util.List;
import docking.widgets.fieldpanel.field.*;
import docking.widgets.fieldpanel.support.FieldLocation;
-import ghidra.app.util.HighlightProvider;
+import ghidra.app.util.ListingHighlightProvider;
import ghidra.app.util.XReferenceUtils;
import ghidra.app.util.viewer.field.ListingColors.XrefColors;
import ghidra.app.util.viewer.format.FieldFormatModel;
@@ -50,7 +50,7 @@ public class XRefHeaderFieldFactory extends XRefFieldFactory {
* @param displayOptions the Options for display properties.
* @param fieldOptions the Options for field specific properties.
*/
- public XRefHeaderFieldFactory(FieldFormatModel model, HighlightProvider hlProvider,
+ public XRefHeaderFieldFactory(FieldFormatModel model, ListingHighlightProvider hlProvider,
Options displayOptions, ToolOptions fieldOptions) {
super(XREF_FIELD_NAME, model, hlProvider, displayOptions, fieldOptions);
}
@@ -116,7 +116,7 @@ public class XRefHeaderFieldFactory extends XRefFieldFactory {
}
@Override
- public FieldFactory newInstance(FieldFormatModel formatModel, HighlightProvider provider,
+ public FieldFactory newInstance(FieldFormatModel formatModel, ListingHighlightProvider provider,
ToolOptions options, ToolOptions fieldOptions) {
return new XRefHeaderFieldFactory(formatModel, provider, options, fieldOptions);
}
diff --git a/Ghidra/Features/Base/src/main/java/ghidra/app/util/viewer/format/FieldFormatModel.java b/Ghidra/Features/Base/src/main/java/ghidra/app/util/viewer/format/FieldFormatModel.java
index f80f309a2a..fef9b401ac 100644
--- a/Ghidra/Features/Base/src/main/java/ghidra/app/util/viewer/format/FieldFormatModel.java
+++ b/Ghidra/Features/Base/src/main/java/ghidra/app/util/viewer/format/FieldFormatModel.java
@@ -21,7 +21,7 @@ import org.jdom.Element;
import docking.widgets.fieldpanel.field.Field;
import docking.widgets.fieldpanel.support.RowLayout;
-import ghidra.app.util.HighlightProvider;
+import ghidra.app.util.ListingHighlightProvider;
import ghidra.app.util.viewer.field.*;
import ghidra.app.util.viewer.proxy.ProxyObj;
import ghidra.framework.options.Options;
@@ -151,7 +151,7 @@ public class FieldFormatModel {
* @param colIndex the position in the row for the new field.
*/
public void addFactory(FieldFactory factory, int rowIndex, int colIndex) {
- HighlightProvider hsProvider = formatMgr.getFormatHighlightProvider();
+ ListingHighlightProvider hsProvider = formatMgr.getFormatHighlightProvider();
ToolOptions displayOptions = formatMgr.getDisplayOptions();
ToolOptions fieldOptions = formatMgr.getFieldOptions();
FieldFactory ff = factory.newInstance(this, hsProvider, displayOptions, fieldOptions);
diff --git a/Ghidra/Features/Base/src/main/java/ghidra/app/util/viewer/format/FormatManager.java b/Ghidra/Features/Base/src/main/java/ghidra/app/util/viewer/format/FormatManager.java
index ec5757367d..33c8111386 100644
--- a/Ghidra/Features/Base/src/main/java/ghidra/app/util/viewer/format/FormatManager.java
+++ b/Ghidra/Features/Base/src/main/java/ghidra/app/util/viewer/format/FormatManager.java
@@ -22,7 +22,7 @@ import java.util.concurrent.CopyOnWriteArrayList;
import org.jdom.Element;
import docking.widgets.fieldpanel.support.Highlight;
-import ghidra.app.util.HighlightProvider;
+import ghidra.app.util.ListingHighlightProvider;
import ghidra.app.util.template.TemplateSimplifier;
import ghidra.app.util.viewer.field.*;
import ghidra.framework.options.*;
@@ -824,10 +824,10 @@ public class FormatManager implements OptionsChangeListener {
*
* @param provider
* the provider to use.
- * @see #removeHighlightProvider(HighlightProvider)
+ * @see #removeHighlightProvider(ListingHighlightProvider)
* @see #getHighlightProviders()
*/
- public void addHighlightProvider(HighlightProvider provider) {
+ public void addHighlightProvider(ListingHighlightProvider provider) {
if (provider instanceof MultipleHighlighterProvider) {
throw new AssertException("Cannot set FormatManager's internal highlight provider " +
"on another FormatManager!");
@@ -840,27 +840,27 @@ public class FormatManager implements OptionsChangeListener {
*
* @param provider
* the provider to remove.
- * @see #addHighlightProvider(HighlightProvider)
+ * @see #addHighlightProvider(ListingHighlightProvider)
*/
- public void removeHighlightProvider(HighlightProvider provider) {
+ public void removeHighlightProvider(ListingHighlightProvider provider) {
highlightProvider.removeHighlightProvider(provider);
}
/**
- * Gets all {@link HighlightProvider}s installed on this FormatManager via the
- * {@link #addHighlightProvider(HighlightProvider)}.
+ * Gets all {@link ListingHighlightProvider}s installed on this FormatManager via the
+ * {@link #addHighlightProvider(ListingHighlightProvider)}.
*
- * @return all {@link HighlightProvider}s installed on this FormatManager.
+ * @return all {@link ListingHighlightProvider}s installed on this FormatManager.
*/
- public List<HighlightProvider> getHighlightProviders() {
+ public List<ListingHighlightProvider> getHighlightProviders() {
return highlightProvider.getHighlightProviders();
}
/**
- * Returns the {@link HighlightProvider} that should be used when creating {@link FieldFactory}
+ * Returns the {@link ListingHighlightProvider} that should be used when creating {@link FieldFactory}
* objects.
*/
- public HighlightProvider getFormatHighlightProvider() {
+ public ListingHighlightProvider getFormatHighlightProvider() {
return highlightProvider;
}
@@ -921,13 +921,13 @@ public class FormatManager implements OptionsChangeListener {
// Inner Classes
//==================================================================================================
- private class MultipleHighlighterProvider implements HighlightProvider {
+ private class MultipleHighlighterProvider implements ListingHighlightProvider {
- private List<HighlightProvider> highlightProviders = new CopyOnWriteArrayList<>();
+ private List<ListingHighlightProvider> highlightProviders =
+ new CopyOnWriteArrayList<>();
@Override
- public Highlight[] getHighlights(String text, Object obj,
- Class<? extends FieldFactory> fieldFactoryClass, int cursorTextOffset) {
+ public Highlight[] createHighlights(String text, ListingField field, int cursorTextOffset) {
//
// Gather and use all other registered providers.
@@ -935,13 +935,13 @@ public class FormatManager implements OptionsChangeListener {
// Note: we loop backwards here as a hacky method to make sure that the middle-mouse
// highlighter runs last and is thus painted above other highlights. This
// works because the middle-mouse highlighter is installed before any other
- // highlighters.
+ // highlighters.
List<Highlight> list = new ArrayList<>();
int size = highlightProviders.size();
for (int i = size - 1; i >= 0; i--) {
- HighlightProvider provider = highlightProviders.get(i);
+ ListingHighlightProvider provider = highlightProviders.get(i);
Highlight[] highlights =
- provider.getHighlights(text, obj, fieldFactoryClass, cursorTextOffset);
+ provider.createHighlights(text, field, cursorTextOffset);
for (Highlight highlight : highlights) {
list.add(highlight);
}
@@ -950,17 +950,17 @@ public class FormatManager implements OptionsChangeListener {
return list.toArray(new Highlight[list.size()]);
}
- List<HighlightProvider> getHighlightProviders() {
+ List<ListingHighlightProvider> getHighlightProviders() {
return new ArrayList<>(highlightProviders);
}
- void addHighlightProvider(HighlightProvider provider) {
+ void addHighlightProvider(ListingHighlightProvider provider) {
if (!highlightProviders.contains(provider)) {
highlightProviders.add(provider);
}
}
- void removeHighlightProvider(HighlightProvider provider) {
+ void removeHighlightProvider(ListingHighlightProvider provider) {
highlightProviders.remove(provider);
}
}
diff --git a/Ghidra/Features/Base/src/main/java/ghidra/app/util/viewer/listingpanel/DualListingNavigator.java b/Ghidra/Features/Base/src/main/java/ghidra/app/util/viewer/listingpanel/DualListingNavigator.java
index 9344790b52..5a585056ba 100644
--- a/Ghidra/Features/Base/src/main/java/ghidra/app/util/viewer/listingpanel/DualListingNavigator.java
+++ b/Ghidra/Features/Base/src/main/java/ghidra/app/util/viewer/listingpanel/DualListingNavigator.java
@@ -19,7 +19,7 @@ import javax.swing.Icon;
import ghidra.app.nav.*;
import ghidra.app.services.GoToService;
-import ghidra.app.util.HighlightProvider;
+import ghidra.app.util.ListingHighlightProvider;
import ghidra.program.model.listing.Program;
import ghidra.program.util.ProgramLocation;
import ghidra.program.util.ProgramSelection;
@@ -152,12 +152,12 @@ class DualListingNavigator implements Navigatable {
}
@Override
- public void removeHighlightProvider(HighlightProvider highlightProvider, Program program) {
+ public void removeHighlightProvider(ListingHighlightProvider highlightProvider, Program program) {
// currently unsupported
}
@Override
- public void setHighlightProvider(HighlightProvider highlightProvider, Program program) {
+ public void setHighlightProvider(ListingHighlightProvider highlightProvider, Program program) {
// currently unsupported
}
}
diff --git a/Ghidra/Features/Base/src/main/java/ghidra/app/util/viewer/listingpanel/ListingCodeComparisonPanel.java b/Ghidra/Features/Base/src/main/java/ghidra/app/util/viewer/listingpanel/ListingCodeComparisonPanel.java
index fd74443260..16432ce690 100644
--- a/Ghidra/Features/Base/src/main/java/ghidra/app/util/viewer/listingpanel/ListingCodeComparisonPanel.java
+++ b/Ghidra/Features/Base/src/main/java/ghidra/app/util/viewer/listingpanel/ListingCodeComparisonPanel.java
@@ -43,7 +43,7 @@ import ghidra.app.plugin.core.codebrowser.MarkerServiceBackgroundColorModel;
import ghidra.app.plugin.core.codebrowser.hover.*;
import ghidra.app.plugin.core.marker.MarkerManager;
import ghidra.app.services.*;
-import ghidra.app.util.HighlightProvider;
+import ghidra.app.util.ListingHighlightProvider;
import ghidra.app.util.SymbolPath;
import ghidra.app.util.viewer.format.*;
import ghidra.app.util.viewer.util.*;
@@ -308,17 +308,17 @@ public class ListingCodeComparisonPanel
* @param leftHighlightProvider the highlight provider for the left side's listing.
* @param rightHighlightProvider the highlight provider for the right side's listing.
*/
- public void addHighlightProviders(HighlightProvider leftHighlightProvider,
- HighlightProvider rightHighlightProvider) {
+ public void addHighlightProviders(ListingHighlightProvider leftHighlightProvider,
+ ListingHighlightProvider rightHighlightProvider) {
addLeftHighlightProvider(leftHighlightProvider);
addRightHighlightProvider(rightHighlightProvider);
}
- private void addLeftHighlightProvider(HighlightProvider leftHighlightProvider) {
+ private void addLeftHighlightProvider(ListingHighlightProvider leftHighlightProvider) {
listingPanels[LEFT].getFormatManager().addHighlightProvider(leftHighlightProvider);
}
- private void addRightHighlightProvider(HighlightProvider rightHighlightProvider) {
+ private void addRightHighlightProvider(ListingHighlightProvider rightHighlightProvider) {
listingPanels[RIGHT].getFormatManager().addHighlightProvider(rightHighlightProvider);
}
@@ -328,17 +328,17 @@ public class ListingCodeComparisonPanel
* @param leftHighlightProvider the highlight provider for the left side's listing.
* @param rightHighlightProvider the highlight provider for the right side's listing.
*/
- public void removeHighlightProviders(HighlightProvider leftHighlightProvider,
- HighlightProvider rightHighlightProvider) {
+ public void removeHighlightProviders(ListingHighlightProvider leftHighlightProvider,
+ ListingHighlightProvider rightHighlightProvider) {
removeLeftHighlightProvider(leftHighlightProvider);
removeRightHighlightProvider(rightHighlightProvider);
}
- private void removeLeftHighlightProvider(HighlightProvider leftHighlightProvider) {
+ private void removeLeftHighlightProvider(ListingHighlightProvider leftHighlightProvider) {
listingPanels[LEFT].getFormatManager().removeHighlightProvider(leftHighlightProvider);
}
- private void removeRightHighlightProvider(HighlightProvider rightHighlightProvider) {
+ private void removeRightHighlightProvider(ListingHighlightProvider rightHighlightProvider) {
listingPanels[RIGHT].getFormatManager().removeHighlightProvider(rightHighlightProvider);
}
diff --git a/Ghidra/Features/Base/src/main/java/ghidra/app/util/viewer/listingpanel/ListingDiffHighlightProvider.java b/Ghidra/Features/Base/src/main/java/ghidra/app/util/viewer/listingpanel/ListingDiffHighlightProvider.java
index 4381ce1e3f..d4e2711648 100644
--- a/Ghidra/Features/Base/src/main/java/ghidra/app/util/viewer/listingpanel/ListingDiffHighlightProvider.java
+++ b/Ghidra/Features/Base/src/main/java/ghidra/app/util/viewer/listingpanel/ListingDiffHighlightProvider.java
@@ -19,14 +19,15 @@ import java.awt.Color;
import java.util.ArrayList;
import docking.widgets.fieldpanel.support.Highlight;
-import ghidra.app.util.HighlightProvider;
+import ghidra.app.util.ListingHighlightProvider;
import ghidra.app.util.viewer.field.*;
+import ghidra.app.util.viewer.proxy.ProxyObj;
import ghidra.program.model.address.*;
import ghidra.program.model.listing.CodeUnit;
import ghidra.program.model.listing.Instruction;
import ghidra.program.util.ListingDiff;
-public class ListingDiffHighlightProvider implements HighlightProvider {
+public class ListingDiffHighlightProvider implements ListingHighlightProvider {
private static final int NUM_CHARACTERS_PER_BYTE = 3; // 2 hex digits and a space;
private static final String DEFAULT_OPERAND_SEPARATOR = ",";
@@ -52,13 +53,14 @@ public class ListingDiffHighlightProvider implements HighlightProvider {
}
@Override
- public Highlight[] getHighlights(String text, Object obj,
- Class<? extends FieldFactory> fieldFactoryClass, int cursorTextOffset) {
+ public Highlight[] createHighlights(String text, ListingField field, int cursorTextOffset) {
- Highlight[] highlights = EMPTY_HIGHLIGHT;
+ Highlight[] highlights = NO_HIGHLIGHTS;
- if (obj instanceof CodeUnit) {
- CodeUnit codeUnit = (CodeUnit) obj;
+ ProxyObj<?> proxy = field.getProxy();
+ Object obj = proxy.getObject();
+ if (obj instanceof CodeUnit codeUnit) {
+ Class<? extends FieldFactory> fieldFactoryClass = field.getFieldFactory().getClass();
if (fieldFactoryClass == BytesFieldFactory.class) {
highlights = getByteDiffHighlights(text, codeUnit, cursorTextOffset);
}
@@ -78,7 +80,7 @@ public class ListingDiffHighlightProvider implements HighlightProvider {
AddressSetView unmatchedDiffs = (isListing1) ? listingDiff.getListing1UnmatchedCode()
: listingDiff.getListing2UnmatchedCode();
if (unmatchedDiffs.contains(minAddress)) {
- return EMPTY_HIGHLIGHT;
+ return NO_HIGHLIGHTS;
}
Color byteDiffsBackgroundColor = comparisonOptions.getByteDiffsBackgroundColor();
AddressSetView byteDiffs =
@@ -100,7 +102,7 @@ public class ListingDiffHighlightProvider implements HighlightProvider {
}
return highlights.toArray(new Highlight[highlights.size()]);
}
- return EMPTY_HIGHLIGHT;
+ return NO_HIGHLIGHTS;
}
private Highlight[] getMnemonicDiffHighlights(String text, CodeUnit codeUnit,
@@ -109,7 +111,7 @@ public class ListingDiffHighlightProvider implements HighlightProvider {
AddressSetView unmatchedDiffs = (isListing1) ? listingDiff.getListing1UnmatchedCode()
: listingDiff.getListing2UnmatchedCode();
if (unmatchedDiffs.contains(minAddress)) {
- return EMPTY_HIGHLIGHT;
+ return NO_HIGHLIGHTS;
}
Color mnemonicDiffsBackgroundColor = comparisonOptions.getMnemonicDiffsBackgroundColor();
AddressSetView codeUnitDiffs = (isListing1) ? listingDiff.getListing1CodeUnitDiffs()
@@ -129,7 +131,7 @@ public class ListingDiffHighlightProvider implements HighlightProvider {
return entireTextHighlight(text, cursorTextOffset, mnemonicDiffsBackgroundColor);
}
}
- return EMPTY_HIGHLIGHT;
+ return NO_HIGHLIGHTS;
}
private Highlight[] getOperandDiffHighlights(String text, CodeUnit codeUnit,
@@ -138,7 +140,7 @@ public class ListingDiffHighlightProvider implements HighlightProvider {
AddressSetView unmatchedDiffs = (isListing1) ? listingDiff.getListing1UnmatchedCode()
: listingDiff.getListing2UnmatchedCode();
if (unmatchedDiffs.contains(minAddress)) {
- return EMPTY_HIGHLIGHT;
+ return NO_HIGHLIGHTS;
}
Color operandDiffsBackgroundColor = comparisonOptions.getOperandDiffsBackgroundColor();
AddressSetView codeUnitDiffs = (isListing1) ? listingDiff.getListing1CodeUnitDiffs()
@@ -165,7 +167,7 @@ public class ListingDiffHighlightProvider implements HighlightProvider {
}
return highlights.toArray(new Highlight[highlights.size()]);
}
- return EMPTY_HIGHLIGHT;
+ return NO_HIGHLIGHTS;
}
/**
diff --git a/Ghidra/Features/Base/src/main/java/ghidra/app/util/viewer/listingpanel/ListingPanel.java b/Ghidra/Features/Base/src/main/java/ghidra/app/util/viewer/listingpanel/ListingPanel.java
index 0992995c1f..e4da6deabf 100644
--- a/Ghidra/Features/Base/src/main/java/ghidra/app/util/viewer/listingpanel/ListingPanel.java
+++ b/Ghidra/Features/Base/src/main/java/ghidra/app/util/viewer/listingpanel/ListingPanel.java
@@ -36,7 +36,7 @@ import generic.theme.GThemeDefaults.Colors;
import ghidra.app.plugin.core.codebrowser.LayeredColorModel;
import ghidra.app.plugin.core.codebrowser.hover.ListingHoverService;
import ghidra.app.services.ButtonPressedListener;
-import ghidra.app.util.HighlightProvider;
+import ghidra.app.util.ListingHighlightProvider;
import ghidra.app.util.viewer.field.FieldFactory;
import ghidra.app.util.viewer.field.ListingField;
import ghidra.app.util.viewer.format.FieldHeader;
@@ -449,22 +449,22 @@ public class ListingPanel extends JPanel implements FieldMouseListener, FieldLoc
}
/**
- * Removes the given {@link HighlightProvider} from this listing.
+ * Removes the given {@link ListingHighlightProvider} from this listing.
*
* @param highlightProvider The provider to remove.
- * @see #addHighlightProvider(HighlightProvider)
+ * @see #addHighlightProvider(ListingHighlightProvider)
*/
- public void removeHighlightProvider(HighlightProvider highlightProvider) {
+ public void removeHighlightProvider(ListingHighlightProvider highlightProvider) {
formatManager.removeHighlightProvider(highlightProvider);
}
/**
- * Adds a {@link HighlightProvider} to this listing. This highlight provider will be used with
+ * Adds a {@link ListingHighlightProvider} to this listing. This highlight provider will be used with
* any other registered providers to paint all the highlights for this listing.
*
* @param highlightProvider The provider to add
*/
- public void addHighlightProvider(HighlightProvider highlightProvider) {
+ public void addHighlightProvider(ListingHighlightProvider highlightProvider) {
formatManager.addHighlightProvider(highlightProvider);
}
@@ -1157,11 +1157,11 @@ public class ListingPanel extends JPanel implements FieldMouseListener, FieldLoc
}
public void setFormatManager(FormatManager formatManager) {
- List<HighlightProvider> highlightProviders = this.formatManager.getHighlightProviders();
+ List<ListingHighlightProvider> highlightProviders = this.formatManager.getHighlightProviders();
this.formatManager = formatManager;
- for (HighlightProvider provider : highlightProviders) {
+ for (ListingHighlightProvider provider : highlightProviders) {
this.formatManager.addHighlightProvider(provider);
}
diff --git a/Ghidra/Features/Base/src/main/java/ghidra/app/util/viewer/options/OptionsGui.java b/Ghidra/Features/Base/src/main/java/ghidra/app/util/viewer/options/OptionsGui.java
index 8dc5be1a1b..44f6a7ee12 100644
--- a/Ghidra/Features/Base/src/main/java/ghidra/app/util/viewer/options/OptionsGui.java
+++ b/Ghidra/Features/Base/src/main/java/ghidra/app/util/viewer/options/OptionsGui.java
@@ -47,7 +47,7 @@ import ghidra.util.SystemUtilities;
*/
public class OptionsGui extends JPanel {
private static final Highlight[] NO_HIGHLIGHTS = new Highlight[0];
- private static final HighlightFactory hlFactory =
+ private static final FieldHighlightFactory hlFactory =
(field, text, cursorTextOffset) -> NO_HIGHLIGHTS;
// @formatter:off
@@ -895,7 +895,7 @@ public class OptionsGui extends JPanel {
private ScreenElement screenElement;
ScreenElementTextField(ScreenElement screenElement, int startX, int length,
- FieldElement field, HighlightFactory factory) {
+ FieldElement field, FieldHighlightFactory factory) {
super(startX, length, field, factory);
this.screenElement = screenElement;
}
diff --git a/Ghidra/Features/Base/src/main/java/ghidra/app/util/viewer/proxy/AddressProxy.java b/Ghidra/Features/Base/src/main/java/ghidra/app/util/viewer/proxy/AddressProxy.java
index 57bae8063d..49ec5d2574 100644
--- a/Ghidra/Features/Base/src/main/java/ghidra/app/util/viewer/proxy/AddressProxy.java
+++ b/Ghidra/Features/Base/src/main/java/ghidra/app/util/viewer/proxy/AddressProxy.java
@@ -1,6 +1,5 @@
/* ###
* IP: GHIDRA
- * REVIEWED: YES
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
@@ -20,14 +19,15 @@ import ghidra.app.util.viewer.listingpanel.ListingModel;
import ghidra.program.model.address.Address;
/**
- * Stores information about a address in a program such that the address can
- * be retrieved when needed.
+ * Stores information about an address in a program.
*/
public class AddressProxy extends ProxyObj<Address> {
- Address addr;
+
+ private Address addr;
/**
* Construct a address proxy
+ * @param model the model
* @param addr the address to proxy
*/
public AddressProxy(ListingModel model, Address addr) {
@@ -35,12 +35,13 @@ public class AddressProxy extends ProxyObj<Address> {
this.addr = addr;
}
- /**
- * @see ghidra.app.util.viewer.proxy.ProxyObj#getObject()
- */
@Override
public Address getObject() {
return addr;
}
+ @Override
+ public boolean contains(Address a) {
+ return addr.equals(a);
+ }
}
diff --git a/Ghidra/Features/Base/src/main/java/ghidra/app/util/viewer/proxy/CodeUnitProxy.java b/Ghidra/Features/Base/src/main/java/ghidra/app/util/viewer/proxy/CodeUnitProxy.java
index 578ab782d4..8518be8932 100644
--- a/Ghidra/Features/Base/src/main/java/ghidra/app/util/viewer/proxy/CodeUnitProxy.java
+++ b/Ghidra/Features/Base/src/main/java/ghidra/app/util/viewer/proxy/CodeUnitProxy.java
@@ -1,6 +1,5 @@
/* ###
* IP: GHIDRA
- * REVIEWED: YES
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
@@ -22,24 +21,24 @@
*/
package ghidra.app.util.viewer.proxy;
+import java.util.ConcurrentModificationException;
+
import ghidra.app.util.viewer.listingpanel.ListingModel;
import ghidra.program.model.address.Address;
import ghidra.program.model.listing.CodeUnit;
import ghidra.program.model.listing.Program;
-import java.util.ConcurrentModificationException;
-
/**
- * Stores information about a code unti in a program such that the code unit can
- * be retrieved when needed.
+ * Stores information about a code unit in a program.
*/
public class CodeUnitProxy extends ProxyObj<CodeUnit> {
- Program program;
- CodeUnit cu;
- Address addr;
+ private Program program;
+ private CodeUnit cu;
+ private Address addr;
/**
* Construct a proxy for a code unit
+ * @param model the model
* @param program the program containing the code unit
* @param cu the code unit to proxy.
*/
@@ -50,9 +49,6 @@ public class CodeUnitProxy extends ProxyObj<CodeUnit> {
this.addr = cu.getMinAddress();
}
- /**
- * @see ghidra.app.util.viewer.proxy.ProxyObj#getObject()
- */
@Override
public CodeUnit getObject() {
if (cu != null) {
@@ -67,4 +63,12 @@ public class CodeUnitProxy extends ProxyObj<CodeUnit> {
return cu;
}
+ @Override
+ public boolean contains(Address a) {
+ CodeUnit c = getObject();
+ if (c == null) {
+ return false;
+ }
+ return c.contains(a);
+ }
}
diff --git a/Ghidra/Features/Base/src/main/java/ghidra/app/util/viewer/proxy/DataProxy.java b/Ghidra/Features/Base/src/main/java/ghidra/app/util/viewer/proxy/DataProxy.java
index 56423b9cfa..bd0b2bd68d 100644
--- a/Ghidra/Features/Base/src/main/java/ghidra/app/util/viewer/proxy/DataProxy.java
+++ b/Ghidra/Features/Base/src/main/java/ghidra/app/util/viewer/proxy/DataProxy.java
@@ -1,6 +1,5 @@
/* ###
* IP: GHIDRA
- * REVIEWED: YES
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
@@ -16,13 +15,13 @@
*/
package ghidra.app.util.viewer.proxy;
+import java.util.ConcurrentModificationException;
+
import ghidra.app.util.viewer.listingpanel.ListingModel;
import ghidra.program.model.address.Address;
import ghidra.program.model.listing.Data;
import ghidra.program.model.listing.Program;
-import java.util.ConcurrentModificationException;
-
/**
* Stores information about a data item in a program such that the data item can
* be retrieved when needed.
@@ -35,6 +34,7 @@ public class DataProxy extends ProxyObj<Data> {
/**
* Construct a proxy for the given Data object.
+ * @param model the model
* @param program the program containing the data object.
* @param data the Data object to proxy.
*/
@@ -46,9 +46,6 @@ public class DataProxy extends ProxyObj<Data> {
this.path = data.getComponentPath();
}
- /**
- * @see ghidra.app.util.viewer.proxy.ProxyObj#getObject()
- */
@Override
public Data getObject() {
if (data != null) {
@@ -66,4 +63,12 @@ public class DataProxy extends ProxyObj<Data> {
return data;
}
+ @Override
+ public boolean contains(Address a) {
+ Data d = getObject();
+ if (d == null) {
+ return false;
+ }
+ return d.contains(a);
+ }
}
diff --git a/Ghidra/Features/Base/src/main/java/ghidra/app/util/viewer/proxy/EmptyProxy.java b/Ghidra/Features/Base/src/main/java/ghidra/app/util/viewer/proxy/EmptyProxy.java
index 0facde58f8..b0e8f85963 100644
--- a/Ghidra/Features/Base/src/main/java/ghidra/app/util/viewer/proxy/EmptyProxy.java
+++ b/Ghidra/Features/Base/src/main/java/ghidra/app/util/viewer/proxy/EmptyProxy.java
@@ -1,6 +1,5 @@
/* ###
* IP: GHIDRA
- * REVIEWED: YES
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
@@ -16,8 +15,10 @@
*/
package ghidra.app.util.viewer.proxy;
+import ghidra.program.model.address.Address;
+
/**
- * Used proxy a null value
+ * Used as proxy for a null value.
*/
public class EmptyProxy extends ProxyObj<Object> {
public static final EmptyProxy EMPTY_PROXY = new EmptyProxy();
@@ -29,12 +30,13 @@ public class EmptyProxy extends ProxyObj<Object> {
super(null);
}
- /**
- * @see ghidra.app.util.viewer.proxy.ProxyObj#getObject()
- */
@Override
public Object getObject() {
return null;
}
+ @Override
+ public boolean contains(Address a) {
+ return false;
+ }
}
diff --git a/Ghidra/Features/Base/src/main/java/ghidra/app/util/viewer/proxy/FunctionProxy.java b/Ghidra/Features/Base/src/main/java/ghidra/app/util/viewer/proxy/FunctionProxy.java
index 6e1a33f2ea..ba6acc1429 100644
--- a/Ghidra/Features/Base/src/main/java/ghidra/app/util/viewer/proxy/FunctionProxy.java
+++ b/Ghidra/Features/Base/src/main/java/ghidra/app/util/viewer/proxy/FunctionProxy.java
@@ -1,6 +1,5 @@
/* ###
* IP: GHIDRA
- * REVIEWED: YES
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
@@ -22,24 +21,24 @@
*/
package ghidra.app.util.viewer.proxy;
+import java.util.ConcurrentModificationException;
+
import ghidra.app.util.viewer.listingpanel.ListingModel;
import ghidra.program.model.address.Address;
import ghidra.program.model.data.Pointer;
import ghidra.program.model.listing.*;
import ghidra.program.model.symbol.Reference;
-import java.util.ConcurrentModificationException;
-
/**
* Stores information about a function in a program such that the function can
* be retrieved when needed. The locationAddr and functionAddr may differ when the
* function object has been inferred via a reference at the locationAddr.
*/
public class FunctionProxy extends ProxyObj<Function> {
- Program program;
- Function function;
- Address functionAddr;
- Address locationAddr;
+ private Program program;
+ private Function function;
+ private Address functionAddr;
+ private Address locationAddr;
/**
* Construct a proxy for a function
@@ -65,9 +64,6 @@ public class FunctionProxy extends ProxyObj<Function> {
return functionAddr;
}
- /**
- * @see ghidra.app.util.viewer.proxy.ProxyObj#getObject()
- */
@Override
public Function getObject() {
if (function != null) {
@@ -105,4 +101,12 @@ public class FunctionProxy extends ProxyObj<Function> {
return function;
}
+ @Override
+ public boolean contains(Address a) {
+ Function f = getObject();
+ if (f == null) {
+ return false;
+ }
+ return f.getBody().contains(a);
+ }
}
diff --git a/Ghidra/Features/Base/src/main/java/ghidra/app/util/viewer/proxy/ProxyObj.java b/Ghidra/Features/Base/src/main/java/ghidra/app/util/viewer/proxy/ProxyObj.java
index 04347f58b9..fd62ebbaae 100644
--- a/Ghidra/Features/Base/src/main/java/ghidra/app/util/viewer/proxy/ProxyObj.java
+++ b/Ghidra/Features/Base/src/main/java/ghidra/app/util/viewer/proxy/ProxyObj.java
@@ -1,6 +1,5 @@
/* ###
* IP: GHIDRA
- * REVIEWED: YES
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
@@ -17,13 +16,15 @@
package ghidra.app.util.viewer.proxy;
import ghidra.app.util.viewer.listingpanel.ListingModel;
+import ghidra.program.model.address.Address;
/**
- * Implementing objects of this interface hold an object from a program (e.g. CodeUnit, Funtion etc.)
- * in such a way as to be robust against changes to the program. In other words, it protects
- * against holding on to` "stale" objects. The getObject() method will return the represented object
+ * Implementing objects of this interface hold an object from a program (e.g., CodeUnit, Function,
+ * etc.) in such a way as to be robust against changes to the program. In other words, it protects
+ * against holding on to "stale" objects. The getObject() method will return the represented object
* (refreshed if it was stale) or null if it no longer exists.
*
+ * @param <T> the proxy object type
*/
public abstract class ProxyObj<T> {
@@ -35,17 +36,22 @@ public abstract class ProxyObj<T> {
/**
* Returns the layout model which corresponds to this field proxy.
+ * @return the model
*/
public ListingModel getListingLayoutModel() {
return model;
}
/**
- * Returns the object that this proxy represents or null if the represented object no longer
- * exists.
- * @return the object that this proxy represents or null if the represented object no longer
- * exists.
+ * Returns the object that this proxy represents or null if the object no longer exists.
+ * @return the object that this proxy represents or null if the object no longer exists.
*/
public abstract T getObject();
+ /**
+ * Returns true if the proxy object of this class contains the given address.
+ * @param a the address
+ * @return true if the proxy object of this class contains the given address.
+ */
+ public abstract boolean contains(Address a);
}
diff --git a/Ghidra/Features/Base/src/main/java/ghidra/app/util/viewer/proxy/VariableProxy.java b/Ghidra/Features/Base/src/main/java/ghidra/app/util/viewer/proxy/VariableProxy.java
index 0ef28613f9..02f0a04e3e 100644
--- a/Ghidra/Features/Base/src/main/java/ghidra/app/util/viewer/proxy/VariableProxy.java
+++ b/Ghidra/Features/Base/src/main/java/ghidra/app/util/viewer/proxy/VariableProxy.java
@@ -59,9 +59,6 @@ public class VariableProxy extends ProxyObj<Variable> {
firstUseOffset = var.getFirstUseOffset();
}
- /**
- * @see ghidra.app.util.viewer.proxy.ProxyObj#getObject()
- */
@Override
public Variable getObject() {
@@ -107,12 +104,12 @@ public class VariableProxy extends ProxyObj<Variable> {
}
Variable[] vars = function.getLocalVariables();
- for (int i = 0; i < vars.length; i++) {
- if (firstUseOffset != vars[i].getFirstUseOffset()) {
+ for (Variable var2 : vars) {
+ if (firstUseOffset != var2.getFirstUseOffset()) {
continue;
}
- if (storageAddr.equals(vars[i].getMinAddress())) {
- var = vars[i];
+ if (storageAddr.equals(var2.getMinAddress())) {
+ var = var2;
return var;
}
}
@@ -127,4 +124,12 @@ public class VariableProxy extends ProxyObj<Variable> {
return functionAddr;
}
+ @Override
+ public boolean contains(Address a) {
+ Variable v = getObject();
+ if (v == null) {
+ return false;
+ }
+ return v.getMinAddress().equals(a);
+ }
}
diff --git a/Ghidra/Features/Base/src/main/java/ghidra/test/AbstractProgramBasedTest.java b/Ghidra/Features/Base/src/main/java/ghidra/test/AbstractProgramBasedTest.java
index 8d6477ea37..42a00e3f5c 100644
--- a/Ghidra/Features/Base/src/main/java/ghidra/test/AbstractProgramBasedTest.java
+++ b/Ghidra/Features/Base/src/main/java/ghidra/test/AbstractProgramBasedTest.java
@@ -17,12 +17,16 @@ package ghidra.test;
import static org.junit.Assert.*;
+import java.math.BigInteger;
import java.util.ArrayList;
import java.util.List;
import org.junit.After;
+import docking.widgets.fieldpanel.*;
import ghidra.app.plugin.core.codebrowser.CodeBrowserPlugin;
+import ghidra.app.util.viewer.field.ListingField;
+import ghidra.app.util.viewer.listingpanel.ListingPanel;
import ghidra.framework.plugintool.PluginTool;
import ghidra.program.model.address.*;
import ghidra.program.model.listing.*;
@@ -206,4 +210,50 @@ public abstract class AbstractProgramBasedTest extends AbstractGhidraHeadedInteg
}
return result;
}
+
+ /**
+ * Returns a field by the given name at the given address. Clients can use the convention
+ * that field factory classes specify a public static field named 'FIELD_NAME' to choose the
+ * desired field name.
+ * <p>
+ * Note: you will have to perform a {@code goTo()} to trigger the view to load the given field.
+ *
+ * @param a the address
+ * @param fieldName the field name
+ * @return the field
+ */
+ protected ListingField getField(Address a, String fieldName) {
+
+ ListingPanel panel = codeBrowser.getListingPanel();
+ BigInteger index = panel.getAddressIndexMap().getIndex(a);
+ FieldPanel fieldPanel = panel.getFieldPanel();
+ ListingField field = getField(fieldName, 1, index, fieldPanel);
+ return field;
+ }
+
+ protected ListingField getField(String fieldName, int occurrence, final BigInteger index,
+ FieldPanel fieldPanel) {
+
+ if (fieldName == null) {
+ return null;
+ }
+
+ LayoutModel model = fieldPanel.getLayoutModel();
+ Layout layout = model.getLayout(index);
+ if (layout == null) {
+ return null;
+ }
+
+ int instanceNum = 1;
+ for (int i = 0; i < layout.getNumFields(); i++) {
+ ListingField bf = (ListingField) layout.getField(i);
+ if (bf.getFieldFactory().getFieldName().equals(fieldName)) {
+ if (instanceNum++ == occurrence) {
+ return bf;
+ }
+ }
+ }
+ return null;
+ }
+
}
diff --git a/Ghidra/Features/Base/src/test.slow/java/ghidra/app/plugin/core/searchmem/AbstractMemSearchTest.java b/Ghidra/Features/Base/src/test.slow/java/ghidra/app/plugin/core/searchmem/AbstractMemSearchTest.java
index cd4e33b51d..04e05c4907 100644
--- a/Ghidra/Features/Base/src/test.slow/java/ghidra/app/plugin/core/searchmem/AbstractMemSearchTest.java
+++ b/Ghidra/Features/Base/src/test.slow/java/ghidra/app/plugin/core/searchmem/AbstractMemSearchTest.java
@@ -27,7 +27,6 @@ import java.util.stream.Collectors;
import javax.swing.*;
import org.apache.commons.collections4.IteratorUtils;
-import org.junit.After;
import docking.action.DockingActionIf;
import docking.test.AbstractDockingTest;
@@ -37,8 +36,9 @@ import ghidra.app.plugin.core.codebrowser.CodeViewerProvider;
import ghidra.app.plugin.core.table.TableComponentProvider;
import ghidra.app.plugin.core.table.TableServicePlugin;
import ghidra.app.services.*;
-import ghidra.app.util.HighlightProvider;
+import ghidra.app.util.ListingHighlightProvider;
import ghidra.app.util.viewer.field.BytesFieldFactory;
+import ghidra.app.util.viewer.field.ListingField;
import ghidra.app.util.viewer.format.FormatManager;
import ghidra.program.model.address.*;
import ghidra.program.model.listing.*;
@@ -98,12 +98,6 @@ public abstract class AbstractMemSearchTest extends AbstractProgramBasedTest {
selectRadioButton("Binary");
}
- @Override
- @After
- public void tearDown() throws Exception {
- env.dispose();
- }
-
@Override
protected Program getProgram() throws Exception {
return buildProgram();
@@ -163,10 +157,10 @@ public abstract class AbstractMemSearchTest extends AbstractProgramBasedTest {
private List<Address> getHighlightAddresses() {
CodeViewerService service = tool.getService(CodeViewerService.class);
Object codeViewerProvider = getInstanceField("connectedProvider", service);
- Map<Program, HighlightProvider> highlighterMap =
- (Map<Program, HighlightProvider>) getInstanceField("programHighlighterMap",
+ Map<Program, ListingHighlightProvider> highlighterMap =
+ (Map<Program, ListingHighlightProvider>) getInstanceField("programHighlighterMap",
codeViewerProvider);
- HighlightProvider highlightProvider = highlighterMap.get(program);
+ ListingHighlightProvider highlightProvider = highlighterMap.get(program);
assertEquals("The inner-class has been renamed", "SearchTableHighlightHandler",
highlightProvider.getClass().getSimpleName());
@@ -237,10 +231,10 @@ public abstract class AbstractMemSearchTest extends AbstractProgramBasedTest {
triggerText(valueField, text);
}
- protected HighlightProvider getHighlightProvider() {
+ protected ListingHighlightProvider getHighlightProvider() {
CodeViewerService service = tool.getService(CodeViewerService.class);
FormatManager fm = (FormatManager) getInstanceField("formatMgr", service);
- return (HighlightProvider) getInstanceField("highlightProvider", fm);
+ return (ListingHighlightProvider) getInstanceField("highlightProvider", fm);
}
protected void repeatSearch() {
@@ -296,10 +290,11 @@ public abstract class AbstractMemSearchTest extends AbstractProgramBasedTest {
}
protected Highlight[] getByteHighlights(Address address, String bytes) {
+ goTo(address);
CodeUnit cu = codeUnitContaining(address);
- HighlightProvider provider1 = getHighlightProvider();
- Highlight[] h = provider1.getHighlights(bytes, cu, BytesFieldFactory.class, -1);
- return h;
+ ListingHighlightProvider hlProvider = getHighlightProvider();
+ ListingField field = getField(address, BytesFieldFactory.FIELD_NAME);
+ return hlProvider.createHighlights(bytes, field, -1);
}
protected void setEndianess(String text) {
diff --git a/Ghidra/Features/Base/src/test.slow/java/ghidra/app/plugin/core/searchmem/MemSearchRegExTest.java b/Ghidra/Features/Base/src/test.slow/java/ghidra/app/plugin/core/searchmem/MemSearchRegExTest.java
index 7bae78737f..8baeef3cbe 100644
--- a/Ghidra/Features/Base/src/test.slow/java/ghidra/app/plugin/core/searchmem/MemSearchRegExTest.java
+++ b/Ghidra/Features/Base/src/test.slow/java/ghidra/app/plugin/core/searchmem/MemSearchRegExTest.java
@@ -15,8 +15,7 @@
*/
package ghidra.app.plugin.core.searchmem;
-import static org.junit.Assert.assertEquals;
-import static org.junit.Assert.assertTrue;
+import static org.junit.Assert.*;
import java.nio.charset.StandardCharsets;
import java.util.List;
@@ -35,10 +34,6 @@ import ghidra.program.model.listing.*;
*/
public class MemSearchRegExTest extends AbstractMemSearchTest {
- public MemSearchRegExTest() {
- super();
- }
-
@Override
@Before
public void setUp() throws Exception {
@@ -313,7 +308,7 @@ public class MemSearchRegExTest extends AbstractMemSearchTest {
waitForSearch("Search Memory - ", 3);
- Highlight[] h = getByteHighlights(addr(0x1002827), "6a 01");
+ Highlight[] h = getByteHighlights(addr(0x1002826), "6a 01");
assertEquals(1, h.length);
}
}
diff --git a/Ghidra/Features/Base/src/test.slow/java/ghidra/app/plugin/core/searchtext/ListingDisplaySearcherTest.java b/Ghidra/Features/Base/src/test.slow/java/ghidra/app/plugin/core/searchtext/ListingDisplaySearcherTest.java
index 68393bcb15..01eec22ccc 100644
--- a/Ghidra/Features/Base/src/test.slow/java/ghidra/app/plugin/core/searchtext/ListingDisplaySearcherTest.java
+++ b/Ghidra/Features/Base/src/test.slow/java/ghidra/app/plugin/core/searchtext/ListingDisplaySearcherTest.java
@@ -149,7 +149,7 @@ public class ListingDisplaySearcherTest extends AbstractGhidraHeadedIntegrationT
assertTrue(searcher.hasNext());
while (searcher.hasNext()) {
- ProgramLocation location = searcher.next();
+ ProgramLocation location = searcher.next().programLocation();
testForMatchingText(searchText, location);
}
}
@@ -171,7 +171,7 @@ public class ListingDisplaySearcherTest extends AbstractGhidraHeadedIntegrationT
assertTrue(searcher.hasNext());
while (searcher.hasNext()) {
- ProgramLocation location = searcher.next();
+ ProgramLocation location = searcher.next().programLocation();
testForMatchingText(searchText, location);
}
}
@@ -267,10 +267,12 @@ public class ListingDisplaySearcherTest extends AbstractGhidraHeadedIntegrationT
int transactionID = program.startTransaction("test");
try {
- DataType dt = program.getDataTypeManager().addDataType(struct,
- DataTypeConflictHandler.DEFAULT_HANDLER);
- floatDt = program.getDataTypeManager().addDataType(new FloatDataType(),
- DataTypeConflictHandler.DEFAULT_HANDLER);
+ DataType dt = program.getDataTypeManager()
+ .addDataType(struct,
+ DataTypeConflictHandler.DEFAULT_HANDLER);
+ floatDt = program.getDataTypeManager()
+ .addDataType(new FloatDataType(),
+ DataTypeConflictHandler.DEFAULT_HANDLER);
listing.createData(addr(0x0100689b), dt);
listing.createData(addr(0x0100688c), floatDt);
listing.createData(addr(0x01006890), floatDt);
@@ -344,10 +346,12 @@ public class ListingDisplaySearcherTest extends AbstractGhidraHeadedIntegrationT
int transactionID = program.startTransaction("test");
try {
- DataType dt = program.getDataTypeManager().addDataType(struct,
- DataTypeConflictHandler.DEFAULT_HANDLER);
- floatDt = program.getDataTypeManager().addDataType(new FloatDataType(),
- DataTypeConflictHandler.DEFAULT_HANDLER);
+ DataType dt = program.getDataTypeManager()
+ .addDataType(struct,
+ DataTypeConflictHandler.DEFAULT_HANDLER);
+ floatDt = program.getDataTypeManager()
+ .addDataType(new FloatDataType(),
+ DataTypeConflictHandler.DEFAULT_HANDLER);
listing.createData(addr(0x0100689b), dt);
listing.createData(addr(0x0100688c), floatDt);
listing.createData(addr(0x01006890), floatDt);
@@ -378,38 +382,38 @@ public class ListingDisplaySearcherTest extends AbstractGhidraHeadedIntegrationT
searcher =
new ListingDisplaySearcher(tool, program, startLoc, sel, options, TaskMonitor.DUMMY);
- ProgramLocation loc = searcher.next();
+ ProgramLocation loc = searcher.next().programLocation();
assertNotNull(loc);
assertEquals(addr(0x0100688c), loc.getByteAddress());
assertTrue(loc instanceof CommentFieldLocation);
//
- loc = searcher.next();
+ loc = searcher.next().programLocation();
assertNotNull(loc);
assertEquals(addr(0x01006890), loc.getByteAddress());
assertTrue(loc instanceof MnemonicFieldLocation);
MnemonicFieldLocation mloc = (MnemonicFieldLocation) loc;
assertEquals("float", mloc.getMnemonic());
//
- loc = searcher.next();
+ loc = searcher.next().programLocation();
assertNotNull(loc);
assertEquals(addr(0x01006890), loc.getByteAddress());
assertTrue(loc instanceof CommentFieldLocation);
//
- loc = searcher.next();
+ loc = searcher.next().programLocation();
assertNotNull(loc);
assertEquals(addr(0x0100689b), loc.getByteAddress());
assertTrue(loc instanceof MnemonicFieldLocation);
mloc = (MnemonicFieldLocation) loc;
assertEquals("float", mloc.getMnemonic());
//
- loc = searcher.next();
+ loc = searcher.next().programLocation();
assertNotNull(loc);
assertEquals(addr(0x0100689f), loc.getByteAddress());
assertTrue(loc instanceof MnemonicFieldLocation);
mloc = (MnemonicFieldLocation) loc;
assertEquals("float", mloc.getMnemonic());
//
- loc = searcher.next();
+ loc = searcher.next().programLocation();
assertNotNull(loc);
assertEquals(addr(0x0100689f), loc.getByteAddress());
assertTrue(loc instanceof CommentFieldLocation);
@@ -432,10 +436,12 @@ public class ListingDisplaySearcherTest extends AbstractGhidraHeadedIntegrationT
int transactionID = program.startTransaction("test");
try {
- DataType dt = program.getDataTypeManager().addDataType(struct,
- DataTypeConflictHandler.DEFAULT_HANDLER);
- floatDt = program.getDataTypeManager().addDataType(new FloatDataType(),
- DataTypeConflictHandler.DEFAULT_HANDLER);
+ DataType dt = program.getDataTypeManager()
+ .addDataType(struct,
+ DataTypeConflictHandler.DEFAULT_HANDLER);
+ floatDt = program.getDataTypeManager()
+ .addDataType(new FloatDataType(),
+ DataTypeConflictHandler.DEFAULT_HANDLER);
listing.createData(addr(0x0100689b), dt);
listing.createData(addr(0x0100688c), floatDt);
listing.createData(addr(0x01006890), floatDt);
@@ -469,26 +475,26 @@ public class ListingDisplaySearcherTest extends AbstractGhidraHeadedIntegrationT
searcher =
new ListingDisplaySearcher(tool, program, startLoc, sel, options, TaskMonitor.DUMMY);
- ProgramLocation loc = searcher.next();
+ ProgramLocation loc = searcher.next().programLocation();
assertNotNull(loc);
assertEquals(addr(0x0100688c), loc.getByteAddress());
assertTrue(loc instanceof CommentFieldLocation);
//
- loc = searcher.next();
+ loc = searcher.next().programLocation();
assertNotNull(loc);
assertEquals(addr(0x0100689b), loc.getByteAddress());
assertTrue(loc instanceof MnemonicFieldLocation);
MnemonicFieldLocation mloc = (MnemonicFieldLocation) loc;
assertEquals("float", mloc.getMnemonic());
//
- loc = searcher.next();
+ loc = searcher.next().programLocation();
assertNotNull(loc);
assertEquals(addr(0x0100689f), loc.getByteAddress());
assertTrue(loc instanceof MnemonicFieldLocation);
mloc = (MnemonicFieldLocation) loc;
assertEquals("float", mloc.getMnemonic());
//
- loc = searcher.next();
+ loc = searcher.next().programLocation();
assertNotNull(loc);
assertEquals(addr(0x0100689f), loc.getByteAddress());
assertTrue(loc instanceof CommentFieldLocation);
@@ -677,16 +683,15 @@ public class ListingDisplaySearcherTest extends AbstractGhidraHeadedIntegrationT
assertTrue(searcher.hasNext());
- ProgramLocation loc = searcher.next();
+ ProgramLocation loc = searcher.next().programLocation();
assertNotNull(loc);
assertEquals(addr(0x01001068), loc.getByteAddress());
assertTrue(loc instanceof LabelFieldLocation);
- loc = searcher.next();
+ loc = searcher.next().programLocation();
assertNotNull(loc);
assertEquals(addr(0x01001068), loc.getByteAddress());
assertTrue(loc instanceof EolCommentFieldLocation);
- loc = searcher.next();
- assertNull(loc);
+ assertNull(searcher.next());
}
@@ -759,7 +764,6 @@ public class ListingDisplaySearcherTest extends AbstractGhidraHeadedIntegrationT
checkTextFound(addr(0x0100419f), OperandFieldLocation.class);
checkTextFound(addr(0x010041a1), LabelFieldLocation.class);
checkTextFound(addr(0x010041a4), LabelFieldLocation.class);
-
}
//==================================================================================================
@@ -816,11 +820,9 @@ public class ListingDisplaySearcherTest extends AbstractGhidraHeadedIntegrationT
private void checkTextFound(ArrayList<Address> startList, Class<?> fieldClass) {
- for (int i = 0; i < startList.size(); i++) {
- ProgramLocation loc = searcher.next();
+ for (Address start : startList) {
+ ProgramLocation loc = searcher.next().programLocation();
assertNotNull(loc);
- Address start = startList.get(i);
-
assertTrue(fieldClass.isAssignableFrom(loc.getClass()));
assertEquals(start, loc.getAddress());
}
@@ -831,7 +833,7 @@ public class ListingDisplaySearcherTest extends AbstractGhidraHeadedIntegrationT
private void checkTextFound(Address addr, Class<?> fieldClass) {
ProgramLocation loc;
- loc = searcher.next();
+ loc = searcher.next().programLocation();
assertNotNull(loc);
assertTrue(fieldClass.isAssignableFrom(loc.getClass()));
diff --git a/Ghidra/Features/Base/src/test.slow/java/ghidra/app/plugin/core/searchtext/SearchTextPlugin3Test.java b/Ghidra/Features/Base/src/test.slow/java/ghidra/app/plugin/core/searchtext/SearchTextPlugin3Test.java
index a03922ea72..8ef6c90f37 100644
--- a/Ghidra/Features/Base/src/test.slow/java/ghidra/app/plugin/core/searchtext/SearchTextPlugin3Test.java
+++ b/Ghidra/Features/Base/src/test.slow/java/ghidra/app/plugin/core/searchtext/SearchTextPlugin3Test.java
@@ -27,6 +27,7 @@ import javax.swing.*;
import org.junit.*;
import docking.action.DockingActionIf;
+import docking.widgets.fieldpanel.FieldPanel;
import docking.widgets.fieldpanel.support.Highlight;
import ghidra.app.plugin.core.codebrowser.CodeBrowserPlugin;
import ghidra.app.plugin.core.codebrowser.CodeViewerProvider;
@@ -34,7 +35,7 @@ import ghidra.app.plugin.core.marker.MarkerManagerPlugin;
import ghidra.app.plugin.core.programtree.ProgramTreePlugin;
import ghidra.app.services.GoToService;
import ghidra.app.services.ProgramManager;
-import ghidra.app.util.HighlightProvider;
+import ghidra.app.util.ListingHighlightProvider;
import ghidra.app.util.viewer.field.*;
import ghidra.app.util.viewer.format.*;
import ghidra.app.util.viewer.listingpanel.ListingPanel;
@@ -64,10 +65,6 @@ public class SearchTextPlugin3Test extends AbstractGhidraHeadedIntegrationTest {
private CodeViewerProvider provider;
private GoToService goToService;
- public SearchTextPlugin3Test() {
- super();
- }
-
@Before
public void setUp() throws Exception {
env = new TestEnv();
@@ -509,18 +506,20 @@ public class SearchTextPlugin3Test extends AbstractGhidraHeadedIntegrationTest {
String signature = ((FunctionSignatureFieldLocation) loc).getSignature();
- Function function = listing.getFunctionAt(loc.getAddress());
- HighlightProvider highlightProvider =
+ ListingHighlightProvider highlightProvider =
cbPlugin.getFormatManager().getFormatHighlightProvider();
- Highlight[] h = highlightProvider.getHighlights(signature, function,
- FunctionSignatureFieldFactory.class, signature.indexOf(searchText));
+
+ FieldPanel fieldPanel = cbPlugin.getFieldPanel();
+ ListingField field = (ListingField) fieldPanel.getCurrentField();
+ int offset = signature.indexOf(searchText);
+ Highlight[] h = highlightProvider.createHighlights(signature, field, offset);
+
assertEquals(1, h.length);
runSwing(() -> dialog.close());
// highlights should be gone
- h = highlightProvider.getHighlights(signature, function,
- FunctionSignatureFieldFactory.class, -1);
+ h = highlightProvider.createHighlights(signature, field, offset);
assertEquals(0, h.length);
}
@@ -564,10 +563,14 @@ public class SearchTextPlugin3Test extends AbstractGhidraHeadedIntegrationTest {
String signature = ((FunctionSignatureFieldLocation) loc).getSignature();
Function function = listing.getFunctionAt(loc.getAddress());
- HighlightProvider highlightProvider =
+ ListingHighlightProvider highlightProvider =
cbPlugin.getFormatManager().getFormatHighlightProvider();
- Highlight[] h = highlightProvider.getHighlights(signature, function,
- FunctionSignatureFieldFactory.class, -1);
+
+ FieldPanel fieldPanel = cbPlugin.getFieldPanel();
+ ListingField field = (ListingField) fieldPanel.getCurrentField();
+ FieldFactory factory = field.getFieldFactory();
+ Highlight[] h = highlightProvider.createHighlights(signature, field, -1);
+
int numberOfHighlights = h.length;
assertTrue("Did not find highlights at expected field.", (numberOfHighlights > 0));
@@ -590,13 +593,12 @@ public class SearchTextPlugin3Test extends AbstractGhidraHeadedIntegrationTest {
cbPlugin.goToField(addr, "Operands", 0, 2);
waitForSwing();
loc = plugin.getNavigatable().getLocation();
-
assertTrue(loc instanceof OperandFieldLocation);
- OperandFieldLocation operandLocation = (OperandFieldLocation) loc;
- Instruction instruction = listing.getInstructionAt(addr);
- h = highlightProvider.getHighlights(operandLocation.getOperandRepresentation(), instruction,
- OperandFieldFactory.class, 0);
+ field = (ListingField) fieldPanel.getCurrentField();
+ factory = field.getFieldFactory();
+ h = highlightProvider.createHighlights(signature, field, -1);
+
assertTrue("Did not update highlights for new search.", (numberOfHighlights != h.length));
}
diff --git a/Ghidra/Features/Base/src/test.slow/java/ghidra/app/plugin/core/searchtext/quicksearch/ProgramDatabaseSearchIteratorTest.java b/Ghidra/Features/Base/src/test.slow/java/ghidra/app/plugin/core/searchtext/quicksearch/ProgramDatabaseSearchIteratorTest.java
index 6f3c991190..6f6b490730 100644
--- a/Ghidra/Features/Base/src/test.slow/java/ghidra/app/plugin/core/searchtext/quicksearch/ProgramDatabaseSearchIteratorTest.java
+++ b/Ghidra/Features/Base/src/test.slow/java/ghidra/app/plugin/core/searchtext/quicksearch/ProgramDatabaseSearchIteratorTest.java
@@ -29,6 +29,7 @@ import ghidra.app.plugin.core.navigation.GoToAddressLabelPlugin;
import ghidra.app.plugin.core.navigation.NextPrevAddressPlugin;
import ghidra.app.plugin.core.searchtext.SearchOptions;
import ghidra.app.plugin.core.searchtext.Searcher;
+import ghidra.app.plugin.core.searchtext.Searcher.TextSearchResult;
import ghidra.app.plugin.core.searchtext.databasesearcher.*;
import ghidra.app.services.ProgramManager;
import ghidra.framework.plugintool.PluginTool;
@@ -115,7 +116,7 @@ public class ProgramDatabaseSearchIteratorTest extends AbstractGhidraHeadedInteg
while (currentAddress != null) {
if (searcher.hasMatch(currentAddress)) {
- return searcher.getMatch();
+ return searcher.getMatch().programLocation();
}
currentAddress = searcher.getNextSignificantAddress(currentAddress);
}
@@ -413,7 +414,7 @@ public class ProgramDatabaseSearchIteratorTest extends AbstractGhidraHeadedInteg
ProgramLocation startLoc = new ProgramLocation(program, getAddr(0x1001950));
Searcher ts = new ProgramDatabaseSearcher(tool, program, startLoc, null, options, monitor);
- ProgramLocation loc = ts.search();
+ ProgramLocation loc = ts.search().programLocation();
assertNotNull(loc);
assertTrue("Expected CommentFieldLocation, got " + loc.getClass() + " instead!",
@@ -422,7 +423,7 @@ public class ProgramDatabaseSearchIteratorTest extends AbstractGhidraHeadedInteg
assertEquals(cloc.getCharOffset(), 5);
// should be 3 hits at address 0x1001960
- loc = ts.search();
+ loc = ts.search().programLocation();
assertNotNull(loc);
assertTrue("Expected CommentFieldLocation, got " + loc.getClass() + " instead!",
(loc instanceof CommentFieldLocation));
@@ -431,7 +432,7 @@ public class ProgramDatabaseSearchIteratorTest extends AbstractGhidraHeadedInteg
cloc = (CommentFieldLocation) loc;
assertEquals(cloc.getCharOffset(), 12);
- loc = ts.search();
+ loc = ts.search().programLocation();
assertNotNull(loc);
assertTrue("Expected LabelFieldLocation, got " + loc.getClass() + " instead!",
(loc instanceof LabelFieldLocation));
@@ -439,7 +440,7 @@ public class ProgramDatabaseSearchIteratorTest extends AbstractGhidraHeadedInteg
assertEquals(floc.getCharOffset(), 3);
assertEquals(getAddr(0x1001960L), floc.getAddress());
- loc = ts.search();
+ loc = ts.search().programLocation();
assertEquals(getAddr(0x1001960), loc.getAddress());
assertTrue("Expected CommentFieldLocation, got " + loc.getClass() + " instead!",
(loc instanceof CommentFieldLocation));
@@ -470,12 +471,12 @@ public class ProgramDatabaseSearchIteratorTest extends AbstractGhidraHeadedInteg
ProgramLocation startLoc =
new ProgramLocation(program, program.getMinAddress().getNewAddress(0x1001950L));
Searcher ts = new ProgramDatabaseSearcher(tool, program, startLoc, null, options, monitor);
- ProgramLocation loc = ts.search();
+ ProgramLocation loc = ts.search().programLocation();
assertEquals(getAddr(0x1001955L), loc.getAddress());
assertTrue("Expected MnemonicFieldLocation, got " + loc.getClass() + " instead!",
(loc instanceof MnemonicFieldLocation));
- loc = ts.search();
+ loc = ts.search().programLocation();
assertTrue("Expected CommentFieldLocation, got " + loc.getClass() + " instead!",
(loc instanceof CommentFieldLocation));
assertEquals(CodeUnit.POST_COMMENT, ((CommentFieldLocation) loc).getCommentType());
@@ -534,8 +535,10 @@ public class ProgramDatabaseSearchIteratorTest extends AbstractGhidraHeadedInteg
return new ProgramDatabaseSearcher(pluginTool, searchProgram, startLoc, set, options,
taskMonitor);
});
- ProgramLocation loc = null;
- while ((loc = ts.search()) != null) {
+
+ TextSearchResult searchResult = null;
+ while ((searchResult = ts.search()) != null) {
+ ProgramLocation loc = searchResult.programLocation();
list.add(loc);
++count;
if (searchLimit > 0 && count >= searchLimit) {
diff --git a/Ghidra/Features/Base/src/test/java/ghidra/app/nav/TestDummyNavigatable.java b/Ghidra/Features/Base/src/test/java/ghidra/app/nav/TestDummyNavigatable.java
index 23475349fa..1043cee0c5 100644
--- a/Ghidra/Features/Base/src/test/java/ghidra/app/nav/TestDummyNavigatable.java
+++ b/Ghidra/Features/Base/src/test/java/ghidra/app/nav/TestDummyNavigatable.java
@@ -17,7 +17,7 @@ package ghidra.app.nav;
import javax.swing.Icon;
-import ghidra.app.util.HighlightProvider;
+import ghidra.app.util.ListingHighlightProvider;
import ghidra.program.model.listing.Program;
import ghidra.program.util.ProgramLocation;
import ghidra.program.util.ProgramSelection;
@@ -143,12 +143,12 @@ public class TestDummyNavigatable implements Navigatable {
}
@Override
- public void setHighlightProvider(HighlightProvider highlightProvider, Program program) {
+ public void setHighlightProvider(ListingHighlightProvider highlightProvider, Program program) {
// stub
}
@Override
- public void removeHighlightProvider(HighlightProvider highlightProvider, Program program) {
+ public void removeHighlightProvider(ListingHighlightProvider highlightProvider, Program program) {
// stub
}
}
diff --git a/Ghidra/Features/ByteViewer/src/main/java/ghidra/app/plugin/core/byteviewer/ByteField.java b/Ghidra/Features/ByteViewer/src/main/java/ghidra/app/plugin/core/byteviewer/ByteField.java
index 4ff2f9472b..4e5467b2b8 100644
--- a/Ghidra/Features/ByteViewer/src/main/java/ghidra/app/plugin/core/byteviewer/ByteField.java
+++ b/Ghidra/Features/ByteViewer/src/main/java/ghidra/app/plugin/core/byteviewer/ByteField.java
@@ -24,7 +24,7 @@ import docking.util.GraphicsUtils;
import docking.widgets.fieldpanel.field.SimpleTextField;
import docking.widgets.fieldpanel.internal.FieldBackgroundColorManager;
import docking.widgets.fieldpanel.internal.PaintContext;
-import docking.widgets.fieldpanel.support.HighlightFactory;
+import docking.widgets.fieldpanel.support.FieldHighlightFactory;
import docking.widgets.fieldpanel.support.RowColLocation;
import ghidra.util.ColorUtils;
@@ -52,7 +52,7 @@ public class ByteField extends SimpleTextField {
*/
public ByteField(String text, FontMetrics fontMetrics, int startX, int width,
boolean allowCursorAtEnd, int fieldOffset, BigInteger index,
- HighlightFactory hlFactory) {
+ FieldHighlightFactory hlFactory) {
super(text, fontMetrics, startX, width, allowCursorAtEnd, hlFactory);
this.fieldOffset = fieldOffset;
@@ -64,7 +64,7 @@ public class ByteField extends SimpleTextField {
public void paint(JComponent c, Graphics g, PaintContext context,
Rectangle clip, FieldBackgroundColorManager colorManager, RowColLocation cursorLoc, int rowHeight) {
paintSelection(g, colorManager, 0);
- paintHighlights(g, hlFactory.getHighlights(this, text, -1));
+ paintHighlights(g, hlFactory.createHighlights(this, text, -1));
g.setFont(metrics.getFont());
if (foregroundColor == null) {
foregroundColor = context.getForeground();
diff --git a/Ghidra/Features/ByteViewer/src/main/java/ghidra/app/plugin/core/byteviewer/ByteViewerComponent.java b/Ghidra/Features/ByteViewer/src/main/java/ghidra/app/plugin/core/byteviewer/ByteViewerComponent.java
index bf588e1ed1..b0f4cfb0aa 100644
--- a/Ghidra/Features/ByteViewer/src/main/java/ghidra/app/plugin/core/byteviewer/ByteViewerComponent.java
+++ b/Ghidra/Features/ByteViewer/src/main/java/ghidra/app/plugin/core/byteviewer/ByteViewerComponent.java
@@ -65,7 +65,7 @@ public class ByteViewerComponent extends FieldPanel implements FieldMouseListene
private boolean indexUpdate = true;
private FieldLocation lastFieldLoc;
- private ByteViewerHighlightProvider highlightProvider;
+ private ByteViewerHighlighter highlightProvider = new ByteViewerHighlighter();
private int highlightButton = MouseEvent.BUTTON2;
/**
@@ -86,7 +86,6 @@ public class ByteViewerComponent extends FieldPanel implements FieldMouseListene
this.bytesPerLine = bytesPerLine;
this.fm = fm;
this.layoutModel = layoutModel;
- highlightProvider = new ByteViewerHighlightProvider();
setName(model.getName());
initialize();
diff --git a/Ghidra/Features/ByteViewer/src/main/java/ghidra/app/plugin/core/byteviewer/ByteViewerHighlightProvider.java b/Ghidra/Features/ByteViewer/src/main/java/ghidra/app/plugin/core/byteviewer/ByteViewerHighlighter.java
similarity index 80%
rename from Ghidra/Features/ByteViewer/src/main/java/ghidra/app/plugin/core/byteviewer/ByteViewerHighlightProvider.java
rename to Ghidra/Features/ByteViewer/src/main/java/ghidra/app/plugin/core/byteviewer/ByteViewerHighlighter.java
index 0b85bed4c5..4c370f5891 100644
--- a/Ghidra/Features/ByteViewer/src/main/java/ghidra/app/plugin/core/byteviewer/ByteViewerHighlightProvider.java
+++ b/Ghidra/Features/ByteViewer/src/main/java/ghidra/app/plugin/core/byteviewer/ByteViewerHighlighter.java
@@ -19,17 +19,14 @@ import java.awt.Color;
import docking.widgets.fieldpanel.support.Highlight;
import generic.theme.GColor;
-import ghidra.app.util.HighlightProvider;
-import ghidra.app.util.viewer.field.FieldFactory;
-public class ByteViewerHighlightProvider implements HighlightProvider {
+class ByteViewerHighlighter {
+
private static Highlight[] NO_HIGHLIGHTS = new Highlight[0];
private String highlightText;
private Color highlightColor = new GColor("color.bg.byteviewer.highlight");
- @Override
- public Highlight[] getHighlights(String text, Object obj,
- Class<? extends FieldFactory> fieldFactoryClass, int cursorTextOffset) {
+ public Highlight[] createHighlights(String text) {
if (text.equals(highlightText)) {
return new Highlight[] { new Highlight(0, text.length() - 1, highlightColor) };
@@ -48,5 +45,4 @@ public class ByteViewerHighlightProvider implements HighlightProvider {
void setHighlightColor(Color color) {
this.highlightColor = color;
}
-
}
diff --git a/Ghidra/Features/ByteViewer/src/main/java/ghidra/app/plugin/core/byteviewer/FieldFactory.java b/Ghidra/Features/ByteViewer/src/main/java/ghidra/app/plugin/core/byteviewer/FieldFactory.java
index ea5cf500c6..68532fe051 100644
--- a/Ghidra/Features/ByteViewer/src/main/java/ghidra/app/plugin/core/byteviewer/FieldFactory.java
+++ b/Ghidra/Features/ByteViewer/src/main/java/ghidra/app/plugin/core/byteviewer/FieldFactory.java
@@ -21,9 +21,8 @@ import java.math.BigInteger;
import docking.widgets.fieldpanel.field.Field;
import docking.widgets.fieldpanel.support.Highlight;
-import docking.widgets.fieldpanel.support.HighlightFactory;
+import docking.widgets.fieldpanel.support.FieldHighlightFactory;
import ghidra.app.plugin.core.format.*;
-import ghidra.app.util.HighlightProvider;
import ghidra.program.model.address.AddressOutOfBoundsException;
/**
@@ -45,7 +44,7 @@ class FieldFactory {
private Color editColor;
private Color separatorColor;
private int unitByteSize;
- private HighlightFactory highlightFactory;
+ private FieldHighlightFactory highlightFactory;
/**
* Constructor
@@ -54,7 +53,7 @@ class FieldFactory {
* @param label label that is used as a renderer in the field viewer
*/
FieldFactory(DataFormatModel model, int bytesPerLine, int fieldOffset, FontMetrics fm,
- HighlightProvider highlightProvider) {
+ ByteViewerHighlighter highlightProvider) {
this.model = model;
this.fieldOffset = fieldOffset;
this.fm = fm;
@@ -204,7 +203,6 @@ class FieldFactory {
separatorColor = c;
}
- ///////////////////////////////////////////////////////////////////
/**
* Get the padded string that has the given char value.
*/
@@ -221,16 +219,16 @@ class FieldFactory {
return new ByteField(value, fm, startX, width, false, fieldOffset, index, highlightFactory);
}
- static class SimpleHighlightFactory implements HighlightFactory {
- private final HighlightProvider provider;
+ static class SimpleHighlightFactory implements FieldHighlightFactory {
+ private final ByteViewerHighlighter provider;
- public SimpleHighlightFactory(HighlightProvider provider) {
+ public SimpleHighlightFactory(ByteViewerHighlighter provider) {
this.provider = provider;
}
@Override
- public Highlight[] getHighlights(Field field, String text, int cursorTextOffset) {
- return provider.getHighlights(text, null, null, -1);
+ public Highlight[] createHighlights(Field field, String text, int cursorTextOffset) {
+ return provider.createHighlights(text);
}
}
}
diff --git a/Ghidra/Features/ByteViewer/src/main/java/ghidra/app/plugin/core/byteviewer/IndexFieldFactory.java b/Ghidra/Features/ByteViewer/src/main/java/ghidra/app/plugin/core/byteviewer/IndexFieldFactory.java
index 409b14ab7a..2889ff4180 100644
--- a/Ghidra/Features/ByteViewer/src/main/java/ghidra/app/plugin/core/byteviewer/IndexFieldFactory.java
+++ b/Ghidra/Features/ByteViewer/src/main/java/ghidra/app/plugin/core/byteviewer/IndexFieldFactory.java
@@ -22,7 +22,7 @@ import java.math.BigInteger;
import docking.widgets.fieldpanel.field.Field;
import docking.widgets.fieldpanel.field.SimpleTextField;
import docking.widgets.fieldpanel.support.Highlight;
-import docking.widgets.fieldpanel.support.HighlightFactory;
+import docking.widgets.fieldpanel.support.FieldHighlightFactory;
import ghidra.app.plugin.core.format.ByteBlockInfo;
/**
@@ -37,7 +37,7 @@ class IndexFieldFactory {
private String noValueStr;
private int startX;
private Color missingValueColor;
- private HighlightFactory highlightFactory = new DummyHighlightFactory();
+ private FieldHighlightFactory highlightFactory = new DummyHighlightFactory();
/**
* Constructor
@@ -136,14 +136,14 @@ class IndexFieldFactory {
missingValueColor = c;
}
- static class DummyHighlightFactory implements HighlightFactory {
+ static class DummyHighlightFactory implements FieldHighlightFactory {
private final Highlight[] NO_HIGHLIGHTS = new Highlight[0];
public DummyHighlightFactory() {
}
@Override
- public Highlight[] getHighlights(Field field, String text, int cursorTextOffset) {
+ public Highlight[] createHighlights(Field field, String text, int cursorTextOffset) {
return NO_HIGHLIGHTS;
}
}
diff --git a/Ghidra/Features/ByteViewer/src/main/java/ghidra/app/plugin/core/byteviewer/ProgramByteViewerComponentProvider.java b/Ghidra/Features/ByteViewer/src/main/java/ghidra/app/plugin/core/byteviewer/ProgramByteViewerComponentProvider.java
index 9f1a1212d2..4f73d2cdbe 100644
--- a/Ghidra/Features/ByteViewer/src/main/java/ghidra/app/plugin/core/byteviewer/ProgramByteViewerComponentProvider.java
+++ b/Ghidra/Features/ByteViewer/src/main/java/ghidra/app/plugin/core/byteviewer/ProgramByteViewerComponentProvider.java
@@ -31,7 +31,7 @@ import ghidra.app.nav.*;
import ghidra.app.plugin.core.format.*;
import ghidra.app.services.ClipboardService;
import ghidra.app.services.ProgramManager;
-import ghidra.app.util.HighlightProvider;
+import ghidra.app.util.ListingHighlightProvider;
import ghidra.framework.model.*;
import ghidra.framework.options.SaveState;
import ghidra.framework.plugintool.PluginEvent;
@@ -787,12 +787,12 @@ public class ProgramByteViewerComponentProvider extends ByteViewerComponentProvi
}
@Override
- public void removeHighlightProvider(HighlightProvider highlightProvider, Program p) {
+ public void removeHighlightProvider(ListingHighlightProvider highlightProvider, Program p) {
// currently unsupported
}
@Override
- public void setHighlightProvider(HighlightProvider highlightProvider, Program p) {
+ public void setHighlightProvider(ListingHighlightProvider highlightProvider, Program p) {
// currently unsupported
}
diff --git a/Ghidra/Features/ByteViewer/src/test.slow/java/ghidra/app/plugin/core/byteviewer/ByteViewerPlugin2Test.java b/Ghidra/Features/ByteViewer/src/test.slow/java/ghidra/app/plugin/core/byteviewer/ByteViewerPlugin2Test.java
index 0b96527272..9c46425a5e 100644
--- a/Ghidra/Features/ByteViewer/src/test.slow/java/ghidra/app/plugin/core/byteviewer/ByteViewerPlugin2Test.java
+++ b/Ghidra/Features/ByteViewer/src/test.slow/java/ghidra/app/plugin/core/byteviewer/ByteViewerPlugin2Test.java
@@ -1404,8 +1404,8 @@ public class ByteViewerPlugin2Test extends AbstractGhidraHeadedIntegrationTest {
env.showTool();
ByteViewerComponent component = panel.getCurrentComponent();
- ByteViewerHighlightProvider highlightProvider =
- (ByteViewerHighlightProvider) getInstanceField("highlightProvider", component);
+ ByteViewerHighlighter highlightProvider =
+ (ByteViewerHighlighter) getInstanceField("highlightProvider", component);
String currentHighlightText = highlightProvider.getText();
assertNull(currentHighlightText);
diff --git a/Ghidra/Features/Decompiler/src/main/java/ghidra/app/decompiler/component/ClangLayoutController.java b/Ghidra/Features/Decompiler/src/main/java/ghidra/app/decompiler/component/ClangLayoutController.java
index e1c05cf747..27a9213841 100644
--- a/Ghidra/Features/Decompiler/src/main/java/ghidra/app/decompiler/component/ClangLayoutController.java
+++ b/Ghidra/Features/Decompiler/src/main/java/ghidra/app/decompiler/component/ClangLayoutController.java
@@ -52,7 +52,7 @@ public class ClangLayoutController implements LayoutModel, LayoutModelListener {
private ClangTokenGroup docroot; // Root of displayed document
private Field[] fieldList; // Array of fields comprising layout
private FontMetrics metrics;
- private HighlightFactory hlFactory;
+ private FieldHighlightFactory hlFactory;
private ArrayList<LayoutModelListener> listeners;
private Color[] syntaxColor; // Foreground colors.
private BigInteger numIndexes = BigInteger.ZERO;
@@ -61,7 +61,7 @@ public class ClangLayoutController implements LayoutModel, LayoutModelListener {
private boolean showLineNumbers = true;
public ClangLayoutController(DecompileOptions opt, DecompilerPanel decompilerPanel,
- FontMetrics met, HighlightFactory hlFactory) {
+ FontMetrics met, FieldHighlightFactory hlFactory) {
options = opt;
this.decompilerPanel = decompilerPanel;
syntaxColor = new Color[ClangToken.MAX_COLOR];
diff --git a/Ghidra/Features/Decompiler/src/main/java/ghidra/app/decompiler/component/ClangTextField.java b/Ghidra/Features/Decompiler/src/main/java/ghidra/app/decompiler/component/ClangTextField.java
index 535f20d397..36ccb9e80d 100644
--- a/Ghidra/Features/Decompiler/src/main/java/ghidra/app/decompiler/component/ClangTextField.java
+++ b/Ghidra/Features/Decompiler/src/main/java/ghidra/app/decompiler/component/ClangTextField.java
@@ -19,7 +19,7 @@ import java.util.List;
import docking.widgets.fieldpanel.field.*;
import docking.widgets.fieldpanel.support.FieldLocation;
-import docking.widgets.fieldpanel.support.HighlightFactory;
+import docking.widgets.fieldpanel.support.FieldHighlightFactory;
import ghidra.app.decompiler.ClangToken;
public class ClangTextField extends WrappingVerticalLayoutTextField {
@@ -32,7 +32,7 @@ public class ClangTextField extends WrappingVerticalLayoutTextField {
}
public ClangTextField(List<ClangToken> tokenList, FieldElement[] fieldElements, int x,
- int lineNumber, int width, HighlightFactory hlFactory) {
+ int lineNumber, int width, FieldHighlightFactory hlFactory) {
super(createSingleLineElement(fieldElements), x, width - x, 30, hlFactory, false);
this.tokenList = tokenList;
this.lineNumber = lineNumber;
diff --git a/Ghidra/Features/Decompiler/src/main/java/ghidra/app/decompiler/component/DecompilerPanel.java b/Ghidra/Features/Decompiler/src/main/java/ghidra/app/decompiler/component/DecompilerPanel.java
index 86fc41927f..649866b193 100644
--- a/Ghidra/Features/Decompiler/src/main/java/ghidra/app/decompiler/component/DecompilerPanel.java
+++ b/Ghidra/Features/Decompiler/src/main/java/ghidra/app/decompiler/component/DecompilerPanel.java
@@ -78,7 +78,7 @@ public class DecompilerPanel extends JPanel implements FieldMouseListener, Field
private final List<DecompilerMarginProvider> marginProviders = new ArrayList<>();
private final VerticalLayoutPixelIndexMap pixmap = new VerticalLayoutPixelIndexMap();
- private HighlightFactory hlFactory;
+ private FieldHighlightFactory hlFactory;
private ClangHighlightController highlightController;
private Map<String, ClangDecompilerHighlighter> highlightersById = new HashMap<>();
private PendingHighlightUpdate pendingHighlightUpdate;
@@ -1220,10 +1220,10 @@ public class DecompilerPanel extends JPanel implements FieldMouseListener, Field
// Inner Classes
//==================================================================================================
- private class SearchHighlightFactory implements HighlightFactory {
+ private class SearchHighlightFactory implements FieldHighlightFactory {
@Override
- public Highlight[] getHighlights(Field field, String text, int cursorTextOffset) {
+ public Highlight[] createHighlights(Field field, String text, int cursorTextOffset) {
if (currentSearchLocation == null) {
return new Highlight[0];
}
diff --git a/Ghidra/Features/Decompiler/src/main/java/ghidra/app/plugin/core/decompile/DecompilerProvider.java b/Ghidra/Features/Decompiler/src/main/java/ghidra/app/plugin/core/decompile/DecompilerProvider.java
index 6a0b8accc3..b4285c6a6b 100644
--- a/Ghidra/Features/Decompiler/src/main/java/ghidra/app/plugin/core/decompile/DecompilerProvider.java
+++ b/Ghidra/Features/Decompiler/src/main/java/ghidra/app/plugin/core/decompile/DecompilerProvider.java
@@ -37,7 +37,7 @@ import ghidra.app.nav.*;
import ghidra.app.plugin.core.decompile.actions.*;
import ghidra.app.services.*;
import ghidra.app.util.HelpTopics;
-import ghidra.app.util.HighlightProvider;
+import ghidra.app.util.ListingHighlightProvider;
import ghidra.framework.model.*;
import ghidra.framework.options.*;
import ghidra.framework.plugintool.NavigatableComponentProviderAdapter;
@@ -1108,12 +1108,12 @@ public class DecompilerProvider extends NavigatableComponentProviderAdapter
}
@Override
- public void removeHighlightProvider(HighlightProvider highlightProvider, Program p) {
+ public void removeHighlightProvider(ListingHighlightProvider highlightProvider, Program p) {
// currently unsupported
}
@Override
- public void setHighlightProvider(HighlightProvider highlightProvider, Program p) {
+ public void setHighlightProvider(ListingHighlightProvider highlightProvider, Program p) {
// currently unsupported
}
diff --git a/Ghidra/Features/FunctionGraph/src/main/java/ghidra/app/plugin/core/functiongraph/FGProvider.java b/Ghidra/Features/FunctionGraph/src/main/java/ghidra/app/plugin/core/functiongraph/FGProvider.java
index 4e08ac7d75..2d01d3f286 100644
--- a/Ghidra/Features/FunctionGraph/src/main/java/ghidra/app/plugin/core/functiongraph/FGProvider.java
+++ b/Ghidra/Features/FunctionGraph/src/main/java/ghidra/app/plugin/core/functiongraph/FGProvider.java
@@ -33,7 +33,7 @@ import ghidra.app.plugin.core.functiongraph.graph.vertex.FGVertex;
import ghidra.app.plugin.core.functiongraph.graph.vertex.GroupedFunctionGraphVertex;
import ghidra.app.plugin.core.functiongraph.mvc.*;
import ghidra.app.services.*;
-import ghidra.app.util.HighlightProvider;
+import ghidra.app.util.ListingHighlightProvider;
import ghidra.framework.model.*;
import ghidra.framework.options.SaveState;
import ghidra.framework.plugintool.PluginTool;
@@ -1298,12 +1298,12 @@ public class FGProvider extends VisualGraphComponentProvider<FGVertex, FGEdge, F
}
@Override
- public void removeHighlightProvider(HighlightProvider highlightProvider, Program program) {
+ public void removeHighlightProvider(ListingHighlightProvider highlightProvider, Program program) {
// currently unsupported
}
@Override
- public void setHighlightProvider(HighlightProvider highlightProvider, Program program) {
+ public void setHighlightProvider(ListingHighlightProvider highlightProvider, Program program) {
// currently unsupported
}
diff --git a/Ghidra/Features/FunctionGraph/src/main/java/ghidra/app/plugin/core/functiongraph/mvc/FGController.java b/Ghidra/Features/FunctionGraph/src/main/java/ghidra/app/plugin/core/functiongraph/mvc/FGController.java
index 9773f95e9c..4d53daab0b 100644
--- a/Ghidra/Features/FunctionGraph/src/main/java/ghidra/app/plugin/core/functiongraph/mvc/FGController.java
+++ b/Ghidra/Features/FunctionGraph/src/main/java/ghidra/app/plugin/core/functiongraph/mvc/FGController.java
@@ -33,7 +33,7 @@ import docking.widgets.fieldpanel.support.FieldLocation;
import docking.widgets.fieldpanel.support.Highlight;
import ghidra.GhidraOptions;
import ghidra.app.nav.Navigatable;
-import ghidra.app.plugin.core.codebrowser.ListingHighlightProvider;
+import ghidra.app.plugin.core.codebrowser.ListingMiddleMouseHighlightProvider;
import ghidra.app.plugin.core.functiongraph.*;
import ghidra.app.plugin.core.functiongraph.graph.FGEdge;
import ghidra.app.plugin.core.functiongraph.graph.FunctionGraph;
@@ -41,7 +41,7 @@ import ghidra.app.plugin.core.functiongraph.graph.layout.FGLayoutProvider;
import ghidra.app.plugin.core.functiongraph.graph.vertex.*;
import ghidra.app.services.ButtonPressedListener;
import ghidra.app.services.CodeViewerService;
-import ghidra.app.util.HighlightProvider;
+import ghidra.app.util.ListingHighlightProvider;
import ghidra.app.util.viewer.field.FieldFactory;
import ghidra.app.util.viewer.field.ListingField;
import ghidra.app.util.viewer.format.FieldFormatModel;
@@ -81,7 +81,7 @@ public class FGController implements ProgramLocationListener, ProgramSelectionLi
private FunctionGraphOptions functionGraphOptions;
- private SharedHighlightProvider sharedHighlightProvider;
+ private FgHighlightProvider sharedHighlightProvider;
private StringSelectionListener sharedStringSelectionListener =
string -> provider.setClipboardStringContent(string);
@@ -140,7 +140,7 @@ public class FGController implements ProgramLocationListener, ProgramSelectionLi
private void setMinimalFormatManager(FormatManager formatManager) {
this.minimalFormatManager = formatManager;
- SharedHighlightProvider highlightProvider = lazilyCreateSharedHighlightProvider();
+ FgHighlightProvider highlightProvider = lazilyCreateSharedHighlightProvider();
minimalFormatManager.addHighlightProvider(highlightProvider);
}
@@ -158,12 +158,12 @@ public class FGController implements ProgramLocationListener, ProgramSelectionLi
return defaultFormatManager;
}
- private SharedHighlightProvider lazilyCreateSharedHighlightProvider() {
+ private FgHighlightProvider lazilyCreateSharedHighlightProvider() {
if (sharedHighlightProvider != null) {
return sharedHighlightProvider;
}
sharedHighlightProvider =
- new SharedHighlightProvider(plugin.getTool(), provider.getComponent());
+ new FgHighlightProvider(plugin.getTool(), provider.getComponent());
return sharedHighlightProvider;
}
@@ -1067,18 +1067,17 @@ public class FGController implements ProgramLocationListener, ProgramSelectionLi
// Inner Classes
//==================================================================================================
- private static class SharedHighlightProvider
- implements HighlightProvider, ButtonPressedListener {
- private ListingHighlightProvider highlighter;
+ private static class FgHighlightProvider
+ implements ListingHighlightProvider, ButtonPressedListener {
+ private ListingMiddleMouseHighlightProvider highlighter;
- SharedHighlightProvider(PluginTool tool, Component repaintComponent) {
- highlighter = new ListingHighlightProvider(tool, repaintComponent);
+ FgHighlightProvider(PluginTool tool, Component repaintComponent) {
+ highlighter = new ListingMiddleMouseHighlightProvider(tool, repaintComponent);
}
@Override
- public Highlight[] getHighlights(String text, Object obj,
- Class<? extends FieldFactory> fieldFactoryClass, int cursorTextOffset) {
- return highlighter.getHighlights(text, obj, fieldFactoryClass, cursorTextOffset);
+ public Highlight[] createHighlights(String text, ListingField field, int cursorTextOffset) {
+ return highlighter.createHighlights(text, field, cursorTextOffset);
}
@Override
diff --git a/Ghidra/Features/ProgramDiff/src/main/java/ghidra/app/plugin/core/diff/DiffNavigatable.java b/Ghidra/Features/ProgramDiff/src/main/java/ghidra/app/plugin/core/diff/DiffNavigatable.java
index 29617a3050..e10412929a 100644
--- a/Ghidra/Features/ProgramDiff/src/main/java/ghidra/app/plugin/core/diff/DiffNavigatable.java
+++ b/Ghidra/Features/ProgramDiff/src/main/java/ghidra/app/plugin/core/diff/DiffNavigatable.java
@@ -19,7 +19,7 @@ import javax.swing.Icon;
import ghidra.app.nav.*;
import ghidra.app.plugin.core.codebrowser.CodeViewerLocationMemento;
-import ghidra.app.util.HighlightProvider;
+import ghidra.app.util.ListingHighlightProvider;
import ghidra.program.model.listing.Program;
import ghidra.program.util.ProgramLocation;
import ghidra.program.util.ProgramSelection;
@@ -173,13 +173,13 @@ class DiffNavigatable implements Navigatable {
}
@Override
- public void setHighlightProvider(HighlightProvider highlightProvider, Program program) {
+ public void setHighlightProvider(ListingHighlightProvider highlightProvider, Program program) {
// CodeViewerProvider handles the other listing (the Diff listing) highlights.
navigatable.setHighlightProvider(highlightProvider, program);
}
@Override
- public void removeHighlightProvider(HighlightProvider highlightProvider, Program program) {
+ public void removeHighlightProvider(ListingHighlightProvider highlightProvider, Program program) {
// CodeViewerProvider handles the other listing (the Diff listing) highlights.
navigatable.removeHighlightProvider(highlightProvider, program);
}
diff --git a/Ghidra/Features/VersionTracking/src/main/java/ghidra/feature/vt/gui/duallisting/VTDualListingHighlightProvider.java b/Ghidra/Features/VersionTracking/src/main/java/ghidra/feature/vt/gui/duallisting/VTDualListingHighlightProvider.java
index 07a21479b5..3cf79ea578 100644
--- a/Ghidra/Features/VersionTracking/src/main/java/ghidra/feature/vt/gui/duallisting/VTDualListingHighlightProvider.java
+++ b/Ghidra/Features/VersionTracking/src/main/java/ghidra/feature/vt/gui/duallisting/VTDualListingHighlightProvider.java
@@ -20,10 +20,11 @@ import java.util.*;
import docking.widgets.fieldpanel.support.Highlight;
import generic.theme.GColor;
-import ghidra.app.plugin.core.codebrowser.ListingHighlightProvider;
-import ghidra.app.util.HighlightProvider;
+import ghidra.app.plugin.core.codebrowser.ListingMiddleMouseHighlightProvider;
+import ghidra.app.util.ListingHighlightProvider;
import ghidra.app.util.viewer.field.*;
import ghidra.app.util.viewer.listingpanel.ListingPanel;
+import ghidra.app.util.viewer.proxy.ProxyObj;
import ghidra.feature.vt.api.main.*;
import ghidra.feature.vt.api.markuptype.*;
import ghidra.feature.vt.api.stringable.*;
@@ -37,7 +38,7 @@ import ghidra.program.model.listing.*;
import ghidra.util.Msg;
import ghidra.util.exception.AssertException;
-public class VTDualListingHighlightProvider implements HighlightProvider {
+public class VTDualListingHighlightProvider implements ListingHighlightProvider {
private static Color APPLIED_MARKUP_COLOR =
new GColor("color.bg.version.tracking.dual.listing.highlight.markup.applied");
@@ -60,7 +61,7 @@ public class VTDualListingHighlightProvider implements HighlightProvider {
new HashMap<>();
private final VTController controller;
private ListingPanel listingPanel;
- private ListingHighlightProvider listingHighlighter;
+ private ListingMiddleMouseHighlightProvider listingHighlighter;
private VTMarkupItem currentMarkupItem;
private boolean isSource;
@@ -80,7 +81,7 @@ public class VTDualListingHighlightProvider implements HighlightProvider {
if (listingPanel != null) {
this.listingHighlighter =
- new ListingHighlightProvider(controller.getTool(), listingPanel);
+ new ListingMiddleMouseHighlightProvider(controller.getTool(), listingPanel);
listingPanel.removeButtonPressedListener(listingHighlighter);
listingPanel.addButtonPressedListener(listingHighlighter);
}
@@ -128,8 +129,7 @@ public class VTDualListingHighlightProvider implements HighlightProvider {
}
@Override
- public Highlight[] getHighlights(String text, Object obj,
- Class<? extends FieldFactory> fieldFactoryClass, int cursorTextOffset) {
+ public Highlight[] createHighlights(String text, ListingField field, int cursorTextOffset) {
VTSession session = controller.getSession();
if (session == null) {
@@ -141,8 +141,11 @@ public class VTDualListingHighlightProvider implements HighlightProvider {
if (matchInfo == null) {
return new Highlight[0];
}
- Highlight[] highlights = new Highlight[0];
+ ProxyObj<?> proxy = field.getProxy();
+ Object obj = proxy.getObject();
+ Highlight[] highlights = new Highlight[0];
+ Class<? extends FieldFactory> fieldFactoryClass = field.getFieldFactory().getClass();
if (fieldFactoryClass == FunctionSignatureFieldFactory.class) {
highlights = getFunctionSignatureHighlights(text, obj, cursorTextOffset);
}
@@ -217,19 +220,21 @@ public class VTDualListingHighlightProvider implements HighlightProvider {
highlightList.add(highlight);
}
- highlightList.addAll(getListingHighlights(text, obj, fieldFactoryClass, cursorTextOffset));
+ highlightList.addAll(
+ getListingHighlights(text, obj, fieldFactoryClass, field, cursorTextOffset));
return highlightList.toArray(new Highlight[highlightList.size()]);
}
private Collection<? extends Highlight> getListingHighlights(String text, Object obj,
- Class<? extends FieldFactory> fieldFactoryClass, int cursorTextOffset) {
+ Class<? extends FieldFactory> fieldFactoryClass, ListingField field,
+ int cursorTextOffset) {
if (listingHighlighter == null) {
return Collections.emptyList();
}
- return Arrays.asList(listingHighlighter.getHighlights(text, obj, fieldFactoryClass,
- cursorTextOffset));
+ return Arrays.asList(
+ listingHighlighter.createHighlights(text, field, cursorTextOffset));
}
private Color getMarkupBackgroundColor(int cursorTextOffset, VTMarkupItem vtMarkupItem,
diff --git a/Ghidra/Features/VersionTracking/src/main/java/ghidra/feature/vt/gui/duallisting/VTListingNavigator.java b/Ghidra/Features/VersionTracking/src/main/java/ghidra/feature/vt/gui/duallisting/VTListingNavigator.java
index efc0d46be0..90080aa64f 100644
--- a/Ghidra/Features/VersionTracking/src/main/java/ghidra/feature/vt/gui/duallisting/VTListingNavigator.java
+++ b/Ghidra/Features/VersionTracking/src/main/java/ghidra/feature/vt/gui/duallisting/VTListingNavigator.java
@@ -18,7 +18,7 @@ package ghidra.feature.vt.gui.duallisting;
import javax.swing.Icon;
import ghidra.app.nav.*;
-import ghidra.app.util.HighlightProvider;
+import ghidra.app.util.ListingHighlightProvider;
import ghidra.app.util.viewer.listingpanel.ListingCodeComparisonPanel;
import ghidra.app.util.viewer.listingpanel.ListingPanel;
import ghidra.program.model.listing.Program;
@@ -147,12 +147,12 @@ public class VTListingNavigator implements Navigatable {
}
@Override
- public void removeHighlightProvider(HighlightProvider highlightProvider, Program program) {
+ public void removeHighlightProvider(ListingHighlightProvider highlightProvider, Program program) {
// currently unsupported
}
@Override
- public void setHighlightProvider(HighlightProvider highlightProvider, Program program) {
+ public void setHighlightProvider(ListingHighlightProvider highlightProvider, Program program) {
// currently unsupported
}
diff --git a/Ghidra/Framework/Docking/src/main/java/docking/widgets/fieldpanel/field/ClippingTextField.java b/Ghidra/Framework/Docking/src/main/java/docking/widgets/fieldpanel/field/ClippingTextField.java
index 18ce8acff7..e7d89dca8a 100644
--- a/Ghidra/Framework/Docking/src/main/java/docking/widgets/fieldpanel/field/ClippingTextField.java
+++ b/Ghidra/Framework/Docking/src/main/java/docking/widgets/fieldpanel/field/ClippingTextField.java
@@ -44,7 +44,7 @@ public class ClippingTextField implements TextField {
private String fullText;
private boolean isClipped;
- private HighlightFactory hlFactory;
+ private FieldHighlightFactory hlFactory;
private boolean isPrimary;
@@ -58,7 +58,7 @@ public class ClippingTextField implements TextField {
* @param hlFactory The HighlightFactory object used to paint highlights.
*/
public ClippingTextField(int startX, int width, FieldElement textElement,
- HighlightFactory hlFactory) {
+ FieldHighlightFactory hlFactory) {
// default to one row
this(startX, width, textElement, 1, hlFactory);
}
@@ -77,7 +77,7 @@ public class ClippingTextField implements TextField {
* @param hlFactory The HighlightFactory object used to paint highlights.
*/
public ClippingTextField(int startX, int width, FieldElement textElement, int numDataRows,
- HighlightFactory hlFactory) {
+ FieldHighlightFactory hlFactory) {
this.startX = startX;
this.width = width;
@@ -282,7 +282,7 @@ public class ClippingTextField implements TextField {
if (cursorLoc != null) {
cursorTextOffset = screenLocationToTextOffset(cursorLoc.row(), cursorLoc.col());
}
- paintHighlights(g, hlFactory.getHighlights(this, getString(), cursorTextOffset));
+ paintHighlights(g, hlFactory.createHighlights(this, getString(), cursorTextOffset));
}
protected void paintSelection(Graphics g, FieldBackgroundColorManager colorManager, int row,
diff --git a/Ghidra/Framework/Docking/src/main/java/docking/widgets/fieldpanel/field/CompositeVerticalLayoutTextField.java b/Ghidra/Framework/Docking/src/main/java/docking/widgets/fieldpanel/field/CompositeVerticalLayoutTextField.java
index 58096b17c5..29a6fe3794 100644
--- a/Ghidra/Framework/Docking/src/main/java/docking/widgets/fieldpanel/field/CompositeVerticalLayoutTextField.java
+++ b/Ghidra/Framework/Docking/src/main/java/docking/widgets/fieldpanel/field/CompositeVerticalLayoutTextField.java
@@ -52,7 +52,7 @@ public class CompositeVerticalLayoutTextField implements TextField {
private int startX;
private int width;
private int preferredWidth;
- private HighlightFactory hlFactory;
+ private FieldHighlightFactory hlFactory;
private int height;
private int heightAbove;
@@ -71,12 +71,12 @@ public class CompositeVerticalLayoutTextField implements TextField {
private boolean isClipped;
public CompositeVerticalLayoutTextField(List<TextField> fields, int startX, int width,
- int maxLines, HighlightFactory hlFactory) {
+ int maxLines, FieldHighlightFactory hlFactory) {
this(fields, startX, width, maxLines, hlFactory, " ");
}
protected CompositeVerticalLayoutTextField(List<TextField> fields, int startX, int width,
- int maxLines, HighlightFactory hlFactory, String rowSeparator) {
+ int maxLines, FieldHighlightFactory hlFactory, String rowSeparator) {
this.startX = startX;
this.width = width;
diff --git a/Ghidra/Framework/Docking/src/main/java/docking/widgets/fieldpanel/field/FlowLayoutTextField.java b/Ghidra/Framework/Docking/src/main/java/docking/widgets/fieldpanel/field/FlowLayoutTextField.java
index 6aa571491c..19726dfb75 100644
--- a/Ghidra/Framework/Docking/src/main/java/docking/widgets/fieldpanel/field/FlowLayoutTextField.java
+++ b/Ghidra/Framework/Docking/src/main/java/docking/widgets/fieldpanel/field/FlowLayoutTextField.java
@@ -17,7 +17,7 @@ package docking.widgets.fieldpanel.field;
import java.util.*;
-import docking.widgets.fieldpanel.support.HighlightFactory;
+import docking.widgets.fieldpanel.support.FieldHighlightFactory;
/**
* This class provides a TextField implementation that takes multiple AttributedString field
@@ -41,7 +41,7 @@ public class FlowLayoutTextField extends VerticalLayoutTextField {
*/
@Deprecated(since = "10.1", forRemoval = true)
public FlowLayoutTextField(FieldElement[] textElements, int startX,
- int width, int maxLines, HighlightFactory hlFactory) {
+ int width, int maxLines, FieldHighlightFactory hlFactory) {
this(Arrays.asList(textElements), startX, width, maxLines, hlFactory);
}
@@ -58,7 +58,7 @@ public class FlowLayoutTextField extends VerticalLayoutTextField {
* @param hlFactory the highlight factory
*/
public FlowLayoutTextField(List<FieldElement> elements, int startX,
- int width, int maxLines, HighlightFactory hlFactory) {
+ int width, int maxLines, FieldHighlightFactory hlFactory) {
super(createLineElements(elements, width), startX, width, maxLines, hlFactory, "");
}
diff --git a/Ghidra/Framework/Docking/src/main/java/docking/widgets/fieldpanel/field/ReverseClippingTextField.java b/Ghidra/Framework/Docking/src/main/java/docking/widgets/fieldpanel/field/ReverseClippingTextField.java
index 7fe81e8e7b..15658cb49b 100644
--- a/Ghidra/Framework/Docking/src/main/java/docking/widgets/fieldpanel/field/ReverseClippingTextField.java
+++ b/Ghidra/Framework/Docking/src/main/java/docking/widgets/fieldpanel/field/ReverseClippingTextField.java
@@ -47,7 +47,7 @@ public class ReverseClippingTextField implements TextField {
private String fullText;
private boolean isClipped;
- private HighlightFactory hlFactory;
+ private FieldHighlightFactory hlFactory;
private boolean isPrimary;
@@ -69,7 +69,7 @@ public class ReverseClippingTextField implements TextField {
* The HighlightFactory object used to paint highlights.
*/
public ReverseClippingTextField(int startX, int width, FieldElement textElement,
- HighlightFactory hlFactory) {
+ FieldHighlightFactory hlFactory) {
this.startX = startX;
@@ -302,7 +302,7 @@ public class ReverseClippingTextField implements TextField {
if (cursorLoc != null) {
cursorTextOffset = screenLocationToTextOffset(cursorLoc.row(), cursorLoc.col());
}
- paintHighlights(g, hlFactory.getHighlights(this, getString(), cursorTextOffset));
+ paintHighlights(g, hlFactory.createHighlights(this, getString(), cursorTextOffset));
}
protected void paintHighlights(Graphics g, Highlight[] highlights) {
diff --git a/Ghidra/Framework/Docking/src/main/java/docking/widgets/fieldpanel/field/SimpleTextField.java b/Ghidra/Framework/Docking/src/main/java/docking/widgets/fieldpanel/field/SimpleTextField.java
index d86bbff75d..802b8a72b8 100644
--- a/Ghidra/Framework/Docking/src/main/java/docking/widgets/fieldpanel/field/SimpleTextField.java
+++ b/Ghidra/Framework/Docking/src/main/java/docking/widgets/fieldpanel/field/SimpleTextField.java
@@ -43,7 +43,7 @@ public class SimpleTextField implements Field {
protected int numCols;
protected boolean allowCursorAtEnd;
protected boolean isPrimary;
- protected final HighlightFactory hlFactory;
+ protected final FieldHighlightFactory hlFactory;
/**
* Constructs a new SimpleTextField.
@@ -55,7 +55,7 @@ public class SimpleTextField implements Field {
* the end of the text.
*/
public SimpleTextField(String text, FontMetrics fontMetrics, int startX, int width,
- boolean allowCursorAtEnd, HighlightFactory hlFactory) {
+ boolean allowCursorAtEnd, FieldHighlightFactory hlFactory) {
this.text = text;
this.hlFactory = hlFactory;
@@ -207,7 +207,7 @@ public class SimpleTextField implements Field {
Rectangle clip, FieldBackgroundColorManager colorManager, RowColLocation cursorLoc,
int rowHeight) {
paintSelection(g, colorManager, 0);
- paintHighlights(g, hlFactory.getHighlights(this, text, -1));
+ paintHighlights(g, hlFactory.createHighlights(this, text, -1));
g.setFont(metrics.getFont());
if (foregroundColor == null) {
foregroundColor = context.getForeground();
diff --git a/Ghidra/Framework/Docking/src/main/java/docking/widgets/fieldpanel/field/VerticalLayoutTextField.java b/Ghidra/Framework/Docking/src/main/java/docking/widgets/fieldpanel/field/VerticalLayoutTextField.java
index 11606f3a5b..665356fe97 100644
--- a/Ghidra/Framework/Docking/src/main/java/docking/widgets/fieldpanel/field/VerticalLayoutTextField.java
+++ b/Ghidra/Framework/Docking/src/main/java/docking/widgets/fieldpanel/field/VerticalLayoutTextField.java
@@ -42,7 +42,7 @@ public class VerticalLayoutTextField implements TextField {
protected int startX;
protected int width;
protected int preferredWidth;
- protected HighlightFactory hlFactory;
+ protected FieldHighlightFactory hlFactory;
private int height;
private int heightAbove;
@@ -71,7 +71,7 @@ public class VerticalLayoutTextField implements TextField {
*/
@Deprecated(since = "10.1", forRemoval = true)
public VerticalLayoutTextField(FieldElement[] textElements, int startX, int width, int maxLines,
- HighlightFactory hlFactory) {
+ FieldHighlightFactory hlFactory) {
this(Arrays.asList(textElements), startX, width, maxLines, hlFactory, " ");
}
@@ -87,7 +87,7 @@ public class VerticalLayoutTextField implements TextField {
*/
public VerticalLayoutTextField(List<FieldElement> textElements, int startX, int width,
int maxLines,
- HighlightFactory hlFactory) {
+ FieldHighlightFactory hlFactory) {
this(textElements, startX, width, maxLines, hlFactory, " ");
}
@@ -104,7 +104,7 @@ public class VerticalLayoutTextField implements TextField {
* getText() method.
*/
protected VerticalLayoutTextField(List<FieldElement> textElements, int startX, int width,
- int maxLines, HighlightFactory hlFactory, String rowSeparator) {
+ int maxLines, FieldHighlightFactory hlFactory, String rowSeparator) {
this.startX = startX;
this.width = width;
@@ -280,7 +280,7 @@ public class VerticalLayoutTextField implements TextField {
cursorRow = cursorLoc.row();
}
- Highlight[] highlights = hlFactory.getHighlights(this, getText(), cursorTextOffset);
+ Highlight[] highlights = hlFactory.createHighlights(this, getText(), cursorTextOffset);
int columns = 0;
int n = subFields.size();
diff --git a/Ghidra/Framework/Docking/src/main/java/docking/widgets/fieldpanel/field/WrappingVerticalLayoutTextField.java b/Ghidra/Framework/Docking/src/main/java/docking/widgets/fieldpanel/field/WrappingVerticalLayoutTextField.java
index 2fe0578fab..d59edeec88 100644
--- a/Ghidra/Framework/Docking/src/main/java/docking/widgets/fieldpanel/field/WrappingVerticalLayoutTextField.java
+++ b/Ghidra/Framework/Docking/src/main/java/docking/widgets/fieldpanel/field/WrappingVerticalLayoutTextField.java
@@ -33,7 +33,7 @@ public class WrappingVerticalLayoutTextField extends VerticalLayoutTextField {
* @param hlFactory the highlight factory
*/
public WrappingVerticalLayoutTextField(FieldElement textElement, int startX, int width,
- int maxLines, HighlightFactory hlFactory) {
+ int maxLines, FieldHighlightFactory hlFactory) {
super(FieldUtils.wrap(textElement, width), startX, width, maxLines, hlFactory, " ");
}
@@ -49,7 +49,7 @@ public class WrappingVerticalLayoutTextField extends VerticalLayoutTextField {
* @param breakOnWhiteSpace is true if wrapping should break on word boundaries
*/
public WrappingVerticalLayoutTextField(FieldElement textElement, int startX, int width,
- int maxLines, HighlightFactory hlFactory, boolean breakOnWhiteSpace) {
+ int maxLines, FieldHighlightFactory hlFactory, boolean breakOnWhiteSpace) {
super(FieldUtils.wrap(textElement, width, breakOnWhiteSpace), startX, width, maxLines,
hlFactory, " ");
}
diff --git a/Ghidra/Framework/Docking/src/main/java/docking/widgets/fieldpanel/internal/TestBigLayoutModel.java b/Ghidra/Framework/Docking/src/main/java/docking/widgets/fieldpanel/internal/TestBigLayoutModel.java
index 07c8b8bb92..c7ec9a4254 100644
--- a/Ghidra/Framework/Docking/src/main/java/docking/widgets/fieldpanel/internal/TestBigLayoutModel.java
+++ b/Ghidra/Framework/Docking/src/main/java/docking/widgets/fieldpanel/internal/TestBigLayoutModel.java
@@ -32,7 +32,7 @@ import generic.theme.GThemeDefaults.Colors;
public class TestBigLayoutModel implements LayoutModel {
private static final Highlight[] NO_HIGHLIGHTS = new Highlight[0];
- private static final HighlightFactory hlFactory =
+ private static final FieldHighlightFactory hlFactory =
(field, text, cursorTextOffset) -> NO_HIGHLIGHTS;
ArrayList<LayoutModelListener> listeners = new ArrayList<>();
diff --git a/Ghidra/Framework/Docking/src/main/java/docking/widgets/fieldpanel/support/HighlightFactory.java b/Ghidra/Framework/Docking/src/main/java/docking/widgets/fieldpanel/support/FieldHighlightFactory.java
similarity index 81%
rename from Ghidra/Framework/Docking/src/main/java/docking/widgets/fieldpanel/support/HighlightFactory.java
rename to Ghidra/Framework/Docking/src/main/java/docking/widgets/fieldpanel/support/FieldHighlightFactory.java
index 8ac6c85d17..49667a881f 100644
--- a/Ghidra/Framework/Docking/src/main/java/docking/widgets/fieldpanel/support/HighlightFactory.java
+++ b/Ghidra/Framework/Docking/src/main/java/docking/widgets/fieldpanel/support/FieldHighlightFactory.java
@@ -17,7 +17,12 @@ package docking.widgets.fieldpanel.support;
import docking.widgets.fieldpanel.field.Field;
-public interface HighlightFactory {
+/**
+ * A highlighter for for {@link Field}s.
+ */
+public interface FieldHighlightFactory {
+
+ public static Highlight[] NO_HIGHLIGHTS = new Highlight[0];
/**
* Returns the highlights for the given text
@@ -28,5 +33,5 @@ public interface HighlightFactory {
* cursor is not in this field.
* @return an array of highlights to be rendered
*/
- public Highlight[] getHighlights(Field field, String text, int cursorTextOffset);
+ public Highlight[] createHighlights(Field field, String text, int cursorTextOffset);
}
diff --git a/Ghidra/Framework/Docking/src/test/java/docking/widgets/fieldpanel/FlowLayoutTextFieldTest.java b/Ghidra/Framework/Docking/src/test/java/docking/widgets/fieldpanel/FlowLayoutTextFieldTest.java
index cb594d1302..fb538c131f 100644
--- a/Ghidra/Framework/Docking/src/test/java/docking/widgets/fieldpanel/FlowLayoutTextFieldTest.java
+++ b/Ghidra/Framework/Docking/src/test/java/docking/widgets/fieldpanel/FlowLayoutTextFieldTest.java
@@ -39,7 +39,7 @@ public class FlowLayoutTextFieldTest extends AbstractGenericTest {
@Before
public void setUp() throws Exception {
- HighlightFactory factory = (field, text, cursorTextOffset) -> {
+ FieldHighlightFactory factory = (field, text, cursorTextOffset) -> {
return new Highlight[] { new Highlight(4, 4, Palette.YELLOW) };
};
diff --git a/Ghidra/Framework/Docking/src/test/java/docking/widgets/fieldpanel/VerticalLayoutTextFieldTest.java b/Ghidra/Framework/Docking/src/test/java/docking/widgets/fieldpanel/VerticalLayoutTextFieldTest.java
index 269b56ff9d..9325668b2c 100644
--- a/Ghidra/Framework/Docking/src/test/java/docking/widgets/fieldpanel/VerticalLayoutTextFieldTest.java
+++ b/Ghidra/Framework/Docking/src/test/java/docking/widgets/fieldpanel/VerticalLayoutTextFieldTest.java
@@ -39,7 +39,7 @@ public class VerticalLayoutTextFieldTest extends AbstractGenericTest {
@Before
public void setUp() throws Exception {
- HighlightFactory factory = (f, text, cursorTextOffset) -> {
+ FieldHighlightFactory factory = (f, text, cursorTextOffset) -> {
return new Highlight[] { new Highlight(4, 4, Palette.YELLOW) };
};
diff --git a/Ghidra/Framework/Docking/src/test/java/docking/widgets/fieldpanel/field/CompositeVerticalLayoutTextFieldTest.java b/Ghidra/Framework/Docking/src/test/java/docking/widgets/fieldpanel/field/CompositeVerticalLayoutTextFieldTest.java
index 9f74f137e3..a695c6ccea 100644
--- a/Ghidra/Framework/Docking/src/test/java/docking/widgets/fieldpanel/field/CompositeVerticalLayoutTextFieldTest.java
+++ b/Ghidra/Framework/Docking/src/test/java/docking/widgets/fieldpanel/field/CompositeVerticalLayoutTextFieldTest.java
@@ -42,7 +42,7 @@ public class CompositeVerticalLayoutTextFieldTest extends AbstractGenericTest {
int width = 100; // used to trigger horizontal clipping
int maxLines = 5; // used to trigger vertical clipping
- private HighlightFactory hlFactory = (hlField, text, cursorTextOffset) -> {
+ private FieldHighlightFactory hlFactory = (hlField, text, cursorTextOffset) -> {
return new Highlight[] {};
};
diff --git a/Ghidra/Framework/SoftwareModeling/src/main/java/ghidra/program/util/BytesFieldLocation.java b/Ghidra/Framework/SoftwareModeling/src/main/java/ghidra/program/util/BytesFieldLocation.java
index 803eea862a..25b5859992 100644
--- a/Ghidra/Framework/SoftwareModeling/src/main/java/ghidra/program/util/BytesFieldLocation.java
+++ b/Ghidra/Framework/SoftwareModeling/src/main/java/ghidra/program/util/BytesFieldLocation.java
@@ -19,10 +19,8 @@ import ghidra.program.model.address.Address;
import ghidra.program.model.listing.*;
/**
- * The <CODE>BytesFieldLocation</CODE> class provides specific information
- * about the BYTES field within a program location.
+ * Provides specific information about the bytes field within a program location.
*/
-
public class BytesFieldLocation extends CodeUnitLocation {
/**
@@ -42,10 +40,9 @@ public class BytesFieldLocation extends CodeUnitLocation {
}
/**
- * Creates a new BytesFieldLocation for the given address.
- * The address will be adjusted to the beginning of the code unit containing
- * that address(if it exists). The original address can be retrieved using
- * the "getByteAddress()" method.
+ * Creates a new BytesFieldLocation for the given address. The address will be adjusted to the
+ * beginning of the code unit containing that address(if it exists). The original address can
+ * be retrieved using the "getByteAddress()" method.
* @param program the program that this location is related.
* @param addr the address of the byte for this location.
*/
@@ -56,7 +53,7 @@ public class BytesFieldLocation extends CodeUnitLocation {
private static int[] getComponentPath(Program program, Address addr) {
CodeUnit cu = program.getListing().getCodeUnitContaining(addr);
- // if the codeunit is a data, try and dig down to the lowest subdata containing the address
+ // if the code unit is a data, get the lowest sub-data containing the address
if (cu instanceof Data) {
Data data = (Data) cu;
Data subData = data.getPrimitiveAt((int) addr.subtract(data.getAddress()));
@@ -73,8 +70,9 @@ public class BytesFieldLocation extends CodeUnitLocation {
}
/**
- * Returns the index of byte that represents the current program location.
- * Sources that do not get this specific should simply return 0.
+ * Returns the index of byte that represents the current program location. Sources that do not
+ * get this specific should simply return 0.
+ * @return the index
*/
public int getByteIndex() {
return (int) getByteAddress().subtract(getAddress());
@@ -92,9 +90,10 @@ public class BytesFieldLocation extends CodeUnitLocation {
/**
* Returns the character position within the byte specified by getByteIndex(). Normally,
- * this is 1,2, or 3 corresponding to before the byte, between the nibbles of the byte or
+ * this is 1, 2, or 3 corresponding to before the byte, between the nibbles of the byte or
* past the byte. Sometimes, extra delimiters may exist allowing the position to be
* greater than 3.
+ * @return the column
*/
public int getColumnInByte() {
return getCharOffset();
diff --git a/Ghidra/Framework/SoftwareModeling/src/main/java/ghidra/program/util/CommentFieldLocation.java b/Ghidra/Framework/SoftwareModeling/src/main/java/ghidra/program/util/CommentFieldLocation.java
index 94ddb973ce..d3165392fe 100644
--- a/Ghidra/Framework/SoftwareModeling/src/main/java/ghidra/program/util/CommentFieldLocation.java
+++ b/Ghidra/Framework/SoftwareModeling/src/main/java/ghidra/program/util/CommentFieldLocation.java
@@ -83,15 +83,16 @@ public class CommentFieldLocation extends CodeUnitLocation {
/**
* Returns the array of strings that make up the comment.
+ * @return the comment
*/
public String[] getComment() {
return comment;
}
/**
- * Returns the comment type. The type is either CodeUnit.EOL_COMMENT,
- * CodeUnit.POST_COMMENT, CodeUnit.PLATE_COMMENT, CodeUnit.PRE_COMMENT,
- * or CodeUnit.REPEATABLE_COMMENT.
+ * Returns the comment type. The type is either CodeUnit.EOL_COMMENT, CodeUnit.POST_COMMENT,
+ * CodeUnit.PLATE_COMMENT, CodeUnit.PRE_COMMENT, or CodeUnit.REPEATABLE_COMMENT.
+ * @return the comment type
*/
public int getCommentType() {
return type;
@@ -149,5 +150,4 @@ public class CommentFieldLocation extends CodeUnitLocation {
comment = obj.getStrings("_COMMENT", new String[0]);
type = obj.getInt("_TYPE", 0);
}
-
}
diff --git a/Ghidra/Framework/SoftwareModeling/src/main/java/ghidra/program/util/ProgramLocation.java b/Ghidra/Framework/SoftwareModeling/src/main/java/ghidra/program/util/ProgramLocation.java
index 3ac1acd566..1bc6cc6096 100644
--- a/Ghidra/Framework/SoftwareModeling/src/main/java/ghidra/program/util/ProgramLocation.java
+++ b/Ghidra/Framework/SoftwareModeling/src/main/java/ghidra/program/util/ProgramLocation.java
@@ -460,15 +460,6 @@ public class ProgramLocation implements Comparable<ProgramLocation> {
return row;
}
- /**
- * Returns the character offset in the display item at the (row,col).
- *
- * @return the character offset in the display item at the (row,col).
- */
- public int getCharOffset() {
- return charOffset;
- }
-
/**
* Returns the column index of the display piece represented by this location. For most
* locations, there is only one display item per row, in which case this value will be 0.
@@ -478,4 +469,12 @@ public class ProgramLocation implements Comparable<ProgramLocation> {
return col;
}
+ /**
+ * Returns the character offset in the display item at the (row,col).
+ *
+ * @return the character offset in the display item at the (row,col).
+ */
+ public int getCharOffset() {
+ return charOffset;
+ }
}