diff --git a/Ghidra/Features/Base/src/main/help/help/topics/Annotations/Annotations.html b/Ghidra/Features/Base/src/main/help/help/topics/Annotations/Annotations.html index f26dbaefc1..4b7946bd01 100644 --- a/Ghidra/Features/Base/src/main/help/help/topics/Annotations/Annotations.html +++ b/Ghidra/Features/Base/src/main/help/help/topics/Annotations/Annotations.html @@ -104,6 +104,11 @@ Notes:
+ * NOTE: ALL AnnotatedStringHandler class names MUST END IN "StringHandler". If not, the
+ * ClassSearcher will not find them.
*/
public interface AnnotatedStringHandler extends ExtensionPoint {
@@ -45,7 +43,7 @@ public interface AnnotatedStringHandler extends ExtensionPoint {
* @param s string to escape
* @return escaped string
*/
- static String escapeAnnotationPart(String s) {
+ public static String escapeAnnotationPart(String s) {
s = Objects.requireNonNullElse(s, "");
String origStr = s;
if (s.indexOf('"') >= 0) {
@@ -57,14 +55,6 @@ public interface AnnotatedStringHandler extends ExtensionPoint {
return s;
}
- AnnotatedMouseHandler DUMMY_MOUSE_HANDLER = new AnnotatedMouseHandler() {
- @Override
- public boolean handleMouseClick(ProgramLocation location, MouseEvent mouseEvent,
- ServiceProvider serviceProvider) {
- return false;
- }
- };
-
/**
* Creates an {@link FieldElement} based 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
@@ -81,7 +71,7 @@ public interface AnnotatedStringHandler extends ExtensionPoint {
* @throws AnnotationException if the given text data does not fit the expected format for
* the given handler implementation.
*/
- AttributedString createAnnotatedString(AttributedString prototypeString, String[] text,
+ public AttributedString createAnnotatedString(AttributedString prototypeString, String[] text,
Program program) throws AnnotationException;
/**
@@ -90,44 +80,44 @@ public interface AnnotatedStringHandler extends ExtensionPoint {
*
* @return the annotation string names that this AnnotatedStringHandler supports.
*/
- String[] getSupportedAnnotations();
+ public String[] getSupportedAnnotations();
/**
* A method that is notified when an annotation is clicked. Returns true if this annotation
* handles the click; return false if this annotation does not do anything with the click.
*
- * @param annotationParts The constituent parts of the annotation
- * @param sourceNavigatable The location in the program that was clicked.
- * @param serviceProvider A service provider for needed services.
+ * @param text the constituent parts of the annotation
+ * @param sourceNavigatable the location in the program that was clicked.
+ * @param serviceProvider the service provider for needed services.
* @return true if this annotation handles the click; return false if this annotation does
* not do anything with the click.
*/
- boolean handleMouseClick(String[] annotationParts, Navigatable sourceNavigatable,
+ public boolean handleMouseClick(String[] text, Navigatable sourceNavigatable,
ServiceProvider serviceProvider);
/**
* Returns the String that represents the GUI presence of this option
* @return the String to display in GUI components.
*/
- String getDisplayString();
+ public String getDisplayString();
/**
* Returns an example string of how the annotation is used
* @return the example of how this is used.
*/
- String getPrototypeString();
+ public String getPrototypeString();
/**
* Returns an example string of how the annotation is used
- * @param displayText The text that may be wrapped, cannot be null
+ * @param displayText the text that may be wrapped, will not be null
* @return the example of how this is used.
*/
- default String getPrototypeString(String displayText) {
+ public default String getPrototypeString(String displayText) {
return getPrototypeString();
}
-
+
@Deprecated(forRemoval = true)
- default String[] modify(String[] text, Program program) {
+ public default String[] modify(String[] text, Program program) {
return modify(text, program, Address.NO_ADDRESS);
}
@@ -138,10 +128,10 @@ public interface AnnotatedStringHandler extends ExtensionPoint {
*
* @param text the array of annotation parts to modify
* @param program the program
- * @param loc location of the annotation in the program
+ * @param addr address of the annotation in the program
* @return the modified array; null otherwise
*/
- default String[] modify(String[] text, Program program, Address loc) {
+ public default String[] modify(String[] text, Program program, Address addr) {
return null;
}
diff --git a/Ghidra/Features/Base/src/main/java/ghidra/app/util/viewer/field/CommentUtils.java b/Ghidra/Features/Base/src/main/java/ghidra/app/util/viewer/field/CommentUtils.java
index de4fc5ed3b..d160fb144e 100644
--- a/Ghidra/Features/Base/src/main/java/ghidra/app/util/viewer/field/CommentUtils.java
+++ b/Ghidra/Features/Base/src/main/java/ghidra/app/util/viewer/field/CommentUtils.java
@@ -50,10 +50,10 @@ public class CommentUtils {
*
* @param rawCommentText the text to be updated
* @param program the program associated with the comment
- * @param loc location of comment in program
+ * @param addr address of comment in program
* @return the updated string
*/
- public static String fixupAnnotations(String rawCommentText, Program program, Address loc) {
+ public static String fixupAnnotations(String rawCommentText, Program program, Address addr) {
if (rawCommentText == null) {
return null;
@@ -67,7 +67,7 @@ public class CommentUtils {
String[] annotationParts = annotation.getAnnotationParts();
AnnotatedStringHandler handler = getAnnotationHandler(annotationParts);
- String[] updatedParts = handler.modify(annotationParts, program, loc);
+ String[] updatedParts = handler.modify(annotationParts, program, addr);
if (updatedParts == null) {
return annotation; // nothing to change
}
@@ -164,8 +164,7 @@ public class CommentUtils {
text = StringUtilities.convertTabsToSpaces(text);
int column = 0;
- List
+ * 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}
+ *
*/
public class VariableAnnotatedStringHandler implements AnnotatedStringHandler {
- private static final String DEFAULT_ANO = "var";
- private static final String HASH_ANO = DEFAULT_ANO + "_hash";
- private static final String[] SUPPORTED_ANNOTATIONS = { "variable", DEFAULT_ANO, HASH_ANO };
-
- private static final String INVALID_SYMBOL_TEXT =
- "@" + DEFAULT_ANO + " annotation must have form: