codetools: complete block: do not add semicolon in front of an else, bug #14021

git-svn-id: trunk@20689 -
This commit is contained in:
mattias 2009-06-21 11:16:35 +00:00
parent 51d5f674d6
commit d25179de98
2 changed files with 22 additions and 1 deletions

View File

@ -26,6 +26,7 @@ implementation
{$IFDEF repeatifelse} {$I repeatifelse1.inc} {$ENDIF}
{$IFDEF ifbegin} {$I ifbegin1.inc} {$ENDIF}
{$IFDEF ifbeginelse} {$I ifbeginelse1.inc} {$ENDIF}
{$IFDEF beginwithoutindent} {$I beginwithoutindent1.inc} {$ENDIF}
end.

View File

@ -5254,13 +5254,22 @@ var
end;
end;
end;
// use existing semicolon
// replace trailing spaces
while (ToPos<=SrcLen) and (Src[ToPos] in [' ',#9]) do inc(ToPos);
// use existing semicolon
if (NewCode[length(NewCode)]=';')
and (ToPos<=SrcLen) and (Src[ToPos]=';') then begin
AfterGap:=gtNone;
inc(ToPos);
end;
// use existing "else"
if (NewCode[length(NewCode)]=';') then begin
MoveCursorToCleanPos(ToPos);
ReadNextAtom;
if UpAtomIs('ELSE') then
NewCode:=copy(NewCode,1,length(NewCode)-1);
end;
// adjust indent of first line
if FrontGap in [gtNone,gtSpace] then begin
BeautifyFlags:=BeautifyFlags+[bcfDoNotIndentFirstLine];
@ -5503,6 +5512,17 @@ var
if not EndBlockIsOk then exit;
BeginBlock(Stack,btCaseElse,CurPos.StartPos);
end;
btBegin:
begin
// missing end
if InCursorBlock then begin
{$IFDEF ShowCompleteBlock}
DebugLn(['ReadStatements NeedCompletion: unexpected else at ',CleanPosToStr(CurPos.StartPos),': missing end. block start: ',CleanPosToStr(Stack.Stack[Stack.Top].StartPos)]);
{$ENDIF}
NeedCompletion:=true;
end;
break;
end;
btCaseColon,btRepeat:
begin
// missing semicolon