Skip to content

Commit 979f4a9

Browse files
yury-sclaude
andcommitted
chore: resolve Object langAliases in function argument types
Inner Objects nested inside function-typed arguments are not visited by createClassesAndEnums, so the api generator never set customType for them and had to fall back to a hardcoded jsonPath switch (the Screencast.start.onFrame -> Consumer<ScreencastFrame> case). Have convertBuiltinType resolve the Java type name from the inner Object's langAliases when no customType is set, and drop the hardcoded onFrame case. This works once microsoft/playwright adds alias-java for the onFrame Object (already proposed upstream). Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
1 parent 7dbd6ca commit 979f4a9

1 file changed

Lines changed: 6 additions & 3 deletions

File tree

tools/api-generator/src/main/java/com/microsoft/playwright/tools/ApiGenerator.java

Lines changed: 6 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -506,6 +506,12 @@ private String convertBuiltinType(JsonObject jsonType) {
506506
if (customType != null) {
507507
return customType;
508508
}
509+
// Inner Objects (e.g. function arguments) are not visited by createClassesAndEnums,
510+
// so resolve their Java type name from langAliases here.
511+
String alias = javaAlias(jsonType);
512+
if (alias != null) {
513+
return alias;
514+
}
509515
return "Map<" + convertTemplateParams(jsonType) + ">";
510516
}
511517
if ("Map".equals(name)) {
@@ -525,9 +531,6 @@ private String convertBuiltinType(JsonObject jsonType) {
525531
if ("WebSocketRoute.onClose.handler".equals(jsonPath)) {
526532
return "BiConsumer<Integer, String>";
527533
}
528-
if ("Screencast.start.options.onFrame".equals(jsonPath)) {
529-
return "Consumer<ScreencastFrame>";
530-
}
531534
if (jsonType.getAsJsonArray("args").size() == 1) {
532535
String paramType = convertBuiltinType(jsonType.getAsJsonArray("args").get(0).getAsJsonObject());
533536
if (!jsonType.has("returnType") || jsonType.get("returnType").isJsonNull()) {

0 commit comments

Comments
 (0)