From 2706cc285c56691a402c9e6c8b105fc9da798af0 Mon Sep 17 00:00:00 2001 From: mattias Date: Sun, 26 Jan 2025 15:23:38 +0100 Subject: [PATCH] codetools: fixed method jump from objfpc generic method body to decl --- components/codetools/methodjumptool.pas | 8 +++++--- components/codetools/tests/testmethodjumptool.pas | 2 ++ 2 files changed, 7 insertions(+), 3 deletions(-) diff --git a/components/codetools/methodjumptool.pas b/components/codetools/methodjumptool.pas index 791eb27a90..e3187c3130 100644 --- a/components/codetools/methodjumptool.pas +++ b/components/codetools/methodjumptool.pas @@ -47,7 +47,6 @@ uses FileProcs, CodeTree, CodeToolsStrConsts, PascalParserTool, StdCodeTools, KeywordFuncLists, BasicCodeTools, LinkScanner, CodeCache, PascalReaderTool; - type { TMethodJumpingCodeTool } @@ -93,7 +92,6 @@ type procedure CalcMemSize(Stats: TCTMemStats); override; end; - implementation { TMethodJumpingCodeTool } @@ -287,9 +285,13 @@ const begin Result:=false; if SearchForProcNode=nil then exit; + if Scanner.CompilerMode=cmOBJFPC then begin + Include(SearchForProcAttr,phpWithoutGenericParams); + Include(SearchInProcAttr,phpWithoutGenericParams); + end; SearchedProcHead:=ExtractProcHeadWithGroup(SearchForProcNode,SearchForProcAttr); {$IFDEF CTDEBUG} - DebugLn('TMethodJumpingCodeTool.FindJumpPoint.FindBestProcNode Searching ',SearchForProcNode.DescAsString,' "',SearchedProcHead.Name,'" ',ProcHeadAttributesToStr(SearchForProcAttr)); + DebugLn('TMethodJumpingCodeTool.FindJumpPoint.FindBestProcNode Searching ',SearchForProcNode.DescAsString,' "',dbgs(SearchedProcHead),'"'); {$ENDIF} if SearchedProcHead.Name='' then exit; ProcNode:=FindProcNode(StartNode,SearchedProcHead,SearchInProcAttr); diff --git a/components/codetools/tests/testmethodjumptool.pas b/components/codetools/tests/testmethodjumptool.pas index 6e3c8c0798..8186dfac4e 100644 --- a/components/codetools/tests/testmethodjumptool.pas +++ b/components/codetools/tests/testmethodjumptool.pas @@ -350,12 +350,14 @@ begin 'implementation', 'generic class function TBird.{b}Do2It(s: T): T;', 'begin', + ' {c}', 'end;', 'procedure TBird.DoIt;', 'begin', 'end;', 'end.']); TestJumpToMethod('a',false,'b',false,2); + TestJumpToMethod('c',false,'a',false); end; procedure TTestMethodJumpTool.TestMethodJump_ParamWithAttribute;