• Stars
    star
    213
  • Rank 184,755 (Top 4 %)
  • Language
    JavaScript
  • Created over 11 years ago
  • Updated almost 8 years ago

Reviews

There are no reviews yet. Be the first to send feedback to the community and the maintainers!

Repository Details

A Sublime Text Refactor Plugin for Javascript Code

Javascript Refactor plugin for Sublime Text 2 and 3

[![Package Control](https://packagecontrol.herokuapp.com/downloads/JavaScript%20Refactor.svg?color=50C32E)](https://packagecontrol.io/packages/JavaScript%20Refactor) [![Donate](http://s-a.github.io/donate/donate.svg)](http://s-a.github.io/donate/)

Overview

  • Goto definition of a variable or function
  • Rename variable or function respecting its current scope
  • Introduce variable
  • Extract selected source to a new method

Preview

http://www.youtube.com/watch?v=P9K7mxWItPw

Installation

Use the Sublime Package Control and search for: "JavaScript Refactor"
or
Clone or download the git repository into your packages folder. In Sublime Text use "Preferences/Browse Packages" menu item to open this folder. The shorter way of doing this is:

Linux

git clone https://github.com/s-a/sublime-text-refactor.git ~/.config/sublime-text-2/Packages/sublime-text-refactor

Mac

git clone https://github.com/s-a/sublime-text-refactor.git ~/Library/Application\ Support/Sublime\ Text\ 2/Packages/sublime-text-refactor

Windows

In an elevated command prompt or powershell (as Admin): git clone https://github.com/s-a/sublime-text-refactor.git "%APPDATA%\Sublime Text 2\Packages\sublime-text-refactor" for Sublime Text 3: git clone https://github.com/s-a/sublime-text-refactor.git "%APPDATA%\Sublime Text 3\Packages\sublime-text-refactor"

Dependencies

  • This Plugin makes heavy usage of Node.js. So it needs a local installation of http://nodejs.org
  • mocha (only for testing)

Usage

Goto Definition:
Select a keyword via double click or point the cursor to the keyword and choose "Goto Definition" from context menu.

Rename:
Select a keyword via double click or point the cursor to the keyword and choose "Rename" from context menu. The plugin will select all variables or function calls occurring in the source code including its declaration. After that you rename them all on the fly. The logic respects the variables or functions scope. So it should be safe to rename them all without thinking ;) .

Introduce Variable:
Select an Expression from source code or point the cursor to the desired position and choose "Introduce Variable" from context menu.

Extract Method:
Select the source code you want to extract into a new method and choose "Refactor / Extract methode" from context menu. This will extract the source code instantly to a new methode aka function. The plugin will manage undeclared variable usages and pass them within a single bundled JSON parameter to the new function. It also generates a sample function call at the bottom of the new methode. The plugin marks all variables occurring in the source code so you can rename them on the fly.

Run the tests

Goto Pluginfolder and type npm test

You can find current test cases here
https://github.com/s-a/sublime-text-refactor/blob/master/js/test/

Troubleshoot

  • Node not found
  • Choose Preferences: Refactor Settings – User from context menu and configure the nodePath setup. (Default Value is node)
	"nodePath" : "node"
}```


Todo
========================
- ***Extract method***  
- Define exceptions of global scoped variable names like jQuery or $.
- Do not pass variables available in current Scope (optional).
- Let the user choose a function name before or after extraction.
- Let the user choose a custom position to insert extracted methode code and indent it correctly.


License
=======


MIT and GPL license.

Copyright (c) 2013 Stephan Ahlf <[email protected]>

Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the "Software"), to deal in the Software without restriction, including without limitation the rights to use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the Software, and to permit persons to whom the Software is furnished to do so, subject to the following conditions:

The above copyright notice and this permission notice shall be included in all copies or substantial portions of the Software.

THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.

More Repositories

1

iron-node

Debug Node.js code with Chrome Developer Tools.
JavaScript
2,330
star
2

sonic-sound-picture

Sonic Sound Picture (SSP) is a free, offline, and customizable music/audio visualizer software. With a range of templates to choose from, users can easily create stunning audio-visual experiences in just a few simple steps. SSP also allows users to create their own templates, giving them endless possibilities to bring their music to life.
JavaScript
221
star
3

deep-autofill-chrome-extension

✒️ Auto fill out forms done right.
JavaScript
121
star
4

digital-numbers-font

A fixed width (web)font in a cool liquid-crystal display (LCD) style.
HTML
100
star
5

iso-8583

💳 A native Node module to process ISO 8583 Financial transaction card originated messages
C
76
star
6

TRY.js

A realtime coding environment to try JavaScript
JavaScript
68
star
7

electron-toaster

A simple desktop notification for electron apps
JavaScript
55
star
8

package.js

a simple package (auto) loader for node.js apps which supports NPM or other package managers.
JavaScript
53
star
9

ToBlender

Use any external text editor with Blender 🐵
Python
42
star
10

socketio-terminal

⚙️ A client server module which acts like SSH but communicates via socket.io.
JavaScript
31
star
11

jQuery.readMore

Adds a read more link to an HTML element respecting it height and width
JavaScript
30
star
12

muenchhausen

Produce authentic fake data
JavaScript
21
star
13

simplify-string

Create a primitive representation of a string
JavaScript
20
star
14

time-track

A time-tracking commandline app.
JavaScript
16
star
15

visual-studio-keyboard-like-sublime-text

A set up for MS Visual Studio shortcuts close to the Sublime Text
16
star
16

license

Central permanent hosted license details under your control
JavaScript
14
star
17

motivation

💟 motivation? - ↪️ ready to contribute!?
JavaScript
13
star
18

scream-js

a command line app which specializes in modifying images and delivering static image and css files
JavaScript
12
star
19

sample-db

A collection of open source samples in wave format
JavaScript
11
star
20

n-cli

A bundle of tools to develop node commandline applications
JavaScript
11
star
21

crunsh-single-page

npm i -g crunsh-single-page
JavaScript
10
star
22

cronus

Schedules custom monitoring jobs and serves a socket.io connected monitoring website.
JavaScript
9
star
23

monitor

JavaScript
9
star
24

user-appdata

JavaScript
9
star
25

look-at-this

A very simple collection and lib of social sharing channels
JavaScript
8
star
26

time-controller

⌚ Control timers in JavaScript
HTML
7
star
27

progress-info

determine long running progress status.
JavaScript
7
star
28

ntcc

JavaScript
6
star
29

flying-panda

Quick serve a folder without headache
JavaScript
6
star
30

iron-node-zerodarkmatrix-theme

A Theme For https://github.com/s-a/iron-node
JavaScript
6
star
31

electron-recompile

re-compile native modules against electron
JavaScript
6
star
32

hnc

just another hacker news console client
JavaScript
4
star
33

visual-studio-code-keyboard-like-sublime-text

4
star
34

chartio

Plot serial chart data to an image and save it to filesystem from shell.
4
star
35

jsDrums

JavaScript
4
star
36

clash-of-clans-unit-levels

JSON data that informs about maximum unit levels per townhall. (spells, troops, heroes)
JavaScript
4
star
37

muenchhausen-client

Produce authentic fake mockup data
JavaScript
4
star
38

discord-shell-slave

🌐 A discord shell client which posts piped shell data to specified guild and channel
JavaScript
4
star
39

channel.try.js

The TRY.js Example Source Code Channel
JavaScript
3
star
40

octo-space-wars

A Web GL Octo "spaceWarSimulation"
JavaScript
3
star
41

jQuery-flyTo-Plugin

JavaScript
3
star
42

iron-node-process-exit-break

Adds a break-point to process.exit
JavaScript
3
star
43

sa-simple-apn

A very simple way to create Apple Push Notifications
JavaScript
3
star
44

nmp

Support different runtime versions of native modules
JavaScript
3
star
45

browserwall

A small, fast and rich-API browser/platform/engine detector for React.
JavaScript
3
star
46

node-translation-validator

Mocha testsuite generator to identify keys in multilanguage dictionaries and compare them to used keys in templateStrings and vice versa
JavaScript
3
star
47

easy-ssp

Blender Utility addon to create stunning Sonic Sound Picture (SSP) templates
Python
3
star
48

creative-software

What software you use to be creative?
3
star
49

ppkey

JavaScript
2
star
50

deep-js

Documenting JavaScript
JavaScript
2
star
51

fake-require-main

Fakes require.main for debug and testing purposes.
JavaScript
2
star
52

examples.try.js

TRY.js Source Code Examples
JavaScript
2
star
53

hex-board-game

JavaScript
2
star
54

beatproducer

a beat producer environment for browsers
HTML
2
star
55

cultures

A json list with global culture and region informations.
2
star
56

BlockBuster

BlockBuster is a Blender addon that allows you to quickly and easily inspect the size of your Blender datablocks, including meshes, textures, materials, and more. With BlockBuster, you can identify and optimize the largest datablocks in your scene to improve performance and reduce memory usage.
Python
2
star
57

e-d-t-e-t

electron-dev-tools-extension-test
JavaScript
1
star
58

you-might-not-need-gulp

This is a list of npm scripts which should replace gulp.js jobs decorated with a small example.
1
star
59

blender-location

Returns the location of Blender executable for various operating systems
JavaScript
1
star
60

sys-hub

A starting point or base for some activity
JavaScript
1
star
61

reverse-proxy-starter

JavaScript
1
star
62

elephant

JavaScript
1
star
63

node-prompt-here

Open a console window at a given absolute directory
JavaScript
1
star
64

qwmi

❔ Query Windows Management Instrumentation from shell and output JSON data
JavaScript
1
star
65

donate

HTML
1
star
66

a-node-module

JavaScript
1
star
67

sjs

C#
1
star
68

wikix

Filter Wikipedia Xml dumps
C#
1
star
69

SignalInputProcessings

Implementation of "Smoothed zero-score alogrithm" in Delphi
Pascal
1
star
70

beatproducer-projects

The beatproducer project channel
JavaScript
1
star
71

six-proto

just a prototype hex grid
JavaScript
1
star
72

keys

https://github.com/brhs/nomouse for windows
C#
1
star
73

3proto

JavaScript
1
star
74

color-schemer

HTML
1
star
75

theme-roller-js

JavaScript
1
star
76

dot-net-filesystemwatch-experiment

C#
1
star
77

ydel

JavaScript
1
star
78

auto-hot-key-windows-media

An (compiled) AHK script for Micosoft Windows to control media from keyboard
AutoHotkey
1
star
79

video-datetime-stamp

Render a date/time stamp into videos using ffmpeg
JavaScript
1
star
80

sa-serialnumber

JavaScript
1
star
81

mocha-soap-service-test-boilerplate

JavaScript
1
star
82

watch-input

watch an input textbox for changes. usefull to provide auto-suggest things of the web
JavaScript
1
star
83

xcmd

Downloads
JavaScript
1
star
84

sqlanywhere-json-remote-webservice

A Sybase Sql Anywhere Json Remote Zombie Webservice.
JavaScript
1
star