Complete Statement, introduced in ReSharper 4.0, is a feature that inserts necessary syntax elements (braces, semicolons etc.) and gets you in position to start the next statement.
- Place the caret at an applicable position (see scenarios below for detials).
- On the main menu, choose ReSharper | Edit | Complete Statement or press Ctrl+Shift+Enter.
Complete Statement (also known as Smart Enter) is helpful in numerous scenarios, including auto-closing parentheses, adding
semicolons, completing if, while and for statements, and so on.
For example, whenever you declare a new method, Complete Statement comes handy after specifying method parameters:
At this point, to start writing the method body, you normally have to:
- Insert a missing parenthesis.
- Press Enter.
- Insert an opening brace.
- Press Enter once again.
In similar ways, Complete Statement is known to work with the following language constructs:
- Type members: class, interface, struct, enum, delegate, field, event, and method declarations.
- Statements:
if,while,do,switch,using,lock,continue,break, andreturnstatements;caseanddefaultclauses; conversion of single-line statements to block statements. - Expressions: invocation, element access, string/char literals; object, member, and collection item initializers; expressions that create anonymous types and implicitly typed arrays.
Below are a number of specific examples of the assistance that Complete Statement provides in specific contexts.
| Use case | Before Complete Statement | After Complete Statement |
|
Class declaration |
|
|
|
Delegate declaration |
|
|
|
Method declaration |
|
|
|
Nested method invocation |
|
|
|
|
|
|
|
|
|
|
|
Conversion of a single-line statement into block (case A) |
|
|
|
Conversion of a single-line statement into block (case B) |
|
|
|
Element access expression |
|
|
