rename

A code renaming tool for Haxe
https://github.com/HaxeCheckstyle/haxe-rename

To install, run:

haxelib install rename 3.0.1 

See using Haxelib in Haxelib documentation for more information.

README.md

Haxe rename

Haxe-Rename codecov

a work-in-progress renaming tool for Haxe code.

CAUTION: Make sure you have backups before performing any rename operations!

Note: renaming uses static code analysis to figure out what places to change in a rename operation. if you make heavy use of type inference you might end up with compile errors.

features

  • move a file to a different package
  • rename an import alias
  • rename a type
  • rename a function parameter
  • rename a local var
  • rename a local function
  • remame a case capture
  • rename module level statics
  • rename interface fields
  • rename class fields
  • rename enum fields
  • rename anon struct fields (limited to object literals)

usage

Haxe Rename 1.0.0
[-s | --source] <path> : file or directory with .hx files (multiple allowed)
[-l] <location>        : location (path + filename and byte offset from beginning of file) of identifier to rename - <src/pack/Filename.hx@123>
[-n] <newName>         : new name for all occurences of identifier
[-x]                   : perform renaming operations
[--i-have-backups]     : you have a backup and you really, really want to rename
[-h | --help]          : display list of options

dry run

node bin/rename.js -s src -s test -l src/refactor/Refactor.hx@108 -n Rename

test/refactor/TestBase.hx
* replace text with "refactor.Rename" @48-65
--- import refactor.Refactor;
+++ import refactor.Rename;
* replace text with "Rename" @993-1001
---             var result:RefactorResult = Refactor.refactor({
+++             var result:RefactorResult = Rename.refactor({
src/refactor/Refactor.hx
* rename to "src/refactor/Rename.hx"
* replace text with "Rename" @348-356
--- class Refactor {
+++ class Rename {
src/refactor/Cli.hx
* replace text with "Rename" @2743-2751
---             var result:RefactorResult = Refactor.refactor({
+++             var result:RefactorResult = Rename.refactor({

danger zone

node bin/rename.js -s src -l path/pack/FileName.hx@600 -n newName -x --i-have-backups

compile

npm install
lix download
haxe build.hxml
Contributors
AlexHaxe
Version
3.0.1
Published
2 months ago
License
MIT

All libraries are free

Every month, more than a thousand developers use Haxelib to find, share, and reuse code — and assemble it in powerful new ways. Enjoy Haxe; It is great!

Explore Haxe

Haxe Manual

Haxe Code Cookbook

Haxe API documentation

You can try Haxe in the browser! try.haxe.org

Join us on GitHub!

Haxe is being developed on GitHub. Feel free to contribute or report issues to our projects.

Haxe on GitHub