mirror of
https://gitlab.com/freepascal.org/lazarus/lazarus.git
synced 2025-11-01 20:39:25 +01:00
codetools: record case variable is now a ctnVarDefinition, bug #18368
git-svn-id: trunk@30781 -
This commit is contained in:
parent
a3fbf4b67c
commit
84ea3ef4f9
@ -114,8 +114,8 @@ const
|
||||
ctnOpenArrayType = 72;
|
||||
ctnOfConstType = 73;
|
||||
ctnRecordType = 74;
|
||||
ctnRecordCase = 75;
|
||||
ctnRecordVariant = 76;
|
||||
ctnRecordCase = 75; // children: ctnVarDefinition plus 0..n ctnRecordVariant
|
||||
ctnRecordVariant = 76; // children: 0..n ctnVarDefinition plus may be a ctnRecordCase
|
||||
ctnProcedureType = 77;
|
||||
ctnSetType = 78;
|
||||
ctnRangeType = 79;
|
||||
|
||||
@ -609,8 +609,6 @@ type
|
||||
Params: TFindDeclarationParams): boolean;
|
||||
function FindIdentifierInUsedUnit(const AnUnitName: string;
|
||||
Params: TFindDeclarationParams): boolean;
|
||||
function FindIdentifierInRecordCase(RecordCaseNode: TCodeTreeNode;
|
||||
Params: TFindDeclarationParams): boolean;
|
||||
function FindIdentifierInTypeOfConstant(VarConstNode: TCodeTreeNode;
|
||||
Params: TFindDeclarationParams): boolean;
|
||||
protected
|
||||
@ -3210,10 +3208,7 @@ begin
|
||||
|
||||
ctnRecordCase:
|
||||
begin
|
||||
if FindIdentifierInRecordCase(ContextNode,Params)
|
||||
and CheckResult(true,true) then
|
||||
exit;
|
||||
// search in variants
|
||||
// search in variable and variants
|
||||
MoveContextNodeToChilds;
|
||||
end;
|
||||
|
||||
@ -6051,32 +6046,6 @@ begin
|
||||
end;
|
||||
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;
|
||||
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),'" Src=',GetIdentifier(@Src[IdentPos]));
|
||||
{$ENDIF}
|
||||
Params.SetResult(Self,RecordCaseNode,IdentPos);
|
||||
Result:=true;
|
||||
end else begin
|
||||
// proceed the search normally ...
|
||||
end;
|
||||
end;
|
||||
|
||||
function TFindDeclarationTool.FindIdentifierInTypeOfConstant(
|
||||
VarConstNode: TCodeTreeNode; Params: TFindDeclarationParams): boolean;
|
||||
{ const a: atype = context;
|
||||
|
||||
@ -4299,6 +4299,8 @@ begin
|
||||
case a:(b,c) of
|
||||
}
|
||||
AtomIsIdentifier(true);
|
||||
CreateChildNode;
|
||||
CurNode.Desc:=ctnVarDefinition;
|
||||
{$IFDEF VerboseRecordCase}
|
||||
debugln(['TPascalParserTool.KeyWordFuncTypeRecordCase case name="',GetAtom,'"']);
|
||||
{$ENDIF}
|
||||
@ -4331,14 +4333,22 @@ begin
|
||||
end else begin
|
||||
// identifier
|
||||
AtomIsIdentifier(true);
|
||||
CreateChildNode;
|
||||
CurNode.Desc:=ctnIdentifier;
|
||||
CurNode.EndPos:=CurPos.EndPos;
|
||||
ReadNextAtom;
|
||||
if CurPos.Flag=cafPoint then begin
|
||||
ReadNextAtom; // unit.type
|
||||
AtomIsIdentifier(true);
|
||||
CurNode.EndPos:=CurPos.EndPos;
|
||||
ReadNextAtom;
|
||||
end;
|
||||
EndChildNode; // close ctnIdentifier
|
||||
end;
|
||||
end;
|
||||
// close ctnVarDefinition
|
||||
CurNode.EndPos:=LastAtoms.GetValueAt(0).EndPos;
|
||||
EndChildNode;
|
||||
if not UpAtomIs('OF') then // read 'of'
|
||||
RaiseStringExpectedButAtomFound('"of"');
|
||||
// read all variants
|
||||
|
||||
@ -1830,18 +1830,16 @@ end;
|
||||
|
||||
function TPascalReaderTool.ExtractRecordCaseType(RecordCaseNode: TCodeTreeNode
|
||||
): string;
|
||||
// case a:b.c of
|
||||
// case a:(b,c) of
|
||||
var
|
||||
VarNode: TCodeTreeNode;
|
||||
begin
|
||||
MoveCursorToNodeStart(RecordCaseNode);
|
||||
ReadNextAtom;// case
|
||||
ReadNextAtom;// identifier
|
||||
ReadNextAtom;// :
|
||||
if AtomIsChar(':') then begin
|
||||
ReadNextAtom;
|
||||
AtomIsIdentifier(true);
|
||||
Result:=GetAtom;
|
||||
end else begin
|
||||
Result:='';
|
||||
end;
|
||||
Result:='';
|
||||
VarNode:=RecordCaseNode.FirstChild;
|
||||
if VarNode=nil then exit;
|
||||
if VarNode.FirstChild<>nil then
|
||||
Result:=ExtractNode(RecordCaseNode.FirstChild,[]);
|
||||
end;
|
||||
|
||||
function TPascalReaderTool.GetSourceType: TCodeTreeNodeDesc;
|
||||
|
||||
Loading…
Reference in New Issue
Block a user