IDE: fpdoc editor: implemented editing unit descriptions

git-svn-id: trunk@21261 -
This commit is contained in:
mattias 2009-08-17 12:25:33 +00:00
parent 3a20a03570
commit 4ea1f0a28b

View File

@ -485,6 +485,20 @@ function TLazFPDocFile.GetElementWithName(const ElementName: string;
var var
ModuleNode: TDOMNode; ModuleNode: TDOMNode;
begin begin
// get first module node
ModuleNode:=GetModuleNode;
if ModuleNode=nil then begin
DebugLn(['TLazFPDocFile.GetElementWithName create failed: missing module name. ElementName=',ElementName]);
exit;
end;
// check module name
if (ModuleNode is TDomElement)
and (SysUtils.CompareText(TDomElement(ModuleNode).GetAttribute('name'),ElementName)=0)
then begin
Result:=ModuleNode;
exit;
end;
// check elements
Result:=GetFirstElement; Result:=GetFirstElement;
//DebugLn(['TLazFPDocFile.GetElementWithName ',ElementName,' GetFirstElement=',GetFirstElement<>nil]); //DebugLn(['TLazFPDocFile.GetElementWithName ',ElementName,' GetFirstElement=',GetFirstElement<>nil]);
while Result<>nil do begin while Result<>nil do begin
@ -498,11 +512,6 @@ begin
end; end;
if (Result=nil) and CreateIfNotExists then begin if (Result=nil) and CreateIfNotExists then begin
DebugLn(['TLazFPDocFile.GetElementWithName creating ',ElementName]); DebugLn(['TLazFPDocFile.GetElementWithName creating ',ElementName]);
ModuleNode:=GetModuleNode;
if ModuleNode=nil then begin
DebugLn(['TLazFPDocFile.GetElementWithName create failed: missing module name. ElementName=',ElementName]);
exit;
end;
Result:=Doc.CreateElement('element'); Result:=Doc.CreateElement('element');
DocChanging; DocChanging;
TDOMElement(Result).SetAttribute('name',ElementName); TDOMElement(Result).SetAttribute('name',ElementName);
@ -627,7 +636,6 @@ begin
if (Node.NodeType = ELEMENT_NODE) then if (Node.NodeType = ELEMENT_NODE) then
begin begin
S := Node.NodeName; S := Node.NodeName;
if S = FPDocItemNames[fpdiShort] then if S = FPDocItemNames[fpdiShort] then
Result[fpdiShort] := GetChildValuesAsString(Node); Result[fpdiShort] := GetChildValuesAsString(Node);
@ -1633,27 +1641,31 @@ var
NodeName: String; NodeName: String;
begin begin
Result:=''; Result:='';
while CodeNode<>nil do begin if CodeNode.Desc in AllSourceTypes then begin
case CodeNode.Desc of Result:=Tool.ExtractSourceName;
ctnVarDefinition, ctnConstDefinition, ctnTypeDefinition, ctnGenericType: end else begin
NodeName:=Tool.ExtractDefinitionName(CodeNode); while CodeNode<>nil do begin
ctnProperty: case CodeNode.Desc of
NodeName:=Tool.ExtractPropName(CodeNode,false); ctnVarDefinition, ctnConstDefinition, ctnTypeDefinition, ctnGenericType:
ctnProcedure: NodeName:=Tool.ExtractDefinitionName(CodeNode);
NodeName:=Tool.ExtractProcName(CodeNode,[]); ctnProperty:
ctnEnumIdentifier: NodeName:=Tool.ExtractPropName(CodeNode,false);
NodeName:=GetIdentifier(@Tool.Src[CodeNode.StartPos]); ctnProcedure:
ctnIdentifier: NodeName:=Tool.ExtractProcName(CodeNode,[]);
if Tool.NodeIsResultType(CodeNode) then ctnEnumIdentifier:
NodeName:='Result'; NodeName:=GetIdentifier(@Tool.Src[CodeNode.StartPos]);
else NodeName:=''; ctnIdentifier:
if Tool.NodeIsResultType(CodeNode) then
NodeName:='Result';
else NodeName:='';
end;
if NodeName<>'' then begin
if Result<>'' then
Result:='.'+Result;
Result:=NodeName+Result;
end;
CodeNode:=CodeNode.Parent;
end; end;
if NodeName<>'' then begin
if Result<>'' then
Result:='.'+Result;
Result:=NodeName+Result;
end;
CodeNode:=CodeNode.Parent;
end; end;
end; end;
@ -1876,7 +1888,7 @@ begin
Node:=Node.Parent; Node:=Node.Parent;
end; end;
if (not (Node.Desc in if (not (Node.Desc in
(AllIdentifierDefinitions (AllIdentifierDefinitions+AllSourceTypes
+[ctnProperty,ctnProcedure,ctnEnumIdentifier]))) +[ctnProperty,ctnProcedure,ctnEnumIdentifier])))
and (not CurTool.NodeIsResultType(Node)) and (not CurTool.NodeIsResultType(Node))
then begin then begin
@ -1942,7 +1954,7 @@ begin
CHElement:=Chain.Add; CHElement:=Chain.Add;
CHElement.CodeXYPos:=CodePos^; CHElement.CodeXYPos:=CodePos^;
CHElement.CodeContext:=FindContext; CHElement.CodeContext:=FindContext;
DebugLn(['TCodeHelpManager.GetElementChain i=',i,' CodeContext=',FindContextToString(CHElement.CodeContext)]); //DebugLn(['TCodeHelpManager.GetElementChain i=',i,' CodeContext=',FindContextToString(CHElement.CodeContext)]);
// find corresponding FPDoc file // find corresponding FPDoc file
CHElement.ElementUnitFileName:=CHElement.CodeContext.Tool.MainFilename; CHElement.ElementUnitFileName:=CHElement.CodeContext.Tool.MainFilename;