halohalospecial / atom-elmjutsu

A bag of tricks for developing with Elm. (Atom package)
https://atom.io/packages/elmjutsu
MIT License
192 stars 24 forks source link

Find usages and rename limitations #14

Closed rundis closed 7 years ago

rundis commented 8 years ago

This is probably multiple issues, but I'll let you be the judge of that. I was looking at your find usages and refactor/rename feature to gain some inspirations for my Light Table plugin and came across a few things that I figured I'd report back to you in case you haven't already thought about them

  1. Find usages doesn't seem to handle the case when you from another module explicitly expose an item in the exposing clause of an import (ie when not using an alias or the module name as prefix for a symbol)
  2. Find usages doesn't cater for comments (you could argue that's fine to get hits in comments, or maybe not)
  3. Find usages doesn't handle shadowing. Really tricky one (:
  4. Find usages doesn't handle using record/type alias field names that shadows a top level declaration name (when getting usages within the module the symbol belongs to)

I'm going to struggle with the exact same problems, so I'm not going to provide a rename feature quite yet I think.

Anyways, super-impressed by what you have done and you've provided me with lots of inspiration :-) So keep up the good work !

halohalospecial commented 8 years ago

Hi @rundis! Thank you for the very kind words :blush: I'm also super impressed by your LightTable plugin that's becoming a full-featured IDE :smile: As what somebody said in the forums, it's the gold standard of Elm editor support. (I recently got inspired by your import management.)

You perfectly summarized the limitations of Find Usages and Rename Symbols :grinning: Perhaps item 1 is a bug, though. Thank you for reporting it! For item 2, I found it more useful (at least for me) to also include the comments because I sometimes comment out working code temporarily to try stuff. Maybe "Find Usages" and "Rename Symbols" are misnomers because they are just "slightly smarter" find and replace :-) Because of the limitations, the Rename Symbols UI has checkboxes so that we could exclude incorrect matches.

The implementation of the features in this package is really just a stopgap until we get access to the AST.

Side story: I experimented before with using the generated .elmo files to extract the JavaScript AST using Esprima. Although it seemed workable, it's not very usable while typing code because it required your project to have already compiled successfully. (It's slightly more usable for reading code.)