diff --git a/components/codetools/codeatom.pas b/components/codetools/codeatom.pas index b65a9fae21..2a17669a7f 100644 --- a/components/codetools/codeatom.pas +++ b/components/codetools/codeatom.pas @@ -144,6 +144,9 @@ function CompareCodeXYPositions(Pos1, Pos2: PCodeXYPosition): integer; var WordToAtomFlag: TWordToAtomFlag; + +function DbgsCXY(const p: TCodeXYPosition): string; +function DbgsCP(const p: TCodePosition): string; implementation @@ -181,6 +184,26 @@ begin else Result:=0; end; +function DbgsCXY(const p: TCodeXYPosition): string; +begin + if p.Code=nil then + Result:='(none)' + else + Result:=p.Code.Filename+'(y='+dbgs(p.y)+',x='+dbgs(p.x)+')'; +end; + +function DbgsCP(const p: TCodePosition): string; +var + CodeXYPosition: TCodeXYPosition; +begin + FillChar(CodeXYPosition,SizeOf(TCodeXYPosition),0); + CodeXYPosition.Code:=p.Code; + if CodeXYPosition.Code<>nil then begin + CodeXYPosition.Code.AbsoluteToLineCol(p.P,CodeXYPosition.Y,CodeXYPosition.X); + end; + Result:=DbgsCXY(CodeXYPosition); +end; + { TAtomRing } constructor TAtomRing.Create; diff --git a/components/codetools/codetemplatestool.pas b/components/codetools/codetemplatestool.pas index cda106f842..11437d1f1c 100644 --- a/components/codetools/codetemplatestool.pas +++ b/components/codetools/codetemplatestool.pas @@ -32,7 +32,7 @@ interface {$I codetools.inc} -{ $DEFINE IgnoreErrorAfterCursor} +{ $DEFINE DisableIgnoreErrorAfter} uses {$IFDEF MEM_CHECK} diff --git a/components/codetools/customcodetool.pas b/components/codetools/customcodetool.pas index 2bc961930b..dc195caa35 100644 --- a/components/codetools/customcodetool.pas +++ b/components/codetools/customcodetool.pas @@ -1654,7 +1654,7 @@ begin LastErrorCheckedForIgnored:=true; end; {$IFDEF ShowIgnoreErrorAfter} - DebugLn('TCustomCodeTool.IgnoreErrAfterPositionIsInFrontOfLastErrMessage ',Result); + DebugLn('TCustomCodeTool.IgnoreErrAfterPositionIsInFrontOfLastErrMessage ',dbgs(Result)); {$ENDIF} end; @@ -1662,7 +1662,7 @@ function TCustomCodeTool.IgnoreErrorAfterValid: boolean; begin Result:=(Scanner<>nil) and (Scanner.IgnoreErrorAfterValid); {$IFDEF ShowIgnoreErrorAfter} - DebugLn('TCustomCodeTool.IgnoreErrorAfterValid ',Result); + DebugLn('TCustomCodeTool.IgnoreErrorAfterValid ',dbgs(Result)); {$ENDIF} end; @@ -1673,7 +1673,7 @@ begin else Result:=-1; {$IFDEF ShowIgnoreErrorAfter} - DebugLn('TCustomCodeTool.IgnoreErrorAfterCleanedPos ',Result); + DebugLn('TCustomCodeTool.IgnoreErrorAfterCleanedPos ',dbgs(Result)); {$ENDIF} end; @@ -1689,8 +1689,7 @@ begin else Result:=false; {$IFDEF ShowIgnoreErrorAfter} - DebugLn('TCustomCodeTool.LastErrorsInFrontOfCleanedPos ACleanedPos=',ACleanedPos, - Result); + DebugLn('TCustomCodeTool.LastErrorsInFrontOfCleanedPos ACleanedPos=',dbgs(ACleanedPos),' ',dbgs(Result)); {$ENDIF} end; @@ -1698,8 +1697,7 @@ procedure TCustomCodeTool.RaiseLastErrorIfInFrontOfCleanedPos( ACleanedPos: integer); begin {$IFDEF ShowIgnoreErrorAfter} - DebugLn('TCustomCodeTool.RaiseLastErrorIfInFrontOfCleanedPos A ACleanedPos=',ACleanedPos, - ' '); + DebugLn('TCustomCodeTool.RaiseLastErrorIfInFrontOfCleanedPos A ACleanedPos=',dbgs(ACleanedPos)); {$ENDIF} if Scanner<>nil then Scanner.RaiseLastErrorIfInFrontOfCleanedPos(ACleanedPos); //DebugLn('TCustomCodeTool.RaiseLastErrorIfInFrontOfCleanedPos B ',LastErrorPhasenil then - DbgOutFIgnoreErrorAfter.Code.Filename) - else - DbgOut'nil'); - DbgOut' ',FIgnoreErrorAfter.P); - DebugLn(''); + DebugLn('TCustomCodeTool.SetIgnoreErrorAfter ',dbgsCP(FIgnoreErrorAfter)); {$ENDIF} if Scanner<>nil then Scanner.SetIgnoreErrorAfter(IgnoreErrorAfter.P,IgnoreErrorAfter.Code); diff --git a/components/codetools/finddeclarationtool.pas b/components/codetools/finddeclarationtool.pas index c54beaa96e..c4fa821500 100644 --- a/components/codetools/finddeclarationtool.pas +++ b/components/codetools/finddeclarationtool.pas @@ -75,7 +75,7 @@ interface {$IFDEF ShowTriedContexts}{$DEFINE DebugPrefix}{$ENDIF} // new features -{ $DEFINE IgnoreErrorAfterCursor} +{ $DEFINE DisableIgnoreErrorAfter} uses {$IFDEF MEM_CHECK} @@ -1026,16 +1026,16 @@ begin ActivateGlobalWriteLock; try // build code tree - {$IFDEF CTDEBUG} - DebugLn(DebugPrefix,'TFindDeclarationTool.FindDeclaration A CursorPos=',dbgs(CursorPos.X),',',dbgs(CursorPos.Y)); - {$ENDIF} + { $IFDEF CTDEBUG} + DebugLn('TFindDeclarationTool.FindDeclaration A CursorPos=X',dbgs(CursorPos.X),',Y',dbgs(CursorPos.Y)); + { $ENDIF} if DirtySrc<>nil then DirtySrc.Clear; BuildTreeAndGetCleanPos(trTillCursor,CursorPos,CleanCursorPos, - [{$IFDEF IgnoreErrorAfterCursor}btSetIgnoreErrorPos{$ENDIF} + [{$IFNDEF DisableIgnoreErrorAfter}btSetIgnoreErrorPos,{$ENDIF} btLoadDirtySource,btCursorPosOutAllowed]); - {$IFDEF CTDEBUG} - DebugLn(DebugPrefix,'TFindDeclarationTool.FindDeclaration C CleanCursorPos=',dbgs(CleanCursorPos)); - {$ENDIF} + { $IFDEF CTDEBUG} + DebugLn('TFindDeclarationTool.FindDeclaration C CleanCursorPos=',dbgs(CleanCursorPos)); + { $ENDIF} // find CodeTreeNode at cursor if (Tree.Root<>nil) and (Tree.Root.StartPos<=CleanCursorPos) then begin CursorNode:=BuildSubTreeAndFindDeepestNodeAtPos(Tree.Root,CleanCursorPos, diff --git a/components/codetools/identcompletiontool.pas b/components/codetools/identcompletiontool.pas index 9ce6c93711..76f27d51db 100644 --- a/components/codetools/identcompletiontool.pas +++ b/components/codetools/identcompletiontool.pas @@ -45,7 +45,7 @@ interface { $DEFINE ShowHistory} // new features -{ $DEFINE IgnoreErrorAfterCursor} +{ $DEFINE DisableIgnoreErrorAfter} uses @@ -855,7 +855,7 @@ begin DebugLn('TIdentCompletionTool.GatherIdentifiers A CursorPos=',dbgs(CursorPos.X),',',dbgs(CursorPos.Y)); {$ENDIF} BuildTreeAndGetCleanPos(trTillCursor,CursorPos,CleanCursorPos, - [{$IFDEF IgnoreErrorAfterCursor}btSetIgnoreErrorPos,{$ENDIF}]); + [{$IFNDEF DisableIgnoreErrorAfter}btSetIgnoreErrorPos{$ENDIF}]); // find node at position CursorNode:=FindDeepestExpandedNodeAtPos(CleanCursorPos,true); diff --git a/components/codetools/linkscanner.pas b/components/codetools/linkscanner.pas index b9e9dc5d50..36ef8c71cb 100644 --- a/components/codetools/linkscanner.pas +++ b/components/codetools/linkscanner.pas @@ -1470,12 +1470,12 @@ begin FIgnoreErrorAfterCursorPos:=ACursorPos; LastErrorCheckedForIgnored:=false; {$IFDEF ShowIgnoreErrorAfter} - DbgOut'TLinkScanner.SetIgnoreErrorAfter '); + DbgOut('TLinkScanner.SetIgnoreErrorAfter '); if FIgnoreErrorAfterCode<>nil then - DbgOutOnGetFileName(Self,FIgnoreErrorAfterCode)) + DbgOut(OnGetFileName(Self,FIgnoreErrorAfterCode)) else - DbgOut'nil'); - DbgOut' ',IntToStr(FIgnoreErrorAfterCursorPos)); + DbgOut('nil'); + DbgOut(' ',dbgs(FIgnoreErrorAfterCursorPos)); DebugLn(''); {$ENDIF} end; @@ -1516,7 +1516,7 @@ begin LastErrorCheckedForIgnored:=true; end; {$IFDEF ShowIgnoreErrorAfter} - DebugLn('TLinkScanner.IgnoreErrAfterPositionIsInFrontOfLastErrMessage Result=',Result); + DebugLn('TLinkScanner.IgnoreErrAfterPositionIsInFrontOfLastErrMessage Result=',dbgs(Result)); {$ENDIF} end; @@ -1527,7 +1527,7 @@ begin else Result:=-1; {$IFDEF ShowIgnoreErrorAfter} - DebugLn('TLinkScanner.IgnoreErrorAfterCleanedPos Result=',Result); + DebugLn('TLinkScanner.IgnoreErrorAfterCleanedPos Result=',dbgs(Result)); {$ENDIF} end; @@ -1535,7 +1535,7 @@ function TLinkScanner.IgnoreErrorAfterValid: boolean; begin Result:=(FIgnoreErrorAfterCode<>nil); {$IFDEF ShowIgnoreErrorAfter} - DebugLn('TLinkScanner.IgnoreErrorAfterValid Result=',Result); + DebugLn('TLinkScanner.IgnoreErrorAfterValid Result=',dbgs(Result)); {$ENDIF} end; @@ -1544,7 +1544,7 @@ function TLinkScanner.LastErrorsInFrontOfCleanedPos(ACleanedPos: integer begin Result:=LastErrorIsValid and (CleanedLen>ACleanedPos); {$IFDEF ShowIgnoreErrorAfter} - DebugLn('TLinkScanner.LastErrorsInFrontOfCleanedPos Result=',Result); + DebugLn('TLinkScanner.LastErrorsInFrontOfCleanedPos Result=',dbgs(Result)); {$ENDIF} end; diff --git a/components/codetools/pascalparsertool.pas b/components/codetools/pascalparsertool.pas index ca5d24b84f..e0e1cb8ab8 100644 --- a/components/codetools/pascalparsertool.pas +++ b/components/codetools/pascalparsertool.pas @@ -3438,6 +3438,7 @@ begin IgnorePos.Code:=CursorPos.Code; IgnorePos.Code.LineColToPosition(CursorPos.Y,CursorPos.X,IgnorePos.P); if IgnorePos.P<1 then IgnorePos.Code:=nil; + debugln('TPascalParserTool.BuildTreeAndGetCleanPos IgnorePos=',dbgsCP(IgnorePos)); IgnoreErrorAfter:=IgnorePos; end else ClearIgnoreErrorAfter; @@ -3474,7 +3475,7 @@ begin CaretType:=CaretToCleanPos(CursorPos, CleanCursorPos); if (CaretType=0) or (CaretType=-1) then begin BuildSubTree(CleanCursorPos); - if (CaretType=-1) and (btLoadDirtySource in BuildTreeFlags) then begin + if (CaretType=-1) and (btLoadDirtySource in BuildTreeFlags) then begin // cursor position lies in dead code (skipped code between IFDEF/ENDIF) LoadDirtySource(CursorPos); end; diff --git a/components/codetools/stdcodetools.pas b/components/codetools/stdcodetools.pas index ef60db928f..7299aa6b3f 100644 --- a/components/codetools/stdcodetools.pas +++ b/components/codetools/stdcodetools.pas @@ -41,7 +41,7 @@ interface {$I codetools.inc} -{ $DEFINE IgnoreErrorAfterCursor} +{ $DEFINE DisableIgnoreErrorAfter} { $DEFINE VerboseGetStringConstBounds} uses @@ -3791,7 +3791,7 @@ begin Result:=false; try BuildTreeAndGetCleanPos(trTillCursor,CursorPos,CleanCursorPos, - [{$IFDEF IgnoreErrorAfterCursor}btSetIgnoreErrorPos{$ENDIF}]); + [{$IFNDEF DisableIgnoreErrorAfter}btSetIgnoreErrorPos{$ENDIF}]); LinkIndex:=Scanner.LinkIndexAtCleanPos(CleanCursorPos); LinkIndex:=Scanner.FindParentLink(LinkIndex); if LinkIndex<0 then