From 8be47d95a1ee79a822baf66883af9400f2e287d4 Mon Sep 17 00:00:00 2001 From: mattias Date: Sun, 29 Apr 2012 18:21:33 +0000 Subject: [PATCH] codetools: GetSmartHint: property params and type git-svn-id: trunk@37087 - --- components/codetools/finddeclarationtool.pas | 61 +++++++++++++++----- 1 file changed, 48 insertions(+), 13 deletions(-) diff --git a/components/codetools/finddeclarationtool.pas b/components/codetools/finddeclarationtool.pas index e3c7b41df1..5d765a4e08 100644 --- a/components/codetools/finddeclarationtool.pas +++ b/components/codetools/finddeclarationtool.pas @@ -2193,6 +2193,8 @@ var IdentNode, TypeNode, ANode: TCodeTreeNode; ClassStr: String; NodeStr: String; + Params: TFindDeclarationParams; + Tool: TFindDeclarationTool; begin Result:=''; @@ -2313,7 +2315,52 @@ begin phpWithDefaultValues,phpWithResultType,phpWithOfObject,phpCommentsToSpace]); end; - ctnProperty, + ctnProperty,ctnGlobalProperty: + begin + IdentNode:=Node; + + // ToDo: ppu, dcu files + + Result+='property '; + MoveCursorToNodeStart(IdentNode); + ReadNextAtom; + if Node.Desc = ctnProperty then begin + // e.g. property Caption: string; + // skip keyword + ReadNextAtom; + // add class name + ClassStr := ExtractClassName(Node, False, True); + if ClassStr <> '' then Result += ClassStr + '.'; + end else begin + // global property starts with identifier + end; + // add name + Result+=GetAtom; + + Tool:=Self; + while (Node.Desc=ctnProperty) + and not Tool.MoveCursorToPropType(Node) do begin + // property without type + // -> search ancestor property + if not Tool.MoveCursorToPropName(Node) then break; + Params:=TFindDeclarationParams.Create; + try + Params.SetIdentifier(Tool,@Tool.Src[Tool.CurPos.StartPos],nil); + Params.Flags:=[fdfSearchInAncestors]; + if not FindIdentifierInAncestors(Node.Parent.Parent,Params) then break; + Tool:=Params.NewCodeTool; + Node:=Params.NewNode; + finally + Params.Free; + end; + end; + if (Node<>nil) + and (Node.Desc in [ctnProperty,ctnGlobalProperty]) then begin + Result += Tool.ExtractProperty(Node, + [phpWithoutName,phpWithParameterNames,phpWithResultType]); + end; + end; + ctnProgram,ctnUnit,ctnPackage,ctnLibrary: begin IdentNode:=Node; @@ -2338,18 +2385,6 @@ begin end; end; - ctnGlobalProperty: - begin - IdentNode:=Node; - - // ToDo: ppu, dcu files - - MoveCursorToNodeStart(IdentNode); - Result+='property '; - ReadNextAtom; - Result+=GetAtom+' '; - end; - else DebugLn('ToDo: TFindDeclarationTool.FindSmartHint ',Node.DescAsString); end;