codetools: completeblock: fixed closing nested if else

git-svn-id: trunk@20433 -
This commit is contained in:
mattias 2009-06-05 11:38:03 +00:00
parent 0ac9217af3
commit 58acb9da65
5 changed files with 35 additions and 27 deletions

1
.gitattributes vendored
View File

@ -167,6 +167,7 @@ components/codetools/examples/testscompleteblock/ifbegin1.inc svneol=native#text
components/codetools/examples/testscompleteblock/procedurebegin1.inc svneol=native#text/plain components/codetools/examples/testscompleteblock/procedurebegin1.inc svneol=native#text/plain
components/codetools/examples/testscompleteblock/procedurebeginend1.inc svneol=native#text/plain components/codetools/examples/testscompleteblock/procedurebeginend1.inc svneol=native#text/plain
components/codetools/examples/testscompleteblock/record1.inc svneol=native#text/plain components/codetools/examples/testscompleteblock/record1.inc svneol=native#text/plain
components/codetools/examples/testscompleteblock/repeatifelse1.inc svneol=native#text/plain
components/codetools/examples/testscompleteblock/unit1.pas svneol=native#text/plain components/codetools/examples/testscompleteblock/unit1.pas svneol=native#text/plain
components/codetools/examples/testscompleteblock/whilebegin1.inc svneol=native#text/plain components/codetools/examples/testscompleteblock/whilebegin1.inc svneol=native#text/plain
components/codetools/expreval.pas svneol=native#text/pascal components/codetools/expreval.pas svneol=native#text/pascal

View File

@ -9,7 +9,7 @@
<MainUnitHasTitleStatement Value="False"/> <MainUnitHasTitleStatement Value="False"/>
<LRSInOutputDirectory Value="False"/> <LRSInOutputDirectory Value="False"/>
</Flags> </Flags>
<SessionStorage Value="InProjectDir"/> <SessionStorage Value="InIDEConfig"/>
<MainUnit Value="0"/> <MainUnit Value="0"/>
<TargetFileExt Value=""/> <TargetFileExt Value=""/>
<Title Value="completeblock"/> <Title Value="completeblock"/>
@ -30,35 +30,12 @@
<PackageName Value="CodeTools"/> <PackageName Value="CodeTools"/>
</Item1> </Item1>
</RequiredPackages> </RequiredPackages>
<Units Count="6"> <Units Count="1">
<Unit0> <Unit0>
<Filename Value="completeblock.pas"/> <Filename Value="completeblock.pas"/>
<IsPartOfProject Value="True"/> <IsPartOfProject Value="True"/>
<UnitName Value="CompleteBlock"/> <UnitName Value="CompleteBlock"/>
</Unit0> </Unit0>
<Unit1>
<Filename Value="scanexamples/brokenfilenames.pas"/>
<IsPartOfProject Value="True"/>
<UnitName Value="BrokenFilenames"/>
</Unit1>
<Unit2>
<Filename Value="scanexamples/brokenincfiles.inc"/>
<IsPartOfProject Value="True"/>
</Unit2>
<Unit3>
<Filename Value="scanexamples/empty.inc"/>
<IsPartOfProject Value="True"/>
</Unit3>
<Unit4>
<Filename Value="scanexamples/indentation.pas"/>
<IsPartOfProject Value="True"/>
<UnitName Value="Indentation"/>
</Unit4>
<Unit5>
<Filename Value="completeblocktests/unit1.pas"/>
<IsPartOfProject Value="True"/>
<UnitName Value="unit1"/>
</Unit5>
</Units> </Units>
</ProjectOptions> </ProjectOptions>
<CompilerOptions> <CompilerOptions>

View File

@ -0,0 +1,22 @@
{%MainUnit unit1.pas}
procedure Do1;
var
FileInfo: TSearchRec;
begin
if FindFirstUTF8(Dir+FileMask,faAnyFile,FileInfo)=0 then begin
repeat
// check if special file
if (FileInfo.Name='.') or (FileInfo.Name='..') or (FileInfo.Name='')
then
continue;
if FilenameIsPascalUnit(FileInfo.Name,false) then begin
List.Add(Dir+FileInfo.Name);
end else if (FileInfo.Attr and faDirectory)>0 then begin
CollectUnits(Dir+);
end;
until FindNextUTF8(FileInfo)<>0;
end;
FindCloseUTF8(FileInfo);
end;

