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

View File

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

View File

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