allow to select the 'global' compiler for completion and move 'global' definition to the option page dedicated t the compiler paths

This commit is contained in:
Basile Burg 2020-01-19 06:39:23 +01:00
parent 6875764241
commit 1fbe967d76
3 changed files with 223 additions and 139 deletions

View File

@ -6,13 +6,12 @@ object CompilersPathsEditor: TCompilersPathsEditor
Caption = 'CompilersPathsEditor'
ClientHeight = 900
ClientWidth = 460
LCLVersion = '2.0.6.0'
object ScrollBox1: TScrollBox
Left = 0
Height = 900
Top = 0
Width = 460
HorzScrollBar.Page = 116
HorzScrollBar.Page = 243
VertScrollBar.Page = 898
Align = alClient
AutoSize = True
@ -21,21 +20,21 @@ object CompilersPathsEditor: TCompilersPathsEditor
TabOrder = 0
object grpDMD: TGroupBox
Left = 0
Height = 175
Top = 52
Height = 168
Top = 106
Width = 443
Align = alTop
AutoSize = True
Caption = 'DMD'
ClientHeight = 157
ClientHeight = 150
ClientWidth = 441
TabOrder = 0
object selDMDexe: TFileNameEdit
Left = 2
Height = 27
Hint = 'select the compiler'
Top = 23
Width = 435
Top = 21
Width = 437
FilterIndex = 0
HideDirectories = False
ButtonWidth = 23
@ -51,8 +50,8 @@ object CompilersPathsEditor: TCompilersPathsEditor
Left = 2
Height = 27
Hint = 'select the root of druntime sources'
Top = 75
Width = 435
Top = 71
Width = 437
ShowHidden = False
ButtonWidth = 23
NumGlyphs = 1
@ -67,8 +66,8 @@ object CompilersPathsEditor: TCompilersPathsEditor
Left = 2
Height = 27
Hint = 'select the root of phobos sources'
Top = 127
Width = 435
Top = 121
Width = 437
ShowHidden = False
ButtonWidth = 23
NumGlyphs = 1
@ -81,9 +80,9 @@ object CompilersPathsEditor: TCompilersPathsEditor
end
object StaticText1: TStaticText
Left = 0
Height = 21
Height = 19
Top = 0
Width = 439
Width = 441
Align = alTop
Alignment = taCenter
AutoSize = True
@ -92,9 +91,9 @@ object CompilersPathsEditor: TCompilersPathsEditor
end
object StaticText2: TStaticText
Left = 0
Height = 21
Top = 52
Width = 439
Height = 19
Top = 50
Width = 441
Align = alTop
Alignment = taCenter
AutoSize = True
@ -103,9 +102,9 @@ object CompilersPathsEditor: TCompilersPathsEditor
end
object StaticText3: TStaticText
Left = 0
Height = 21
Top = 104
Width = 439
Height = 19
Top = 100
Width = 441
Align = alTop
Alignment = taCenter
AutoSize = True
@ -115,21 +114,21 @@ object CompilersPathsEditor: TCompilersPathsEditor
end
object grpGDC: TGroupBox
Left = 0
Height = 175
Top = 227
Height = 168
Top = 274
Width = 443
Align = alTop
AutoSize = True
Caption = 'GDC'
ClientHeight = 157
ClientHeight = 150
ClientWidth = 441
TabOrder = 1
object selGDCexe: TFileNameEdit
Left = 2
Height = 27
Hint = 'select the compiler'
Top = 23
Width = 435
Top = 21
Width = 437
FilterIndex = 0
HideDirectories = False
ButtonWidth = 23
@ -145,8 +144,8 @@ object CompilersPathsEditor: TCompilersPathsEditor
Left = 2
Height = 27
Hint = 'select the root of druntime sources'
Top = 75
Width = 435
Top = 71
Width = 437
ShowHidden = False
ButtonWidth = 23
NumGlyphs = 1
@ -161,8 +160,8 @@ object CompilersPathsEditor: TCompilersPathsEditor
Left = 2
Height = 27
Hint = 'select the root of phobos sources'
Top = 127
Width = 435
Top = 121
Width = 437
ShowHidden = False
ButtonWidth = 23
NumGlyphs = 1
@ -175,9 +174,9 @@ object CompilersPathsEditor: TCompilersPathsEditor
end
object StaticText4: TStaticText
Left = 0
Height = 21
Height = 19
Top = 0
Width = 439
Width = 441
Align = alTop
Alignment = taCenter
AutoSize = True
@ -186,9 +185,9 @@ object CompilersPathsEditor: TCompilersPathsEditor
end
object StaticText5: TStaticText
Left = 0
Height = 21
Top = 52
Width = 439
Height = 19
Top = 50
Width = 441
Align = alTop
Alignment = taCenter
AutoSize = True
@ -197,9 +196,9 @@ object CompilersPathsEditor: TCompilersPathsEditor
end
object StaticText6: TStaticText
Left = 0
Height = 21
Top = 104
Width = 439
Height = 19
Top = 100
Width = 441
Align = alTop
Alignment = taCenter
AutoSize = True
@ -209,21 +208,21 @@ object CompilersPathsEditor: TCompilersPathsEditor
end
object grpLDC: TGroupBox
Left = 0
Height = 175
Top = 402
Height = 168
Top = 442
Width = 443
Align = alTop
AutoSize = True
Caption = 'LDC'
ClientHeight = 157
ClientHeight = 150
ClientWidth = 441
TabOrder = 2
object selLDCexe: TFileNameEdit
Left = 2
Height = 27
Hint = 'select the compiler'
Top = 23
Width = 435
Top = 21
Width = 437
FilterIndex = 0
HideDirectories = False
ButtonWidth = 23
@ -239,8 +238,8 @@ object CompilersPathsEditor: TCompilersPathsEditor
Left = 2
Height = 27
Hint = 'select the root of LDC runtime & phobos sources (can be a common folder)'
Top = 75
Width = 435
Top = 71
Width = 437
ShowHidden = False
ButtonWidth = 23
NumGlyphs = 1
@ -255,8 +254,8 @@ object CompilersPathsEditor: TCompilersPathsEditor
Left = 2
Height = 27
Hint = 'select the root of phobos sources (can be empty)'
Top = 127
Width = 435
Top = 121
Width = 437
ShowHidden = False
ButtonWidth = 23
NumGlyphs = 1
@ -269,9 +268,9 @@ object CompilersPathsEditor: TCompilersPathsEditor
end
object StaticText7: TStaticText
Left = 0
Height = 21
Height = 19
Top = 0
Width = 439
Width = 441
Align = alTop
Alignment = taCenter
AutoSize = True
@ -280,9 +279,9 @@ object CompilersPathsEditor: TCompilersPathsEditor
end
object StaticText8: TStaticText
Left = 0
Height = 21
Top = 52
Width = 439
Height = 19
Top = 50
Width = 441
Align = alTop
Alignment = taCenter
AutoSize = True
@ -291,9 +290,9 @@ object CompilersPathsEditor: TCompilersPathsEditor
end
object StaticText9: TStaticText
Left = 0
Height = 21
Top = 104
Width = 439
Height = 19
Top = 100
Width = 441
Align = alTop
Alignment = taCenter
AutoSize = True
@ -303,21 +302,21 @@ object CompilersPathsEditor: TCompilersPathsEditor
end
object grpUSER1: TGroupBox
Left = 0
Height = 175
Top = 577
Height = 168
Top = 610
Width = 443
Align = alTop
AutoSize = True
Caption = 'User 1'
ClientHeight = 157
ClientHeight = 150
ClientWidth = 441
TabOrder = 3
object selUSER1exe: TFileNameEdit
Left = 2
Height = 27
Hint = 'select the compiler'
Top = 23
Width = 435
Top = 21
Width = 437
FilterIndex = 0
HideDirectories = False
ButtonWidth = 23
@ -333,8 +332,8 @@ object CompilersPathsEditor: TCompilersPathsEditor
Left = 2
Height = 27
Hint = 'select the root of druntime sources'
Top = 75
Width = 435
Top = 71
Width = 437
ShowHidden = False
ButtonWidth = 23
NumGlyphs = 1
@ -349,8 +348,8 @@ object CompilersPathsEditor: TCompilersPathsEditor
Left = 2
Height = 27
Hint = 'select the root of phobos sources'
Top = 127
Width = 435
Top = 121
Width = 437
ShowHidden = False
ButtonWidth = 23
NumGlyphs = 1
@ -363,9 +362,9 @@ object CompilersPathsEditor: TCompilersPathsEditor
end
object StaticText10: TStaticText
Left = 0
Height = 21
Height = 19
Top = 0
Width = 439
Width = 441
Align = alTop
Alignment = taCenter
AutoSize = True
@ -374,9 +373,9 @@ object CompilersPathsEditor: TCompilersPathsEditor
end
object StaticText11: TStaticText
Left = 0
Height = 21
Top = 52
Width = 439
Height = 19
Top = 50
Width = 441
Align = alTop
Alignment = taCenter
AutoSize = True
@ -385,9 +384,9 @@ object CompilersPathsEditor: TCompilersPathsEditor
end
object StaticText12: TStaticText
Left = 0
Height = 21
Top = 104
Width = 439
Height = 19
Top = 100
Width = 441
Align = alTop
Alignment = taCenter
AutoSize = True
@ -397,21 +396,21 @@ object CompilersPathsEditor: TCompilersPathsEditor
end
object grpUSER2: TGroupBox
Left = 0
Height = 175
Top = 752
Height = 168
Top = 778
Width = 443
Align = alTop
AutoSize = True
Caption = 'User 2'
ClientHeight = 157
ClientHeight = 150
ClientWidth = 441
TabOrder = 4
object selUSER2exe: TFileNameEdit
Left = 2
Height = 27
Hint = 'select the compiler'
Top = 23
Width = 435
Top = 21
Width = 437
FilterIndex = 0
HideDirectories = False
ButtonWidth = 23
@ -427,8 +426,8 @@ object CompilersPathsEditor: TCompilersPathsEditor
Left = 2
Height = 27
Hint = 'select the root of druntime sources'
Top = 75
Width = 435
Top = 71
Width = 437
ShowHidden = False
ButtonWidth = 23
NumGlyphs = 1
@ -443,8 +442,8 @@ object CompilersPathsEditor: TCompilersPathsEditor
Left = 2
Height = 27
Hint = 'select the root of phobos sources'
Top = 127
Width = 435
Top = 121
Width = 437
ShowHidden = False
ButtonWidth = 23
NumGlyphs = 1
@ -457,9 +456,9 @@ object CompilersPathsEditor: TCompilersPathsEditor
end
object StaticText13: TStaticText
Left = 0
Height = 21
Height = 19
Top = 0
Width = 439
Width = 441
Align = alTop
Alignment = taCenter
AutoSize = True
@ -468,9 +467,9 @@ object CompilersPathsEditor: TCompilersPathsEditor
end
object StaticText14: TStaticText
Left = 0
Height = 21
Top = 52
Width = 439
Height = 19
Top = 50
Width = 441
Align = alTop
Alignment = taCenter
AutoSize = True
@ -479,9 +478,9 @@ object CompilersPathsEditor: TCompilersPathsEditor
end
object StaticText15: TStaticText
Left = 0
Height = 21
Top = 104
Width = 439
Height = 19
Top = 100
Width = 441
Align = alTop
Alignment = taCenter
AutoSize = True
@ -491,13 +490,13 @@ object CompilersPathsEditor: TCompilersPathsEditor
end
object GroupBox6: TGroupBox
Left = 0
Height = 52
Height = 51
Top = 0
Width = 443
Align = alTop
AutoSize = True
Caption = 'Default compiler for completion'
ClientHeight = 34
Caption = 'Compiler paths used for intellisense'
ClientHeight = 33
ClientWidth = 441
TabOrder = 5
object selDefault: TComboBox
@ -505,23 +504,36 @@ object CompilersPathsEditor: TCompilersPathsEditor
Height = 25
Hint = 'select which the compiler for which the library paths are used by the completion daemon'
Top = 4
Width = 431
Width = 433
Align = alClient
BorderSpacing.Around = 4
ItemHeight = 0
Style = csDropDownList
TabOrder = 0
end
end
object GroupBox7: TGroupBox
Left = 0
Height = 55
Top = 51
Width = 443
Align = alTop
AutoSize = True
Caption = 'Compiler selected as "global"'
ClientHeight = 37
ClientWidth = 441
TabOrder = 6
object selGlobal: TComboBox
Left = 4
Height = 29
Hint = 'select which the compiler for which the library paths are used by the completion daemon'
Top = 4
Width = 433
Align = alClient
BorderSpacing.Around = 4
ItemHeight = 0
ItemIndex = 0
Items.Strings = (
'DMD'
'GDC'
'GDMD'
'LDC'
'LDMD'
'USER 1'
'USER 2'
)
Style = csDropDownList
TabOrder = 0
Text = 'DMD'
end
end
end

