CoffeeScript
In this section:
Overview
PhpStorm provides CoffeeScript support. PhpStorm recognizes *.coffee
files, and allows you to edit them providing full range of coding assistance without any additional steps from your side. CoffeeScript files are marked with icon.
To run, debug, and test your code, you will need it translated into JavaScript which requires a compiler and Node.js. For more details on CoffeeScript compilation, see Compiling CoffeeScript to JavaScript.
Preparing for CoffeeScript development
- Make sure the CoffeeScript and Node.js plugins are installed and enabled. The plugins are not bundled with PhpStorm, but they can be installed from the JetBrains plugin repository as described in Installing, Updating and Uninstalling Repository Plugins and Enabling and Disabling Plugins. Once enabled, the plugins are available at the IDE level, that is, you can use them in all your PhpStorm projects.
- Download and install the Node.js runtime environment.
- Configure the Node.js interpreter in PhpStorm:
- Open the Settings / Preferences Dialog by choosing for Windows and Linux or for macOS, and click Node.js and NPM under Languages & Frameworks.
- On the Node.js and NPM page that opens, specify the location of the desired Node.js interpreter.
See Configuring Node.js Interpreters for details.
Coding assistance
CoffeeScript support includes:
- Code completion for keywords, labels, variables, parameters and functions.
- Error and syntax highlighting.
- Code formatting and folding.
- Refactoring:
- Common refactoring procedures, such as extract method, inline, rename/move, etc.
- CoffeeScript-specific refactoring procedures, such as change signature, extract parameter, extract variable.
See also Refactoring JavaScript.
- Code generation
- Generating code stubs based on file templates during file creation.
- Ability to create line and block comments (Ctrl+Slash/Ctrl+Shift+Slash).
- Navigation through source code
- Navigating with Structure View.
- (Ctrl+B).
- (Ctrl+Alt+B) from overridden method / subclassed class.
- (Ctrl+Shift+Alt+N.
- Compiling to JavaScript for further running, debugging, and testing, see Running CoffeeScript and Debugging CoffeeScript.
- Executing CoffeeScript files involves:
- Ability to preview results of CoffeeScript files compilation to JavaScript.
- Ability to launch CoffeeScript files from the context menu.
- Run/debug configuration for Node.js includes the ability to use CoffeeScript plugin.
Last modified: 28 November 2017