mirror of
https://gitlab.com/freepascal.org/lazarus/lazarus.git
synced 2025-04-14 05:41:16 +02:00
improved package file search for relative paths
git-svn-id: trunk@8833 -
This commit is contained in:
parent
4e9a61507b
commit
2e81a8fee5
@ -300,8 +300,8 @@ type
|
||||
|
||||
// find declaration
|
||||
function FindDeclaration(Code: TCodeBuffer; X,Y: integer;
|
||||
var NewCode: TCodeBuffer;
|
||||
var NewX, NewY, NewTopLine: integer): boolean;
|
||||
out NewCode: TCodeBuffer;
|
||||
out NewX, NewY, NewTopLine: integer): boolean;
|
||||
function FindSmartHint(Code: TCodeBuffer; X,Y: integer): string;
|
||||
function FindDeclarationInInterface(Code: TCodeBuffer;
|
||||
const Identifier: string; var NewCode: TCodeBuffer;
|
||||
@ -664,14 +664,14 @@ begin
|
||||
// build DefinePool
|
||||
with DefinePool do begin
|
||||
FPCUnitPath:=Config.FPCUnitPath;
|
||||
TargetOS:=Config.FPCUnitPath;
|
||||
TargetOS:=Config.TargetOS;
|
||||
TargetProcessor:=Config.TargetProcessor;
|
||||
Add(CreateFPCTemplate(Config.FPCPath, Config.FPCOptions,
|
||||
Config.TestPascalFile,
|
||||
FPCUnitPath, TargetOS, TargetProcessor,
|
||||
nil));
|
||||
Config.FPCUnitPath:=FPCUnitPath;
|
||||
Config.TargetOS:=FPCUnitPath;
|
||||
Config.TargetOS:=TargetOS;
|
||||
Config.TargetProcessor:=TargetProcessor;
|
||||
UnitLinkList:=Config.UnitLinkList;
|
||||
Add(CreateFPCSrcTemplate(Config.FPCSrcDir,Config.FPCUnitPath,Config.PPUExt,
|
||||
@ -1351,8 +1351,8 @@ begin
|
||||
end;
|
||||
|
||||
function TCodeToolManager.FindDeclaration(Code: TCodeBuffer; X,Y: integer;
|
||||
var NewCode: TCodeBuffer;
|
||||
var NewX, NewY, NewTopLine: integer): boolean;
|
||||
out NewCode: TCodeBuffer;
|
||||
out NewX, NewY, NewTopLine: integer): boolean;
|
||||
var
|
||||
CursorPos: TCodeXYPosition;
|
||||
NewPos: TCodeXYPosition;
|
||||
|
@ -84,7 +84,7 @@ begin
|
||||
then begin
|
||||
LazarusIDE.DoJumpToCodeToolBossError;
|
||||
end;
|
||||
|
||||
|
||||
// message fixed
|
||||
Msg.Msg:='';
|
||||
end;
|
||||
|
@ -52,6 +52,7 @@ function FileIsText(const AFilename: string): boolean;
|
||||
function FileIsText(const AFilename: string; out FileReadable: boolean): boolean;
|
||||
function FileIsExecutable(const AFilename: string): boolean;
|
||||
function FileIsSymlink(const AFilename: string): boolean;
|
||||
function FileSize(const Filename: string): int64;
|
||||
function GetFileDescription(const AFilename: string): string;
|
||||
function ReadAllLinks(const Filename: string;
|
||||
ExceptionOnError: boolean): string;
|
||||
@ -69,6 +70,7 @@ const
|
||||
PascalFileExt: array[1..3] of string = ('.pas','.pp','.p');
|
||||
|
||||
function ExtractFileNameOnly(const AFilename: string): string;
|
||||
function ExtractFileNameWithoutExt(const AFilename: string): string;
|
||||
function CompareFileExt(const Filename, Ext: string;
|
||||
CaseSensitive: boolean): integer;
|
||||
function CompareFileExt(const Filename, Ext: string): integer;
|
||||
|
@ -315,6 +315,21 @@ begin
|
||||
SetLength(Result,DestPos-1);
|
||||
end;
|
||||
|
||||
function ExtractFileNameWithoutExt(const AFilename: string): string;
|
||||
var
|
||||
p: Integer;
|
||||
begin
|
||||
Result:=AFilename;
|
||||
p:=length(Result);
|
||||
while (p>0) do begin
|
||||
case Result[p] of
|
||||
PathDelim: exit;
|
||||
'.': Result:=copy(Result,p-1,length(Result));
|
||||
else dec(p);
|
||||
end;
|
||||
end;
|
||||
end;
|
||||
|
||||
{------------------------------------------------------------------------------
|
||||
function CompareFileExt(const Filename, Ext: string;
|
||||
CaseSensitive: boolean): integer;
|
||||
@ -517,6 +532,17 @@ begin
|
||||
{$ENDIF}
|
||||
end;
|
||||
|
||||
function FileSize(const Filename: string): int64;
|
||||
var
|
||||
FileInfo: TSearchRec;
|
||||
begin
|
||||
if SysUtils.FindFirst(Filename,faAnyFile,FileInfo)=0 then begin
|
||||
Result:=FileInfo.Size;
|
||||
SysUtils.FindClose(FileInfo);
|
||||
end else
|
||||
Result:=-1;
|
||||
end;
|
||||
|
||||
{------------------------------------------------------------------------------
|
||||
GetFileDescription
|
||||
------------------------------------------------------------------------------}
|
||||
|
@ -3040,9 +3040,7 @@ var
|
||||
function FilenameFits(TheFilename: string): boolean;
|
||||
begin
|
||||
if siffIgnoreExtension in SearchFlags then
|
||||
TheFileName:=ExtractFilenameOnly(TheFileName);
|
||||
if FilenameIsAbsolute(TheFileName) then
|
||||
TheFileName:=ExtractFilename(TheFileName);
|
||||
TheFileName:=ExtractFileNameWithoutExt(TheFileName);
|
||||
//debugln('TLazPackage.SearchFile A ',SearchedFilename,' ',TheFilename);
|
||||
if siffCaseSensitive in SearchFlags then
|
||||
Result:=SearchedFilename=TheFilename
|
||||
@ -3053,12 +3051,12 @@ var
|
||||
begin
|
||||
SearchedFilename:=ShortFilename;
|
||||
if siffIgnoreExtension in SearchFlags then
|
||||
SearchedFilename:=ExtractFilenameOnly(SearchedFilename);
|
||||
SearchedFilename:=ExtractFileNameWithoutExt(SearchedFilename);
|
||||
|
||||
// search in files
|
||||
for i:=0 to FileCount-1 do begin
|
||||
Result:=Files[i];
|
||||
if FilenameFits(Result.Filename) then exit;
|
||||
if FilenameFits(Result.GetShortFilename(true)) then exit;
|
||||
end;
|
||||
Result:=nil;
|
||||
end;
|
||||
|
@ -3664,10 +3664,10 @@ var
|
||||
SrcEdit: TSourceEditor;
|
||||
begin
|
||||
SrcEdit:=SourceNotebook.GetActiveSE;
|
||||
//debugln('TPkgManager.GetPackageOfCurrentSourceEditor ',SrcEdit.Filename);
|
||||
if SrcEdit<>nil then
|
||||
Result:=SearchFile(SrcEdit.Filename,[],nil)
|
||||
else
|
||||
if SrcEdit<>nil then begin
|
||||
//debugln('TPkgManager.GetPackageOfCurrentSourceEditor ',SrcEdit.Filename);
|
||||
Result:=SearchFile(SrcEdit.Filename,[],nil);
|
||||
end else
|
||||
SrcEdit:=nil;
|
||||
end;
|
||||
|
||||
@ -3717,7 +3717,7 @@ begin
|
||||
CurFilename:=AFilename;
|
||||
APackage.ShortenFilename(CurFilename,true);
|
||||
Result:=APackage.SearchFile(CurFilename,SearchFlags);
|
||||
//debugln('TPkgManager.SearchFile ',APackage.Files[0].Filename);
|
||||
//debugln('TPkgManager.SearchFile Pkg=',APackage.Filename,' CurFilename="',CurFilename,'"');
|
||||
if Result<>nil then exit;
|
||||
end;
|
||||
end;
|
||||
|
Loading…
Reference in New Issue
Block a user