Context actions for JavaScript
JetBrains Rider provides the following context actions for JavaScript:
Name | Description |
---|---|
Add braces | Adds braces around if/else/for/do/while/with statement body |
Add JsDoc comments | Add JsDoc comments |
Add 'use strict' | Adds 'use strict' |
Add XML Comment Reference | Add XML comment reference to the file where the referenced symbol is declared |
Add xml-doc comments | Add xml-doc comments |
Compute constant value | Computes value of the current expression and replace it (e.g. 1 + 1 replaced by 2) |
Convert bin to dec (ES6) | Converts numeric literal from binary to decimal form |
Convert concatenation to template string | Converts string and arguments concatenation to template string |
Convert 'if' statement to ternary expression | Works on 'if' statement that returns value or performs assignment inside each branch. It converts the statement to a ternary expression ('x ? a : b') |
Convert 'if' to 'switch' | If the same expression is checked against several values for strict equality, 'if' statement may be converted to 'switch' |
Convert object literal get-accessor to simple property | Converts ECMAScript 5 get-accessor to simple property |
Convert object literal property to accessors pair with backing field | Converts object literal property to ECMAScript 5 accessors pair with backing field |
Convert object literal property to get-accessor | Converts object literal property to ECMAScript 5 get-accessor |
Convert oct to dec (ES6) | Converts numeric literal from binary to decimal form |
Convert property assignment in constructors to accessor property definition with backing field | Converts property assignment in constructors to accessor property definition via Object.defineProperty() call |
Convert property assignment in constructors to data property definition | Converts property assignment in constructors to data property definition via Object.defineProperty() call |
Convert property assignment in constructors to get-accessor property definition | Converts property assignment in constructors to get-accessor property definition via Object.defineProperty() call |
Convert ternary expression to 'if' statement | Converts ternary expression whose value is returned or assigned to an 'if' statement |
Convert to bin (ES6) | Converts numeric literal from decimal to binary form |
Convert to dec | Converts numeric literal from hexadecimal to decimal form |
Convert to dec | Converts numeric literal from octal to decimal form |
Convert to hex | Converts numeric literal from decimal to hexadecimal form |
Convert to oct | Converts numeric literal from decimal to octal form |
Converts expression lambda to block lambda with return | Converts expression lambda to block lambda with return |
Converts single-return block lambda to expression | Converts single-return block lambda to expression lambda |
Create From Usage | Creates property, function, local variable or parameter from usage For more information, see generate code from usage. |
Flip operator arguments | Flips left and right arguments for selected operator e.g. null == x to x == null. |
Flip relational expression | Flips the current relational expression e.g. x > 1 to x < 1. |
Introduce variable from expression statement | Introduces variable from expression statement |
Invert 'if' statement | Inverts guard condition of an 'if' statement and swaps the branches' code accordingly |
Invert ternary condition | Inverts condition and swaps branches of a ternary expression |
Join local variable declaration and assignment | Works on an assignment to a variable that was declared without initializer. Moves the declaration to the current point and merges it with the assignment. |
Join string literals | Concatenates two string literals into one |
Merge nested 'if' statements | Merges two nested 'if' statements to a single 'if' statement that checks conjunction of the original conditions. |
Merge two 'if' statements | Merges 'if' statement with nested 'if' statement in else branch with equal body to a single 'if' statement that checks disjunction of the original conditions. |
Negate logical expression | Negates logical expression |
Remove braces | Removes unnecessary braces around one or more statements in the code |
Remove redundant parenthesis | Removes parenthesis in case they are redundant |
Replace logical expression with equal expression | Replace logical expression with equal expression |
Replace single-quoted string literal with double-quoted | Replace single-quoted string literal with double-quoted and vice versa |
Reverse assignment statement | Reverses source and destination parts of an assignment statement. |
Split 'if' with '&&'-condition into nested 'if'-statements | Works on an 'if' statement, whose value is a conjunction ('&&') of two simpler conditions. It converts the 'if' statement into two nested 'if' statements. |
Split 'if' with '||'-condition into two 'if'-statements | Works on an 'if' statement, whose condition is a disjunction ('||') of two simpler conditions. It converts the 'if' statement into two 'if' statements with equal bodies. |
Split into separate declarations | Works on variable declaration or lexical declaration statement that declares multiple variables. It splits such statement into multiple statements each declaring a single variable. |
Split 'return' statement of boolean value to 'if' statement | Works on a 'return' statement, whose value is of the boolean type. It converts the 'return' statement into an 'if' statement with two 'return' statements, returning 'true' and 'false' values. |
Split 'return' with '&&'-condition into guarding 'if' and 'return' | Works on a 'return' statement, whose condition is a conjunction ('&&') of two simpler conditions. It converts the 'return' statement into a guarding 'if' statement and a 'return'. |
Split 'return' with '||'-condition into assignment to temporary variable, 'if'-statement and 'return' | Works on a 'return' statement, whose value is a disjunction ('||') of two simpler conditions. It converts the 'return' statement into a guarding 'if' statement and a 'return'. |
Split variable declaration and assignment | Moves variable initializer from declaration statement to separate assignment statement. |