Recent

Author Topic: Autocomplete question while coding  (Read 4038 times)

Martin_fr

  • Administrator
  • Hero Member
  • *
  • Posts: 9794
  • Debugger - SynEdit - and more
    • wiki
Re: Autocomplete question while coding
« Reply #15 on: June 04, 2020, 02:17:56 pm »
I know as you type code in Lazarus should give an auto popup with suggestions, like typing lblDisplay.Capt should popup and show .Caption and allow you to select that to autocomplete.

You have to press ctrl space to trigger auto complete.
https://bugs.freepascal.org/view.php?id=33054

rvk

  • Hero Member
  • *****
  • Posts: 6111
Re: Autocomplete question while coding
« Reply #16 on: June 04, 2020, 03:09:34 pm »
Using the debugger you can't use the property TStringList.Count, because that involves calling a function which is currently a no-go.
It's one of the biggest downsides of using the GDB debugger. Delphi for example has a much much much more powerful debugger.

I hope that one of the newer debugger alternatives coming up, will be able to do this better.

PascalDragon

  • Hero Member
  • *****
  • Posts: 5446
  • Compiler Developer
Re: Autocomplete question while coding
« Reply #17 on: June 04, 2020, 04:12:43 pm »
Using the debugger you can't use the property TStringList.Count, because that involves calling a function which is currently a no-go.
It's one of the biggest downsides of using the GDB debugger. Delphi for example has a much much much more powerful debugger.

I hope that one of the newer debugger alternatives coming up, will be able to do this better.

As I've highlighted in my post any debugger faces these challenges. And GDB can in principle call functions.

rvk

  • Hero Member
  • *****
  • Posts: 6111
Re: Autocomplete question while coding
« Reply #18 on: June 04, 2020, 04:27:01 pm »
Then Delphi has done a wonderful job to overcome those challenges  8)

Martin_fr

  • Administrator
  • Hero Member
  • *
  • Posts: 9794
  • Debugger - SynEdit - and more
    • wiki
Re: Autocomplete question while coding
« Reply #19 on: June 04, 2020, 05:08:03 pm »
It's one of the biggest downsides of using the GDB debugger. Delphi for example has a much much much more powerful debugger.

It is a lot more complex:

- FPC writes DWARF (or the older stabs).
DWARF does not have the concept of a property. At least last time I checked, maybe some newer version has....

So Fpc does not include the info that there is a property (or anything of that name).
The exception is "property Foo : TType read FFoo;" => direct field access. Fpc pretends that "Foo" is a field, not a property.

- Method calls
That is something that we can address (not yet done, but no more big hurdles, other than time)


Assuming we can do method calls, and assuming that we find some way, how FPC can tell the debugger: there is something under the name of that property.....
There is at least one more issue.

We could then call
SomeList.GetCount  and SomeList.SetCount(cnt)

But
SomeList.GetString
is still an issue.
Strings and arrays are managed types. If the debugger calls that method the ref count is increased. And never released. Still do-able, it would create a memleak.In extremely rare cases change the flow of the application.

SomeList.SetString(val)
The debugger can not create "val" because it must set a refcount, and there is no info how to do that.

Both can be addressed by some pretty vile hacks.
But keeping in mind, that detecting a "string" is already relying on hacks (because dwarf has no type for that either, it is either pchar, or array of char), basing yet more hacks on it..... crumble.


And then I need to check, if currently there is a way to detect virtual and overriden methods. I do not know, I have not checked if that is part of the debug info....




Having said all that, its still something that is on the list.
Most of it requires changes in fpc (writing some info about the property). So most of it cannot be done with fpc 3.2.


Martin_fr

  • Administrator
  • Hero Member
  • *
  • Posts: 9794
  • Debugger - SynEdit - and more
    • wiki
Re: Autocomplete question while coding
« Reply #20 on: June 04, 2020, 05:34:06 pm »
When it comes to TStringList, you can watch (to get the string items)

Code: Pascal  [Select][+][-]
  1. (MyStringList.FLIST)^[0]

