codetools: fixed TCodeCompletionCodeTool.DeclareVariableNearBy class members

git-svn-id: trunk@31275 -
This commit is contained in:
mattias 2011-06-18 23:05:11 +00:00
parent 93a6c5de7b
commit 9fb8ba331a

View File

@ -5500,16 +5500,18 @@ var
begin begin
Result:=false; Result:=false;
{$IFDEF CTDEBUG} {$IFDEF CTDEBUG}
debugln(['TCodeCompletionCodeTool.DeclareVariableNearBy InsertPos=',dbgs(InsertPos),' Name="',VariableName,'" Type="',NewType,'" Unit=',NewUnitName]); debugln(['TCodeCompletionCodeTool.DeclareVariableNearBy InsertPos=',dbgs(InsertPos),' Name="',VariableName,'" Type="',NewType,'" Unit=',NewUnitName,' LevelPos=',dbgs(LevelPos)]);
{$ENDIF} {$ENDIF}
BuildTreeAndGetCleanPos(InsertPos,CleanCursorPos); BuildTreeAndGetCleanPos(InsertPos,CleanCursorPos);
CursorNode:=FindDeepestNodeAtPos(CleanCursorPos,true); CursorNode:=FindDeepestNodeAtPos(CleanCursorPos,true);
CaretToCleanPos(LevelPos,LevelCleanPos); CaretToCleanPos(LevelPos,LevelCleanPos);
SourceChangeCache.MainScanner:=Scanner; if LevelCleanPos>0 then begin
Node:=CursorNode; Node:=FindDeepestNodeAtPos(LevelCleanPos,false);
while Node<>nil do begin while Node<>nil do begin
//debugln(['TCodeCompletionCodeTool.DeclareVariableNearBy Node=',Node.DescAsString]);
if Node.Desc in AllClassObjects then begin if Node.Desc in AllClassObjects then begin
// class member // class member
debugln(['TCodeCompletionCodeTool.DeclareVariableNearBy class member']);
// initialize class for code completion // initialize class for code completion
InitClassCompletion(Node,SourceChangeCache); InitClassCompletion(Node,SourceChangeCache);
// check if variable already exists // check if variable already exists
@ -5540,6 +5542,9 @@ begin
end; end;
Node:=Node.Parent; Node:=Node.Parent;
end; end;
end;
SourceChangeCache.MainScanner:=Scanner;
Node:=CursorNode;
Result:=AddLocalVariable(CleanCursorPos,1,VariableName,NewType,NewUnitName, Result:=AddLocalVariable(CleanCursorPos,1,VariableName,NewType,NewUnitName,
NewPos,NewTopLine,SourceChangeCache,LevelCleanPos); NewPos,NewTopLine,SourceChangeCache,LevelCleanPos);
end; end;