mirror of
https://gitlab.com/freepascal.org/lazarus/lazarus.git
synced 2025-08-11 14:37:48 +02:00
codetools: fixed validating last error
git-svn-id: trunk@9502 -
This commit is contained in:
parent
a53d727f95
commit
609922d9e5
@ -190,9 +190,9 @@ type
|
||||
ExceptionOnNotFound: boolean): TCodeTreeNode;
|
||||
function CaretToCleanPos(Caret: TCodeXYPosition;
|
||||
var CleanPos: integer): integer; // 0=valid CleanPos
|
||||
//-1=CursorPos was skipped, CleanPos between two links
|
||||
// 1=CursorPos beyond scanned code
|
||||
//-2=X,Y beyond source
|
||||
//-1=CursorPos was skipped, CleanPos between two links
|
||||
// 1=CursorPos beyond scanned code
|
||||
//-2=X,Y beyond source
|
||||
function CleanPosToCodePos(CleanPos: integer;
|
||||
out CodePos:TCodePosition): boolean; // true=ok, false=invalid CleanPos
|
||||
function CleanPosToCaret(CleanPos: integer;
|
||||
@ -1655,17 +1655,17 @@ function TCustomCodeTool.IgnoreErrorAfterPositionIsInFrontOfLastErrMessage: bool
|
||||
var
|
||||
IgnoreErrorAfterCleanPos: integer;
|
||||
begin
|
||||
DebugLn('TCustomCodeTool.IgnoreErrorAfterPositionIsInFrontOfLastErrMessage ',
|
||||
' LastErrorCheckedForIgnored='+dbgs(LastErrorCheckedForIgnored),
|
||||
' LastErrorBehindIgnorePosition='+dbgs(LastErrorBehindIgnorePosition));
|
||||
//DebugLn('TCustomCodeTool.IgnoreErrorAfterPositionIsInFrontOfLastErrMessage ',
|
||||
// ' LastErrorCheckedForIgnored='+dbgs(LastErrorCheckedForIgnored),
|
||||
// ' LastErrorBehindIgnorePosition='+dbgs(LastErrorBehindIgnorePosition));
|
||||
if LastErrorCheckedForIgnored then begin
|
||||
Result:=LastErrorBehindIgnorePosition;
|
||||
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='+dbgs(IgnoreErrorAfterCleanPos)+'"'+copy(Src,IgnoreErrorAfterCleanPos-6,6)+'"',
|
||||
// ' LastErrorCurPos.StartPos='+dbgs(LastErrorCurPos.StartPos)+'"'+copy(Src,LastErrorCurPos.StartPos-6,6)+'"',
|
||||
// ' LastErrorPhase>CodeToolPhaseParse='+dbgs(LastErrorPhase>CodeToolPhaseParse));
|
||||
if IgnoreErrorAfterCleanPos>0 then begin
|
||||
// ignore position in scanned code
|
||||
// -> check if last error is behind ignore position
|
||||
@ -1883,7 +1883,7 @@ begin
|
||||
FIgnoreErrorAfter:=AValue;
|
||||
LastErrorCheckedForIgnored:=false;
|
||||
{$IFDEF ShowIgnoreErrorAfter}
|
||||
DebugLn('TCustomCodeTool.SetIgnoreErrorAfter ',dbgsCP(FIgnoreErrorAfter));
|
||||
DebugLn('TCustomCodeTool.SetIgnoreErrorAfter FIgnoreErrorAfter=',dbgsCP(FIgnoreErrorAfter));
|
||||
{$ENDIF}
|
||||
if Scanner<>nil then
|
||||
Scanner.SetIgnoreErrorAfter(IgnoreErrorAfter.P,IgnoreErrorAfter.Code);
|
||||
|
@ -1490,8 +1490,8 @@ var
|
||||
CleanResult: integer;
|
||||
begin
|
||||
//DebugLn('TLinkScanner.IgnoreErrAfterPositionIsInFrontOfLastErrMessage');
|
||||
//DebugLn(' LastErrorCheckedForIgnored=',LastErrorCheckedForIgnored,
|
||||
// ' LastErrorBehindIgnorePosition=',LastErrorBehindIgnorePosition);
|
||||
//DebugLn([' LastErrorCheckedForIgnored=',LastErrorCheckedForIgnored,
|
||||
// ' LastErrorBehindIgnorePosition=',LastErrorBehindIgnorePosition]);
|
||||
if LastErrorCheckedForIgnored then
|
||||
Result:=LastErrorBehindIgnorePosition
|
||||
else begin
|
||||
@ -1500,9 +1500,11 @@ begin
|
||||
begin
|
||||
CleanResult:=CursorToCleanPos(FIgnoreErrorAfterCursorPos,
|
||||
FIgnoreErrorAfterCode,CleanedIgnoreErrorAfterPosition);
|
||||
//DebugLn(' CleanResult=',CleanResult,
|
||||
//DebugLn([' CleanResult=',CleanResult,
|
||||
// ' CleanedIgnoreErrorAfterPosition=',CleanedIgnoreErrorAfterPosition,
|
||||
// ' FIgnoreErrorAfterCursorPos=',FIgnoreErrorAfterCursorPos);
|
||||
// ' FIgnoreErrorAfterCursorPos=',FIgnoreErrorAfterCursorPos,
|
||||
// ' CleanedLen=',CleanedLen,
|
||||
// ' LastErrorIsValid=',LastErrorIsValid]);
|
||||
if (CleanResult=0) or (CleanResult=-1)
|
||||
or (not LastErrorIsValid) then begin
|
||||
Result:=true;
|
||||
@ -2754,7 +2756,7 @@ begin
|
||||
//DebugLn('[TLinkScanner.CursorToCleanPos] B ACleanPos=',ACleanPos);
|
||||
if i+1<LinkCount then begin
|
||||
// link has successor
|
||||
//DebugLn('[TLinkScanner.CursorToCleanPos] C Links[i+1].CleanedPos=',Links[i+1].CleanedPos);
|
||||
//DebugLn(['[TLinkScanner.CursorToCleanPos] C Links[i+1].CleanedPos=',Links[i+1].CleanedPos]);
|
||||
if ACleanPos<FLinks[i+1].CleanedPos then begin
|
||||
// link covers the cursor position
|
||||
Result:=0; // valid position
|
||||
@ -2782,8 +2784,8 @@ begin
|
||||
i:=j-1;
|
||||
end else begin
|
||||
// in last link
|
||||
//DebugLn('[TLinkScanner.CursorToCleanPos] E length(FCleanedSrc)=',length(FCleanedSrc));
|
||||
if ACleanPos<=length(FCleanedSrc) then begin
|
||||
//DebugLn(['[TLinkScanner.CursorToCleanPos] E ACleanPos=',ACleanPos,' CleanedLen=',CleanedLen]);
|
||||
if ACleanPos<=CleanedLen then begin
|
||||
Result:=0; // valid position
|
||||
exit;
|
||||
end;
|
||||
@ -2969,6 +2971,7 @@ begin
|
||||
LastErrorSrcPos:=SrcPos;
|
||||
LastErrorCode:=Code;
|
||||
LastErrorCheckedForIgnored:=false;
|
||||
LastErrorIsValid:=true;
|
||||
raise ExceptionClass.Create(Self,AMessage);
|
||||
end;
|
||||
|
||||
|
@ -3769,15 +3769,15 @@ begin
|
||||
end
|
||||
else if not (btKeepIgnoreErrorPos in BuildTreeFlags) then
|
||||
ClearIgnoreErrorAfter;
|
||||
|
||||
if (TreeRange=trTillCursor) and (not UpdateNeeded(true)) then begin
|
||||
// interface tree is valid
|
||||
|
||||
if (TreeRange=trTillCursor) and (not UpdateNeeded(false)) then begin
|
||||
// tree is valid
|
||||
// -> if there was an error, raise it again
|
||||
if (LastErrorPhase in [CodeToolPhaseScan,CodeToolPhaseParse])
|
||||
and ((not IgnoreErrorAfterValid)
|
||||
or (not IgnoreErrorAfterPositionIsInFrontOfLastErrMessage))
|
||||
then begin
|
||||
//DebugLn('TPascalParserTool.BuildTreeAndGetCleanPos RaiseLastError ',MainFilename);
|
||||
DebugLn('TPascalParserTool.BuildTreeAndGetCleanPos RaiseLastError ',MainFilename);
|
||||
RaiseLastError;
|
||||
end;
|
||||
// check if cursor is in interface
|
||||
|
Loading…
Reference in New Issue
Block a user