Class MappingNsCompleter
java.lang.Object
net.fabricmc.mappingio.adapter.ForwardingMappingVisitor
net.fabricmc.mappingio.adapter.MappingNsCompleter
- All Implemented Interfaces:
MappingVisitor
A mapping visitor that completes missing destination names.
Some mapping formats allow omitting destination names if equal to the source name. This visitor fills in these "holes" by copying names from another namespace.
-
Field Summary
Fields inherited from class ForwardingMappingVisitor
next -
Constructor Summary
ConstructorsConstructorDescriptionConstructs a newMappingNsCompleterwhich completes all destination namespaces.MappingNsCompleter(MappingVisitor next, @Nullable Map<String, String> alternatives) MappingNsCompleter(MappingVisitor next, @Nullable Map<String, String> alternatives, boolean addMissingNs) -
Method Summary
Modifier and TypeMethodDescriptionbooleanvisitClass(String srcName) Visit a class.booleanDetermine whether the mapping content (classes and anything below, metadata if not part of the header) should be visited.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.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) Visit a parameter.booleanvisitMethodVar(int lvtRowIndex, int lvIndex, int startOpIdx, int endOpIdx, @Nullable String srcName) Visit a variable.voidvisitNamespaces(String srcNamespace, List<String> dstNamespaces) Methods inherited from class ForwardingMappingVisitor
getFlags, reset, visitComment, visitDstDesc, visitEnd
-
Constructor Details
-
MappingNsCompleter
Constructs a newMappingNsCompleterwhich completes all destination namespaces.- Parameters:
next- The next visitor to forward the data to.
-
MappingNsCompleter
- Parameters:
next- The next visitor to forward the data to.alternatives- A map of which namespaces should copy from which others. Passingnullcauses all destination namespaces to be completed.
-
MappingNsCompleter
public MappingNsCompleter(MappingVisitor next, @Nullable @Nullable Map<String, String> alternatives, boolean addMissingNs) - Parameters:
next- The next visitor to forward the data to.alternatives- A map of which namespaces should copy from which others. Passingnullcauses all destination namespaces to be completed.addMissingNs- Whether to copy namespaces from the alternatives key set if not already present.
-
-
Method Details
-
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:
trueif the header is to be visited,falseotherwise.- 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:
trueif content is to be visited,falseotherwise.- Throws:
IOException
-
visitClass
Description copied from interface:MappingVisitorVisit a class.- Specified by:
visitClassin interfaceMappingVisitor- Overrides:
visitClassin classForwardingMappingVisitor- Parameters:
srcName- The fully qualified source name of the class, in internal form (slashes instead of dots, dollar signs for delimiting inner classes).- Returns:
- Whether the class's content should be visited too.
- 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 Description copied from interface:MappingVisitorVisit a parameter.- Specified by:
visitMethodArgin interfaceMappingVisitor- Overrides:
visitMethodArgin classForwardingMappingVisitor- Parameters:
argPosition- Always starts at 0 and gets incremented by 1 for each additional parameter.lvIndex- The parameter's local variable index in the current method, also known asslot. Starts at 0 for static methods, 1 otherwise. For each additional parameter, it gets incremented by 1, or by 2 if it's a double-wide primitive (longordouble).srcName- The optional source name of the parameter.- Returns:
- Whether the arg's content should be visited too.
- Throws:
IOException
-
visitMethodVar
public boolean visitMethodVar(int lvtRowIndex, int lvIndex, int startOpIdx, int endOpIdx, @Nullable @Nullable String srcName) throws IOException Description copied from interface:MappingVisitorVisit a variable.- Specified by:
visitMethodVarin interfaceMappingVisitor- Overrides:
visitMethodVarin classForwardingMappingVisitor- Parameters:
lvtRowIndex- The variable's index in the method's LVT (local variable table). It is optional, so -1 can be passed instead. This is the case since LVTs themselves are optional debug information, see JVMS 4.7.13.lvIndex- The var's local variable index in the current method, also known asslot. For each additional variable, it gets incremented by 1, or by 2 if it's a double-wide primitive (longordouble). The first variable starts at the last parameter's slot plus wideness.startOpIdx- Required for cases when the lvIndex alone doesn't uniquely identify a local variable. This is the case when variables get re-defined later on, in which case most decompilers opt to not re-define the existing var, but instead generate a new one (with both sharing the same lvIndex).endOpIdx- Counterpart to startOpIdx. Exclusive.srcName- The optional source name of the variable.- Returns:
- Whether the var's content should be visited too.
- Throws:
IOException
-
visitDstName
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(String, List)).name- Destination name.
-
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:
trueif the contents are to be visited,falseotherwise- Throws:
IOException
-