mirror of
https://gitlab.com/freepascal.org/lazarus/lazarus.git
synced 2025-08-18 20:59:08 +02:00
IDE: lazdoc: added utility function to find dom nodes
git-svn-id: trunk@12913 -
This commit is contained in:
parent
bc6dd44a80
commit
ec8cae645e
@ -32,7 +32,7 @@ interface
|
|||||||
|
|
||||||
uses
|
uses
|
||||||
Classes, SysUtils, LCLProc, FileUtil,
|
Classes, SysUtils, LCLProc, FileUtil,
|
||||||
CodeToolManager, CodeCache, FileProcs, AvgLvlTree,
|
CodeTree, CodeToolManager, CodeCache, FileProcs, AvgLvlTree,
|
||||||
Laz_DOM, Laz_XMLRead, Laz_XMLWrite,
|
Laz_DOM, Laz_XMLRead, Laz_XMLWrite,
|
||||||
MacroIntf, PackageIntf, LazHelpIntf, ProjectIntf, LazIDEIntf,
|
MacroIntf, PackageIntf, LazHelpIntf, ProjectIntf, LazIDEIntf,
|
||||||
IDEProcs, PackageDefs, EnvironmentOpts;
|
IDEProcs, PackageDefs, EnvironmentOpts;
|
||||||
@ -47,6 +47,9 @@ type
|
|||||||
ChangeStep: integer;// the CodeBuffer.ChangeStep value, when Doc was build
|
ChangeStep: integer;// the CodeBuffer.ChangeStep value, when Doc was build
|
||||||
CodeBuffer: TCodeBuffer;
|
CodeBuffer: TCodeBuffer;
|
||||||
destructor Destroy; override;
|
destructor Destroy; override;
|
||||||
|
function GetModuleNode: TDOMNode;
|
||||||
|
function GetFirstElement: TDOMNode;
|
||||||
|
function GetElementWithName(const ElementName: string): TDOMNode;
|
||||||
end;
|
end;
|
||||||
|
|
||||||
TLazDocChangeEvent =
|
TLazDocChangeEvent =
|
||||||
@ -82,6 +85,7 @@ type
|
|||||||
Context: TPascalHelpContextList): string;
|
Context: TPascalHelpContextList): string;
|
||||||
function GetFPDocFilenameForSource(SrcFilename: string;
|
function GetFPDocFilenameForSource(SrcFilename: string;
|
||||||
ResolveIncludeFiles: Boolean): string;
|
ResolveIncludeFiles: Boolean): string;
|
||||||
|
function CodeNodeToElementName(Tool: TCodeTool; CodeNode: TCodeTreeNode): string;
|
||||||
public
|
public
|
||||||
// Event lists
|
// Event lists
|
||||||
procedure RemoveAllHandlersOfObject(AnObject: TObject);
|
procedure RemoveAllHandlersOfObject(AnObject: TObject);
|
||||||
@ -121,6 +125,49 @@ begin
|
|||||||
inherited Destroy;
|
inherited Destroy;
|
||||||
end;
|
end;
|
||||||
|
|
||||||
|
function TLazFPDocFile.GetModuleNode: TDOMNode;
|
||||||
|
begin
|
||||||
|
Result:=nil;
|
||||||
|
if Doc=nil then exit;
|
||||||
|
|
||||||
|
// get first node
|
||||||
|
Result := Doc.FindNode('fpdoc-descriptions');
|
||||||
|
if Result=nil then exit;
|
||||||
|
|
||||||
|
// proceed to package
|
||||||
|
Result := Result.FirstChild;
|
||||||
|
if Result=nil then exit;
|
||||||
|
|
||||||
|
// proceed to module
|
||||||
|
Result := Result.FirstChild;
|
||||||
|
while (Result<>nil) and (Result.NodeName <> 'module') do
|
||||||
|
Result := Result.NextSibling;
|
||||||
|
end;
|
||||||
|
|
||||||
|
function TLazFPDocFile.GetFirstElement: TDOMNode;
|
||||||
|
begin
|
||||||
|
//get first module node
|
||||||
|
Result := GetModuleNode;
|
||||||
|
if Result=nil then exit;
|
||||||
|
|
||||||
|
//proceed to element
|
||||||
|
Result := Result.FirstChild;
|
||||||
|
while Result.NodeName <> 'element' do
|
||||||
|
Result := Result.NextSibling;
|
||||||
|
end;
|
||||||
|
|
||||||
|
function TLazFPDocFile.GetElementWithName(const ElementName: string): TDOMNode;
|
||||||
|
begin
|
||||||
|
Result:=GetFirstElement;
|
||||||
|
while Result<>nil do begin
|
||||||
|
if (Result is TDomElement)
|
||||||
|
and (CompareText(TDomElement(Result).GetAttribute('name'),ElementName)=0)
|
||||||
|
then
|
||||||
|
exit;
|
||||||
|
Result:=Result.NextSibling;
|
||||||
|
end;
|
||||||
|
end;
|
||||||
|
|
||||||
procedure TLazDocManager.AddHandler(HandlerType: TLazDocManagerHandler;
|
procedure TLazDocManager.AddHandler(HandlerType: TLazDocManagerHandler;
|
||||||
const AMethod: TMethod; AsLast: boolean);
|
const AMethod: TMethod; AsLast: boolean);
|
||||||
begin
|
begin
|
||||||
@ -346,8 +393,40 @@ begin
|
|||||||
Result:=SearchFileInPath(FPDocName,'',SearchPath,';',ctsfcAllCase);
|
Result:=SearchFileInPath(FPDocName,'',SearchPath,';',ctsfcAllCase);
|
||||||
end;
|
end;
|
||||||
|
|
||||||
procedure TLazDocManager.FreeDocs;
|
function TLazDocManager.CodeNodeToElementName(Tool: TCodeTool;
|
||||||
|
CodeNode: TCodeTreeNode): string;
|
||||||
|
var
|
||||||
|
NodeName: String;
|
||||||
begin
|
begin
|
||||||
|
Result:='';
|
||||||
|
while CodeNode<>nil do begin
|
||||||
|
case CodeNode.Desc of
|
||||||
|
ctnVarDefinition, ctnConstDefinition, ctnTypeDefinition, ctnGenericType:
|
||||||
|
NodeName:=Tool.ExtractDefinitionName(CodeNode);
|
||||||
|
ctnProperty:
|
||||||
|
NodeName:=Tool.ExtractPropName(CodeNode,false);
|
||||||
|
ctnProcedure:
|
||||||
|
NodeName:=Tool.ExtractProcName(CodeNode,[]);
|
||||||
|
else NodeName:='';
|
||||||
|
end;
|
||||||
|
if NodeName<>'' then begin
|
||||||
|
if Result<>'' then
|
||||||
|
Result:='.'+Result;
|
||||||
|
Result:=NodeName+Result;
|
||||||
|
end;
|
||||||
|
CodeNode:=CodeNode.Parent;
|
||||||
|
end;
|
||||||
|
end;
|
||||||
|
|
||||||
|
procedure TLazDocManager.FreeDocs;
|
||||||
|
var
|
||||||
|
AVLNode: TAvgLvlTreeNode;
|
||||||
|
begin
|
||||||
|
AVLNode:=FDocs.FindLowest;
|
||||||
|
while AVLNode<>nil do begin
|
||||||
|
CallDocChangeEvents(ldmhDocChanging,TLazFPDocFile(AVLNode.Data));
|
||||||
|
AVLNode:=FDocs.FindSuccessor(AVLNode);
|
||||||
|
end;
|
||||||
FDocs.FreeAndClear;
|
FDocs.FreeAndClear;
|
||||||
end;
|
end;
|
||||||
|
|
||||||
|
@ -212,7 +212,7 @@ begin
|
|||||||
GetMem(FormatList,SizeOf(TClipboardFormat)*FCount);
|
GetMem(FormatList,SizeOf(TClipboardFormat)*FCount);
|
||||||
for i:=0 to FCount-1 do
|
for i:=0 to FCount-1 do
|
||||||
FormatList[i]:=FData[i].FormatID;
|
FormatList[i]:=FData[i].FormatID;
|
||||||
//DebugLn('[TClipboard.GetOwnerShip] A ',ClipboardTypeName[ClipboardType],' Allocated=',FAllocated);
|
//DebugLn(['[TClipboard.GetOwnerShip] A ',ClipboardTypeName[ClipboardType],' Allocated=',FAllocated]);
|
||||||
FAllocated:=true;
|
FAllocated:=true;
|
||||||
if not ClipboardGetOwnerShip(ClipboardType,@InternalOnRequest,FCount,
|
if not ClipboardGetOwnerShip(ClipboardType,@InternalOnRequest,FCount,
|
||||||
FormatList)
|
FormatList)
|
||||||
|
Loading…
Reference in New Issue
Block a user