1Your task is to map a step from the conversation above to operations on symbols inside the provided source files.
2
3Guidelines:
4- There's no need to describe *what* to do, just *where* to do it.
5- If creating a file, assume any subsequent updates are included at the time of creation.
6- Don't create and then update a file.
7- We'll create it in one shot.
8- Prefer updating symbols lower in the syntax tree if possible.
9- Never include operations on a parent symbol and one of its children in the same operations block.
10- Never nest an operation with another operation or include CDATA or other content. All operations are leaf nodes.
11- Include a description attribute for each operation with a brief, one-line description of the change to perform.
12- Descriptions are required for all operations except delete.
13- When generating multiple operations, ensure the descriptions are specific to each individual operation.
14- Avoid referring to the location in the description. Focus on the change to be made, not the location where it's made. That's implicit with the symbol you provide.
15- Don't generate multiple operations at the same location. Instead, combine them together in a single operation with a succinct combined description.
16
17Example 1:
18
19User:
20```rs src/rectangle.rs
21struct Rectangle {
22 width: f64,
23 height: f64,
24}
25
26impl Rectangle {
27 fn new(width: f64, height: f64) -> Self {
28 Rectangle { width, height }
29 }
30}
31```
32
33<step>Add new methods 'calculate_area' and 'calculate_perimeter' to the Rectangle struct</step>
34<step>Implement the 'Display' trait for the Rectangle struct</step>
35
36What are the operations for the step: <step>Add a new method 'calculate_area' to the Rectangle struct</step>
37
38A (wrong):
39{
40 "operations": [
41 {
42 "kind": "AppendChild",
43 "path": "src/shapes.rs",
44 "symbol": "impl Rectangle",
45 "description": "Add calculate_area method"
46 },
47 {
48 "kind": "AppendChild",
49 "path": "src/shapes.rs",
50 "symbol": "impl Rectangle",
51 "description": "Add calculate_perimeter method"
52 }
53 ]
54}
55
56This demonstrates what NOT to do. NEVER append multiple children at the same location.
57
58A (corrected):
59{
60 "operations": [
61 {
62 "kind": "AppendChild",
63 "path": "src/shapes.rs",
64 "symbol": "impl Rectangle",
65 "description": "Add calculate area and perimeter methods"
66 }
67 ]
68}
69
70User:
71What are the operations for the step: <step>Implement the 'Display' trait for the Rectangle struct</step>
72
73A:
74{
75 "operations": [
76 {
77 "kind": "InsertSiblingAfter",
78 "path": "src/shapes.rs",
79 "symbol": "impl Rectangle",
80 "description": "Implement Display trait for Rectangle"
81 }
82 ]
83}
84
85Example 2:
86
87User:
88```rs src/user.rs
89struct User {
90 pub name: String,
91 age: u32,
92 email: String,
93}
94
95impl User {
96 fn new(name: String, age: u32, email: String) -> Self {
97 User { name, age, email }
98 }
99
100 pub fn print_info(&self) {
101 println!("Name: {}, Age: {}, Email: {}", self.name, self.age, self.email);
102 }
103}
104```
105
106<step>Update the 'print_info' method to use formatted output</step>
107<step>Remove the 'email' field from the User struct</step>
108
109What are the operations for the step: <step>Update the 'print_info' method to use formatted output</step>
110
111A:
112{
113 "operations": [
114 {
115 "kind": "Update",
116 "path": "src/user.rs",
117 "symbol": "impl User pub fn print_info",
118 "description": "Use formatted output"
119 }
120 ]
121}
122
123User:
124What are the operations for the step: <step>Remove the 'email' field from the User struct</step>
125
126A:
127{
128 "operations": [
129 {
130 "kind": "Delete",
131 "path": "src/user.rs",
132 "symbol": "struct User email"
133 }
134 ]
135}
136
137Example 3:
138
139User:
140```rs src/vehicle.rs
141struct Vehicle {
142 make: String,
143 model: String,
144 year: u32,
145}
146
147impl Vehicle {
148 fn new(make: String, model: String, year: u32) -> Self {
149 Vehicle { make, model, year }
150 }
151
152 fn print_year(&self) {
153 println!("Year: {}", self.year);
154 }
155}
156```
157
158<step>Add a 'use std::fmt;' statement at the beginning of the file</step>
159<step>Add a new method 'start_engine' in the Vehicle impl block</step>
160
161What are the operations for the step: <step>Add a 'use std::fmt;' statement at the beginning of the file</step>
162
163A:
164{
165 "operations": [
166 {
167 "kind": "PrependChild",
168 "path": "src/vehicle.rs",
169 "description": "Add 'use std::fmt' statement"
170 }
171 ]
172}
173
174User:
175What are the operations for the step: <step>Add a new method 'start_engine' in the Vehicle impl block</step>
176
177A:
178{
179 "operations": [
180 {
181 "kind": "InsertSiblingAfter",
182 "path": "src/vehicle.rs",
183 "symbol": "impl Vehicle fn new",
184 "description": "Add start_engine method"
185 }
186 ]
187}
188
189Example 4:
190
191User:
192```rs src/employee.rs
193struct Employee {
194 name: String,
195 position: String,
196 salary: u32,
197 department: String,
198}
199
200impl Employee {
201 fn new(name: String, position: String, salary: u32, department: String) -> Self {
202 Employee { name, position, salary, department }
203 }
204
205 fn print_details(&self) {
206 println!("Name: {}, Position: {}, Salary: {}, Department: {}",
207 self.name, self.position, self.salary, self.department);
208 }
209
210 fn give_raise(&mut self, amount: u32) {
211 self.salary += amount;
212 }
213}
214```
215
216<step>Make salary an f32</step>
217
218What are the operations for the step: <step>Make salary an f32</step>
219
220A (wrong):
221{
222 "operations": [
223 {
224 "kind": "Update",
225 "path": "src/employee.rs",
226 "symbol": "struct Employee",
227 "description": "Change the type of salary to an f32"
228 },
229 {
230 "kind": "Update",
231 "path": "src/employee.rs",
232 "symbol": "struct Employee salary",
233 "description": "Change the type to an f32"
234 }
235 ]
236}
237
238This example demonstrates what not to do. `struct Employee salary` is a child of `struct Employee`.
239
240A (corrected):
241{
242 "operations": [
243 {
244 "kind": "Update",
245 "path": "src/employee.rs",
246 "symbol": "struct Employee salary",
247 "description": "Change the type to an f32"
248 }
249 ]
250}
251
252User:
253What are the correct operations for the step: <step>Remove the 'department' field and update the 'print_details' method</step>
254
255A:
256{
257 "operations": [
258 {
259 "kind": "Delete",
260 "path": "src/employee.rs",
261 "symbol": "struct Employee department"
262 },
263 {
264 "kind": "Update",
265 "path": "src/employee.rs",
266 "symbol": "impl Employee fn print_details",
267 "description": "Don't print the 'department' field"
268 }
269 ]
270}
271
272Example 5:
273
274User:
275```rs src/game.rs
276struct Player {
277 name: String,
278 health: i32,
279 pub score: u32,
280}
281
282impl Player {
283 pub fn new(name: String) -> Self {
284 Player { name, health: 100, score: 0 }
285 }
286}
287
288struct Game {
289 players: Vec<Player>,
290}
291
292impl Game {
293 fn new() -> Self {
294 Game { players: Vec::new() }
295 }
296}
297```
298
299<step>Add a 'level' field to Player and update the 'new' method</step>
300
301A:
302{
303 "operations": [
304 {
305 "kind": "InsertSiblingAfter",
306 "path": "src/game.rs",
307 "symbol": "struct Player pub score",
308 "description": "Add level field to Player"
309 },
310 {
311 "kind": "Update",
312 "path": "src/game.rs",
313 "symbol": "impl Player pub fn new",
314 "description": "Initialize level in new method"
315 }
316 ]
317}
318
319Example 6:
320
321User:
322```rs src/config.rs
323use std::collections::HashMap;
324
325struct Config {
326 settings: HashMap<String, String>,
327}
328
329impl Config {
330 fn new() -> Self {
331 Config { settings: HashMap::new() }
332 }
333}
334```
335
336<step>Add a 'load_from_file' method to Config and import necessary modules</step>
337
338A:
339{
340 "operations": [
341 {
342 "kind": "PrependChild",
343 "path": "src/config.rs",
344 "description": "Import std::fs and std::io modules"
345 },
346 {
347 "kind": "AppendChild",
348 "path": "src/config.rs",
349 "symbol": "impl Config",
350 "description": "Add load_from_file method"
351 }
352 ]
353}
354
355Example 7:
356
357User:
358```rs src/database.rs
359pub(crate) struct Database {
360 connection: Connection,
361}
362
363impl Database {
364 fn new(url: &str) -> Result<Self, Error> {
365 let connection = Connection::connect(url)?;
366 Ok(Database { connection })
367 }
368
369 async fn query(&self, sql: &str) -> Result<Vec<Row>, Error> {
370 self.connection.query(sql, &[])
371 }
372}
373```
374
375<step>Add error handling to the 'query' method and create a custom error type</step>
376
377A:
378{
379 "operations": [
380 {
381 "kind": "PrependChild",
382 "path": "src/database.rs",
383 "description": "Import necessary error handling modules"
384 },
385 {
386 "kind": "InsertSiblingBefore",
387 "path": "src/database.rs",
388 "symbol": "pub(crate) struct Database",
389 "description": "Define custom DatabaseError enum"
390 },
391 {
392 "kind": "Update",
393 "path": "src/database.rs",
394 "symbol": "impl Database async fn query",
395 "description": "Implement error handling in query method"
396 }
397 ]
398}
399
400Now generate the operations for the following step: