Author Topic: Finding unused variables  (Read 2843 times)

Offline scunliffe

  • Registered User
  • Newbie
  • *
  • Posts: 17
  • Karma: +0/-0
Finding unused variables
« on: September 06, 2012, 03:33:10 PM »
I love HippoEDIT as my editor but occasionally I miss certain IDE features.

One feature I'd like to emmulate is the ability to run a quick scan of a file to see if any declared variables are never used (e.g. dead code)

For example in an ActionScript class (for Adobe AIR development) I know that my variable declarations will be in a certain format that I should be able to extract the variable name and then compare to the rest of the document.

So, in short a variable is declared like:

Code: [Select]
var fooBar:String = "DefaultIfSpecified";
thus anything between "var " and ":" is my variable name... and I just want to search the rest of the document to see if "fooBar" is found more than once.

Would this concept be possible with the macro/scripting abilities of HippoEDIT?... if so, is there a page with any info/commands I can use? and if not... can I bump this to another thread as part of a wishlist of scripting capabilities for HippoEDIT? ;-)

Offline alex

  • Developer
  • Global Moderator
  • Hero Member
  • *****
  • Posts: 2223
  • Karma: +37/-3
    • HippoEDIT
Re: Finding unused variables
« Reply #1 on: September 07, 2012, 12:59:08 AM »
yes this should be easy possible. But you need to write the logic :)
- so you need service or tool plugin. See info on forum or in wiki
- if service you have command, if tool you can register it as tool
- then get current word
- the find all of this word in current document
- if positions do not fit to current -> not used
- some extra logic.
- use output or alert to show results
- if not current word, search with regexp for all var(\w+): and loop through them as for current word.

there is no good api description yet (will come in wiki) but you can check hejs_spec for commands.