IDE, CodeTools: add more options and a prompt dialog for method creation. Issue #13994

git-svn-id: trunk@50196 -
This commit is contained in:
ondrej 2015-10-29 11:08:52 +00:00
parent 95b1502bcd
commit 14e8ffa23a
8 changed files with 271 additions and 94 deletions

View File

@ -124,6 +124,13 @@ const
ctnClassPublished // pcsPublished
);
InsertClassSectionToNewClassPart: array[TInsertClassSectionResult] of TNewClassPart = (
ncpPrivateProcs,
ncpProtectedProcs,
ncpPublicProcs,
ncpPublishedProcs
);
type
TCodeCompletionCodeTool = class;
@ -207,10 +214,10 @@ type
procedure AdjustCursor(OldCodePos: TCodePosition; OldTopLine: integer;
out NewPos: TCodeXYPosition; out NewTopLine: integer);
procedure AddNeededUnitToMainUsesSection(AnUnitName: PChar);
procedure AddMethodCompatibleToProcType(AClassNode: TCodeTreeNode;
function AddMethodCompatibleToProcType(AClassNode: TCodeTreeNode;
const AnEventName: string; ProcContext: TFindContext; out
MethodDefinition: string; out MethodAttr: TProcHeadAttributes;
SourceChangeCache: TSourceChangeCache);
SourceChangeCache: TSourceChangeCache): Boolean;
procedure AddProcedureCompatibleToProcType(
const NewProcName: string; ProcContext: TFindContext; out
MethodDefinition: string; out MethodAttr: TProcHeadAttributes;
@ -1361,14 +1368,17 @@ begin
Pointer(s):=nil;
end;
procedure TCodeCompletionCodeTool.AddMethodCompatibleToProcType(
function TCodeCompletionCodeTool.AddMethodCompatibleToProcType(
AClassNode: TCodeTreeNode; const AnEventName: string;
ProcContext: TFindContext; out MethodDefinition: string; out
MethodAttr: TProcHeadAttributes; SourceChangeCache: TSourceChangeCache);
MethodAttr: TProcHeadAttributes; SourceChangeCache: TSourceChangeCache
): Boolean;
var
CleanMethodDefinition: string;
Beauty: TBeautifyCodeOptions;
MethodSection: TInsertClassSectionResult;
begin
Result := False;
MethodDefinition:='';
MethodAttr:=[];
@ -1400,8 +1410,10 @@ begin
{$ENDIF}
if not ProcExistsInCodeCompleteClass(CleanMethodDefinition) then begin
// insert method definition into class
if not Beauty.GetRealEventMethodSection(MethodSection) then
Exit;
AddClassInsertion(CleanMethodDefinition, MethodDefinition,
AnEventName, ncpPublishedProcs);
AnEventName, InsertClassSectionToNewClassPart[MethodSection]);
end;
MethodDefinition:=Beauty.AddClassAndNameToProc(MethodDefinition,
ExtractClassName(AClassNode,false,true), AnEventName);
@ -1411,6 +1423,7 @@ begin
// insert all missing proc bodies
if not CreateMissingClassProcBodies(false) then
RaiseException(ctsErrorDuringCreationOfNewProcBodies);
Result := True;
end;
procedure TCodeCompletionCodeTool.AddProcedureCompatibleToProcType(
@ -2143,8 +2156,10 @@ begin
if FullEventName='' then exit;
// add published method and method body and right side of assignment
AddMethodCompatibleToProcType(AClassNode,FullEventName,ProcContext,
AMethodDefinition,AMethodAttr,SourceChangeCache);
if not AddMethodCompatibleToProcType(AClassNode,FullEventName,ProcContext,
AMethodDefinition,AMethodAttr,SourceChangeCache)
then
Exit;
if not CompleteAssignment(FullEventName,AssignmentOperator,
AddrOperatorPos,SemicolonPos,UserEventAtom)
then
@ -2291,8 +2306,10 @@ function TCodeCompletionCodeTool.CompleteLocalIdentifierByParameter(
ProcContext:=CreateFindContext(TypeTool,TypeNode);
// create new method
AddMethodCompatibleToProcType(AClassNode,Identifier,
ProcContext,AMethodDefinition,AMethodAttr,SourceChangeCache);
if not AddMethodCompatibleToProcType(AClassNode,Identifier,
ProcContext,AMethodDefinition,AMethodAttr,SourceChangeCache)
then
Exit;
// apply the changes
if not SourceChangeCache.Apply then

View File

@ -59,6 +59,21 @@ type
mipClassOrder // try to copy the order of the class
);
//where to add created methods from event assignment: "OnClick := @MyNewProc;"
TInsertClassSection = (
icsPrivate,
icsProtected,
icsPublic,
icsPublished,
icsPrompt //show dialog prompt
);
TInsertClassSectionResult = (
icsrPrivate,
icsrProtected,
icsrPublic,
icsrPublished
);
TForwardProcBodyInsertPolicy = (
fpipLast,
fpipInFrontOfMethods,
@ -90,6 +105,15 @@ type
const
DefaultUsesInsertPolicy = uipBehindRelated;
DefaultEventMethodSection = icsPrompt;
InsertClassSectionToResult: array[TInsertClassSection] of TInsertClassSectionResult = (
icsrPrivate,
icsrProtected,
icsrPublic,
icsrPublished,
icsrPrivate
);
type
TWordPolicyException = class
@ -157,6 +181,7 @@ type
ClassPartInsertPolicy: TClassPartInsertPolicy;
MixMethodsAndProperties: boolean;
MethodInsertPolicy: TMethodInsertPolicy;
EventMethodSection: TInsertClassSection;
PropertyReadIdentPrefix: string;
PropertyWriteIdentPrefix: string;
PropertyStoredIdentPostfix: string;
@ -169,6 +194,7 @@ type
NestedComments: boolean;
function GetRealEventMethodSection(out Section: TInsertClassSectionResult): Boolean; //in case of imsPrompt show a dialog and return a "normal" section; returns true if OK, false if canceled
function GetIndentStr(TheIndent: integer): string; inline;
function GetLineIndent(const Source: string; Position: integer): integer; inline;
procedure SetupWordPolicyExceptions(ws: TStrings);
@ -328,7 +354,15 @@ const
MethodInsertPolicyNames: array[TMethodInsertPolicy] of shortstring = (
'Alphabetically', 'Last', 'ClassOrder'
);
InsertClassSectionNames: array[TInsertClassSection] of ShortString = (
'Private', 'Protected', 'Public', 'Published', 'Prompt'
);
InsertClassSectionResultNames: array[TInsertClassSectionResult] of ShortString = (
'Private', 'Protected', 'Public', 'Published'
);
ForwardProcBodyInsertPolicyNames: array[TForwardProcBodyInsertPolicy] of
shortstring = (
'Last',
@ -352,11 +386,18 @@ const
DefaultDoNotInsertSpaceInFront: TAtomTypes = [];
DefaultDoNotInsertSpaceAfter: TAtomTypes = [atDirectiveStart];
type
TShowEventClassSectionPromptFunc = function(out Section: TInsertClassSectionResult): Boolean;
var
ShowEventMethodSectionPrompt: TShowEventClassSectionPromptFunc = nil;
function AtomTypeNameToType(const s: string): TAtomType;
function AtomTypesToStr(const AtomTypes: TAtomTypes): string;
function WordPolicyNameToPolicy(const s: string): TWordPolicy;
function ClassPartPolicyNameToPolicy(const s: string): TClassPartInsertPolicy;
function MethodInsertPolicyNameToPolicy(const s: string): TMethodInsertPolicy;
function InsertClassSectionNameToSection(const s: string; Default: TInsertClassSection): TInsertClassSection;
function InsertClassSectionResultNameToSection(const s: string): TInsertClassSectionResult;
function ForwardProcBodyInsertPolicyNameToPolicy(
const s: string): TForwardProcBodyInsertPolicy;
function UsesInsertPolicyNameToPolicy(const s: string): TUsesInsertPolicy;
@ -409,6 +450,21 @@ begin
Result:=mipLast;
end;
function InsertClassSectionNameToSection(const s: string;
Default: TInsertClassSection): TInsertClassSection;
begin
for Result:=Low(TInsertClassSection) to High(TInsertClassSection) do
if SysUtils.CompareText(InsertClassSectionNames[Result],s)=0 then exit;
Result:=Default;
end;
function InsertClassSectionResultNameToSection(const s: string): TInsertClassSectionResult;
begin
for Result:=Low(TInsertClassSectionResult) to High(TInsertClassSectionResult) do
if SysUtils.CompareText(InsertClassSectionResultNames[Result],s)=0 then exit;
Result:=icsrPrivate;
end;
function ForwardProcBodyInsertPolicyNameToPolicy(
const s: string): TForwardProcBodyInsertPolicy;
begin
@ -1259,6 +1315,7 @@ begin
UpdateOtherProcSignaturesCase:=true;
GroupLocalVariables:=true;
MethodInsertPolicy:=mipClassOrder;
EventMethodSection:=DefaultEventMethodSection;
ForwardProcBodyInsertPolicy:=fpipBehindMethods;
KeepForwardProcOrder:=true;
ClassHeaderComments:=true;
@ -1685,6 +1742,21 @@ begin
Result:=false;
end;
function TBeautifyCodeOptions.GetRealEventMethodSection(out
Section: TInsertClassSectionResult): Boolean;
begin
Result := True;
if (EventMethodSection <> icsPrompt) then
Section := InsertClassSectionToResult[EventMethodSection]
else
begin
if Assigned(ShowEventMethodSectionPrompt) then
Result := ShowEventMethodSectionPrompt(Section)
else
Section := InsertClassSectionToResult[DefaultEventMethodSection];
end;
end;
procedure TBeautifyCodeOptions.SetupWordPolicyExceptions(ws: TStrings);
begin
if Assigned(WordExceptions) then WordExceptions.Free;

View File

@ -82,6 +82,7 @@ type
FForwardProcBodyInsertPolicy: TForwardProcBodyInsertPolicy;
FKeepForwardProcOrder: boolean;
FMethodInsertPolicy: TMethodInsertPolicy;
FEventMethodSection: TInsertClassSection;
FKeyWordPolicy : TWordPolicy;
FIdentifierPolicy: TWordPolicy;
FUpdateAllMethodSignatures: boolean;
@ -188,6 +189,8 @@ type
read FClassImplementationComments write FClassImplementationComments;
property MethodInsertPolicy: TMethodInsertPolicy
read FMethodInsertPolicy write FMethodInsertPolicy;
property EventMethodSection: TInsertClassSection
read FEventMethodSection write FEventMethodSection;
property KeyWordPolicy : TWordPolicy
read FKeyWordPolicy write FKeyWordPolicy;
property IdentifierPolicy: TWordPolicy
@ -462,6 +465,9 @@ begin
FMethodInsertPolicy:=MethodInsertPolicyNameToPolicy(XMLConfig.GetValue(
'CodeToolsOptions/MethodInsertPolicy/Value',
MethodInsertPolicyNames[mipClassOrder]));
FEventMethodSection:=InsertClassSectionNameToSection(XMLConfig.GetValue(
'CodeToolsOptions/EventMethodSection/Value',
InsertClassSectionNames[DefaultEventMethodSection]), DefaultEventMethodSection);
FKeyWordPolicy:=WordPolicyNameToPolicy(XMLConfig.GetValue(
'CodeToolsOptions/KeyWordPolicy/Value',
WordPolicyNames[wpLowerCase]));
@ -619,6 +625,9 @@ begin
XMLConfig.SetDeleteValue('CodeToolsOptions/MethodInsertPolicy/Value',
MethodInsertPolicyNames[FMethodInsertPolicy],
MethodInsertPolicyNames[mipClassOrder]);
XMLConfig.SetDeleteValue('CodeToolsOptions/EventMethodSection/Value',
InsertClassSectionNames[FEventMethodSection],
InsertClassSectionNames[DefaultEventMethodSection]);
XMLConfig.SetDeleteValue('CodeToolsOptions/KeyWordPolicy/Value',
WordPolicyNames[FKeyWordPolicy],
WordPolicyNames[wpLowerCase]);
@ -786,6 +795,7 @@ begin
FClassHeaderComments:=CodeToolsOpts.ClassHeaderComments;
FClassImplementationComments:=CodeToolsOpts.ClassImplementationComments;
FMethodInsertPolicy:=CodeToolsOpts.FMethodInsertPolicy;
FEventMethodSection:=CodeToolsOpts.FEventMethodSection;
FKeyWordPolicy:=CodeToolsOpts.FKeyWordPolicy;
FIdentifierPolicy:=CodeToolsOpts.FIdentifierPolicy;
FDoNotSplitLineInFront:=CodeToolsOpts.FDoNotSplitLineInFront;
@ -847,6 +857,7 @@ begin
FClassHeaderComments:=true;
FClassImplementationComments:=true;
FMethodInsertPolicy:=mipClassOrder;
FEventMethodSection:=DefaultEventMethodSection;
FKeyWordPolicy:=wpLowerCase;
FIdentifierPolicy:=wpNone;
FDoNotSplitLineInFront:=DefaultDoNotSplitLineInFront;
@ -926,6 +937,7 @@ begin
and (FClassHeaderComments=CodeToolsOpts.ClassHeaderComments)
and (FClassImplementationComments=CodeToolsOpts.ClassImplementationComments)
and (FMethodInsertPolicy=CodeToolsOpts.FMethodInsertPolicy)
and (FEventMethodSection=CodeToolsOpts.FEventMethodSection)
and (FKeyWordPolicy=CodeToolsOpts.FKeyWordPolicy)
and (FIdentifierPolicy=CodeToolsOpts.FIdentifierPolicy)
and (FDoNotSplitLineInFront=CodeToolsOpts.FDoNotSplitLineInFront)
@ -1047,6 +1059,7 @@ begin
Beauty.ClassHeaderComments:=ClassHeaderComments;
Beauty.ClassImplementationComments:=ClassImplementationComments;
Beauty.MethodInsertPolicy:=MethodInsertPolicy;
Beauty.EventMethodSection:=EventMethodSection;
Beauty.KeyWordPolicy:=KeyWordPolicy;
Beauty.IdentifierPolicy:=IdentifierPolicy;
Beauty.SetupWordPolicyExceptions(WordPolicyExceptions);

View File

@ -39,7 +39,7 @@ uses
{$endif}
Classes, SysUtils, TypInfo, contnrs, Graphics, Controls, Forms, Dialogs,
LCLProc, FileProcs, LazFileUtils, LazFileCache, LazConfigStorage,
Laz2_XMLCfg, LazUTF8,
Laz2_XMLCfg, LazUTF8, SourceChanger,
// IDEIntf
ProjectIntf, ObjectInspector, IDEWindowIntf, IDEOptionsIntf,
ComponentReg, IDEExternToolIntf, MacroDefIntf, DbgIntfDebuggerBase,
@ -499,6 +499,9 @@ type
// Prevent repopulating Recent project files menu with example projects if it was already cleared up.
FAlreadyPopulatedRecentFiles : Boolean;
//other recent settings
FLastEventMethodSectionPrompt: TInsertClassSectionResult;
// backup
FBackupInfoProjectFiles: TBackupInfo;
FBackupInfoOtherFiles: TBackupInfo;
@ -752,6 +755,10 @@ type
write FMultipleInstances;
property FileDialogFilter: string read FFileDialogFilter write FFileDialogFilter;
// other recent settings
property LastEventMethodSectionPrompt: TInsertClassSectionResult
read FLastEventMethodSectionPrompt write FLastEventMethodSectionPrompt;
// backup
property BackupInfoProjectFiles: TBackupInfo read FBackupInfoProjectFiles
write FBackupInfoProjectFiles;
@ -1347,6 +1354,9 @@ begin
FOpenLastProjectAtStart:=true;
FMultipleInstances:=DefaultIDEMultipleInstancesOption;
// other recent settings
FLastEventMethodSectionPrompt:=InsertClassSectionToResult[DefaultEventMethodSection];
// backup
with FBackupInfoProjectFiles do begin
BackupType:=bakSameName;
@ -1745,6 +1755,11 @@ begin
FAlreadyPopulatedRecentFiles := FXMLCfg.GetValue(Path+'Recent/AlreadyPopulated', false);
// other recent settings
FLastEventMethodSectionPrompt:=InsertClassSectionResultNameToSection(FXMLCfg.GetValue(
'Recent/EventMethodSectionPrompt/Value',
InsertClassSectionNames[DefaultEventMethodSection]));
// Add example projects to an empty project list if examples have write access
if (FRecentProjectFiles.count=0) and (not FAlreadyPopulatedRecentFiles) then begin
AddRecentProjectInitial('examples/jpeg/', 'jpegexample.lpi');
@ -2073,6 +2088,11 @@ begin
FXMLCfg.SetDeleteValue(Path+'Recent/AlreadyPopulated', FAlreadyPopulatedRecentFiles, false);
// other recent settings
FXMLCfg.SetDeleteValue('Recent/EventMethodSectionPrompt/Value',
InsertClassSectionResultNames[FLastEventMethodSectionPrompt],
InsertClassSectionResultNames[InsertClassSectionToResult[DefaultEventMethodSection]]);
// external tools
fExternalUserTools.Save(FConfigStore,Path+'ExternalTools/');
FXMLCfg.SetDeleteValue(Path+'ExternalTools/MaxInParallel',FMaxExtToolsInParallel,0);

View File

@ -8,76 +8,27 @@ object CodetoolsCodeCreationOptionsFrame: TCodetoolsCodeCreationOptionsFrame
TabOrder = 0
Visible = False
DesignLeft = 322
DesignTop = 184
object ForwardProcsInsertPolicyRadioGroup: TRadioGroup
AnchorSideLeft.Control = Owner
AnchorSideTop.Control = Owner
AnchorSideRight.Control = Owner
AnchorSideRight.Side = asrBottom
Left = 6
Height = 100
Top = 6
Width = 554
Anchors = [akTop, akLeft, akRight]
AutoFill = True
BorderSpacing.Around = 6
Caption = 'ForwardProcsInsertPolicyRadioGroup'
ChildSizing.LeftRightSpacing = 6
ChildSizing.TopBottomSpacing = 6
ChildSizing.EnlargeHorizontal = crsHomogenousChildResize
ChildSizing.EnlargeVertical = crsHomogenousChildResize
ChildSizing.ShrinkHorizontal = crsScaleChilds
ChildSizing.ShrinkVertical = crsScaleChilds
ChildSizing.Layout = cclLeftToRightThenTopToBottom
ChildSizing.ControlsPerLine = 1
TabOrder = 0
end
DesignTop = 167
object ForwardProcsKeepOrderCheckBox: TCheckBox
AnchorSideLeft.Control = Owner
AnchorSideTop.Control = ForwardProcsInsertPolicyRadioGroup
AnchorSideTop.Control = ForwardProcsInsertPolicyComboBox
AnchorSideTop.Side = asrBottom
Left = 6
Height = 19
Top = 112
Top = 45
Width = 200
BorderSpacing.Around = 6
BorderSpacing.Left = 6
BorderSpacing.Top = 6
Caption = 'ForwardProcsKeepOrderCheckBox'
TabOrder = 1
end
object UsesInsertPolicyRadioGroup: TRadioGroup
AnchorSideLeft.Control = Owner
AnchorSideTop.Control = ForwardProcsKeepOrderCheckBox
AnchorSideTop.Side = asrBottom
AnchorSideRight.Control = Owner
AnchorSideRight.Side = asrBottom
Left = 6
Height = 100
Top = 143
Width = 554
Anchors = [akTop, akLeft, akRight]
AutoFill = True
AutoSize = True
BorderSpacing.Top = 6
BorderSpacing.Around = 6
Caption = 'UsesInsertPolicyRadioGroup'
ChildSizing.LeftRightSpacing = 6
ChildSizing.TopBottomSpacing = 6
ChildSizing.EnlargeHorizontal = crsHomogenousChildResize
ChildSizing.EnlargeVertical = crsHomogenousChildResize
ChildSizing.ShrinkHorizontal = crsScaleChilds
ChildSizing.ShrinkVertical = crsScaleChilds
ChildSizing.Layout = cclLeftToRightThenTopToBottom
ChildSizing.ControlsPerLine = 1
Constraints.MinHeight = 100
TabOrder = 2
end
object UpdateMultiProcSignaturesCheckBox: TCheckBox
AnchorSideLeft.Control = Owner
AnchorSideTop.Control = UsesInsertPolicyRadioGroup
AnchorSideTop.Control = UsesInsertPolicyComboBox
AnchorSideTop.Side = asrBottom
Left = 6
Height = 19
Top = 249
Top = 99
Width = 217
BorderSpacing.Left = 6
BorderSpacing.Top = 6
@ -90,7 +41,7 @@ object CodetoolsCodeCreationOptionsFrame: TCodetoolsCodeCreationOptionsFrame
AnchorSideTop.Side = asrBottom
Left = 6
Height = 19
Top = 268
Top = 118
Width = 244
BorderSpacing.Left = 6
Caption = 'UpdateOtherProcSignaturesCaseCheckBox'
@ -102,7 +53,7 @@ object CodetoolsCodeCreationOptionsFrame: TCodetoolsCodeCreationOptionsFrame
AnchorSideTop.Side = asrCenter
Left = 6
Height = 15
Top = 316
Top = 195
Width = 95
Caption = 'TemplateFileLabel'
ParentColor = False
@ -110,16 +61,17 @@ object CodetoolsCodeCreationOptionsFrame: TCodetoolsCodeCreationOptionsFrame
object TemplateFileEdit: TEdit
AnchorSideLeft.Control = TemplateFileLabel
AnchorSideLeft.Side = asrBottom
AnchorSideTop.Control = GroupLocalVariablesCheckBox
AnchorSideTop.Control = EventMethodSectionComboBox
AnchorSideTop.Side = asrBottom
AnchorSideRight.Control = TemplateFileBrowseButton
Left = 101
Left = 107
Height = 23
Top = 312
Width = 424
Top = 191
Width = 418
Anchors = [akTop, akLeft, akRight]
BorderSpacing.Left = 6
BorderSpacing.Top = 6
TabOrder = 6
TabOrder = 7
Text = 'TemplateFileEdit'
end
object TemplateFileBrowseButton: TButton
@ -130,14 +82,14 @@ object CodetoolsCodeCreationOptionsFrame: TCodetoolsCodeCreationOptionsFrame
AnchorSideBottom.Side = asrBottom
Left = 525
Height = 23
Top = 312
Top = 191
Width = 35
Anchors = [akTop, akRight, akBottom]
AutoSize = True
BorderSpacing.Right = 6
Caption = '...'
OnClick = TemplateFileBrowseButtonClick
TabOrder = 7
TabOrder = 8
end
object GroupLocalVariablesCheckBox: TCheckBox
AnchorSideLeft.Control = Owner
@ -145,10 +97,88 @@ object CodetoolsCodeCreationOptionsFrame: TCodetoolsCodeCreationOptionsFrame
AnchorSideTop.Side = asrBottom
Left = 6
Height = 19
Top = 287
Top = 137
Width = 180
BorderSpacing.Left = 6
Caption = 'GroupLocalVariablesCheckBox'
TabOrder = 5
end
object ForwardProcsInsertPolicyComboBox: TComboBox
AnchorSideLeft.Control = ForwardProcsInsertPolicyLabel
AnchorSideLeft.Side = asrBottom
Left = 173
Height = 23
Top = 16
Width = 170
ItemHeight = 15
Style = csDropDownList
TabOrder = 0
end
object ForwardProcsInsertPolicyLabel: TLabel
AnchorSideLeft.Control = Owner
AnchorSideTop.Control = ForwardProcsInsertPolicyComboBox
AnchorSideTop.Side = asrCenter
AnchorSideRight.Control = ForwardProcsInsertPolicyComboBox
Left = 6
Height = 15
Top = 20
Width = 161
BorderSpacing.Around = 6
Caption = 'ForwardProcsInsertPolicyLabel'
ParentColor = False
end
object UsesInsertPolicyLabel: TLabel
AnchorSideLeft.Control = Owner
AnchorSideTop.Control = UsesInsertPolicyComboBox
AnchorSideTop.Side = asrCenter
AnchorSideRight.Control = UsesInsertPolicyComboBox
Left = 6
Height = 15
Top = 74
Width = 113
BorderSpacing.Around = 6
Caption = 'UsesInsertPolicyLabel'
ParentColor = False
end
object UsesInsertPolicyComboBox: TComboBox
AnchorSideLeft.Control = UsesInsertPolicyLabel
AnchorSideLeft.Side = asrBottom
AnchorSideTop.Control = ForwardProcsKeepOrderCheckBox
AnchorSideTop.Side = asrBottom
Left = 125
Height = 23
Top = 70
Width = 170
BorderSpacing.Top = 6
ItemHeight = 15
Style = csDropDownList
TabOrder = 2
end
object EventMethodSectionLabel: TLabel
AnchorSideLeft.Control = Owner
AnchorSideTop.Control = EventMethodSectionComboBox
AnchorSideTop.Side = asrCenter
AnchorSideRight.Control = EventMethodSectionComboBox
Left = 6
Height = 15
Top = 166
Width = 138
BorderSpacing.Around = 6
Caption = 'EventMethodSectionLabel'
ParentColor = False
end
object EventMethodSectionComboBox: TComboBox
AnchorSideLeft.Control = EventMethodSectionLabel
AnchorSideLeft.Side = asrBottom
AnchorSideTop.Control = GroupLocalVariablesCheckBox
AnchorSideTop.Side = asrBottom
Left = 150
Height = 23
Top = 162
Width = 170
BorderSpacing.Top = 6
ItemHeight = 15
Style = csDropDownList
TabOrder = 6
end
end

View File

@ -34,15 +34,19 @@ type
{ TCodetoolsCodeCreationOptionsFrame }
TCodetoolsCodeCreationOptionsFrame = class(TAbstractIDEOptionsEditor)
ForwardProcsInsertPolicyRadioGroup: TRadioGroup;
ForwardProcsInsertPolicyComboBox: TComboBox;
UsesInsertPolicyComboBox: TComboBox;
ForwardProcsKeepOrderCheckBox: TCheckBox;
ForwardProcsInsertPolicyLabel: TLabel;
EventMethodSectionComboBox: TComboBox;
UsesInsertPolicyLabel: TLabel;
TemplateFileBrowseButton: TButton;
TemplateFileEdit: TEdit;
TemplateFileLabel: TLabel;
UpdateMultiProcSignaturesCheckBox: TCheckBox;
UpdateOtherProcSignaturesCaseCheckBox: TCheckBox;
GroupLocalVariablesCheckBox: TCheckBox;
UsesInsertPolicyRadioGroup: TRadioGroup;
EventMethodSectionLabel: TLabel;
procedure TemplateFileBrowseButtonClick(Sender: TObject);
private
public
@ -87,8 +91,8 @@ end;
procedure TCodetoolsCodeCreationOptionsFrame.Setup(
ADialog: TAbstractOptionsEditorDialog);
begin
with ForwardProcsInsertPolicyRadioGroup do begin
Caption:=dlgForwardProcsInsertPolicy;
ForwardProcsInsertPolicyLabel.Caption:=dlgForwardProcsInsertPolicy;
with ForwardProcsInsertPolicyComboBox do begin
with Items do begin
BeginUpdate;
Add(dlgLast);
@ -100,8 +104,8 @@ begin
ForwardProcsKeepOrderCheckBox.Caption:=dlgForwardProcsKeepOrder;
with UsesInsertPolicyRadioGroup do begin
Caption:=lisNewUnitsAreAddedToUsesSections;
UsesInsertPolicyLabel.Caption:=lisNewUnitsAreAddedToUsesSections;
with UsesInsertPolicyComboBox do begin
with Items do begin
BeginUpdate;
Add(lisFirst);
@ -113,6 +117,20 @@ begin
end;
end;
EventMethodSectionLabel.Caption:=lisEventMethodSectionLabel;
with EventMethodSectionComboBox do begin
Assert(Ord(High(TInsertClassSectionResult)) = 3, 'TCodetoolsCodeCreationOptionsFrame.Setup: High(TInsertClassSectionResult) <> 3');
with Items do begin
BeginUpdate;
Add(lisPrivate);
Add(lisProtected);
Add(lisEMDPublic);
Add(lisEMDPublished);
Add(lisPromptForValue);
EndUpdate;
end;
end;
UpdateMultiProcSignaturesCheckBox.Caption:=
lisCTOUpdateMultipleProcedureSignatures;
UpdateOtherProcSignaturesCaseCheckBox.Caption:=
@ -134,24 +152,25 @@ begin
with AOptions as TCodetoolsOptions do
begin
case ForwardProcBodyInsertPolicy of
fpipLast: ForwardProcsInsertPolicyRadioGroup.ItemIndex:=0;
fpipInFrontOfMethods: ForwardProcsInsertPolicyRadioGroup.ItemIndex:=1;
fpipLast: ForwardProcsInsertPolicyComboBox.ItemIndex:=0;
fpipInFrontOfMethods: ForwardProcsInsertPolicyComboBox.ItemIndex:=1;
else
// fpipBehindMethods
ForwardProcsInsertPolicyRadioGroup.ItemIndex:=2;
ForwardProcsInsertPolicyComboBox.ItemIndex:=2;
end;
ForwardProcsKeepOrderCheckBox.Checked := KeepForwardProcOrder;
case UsesInsertPolicy of
uipFirst: UsesInsertPolicyRadioGroup.ItemIndex:=0;
uipInFrontOfRelated: UsesInsertPolicyRadioGroup.ItemIndex:=1;
uipBehindRelated: UsesInsertPolicyRadioGroup.ItemIndex:=2;
uipLast: UsesInsertPolicyRadioGroup.ItemIndex:=3;
uipFirst: UsesInsertPolicyComboBox.ItemIndex:=0;
uipInFrontOfRelated: UsesInsertPolicyComboBox.ItemIndex:=1;
uipBehindRelated: UsesInsertPolicyComboBox.ItemIndex:=2;
uipLast: UsesInsertPolicyComboBox.ItemIndex:=3;
else
//uipAlphabetically:
UsesInsertPolicyRadioGroup.ItemIndex:=4;
UsesInsertPolicyComboBox.ItemIndex:=4;
end;
EventMethodSectionComboBox.ItemIndex := Ord(EventMethodSection);
UpdateMultiProcSignaturesCheckBox.Checked:=UpdateMultiProcSignatures;
UpdateOtherProcSignaturesCaseCheckBox.Checked:=UpdateOtherProcSignaturesCase;
@ -166,7 +185,7 @@ procedure TCodetoolsCodeCreationOptionsFrame.WriteSettings(
begin
with AOptions as TCodetoolsOptions do
begin
case ForwardProcsInsertPolicyRadioGroup.ItemIndex of
case ForwardProcsInsertPolicyComboBox.ItemIndex of
0: ForwardProcBodyInsertPolicy := fpipLast;
1: ForwardProcBodyInsertPolicy := fpipInFrontOfMethods;
2: ForwardProcBodyInsertPolicy := fpipBehindMethods;
@ -174,7 +193,7 @@ begin
KeepForwardProcOrder := ForwardProcsKeepOrderCheckBox.Checked;
case UsesInsertPolicyRadioGroup.ItemIndex of
case UsesInsertPolicyComboBox.ItemIndex of
0: UsesInsertPolicy:=uipFirst;
1: UsesInsertPolicy:=uipInFrontOfRelated;
2: UsesInsertPolicy:=uipBehindRelated;
@ -182,6 +201,8 @@ begin
else UsesInsertPolicy:=uipAlphabetically;
end;
EventMethodSection := TInsertClassSection(EventMethodSectionComboBox.ItemIndex);
UpdateMultiProcSignatures:=UpdateMultiProcSignaturesCheckBox.Checked;
UpdateOtherProcSignaturesCase:=UpdateOtherProcSignaturesCaseCheckBox.Checked;
GroupLocalVariables:=GroupLocalVariablesCheckBox.Checked;

View File

@ -3645,6 +3645,10 @@ resourcestring
lisAllBlocksLooksOk = 'All blocks look ok.';
lisTheApplicationBundleWasCreatedFor = 'The Application Bundle was created for "%s"';
//codetools ChooseClassSectionDlg
lisChooseClassSectionDlgForMethodCaption = 'Insert new method to section';
lisEventMethodSectionLabel = 'Insert new event methods to section';
// diff dialog
lisDiffDlgFile1 = 'File1';
lisDiffDlgOnlySelection = 'Only selection';

View File

@ -66,7 +66,7 @@ uses
// CodeTools
FileProcs, FindDeclarationTool, LinkScanner, BasicCodeTools, CodeToolsStructs,
CodeToolManager, CodeCache, DefineTemplates, KeywordFuncLists, CodeTree,
StdCodeTools,
StdCodeTools, ChooseClassSectionDlg,
// LazUtils
// use lazutf8, lazfileutils and lazfilecache after FileProcs and FileUtil
FileUtil, LazFileUtils, LazFileCache, LazUTF8, LazUTF8Classes, UTF8Process,