View File

@ -14,7 +14,7 @@ type
TCompilersPaths = class(TWritableLfmTextComponent)
strict private
fDefaultCompiler: DCompiler;
fPathsForCompletion: DCompiler;
fDmdExeName: string;
fDmdRuntimePath: string;
fDmdPhobosPath: string;
@ -32,7 +32,9 @@ type
fUser2PhobosPath: string;
fModified: boolean;
fWouldNeedRestart: boolean;
procedure setDefaultCompiler(value: DCompiler);
fDefinedAsGlobal: DCompiler;
procedure setDefinedAsGlobal(value: DCompiler);
procedure setPathsForCompletion(value: DCompiler);
procedure setDmdExeName(const value: string);
procedure setDmdRuntimePath(const value: string);
procedure setDmdPhobosPath(const value: string);
@ -53,7 +55,8 @@ type
protected
procedure afterLoad; override;
published
property defaultCompiler: DCompiler read fDefaultCompiler write setDefaultCompiler;
property definedAsGlobal: DCompiler read fDefinedAsGlobal write setDefinedAsGlobal;
property pathsForCompletion: DCompiler read fPathsForCompletion write setPathsForCompletion;
property DmdExeName: string read fDmdExeName write setDmdExeName;
property DmdRuntimePath: string read fDmdRuntimePath write setDmdRuntimePath;
property DmdPhobosPath: string read fDmdPhobosPath write setDmdPhobosPath;
@ -78,7 +81,9 @@ type
{ TCompilersPathsEditor }
TCompilersPathsEditor = class(TForm, IEditableOptions, ICompilerSelector, IProjectObserver)
GroupBox7: TGroupBox;
selDefault: TComboBox;
selGlobal: TComboBox;
selDMDrt: TDirectoryEdit;
selUSER2std: TDirectoryEdit;
selDMDstd: TDirectoryEdit;
@ -128,6 +133,7 @@ type
procedure selectedRt(sender: TObject; var value: string);
procedure selectedStd(sender: TObject; var value: string);
procedure selectedDefault(sender: TObject);
procedure selectedGlobal(sender: TObject);
procedure autoDetectDMD;
procedure autoDetectGDC;
procedure autoDetectLDC;
@ -156,8 +162,8 @@ type
destructor destroy; override;
end;
var
globalCompiler: DCompiler;
//var
// globalCompiler: DCompiler;
implementation
{$R *.lfm}
@ -175,8 +181,64 @@ const
constructor TCompilersPathsEditor.create(aOwner: TComponent);
var
fname: string;
dcomp: DCompiler;
begin
inherited;
selDefault.Items.BeginUpdate;
selGlobal.Items.BeginUpdate;
try for dcomp in DCompiler do
begin
case dcomp of
dmd:
begin
selDefault.Items.Add('DMD');
selGlobal.Items.Add('DMD');
end;
gdc:
begin
selDefault.Items.Add('GDC');
selGlobal.Items.Add('GDC');
end;
gdmd:
begin
selDefault.Items.Add('GDMD (same paths as GDC)');
selGlobal.Items.Add('GDMD (same paths as GDC)');
end;
ldc:
begin
selDefault.Items.Add('LDC');
selGlobal.Items.Add('LDC');
end;
ldmd:
begin
selDefault.Items.Add('GDMD (same paths as LDC)');
selGlobal.Items.Add('GDMD (same paths as LDC)');
end;
user1:
begin
selDefault.Items.Add('USER1');
selGlobal.Items.Add('USER1');
end;
user2:
begin
selDefault.Items.Add('USER2');
selGlobal.Items.Add('USER2');
end;
global:
begin
selDefault.Items.Add('GLOBAL (as defined in the options)');
// 'global' must be everything but 'global'
selGlobal.Items.Add('<N/A>');
end;
else raise Exception.create('missing DCompiler value in a case of');
end;
end;
finally
selDefault.Items.EndUpdate;
selGlobal.Items.EndUpdate;
end;
fPaths:= TCompilersPaths.Create(self);
fPathsBackup:= TCompilersPaths.Create(self);
@ -229,6 +291,7 @@ begin
selUSER2std.OnEditingDone:= @editedStd;
selDefault.OnSelect:= @selectedDefault;
selGlobal.OnSelect:= @selectedGlobal;
EntitiesConnector.addSingleService(self);
EntitiesConnector.addObserver(self);
@ -243,9 +306,9 @@ end;
procedure TCompilersPaths.checkIfGlobalIsGlobal;
begin
if globalCompiler = DCompiler.global then
if fDefinedAsGlobal = DCompiler.global then
begin
globalCompiler := low(DCompiler);
fDefinedAsGlobal := low(DCompiler);
raise Exception.Create('global compiler should not be set to DCompiler.global');
end;
end;
@ -257,7 +320,7 @@ begin
if source is TCompilersPaths then
begin
src := TCompilersPaths(source);
DefaultCompiler := src.fDefaultCompiler;
pathsForCompletion := src.fPathsForCompletion;
DmdExeName := src.fDmdExeName;
DmdRuntimePath := src.fDmdRuntimePath;
DmdPhobosPath := src.fDmdPhobosPath;
@ -277,15 +340,22 @@ begin
else inherited;
end;
procedure TCompilersPaths.setDefaultCompiler(value: Dcompiler);
procedure TCompilersPaths.setPathsForCompletion(value: Dcompiler);
begin
if fDefaultCompiler = value then
if fPathsForCompletion = value then
exit;
fDefaultCompiler:=value;
fPathsForCompletion:=value;
fWouldNeedRestart := true;
fModified:=true;
end;
procedure TCompilersPaths.setDefinedAsGlobal(value: DCompiler);
begin
if value = DCompiler.global then
value := low(DCompiler);
fDefinedAsGlobal := value;
end;
procedure TCompilersPaths.setDmdExeName(const value: string);
begin
if fDmdExeName = value then
@ -300,7 +370,7 @@ begin
exit;
fDmdRuntimePath:=value;
fModified:=true;
if fDefaultCompiler = dmd then
if fPathsForCompletion = dmd then
fWouldNeedRestart := true;
end;
@ -310,7 +380,7 @@ begin
exit;
fDmdPhobosPath:=value;
fModified:=true;
if fDefaultCompiler = dmd then
if fPathsForCompletion = dmd then
fWouldNeedRestart := true;
end;
@ -328,7 +398,7 @@ begin
exit;
fGdcRuntimePath:=value;
fModified:=true;
if fDefaultCompiler in [gdc,gdmd] then
if fPathsForCompletion in [gdc,gdmd] then
fWouldNeedRestart := true;
end;
@ -338,7 +408,7 @@ begin
exit;
fGdcPhobosPath:=value;
fModified:=true;
if fDefaultCompiler in [gdc,gdmd] then
if fPathsForCompletion in [gdc,gdmd] then
fWouldNeedRestart := true;
end;
@ -356,7 +426,7 @@ begin
exit;
fLdcRuntimePath:=value;
fModified:=true;
if fDefaultCompiler in [ldc,ldmd] then
if fPathsForCompletion in [ldc,ldmd] then
fWouldNeedRestart := true;
end;
@ -366,7 +436,7 @@ begin
exit;
fLdcPhobosPath:=value;
fModified:=true;
if fDefaultCompiler in [ldc,ldmd] then
if fPathsForCompletion in [ldc,ldmd] then
fWouldNeedRestart := true;
end;
@ -384,7 +454,7 @@ begin
exit;
fUser1RuntimePath:=value;
fModified:=true;
if fDefaultCompiler = user1 then
if fPathsForCompletion = user1 then
fWouldNeedRestart := true;
end;
@ -394,7 +464,7 @@ begin
exit;
fUser1PhobosPath:=value;
fModified:=true;
if fDefaultCompiler = user1 then
if fPathsForCompletion = user1 then
fWouldNeedRestart := true;
end;
@ -412,7 +482,7 @@ begin
exit;
fUser2RuntimePath:=value;
fModified:=true;
if fDefaultCompiler = user2 then
if fPathsForCompletion = user2 then
fWouldNeedRestart := true;
end;
@ -422,7 +492,7 @@ begin
exit;
fUser2PhobosPath:=value;
fModified:=true;
if fDefaultCompiler = user2 then
if fPathsForCompletion = user2 then
fWouldNeedRestart := true;
end;
@ -538,7 +608,7 @@ begin
DCompiler.global:
begin
fPaths.checkIfGlobalIsGlobal;
exit(isCompilerValid(globalCompiler));
exit(isCompilerValid(fPaths.definedAsGlobal));
end;
end;
end;
@ -557,7 +627,7 @@ begin
DCompiler.global:
begin
checkIfGlobalIsGlobal;
exit(getCompilerPath(globalCompiler));
exit(getCompilerPath(fPaths.definedAsGlobal));
end;
end;
end;
@ -580,7 +650,7 @@ begin
DCompiler.user2:
begin tryAdd(User2RuntimePath); tryAdd(User2PhobosPath); end;
DCompiler.global:
begin checkIfGlobalIsGlobal; getCompilerImports(globalCompiler, paths); end;
begin checkIfGlobalIsGlobal; getCompilerImports(fPaths.definedAsGlobal, paths); end;
end;
end;
{$ENDREGION}
@ -592,7 +662,7 @@ var
begin
imprt := TStringList.Create;
try
getCompilerImports(fPaths.defaultCompiler, imprt);
getCompilerImports(fPaths.pathsForCompletion, imprt);
DcdWrapper.addImportFolders(imprt);
finally
imprt.free;
@ -623,7 +693,8 @@ begin
selUSER2rt.Directory := User2RuntimePath;
selUSER2std.Directory := User2PhobosPath;
selDefault.ItemIndex := integer(defaultCompiler);
selDefault.ItemIndex := integer(pathsForCompletion);
selGlobal.ItemIndex := integer(definedAsGlobal);
end;
end;
@ -751,7 +822,17 @@ end;
procedure TCompilersPathsEditor.selectedDefault(sender: TObject);
begin
fPaths.defaultCompiler:= DCompiler(selDefault.ItemIndex);
fPaths.pathsForCompletion:= DCompiler(selDefault.ItemIndex);
end;
procedure TCompilersPathsEditor.selectedGlobal(sender: TObject);
var
v: DCompiler;
begin
v := DCompiler(selGlobal.ItemIndex);
if v = DCompiler.global then
v := DCompiler.dmd;
fPaths.definedAsGlobal := v;
end;
procedure TCompilersPathsEditor.autoDetectDMD;

