codetools: fixed AddUnitWarnDirective insert position

git-svn-id: branches/fixes_1_8@56078 -
This commit is contained in:
mattias 2017-10-16 12:00:17 +00:00
parent 91e848b779
commit 24af7385ca
2 changed files with 12 additions and 18 deletions

View File

@ -717,7 +717,7 @@ begin
break; break;
until false; until false;
if CurNode.Desc=ctnSrcName then begin if CurNode.Desc=ctnSrcName then begin
CurNode.EndPos:=CurPos.StartPos; CurNode.EndPos:=CurPos.EndPos;
EndChildNode; EndChildNode;
end; end;
if CurSection in [ctnProgram,ctnLibrary,ctnPackage] then if CurSection in [ctnProgram,ctnLibrary,ctnPackage] then

View File

@ -6555,7 +6555,7 @@ end;
function TStandardCodeTool.AddUnitWarnDirective(WarnID, Comment: string; function TStandardCodeTool.AddUnitWarnDirective(WarnID, Comment: string;
TurnOn: boolean; SourceChangeCache: TSourceChangeCache): boolean; TurnOn: boolean; SourceChangeCache: TSourceChangeCache): boolean;
const const
DirectiveFlagValue: array[boolean] of string = ('on','off'); DirectiveFlagValue: array[boolean] of string = ('off','on');
var var
ACleanPos, DirEndPos, InsertStartPos, MaxPos: Integer; ACleanPos, DirEndPos, InsertStartPos, MaxPos: Integer;
Node: TCodeTreeNode; Node: TCodeTreeNode;
@ -6577,24 +6577,18 @@ begin
if not (Comment[1] in [' ',#9,#10,#13]) then Comment:=' '+Comment; if not (Comment[1] in [' ',#9,#10,#13]) then Comment:=' '+Comment;
end; end;
MaxPos:=0; // insert in front of first node after source name
Node:=FindInterfaceNode; Node:=Tree.Root;
if Node=nil then MaxPos:=Node.StartPos;
Node:=FindMainUsesNode; if Node.Desc in AllSourceTypes then
debugln(['TStandardCodeTool.AddUnitWarnDirective AAA1 ',Tree.Root.DescAsString]); Node:=Node.Next;
debugln(['TStandardCodeTool.AddUnitWarnDirective AAA2 ',Tree.Root.FirstChild.DescAsString]); if (Node<>nil) and (Node.Desc=ctnSrcName) then begin
if Node=nil then begin MaxPos:=Node.EndPos;
Node:=Tree.Root.FirstChild; Node:=Node.NextSkipChilds;
if (Node<>nil) and (Node.Desc=ctnSrcName) then begin
debugln(['TStandardCodeTool.AddUnitWarnDirective AA3 ',Node.DescAsString]);
Node:=Node.NextSkipChilds;
end;
end; end;
debugln(['TStandardCodeTool.AddUnitWarnDirective ',Node.DescAsString]);
if Node<>nil then if Node<>nil then
MaxPos:=Node.StartPos MaxPos:=Node.StartPos;
else MaxPos:=FindLineEndOrCodeAfterPosition(MaxPos,true,true);
MaxPos:=SrcLen;
// find existing directive for replacement // find existing directive for replacement
ACleanPos:=1; ACleanPos:=1;