codetools: fixed ignoreerrorafter position to <= instead of <

git-svn-id: trunk@13561 -
This commit is contained in:
mattias 2008-01-01 21:03:27 +00:00
parent b7a82699cc
commit 4b2895f732
3 changed files with 64 additions and 25 deletions

View File

@ -316,6 +316,7 @@ type
function IgnoreErrorAfterPositionIsInFrontOfLastErrMessage: boolean;
function IgnoreErrorAfterValid: boolean;
function IgnoreErrorAfterCleanedPos: integer;
function CleanPosIsAfterIgnorePos(CleanPos: integer): boolean;
function LastErrorIsInFrontOfCleanedPos(ACleanedPos: integer): boolean;
procedure RaiseLastErrorIfInFrontOfCleanedPos(ACleanedPos: integer);
property OnParserProgress: TOnParserProgress
@ -1743,14 +1744,14 @@ begin
end else begin
if (Scanner<>nil) then begin
IgnoreErrorAfterCleanPos:=Scanner.IgnoreErrorAfterCleanedPos;
//DebugLn(' IgnoreErrorAfterCleanPos='+dbgs(IgnoreErrorAfterCleanPos)+'"'+copy(Src,IgnoreErrorAfterCleanPos-6,6)+'"',
// ' LastErrorCurPos.StartPos='+dbgs(LastErrorCurPos.StartPos)+'"'+copy(Src,LastErrorCurPos.StartPos-6,6)+'"',
// ' LastErrorPhase>CodeToolPhaseParse='+dbgs(LastErrorPhase>CodeToolPhaseParse));
//DebugLn([' IgnoreErrorAfterCleanPos=',IgnoreErrorAfterCleanPos,' "',copy(Src,IgnoreErrorAfterCleanPos-6,6),'"',
// ' LastErrorCurPos.StartPos=',LastErrorCurPos.StartPos,' "',copy(Src,LastErrorCurPos.StartPos-6,6),'"',
// ' LastErrorPhase>CodeToolPhaseParse=',LastErrorPhase>CodeToolPhaseParse]);
if IgnoreErrorAfterCleanPos>0 then begin
// ignore position in scanned code
// -> check if last error is behind ignore position
// -> check if last error is behind or equal ignore position
if (not LastErrorValid)
or (IgnoreErrorAfterCleanPos<LastErrorCurPos.StartPos) then
or (IgnoreErrorAfterCleanPos<=LastErrorCurPos.StartPos) then
Result:=true
else
Result:=false;
@ -1785,6 +1786,11 @@ begin
{$ENDIF}
end;
function TCustomCodeTool.CleanPosIsAfterIgnorePos(CleanPos: integer): boolean;
begin
Result:=(Scanner<>nil) and Scanner.CleanPosIsAfterIgnorePos(CleanPos);
end;
function TCustomCodeTool.LastErrorIsInFrontOfCleanedPos(ACleanedPos: integer
): boolean;
begin

View File

