mirror of
https://gitlab.com/freepascal.org/lazarus/lazarus.git
synced 2025-06-02 11:52:37 +02:00
codetools: added record case variables to identifier completion
git-svn-id: trunk@10157 -
This commit is contained in:
parent
212503e493
commit
e7be3ae1d3
@ -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 ...
|
||||
|
@ -821,6 +821,9 @@ begin
|
||||
end;
|
||||
end;
|
||||
|
||||
ctnRecordCase:
|
||||
Ident:=@FoundContext.Tool.Src[Params.NewCleanPos];
|
||||
|
||||
end;
|
||||
if Ident=nil then exit;
|
||||
|
||||
|
@ -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
|
||||
|
@ -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
|
||||
|
Loading…
Reference in New Issue
Block a user