codetools: fixed method jump from objfpc generic method body to decl

This commit is contained in:
mattias 2025-01-26 15:23:38 +01:00
parent b7aafac192
commit 2706cc285c
2 changed files with 7 additions and 3 deletions

View File

@ -47,7 +47,6 @@ uses
FileProcs, CodeTree, CodeToolsStrConsts, PascalParserTool, StdCodeTools, FileProcs, CodeTree, CodeToolsStrConsts, PascalParserTool, StdCodeTools,
KeywordFuncLists, BasicCodeTools, LinkScanner, CodeCache, PascalReaderTool; KeywordFuncLists, BasicCodeTools, LinkScanner, CodeCache, PascalReaderTool;
type type
{ TMethodJumpingCodeTool } { TMethodJumpingCodeTool }
@ -93,7 +92,6 @@ type
procedure CalcMemSize(Stats: TCTMemStats); override; procedure CalcMemSize(Stats: TCTMemStats); override;
end; end;
implementation implementation
{ TMethodJumpingCodeTool } { TMethodJumpingCodeTool }
@ -287,9 +285,13 @@ const
begin begin
Result:=false; Result:=false;
if SearchForProcNode=nil then exit; if SearchForProcNode=nil then exit;
if Scanner.CompilerMode=cmOBJFPC then begin
Include(SearchForProcAttr,phpWithoutGenericParams);
Include(SearchInProcAttr,phpWithoutGenericParams);
end;
SearchedProcHead:=ExtractProcHeadWithGroup(SearchForProcNode,SearchForProcAttr); SearchedProcHead:=ExtractProcHeadWithGroup(SearchForProcNode,SearchForProcAttr);
{$IFDEF CTDEBUG} {$IFDEF CTDEBUG}
DebugLn('TMethodJumpingCodeTool.FindJumpPoint.FindBestProcNode Searching ',SearchForProcNode.DescAsString,' "',SearchedProcHead.Name,'" ',ProcHeadAttributesToStr(SearchForProcAttr)); DebugLn('TMethodJumpingCodeTool.FindJumpPoint.FindBestProcNode Searching ',SearchForProcNode.DescAsString,' "',dbgs(SearchedProcHead),'"');
{$ENDIF} {$ENDIF}
if SearchedProcHead.Name='' then exit; if SearchedProcHead.Name='' then exit;
ProcNode:=FindProcNode(StartNode,SearchedProcHead,SearchInProcAttr); ProcNode:=FindProcNode(StartNode,SearchedProcHead,SearchInProcAttr);

View File

@ -350,12 +350,14 @@ begin
'implementation', 'implementation',
'generic class function TBird.{b}Do2It<T>(s: T): T;', 'generic class function TBird.{b}Do2It<T>(s: T): T;',
'begin', 'begin',
' {c}',
'end;', 'end;',
'procedure TBird.DoIt;', 'procedure TBird.DoIt;',
'begin', 'begin',
'end;', 'end;',
'end.']); 'end.']);
TestJumpToMethod('a',false,'b',false,2); TestJumpToMethod('a',false,'b',false,2);
TestJumpToMethod('c',false,'a',false);
end; end;
procedure TTestMethodJumpTool.TestMethodJump_ParamWithAttribute; procedure TTestMethodJumpTool.TestMethodJump_ParamWithAttribute;