mirror of
https://gitlab.com/freepascal.org/lazarus/lazarus.git
synced 2025-08-15 00:19:22 +02:00
codetools: fixed deleting nodes if diff is behind last scanned node
git-svn-id: trunk@29808 -
This commit is contained in:
parent
29b00c7528
commit
420d07490d
@ -1207,7 +1207,6 @@ var
|
|||||||
NewSrcLen: Integer;
|
NewSrcLen: Integer;
|
||||||
begin
|
begin
|
||||||
if (not UpdateNeeded(Range,CheckFilesOnDisk)) then begin
|
if (not UpdateNeeded(Range,CheckFilesOnDisk)) then begin
|
||||||
debugln(['TLinkScanner.Scan AAA1 no update needed Range=',dbgs(Range),' ScannedRange=',dbgs(ScannedRange)]);
|
|
||||||
// input is the same as last time -> output is the same
|
// input is the same as last time -> output is the same
|
||||||
// -> if there was an error and it was in a needed range, raise it again
|
// -> if there was an error and it was in a needed range, raise it again
|
||||||
if LastErrorIsValid then begin
|
if LastErrorIsValid then begin
|
||||||
|
@ -648,17 +648,21 @@ begin
|
|||||||
Node.EndPos:=-1;
|
Node.EndPos:=-1;
|
||||||
if (Node.LastChild=nil) then begin
|
if (Node.LastChild=nil) then begin
|
||||||
// section was not parsed => reopen it
|
// section was not parsed => reopen it
|
||||||
//debugln(['TPascalParserTool.BuildTree scan a section from start ...']);
|
|
||||||
MoveCursorToCleanPos(Node.StartPos);
|
MoveCursorToCleanPos(Node.StartPos);
|
||||||
// skip keyword starting the section
|
// skip keyword starting the section
|
||||||
ReadNextAtom;
|
ReadNextAtom;
|
||||||
|
{$IFDEF VerboseUpdateNeeded}
|
||||||
|
debugln(['TPascalParserTool.BuildTree scan section ',Node.DescAsString,' from start. First atom=',GetAtom]);
|
||||||
|
{$ENDIF}
|
||||||
end else begin
|
end else begin
|
||||||
// half parsed section
|
// half parsed section
|
||||||
//debugln(['TPascalParserTool.BuildTree scan a section from middle ...']);
|
//debugln(['TPascalParserTool.BuildTree scan a section from middle ...']);
|
||||||
if (Node.LastChild.Desc=ctnUsesSection)
|
if (Node.LastChild.Desc=ctnUsesSection)
|
||||||
and (Node.LastChild.FirstChild=nil) then begin
|
and (Node.LastChild.FirstChild=nil) then begin
|
||||||
// uses section was not parsed completely => reopen it
|
// uses section was not parsed completely => reopen it
|
||||||
debugln(['TPascalParserTool.BuildTree REOPEN uses section']);
|
{$IFDEF VerboseUpdateNeeded}
|
||||||
|
debugln(['TPascalParserTool.BuildTree REOPEN uses section, section=',Node.DescAsString]);
|
||||||
|
{$ENDIF}
|
||||||
Node:=CurNode.LastChild;
|
Node:=CurNode.LastChild;
|
||||||
Node.EndPos:=-1;
|
Node.EndPos:=-1;
|
||||||
MoveCursorToCleanPos(Node.StartPos);
|
MoveCursorToCleanPos(Node.StartPos);
|
||||||
@ -666,18 +670,29 @@ begin
|
|||||||
// place cursor behind last child node
|
// place cursor behind last child node
|
||||||
while (Node.LastChild<>nil) and (Node.LastChild.EndPos<1) do
|
while (Node.LastChild<>nil) and (Node.LastChild.EndPos<1) do
|
||||||
Node:=Node.LastChild;
|
Node:=Node.LastChild;
|
||||||
if Node.LastChild<>nil then
|
Node.EndPos:=-1;
|
||||||
|
if Node.LastChild<>nil then begin
|
||||||
|
{$IFDEF VerboseUpdateNeeded}
|
||||||
|
debugln(['TPascalParserTool.BuildTree scan at end of ',Node.LastChild.DescAsString]);
|
||||||
|
{$ENDIF}
|
||||||
MoveCursorToCleanPos(Node.LastChild.EndPos)
|
MoveCursorToCleanPos(Node.LastChild.EndPos)
|
||||||
else if CurNode.EndPos>0 then
|
end else if Node.EndPos>0 then begin
|
||||||
|
{$IFDEF VerboseUpdateNeeded}
|
||||||
|
debugln(['TPascalParserTool.BuildTree scan at end of ',Node.DescAsString]);
|
||||||
|
{$ENDIF}
|
||||||
MoveCursorToCleanPos(Node.EndPos)
|
MoveCursorToCleanPos(Node.EndPos)
|
||||||
else begin
|
end else begin
|
||||||
|
{$IFDEF VerboseUpdateNeeded}
|
||||||
|
debugln(['TPascalParserTool.BuildTree scan at start of ',Node.DescAsString]);
|
||||||
|
{$ENDIF}
|
||||||
MoveCursorToCleanPos(Node.StartPos);
|
MoveCursorToCleanPos(Node.StartPos);
|
||||||
Node.EndPos:=-1;
|
|
||||||
end;
|
end;
|
||||||
end;
|
end;
|
||||||
end;
|
end;
|
||||||
CurNode:=Node;
|
CurNode:=Node;
|
||||||
//debugln(['TPascalParserTool.BuildTree curnode=',CurNode.DescAsString,' cursor="',dbgstr(copy(Src,CurPos.StartPos,40)),'"']);
|
{$IFDEF VerboseUpdateNeeded}
|
||||||
|
debugln(['TPascalParserTool.BuildTree CurNode=',CurNode.DescAsString,' cursor="',dbgstr(copy(Src,CurPos.StartPos,40)),'"']);
|
||||||
|
{$ENDIF}
|
||||||
if not (CurNode.Desc in (AllCodeSections+[ctnUsesSection])) then
|
if not (CurNode.Desc in (AllCodeSections+[ctnUsesSection])) then
|
||||||
// FetchScannerSource failed
|
// FetchScannerSource failed
|
||||||
RaiseCatchableException('TPascalParserTool.BuildTree inconsistency');
|
RaiseCatchableException('TPascalParserTool.BuildTree inconsistency');
|
||||||
@ -4534,10 +4549,10 @@ begin
|
|||||||
Node:=Node.NextBrother;
|
Node:=Node.NextBrother;
|
||||||
// mark section as unfinished
|
// mark section as unfinished
|
||||||
Node.EndPos:=-1;
|
Node.EndPos:=-1;
|
||||||
if (Node.NextBrother=nil) and (Node.EndPos<=DiffPos) then begin
|
if (Node.Desc=ctnEndPoint) and (Node.EndPos<=DiffPos) then begin
|
||||||
// difference is behind nodes => keep all nodes
|
// difference is behind nodes => keep all nodes
|
||||||
{$IFDEF VerboseUpdateNeeded}
|
{$IFDEF VerboseUpdateNeeded}
|
||||||
debugln(['TPascalParserTool.FetchScannerSource cleansrc was changed after scanned nodes => keep all nodes ',MainFilename]);
|
debugln(['TPascalParserTool.FetchScannerSource cleansrc was changed after scanned nodes => keep all nodes, last node=',Node.DescAsString,' ',MainFilename]);
|
||||||
{$ENDIF}
|
{$ENDIF}
|
||||||
end else begin
|
end else begin
|
||||||
// some nodes can be kept
|
// some nodes can be kept
|
||||||
|
Loading…
Reference in New Issue
Block a user