codetools: never add spaces in front of newline and space

git-svn-id: trunk@34971 -
This commit is contained in:
mattias 2012-01-27 10:07:22 +00:00
parent 7d4c394fe2
commit c69b510a58
2 changed files with 19 additions and 15 deletions

View File

@ -161,19 +161,19 @@ var
: TKeyWordFunctionList;
UpChars: array[char] of char;
IsSpaceChar, // [#0..#32]
IsLineEndChar,
IsWordChar, // ['a'..'z','A'..'Z']
IsNonWordChar, // [#0..#127]-IsIdentChar
IsIdentStartChar,
IsIdentChar,
IsDottedIdentChar,
IsNumberChar,
IsSpaceChar, // [#0..#32]
IsLineEndChar, // [#10,#13]
IsWordChar, // ['a'..'z','A'..'Z']
IsNonWordChar, // [#0..#127]-IsIdentChar
IsIdentStartChar, // ['a'..'z','A'..'Z','_']
IsIdentChar, // ['a'..'z','A'..'Z','_','0'..'9']
IsDottedIdentChar, // ['.','a'..'z','A'..'Z','_','0'..'9']
IsNumberChar, // ['0'..'9']
IsCommentStartChar,
IsCommentEndChar,
IsHexNumberChar,
IsEqualOperatorStartChar,
IsAfterFloatPointChar:
IsHexNumberChar, // ['0'..'9','a'..'f','A'..'F']
IsEqualOperatorStartChar, // [':','+','-','/','*','<','>']
IsAfterFloatPointChar: // ['0'..'9','e','E']
array[char] of boolean;
function UpperCaseStr(const s: string): string;

View File

@ -1634,6 +1634,8 @@ var
OldIndent: Integer;
OldAtomStart: LongInt;
AfterProcedure: Boolean;
CurDoNotInsertSpaceAfter: TAtomTypes;
CurDoNotInsertSpaceInFront: TAtomTypes;
begin
//DebugLn('**********************************************************');
//DebugLn('[TBeautifyCodeOptions.BeautifyStatement] "',AStatement,'"');
@ -1641,6 +1643,8 @@ begin
// set flags
CurFlags:=BeautifyFlags;
OldIndent:=Indent;
CurDoNotInsertSpaceAfter:=DoNotInsertSpaceAfter+[atNewLine,atSpace];
CurDoNotInsertSpaceInFront:=DoNotInsertSpaceInFront+[atNewLine,atSpace];
try
if bcfNoIndentOnBreakLine in CurFlags then
Indent:=0;
@ -1696,10 +1700,10 @@ begin
and (SameText(CurAtom, 'procedure') or SameText(CurAtom, 'function'))
then
AfterProcedure := True;
//DebugLn(['TBeautifyCodeOptions.BeautifyStatement ',CurAtom,' LastAtomType=',AtomTypeNames[LastAtomType],',',LastAtomType in DoNotInsertSpaceAfter,',',LastAtomType in DoInsertSpaceAfter,' CurAtomType=',AtomTypeNames[CurAtomType],',',CurAtomType in DoNotInsertSpaceInFront,',',CurAtomType in DoInsertSpaceInFront]);
if ((Result='') or (Result[length(Result)]<>' '))
and (not (CurAtomType in DoNotInsertSpaceInFront))
and (not (LastAtomType in DoNotInsertSpaceAfter))
//DebugLn(['TBeautifyCodeOptions.BeautifyStatement ',CurAtom,' LastAtomType=',AtomTypeNames[LastAtomType],',',LastAtomType in CurDoNotInsertSpaceAfter,',',LastAtomType in DoInsertSpaceAfter,' CurAtomType=',AtomTypeNames[CurAtomType],',',CurAtomType in CurDoNotInsertSpaceInFront,',',CurAtomType in DoInsertSpaceInFront]);
if ((Result='') or (not IsSpaceChar[Result[length(Result)]]))
and (not (CurAtomType in CurDoNotInsertSpaceInFront))
and (not (LastAtomType in CurDoNotInsertSpaceAfter))
and ((CurAtomType in DoInsertSpaceInFront)
or (LastAtomType in DoInsertSpaceAfter))
then begin