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

View File

@ -59,6 +59,21 @@ type
mipClassOrder // try to copy the order of the class 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 = ( TForwardProcBodyInsertPolicy = (
fpipLast, fpipLast,
fpipInFrontOfMethods, fpipInFrontOfMethods,
@ -90,6 +105,15 @@ type
const const
DefaultUsesInsertPolicy = uipBehindRelated; DefaultUsesInsertPolicy = uipBehindRelated;
DefaultEventMethodSection = icsPrompt;
InsertClassSectionToResult: array[TInsertClassSection] of TInsertClassSectionResult = (
icsrPrivate,
icsrProtected,
icsrPublic,
icsrPublished,
icsrPrivate
);
type type
TWordPolicyException = class TWordPolicyException = class
@ -157,6 +181,7 @@ type
ClassPartInsertPolicy: TClassPartInsertPolicy; ClassPartInsertPolicy: TClassPartInsertPolicy;
MixMethodsAndProperties: boolean; MixMethodsAndProperties: boolean;
MethodInsertPolicy: TMethodInsertPolicy; MethodInsertPolicy: TMethodInsertPolicy;
EventMethodSection: TInsertClassSection;
PropertyReadIdentPrefix: string; PropertyReadIdentPrefix: string;
PropertyWriteIdentPrefix: string; PropertyWriteIdentPrefix: string;
PropertyStoredIdentPostfix: string; PropertyStoredIdentPostfix: string;
@ -169,6 +194,7 @@ type
NestedComments: boolean; 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 GetIndentStr(TheIndent: integer): string; inline;
function GetLineIndent(const Source: string; Position: integer): integer; inline; function GetLineIndent(const Source: string; Position: integer): integer; inline;
procedure SetupWordPolicyExceptions(ws: TStrings); procedure SetupWordPolicyExceptions(ws: TStrings);
@ -329,6 +355,14 @@ const
'Alphabetically', 'Last', 'ClassOrder' '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 ForwardProcBodyInsertPolicyNames: array[TForwardProcBodyInsertPolicy] of
shortstring = ( shortstring = (
'Last', 'Last',
@ -352,11 +386,18 @@ const
DefaultDoNotInsertSpaceInFront: TAtomTypes = []; DefaultDoNotInsertSpaceInFront: TAtomTypes = [];
DefaultDoNotInsertSpaceAfter: TAtomTypes = [atDirectiveStart]; DefaultDoNotInsertSpaceAfter: TAtomTypes = [atDirectiveStart];
type
TShowEventClassSectionPromptFunc = function(out Section: TInsertClassSectionResult): Boolean;
var
ShowEventMethodSectionPrompt: TShowEventClassSectionPromptFunc = nil;
function AtomTypeNameToType(const s: string): TAtomType; function AtomTypeNameToType(const s: string): TAtomType;
function AtomTypesToStr(const AtomTypes: TAtomTypes): string; function AtomTypesToStr(const AtomTypes: TAtomTypes): string;
function WordPolicyNameToPolicy(const s: string): TWordPolicy; function WordPolicyNameToPolicy(const s: string): TWordPolicy;
function ClassPartPolicyNameToPolicy(const s: string): TClassPartInsertPolicy; function ClassPartPolicyNameToPolicy(const s: string): TClassPartInsertPolicy;
function MethodInsertPolicyNameToPolicy(const s: string): TMethodInsertPolicy; function MethodInsertPolicyNameToPolicy(const s: string): TMethodInsertPolicy;
function InsertClassSectionNameToSection(const s: string; Default: TInsertClassSection): TInsertClassSection;
function InsertClassSectionResultNameToSection(const s: string): TInsertClassSectionResult;
function ForwardProcBodyInsertPolicyNameToPolicy( function ForwardProcBodyInsertPolicyNameToPolicy(
const s: string): TForwardProcBodyInsertPolicy; const s: string): TForwardProcBodyInsertPolicy;
function UsesInsertPolicyNameToPolicy(const s: string): TUsesInsertPolicy; function UsesInsertPolicyNameToPolicy(const s: string): TUsesInsertPolicy;
@ -409,6 +450,21 @@ begin
Result:=mipLast; Result:=mipLast;
end; 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( function ForwardProcBodyInsertPolicyNameToPolicy(
const s: string): TForwardProcBodyInsertPolicy; const s: string): TForwardProcBodyInsertPolicy;
begin begin
@ -1259,6 +1315,7 @@ begin
UpdateOtherProcSignaturesCase:=true; UpdateOtherProcSignaturesCase:=true;
GroupLocalVariables:=true; GroupLocalVariables:=true;
MethodInsertPolicy:=mipClassOrder; MethodInsertPolicy:=mipClassOrder;
EventMethodSection:=DefaultEventMethodSection;
ForwardProcBodyInsertPolicy:=fpipBehindMethods; ForwardProcBodyInsertPolicy:=fpipBehindMethods;
KeepForwardProcOrder:=true; KeepForwardProcOrder:=true;
ClassHeaderComments:=true; ClassHeaderComments:=true;
@ -1685,6 +1742,21 @@ begin
Result:=false; Result:=false;
end; 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); procedure TBeautifyCodeOptions.SetupWordPolicyExceptions(ws: TStrings);
begin begin
if Assigned(WordExceptions) then WordExceptions.Free; if Assigned(WordExceptions) then WordExceptions.Free;

View File

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

View File

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

View File

@ -8,76 +8,27 @@ object CodetoolsCodeCreationOptionsFrame: TCodetoolsCodeCreationOptionsFrame
TabOrder = 0 TabOrder = 0
Visible = False Visible = False
DesignLeft = 322 DesignLeft = 322
DesignTop = 184 DesignTop = 167
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
object ForwardProcsKeepOrderCheckBox: TCheckBox object ForwardProcsKeepOrderCheckBox: TCheckBox
AnchorSideLeft.Control = Owner AnchorSideLeft.Control = Owner
AnchorSideTop.Control = ForwardProcsInsertPolicyRadioGroup AnchorSideTop.Control = ForwardProcsInsertPolicyComboBox
AnchorSideTop.Side = asrBottom AnchorSideTop.Side = asrBottom
Left = 6 Left = 6
Height = 19 Height = 19
Top = 112 Top = 45
Width = 200 Width = 200
BorderSpacing.Around = 6 BorderSpacing.Left = 6
BorderSpacing.Top = 6
Caption = 'ForwardProcsKeepOrderCheckBox' Caption = 'ForwardProcsKeepOrderCheckBox'
TabOrder = 1 TabOrder = 1
end 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 object UpdateMultiProcSignaturesCheckBox: TCheckBox
AnchorSideLeft.Control = Owner AnchorSideLeft.Control = Owner
AnchorSideTop.Control = UsesInsertPolicyRadioGroup AnchorSideTop.Control = UsesInsertPolicyComboBox
AnchorSideTop.Side = asrBottom AnchorSideTop.Side = asrBottom
Left = 6 Left = 6
Height = 19 Height = 19
Top = 249 Top = 99
Width = 217 Width = 217
BorderSpacing.Left = 6 BorderSpacing.Left = 6
BorderSpacing.Top = 6 BorderSpacing.Top = 6
@ -90,7 +41,7 @@ object CodetoolsCodeCreationOptionsFrame: TCodetoolsCodeCreationOptionsFrame
AnchorSideTop.Side = asrBottom AnchorSideTop.Side = asrBottom
Left = 6 Left = 6
Height = 19 Height = 19
Top = 268 Top = 118
Width = 244 Width = 244
BorderSpacing.Left = 6 BorderSpacing.Left = 6
Caption = 'UpdateOtherProcSignaturesCaseCheckBox' Caption = 'UpdateOtherProcSignaturesCaseCheckBox'
@ -102,7 +53,7 @@ object CodetoolsCodeCreationOptionsFrame: TCodetoolsCodeCreationOptionsFrame
AnchorSideTop.Side = asrCenter AnchorSideTop.Side = asrCenter
Left = 6 Left = 6
Height = 15 Height = 15
Top = 316 Top = 195
Width = 95 Width = 95
Caption = 'TemplateFileLabel' Caption = 'TemplateFileLabel'
ParentColor = False ParentColor = False
@ -110,16 +61,17 @@ object CodetoolsCodeCreationOptionsFrame: TCodetoolsCodeCreationOptionsFrame
object TemplateFileEdit: TEdit object TemplateFileEdit: TEdit
AnchorSideLeft.Control = TemplateFileLabel AnchorSideLeft.Control = TemplateFileLabel
AnchorSideLeft.Side = asrBottom AnchorSideLeft.Side = asrBottom
AnchorSideTop.Control = GroupLocalVariablesCheckBox AnchorSideTop.Control = EventMethodSectionComboBox
AnchorSideTop.Side = asrBottom AnchorSideTop.Side = asrBottom
AnchorSideRight.Control = TemplateFileBrowseButton AnchorSideRight.Control = TemplateFileBrowseButton
Left = 101 Left = 107
Height = 23 Height = 23
Top = 312 Top = 191
Width = 424 Width = 418
Anchors = [akTop, akLeft, akRight] Anchors = [akTop, akLeft, akRight]
BorderSpacing.Left = 6
BorderSpacing.Top = 6 BorderSpacing.Top = 6
TabOrder = 6 TabOrder = 7
Text = 'TemplateFileEdit' Text = 'TemplateFileEdit'
end end
object TemplateFileBrowseButton: TButton object TemplateFileBrowseButton: TButton
@ -130,14 +82,14 @@ object CodetoolsCodeCreationOptionsFrame: TCodetoolsCodeCreationOptionsFrame
AnchorSideBottom.Side = asrBottom AnchorSideBottom.Side = asrBottom
Left = 525 Left = 525
Height = 23 Height = 23
Top = 312 Top = 191
Width = 35 Width = 35
Anchors = [akTop, akRight, akBottom] Anchors = [akTop, akRight, akBottom]
AutoSize = True AutoSize = True
BorderSpacing.Right = 6 BorderSpacing.Right = 6
Caption = '...' Caption = '...'
OnClick = TemplateFileBrowseButtonClick OnClick = TemplateFileBrowseButtonClick
TabOrder = 7 TabOrder = 8
end end
object GroupLocalVariablesCheckBox: TCheckBox object GroupLocalVariablesCheckBox: TCheckBox
AnchorSideLeft.Control = Owner AnchorSideLeft.Control = Owner
@ -145,10 +97,88 @@ object CodetoolsCodeCreationOptionsFrame: TCodetoolsCodeCreationOptionsFrame
AnchorSideTop.Side = asrBottom AnchorSideTop.Side = asrBottom
Left = 6 Left = 6
Height = 19 Height = 19
Top = 287 Top = 137
Width = 180 Width = 180
BorderSpacing.Left = 6 BorderSpacing.Left = 6
Caption = 'GroupLocalVariablesCheckBox' Caption = 'GroupLocalVariablesCheckBox'
TabOrder = 5 TabOrder = 5
end 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 end

View File

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

View File

@ -3645,6 +3645,10 @@ resourcestring
lisAllBlocksLooksOk = 'All blocks look ok.'; lisAllBlocksLooksOk = 'All blocks look ok.';
lisTheApplicationBundleWasCreatedFor = 'The Application Bundle was created for "%s"'; 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 // diff dialog
lisDiffDlgFile1 = 'File1'; lisDiffDlgFile1 = 'File1';
lisDiffDlgOnlySelection = 'Only selection'; lisDiffDlgOnlySelection = 'Only selection';

View File

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