more style modernisation

This commit is contained in:
Basile Burg 2016-01-19 21:52:15 +01:00
parent 5e2a1b8290
commit 2bbd854fc8
15 changed files with 54 additions and 51 deletions

View File

@ -57,6 +57,7 @@ type
function extractFilePath: string; function extractFilePath: string;
function fileExists: boolean; function fileExists: boolean;
function dirExists: boolean; function dirExists: boolean;
function upperCase: string;
end; end;
(** (**
@ -278,7 +279,7 @@ begin
err := false; err := false;
doneLinuxDataMigration := true; doneLinuxDataMigration := true;
oldLocation := sysutils.GetEnvironmentVariable('HOME') +'/Coedit'; oldLocation := sysutils.GetEnvironmentVariable('HOME') +'/Coedit';
if not DirectoryExists(oldLocation) then exit; if not oldLocation.dirExists then exit;
newLocation := getUserDataPath + 'Coedit'; newLocation := getUserDataPath + 'Coedit';
try try
try try
@ -362,6 +363,11 @@ begin
exit(sysutils.DirectoryExists(self)); exit(sysutils.DirectoryExists(self));
end; end;
function TStringHelper.upperCase: string;
begin
exit(sysutils.upperCase(self));
end;
{$IFDEF LINUX} {$IFDEF LINUX}
constructor TCheckedAsyncProcess.Create(aOwner: TComponent); constructor TCheckedAsyncProcess.Create(aOwner: TComponent);
begin begin
@ -474,7 +480,7 @@ var
begin begin
getDir(0, curr); getDir(0, curr);
try try
if (curr <> aBasePath) and DirectoryExists(aBasePath) then if (curr <> aBasePath) and aBasePath.dirExists then
chDir(aBasePath); chDir(aBasePath);
result := expandFileName(aFilename); result := expandFileName(aFilename);
finally finally
@ -533,7 +539,7 @@ function patchPlateformExt(const aFilename: string): string;
var var
ext, newext: string; ext, newext: string;
begin begin
ext := extractFileExt(aFilename); ext := aFilename.extractFileExt;
newext := ''; newext := '';
{$IFDEF MSWINDOWS} {$IFDEF MSWINDOWS}
case ext of case ext of
@ -707,7 +713,7 @@ begin
pth := aPath[1..length(aPath)-1]; pth := aPath[1..length(aPath)-1];
if pth[length(pth)] in ['/', '\'] then if pth[length(pth)] in ['/', '\'] then
pth := pth[1..length(pth)-1]; pth := pth[1..length(pth)-1];
if not directoryExists(pth) then exit(false); if not pth.dirExists then exit(false);
// //
files := TStringList.Create; files := TStringList.Create;
try try
@ -718,7 +724,7 @@ begin
aList.Add(fname) aList.Add(fname)
else else
begin begin
ext := extractFileExt(fname); ext := fname.extractFileExt;
if someExts.IndexOf(ext) <> -1 then if someExts.IndexOf(ext) <> -1 then
aList.Add(fname); aList.Add(fname);
end; end;
@ -804,7 +810,7 @@ var
ext: string; ext: string;
env: string; env: string;
begin begin
ext := extractFileExt(anExeName); ext := anExeName.extractFileExt;
if ext.isEmpty then if ext.isEmpty then
anExeName += exeExt; anExeName += exeExt;
//full path already specified //full path already specified
@ -981,7 +987,7 @@ begin
try try
sink.Assign(someFiles); sink.Assign(someFiles);
for i := sink.Count-1 downto 0 do 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); sink.Delete(i);
// folders count // folders count
cnt := 256; cnt := 256;

View File

@ -151,8 +151,8 @@ begin
for i := 0 to fProj.importsPathCount-1 do for i := 0 to fProj.importsPathCount-1 do
begin begin
fold := fProj.importPath(i); fold := fProj.importPath(i);
if DirectoryExists(fold) and (folds.IndexOf(fold) = -1) then if fold.dirExists and (folds.IndexOf(fold) = -1) then
folds.Add(fold); folds.Add(fold);
end; end;
for fold in folds do addImportFolder(fold); for fold in folds do addImportFolder(fold);
finally finally

View File

@ -389,10 +389,10 @@ begin
msgs.message('compiling ' + prjname, self as ICECommonProject, amcProj, amkInf); msgs.message('compiling ' + prjname, self as ICECommonProject, amcProj, amkInf);
if modified then saveToFile(fFilename); if modified then saveToFile(fFilename);
end; end;
chDir(extractFilePath(fFilename)); chDir(fFilename.extractFilePath);
dubproc.Executable := 'dub' + exeExt; dubproc.Executable := 'dub' + exeExt;
dubproc.Options := dubproc.Options + [poStderrToOutPut, poUsePipes]; dubproc.Options := dubproc.Options + [poStderrToOutPut, poUsePipes];
dubproc.CurrentDirectory := extractFilePath(fFilename); dubproc.CurrentDirectory := fFilename.extractFilePath;
dubproc.ShowWindow := swoHIDE; dubproc.ShowWindow := swoHIDE;
if not run then if not run then
dubproc.Parameters.Add('build') dubproc.Parameters.Add('build')
@ -539,12 +539,12 @@ procedure tryAddFromFolder(const pth: string);
var var
abs: string; abs: string;
begin begin
if DirectoryExists(pth) then if pth.dirExists then
begin begin
lst.Clear; lst.Clear;
listFiles(lst, pth, true); listFiles(lst, pth, true);
for abs in lst do for abs in lst do
if isDlangCompilable(extractFileExt(abs)) then if isDlangCompilable(abs.extractFileExt) then
fSrcs.Add(ExtractRelativepath(fBasePath, abs)); fSrcs.Add(ExtractRelativepath(fBasePath, abs));
end; end;
end; end;
@ -570,7 +570,7 @@ begin
for i := 0 to arr.Count-1 do for i := 0 to arr.Count-1 do
begin begin
pth := TrimRightSet(arr.Strings[i], ['/','\']); pth := TrimRightSet(arr.Strings[i], ['/','\']);
if DirectoryExists(pth) then if pth.dirExists then
tryAddFromFolder(pth) tryAddFromFolder(pth)
else else
tryAddFromFolder(fBasePath + pth); tryAddFromFolder(fBasePath + pth);
@ -598,7 +598,7 @@ begin
for i := 0 to arr.Count-1 do for i := 0 to arr.Count-1 do
begin begin
pth := TrimRightSet(arr.Strings[i], ['/','\']); pth := TrimRightSet(arr.Strings[i], ['/','\']);
if DirectoryExists(pth) then if pth.dirExists then
tryAddFromFolder(pth) tryAddFromFolder(pth)
else else
tryAddFromFolder(fBasePath + pth); tryAddFromFolder(fBasePath + pth);
@ -790,7 +790,7 @@ function isValidDubProject(const filename: string): boolean;
var var
maybe: TCEDubProject; maybe: TCEDubProject;
begin begin
if (UpperCase(ExtractFileExt(filename)) <> '.JSON') then if (filename.extractFileExt.upperCase <> '.JSON') then
exit(false); exit(false);
result := true; result := true;
// avoid the project to notify the observers, current project is not replaced // avoid the project to notify the observers, current project is not replaced

View File

@ -64,7 +64,7 @@ inherited CEDubProjectEditorWidget: TCEDubProjectEditorWidget
Width = 387 Width = 387
Align = alClient Align = alClient
BorderSpacing.Around = 4 BorderSpacing.Around = 4
DefaultItemHeight = 18 DefaultItemHeight = 16
HideSelection = False HideSelection = False
Images = imgList Images = imgList
ReadOnly = True ReadOnly = True

View File

@ -485,7 +485,7 @@ begin
if node.Parent = fNodeSources then if node.Parent = fNodeSources then
begin begin
fname := fProj.sourceAbsolute(node.Index); fname := fProj.sourceAbsolute(node.Index);
if isEditable(extractFileExt(fname)) then if isEditable(fname.extractFileExt) then
getMultiDocHandler.openDocument(fname); getMultiDocHandler.openDocument(fname);
end end
// select active config // select active config

View File

@ -92,19 +92,16 @@ begin
{$ENDIF} {$ENDIF}
{$IFDEF LINUX} {$IFDEF LINUX}
// add phobos // add phobos
if DirectoryExists('/usr/include/dmd/phobos') then if '/usr/include/dmd/phobos'.dirExists then
begin begin
with TLibraryItem(fCol.Add) do begin with TLibraryItem(fCol.Add) do begin
libAlias := 'phobos'; libAlias := 'phobos';
if FileExists('/usr/lib/libphobos2.a') then libFile := '';
libFile := '/usr/lib/libphobos2.a'
else if FileExists('/usr/lib32/libphobos2.a') then
libFile := '/usr/lib32/libphobos2.a';
libSourcePath := '/usr/include/dmd/phobos'; libSourcePath := '/usr/include/dmd/phobos';
end; end;
end; end;
// add druntime (no lib - only for DCD) // add druntime (no lib - only for DCD)
if DirectoryExists('/usr/include/dmd/druntime/import') then if '/usr/include/dmd/druntime/import'.dirExists then
begin begin
with TLibraryItem(fCol.Add) do begin with TLibraryItem(fCol.Add) do begin
libAlias := 'druntime'; libAlias := 'druntime';
@ -179,7 +176,7 @@ begin
aList.Add(itm.libFile); aList.Add(itm.libFile);
end end
// folder of lib file // folder of lib file
else if directoryExists(itm.libFile) then else if itm.libFile.dirExists then
begin begin
lst := TStringList.Create; lst := TStringList.Create;
try try
@ -189,7 +186,7 @@ begin
listFiles(lst, dir); listFiles(lst, dir);
for j:= 0 to lst.Count-1 do for j:= 0 to lst.Count-1 do
begin begin
if extractFileExt(lst.Strings[j]) = libExt then if lst.Strings[j].extractFileExt = libExt then
if aList.IndexOf(lst.Strings[j]) = -1 then if aList.IndexOf(lst.Strings[j]) = -1 then
aList.Add(lst.Strings[j]); aList.Add(lst.Strings[j]);
end; end;
@ -218,7 +215,7 @@ begin
// //
if aList.IndexOf(itm.libSourcePath) <> -1 then if aList.IndexOf(itm.libSourcePath) <> -1 then
continue; continue;
if not directoryExists(itm.libSourcePath) then if not itm.libSourcePath.dirExists then
continue; continue;
aList.Add('-I' + itm.libSourcePath); aList.Add('-I' + itm.libSourcePath);
end; end;

View File

@ -180,7 +180,7 @@ begin
pth := GetEnvironmentVariable('HOME') + '/.dub/packages/' + nme + '-master'; pth := GetEnvironmentVariable('HOME') + '/.dub/packages/' + nme + '-master';
{$ENDIF} {$ENDIF}
itf := getMessageDisplay; itf := getMessageDisplay;
if DirectoryExists(pth) then if pth.dirExists then
begin begin
upd := true; upd := true;
itf.message('information, the dub package is already fetched and will be upgraded', nil, amcApp, amkInf); 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 with List.Items.Add do
begin begin
Caption := ExtractFileNameOnly(fname); Caption := ExtractFileNameOnly(fname);
if ExtractFileExt(fname) <> libExt then if fname.extractFileExt <> libExt then
SubItems.add(fname + libExt) SubItems.add(fname + libExt)
else else
SubItems.add(fname); SubItems.add(fname);

View File

@ -748,7 +748,7 @@ begin
for value in lst do for value in lst do
begin begin
if value.isEmpty then continue; if value.isEmpty then continue;
if isEditable(ExtractFileExt(value)) then if isEditable(value.extractFileExt) then
openFile(value) openFile(value)
else if isValidNativeProject(value) or isValidDubProject(value) then else if isValidNativeProject(value) or isValidDubProject(value) then
begin begin
@ -1815,7 +1815,7 @@ begin
i := length(firstlineFlags); i := length(firstlineFlags);
if ( i > 18) then if ( i > 18) then
begin begin
if UpperCase(firstlineFlags[1..17]) = '#!RUNNABLE-FLAGS:' then if firstlineFlags.upperCase[1..17] = '#!RUNNABLE-FLAGS:' then
firstlineFlags := symbolExpander.get(firstlineFlags[18..i]) firstlineFlags := symbolExpander.get(firstlineFlags[18..i])
else firstlineFlags:= ''; else firstlineFlags:= '';
end else firstlineFlags:= ''; end else firstlineFlags:= '';
@ -2212,7 +2212,7 @@ end;
procedure TCEMainForm.openProj(const aFilename: string); procedure TCEMainForm.openProj(const aFilename: string);
begin begin
closeProj; closeProj;
if LowerCase(ExtractFileExt(aFilename)) = '.json' then if aFilename.extractFileExt.upperCase = '.JSON' then
newDubProj newDubProj
else else
newNativeProj; newNativeProj;

View File

@ -1028,7 +1028,7 @@ begin
exit; exit;
// '(': line will be indicated after fname // '(': line will be indicated after fname
// -mixin: dmd, error in mixin(token string) '<fname>-mixinXX<index>(' // -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) ((aMessage[i] = '-') and (i < length(aMessage)-5)
and (aMessage[i..i+5] = '-mixin'))) then and (aMessage[i..i+5] = '-mixin'))) then
begin begin

View File

@ -62,7 +62,7 @@ inherited CEMiniExplorerWidget: TCEMiniExplorerWidget
Top = 32 Top = 32
Width = 335 Width = 335
Align = alTop Align = alTop
DefaultItemHeight = 18 DefaultItemHeight = 16
Images = imgList Images = imgList
ReadOnly = True ReadOnly = True
ScrollBars = ssAutoBoth ScrollBars = ssAutoBoth

View File

@ -135,7 +135,7 @@ begin
widg.Splitter1.SetSplitterPosition(fSplitter1Position); widg.Splitter1.SetSplitterPosition(fSplitter1Position);
widg.Splitter2.SetSplitterPosition(fSplitter2Position); widg.Splitter2.SetSplitterPosition(fSplitter2Position);
widg.updateFavorites; widg.updateFavorites;
if DirectoryExists(widg.fLastFold) then if widg.fLastFold.dirExists then
widg.expandPath(fLastFolder); widg.expandPath(fLastFolder);
end end
else inherited; else inherited;

View File

@ -196,9 +196,9 @@ var
relSrc, absSrc: string; relSrc, absSrc: string;
expand: boolean; expand: boolean;
begin begin
if not isDlangCompilable(ExtractFileExt(aFilename)) then if not isDlangCompilable(aFilename.extractFileExt) then
exit; exit;
expand := DirectoryExists(fBasePath); expand := fBasePath.dirExists;
for relSrc in fSrcs do for relSrc in fSrcs do
begin begin
if not expand then absSrc := relSrc if not expand then absSrc := relSrc
@ -402,11 +402,11 @@ begin
rel := expandFilenameEx(fBasePath, currentConfiguration.pathsOptions.exclusions.Strings[i]); rel := expandFilenameEx(fBasePath, currentConfiguration.pathsOptions.exclusions.Strings[i]);
if fileExists(str) then if fileExists(str) then
ex_files.Add(str) ex_files.Add(str)
else if DirectoryExists(str) then else if str.dirExists then
ex_folds.Add(str); ex_folds.Add(str);
if fileExists(rel) then if rel.fileExists then
ex_files.Add(rel) ex_files.Add(rel)
else if DirectoryExists(rel) then else if rel.dirExists then
ex_folds.Add(rel); ex_folds.Add(rel);
end; end;
// sources // sources
@ -721,7 +721,7 @@ begin
try try
msgs.message('compiling ' + prjname, self as ICECommonProject, amcProj, amkInf); msgs.message('compiling ' + prjname, self as ICECommonProject, amcProj, amkInf);
// this doesn't work under linux, so the previous ChDir. // this doesn't work under linux, so the previous ChDir.
if directoryExists(prjpath) then if prjpath.dirExists then
compilproc.CurrentDirectory := prjpath; compilproc.CurrentDirectory := prjpath;
compilproc.Executable := NativeProjectCompilerFilename; compilproc.Executable := NativeProjectCompilerFilename;
compilproc.Options := compilproc.Options + [poStderrToOutPut, poUsePipes]; compilproc.Options := compilproc.Options + [poStderrToOutPut, poUsePipes];
@ -761,7 +761,7 @@ var
begin begin
result := false; result := false;
killProcess(fRunner); killProcess(fRunner);
if DirectoryExists(fRunnerOldCwd) then if fRunnerOldCwd.dirExists then
ChDir(fRunnerOldCwd); ChDir(fRunnerOldCwd);
// //
fRunner := TCEProcess.Create(nil); // fRunner can use the input process widget. fRunner := TCEProcess.Create(nil); // fRunner can use the input process widget.
@ -955,7 +955,7 @@ end;
function TCENativeProject.importPath(index: integer): string; function TCENativeProject.importPath(index: integer): string;
begin begin
result := currentConfiguration.pathsOptions.importModulePaths.Strings[index]; result := currentConfiguration.pathsOptions.importModulePaths.Strings[index];
if DirectoryExists(fBasePath) then if fBasePath.dirExists then
result := expandFilenameEx(fBasePath, result); result := expandFilenameEx(fBasePath, result);
end; end;
@ -964,7 +964,7 @@ var
maybe: TCENativeProject; maybe: TCENativeProject;
begin begin
result := false; result := false;
if isDlangCompilable(ExtractFileExt(filename)) then if isDlangCompilable(filename.extractFileExt) then
exit; exit;
// avoid the project to notify the observers, current project is not replaced // avoid the project to notify the observers, current project is not replaced
EntitiesConnector.beginUpdate; EntitiesConnector.beginUpdate;

View File

@ -28,7 +28,7 @@ inherited CEProjectInspectWidget: TCEProjectInspectWidget
Align = alClient Align = alClient
AutoExpand = True AutoExpand = True
BorderSpacing.Around = 2 BorderSpacing.Around = 2
DefaultItemHeight = 18 DefaultItemHeight = 16
Images = imgList Images = imgList
ReadOnly = True ReadOnly = True
RightClickSelect = True RightClickSelect = True

View File

@ -217,7 +217,7 @@ begin
i := fProject.Sources.IndexOf(fname); i := fProject.Sources.IndexOf(fname);
if i > -1 then if i > -1 then
fname := fProject.sourceAbsolute(i); fname := fProject.sourceAbsolute(i);
if isEditable(ExtractFileExt(fname)) and fileExists(fname) then if isEditable(fname.extractFileExt) and fname.fileExists then
getMultiDocHandler.openDocument(fname); getMultiDocHandler.openDocument(fname);
end end
else if Tree.Selected.Parent = fConfNode then else if Tree.Selected.Parent = fConfNode then
@ -283,7 +283,7 @@ begin
for i := 0 to lst.Count-1 do for i := 0 to lst.Count-1 do
begin begin
fname := lst.Strings[i]; fname := lst.Strings[i];
if isDlangCompilable(extractFileExt(fname)) then if isDlangCompilable(fname.extractFileExt) then
fProject.addSource(fname); fProject.addSource(fname);
end; end;
finally finally
@ -342,7 +342,7 @@ procedure addFile(const aFilename: string);
var var
ext: string; ext: string;
begin begin
ext := ExtractFileExt(aFilename); ext := aFilename.extractFileExt;
if not isDlangCompilable(ext) then if not isDlangCompilable(ext) then
exit; exit;
fProject.addSource(aFilename); fProject.addSource(aFilename);
@ -359,7 +359,7 @@ begin
try for fname in Filenames do try for fname in Filenames do
if FileExists(fname) then if FileExists(fname) then
addFile(fname) addFile(fname)
else if DirectoryExists(fname) then else if fname.dirExists then
begin begin
lst.Clear; lst.Clear;
listFiles(lst, fname, true); listFiles(lst, fname, true);

View File

@ -951,7 +951,7 @@ procedure TCESynMemo.loadFromFile(const aFilename: string);
var var
ext: string; ext: string;
begin begin
ext := extractFileExt(aFilename); ext := aFilename.extractFileExt;
if not hasDlangSyntax(ext) then if not hasDlangSyntax(ext) then
Highlighter := TxtSyn; Highlighter := TxtSyn;
Lines.LoadFromFile(aFilename); Lines.LoadFromFile(aFilename);
@ -974,7 +974,7 @@ var
begin begin
Lines.SaveToFile(aFilename); Lines.SaveToFile(aFilename);
fFilename := aFilename; fFilename := aFilename;
ext := extractFileExt(aFilename); ext := aFilename.extractFileExt;
if hasDlangSyntax(ext) then if hasDlangSyntax(ext) then
Highlighter := fD2Highlighter; Highlighter := fD2Highlighter;
FileAge(fFilename, fFileDate); FileAge(fFilename, fFileDate);