private static MethodDescriptor handleNonePrefix(final MethodDescriptor descriptor) { return new MethodDescriptor( descriptor.getParamTypes().stream() .map(Processor::handleNonePrefix) .collect(Collectors.toList()), handleNonePrefix(descriptor.getReturnType()) ); }
/** * Creates a method signature, with the given method name and raw descriptor. * * @param name The method name * @param descriptor The method's raw descriptor * @return The new method signature */ public static MethodSignature of(final String name, final String descriptor) { return new MethodSignature(name, MethodDescriptor.of(descriptor)); }
/** * Gets the obfuscated descriptor of the method. * * @return The obfuscated descriptor * @see MethodSignature#getDescriptor() * @see MethodDescriptor#toString() */ default String getObfuscatedDescriptor() { return this.getDescriptor().toString(); }
private static String handleNonePrefix(final MethodDescriptor descriptor) { final StringBuilder typeBuilder = new StringBuilder(); typeBuilder.append("("); descriptor.getParamTypes().forEach(type -> typeBuilder.append(handleNonePrefix(type))); typeBuilder.append(")"); typeBuilder.append(handleNonePrefix(descriptor.getReturnType())); return typeBuilder.toString(); }
final String descriptor = handleNonePrefix(MethodDescriptor.of(split[2])).toString(); this.stack.push(this.peekClass().getOrCreateMethodMapping(obfName, descriptor)); final String obfName = split[1]; final String deobfName = split[2]; final String descriptor = handleNonePrefix(MethodDescriptor.of(split[3])).toString(); this.stack.push(this.peekClass().getOrCreateMethodMapping(obfName, descriptor) .setDeobfuscatedName(deobfName));
/** * Reads the next {@link MethodDescriptor} from source. * * @return The type * @throws IllegalStateException If the descriptor is invalid */ public MethodDescriptor read() { final List<FieldType> params = new ArrayList<>(); if (this.peek() != '(') throw new IllegalStateException("Invalid descriptor provided!"); this.advance(); while (this.hasNext() && this.peek() != ')') { params.add(this.readFieldType()); } if (this.peek() != ')') throw new IllegalStateException("Invalid descriptor provided!"); this.advance(); return new MethodDescriptor(params, this.readType()); }
/** * Gets the de-obfuscated descriptor of the method. * * @param descriptor The descriptor to de-obfuscate * @return The de-obfuscated descriptor * @since 0.4.0 */ default String deobfuscate(final MethodDescriptor descriptor) { final StringBuilder typeBuilder = new StringBuilder(); typeBuilder.append("("); descriptor.getParamTypes().forEach(type -> typeBuilder.append(this.deobfuscate(type))); typeBuilder.append(")"); typeBuilder.append(this.deobfuscate(descriptor.getReturnType())); return typeBuilder.toString(); }