IDE: use unit dialog: simplified DetermineUsesSection

git-svn-id: trunk@35685 -
This commit is contained in:
mattias 2012-03-03 19:11:03 +00:00
parent 14d32a0423
commit 009b5cfb04

View File

@ -377,36 +377,26 @@ procedure TUseUnitDialog.DetermineUsesSection(ACode: TCodeBuffer; ACursorPos: TP
var var
CursorPos: TCodeXYPosition; CursorPos: TCodeXYPosition;
CleanCursorPos: Integer; CleanCursorPos: Integer;
CursorNode: TCodeTreeNode;
ImplUsesNode: TCodeTreeNode; ImplUsesNode: TCodeTreeNode;
i: Integer; i: Integer;
Tool: TCodeTool;
ImplNode: TCodeTreeNode;
begin begin
if not CodeToolBoss.InitCurCodeTool(ACode) then Exit; CodeToolBoss.Explore(ACode,Tool,false);
with CodeToolBoss.CurCodeTool do if Tool=nil then exit;
begin // collect implementation use unit nodes
CursorPos := CodeXYPosition(ACursorPos.X, ACursorPos.Y, ACode); ImplUsesNode := Tool.FindImplementationUsesSection;
ActivateGlobalWriteLock; if Assigned(ImplUsesNode) then
try for i := 0 to FImplUsedUnits.Count - 1 do
// build code tree FImplUsedUnits.Objects[i] := ImplUsesNode;
BuildTreeAndGetCleanPos(trTillCursor,lsrEnd,CursorPos,CleanCursorPos, // check if cursor is behind interface section
[btSetIgnoreErrorPos,btLoadDirtySource,btCursorPosOutAllowed]); CursorPos := CodeXYPosition(ACursorPos.X, ACursorPos.Y, ACode);
if (Tree.Root = nil) or (Tree.Root.StartPos > CleanCursorPos) then Exit; Tool.CaretToCleanPos(CursorPos,CleanCursorPos);
ImplUsesNode := FindImplementationUsesSection; ImplNode:=Tool.FindImplementationNode;
if Assigned(ImplUsesNode) then if (ImplNode<>nil) and (CleanCursorPos>ImplNode.StartPos) then
for i := 0 to FImplUsedUnits.Count - 1 do SectionRadioGroup.ItemIndex := 1;
FImplUsedUnits.Objects[i] := ImplUsesNode; // update
// find CodeTreeNode at cursor SectionRadioGroup.OnClick(SectionRadioGroup);
CursorNode := BuildSubTreeAndFindDeepestNodeAtPos(CleanCursorPos, True);
if (CursorNode.Desc in [ctnImplementation,ctnInitialization,ctnFinalization])
or CursorNode.HasParentOfType(ctnImplementation)
or CursorNode.HasParentOfType(ctnInitialization)
or CursorNode.HasParentOfType(ctnFinalization) then
SectionRadioGroup.ItemIndex := 1;
SectionRadioGroup.OnClick(SectionRadioGroup);
finally
DeactivateGlobalWriteLock
end;
end;
end; end;
procedure TUseUnitDialog.FillAvailableUnitsList; procedure TUseUnitDialog.FillAvailableUnitsList;