mirror of
https://gitlab.com/freepascal.org/lazarus/lazarus.git
synced 2025-08-16 10:39:30 +02:00
codetools: fixed rescan of modified initialization section, fixed check if a virtual file has changed on disl
git-svn-id: trunk@30177 -
This commit is contained in:
parent
ce19f7ed35
commit
67b58b4044
@ -1172,7 +1172,7 @@ end;
|
|||||||
function TCodeBuffer.FileNeedsUpdate: boolean;
|
function TCodeBuffer.FileNeedsUpdate: boolean;
|
||||||
// file needs update (to be loaded), if file is not modified and file on disk has changed
|
// file needs update (to be loaded), if file is not modified and file on disk has changed
|
||||||
begin
|
begin
|
||||||
if Modified then exit(false);
|
if Modified or IsVirtual then exit(false);
|
||||||
if LoadDateValid then
|
if LoadDateValid then
|
||||||
Result:=(FFileChangeStep=ChangeStep) and (FileDateOnDisk<>LoadDate)
|
Result:=(FFileChangeStep=ChangeStep) and (FileDateOnDisk<>LoadDate)
|
||||||
else
|
else
|
||||||
|
@ -775,7 +775,7 @@ type
|
|||||||
function FindDeclarationNodeInInterface(const Identifier: string;
|
function FindDeclarationNodeInInterface(const Identifier: string;
|
||||||
BuildTheTree: Boolean): TCodeTreeNode;// search for type, const, var
|
BuildTheTree: Boolean): TCodeTreeNode;// search for type, const, var
|
||||||
|
|
||||||
function FindInitializationSection: TCodeTreeNode;
|
function FindInitializationSection: TCodeTreeNode; deprecated; // use FindInitializationNode
|
||||||
function FindMainUsesSection(UseContainsSection: boolean = false): TCodeTreeNode;
|
function FindMainUsesSection(UseContainsSection: boolean = false): TCodeTreeNode;
|
||||||
function FindImplementationUsesSection: TCodeTreeNode;
|
function FindImplementationUsesSection: TCodeTreeNode;
|
||||||
function FindNameInUsesSection(UsesNode: TCodeTreeNode;
|
function FindNameInUsesSection(UsesNode: TCodeTreeNode;
|
||||||
@ -1962,10 +1962,7 @@ end;
|
|||||||
|
|
||||||
function TFindDeclarationTool.FindInitializationSection: TCodeTreeNode;
|
function TFindDeclarationTool.FindInitializationSection: TCodeTreeNode;
|
||||||
begin
|
begin
|
||||||
Result:=Tree.Root;
|
Result:=FindInitializationNode;
|
||||||
if Result=nil then exit;
|
|
||||||
while (Result<>nil) and (Result.Desc<>ctnInitialization) do
|
|
||||||
Result:=Result.NextBrother;
|
|
||||||
end;
|
end;
|
||||||
|
|
||||||
function TFindDeclarationTool.FindDeclarationInUsesSection(
|
function TFindDeclarationTool.FindDeclarationInUsesSection(
|
||||||
|
@ -525,7 +525,7 @@ begin
|
|||||||
if not UpdateNeeded(Range) then begin
|
if not UpdateNeeded(Range) then begin
|
||||||
// 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, raise it again
|
// => if there was an error, raise it again
|
||||||
//debugln(['TPascalParserTool.BuildTree ',IgnoreErrorAfterValid]);
|
//debugln(['TPascalParserTool.BuildTree no update needed, IgnoreErrorAfterValid=',IgnoreErrorAfterValid]);
|
||||||
if LastErrorValid then begin
|
if LastErrorValid then begin
|
||||||
// last time a parsing error occurred
|
// last time a parsing error occurred
|
||||||
if IgnoreErrorAfterValid
|
if IgnoreErrorAfterValid
|
||||||
@ -683,7 +683,8 @@ begin
|
|||||||
// section was not parsed => reopen it
|
// section was not parsed => reopen it
|
||||||
MoveCursorToCleanPos(Node.StartPos);
|
MoveCursorToCleanPos(Node.StartPos);
|
||||||
// skip keyword starting the section
|
// skip keyword starting the section
|
||||||
ReadNextAtom;
|
if Node.Desc in [ctnInterface,ctnImplementation] then
|
||||||
|
ReadNextAtom;
|
||||||
{$IFDEF VerboseUpdateNeeded}
|
{$IFDEF VerboseUpdateNeeded}
|
||||||
debugln(['TPascalParserTool.BuildTree scan section ',Node.DescAsString,' from start. First atom=',GetAtom]);
|
debugln(['TPascalParserTool.BuildTree scan section ',Node.DescAsString,' from start. First atom=',GetAtom]);
|
||||||
{$ENDIF}
|
{$ENDIF}
|
||||||
@ -708,12 +709,12 @@ begin
|
|||||||
{$IFDEF VerboseUpdateNeeded}
|
{$IFDEF VerboseUpdateNeeded}
|
||||||
debugln(['TPascalParserTool.BuildTree scan at end of ',Node.LastChild.DescAsString]);
|
debugln(['TPascalParserTool.BuildTree scan at end of ',Node.LastChild.DescAsString]);
|
||||||
{$ENDIF}
|
{$ENDIF}
|
||||||
MoveCursorToCleanPos(Node.LastChild.EndPos)
|
MoveCursorToCleanPos(Node.LastChild.EndPos);
|
||||||
end else if Node.EndPos>0 then begin
|
end else if Node.EndPos>0 then begin
|
||||||
{$IFDEF VerboseUpdateNeeded}
|
{$IFDEF VerboseUpdateNeeded}
|
||||||
debugln(['TPascalParserTool.BuildTree scan at end of ',Node.DescAsString]);
|
debugln(['TPascalParserTool.BuildTree scan at end of ',Node.DescAsString]);
|
||||||
{$ENDIF}
|
{$ENDIF}
|
||||||
MoveCursorToCleanPos(Node.EndPos)
|
MoveCursorToCleanPos(Node.EndPos);
|
||||||
end else begin
|
end else begin
|
||||||
{$IFDEF VerboseUpdateNeeded}
|
{$IFDEF VerboseUpdateNeeded}
|
||||||
debugln(['TPascalParserTool.BuildTree scan at start of ',Node.DescAsString]);
|
debugln(['TPascalParserTool.BuildTree scan at start of ',Node.DescAsString]);
|
||||||
@ -732,7 +733,9 @@ begin
|
|||||||
end;
|
end;
|
||||||
|
|
||||||
ReadNextAtom;
|
ReadNextAtom;
|
||||||
//debugln(['TPascalParserTool.BuildTree first atom=',GetAtom]);
|
{$IFDEF VerboseUpdateNeeded}
|
||||||
|
debugln(['TPascalParserTool.BuildTree ScannedRange=',dbgs(ScannedRange),' CurNode=',CurNode.DescAsString,' first atom=',GetAtom]);
|
||||||
|
{$ENDIF}
|
||||||
|
|
||||||
if (CurNode.Desc in (AllSourceTypes+[ctnInterface]))
|
if (CurNode.Desc in (AllSourceTypes+[ctnInterface]))
|
||||||
or ((CurNode.Desc=ctnUsesSection) and (CurNode.Parent.Desc<>ctnImplementation))
|
or ((CurNode.Desc=ctnUsesSection) and (CurNode.Parent.Desc<>ctnImplementation))
|
||||||
@ -742,11 +745,10 @@ begin
|
|||||||
ReadUsesSection(true);
|
ReadUsesSection(true);
|
||||||
//debugln(['TPascalParserTool.BuildTree AFTER reading main uses section Atom="',GetAtom,'"']);
|
//debugln(['TPascalParserTool.BuildTree AFTER reading main uses section Atom="',GetAtom,'"']);
|
||||||
if ord(Range)<=ord(ScannedRange) then exit;
|
if ord(Range)<=ord(ScannedRange) then exit;
|
||||||
|
ScannedRange:=lsrMainUsesSectionEnd;
|
||||||
|
if ord(Range)<=ord(ScannedRange) then exit;
|
||||||
end;
|
end;
|
||||||
|
|
||||||
ScannedRange:=lsrMainUsesSectionEnd;
|
|
||||||
if ord(Range)<=ord(ScannedRange) then exit;
|
|
||||||
|
|
||||||
if (CurNode.Desc=ctnPackage)
|
if (CurNode.Desc=ctnPackage)
|
||||||
and ((CurNode.FirstChild=nil) or (CurNode.LastChild.Desc=ctnUsesSection))
|
and ((CurNode.FirstChild=nil) or (CurNode.LastChild.Desc=ctnUsesSection))
|
||||||
then begin
|
then begin
|
||||||
@ -759,7 +761,9 @@ begin
|
|||||||
end;
|
end;
|
||||||
|
|
||||||
if CurNode.GetNodeOfType(ctnImplementation)<>nil then begin
|
if CurNode.GetNodeOfType(ctnImplementation)<>nil then begin
|
||||||
//debugln(['TPascalParserTool.BuildTree CONTINUE implementation ...']);
|
{$IFDEF VerboseUpdateNeeded}
|
||||||
|
debugln(['TPascalParserTool.BuildTree CONTINUE implementation ...']);
|
||||||
|
{$ENDIF}
|
||||||
ScannedRange:=lsrImplementationStart;
|
ScannedRange:=lsrImplementationStart;
|
||||||
if ord(Range)<=ord(ScannedRange) then exit;
|
if ord(Range)<=ord(ScannedRange) then exit;
|
||||||
|
|
||||||
@ -772,6 +776,8 @@ begin
|
|||||||
//debugln(['TPascalParserTool.BuildTree AFTER reading implementation uses section Atom="',GetAtom,'"']);
|
//debugln(['TPascalParserTool.BuildTree AFTER reading implementation uses section Atom="',GetAtom,'"']);
|
||||||
if ord(Range)<=ord(ScannedRange) then exit;
|
if ord(Range)<=ord(ScannedRange) then exit;
|
||||||
end;
|
end;
|
||||||
|
ScannedRange:=lsrImplementationUsesSectionEnd;
|
||||||
|
if ord(Range)<=ord(ScannedRange) then exit;
|
||||||
end;
|
end;
|
||||||
|
|
||||||
repeat
|
repeat
|
||||||
@ -1814,6 +1820,7 @@ function TPascalParserTool.ReadUsesSection(
|
|||||||
|
|
||||||
}
|
}
|
||||||
begin
|
begin
|
||||||
|
Result:=false;
|
||||||
if CurNode.Desc<>ctnUsesSection then begin
|
if CurNode.Desc<>ctnUsesSection then begin
|
||||||
CreateChildNode;
|
CreateChildNode;
|
||||||
CurNode.Desc:=ctnUsesSection;
|
CurNode.Desc:=ctnUsesSection;
|
||||||
@ -1849,8 +1856,15 @@ begin
|
|||||||
until (CurPos.StartPos>SrcLen);
|
until (CurPos.StartPos>SrcLen);
|
||||||
CurNode.EndPos:=CurPos.EndPos;
|
CurNode.EndPos:=CurPos.EndPos;
|
||||||
EndChildNode;
|
EndChildNode;
|
||||||
ReadNextAtom;
|
|
||||||
Result:=true;
|
Result:=true;
|
||||||
|
|
||||||
|
if ScannedRange=lsrMainUsesSectionStart then
|
||||||
|
ScannedRange:=lsrMainUsesSectionEnd
|
||||||
|
else if ScannedRange=lsrImplementationUsesSectionStart then
|
||||||
|
ScannedRange:=lsrImplementationUsesSectionEnd;
|
||||||
|
if ord(ScanTill)<=ord(ScannedRange) then exit;
|
||||||
|
|
||||||
|
ReadNextAtom;
|
||||||
end;
|
end;
|
||||||
|
|
||||||
function TPascalParserTool.ReadRequiresSection(ExceptionOnError: boolean
|
function TPascalParserTool.ReadRequiresSection(ExceptionOnError: boolean
|
||||||
|
Loading…
Reference in New Issue
Block a user