• Packages
  • Themes
  • Documentation
  • Blog
  • Discuss
Sign in

refactor

Refactoring support
hax
67,032
117
  • Repo
  • Bugs
  • Versions
  • License
Flag as spam or malicious

Refactor Package

Greenkeeper badge

Let's refactor code! With this package, you can rename the name of variables and functions easily.

capture_rename

Language Support

This package works with these language plugins. You can install using the preferences pane.

  • JavaScript: js-refactor Build Status with ES6+ support
  • CoffeeScript: coffee-refactor
  • PHP

Usage

  1. Set cursor to a symbol.
  2. Start renaming by using ctrl-alt-r.
  3. Type new name.
  4. Finish renaming by using enter or removing cursor from the focused symbol.

User Setting

  • Override keymap by using Atom > Open Your Keymap.

For example, you can override the shortcut to ctrl-alt-e

'atom-text-editor:not(.mini)':
  'ctrl-alt-r': 'unset!'
  'ctrl-alt-e': 'refactor:rename'
  • Override stylesheet by using Atom > Open Your Stylesheet.

API Documentation (for plugin developer)

package.json

Add refactor as engines in package.json.

{
  ...
  "engines": {
    "atom": ">=1.0.0",
    "refactor": ">=0.6.0"
  },
  ...
}

Interface

You should implement Ripper class in main module.

  • Ripper.scopeNames []String : [Required] Array of scope name, like 'source.coffee', 'source.js' and all that.
  • Ripper#parse(code String, callback Function) : [Required] Parse code, and you should callback when the parsing process is done. Callback specify the params as an array of error Object. The error Object should have params range and message.
  • Ripper#find(point Point) []Range : [Required] Return an array of found symbols' Range at the passed Point.
{ Range, Point } = require 'atom'
class Riper
  @scopeNames: []
  parse: (code, callback) ->
    # parse code
    callback [
      range = new Range()
      message: 'foo'
    ]
  find: (point) ->
    # find references
    [
      new Range()
      new Range()
      ...
      new Range()
    ]

Examples

  • hax/js-refactor
  • Ragg-/coffee-refactor

See

  • Changelog

I think this package is bad news.

Good catch. Let us know what about this package looks wrong to you, and we'll investigate right away.

  • Terms of Use
  • Privacy
  • Code of Conduct
  • Releases
  • FAQ
  • Contact
with by