<div dir="ltr"><div class="gmail_default" style="font-family:georgia,serif">There is a new <a href="https://github.com/johnno1962/Refactorator">Swift refactoring plugin</a> for Xcode. It is developed by johnno1962.</div><div class="gmail_default" style="font-family:georgia,serif"><br></div><div class="gmail_default"><font face="georgia, serif">Tonight I have a conversation with him on an issue of the refactoring plugin. The </font><a href="https://github.com/johnno1962/Refactorator/issues/3" style="font-family:georgia,serif">issue</a><font face="georgia, serif"> is closed because johnno1962 says the issue is the limit of SourceKit, which he can do nothing further.</font></div><div class="gmail_default"><font face="georgia, serif"><br></font></div><div class="gmail_default"><font face="georgia, serif">So I bring it here and see if anyone can help.</font></div><div class="gmail_default"><font face="georgia, serif"><br></font></div><div class="gmail_default"><font face="georgia, serif">The example is simple. Supposing we have code like this:</font></div><div class="gmail_default"><font face="georgia, serif"><br></font></div><div class="gmail_default"><pre style="overflow:auto;font-family:Consolas,'Liberation Mono',Menlo,Courier,monospace;font-size:12px;margin-top:0px;margin-bottom:0px;line-height:1.45;padding:16px;background-color:rgb(247,247,247);border-top-left-radius:3px;border-top-right-radius:3px;border-bottom-right-radius:3px;border-bottom-left-radius:3px;word-wrap:normal;color:rgb(51,51,51)"><span class="" style="color:rgb(167,29,93)">struct</span> Person {
<span class="" style="color:rgb(167,29,93)">var</span> name:<span class="" style="color:rgb(0,134,179)">String</span>
<span class="" style="color:rgb(167,29,93)">init</span>(aName:<span class="" style="color:rgb(0,134,179)">String</span>) {
<span class="" style="color:rgb(167,29,93)">self</span><span class="" style="color:rgb(167,29,93)">.</span>name <span class="" style="color:rgb(167,29,93)">=</span> aName
}
}
<span class="" style="color:rgb(167,29,93)">func</span> <span class="" style="color:rgb(121,93,163)">testOnly</span>() {
<span class="" style="color:rgb(167,29,93)">let</span> john <span class="" style="color:rgb(167,29,93)">=</span> Person(aName: <span class="" style="color:rgb(24,54,145)"><span class="" style="">"</span>John<span class="" style="">"</span></span>)
<span class="" style="color:rgb(0,134,179)">print</span>(john)
}</pre></div><div><br></div><div><div class="gmail_default" style="font-family:georgia,serif">When we do a refactor on aName, in let john = Person(aName: "John"). SourceKit only find this line of code and the code line init(aName:String).</div><div class="gmail_default" style="font-family:georgia,serif"><br></div><div class="gmail_default" style="font-family:georgia,serif">It should also find the code line: <a href="http://self.name">self.name</a> = aName, which it didn't.</div><div class="gmail_default" style="font-family:georgia,serif"><br></div><div class="gmail_default"><font face="georgia, serif">According to johnno1962, SourceKit treats the aName inside the init(aName:String) as a variable different from the aName in init(aName:String).</font></div></div><div class="gmail_default" style="font-family:georgia,serif"><br></div>-- <br><div class="gmail_signature"></div>
<div><br></div><div><div class="gmail_default" style="font-family:georgia,serif">zhaoxin</div><br></div></div>