If you use FpDebug, you can use the debug inspector, and double click each item. You only need to add the "[0]" at the end.

Make sure to use dwarf or better dwarf3 (dwarf3 is save to be used with fpdebug)

darkcyber

  • Newbie
  • Posts: 4
Re: Autocomplete question while coding
« Reply #21 on: June 05, 2020, 03:01:18 am »
Thanks! I followed the link, but didn't see anything that tells how to turn it on/off. Maybe I'm just overlooking it.

I know as you type code in Lazarus should give an auto popup with suggestions, like typing lblDisplay.Capt should popup and show .Caption and allow you to select that to autocomplete. For some reason, mine isn't doing this. I'm having to manually type in all the code, which isn't a big deal, but would like to have that shortcut if I could. I am using the version I downloaded directly from larazus-ide.org, the 32 bit, 2.0.8 version, if that helps.

Thanks!

https://wiki.freepascal.org/IDE_Window:_Editor_Options_Completion_Hints

Martin_fr

  • Administrator
  • Hero Member
  • *
  • Posts: 9794
  • Debugger - SynEdit - and more
    • wiki
Re: Autocomplete question while coding
« Reply #22 on: June 05, 2020, 03:04:28 am »
Thanks! I followed the link, but didn't see anything that tells how to turn it on/off. Maybe I'm just overlooking it.

If you type
  Form1.capt
and then hit ctrl-space, that will open the suggestions.

If you type
  Form1.
and wait 1 second (only directly after typing the ".") that will also do.

PascalDragon

  • Hero Member
  • *****
  • Posts: 5446
  • Compiler Developer
Re: Autocomplete question while coding
« Reply #23 on: June 05, 2020, 09:18:04 am »
- FPC writes DWARF (or the older stabs).
DWARF does not have the concept of a property. At least last time I checked, maybe some newer version has....

Maybe we should introduce Vendor Specific Tags for Free Pascal. Those will also work with older versions. Though of course you can't solely rely on GDB then as that doesn't provide you with the necessary debug information.

Assuming we can do method calls, and assuming that we find some way, how FPC can tell the debugger: there is something under the name of that property.....
There is at least one more issue.

We could then call
SomeList.GetCount  and SomeList.SetCount(cnt)

I think as a first step simply calling getters would be enough to satisfy a majority of the needs.

But
SomeList.GetString
is still an issue.
Strings and arrays are managed types. If the debugger calls that method the ref count is increased. And never released. Still do-able, it would create a memleak.In extremely rare cases change the flow of the application.

The debugger (interface) would need to know that it's dealing with a managed type and call FPC_FINALIZE accordingly.

Most of it requires changes in fpc (writing some info about the property). So most of it cannot be done with fpc 3.2.

But we can try to get it working with FPC 3.3.1, so that the next major release can support all this.

Martin_fr

  • Administrator
  • Hero Member
  • *
  • Posts: 9794
  • Debugger - SynEdit - and more
    • wiki
Re: Autocomplete question while coding
« Reply #24 on: June 06, 2020, 05:20:34 pm »
I know as you type code in Lazarus should give an auto popup with suggestions, like typing lblDisplay.Capt should popup and show .Caption and allow you to select that to autocomplete.

You have to press ctrl space to trigger auto complete.
https://bugs.freepascal.org/view.php?id=33054
The issue has been updated, and the new functionality will be available in Lazarus 2.2, once released.

Martin_fr

  • Administrator
  • Hero Member
  • *
  • Posts: 9794
  • Debugger - SynEdit - and more
    • wiki
Re: Autocomplete question while coding
« Reply #25 on: June 06, 2020, 05:21:10 pm »
But we can try to get it working with FPC 3.3.1, so that the next major release can support all this.
I will be in contact, when I get to look closer at it.

PascalDragon

  • Hero Member
  • *****
  • Posts: 5446
  • Compiler Developer
Re: Autocomplete question while coding
« Reply #26 on: June 06, 2020, 08:33:12 pm »
Okay. :)

 

TinyPortal © 2005-2018