Create bookmarks/comments API
Purpose
Allow assigning comments to different classes/fields/methods. When decompiling, comments are "injected" at the relevant locations.
This can also double as a bookmarking system, where you write a comment at a location you want to jump back to later.
Outline
interface CommentsApi {
void setComment(ClassPathNode path, String comment) { ... }
void setComment(ClassMemberPathNode path, String comment) { ... }
void removeComment(ClassPathNode path) { ... }
void removeComment(ClassMemberPathNode path) { ... }
}
Implementation
Prior versions of Recaf did support serialized comments in the class via annotations, with the comment being stored inline. This worked, but was subject to abuse since the annotation names were consistent. We can adapt this approach to be more resilient.
- Associate comments with a
UUIDkey - Use annotations with the key embedded in the name, such as
COMMENT-0000-000-000-0000 - Store the actual comment info in Recaf's data directory
- Substitute the annotation for a comment at decompile/disassemble time
The last step can be done with basic text matching in decompiled output, so it is agnostic to the decompiler used. As for the assembler, we can do something similar there (which we did in the old Recaf assembler)