mirror of
https://gitlab.com/freepascal.org/lazarus/lazarus.git
synced 2025-08-12 07:55:58 +02:00
codetools: GuessTypeOfIdentifier: guess type of for-in
git-svn-id: trunk@30893 -
This commit is contained in:
parent
3ce75c3558
commit
bba64bdf3c
@ -5337,6 +5337,7 @@ var
|
|||||||
Section: TCodeTreeNode;
|
Section: TCodeTreeNode;
|
||||||
ExistingNodeInProc: Boolean;
|
ExistingNodeInProc: Boolean;
|
||||||
Keep: Boolean;
|
Keep: Boolean;
|
||||||
|
InAtomEndPos: Integer;
|
||||||
begin
|
begin
|
||||||
Result:=false;
|
Result:=false;
|
||||||
IsKeyword:=false;
|
IsKeyword:=false;
|
||||||
@ -5450,7 +5451,40 @@ begin
|
|||||||
end;
|
end;
|
||||||
debugln(['TCodeCompletionCodeTool.GuessTypeOfIdentifier Assignment type=',NewType]);
|
debugln(['TCodeCompletionCodeTool.GuessTypeOfIdentifier Assignment type=',NewType]);
|
||||||
Result:=true;
|
Result:=true;
|
||||||
end else begin
|
end;
|
||||||
|
|
||||||
|
if not Result then begin
|
||||||
|
MoveCursorToAtomPos(IdentifierAtom);
|
||||||
|
// find 'in' operator
|
||||||
|
ReadNextAtom;
|
||||||
|
if UpAtomIs('IN') then begin
|
||||||
|
InAtomEndPos:=CurPos.EndPos;
|
||||||
|
|
||||||
|
// find 'for' keyword
|
||||||
|
MoveCursorToCleanPos(IdentifierAtom.StartPos);
|
||||||
|
ReadPriorAtom;
|
||||||
|
if not UpAtomIs('FOR') then exit;
|
||||||
|
|
||||||
|
// find term
|
||||||
|
MoveCursorToCleanPos(InAtomEndPos);
|
||||||
|
ReadNextAtom;
|
||||||
|
TermAtom.StartPos:=CurPos.StartPos;
|
||||||
|
TermAtom.EndPos:=FindEndOfExpression(TermAtom.StartPos);
|
||||||
|
|
||||||
|
debugln(['TCodeCompletionCodeTool.GuessTypeOfIdentifier guessing type of for-in list "',dbgstr(Src,TermAtom.StartPos,TermAtom.EndPos-TermAtom.StartPos),'"']);
|
||||||
|
// find type of term
|
||||||
|
Params:=TFindDeclarationParams.Create;
|
||||||
|
try
|
||||||
|
NewType:=FindForInTypeAsString(TermAtom,CursorNode,Params,NewExprType);
|
||||||
|
finally
|
||||||
|
Params.Free;
|
||||||
|
end;
|
||||||
|
debugln(['TCodeCompletionCodeTool.GuessTypeOfIdentifier For-In type=',NewType]);
|
||||||
|
Result:=true;
|
||||||
|
end;
|
||||||
|
end;
|
||||||
|
|
||||||
|
if not Result then begin
|
||||||
debugln(['TCodeCompletionCodeTool.GuessTypeOfIdentifier can not guess type']);
|
debugln(['TCodeCompletionCodeTool.GuessTypeOfIdentifier can not guess type']);
|
||||||
exit;
|
exit;
|
||||||
end;
|
end;
|
||||||
|
@ -26,7 +26,6 @@
|
|||||||
that the user needs only to choose where to create the var.
|
that the user needs only to choose where to create the var.
|
||||||
|
|
||||||
ToDo:
|
ToDo:
|
||||||
- guess for in
|
|
||||||
- guess parameter
|
- guess parameter
|
||||||
- guess j:=<i>
|
- guess j:=<i>
|
||||||
- Extend uses section when adding to a class
|
- Extend uses section when adding to a class
|
||||||
|
Loading…
Reference in New Issue
Block a user