Class VariableAnnotatedStringHandler
java.lang.Object
ghidra.app.util.viewer.field.VariableAnnotatedStringHandler
- All Implemented Interfaces:
AnnotatedStringHandler, ExtensionPoint
Provides support for local function variable annotations.
This allows users to reference function variables in comments without having to change the comment text when the variable is renamed. Users can enter the annotation using the variable's name:
{@variable local_8}
or
{@variable coolVariable SomeFunction}
The user annotation will be converted to use address information:
{@variable Stack[0xa] FUN_1234eaea}
-
Constructor Summary
Constructors -
Method Summary
Modifier and TypeMethodDescriptioncreateAnnotatedString(AttributedString prototypeString, String[] text, Program program) Creates anFieldElementbased upon the give array of Strings.Returns the String that represents the GUI presence of this optionReturns an example string of how the annotation is usedgetPrototypeString(String displayText) Returns an example string of how the annotation is usedString[]Returns the annotation string names that this AnnotatedStringHandler supports (e.g., "symbol", "address", etc...).booleanhandleMouseClick(String[] text, Navigatable sourceNavigatable, ServiceProvider serviceProvider) A method that is notified when an annotation is clicked.String[]Update the annotation to convert names to addresses.Methods inherited from class Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, waitMethods inherited from interface AnnotatedStringHandler
modify
-
Constructor Details
-
VariableAnnotatedStringHandler
public VariableAnnotatedStringHandler()
-
-
Method Details
-
getSupportedAnnotations
Description copied from interface:AnnotatedStringHandlerReturns the annotation string names that this AnnotatedStringHandler supports (e.g., "symbol", "address", etc...).- Specified by:
getSupportedAnnotationsin interfaceAnnotatedStringHandler- Returns:
- the annotation string names that this AnnotatedStringHandler supports.
-
getDisplayString
Description copied from interface:AnnotatedStringHandlerReturns the String that represents the GUI presence of this option- Specified by:
getDisplayStringin interfaceAnnotatedStringHandler- Returns:
- the String to display in GUI components.
-
getPrototypeString
Description copied from interface:AnnotatedStringHandlerReturns an example string of how the annotation is used- Specified by:
getPrototypeStringin interfaceAnnotatedStringHandler- Returns:
- the example of how this is used.
-
getPrototypeString
Description copied from interface:AnnotatedStringHandlerReturns an example string of how the annotation is used- Specified by:
getPrototypeStringin interfaceAnnotatedStringHandler- Parameters:
displayText- the text that may be wrapped, will not be null- Returns:
- the example of how this is used.
-
createAnnotatedString
public AttributedString createAnnotatedString(AttributedString prototypeString, String[] text, Program program) throws AnnotationException Description copied from interface:AnnotatedStringHandlerCreates anFieldElementbased upon the give array of Strings. The first String in the list is expected to be the annotation tag used to create the annotation. At the very least the array is expected to be comprised of two elements, the annotation and some data. Extra data may be provided as needed by implementing classes.- Specified by:
createAnnotatedStringin interfaceAnnotatedStringHandler- Parameters:
prototypeString- The prototypeFieldElementthat dictates the attributes for the newly created string. Implementations may change attributes as needed.text- An array of Strings used to create theFieldElementbeing returned.program- The program with which the returned string is associated.- Returns:
- An
AnnotatedTextFieldElementthat will be used to render the given text. - Throws:
AnnotationException- if the given text data does not fit the expected format for the given handler implementation.
-
modify
Update the annotation to convert names to addresses.- Specified by:
modifyin interfaceAnnotatedStringHandler- Parameters:
text- the array of annotation parts to modifyprogram- the programaddr- address of the annotation in the program- Returns:
- the modified array; null otherwise
-