codetools: GuessTypeOfIdentifier: guess type of for-in

git-svn-id: trunk@30893 -
This commit is contained in:
mattias 2011-05-24 21:55:20 +00:00
parent 3ce75c3558
commit bba64bdf3c
2 changed files with 35 additions and 2 deletions

View File

@ -5337,6 +5337,7 @@ var
Section: TCodeTreeNode;
ExistingNodeInProc: Boolean;
Keep: Boolean;
InAtomEndPos: Integer;
begin
Result:=false;
IsKeyword:=false;
@ -5450,7 +5451,40 @@ begin
end;
debugln(['TCodeCompletionCodeTool.GuessTypeOfIdentifier Assignment type=',NewType]);
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']);
exit;
end;

View File

@ -26,7 +26,6 @@
that the user needs only to choose where to create the var.
ToDo:
- guess for in
- guess parameter
- guess j:=<i>
- Extend uses section when adding to a class