{"id":205084,"date":"2013-12-06T13:59:03","date_gmt":"2013-12-06T09:59:03","guid":{"rendered":"http:\/\/savepearlharbor.com\/?p=205084"},"modified":"-0001-11-30T00:00:00","modified_gmt":"-0001-11-29T21:00:00","slug":"","status":"publish","type":"post","link":"https:\/\/savepearlharbor.com\/?p=205084","title":{"rendered":"<span class=\"post_title\">MacroGroovy \u2014 \u0440\u0430\u0431\u043e\u0442\u0430 \u0441 AST \u043d\u0430 Groovy \u0435\u0449\u0451 \u043d\u0438\u043a\u043e\u0433\u0434\u0430 \u043d\u0435 \u0431\u044b\u043b\u0430 \u0442\u0430\u043a\u043e\u0439 \u043f\u0440\u043e\u0441\u0442\u043e\u0439<\/span>"},"content":{"rendered":"<div class=\"content html_format\">   \t<img decoding=\"async\" src=\"http:\/\/groovy.codehaus.org\/download\/attachments\/1866\/groovydukemed.jpg?version=1&amp;modificationDate=1176732937408&amp;api=v2\" alt=\"image\"\/><br \/>  \u041f\u043e\u0441\u043b\u0435\u0434\u043d\u0435\u0435 \u0432\u0440\u0435\u043c\u044f \u0447\u0430\u0441\u0442\u043e \u043f\u0440\u0438\u0445\u043e\u0434\u0438\u0442\u0441\u044f \u0440\u0430\u0431\u043e\u0442\u0430\u0442\u044c \u0441 \u0442\u0430\u043a\u043e\u0439 \u043c\u043e\u0449\u043d\u043e\u0439 \u0432\u043e\u0437\u043c\u043e\u0436\u043d\u043e\u0441\u0442\u044c\u044e Groovy \u043a\u0430\u043a <a href=\"http:\/\/groovy.codehaus.org\/Compile-time+Metaprogramming+-+AST+Transformations\">Compile-time AST Transformations<\/a>. <\/p>\n<p>  \u0422\u0430\u043a \u043a\u0430\u043a \u044f \u043d\u0435 \u043b\u044e\u0431\u043b\u044e \u0438\u0437\u043b\u0438\u0448\u043d\u044e\u044e \u0434\u0438\u043d\u0430\u043c\u0438\u043a\u0443, \u0442\u043e \u0431\u041e\u043b\u044c\u0448\u0430\u044f \u0447\u0430\u0441\u0442\u044c \u043f\u0440\u043e\u0432\u0435\u0440\u043e\u043a DSL \u043d\u0430 \u0432\u0430\u043b\u0438\u0434\u043d\u043e\u0441\u0442\u044c \u0443 \u043d\u0430\u0441 \u043f\u0440\u043e\u0438\u0441\u0445\u043e\u0434\u0438\u0442 \u043d\u0430 \u044d\u0442\u0430\u043f\u0435 \u043a\u043e\u043c\u043f\u0438\u043b\u044f\u0446\u0438\u0438, \u0430 \u0442\u0430\u043a \u0436\u0435 \u043c\u044b \u0438\u0441\u043f\u043e\u043b\u044c\u0437\u0443\u0435\u043c \u043e\u0447\u0435\u043d\u044c \u043c\u043d\u043e\u0433\u043e \u0433\u0435\u043d\u0435\u0440\u0430\u0446\u0438\u0438 \u043a\u043e\u0434\u0430. \u041f\u043e\u044d\u0442\u043e\u043c\u0443 \u043a\u0430\u0436\u0434\u044b\u0439 \u0434\u0435\u043d\u044c \u043f\u0440\u0438\u0445\u043e\u0434\u0438\u0442\u0441\u044f \u0441\u0442\u0430\u043b\u043a\u0438\u0432\u0430\u0442\u044c\u0441\u044f \u0441 \u0441\u043e\u0441\u0442\u0430\u0432\u043b\u0435\u043d\u0438\u0435\u043c ASTNode-\u043e\u0432 \u0432\u0440\u0443\u0447\u043d\u0443\u044e. <\/p>\n<pre><code class=\"ruby\">def someVariable = new ConstantExpression(&quot;someValue&quot;); def returnStatement = new ReturnStatement(     new ConstructorCallExpression(         ClassHelper.make(SomeCoolClass),         new ArgumentListExpression(someVariable)     ) ); <\/code><\/pre>\n<p>  \u0414\u043e \u0431\u043e\u043b\u0438 \u0437\u043d\u0430\u043a\u043e\u043c\u044b\u0435 \u043a\u043e\u043d\u0441\u0442\u0440\u0443\u043a\u0446\u0438\u0438, \u043d\u0435 \u043f\u0440\u0430\u0432\u0434\u0430 \u043b\u0438? \u0425\u043e\u0442\u0438\u0442\u0435, \u0447\u0442\u043e\u0431\u044b \u0431\u044b\u043b\u043e \u0432\u043e\u0442 \u0442\u0430\u043a?  <\/p>\n<pre><code class=\"ruby\">def someVariable = macro { &quot;someValue&quot; }; def returnStatement = macro { return new SomeCoolClass($v{ someVariable }) } <\/code><\/pre>\n<p>  \u0418\u043b\u0438 \u0434\u0430\u0436\u0435 \u0442\u0430\u043a?  <\/p>\n<pre><code class=\"ruby\">def constructorCall = macro { new SomeCoolClass($v{ macro { &quot;someValue&quot; } }) } <\/code><\/pre>\n<p>  \u0412 \u0434\u0430\u043d\u043d\u043e\u0439 \u0441\u0442\u0430\u0442\u044c\u0435 \u0440\u0435\u0447\u044c \u043f\u043e\u0439\u0434\u0451\u0442 \u043e \u043c\u043e\u0451\u043c \u0440\u0435\u0448\u0435\u043d\u0438\u0438 \u044d\u0442\u043e\u0439 \u043f\u0440\u043e\u0431\u043b\u0435\u043c\u044b, \u043c\u0430\u043a\u0441\u0438\u043c\u0430\u043b\u044c\u043d\u043e \u0431\u043b\u0438\u0437\u043a\u043e\u043c \u043a \u0440\u043e\u0434\u043d\u043e\u043c\u0443 \u0440\u0435\u0448\u0435\u043d\u0438\u044e Groovy \u2014 <a href=\"https:\/\/github.com\/bsideup\/MacroGroovy\">github.com\/bsideup\/MacroGroovy<\/a><\/p>\n<p>  <a name=\"habracut\"><\/a><\/p>\n<h5>AstBuilder<\/h5>\n<p>  Groovy 1.7 \u043f\u0440\u0438\u043d\u0451\u0441 \u0442\u0430\u043a\u0443\u044e \u0437\u0430\u043c\u0435\u0447\u0430\u0442\u0435\u043b\u044c\u043d\u0443\u044e, \u043a\u0430\u0437\u0430\u043b\u043e\u0441\u044c \u0431\u044b, \u0448\u0442\u0443\u043a\u0443 \u043a\u0430\u043a <a href=\"http:\/\/groovy.codehaus.org\/Building+AST+Guide\">AstBuilder<\/a>, \u043a\u043e\u0442\u043e\u0440\u044b\u0439 \u043f\u0440\u0435\u0434\u043b\u0430\u0433\u0430\u0435\u0442 \u043d\u0430\u043c 3 \u0441\u043f\u043e\u0441\u043e\u0431\u0430 \u043f\u043e\u0441\u0442\u0440\u043e\u0435\u043d\u0438\u044f AST:<\/p>\n<h5><b>AstBuilder.buildFromString<\/b><\/h5>\n<p>  <\/p>\n<blockquote><p>\u041f\u0435\u0440\u0435\u0434\u0430\u0451\u043c \u0441\u0442\u0440\u043e\u043a\u0443 \u0441 \u043a\u043e\u0434\u043e\u043c, \u043d\u0430 \u0432\u044b\u0445\u043e\u0434\u0435 \u0438\u043c\u0435\u0435\u043c \u0441\u043f\u0438\u0441\u043e\u043a ASTNode-\u043e\u0432:  <\/p>\n<pre><code class=\"ruby\">List&lt;ASTNode&gt; nodes = new AstBuilder().buildFromString(&quot;\\&quot;Hello\\&quot;&quot;) <\/code><\/pre>\n<p>  <b>\u041f\u0440\u0435\u0438\u043c\u0443\u0449\u0435\u0441\u0442\u0432\u0430<\/b>  <\/p>\n<ul>\n<li>\u0412\u0445\u043e\u0434\u043d\u044b\u0435 \u0434\u0430\u043d\u043d\u044b\u0435 \u2014 \u0441\u0442\u0440\u043e\u043a\u0430, \u043c\u043e\u0436\u0435\u0442 \u0431\u044b\u0442\u044c \u0432\u0437\u044f\u0442\u0430 \u043e\u0442\u043a\u0443\u0434\u0430 \u0443\u0433\u043e\u0434\u043d\u043e;<\/li>\n<li>\u041d\u0435 \u0442\u0440\u0435\u0431\u0443\u0435\u0442 \u043f\u043e\u043d\u0438\u043c\u0430\u043d\u0438\u044f \u043a\u0430\u043a \u0443\u0441\u0442\u0440\u043e\u0435\u043d\u044b ASTNode-\u044b;<\/li>\n<li>\u041f\u043e\u0437\u0432\u043e\u043b\u044f\u0435\u0442 \u0443\u043a\u0430\u0437\u044b\u0432\u0430\u0442\u044c CompilePhase;<\/li>\n<li>\u0413\u0435\u043d\u0435\u0440\u0438\u0440\u0443\u0435\u0442 \u043f\u0440\u0430\u043a\u0442\u0438\u0447\u0435\u0441\u043a\u0438 100% \u0432\u0430\u043b\u0438\u0434\u043d\u044b\u0439 \u043a\u043e\u0434;<\/li>\n<li>\u041d\u0430\u0434\u0451\u0436\u043d\u044b\u0439 \u2014 \u043d\u0435 \u0442\u0440\u0435\u0431\u0443\u0435\u0442 \u0438\u0437\u043c\u0435\u043d\u0435\u043d\u0438\u044f \u0432 \u0432\u0430\u0448\u0435\u043c \u043a\u043e\u0434\u0435 \u0435\u0441\u043b\u0438 \u0441\u0442\u0440\u0443\u043a\u0442\u0443\u0440\u0430 ASTNode-\u043e\u0432 \u0432 Groovy \u043f\u043e\u043c\u0435\u043d\u044f\u043b\u0430\u0441\u044c.<\/li>\n<\/ul>\n<p>  <b>\u041d\u0435\u0434\u043e\u0441\u0442\u0430\u0442\u043a\u0438<\/b>  <\/p>\n<ul>\n<li>IDE \u043d\u0435 \u043f\u043e\u043c\u043e\u0436\u0435\u0442 \u0432\u0430\u043c \u0441 \u043f\u0440\u043e\u0432\u0435\u0440\u043a\u043e\u0439 \u0441\u0438\u043d\u0442\u0430\u043a\u0441\u0438\u0441\u0430;<\/li>\n<li>\u0440\u0435\u0444\u0430\u043a\u0442\u043e\u0440\u0438\u043d\u0433\u0438 \u0432 IDE \u0442\u0430\u043a \u0436\u0435 \u043d\u0435 \u0431\u0443\u0434\u0443\u0442 \u0440\u0430\u0431\u043e\u0442\u0430\u0442\u044c;<\/li>\n<li>\u041d\u0435\u043a\u043e\u0442\u043e\u0440\u044b\u0435 \u0441\u0443\u0449\u043d\u043e\u0441\u0442\u0438 \u0441\u043e\u0437\u0434\u0430\u0442\u044c \u043d\u0435 \u043f\u043e\u043b\u0443\u0447\u0438\u0442\u0441\u044f \u2014 \u043d\u0430\u043f\u0440\u0438\u043c\u0435\u0440 \u043e\u0431\u044a\u044f\u0432\u043b\u0435\u043d\u0438\u0435 \u043f\u043e\u043b\u044f \u043a\u043b\u0430\u0441\u0441\u0430.<\/li>\n<\/ul>\n<p>  <\/p><\/blockquote>\n<p>  \u0427\u0430\u0441\u0442\u044c \u044d\u0442\u0438\u0445 \u043d\u0435\u0434\u043e\u0441\u0442\u0430\u0442\u043a\u043e\u0432 \u043f\u0440\u0438\u0437\u0432\u0430\u043d \u0438\u0441\u043f\u0440\u0430\u0432\u0438\u0442\u044c \u0441\u043b\u0435\u0434\u0443\u044e\u0449\u0438\u0439 \u043c\u0435\u0442\u043e\u0434.<\/p>\n<h6><b>AstBuilder.buildFromCode<\/b><\/h6>\n<p>  <\/p>\n<blockquote><p>\u041f\u0435\u0440\u0435\u0434\u0430\u0451\u043c \u0437\u0430\u043c\u044b\u043a\u0430\u043d\u0438\u0435 (aka Closure) \u0441 \u043a\u043e\u0434\u043e\u043c, \u043d\u0430 \u0432\u044b\u0445\u043e\u0434\u0435 \u0438\u043c\u0435\u0435\u043c \u0441\u043f\u0438\u0441\u043e\u043a \u043d\u043e\u0434\u043e\u0432:  <\/p>\n<pre><code class=\"ruby\">List&lt;ASTNode&gt; nodes = new AstBuilder().buildFromCode { &quot;Hello&quot; } <\/code><\/pre>\n<p>  <b>\u041f\u0440\u0435\u0438\u043c\u0443\u0449\u0435\u0441\u0442\u0432\u0430 (\u043a\u0440\u043e\u043c\u0435 \u043f\u0440\u0435\u0438\u043c\u0443\u0449\u0435\u0441\u0442\u0432 \u043f\u0440\u0435\u0434\u044b\u0434\u0443\u0449\u0435\u0433\u043e \u043c\u0435\u0442\u043e\u0434\u0430)<\/b>  <\/p>\n<ul>\n<li>IDE \u043f\u043e\u0437\u0432\u043e\u043b\u044f\u0435\u0442 \u0438\u0441\u043f\u043e\u043b\u044c\u0437\u043e\u0432\u0430\u0442\u044c autocomplete, \u043f\u0440\u043e\u0432\u0435\u0440\u043a\u0443 \u0441\u0438\u043d\u0442\u0430\u043a\u0441\u0438\u0441\u0430 \u0438 \u0440\u0435\u0444\u0430\u043a\u0442\u043e\u0440\u0438\u043d\u0433\u0438 \u0432 \u0437\u0430\u043c\u044b\u043a\u0430\u043d\u0438\u0438.<\/li>\n<\/ul>\n<p>  <b>\u041d\u0435\u0434\u043e\u0441\u0442\u0430\u0442\u043a\u0438:<\/b>  <\/p>\n<ul>\n<li>\u0414\u0430\u043d\u043d\u044b\u0439 \u0441\u043f\u043e\u0441\u043e\u0431 \u043d\u0435 \u0440\u0435\u0448\u0430\u0435\u0442 \u043f\u0440\u043e\u0431\u043b\u0435\u043c\u044b \u043d\u0435\u0432\u043e\u0437\u043c\u043e\u0436\u043d\u043e\u0441\u0442\u0438 \u0433\u0435\u043d\u0435\u0440\u0438\u0440\u043e\u0432\u0430\u0442\u044c \u0440\u044f\u0434 \u0441\u0443\u0449\u043d\u043e\u0441\u0442\u0435\u0439;<\/li>\n<li>\u041a\u043e\u043c\u043f\u0438\u043b\u0438\u0440\u0443\u0435\u0442 \u043a\u043e\u0434, \u0438\u0437-\u0437\u0430 \u0447\u0435\u0433\u043e \u043d\u0435 \u0432\u0441\u0435\u0433\u0434\u0430 \u043f\u043e\u043b\u0443\u0447\u0438\u0442\u0441\u044f \u0438\u0441\u043f\u043e\u043b\u044c\u0437\u043e\u0432\u0430\u0442\u044c \u0445\u0438\u0442\u0440\u044b\u0435 \u043a\u043e\u043d\u0441\u0442\u0440\u0443\u043a\u0446\u0438\u0438, \u043b\u0438\u0431\u043e \u043d\u0435 \u0441\u0443\u0449\u0435\u0441\u0442\u0432\u0443\u044e\u0449\u0438\u0439 \u043a\u043b\u0430\u0441\u0441;<\/li>\n<li>\u0421\u0430\u043c\u044b\u0439 \u0433\u043b\u0430\u0432\u043d\u044b\u0439 \u043d\u0435\u0434\u043e\u0441\u0442\u0430\u0442\u043e\u043a \u0434\u043b\u044f \u043c\u0435\u043d\u044f: \u0432\u044b\u0437\u043e\u0432 buildFromCode <b>\u0442\u0440\u0435\u0431\u0443\u0435\u0442<\/b> \u0447\u0442\u043e\u0431\u044b \u043c\u0435\u0442\u043e\u0434 \u0432\u044b\u0437\u044b\u0432\u0430\u043b\u0441\u044f \u0438\u043c\u0435\u043d\u043d\u043e \u043f\u0443\u0442\u0451\u043c<b> \u0441\u043e\u0437\u0434\u0430\u043d\u0438\u044f<\/b> AstBuilder-\u0430:\n<pre><code class=\"ruby\">new AstBuilder().buildFromCode { ... } <\/code><\/pre>\n<p>  \u041f\u0440\u0438 \u044d\u0442\u043e\u043c \u0412\u044b \u0434\u0430\u0436\u0435 \u043d\u0435 \u0441\u043c\u043e\u0436\u0435\u0442\u0435 \u0432\u044b\u043d\u0435\u0441\u0442\u0438 AstBuilder \u0432 \u043e\u0442\u0434\u0435\u043b\u044c\u043d\u043e\u0435 \u043f\u043e\u043b\u0435 \u0438\u043b\u0438 \u043b\u043e\u043a\u0430\u043b\u044c\u043d\u0443\u044e \u043f\u0435\u0440\u0435\u043c\u0435\u043d\u043d\u0443\u044e (\u043f\u043e\u044d\u0442\u043e\u043c\u0443 \u0430\u0432\u0442\u043e\u0440\u0430\u043c Groovy \u0434\u0430\u0436\u0435 <a href=\"https:\/\/github.com\/groovy\/groovy-core\/blob\/master\/src\/test\/org\/codehaus\/groovy\/ast\/builder\/AstBuilderFromCodeTest.groovy\">\u043f\u0440\u0438\u0448\u043b\u043e\u0441\u044c \u043f\u0440\u0438\u0431\u0435\u0433\u043d\u0443\u0442\u044c<\/a> \u043a AstTransformation \u0434\u043b\u044f \u044d\u0442\u043e\u0439 AstTransformation \u0447\u0442\u043e\u0431\u044b \u043d\u0435 \u043f\u0438\u0441\u0430\u0442\u044c \u043c\u043d\u043e\u0433\u043e \u043a\u043e\u0434\u0430)<\/li>\n<\/ul>\n<p>  <\/p><\/blockquote>\n<p>  \u0414\u043b\u044f \u0442\u0435\u0445, \u043a\u043e\u043c\u0443 \u043d\u0435 \u0445\u0432\u0430\u0442\u0430\u0435\u0442 \u043e\u0431\u043e\u0438\u0445 \u043c\u0435\u0442\u043e\u0434\u043e\u0432, \u0435\u0441\u0442\u044c \u0442\u0440\u0435\u0442\u0438\u0439 \u0441\u043f\u043e\u0441\u043e\u0431:<\/p>\n<h6><b>AstBuilder.buildFromSpec<\/b><\/h6>\n<p>  <\/p>\n<blockquote><p>\u0414\u0430\u043d\u043d\u044b\u0439 \u043c\u0435\u0442\u043e\u0434 \u043f\u0440\u0438\u043d\u0438\u043c\u0430\u0435\u0442 \u0432 \u0441\u0435\u0431\u044f \u0437\u0430\u043c\u044b\u043a\u0430\u043d\u0438\u0435 (\u043a \u0441\u043b\u043e\u0432\u0443, \u0432\u044b \u043c\u043e\u0436\u0435\u0442\u0435 \u043f\u0440\u043e\u0433\u043e\u043b\u043e\u0441\u043e\u0432\u0430\u0442\u044c \u0437\u0430 \u043c\u043e\u044e <a href=\"https:\/\/jira.codehaus.org\/browse\/GROOVY-6448\">Issue<\/a> \u0438\u043b\u0438 \u043e\u0442\u043a\u043e\u043c\u043c\u0435\u043d\u0442\u0438\u0440\u043e\u0432\u0430\u0442\u044c <a href=\"https:\/\/github.com\/groovy\/groovy-core\/pull\/285\">Pull Request<\/a> \u0447\u0442\u043e\u0431\u044b \u043d\u0430 \u044d\u0442\u043e\u043c \u043c\u0435\u0442\u043e\u0434\u0435 \u043f\u043e\u044f\u0432\u0438\u043b\u0430\u0441\u044c \u043f\u0440\u0435\u043a\u0440\u0430\u0441\u043d\u0430\u044f \u0430\u043d\u043d\u043e\u0442\u0430\u0446\u0438\u044f <a href=\"http:\/\/groovy.codehaus.org\/The+@DelegatesTo+annotation\">DelegatesTo<\/a>), \u043a\u043e\u0442\u043e\u0440\u043e\u0435 \u043f\u0440\u0435\u0434\u0441\u0442\u0430\u0432\u043b\u044f\u0435\u0442 \u0438\u0437 \u0441\u0435\u0431\u044f DSL \u0434\u043b\u044f \u043f\u043e\u0441\u0442\u0440\u043e\u0435\u043d\u0438\u044f AST:  <\/p>\n<pre><code class=\"ruby\">List&lt;ASTNode&gt; nodes = new AstBuilder().buildFromSpec {     block {         returnStatement {             constant &quot;Hello&quot;         }     } } <\/code><\/pre>\n<p>  <b>\u041f\u0440\u0435\u0438\u043c\u0443\u0449\u0435\u0441\u0442\u0432\u0430<\/b>  <\/p>\n<ul>\n<li>\u041f\u043e\u0437\u0432\u043e\u043b\u044f\u0435\u0442 \u0438\u0441\u043f\u043e\u043b\u044c\u0437\u043e\u0432\u0430\u0442\u044c \u043b\u043e\u0433\u0438\u043a\u0443 \u043d\u0430 Groovy \u0434\u043b\u044f \u043f\u043e\u0441\u0442\u0440\u043e\u0435\u043d\u0438\u044f \u043d\u043e\u0434\u043e\u0432;<\/li>\n<li>\u041f\u0440\u0435\u0434\u043e\u0441\u0442\u0430\u0432\u043b\u044f\u0442 \u0432\u043e\u0437\u043c\u043e\u0436\u043d\u043e\u0441\u0442\u044c \u043a\u043e\u043d\u0441\u0442\u0440\u0443\u0438\u0440\u043e\u0432\u0430\u0442\u044c \u043f\u0440\u0430\u043a\u0442\u0438\u0447\u0435\u0441\u043a\u0438 \u043b\u044e\u0431\u0443\u044e \u0441\u0443\u0449\u0435\u0441\u0442\u0432\u0443\u044e\u0449\u0443\u044e ASTNode-\u0443;<\/li>\n<li>\u0412\u0430\u0436\u043d\u044b\u0439 \u043f\u043b\u044e\u0441, \u0442.\u043a. \u0442\u0435\u043c\u0430 AST generation \u0432 Groovy \u0434\u043e\u043a\u0443\u043c\u0435\u043d\u0442\u0438\u0440\u043e\u0432\u0430\u043d\u0430 \u043d\u0435 \u0438\u0434\u0435\u0430\u043b\u044c\u043d\u043e: \u041f\u043e\u043b\u043d\u043e\u0441\u0442\u044c\u044e \u0437\u0430\u0434\u043e\u043a\u0443\u043c\u0435\u043d\u0442\u0438\u0440\u043e\u0432\u0430\u043d \u0438 \u0438\u043c\u0435\u0435\u0442 \u043e\u0431\u0448\u0438\u0440\u043d\u044b\u0435 \u043f\u0440\u0438\u043c\u0435\u0440\u044b \u0438\u0441\u043f\u043e\u043b\u044c\u0437\u043e\u0432\u0430\u043d\u0438\u044f \u0432 <a href=\"http:\/\/svn.codehaus.org\/groovy\/trunk\/groovy\/groovy-core\/src\/test\/org\/codehaus\/groovy\/ast\/builder\/AstBuilderFromSpecificationTest.groovy\">TestCase<\/a>-\u0435<\/li>\n<\/ul>\n<p>  <b>\u041d\u0435\u0434\u043e\u0441\u0442\u0430\u0442\u043a\u0438<\/b>  <\/p>\n<ul>\n<li>\u0418\u043d\u043e\u0433\u0434\u0430 \u0441\u043b\u043e\u0436\u043d\u043e \u043f\u043e\u043d\u044f\u0442\u044c \u0447\u0442\u043e \u0438\u043c\u0435\u043d\u043d\u043e \u0432\u0430\u043c \u043d\u0430\u0434\u043e \u0432\u044b\u0437\u0432\u0430\u0442\u044c \u0447\u0442\u043e\u0431\u044b \u043f\u043e\u043b\u0443\u0447\u0438\u0442\u044c \u0436\u0435\u043b\u0430\u0435\u043c\u044b\u0439 \u0440\u0435\u0437\u0443\u043b\u044c\u0442\u0430\u0442;<\/li>\n<li>\u041c\u0435\u043d\u0435\u0435 \u043c\u043d\u043e\u0433\u043e\u0441\u043b\u043e\u0432\u0435\u043d \u0447\u0435\u043c \u0432\u044b\u0437\u043e\u0432\u044b \u043a\u043e\u043d\u0441\u0442\u0440\u0443\u043a\u0442\u043e\u0440\u043e\u0432 \u043d\u043e\u0434\u043e\u0432, \u043d\u043e \u0432\u0441\u0451 \u0440\u0430\u0432\u043d\u043e \u043e\u0441\u0442\u0430\u0451\u0442\u0441\u044f \u0442\u0430\u043a\u043e\u0432\u044b\u043c;<\/li>\n<li>\u0421\u0442\u0440\u0430\u043d\u043d\u0430\u044f \u0440\u0435\u0430\u043b\u0438\u0437\u0430\u0446\u0438\u044f \u2014 \u043d\u0430\u043f\u0440\u0438\u043c\u0435\u0440 \u043d\u0435\u043a\u043e\u0442\u043e\u0440\u044b\u0435 \u043c\u0435\u0442\u043e\u0434\u044b \u043f\u0440\u0438\u043d\u0438\u043c\u0430\u044e\u0442 Class \u0432\u043c\u0435\u0441\u0442\u043e ClassNode, \u0447\u0442\u043e \u0441\u0432\u043e\u0434\u0438\u0442 \u0435\u0433\u043e \u0438\u0441\u043f\u043e\u043b\u044c\u0437\u043e\u0432\u0430\u043d\u0438\u0435 \u043d\u0430 \u043d\u0435\u0442;<\/li>\n<li>\u041d\u0435\u043d\u0430\u0434\u0451\u0436\u0435\u043d \u2014 AST \u043c\u043e\u0436\u0435\u0442 \u043c\u0435\u043d\u044f\u0442\u044c\u0441\u044f \u0441 \u043c\u0430\u0436\u043e\u0440\u043d\u044b\u043c\u0438 \u0440\u0435\u043b\u0438\u0437\u0430\u043c\u0438 \u044f\u0437\u044b\u043a\u0430;<\/li>\n<li>\u0412\u044b \u0434\u043e\u043b\u0436\u043d\u044b \u0442\u043e\u0447\u043d\u043e \u0437\u043d\u0430\u0442\u044c \u043a\u0430\u043a \u0432\u0430\u0448 AST \u0434\u043e\u043b\u0436\u0435\u043d \u0432\u044b\u0433\u043b\u044f\u0434\u0435\u0442\u044c \u0432 \u043a\u043e\u043d\u043a\u0440\u0435\u0442\u043d\u043e\u0439 \u0444\u0430\u0437\u0435 \u043a\u043e\u043c\u043f\u0438\u043b\u044f\u0446\u0438\u0438;<\/li>\n<li>IDE <u>\u043f\u043e\u043a\u0430 \u0447\u0442\u043e<\/u> (\u0441\u043c. \u043c\u043e\u0439 \u043a\u043e\u043c\u043c\u0435\u043d\u0442\u0430\u0440\u0438\u0439 \u043f\u043e \u043f\u043e\u0432\u043e\u0434\u0443 Pull Request-\u0430) \u043d\u0435 \u043f\u043e\u0434\u0434\u0435\u0440\u0436\u0438\u0432\u0430\u044e\u0442 autocomplete \u0434\u043b\u044f \u0434\u0430\u043d\u043d\u043e\u0433\u043e DSL.<\/li>\n<\/ul>\n<p>  <\/p><\/blockquote>\n<h6><b>\u041a\u043e\u043c\u0431\u0438\u043d\u0438\u0440\u043e\u0432\u0430\u043d\u0438\u0435 \u043c\u0435\u0442\u043e\u0434\u043e\u0432<\/b><\/h6>\n<p>  <\/p>\n<blockquote><p>\u0422\u0430\u043a \u0436\u0435 \u0441\u0442\u043e\u0438\u0442 \u0443\u043f\u043e\u043c\u044f\u043d\u0443\u0442\u044c \u0447\u0442\u043e \u0432\u044b \u043c\u043e\u0436\u0435\u0442\u0435 \u043a\u043e\u043c\u0431\u0438\u043d\u0438\u0440\u043e\u0432\u0430\u0442\u044c \u044d\u0442\u0438 \u043c\u0435\u0442\u043e\u0434\u044b:  <\/p>\n<pre><code class=\"ruby\">List&lt;ASTNode&gt; result = new AstBuilder().buildFromSpec {     method('myMethod', Opcodes.ACC_PUBLIC, String) {         parameters {             parameter 'parameter': String.class         }         exceptions {}         block {             owner.expression.addAll new AstBuilder().buildFromCode {                 println 'Hello from a synthesized method!'                 println &quot;Parameter value: $parameter&quot;             }         }         annotations {}     } } <\/code><\/pre>\n<p>  <\/p><\/blockquote>\n<h5>MacroGroovy<\/h5>\n<p>  \u0418\u0442\u0430\u043a, \u043f\u043e\u0441\u043b\u0435 \u0441\u0442\u043e\u043b\u044c \u043e\u0431\u0448\u0438\u0440\u043d\u043e\u0433\u043e \u043e\u0431\u0437\u043e\u0440\u0430 \u0432\u043e\u0437\u043c\u043e\u0436\u043d\u043e\u0441\u0442\u0435\u0439, \u0412\u044b \u043c\u043e\u0436\u0435\u0442\u0435 \u0441\u043f\u0440\u043e\u0441\u0438\u0442\u044c: \u0422\u0430\u043a \u043d\u0430&#8230;*\u043a\u0445\u043c*\u2026 \u0444\u0438\u0433\u0430 \u043d\u0443\u0436\u0435\u043d MacroGroovy?<\/p>\n<p>  \u0420\u0430\u0441\u0441\u043c\u043e\u0442\u0440\u0438\u043c \u043f\u0440\u0438\u043c\u0435\u0440 \u0438\u0437 \u0448\u0430\u043f\u043a\u0438 \u043f\u043e\u0441\u0442\u0430:  <\/p>\n<pre><code class=\"ruby\">def someVariable = new ConstantExpression(&quot;someValue&quot;); def returnStatement = new ReturnStatement(     new ConstructorCallExpression(         ClassHelper.make(SomeCoolClass),         new ArgumentListExpression(someVariable)     ) ); <\/code><\/pre>\n<p>  \u0412\u0438\u0434\u0438\u0442\u0435 someVariable, \u043f\u0435\u0440\u0435\u0434\u0430\u043d\u043d\u0443\u044e \u0432 \u043a\u043e\u043d\u0441\u0442\u0440\u0443\u043a\u0442\u043e\u0440 \u0441\u043f\u0438\u0441\u043a\u0430 \u0430\u0440\u0433\u0443\u043c\u0435\u043d\u0442\u043e\u0432? \u041f\u043e\u0432\u0435\u0440\u044c\u0442\u0435 \u043c\u043d\u0435, \u0442\u0430\u043a\u0430\u044f \u0441\u0438\u0442\u0443\u0430\u0446\u0438\u044f \u0432\u0441\u0442\u0440\u0435\u0447\u0430\u0435\u0442\u0441\u044f \u043e\u0447\u0435\u043d\u044c \u0438 \u043e\u0447\u0435\u043d\u044c \u0447\u0430\u0441\u0442\u043e. \u0418 \u043e\u043d\u0430 \u0441\u0440\u0430\u0437\u0443 \u043e\u0442\u043c\u0435\u0442\u0430\u0435\u0442 buildFromCode \u0438 buildFromString. \u0417\u043d\u0430\u0447\u0438\u0442 \u043e\u0441\u0442\u0430\u0451\u0442\u0441\u044f \u0442\u043e\u043b\u044c\u043a\u043e buildFromSpec, \u043d\u043e \u0432\u044b \u043f\u043e\u043c\u043d\u0438\u0442\u0435 \u0441\u043f\u0438\u0441\u043e\u043a \u0435\u0433\u043e \u043d\u0435\u0434\u043e\u0441\u0442\u0430\u0442\u043a\u043e\u0432? \u0412\u043e\u0442 \u0442\u0443\u0442 \u0438 \u043f\u0440\u0438\u0445\u043e\u0434\u0438\u0442 \u043d\u0430 \u043f\u043e\u043c\u043e\u0449\u044c MacroGroovy:<\/p>\n<pre><code class=\"ruby\">def someVariable = macro { &quot;someValue&quot; }; def returnStatement = macro { return new SomeCoolClass($v{ someVariable }) } <\/code><\/pre>\n<p>  <b>\u041f\u0440\u0435\u0438\u043c\u0443\u0449\u0435\u0441\u0442\u0432\u0430<\/b>  <\/p>\n<ul>\n<li>\u0412\u0441\u0435 \u043f\u0440\u0435\u0438\u043c\u0443\u0449\u0435\u0441\u0442\u0432\u0430 \u043f\u0435\u0440\u0432\u043e\u0433\u043e \u0438 \u0432\u0442\u043e\u0440\u043e\u0433\u043e \u043c\u0435\u0442\u043e\u0434\u0430;<\/li>\n<li>\u041d\u0435 \u0442\u0440\u0435\u0431\u0443\u0435\u0442 \u0441\u043e\u0437\u0434\u0430\u043d\u0438\u0435 \u043e\u0431\u044a\u0435\u043a\u0442\u0430, \u043e\u0442\u043d\u043e\u0441\u0438\u0442\u0435\u043b\u044c\u043d\u043e \u043a\u043e\u0442\u043e\u0440\u043e\u0433\u043e \u0432\u044b\u0437\u044b\u0432\u0430\u0435\u0442\u0441\u044f \u043c\u0435\u0442\u043e\u0434 macro \u2014 \u043e\u043d \u0434\u043e\u0441\u0442\u0443\u043f\u0435\u043d \u0432\u043e \u0432\u0441\u0435\u0445 \u043a\u043b\u0430\u0441\u0441\u0430\u0445 \u043a\u0430\u043a <a href=\"http:\/\/docs.codehaus.org\/display\/GROOVY\/Creating+an+extension+module\">Extension Method<\/a><\/li>\n<li>\u0412\u043d\u0443\u0442\u0440\u0438 \u043f\u0435\u0440\u0435\u0438\u0441\u043f\u043e\u043b\u044c\u0437\u0443\u0435\u0442 \u043a\u043e\u0434 \u0438\u0437 AstBuilder, \u0442\u0430\u043a \u0447\u0442\u043e \u043c\u0435\u0442\u043e\u0434 \u043d\u0430\u0434\u0451\u0436\u043d\u044b\u0439 \u0438 \u043f\u0440\u043e\u0442\u0435\u0441\u0442\u0438\u0440\u043e\u0432\u0430\u043d\u044b\u0439;<\/li>\n<li>\u041f\u043e\u0437\u0432\u043e\u043b\u044f\u0435\u0442 \u0438\u0441\u043f\u043e\u043b\u044c\u0437\u043e\u0432\u0430\u0442\u044c \u043b\u043e\u0433\u0438\u043a\u0443 Groovy \u0432\u043d\u0443\u0442\u0440\u0438 \u043a\u043e\u0434\u0430, \u0442.\u043a. $v \u043f\u0440\u0438\u043d\u0438\u043c\u0430\u0435\u0442 \u0432 \u0441\u0435\u0431\u044f \u0437\u0430\u043c\u044b\u043a\u0430\u043d\u0438\u0435, \u043a\u043e\u0442\u043e\u0440\u043e\u0435 \u0434\u043e\u043b\u0436\u043d\u043e \u0432\u0435\u0440\u043d\u0443\u0442\u044c \u0442\u043e, \u0447\u0442\u043e \u043d\u0430\u0434\u043e \u043f\u043e\u0441\u0442\u0430\u0432\u0438\u0442\u044c \u043d\u0430 \u043c\u0435\u0441\u0442\u043e \u0435\u0433\u043e \u0432\u044b\u0437\u043e\u0432\u0430;<\/li>\n<li>\u041e\u0447\u0435\u043d\u044c, \u041e\u0427\u0415\u041d\u042c \u043a\u043e\u043c\u043f\u0430\u043a\u0442\u043d\u044b\u0439:) \u0441\u0440\u0430\u0432\u043d\u0438\u0442\u0435:\n<pre><code class=\"ruby\">macro { return mySuperVariable }<\/code><\/pre>\n<p> \u0438 <\/p>\n<pre><code class=\"ruby\">(new AstBuilder()).buildFromCode { return mySuperVariable }.first().expressions.first() <\/code><\/pre>\n<\/li>\n<\/ul>\n<p>  <b>\u041d\u0435\u0434\u043e\u0441\u0442\u0430\u0442\u043a\u0438<\/b>  <\/p>\n<ul>\n<li>\u041a \u0441\u043e\u0436\u0430\u043b\u0435\u043d\u0438\u044e, \u043f\u043e\u043b\u0435 \u043a\u043b\u0430\u0441\u0441\u0430 \u0432\u044b \u0441 \u043f\u043e\u043c\u043e\u0449\u044c\u044e macro {} \u0442\u0430\u043a \u0436\u0435 \u043d\u0435 \u0441\u043e\u0437\u0434\u0430\u0442\u0438\u0442\u0435;<\/li>\n<li>\u041d\u0435\u0442 \u0432\u043e\u0437\u043c\u043e\u0436\u043d\u043e\u0441\u0442\u0438 CompilePhase;<\/li>\n<\/ul>\n<p>  \u041a \u0441\u043b\u043e\u0432\u0443, \u0432\u044b \u0432\u0441\u0451 \u0442\u0430\u043a \u0436\u0435 \u043c\u043e\u0436\u0435\u0442\u0435 \u043a\u043e\u043c\u0431\u0438\u043d\u0438\u0440\u043e\u0432\u0430\u0442\u044c buildFromSpec \u0438 macro:  <\/p>\n<pre><code class=\"ruby\">List&lt;ASTNode&gt; result = new AstBuilder().buildFromSpec {     method('myMethod', Opcodes.ACC_PUBLIC, String) {         parameters {             parameter 'parameter': String.class         }         exceptions {}         block macro {                 println 'Hello from a synthesized method!'                 println &quot;Parameter value: $parameter&quot;         }          annotations {}     } } <\/code><\/pre>\n<h5>\u0417\u0430\u043a\u043b\u044e\u0447\u0435\u043d\u0438\u0435<\/h5>\n<p>  \u041a\u0430\u0436\u0434\u044b\u0439 \u0438\u0437 \u043c\u0435\u0442\u043e\u0434\u043e\u0432 \u0438\u043c\u0435\u0435\u0442 \u0441\u0432\u043e\u0438 \u043f\u043b\u044e\u0441\u044b \u0438 \u043c\u0438\u043d\u0443\u0441\u044b, \u0438 \u044f \u043b\u0438\u0448\u044c \u043f\u043e\u0441\u0442\u0430\u0440\u0430\u043b\u0441\u044f \u0441\u0433\u043b\u0430\u0434\u0438\u0442\u044c \u043c\u0438\u043d\u0443\u0441\u044b \u0434\u0440\u0443\u0433\u0438\u0445 \u043c\u0435\u0442\u043e\u0434\u043e\u0432. \u0411\u0443\u0434\u0443 \u043f\u0440\u0438\u0437\u043d\u0430\u0442\u0435\u043b\u0435\u043d \u0437\u0430 \u043f\u043e\u043c\u043e\u0449\u044c \u0432 \u0442\u0435\u0441\u0442\u0438\u0440\u043e\u0432\u0430\u043d\u0438\u0438 \u0438 \u0432\u0430\u0448\u0438 Pull Request-\u044b. <\/p>\n<p>  \u0411\u0438\u0431\u043b\u0438\u043e\u0442\u0435\u043a\u0430 \u0432\u043e\u0442-\u0432\u043e\u0442 \u043f\u043e\u044f\u0432\u0438\u0442\u0441\u044f \u0432 Maven Central, \u043e\u0441\u0442\u0430\u0432\u043b\u044e \u0441\u0441\u044b\u043b\u043a\u0443 \u043f\u043e \u043a\u043e\u0442\u043e\u0440\u043e\u0439 \u0432\u0441\u0435\u0433\u0434\u0430 \u043c\u043e\u0436\u043d\u043e \u043d\u0430\u0439\u0442\u0438 \u0441\u0432\u0435\u0436\u0443\u044e \u0432\u0435\u0440\u0441\u0438\u044e: <br \/>  <a href=\"http:\/\/search.maven.org\/#search%7Cga%7C1%7Cmacro-groovy\">search.maven.org\/#search%7Cga%7C1%7Cmacro-groovy<\/a><\/p>\n<p>  \u0421\u043f\u0430\u0441\u0438\u0431\u043e.  \t\t\t\t<\/p>\n<div class=\"polling\">\n<form action=\"\/json\/polling\/\" class=\"poll\" method=\"post\">\n<div class=\"poll_title\">\u0427\u0442\u043e \u043f\u0440\u0435\u0434\u043f\u043e\u0447\u0438\u0442\u0430\u0435\u0442\u0435 \u0412\u044b?<\/div>\n<p>  \t\t<input type=\"hidden\" name=\"post_id\" value=\"205084\"\/> \t\t<input type=\"hidden\" name=\"polling_question_id\" value=\"9782\"\/>  \t\t<\/p>\n<table class=\"answer\">\n<tr>\n<td class=\"input\"> \t\t\t\t\t<input type=\"checkbox\" id=\"vv49860\" \t\t\t\t\t\tclass=\"checkbox js-field-data\" \t\t\t\t\t\tname=\"variant[]\" \t\t\t\t\t\tvalue=\"49860\" \/> \t\t\t\t<\/td>\n<td class=\"label\"> \t\t\t\t\t<label for=\"vv49860\">buildFromString<\/label> \t\t\t\t<\/td>\n<\/tr>\n<tr>\n<td class=\"input\"> \t\t\t\t\t<input type=\"checkbox\" id=\"vv49862\" \t\t\t\t\t\tclass=\"checkbox js-field-data\" \t\t\t\t\t\tname=\"variant[]\" \t\t\t\t\t\tvalue=\"49862\" \/> \t\t\t\t<\/td>\n<td class=\"label\"> \t\t\t\t\t<label for=\"vv49862\">buildFromCode<\/label> \t\t\t\t<\/td>\n<\/tr>\n<tr>\n<td class=\"input\"> \t\t\t\t\t<input type=\"checkbox\" id=\"vv49864\" \t\t\t\t\t\tclass=\"checkbox js-field-data\" \t\t\t\t\t\tname=\"variant[]\" \t\t\t\t\t\tvalue=\"49864\" \/> \t\t\t\t<\/td>\n<td class=\"label\"> \t\t\t\t\t<label for=\"vv49864\">buildFromSpec<\/label> \t\t\t\t<\/td>\n<\/tr>\n<tr>\n<td class=\"input\"> \t\t\t\t\t<input type=\"checkbox\" id=\"vv49866\" \t\t\t\t\t\tclass=\"checkbox js-field-data\" \t\t\t\t\t\tname=\"variant[]\" \t\t\t\t\t\tvalue=\"49866\" \/> \t\t\t\t<\/td>\n<td class=\"label\"> \t\t\t\t\t<label for=\"vv49866\">\u0442\u043e\u043b\u044c\u043a\u043e \u0440\u0443\u0447\u043d\u043e\u0435 \u0441\u043e\u0437\u0434\u0430\u043d\u0438\u0435 \u043d\u043e\u0434\u043e\u0432, \u0442\u043e\u043b\u044c\u043a\u043e \u0445\u0430\u0440\u0434\u043a\u043e\u0440!<\/label> \t\t\t\t<\/td>\n<\/tr>\n<tr>\n<td class=\"input\"> \t\t\t\t\t<input type=\"checkbox\" id=\"vv49868\" \t\t\t\t\t\tclass=\"checkbox js-field-data\" \t\t\t\t\t\tname=\"variant[]\" \t\t\t\t\t\tvalue=\"49868\" \/> \t\t\t\t<\/td>\n<td class=\"label\"> \t\t\t\t\t<label for=\"vv49868\">MacroGroovy \ud83d\ude42<\/label> \t\t\t\t<\/td>\n<\/tr>\n<\/table>\n<p class=\"for_users_only_msg\">\u0422\u043e\u043b\u044c\u043a\u043e \u0437\u0430\u0440\u0435\u0433\u0438\u0441\u0442\u0440\u0438\u0440\u043e\u0432\u0430\u043d\u043d\u044b\u0435 \u043f\u043e\u043b\u044c\u0437\u043e\u0432\u0430\u0442\u0435\u043b\u0438 \u043c\u043e\u0433\u0443\u0442 \u0443\u0447\u0430\u0441\u0442\u0432\u043e\u0432\u0430\u0442\u044c \u0432 \u043e\u043f\u0440\u043e\u0441\u0435. <a href=\"https:\/\/auth.habrahabr.ru\/login\/\">\u0412\u043e\u0439\u0434\u0438\u0442\u0435<\/a>, \u043f\u043e\u0436\u0430\u043b\u0443\u0439\u0441\u0442\u0430.<\/p>\n<p class=\"total\">\u041d\u0438\u043a\u0442\u043e \u0435\u0449\u0451 \u043d\u0435 \u0433\u043e\u043b\u043e\u0441\u043e\u0432\u0430\u043b. \u0412\u043e\u0437\u0434\u0435\u0440\u0436\u0430\u0432\u0448\u0438\u0445\u0441\u044f \u043d\u0435\u0442.<\/p>\n<\/p><\/form>\n<\/p><\/div>\n<div class=\"clear\"><\/div>\n<\/p><\/div>\n<p> \u0441\u0441\u044b\u043b\u043a\u0430 \u043d\u0430 \u043e\u0440\u0438\u0433\u0438\u043d\u0430\u043b \u0441\u0442\u0430\u0442\u044c\u0438 <a href=\"http:\/\/habrahabr.ru\/post\/205084\/\"> http:\/\/habrahabr.ru\/post\/205084\/<\/a><\/p>\n","protected":false},"excerpt":{"rendered":"<div class=\"content html_format\">   \t<img decoding=\"async\" src=\"http:\/\/groovy.codehaus.org\/download\/attachments\/1866\/groovydukemed.jpg?version=1&amp;modificationDate=1176732937408&amp;api=v2\" alt=\"image\"\/><br \/>  \u041f\u043e\u0441\u043b\u0435\u0434\u043d\u0435\u0435 \u0432\u0440\u0435\u043c\u044f \u0447\u0430\u0441\u0442\u043e \u043f\u0440\u0438\u0445\u043e\u0434\u0438\u0442\u0441\u044f \u0440\u0430\u0431\u043e\u0442\u0430\u0442\u044c \u0441 \u0442\u0430\u043a\u043e\u0439 \u043c\u043e\u0449\u043d\u043e\u0439 \u0432\u043e\u0437\u043c\u043e\u0436\u043d\u043e\u0441\u0442\u044c\u044e Groovy \u043a\u0430\u043a <a href=\"http:\/\/groovy.codehaus.org\/Compile-time+Metaprogramming+-+AST+Transformations\">Compile-time AST Transformations<\/a>. <\/p>\n<p>  \u0422\u0430\u043a \u043a\u0430\u043a \u044f \u043d\u0435 \u043b\u044e\u0431\u043b\u044e \u0438\u0437\u043b\u0438\u0448\u043d\u044e\u044e \u0434\u0438\u043d\u0430\u043c\u0438\u043a\u0443, \u0442\u043e \u0431\u041e\u043b\u044c\u0448\u0430\u044f \u0447\u0430\u0441\u0442\u044c \u043f\u0440\u043e\u0432\u0435\u0440\u043e\u043a DSL \u043d\u0430 \u0432\u0430\u043b\u0438\u0434\u043d\u043e\u0441\u0442\u044c \u0443 \u043d\u0430\u0441 \u043f\u0440\u043e\u0438\u0441\u0445\u043e\u0434\u0438\u0442 \u043d\u0430 \u044d\u0442\u0430\u043f\u0435 \u043a\u043e\u043c\u043f\u0438\u043b\u044f\u0446\u0438\u0438, \u0430 \u0442\u0430\u043a \u0436\u0435 \u043c\u044b \u0438\u0441\u043f\u043e\u043b\u044c\u0437\u0443\u0435\u043c \u043e\u0447\u0435\u043d\u044c \u043c\u043d\u043e\u0433\u043e \u0433\u0435\u043d\u0435\u0440\u0430\u0446\u0438\u0438 \u043a\u043e\u0434\u0430. \u041f\u043e\u044d\u0442\u043e\u043c\u0443 \u043a\u0430\u0436\u0434\u044b\u0439 \u0434\u0435\u043d\u044c \u043f\u0440\u0438\u0445\u043e\u0434\u0438\u0442\u0441\u044f \u0441\u0442\u0430\u043b\u043a\u0438\u0432\u0430\u0442\u044c\u0441\u044f \u0441 \u0441\u043e\u0441\u0442\u0430\u0432\u043b\u0435\u043d\u0438\u0435\u043c ASTNode-\u043e\u0432 \u0432\u0440\u0443\u0447\u043d\u0443\u044e. <\/p>\n<pre><code class=\"ruby\">def someVariable = new ConstantExpression(&quot;someValue&quot;); def returnStatement = new ReturnStatement(     new ConstructorCallExpression(         ClassHelper.make(SomeCoolClass),         new ArgumentListExpression(someVariable)     ) ); <\/code><\/pre>\n<p>  \u0414\u043e \u0431\u043e\u043b\u0438 \u0437\u043d\u0430\u043a\u043e\u043c\u044b\u0435 \u043a\u043e\u043d\u0441\u0442\u0440\u0443\u043a\u0446\u0438\u0438, \u043d\u0435 \u043f\u0440\u0430\u0432\u0434\u0430 \u043b\u0438? \u0425\u043e\u0442\u0438\u0442\u0435, \u0447\u0442\u043e\u0431\u044b \u0431\u044b\u043b\u043e \u0432\u043e\u0442 \u0442\u0430\u043a?  <\/p>\n<pre><code class=\"ruby\">def someVariable = macro { &quot;someValue&quot; }; def returnStatement = macro { return new SomeCoolClass($v{ someVariable }) } <\/code><\/pre>\n<p>  \u0418\u043b\u0438 \u0434\u0430\u0436\u0435 \u0442\u0430\u043a?  <\/p>\n<pre><code class=\"ruby\">def constructorCall = macro { new SomeCoolClass($v{ macro { &quot;someValue&quot; } }) } <\/code><\/pre>\n<p>  \u0412 \u0434\u0430\u043d\u043d\u043e\u0439 \u0441\u0442\u0430\u0442\u044c\u0435 \u0440\u0435\u0447\u044c \u043f\u043e\u0439\u0434\u0451\u0442 \u043e \u043c\u043e\u0451\u043c \u0440\u0435\u0448\u0435\u043d\u0438\u0438 \u044d\u0442\u043e\u0439 \u043f\u0440\u043e\u0431\u043b\u0435\u043c\u044b, \u043c\u0430\u043a\u0441\u0438\u043c\u0430\u043b\u044c\u043d\u043e \u0431\u043b\u0438\u0437\u043a\u043e\u043c \u043a \u0440\u043e\u0434\u043d\u043e\u043c\u0443 \u0440\u0435\u0448\u0435\u043d\u0438\u044e Groovy \u2014 <a href=\"https:\/\/github.com\/bsideup\/MacroGroovy\">github.com\/bsideup\/MacroGroovy<\/a><\/p>\n","protected":false},"author":1,"featured_media":0,"comment_status":"open","ping_status":"open","sticky":false,"template":"","format":"standard","meta":{"footnotes":""},"categories":[],"tags":[],"class_list":["post-205084","post","type-post","status-publish","format-standard","hentry"],"_links":{"self":[{"href":"https:\/\/savepearlharbor.com\/index.php?rest_route=\/wp\/v2\/posts\/205084","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/savepearlharbor.com\/index.php?rest_route=\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/savepearlharbor.com\/index.php?rest_route=\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/savepearlharbor.com\/index.php?rest_route=\/wp\/v2\/users\/1"}],"replies":[{"embeddable":true,"href":"https:\/\/savepearlharbor.com\/index.php?rest_route=%2Fwp%2Fv2%2Fcomments&post=205084"}],"version-history":[{"count":0,"href":"https:\/\/savepearlharbor.com\/index.php?rest_route=\/wp\/v2\/posts\/205084\/revisions"}],"wp:attachment":[{"href":"https:\/\/savepearlharbor.com\/index.php?rest_route=%2Fwp%2Fv2%2Fmedia&parent=205084"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/savepearlharbor.com\/index.php?rest_route=%2Fwp%2Fv2%2Fcategories&post=205084"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/savepearlharbor.com\/index.php?rest_route=%2Fwp%2Fv2%2Ftags&post=205084"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}