Padre: Ticket Queryhttp://padre.perlide.org/trac/query?status=!closed&component=Refactoring+Perl+5&order=status
Perl Application Development and Refactoring Environmenten-USPadre/static/logo.pnghttp://padre.perlide.org/trac/query?status=!closed&component=Refactoring+Perl+5&order=status
Trac 1.0.1http://padre.perlide.org/trac/ticket/502
http://padre.perlide.org/trac/ticket/502#502: code analyzis: find code not in subs, rearrange codeThu, 27 Aug 2009 19:13:57 GMTszabgab<p>
When looking at a script or module I never saw before I am never sure there is no code between functions:
</p>
<pre class="wiki">sub a {
}
die "hello world";
sub b {
}
</pre><p>
Also END, BEGIN etc blocks are relevant.
</p>
<p>
I would like to make it easy to find any such code and maybe
even rearrange the file so I'll have all the non-sub stuff at the top.
</p>
Resultshttp://padre.perlide.org/trac/ticket/502#changeloghttp://padre.perlide.org/trac/ticket/992
http://padre.perlide.org/trac/ticket/992#992: refactoring: list conversionsThu, 02 Sep 2010 09:24:59 GMTzenogantner<p>
Some rather Perl-specific refactoring functions would be source code conversions of lists:
</p>
<ol><li>switch between "qw(a b c)" and "('a', 'b', 'c')" (if possible)
</li><li>switch between fat and normal commas: "( a =&gt; 'b')" and "('a', 'b')"
</li><li>(any other idea ...)
</li></ol>Resultshttp://padre.perlide.org/trac/ticket/992#changeloghttp://padre.perlide.org/trac/ticket/1200
http://padre.perlide.org/trac/ticket/1200#1200: Refactoring tool: replace indirect calls by direct callsMon, 28 Mar 2011 13:50:30 GMTszabgab<p>
Replace one or all occurrences of indirect notations such as this:
</p>
<pre class="wiki">new Something("bla");
</pre><p>
by this:
</p>
<pre class="wiki">Something-&gt;new("bla");
</pre>Resultshttp://padre.perlide.org/trac/ticket/1200#changeloghttp://padre.perlide.org/trac/ticket/8
http://padre.perlide.org/trac/ticket/8#8: Tool for refactoring codeThu, 07 Aug 2008 22:59:50 GMTszabgab<p>
locate and replace all occurrences of a method name or variable name within a project
</p>
<p>
see <a class="ext-link" href="http://www.perlmonks.org/?node_id=622705"><span class="icon">​</span>http://www.perlmonks.org/?node_id=622705</a>
</p>
Resultshttp://padre.perlide.org/trac/ticket/8#changeloghttp://padre.perlide.org/trac/ticket/279
http://padre.perlide.org/trac/ticket/279#279: Refactoring support: automatic global-to-lexical conversionTue, 24 Mar 2009 10:47:36 GMTtsee<p>
I recently had the non-fun experience of having to refactor a moderately large single-file program that was not strict-clean. No variable declarations anywhere.
</p>
<p>
In such programs, variables are still usually being used like lexicals. Very few variables are *really* global.
</p>
<p>
My experience was that getting the program strict clean and declaring all variables lexically in the tightest possible scope went a long way towards making the program more readable and accessible.
</p>
<p>
The way there, however, was paved with rather tedious hours of work. Therefore, I propose the ultimately useful refactoring feature:
</p>
<p>
In a similar fashion to the lexical-variable renaming, introduce a feature that finds the tightest scope in which a given variable could be declared lexically and then does so. Of course, this doesn't work for true globals, but honestly, I believe those can be identified rather easily in most cases.
</p>
<p>
This is not an easy task, however. The lexical rename walks the PPI tree upwards until it finds a scope in which (not including arbitrary sub-scopes, I hope) there is a declaration of the variable. This would have to do something remotely similar, but really the other way around. Starting from the top-level, recurse into all sub scopes and find out whether the variable is used there. If it's only used in one of them, go into that one and rinse, repeat. I'm sure there's something (apart from the trivial "this will be ugly to implement using PPI") I'm missing.
</p>
<p>
Of course, this feature won't work well for reused variable names such as $i for iteration. But it'd still be a start!
</p>
Resultshttp://padre.perlide.org/trac/ticket/279#changeloghttp://padre.perlide.org/trac/ticket/386
http://padre.perlide.org/trac/ticket/386#386: Ideas for more refactoring toolsWed, 10 Jun 2009 09:07:44 GMTtsee<p>
This perlmonks meditation may provide ideas for more semi-automatic refactoring tools: <a class="ext-link" href="http://perlmonks.org/?node_id=769387"><span class="icon">​</span>http://perlmonks.org/?node_id=769387</a>
</p>
Resultshttp://padre.perlide.org/trac/ticket/386#changeloghttp://padre.perlide.org/trac/ticket/494
http://padre.perlide.org/trac/ticket/494#494: Rename variable options and preview windowWed, 19 Aug 2009 12:01:54 GMTszabgab<p>
In the Rename variable we could add a few options ideas from Visual Studio:
Check boxes:
</p>
<blockquote>
<p>
[ ] Preview reference changes
[ ] Search in comments
[ ] Search in strings
</p>
</blockquote>
<p>
Then it shows a "preview code changes" window where you can see the places it going to change the code. (I can also imagine a tool to show a diff between two changes, or the current version and the version after the change.
</p>
Resultshttp://padre.perlide.org/trac/ticket/494#changeloghttp://padre.perlide.org/trac/ticket/525
http://padre.perlide.org/trac/ticket/525#525: Feature request: "Rename subroutine"Wed, 09 Sep 2009 13:30:50 GMTrhebus<p>
Subroutine renaming is an important refactoring technique. Often you find that the name you originally used for a subroutine wasn't ideal, but by the time you have thought of a better, clearer name it is already referenced 20 times in 10 files.
</p>
<p>
A "rename subroutine" function would rename the subroutine *and* all references to it throughout the project. Clearly this requires syntactic parsing of all files in the project; a global search-and-replace is flaky and dangerous since it will change subroutines with the same name in different packages.
</p>
<p>
More info on subroutine renaming:
<a class="ext-link" href="http://en.wikipedia.org/wiki/Rename_method"><span class="icon">​</span>http://en.wikipedia.org/wiki/Rename_method</a>
<a class="ext-link" href="https://eclipse-tutorial.dev.java.net/visual-tutorials/refactoringrenamefieldandmethod.html"><span class="icon">​</span>https://eclipse-tutorial.dev.java.net/visual-tutorials/refactoringrenamefieldandmethod.html</a> -- example of rename field and method in eclipse for Java
</p>
Resultshttp://padre.perlide.org/trac/ticket/525#changeloghttp://padre.perlide.org/trac/ticket/535
http://padre.perlide.org/trac/ticket/535#535: Preview window for extract subroutineThu, 10 Sep 2009 07:57:16 GMTszabgab<p>
I am always afraid of using these magic tools for code refactoring. If I could see up-front what a certain action will do, that would improve my confidence by a lot.
</p>
<p>
So I'd like to see a way to preview the changes the extract subroutine will do.
</p>
<p>
I am not sure if I want to see the new code, a unix-like textual diff, a side-by-side diff of some external tool or something totally different but any one of these could be a huge step forward in gaining confidence.
</p>
Resultshttp://padre.perlide.org/trac/ticket/535#changeloghttp://padre.perlide.org/trac/ticket/537
http://padre.perlide.org/trac/ticket/537#537: extract subroutine should put the new subroutine in a better placeThu, 10 Sep 2009 08:41:25 GMTrhebus<p>
Currently the new sub is dumped at the end of the file. This is easy, but incorrect if it is after the 1; line of a .pm or after a <span class="underline">END</span> line, and ugly if it is after any pod.
</p>
<p>
The best thing would be immediately after or before the subroutine it was extracted from.
</p>
Resultshttp://padre.perlide.org/trac/ticket/537#changeloghttp://padre.perlide.org/trac/ticket/645
http://padre.perlide.org/trac/ticket/645#645: Lexically rename variable changes the screen position dramatically (and shouldn't have to)Sat, 03 Oct 2009 16:30:03 GMTadamk<p>
In the current implementation, the "Lexically Rename Variable" function results in a long wait to parse the document (which is not a big deal) followed by a dramatic snap to a new focus and line (which is really annoying).
</p>
<p>
The Lexically Rename Variable function inherently should never change the line quantity or the position of any code. As a result, we SHOULD be able to remember and keep the position of the editor at the time of the Lexical Rename Variable menu entry being fired and keep it at the end of the replacement.
</p>
Resultshttp://padre.perlide.org/trac/ticket/645#changeloghttp://padre.perlide.org/trac/ticket/816
http://padre.perlide.org/trac/ticket/816#816: Lexical variable renaming doesn't support <<"HEREDOCS"Wed, 06 Jan 2010 05:53:38 GMTadamk<p>
The lexical variable rename function currently reaches into "" quoted strings correctly and changes them.
</p>
<p>
However, it currently overlooks code in the "rollup" section of a heredoc operator. That content needs to be processed in the same way as the double quoted string.
</p>
Resultshttp://padre.perlide.org/trac/ticket/816#changeloghttp://padre.perlide.org/trac/ticket/890
http://padre.perlide.org/trac/ticket/890#890: "Introduce Temporary Variable" need to be fixedTue, 16 Mar 2010 15:36:18 GMTjagd<p>
This is a code piece from the Wx examples, just put the cursor there and click Refactor-&gt;Introduce Temporary Variable :
</p>
<pre class="wiki">
sub new {
my ($class) = @_;
#&lt;-------- CURSOR HERE
my $self = $class-&gt;SUPER::new(
undef, -1,
'Demo::App',
wxDefaultPosition, wxDefaultSize,
);
my $button = Wx::Button-&gt;new( $self, -1, "Press here" );
EVT_BUTTON( $self, $button, sub { print "button pressed\n" } );
$self-&gt;SetSize( $button-&gt;GetSizeWH );
return $self;
}
</pre>Resultshttp://padre.perlide.org/trac/ticket/890#changeloghttp://padre.perlide.org/trac/ticket/901
http://padre.perlide.org/trac/ticket/901#901: (wishlist) variable renaming: highlighting, inline-editingThu, 18 Mar 2010 19:40:36 GMTzenogantner<p>
When renaming a variable, all occurrences of the variable should be highlighted, so that users see where there will be consequences.
</p>
<p>
One more step would be to allow inline editing: Instead of a pop-up window, the variable is renamed in-place, and the user can see all other occurrences change at the same time.
</p>
Resultshttp://padre.perlide.org/trac/ticket/901#changeloghttp://padre.perlide.org/trac/ticket/937
http://padre.perlide.org/trac/ticket/937#937: Variable renaming: No declaration found if variable is declared in parenthesesSun, 02 May 2010 19:17:12 GMTzenogantner<p>
How to reproduce:
Load/create a Perl file such a variable declaration:
</p>
<p>
my ($var);
</p>
<p>
Try to rename the variable.
It does not work: "No declaration could be found for the specified (lexical?) variable.
</p>
<p>
What should happen: Should work as for a variable declared by
</p>
<p>
my $var;
</p>
Resultshttp://padre.perlide.org/trac/ticket/937#changeloghttp://padre.perlide.org/trac/ticket/955
http://padre.perlide.org/trac/ticket/955#955: Feature request: "Rename label"Tue, 25 May 2010 15:06:46 GMTzenogantner<p>
I would like to be able to rename labels with Padre.
</p>
<p>
e.g.
</p>
<p>
LABEL:
while (&lt;&gt;) {
</p>
<blockquote>
<p>
next LABEL if ...
</p>
</blockquote>
<p>
</p>
<blockquote>
<p>
...
</p>
</blockquote>
<p>
}
</p>
<p>
would be renamed to
</p>
<p>
LINE:
while (&lt;&gt;) {
</p>
<blockquote>
<p>
next LINE if ...
</p>
</blockquote>
<p>
</p>
<blockquote>
<p>
...
</p>
</blockquote>
<p>
}
</p>
<p>
in one step.
</p>
Resultshttp://padre.perlide.org/trac/ticket/955#changeloghttp://padre.perlide.org/trac/ticket/991
http://padre.perlide.org/trac/ticket/991#991: rename project-wide variable/function nameThu, 02 Sep 2010 09:17:53 GMTzenogantner<p>
Currently, renaming variables is only supported within one file.
It would be nice if one could also rename subroutines, in particular methods, and perform all those renaming actions project-wide
</p>
<p>
Things like Moose and XSAccessor should be supported as well.
</p>
Resultshttp://padre.perlide.org/trac/ticket/991#changeloghttp://padre.perlide.org/trac/ticket/996
http://padre.perlide.org/trac/ticket/996#996: refactoring: renaming of hash keysThu, 02 Sep 2010 11:34:42 GMTzenogantner<p>
Another nice refactoring feature would be the renaming of hash keys in the current scope.
</p>
<p>
E.g. you want to rename the key 'replace' to 'replace_button' in the following code:
</p>
<pre class="wiki">
# The "Replace" button
$self-&gt;{replace} = Wx::Button-&gt;new(
$self,
Wx::wxID_REPLACE,
Wx::gettext("&amp;Replace"),
);
Wx::Event::EVT_BUTTON(
$self,
$self-&gt;{replace},
sub {
$_[0]-&gt;replace_button;
}
);
Wx::Event::EVT_CHAR(
$self-&gt;{replace},
sub {
$self-&gt;hotkey( $_[1]-&gt;GetKeyCode );
}
);
$self-&gt;{replace}-&gt;SetDefault;
</pre><p>
Then having this rename-feature would come in handy, and it would be nicer to use than the normal 'search and replace' function.
</p>
<p>
The functionality could be integrated into one action 'rename' that renames several other things like variables, subroutines, or modules.
Having a menu entry and a context menu entry for the one action won't make the user interface more complicated, just more consistent.
</p>
Resultshttp://padre.perlide.org/trac/ticket/996#changeloghttp://padre.perlide.org/trac/ticket/998
http://padre.perlide.org/trac/ticket/998#998: refactoring: replace double quotes by single quotes where appropriateThu, 02 Sep 2010 12:17:38 GMTzenogantner<p>
Apply to selected text or complete document.
</p>
<p>
Some examples:
</p>
<pre class="wiki">"bla" --&gt; 'bla'
"$value" --&gt; "$value"
"'" --&gt; "'"
"You said \"that\"." --&gt; 'You said "that".'
qq{Some text} --&gt; q{Some text}
</pre>Resultshttp://padre.perlide.org/trac/ticket/998#changeloghttp://padre.perlide.org/trac/ticket/1024
http://padre.perlide.org/trac/ticket/1024#1024: "Change variable style" does not always work properlyTue, 12 Oct 2010 08:57:43 GMTzenogantner<p>
The following things do not work as expected for me:
</p>
<p>
var: '$number_of_lines'
action: to Using_Underscores
expected: '$Number_Of_Lines'
got: '$Number_of_lines'
</p>
<p>
var: '$Number_Of_Lines'
action: to using_underscores
expected: '$number_of_lines'
got: '$number<span class="underline">of</span>lines'
</p>
<p>
var: '$Number_Of_Lines'
action: to Using_Underscores
expected: '$Number_Of_Lines'
got: '$Number<span class="underline">Of</span>Lines'
</p>
Resultshttp://padre.perlide.org/trac/ticket/1024#changeloghttp://padre.perlide.org/trac/ticket/1134
http://padre.perlide.org/trac/ticket/1134#1134: refactoring: reference/dereferenceFri, 18 Feb 2011 10:44:59 GMTzenogantner<p>
Example:
</p>
<pre class="wiki">%hash = ( key1 =&gt; 'val1');
say $hash{key1};
function(\%hash);
</pre><p>
to/from
</p>
<pre class="wiki">$hash_ref = { key1 =&gt; 'val1'};
say $hash_ref-&gt;{$key1};
function($hash_ref);
</pre><p>
The same for scalars and arrays.
</p>
<p>
Of course, there may be corner cases where this fails, but it would be neat to have such a tool...
</p>
Resultshttp://padre.perlide.org/trac/ticket/1134#changeloghttp://padre.perlide.org/trac/ticket/1201
http://padre.perlide.org/trac/ticket/1201#1201: Refactoring tool for Perl::Critic rulesMon, 28 Mar 2011 13:53:14 GMTszabgab<p>
Create refactoring tools for many of the Perl::Critic errors so when Perl::Critic finds an issue it can be fixed with a single click.
We could package it as an external module and provide a command line interface to it so it will locate the problematic pieces of code and fix them in a given file.
</p>
<p>
<a class="assigned ticket" href="http://padre.perlide.org/trac/ticket/1200" title="enhancement: Refactoring tool: replace indirect calls by direct calls (assigned)">#1200</a> is a special case of this
</p>
Resultshttp://padre.perlide.org/trac/ticket/1201#changeloghttp://padre.perlide.org/trac/ticket/1349
http://padre.perlide.org/trac/ticket/1349#1349: renaming variable names inside regular expressions does not workTue, 11 Oct 2011 14:43:53 GMTzenogantner<p>
How to reproduce:
</p>
<ul><li>load the file <tt>Padre/Document/Java/FunctionList.pm</tt> from the Padre source (it exists in <a class="changeset" href="http://padre.perlide.org/trac/changeset/16930" title="update German translation">r16930</a>)
</li><li>move cursor to the line where the variable $n is defined
</li><li>use Alt-Shift-R to rename (works)
</li><li>now do the same with the occurrence of this variable inside the regular expression below
</li><li>result: You get a prompt for renaming, but an error message afterwards
</li></ul>Resultshttp://padre.perlide.org/trac/ticket/1349#changelog