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