codetools: debug FindFileAtCursor

git-svn-id: branches/fixes_1_8@56730 -
This commit is contained in:
mattias 2017-12-14 18:03:55 +00:00
parent 2387fda18e
commit fa47319eb9
2 changed files with 32 additions and 14 deletions

View File

@ -67,6 +67,7 @@ interface
{ $DEFINE DebugAddToolDependency} { $DEFINE DebugAddToolDependency}
{ $DEFINE VerboseCPS} { $DEFINE VerboseCPS}
{ $DEFINE VerboseFindDeclarationAndOverload} { $DEFINE VerboseFindDeclarationAndOverload}
{ $DEFINE VerboseFindFileAtCursor}
{$IFDEF CTDEBUG}{$DEFINE DebugPrefix}{$ENDIF} {$IFDEF CTDEBUG}{$DEFINE DebugPrefix}{$ENDIF}
{$IFDEF ShowTriedIdentifiers}{$DEFINE DebugPrefix}{$ENDIF} {$IFDEF ShowTriedIdentifiers}{$DEFINE DebugPrefix}{$ENDIF}
@ -3015,12 +3016,14 @@ begin
DebugLn('TFindDeclarationTool.FindUnitSource Self="',MainFilename,'" AnUnitName="',AnUnitName,'" AnUnitInFilename="',AnUnitInFilename,'"'); DebugLn('TFindDeclarationTool.FindUnitSource Self="',MainFilename,'" AnUnitName="',AnUnitName,'" AnUnitInFilename="',AnUnitInFilename,'"');
{$ENDIF} {$ENDIF}
Result:=nil; Result:=nil;
if (AnUnitName='') or (Scanner=nil) or (Scanner.MainCode=nil) if (AnUnitName='') or (Scanner=nil) then
or (not (TObject(Scanner.MainCode) is TCodeBuffer)) RaiseException(20171214184503,'TFindDeclarationTool.FindUnitSource Invalid Data');
or (Scanner.OnLoadSource=nil) if (Scanner.MainCode=nil) then
then begin RaiseException(20171214184512,'TFindDeclarationTool.FindUnitSource Invalid Data');
RaiseException(20170421200035,'TFindDeclarationTool.FindUnitSource Invalid Data'); if (not (TObject(Scanner.MainCode) is TCodeBuffer)) then
end; RaiseException(20171214184519,'TFindDeclarationTool.FindUnitSource Invalid Data');
if (Scanner.OnLoadSource=nil) then
RaiseException(20171214184527,'TFindDeclarationTool.FindUnitSource Invalid Data');
NewUnitName:=AnUnitName; NewUnitName:=AnUnitName;
NewInFilename:=AnUnitInFilename; NewInFilename:=AnUnitInFilename;
@ -3658,17 +3661,32 @@ var
NewCode: TCodeBuffer; NewCode: TCodeBuffer;
p, StartP: PChar; p, StartP: PChar;
begin begin
{$IFDEF VerboseFindFileAtCursor}
debugln(['TFindDeclarationTool.FindFileAtCursor START']);
{$ENDIF}
Result:=false; Result:=false;
Found:=ffatNone; Found:=ffatNone;
FoundFilename:=''; FoundFilename:='';
if StartPos<>nil then if StartPos<>nil then
StartPos^:=CleanCodeXYPosition; StartPos^:=CleanCodeXYPosition;
if CursorPos.Code.LineColIsOutside(CursorPos.Y,CursorPos.X) then exit; if CursorPos.Code.LineColIsOutside(CursorPos.Y,CursorPos.X) then begin
if CursorPos.Code.LineColIsSpace(CursorPos.Y,CursorPos.X) then exit;
if (CursorPos.Y<1) or (CursorPos.Y>CursorPos.Code.LineCount) then exit;
{$IFDEF VerboseFindFileAtCursor} {$IFDEF VerboseFindFileAtCursor}
debugln(['TFindDeclarationTool.FindFileAtCursor START']); debugln(['TFindDeclarationTool.FindFileAtCursor LineColIsOutside ',dbgs(CursorPos)]);
{$ENDIF} {$ENDIF}
exit;
end;
if CursorPos.Code.LineColIsSpace(CursorPos.Y,CursorPos.X) then begin
{$IFDEF VerboseFindFileAtCursor}
debugln(['TFindDeclarationTool.FindFileAtCursor LineColIsSpace ',dbgs(CursorPos)]);
{$ENDIF}
exit;
end;
if (CursorPos.Y<1) or (CursorPos.Y>CursorPos.Code.LineCount) then begin
{$IFDEF VerboseFindFileAtCursor}
debugln(['TFindDeclarationTool.FindFileAtCursor outside Line ',dbgs(CursorPos)]);
{$ENDIF}
exit;
end;
if [ffatUsedUnit,ffatIncludeFile,ffatDisabledIncludeFile]*SearchFor<>[] if [ffatUsedUnit,ffatIncludeFile,ffatDisabledIncludeFile]*SearchFor<>[]
then begin then begin
try try
@ -3705,7 +3723,7 @@ begin
end; end;
end else begin end else begin
{$IFDEF VerboseFindFileAtCursor} {$IFDEF VerboseFindFileAtCursor}
debugln(['TFindDeclarationTool.FindFileAtCursor in parsed code, not in comment']); debugln(['TFindDeclarationTool.FindFileAtCursor in parsed code, not in comment Node=',Node.DescAsString]);
{$ENDIF} {$ENDIF}
if Node.Desc in [ctnUseUnitClearName,ctnUseUnitNamespace] then begin if Node.Desc in [ctnUseUnitClearName,ctnUseUnitNamespace] then begin
Node:=Node.Parent; Node:=Node.Parent;

View File

@ -2070,7 +2070,7 @@ begin
CreateChildNode; CreateChildNode;
LastUnitNode := CurNode; LastUnitNode := CurNode;
CurNode.Desc:=ctnUseUnitClearName; CurNode.Desc:=ctnUseUnitClearName;
CurNode.EndPos:=CurNode.Parent.EndPos; CurNode.EndPos:=CurPos.EndPos;
EndChildNode; EndChildNode;
ReadNextAtom; ReadNextAtom;
if CurPos.Flag<>cafPoint then break; if CurPos.Flag<>cafPoint then break;