@ -293,7 +293,7 @@ type
LastErrorIsValid: boolean;
LastErrorBehindIgnorePosition: boolean;
LastErrorCheckedForIgnored: boolean;
CleanedIgnoreErrorAfterPosition: integer;
CleanedIgnoreErrorAfterPosition: integer;// ignore if valid and >=
procedure RaiseExceptionFmt(const AMessage: string; Args: array of const);
procedure RaiseException(const AMessage: string);
procedure RaiseExceptionClass(const AMessage: string;
@ -357,8 +357,9 @@ type
procedure SetIgnoreErrorAfter(ACursorPos: integer; ACode: Pointer);
procedure ClearIgnoreErrorAfter;
function IgnoreErrAfterPositionIsInFrontOfLastErrMessage: boolean;
function IgnoreErrorAfterCleanedPos: integer;
function IgnoreErrorAfterCleanedPos: integer;// before using this, check if valid!
function IgnoreErrorAfterValid: boolean;
function CleanPosIsAfterIgnorePos(CleanPos: integer): boolean;
function LoadSourceCaseLoUp(const AFilename: string): pointer;
function GuessMisplacedIfdefEndif(StartCursorPos: integer;
@ -1568,6 +1569,21 @@ begin
{$ENDIF}
end;
function TLinkScanner.CleanPosIsAfterIgnorePos(CleanPos: integer): boolean;
var
p: LongInt;
begin
if IgnoreErrorAfterValid then begin
p:=IgnoreErrorAfterCleanedPos;
if p<1 then
Result:=false
else
Result:=CleanPos>=p;
end else begin
Result:=false
end;
end;
function TLinkScanner.LastErrorIsInFrontOfCleanedPos(ACleanedPos: integer
): boolean;
begin

View File

@ -722,8 +722,9 @@ begin
DebugLn('TPascalParserTool.BuildSubTreeForBeginBlock ',MainFilename,' ERROR: ',LastErrorMessage);
{$ENDIF}
if (not IgnoreErrorAfterValid)
or (not IgnoreErrorAfterPositionIsInFrontOfLastErrMessage) then
or (not IgnoreErrorAfterPositionIsInFrontOfLastErrMessage) then begin
raise;
end;
{$IFDEF ShowIgnoreErrorAfter}
DebugLn('TPascalParserTool.BuildSubTreeForBeginBlock ',MainFilename,' IGNORING ERROR: ',LastErrorMessage);
{$ENDIF}
@ -2412,14 +2413,37 @@ end;
function TPascalParserTool.ReadWithStatement(ExceptionOnError,
CreateNodes: boolean): boolean;
var WithVarNode: TCodeTreeNode;
procedure CloseNodes;
var WithVarNode: TCodeTreeNode;
begin
if CreateNodes then begin
if CurNode.Desc=ctnWithStatement then begin
CurNode.EndPos:=CurPos.StartPos;
EndChildNode; // ctnWithStatement
end;
WithVarNode:=CurNode;
CurNode.EndPos:=CurPos.StartPos;
EndChildNode; // ctnWithVariable
// set all with variable ends
while (WithVarNode<>nil) and (WithVarNode.FirstChild=nil) do begin
WithVarNode.EndPos:=CurPos.StartPos;
WithVarNode:=WithVarNode.PriorBrother;
end;
end;
end;
begin
ReadNextAtom; // read variable name
if CreateNodes then begin
CreateChildNode;
CurNode.Desc:=ctnWithVariable;
end;
ReadTilVariableEnd(true);
if not ReadTilVariableEnd(ExceptionOnError) then begin
CloseNodes;
Result:=false;
exit;
end;
while CurPos.Flag=cafComma do begin
if CreateNodes then
EndChildNode;
@ -2428,12 +2452,17 @@ begin
CreateChildNode;
CurNode.Desc:=ctnWithVariable
end;
ReadTilVariableEnd(true);
if not ReadTilVariableEnd(ExceptionOnError) then begin
CloseNodes;
Result:=false;
exit;
end;
end;
if not UpAtomIs('DO') then begin
if ExceptionOnError then
RaiseStringExpectedButAtomFound('"do"')
else begin
CloseNodes;
Result:=false;
exit;
end;
@ -2443,20 +2472,8 @@ begin
CreateChildNode;
CurNode.Desc:=ctnWithStatement;
end;
ReadTilStatementEnd(true,CreateNodes);
if CreateNodes then begin
CurNode.EndPos:=CurPos.StartPos;
EndChildNode; // ctnWithStatement
WithVarNode:=CurNode.PriorBrother;
CurNode.EndPos:=CurPos.StartPos;
EndChildNode; // ctnWithVariable
// set all with variable ends
while (WithVarNode<>nil) and (WithVarNode.FirstChild=nil) do begin
WithVarNode.EndPos:=CurPos.StartPos;
WithVarNode:=WithVarNode.PriorBrother;
end;
end;
Result:=true;
Result:=ReadTilStatementEnd(ExceptionOnError,CreateNodes);
CloseNodes;
end;
function TPascalParserTool.ReadOnStatement(ExceptionOnError,