mirror of
https://gitlab.com/freepascal.org/lazarus/lazarus.git
synced 2025-08-17 10:49:09 +02:00
fixed commenting units in case of last needs commenting
git-svn-id: trunk@8896 -
This commit is contained in:
parent
4df5c10804
commit
6afd88f967
@ -79,8 +79,13 @@ begin
|
|||||||
MissingUnits:=nil;
|
MissingUnits:=nil;
|
||||||
if not CodeToolBoss.FindMissingUnits(Code,MissingUnits,true) then
|
if not CodeToolBoss.FindMissingUnits(Code,MissingUnits,true) then
|
||||||
raise Exception.Create('unable to fix unit names in '+Filename+' '+CodeToolBoss.ErrorMessage);
|
raise Exception.Create('unable to fix unit names in '+Filename+' '+CodeToolBoss.ErrorMessage);
|
||||||
if MissingUnits<>nil then
|
|
||||||
|
if MissingUnits<>nil then begin
|
||||||
writeln('MissingUnits=',MissingUnits.Text);
|
writeln('MissingUnits=',MissingUnits.Text);
|
||||||
|
if not CodeToolBoss.CommentUnitsInUsesSections(Code,MissingUnits) then
|
||||||
|
raise Exception.Create('unable to comment units in uses section in '+Filename+' '+CodeToolBoss.ErrorMessage);
|
||||||
|
end;
|
||||||
|
|
||||||
writeln('==================================================================');
|
writeln('==================================================================');
|
||||||
writeln(Code.Source);
|
writeln(Code.Source);
|
||||||
end.
|
end.
|
||||||
|
@ -10,7 +10,7 @@ uses
|
|||||||
biglettersunit, // must be fixed to BigLettersUnit
|
biglettersunit, // must be fixed to BigLettersUnit
|
||||||
biglettersunit in 'biglettersunit.pas',// -> BigLettersUnit.pas
|
biglettersunit in 'biglettersunit.pas',// -> BigLettersUnit.pas
|
||||||
biglettersunit in '..\ScanExamples\biglettersunit.pas',// -> ../scanexamples/BigLettersUnit
|
biglettersunit in '..\ScanExamples\biglettersunit.pas',// -> ../scanexamples/BigLettersUnit
|
||||||
SysUtils;
|
NonExistingUnit1, SysUtils, NonExistingUnit2;
|
||||||
|
|
||||||
{$I BROKENincfiles.inc}// must be fixed to brokenincfiles.inc
|
{$I BROKENincfiles.inc}// must be fixed to brokenincfiles.inc
|
||||||
{$I ../ScanExamples/BROKENincfiles.inc}// must be fixed to ../scanexamples/brokenincfiles.inc
|
{$I ../ScanExamples/BROKENincfiles.inc}// must be fixed to ../scanexamples/brokenincfiles.inc
|
||||||
|
@ -1051,13 +1051,14 @@ function TStandardCodeTool.CommentUnitsInUsesSections(MissingUnits: TStrings;
|
|||||||
// 3. uses {a, b,} c; commenting several units not at end
|
// 3. uses {a, b,} c; commenting several units not at end
|
||||||
// 4. uses a{, b, c} ; commenting units at end
|
// 4. uses a{, b, c} ; commenting units at end
|
||||||
// 5. {uses a, b, c;} commenting all units
|
// 5. {uses a, b, c;} commenting all units
|
||||||
|
// 6. uses {a,} b{, c}; commenting several units
|
||||||
var
|
var
|
||||||
i: Integer;
|
i: Integer;
|
||||||
CurUnitName: String;
|
CurUnitName: String;
|
||||||
CommentCurUnit: Boolean;
|
CommentCurUnit: Boolean;
|
||||||
FirstCommentUnitStart: Integer;
|
FirstCommentUnitStart: Integer;
|
||||||
LastCommaAfterCommentUnitsStart: Integer;
|
LastCommaAfterCommentUnitsStart: Integer;
|
||||||
FirstNormalUnitEnd: Integer;
|
LastNormalUnitEnd: Integer;
|
||||||
LastCommentUnitEnd: Integer;
|
LastCommentUnitEnd: Integer;
|
||||||
begin
|
begin
|
||||||
Result:=true;
|
Result:=true;
|
||||||
@ -1065,7 +1066,7 @@ function TStandardCodeTool.CommentUnitsInUsesSections(MissingUnits: TStrings;
|
|||||||
MoveCursorToUsesStart(UsesNode);
|
MoveCursorToUsesStart(UsesNode);
|
||||||
FirstCommentUnitStart:=-1;
|
FirstCommentUnitStart:=-1;
|
||||||
LastCommaAfterCommentUnitsStart:=-1;
|
LastCommaAfterCommentUnitsStart:=-1;
|
||||||
FirstNormalUnitEnd:=-1;
|
LastNormalUnitEnd:=-1;
|
||||||
LastCommentUnitEnd:=-1;
|
LastCommentUnitEnd:=-1;
|
||||||
repeat
|
repeat
|
||||||
// check if unit should be commented
|
// check if unit should be commented
|
||||||
@ -1084,10 +1085,10 @@ function TStandardCodeTool.CommentUnitsInUsesSections(MissingUnits: TStrings;
|
|||||||
LastCommentUnitEnd:=CurPos.EndPos;
|
LastCommentUnitEnd:=CurPos.EndPos;
|
||||||
end else begin
|
end else begin
|
||||||
// unit should be kept
|
// unit should be kept
|
||||||
if FirstNormalUnitEnd<1 then FirstNormalUnitEnd:=CurPos.EndPos;
|
LastNormalUnitEnd:=CurPos.EndPos;
|
||||||
if FirstCommentUnitStart>=1 then begin
|
if FirstCommentUnitStart>=1 then begin
|
||||||
// there are some units to be commented
|
// there are some units to be commented
|
||||||
// See examples: 1., 2., 3.
|
// See examples: 1., 2., 3. and 6.
|
||||||
Comment(FirstCommentUnitStart,LastCommaAfterCommentUnitsStart);
|
Comment(FirstCommentUnitStart,LastCommaAfterCommentUnitsStart);
|
||||||
FirstCommentUnitStart:=-1;
|
FirstCommentUnitStart:=-1;
|
||||||
LastCommentUnitEnd:=-1;
|
LastCommentUnitEnd:=-1;
|
||||||
@ -1100,8 +1101,8 @@ function TStandardCodeTool.CommentUnitsInUsesSections(MissingUnits: TStrings;
|
|||||||
ReadNextAtom; // read filename
|
ReadNextAtom; // read filename
|
||||||
if not AtomIsStringConstant then
|
if not AtomIsStringConstant then
|
||||||
RaiseExceptionFmt(ctsStrExpectedButAtomFound,[ctsStringConstant,GetAtom]);
|
RaiseExceptionFmt(ctsStrExpectedButAtomFound,[ctsStringConstant,GetAtom]);
|
||||||
if (not CommentCurUnit) and (FirstNormalUnitEnd<1) then
|
if (not CommentCurUnit) then
|
||||||
FirstNormalUnitEnd:=CurPos.EndPos;
|
LastNormalUnitEnd:=CurPos.EndPos;
|
||||||
if CommentCurUnit then
|
if CommentCurUnit then
|
||||||
LastCommentUnitEnd:=CurPos.EndPos;
|
LastCommentUnitEnd:=CurPos.EndPos;
|
||||||
ReadNextAtom; // read comma or semicolon
|
ReadNextAtom; // read comma or semicolon
|
||||||
@ -1113,10 +1114,10 @@ function TStandardCodeTool.CommentUnitsInUsesSections(MissingUnits: TStrings;
|
|||||||
if CurPos.Flag<>cafComma then begin
|
if CurPos.Flag<>cafComma then begin
|
||||||
if CommentCurUnit then begin
|
if CommentCurUnit then begin
|
||||||
// last unit must be commented
|
// last unit must be commented
|
||||||
if FirstNormalUnitEnd>=1 then begin
|
if LastNormalUnitEnd>=1 then begin
|
||||||
// there are some units to be kept
|
// there are some units to be kept
|
||||||
// See example: 4.
|
// See example: 4.
|
||||||
Comment(FirstNormalUnitEnd,LastCommentUnitEnd);
|
Comment(LastNormalUnitEnd,LastCommentUnitEnd);
|
||||||
end else begin
|
end else begin
|
||||||
// all units should be commented
|
// all units should be commented
|
||||||
// See example: 5.
|
// See example: 5.
|
||||||
|
Loading…
Reference in New Issue
Block a user