Chain completers

This commit is contained in:
Liam Miller-Cushon 2025-11-05 13:36:23 +01:00
parent 2781df575c
commit d78c3425a1

View File

@ -2310,35 +2310,17 @@ public class ClassReader {
currentClassFile = classFile;
List<Attribute.TypeCompound> newList = deproxyTypeCompoundList(proxies);
sym.setTypeAttributes(newList.prependList(sym.getRawTypeAttributes()));
if (sym.completer != Completer.NULL_COMPLETER) {
Assert.check(sym.completer instanceof TypeAnnotationsSymbolCompleter);
TypeAnnotationsSymbolCompleter completer = (TypeAnnotationsSymbolCompleter) sym.completer;
completer.attributes = newList.prependList(completer.attributes);
} else {
sym.completer = new TypeAnnotationsSymbolCompleter(newList);
}
Completer previousCompleter = sym.completer;
sym.completer = sym -> {
addTypeAnnotationsToSymbol(sym, newList);
previousCompleter.complete(sym);
};
} finally {
currentClassFile = previousClassFile;
}
}
}
private class TypeAnnotationsSymbolCompleter implements Completer {
List<Attribute.TypeCompound> attributes;
private TypeAnnotationsSymbolCompleter(List<Attribute.TypeCompound> attributes) {
this.attributes = attributes;
}
@Override
public void complete(Symbol sym) throws CompletionFailure {
Assert.checkNonNull(attributes);
addTypeAnnotationsToSymbol(sym, attributes);
attributes = null;
}
}
/**
* Rewrites types in the given symbol to include type annotations.
*