Interface MappingVisitor
- All Known Subinterfaces:
MappingWriter,VisitableMappingTree
- All Known Implementing Classes:
EnigmaDirWriter,EnigmaFileWriter,FlatAsRegularMappingVisitor,ForwardingMappingVisitor,MappingDstNsReorder,MappingNsCompleter,MappingNsRenamer,MappingSourceNsSwitch,MemoryMappingTree,MissingDescFilter,ProGuardFileWriter,Tiny1FileWriter,Tiny2FileWriter
The visitation order is as follows (omitting visit prefixes for brevity, lowercase for cross references):
- overall: header -> content -> End -> overall
- header: Header -> Namespaces [-> Metadata]*
- content: Content [-> class|Metadata]*
- class: Class [-> DstName]* -> ElementContent [-> field|method|Comment]*
- field: Field [-> DstName|DstDesc]* -> ElementContent [-> Comment]
- method: Method [-> DstName|DstDesc]* -> ElementContent [-> arg|var|Comment]*
- arg: Arg [-> DstName]* -> ElementContent [-> Comment]
- var: Var [-> DstName]* -> ElementContent [-> Comment]
The elements with a skip-return (Header/Content/Class/Field/Method/Arg/Var/ElementContent) abort processing the
remainder of their associated item in the above listing if requested by a true return value. For example
skipping in Class does neither DstName nor ElementContent, but continues with another class or End.
Returning false in End requests another complete visitation pass if the flag
MappingFlag.NEEDS_MULTIPLE_PASSES is provided, otherwise the behavior is unspecified. This is used for
visitors that first have to acquire some overall mapping knowledge before being able to perform their task.
Subsequent visitation passes need to use the same namespaces and data, only a new independent visitation may use
something else after a reset().
The same element may be visited more than once unless the flags contain MappingFlag.NEEDS_ELEMENT_UNIQUENESS.
-
Method Summary
Modifier and TypeMethodDescriptiondefault Set<MappingFlag> getFlags()default voidreset()Reset the visitor including any chained visitors to allow for another independent visit (excluding visitEnd=false).booleanvisitClass(String srcName) voidvisitComment(MappedElementKind targetKind, String comment) Comment for the specified element (last content-visited or any parent).default booleanDetermine whether the mapping content (classes and anything below, metadata if not part of the header) should be visited.default voidvisitDstDesc(MappedElementKind targetKind, int namespace, String desc) voidvisitDstName(MappedElementKind targetKind, int namespace, String name) Destination name for the current element.default booleanvisitElementContent(MappedElementKind targetKind) Determine whether the element content (comment, sub-elements) should be visited.default booleanvisitEnd()Finish the visitation pass.booleanvisitField(String srcName, @Nullable String srcDesc) default booleanDetermine whether the header (namespaces, metadata if part of the header) should be visited.default voidvisitMetadata(String key, @Nullable String value) booleanvisitMethod(String srcName, @Nullable String srcDesc) booleanvisitMethodArg(int argPosition, int lvIndex, @Nullable String srcName) booleanvisitMethodVar(int lvtRowIndex, int lvIndex, int startOpIdx, int endOpIdx, @Nullable String srcName) voidvisitNamespaces(String srcNamespace, List<String> dstNamespaces)
-
Method Details
-
getFlags
-
reset
default void reset()Reset the visitor including any chained visitors to allow for another independent visit (excluding visitEnd=false). -
visitHeader
Determine whether the header (namespaces, metadata if part of the header) should be visited.- Returns:
- true if the header is to be visited, false otherwise
- Throws:
IOException
-
visitNamespaces
- Throws:
IOException
-
visitMetadata
- Throws:
IOException
-
visitContent
Determine whether the mapping content (classes and anything below, metadata if not part of the header) should be visited.- Returns:
- true if content is to be visited, false otherwise
- Throws:
IOException
-
visitClass
- Throws:
IOException
-
visitField
- Throws:
IOException
-
visitMethod
- Throws:
IOException
-
visitMethodArg
boolean visitMethodArg(int argPosition, int lvIndex, @Nullable @Nullable String srcName) throws IOException - Throws:
IOException
-
visitMethodVar
boolean visitMethodVar(int lvtRowIndex, int lvIndex, int startOpIdx, int endOpIdx, @Nullable @Nullable String srcName) throws IOException - Throws:
IOException
-
visitEnd
Finish the visitation pass.- Returns:
- true if the visitation pass is final, false if it should be started over
- Throws:
IOException
-
visitDstName
Destination name for the current element.- Parameters:
namespace- namespace index, index into the dstNamespaces List invisitNamespaces(java.lang.String, java.util.List<java.lang.String>)name- destination name- Throws:
IOException
-
visitDstDesc
default void visitDstDesc(MappedElementKind targetKind, int namespace, String desc) throws IOException - Throws:
IOException
-
visitElementContent
Determine whether the element content (comment, sub-elements) should be visited.Called after visiting the target itself (e.g. visitClass for targetKind=class), its dst names and descs, but before any child elements or the comment.
This is also a notification about all available dst names having been passed on.
- Returns:
- true if the contents are to be visited, false otherwise
- Throws:
IOException
-
visitComment
Comment for the specified element (last content-visited or any parent).- Parameters:
comment- comment as a potentially multi-line string- Throws:
IOException
-