mirror of
https://gitlab.com/freepascal.org/lazarus/lazarus.git
synced 2025-09-11 13:19:21 +02:00
codetools: FindFileAtCursor: fixed find enabled include directive of empth file
git-svn-id: trunk@53288 -
This commit is contained in:
parent
8fdf97baa2
commit
9e59740549
@ -934,7 +934,7 @@ type
|
|||||||
out IncludeCode: TCodeBuffer): boolean;
|
out IncludeCode: TCodeBuffer): boolean;
|
||||||
function FindFileAtCursor(const CursorPos: TCodeXYPosition;
|
function FindFileAtCursor(const CursorPos: TCodeXYPosition;
|
||||||
out Found: TFindFileAtCursorFlag; out FoundFilename: string;
|
out Found: TFindFileAtCursorFlag; out FoundFilename: string;
|
||||||
Allowed: TFindFileAtCursorFlags = DefaultFindFileAtCursorAllowed;
|
SearchFor: TFindFileAtCursorFlags = DefaultFindFileAtCursorAllowed;
|
||||||
StartPos: PCodeXYPosition = nil): boolean;
|
StartPos: PCodeXYPosition = nil): boolean;
|
||||||
|
|
||||||
function FindSmartHint(const CursorPos: TCodeXYPosition;
|
function FindSmartHint(const CursorPos: TCodeXYPosition;
|
||||||
@ -3492,7 +3492,7 @@ end;
|
|||||||
|
|
||||||
function TFindDeclarationTool.FindFileAtCursor(
|
function TFindDeclarationTool.FindFileAtCursor(
|
||||||
const CursorPos: TCodeXYPosition; out Found: TFindFileAtCursorFlag; out
|
const CursorPos: TCodeXYPosition; out Found: TFindFileAtCursorFlag; out
|
||||||
FoundFilename: string; Allowed: TFindFileAtCursorFlags;
|
FoundFilename: string; SearchFor: TFindFileAtCursorFlags;
|
||||||
StartPos: PCodeXYPosition): boolean;
|
StartPos: PCodeXYPosition): boolean;
|
||||||
var
|
var
|
||||||
CleanPos, CommentStart, CommentEnd: integer;
|
CleanPos, CommentStart, CommentEnd: integer;
|
||||||
@ -3510,7 +3510,7 @@ begin
|
|||||||
{$IFDEF VerboseFindFileAtCursor}
|
{$IFDEF VerboseFindFileAtCursor}
|
||||||
debugln(['TFindDeclarationTool.FindFileAtCursor START']);
|
debugln(['TFindDeclarationTool.FindFileAtCursor START']);
|
||||||
{$ENDIF}
|
{$ENDIF}
|
||||||
if [ffatUsedUnit,ffatIncludeFile,ffatDisabledIncludeFile]*Allowed<>[]
|
if [ffatUsedUnit,ffatIncludeFile,ffatDisabledIncludeFile]*SearchFor<>[]
|
||||||
then begin
|
then begin
|
||||||
try
|
try
|
||||||
{$IFDEF VerboseFindFileAtCursor}
|
{$IFDEF VerboseFindFileAtCursor}
|
||||||
@ -3533,32 +3533,31 @@ begin
|
|||||||
{$IFDEF VerboseFindFileAtCursor}
|
{$IFDEF VerboseFindFileAtCursor}
|
||||||
debugln(['TFindDeclarationTool.FindFileAtCursor in comment']);
|
debugln(['TFindDeclarationTool.FindFileAtCursor in comment']);
|
||||||
{$ENDIF}
|
{$ENDIF}
|
||||||
if (ffatIncludeFile in Allowed)
|
if ExtractLongParamDirective(Src,CommentStart,DirectiveName,Param)
|
||||||
and IsIncludeDirectiveAtPos(CleanPos,CommentStart,NewCode) then begin
|
|
||||||
// enabled include directive
|
|
||||||
Found:=ffatIncludeFile;
|
|
||||||
FoundFilename:=NewCode.Filename;
|
|
||||||
Result:=true;
|
|
||||||
exit;
|
|
||||||
end else if ExtractLongParamDirective(Src,CommentStart,DirectiveName,Param)
|
|
||||||
then begin
|
then begin
|
||||||
DirectiveName:=lowercase(DirectiveName);
|
DirectiveName:=lowercase(DirectiveName);
|
||||||
if (ffatDisabledIncludeFile in Allowed)
|
if (ffatIncludeFile in SearchFor)
|
||||||
and ((DirectiveName='i') or (DirectiveName='include')) then begin
|
and (DirectiveName='i') or (DirectiveName='include') then begin
|
||||||
// disabled include directive
|
// include directive
|
||||||
if (Param<>'') and (Param[1]<>'%') then begin
|
if (Param<>'') and (Param[1]<>'%') then begin
|
||||||
|
// include file directive
|
||||||
Result:=true;
|
Result:=true;
|
||||||
Found:=ffatDisabledIncludeFile;
|
Found:=ffatIncludeFile;
|
||||||
FoundFilename:=ResolveDots(GetForcedPathDelims(Param));
|
if IsIncludeDirectiveAtPos(CleanPos,CommentStart,NewCode) then
|
||||||
// search include file
|
begin
|
||||||
MissingIncludeFile:=nil;
|
FoundFilename:=NewCode.Filename;
|
||||||
if Scanner.SearchIncludeFile(FoundFilename,NewCodePtr,
|
end else begin
|
||||||
MissingIncludeFile)
|
FoundFilename:=ResolveDots(GetForcedPathDelims(Param));
|
||||||
then
|
// search include file
|
||||||
FoundFilename:=TCodeBuffer(NewCodePtr).Filename;
|
MissingIncludeFile:=nil;
|
||||||
|
if Scanner.SearchIncludeFile(FoundFilename,NewCodePtr,
|
||||||
|
MissingIncludeFile)
|
||||||
|
then
|
||||||
|
FoundFilename:=TCodeBuffer(NewCodePtr).Filename;
|
||||||
|
end;
|
||||||
exit;
|
exit;
|
||||||
end;
|
end;
|
||||||
end else if (ffatResource in Allowed)
|
end else if (ffatResource in SearchFor)
|
||||||
and ((DirectiveName='r') or (DirectiveName='resource')) then begin
|
and ((DirectiveName='r') or (DirectiveName='resource')) then begin
|
||||||
// resource directive
|
// resource directive
|
||||||
Result:=true;
|
Result:=true;
|
||||||
@ -3573,7 +3572,7 @@ begin
|
|||||||
exit;
|
exit;
|
||||||
end;
|
end;
|
||||||
end;
|
end;
|
||||||
if ffatComment in Allowed then begin
|
if ffatComment in SearchFor then begin
|
||||||
// ToDo: check comment
|
// ToDo: check comment
|
||||||
|
|
||||||
end;
|
end;
|
||||||
@ -3625,10 +3624,10 @@ begin
|
|||||||
if (CursorPos.Y<1) or (CursorPos.Y>CursorPos.Code.LineCount) then exit;
|
if (CursorPos.Y<1) or (CursorPos.Y>CursorPos.Code.LineCount) then exit;
|
||||||
Line:=CursorPos.Code.GetLine(CursorPos.Y,false);
|
Line:=CursorPos.Code.GetLine(CursorPos.Y,false);
|
||||||
if CursorPos.X>length(Line) then exit;
|
if CursorPos.X>length(Line) then exit;
|
||||||
if ffatLiteral in Allowed then begin
|
if ffatLiteral in SearchFor then begin
|
||||||
// ToDo: check literal
|
// ToDo: check literal
|
||||||
end;
|
end;
|
||||||
if ffatComment in Allowed then begin
|
if ffatComment in SearchFor then begin
|
||||||
// ToDo: check simple
|
// ToDo: check simple
|
||||||
end;
|
end;
|
||||||
end;
|
end;
|
||||||
|
@ -347,7 +347,7 @@ begin
|
|||||||
SubUnit2Code.Source:='';
|
SubUnit2Code.Source:='';
|
||||||
if not CodeToolBoss.FindFileAtCursor(Code,1,2,Found,FoundFilename) then
|
if not CodeToolBoss.FindFileAtCursor(Code,1,2,Found,FoundFilename) then
|
||||||
Fail('CodeToolBoss.FindFileAtCursor at uses unit2 failed');
|
Fail('CodeToolBoss.FindFileAtCursor at uses unit2 failed');
|
||||||
//ToDo AssertEquals('FindFileAtCursor at enabled include directive Found',ord(ffatIncludeFile),ord(Found));
|
AssertEquals('FindFileAtCursor at enabled include directive Found',ord(ffatIncludeFile),ord(Found));
|
||||||
AssertEquals('FindFileAtCursor at enabled include directive FoundFilename','unit2.pas',FoundFilename);
|
AssertEquals('FindFileAtCursor at enabled include directive FoundFilename','unit2.pas',FoundFilename);
|
||||||
|
|
||||||
|
|
||||||
|
Loading…
Reference in New Issue
Block a user