Script to refactor assignment a.x=3 to setter method a->setX(3)
<p>I'm converting part of my code from JS to C++ thus I need to refactor direct instance variables assignment into setter methods:</p>

<p><code>a.xx=3;</code> to <code>a-&gt;setXx(3);</code></p>

<p>and also getter methods:</p>

<p><code>...a.xx...</code> to <code>...a-&gt;getXx()...</code></p>

<p>Currently I use <strong>shelljs (node.js)</strong> for the conversions.
Sample command for renaming a function from oldMethod() to newMethod():</p>

<pre><code>sed('-i', /\boldMethod[ ]*\(/g, 'newMethod(', filename);
</code></pre>

<p>Preferably I would use the same technique fro the setters/getter. However I'm open to use other acceptable approach too.</p>

<p>My problems:</p>

<ol>
<li>I can not get the tagged substitutions working</li>
<li>I'll need to capitalize the first letter</li>
<li><p>I'm not sure how to set proper conditions for the getter methods. There is no clear expression like <code>X=Y;</code> I can't simply turn all <code>alphanum.alphanum</code> into getters because it would also replace incorrect expressions e.g. <code>a("foo.doo");</code>
My suggestions:</p>

<p>a. do it anyway and manually update the incorrect replacements</p>

<p>b. supply a set of valid variable names, e.g. <code>"tag|possition|rotation|..."</code></p></li>
</ol>