(Path path, MappingFormat format, String nsSource, String nsTarget, MappingField fieldSource, MappingField fieldTarget, LocalClassEnv env, final boolean replace)
| 32 | |
| 33 | public class Mappings { |
| 34 | public static void load(Path path, MappingFormat format, |
| 35 | String nsSource, String nsTarget, |
| 36 | MappingField fieldSource, MappingField fieldTarget, |
| 37 | LocalClassEnv env, final boolean replace) throws IOException { |
| 38 | assert fieldTarget != MappingField.PLAIN; |
| 39 | int[] dstNameCounts = new int[MatchableKind.VALUES.length]; |
| 40 | int[] commentCounts = new int[MatchableKind.VALUES.length]; |
| 41 | Set<String> warnedClasses = new HashSet<>(); |
| 42 | |
| 43 | try { |
| 44 | MappingReader.read(path, format, new MappingSourceNsSwitch(new MappingVisitor() { |
| 45 | @Override |
| 46 | public void visitNamespaces(String srcNamespace, List<String> dstNamespaces) { |
| 47 | dstNs = dstNamespaces.indexOf(nsTarget); |
| 48 | if (dstNs < 0) throw new RuntimeException("missing target namespace: "+nsTarget); |
| 49 | } |
| 50 | |
| 51 | @Override |
| 52 | public void visitMetadata(String key, String value) { |
| 53 | if (fieldTarget == MappingField.UID) { |
| 54 | switch (key) { |
| 55 | case Mappings.metaUidNextClass: { |
| 56 | int val = Integer.parseInt(value); |
| 57 | if (replace || env.getGlobal().nextClassUid < val) env.getGlobal().nextClassUid = val; |
| 58 | break; |
| 59 | } |
| 60 | case Mappings.metaUidNextMethod: { |
| 61 | int val = Integer.parseInt(value); |
| 62 | if (replace || env.getGlobal().nextMethodUid < val) env.getGlobal().nextMethodUid = val; |
| 63 | break; |
| 64 | } |
| 65 | case Mappings.metaUidNextField: { |
| 66 | int val = Integer.parseInt(value); |
| 67 | if (replace || env.getGlobal().nextFieldUid < val) env.getGlobal().nextFieldUid = val; |
| 68 | break; |
| 69 | } |
| 70 | } |
| 71 | } |
| 72 | } |
| 73 | |
| 74 | @Override |
| 75 | public boolean visitClass(String srcName) { |
| 76 | method = null; |
| 77 | field = null; |
| 78 | arg = null; |
| 79 | var = null; |
| 80 | |
| 81 | cur = cls = findClass(srcName, fieldSource, env); |
| 82 | |
| 83 | if (cls == null) { |
| 84 | if (warnedClasses.add(srcName)) Matcher.LOGGER.warn("Can't find mapped class {}", srcName); |
| 85 | return false; |
| 86 | } |
| 87 | |
| 88 | return true; |
| 89 | } |
| 90 | |
| 91 | @Override |
no test coverage detected