LiveTemplates

I've created a LiveTemplate, and I'm having a minor issue that I'd like your
input on...

I have a template uses a "Suggest variable of type..." macro. I've
specified the type as "MyType".

The live template works great when there is a variable of that type in
scope. But the problem is when there isn't a variable of that type in
scope. What I WANT to happen is for it to default to the this.MyType
property on the current object. Since on all my objects that I'd use this
live template on, the property is named "MyType", I'd be fine with just
being able to specify a default value if no local variable is found. But
instead of putting "MyType" in the expansion, it puts "mytype". Which means
I always have to re-type it.

I'd love to see it either keep the case of the type (i.e. put "MyType" in
instead of lower-casing the specified type and putting in "mytype"), allow
me to specify a literal string as a default, or have the macro expand its
search to include this.]]> properties, and after that, class
fields.

Thanks!





2 comments
Comment actions Permalink

Hello Paul,

When ReSharper is unable to find appropriate variable it tries to invent
a local variable name from the name of the type. Unfortunately, at present
there is no way to configure the default name for the variable. To lessen
the amout of typing you can try the following workaround. When the template
field is selected press Ctrl+left arrow to jump to the beginnig of the variable
name, change the first letter to uppercase, and use either "Create property"
quick fix if property exists or smart-completion otherwise.
Could you post the request that "Suggest variable of type..." macro should
suggest property names into the tracker?

I've created a LiveTemplate, and I'm having a minor issue that I'd
like your input on...

I have a template uses a "Suggest variable of type..." macro. I've
specified the type as "MyType".

The live template works great when there is a variable of that type in
scope. But the problem is when there isn't a variable of that type in
scope. What I WANT to happen is for it to default to the this.MyType
property on the current object. Since on all my objects that I'd use
this live template on, the property is named "MyType", I'd be fine
with just being able to specify a default value if no local variable
is found. But instead of putting "MyType" in the expansion, it puts
"mytype". Which means I always have to re-type it.

I'd love to see it either keep the case of the type (i.e. put "MyType"
in instead of lower-casing the specified type and putting in
"mytype"), allow me to specify a literal string as a default, or have
the macro expand its search to include this.<ProprtyName> properties,
and after that, class fields.

Thanks!

Thanks,
Andrey Simanovsky


0
Comment actions Permalink

Done. Thanks!

"Andrey Simanovsky (JetBrains)" <ands@intellij.com> wrote in message
news:35077632502272598642588@news.intellij.net...

Hello Paul,

>

When ReSharper is unable to find appropriate variable it tries to invent a
local variable name from the name of the type. Unfortunately, at present
there is no way to configure the default name for the variable. To lessen
the amout of typing you can try the following workaround. When the
template field is selected press Ctrl+left arrow to jump to the beginnig
of the variable name, change the first letter to uppercase, and use either
"Create property" quick fix if property exists or smart-completion
otherwise.
Could you post the request that "Suggest variable of type..." macro should
suggest property names into the tracker?

>
>> I've created a LiveTemplate, and I'm having a minor issue that I'd
>> like your input on...
>>
>> I have a template uses a "Suggest variable of type..." macro. I've
>> specified the type as "MyType".
>>
>> The live template works great when there is a variable of that type in
>> scope. But the problem is when there isn't a variable of that type in
>> scope. What I WANT to happen is for it to default to the this.MyType
>> property on the current object. Since on all my objects that I'd use
>> this live template on, the property is named "MyType", I'd be fine
>> with just being able to specify a default value if no local variable
>> is found. But instead of putting "MyType" in the expansion, it puts
>> "mytype". Which means I always have to re-type it.
>>
>> I'd love to see it either keep the case of the type (i.e. put "MyType"
>> in instead of lower-casing the specified type and putting in
>> "mytype"), allow me to specify a literal string as a default, or have
>> the macro expand its search to include this. properties, >> and after that, class fields. >> >> Thanks! >>]]>

Thanks,
Andrey Simanovsky

>



0

Please sign in to leave a comment.