Author Topic: Finding unused variables  (Read 1541 times)

Offline scunliffe

  • Registered User
  • Newbie
  • *
  • Posts: 15
  • Karma: +0/-0
    • View Profile
Finding unused variables
« on: September 06, 2012, 02: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: 2170
  • Karma: +37/-3
    • View Profile
    • HippoEDIT
Re: Finding unused variables
« Reply #1 on: September 06, 2012, 11:59:08 pm »
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.

 

Related Topics

  Subject / Started by Replies Last post
2 Replies
1297 Views
Last post March 04, 2009, 04:08:47 pm
by Arthur
16 Replies
5342 Views
Last post April 15, 2009, 10:03:58 pm
by allen