activated IgnoreErrorAfterCursor in codetools finddeclaration and identifier completion

git-svn-id: trunk@7521 -
This commit is contained in:
mattias 2005-08-17 16:51:41 +00:00
parent 40a72b9798
commit cad5a68f98
8 changed files with 52 additions and 36 deletions

View File

@ -145,6 +145,9 @@ function CompareCodeXYPositions(Pos1, Pos2: PCodeXYPosition): integer;
var var
WordToAtomFlag: TWordToAtomFlag; WordToAtomFlag: TWordToAtomFlag;
function DbgsCXY(const p: TCodeXYPosition): string;
function DbgsCP(const p: TCodePosition): string;
implementation implementation
@ -181,6 +184,26 @@ begin
else Result:=0; else Result:=0;
end; 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 } { TAtomRing }
constructor TAtomRing.Create; constructor TAtomRing.Create;

View File

@ -32,7 +32,7 @@ interface
{$I codetools.inc} {$I codetools.inc}
{ $DEFINE IgnoreErrorAfterCursor} { $DEFINE DisableIgnoreErrorAfter}
uses uses
{$IFDEF MEM_CHECK} {$IFDEF MEM_CHECK}

View File

@ -1654,7 +1654,7 @@ begin
LastErrorCheckedForIgnored:=true; LastErrorCheckedForIgnored:=true;
end; end;
{$IFDEF ShowIgnoreErrorAfter} {$IFDEF ShowIgnoreErrorAfter}
DebugLn('TCustomCodeTool.IgnoreErrAfterPositionIsInFrontOfLastErrMessage ',Result); DebugLn('TCustomCodeTool.IgnoreErrAfterPositionIsInFrontOfLastErrMessage ',dbgs(Result));
{$ENDIF} {$ENDIF}
end; end;
@ -1662,7 +1662,7 @@ function TCustomCodeTool.IgnoreErrorAfterValid: boolean;
begin begin
Result:=(Scanner<>nil) and (Scanner.IgnoreErrorAfterValid); Result:=(Scanner<>nil) and (Scanner.IgnoreErrorAfterValid);
{$IFDEF ShowIgnoreErrorAfter} {$IFDEF ShowIgnoreErrorAfter}
DebugLn('TCustomCodeTool.IgnoreErrorAfterValid ',Result); DebugLn('TCustomCodeTool.IgnoreErrorAfterValid ',dbgs(Result));
{$ENDIF} {$ENDIF}
end; end;
@ -1673,7 +1673,7 @@ begin
else else
Result:=-1; Result:=-1;
{$IFDEF ShowIgnoreErrorAfter} {$IFDEF ShowIgnoreErrorAfter}
DebugLn('TCustomCodeTool.IgnoreErrorAfterCleanedPos ',Result); DebugLn('TCustomCodeTool.IgnoreErrorAfterCleanedPos ',dbgs(Result));
{$ENDIF} {$ENDIF}
end; end;
@ -1689,8 +1689,7 @@ begin
else else
Result:=false; Result:=false;
{$IFDEF ShowIgnoreErrorAfter} {$IFDEF ShowIgnoreErrorAfter}
DebugLn('TCustomCodeTool.LastErrorsInFrontOfCleanedPos ACleanedPos=',ACleanedPos, DebugLn('TCustomCodeTool.LastErrorsInFrontOfCleanedPos ACleanedPos=',dbgs(ACleanedPos),' ',dbgs(Result));
Result);
{$ENDIF} {$ENDIF}
end; end;
@ -1698,8 +1697,7 @@ procedure TCustomCodeTool.RaiseLastErrorIfInFrontOfCleanedPos(
ACleanedPos: integer); ACleanedPos: integer);
begin begin
{$IFDEF ShowIgnoreErrorAfter} {$IFDEF ShowIgnoreErrorAfter}
DebugLn('TCustomCodeTool.RaiseLastErrorIfInFrontOfCleanedPos A ACleanedPos=',ACleanedPos, DebugLn('TCustomCodeTool.RaiseLastErrorIfInFrontOfCleanedPos A ACleanedPos=',dbgs(ACleanedPos));
' ');
{$ENDIF} {$ENDIF}
if Scanner<>nil then Scanner.RaiseLastErrorIfInFrontOfCleanedPos(ACleanedPos); if Scanner<>nil then Scanner.RaiseLastErrorIfInFrontOfCleanedPos(ACleanedPos);
//DebugLn('TCustomCodeTool.RaiseLastErrorIfInFrontOfCleanedPos B ',LastErrorPhase<CodeToolPhaseTool,' ',LastErrorCurPos.EndPos); //DebugLn('TCustomCodeTool.RaiseLastErrorIfInFrontOfCleanedPos B ',LastErrorPhase<CodeToolPhaseTool,' ',LastErrorCurPos.EndPos);
@ -1844,13 +1842,7 @@ begin
FIgnoreErrorAfter:=AValue; FIgnoreErrorAfter:=AValue;
LastErrorCheckedForIgnored:=false; LastErrorCheckedForIgnored:=false;
{$IFDEF ShowIgnoreErrorAfter} {$IFDEF ShowIgnoreErrorAfter}
DbgOut'TCustomCodeTool.SetIgnoreErrorAfter '); DebugLn('TCustomCodeTool.SetIgnoreErrorAfter ',dbgsCP(FIgnoreErrorAfter));
if FIgnoreErrorAfter.Code<>nil then
DbgOutFIgnoreErrorAfter.Code.Filename)
else
DbgOut'nil');
DbgOut' ',FIgnoreErrorAfter.P);
DebugLn('');
{$ENDIF} {$ENDIF}
if Scanner<>nil then if Scanner<>nil then
Scanner.SetIgnoreErrorAfter(IgnoreErrorAfter.P,IgnoreErrorAfter.Code); Scanner.SetIgnoreErrorAfter(IgnoreErrorAfter.P,IgnoreErrorAfter.Code);

