From users-return-3751-archive-asf-public=cust-asf.ponee.io@groovy.apache.org Mon Sep 24 19:35:34 2018 Return-Path: X-Original-To: archive-asf-public@cust-asf.ponee.io Delivered-To: archive-asf-public@cust-asf.ponee.io Received: from mail.apache.org (hermes.apache.org [140.211.11.3]) by mx-eu-01.ponee.io (Postfix) with SMTP id CF04C180649 for ; Mon, 24 Sep 2018 19:35:33 +0200 (CEST) Received: (qmail 43186 invoked by uid 500); 24 Sep 2018 17:35:32 -0000 Mailing-List: contact users-help@groovy.apache.org; run by ezmlm Precedence: bulk List-Help: List-Unsubscribe: List-Post: List-Id: Reply-To: users@groovy.apache.org Delivered-To: mailing list users@groovy.apache.org Received: (qmail 43171 invoked by uid 99); 24 Sep 2018 17:35:32 -0000 Received: from pnap-us-west-generic-nat.apache.org (HELO spamd2-us-west.apache.org) (209.188.14.142) by apache.org (qpsmtpd/0.29) with ESMTP; Mon, 24 Sep 2018 17:35:32 +0000 Received: from localhost (localhost [127.0.0.1]) by spamd2-us-west.apache.org (ASF Mail Server at spamd2-us-west.apache.org) with ESMTP id EBC2C1A0737 for ; Mon, 24 Sep 2018 17:35:31 +0000 (UTC) X-Virus-Scanned: Debian amavisd-new at spamd2-us-west.apache.org X-Spam-Flag: NO X-Spam-Score: 1.869 X-Spam-Level: * X-Spam-Status: No, score=1.869 tagged_above=-999 required=6.31 tests=[DKIM_SIGNED=0.1, DKIM_VALID=-0.1, DKIM_VALID_AU=-0.1, HTML_MESSAGE=2, RCVD_IN_DNSWL_NONE=-0.0001, RCVD_IN_MSPIKE_H3=-0.01, RCVD_IN_MSPIKE_WL=-0.01, SPF_PASS=-0.001, T_DKIMWL_WL_MED=-0.01] autolearn=disabled Authentication-Results: spamd2-us-west.apache.org (amavisd-new); dkim=pass (2048-bit key) header.d=gmail.com Received: from mx1-lw-us.apache.org ([10.40.0.8]) by localhost (spamd2-us-west.apache.org [10.40.0.9]) (amavisd-new, port 10024) with ESMTP id QtinTW3T7H1M for ; Mon, 24 Sep 2018 17:35:30 +0000 (UTC) Received: from mail-oi0-f51.google.com (mail-oi0-f51.google.com [209.85.218.51]) by mx1-lw-us.apache.org (ASF Mail Server at mx1-lw-us.apache.org) with ESMTPS id D67175F3EE for ; Mon, 24 Sep 2018 17:35:29 +0000 (UTC) Received: by mail-oi0-f51.google.com with SMTP id k64-v6so3159854oia.13 for ; Mon, 24 Sep 2018 10:35:29 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20161025; h=mime-version:from:date:message-id:subject:to; bh=NZVrM0/QETIYnNj8hm+oq/QWonJTce3e1hvIjVocEKg=; b=NoDsJ0a3B7a78SwKS8DFOXRRWy0tczltXAJQ1Rgw38btHsTOwz2bNF6Kn34MO0yL00 67lKJZbAuzTOAbzigPpj+eREkFA5WZ7qh2kXP1pL5klxBvda957ok2ZC64+imKGvam8h BGZoo85JeyQj/6Z9VXeh0IanwgM79vNJdnkiQyL4vCnC41CT27M69p6fAQIcPWRUCQLf 9oybvDqBXCCuPbCo+0IKGlJrRmjRYw/zR0kY2idmTfviFbnEXuYyvETortgXwbu17mFv Q4CPbpzqifMVEEsvo+hCjtAkkPpDjlzHX3Uq9LG4CPzdYlJ1zordFDpXGwmeB1pL073d pZSA== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:mime-version:from:date:message-id:subject:to; bh=NZVrM0/QETIYnNj8hm+oq/QWonJTce3e1hvIjVocEKg=; b=G14F+nNmZmaT34DZB2oey279zENL462P7JchtjnARf6/CTztiIKQgCRdT0IO60IpIX +NvQUUIWbs//L4ma7ltZyBAUzLosYqSzhn3pTN/N3M9B9LFVqHQmjiMOM0JsDXYPzjn8 e8Z+M3u159Hut378GpmTLD3bMulDP+MJq3bDwz/mWhEYuGmL8qP/ahJIzZBxej3pO2Xa a6hJ6BB2WlX48ky5KTpUF82btkH0IShZwRumEpHbzZBJc/1Xd3jY6oPy7qFKokzwr78p pMA/MOkijgb67FaJRNO3UdYIkuX/YUDsGhFqP5sSlRRoeGkI/fjD13J14VDMRBzS0/b2 cdwg== X-Gm-Message-State: APzg51BqcH0aZk645/64Syc7v249W60KvCKu/1g5A/ERwd5fdvvlBDtU ef6K+zcZrgb/XUFWtCaOBh7AhE8bF06TsmCYIZ3Oi2mG X-Google-Smtp-Source: ANB0VdY/2f8xsuM79fETexwOlTYZ3/lhIAsh0mpeZnHiPz6hCmcV+/DqO/wGq5reN4M+6aXULuzOLAbOxvwhseSH9hg= X-Received: by 2002:aca:6285:: with SMTP id w127-v6mr6245338oib.120.1537810522480; Mon, 24 Sep 2018 10:35:22 -0700 (PDT) MIME-Version: 1.0 From: Paolo Di Tommaso Date: Mon, 24 Sep 2018 19:34:58 +0200 Message-ID: Subject: Clousure expression transformation To: users@groovy.apache.org Content-Type: multipart/alternative; boundary="000000000000eca5820576a169bf" --000000000000eca5820576a169bf Content-Type: text/plain; charset="UTF-8" Dear all, I'm trying to write a global transformation for my DSL to apply a custom logic on binary expression. For example: @GroovyASTTransformation(phase = CompilePhase.CONVERSION) class FooXformImpl implements ASTTransformation { SourceUnit unit @Override void visit(ASTNode[] nodes, SourceUnit source) { this.unit = unit createVisitor().visitClass((ClassNode)nodes[1]) } protected ClassCodeExpressionTransformer createVisitor() { new ClassCodeExpressionTransformer() { protected SourceUnit getSourceUnit() { unit } Expression transform(Expression expr) { if( expr.class == BinaryExpression ) { return .. // my replacement where } super.transform(expr) } } } } The transformation is correctly applied, however it turns out the expressions nested in a closure definition are *not* visited. Therefore the above transformation is not applied to binary expressions inside a closure. Is that expected? How to manage this use case ? Cheers, Paolo --000000000000eca5820576a169bf Content-Type: text/html; charset="UTF-8" Content-Transfer-Encoding: quoted-printable
Dear all,=C2=A0


