codetools: fixed skipping program name nodes

git-svn-id: trunk@55855 -
This commit is contained in:
mattias 2017-09-13 18:43:33 +00:00
parent 80021aec47
commit fef3d14b6d
3 changed files with 17 additions and 6 deletions

View File

@ -1043,6 +1043,8 @@ begin
end; end;
if InsertPos<1 then begin if InsertPos<1 then begin
InsertNode:=FindFirstSectionChild; InsertNode:=FindFirstSectionChild;
while (InsertNode<>nil) and (InsertNode.Desc=ctnIdentifier) do
InsertNode:=InsertNode.NextBrother;
if InsertNode<>nil then begin if InsertNode<>nil then begin
Indent:=Beauty.GetLineIndent(Src,InsertNode.StartPos); Indent:=Beauty.GetLineIndent(Src,InsertNode.StartPos);
if InsertNode.Desc=ctnUsesSection then if InsertNode.Desc=ctnUsesSection then

View File

@ -74,7 +74,7 @@ const
ctnResStrSection = 13; ctnResStrSection = 13;
ctnLabelSection = 14; ctnLabelSection = 14;
ctnPropertySection = 15; ctnPropertySection = 15;
ctnUsesSection = 16; // child nodes are ctnUseUnit ctnUsesSection = 16; // child nodes are ctnUseUnit, parent is ctnInterface,ctnImplementation,ctnProgram,ctnPackage,ctnLibrary
ctnRequiresSection = 17; ctnRequiresSection = 17;
ctnContainsSection = 18; // child nodes are ctnUseUnit ctnContainsSection = 18; // child nodes are ctnUseUnit
ctnExportsSection = 19; ctnExportsSection = 19;

View File

@ -555,7 +555,7 @@ var
p: PChar; p: PChar;
HasSourceType: Boolean; HasSourceType: Boolean;
ok: Boolean; ok: Boolean;
OldLastNode: TCodeTreeNode; OldLastNode, SubNode: TCodeTreeNode;
OldLastPos: Integer; OldLastPos: Integer;
aNameSpace, aName: String; aNameSpace, aName: String;
begin begin
@ -791,9 +791,12 @@ begin
Node.EndPos:=-1; Node.EndPos:=-1;
MoveCursorToCleanPos(Node.StartPos); MoveCursorToCleanPos(Node.StartPos);
end else begin end else begin
if Node.FirstChild.Desc=ctnUsesSection then begin SubNode:=Node.FirstChild;
while (SubNode<>nil) and (SubNode.Desc=ctnIdentifier) do
SubNode:=SubNode.NextBrother;
if (SubNode<>nil) and (SubNode.Desc=ctnUsesSection) then begin
// uses section is already parsed // uses section is already parsed
if Node.FirstChild.FirstChild=nil then if SubNode.FirstChild=nil then
RaiseException(20170421194939, RaiseException(20170421194939,
'TPascalParserTool.BuildTree inconsistency: uses section was not scanned completely and was not deleted'); 'TPascalParserTool.BuildTree inconsistency: uses section was not scanned completely and was not deleted');
if ScannedRange<lsrMainUsesSectionEnd then if ScannedRange<lsrMainUsesSectionEnd then
@ -6188,6 +6191,8 @@ begin
exit; exit;
end; end;
Result:=Result.FirstChild; Result:=Result.FirstChild;
while (Result.NextBrother<>nil) and (Result.Desc=ctnIdentifier) do
Result:=Result.NextBrother;
if Result.Desc<>ctnUsesSection then exit; if Result.Desc<>ctnUsesSection then exit;
// lsrMainUsesSectionStart in program // lsrMainUsesSectionStart in program
if Range=lsrMainUsesSectionStart then exit; if Range=lsrMainUsesSectionStart then exit;
@ -6203,6 +6208,8 @@ begin
exit; exit;
end; end;
Result:=Result.FirstChild; Result:=Result.FirstChild;
while (Result.NextBrother<>nil) and (Result.Desc=ctnIdentifier) do
Result:=Result.NextBrother;
if Result.Desc=ctnUsesSection then if Result.Desc=ctnUsesSection then
Result:=Result.NextSkipChilds; Result:=Result.NextSkipChilds;
exit; exit;
@ -6230,9 +6237,11 @@ var
begin begin
Result:=FindSectionNodeAtPos(P); Result:=FindSectionNodeAtPos(P);
if Result=nil then exit; if Result=nil then exit;
if (Result.FirstChild<>nil) and (Result.FirstChild.Desc=ctnUsesSection) then UsesNode:=Result.FirstChild;
while (UsesNode<>nil) and (UsesNode.Desc=ctnIdentifier) do
UsesNode:=UsesNode.NextBrother;
if (UsesNode<>nil) and (UsesNode.Desc=ctnUsesSection) then
begin begin
UsesNode:=Result.FirstChild;
if (UsesNode.StartPos<=P) and (UsesNode.EndPos>P) then if (UsesNode.StartPos<=P) and (UsesNode.EndPos>P) then
Result:=UsesNode; Result:=UsesNode;
end; end;