View File

@ -75,7 +75,7 @@ interface
{$IFDEF ShowTriedContexts}{$DEFINE DebugPrefix}{$ENDIF} {$IFDEF ShowTriedContexts}{$DEFINE DebugPrefix}{$ENDIF}
// new features // new features
{ $DEFINE IgnoreErrorAfterCursor} { $DEFINE DisableIgnoreErrorAfter}
uses uses
{$IFDEF MEM_CHECK} {$IFDEF MEM_CHECK}
@ -1026,16 +1026,16 @@ begin
ActivateGlobalWriteLock; ActivateGlobalWriteLock;
try try
// build code tree // build code tree
{$IFDEF CTDEBUG} { $IFDEF CTDEBUG}
DebugLn(DebugPrefix,'TFindDeclarationTool.FindDeclaration A CursorPos=',dbgs(CursorPos.X),',',dbgs(CursorPos.Y)); DebugLn('TFindDeclarationTool.FindDeclaration A CursorPos=X',dbgs(CursorPos.X),',Y',dbgs(CursorPos.Y));
{$ENDIF} { $ENDIF}
if DirtySrc<>nil then DirtySrc.Clear; if DirtySrc<>nil then DirtySrc.Clear;
BuildTreeAndGetCleanPos(trTillCursor,CursorPos,CleanCursorPos, BuildTreeAndGetCleanPos(trTillCursor,CursorPos,CleanCursorPos,
[{$IFDEF IgnoreErrorAfterCursor}btSetIgnoreErrorPos{$ENDIF} [{$IFNDEF DisableIgnoreErrorAfter}btSetIgnoreErrorPos,{$ENDIF}
btLoadDirtySource,btCursorPosOutAllowed]); btLoadDirtySource,btCursorPosOutAllowed]);
{$IFDEF CTDEBUG} { $IFDEF CTDEBUG}
DebugLn(DebugPrefix,'TFindDeclarationTool.FindDeclaration C CleanCursorPos=',dbgs(CleanCursorPos)); DebugLn('TFindDeclarationTool.FindDeclaration C CleanCursorPos=',dbgs(CleanCursorPos));
{$ENDIF} { $ENDIF}
// find CodeTreeNode at cursor // find CodeTreeNode at cursor
if (Tree.Root<>nil) and (Tree.Root.StartPos<=CleanCursorPos) then begin if (Tree.Root<>nil) and (Tree.Root.StartPos<=CleanCursorPos) then begin
CursorNode:=BuildSubTreeAndFindDeepestNodeAtPos(Tree.Root,CleanCursorPos, CursorNode:=BuildSubTreeAndFindDeepestNodeAtPos(Tree.Root,CleanCursorPos,

View File

@ -45,7 +45,7 @@ interface
{ $DEFINE ShowHistory} { $DEFINE ShowHistory}
// new features // new features
{ $DEFINE IgnoreErrorAfterCursor} { $DEFINE DisableIgnoreErrorAfter}
uses uses
@ -855,7 +855,7 @@ begin
DebugLn('TIdentCompletionTool.GatherIdentifiers A CursorPos=',dbgs(CursorPos.X),',',dbgs(CursorPos.Y)); DebugLn('TIdentCompletionTool.GatherIdentifiers A CursorPos=',dbgs(CursorPos.X),',',dbgs(CursorPos.Y));
{$ENDIF} {$ENDIF}
BuildTreeAndGetCleanPos(trTillCursor,CursorPos,CleanCursorPos, BuildTreeAndGetCleanPos(trTillCursor,CursorPos,CleanCursorPos,
[{$IFDEF IgnoreErrorAfterCursor}btSetIgnoreErrorPos,{$ENDIF}]); [{$IFNDEF DisableIgnoreErrorAfter}btSetIgnoreErrorPos{$ENDIF}]);
// find node at position // find node at position
CursorNode:=FindDeepestExpandedNodeAtPos(CleanCursorPos,true); CursorNode:=FindDeepestExpandedNodeAtPos(CleanCursorPos,true);

View File

@ -1470,12 +1470,12 @@ begin
FIgnoreErrorAfterCursorPos:=ACursorPos; FIgnoreErrorAfterCursorPos:=ACursorPos;
LastErrorCheckedForIgnored:=false; LastErrorCheckedForIgnored:=false;
{$IFDEF ShowIgnoreErrorAfter} {$IFDEF ShowIgnoreErrorAfter}
DbgOut'TLinkScanner.SetIgnoreErrorAfter '); DbgOut('TLinkScanner.SetIgnoreErrorAfter ');
if FIgnoreErrorAfterCode<>nil then if FIgnoreErrorAfterCode<>nil then
DbgOutOnGetFileName(Self,FIgnoreErrorAfterCode)) DbgOut(OnGetFileName(Self,FIgnoreErrorAfterCode))
else else
DbgOut'nil'); DbgOut('nil');
DbgOut' ',IntToStr(FIgnoreErrorAfterCursorPos)); DbgOut(' ',dbgs(FIgnoreErrorAfterCursorPos));
DebugLn(''); DebugLn('');
{$ENDIF} {$ENDIF}
end; end;
@ -1516,7 +1516,7 @@ begin
LastErrorCheckedForIgnored:=true; LastErrorCheckedForIgnored:=true;
end; end;
{$IFDEF ShowIgnoreErrorAfter} {$IFDEF ShowIgnoreErrorAfter}
DebugLn('TLinkScanner.IgnoreErrAfterPositionIsInFrontOfLastErrMessage Result=',Result); DebugLn('TLinkScanner.IgnoreErrAfterPositionIsInFrontOfLastErrMessage Result=',dbgs(Result));
{$ENDIF} {$ENDIF}
end; end;
@ -1527,7 +1527,7 @@ begin
else else
Result:=-1; Result:=-1;
{$IFDEF ShowIgnoreErrorAfter} {$IFDEF ShowIgnoreErrorAfter}
DebugLn('TLinkScanner.IgnoreErrorAfterCleanedPos Result=',Result); DebugLn('TLinkScanner.IgnoreErrorAfterCleanedPos Result=',dbgs(Result));
{$ENDIF} {$ENDIF}
end; end;
@ -1535,7 +1535,7 @@ function TLinkScanner.IgnoreErrorAfterValid: boolean;
begin begin
Result:=(FIgnoreErrorAfterCode<>nil); Result:=(FIgnoreErrorAfterCode<>nil);
{$IFDEF ShowIgnoreErrorAfter} {$IFDEF ShowIgnoreErrorAfter}
DebugLn('TLinkScanner.IgnoreErrorAfterValid Result=',Result); DebugLn('TLinkScanner.IgnoreErrorAfterValid Result=',dbgs(Result));
{$ENDIF} {$ENDIF}
end; end;
@ -1544,7 +1544,7 @@ function TLinkScanner.LastErrorsInFrontOfCleanedPos(ACleanedPos: integer
begin begin
Result:=LastErrorIsValid and (CleanedLen>ACleanedPos); Result:=LastErrorIsValid and (CleanedLen>ACleanedPos);
{$IFDEF ShowIgnoreErrorAfter} {$IFDEF ShowIgnoreErrorAfter}
DebugLn('TLinkScanner.LastErrorsInFrontOfCleanedPos Result=',Result); DebugLn('TLinkScanner.LastErrorsInFrontOfCleanedPos Result=',dbgs(Result));
{$ENDIF} {$ENDIF}
end; end;

View File

@ -3438,6 +3438,7 @@ begin
IgnorePos.Code:=CursorPos.Code; IgnorePos.Code:=CursorPos.Code;
IgnorePos.Code.LineColToPosition(CursorPos.Y,CursorPos.X,IgnorePos.P); IgnorePos.Code.LineColToPosition(CursorPos.Y,CursorPos.X,IgnorePos.P);
if IgnorePos.P<1 then IgnorePos.Code:=nil; if IgnorePos.P<1 then IgnorePos.Code:=nil;
debugln('TPascalParserTool.BuildTreeAndGetCleanPos IgnorePos=',dbgsCP(IgnorePos));
IgnoreErrorAfter:=IgnorePos; IgnoreErrorAfter:=IgnorePos;
end else end else
ClearIgnoreErrorAfter; ClearIgnoreErrorAfter;
@ -3474,7 +3475,7 @@ begin
CaretType:=CaretToCleanPos(CursorPos, CleanCursorPos); CaretType:=CaretToCleanPos(CursorPos, CleanCursorPos);
if (CaretType=0) or (CaretType=-1) then begin if (CaretType=0) or (CaretType=-1) then begin
BuildSubTree(CleanCursorPos); 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) // cursor position lies in dead code (skipped code between IFDEF/ENDIF)
LoadDirtySource(CursorPos); LoadDirtySource(CursorPos);
end; end;

View File

@ -41,7 +41,7 @@ interface
{$I codetools.inc} {$I codetools.inc}
{ $DEFINE IgnoreErrorAfterCursor} { $DEFINE DisableIgnoreErrorAfter}
{ $DEFINE VerboseGetStringConstBounds} { $DEFINE VerboseGetStringConstBounds}
uses uses
@ -3791,7 +3791,7 @@ begin
Result:=false; Result:=false;
try try
BuildTreeAndGetCleanPos(trTillCursor,CursorPos,CleanCursorPos, BuildTreeAndGetCleanPos(trTillCursor,CursorPos,CleanCursorPos,
[{$IFDEF IgnoreErrorAfterCursor}btSetIgnoreErrorPos{$ENDIF}]); [{$IFNDEF DisableIgnoreErrorAfter}btSetIgnoreErrorPos{$ENDIF}]);
LinkIndex:=Scanner.LinkIndexAtCleanPos(CleanCursorPos); LinkIndex:=Scanner.LinkIndexAtCleanPos(CleanCursorPos);
LinkIndex:=Scanner.FindParentLink(LinkIndex); LinkIndex:=Scanner.FindParentLink(LinkIndex);
if LinkIndex<0 then if LinkIndex<0 then