Skip to content
This repository has been archived by the owner on Jan 18, 2022. It is now read-only.

[UTY-2389] CodeWriter v2: minimum feature set (1/3) #1237

Merged
merged 16 commits into from
Jan 16, 2020

Conversation

paulbalaji
Copy link
Contributor

@paulbalaji paulbalaji commented Jan 8, 2020

Description

The minimum feature set of CodeWriter v2 such that CodeGenerationLib can make full use of it.

Information about the CodeWriter v2 classes

ICodeBlock

  • a unit of code that can be turned into an indented string

ScopeBlock : ICodeBlock

  • a CodeBlock with scope + indentation implemented

ScopeBody : ScopeBlock

  • contains helpers for writing code that is found in functions

CustomScopeBlock : ScopeBody

  • a generic scope with optional declaration

LoopBlock : ScopeBody

  • a scope with mandatory declaration for defining loops

ScopeBodyList : ICodeBlock

  • a grouping of scoped bodies

IfElseBlock : ScopeBodyList

  • a unit representing if/elseif/else code

TryCatchBlock : ScopeBodyList

  • a unit representing try/catch/finally code

InitializerCodeBlock : ICodeBlock

  • a helper to write initializers

Text : ICodeBlock

  • plaintext

TextList : ICodeBlock

  • a grouping of text to be on consecutive lines

Pending work before merging

  • changelog
  • regenerate & validate test-project code
  • run playground

Tests

  • ensuring generated code still compiles (buildkite)
  • check generated code diff to ensure any changes are only whitespace trivia

Paul Balaji added 3 commits January 8, 2020 16:29
@paulbalaji paulbalaji added the A: codegen Area: Code generation label Jan 8, 2020
@paulbalaji paulbalaji self-assigned this Jan 8, 2020
@improbable-prow-robot
Copy link

Corresponding JIRA ticket: https://improbableio.atlassian.net/browse/UTY-2389

@improbable-prow-robot improbable-prow-robot added jira/UTY size/XXL Denotes a PR that changes 600+ lines, ignoring generated files. A: tooling Area: Tooling labels Jan 8, 2020
{
get
{
if (containedType.FqnType ==
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This could be a lovely switch statement

@zeroZshadow
Copy link
Contributor

Lots of blocks create their own indent string, while most blocks will share a similar indent string.
We should have a helper to get this indent string, which caches the string for certain indentation levels.
With indentation level 0 hard coded to string.Empty

@paulbalaji paulbalaji force-pushed the feature/codewriter-v2-for-codegenlib branch from 9997a34 to 6eb3f64 Compare January 13, 2020 17:41
@jamiebrynes7
Copy link
Contributor

Add link to this PR in the changelog then :shipit:

Signed-off-by: Paul Balaji <[email protected]>
@paulbalaji paulbalaji changed the title UTY-2389: CodeWriter v2 minimum feature set [UTY-2389] CodeWriter v2: minimum feature set Jan 14, 2020
Signed-off-by: Paul Balaji <[email protected]>
Copy link
Contributor

@jessicafalk jessicafalk left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

overall lgtm, one question regarding loops: seems like the loop block covers foreach / for / while, but what about do { .. } while (...)

@paulbalaji
Copy link
Contributor Author

overall lgtm, one question regarding loops: seems like the loop block covers foreach / for / while, but what about do { .. } while (...)

I didn't find a need for it when porting across our current templates, but it's something that could be added in later should we need it

@paulbalaji paulbalaji changed the title [UTY-2389] CodeWriter v2: minimum feature set [UTY-2389] CodeWriter v2: minimum feature set (1/3) Jan 16, 2020
@paulbalaji paulbalaji merged commit 9f975db into develop Jan 16, 2020
@paulbalaji paulbalaji deleted the feature/codewriter-v2-for-codegenlib branch January 17, 2020 15:37
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
A: codegen Area: Code generation A: tooling Area: Tooling jira/UTY size/XXL Denotes a PR that changes 600+ lines, ignoring generated files.
Projects
None yet
Development

Successfully merging this pull request may close these issues.

5 participants