IDE: codebrowser: clean up

git-svn-id: trunk@24393 -
This commit is contained in:
mattias 2010-04-04 14:25:43 +00:00
parent 9cdf3fa212
commit 77c705410a

View File

@ -1867,9 +1867,12 @@ var
end; end;
function Shorten(const s: string): string; function Shorten(const s: string): string;
const
MAX_LEN=100;
begin begin
Result:=DbgStr(s); Result:=DbgStr(s);
if length(Result)>100 then Result:=copy(Result,1,100)+' ...'; if Length(Result)>MAX_LEN then
Result:=LeftStr(Result, MAX_LEN)+'...';
end; end;
procedure GetNodeDescription(CTNode: TCodeTreeNode; procedure GetNodeDescription(CTNode: TCodeTreeNode;
@ -2106,8 +2109,7 @@ var
List.DeleteUnit(NewUnit); List.DeleteUnit(NewUnit);
NewUnit:=nil; NewUnit:=nil;
if OldDestParentList=nil then begin if OldDestParentList=nil then begin
DestParentList.Free; FreeAndNil(DestParentList);
DestParentList:=nil;
end; end;
end; end;
if (NewUnit<>nil) and (NewUnit.UnitList=nil) and (List<>nil) then if (NewUnit<>nil) and (NewUnit.UnitList=nil) and (List<>nil) then
@ -2169,8 +2171,7 @@ var
NewList:=nil; NewList:=nil;
if (OldDestParentList=nil) and (DestParentList<>nil) if (OldDestParentList=nil) and (DestParentList<>nil)
and DestParentList.IsEmpty then begin and DestParentList.IsEmpty then begin
DestParentList.Free; FreeAndNil(DestParentList);
DestParentList:=nil;
end; end;
end; end;
// update DestParentList // update DestParentList
@ -2180,13 +2181,37 @@ var
end; end;
procedure AddTreeNodes(CodeNode: TObject; ParentViewNode: TTreeNode); procedure AddTreeNodes(CodeNode: TObject; ParentViewNode: TTreeNode);
// create visual nodes (TTreeNode)
{off $DEFINE DisableTreeViewNodes}
var var
List: TCodeBrowserUnitList;
ListName: String;
Node: TAVLTreeNode;
TVNode: TTreeNode; TVNode: TTreeNode;
procedure RecursiveAdd(Tree: TAVLTree);
var
Node: TAVLTreeNode;
begin
if Tree<>nil then begin
Node:=Tree.FindLowest;
while Node<>nil do begin
AddTreeNodes(TObject(Node.Data), TVNode);
Node:=Tree.FindSuccessor(Node);
end;
end;
end;
{off $DEFINE DisableTreeViewNodes}
procedure AddToTreeView(Name: String);
begin
{$IFNDEF DisableTreeViewNodes}
TVNode:=BrowseTreeView.Items.AddChildObject(
ParentViewNode, Name, CodeNode);
TVNode.ImageIndex:=GetNodeImage(CodeNode);
TVNode.SelectedIndex:=TVNode.ImageIndex;
{$ENDIF}
end;
// create visual nodes (TTreeNode)
var
CurList: TCodeBrowserUnitList;
CurListName: String;
CurUnit: TCodeBrowserUnit; CurUnit: TCodeBrowserUnit;
CurUnitName: String; CurUnitName: String;
CurTool: TStandardCodeTool; CurTool: TStandardCodeTool;
@ -2197,93 +2222,50 @@ var
ExpandParent:=true; ExpandParent:=true;
//DebugLn(['AddTreeNodes ',DbgSName(CodeNode)]); //DebugLn(['AddTreeNodes ',DbgSName(CodeNode)]);
TVNode:=ParentViewNode; TVNode:=ParentViewNode;
if CodeNode is TCodeBrowserUnitList then begin if CodeNode is TCodeBrowserUnitList then begin
// unit list CurList:=TCodeBrowserUnitList(CodeNode);
List:=TCodeBrowserUnitList(CodeNode); //DebugLn(['AddTreeNodes ',CurList.Owner]);
//DebugLn(['AddTreeNodes ',List.Owner]); if CurList.Owner=CodeBrowserHidden then begin
if List.Owner=CodeBrowserHidden then begin
TVNode:=ParentViewNode; TVNode:=ParentViewNode;
end else begin end else begin
ListName:=ListOwnerToText(List.Owner); CurListName:=ListOwnerToText(CurList.Owner);
inc(NewPackageCount); inc(NewPackageCount);
{$IFNDEF DisableTreeViewNodes} AddToTreeView(CurListName);
TVNode:=BrowseTreeView.Items.AddChildObject(
ParentViewNode,ListName,CodeNode);
TVNode.ImageIndex:=GetNodeImage(CodeNode);
TVNode.SelectedIndex:=TVNode.ImageIndex;
{$ENDIF}
end;
if List.UnitLists<>nil then begin
Node:=List.UnitLists.FindLowest;
while Node<>nil do begin
AddTreeNodes(TObject(Node.Data),TVNode);
Node:=List.UnitLists.FindSuccessor(Node);
end;
end;
if List.Units<>nil then begin
Node:=List.Units.FindLowest;
while Node<>nil do begin
AddTreeNodes(TObject(Node.Data),TVNode);
Node:=List.Units.FindSuccessor(Node);
end;
end; end;
RecursiveAdd(CurList.UnitLists);
RecursiveAdd(CurList.Units);
end end
else if CodeNode is TCodeBrowserUnit then begin else if CodeNode is TCodeBrowserUnit then begin
// unit
CurUnit:=TCodeBrowserUnit(CodeNode); CurUnit:=TCodeBrowserUnit(CodeNode);
CurTool:=nil; CurTool:=nil;
if CurUnit.Filename<>'' then if CurUnit.Filename<>'' then
CurTool:=GetCodeTool(CurUnit); CurTool:=GetCodeTool(CurUnit);
if CurTool<>nil then begin if CurTool<>nil then begin
// add a treenode for this unit // add a tree node for this unit
CurUnitName:=TCodeTool(CurTool).GetCachedSourceName; CurUnitName:=TCodeTool(CurTool).GetCachedSourceName;
if CurUnitName='' then if CurUnitName='' then
CurUnitName:=ExtractFileNameOnly(CurTool.MainFilename); CurUnitName:=ExtractFileNameOnly(CurTool.MainFilename);
inc(NewUnitCount); inc(NewUnitCount);
{$IFNDEF DisableTreeViewNodes} AddToTreeView(CurUnitName);
TVNode:=BrowseTreeView.Items.AddChildObject(ParentViewNode,
CurUnitName,CodeNode);
TVNode.ImageIndex:=GetNodeImage(CodeNode);
TVNode.SelectedIndex:=TVNode.ImageIndex;
{$ENDIF}
end else begin end else begin
// do not add a tree node for this unit // do not add a tree node for this unit
TVNode:=ParentViewNode; TVNode:=ParentViewNode;
end; end;
// create tree nodes for code nodes // create tree nodes for code nodes
if CurUnit.ChildNodes<>nil then begin RecursiveAdd(CurUnit.ChildNodes);
Node:=CurUnit.ChildNodes.FindLowest;
while Node<>nil do begin
AddTreeNodes(TObject(Node.Data),TVNode);
Node:=CurUnit.ChildNodes.FindSuccessor(Node);
end;
end;
end end
else if CodeNode is TCodeBrowserNode then begin else if CodeNode is TCodeBrowserNode then begin
// code node
CurNode:=TCodeBrowserNode(CodeNode); CurNode:=TCodeBrowserNode(CodeNode);
if CurNode.Description<>'' then begin if CurNode.Description<>'' then begin
inc(NewIdentifierCount); inc(NewIdentifierCount);
//if (NewIdentifierCount mod 100)=0 then //if (NewIdentifierCount mod 100)=0 then
// DebugLn(['AddTreeNodes ',NewIdentifierCount,' ',CurNode.Description]); // DebugLn(['AddTreeNodes ',NewIdentifierCount,' ',CurNode.Description]);
{$IFNDEF DisableTreeViewNodes} AddToTreeView(CurNode.Description);
TVNode:=BrowseTreeView.Items.AddChildObject(ParentViewNode,
CurNode.Description,CodeNode);
TVNode.ImageIndex:=GetNodeImage(CodeNode);
TVNode.SelectedIndex:=TVNode.ImageIndex;
{$ENDIF}
// create tree nodes for child code nodes // create tree nodes for child code nodes
if CurNode.ChildNodes<>nil then begin RecursiveAdd(CurNode.ChildNodes);
Node:=CurNode.ChildNodes.FindLowest;
while Node<>nil do begin
AddTreeNodes(TObject(Node.Data),TVNode);
Node:=CurNode.ChildNodes.FindSuccessor(Node);
end;
end;
// do not expand unit nodes // do not expand unit nodes
if (TObject(ParentViewNode.Data) is TCodeBrowserUnit) then if TObject(ParentViewNode.Data) is TCodeBrowserUnit then
ExpandParent:=false; ExpandParent:=false;
end; end;
end; end;