@@ -81,24 +81,42 @@ interface LangWorker {
81
81
}
82
82
}
83
83
84
- val result = jobs.map { job ->
85
- val jobContext = contextFromJob(job, workerContext)
84
+ val result = executeJob().map {
85
+ outputFile.appendText(it.toString() + " \n " )
86
+ it
87
+ }
86
88
87
- val flatten = workerContext.codeContextStrategies.map { type ->
88
- type.builder(jobContext).build()
89
- }.flatten()
89
+ return @coroutineScope result
90
+ }
90
91
91
- flatten.map {
92
- outputFile.appendText(it.toString() + " \n " )
93
- }
92
+ /* *
93
+ * Executes a job and returns a list of typed instructions.
94
+ *
95
+ * This method iterates over the list of jobs and creates a job context for each job using the provided worker context.
96
+ * It then iterates over the code context strategies of the worker context and builds a list of typed instructions
97
+ * using the job context and each code context strategy. The resulting list of typed instructions is flattened and returned.
98
+ *
99
+ * @return a list of typed instructions generated by executing the jobs
100
+ */
101
+ fun executeJob (): List <TypedIns > {
102
+ return jobs.map { job ->
103
+ val jobContext = createJob(job, workerContext)
94
104
95
- flatten
105
+ workerContext.codeContextStrategies.map { type ->
106
+ type.builder(jobContext).build()
107
+ }.flatten()
96
108
}.flatten()
97
-
98
- return @coroutineScope result
99
109
}
100
110
101
- fun contextFromJob (job : InstructionFileJob , workerContext : WorkerContext ) = JobContext (
111
+ /* *
112
+ * Creates a JobContext object based on the given InstructionFileJob and WorkerContext.
113
+ *
114
+ * @param job The InstructionFileJob object representing the job to be processed.
115
+ * @param workerContext The WorkerContext object containing the context information for the worker.
116
+ * @return A JobContext object containing the job, quality types, file tree, output configuration, completion types,
117
+ * maximum completion in one file, project context, and quality threshold.
118
+ */
119
+ fun createJob (job : InstructionFileJob , workerContext : WorkerContext ) = JobContext (
102
120
job,
103
121
workerContext.qualityTypes,
104
122
fileTree,
0 commit comments