View File

@ -22,6 +22,8 @@ implementation
{$IFDEF casecolon} {$I casecolon1.inc} {$ENDIF} {$IFDEF casecolon} {$I casecolon1.inc} {$ENDIF}
{$IFDEF repeatifelse} {$I repeatifelse1.inc} {$ENDIF}
{$IFDEF ifbegin} {$I ifbegin1.inc} {$ENDIF} {$IFDEF ifbegin} {$I ifbegin1.inc} {$ENDIF}
{$IFDEF beginwithoutindent} {$I beginwithoutindent1.inc} {$ENDIF} {$IFDEF beginwithoutindent} {$I beginwithoutindent1.inc} {$ENDIF}

View File

@ -43,7 +43,7 @@ interface
{ $DEFINE DisableIgnoreErrorAfter} { $DEFINE DisableIgnoreErrorAfter}
{ $DEFINE VerboseGetStringConstBounds} { $DEFINE VerboseGetStringConstBounds}
{ $DEFINE ShowCompleteBlock} {$DEFINE ShowCompleteBlock}
uses uses
{$IFDEF MEM_CHECK} {$IFDEF MEM_CHECK}
@ -5397,6 +5397,8 @@ var
btCaseColon,btRepeat: btCaseColon,btRepeat:
begin begin
// missing semicolon or until // missing semicolon or until
DebugLn(['ReadStatements CursorBlockLvl=',CursorBlockLvl,' Stack.Top=',Stack.Top,' BehindCursorBlock=',BehindCursorBlock]);
DebugLn(['ReadStatements unexpected end at ',CleanPosToStr(CurPos.StartPos),': missing finally ',CleanPosToStr(Stack.Stack[Stack.Top].StartPos)]);
if InCursorBlock then begin if InCursorBlock then begin
{$IFDEF ShowCompleteBlock} {$IFDEF ShowCompleteBlock}
DebugLn(['ReadStatements NeedCompletion: unexpected end at ',CleanPosToStr(CurPos.StartPos),': missing semicolon or until ',CleanPosToStr(Stack.Stack[Stack.Top].StartPos)]); DebugLn(['ReadStatements NeedCompletion: unexpected end at ',CleanPosToStr(CurPos.StartPos),': missing semicolon or until ',CleanPosToStr(Stack.Stack[Stack.Top].StartPos)]);
@ -5449,8 +5451,9 @@ var
if TopBlockType(Stack)=btCaseOf then if TopBlockType(Stack)=btCaseOf then
BeginBlock(Stack,btCaseColon,CurPos.StartPos); BeginBlock(Stack,btCaseColon,CurPos.StartPos);
cafSemicolon: cafSemicolon:
if TopBlockType(Stack) in [btCaseColon,btIf,btIfElse] then while TopBlockType(Stack) in [btCaseColon,btIf,btIfElse] do begin
if not EndBlockIsOk then exit; if not EndBlockIsOk then exit;
end;
cafBegin: cafBegin:
BeginBlock(Stack,btBegin,CurPos.StartPos); BeginBlock(Stack,btBegin,CurPos.StartPos);
cafWord: cafWord:
@ -5472,6 +5475,9 @@ var
if not EndBlockIsOk then exit; if not EndBlockIsOk then exit;
end else begin end else begin
// until without repeat // until without repeat
DebugLn(['ReadStatements CursorBlockLvl=',CursorBlockLvl,' Stack.Top=',Stack.Top,' BehindCursorBlock=',BehindCursorBlock,' Block=',ord(TopBlockType(Stack))]);
DebugLn(['ReadStatements unexpected until at ',CleanPosToStr(CurPos.StartPos)]);
exit;
end; end;
end else if UpAtomIs('ASM') then begin end else if UpAtomIs('ASM') then begin
BeginBlock(Stack,btAsm,CurPos.StartPos); BeginBlock(Stack,btAsm,CurPos.StartPos);