mirror of https://gitlab.com/basile.b/dexed.git
more style modernisation
This commit is contained in:
parent
5e2a1b8290
commit
2bbd854fc8
|
@ -57,6 +57,7 @@ type
|
|||
function extractFilePath: string;
|
||||
function fileExists: boolean;
|
||||
function dirExists: boolean;
|
||||
function upperCase: string;
|
||||
end;
|
||||
|
||||
(**
|
||||
|
@ -278,7 +279,7 @@ begin
|
|||
err := false;
|
||||
doneLinuxDataMigration := true;
|
||||
oldLocation := sysutils.GetEnvironmentVariable('HOME') +'/Coedit';
|
||||
if not DirectoryExists(oldLocation) then exit;
|
||||
if not oldLocation.dirExists then exit;
|
||||
newLocation := getUserDataPath + 'Coedit';
|
||||
try
|
||||
try
|
||||
|
@ -362,6 +363,11 @@ begin
|
|||
exit(sysutils.DirectoryExists(self));
|
||||
end;
|
||||
|
||||
function TStringHelper.upperCase: string;
|
||||
begin
|
||||
exit(sysutils.upperCase(self));
|
||||
end;
|
||||
|
||||
{$IFDEF LINUX}
|
||||
constructor TCheckedAsyncProcess.Create(aOwner: TComponent);
|
||||
begin
|
||||
|
@ -474,7 +480,7 @@ var
|
|||
begin
|
||||
getDir(0, curr);
|
||||
try
|
||||
if (curr <> aBasePath) and DirectoryExists(aBasePath) then
|
||||
if (curr <> aBasePath) and aBasePath.dirExists then
|
||||
chDir(aBasePath);
|
||||
result := expandFileName(aFilename);
|
||||
finally
|
||||
|
@ -533,7 +539,7 @@ function patchPlateformExt(const aFilename: string): string;
|
|||
var
|
||||
ext, newext: string;
|
||||
begin
|
||||
ext := extractFileExt(aFilename);
|
||||
ext := aFilename.extractFileExt;
|
||||
newext := '';
|
||||
{$IFDEF MSWINDOWS}
|
||||
case ext of
|
||||
|
@ -707,7 +713,7 @@ begin
|
|||
pth := aPath[1..length(aPath)-1];
|
||||
if pth[length(pth)] in ['/', '\'] then
|
||||
pth := pth[1..length(pth)-1];
|
||||
if not directoryExists(pth) then exit(false);
|
||||
if not pth.dirExists then exit(false);
|
||||
//
|
||||
files := TStringList.Create;
|
||||
try
|
||||
|
@ -718,7 +724,7 @@ begin
|
|||
aList.Add(fname)
|
||||
else
|
||||
begin
|
||||
ext := extractFileExt(fname);
|
||||
ext := fname.extractFileExt;
|
||||
if someExts.IndexOf(ext) <> -1 then
|
||||
aList.Add(fname);
|
||||
end;
|
||||
|
@ -804,7 +810,7 @@ var
|
|||
ext: string;
|
||||
env: string;
|
||||
begin
|
||||
ext := extractFileExt(anExeName);
|
||||
ext := anExeName.extractFileExt;
|
||||
if ext.isEmpty then
|
||||
anExeName += exeExt;
|
||||
//full path already specified
|
||||
|
@ -981,7 +987,7 @@ begin
|
|||
try
|
||||
sink.Assign(someFiles);
|
||||
for i := sink.Count-1 downto 0 do
|
||||
if (not sink.Strings[i].fileExists) and (not DirectoryExists(sink.Strings[i])) then
|
||||
if (not sink.Strings[i].fileExists) and (not sink.Strings[i].dirExists) then
|
||||
sink.Delete(i);
|
||||
// folders count
|
||||
cnt := 256;
|
||||
|
|
|
@ -151,8 +151,8 @@ begin
|
|||
for i := 0 to fProj.importsPathCount-1 do
|
||||
begin
|
||||
fold := fProj.importPath(i);
|
||||
if DirectoryExists(fold) and (folds.IndexOf(fold) = -1) then
|
||||
folds.Add(fold);
|
||||
if fold.dirExists and (folds.IndexOf(fold) = -1) then
|
||||
folds.Add(fold);
|
||||
end;
|
||||
for fold in folds do addImportFolder(fold);
|
||||
finally
|
||||
|
|
|
@ -389,10 +389,10 @@ begin
|
|||
msgs.message('compiling ' + prjname, self as ICECommonProject, amcProj, amkInf);
|
||||
if modified then saveToFile(fFilename);
|
||||
end;
|
||||
chDir(extractFilePath(fFilename));
|
||||
chDir(fFilename.extractFilePath);
|
||||
dubproc.Executable := 'dub' + exeExt;
|
||||
dubproc.Options := dubproc.Options + [poStderrToOutPut, poUsePipes];
|
||||
dubproc.CurrentDirectory := extractFilePath(fFilename);
|
||||
dubproc.CurrentDirectory := fFilename.extractFilePath;
|
||||
dubproc.ShowWindow := swoHIDE;
|
||||
if not run then
|
||||
dubproc.Parameters.Add('build')
|
||||
|
@ -539,12 +539,12 @@ procedure tryAddFromFolder(const pth: string);
|
|||
var
|
||||
abs: string;
|
||||
begin
|
||||
if DirectoryExists(pth) then
|
||||
if pth.dirExists then
|
||||
begin
|
||||
lst.Clear;
|
||||
listFiles(lst, pth, true);
|
||||
for abs in lst do
|
||||
if isDlangCompilable(extractFileExt(abs)) then
|
||||
if isDlangCompilable(abs.extractFileExt) then
|
||||
fSrcs.Add(ExtractRelativepath(fBasePath, abs));
|
||||
end;
|
||||
end;
|
||||
|
@ -570,7 +570,7 @@ begin
|
|||
for i := 0 to arr.Count-1 do
|
||||
begin
|
||||
pth := TrimRightSet(arr.Strings[i], ['/','\']);
|
||||
if DirectoryExists(pth) then
|
||||
if pth.dirExists then
|
||||
tryAddFromFolder(pth)
|
||||
else
|
||||
tryAddFromFolder(fBasePath + pth);
|
||||
|
@ -598,7 +598,7 @@ begin
|
|||
for i := 0 to arr.Count-1 do
|
||||
begin
|
||||
pth := TrimRightSet(arr.Strings[i], ['/','\']);
|
||||
if DirectoryExists(pth) then
|
||||
if pth.dirExists then
|
||||
tryAddFromFolder(pth)
|
||||
else
|
||||
tryAddFromFolder(fBasePath + pth);
|
||||
|
@ -790,7 +790,7 @@ function isValidDubProject(const filename: string): boolean;
|
|||
var
|
||||
maybe: TCEDubProject;
|
||||
begin
|
||||
if (UpperCase(ExtractFileExt(filename)) <> '.JSON') then
|
||||
if (filename.extractFileExt.upperCase <> '.JSON') then
|
||||
exit(false);
|
||||
result := true;
|
||||
// avoid the project to notify the observers, current project is not replaced
|
||||
|
|
|
@ -64,7 +64,7 @@ inherited CEDubProjectEditorWidget: TCEDubProjectEditorWidget
|
|||
Width = 387
|
||||
Align = alClient
|
||||
BorderSpacing.Around = 4
|
||||
DefaultItemHeight = 18
|
||||
DefaultItemHeight = 16
|
||||
HideSelection = False
|
||||
Images = imgList
|
||||
ReadOnly = True
|
||||
|
|
|
@ -485,7 +485,7 @@ begin
|
|||
if node.Parent = fNodeSources then
|
||||
begin
|
||||
fname := fProj.sourceAbsolute(node.Index);
|
||||
if isEditable(extractFileExt(fname)) then
|
||||
if isEditable(fname.extractFileExt) then
|
||||
getMultiDocHandler.openDocument(fname);
|
||||
end
|
||||
// select active config
|
||||
|
|
|
@ -92,19 +92,16 @@ begin
|
|||
{$ENDIF}
|
||||
{$IFDEF LINUX}
|
||||
// add phobos
|
||||
if DirectoryExists('/usr/include/dmd/phobos') then
|
||||
if '/usr/include/dmd/phobos'.dirExists then
|
||||
begin
|
||||
with TLibraryItem(fCol.Add) do begin
|
||||
libAlias := 'phobos';
|
||||
if FileExists('/usr/lib/libphobos2.a') then
|
||||
libFile := '/usr/lib/libphobos2.a'
|
||||
else if FileExists('/usr/lib32/libphobos2.a') then
|
||||
libFile := '/usr/lib32/libphobos2.a';
|
||||
libFile := '';
|
||||
libSourcePath := '/usr/include/dmd/phobos';
|
||||
end;
|
||||
end;
|
||||
// add druntime (no lib - only for DCD)
|
||||
if DirectoryExists('/usr/include/dmd/druntime/import') then
|
||||
if '/usr/include/dmd/druntime/import'.dirExists then
|
||||
begin
|
||||
with TLibraryItem(fCol.Add) do begin
|
||||
libAlias := 'druntime';
|
||||
|
@ -179,7 +176,7 @@ begin
|
|||
aList.Add(itm.libFile);
|
||||
end
|
||||
// folder of lib file
|
||||
else if directoryExists(itm.libFile) then
|
||||
else if itm.libFile.dirExists then
|
||||
begin
|
||||
lst := TStringList.Create;
|
||||
try
|
||||
|
@ -189,7 +186,7 @@ begin
|
|||
listFiles(lst, dir);
|
||||
for j:= 0 to lst.Count-1 do
|
||||
begin
|
||||
if extractFileExt(lst.Strings[j]) = libExt then
|
||||
if lst.Strings[j].extractFileExt = libExt then
|
||||
if aList.IndexOf(lst.Strings[j]) = -1 then
|
||||
aList.Add(lst.Strings[j]);
|
||||
end;
|
||||
|
@ -218,7 +215,7 @@ begin
|
|||
//
|
||||
if aList.IndexOf(itm.libSourcePath) <> -1 then
|
||||
continue;
|
||||
if not directoryExists(itm.libSourcePath) then
|
||||
if not itm.libSourcePath.dirExists then
|
||||
continue;
|
||||
aList.Add('-I' + itm.libSourcePath);
|
||||
end;
|
||||
|
|
|
@ -180,7 +180,7 @@ begin
|
|||
pth := GetEnvironmentVariable('HOME') + '/.dub/packages/' + nme + '-master';
|
||||
{$ENDIF}
|
||||
itf := getMessageDisplay;
|
||||
if DirectoryExists(pth) then
|
||||
if pth.dirExists then
|
||||
begin
|
||||
upd := true;
|
||||
itf.message('information, the dub package is already fetched and will be upgraded', nil, amcApp, amkInf);
|
||||
|
@ -378,7 +378,7 @@ begin
|
|||
with List.Items.Add do
|
||||
begin
|
||||
Caption := ExtractFileNameOnly(fname);
|
||||
if ExtractFileExt(fname) <> libExt then
|
||||
if fname.extractFileExt <> libExt then
|
||||
SubItems.add(fname + libExt)
|
||||
else
|
||||
SubItems.add(fname);
|
||||
|
|
|
@ -748,7 +748,7 @@ begin
|
|||
for value in lst do
|
||||
begin
|
||||
if value.isEmpty then continue;
|
||||
if isEditable(ExtractFileExt(value)) then
|
||||
if isEditable(value.extractFileExt) then
|
||||
openFile(value)
|
||||
else if isValidNativeProject(value) or isValidDubProject(value) then
|
||||
begin
|
||||
|
@ -1815,7 +1815,7 @@ begin
|
|||
i := length(firstlineFlags);
|
||||
if ( i > 18) then
|
||||
begin
|
||||
if UpperCase(firstlineFlags[1..17]) = '#!RUNNABLE-FLAGS:' then
|
||||
if firstlineFlags.upperCase[1..17] = '#!RUNNABLE-FLAGS:' then
|
||||
firstlineFlags := symbolExpander.get(firstlineFlags[18..i])
|
||||
else firstlineFlags:= '';
|
||||
end else firstlineFlags:= '';
|
||||
|
@ -2212,7 +2212,7 @@ end;
|
|||
procedure TCEMainForm.openProj(const aFilename: string);
|
||||
begin
|
||||
closeProj;
|
||||
if LowerCase(ExtractFileExt(aFilename)) = '.json' then
|
||||
if aFilename.extractFileExt.upperCase = '.JSON' then
|
||||
newDubProj
|
||||
else
|
||||
newNativeProj;
|
||||
|
|
|
@ -1028,7 +1028,7 @@ begin
|
|||
exit;
|
||||
// '(': line will be indicated after fname
|
||||
// -mixin: dmd, error in mixin(token string) '<fname>-mixinXX<index>('
|
||||
if isEditable(extractFileExt(ident)) and ((aMessage[i] = '(') or
|
||||
if isEditable(ident.extractFileExt) and ((aMessage[i] = '(') or
|
||||
((aMessage[i] = '-') and (i < length(aMessage)-5)
|
||||
and (aMessage[i..i+5] = '-mixin'))) then
|
||||
begin
|
||||
|
|
|
@ -62,7 +62,7 @@ inherited CEMiniExplorerWidget: TCEMiniExplorerWidget
|
|||
Top = 32
|
||||
Width = 335
|
||||
Align = alTop
|
||||
DefaultItemHeight = 18
|
||||
DefaultItemHeight = 16
|
||||
Images = imgList
|
||||
ReadOnly = True
|
||||
ScrollBars = ssAutoBoth
|
||||
|
|
|
@ -135,7 +135,7 @@ begin
|
|||
widg.Splitter1.SetSplitterPosition(fSplitter1Position);
|
||||
widg.Splitter2.SetSplitterPosition(fSplitter2Position);
|
||||
widg.updateFavorites;
|
||||
if DirectoryExists(widg.fLastFold) then
|
||||
if widg.fLastFold.dirExists then
|
||||
widg.expandPath(fLastFolder);
|
||||
end
|
||||
else inherited;
|
||||
|
|
|
@ -196,9 +196,9 @@ var
|
|||
relSrc, absSrc: string;
|
||||
expand: boolean;
|
||||
begin
|
||||
if not isDlangCompilable(ExtractFileExt(aFilename)) then
|
||||
if not isDlangCompilable(aFilename.extractFileExt) then
|
||||
exit;
|
||||
expand := DirectoryExists(fBasePath);
|
||||
expand := fBasePath.dirExists;
|
||||
for relSrc in fSrcs do
|
||||
begin
|
||||
if not expand then absSrc := relSrc
|
||||
|
@ -402,11 +402,11 @@ begin
|
|||
rel := expandFilenameEx(fBasePath, currentConfiguration.pathsOptions.exclusions.Strings[i]);
|
||||
if fileExists(str) then
|
||||
ex_files.Add(str)
|
||||
else if DirectoryExists(str) then
|
||||
else if str.dirExists then
|
||||
ex_folds.Add(str);
|
||||
if fileExists(rel) then
|
||||
if rel.fileExists then
|
||||
ex_files.Add(rel)
|
||||
else if DirectoryExists(rel) then
|
||||
else if rel.dirExists then
|
||||
ex_folds.Add(rel);
|
||||
end;
|
||||
// sources
|
||||
|
@ -721,7 +721,7 @@ begin
|
|||
try
|
||||
msgs.message('compiling ' + prjname, self as ICECommonProject, amcProj, amkInf);
|
||||
// this doesn't work under linux, so the previous ChDir.
|
||||
if directoryExists(prjpath) then
|
||||
if prjpath.dirExists then
|
||||
compilproc.CurrentDirectory := prjpath;
|
||||
compilproc.Executable := NativeProjectCompilerFilename;
|
||||
compilproc.Options := compilproc.Options + [poStderrToOutPut, poUsePipes];
|
||||
|
@ -761,7 +761,7 @@ var
|
|||
begin
|
||||
result := false;
|
||||
killProcess(fRunner);
|
||||
if DirectoryExists(fRunnerOldCwd) then
|
||||
if fRunnerOldCwd.dirExists then
|
||||
ChDir(fRunnerOldCwd);
|
||||
//
|
||||
fRunner := TCEProcess.Create(nil); // fRunner can use the input process widget.
|
||||
|
@ -955,7 +955,7 @@ end;
|
|||
function TCENativeProject.importPath(index: integer): string;
|
||||
begin
|
||||
result := currentConfiguration.pathsOptions.importModulePaths.Strings[index];
|
||||
if DirectoryExists(fBasePath) then
|
||||
if fBasePath.dirExists then
|
||||
result := expandFilenameEx(fBasePath, result);
|
||||
end;
|
||||
|
||||
|
@ -964,7 +964,7 @@ var
|
|||
maybe: TCENativeProject;
|
||||
begin
|
||||
result := false;
|
||||
if isDlangCompilable(ExtractFileExt(filename)) then
|
||||
if isDlangCompilable(filename.extractFileExt) then
|
||||
exit;
|
||||
// avoid the project to notify the observers, current project is not replaced
|
||||
EntitiesConnector.beginUpdate;
|
||||
|
|
|
@ -28,7 +28,7 @@ inherited CEProjectInspectWidget: TCEProjectInspectWidget
|
|||
Align = alClient
|
||||
AutoExpand = True
|
||||
BorderSpacing.Around = 2
|
||||
DefaultItemHeight = 18
|
||||
DefaultItemHeight = 16
|
||||
Images = imgList
|
||||
ReadOnly = True
|
||||
RightClickSelect = True
|
||||
|
|
|
@ -217,7 +217,7 @@ begin
|
|||
i := fProject.Sources.IndexOf(fname);
|
||||
if i > -1 then
|
||||
fname := fProject.sourceAbsolute(i);
|
||||
if isEditable(ExtractFileExt(fname)) and fileExists(fname) then
|
||||
if isEditable(fname.extractFileExt) and fname.fileExists then
|
||||
getMultiDocHandler.openDocument(fname);
|
||||
end
|
||||
else if Tree.Selected.Parent = fConfNode then
|
||||
|
@ -283,7 +283,7 @@ begin
|
|||
for i := 0 to lst.Count-1 do
|
||||
begin
|
||||
fname := lst.Strings[i];
|
||||
if isDlangCompilable(extractFileExt(fname)) then
|
||||
if isDlangCompilable(fname.extractFileExt) then
|
||||
fProject.addSource(fname);
|
||||
end;
|
||||
finally
|
||||
|
@ -342,7 +342,7 @@ procedure addFile(const aFilename: string);
|
|||
var
|
||||
ext: string;
|
||||
begin
|
||||
ext := ExtractFileExt(aFilename);
|
||||
ext := aFilename.extractFileExt;
|
||||
if not isDlangCompilable(ext) then
|
||||
exit;
|
||||
fProject.addSource(aFilename);
|
||||
|
@ -359,7 +359,7 @@ begin
|
|||
try for fname in Filenames do
|
||||
if FileExists(fname) then
|
||||
addFile(fname)
|
||||
else if DirectoryExists(fname) then
|
||||
else if fname.dirExists then
|
||||
begin
|
||||
lst.Clear;
|
||||
listFiles(lst, fname, true);
|
||||
|
|
|
@ -951,7 +951,7 @@ procedure TCESynMemo.loadFromFile(const aFilename: string);
|
|||
var
|
||||
ext: string;
|
||||
begin
|
||||
ext := extractFileExt(aFilename);
|
||||
ext := aFilename.extractFileExt;
|
||||
if not hasDlangSyntax(ext) then
|
||||
Highlighter := TxtSyn;
|
||||
Lines.LoadFromFile(aFilename);
|
||||
|
@ -974,7 +974,7 @@ var
|
|||
begin
|
||||
Lines.SaveToFile(aFilename);
|
||||
fFilename := aFilename;
|
||||
ext := extractFileExt(aFilename);
|
||||
ext := aFilename.extractFileExt;
|
||||
if hasDlangSyntax(ext) then
|
||||
Highlighter := fD2Highlighter;
|
||||
FileAge(fFilename, fFileDate);
|
||||
|
|
Loading…
Reference in New Issue