Fix missing parameter names, annotations in following annotation processors

This commit is contained in:
Denis Stepanov authored and Roel Spilker committed 2020-07-02 20:25:28 +02:00
1 parent 326955cde1
commit e4ec9e6648
3 files changed
+18 -3

No files matched your search

+1
View File
@@ -9,6 +9,7 @@ Christian Sterzl <christian.sterzl@gmail.com>
DaveLaw <project.lombok@apconsult.de>
Dave Brosius <dbrosius@mebigfatguy.com>
Dawid Rusin <dawidrusin90@gmail.com>
Denis Stepanov <denis.stepanov@gmail.com>
Emil Lundberg <emil@yubico.com>
Enrique da Costa Cambio <enrique.dacostacambio@gmail.com>
Jacob Middag <jacob@gaddim.nl>
@@ -1200,16 +1200,28 @@ public class JavacHandlerUtil {
addSuppressWarningsAll(method.mods, typeNode, method.pos, getGeneratedBy(method), typeNode.getContext());
addGenerated(method.mods, typeNode, method.pos, getGeneratedBy(method), typeNode.getContext());
type.defs = type.defs.append(method);
fixMethodMirror(typeNode.getContext(), typeNode.getElement(), method.getModifiers().flags, method.getName(), paramTypes, returnType);
List<Symbol.VarSymbol> params = null;
if (method.getParameters() != null && !method.getParameters().isEmpty()) {
ListBuffer<Symbol.VarSymbol> newParams = new ListBuffer<Symbol.VarSymbol>();
for (JCTree.JCVariableDecl param : method.getParameters()) {
newParams.append(param.sym);
}
params = newParams.toList();
}
fixMethodMirror(typeNode.getContext(), typeNode.getElement(), method.getModifiers().flags, method.getName(), paramTypes, params, returnType);
typeNode.add(method, Kind.METHOD);
}
private static void fixMethodMirror(Context context, Element typeMirror, long access, Name methodName, List<Type> paramTypes, Type returnType) {
private static void fixMethodMirror(Context context, Element typeMirror, long access, Name methodName, List<Type> paramTypes, List<Symbol.VarSymbol> params, Type returnType) {
if (typeMirror == null || paramTypes == null || returnType == null) return;
ClassSymbol cs = (ClassSymbol) typeMirror;
MethodSymbol methodSymbol = new MethodSymbol(access, methodName, new MethodType(paramTypes, returnType, List.<Type>nil(), Symtab.instance(context).methodClass), cs);
if (params != null && !params.isEmpty()) {
methodSymbol.params = params;
}
ClassSymbolMembersField.enter(cs, methodSymbol);
}
@@ -18,6 +18,7 @@ import javax.lang.model.element.TypeParameterElement;
import javax.lang.model.element.VariableElement;
import javax.lang.model.type.TypeMirror;
import com.sun.tools.javac.util.List;
import com.sun.tools.javac.util.Name;
public abstract class Symbol implements Element {
@@ -41,6 +42,7 @@ public abstract class Symbol implements Element {
public static abstract class TypeSymbol extends Symbol {}
public static class MethodSymbol extends Symbol implements ExecutableElement {
public List<Symbol.VarSymbol> params = null;
public MethodSymbol(long flags, Name name, Type type, Symbol owner) {}
@Override public ElementKind getKind() { return null; }
@Override public Set<Modifier> getModifiers() { return null; }