View Issue Details

IDProjectCategoryView StatusLast Update
0031299LazarusIDEpublic2019-11-04 08:04
ReporterGraeme GeldenhuysAssigned ToMattias Gaertner 
PrioritynormalSeverityminorReproducibilityalways
Status acknowledgedResolutionfixed 
Platformx86_64OSFreeBSDOS Version10.3
Product Version1.7 (SVN)Product Build 
Target VersionFixed in Version 
Summary0031299: [feature request] More intelligent code/class completion
DescriptionI'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.
TagsNo tags attached.
Fixed in Revision
LazTarget-
Widgetset
Attached Files

Relationships

related to 0035413 new "Complete code" duplicates getter/setter methods with empty parenthesis 
related to 0023324 assignedMattias Gaertner code tools do not recognize function with default parameter as property accessor 

Activities

Graeme Geldenhuys

2017-01-30 13:19

reporter   ~0097819

There is a short discussion on this topic in the mailing list.

  https://www.mail-archive.com/lazarus@lists.lazarus-ide.org/msg02166.html

Mattias Gaertner

2017-11-13 11:44

manager   ~0104057

Implemented by Ondrej. Ctrl+Shift+X

Ondrej Pokorny

2017-11-13 12:34

developer   ~0104065

IMO it's a different feature. Ctrl+Shift+X cannot extend different objects. Only the current object (Self) is supported. And properties aren't supported either - only fields.

On the other hand, there are so many possibilities how to create a property that IMO it's easier to do it with Code Templates. E.g. I use:

pf = property $param(PropName): $param(PropType) read f$param(PropName,Sync=1);|
pff = property $param(PropName): $param(PropType) read f$param(PropName,Sync=1) write f$param(PropName,Sync=1);|
pfs = property $param(PropName): $param(PropType) read f$param(PropName,Sync=1) write Set$param(PropName,Sync=1);|
pg = property $param(PropName): $param(PropType) read Get$param(PropName,Sync=1);|
pgs = property $param(PropName): $param(PropType) read Get$param(PropName,Sync=1) write Set$param(PropName,Sync=1);|

Mattias Gaertner

2017-11-13 13:25

manager   ~0104070

I agree that it would be great if the interactive code completion would offer the option create a property and to another class than self.

Issue History

Date Modified Username Field Change
2017-01-30 13:07 Graeme Geldenhuys New Issue
2017-01-30 13:19 Graeme Geldenhuys Note Added: 0097819
2017-11-13 11:44 Mattias Gaertner LazTarget => -
2017-11-13 11:44 Mattias Gaertner Note Added: 0104057
2017-11-13 11:44 Mattias Gaertner Status new => resolved
2017-11-13 11:44 Mattias Gaertner Resolution open => fixed
2017-11-13 11:44 Mattias Gaertner Assigned To => Mattias Gaertner
2017-11-13 12:34 Ondrej Pokorny Note Added: 0104065
2017-11-13 13:25 Mattias Gaertner Note Added: 0104070
2017-11-13 13:25 Mattias Gaertner Status resolved => acknowledged
2019-11-04 08:03 Juha Manninen Relationship added related to 0035413
2019-11-04 08:04 Juha Manninen Relationship added related to 0023324