mirror of
				https://gitlab.com/freepascal.org/lazarus/lazarus.git
				synced 2025-11-04 10:19:52 +01:00 
			
		
		
		
	activated IgnoreErrorAfterCursor in codetools finddeclaration and identifier completion
git-svn-id: trunk@7521 -
This commit is contained in:
		
							parent
							
								
									40a72b9798
								
							
						
					
					
						commit
						cad5a68f98
					
				@ -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;
 | 
			
		||||
 | 
			
		||||
@ -32,7 +32,7 @@ interface
 | 
			
		||||
 | 
			
		||||
{$I codetools.inc}
 | 
			
		||||
 | 
			
		||||
{ $DEFINE IgnoreErrorAfterCursor}
 | 
			
		||||
{ $DEFINE DisableIgnoreErrorAfter}
 | 
			
		||||
 | 
			
		||||
uses
 | 
			
		||||
  {$IFDEF MEM_CHECK}
 | 
			
		||||
 | 
			
		||||
@ -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 ',LastErrorPhase<CodeToolPhaseTool,' ',LastErrorCurPos.EndPos);
 | 
			
		||||
@ -1844,13 +1842,7 @@ begin
 | 
			
		||||
  FIgnoreErrorAfter:=AValue;
 | 
			
		||||
  LastErrorCheckedForIgnored:=false;
 | 
			
		||||
  {$IFDEF ShowIgnoreErrorAfter}
 | 
			
		||||
  DbgOut'TCustomCodeTool.SetIgnoreErrorAfter ');
 | 
			
		||||
  if FIgnoreErrorAfter.Code<>nil 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);
 | 
			
		||||
 | 
			
		||||
@ -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,
 | 
			
		||||
 | 
			
		||||
@ -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);
 | 
			
		||||
 | 
			
		||||
@ -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;
 | 
			
		||||
 | 
			
		||||
 | 
			
		||||
@ -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;
 | 
			
		||||
 | 
			
		||||
@ -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
 | 
			
		||||
 | 
			
		||||
		Loading…
	
		Reference in New Issue
	
	Block a user