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

Update model for interfaces extending interfaces #4663

Merged
merged 6 commits into from
Nov 13, 2024
Merged
Changes from all commits
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
13 changes: 13 additions & 0 deletions rewrite-java/src/main/java/org/openrewrite/java/tree/J.java
Original file line number Diff line number Diff line change
Expand Up @@ -1222,6 +1222,12 @@ public ClassDeclaration withPrimaryConstructor(@Nullable List<Statement> primary
@Nullable
JLeftPadded<TypeTree> extendings;

/**
* This is used to access the parent class.
*
* @return The parent class of the ClassDeclaration. If the ClassDeclaration is a class, this will return the
* class specified by the 'extends' keyword. If the ClassDeclaration is an interface, this will return null.
*/
public @Nullable TypeTree getExtends() {
return extendings == null ? null : extendings.getElement();
}
Expand All @@ -1233,6 +1239,13 @@ public ClassDeclaration withExtends(@Nullable TypeTree extendings) {
@Nullable
JContainer<TypeTree> implementings;

/**
* This is used to access the parent interfaces.
*
* @return A list of the parent interfaces of the ClassDeclaration. If the ClassDeclaration is a class, this
* will return the interfaces specified by the 'implements' keyword. If the ClassDeclaration is an interface,
* this will return the interfaces specified by the 'extends' keyword.
*/
public @Nullable List<TypeTree> getImplements() {
return implementings == null ? null : implementings.getElements();
}
Expand Down