mirror of
https://github.com/NationalSecurityAgency/ghidra.git
synced 2025-10-04 10:19:23 +02:00
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.
This commit is contained in:
parent
a21c2c4347
commit
84650030d0
130 changed files with 1096 additions and 919 deletions
|
@ -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);
|
||||
}
|
||||
|
|
|
@ -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);
|
||||
}
|
||||
|
|
|
@ -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);
|
||||
}
|
||||
|
|
|
@ -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
|
||||
|
||||
}
|
||||
|
|
|
@ -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);
|
||||
}
|
||||
|
|
|
@ -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);
|
||||
}
|
||||
|
|
|
@ -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);
|
||||
}
|
||||
|
|
|
@ -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) {
|
|
@ -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);
|
||||
|
|
|
@ -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);
|
||||
|
|
|
@ -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);
|
||||
}
|
||||
|
||||
}
|
||||
|
|
|
@ -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);
|
||||
|
|
|
@ -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();
|
||||
}
|
||||
}
|
||||
|
||||
|
|
|
@ -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();
|
||||
|
@ -560,7 +562,7 @@ class ListingDisplaySearcher implements Searcher {
|
|||
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);
|
||||
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()) {
|
||||
|
|
|
@ -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;
|
||||
}
|
||||
|
||||
/**
|
||||
|
|
|
@ -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,20 +145,22 @@ 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) {
|
||||
searchDialog.setStatusText("");
|
||||
if (goToService.goTo(searchNavigatable, loc, program)) {
|
||||
new HighlightHandler(searchNavigatable, searchOptions, null, program, loc);
|
||||
}
|
||||
}
|
||||
else {
|
||||
searchDialog.setStatusText("Not found");
|
||||
searchDialog.setStatusText("");
|
||||
ProgramLocation loc = result.programLocation();
|
||||
if (goToService.goTo(searchNavigatable, loc, program)) {
|
||||
new SearchTextHighlightProvider(searchNavigatable, searchOptions, null, program,
|
||||
result);
|
||||
}
|
||||
}
|
||||
|
||||
lastSearchedText = searchOptions.getText();
|
||||
|
@ -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.size() == 0) {
|
||||
if (list.isEmpty()) {
|
||||
return NO_HIGHLIGHTS;
|
||||
}
|
||||
Highlight[] h = new Highlight[list.size()];
|
||||
return list.toArray(h);
|
||||
return list.toArray(Highlight[]::new);
|
||||
}
|
||||
|
||||
/**
|
||||
* 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 Highlight[] getSingleSearchHighlight(String text, ListingField field,
|
||||
int cursorTextOffset) {
|
||||
|
||||
String searchText = searchOptions.getText();
|
||||
if (StringUtils.isBlank(searchText) || StringUtils.isBlank(text)) {
|
||||
return NO_HIGHLIGHTS;
|
||||
}
|
||||
|
||||
FieldFactory fieldFactory = field.getFieldFactory();
|
||||
ProgramLocation loc = searchResult.programLocation();
|
||||
if (!fieldFactory.supportsLocation(field, loc)) {
|
||||
return NO_HIGHLIGHTS;
|
||||
}
|
||||
|
||||
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;
|
||||
}
|
||||
|
||||
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 ||
|
||||
|
|
|
@ -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
|
||||
}
|
||||
}
|
||||
|
|
|
@ -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) {
|
||||
|
|
|
@ -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));
|
||||
}
|
||||
}
|
||||
|
|
|
@ -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));
|
||||
}
|
||||
}
|
||||
|
||||
|
|
|
@ -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));
|
||||
}
|
||||
|
||||
|
|
|
@ -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();
|
||||
|
|
|
@ -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())) {
|
||||
!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())) {
|
||||
!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) {
|
||||
Address address = advance(matchesForCurrentAddress);
|
||||
if (!forward) {
|
||||
Collections.reverse( matchesForCurrentAddress );
|
||||
}
|
||||
return address;
|
||||
}
|
||||
protected abstract Address advance(List<ProgramLocation> currentMatches);
|
||||
|
||||
public Address getNextSignificantAddress( Address address ) {
|
||||
private Address doAdvance(List<TextSearchResult> currentMatches) {
|
||||
Address address = advance(matchesForCurrentAddress);
|
||||
if (!forward) {
|
||||
Collections.reverse(matchesForCurrentAddress);
|
||||
}
|
||||
return 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();
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
|
@ -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(
|
||||
|
|
|
@ -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);
|
||||
}
|
||||
|
|
|
@ -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.
|
||||
|
|
|
@ -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);
|
||||
}
|
|
@ -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);
|
||||
}
|
||||
|
||||
|
|
|
@ -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);
|
||||
|
|
|
@ -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);
|
||||
|
|
|
@ -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);
|
||||
|
|
|
@ -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();
|
||||
|
||||
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);
|
||||
}
|
||||
|
|
|
@ -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;
|
||||
}
|
||||
|
|
|
@ -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);
|
||||
|
|
|
@ -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;
|
||||
|
|
|
@ -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) {
|
|
@ -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.
|
||||
|
|
|
@ -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);
|
||||
}
|
||||
}
|
|
@ -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);
|
||||
}
|
||||
|
|
|
@ -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);
|
||||
}
|
||||
|
||||
|
|
|
@ -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);
|
||||
|
|
|
@ -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);
|
||||
}
|
||||
|
|
|
@ -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,
|
||||
|
|
|
@ -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);
|
||||
}
|
||||
|
|
|
@ -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);
|
||||
|
|
|
@ -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);
|
||||
}
|
||||
|
|
|
@ -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) {
|
||||
|
|
|
@ -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.
|
||||
*/
|
||||
|
|
|
@ -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);
|
||||
|
|
|
@ -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);
|
||||
}
|
||||
|
|
|
@ -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.
|
||||
|
|
|
@ -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);
|
||||
}
|
||||
}
|
|
@ -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();
|
||||
|
|
|
@ -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);
|
||||
|
|
|
@ -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);
|
||||
}
|
||||
|
|
|
@ -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) {
|
||||
|
|
|
@ -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);
|
||||
}
|
||||
|
|
|
@ -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);
|
||||
}
|
||||
|
|
|
@ -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);
|
||||
|
||||
|
|
|
@ -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);
|
||||
|
|
|
@ -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;
|
||||
}
|
||||
|
|
|
@ -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);
|
||||
}
|
||||
|
|
|
@ -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);
|
||||
}
|
||||
|
|
|
@ -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);
|
||||
}
|
||||
|
|
|
@ -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);
|
||||
|
|
|
@ -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);
|
||||
}
|
||||
|
|
|
@ -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);
|
||||
}
|
||||
|
|
|
@ -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);
|
||||
}
|
||||
|
|
|
@ -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);
|
||||
|
|
|
@ -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);
|
||||
|
|
|
@ -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);
|
||||
}
|
||||
|
|
|
@ -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);
|
||||
}
|
||||
|
|
|
@ -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);
|
||||
}
|
||||
|
|
|
@ -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);
|
||||
}
|
||||
|
|
|
@ -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);
|
||||
}
|
||||
|
|
|
@ -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);
|
||||
|
|
|
@ -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);
|
||||
}
|
||||
|
||||
}
|
||||
|
|
|
@ -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);
|
||||
}
|
||||
|
|
|
@ -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);
|
||||
|
|
|
@ -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.
|
||||
|
@ -939,9 +939,9 @@ public class FormatManager implements OptionsChangeListener {
|
|||
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);
|
||||
}
|
||||
}
|
||||
|
|
|
@ -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
|
||||
}
|
||||
}
|
||||
|
|
|
@ -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);
|
||||
}
|
||||
|
||||
|
|
|
@ -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;
|
||||
}
|
||||
|
||||
/**
|
||||
|
|
|
@ -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);
|
||||
}
|
||||
|
||||
|
|
|
@ -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;
|
||||
}
|
||||
|
|
|
@ -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);
|
||||
}
|
||||
}
|
||||
|
|
|
@ -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);
|
||||
}
|
||||
}
|
||||
|
|
|
@ -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);
|
||||
}
|
||||
}
|
||||
|
|
|
@ -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;
|
||||
}
|
||||
}
|
||||
|
|
|
@ -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);
|
||||
}
|
||||
}
|
||||
|
|
|
@ -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);
|
||||
}
|
||||
|
|
|
@ -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);
|
||||
}
|
||||
}
|
||||
|
|
|
@ -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;
|
||||
}
|
||||
|
||||
}
|
||||
|
|
|
@ -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) {
|
||||
|
|
|
@ -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);
|
||||
}
|
||||
}
|
||||
|
|
|
@ -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()));
|
||||
|
|
|
@ -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));
|
||||
}
|
||||
|
||||
|
|
|
@ -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) {
|
||||
|
|
|
@ -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
|
||||
}
|
||||
}
|
||||
|
|
|
@ -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();
|
||||
|
|
Some files were not shown because too many files have changed in this diff Show more
Loading…
Add table
Add a link
Reference in a new issue