The idea is to prevent caret jumps backwards while typing C# code, see it in action.
This plugin is available in ReSharper 8.0 Extension Manager gallery.
ReSharper 7.1 version is available for download here.
Currently available templates:
.arg
– helps surround argument with invocationMethod(expr)
.await
– awaits expression with C# await keywordawait expr
.cast
– surrounds expression with cast(SomeType) expr
.null
– checks nullable expression to be nullif (expr == null)
.notnull
– checks expression to be non-nullif (expr != null)
.foreach
– iterates over collectionforeach (var x in expr)
.for
– surrounds with loopfor (var i = 0; i < expr.Length; i++)
.forr
– reverse loopfor (var i = expr.Length; i >= 0; i--)
.if
– checks boolean expression to be trueif (expr)
.ifnot
– checks boolean expression to be falseif (!expr)
.not
– negates value of inner boolean expression!expr
.field
– intoduces field for expression_field = expr;
.prop
– introduces property for expressionProp = expr;
.var
– initialize new variable with expressionvar x = expr;
.new
– produces instantiation expression for typenew T()
.paren
– surrounds outer expression with parentheses(expr)
.parse
– parses string as value of some typeint.Parse(expr)
.return
– returns value from method/propertyreturn expr;
.typeof
– Wraps type usage with typeof-expressiontypeof(TExpr)
.switch
– produces switch over integral/string typeswitch (expr)
.yield
– yields value from iterator methodyield return expr;
.throw
– throws value of Exception typethrow expr;
.using
– surrounds disposable expressionusing (var x = expr)
.while
– uses expression as loop conditionwhile (expr)
.lock
– surrounds expression with statementlock (expr)
Template availability depends on context where code completion is executed - for example, .notnull
template
is not be available if some expression is known to be not-null value in some particular context,
.using
template will be available only on expression of IDisposable
type and so on.
You can invoke code completion one more time ("double completion" feature of ReSharper 8) and it will came up with all the postfix templates available, without any semantic filtering.
Also PostfixCompletion includes two features with the same idea:
someStr.IsNullOrEmpty
– static members of first argument type capatible available just as instance members and automatically convert call into static member callstring.IsNullOrEmpty(someStr)
obj.SomeEnumProp.EnumMember
– enum members available at values of enumeration types and when completed emits member check expressionobj.SomeEnumProp == E.EnumMember
or for flags enumerations(obj.SomeEnumProp & E.EnumMember) != 0
Options page allows to enable/disable specific templates and control braces inserion:
Feel free to post any issues or feature requests in YouTrack (use "PostfixCompletion" subsystem).
Or contact directly: alexander.shvedov[at]jetbrains.com