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; until false;
ReadNextAtom; ReadNextAtom;
if CurPos.StartPos<CleanPos then if CurPos.StartPos<CleanPos then
exit; break;
// first atom of node is behind CleanPos => try prior node // first atom of node is behind CleanPos => try prior node
Node:=Node.Prior; Node:=Node.Prior;
until false; until false;

View File

@ -1726,6 +1726,7 @@ procedure TIdentCompletionTool.ParseSourceTillCollectionStart(
out CursorNode: TCodeTreeNode; out IdentStartPos, IdentEndPos: integer); out CursorNode: TCodeTreeNode; out IdentStartPos, IdentEndPos: integer);
var var
StartContext: TFindContext; StartContext: TFindContext;
ContextPos: Integer;
begin begin
CleanCursorPos:=0; CleanCursorPos:=0;
CursorNode:=nil; CursorNode:=nil;
@ -1740,7 +1741,19 @@ begin
[btSetIgnoreErrorPos]); [btSetIgnoreErrorPos]);
// find node at position // 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 if CurrentIdentifierList<>nil then begin
StartContext:=CurrentIdentifierList.StartContext; StartContext:=CurrentIdentifierList.StartContext;
StartContext.Node:=CursorNode; StartContext.Node:=CursorNode;