ruby/src/org/netbeans/modules/ruby/RubyRenameHandler.java
changeset 4556 e276e451257b
parent 4555 3773928e70d0
     1.1 --- a/ruby/src/org/netbeans/modules/ruby/RubyRenameHandler.java	Sun Dec 08 12:20:16 2013 -0600
     1.2 +++ b/ruby/src/org/netbeans/modules/ruby/RubyRenameHandler.java	Sun Dec 08 12:53:22 2013 -0600
     1.3 @@ -56,46 +56,9 @@
     1.4  import org.openide.util.NbBundle;
     1.5  
     1.6  /**
     1.7 - * Handle renaming of local elements
     1.8 - * @todo I should be able to rename top-level methods as well since they
     1.9 - *   are private
    1.10 - * @todo Rename |j| in the following will only rename "j" inside the block!
    1.11 - * <pre>
    1.12 -i = 50
    1.13 -j = 200
    1.14 -k = 100
    1.15 -x = [1,2,3]
    1.16 -x.each do |j|
    1.17 -  puts j
    1.18 -end
    1.19 -puts j
    1.20 - * </pre>
    1.21 - * @todo When you fix, make sure BlockarReuse is also fixed!
    1.22 - * @todo Try renaming "hello" in the exception here; my code is confused
    1.23 - *   about what I'm renaming (aliases method name) and the refactoring dialog
    1.24 - *   name is wrong! This is happening because it's also changing GlobalAsgnNode for $!
    1.25 - *   but its parent is LocalAsgnNode, and -its- -grand- parent is a RescueBodyNode! 
    1.26 - *   I should special case this!
    1.27 - * <pre>
    1.28 -def hello
    1.29 -  begin
    1.30 -    ex = 50
    1.31 -    puts "test"
    1.32 -  
    1.33 -  rescue Exception => hello
    1.34 -    puts hello
    1.35 -  end
    1.36 -end
    1.37 - *
    1.38 - * </pre>
    1.39 - *
    1.40 - * @author Tor Norbye
    1.41 + * Handles renaming of local elements.
    1.42   */
    1.43  public class RubyRenameHandler implements InstantRenamer {
    1.44 -    
    1.45 -    public RubyRenameHandler() {
    1.46 -    }
    1.47 -
    1.48      @Override
    1.49      public boolean isRenameAllowed(ParserResult info, int caretOffset, String[] explanationRetValue) {
    1.50          Node root = AstUtilities.getRoot(info);
    1.51 @@ -122,13 +85,12 @@
    1.52  
    1.53      @Override
    1.54      public Set<OffsetRange> getRenameRegions(ParserResult info, int caretOffset) {
    1.55 -        Node closest = AstUtilities.findNodeAtOffset(info, caretOffset);
    1.56 -        if (closest == null || !(closest instanceof ILocalVariable)) return Collections.emptySet();
    1.57 +        Node variable = AstUtilities.findNodeAtOffset(info, caretOffset);
    1.58 +        if (variable == null || !(variable instanceof ILocalVariable)) return Collections.emptySet();
    1.59  
    1.60 -        ILocalVariable variable = (ILocalVariable) closest;
    1.61          Set<OffsetRange> regions = new HashSet<OffsetRange>();
    1.62  
    1.63 -        for (ILocalVariable occurrence: variable.getOccurrences()) {
    1.64 +        for (ILocalVariable occurrence: ((ILocalVariable) variable).getOccurrences()) {
    1.65              OffsetRange range = LexUtilities.getLexerOffsets(info, 
    1.66                      AstUtilities.offsetRangeFor(occurrence.getNamePosition()));
    1.67  
    1.68 @@ -137,15 +99,4 @@
    1.69  
    1.70          return regions;
    1.71      }
    1.72 -
    1.73 -    // TODO: Check
    1.74 -    //  quick tip renaming
    1.75 -    //  unused detection
    1.76 -    //  occurrences marking
    1.77 -    //  code completion
    1.78 -    //  live code templates
    1.79 -    // ...anyone else who calls findBlock
    1.80 -    //
    1.81 -    // Test both parent blocks, sibling blocks and descendant blocks
    1.82 -    // Make sure the "isUsed" detection is smarter too.
    1.83 -}
    1.84 +}
    1.85 \ No newline at end of file