code-generation

Change output directory of generated code in gradle

廉价感情. 提交于 2019-12-06 19:33:19
问题 Project contains annotation processor which generates java code during compilation. By default, gradle outputs generated source files into build/classes directory. That causes some problems with discovery of newly generated source files by IntelliJ. Is there any straightforward way of configuring gradle to output source files into another directory? For example $buildDir/gen/main/java or $buildDir/build/generated/main/java ? 回答1: There is an option for java compiler which allows to customize

How to add a code snippet to method body with JDT/AST

独自空忆成欢 提交于 2019-12-06 17:19:58
问题 I'm trying to generate Java source code with JDT/AST. I now have MethodDeclaration and want to add a code snippet (from another source) to the method body. The code snippet can contain any Java code, even syntactically invalid code . I just can't find the way to do this. With JCodeModel you would use JBlock#directStatement(String s) method. Is there a way to do this with JDT/AST? 回答1: Since you have a well-formed tree for the rest of the application, and you want to insert non-well-formed

Replacing // comments with /* comments */ in PHP

China☆狼群 提交于 2019-12-06 16:56:40
I'm creating a CSS generator in PHP which uses CSSX (yep, they are my idea) files (with a special syntax). One feature is 'short comments': body { font-family: Georgia; //I really like this font! } Now I want to replace this comment with a /* ... */ comment, so the output is like this: body { font-family: Georgia; /*I really like this font!*/ } How can I do this? Thanks, P.S. The complete CSSX file is read into one string variable. P.P.S This q is answered. To fix the url('//server/etc.cssx') problem, use this: $file = preg_replace('~[^"\'\(]//([^\r\n]*)[^"\'\)]~', '/*$1*/', $file); A regexp

Comaprison of Liferay ServiceBuilder to other Code generation tools like AndroMDA

泪湿孤枕 提交于 2019-12-06 16:34:45
I started digging into the liferay 6.x ServiceBuilder framework and really liked its code generation approach. A simple service.xml file can generate ready to use powerful services without even writing a single line of code. I also tried looking into AndroMDA which can generate similar services from the UML model, which sounds even more interesting since it will link my business model directly without me needing to learn a new xml config for service.xml (in case of liferay ServiceBuilder) now I am in the process of deciding which tool should I use. Based on your experience with any of these

Vim script for automatic function insertion

纵然是瞬间 提交于 2019-12-06 15:31:00
Say I have a class evilLord declared in the file evil_lair.hh and is implemented in the file evil_lair.cc . Now, I want to add the function bool minionDo(std::string command) . Is there any script which will put the declaration and empty function definition in the respective files automatically? I am using c-support vim-plugin which I find useful. Maybe this can be added as a functionality to this script... The task is not that trivial -- if we want to correctly report the scope of the function. I've already done the work in my :GOTOIMPL (and :MOVEIMPL ) command, from my lh-cpp ftplugin suite

Maven build with AnnotationProcessor that parses files in src/main/java and generates sources to generated-test-sources/test-annotations

为君一笑 提交于 2019-12-06 13:37:49
I'm using maven 3.0.3 and Java7. I've got an AnnotationProcessor that is supposed to parse annotated java-files in src/main/java ( not src/test/java ) and generate Helper-Classes for JUnit-Tests. These Helper-Classes are supposed to be stored in target/generated-test-sources/test-annotations because they use libraries that are only available in test-scope. (Note: everything works fine as long as this dependency isn't in test-scope, but the build fails as soon as it is. It's definitely only needed in test-scope / during unit-tests and compilation of test-classes.) I tried several configurations

Instance of an interface without an implementation class

非 Y 不嫁゛ 提交于 2019-12-06 12:58:23
问题 I have a JET Template that is meant to generate code for an interface implementation class. I am having trouble coming up with an executable test class that prints out this generated code because I am unable to get an object for the argument of the generate method created from the JET Template. I want the test class to work something like this: /** * An executable test class that prints out exemplary generator output * and demonstrates that the JET template does what it should. */ public

C++11 source code generation

社会主义新天地 提交于 2019-12-06 11:48:05
Is there some sort of library for C++ which contains classes which represents C++ source code? It should of course be able to output the source code to a stream. I'm looking for something which supports most C++11 features and is also capable of generating templated constructions. When I google for this, I'm not getting the results I want. I'm sure though, that there is something available. Maybe I'm just using the wrong terms. Check out the Clang compiler which uses a library-based architecture to support implementing IDEs and other tools that need to process the AST. Clang fully supports all

Matlab Codgen eig() function - strange behaviour

烂漫一生 提交于 2019-12-06 11:44:32
First, don't be fooled by the long post, there is not a lot of code just an observation of results so there are few example matrices. This is a bit related to this question: Matlab Codegen Eig Function - Is this a Bug? I know that mex/C/C++ translated eig() function may not return the same eigenvectors when using the same function in MATLAB and that's fine, but i am puzzled with results I'm getting. First this simple example: Output % c = diagonal matrix of eigenvalues % b = matrix whose columns are the corresponding right eigenvectors function [ b, c ] = eig_test(a) [b, c] = eig(a); end

Play framework auto javascript and CSS minifier

社会主义新天地 提交于 2019-12-06 11:41:49
Does anyone know a good play plugin that automatically minifies javascript and css to attach to a production play server? I've found this one, but I guess there are more out there: https://github.com/greenlaw110/play-greenscript The main problem I see here is that the having javascript being generated from the play side, the plugin would have to detect JS code that gets generated on the fly. Mainly because I'm writing values directly into the javascript like: function foo${handlerID}(someVar){ var x = ${some_val}; (...) } var t = foo${handlerID}('bar'); The reason we do minimizing/compressing