Message from discussion
how to script more complex restructurings?
Received: by 10.14.186.135 with SMTP id w7mr512953eem.18.1306475054055;
Thu, 26 May 2011 22:44:14 -0700 (PDT)
MIME-Version: 1.0
X-BeenThere: rope-dev@googlegroups.com
Received: by 10.14.3.104 with SMTP id 80ls261468eeg.7.gmail; Thu, 26 May 2011
22:44:13 -0700 (PDT)
Received: by 10.14.42.68 with SMTP id i44mr519766eeb.54.1306475053115;
Thu, 26 May 2011 22:44:13 -0700 (PDT)
Received: by 10.14.42.68 with SMTP id i44mr519765eeb.54.1306475053102;
Thu, 26 May 2011 22:44:13 -0700 (PDT)
Return-Path: <aligr...@gmail.com>
Received: from mail-ew0-f52.google.com (mail-ew0-f52.google.com [209.85.215.52])
by gmr-mx.google.com with ESMTPS id c46si1040888eei.1.2011.05.26.22.44.13
(version=TLSv1/SSLv3 cipher=OTHER);
Thu, 26 May 2011 22:44:13 -0700 (PDT)
Received-SPF: pass (google.com: domain of aligr...@gmail.com designates 209.85.215.52 as permitted sender) client-ip=209.85.215.52;
Authentication-Results: gmr-mx.google.com; spf=pass (google.com: domain of aligr...@gmail.com designates 209.85.215.52 as permitted sender) smtp.mail=aligr...@gmail.com; dkim=pass (test mode) header...@gmail.com
Received: by ewy28 with SMTP id 28so715856ewy.11
for <rope-dev@googlegroups.com>; Thu, 26 May 2011 22:44:13 -0700 (PDT)
DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed;
d=gmail.com; s=gamma;
h=domainkey-signature:date:from:to:cc:subject:message-id:in-reply-to
:references:user-agent;
bh=0sc8+L1tXZMfw0Ij7BuutLwoj9m/ZzaW0ehRSmViwJw=;
b=rF0hWCfgjiwWqWRieBq6Ada0FoIBnJ7bgRjhyCeU2JjJbwAJzNNj54yCszGx/O0P04
pkFpRBwQu6PyyCcFXHi4gxkrkAy2yoLB1el8tpmlJxcCFtg42LfRMZSeXj85ONb8IU2R
QzPKTaIJpl6oxj34P09AAxNLswNFEERz4g7DA=
DomainKey-Signature: a=rsa-sha1; c=nofws;
d=gmail.com; s=gamma;
h=date:from:to:cc:subject:message-id:in-reply-to:references
:user-agent;
b=fZSijlw6qerK8eVutxdG1ESYzQY8G33bvLLAcA46rPid5pnLwWhYFg4oy1a2WJX33e
FgFzvtPuvxn71U+pe/wj22gC/QMHpRnZIOKzIxsgYjD/0zH0EPkZEOqWdhpoecfweQI/
aYttFI6BIlzywkBSx1kOmE5Uc9e2GzAL3NFCQ=
Received: by 10.14.9.155 with SMTP id 27mr611970eet.237.1306475051425;
Thu, 26 May 2011 22:44:11 -0700 (PDT)
Return-Path: <aligr...@gmail.com>
Received: from lilem.mirepesht ([91.99.78.55])
by mx.google.com with ESMTPS id y15sm1005015eea.25.2011.05.26.22.44.05
(version=SSLv3 cipher=OTHER);
Thu, 26 May 2011 22:44:09 -0700 (PDT)
Date: Fri, 27 May 2011 09:50:09 +0430
From: Ali Gholami Rudi <aligr...@gmail.com>
To: RonnyPfannschmidt <ronny.pfannschm...@gmail.com>
Cc: rope-dev <rope-dev@googlegroups.com>
Subject: Re: how to script more complex restructurings?
Message-ID: <20112705095...@lilem.mirepesht>
In-Reply-To: <9e68245a-1813-47a7-b6ec-7a408f64a...@gv8g2000vbb.googlegroups.com>
References: <f145b870-7f2f-4c53-b709-6e34416ca...@l26g2000yqm.googlegroups.com>
<20112605231...@lilem.mirepesht>
<9e68245a-1813-47a7-b6ec-7a408f64a...@gv8g2000vbb.googlegroups.com>
User-Agent: git://repo.or.cz/mailx.git
RonnyPfannschmidt <ronny.pfannschm...@gmail.com> wrote:
> > >https://bitbucket.org/RonnyPfannschmidt/pida-hacks/changeset/3bd765e2...
> >
> > Restructurings handle AST branches that match exactly (i.e. the
> > same number of parameters for calls) and perform a unique source
> > transformation on it; the goal string should depend only on the
> > matched expression in the pattern.
> >
> > pattern: self.create_action(${name}, ${kind}, ${n1}, ${n2}, ${n3}, ${n4}, ${n5})
> > goal: ${kind}(${name}, ${n1}, ${n2}, ${n3})
> >
> > The pattern could be made more general by replacing
> > self.create_action by ${create_action} and adding a
> > name=[modulename].BufferActionsConfig.create_action restriction
> > for ${create_action} (but it doesn't seem necessary if all
> > calls use self.create_action).
>
> just that pattern isn't even half of what i need i think
>
> unless i can take the callback names to rename refactorings and move
> the optional shortcuts to some dicts as well its meaningless
>
> i lack an understanding in how i get from finding create_action calls
> in classes to writing a list named actions + optionally some more
> mappings
Restructurings merely replace an AST node (though replacing a few
statements with different number of statements is possible; see
restructuring section of overview.txt and examples in restructure.py).
So it cannot help in your case. But it may make a few things easier:
If you can rewrite your transformation like this:
pattern: stmt1
goal:
stmt2
stmt3
stmtn
there's no problems and restructure.py should handle it. Otherwise
restructure.py can ease some of the steps:
pattern: stmt1
goal:
items_to_be_inserted_into_a_list(${n7})
items_to_be_inserted_into_a_dict(${n8}, ${n9})
stmt2
That is you can use nonexistent functions to help other parts of
your transformations. But this doesn't seem possible when the pattern
matches an expression, like an item of a list (a similar hack may
help; also the unimplemented "insert before" may help, see docs/dev/
issues.txt).
Ali