Package ghidra.app.util.viewer.field
Class CommentUtils
java.lang.Object
ghidra.app.util.viewer.field.CommentUtils
-
Constructor Summary
Constructors -
Method Summary
Modifier and TypeMethodDescriptionstatic String
fixupAnnotations
(String rawCommentText, Program program) Makes adjustments as necessary to any annotations in the given text.static List
<AnnotatedStringHandler> Returns all known annotation handlersstatic AnnotatedStringHandler
getAnnotationHandler
(String[] annotationParts) Returns the annotation handler for the given annotation parts.static String
getDisplayString
(String rawCommentText, Program program) Returns the display string for the given raw annotation text.getSymbols
(String rawText, Program program) Returns all symbols that match the given text or an empty list.static FieldElement
parseTextForAnnotations
(String text, Program program, AttributedString prototypeString, int row) Parses the given text looking for annotations.static String
Sanitizes the given text, removing or replacing illegal characters.
-
Constructor Details
-
CommentUtils
public CommentUtils()
-
-
Method Details
-
fixupAnnotations
Makes adjustments as necessary to any annotations in the given text.- Parameters:
rawCommentText
- the text to be updatedprogram
- the program associated with the comment- Returns:
- the updated string
-
getDisplayString
Returns the display string for the given raw annotation text. Annotations are encoded strings that fit this pattern:{@name text}
. This method will parse the given text, converting any annotations into their display version.- Parameters:
rawCommentText
- text that may include annotationsprogram
- the program- Returns:
- the display string
-
parseTextForAnnotations
public static FieldElement parseTextForAnnotations(String text, Program program, AttributedString prototypeString, int row) Parses the given text looking for annotations.- Parameters:
text
- The text to parse.program
- the program from which to get informationprototypeString
- The reference string used to determine the attributes of any newly created AttributedString.row
- the row of the newly created FieldElement- Returns:
- A field element containing
AttributedString
s
-
sanitize
Sanitizes the given text, removing or replacing illegal characters.Each illegal character is handled as follows:
- null character (\0) -> remove
- Parameters:
text
- The text to sanitize- Returns:
- The sanitized text, or null if the given text was null
-
getSymbols
Returns all symbols that match the given text or an empty list.- Parameters:
rawText
- the raw symbol textprogram
- the program- Returns:
- the symbols
-
getAnnotationHandler
Returns the annotation handler for the given annotation parts. If no handler can be found, then theInvalidAnnotatedStringHandler
will be returned with n error message.- Parameters:
annotationParts
- the annotation parts- Returns:
- the handler
-
getAnnotatedStringHandlers
Returns all known annotation handlers- Returns:
- the handlers
-