codetools: fixed TIdentCompletionTool.ParseSourceTillCollectionStart check atom in front

git-svn-id: trunk@31318 -
This commit is contained in:
mattias 2011-06-21 15:01:29 +00:00
parent cf32ea0df9
commit a1d7624a88
2 changed files with 15 additions and 2 deletions

View File

@ -1719,7 +1719,7 @@ begin
until false;
ReadNextAtom;
if CurPos.StartPos<CleanPos then
exit;
break;
// first atom of node is behind CleanPos => try prior node
Node:=Node.Prior;
until false;

View File

@ -1726,6 +1726,7 @@ procedure TIdentCompletionTool.ParseSourceTillCollectionStart(
out CursorNode: TCodeTreeNode; out IdentStartPos, IdentEndPos: integer);
var
StartContext: TFindContext;
ContextPos: Integer;
begin
CleanCursorPos:=0;
CursorNode:=nil;
@ -1740,7 +1741,19 @@ begin
[btSetIgnoreErrorPos]);
// find node at position
CursorNode:=BuildSubTreeAndFindDeepestNodeAtPos(CleanCursorPos,true);
ContextPos:=CleanCursorPos;
// The context node might be in front of the CleanCursorPos
// For example: A.|end; In this case the statement ends at the point.
// Check the atom in front
ReadPriorAtomSafe(CleanCursorPos);
if (CurPos.Flag<>cafNone) then begin
ContextPos:=CurPos.EndPos;
if (CurPos.Flag in [cafPoint,cafRoundBracketOpen,cafEdgedBracketOpen])
or UpAtomIs('INHERITED') then
ContextPos:=CurPos.StartPos;
end;
CursorNode:=BuildSubTreeAndFindDeepestNodeAtPos(ContextPos,true);
if CurrentIdentifierList<>nil then begin
StartContext:=CurrentIdentifierList.StartContext;
StartContext.Node:=CursorNode;