question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

CodeGen API Simplification

See original GitHub issue

I believe the codegen API can be simplified. E.g.

.withMethod("setIdAndName", sequence(
				set(property(self(), "id"), arg(0)),
				set(property(self(), "name"), arg(1))))

can become

.method("setIdAndName").args("id", "name").of(int.class, String.class).body(statements(assign("this.id", "this.name").to("id", "name")))

or

.method("setIdAndName").body(assign("this.id", "this.name").to("id", "name"))

as Person defines the arguments and types this is implied.

Similarly

.withField("id", int.class)
...
.withMethod("getId", property(self(), "id"))

can become

.getter("id", int.class)

Also,

.withMethod("hashOfPojo", hash(property(arg(0), "id"), property(arg(0), "name")))

can become

.method("hashOfPojo").args("personPojo").of("ExamplePojo").returning(int.class).body(statements(returning(hash("personPojo.id", "personPojo.name"))))

or

.method("hashOfPojo").body(returning(hash("personPojo.id", "personPojo.name")))

as Person defines the arguments

etc.

Basically,

  • add shortcuts to all JavaBeans specific constructs
  • Use builder pattern and fluent API
  • a simple way to access arguments, fields, etc.
  • a simple way to set fields and return values

Issue Analytics

  • State:closed
  • Created 3 years ago
  • Comments:9 (9 by maintainers)

github_iconTop GitHub Comments

1reaction
eduard-vasinskyicommented, Dec 15, 2020

Here we have provided some of the goals and design decisions behind ActiveCodegen. It is a tool for dynamic class generation based on runtime parameters and information available in runtime. It supports code generation using functional composition of LISP-like expressions and ASTs. The current API is completely suitable for this task.

0reactions
sirinathcommented, Dec 15, 2020

It supports code generation using functional composition of LISP-like expressions and ASTs.

Since LISP like expressions and ASTs is supported. Perhaps some additional abilities which might prove to be useful:

  • convert byte-code into and S-expression/AST representation,
  • analyse S-expression/AST representation,
  • search for patterns in the S-expression/AST representation,
  • modify the S-expression/AST representation,
  • write results back modifying the class files.
Read more comments on GitHub >

github_iconTop Results From Across the Web

API Code & Client Generator | Swagger Codegen
Codegen simplifies your build process by generating server stubs and client SDKs for any API defined with the OpenAPI specification. Download Codegen today....
Read more >
Introduction to OpenAPI codegen | by Divyansh Sharma
Introduction to OpenAPI codegen - Simplify RESTful development. This blog gives an introduction to OpenAPI codegen. We will publish another ...
Read more >
Simplify Framework - OpenAPI Based Serverless - GitHub
Generate Simplify Framework base projects with True-DevOps code skeleton to run on Cloud with API Gateway, AWS Lambda and other AWS Services from...
Read more >
simplify-codegen - npm
Simplify Code Generator from OpenAPI 3.0 Specs. ... Start using simplify-codegen in your project by running `npm i simplify-codegen`.
Read more >
Support for Swagger Codegen in REST APIs - YouTube
Swagger Codegen can simplify a build process by generating server stubs and client SDKs for any API, that is defined with the OpenAPI....
Read more >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found