MCPcopy Create free account
hub / github.com/FabricMC/Matcher / match

Method match

src/main/java/matcher/Matcher.java:173–256  ·  view source on GitHub ↗
(ClassInstance a, ClassInstance b)

Source from the content-addressed store, hash-verified

171 }
172
173 public void match(ClassInstance a, ClassInstance b) {
174 if (a == null) throw new NullPointerException("null class A");
175 if (b == null) throw new NullPointerException("null class B");
176 if (a.getArrayDimensions() != b.getArrayDimensions()) throw new IllegalArgumentException("the classes don't have the same amount of array dimensions");
177 if (a.getMatch() == b) return;
178
179 LOGGER.debug("Matching class {} -> {}{}", a, b, (a.hasMappedName() ? " ("+a.getName(NameType.MAPPED_PLAIN)+")" : ""));
180
181 if (a.getMatch() != null) {
182 a.getMatch().setMatch(null);
183 unmatchMembers(a);
184 }
185
186 if (b.getMatch() != null) {
187 b.getMatch().setMatch(null);
188 unmatchMembers(b);
189 }
190
191 a.setMatch(b);
192 b.setMatch(a);
193
194 // match array classes
195
196 if (a.isArray()) {
197 ClassInstance elemA = a.getElementClass();
198
199 if (!elemA.hasMatch()) match(elemA, b.getElementClass());
200 } else {
201 for (ClassInstance arrayA : a.getArrays()) {
202 int dims = arrayA.getArrayDimensions();
203
204 for (ClassInstance arrayB : b.getArrays()) {
205 if (arrayB.hasMatch() || arrayB.getArrayDimensions() != dims) continue;
206
207 assert arrayA.getElementClass() == a && arrayB.getElementClass() == b;
208
209 match(arrayA, arrayB);
210 break;
211 }
212 }
213 }
214
215 // match methods that are not obfuscated or matched via parents/children
216
217 for (MethodInstance src : a.getMethods()) {
218 if (!src.isNameObfuscated()) {
219 MethodInstance dst = b.getMethod(src.getId());
220
221 if ((dst != null || (dst = b.getMethod(src.getName(), null)) != null) && !dst.isNameObfuscated()) { // full match or name match with no alternatives
222 match(src, dst);
223 continue;
224 }
225 }
226
227 MethodInstance matchedDst = src.getHierarchyMatch();
228 if (matchedDst == null) continue;
229
230 Set<MethodInstance> dstHierarchyMembers = matchedDst.getAllHierarchyMembers();

Callers 6

matchUnobfuscatedMethod · 0.95
autoMatchClassesMethod · 0.95
autoMatchMethodsMethod · 0.95
autoMatchFieldsMethod · 0.95
autoMatchMethodVarsMethod · 0.95
importMatchesMethod · 0.95

Calls 15

unmatchMembersMethod · 0.95
unmatchArgsVarsMethod · 0.95
getEnvMethod · 0.95
getMatchMethod · 0.95
getRawScoreMethod · 0.95
runInParallelMethod · 0.95
checkRankMethod · 0.95
sanitizeMatchesMethod · 0.95
getArrayDimensionsMethod · 0.80
isArrayMethod · 0.80
getElementClassMethod · 0.80
hasMatchMethod · 0.80

Tested by

no test coverage detected