Property generation?

Not all properties are backed by simple fields.

When you type something like this:

public string foo() {

and then hit Enter, the closing brace is added and the cursor is placed for
you to properly type the body of the method call. It'd be nice if something
like this could work with properties too... in other words, if you type
this:

public string foo {

and press enter, it would be nice if it did this for you ( "|" is the
location fo the cursor):

public string foo
{
get
{
|
}
set
{

}
}

(and pressing tab would move you from the getter to the setter body, and tab
again would exit... or something nice like that). Of course, it should
conform to whatever coding style/standards you've set up as far as brace
placement, etc.

Would something like this be possible in 2.0?


10 comments
Comment actions Permalink

Actually it seems to me this functionality can be easily achieved with Live Templates.

0
Comment actions Permalink

Nice idea! But what if the user wants only getter? He will need to manually
erase setter in this case and this can be annoying.

Valentin Kipiatkov
Chief Scientist, Vice President of Product Development
JetBrains, Inc
http://www.jetbrains.com
"Develop with pleasure!"

Not all properties are backed by simple fields.

When you type something like this:

public string foo() {

and then hit Enter, the closing brace is added and the cursor is
placed for you to properly type the body of the method call. It'd be
nice if something like this could work with properties too... in other
words, if you type this:

public string foo {

and press enter, it would be nice if it did this for you ( "|" is the
location fo the cursor):

public string foo
{
get
{
|
}
set
{
}
}
(and pressing tab would move you from the getter to the setter body,
and tab again would exit... or something nice like that). Of course,
it should conform to whatever coding style/standards you've set up as
far as brace placement, etc.

Would something like this be possible in 2.0?



0
Comment actions Permalink

Valentin Kipiatkov (JetBrains) wrote:

Nice idea! But what if the user wants only getter? He will need to
manually erase setter in this case and this can be annoying.


Why not show the nice lightbulb with an option to put a getter, a setter
or both? That solves the problem and still allows to generate the rest
of the property.

Coderush dos this differently, they have templates for these options, so
if you type set the rest is gerenated automatically and if you type get the same is done for the getter. Alternatively you can just type pb]]> (property bool) and a complete propetry including
backer is generated. I use this a lot. It's easier and faster to use
than the generate propety funtion of Resharper.

Jesse


Valentin Kipiatkov
Chief Scientist, Vice President of Product Development
JetBrains, Inc
http://www.jetbrains.com
"Develop with pleasure!"

>> Not all properties are backed by simple fields.
>>
>> When you type something like this:
>>
>> public string foo() {
>>
>> and then hit Enter, the closing brace is added and the cursor is
>> placed for you to properly type the body of the method call. It'd be
>> nice if something like this could work with properties too... in other
>> words, if you type this:
>>
>> public string foo {
>>
>> and press enter, it would be nice if it did this for you ( "|" is the
>> location fo the cursor):
>>
>> public string foo
>> {
>> get
>> {
>> |
>> }
>> set
>> {
>> }
>> }
>> (and pressing tab would move you from the getter to the setter body,
>> and tab again would exit... or something nice like that). Of course,
>> it should conform to whatever coding style/standards you've set up as
>> far as brace placement, etc.
>>
>> Would something like this be possible in 2.0?
>>


0
Comment actions Permalink

Why not show the nice lightbulb with an option to put a getter, a setter

or both? That solves the problem and still allows to generate the rest

of the property.


I second this motion! Simple, elegant solution. I'd like to see a
customizable default behavior, though, since I think the majority of
properties use both getters and setters. I'd rather not have to use an
unnecessary mouse motion every time.


0
Comment actions Permalink

Personally, I wouldn't find that nearly as annoying as having to set up the
scaffolding myself ;)

Particularly because over 90% of the properties I write are read/write.
Maybe this could be an option?

"Valentin Kipiatkov (JetBrains)" <valentin@jetbrains.com> wrote in message
news:3fdb29a6827428c74f7143e3f30c@news.intellij.net...

Nice idea! But what if the user wants only getter? He will need to
manually erase setter in this case and this can be annoying.

>

Valentin Kipiatkov
Chief Scientist, Vice President of Product Development
JetBrains, Inc
http://www.jetbrains.com
"Develop with pleasure!"

>
>> Not all properties are backed by simple fields.
>>
>> When you type something like this:
>>
>> public string foo() {
>>
>> and then hit Enter, the closing brace is added and the cursor is
>> placed for you to properly type the body of the method call. It'd be
>> nice if something like this could work with properties too... in other
>> words, if you type this:
>>
>> public string foo {
>>
>> and press enter, it would be nice if it did this for you ( "|" is the
>> location fo the cursor):
>>
>> public string foo
>> {
>> get
>> {
>> |
>> }
>> set
>> {
>> }
>> }
>> (and pressing tab would move you from the getter to the setter body,
>> and tab again would exit... or something nice like that). Of course,
>> it should conform to whatever coding style/standards you've set up as
>> far as brace placement, etc.
>>
>> Would something like this be possible in 2.0?
>>
>



0
Comment actions Permalink

I suggested creating a "live template" as a work-around for now, but it'd be
nice if this were in the core editor in some way, rather than having to have
each developer manually come up with some solution, each one possibly
different...

"Maxim Babenko" <mab@shade.msu.ru> wrote in message
news:18467967.1120477720100.JavaMail.itn@is.intellij.net...

Actually it seems to me this functionality can be easily achieved with
Live Templates.



0
Comment actions Permalink

Hello Jesse,

Valentin Kipiatkov (JetBrains) wrote:

>> Nice idea! But what if the user wants only getter? He will need to
>> manually erase setter in this case and this can be annoying.
>>

Why not show the nice lightbulb with an option to put a getter, a
setter or both? That solves the problem and still allows to generate
the rest of the property.


This functionality is already implemented in 2.0.

Thanks,
Andrey Simanovsky


0
Comment actions Permalink

But does that work when there is no simple field underlying the property?
How does one invoke this lightbulb? Just curious.

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

Hello Jesse,

>
>> Valentin Kipiatkov (JetBrains) wrote:
>>
>>> Nice idea! But what if the user wants only getter? He will need to
>>> manually erase setter in this case and this can be annoying.
>>>
>> Why not show the nice lightbulb with an option to put a getter, a
>> setter or both? That solves the problem and still allows to generate
>> the rest of the property.
>

This functionality is already implemented in 2.0.

>

Thanks,
Andrey Simanovsky

>



0
Comment actions Permalink

Hello Paul,

It is a quick fix on an error of missing accessors. It is invoked through
Alt+Enter as other quick fixes.

But does that work when there is no simple field underlying the
property? How does one invoke this lightbulb? Just curious.

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

>> Hello Jesse,
>>
>>> Valentin Kipiatkov (JetBrains) wrote:
>>>
>>>> Nice idea! But what if the user wants only getter? He will need to
>>>> manually erase setter in this case and this can be annoying.
>>>>
>>> Why not show the nice lightbulb with an option to put a getter, a
>>> setter or both? That solves the problem and still allows to generate
>>> the rest of the property.
>>>
>> This functionality is already implemented in 2.0.
>>
>> Thanks,
>> Andrey Simanovsky
Thanks,
Andrey Simanovsky


0
Comment actions Permalink

Could you please submit request into the Tracker?

Valentin Kipiatkov
Chief Scientist, Vice President of Product Development
JetBrains, Inc
http://www.jetbrains.com
"Develop with pleasure!"

Personally, I wouldn't find that nearly as annoying as having to set
up the scaffolding myself ;)

Particularly because over 90% of the properties I write are
read/write. Maybe this could be an option?

"Valentin Kipiatkov (JetBrains)" <valentin@jetbrains.com> wrote in
message news:3fdb29a6827428c74f7143e3f30c@news.intellij.net...

>> Nice idea! But what if the user wants only getter? He will need to
>> manually erase setter in this case and this can be annoying.
>>
>> Valentin Kipiatkov
>> Chief Scientist, Vice President of Product Development
>> JetBrains, Inc
>> http://www.jetbrains.com
>> "Develop with pleasure!"
>>> Not all properties are backed by simple fields.
>>>
>>> When you type something like this:
>>>
>>> public string foo() {
>>>
>>> and then hit Enter, the closing brace is added and the cursor is
>>> placed for you to properly type the body of the method call. It'd
>>> be nice if something like this could work with properties too... in
>>> other words, if you type this:
>>>
>>> public string foo {
>>>
>>> and press enter, it would be nice if it did this for you ( "|" is
>>> the location fo the cursor):
>>>
>>> public string foo
>>> {
>>> get
>>> {
>>> |
>>> }
>>> set
>>> {
>>> }
>>> }
>>> (and pressing tab would move you from the getter to the setter body,
>>> and tab again would exit... or something nice like that). Of
>>> course,
>>> it should conform to whatever coding style/standards you've set up
>>> as
>>> far as brace placement, etc.
>>> Would something like this be possible in 2.0?
>>>


0

Please sign in to leave a comment.