View previous topic :: View next topic |
Author |
Message |
doob
Joined: 06 Jan 2007 Posts: 367
|
Posted: Mon Oct 06, 2008 7:32 am Post subject: Autocomplete a function as a property? |
|
|
Is there a way to autocomplete a function as a property? |
|
Back to top |
|
|
asterite
Joined: 01 Jun 2006 Posts: 235 Location: Buenos Aires, Argentina
|
Posted: Mon Oct 06, 2008 11:21 am Post subject: |
|
|
Yes. If you press = instead of enter when autocompleting a setter, you'll get
Check "Other tips" in http://www.dsource.org/projects/descent/wiki/Shortcuts
I can't remember well now, but I think that if you press ; when autocompleting a getter, you don't get the extra parenthesis. But I'm not sure. |
|
Back to top |
|
|
doob
Joined: 06 Jan 2007 Posts: 367
|
Posted: Tue Oct 07, 2008 4:23 am Post subject: |
|
|
It's not working for me, neither = or ; |
|
Back to top |
|
|
asterite
Joined: 01 Jun 2006 Posts: 235 Location: Buenos Aires, Argentina
|
Posted: Tue Oct 07, 2008 5:00 am Post subject: |
|
|
The ; is not working (I just tried it), but the = is definitely working. I've tried this:
Code: | class Foo {
void property(int someValue) {
}
void prop() {
}
}
void lala(Foo foo) {
foo.pro
} |
I autocomplete after foo.pro, select the item "property(int x) void - void Foo" and press = (in my keyboard, I have to do shift+0 (zero)). The result is:
Code: | void lala(Foo foo) {
foo.property = someValue
} |
Can you confirm this is not working for you in the latest nightly build? |
|
Back to top |
|
|
doob
Joined: 06 Jan 2007 Posts: 367
|
Posted: Tue Oct 07, 2008 8:36 am Post subject: |
|
|
I find the problem, if I have a return value for the property it's not working. http://www.digitalmars.com/d/1.0/property.html
Code: | struct Foo
{
int data() { return m_data; } // read property
int data(int value) { return m_data = value; } // write property
private:
int m_data;
} |
This is how the digitalmars site says how to create a property |
|
Back to top |
|
|
asterite
Joined: 01 Jun 2006 Posts: 235 Location: Buenos Aires, Argentina
|
Posted: Tue Oct 07, 2008 9:10 am Post subject: |
|
|
But... do you select the method (setter) to autocomplete, and then press "="?
For example, in the suggestions you would see:
Quote: | data() int - Foo
data(int value) void - Foo |
Now, if you have the first option highlighted and you press "=", you won't get the setter autocompleted. You have to press the down arrow key to select the second option, and there press "=".
If you want to, you can create a feature enhancment that does that: if you press "=" in a getter, you get the setter aucompleted. |
|
Back to top |
|
|
doob
Joined: 06 Jan 2007 Posts: 367
|
Posted: Tue Oct 07, 2008 3:00 pm Post subject: |
|
|
asterite wrote: | But... do you select the method (setter) to autocomplete, and then press "="? |
Yes. When I have a return value for the setter it doesn't work. Try to add a return value to the setter.
descent 0.5.3.20080925 |
|
Back to top |
|
|
asterite
Joined: 01 Jun 2006 Posts: 235 Location: Buenos Aires, Argentina
|
Posted: Tue Oct 07, 2008 10:52 pm Post subject: |
|
|
Ok, I found it. The thing is, I thought setters are:
void name(type argument);
and your setter is:
int data(int value);
I considered a setter to have a void return value.
But you are right, in the documentation it just says "a method with one argument", saying nothing about the return type. In fact, your example is here: http://digitalmars.com/d/1.0/property.html
I'll fix that for the next release. Thanks!! |
|
Back to top |
|
|
doob
Joined: 06 Jan 2007 Posts: 367
|
Posted: Wed Oct 08, 2008 4:48 am Post subject: |
|
|
I have always used setters with a return value because of that example and because of it's in the documentation there's a chance that other people will do the same.
asterite wrote: | I'll fix that for the next release. Thanks!! | Thanks |
|
Back to top |
|
|
asterite
Joined: 01 Jun 2006 Posts: 235 Location: Buenos Aires, Argentina
|
|
Back to top |
|
|
doob
Joined: 06 Jan 2007 Posts: 367
|
|
Back to top |
|
|
|