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.

Options to ignore certain struct fields/properties during code generation?

See original GitHub issue

Hello, I’m looking to ignore struct fields of certain types based on type names (these fields are not used in Java generated code)

If I try to do this in the implementation of KotlinTypeProcessor, e.g. calling TypeSpec.Builder.propertySpecs.removeIf { }, it’s too late.

I can do this easily in the StructType constructor:

internal constructor(element: StructElement, namespaces: Map<NamespaceScope, String>)
            : super(UserElementMixin(element, namespaces)) {
        this.structType = element.type
        this.fields = element.fields.filter { /* CONDITION */ }.map { Field(it, namespaces) }
    }

But I want to make this more generic for everyone. How do I pass an option from ThriftyCompiler so it can be picked up here?

Thanks,

Issue Analytics

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

github_iconTop GitHub Comments

1reaction
benjamin-badercommented, Mar 18, 2021

That sounds like a perfect job for a Python program 😃

1reaction
benjamin-badercommented, Mar 18, 2021

Honestly, annotations sound like the perfect vehicle for metadata. Here’s an example of thrift annotations:

struct SomeEvent {
  1: string foo (thrifty.ignored = "true"); // <-- this is a "field" annotation
  2: string bar;
} (meta.one = "foo", meta.two = "bar");  // <-- this is a "struct" annotation
Read more comments on GitHub >

github_iconTop Results From Across the Web

inheritance - How to avoid code duplication of different structs ...
As I come from Java, I would extract a base class ShapeRenderer out of those and apply the fields canvas and origin into...
Read more >
datastore: When loading kinds into structs, ignore items where ...
We process orders and we sometimes deprecate or are no longer interested in certain fields in an order. This means that during transaction ......
Read more >
Fields - ent
Fields (or properties) in the schema are the attributes of the node. ... setting it to Nillable will generate a struct field with...
Read more >
Integrate C Functions Using Legacy Code Tool - MathWorks
Options for the generated S-function. Use the legacy_code function to. Initialize the Legacy Code Tool data structure for a given C function. Generate...
Read more >
Dynamic Source Code Generation and Compilation - .NET ...
Compile and generate dynamic source code in . ... a data structure known as a CodeDOM graph, which models the structure of some...
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