shagabutdinov / sublime-local-variable

Extract/detach/rename variable refactoring
Other
9 stars 2 forks source link

CoffeeScript support #2

Open bpaczkowski opened 8 years ago

bpaczkowski commented 8 years ago

Could we get CoffeeScript support? It already works more or less, it finds all occurrences of a variable in the current function, but it doesn't stop when it reaches the end of that function, instead it finds all occurrences of that variable name from selected function till the end of the file.

shagabutdinov commented 8 years ago

I'm surprised somebody uses this plugin =) Please specify how to reproduce this bug, because everything works fine in raw test attempt (see video with attempt). issue_2 avi

bpaczkowski commented 8 years ago

It's not exactly IDE's level refactor, but still better than built-in Quick Find All :smiley:

In your example, if you also had a local variable options in the method decodeRange, or any method after that, it would also select those.

sublime_text_2016-03-23_10-14-43 I selected name in off, notice how it selected name's in off and emit but not in on.

shagabutdinov commented 8 years ago

Send me all information so I can reproduce this bug. It does not helps to have a screenshot - I'm not going to retype all text from screenshot to a file.

bpaczkowski commented 8 years ago

Like I said, all it takes is for one variable name to be used in more than one method.

class Name
  constructor: (test) ->
    x = test

  n: (test) ->
    a = test

  b: (test) ->
    z = test

Try to rename test in n method.

shagabutdinov commented 8 years ago

There is a problem with method plugin, as it wrongly detects method end for coffeescript.

There is methods dump for the code you provided:

[
  { 
    'privacy': 'public', 
    'body_start': 33, 
    'body_end': 106, 
    'name': 'constructor', 
    'start': 13, 
    'end': 106, 
    'index': 0,
  }, 
  { 
    'privacy': 'public', 
    'body_start': 62, 
    'body_end': 106, 
    'name': 'n', 
    'start': 52, 
    'end': 106, 
    'index': 1,
  }, 
  { 
    'privacy': 'public', 
    'body_start': 91, 
    'body_end': 106, 
    'name': 'b', 
    'start': 81, 
    'end': 106, 
    'index': 2,
  }
]

I've opened issue for method plugin: https://github.com/shagabutdinov/sublime-method/issues/5

I doubt I'll have time to investigate issue in next month because I'll have business trip I will be busy. So I hope you or somebody else can open pull request in order to fix this problem.

bpaczkowski commented 8 years ago

That looks a little too complicated for me I'm afraid. Someone else will have to take care of it.