replace variable and function names?

Is there an option to "minify" Java files in Intellij?  I would like to obfuscate function and variable names in the editor (before compiling).

(I am aware this is a strange request... and I want to perform this step before compiling)

Maybe there is a plugin which can help with this?

5 comments
Comment actions Permalink

Why do you want to do this before compiling? There are plenty of tools (ProGuard, for example) that will obfuscate your class files after you compile them..

0
Comment actions Permalink

I am writing code for processing (compiles to java) and processing.js ('compiles' to JavaScript).

For processing.js I want to obfuscate and minimize my code with variable renaming.

My expirements with proguard change my files too much so that the JavaScript compiler doesn't recognize them ( even with dontoptimize flags).  Also, I have to use a decompiler to get at the source.  Given that IntelliJ can do this sort of refactoring so easily, I was hoping it might provide a solution to my problem.

Note: google closure compiler 'advanced' does not like the format of the 'compiled' JavaScript, so my attempts to minimize there have been thwarted.

0
Comment actions Permalink

It's fairly easy to write a plugin that will go through all your code and rename everything to shortened names, but I'm not aware of any existing plugin that does it.

0
Comment actions Permalink

Looks like I will write a plugin then.

This looks pertinent:
http://confluence.jetbrains.net/display/IDEADEV/Developing+Custom+Language+Plugins+for+IntelliJ+IDEA#DevelopingCustomLanguagePluginsforIntelliJIDEA-RenameRefactoring

Most plugins I've used add new dialogs/user interaction while coding.  
Is there a good example of a plugin which changes your code in one fell swoop?

Maybe a better question is where do I go for plugin development support?

0
Comment actions Permalink

This page talks about implementing a rename refactoring for a custom language, rather than about invoking the rename refactoring for Java.

The plugin development forum is at http://devnet.jetbrains.net/community/idea/open_api_and_plugin_development

0

Please sign in to leave a comment.