codetools: code completion: create local var based on first occurence instead of at cursor, patch #28819 from Ondrej

git-svn-id: trunk@50051 -
This commit is contained in:
mattias 2015-10-14 09:27:25 +00:00
parent b3ff6d8167
commit 6716258279

View File

@ -9141,14 +9141,12 @@ function TCodeCompletionCodeTool.CompleteCode(CursorPos: TCodeXYPosition;
if Result then exit;
end;
function TryComplete(CleanCursorPos, OrigCleanCursorPos: integer): Boolean;
function TryComplete(CursorNode: TCodeTreeNode; CleanCursorPos, OrigCleanCursorPos: integer): Boolean;
var
CursorNode: TCodeTreeNode;
ProcNode, AClassNode: TCodeTreeNode;
IsEventAssignment: boolean;
begin
Result := False;
CursorNode:=FindDeepestNodeAtPos(CleanCursorPos,true);
FCompletingCursorNode:=CursorNode;
try
@ -9321,18 +9319,14 @@ begin
CodeCompleteSrcChgCache:=SourceChangeCache;
CursorNode:=FindDeepestNodeAtPos(CleanCursorPos,true);
FCompletingCursorNode:=CursorNode;
try
if TryComplete(CleanCursorPos, OrigCleanCursorPos) then exit;
finally
FCompletingCursorNode:=nil;
end;
{ Find the first occurence of the (local) identifier at cursor in current
procedure body and try again. }
Result:=TryFirstLocalIdentOccurence(CursorNode,OrigCleanCursorPos,CleanCursorPos);
if Result then exit;
if TryComplete(CursorNode, CleanCursorPos, OrigCleanCursorPos) then exit;
{$IFDEF CTDEBUG}
DebugLn('TCodeCompletionCodeTool.CompleteCode nothing to complete ... ');
{$ENDIF}