mirror of
https://gitlab.com/freepascal.org/lazarus/lazarus.git
synced 2025-12-05 09:57:04 +01:00
ide: initial implementation of automatic removing of empty published form/frame/datamodule methods
git-svn-id: trunk@17793 -
This commit is contained in:
parent
98dbf8f94c
commit
8530d2cdc8
@ -450,7 +450,8 @@ type
|
||||
fAutoDelayInMSec: Integer;
|
||||
fCodeTemplateFileName: String;
|
||||
fCTemplIndentToTokenStart: Boolean;
|
||||
|
||||
FAutoRemoveEmptyMethods: Boolean;
|
||||
|
||||
// Code Folding
|
||||
FUseCodeFolding: Boolean;
|
||||
FCFDividerDrawLevel: Integer;
|
||||
@ -568,6 +569,8 @@ type
|
||||
read fCodeTemplateFileName write fCodeTemplateFileName;
|
||||
property CodeTemplateIndentToTokenStart: Boolean
|
||||
read fCTemplIndentToTokenStart write fCTemplIndentToTokenStart;
|
||||
property AutoRemoveEmptyMethods: Boolean read FAutoRemoveEmptyMethods
|
||||
write FAutoRemoveEmptyMethods default False;
|
||||
|
||||
// Code Folding
|
||||
property UseCodeFolding: Boolean
|
||||
@ -1526,6 +1529,8 @@ begin
|
||||
fCTemplIndentToTokenStart :=
|
||||
XMLConfig.GetValue(
|
||||
'EditorOptions/CodeTools/CodeTemplateIndentToTokenStart/Value', False);
|
||||
fAutoRemoveEmptyMethods :=
|
||||
XMLConfig.GetValue('EditorOptions/CodeTools/AutoRemoveEmptyMethods', False);
|
||||
|
||||
// Code Folding
|
||||
FUseCodeFolding :=
|
||||
@ -1660,6 +1665,9 @@ begin
|
||||
XMLConfig.SetDeleteValue(
|
||||
'EditorOptions/CodeTools/CodeTemplateIndentToTokenStart/Value'
|
||||
, fCTemplIndentToTokenStart, False);
|
||||
XMLConfig.SetDeleteValue(
|
||||
'EditorOptions/CodeTools/AutoRemoveEmptyMethods'
|
||||
, fAutoRemoveEmptyMethods, False);
|
||||
|
||||
// Code Folding
|
||||
XMLConfig.SetDeleteValue('EditorOptions/CodeFolding/UseCodeFolding',
|
||||
|
||||
@ -1,44 +1,50 @@
|
||||
object EditorCodetoolsOptionsFrame: TEditorCodetoolsOptionsFrame
|
||||
inherited EditorCodetoolsOptionsFrame: TEditorCodetoolsOptionsFrame
|
||||
Height = 440
|
||||
Width = 496
|
||||
ClientHeight = 440
|
||||
ClientWidth = 496
|
||||
TabOrder = 0
|
||||
Visible = False
|
||||
DesignLeft = 436
|
||||
DesignTop = 200
|
||||
object AutomaticFeaturesGroupBox: TGroupBox
|
||||
DesignLeft = 520
|
||||
DesignTop = 289
|
||||
object AutomaticFeaturesGroupBox: TGroupBox[0]
|
||||
AnchorSideLeft.Control = Owner
|
||||
AnchorSideTop.Control = Owner
|
||||
AnchorSideRight.Control = Owner
|
||||
AnchorSideRight.Side = asrBottom
|
||||
AnchorSideBottom.Control = Owner
|
||||
AnchorSideBottom.Side = asrBottom
|
||||
Left = 0
|
||||
Height = 440
|
||||
Top = 0
|
||||
Width = 496
|
||||
Anchors = [akTop, akLeft, akRight, akBottom]
|
||||
Caption = 'AutomaticFeaturesGroupBox'
|
||||
ClientHeight = 422
|
||||
ClientWidth = 492
|
||||
Ctl3D = False
|
||||
TabOrder = 0
|
||||
object AutoDelayLabel: TLabel
|
||||
AnchorSideLeft.Control = AutomaticFeaturesGroupBox
|
||||
AnchorSideTop.Control = AutoDelayTrackBar
|
||||
AnchorSideTop.Side = asrBottom
|
||||
Left = 6
|
||||
Height = 14
|
||||
Top = 176
|
||||
Width = 480
|
||||
Align = alTop
|
||||
Top = 201
|
||||
Width = 76
|
||||
BorderSpacing.Top = 24
|
||||
BorderSpacing.Around = 6
|
||||
Caption = 'AutoDelayLabel'
|
||||
ParentColor = False
|
||||
end
|
||||
object AutoDelayMinLabel: TLabel
|
||||
AnchorSideLeft.Control = AutomaticFeaturesGroupBox
|
||||
AnchorSideTop.Control = AutoDelayTrackBar
|
||||
AnchorSideTop.Side = asrBottom
|
||||
Left = 6
|
||||
Height = 14
|
||||
Top = 148
|
||||
Top = 177
|
||||
Width = 92
|
||||
BorderSpacing.Left = 6
|
||||
BorderSpacing.Top = 2
|
||||
Caption = 'AutoDelayMinLabel'
|
||||
ParentColor = False
|
||||
@ -46,72 +52,96 @@ object EditorCodetoolsOptionsFrame: TEditorCodetoolsOptionsFrame
|
||||
object AutoDelayMaxLabel: TLabel
|
||||
AnchorSideTop.Control = AutoDelayTrackBar
|
||||
AnchorSideTop.Side = asrBottom
|
||||
Left = 358
|
||||
AnchorSideRight.Control = AutomaticFeaturesGroupBox
|
||||
AnchorSideRight.Side = asrBottom
|
||||
Left = 390
|
||||
Height = 14
|
||||
Top = 148
|
||||
Top = 177
|
||||
Width = 96
|
||||
Alignment = taRightJustify
|
||||
Anchors = [akTop, akRight]
|
||||
BorderSpacing.Top = 2
|
||||
BorderSpacing.Right = 6
|
||||
Caption = 'AutoDelayMaxLabel'
|
||||
ParentColor = False
|
||||
end
|
||||
object AutoIdentifierCompletionCheckBox: TCheckBox
|
||||
AnchorSideLeft.Control = AutomaticFeaturesGroupBox
|
||||
AnchorSideTop.Control = AutomaticFeaturesGroupBox
|
||||
Left = 6
|
||||
Height = 19
|
||||
Top = 6
|
||||
Width = 480
|
||||
Align = alTop
|
||||
Width = 193
|
||||
BorderSpacing.Around = 6
|
||||
Caption = 'AutoIdentifierCompletionCheckBox'
|
||||
TabOrder = 0
|
||||
end
|
||||
object AutoCodeParametersCheckBox: TCheckBox
|
||||
AnchorSideLeft.Control = AutomaticFeaturesGroupBox
|
||||
AnchorSideTop.Control = AutoToolTipSymbToolsCheckBox
|
||||
AnchorSideTop.Side = asrBottom
|
||||
Left = 6
|
||||
Height = 19
|
||||
Top = 56
|
||||
Width = 480
|
||||
Align = alTop
|
||||
Top = 81
|
||||
Width = 176
|
||||
BorderSpacing.Around = 6
|
||||
Caption = 'AutoCodeParametersCheckBox'
|
||||
Enabled = False
|
||||
TabOrder = 1
|
||||
end
|
||||
object AutoToolTipExprEvalCheckBox: TCheckBox
|
||||
AnchorSideLeft.Control = AutomaticFeaturesGroupBox
|
||||
AnchorSideTop.Control = AutoCodeParametersCheckBox
|
||||
AnchorSideTop.Side = asrBottom
|
||||
Left = 6
|
||||
Height = 19
|
||||
Top = 81
|
||||
Width = 480
|
||||
Align = alTop
|
||||
Top = 106
|
||||
Width = 172
|
||||
BorderSpacing.Around = 6
|
||||
Caption = 'AutoToolTipExprEvalCheckBox'
|
||||
TabOrder = 2
|
||||
end
|
||||
object AutoToolTipSymbToolsCheckBox: TCheckBox
|
||||
AnchorSideLeft.Control = AutomaticFeaturesGroupBox
|
||||
AnchorSideTop.Control = AutoRemoveEmptyMethodsOnSave
|
||||
AnchorSideTop.Side = asrBottom
|
||||
Left = 6
|
||||
Height = 19
|
||||
Top = 31
|
||||
Width = 480
|
||||
Align = alTop
|
||||
Top = 56
|
||||
Width = 181
|
||||
BorderSpacing.Around = 6
|
||||
Caption = 'AutoToolTipSymbToolsCheckBox'
|
||||
TabOrder = 3
|
||||
end
|
||||
object AutoDelayTrackBar: TTrackBar
|
||||
AnchorSideLeft.Control = AutomaticFeaturesGroupBox
|
||||
AnchorSideTop.Control = AutoToolTipExprEvalCheckBox
|
||||
AnchorSideTop.Side = asrBottom
|
||||
AnchorSideRight.Control = AutomaticFeaturesGroupBox
|
||||
AnchorSideRight.Side = asrBottom
|
||||
Left = 6
|
||||
Height = 40
|
||||
Top = 106
|
||||
Top = 131
|
||||
Width = 480
|
||||
Frequency = 250
|
||||
Max = 4000
|
||||
Min = 500
|
||||
Position = 500
|
||||
ScalePos = trTop
|
||||
Align = alTop
|
||||
BorderSpacing.Left = 6
|
||||
BorderSpacing.Top = 6
|
||||
BorderSpacing.Right = 6
|
||||
BorderSpacing.Around = 6
|
||||
Ctl3D = False
|
||||
TabOrder = 4
|
||||
end
|
||||
object AutoRemoveEmptyMethodsOnSave: TCheckBox
|
||||
AnchorSideLeft.Control = AutomaticFeaturesGroupBox
|
||||
AnchorSideTop.Control = AutoIdentifierCompletionCheckBox
|
||||
AnchorSideTop.Side = asrBottom
|
||||
Left = 6
|
||||
Height = 19
|
||||
Top = 31
|
||||
Width = 197
|
||||
BorderSpacing.Around = 6
|
||||
Caption = 'AutoRemoveEmptyMethodsOnSave'
|
||||
TabOrder = 5
|
||||
end
|
||||
end
|
||||
end
|
||||
|
||||
@ -1,40 +1,59 @@
|
||||
{ This is an automatically generated lazarus resource file }
|
||||
|
||||
LazarusResources.Add('TEditorCodetoolsOptionsFrame','FORMDATA',[
|
||||
'TPF0'#28'TEditorCodetoolsOptionsFrame'#27'EditorCodetoolsOptionsFrame'#6'Hei'
|
||||
+'ght'#3#184#1#5'Width'#3#240#1#12'ClientHeight'#3#184#1#11'ClientWidth'#3#240
|
||||
+#1#8'TabOrder'#2#0#7'Visible'#8#10'DesignLeft'#3#180#1#9'DesignTop'#3#200#0#0
|
||||
+#9'TGroupBox'#25'AutomaticFeaturesGroupBox'#22'AnchorSideLeft.Control'#7#5'O'
|
||||
+'wner'#21'AnchorSideTop.Control'#7#5'Owner'#23'AnchorSideRight.Control'#7#5
|
||||
+'Owner'#20'AnchorSideRight.Side'#7#9'asrBottom'#24'AnchorSideBottom.Control'
|
||||
+#7#5'Owner'#21'AnchorSideBottom.Side'#7#9'asrBottom'#6'Height'#3#184#1#5'Wid'
|
||||
+'th'#3#240#1#7'Anchors'#11#5'akTop'#6'akLeft'#7'akRight'#8'akBottom'#0#7'Cap'
|
||||
+'tion'#6#25'AutomaticFeaturesGroupBox'#12'ClientHeight'#3#166#1#11'ClientWid'
|
||||
+'th'#3#236#1#8'TabOrder'#2#0#0#6'TLabel'#14'AutoDelayLabel'#4'Left'#2#6#6'He'
|
||||
+'ight'#2#14#3'Top'#3#176#0#5'Width'#3#224#1#5'Align'#7#5'alTop'#17'BorderSpa'
|
||||
+'cing.Top'#2#24#20'BorderSpacing.Around'#2#6#7'Caption'#6#14'AutoDelayLabel'
|
||||
+#11'ParentColor'#8#0#0#6'TLabel'#17'AutoDelayMinLabel'#21'AnchorSideTop.Cont'
|
||||
+'rol'#7#17'AutoDelayTrackBar'#18'AnchorSideTop.Side'#7#9'asrBottom'#4'Left'#2
|
||||
+#6#6'Height'#2#14#3'Top'#3#148#0#5'Width'#2'\'#17'BorderSpacing.Top'#2#2#7'C'
|
||||
+'aption'#6#17'AutoDelayMinLabel'#11'ParentColor'#8#0#0#6'TLabel'#17'AutoDela'
|
||||
+'yMaxLabel'#21'AnchorSideTop.Control'#7#17'AutoDelayTrackBar'#18'AnchorSideT'
|
||||
+'op.Side'#7#9'asrBottom'#4'Left'#3'f'#1#6'Height'#2#14#3'Top'#3#148#0#5'Widt'
|
||||
+'h'#2'`'#9'Alignment'#7#14'taRightJustify'#7'Anchors'#11#5'akTop'#7'akRight'
|
||||
+#0#17'BorderSpacing.Top'#2#2#7'Caption'#6#17'AutoDelayMaxLabel'#11'ParentCol'
|
||||
+'or'#8#0#0#9'TCheckBox AutoIdentifierCompletionCheckBox'#4'Left'#2#6#6'Heigh'
|
||||
+'t'#2#19#3'Top'#2#6#5'Width'#3#224#1#5'Align'#7#5'alTop'#20'BorderSpacing.Ar'
|
||||
+'ound'#2#6#7'Caption'#6' AutoIdentifierCompletionCheckBox'#8'TabOrder'#2#0#0
|
||||
+#0#9'TCheckBox'#26'AutoCodeParametersCheckBox'#4'Left'#2#6#6'Height'#2#19#3
|
||||
+'Top'#2'8'#5'Width'#3#224#1#5'Align'#7#5'alTop'#20'BorderSpacing.Around'#2#6
|
||||
+#7'Caption'#6#26'AutoCodeParametersCheckBox'#7'Enabled'#8#8'TabOrder'#2#1#0#0
|
||||
+#9'TCheckBox'#27'AutoToolTipExprEvalCheckBox'#4'Left'#2#6#6'Height'#2#19#3'T'
|
||||
+'op'#2'Q'#5'Width'#3#224#1#5'Align'#7#5'alTop'#20'BorderSpacing.Around'#2#6#7
|
||||
+'Caption'#6#27'AutoToolTipExprEvalCheckBox'#8'TabOrder'#2#2#0#0#9'TCheckBox'
|
||||
+#28'AutoToolTipSymbToolsCheckBox'#4'Left'#2#6#6'Height'#2#19#3'Top'#2#31#5'W'
|
||||
+'idth'#3#224#1#5'Align'#7#5'alTop'#20'BorderSpacing.Around'#2#6#7'Caption'#6
|
||||
+#28'AutoToolTipSymbToolsCheckBox'#8'TabOrder'#2#3#0#0#9'TTrackBar'#17'AutoDe'
|
||||
+'layTrackBar'#4'Left'#2#6#6'Height'#2'('#3'Top'#2'j'#5'Width'#3#224#1#9'Freq'
|
||||
+'uency'#3#250#0#3'Max'#3#160#15#3'Min'#3#244#1#8'Position'#3#244#1#8'ScalePo'
|
||||
+'s'#7#5'trTop'#5'Align'#7#5'alTop'#18'BorderSpacing.Left'#2#6#17'BorderSpaci'
|
||||
+'ng.Top'#2#6#19'BorderSpacing.Right'#2#6#8'TabOrder'#2#4#0#0#0#0
|
||||
'TPF0'#241#28'TEditorCodetoolsOptionsFrame'#27'EditorCodetoolsOptionsFrame'#6
|
||||
+'Height'#3#184#1#5'Width'#3#240#1#12'ClientHeight'#3#184#1#11'ClientWidth'#3
|
||||
+#240#1#7'Visible'#8#10'DesignLeft'#3#8#2#9'DesignTop'#3'!'#1#0#242#2#0#9'TGr'
|
||||
+'oupBox'#25'AutomaticFeaturesGroupBox'#22'AnchorSideLeft.Control'#7#5'Owner'
|
||||
+#21'AnchorSideTop.Control'#7#5'Owner'#23'AnchorSideRight.Control'#7#5'Owner'
|
||||
+#20'AnchorSideRight.Side'#7#9'asrBottom'#24'AnchorSideBottom.Control'#7#5'Ow'
|
||||
+'ner'#21'AnchorSideBottom.Side'#7#9'asrBottom'#4'Left'#2#0#6'Height'#3#184#1
|
||||
+#3'Top'#2#0#5'Width'#3#240#1#7'Anchors'#11#5'akTop'#6'akLeft'#7'akRight'#8'a'
|
||||
+'kBottom'#0#7'Caption'#6#25'AutomaticFeaturesGroupBox'#12'ClientHeight'#3#166
|
||||
+#1#11'ClientWidth'#3#236#1#5'Ctl3D'#8#8'TabOrder'#2#0#0#6'TLabel'#14'AutoDel'
|
||||
+'ayLabel'#22'AnchorSideLeft.Control'#7#25'AutomaticFeaturesGroupBox'#21'Anch'
|
||||
+'orSideTop.Control'#7#17'AutoDelayTrackBar'#18'AnchorSideTop.Side'#7#9'asrBo'
|
||||
+'ttom'#4'Left'#2#6#6'Height'#2#14#3'Top'#3#201#0#5'Width'#2'L'#17'BorderSpac'
|
||||
+'ing.Top'#2#24#20'BorderSpacing.Around'#2#6#7'Caption'#6#14'AutoDelayLabel'
|
||||
+#11'ParentColor'#8#0#0#6'TLabel'#17'AutoDelayMinLabel'#22'AnchorSideLeft.Con'
|
||||
+'trol'#7#25'AutomaticFeaturesGroupBox'#21'AnchorSideTop.Control'#7#17'AutoDe'
|
||||
+'layTrackBar'#18'AnchorSideTop.Side'#7#9'asrBottom'#4'Left'#2#6#6'Height'#2
|
||||
+#14#3'Top'#3#177#0#5'Width'#2'\'#18'BorderSpacing.Left'#2#6#17'BorderSpacing'
|
||||
+'.Top'#2#2#7'Caption'#6#17'AutoDelayMinLabel'#11'ParentColor'#8#0#0#6'TLabel'
|
||||
+#17'AutoDelayMaxLabel'#21'AnchorSideTop.Control'#7#17'AutoDelayTrackBar'#18
|
||||
+'AnchorSideTop.Side'#7#9'asrBottom'#23'AnchorSideRight.Control'#7#25'Automat'
|
||||
+'icFeaturesGroupBox'#20'AnchorSideRight.Side'#7#9'asrBottom'#4'Left'#3#134#1
|
||||
+#6'Height'#2#14#3'Top'#3#177#0#5'Width'#2'`'#9'Alignment'#7#14'taRightJustif'
|
||||
+'y'#7'Anchors'#11#5'akTop'#7'akRight'#0#17'BorderSpacing.Top'#2#2#19'BorderS'
|
||||
+'pacing.Right'#2#6#7'Caption'#6#17'AutoDelayMaxLabel'#11'ParentColor'#8#0#0#9
|
||||
+'TCheckBox AutoIdentifierCompletionCheckBox'#22'AnchorSideLeft.Control'#7#25
|
||||
+'AutomaticFeaturesGroupBox'#21'AnchorSideTop.Control'#7#25'AutomaticFeatures'
|
||||
+'GroupBox'#4'Left'#2#6#6'Height'#2#19#3'Top'#2#6#5'Width'#3#193#0#20'BorderS'
|
||||
+'pacing.Around'#2#6#7'Caption'#6' AutoIdentifierCompletionCheckBox'#8'TabOrd'
|
||||
+'er'#2#0#0#0#9'TCheckBox'#26'AutoCodeParametersCheckBox'#22'AnchorSideLeft.C'
|
||||
+'ontrol'#7#25'AutomaticFeaturesGroupBox'#21'AnchorSideTop.Control'#7#28'Auto'
|
||||
+'ToolTipSymbToolsCheckBox'#18'AnchorSideTop.Side'#7#9'asrBottom'#4'Left'#2#6
|
||||
+#6'Height'#2#19#3'Top'#2'Q'#5'Width'#3#176#0#20'BorderSpacing.Around'#2#6#7
|
||||
+'Caption'#6#26'AutoCodeParametersCheckBox'#7'Enabled'#8#8'TabOrder'#2#1#0#0#9
|
||||
+'TCheckBox'#27'AutoToolTipExprEvalCheckBox'#22'AnchorSideLeft.Control'#7#25
|
||||
+'AutomaticFeaturesGroupBox'#21'AnchorSideTop.Control'#7#26'AutoCodeParameter'
|
||||
+'sCheckBox'#18'AnchorSideTop.Side'#7#9'asrBottom'#4'Left'#2#6#6'Height'#2#19
|
||||
+#3'Top'#2'j'#5'Width'#3#172#0#20'BorderSpacing.Around'#2#6#7'Caption'#6#27'A'
|
||||
+'utoToolTipExprEvalCheckBox'#8'TabOrder'#2#2#0#0#9'TCheckBox'#28'AutoToolTip'
|
||||
+'SymbToolsCheckBox'#22'AnchorSideLeft.Control'#7#25'AutomaticFeaturesGroupBo'
|
||||
+'x'#21'AnchorSideTop.Control'#7#28'AutoRemoveEmptyMethodsOnSave'#18'AnchorSi'
|
||||
+'deTop.Side'#7#9'asrBottom'#4'Left'#2#6#6'Height'#2#19#3'Top'#2'8'#5'Width'#3
|
||||
+#181#0#20'BorderSpacing.Around'#2#6#7'Caption'#6#28'AutoToolTipSymbToolsChec'
|
||||
+'kBox'#8'TabOrder'#2#3#0#0#9'TTrackBar'#17'AutoDelayTrackBar'#22'AnchorSideL'
|
||||
+'eft.Control'#7#25'AutomaticFeaturesGroupBox'#21'AnchorSideTop.Control'#7#27
|
||||
+'AutoToolTipExprEvalCheckBox'#18'AnchorSideTop.Side'#7#9'asrBottom'#23'Ancho'
|
||||
+'rSideRight.Control'#7#25'AutomaticFeaturesGroupBox'#20'AnchorSideRight.Side'
|
||||
+#7#9'asrBottom'#4'Left'#2#6#6'Height'#2'('#3'Top'#3#131#0#5'Width'#3#224#1#9
|
||||
+'Frequency'#3#250#0#3'Max'#3#160#15#3'Min'#3#244#1#8'Position'#3#244#1#20'Bo'
|
||||
+'rderSpacing.Around'#2#6#5'Ctl3D'#8#8'TabOrder'#2#4#0#0#9'TCheckBox'#28'Auto'
|
||||
+'RemoveEmptyMethodsOnSave'#22'AnchorSideLeft.Control'#7#25'AutomaticFeatures'
|
||||
+'GroupBox'#21'AnchorSideTop.Control'#7' AutoIdentifierCompletionCheckBox'#18
|
||||
+'AnchorSideTop.Side'#7#9'asrBottom'#4'Left'#2#6#6'Height'#2#19#3'Top'#2#31#5
|
||||
+'Width'#3#197#0#20'BorderSpacing.Around'#2#6#7'Caption'#6#28'AutoRemoveEmpty'
|
||||
+'MethodsOnSave'#8'TabOrder'#2#5#0#0#0#0
|
||||
]);
|
||||
|
||||
@ -41,6 +41,7 @@ type
|
||||
AutomaticFeaturesGroupBox: TGroupBox;
|
||||
AutoToolTipExprEvalCheckBox: TCheckBox;
|
||||
AutoToolTipSymbToolsCheckBox: TCheckBox;
|
||||
AutoRemoveEmptyMethodsOnSave: TCheckBox;
|
||||
private
|
||||
{ private declarations }
|
||||
public
|
||||
@ -68,6 +69,7 @@ begin
|
||||
AutoCodeParametersCheckBox.Caption := dlgEdCodeParams;
|
||||
AutoToolTipExprEvalCheckBox.Caption := dlgTooltipEval;
|
||||
AutoToolTipSymbToolsCheckBox.Caption := dlgTooltipTools;
|
||||
AutoRemoveEmptyMethodsOnSave.Caption := dlgAutoRemoveEmptyMethods;
|
||||
|
||||
AutoDelayLabel.Caption := dlgEdDelay;
|
||||
AutoDelayMinLabel.Caption := '0.5 ' + DlgTimeSecondUnit;
|
||||
@ -83,6 +85,7 @@ begin
|
||||
AutoToolTipExprEvalCheckBox.Checked := AutoToolTipExprEval;
|
||||
AutoToolTipSymbToolsCheckBox.Checked := AutoToolTipSymbTools;
|
||||
AutoDelayTrackBar.Position := AutoDelayInMSec;
|
||||
AutoRemoveEmptyMethodsOnSave.Checked := AutoRemoveEmptyMethods;
|
||||
end;
|
||||
end;
|
||||
|
||||
@ -95,6 +98,7 @@ begin
|
||||
AutoToolTipExprEval := AutoToolTipExprEvalCheckBox.Checked;
|
||||
AutoToolTipSymbTools := AutoToolTipSymbToolsCheckBox.Checked;
|
||||
AutoDelayInMSec := AutoDelayTrackBar.Position;
|
||||
AutoRemoveEmptyMethods := AutoRemoveEmptyMethodsOnSave.Checked;
|
||||
end;
|
||||
end;
|
||||
|
||||
|
||||
@ -1186,6 +1186,7 @@ resourcestring
|
||||
dlgEdCodeParams = 'Code parameters';
|
||||
dlgTooltipEval = 'Tooltip expression evaluation';
|
||||
dlgTooltipTools = 'Tooltip symbol Tools';
|
||||
dlgAutoRemoveEmptyMethods = 'Auto remove empty methods';
|
||||
dlgEdDelay = 'Delay';
|
||||
dlgTimeSecondUnit = 'sec';
|
||||
dlgEdCodeTempl = 'Code templates';
|
||||
|
||||
38
ide/main.pp
38
ide/main.pp
@ -7149,21 +7149,35 @@ begin
|
||||
end;
|
||||
|
||||
// save source
|
||||
if (sfSaveToTestDir in Flags) or ActiveUnitInfo.IsVirtual then begin
|
||||
|
||||
// a) do before save events
|
||||
|
||||
if EditorOpts.AutoRemoveEmptyMethods then
|
||||
ActiveUnitInfo.RemoveEmptyMethods;
|
||||
|
||||
// b) do actual save
|
||||
if (sfSaveToTestDir in Flags) or ActiveUnitInfo.IsVirtual then
|
||||
begin
|
||||
// save source to test directory
|
||||
TestFilename:=MainBuildBoss.GetTestUnitFilename(ActiveUnitInfo);
|
||||
if TestFilename<>'' then begin
|
||||
Result:=ActiveUnitInfo.WriteUnitSourceToFile(TestFilename);
|
||||
if Result<>mrOk then exit;
|
||||
DestFilename:=TestFilename;
|
||||
end else
|
||||
TestFilename := MainBuildBoss.GetTestUnitFilename(ActiveUnitInfo);
|
||||
if TestFilename <> '' then
|
||||
begin
|
||||
Result := ActiveUnitInfo.WriteUnitSourceToFile(TestFilename);
|
||||
if Result <> mrOk then
|
||||
Exit;
|
||||
DestFilename := TestFilename;
|
||||
end
|
||||
else
|
||||
exit;
|
||||
end else begin
|
||||
if ActiveUnitInfo.Modified or ActiveUnitInfo.NeedsSaveToDisk then begin
|
||||
end else
|
||||
begin
|
||||
if ActiveUnitInfo.Modified or ActiveUnitInfo.NeedsSaveToDisk then
|
||||
begin
|
||||
// save source to file
|
||||
Result:=ActiveUnitInfo.WriteUnitSource;
|
||||
if Result=mrAbort then exit;
|
||||
DestFilename:=ActiveUnitInfo.Filename;
|
||||
Result := ActiveUnitInfo.WriteUnitSource;
|
||||
if Result = mrAbort then
|
||||
Exit;
|
||||
DestFilename := ActiveUnitInfo.Filename;
|
||||
end;
|
||||
end;
|
||||
|
||||
|
||||
133
ide/project.pp
133
ide/project.pp
@ -56,8 +56,8 @@ uses
|
||||
// IDE
|
||||
LazarusIDEStrConsts, CompilerOptions, CodeToolManager, CodeCache,
|
||||
TransferMacros, EditorOptions, IDEProcs, RunParamsOpts, ProjectDefs,
|
||||
FileReferenceList, EditDefineTree, DefineTemplates, PackageDefs
|
||||
;
|
||||
FileReferenceList, EditDefineTree, DefineTemplates, PackageDefs,
|
||||
CodeToolsStructs, CodeTree, CodeAtom, PascalParserTool;
|
||||
|
||||
type
|
||||
TUnitInfo = class;
|
||||
@ -299,6 +299,7 @@ type
|
||||
function FindAncestorUnit: TUnitInfo;
|
||||
procedure ClearUnitComponentDependencies(
|
||||
ClearTypes: TUnitCompDependencyTypes);
|
||||
procedure RemoveEmptyMethods;
|
||||
public
|
||||
{ Properties }
|
||||
// Unit lists
|
||||
@ -1612,6 +1613,134 @@ begin
|
||||
end;
|
||||
end;
|
||||
|
||||
procedure TUnitInfo.RemoveEmptyMethods;
|
||||
var
|
||||
RemovedProcHeads: TStringList;
|
||||
PropChanged: boolean;
|
||||
|
||||
procedure CheckEvents(LookupRoot, AComponent: TComponent);
|
||||
var
|
||||
TypeInfo: PTypeInfo;
|
||||
TypeData: PTypeData;
|
||||
PropInfo: PPropInfo;
|
||||
CurCount: Word;
|
||||
AMethod: TMethod;
|
||||
AMethodName: String;
|
||||
i: Integer;
|
||||
begin
|
||||
// read all properties and remove doubles
|
||||
TypeInfo:=PTypeInfo(AComponent.ClassInfo);
|
||||
repeat
|
||||
// read all property infos of current class
|
||||
TypeData:=GetTypeData(TypeInfo);
|
||||
// skip unitname
|
||||
PropInfo:=PPropInfo(PByte(@TypeData^.UnitName)+Length(TypeData^.UnitName)+1);
|
||||
// read property count
|
||||
CurCount:=PWord(PropInfo)^;
|
||||
inc(PtrUInt(PropInfo),SizeOf(Word));
|
||||
// read properties
|
||||
while CurCount>0 do
|
||||
begin
|
||||
// point PropInfo to next propinfo record.
|
||||
// Located at Name[Length(Name)+1] !
|
||||
if (PropInfo^.PropType^.Kind=tkMethod) then
|
||||
begin
|
||||
// event
|
||||
AMethod:=GetMethodProp(AComponent,PropInfo);
|
||||
AMethodName:=GlobalDesignHook.GetMethodName(AMethod,nil);
|
||||
if AMethodName<>'' then
|
||||
begin
|
||||
i:=RemovedProcHeads.Count-1;
|
||||
while (i>=0)
|
||||
and (SysUtils.CompareText(RemovedProcHeads[i],AMethodName)<>0) do
|
||||
dec(i);
|
||||
if i>=0 then
|
||||
begin
|
||||
FillByte(AMethod,SizeOf(AMethod),0);
|
||||
SetMethodProp(AComponent,PropInfo,AMethod);
|
||||
PropChanged:=true;
|
||||
end;
|
||||
end;
|
||||
end;
|
||||
PropInfo:=PPropInfo(pointer(@PropInfo^.Name)+PByte(@PropInfo^.Name)^+1);
|
||||
dec(CurCount);
|
||||
end;
|
||||
TypeInfo:=TypeData^.ParentInfo;
|
||||
until TypeInfo=nil;
|
||||
end;
|
||||
|
||||
function ExtractClassName: string;
|
||||
var
|
||||
ProcName: string;
|
||||
p: LongInt;
|
||||
i: Integer;
|
||||
begin
|
||||
Result := '';
|
||||
if (RemovedProcHeads = nil) or (RemovedProcHeads.Count = 0) then
|
||||
Exit;
|
||||
for i := RemovedProcHeads.Count - 1 downto 0 do
|
||||
begin
|
||||
ProcName := RemovedProcHeads[i];
|
||||
p := System.Pos('.',ProcName);
|
||||
if p < 1 then
|
||||
RemovedProcHeads.Delete(i)
|
||||
else
|
||||
begin
|
||||
Result := copy(ProcName,1,p-1);
|
||||
RemovedProcHeads[i] := copy(ProcName, p + 1, length(ProcName));
|
||||
end;
|
||||
end;
|
||||
end;
|
||||
|
||||
var
|
||||
Node: TCodeTreeNode;
|
||||
Caret: TCodeXYPosition;
|
||||
AllEmpty: Boolean;
|
||||
i: Integer;
|
||||
CurClassName: String;
|
||||
begin
|
||||
if (Component = nil) or not LazarusIDE.BeginCodeTools then
|
||||
Exit;
|
||||
|
||||
Node := CodeToolBoss.CurCodeTool.FindClassNodeInInterface(Component.ClassName,
|
||||
True, False, False);
|
||||
if (Node = nil) or
|
||||
not CodeToolBoss.CurCodeTool.CleanPosToCaret(Node.StartPos, Caret) then
|
||||
Exit;
|
||||
|
||||
RemovedProcHeads := nil;
|
||||
try
|
||||
if not CodeToolBoss.RemoveEmptyMethods(Source, Caret.X, Caret.Y,
|
||||
[pcsPublished], AllEmpty,
|
||||
[phpAddClassName,phpDoNotAddSemicolon,phpWithoutParamList,
|
||||
phpWithoutBrackets,phpWithoutClassKeyword,phpWithoutSemicolon],
|
||||
RemovedProcHeads) then
|
||||
begin
|
||||
DebugLn(['TUnitInfo.RemoveEmptyMethods failed']);
|
||||
exit;
|
||||
end;
|
||||
|
||||
if (RemovedProcHeads <> nil) and (RemovedProcHeads.Count > 0) then
|
||||
begin
|
||||
// RemovedProcHeads contains a list of classname.procname
|
||||
// remove the classname from the list
|
||||
CurClassName := ExtractClassName;
|
||||
if CurClassName = Component.ClassName then
|
||||
begin;
|
||||
PropChanged := False;
|
||||
CheckEvents(Component, Component);
|
||||
for i := 0 to Component.ComponentCount - 1 do
|
||||
CheckEvents(Component, Component.Components[i]);
|
||||
// update objectinspector
|
||||
if PropChanged and (GlobalDesignHook.LookupRoot = Component) then
|
||||
GlobalDesignHook.RefreshPropertyValues;
|
||||
end;
|
||||
end;
|
||||
finally
|
||||
RemovedProcHeads.Free;
|
||||
end;
|
||||
end;
|
||||
|
||||
function TUnitInfo.ReadOnly: boolean;
|
||||
begin
|
||||
Result:=UserReadOnly or FileReadOnly;
|
||||
|
||||
Loading…
Reference in New Issue
Block a user