codetools: code completion: check completing method body to header as last check, patch #28819 from Ondrej

git-svn-id: trunk@50067 -
This commit is contained in:
mattias 2015-10-14 23:21:24 +00:00
parent ea8b3ac796
commit bfea0890b0

View File

@ -9141,7 +9141,7 @@ function TCodeCompletionCodeTool.CompleteCode(CursorPos: TCodeXYPosition;
if Result then exit; if Result then exit;
end; end;
function TryComplete(CursorNode: TCodeTreeNode; CleanCursorPos, OrigCleanCursorPos: integer): Boolean; function TryComplete(CursorNode: TCodeTreeNode; CleanCursorPos: integer): Boolean;
var var
ProcNode, AClassNode: TCodeTreeNode; ProcNode, AClassNode: TCodeTreeNode;
IsEventAssignment: boolean; IsEventAssignment: boolean;
@ -9200,12 +9200,6 @@ function TCodeCompletionCodeTool.CompleteCode(CursorPos: TCodeXYPosition;
Result:=CompleteProcByCall(CleanCursorPos,OldTopLine, Result:=CompleteProcByCall(CleanCursorPos,OldTopLine,
CursorNode,NewPos,NewTopLine,SourceChangeCache); CursorNode,NewPos,NewTopLine,SourceChangeCache);
if Result then exit; if Result then exit;
// test if method body
if OrigCleanCursorPos <> -1 then
Result:=CompleteMethodByBody(OrigCleanCursorPos,OldTopLine,CursorNode,
NewPos,NewTopLine,SourceChangeCache);
if Result then exit;
finally finally
FCompletingCursorNode:=nil; FCompletingCursorNode:=nil;
end; end;
@ -9320,7 +9314,7 @@ begin
CodeCompleteSrcChgCache:=SourceChangeCache; CodeCompleteSrcChgCache:=SourceChangeCache;
CursorNode:=FindDeepestNodeAtPos(CleanCursorPos,true); CursorNode:=FindDeepestNodeAtPos(CleanCursorPos,true);
if TryComplete(CursorNode, CleanCursorPos, OrigCleanCursorPos) then if TryComplete(CursorNode, CleanCursorPos) then
exit(true); exit(true);
{ Find the first occurence of the (local) identifier at cursor in current { Find the first occurence of the (local) identifier at cursor in current
@ -9328,6 +9322,11 @@ begin
if TryFirstLocalIdentOccurence(CursorNode,OrigCleanCursorPos,CleanCursorPos) then if TryFirstLocalIdentOccurence(CursorNode,OrigCleanCursorPos,CleanCursorPos) then
exit(true); exit(true);
if CompleteMethodByBody(OrigCleanCursorPos,OldTopLine,CursorNode,
NewPos,NewTopLine,SourceChangeCache)
then
exit(true);
{$IFDEF CTDEBUG} {$IFDEF CTDEBUG}
DebugLn('TCodeCompletionCodeTool.CompleteCode nothing to complete ... '); DebugLn('TCodeCompletionCodeTool.CompleteCode nothing to complete ... ');
{$ENDIF} {$ENDIF}