mirror of
https://gitlab.com/freepascal.org/lazarus/lazarus.git
synced 2025-08-10 18:17:18 +02:00
IDE: Support dotted unit names in FilenameIsPascalSource. Issue #29363.
git-svn-id: trunk@51261 -
This commit is contained in:
parent
6c2d50b2d5
commit
5ff026ab94
@ -279,6 +279,8 @@ function CopyDirTree(const SourceDir, TargetDir: string; Flags: TCopyFileFlags=[
|
||||
// filename parts
|
||||
const
|
||||
PascalFileExt: array[1..3] of string = ('.pas','.pp','.p');
|
||||
PascalSourceExt: array[1..6] of string = ('.pas','.pp','.p','.lpr','.dpr','.dpk');
|
||||
|
||||
AllDirectoryEntriesMask = '*';
|
||||
|
||||
implementation
|
||||
|
@ -33,7 +33,7 @@ uses
|
||||
// RTL + LCL
|
||||
Classes, SysUtils, LCLProc, StdCtrls, ExtCtrls,
|
||||
// CodeTools
|
||||
SourceLog, FileProcs, CodeToolManager, CodeToolsConfig, CodeCache,
|
||||
BasicCodeTools, SourceLog, FileProcs, CodeToolManager, CodeToolsConfig, CodeCache,
|
||||
// LazUtils
|
||||
FileUtil, LazFileUtils, LazFileCache, LazUTF8, lazutf8classes,
|
||||
AvgLvlTree, Laz2_XMLCfg,
|
||||
@ -359,18 +359,29 @@ begin
|
||||
end;
|
||||
|
||||
function FilenameIsPascalSource(const Filename: string): boolean;
|
||||
var Ext: string;
|
||||
p: Integer;
|
||||
AnUnitName: String;
|
||||
var
|
||||
s: string;
|
||||
i: Integer;
|
||||
begin
|
||||
Result:=False;
|
||||
// Check unit name
|
||||
s:=ExtractFileNameOnly(Filename);
|
||||
if (s='') or not IsDottedIdentifier(s) then
|
||||
exit;
|
||||
// Check extension
|
||||
s:=lowercase(ExtractFileExt(Filename));
|
||||
for i:=Low(PascalSourceExt) to High(PascalSourceExt) do
|
||||
if s=PascalSourceExt[i] then
|
||||
exit(True);
|
||||
end;
|
||||
|
||||
function FilenameIsFormText(const Filename: string): boolean;
|
||||
var
|
||||
Ext: string;
|
||||
begin
|
||||
AnUnitName:=ExtractFileNameOnly(Filename);
|
||||
if (AnUnitName='') or (not IsValidIdent(AnUnitName)) then
|
||||
exit(false);
|
||||
Ext:=lowercase(ExtractFileExt(Filename));
|
||||
for p:=Low(PascalFileExt) to High(PascalFileExt) do
|
||||
if Ext=PascalFileExt[p] then
|
||||
exit(true);
|
||||
Result:=(Ext='.lpr') or (Ext='.dpr') or (Ext='.dpk');
|
||||
Result:=((Ext='.lfm') or (Ext='.dfm') or (Ext='.xfm'))
|
||||
and (ExtractFileNameOnly(Filename)<>'');
|
||||
end;
|
||||
|
||||
function FindShortFileNameOnDisk(const Filename: string): string;
|
||||
@ -448,14 +459,6 @@ begin
|
||||
end;
|
||||
end;
|
||||
|
||||
function FilenameIsFormText(const Filename: string): boolean;
|
||||
var Ext: string;
|
||||
begin
|
||||
Ext:=lowercase(ExtractFileExt(Filename));
|
||||
Result:=((Ext='.lfm') or (Ext='.dfm') or (Ext='.xfm'))
|
||||
and (ExtractFileNameOnly(Filename)<>'');
|
||||
end;
|
||||
|
||||
function MergeSearchPaths(const OldSearchPath, AddSearchPath: string): string;
|
||||
var
|
||||
l: Integer;
|
||||
|
Loading…
Reference in New Issue
Block a user