View File

@ -626,7 +626,6 @@ type
procedure setAdditionalPATH(const value: string);
function getNativeProjecCompiler: DCompiler;
procedure setNativeProjecCompiler(value: DCompiler);
procedure setGlobalCompiler(value: DCompiler);
procedure setSplitterScsrollSpeed(value: byte);
published
property additionalPATH: string read getAdditionalPATH write setAdditionalPath;
@ -645,7 +644,7 @@ type
property flatLook: boolean read fFlatLook write fFlatLook;
property splitterScrollSpeed: byte read fSplitterScrollSpeed write setSplitterScsrollSpeed;
property showBuildDuration: boolean read fShowBuildDuration write fShowBuildDuration default false;
property globalCompiler: DCompiler read fGlobalCompiler write setGLobalCompiler;
property globalCompiler: DCompiler write fGlobalCompiler; deprecated;
// property toolBarScaling: TToolBarScaling read fToolBarScaling write fToolBarScaling stored false;
// published for IEditableOptions but stored by DCD wrapper since it reloads before MainForm
property dcdPort: word read fDcdPort write fDcdPort stored false;
@ -866,14 +865,6 @@ begin
u_ceproject.setCEProjectCompiler(value);
end;
procedure TApplicationOptionsBase.setGlobalCompiler(value: DCompiler);
begin
if value = DCompiler.global then
value := low(DCompiler);
fGlobalCompiler := value;
u_compilers.globalCompiler := value;
end;
procedure TApplicationOptionsBase.setSplitterScsrollSpeed(value: byte);
begin
if value < 1 then