diff --git a/components/codetools/finddeclarationtool.pas b/components/codetools/finddeclarationtool.pas index 90f710af1f..ba75fa1fb8 100644 --- a/components/codetools/finddeclarationtool.pas +++ b/components/codetools/finddeclarationtool.pas @@ -643,8 +643,6 @@ type function FindExpressionTypeOfTerm(StartPos, EndPos: integer; Params: TFindDeclarationParams; WithAsOperator: boolean): TExpressionType; function FindEndOfExpression(StartPos: integer): integer; - function ConvertNodeToExpressionType(Node: TCodeTreeNode; - Params: TFindDeclarationParams): TExpressionType; function ReadOperandTypeAtCursor( Params: TFindDeclarationParams; MaxEndPos: integer = -1): TExpressionType; function FindExpressionTypeOfPredefinedIdentifier(StartPos: integer; @@ -801,6 +799,8 @@ type function BaseTypeOfNodeHasSubIdents(ANode: TCodeTreeNode): boolean; function FindBaseTypeOfNode(Params: TFindDeclarationParams; Node: TCodeTreeNode): TFindContext; + function ConvertNodeToExpressionType(Node: TCodeTreeNode; + Params: TFindDeclarationParams): TExpressionType; function FindDeclarationAndOverload(const CursorPos: TCodeXYPosition; out ListOfPCodeXYPosition: TFPList; diff --git a/components/codetools/identcompletiontool.pas b/components/codetools/identcompletiontool.pas index c2f7a3e0c5..c1d7ac6f9e 100644 --- a/components/codetools/identcompletiontool.pas +++ b/components/codetools/identcompletiontool.pas @@ -1760,6 +1760,7 @@ begin else exit; end; + //DebugLn(['TIdentCompletionTool.CollectAllContexts add ',FoundContext.Node.DescAsString]); AddCollectionContext(FoundContext.Tool,FoundContext.Node); end; @@ -2208,7 +2209,7 @@ var if not StartInSubContext then Include(Params.Flags,fdfSearchInParentNodes); CurrentIdentifierList.Context:=GatherContext; - //DebugLn('CheckContextIsParameter searching procedure ...'); + //DebugLn('CheckContextIsParameter searching procedures, properties and variables ...'); GatherContext.Tool.FindIdentifierInContext(Params); //DebugLn('CheckContextIsParameter END'); Ok:=true; diff --git a/ide/codecontextform.pas b/ide/codecontextform.pas index 8dae46c1f8..9a27f4836f 100644 --- a/ide/codecontextform.pas +++ b/ide/codecontextform.pas @@ -105,6 +105,7 @@ begin if CodeContextFrm = nil then CodeContextFrm := TCodeContextFrm.Create(nil); CodeContextFrm.SetCodeContexts(CodeContexts); + CodeContextFrm.Visible := True; Result := True; finally @@ -294,24 +295,33 @@ procedure TCodeContextFrm.CreateHints(const CodeContexts: TCodeContextInfo); function FindBaseType(Tool: TFindDeclarationTool; Node: TCodeTreeNode; var s: string): boolean; var - Context: TFindContext; + Expr: TExpressionType; Params: TFindDeclarationParams; begin Result:=false; Params:=TFindDeclarationParams.Create; try try - Context:=Tool.FindBaseTypeOfNode(Params,Node); - if Context.Node=nil then exit; - case Context.Node.Desc of - ctnProcedureType: - begin - s:=s+Context.Tool.ExtractProcHead(Context.Node, - [phpWithVarModifiers,phpWithParameterNames,phpWithDefaultValues, - phpWithResultType]); - Result:=true; + Expr:=Tool.ConvertNodeToExpressionType(Node,Params); + if (Expr.Desc=xtContext) and (Expr.Context.Node<>nil) then begin + case Expr.Context.Node.Desc of + ctnProcedureType: + begin + s:=s+Expr.Context.Tool.ExtractProcHead(Expr.Context.Node, + [phpWithVarModifiers,phpWithParameterNames,phpWithDefaultValues, + phpWithResultType]); + Result:=true; + end; end; - end; + end else if Expr.Desc in (xtAllStringTypes+xtAllWideStringTypes-[xtShortString]) + then begin + s:=s+'[1..high(PtrUInt)]'; + Result:=true; + end else if Expr.Desc=xtShortString then begin + s:=s+'[0..255]'; + Result:=true; + end else + debugln(['FindBaseType ',ExprTypeToString(Expr)]); except end; finally