dart-lang / code_builder

A fluent API for generating valid Dart source code
https://pub.dev/packages/code_builder
BSD 3-Clause "New" or "Revised" License
423 stars 66 forks source link

Is there a way to read existing code into a ClassBuilder ? #393

Open evanholt1 opened 1 year ago

evanholt1 commented 1 year ago

Hello!

I am still reading the documentation of this package, so please point out if there way a piece of documentation I missed.

My use case requires being able to write classes, such as the example in this package of creating a Class using ClassBuilder, but to also read existing source code to be able to edit it. I have seen there are classes such as Code and Block, but found no way to map them into a class.

So my question: is there a way to use this package to turn an existing piece of code into a Class ?

I believe code generation would be a lot easier if I can write a class using code as done in this package, but then also be able to read that source code again, and edit it.

jodinathan commented 1 year ago

I guess you need to use analyzer instead