Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Generate builders for structures #18

Open
keynmol opened this issue Aug 26, 2022 · 0 comments
Open

Generate builders for structures #18

keynmol opened this issue Aug 26, 2022 · 0 comments
Milestone

Comments

@keynmol
Copy link
Contributor

keynmol commented Aug 26, 2022

Perhaps it will make IDE experience better if structures exposed builder-style pattern.

I.e. if you have a SymbolInformation structure:

case class SymbolInformation(
  deprecated: Opt[Boolean] = Opt.empty,
  location: structures.Location,
  name: String,
  kind: enumerations.SymbolKind,
  tags: Opt[Vector[enumerations.SymbolTag]] = Opt.empty,
  containerName: Opt[String] = Opt.empty
)

It has 3 required fields (location, name, kind) and several optional fields. All the fields become withCamelCase methods on the generated builder, but to create the builder you need to pass the required fields:

SymbolInformation
  .builder(name, location, kind)
  .withTags(v: Vector[SymbolTag])
  .withContainerName(s: String)
  .withName(s: String) // overwrites the value passed to the builder method
  .build // : SymbolInformation
@keynmol keynmol added this to the 0.1.0 milestone Aug 26, 2022
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

1 participant