mirror of
https://gitlab.com/freepascal.org/lazarus/lazarus.git
synced 2025-09-11 10:39:20 +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;
|
||||
function FindFileAtCursor(const CursorPos: TCodeXYPosition;
|
||||
out Found: TFindFileAtCursorFlag; out FoundFilename: string;
|
||||
Allowed: TFindFileAtCursorFlags = DefaultFindFileAtCursorAllowed;
|
||||
SearchFor: TFindFileAtCursorFlags = DefaultFindFileAtCursorAllowed;
|
||||
StartPos: PCodeXYPosition = nil): boolean;
|
||||
|
||||
function FindSmartHint(const CursorPos: TCodeXYPosition;
|
||||
@ -3492,7 +3492,7 @@ end;
|
||||
|
||||
function TFindDeclarationTool.FindFileAtCursor(
|
||||
const CursorPos: TCodeXYPosition; out Found: TFindFileAtCursorFlag; out
|
||||
FoundFilename: string; Allowed: TFindFileAtCursorFlags;
|
||||
FoundFilename: string; SearchFor: TFindFileAtCursorFlags;
|
||||
StartPos: PCodeXYPosition): boolean;
|
||||
var
|
||||
CleanPos, CommentStart, CommentEnd: integer;
|
||||
@ -3510,7 +3510,7 @@ begin
|
||||
{$IFDEF VerboseFindFileAtCursor}
|
||||
debugln(['TFindDeclarationTool.FindFileAtCursor START']);
|
||||
{$ENDIF}
|
||||
if [ffatUsedUnit,ffatIncludeFile,ffatDisabledIncludeFile]*Allowed<>[]
|
||||
if [ffatUsedUnit,ffatIncludeFile,ffatDisabledIncludeFile]*SearchFor<>[]
|
||||
then begin
|
||||
try
|
||||
{$IFDEF VerboseFindFileAtCursor}
|
||||
@ -3533,22 +3533,20 @@ begin
|
||||
{$IFDEF VerboseFindFileAtCursor}
|
||||
debugln(['TFindDeclarationTool.FindFileAtCursor in comment']);
|
||||
{$ENDIF}
|
||||
if (ffatIncludeFile in Allowed)
|
||||
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)
|
||||
if ExtractLongParamDirective(Src,CommentStart,DirectiveName,Param)
|
||||
then begin
|
||||
DirectiveName:=lowercase(DirectiveName);
|
||||
if (ffatDisabledIncludeFile in Allowed)
|
||||
and ((DirectiveName='i') or (DirectiveName='include')) then begin
|
||||
// disabled include directive
|
||||
if (ffatIncludeFile in SearchFor)
|
||||
and (DirectiveName='i') or (DirectiveName='include') then begin
|
||||
// include directive
|
||||
if (Param<>'') and (Param[1]<>'%') then begin
|
||||
// include file directive
|
||||
Result:=true;
|
||||
Found:=ffatDisabledIncludeFile;
|
||||
Found:=ffatIncludeFile;
|
||||
if IsIncludeDirectiveAtPos(CleanPos,CommentStart,NewCode) then
|
||||
begin
|
||||
FoundFilename:=NewCode.Filename;
|
||||
end else begin
|
||||
FoundFilename:=ResolveDots(GetForcedPathDelims(Param));
|
||||
// search include file
|
||||
MissingIncludeFile:=nil;
|
||||
@ -3556,9 +3554,10 @@ begin
|
||||
MissingIncludeFile)
|
||||
then
|
||||
FoundFilename:=TCodeBuffer(NewCodePtr).Filename;
|
||||
end;
|
||||
exit;
|
||||
end;
|
||||
end else if (ffatResource in Allowed)
|
||||
end else if (ffatResource in SearchFor)
|
||||
and ((DirectiveName='r') or (DirectiveName='resource')) then begin
|
||||
// resource directive
|
||||
Result:=true;
|
||||
@ -3573,7 +3572,7 @@ begin
|
||||
exit;
|
||||
end;
|
||||
end;
|
||||
if ffatComment in Allowed then begin
|
||||
if ffatComment in SearchFor then begin
|
||||
// ToDo: check comment
|
||||
|
||||
end;
|
||||
@ -3625,10 +3624,10 @@ begin
|
||||
if (CursorPos.Y<1) or (CursorPos.Y>CursorPos.Code.LineCount) then exit;
|
||||
Line:=CursorPos.Code.GetLine(CursorPos.Y,false);
|
||||
if CursorPos.X>length(Line) then exit;
|
||||
if ffatLiteral in Allowed then begin
|
||||
if ffatLiteral in SearchFor then begin
|
||||
// ToDo: check literal
|
||||
end;
|
||||
if ffatComment in Allowed then begin
|
||||
if ffatComment in SearchFor then begin
|
||||
// ToDo: check simple
|
||||
end;
|
||||
end;
|
||||
|
@ -347,7 +347,7 @@ begin
|
||||
SubUnit2Code.Source:='';
|
||||
if not CodeToolBoss.FindFileAtCursor(Code,1,2,Found,FoundFilename) then
|
||||
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);
|
||||
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user