code-generation

Generate setters that return self in Eclipse

一世执手 提交于 2019-12-08 23:11:33
问题 I'd like to have my setters so that I can chain them like: myPojo.setX(x).setY(y); Usually I generate setters with Eclipse but unfortunately code template for setters allows me to change only the body of the setter, not the signature. What would be the easiest way to complete the above? Besides search-and-replace + manual editing? :) 回答1: You could use the Editor/Templates for this purpose. To define a new Template open the Preferences Window, then Java->Editor->Templates. In this window you

Associate attribute with code generated property in .net

牧云@^-^@ 提交于 2019-12-08 22:57:00
问题 I wish to set an attribute on a public property in .NET, however I do not have access to the explicit property itself, as this has been code generated in another file. I have this field: public virtual string Name { get; set; } I wish to set this: [ValidateNonEmpty("Name is required", ExecutionOrder = 1)] public virtual string Name { get; set; } My class is marked as partial, but you cannot have partial properties. I thought I was on to something with the MetadataType class which is a new

Generate and publish Ruby based REST APIs documentation

醉酒当歌 提交于 2019-12-08 22:43:15
问题 What are cool kids using nowadays to easily parse/generate/publish REST APIs? I took a look on Swagger and It looks nice but from my point of view it doesn't fit ok with Ruby. Maybe I'm just wrong and I'm missing something, help would be appreciated. 回答1: Sounds like you don't have an API yet? If that's the case, this is the approach that I recommend. Create an interface for the API by using the swagger-specification. You can do this without using a server, see here. Verify the interface by

SCons to generate variable number of targets

ε祈祈猫儿з 提交于 2019-12-08 18:56:11
问题 I am trying to get SCons to generate multiple targets (number unknown directly in SConscript ). I have directory like: headers/ Header1.h Header2.h Header3.h Header4.h meta/ headers_list.txt Now I want SConscript to read headers_list.txt , basing on its contents pick files from headers/ directory (i.e. it might contain only Header1 and Header3 ), for each of those I want to generate source using some function. I have been trying to use env.Command to do that, but the issue is that it requires

Running hibernate tool annotation generation without the “catalog” attribute

纵然是瞬间 提交于 2019-12-08 18:08:10
问题 when i run my hibernate tools it reads from the db and create java classes for each tables, and a java class for composite primary keys. that's great. the problem is this line @Table(name="tst_feature" ,catalog="tstdb" ) while the table name is required, the "catalog" attribute is not required. sometimes i want to use "tstdb", sometimes i want to use "tstdev" i thought which db was chosen depends on the jdbc connection url but when i change the jdbc url to point to "tstdev", it is still using

How to simplify a C-style arithmetical expression containing variables during code generation?

廉价感情. 提交于 2019-12-08 17:26:41
问题 I am trying to optimize expression evaluation in a compiler. The arithmetical expressions are all C-style, and they may contain variables. I hope to simplify the expressions as much as possible. For example, (3+100*A*B+100)*3+100 may be simplified to 409+300*A*B . It mainly depends on the distributive law, the associative law and the commutative law. The main difficulty I encounter is how to combine these arithmetical laws and traditional stack-scan evaluating algorithms. Can anyone share

Can I execute code from another file in a T4 .tt template for code generation?

自古美人都是妖i 提交于 2019-12-08 15:56:08
问题 I'm using several T4 templates to generate several T4 files, and most of them share a lot of the same code, so naturally I would like to make a function out of it and put it in a different file that all of the T4 files could access. However I can't seem to find a way, or google for a way to actually use code stored in another file. Is this possible? and if so, is there a simple example of how to do so? 回答1: From your question, it sounds like you're just using T4 in a normal template file in

C# CodeDom Automatic Property

烈酒焚心 提交于 2019-12-08 15:41:05
问题 I have a property created with CodeDom. How can I set it to being an automatic property instead of adding CodeFieldReferenceExpressions against a private member? 回答1: IIRC, CodeDom simply doesn't have a way of expressing this. Automatically implemented properties are just compiler sugar, but since it doesn't map (cleanly) to all languages, it doesn't fit cleanly into CodeDom (besides, CodeDom would have needed an update). 回答2: Yes you can. You can use CodeSnippetTypeMember class for that

How do I customize the auto-generated comment when using .NET CodeDom Code Generation?

和自甴很熟 提交于 2019-12-08 14:58:55
问题 I'm using CodeCompileUnit and CSharpCodeProvider to generate some source code. It adds the header below to all generated code. Is there a way to customize the comment so it says something else? // <auto-generated> // This code was generated by a tool. // Runtime Version:2.0.50727.3053 // // Changes to this file may cause incorrect behavior and will be lost if // the code is regenerated. // </auto-generated> 回答1: You can't. I recommend adding your own comment immediately after this one. Here's

Is there a runtime proxy creation library that supports to retain annotations of the proxied class? [closed]

自闭症网瘾萝莉.ら 提交于 2019-12-08 13:50:13
问题 Closed. This question is off-topic. It is not currently accepting answers. Want to improve this question? Update the question so it's on-topic for Stack Overflow. Closed 2 years ago . When creating a proxy with for example cglib or javassist proxies, this proxy is implemented by creating a subclass of the proxy target. However, this means that the annotations on this proxy are lost. This is problematic when a class is processed by two libraries where: The first libraries requires the creation