Recent

Author Topic: Code/identifier completion  (Read 9168 times)

SymbolicFrank

  • Hero Member
  • *****
  • Posts: 1313
Code/identifier completion
« on: December 12, 2017, 03:45:44 pm »
I just installed trunk (win 64), and I'm probably doing something wrong, but code and identifier completion stopped working.

I made a simple class, with only a constructor and destructor, pressed Shift+Ctrl+c and it worked as expected. I changed to {$mode delphi} for the generics, added a lot more stuff and it stopped working.

Ok, I had that last time as well: remove the generics and it'll work. But it didn't. It highlights the first line of the unit and gives the error: identifier not found: TObject. But it compiles and runs fine.

Does it only work in {$mode objfpc}, or am I doing something wrong?
« Last Edit: December 12, 2017, 03:47:30 pm by SymbolicFrank »

SymbolicFrank

  • Hero Member
  • *****
  • Posts: 1313
Re: Code/identifier completion
« Reply #1 on: December 12, 2017, 04:25:10 pm »
Where is TObject defined? It is in objpas.inc, which seems to be included in system.inc:

Code: Pascal  [Select][+][-]
  1. {*****************************************************************************
  2.                         Object Pascal support
  3. *****************************************************************************}
  4.  
  5. {$ifdef FPC_HAS_FEATURE_CLASSES}
  6. {$i objpas.inc}
  7. {$endif FPC_HAS_FEATURE_CLASSES}

I don't understand what happens.

bytebites

  • Hero Member
  • *****
  • Posts: 632
Re: Code/identifier completion
« Reply #2 on: December 12, 2017, 04:30:19 pm »
Here is bug report about the problem:
https://bugs.freepascal.org/view.php?id=32809

Pascal

  • Hero Member
  • *****
  • Posts: 932
Re: Code/identifier completion
« Reply #3 on: December 12, 2017, 04:36:21 pm »
Just apply the attached patch! And rebuild fpc.
laz trunk x64 - fpc trunk i386 (cross x64) - Windows 10 Pro x64 (21H2)

SymbolicFrank

  • Hero Member
  • *****
  • Posts: 1313
Re: Code/identifier completion
« Reply #4 on: December 12, 2017, 04:47:45 pm »
Thanks!

SymbolicFrank

  • Hero Member
  • *****
  • Posts: 1313
Re: Code/identifier completion
« Reply #5 on: December 12, 2017, 05:04:26 pm »
 :(

That didn't help, even after a clean and rebuild of Lazarus. But that isn't fpc, of course.

I have a bad experience with getting the source from trunk and building it (the configuration is a problem), so I use fpcupdeluxe.

This makes it hard to add controls to forms.

Thaddy

  • Hero Member
  • *****
  • Posts: 14201
  • Probably until I exterminate Putin.
Re: Code/identifier completion
« Reply #6 on: December 12, 2017, 05:43:10 pm »
The IDE and its tools are not fully prepared for generics yet.
I usually get around that - to some extend - by skipping the generics part, pressing ctrl-j, and add the generics parts as I go.
Specialize a type, not a var.

Pascal

  • Hero Member
  • *****
  • Posts: 932
Re: Code/identifier completion
« Reply #7 on: December 12, 2017, 08:12:37 pm »
Have a look in this thread http://forum.lazarus.freepascal.org/index.php/topic,39255.msg268905.html.
Especially the wiki entry and my adapted build script (ignore OPT parameter).
laz trunk x64 - fpc trunk i386 (cross x64) - Windows 10 Pro x64 (21H2)

Pascal

  • Hero Member
  • *****
  • Posts: 932
Re: Code/identifier completion
« Reply #8 on: December 13, 2017, 06:30:48 am »
The IDE and its tools are not fully prepared for generics yet.
I usually get around that - to some extend - by skipping the generics part, pressing ctrl-j, and add the generics parts as I go.

Thaddy, have you tried it lately? Mattias an i have done some bug fixing for generics in codetools. For me it works quite okay now, though it's not finished yet.
laz trunk x64 - fpc trunk i386 (cross x64) - Windows 10 Pro x64 (21H2)

Thaddy

  • Hero Member
  • *****
  • Posts: 14201
  • Probably until I exterminate Putin.
Re: Code/identifier completion
« Reply #9 on: December 13, 2017, 08:45:09 am »
Thaddy, have you tried it lately? Mattias an i have done some bug fixing for generics in codetools. For me it works quite okay now, though it's not finished yet.

I have tried it in 1.9 and it is quite satisfactory. I only tested mode delphi. Very useful now.Thanks.
Specialize a type, not a var.

SymbolicFrank

  • Hero Member
  • *****
  • Posts: 1313
Re: Code/identifier completion
« Reply #10 on: December 14, 2017, 08:48:12 am »
Have a look in this thread http://forum.lazarus.freepascal.org/index.php/topic,39255.msg268905.html.
Especially the wiki entry and my adapted build script (ignore OPT parameter).
Thanks, but with fpcdeluxe, the directory structure looks completely different.

Is it in SVN? Then I'll just reinstall it.

Well, I would prefer to be able to just build it myself, but I'm not going to spend a week figuring out how it all works.

Pascal

  • Hero Member
  • *****
  • Posts: 932
Re: Code/identifier completion
« Reply #11 on: December 14, 2017, 10:59:06 am »
I just updated the wiki http://wiki.freepascal.org/Installing_Lazarus#Compiling.2Finstalling_FPC_and_Lazarus_from_Sources_of_SVN_.28Win32.29.
You can use fpc 3.0.4 or trunk.

After getting the fpc trunk sources with TortoiseSVN apply the above patch.
laz trunk x64 - fpc trunk i386 (cross x64) - Windows 10 Pro x64 (21H2)

Eugene Loza

  • Hero Member
  • *****
  • Posts: 663
    • My games in Pascal
Re: Code/identifier completion
« Reply #12 on: December 14, 2017, 07:32:21 pm »
Pascal, thanks a lot for the patch! Worked for me too  :D
My FOSS games in FreePascal&CastleGameEngine: https://decoherence.itch.io/ (Sources: https://gitlab.com/EugeneLoza)

SymbolicFrank

  • Hero Member
  • *****
  • Posts: 1313
Re: Code/identifier completion
« Reply #13 on: December 19, 2017, 11:01:52 am »
After some testing it seems that it mostly works.

I did a full clean + build, and it compiles and runs fine. But as soon as you do Ctrl+Space and there is no identifier completion available (no member starting with those chars), everything breaks again. If you press Ctrl+Space+C at that point, even after you commented or fixed the line with the wrong identifier, all the members are regenerated. So, you have two of everything.

A clean + rebuild (after fixing the code) seems to make it work again.

And I'm not sure if the bug that owned components sometimes aren't created or destroyed is related to this, or that it is something else.


Edit: now it keeps giving: "Error: end of source not found."

Edit2: Restarting Lazarus fixed it.
« Last Edit: December 19, 2017, 11:13:42 am by SymbolicFrank »

SymbolicFrank

  • Hero Member
  • *****
  • Posts: 1313
Re: Code/identifier completion
« Reply #14 on: July 02, 2018, 05:24:25 pm »
This bug is still present in trunk.

If you remove all empty lines inside code blocks and restart Lazarus, it seems to go away.

 

TinyPortal © 2005-2018