View Issue Details

IDProjectCategoryView StatusLast Update
0023782LazarusIDEpublic2019-12-30 15:07
ReporterVojtech Cihak Assigned ToJuha Manninen  
PrioritynormalSeverityminorReproducibilityalways
Status resolvedResolutionfixed 
Platformamd64OSLinux 
Product Version1.1 (SVN) 
Summary0023782: Autocomplete with generics
DescriptionAutocomplete does not work inside the "with begin end" block.

unit Unit1;
{$mode objfpc}{$H+}

interface

uses
  Classes, SysUtils, FileUtil, Forms, Controls, Graphics, Dialogs, StdCtrls, FGL;

type
  { TForm1 }
  TForm1 = class(TForm)
    procedure FormClick(Sender: TObject);
  private
    { private declarations }
  public
    { public declarations }
  end;
  
  TGList = class(specialize TFPGObjectList<TButton>)
    
  end;

var
  Form1: TForm1;
  GList: TGList;
  
implementation

{$R *.lfm}

{ TForm1 }

procedure TForm1.FormClick(Sender: TObject);
begin
  with GList[0] do
    begin
      
      Cancel:=True;
    end;
end;

end.

The code is compilable.

Lazarus 1.1 r39980M FPC 2.7.1 x86_64-linux-qt
                
Steps To ReproduceStart a new project (application)
CTRL+C and CTRL+V the code above.
Try CTRL+Space inside the "with begin .. end" block.

Messages says: unit1.pas(35,8) Error: expression type must be class or record type
but code is compilable with fpc 2.7.1
Tagspatch
Fixed in Revisionr62470
LazTarget-
Widgetset
Attached Files

Relationships

related to 0023496 resolvedMattias Gaertner Add support for generic constraints to CodeTools 
related to 0023903 resolvedMattias Gaertner Complete code error 
related to 0030124 resolvedJuha Manninen specialize TFPGList<Int64> declaration is not supported by CodeTools 

Activities

jefferywa

2018-06-02 15:19

reporter  

0001-IDE-Correction-of-the-issue-ID-0023782-Generic-auto-.patch (1,476 bytes)   
From f513d9f8d64710a108fe00ed34a8139959423f50 Mon Sep 17 00:00:00 2001
From: JefferyWa <sevafara@gmail.com>
Date: Sat, 2 Jun 2018 15:38:42 +0300
Subject: [PATCH] IDE: Correction of the issue (ID 0023782): Generic
 auto-completion

---
 components/codetools/finddeclarationtool.pas | 6 ++++++
 1 file changed, 6 insertions(+)

diff --git a/components/codetools/finddeclarationtool.pas b/components/codetools/finddeclarationtool.pas
index 34be65c..c5b0097 100644
--- a/components/codetools/finddeclarationtool.pas
+++ b/components/codetools/finddeclarationtool.pas
@@ -7534,6 +7534,7 @@ function TFindDeclarationTool.FindAncestorOfClassInheritance(
 var
   InheritanceNode: TCodeTreeNode;
   ClassNode: TCodeTreeNode;
+  SpecializeNode : TCodeTreeNode;
   AncestorContext: TFindContext;
   AncestorStartPos: LongInt;
   ExprType: TExpressionType;
@@ -7613,9 +7614,14 @@ begin
     if (AncestorContext.Node.Desc in [ctnTypeDefinition,ctnGenericType]) then
     begin
       Params:=TFindDeclarationParams.Create;
+      if IdentifierNode.Desc=ctnSpecialize then begin
+         SpecializeNode:=IdentifierNode;
+         Params.SetGenericParamValues(Self, SpecializeNode);
+      end;
       try
         Params.Flags:=fdfDefaultForExpressions+[fdfFindChildren];
         AncestorContext:=AncestorContext.Tool.FindBaseTypeOfNode(Params,AncestorContext.Node);
+        ResultParams.GenParams:=Params.GenParams;
       finally
         Params.Free;
       end;
-- 
2.8.3.windows.1

jefferywa

2018-06-02 15:20

reporter  

tests.zip (2,104 bytes)

jefferywa

2018-06-02 15:21

reporter   ~0108643

Corrected two cases of autocompletion
First, when we use the record (c1 = class (specialize generic <TForm1>)),
and the second when we use (c2 = generic <TForm1>), c3 = class (c2)).

Juha Manninen

2019-12-30 13:22

developer   ~0120147

Last edited: 2019-12-30 15:06

View 2 revisions

Hey, the patch from jefferywa really solves this issue!
It has been waiting here a year and a half. I plan to apply it and see what other issues it solves.
[Edit] Didn't find other issues solved by this one. Resolving.

Issue History

Date Modified Username Field Change
2013-01-29 18:37 Vojtech Cihak New Issue
2014-09-25 08:12 Juha Manninen Relationship added related to 0023496
2015-12-10 15:12 Mattias Gaertner Assigned To => Mattias Gaertner
2015-12-10 15:12 Mattias Gaertner Status new => assigned
2015-12-10 15:12 Mattias Gaertner Relationship added related to 0023903
2016-05-19 00:10 Juha Manninen Relationship added related to 0030124
2017-11-28 16:09 Mattias Gaertner LazTarget => -
2017-11-28 16:09 Mattias Gaertner Status assigned => confirmed
2018-06-02 15:19 jefferywa File Added: 0001-IDE-Correction-of-the-issue-ID-0023782-Generic-auto-.patch
2018-06-02 15:20 jefferywa File Added: tests.zip
2018-06-02 15:21 jefferywa Note Added: 0108643
2018-06-09 18:26 jefferywa Tag Attached: patch
2019-12-30 13:20 Juha Manninen Assigned To Mattias Gaertner => Juha Manninen
2019-12-30 13:22 Juha Manninen Note Added: 0120147
2019-12-30 15:06 Juha Manninen Note Edited: 0120147 View Revisions
2019-12-30 15:07 Juha Manninen Status confirmed => resolved
2019-12-30 15:07 Juha Manninen Resolution open => fixed
2019-12-30 15:07 Juha Manninen Fixed in Revision => r62470