-
Notifications
You must be signed in to change notification settings - Fork 166
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
fix(java): Omit methods with inlined types from interface definitions (…
…#5639) * fix(java): Fix union type name conflict resolution * Add version yamls * fix(java): Omit methods with inline types in interfaces * make distinction between rendered and actual method specs, and ensure to check inlined status properly * chore: update changelog * Don't add an override label to non-rendered interface fields * Add version entries --------- Co-authored-by: Alberto <[email protected]>
- Loading branch information
Showing
8 changed files
with
172 additions
and
16 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
81 changes: 81 additions & 0 deletions
81
...rs/java/generator-utils/src/main/java/com/fern/java/utils/TypeReferenceInlineChecker.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,81 @@ | ||
package com.fern.java.utils; | ||
|
||
import com.fern.ir.model.types.ContainerType; | ||
import com.fern.ir.model.types.Literal; | ||
import com.fern.ir.model.types.MapType; | ||
import com.fern.ir.model.types.NamedType; | ||
import com.fern.ir.model.types.PrimitiveType; | ||
import com.fern.ir.model.types.TypeDeclaration; | ||
import com.fern.ir.model.types.TypeReference; | ||
import com.fern.java.AbstractGeneratorContext; | ||
import java.util.Optional; | ||
|
||
public class TypeReferenceInlineChecker implements TypeReference.Visitor<Boolean>, ContainerType.Visitor<Boolean> { | ||
|
||
private final AbstractGeneratorContext<?, ?> generatorContext; | ||
|
||
public TypeReferenceInlineChecker(AbstractGeneratorContext<?, ?> generatorContext) { | ||
this.generatorContext = generatorContext; | ||
} | ||
|
||
// Handle main types | ||
|
||
@Override | ||
public Boolean visitContainer(ContainerType containerType) { | ||
return containerType.visit(this); | ||
} | ||
|
||
@Override | ||
public Boolean visitNamed(NamedType namedType) { | ||
// TODO(ajgateno): Tracking in FER-4050 that we can't just get inline from namedType.getInline() | ||
Optional<TypeDeclaration> existingTypeDeclaration = | ||
Optional.ofNullable(generatorContext.getTypeDeclarations().get(namedType.getTypeId())); | ||
return existingTypeDeclaration | ||
.map(declaration -> declaration.getInline().orElse(false)) | ||
.orElse(false); | ||
} | ||
|
||
@Override | ||
public Boolean visitPrimitive(PrimitiveType primitiveType) { | ||
return false; | ||
} | ||
|
||
@Override | ||
public Boolean visitUnknown() { | ||
return false; | ||
} | ||
|
||
// Handle container types | ||
|
||
@Override | ||
public Boolean visitList(TypeReference typeReference) { | ||
return typeReference.visit(this); | ||
} | ||
|
||
@Override | ||
public Boolean visitMap(MapType mapType) { | ||
return mapType.getKeyType().visit(this) || mapType.getValueType().visit(this); | ||
} | ||
|
||
@Override | ||
public Boolean visitOptional(TypeReference typeReference) { | ||
return typeReference.visit(this); | ||
} | ||
|
||
@Override | ||
public Boolean visitSet(TypeReference typeReference) { | ||
return typeReference.visit(this); | ||
} | ||
|
||
@Override | ||
public Boolean visitLiteral(Literal literal) { | ||
return false; | ||
} | ||
|
||
// Unknown | ||
|
||
@Override | ||
public Boolean _visitUnknown(Object o) { | ||
return false; | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters