[Lazarus] Feature Request: more intelligent code completion

Graeme Geldenhuys mailinglists at geldenhuys.co.uk
Mon Jan 30 12:09:19 CET 2017


Hi,

I've using the Eclipse IDE for a while now, and the developer is really
spoilt with intelligent code/class completion. I'm wondering if Lazarus
IDE could benefit of some of those features too.

For example - improved (more intelligent) code completion.

I have this code:

======================================
procedure TBuildDelphiProjects.DoRun;
var
  lProjDirName: string;
  lDefFile: string; // global defaults INI file
  lFullProjFile: string;
begin
  CaseSensitiveOptions:=True;

  if HasOption('h','help') then
    WriteHelp(0)
  else if not HasOption('p','project') then
    WriteHelp(1)
  else
  begin
    FVerbose := HasOption('V','verbose');
    BuildProject.Verbose := FVerbose;    //  <-- I just typed this.
======================================


Now the BuildProject class doesn't have a Verbose property. The
TBuildDelphiProjects class does have a FVerbose field of type boolean.
So the data type of FVerbose is known, so to deduce what the missing
property "Verbose"'s data type should be is known (or should be known).

Now if I press Ctrl+Shift+C to code/class complete, Lazarus generates
the following, which has no relevance to what I typed! It doesn't even
solve the compiler error problem.

===================================
procedure TBuildDelphiProjects.DoRun;
var
  lProjDirName: string;
  lDefFile: string; // global defaults INI file
  lFullProjFile: string;
  Verbose: Boolean;              //  <---- Lazarus inserted this???
begin
  CaseSensitiveOptions:=True;

  if HasOption('h','help') then
    WriteHelp(0)
  else if not HasOption('p','project') then
    WriteHelp(1)
  else
  begin
    FVerbose := HasOption('V','verbose');
    BuildProject.Verbose := FVerbose;
===================================


It would have been a lot more logical, and to actually generate
compilable code, if Lazarus prompted me (user configurable) to say that
it wants to implement the missing property "Verbose" for the object
BuildProject (of type TBuildProject). The property simply needs to ask
what visibility do I want the Verbose property... Public of Published
(as TBuildProject is defined in another unit)?

Lazarus (v1.3 and v1.7) generated the same code as show above, and
neither is compilable afterwards! So I don't know what Lazarus was
trying to achieve by introducing that local Verbose: boolean variable.

This is the compiler output I get when I try to compile my project
before and after the code/class completion was triggered.

  builddelphiprojects.lpr(79,18) Error: identifier idents no member
"Verbose"

After using Eclipse for some time now, such shortcuts for the developer
is a massive time saver. It also works fantastically well if you do Test
Driven Development. I'm sure Lazarus IDE could benefit from such code
completion improvements too.

I can file this as a feature request on Mantis if need be.

Regards,
  Graeme

-- 
fpGUI Toolkit - a cross-platform GUI toolkit using Free Pascal
http://fpgui.sourceforge.net/

My public PGP key:  http://tinyurl.com/graeme-pgp


More information about the Lazarus mailing list