MCPcopy
hub / github.com/Col-E/Recaf / accept

Method accept

src/main/java/me/coley/recaf/mapping/Mappings.java:151–174  ·  view source on GitHub ↗

Applies mappings to all classes in the given resource. Return value is the map of updated classes. @param resource Resource containing classes. @return Map of updated classes. Keys of the old names, values of the updated code.

(JavaResource resource)

Source from the content-addressed store, hash-verified

149 * @return Map of updated classes. Keys of the old names, values of the updated code.
150 */
151 public Map<String, byte[]> accept(JavaResource resource) {
152 // Collect: <OldName, NewBytecode>
153 Map<String, byte[]> updated = new HashMap<>();
154 for(Map.Entry<String, byte[]> e : resource.getClasses().entrySet()) {
155 byte[] old = e.getValue();
156 ClassReader cr = new ClassReader(old);
157 accept(updated, cr);
158 }
159 // Update the resource's classes map
160 for(Map.Entry<String, byte[]> e : updated.entrySet()) {
161 String oldKey = e.getKey();
162 String newKey = new ClassReader(e.getValue()).getClassName();
163 if (!oldKey.equals(newKey))
164 resource.getClasses().remove(oldKey);
165 resource.getClasses().put(newKey, e.getValue());
166 }
167 // Tell the workspace we've finished renaming classes
168 workspace.onPrimaryDefinitionChanges(updated.keySet());
169 // Update hierarchy graph
170 workspace.getHierarchyGraph().refresh();
171 // Update saved mappings
172 workspace.updateAggregateMappings(getMappings(), updated.keySet());
173 return updated;
174 }
175
176 /**
177 * Applies mappings to the given class and puts the modified bytecode in the map.

Callers 15

testRenamedClassesMethod · 0.95
testRenamedMethodMethod · 0.95
testResourceKeysMethod · 0.95
callMethod · 0.95
applyMapMethod · 0.95
defaultActionMethod · 0.95
containsEntryMethod · 0.80
isBogusMethod · 0.80
openMethod · 0.80
loopMethod · 0.80
handleMethod · 0.80
loadWorkspaceMethod · 0.80

Calls 15

getMappingsMethod · 0.95
setMappingsMethod · 0.95
getInstanceMethod · 0.95
isDirtyMethod · 0.95
entrySetMethod · 0.80
getKeyMethod · 0.80
removeMethod · 0.80
keySetMethod · 0.80
getHierarchyGraphMethod · 0.80
createWriterMethod · 0.80

Tested by 3

testRenamedClassesMethod · 0.76
testRenamedMethodMethod · 0.76
testResourceKeysMethod · 0.76