outfoxx / swiftpoet

Kotlin and Java API for generating .swift source files.
Apache License 2.0
277 stars 26 forks source link

Add support for variable didSet and private(set) #70

Closed hbmartin closed 1 year ago

kdubb commented 1 year ago

Hi @hbmartin thanks for the contribution 🙌. I will go over it in the next few days.

That being said... please don't group unrelated changes into a PR (e.g. your varargs change to DeclaredTypeName). It makes generating changes in releases a lot harder.

kdubb commented 1 year ago

@hbmartin Can you make this PR for didSet and then open separate ones for private(set) and adding list calls?

kdubb commented 1 year ago

@hbmartin Swift supports any visibility (open, public, internal, private) on a field setter. I've implemented this in PR #77.

You use it as follows:

PropertySpec.varBuilder("test", STRING, PUBLIC)
  .mutableVisibility(PRIVATE)
  .build()
kdubb commented 1 year ago

PR #79 adds support for willSet and didSet observers.

Simple usage...

PropertySpec.varBuilder("test", STRING)
  .didSet(FunctionSpec.willSetBuilder(...))
  .willSet(FunctionSpec.didSetBuilder(...))        
kdubb commented 1 year ago

Closing PR because these features have been implemented.