mirror of
https://gitlab.com/freepascal.org/lazarus/lazarus.git
synced 2025-08-27 16:20:35 +02:00
codetools: fixed continuing parsing after source name
git-svn-id: branches/fixes_1_8@55949 -
This commit is contained in:
parent
93eab7f1d6
commit
2fec1e02cb
@ -636,8 +636,15 @@ begin
|
||||
//if (ExtractFileNameOnly(MainFilename)='androidr14') and (CurNode<>nil) then
|
||||
//debugln(['TPascalParserTool.BuildTree CurNode=',CurNode.DescAsString]);
|
||||
if (CurNode=nil)
|
||||
or ((CurNode.Desc in AllSourceTypes) and (CurNode.FirstChild=nil)) then begin
|
||||
or ((CurNode.Desc in AllSourceTypes)
|
||||
and ((CurNode.FirstChild=nil)
|
||||
or ((CurNode.FirstChild.Desc=ctnIdentifier)
|
||||
and (CurNode.FirstChild.NextBrother=nil))))
|
||||
then begin
|
||||
// parse source from the beginning
|
||||
if CurNode<>nil then
|
||||
while CurNode.FirstChild<>nil do
|
||||
Tree.DeleteNode(CurNode.FirstChild);
|
||||
|
||||
if (CurPos.StartPos=1) and (Src<>'') then begin
|
||||
// skip shebang
|
||||
@ -683,6 +690,7 @@ begin
|
||||
CurNode.Desc:=CurSection;
|
||||
ScannedRange:=lsrSourceType;
|
||||
if ord(Range)<=ord(ScannedRange) then exit;
|
||||
|
||||
if HasSourceType then begin
|
||||
aNameSpace:='';
|
||||
repeat
|
||||
@ -693,8 +701,6 @@ begin
|
||||
AtomIsIdentifierSaveE;
|
||||
CreateChildNode;
|
||||
CurNode.Desc:=ctnIdentifier;
|
||||
CurNode.EndPos:=CurPos.EndPos;
|
||||
EndChildNode;
|
||||
aName:=GetAtom;
|
||||
ReadNextAtom; // read ';' (or 'platform;' or 'unimplemented;')
|
||||
if CurPos.Flag=cafPoint then begin
|
||||
@ -703,11 +709,16 @@ begin
|
||||
end else
|
||||
break;
|
||||
until false;
|
||||
while CurNode.Desc=ctnIdentifier do begin
|
||||
CurNode.EndPos:=CurPos.StartPos;
|
||||
EndChildNode;
|
||||
end;
|
||||
if CurSection in [ctnProgram,ctnLibrary,ctnPackage] then
|
||||
AddedNameSpace:=aNameSpace;
|
||||
end;
|
||||
ScannedRange:=lsrSourceName;
|
||||
if ord(Range)<=ord(ScannedRange) then exit;
|
||||
|
||||
if HasSourceType then begin
|
||||
if (CurSection=ctnProgram)
|
||||
and (CurPos.Flag=cafRoundBracketOpen) then begin
|
||||
@ -6106,6 +6117,7 @@ function TPascalParserTool.FindScanRangeNode(Range: TLinkScannerRange
|
||||
{ search a node of the Range or higher
|
||||
lsrNone and lsrInit are always nil
|
||||
lsrSourceType is the unit/program/library node if exists
|
||||
lsrSourceName is the ctnIdentifier if exists
|
||||
Otherwise it is the next node (e.g. in a unit the interface)
|
||||
}
|
||||
begin
|
||||
@ -6114,11 +6126,13 @@ begin
|
||||
if (ord(Range)<=ord(lsrInit)) then exit;
|
||||
Result:=Tree.Root;
|
||||
if Result=nil then exit;
|
||||
// lsrSourceType;
|
||||
// lsrSourceType
|
||||
if Range=lsrSourceType then exit;
|
||||
// lsrSourceName;
|
||||
// lsrSourceName
|
||||
if Range=lsrSourceName then begin
|
||||
// the source name has no node of its own
|
||||
if (Result.Desc in AllSourceTypes) and (Result.FirstChild<>nil)
|
||||
and (Result.FirstChild.Desc=ctnIdentifier) then
|
||||
Result:=Result.FirstChild;
|
||||
exit;
|
||||
end;
|
||||
if ord(Range)<ord(lsrEnd) then begin
|
||||
|
Loading…
Reference in New Issue
Block a user