Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Sync delivery to master after 23-rc2 #7630

Merged
merged 16 commits into from
Aug 7, 2024
Merged
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Prev Previous commit
Next Next commit
CodeGenerator should be able to generate basic code for records
generates a final class as workaround instead of throwing an exception
  • Loading branch information
mbien committed Aug 2, 2024
commit 3c0f5222466f6320ad748e886651255ef8136981
Original file line number Diff line number Diff line change
@@ -393,6 +393,9 @@ public Tree visitType(TypeElement e, Void p) {
List<Tree> members = new LinkedList<Tree>();

for (Element m : e.getEnclosedElements()) {
if (m.getKind() == ElementKind.RECORD_COMPONENT) {
continue; // TODO update to 'extend AbstractElementVisitor14'; visiting record components causes UnknownElementException
}
Tree member = visit(m);

if (member != null)
@@ -408,6 +411,10 @@ public Tree visitType(TypeElement e, Void p) {
return addDeprecated(e, make.Interface(mods, e.getSimpleName(), constructTypeParams(e.getTypeParameters()), computeSuper(e.getInterfaces()), members));
case ENUM:
return addDeprecated(e, make.Enum(mods, e.getSimpleName(), computeSuper(e.getInterfaces()), members));
case RECORD:
// TODO generates final class atm
return addDeprecated(e, make.Class(mods, e.getSimpleName(), constructTypeParams(e.getTypeParameters()), null, computeSuper(e.getInterfaces()), members));
// return addDeprecated(e, make.Record(mods, e.getSimpleName(), computeSuper(e.getInterfaces()), members));
case ANNOTATION_TYPE:
return addDeprecated(e, make.AnnotationType(mods, e.getSimpleName(), members));
default:
@@ -782,6 +789,8 @@ public void writeInstr(Instruction instr) {
IMPLICIT_MODIFIERS = new HashMap<List<ElementKind>, Set<Modifier>>();

IMPLICIT_MODIFIERS.put(Arrays.asList(ElementKind.ENUM), EnumSet.of(Modifier.STATIC, Modifier.ABSTRACT, Modifier.FINAL));
// TODO implement record support
// IMPLICIT_MODIFIERS.put(Arrays.asList(ElementKind.RECORD), EnumSet.of(Modifier.STATIC, Modifier.ABSTRACT, Modifier.FINAL));
IMPLICIT_MODIFIERS.put(Arrays.asList(ElementKind.ANNOTATION_TYPE), EnumSet.of(Modifier.STATIC, Modifier.ABSTRACT));
IMPLICIT_MODIFIERS.put(Arrays.asList(ElementKind.METHOD, ElementKind.ANNOTATION_TYPE), EnumSet.of(Modifier.ABSTRACT));
IMPLICIT_MODIFIERS.put(Arrays.asList(ElementKind.METHOD, ElementKind.INTERFACE), EnumSet.of(Modifier.ABSTRACT));
Loading