diff --git a/components/codetools/finddeclarationtool.pas b/components/codetools/finddeclarationtool.pas index e0a80ead8d..3a55501cbe 100644 --- a/components/codetools/finddeclarationtool.pas +++ b/components/codetools/finddeclarationtool.pas @@ -2553,7 +2553,7 @@ begin ctnRecordCase: begin if FindIdentifierInRecordCase(ContextNode,Params) - and CheckResult(true,false) then + and CheckResult(true,true) then exit; // search in variants MoveContextNodeToChilds; @@ -4577,18 +4577,24 @@ end; function TFindDeclarationTool.FindIdentifierInRecordCase( RecordCaseNode: TCodeTreeNode; Params: TFindDeclarationParams): boolean; +var + IdentPos: LongInt; begin Result:=false; MoveCursorToNodeStart(RecordCaseNode); + ReadNextAtom;// case + ReadNextAtom;// identifier + IdentPos:=CurPos.StartPos; ReadNextAtom; - ReadNextAtom; - if (fdfCollect in Params.Flags) - or CompareSrcIdentifiers(CurPos.StartPos,Params.Identifier) then begin + if AtomIsChar(':') + and ((fdfCollect in Params.Flags) + or CompareSrcIdentifiers(IdentPos,Params.Identifier)) + then begin // identifier found {$IFDEF ShowTriedContexts} - DebugLn('[TFindDeclarationTool.FindIdentifierInRecordCase] found="',GetIdentifier(Params.Identifier),'"'); + DebugLn('[TFindDeclarationTool.FindIdentifierInRecordCase] found="',GetIdentifier(Params.Identifier),'" Src=',GetIdentifier(@Src[IdentPos])); {$ENDIF} - Params.SetResult(Self,RecordCaseNode,CurPos.StartPos); + Params.SetResult(Self,RecordCaseNode,IdentPos); Result:=true; end else begin // proceed the search normally ... diff --git a/components/codetools/identcompletiontool.pas b/components/codetools/identcompletiontool.pas index bdb4470ed7..310fdac866 100644 --- a/components/codetools/identcompletiontool.pas +++ b/components/codetools/identcompletiontool.pas @@ -821,6 +821,9 @@ begin end; end; + ctnRecordCase: + Ident:=@FoundContext.Tool.Src[Params.NewCleanPos]; + end; if Ident=nil then exit; diff --git a/components/codetools/pascalreadertool.pas b/components/codetools/pascalreadertool.pas index 1be280742c..5f576ebae6 100644 --- a/components/codetools/pascalreadertool.pas +++ b/components/codetools/pascalreadertool.pas @@ -130,6 +130,9 @@ type function FindFirstIdentNodeInClass(ClassNode: TCodeTreeNode): TCodeTreeNode; function ClassSectionNodeStartsWithWord(ANode: TCodeTreeNode): boolean; + // records + function ExtractRecordCaseType(RecordCaseNode: TCodeTreeNode): string; + // variables, types function FindVarNode(StartNode: TCodeTreeNode; const UpperVarName: string): TCodeTreeNode; @@ -1267,6 +1270,22 @@ begin Result:=true; end; +function TPascalReaderTool.ExtractRecordCaseType(RecordCaseNode: TCodeTreeNode + ): string; +begin + MoveCursorToNodeStart(RecordCaseNode); + ReadNextAtom;// case + ReadNextAtom;// identifier + ReadNextAtom;// : + if AtomIsChar(':') then begin + ReadNextAtom; + AtomIsIdentifier(true); + Result:=GetAtom; + end else begin + Result:=''; + end; +end; + function TPascalReaderTool.GetSourceType: TCodeTreeNodeDesc; begin if Tree.Root<>nil then diff --git a/ide/sourceeditprocs.pas b/ide/sourceeditprocs.pas index e1f05ad392..9142047ca6 100644 --- a/ide/sourceeditprocs.pas +++ b/ide/sourceeditprocs.pas @@ -188,7 +188,7 @@ begin // var, procedure, property, function, type, const case IdentItem.GetDesc of - ctnVarDefinition: + ctnVarDefinition, ctnRecordCase: begin AColor:=clMaroon; s:='var'; @@ -305,6 +305,11 @@ begin s:=copy(s,1,50); end; + ctnRecordCase: + begin + s:=' : '+IdentItem.Tool.ExtractRecordCaseType(IdentItem.Node); + end; + end; end else begin // IdentItem.Node=nil