uranusjr commented on code in PR #74230:
URL: https://github.com/apache/airflow/pull/74230#discussion_r4203870207
##########
java-sdk/processor/src/main/kotlin/org/apache/airflow/sdk/BuilderProcessor.kt:
##########
@@ -682,13 +829,45 @@ class BuilderProcessor : AbstractProcessor() {
}
}
-/** One [Builder.Task]-annotated method with its resolved id and data
parameters. */
+/** The tasks and task groups one class declares. */
+private class Scope(
+ val tasks: List<TaskDeclaration>,
+ val groups: List<GroupDeclaration>,
+) {
+ /** Every task of this scope and the groups beneath it, outermost first. */
+ fun allTasks(): List<TaskDeclaration> = tasks + groups.flatMap {
it.scope.allTasks() }
+
+ /** Every group beneath this scope, parents before the groups nested in
them. */
+ fun allGroups(): List<GroupDeclaration> = groups.flatMap { listOf(it) +
it.scope.allGroups() }
+}
+
+/** One `@Builder.TaskGroup` class, and what it declares. */
+private class GroupDeclaration(
+ val element: TypeElement,
+ val id: String,
+ val fullId: String,
+ val scope: Scope,
+) {
+ /** The view method that reaches this group, named after the class it is
declared as. */
+ val accessor: String =
element.simpleName.toString().replaceFirstChar(Char::lowercase)
+}
+
+/**
+ * One [Builder.Task]-annotated method with its resolved id and data
parameters.
+ * [owner] is the class that declares it, which the generated body
instantiates,
+ * and [classPath] the task-group classes enclosing it.
+ */
private class TaskDeclaration(
val method: ExecutableElement,
val id: String,
val dataParams: List<DataParam>,
+ val owner: TypeElement,
+ val classPath: List<String> = emptyList(),
+ /** Full ID of the group this task sits in, empty when it sits in none. */
+ val groupId: String = "",
) {
- val className: String =
method.simpleName.toString().replaceFirstChar(Char::uppercase)
+ val className: String =
+ (classPath +
method.simpleName.toString().replaceFirstChar(Char::uppercase)).joinToString("_")
Review Comment:
Flattening with `_` can collide. Nest the generated task classes to mirror
the group tree, or detect the clash and report it.
--
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
To unsubscribe, e-mail: [email protected]
For queries about this service, please contact Infrastructure at:
[email protected]