(
className: string,
schema: JSONSchema7,
packageName: string,
packageDir: string,
rpcMethod: string,
kind: "params" | "result",
stability?: string,
deprecated?: boolean
)
| 1428 | } |
| 1429 | |
| 1430 | async function generateRpcDataClass( |
| 1431 | className: string, |
| 1432 | schema: JSONSchema7, |
| 1433 | packageName: string, |
| 1434 | packageDir: string, |
| 1435 | rpcMethod: string, |
| 1436 | kind: "params" | "result", |
| 1437 | stability?: string, |
| 1438 | deprecated?: boolean |
| 1439 | ): Promise<string> { |
| 1440 | const nestedTypes = new Map<string, { code: string }>(); |
| 1441 | const { code, imports } = generateRpcClass(className, schema, nestedTypes, packageName); |
| 1442 | |
| 1443 | const lines: string[] = []; |
| 1444 | lines.push(COPYRIGHT); |
| 1445 | lines.push(""); |
| 1446 | lines.push(AUTO_GENERATED_HEADER); |
| 1447 | lines.push(GENERATED_FROM_API); |
| 1448 | lines.push(""); |
| 1449 | lines.push(`package ${packageName};`); |
| 1450 | lines.push(""); |
| 1451 | |
| 1452 | const allImports = new Set<string>([ |
| 1453 | "com.fasterxml.jackson.annotation.JsonIgnoreProperties", |
| 1454 | "com.fasterxml.jackson.annotation.JsonProperty", |
| 1455 | "com.fasterxml.jackson.annotation.JsonInclude", |
| 1456 | "javax.annotation.processing.Generated", |
| 1457 | ...imports, |
| 1458 | ]); |
| 1459 | if (stability === "experimental") { |
| 1460 | allImports.add("com.github.copilot.CopilotExperimental"); |
| 1461 | } |
| 1462 | const sortedImports = [...allImports].sort(); |
| 1463 | for (const imp of sortedImports) { |
| 1464 | lines.push(`import ${imp};`); |
| 1465 | } |
| 1466 | lines.push(""); |
| 1467 | |
| 1468 | if (schema.description) { |
| 1469 | lines.push(`/**`); |
| 1470 | lines.push(` * ${schema.description}`); |
| 1471 | } else { |
| 1472 | lines.push(`/**`); |
| 1473 | lines.push(` * ${kind === "params" ? "Request parameters" : "Result"} for the {@code ${rpcMethod}} RPC method.`); |
| 1474 | } |
| 1475 | if (stability === "experimental") { |
| 1476 | lines.push(` *`); |
| 1477 | lines.push(` * @apiNote This method is experimental and may change in a future version.`); |
| 1478 | } |
| 1479 | lines.push(` * @since 1.0.0`); |
| 1480 | lines.push(` */`); |
| 1481 | if (deprecated) { |
| 1482 | lines.push(`@Deprecated`); |
| 1483 | } |
| 1484 | if (stability === "experimental") { |
| 1485 | lines.push(`@CopilotExperimental`); |
| 1486 | } |
| 1487 | lines.push(GENERATED_ANNOTATION); |
no test coverage detected
searching dependent graphs…