diff --git a/components/codetools/finddeclarationtool.pas b/components/codetools/finddeclarationtool.pas index 30fe83d568..da19476cb5 100644 --- a/components/codetools/finddeclarationtool.pas +++ b/components/codetools/finddeclarationtool.pas @@ -8254,6 +8254,9 @@ var debugln([' FindExpressionTypeOfTerm ResolveChildren']); {$ENDIF} ResolveBaseTypeOfIdentifier; + {$IFDEF ShowExprEval} + debugln([' FindExpressionTypeOfTerm ResolveChildren ExprType=',ExprTypeToString(ExprType)]); + {$ENDIF} if (ExprType.Context.Node=nil) then exit; if (ExprType.Context.Node.Desc in AllUsableSourceTypes) then begin if ExprType.Context.Tool=Self then begin diff --git a/components/codetools/tests/fdt_typehelper.pas b/components/codetools/tests/fdt_typehelper.pas index 69ab4ec0c3..3f4073ff16 100644 --- a/components/codetools/tests/fdt_typehelper.pas +++ b/components/codetools/tests/fdt_typehelper.pas @@ -1,3 +1,6 @@ +{ + ./finddeclarationtest --format=plain --suite=TestFindDeclaration_TypeHelper +} unit fdt_typehelper; {$mode objfpc}{$H+} @@ -10,31 +13,86 @@ uses type - { TStringTypeHelper } + { TShortStringTypeHelper } - TStringTypeHelper = type helper for ShortString + TShortStringTypeHelper = type helper for ShortString public function MyVar: integer; end; + { TStringTypeHelper } + + TStringTypeHelper = type helper for String + public + function Get45: integer; + end; + + { TLongIntTypeHelper } + + TLongIntTypeHelper = type helper for LongInt + public + function GetStr: string; + end; + + { TEnumTypeHelper } + + TEnumTypeHelper = type helper for TShiftStateEnum + public + function Get78: integer; + end; + procedure DoIt; implementation procedure DoIt; var - s: ShortString; + ShortS: ShortString; + AnsiS: string; + i: integer; + e: TShiftStateEnum; begin - s:='ABC'; - writeln('DoIt ',s.MyVar{declaration:fdt_typehelper.TStringTypeHelper.MyVar}); + ShortS:='ABC'; + writeln('DoIt ',ShortS.MyVar{declaration:fdt_typehelper.TShortStringTypeHelper.MyVar}); + + i:='Hello'.Get45{declaration:fdt_typehelper.TStringTypeHelper.Get45}; + if i<>45 then ; + + AnsiS:=i.GetStr{declaration:fdt_typehelper.TLongIntTypeHelper.GetStr}; + if AnsiS<>'' then ; + + e:=ssDouble; + i:=e.Get78{ Not yet supported: declaration:fdt_typehelper.TEnumTypeHelper.Get78}; + if i<>78 then ; end; -{ TStringTypeHelper } +{ TEnumTypeHelper } -function TStringTypeHelper.MyVar: integer; +function TEnumTypeHelper.Get78: integer; +begin + Result:=78; +end; + +{ TLongIntTypeHelper } + +function TLongIntTypeHelper.GetStr: string; +begin + Result:=IntToStr(Self) +end; + +{ TShortStringTypeHelper } + +function TShortStringTypeHelper.MyVar: integer; begin Result:=123; end; +{ TStringTypeHelper } + +function TStringTypeHelper.Get45: integer; +begin + Result:=45; +end; + end.