I'm trying to write a global transformation for my DSL to appl= y a custom logic on binary expression. For example:=C2=A0

@GroovyASTTransformation(phase = =3D CompilePhase.CONVERSION)
class FooXformImpl implements ASTTransformation {
<= font face=3D"monospace, monospace">
=C2=A0 =C2=A0 SourceUnit unit

=C2=A0 =C2=A0 @Override
=C2=A0 =C2=A0 void visit(ASTNode[] nodes, SourceUnit source) {
=C2=A0 =C2=A0 =C2=A0 = =C2=A0 this.unit =3D unit
=C2=A0 =C2=A0 =C2=A0 =C2=A0 createVisitor().visitClass((ClassNode)nodes= [1])
=C2=A0 =C2=A0 }

<= font face=3D"monospace, monospace">=C2=A0 =C2=A0 protected ClassCodeExpress= ionTransformer createVisitor() {

=C2=A0= =C2=A0 =C2=A0 =C2=A0 new ClassCodeExpressionTransformer() {

=C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 protected S= ourceUnit getSourceUnit() { unit }

=C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 Expre= ssion transform(Expression expr) {
=C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 if( ex= pr.class =3D=3D BinaryExpression ) {
=C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2= =A0 =C2=A0 return .. // my replacement where
=C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2= =A0 }
=C2=A0 =C2=A0 = =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 super.transform(expr)
=C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2= =A0 =C2=A0 }
=C2=A0 = =C2=A0 =C2=A0 =C2=A0 }
=C2=A0 =C2=A0 }
}


The transformation is cor= rectly applied, however it turns out the expressions nested in a closure de= finition are *not* visited. Therefore the above transformation is not appli= ed to binary expressions inside a closure.=C2=A0

I= s that expected? How to manage this use case ?=C2=A0


=
Cheers,
Paolo
=C2=A0
--000000000000eca5820576a169bf--