Skip to content

asgerf/light-refactor.js

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

76 Commits
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

Lightweight Refactoring Tools for JavaScript

Lightweight analysis tools for JavaScript, geared towards automated refactoring support.

Basic Usage

var jsb = new JavaScriptBuffer;
jsb.add(<filename>, <source code>);
var groups = jsb.renameTokenAt(<file>, <offset>);

The groups returned are of type Range[][] given the following type schema:

interface Position {
    offset: int;
    line: int;
    column: int;
}
interface Range {
    file: string;
    start: Position
    end: Position
}

Each Range[] object in the topmost array is one group of identifiers that should be renamed together.

Usage Details

For renaming local variables and labels, loading all files into the buffer is not necessary. For that reason, one may use the following approach:

jsb.add(<current file>, <source code>)
if (!jsb.canRenameLocally(<current file>, <offset>))  {
/* add all other files that should be updated */
}

For the time being, a JavaScriptBuffer object should not be reused once a rename function has been invoked.

About

No description, website, or topics provided.

Resources

License

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published

Contributors 2

  •  
  •