From 5ff026ab94e6affd388867663d16381884c0fa73 Mon Sep 17 00:00:00 2001 From: juha Date: Tue, 12 Jan 2016 17:00:28 +0000 Subject: [PATCH] IDE: Support dotted unit names in FilenameIsPascalSource. Issue #29363. git-svn-id: trunk@51261 - --- components/lazutils/fileutil.pas | 2 ++ ide/ideprocs.pp | 41 +++++++++++++++++--------------- 2 files changed, 24 insertions(+), 19 deletions(-) diff --git a/components/lazutils/fileutil.pas b/components/lazutils/fileutil.pas index d9afd3dc97..4df5348662 100644 --- a/components/lazutils/fileutil.pas +++ b/components/lazutils/fileutil.pas @@ -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 diff --git a/ide/ideprocs.pp b/ide/ideprocs.pp index 6bbc11fb38..80cde9ea80 100644 --- a/ide/ideprocs.pp +++ b/ide/ideprocs.pp @@ -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;