mirror of
https://gitlab.com/freepascal.org/lazarus/lazarus.git
synced 2025-08-28 03:21:44 +02:00
IDE: codebrowser: load description only if node added to treeview
git-svn-id: trunk@46865 -
This commit is contained in:
parent
3b929dc9d2
commit
02afa460c3
@ -62,7 +62,7 @@ type
|
|||||||
property CodePos: TCodePosition read FCodePos write FCodePos;
|
property CodePos: TCodePosition read FCodePos write FCodePos;
|
||||||
property ParentNode: TCodeBrowserNode read FParentNode;
|
property ParentNode: TCodeBrowserNode read FParentNode;
|
||||||
property ChildNodes: TAVLTree read FChildNodes;
|
property ChildNodes: TAVLTree read FChildNodes;
|
||||||
property Description: string read FDescription;
|
property Description: string read FDescription write FDescription;
|
||||||
property Identifier: string read FIdentifier;
|
property Identifier: string read FIdentifier;
|
||||||
end;
|
end;
|
||||||
|
|
||||||
|
@ -334,8 +334,10 @@ type
|
|||||||
Expand: boolean);
|
Expand: boolean);
|
||||||
procedure CopyNode(TVNode: TTreeNode; NodeType: TCopyNodeType);
|
procedure CopyNode(TVNode: TTreeNode; NodeType: TCopyNodeType);
|
||||||
function GetCodeTool(AnUnit: TCodeBrowserUnit): TStandardCodeTool;
|
function GetCodeTool(AnUnit: TCodeBrowserUnit): TStandardCodeTool;
|
||||||
|
procedure GetNodeIdentifier(Tool: TStandardCodeTool;
|
||||||
|
CTNode: TCodeTreeNode; out Identifier: string);
|
||||||
procedure GetNodeDescription(Tool: TStandardCodeTool;
|
procedure GetNodeDescription(Tool: TStandardCodeTool;
|
||||||
CTNode: TCodeTreeNode; out Description, Identifier: string);
|
CTNode: TCodeTreeNode; Identifier: string; out Description: string);
|
||||||
function GetSelectedUnit: TCodeBrowserUnit;
|
function GetSelectedUnit: TCodeBrowserUnit;
|
||||||
function GetSelectedPackage: TLazPackage;
|
function GetSelectedPackage: TLazPackage;
|
||||||
function GetCurUnitInSrcEditor(out FileOwner: TObject;
|
function GetCurUnitInSrcEditor(out FileOwner: TObject;
|
||||||
@ -1864,8 +1866,55 @@ begin
|
|||||||
//DebugLn(['TCodeBrowserView.GetCodeTool END ',AnUnit.Filename,' ',Result<>nil]);
|
//DebugLn(['TCodeBrowserView.GetCodeTool END ',AnUnit.Filename,' ',Result<>nil]);
|
||||||
end;
|
end;
|
||||||
|
|
||||||
|
procedure TCodeBrowserView.GetNodeIdentifier(Tool: TStandardCodeTool;
|
||||||
|
CTNode: TCodeTreeNode; out Identifier: string);
|
||||||
|
|
||||||
|
function Shorten(const s: string): string;
|
||||||
|
const
|
||||||
|
MAX_LEN=100;
|
||||||
|
begin
|
||||||
|
Result:=DbgStr(s);
|
||||||
|
if Length(Result)>MAX_LEN then
|
||||||
|
Result:=LeftStr(Result, MAX_LEN)+'...';
|
||||||
|
end;
|
||||||
|
|
||||||
|
const
|
||||||
|
NodeFlags = [];
|
||||||
|
begin
|
||||||
|
if CTNode.StartPos>=CTNode.EndPos then begin
|
||||||
|
Identifier:='';
|
||||||
|
exit;
|
||||||
|
end;
|
||||||
|
case CTNode.Desc of
|
||||||
|
ctnProcedure:
|
||||||
|
begin
|
||||||
|
Identifier:=Tool.ExtractProcName(CTNode,ProcIdentifierFlags);
|
||||||
|
end;
|
||||||
|
ctnVarDefinition:
|
||||||
|
begin
|
||||||
|
Identifier:=Tool.ExtractDefinitionName(CTNode);
|
||||||
|
end;
|
||||||
|
ctnConstDefinition:
|
||||||
|
begin
|
||||||
|
Identifier:=Tool.ExtractDefinitionName(CTNode);
|
||||||
|
end;
|
||||||
|
ctnTypeDefinition,ctnGenericType:
|
||||||
|
begin
|
||||||
|
Identifier:=Tool.ExtractDefinitionName(CTNode);
|
||||||
|
end;
|
||||||
|
ctnProperty:
|
||||||
|
begin
|
||||||
|
Identifier:=Tool.ExtractPropName(CTNode,false);
|
||||||
|
end;
|
||||||
|
ctnEnumIdentifier:
|
||||||
|
begin
|
||||||
|
Identifier:=Tool.ExtractIdentifier(CTNode.StartPos);
|
||||||
|
end;
|
||||||
|
end;
|
||||||
|
end;
|
||||||
|
|
||||||
procedure TCodeBrowserView.GetNodeDescription(Tool: TStandardCodeTool;
|
procedure TCodeBrowserView.GetNodeDescription(Tool: TStandardCodeTool;
|
||||||
CTNode: TCodeTreeNode; out Description, Identifier: string);
|
CTNode: TCodeTreeNode; Identifier: string; out Description: string);
|
||||||
|
|
||||||
function Shorten(const s: string): string;
|
function Shorten(const s: string): string;
|
||||||
const
|
const
|
||||||
@ -1882,30 +1931,25 @@ var
|
|||||||
Inheritance: String;
|
Inheritance: String;
|
||||||
begin
|
begin
|
||||||
if CTNode.StartPos>=CTNode.EndPos then begin
|
if CTNode.StartPos>=CTNode.EndPos then begin
|
||||||
Identifier:='';
|
|
||||||
Description:='';
|
Description:='';
|
||||||
exit;
|
exit;
|
||||||
end;
|
end;
|
||||||
case CTNode.Desc of
|
case CTNode.Desc of
|
||||||
ctnProcedure:
|
ctnProcedure:
|
||||||
begin
|
begin
|
||||||
Identifier:=Tool.ExtractProcName(CTNode,ProcIdentifierFlags);
|
|
||||||
Description:=Tool.ExtractProcHead(CTNode,ProcDescFlags);
|
Description:=Tool.ExtractProcHead(CTNode,ProcDescFlags);
|
||||||
end;
|
end;
|
||||||
ctnVarDefinition:
|
ctnVarDefinition:
|
||||||
begin
|
begin
|
||||||
Identifier:=Tool.ExtractDefinitionName(CTNode);
|
|
||||||
Description:='var '+Identifier
|
Description:='var '+Identifier
|
||||||
+' : '+Shorten(Tool.ExtractDefinitionNodeType(CTNode));
|
+' : '+Shorten(Tool.ExtractDefinitionNodeType(CTNode));
|
||||||
end;
|
end;
|
||||||
ctnConstDefinition:
|
ctnConstDefinition:
|
||||||
begin
|
begin
|
||||||
Identifier:=Tool.ExtractDefinitionName(CTNode);
|
|
||||||
Description:='const '+Shorten(Tool.ExtractNode(CTNode,NodeFlags));
|
Description:='const '+Shorten(Tool.ExtractNode(CTNode,NodeFlags));
|
||||||
end;
|
end;
|
||||||
ctnTypeDefinition,ctnGenericType:
|
ctnTypeDefinition,ctnGenericType:
|
||||||
begin
|
begin
|
||||||
Identifier:=Tool.ExtractDefinitionName(CTNode);
|
|
||||||
Description:='type '+Identifier;
|
Description:='type '+Identifier;
|
||||||
if CTNode.FirstChild<>nil then begin
|
if CTNode.FirstChild<>nil then begin
|
||||||
case CTNode.FirstChild.Desc of
|
case CTNode.FirstChild.Desc of
|
||||||
@ -1940,12 +1984,10 @@ begin
|
|||||||
end;
|
end;
|
||||||
ctnProperty:
|
ctnProperty:
|
||||||
begin
|
begin
|
||||||
Identifier:=Tool.ExtractPropName(CTNode,false);
|
|
||||||
Description:='property '+Shorten(Tool.ExtractProperty(CTNode,PropDescFlags));
|
Description:='property '+Shorten(Tool.ExtractProperty(CTNode,PropDescFlags));
|
||||||
end;
|
end;
|
||||||
ctnEnumIdentifier:
|
ctnEnumIdentifier:
|
||||||
begin
|
begin
|
||||||
Identifier:=Tool.ExtractIdentifier(CTNode.StartPos);
|
|
||||||
Description:='enum '+Identifier;
|
Description:='enum '+Identifier;
|
||||||
end;
|
end;
|
||||||
end;
|
end;
|
||||||
@ -2015,10 +2057,11 @@ var
|
|||||||
if (CTNode.Parent.Desc=ctnClassProtected) and (not ShowProtected)
|
if (CTNode.Parent.Desc=ctnClassProtected) and (not ShowProtected)
|
||||||
then
|
then
|
||||||
exit;
|
exit;
|
||||||
GetNodeDescription(CTTool,CTNode,ChildDescription,ChildIdentifier);
|
GetNodeIdentifier(CTTool,CTNode,ChildIdentifier);
|
||||||
|
|
||||||
if IdentifierFitsFilter(cblIdentifiers,ChildIdentifier) then begin
|
if IdentifierFitsFilter(cblIdentifiers,ChildIdentifier) then begin
|
||||||
inc(ShownIdentifierCount);
|
inc(ShownIdentifierCount);
|
||||||
|
GetNodeDescription(CTTool,CTNode,ChildIdentifier,ChildDescription);
|
||||||
NewChildNode:=ParentBrowserNode.AddNode(ChildDescription,ChildIdentifier);
|
NewChildNode:=ParentBrowserNode.AddNode(ChildDescription,ChildIdentifier);
|
||||||
if NewChildNode<>nil then begin
|
if NewChildNode<>nil then begin
|
||||||
NewChildNode.Desc:=CTNode.Desc;
|
NewChildNode.Desc:=CTNode.Desc;
|
||||||
@ -2049,8 +2092,8 @@ var
|
|||||||
DestUnit:=TCodeBrowserUnit.Create('');
|
DestUnit:=TCodeBrowserUnit.Create('');
|
||||||
CurUnit:=TCodeBrowserUnit(DestUnit);
|
CurUnit:=TCodeBrowserUnit(DestUnit);
|
||||||
//DebugLn(['AddIdentifierNode ',CTNode.DescAsString,' Description="',Description,'"']);
|
//DebugLn(['AddIdentifierNode ',CTNode.DescAsString,' Description="',Description,'"']);
|
||||||
GetNodeDescription(CTTool,CTNode,Description,Identifier);
|
GetNodeIdentifier(CTTool,CTNode,Identifier);
|
||||||
NewNode:=CurUnit.AddNode(Description,Identifier);
|
NewNode:=CurUnit.AddNode('',Identifier);
|
||||||
{$IFDEF VerboseCodeBrowser}
|
{$IFDEF VerboseCodeBrowser}
|
||||||
if (length(Description)>100) then
|
if (length(Description)>100) then
|
||||||
debugln(['AddIdentifierNode WARNING: big description ',CurUnit.Filename,' desc=',Description]);
|
debugln(['AddIdentifierNode WARNING: big description ',CurUnit.Filename,' desc=',Description]);
|
||||||
@ -2088,6 +2131,9 @@ var
|
|||||||
// ToDo: remove nodes later
|
// ToDo: remove nodes later
|
||||||
CurUnit.DeleteNode(NewNode);
|
CurUnit.DeleteNode(NewNode);
|
||||||
end else begin
|
end else begin
|
||||||
|
// keep node, set Description
|
||||||
|
GetNodeDescription(CTTool,CTNode,Identifier,Description);
|
||||||
|
NewNode.Description:=Description;
|
||||||
inc(ShownIdentifierCount);
|
inc(ShownIdentifierCount);
|
||||||
end;
|
end;
|
||||||
end;
|
end;
|
||||||
|
@ -597,15 +597,15 @@ msgstr "Verde"
|
|||||||
|
|
||||||
#: lclstrconsts.rsgridfiledoesnotexist
|
#: lclstrconsts.rsgridfiledoesnotexist
|
||||||
msgid "Grid file doesn't exist"
|
msgid "Grid file doesn't exist"
|
||||||
msgstr "Il file della griglia non esiste"
|
msgstr ""
|
||||||
|
|
||||||
#: lclstrconsts.rsgridhasnocols
|
#: lclstrconsts.rsgridhasnocols
|
||||||
msgid "Cannot insert rows into a grid when it has no columns"
|
msgid "Cannot insert rows into a grid when it has no columns"
|
||||||
msgstr "Non si possono inserire righe in una grigli che non ha nessuna riga"
|
msgstr ""
|
||||||
|
|
||||||
#: lclstrconsts.rsgridhasnorows
|
#: lclstrconsts.rsgridhasnorows
|
||||||
msgid "Cannot insert columns into a grid when it has no rows"
|
msgid "Cannot insert columns into a grid when it has no rows"
|
||||||
msgstr "Non si possono inserire colonne in una griglia che non ha nessuna riga"
|
msgstr ""
|
||||||
|
|
||||||
#: lclstrconsts.rsgridindexoutofrange
|
#: lclstrconsts.rsgridindexoutofrange
|
||||||
msgid "Grid index out of range."
|
msgid "Grid index out of range."
|
||||||
@ -1493,3 +1493,4 @@ msgstr "Simbolo token errato: atteso %s, trovato %s"
|
|||||||
#: lclstrconsts.sparwrongtokentype
|
#: lclstrconsts.sparwrongtokentype
|
||||||
msgid "Wrong token type: %s expected but %s found"
|
msgid "Wrong token type: %s expected but %s found"
|
||||||
msgstr "Tipo token errato: atteso %s, trovato %s"
|
msgstr "Tipo token errato: atteso %s, trovato %s"
|
||||||
|
|
||||||
|
@ -601,15 +601,15 @@ msgstr "Тёмно-зелёный"
|
|||||||
|
|
||||||
#: lclstrconsts.rsgridfiledoesnotexist
|
#: lclstrconsts.rsgridfiledoesnotexist
|
||||||
msgid "Grid file doesn't exist"
|
msgid "Grid file doesn't exist"
|
||||||
msgstr "Файл Grid не существует"
|
msgstr ""
|
||||||
|
|
||||||
#: lclstrconsts.rsgridhasnocols
|
#: lclstrconsts.rsgridhasnocols
|
||||||
msgid "Cannot insert rows into a grid when it has no columns"
|
msgid "Cannot insert rows into a grid when it has no columns"
|
||||||
msgstr "Невозможно вставить строки, если отсутствуют столбцы"
|
msgstr ""
|
||||||
|
|
||||||
#: lclstrconsts.rsgridhasnorows
|
#: lclstrconsts.rsgridhasnorows
|
||||||
msgid "Cannot insert columns into a grid when it has no rows"
|
msgid "Cannot insert columns into a grid when it has no rows"
|
||||||
msgstr "Невозможно вставить столбцы, если отсутствуют строки"
|
msgstr ""
|
||||||
|
|
||||||
#: lclstrconsts.rsgridindexoutofrange
|
#: lclstrconsts.rsgridindexoutofrange
|
||||||
msgid "Grid index out of range."
|
msgid "Grid index out of range."
|
||||||
|
Loading…
Reference in New Issue
Block a user