Cleanup (duplicates; final fields; typos)
This commit is contained in:
@@ -2,6 +2,9 @@
|
||||
package org.jetbrains.java.decompiler.struct.gen.generics;
|
||||
|
||||
public class GenericFieldDescriptor {
|
||||
public final GenericType type;
|
||||
|
||||
public GenericType type;
|
||||
}
|
||||
public GenericFieldDescriptor(GenericType type) {
|
||||
this.type = type;
|
||||
}
|
||||
}
|
||||
@@ -49,9 +49,7 @@ public class GenericMain {
|
||||
|
||||
public static GenericFieldDescriptor parseFieldSignature(String signature) {
|
||||
try {
|
||||
GenericFieldDescriptor descriptor = new GenericFieldDescriptor();
|
||||
descriptor.type = new GenericType(signature);
|
||||
return descriptor;
|
||||
return new GenericFieldDescriptor(new GenericType(signature));
|
||||
}
|
||||
catch (RuntimeException e) {
|
||||
DecompilerContext.getLogger().writeMessage("Invalid signature: " + signature, IFernflowerLogger.Severity.WARN);
|
||||
@@ -62,33 +60,34 @@ public class GenericMain {
|
||||
public static GenericMethodDescriptor parseMethodSignature(String signature) {
|
||||
String original = signature;
|
||||
try {
|
||||
GenericMethodDescriptor descriptor = new GenericMethodDescriptor();
|
||||
|
||||
signature = parseFormalParameters(signature, descriptor.fparameters, descriptor.fbounds);
|
||||
List<String> typeParameters = new ArrayList<>();
|
||||
List<List<GenericType>> typeParameterBounds = new ArrayList<>();
|
||||
signature = parseFormalParameters(signature, typeParameters, typeParameterBounds);
|
||||
|
||||
int to = signature.indexOf(")");
|
||||
String pars = signature.substring(1, to);
|
||||
String parameters = signature.substring(1, to);
|
||||
signature = signature.substring(to + 1);
|
||||
|
||||
while (pars.length() > 0) {
|
||||
String par = GenericType.getNextType(pars);
|
||||
descriptor.params.add(new GenericType(par));
|
||||
pars = pars.substring(par.length());
|
||||
List<GenericType> parameterTypes = new ArrayList<>();
|
||||
while (parameters.length() > 0) {
|
||||
String par = GenericType.getNextType(parameters);
|
||||
parameterTypes.add(new GenericType(par));
|
||||
parameters = parameters.substring(par.length());
|
||||
}
|
||||
|
||||
String par = GenericType.getNextType(signature);
|
||||
descriptor.ret = new GenericType(par);
|
||||
signature = signature.substring(par.length());
|
||||
String ret = GenericType.getNextType(signature);
|
||||
GenericType returnType = new GenericType(ret);
|
||||
signature = signature.substring(ret.length());
|
||||
|
||||
List<GenericType> exceptionTypes = new ArrayList<>();
|
||||
if (signature.length() > 0) {
|
||||
String[] exceptions = signature.split("\\^");
|
||||
|
||||
for (int i = 1; i < exceptions.length; i++) {
|
||||
descriptor.exceptions.add(new GenericType(exceptions[i]));
|
||||
exceptionTypes.add(new GenericType(exceptions[i]));
|
||||
}
|
||||
}
|
||||
|
||||
return descriptor;
|
||||
return new GenericMethodDescriptor(typeParameters, typeParameterBounds, parameterTypes, returnType, exceptionTypes);
|
||||
}
|
||||
catch (RuntimeException e) {
|
||||
DecompilerContext.getLogger().writeMessage("Invalid signature: " + original, IFernflowerLogger.Severity.WARN);
|
||||
|
||||
@@ -1,18 +1,29 @@
|
||||
// Copyright 2000-2017 JetBrains s.r.o. Use of this source code is governed by the Apache 2.0 license that can be found in the LICENSE file.
|
||||
package org.jetbrains.java.decompiler.struct.gen.generics;
|
||||
|
||||
import java.util.ArrayList;
|
||||
import java.util.Collections;
|
||||
import java.util.List;
|
||||
|
||||
public class GenericMethodDescriptor {
|
||||
public final List<String> typeParameters;
|
||||
public final List<List<GenericType>> typeParameterBounds;
|
||||
public final List<GenericType> parameterTypes;
|
||||
public final GenericType returnType;
|
||||
public final List<GenericType> exceptionTypes;
|
||||
|
||||
public final List<String> fparameters = new ArrayList<>();
|
||||
public GenericMethodDescriptor(List<String> typeParameters,
|
||||
List<List<GenericType>> typeParameterBounds,
|
||||
List<GenericType> parameterTypes,
|
||||
GenericType returnType,
|
||||
List<GenericType> exceptionTypes) {
|
||||
this.typeParameters = substitute(typeParameters);
|
||||
this.typeParameterBounds = substitute(typeParameterBounds);
|
||||
this.parameterTypes = substitute(parameterTypes);
|
||||
this.returnType = returnType;
|
||||
this.exceptionTypes = substitute(exceptionTypes);
|
||||
}
|
||||
|
||||
public final List<List<GenericType>> fbounds = new ArrayList<>();
|
||||
|
||||
public final List<GenericType> params = new ArrayList<>();
|
||||
|
||||
public GenericType ret;
|
||||
|
||||
public final List<GenericType> exceptions = new ArrayList<>();
|
||||
}
|
||||
private static <T> List<T> substitute(List<T> list) {
|
||||
return list.isEmpty() ? Collections.emptyList() : list;
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user