Package net.fabricmc.mappingio.adapter
Class MappingSourceNsSwitch
java.lang.Object
net.fabricmc.mappingio.adapter.ForwardingMappingVisitor
net.fabricmc.mappingio.adapter.MappingSourceNsSwitch
- All Implemented Interfaces:
MappingVisitor
Adapter switching the source namespace with one of the destination namespaces.
This adapts e.g. "src -> dstA, dstB, dstC, ..." mappings to "dstB -> dstA, src, dstC, ..." with a pre-pass to build a class map for descriptor remapping.
After gathering the class map, the implementation delays src-named visit* invocations until the replacement dst name is known, then replays it with the adjusted names.
By default elements without a name in newSourceNs will keep using the original srcName. This behavior can be
changed by setting dropMissingNewSrcName to true in the constructor.
-
Field Summary
Fields inherited from class net.fabricmc.mappingio.adapter.ForwardingMappingVisitor
next -
Constructor Summary
ConstructorsConstructorDescriptionMappingSourceNsSwitch(MappingVisitor next, String newSourceNs) MappingSourceNsSwitch(MappingVisitor next, String newSourceNs, boolean dropMissingNewSrcName) Create a new MappingSourceNsSwitch instance. -
Method Summary
Modifier and TypeMethodDescriptiongetFlags()voidreset()Reset the visitor including any chained visitors to allow for another independent visit (excluding visitEnd=false).booleanvisitClass(String srcName) booleanDetermine whether the mapping content (classes and anything below, metadata if not part of the header) should be visited.voidvisitDstDesc(MappedElementKind targetKind, int namespace, String desc) voidvisitDstName(MappedElementKind targetKind, int namespace, String name) Destination name for the current element.booleanvisitElementContent(MappedElementKind targetKind) Determine whether the element content (comment, sub-elements) should be visited.booleanvisitEnd()Finish the visitation pass.booleanvisitField(String srcName, @Nullable String srcDesc) booleanDetermine whether the header (namespaces, metadata if part of the header) should be visited.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) Methods inherited from class net.fabricmc.mappingio.adapter.ForwardingMappingVisitor
visitComment
-
Constructor Details
-
MappingSourceNsSwitch
-
MappingSourceNsSwitch
public MappingSourceNsSwitch(MappingVisitor next, String newSourceNs, boolean dropMissingNewSrcName) Create a new MappingSourceNsSwitch instance.- Parameters:
next- MappingVisitor to pass the output tonewSourceNs- namespace to use for the new source namedropMissingNewSrcName- whether to drop elements without a name in newSourceNs, will use original srcName otherwise
-
-
Method Details
-
getFlags
- Specified by:
getFlagsin interfaceMappingVisitor- Overrides:
getFlagsin classForwardingMappingVisitor
-
reset
public void reset()Description copied from interface:MappingVisitorReset the visitor including any chained visitors to allow for another independent visit (excluding visitEnd=false).- Specified by:
resetin interfaceMappingVisitor- Overrides:
resetin classForwardingMappingVisitor
-
visitHeader
Description copied from interface:MappingVisitorDetermine whether the header (namespaces, metadata if part of the header) should be visited.- Specified by:
visitHeaderin interfaceMappingVisitor- Overrides:
visitHeaderin classForwardingMappingVisitor- Returns:
- true if the header is to be visited, false otherwise
- Throws:
IOException
-
visitNamespaces
- Specified by:
visitNamespacesin interfaceMappingVisitor- Overrides:
visitNamespacesin classForwardingMappingVisitor- Throws:
IOException
-
visitMetadata
- Specified by:
visitMetadatain interfaceMappingVisitor- Overrides:
visitMetadatain classForwardingMappingVisitor- Throws:
IOException
-
visitContent
Description copied from interface:MappingVisitorDetermine whether the mapping content (classes and anything below, metadata if not part of the header) should be visited.- Specified by:
visitContentin interfaceMappingVisitor- Overrides:
visitContentin classForwardingMappingVisitor- Returns:
- true if content is to be visited, false otherwise
- Throws:
IOException
-
visitClass
- Specified by:
visitClassin interfaceMappingVisitor- Overrides:
visitClassin classForwardingMappingVisitor- Throws:
IOException
-
visitField
- Specified by:
visitFieldin interfaceMappingVisitor- Overrides:
visitFieldin classForwardingMappingVisitor- Throws:
IOException
-
visitMethod
- Specified by:
visitMethodin interfaceMappingVisitor- Overrides:
visitMethodin classForwardingMappingVisitor- Throws:
IOException
-
visitMethodArg
public boolean visitMethodArg(int argPosition, int lvIndex, @Nullable @Nullable String srcName) throws IOException - Specified by:
visitMethodArgin interfaceMappingVisitor- Overrides:
visitMethodArgin classForwardingMappingVisitor- Throws:
IOException
-
visitMethodVar
public boolean visitMethodVar(int lvtRowIndex, int lvIndex, int startOpIdx, int endOpIdx, @Nullable @Nullable String srcName) throws IOException - Specified by:
visitMethodVarin interfaceMappingVisitor- Overrides:
visitMethodVarin classForwardingMappingVisitor- Throws:
IOException
-
visitEnd
Description copied from interface:MappingVisitorFinish the visitation pass.- Specified by:
visitEndin interfaceMappingVisitor- Overrides:
visitEndin classForwardingMappingVisitor- Returns:
- true if the visitation pass is final, false if it should be started over
- Throws:
IOException
-
visitDstName
public void visitDstName(MappedElementKind targetKind, int namespace, String name) throws IOException Description copied from interface:MappingVisitorDestination name for the current element.- Specified by:
visitDstNamein interfaceMappingVisitor- Overrides:
visitDstNamein classForwardingMappingVisitor- Parameters:
namespace- namespace index, index into the dstNamespaces List inMappingVisitor.visitNamespaces(java.lang.String, java.util.List<java.lang.String>)name- destination name- Throws:
IOException
-
visitDstDesc
public void visitDstDesc(MappedElementKind targetKind, int namespace, String desc) throws IOException - Specified by:
visitDstDescin interfaceMappingVisitor- Overrides:
visitDstDescin classForwardingMappingVisitor- Throws:
IOException
-
visitElementContent
Description copied from interface:MappingVisitorDetermine 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.
- Specified by:
visitElementContentin interfaceMappingVisitor- Overrides:
visitElementContentin classForwardingMappingVisitor- Returns:
- true if the contents are to be visited, false otherwise
- Throws:
IOException
-