mirror of
https://gitlab.com/freepascal.org/lazarus/lazarus.git
synced 2025-08-22 19:59:26 +02:00
IDE: codehelp: catch xmlread errors when setting value
git-svn-id: trunk@22170 -
This commit is contained in:
parent
01bda7a61b
commit
b6c3edb9ec
@ -152,6 +152,7 @@ type
|
|||||||
procedure UpdateButtons;
|
procedure UpdateButtons;
|
||||||
function GetCurrentUnitName: string;
|
function GetCurrentUnitName: string;
|
||||||
function GetCurrentModuleName: string;
|
function GetCurrentModuleName: string;
|
||||||
|
procedure JumpToError(Item : TFPDocItem; LineCol: TPoint);
|
||||||
public
|
public
|
||||||
procedure Reset;
|
procedure Reset;
|
||||||
procedure InvalidateChain;
|
procedure InvalidateChain;
|
||||||
@ -797,6 +798,22 @@ begin
|
|||||||
Result:='';
|
Result:='';
|
||||||
end;
|
end;
|
||||||
|
|
||||||
|
procedure TFPDocEditor.JumpToError(Item: TFPDocItem; LineCol: TPoint);
|
||||||
|
begin
|
||||||
|
case Item of
|
||||||
|
fpdiShort: PageControl.ActivePage:=ShortTabSheet;
|
||||||
|
fpdiElementLink: PageControl.ActivePage:=InheritedTabSheet;
|
||||||
|
fpdiDescription:
|
||||||
|
begin
|
||||||
|
PageControl.ActivePage:=DescrTabSheet;
|
||||||
|
|
||||||
|
end;
|
||||||
|
fpdiErrors: PageControl.ActivePage:=ErrorsTabSheet;
|
||||||
|
fpdiSeeAlso: PageControl.ActivePage:=SeeAlsoTabSheet;
|
||||||
|
fpdiExample: PageControl.ActivePage:=ExampleTabSheet;
|
||||||
|
end;
|
||||||
|
end;
|
||||||
|
|
||||||
procedure TFPDocEditor.Reset;
|
procedure TFPDocEditor.Reset;
|
||||||
begin
|
begin
|
||||||
FreeAndNil(fChain);
|
FreeAndNil(fChain);
|
||||||
@ -941,6 +958,26 @@ var
|
|||||||
end;
|
end;
|
||||||
end;
|
end;
|
||||||
|
|
||||||
|
function SetValue(Item: TFPDocItem): boolean;
|
||||||
|
var
|
||||||
|
NewValue: String;
|
||||||
|
begin
|
||||||
|
Result:=false;
|
||||||
|
NewValue:=Values[Item];
|
||||||
|
try
|
||||||
|
CurDocFile.SetChildValue(TopNode,FPDocItemNames[Item],NewValue);
|
||||||
|
Result:=true;
|
||||||
|
except
|
||||||
|
on E: EXMLReadError do begin
|
||||||
|
DebugLn(['SetValue ',dbgs(E.LineCol),' Name=',FPDocItemNames[Item]]);
|
||||||
|
JumpToError(Item,E.LineCol);
|
||||||
|
MessageDlg('FPDoc syntax error',
|
||||||
|
'There is a syntax error in the fpdoc element "'+FPDocItemNames[Item]+'":'#13#13
|
||||||
|
+E.Message,mtError,[mbOk],'');
|
||||||
|
end;
|
||||||
|
end;
|
||||||
|
end;
|
||||||
|
|
||||||
begin
|
begin
|
||||||
Result:=false;
|
Result:=false;
|
||||||
if fpdefWriting in FFlags then begin
|
if fpdefWriting in FFlags then begin
|
||||||
@ -968,12 +1005,13 @@ begin
|
|||||||
Include(FFlags,fpdefWriting);
|
Include(FFlags,fpdefWriting);
|
||||||
CurDocFile.BeginUpdate;
|
CurDocFile.BeginUpdate;
|
||||||
try
|
try
|
||||||
CurDocFile.SetChildValue(TopNode,'short',Values[fpdiShort]);
|
if SetValue(fpdiShort)
|
||||||
CurDocFile.SetChildValue(TopNode,'elementlink',Values[fpdiElementLink]);
|
and SetValue(fpdiElementLink)
|
||||||
CurDocFile.SetChildValue(TopNode,'descr',Values[fpdiDescription]);
|
and SetValue(fpdiDescription)
|
||||||
CurDocFile.SetChildValue(TopNode,'errors',Values[fpdiErrors]);
|
and SetValue(fpdiErrors)
|
||||||
CurDocFile.SetChildValue(TopNode,'seealso',Values[fpdiSeeAlso]);
|
and SetValue(fpdiSeeAlso)
|
||||||
CurDocFile.SetChildValue(TopNode,'example',Values[fpdiExample]);
|
and SetValue(fpdiExample) then
|
||||||
|
;
|
||||||
finally
|
finally
|
||||||
CurDocFile.EndUpdate;
|
CurDocFile.EndUpdate;
|
||||||
fChain.MakeValid;
|
fChain.MakeValid;
|
||||||
|
Loading…
Reference in New Issue
Block a user