From a387dabeabe0237980603c11eaf99767ded9ce93 Mon Sep 17 00:00:00 2001 From: mattias Date: Thu, 8 Oct 2015 22:20:57 +0000 Subject: [PATCH] codetools: fixed method jumping of generic class method git-svn-id: trunk@50008 - --- components/codetools/methodjumptool.pas | 6 ++-- components/codetools/pascalreadertool.pas | 43 ++++++++++++----------- 2 files changed, 26 insertions(+), 23 deletions(-) diff --git a/components/codetools/methodjumptool.pas b/components/codetools/methodjumptool.pas index 8f87c9381d..7cdfec7e68 100644 --- a/components/codetools/methodjumptool.pas +++ b/components/codetools/methodjumptool.pas @@ -34,7 +34,7 @@ interface {$I codetools.inc} -{ $DEFINE CTDEBUG} +{off $DEFINE CTDEBUG} uses {$IFDEF MEM_CHECK} @@ -281,7 +281,7 @@ const if SearchForProcNode=nil then exit; SearchedProcHead:=ExtractProcHeadWithGroup(SearchForProcNode,SearchForProcAttr); {$IFDEF CTDEBUG} - DebugLn('TMethodJumpingCodeTool.FindJumpPoint.FindBestProcNode Searching ',SearchForProcNode.DescAsString,' "',SearchedProcHead.Head,'" ',ProcHeadAttributesToStr(SearchForProcAttr)); + DebugLn('TMethodJumpingCodeTool.FindJumpPoint.FindBestProcNode Searching ',SearchForProcNode.DescAsString,' "',SearchedProcHead.Name,'" ',ProcHeadAttributesToStr(SearchForProcAttr)); {$ENDIF} if SearchedProcHead.Name='' then exit; ProcNode:=FindProcNode(StartNode,SearchedProcHead,SearchInProcAttr); @@ -366,7 +366,7 @@ begin // and then jumping is a nide feature // => search in all implemented class procedures for the body {$IFDEF CTDEBUG} - DebugLn('TMethodJumpingCodeTool.FindJumpPoint ClasNode=',ClassNode.DescAsString); + DebugLn('TMethodJumpingCodeTool.FindJumpPoint ClassNode=',ClassNode.DescAsString); {$ENDIF} if (ClassNode.SubDesc and ctnsForwardDeclaration)>0 then exit; // parse class and build CodeTreeNodes for all properties/methods diff --git a/components/codetools/pascalreadertool.pas b/components/codetools/pascalreadertool.pas index 5a01126750..cc7637606b 100644 --- a/components/codetools/pascalreadertool.pas +++ b/components/codetools/pascalreadertool.pas @@ -187,7 +187,8 @@ type // classes function ExtractClassName(Node: TCodeTreeNode; - InUpperCase: boolean; WithParents: boolean = true): string; + InUpperCase: boolean; WithParents: boolean = true; + WithGenericParams: boolean = false): string; function ExtractClassPath(Node: TCodeTreeNode): string; function ExtractClassInheritance(ClassNode: TCodeTreeNode; Attr: TProcHeadAttributes): string; @@ -763,7 +764,8 @@ begin end; function TPascalReaderTool.ExtractClassName(Node: TCodeTreeNode; - InUpperCase: boolean; WithParents: boolean): string; + InUpperCase: boolean; WithParents: boolean; WithGenericParams: boolean + ): string; var ParamsNode: TCodeTreeNode; ParamNode: TCodeTreeNode; @@ -781,28 +783,29 @@ begin ctnGenericType: begin if Result<>'' then Result:='.'+Result; - if (Scanner.CompilerMode = cmDELPHI) and (Node.Desc = ctnGenericType) - then begin + if (Node.Desc = ctnGenericType) then begin // extract generic type param names - ParamsNode:=Node.FirstChild.NextBrother; - First:=true; - while ParamsNode<>nil do begin - if ParamsNode.Desc=ctnGenericParams then begin - Result:='>'+Result; - ParamNode:=ParamsNode.FirstChild; - while ParamNode<>nil do begin - if ParamNode.Desc=ctnGenericParameter then begin - if First then - First:=false - else - Result:=','+Result; - Result:=GetIdentifier(@Src[ParamNode.StartPos])+Result; + if WithGenericParams then begin + ParamsNode:=Node.FirstChild.NextBrother; + First:=true; + while ParamsNode<>nil do begin + if ParamsNode.Desc=ctnGenericParams then begin + Result:='>'+Result; + ParamNode:=ParamsNode.FirstChild; + while ParamNode<>nil do begin + if ParamNode.Desc=ctnGenericParameter then begin + if First then + First:=false + else + Result:=','+Result; + Result:=GetIdentifier(@Src[ParamNode.StartPos])+Result; + end; + ParamNode:=ParamNode.NextBrother; end; - ParamNode:=ParamNode.NextBrother; + Result:='<'+Result; end; - Result:='<'+Result; + ParamsNode:=ParamsNode.NextBrother; end; - ParamsNode:=ParamsNode.NextBrother; end; Result:=GetIdentifier(@Src[Node.FirstChild.StartPos])+Result; end;