IDE: Support dotted unit names in FilenameIsPascalSource. Issue #29363.

git-svn-id: trunk@51261 -
This commit is contained in:
juha 2016-01-12 17:00:28 +00:00
parent 6c2d50b2d5
commit 5ff026ab94
2 changed files with 24 additions and 19 deletions

View File

@ -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

View File

@ -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;