IDE: find/rename identifier: search private identifiers only in current unit

git-svn-id: trunk@19566 -
This commit is contained in:
mattias 2009-04-22 06:47:34 +00:00
parent a9d598fdb3
commit 2e18113fd7
3 changed files with 80 additions and 50 deletions

View File

@ -15,18 +15,18 @@ object FindRenameIdentifierDialog: TFindRenameIdentifierDialog
LCLVersion = '0.9.27'
object CurrentGroupBox: TGroupBox
Left = 6
Height = 102
Height = 117
Top = 6
Width = 440
Align = alClient
BorderSpacing.Around = 6
Caption = 'CurrentGroupBox'
ClientHeight = 83
ClientHeight = 98
ClientWidth = 436
TabOrder = 0
object CurrentListBox: TListBox
Left = 6
Height = 71
Height = 86
Top = 6
Width = 424
Align = alClient
@ -39,14 +39,14 @@ object FindRenameIdentifierDialog: TFindRenameIdentifierDialog
end
object NewGroupBox: TGroupBox
Left = 6
Height = 82
Top = 114
Height = 67
Top = 129
Width = 440
Align = alBottom
AutoSize = True
BorderSpacing.Around = 6
Caption = 'NewGroupBox'
ClientHeight = 63
ClientHeight = 48
ClientWidth = 436
TabOrder = 1
object NewEdit: TEdit

View File

@ -8,43 +8,44 @@ LazarusResources.Add('TFindRenameIdentifierDialog','FORMDATA',[
+'OnClose'#7#31'FindRenameIdentifierDialogClose'#8'OnCreate'#7' FindRenameIde'
+'ntifierDialogCreate'#6'OnShow'#7#8'FormShow'#8'Position'#7#14'poScreenCente'
+'r'#10'LCLVersion'#6#6'0.9.27'#0#9'TGroupBox'#15'CurrentGroupBox'#4'Left'#2#6
+#6'Height'#2'f'#3'Top'#2#6#5'Width'#3#184#1#5'Align'#7#8'alClient'#20'Border'
+'Spacing.Around'#2#6#7'Caption'#6#15'CurrentGroupBox'#12'ClientHeight'#2'S'
+#6'Height'#2'u'#3'Top'#2#6#5'Width'#3#184#1#5'Align'#7#8'alClient'#20'Border'
+'Spacing.Around'#2#6#7'Caption'#6#15'CurrentGroupBox'#12'ClientHeight'#2'b'
+#11'ClientWidth'#3#180#1#8'TabOrder'#2#0#0#8'TListBox'#14'CurrentListBox'#4
+'Left'#2#6#6'Height'#2'G'#3'Top'#2#6#5'Width'#3#168#1#5'Align'#7#8'alClient'
+'Left'#2#6#6'Height'#2'V'#3'Top'#2#6#5'Width'#3#168#1#5'Align'#7#8'alClient'
+#20'BorderSpacing.Around'#2#6#16'ClickOnSelChange'#8#10'ItemHeight'#2#0#8'Ta'
+'bOrder'#2#0#8'TopIndex'#2#255#0#0#0#9'TGroupBox'#11'NewGroupBox'#4'Left'#2#6
+#6'Height'#2'R'#3'Top'#2'r'#5'Width'#3#184#1#5'Align'#7#8'alBottom'#8'AutoSi'
+'ze'#9#20'BorderSpacing.Around'#2#6#7'Caption'#6#11'NewGroupBox'#12'ClientHe'
+'ight'#2'?'#11'ClientWidth'#3#180#1#8'TabOrder'#2#1#0#5'TEdit'#7'NewEdit'#4
+'Left'#2#6#6'Height'#2#23#3'Top'#2'"'#5'Width'#3#168#1#5'Align'#7#5'alTop'#20
+'BorderSpacing.Around'#2#6#8'TabOrder'#2#0#4'Text'#6#7'NewEdit'#0#0#9'TCheck'
+'Box'#14'RenameCheckBox'#4'Left'#2#6#6'Height'#2#22#3'Top'#2#6#5'Width'#3#168
+#1#5'Align'#7#5'alTop'#20'BorderSpacing.Around'#2#6#7'Caption'#6#14'RenameCh'
+'eckBox'#8'OnChange'#7#20'RenameCheckBoxChange'#8'TabOrder'#2#1#0#0#0#9'TGro'
+'upBox'#13'ScopeGroupBox'#4'Left'#2#6#6'Height'#3#238#0#3'Top'#3#202#0#5'Wid'
+'th'#3#184#1#5'Align'#7#8'alBottom'#8'AutoSize'#9#20'BorderSpacing.Around'#2
+#6#7'Caption'#6#13'ScopeGroupBox'#12'ClientHeight'#3#219#0#11'ClientWidth'#3
+#180#1#8'TabOrder'#2#2#0#9'TCheckBox'#21'ScopeCommentsCheckBox'#4'Left'#2#6#6
+'Height'#2#22#3'Top'#3#191#0#5'Width'#3#168#1#5'Align'#7#5'alTop'#11'AllowGr'
+'ayed'#9#20'BorderSpacing.Around'#2#6#7'Caption'#6#21'ScopeCommentsCheckBox'
+#8'TabOrder'#2#0#0#0#11'TRadioGroup'#15'ScopeRadioGroup'#4'Left'#2#6#6'Heigh'
+'t'#2'w'#3'Top'#2#6#5'Width'#3#168#1#5'Align'#7#5'alTop'#8'AutoFill'#9#8'Aut'
+'oSize'#9#20'BorderSpacing.Around'#2#6#7'Caption'#6#15'ScopeRadioGroup'#28'C'
+'hildSizing.LeftRightSpacing'#2#6#28'ChildSizing.TopBottomSpacing'#2#6#29'Ch'
+'ildSizing.EnlargeHorizontal'#7#24'crsHomogenousChildResize'#27'ChildSizing.'
+'EnlargeVertical'#7#24'crsHomogenousChildResize'#28'ChildSizing.ShrinkHorizo'
+'ntal'#7#14'crsScaleChilds'#26'ChildSizing.ShrinkVertical'#7#14'crsScaleChil'
+'ds'#18'ChildSizing.Layout'#7#29'cclLeftToRightThenTopToBottom'#27'ChildSizi'
+'ng.ControlsPerLine'#2#1#12'ClientHeight'#2'd'#11'ClientWidth'#3#164#1#13'It'
+'ems.Strings'#1#6#15'in current unit'#6#15'in main project'#6#30'in project/'
+'package owning file'#6'!in all open projects and packages'#0#8'TabOrder'#2#1
+#0#0#9'TGroupBox'#18'ExtraFilesGroupBox'#4'Left'#2#6#6'Height'#2'6'#3'Top'#3
+#131#0#5'Width'#3#168#1#5'Align'#7#5'alTop'#8'AutoSize'#9#20'BorderSpacing.A'
+'round'#2#6#7'Caption'#6#18'ExtraFilesGroupBox'#12'ClientHeight'#2'#'#11'Cli'
+'entWidth'#3#164#1#8'TabOrder'#2#2#0#5'TEdit'#14'ExtraFilesEdit'#4'Left'#2#6
+#6'Height'#2#23#3'Top'#2#6#5'Width'#3#152#1#5'Align'#7#5'alTop'#20'BorderSpa'
+'cing.Around'#2#6#8'TabOrder'#2#0#4'Text'#6#14'ExtraFilesEdit'#0#0#0#0#12'TB'
+'uttonPanel'#12'ButtonPanel1'#4'Left'#2#6#6'Height'#2','#3'Top'#3#190#1#5'Wi'
+'dth'#3#184#1#8'TabOrder'#2#3#11'ShowButtons'#11#4'pbOK'#8'pbCancel'#0#0#0#0
+#6'Height'#2'C'#3'Top'#3#129#0#5'Width'#3#184#1#5'Align'#7#8'alBottom'#8'Aut'
+'oSize'#9#20'BorderSpacing.Around'#2#6#7'Caption'#6#11'NewGroupBox'#12'Clien'
+'tHeight'#2'0'#11'ClientWidth'#3#180#1#8'TabOrder'#2#1#0#5'TEdit'#7'NewEdit'
+#4'Left'#2#6#6'Height'#2#23#3'Top'#2'"'#5'Width'#3#168#1#5'Align'#7#5'alTop'
+#20'BorderSpacing.Around'#2#6#8'TabOrder'#2#0#4'Text'#6#7'NewEdit'#0#0#9'TCh'
+'eckBox'#14'RenameCheckBox'#4'Left'#2#6#6'Height'#2#22#3'Top'#2#6#5'Width'#3
+#168#1#5'Align'#7#5'alTop'#20'BorderSpacing.Around'#2#6#7'Caption'#6#14'Rena'
+'meCheckBox'#8'OnChange'#7#20'RenameCheckBoxChange'#8'TabOrder'#2#1#0#0#0#9
+'TGroupBox'#13'ScopeGroupBox'#4'Left'#2#6#6'Height'#3#238#0#3'Top'#3#202#0#5
+'Width'#3#184#1#5'Align'#7#8'alBottom'#8'AutoSize'#9#20'BorderSpacing.Around'
+#2#6#7'Caption'#6#13'ScopeGroupBox'#12'ClientHeight'#3#219#0#11'ClientWidth'
+#3#180#1#8'TabOrder'#2#2#0#9'TCheckBox'#21'ScopeCommentsCheckBox'#4'Left'#2#6
+#6'Height'#2#22#3'Top'#3#191#0#5'Width'#3#168#1#5'Align'#7#5'alTop'#11'Allow'
+'Grayed'#9#20'BorderSpacing.Around'#2#6#7'Caption'#6#21'ScopeCommentsCheckBo'
+'x'#8'TabOrder'#2#0#0#0#11'TRadioGroup'#15'ScopeRadioGroup'#4'Left'#2#6#6'He'
+'ight'#2'w'#3'Top'#2#6#5'Width'#3#168#1#5'Align'#7#5'alTop'#8'AutoFill'#9#8
+'AutoSize'#9#20'BorderSpacing.Around'#2#6#7'Caption'#6#15'ScopeRadioGroup'#28
+'ChildSizing.LeftRightSpacing'#2#6#28'ChildSizing.TopBottomSpacing'#2#6#29'C'
+'hildSizing.EnlargeHorizontal'#7#24'crsHomogenousChildResize'#27'ChildSizing'
+'.EnlargeVertical'#7#24'crsHomogenousChildResize'#28'ChildSizing.ShrinkHoriz'
+'ontal'#7#14'crsScaleChilds'#26'ChildSizing.ShrinkVertical'#7#14'crsScaleChi'
+'lds'#18'ChildSizing.Layout'#7#29'cclLeftToRightThenTopToBottom'#27'ChildSiz'
+'ing.ControlsPerLine'#2#1#12'ClientHeight'#2'd'#11'ClientWidth'#3#164#1#13'I'
+'tems.Strings'#1#6#15'in current unit'#6#15'in main project'#6#30'in project'
+'/package owning file'#6'!in all open projects and packages'#0#8'TabOrder'#2
+#1#0#0#9'TGroupBox'#18'ExtraFilesGroupBox'#4'Left'#2#6#6'Height'#2'6'#3'Top'
+#3#131#0#5'Width'#3#168#1#5'Align'#7#5'alTop'#8'AutoSize'#9#20'BorderSpacing'
+'.Around'#2#6#7'Caption'#6#18'ExtraFilesGroupBox'#12'ClientHeight'#2'#'#11'C'
+'lientWidth'#3#164#1#8'TabOrder'#2#2#0#5'TEdit'#14'ExtraFilesEdit'#4'Left'#2
+#6#6'Height'#2#23#3'Top'#2#6#5'Width'#3#152#1#5'Align'#7#5'alTop'#20'BorderS'
+'pacing.Around'#2#6#8'TabOrder'#2#0#4'Text'#6#14'ExtraFilesEdit'#0#0#0#0#12
+'TButtonPanel'#12'ButtonPanel1'#4'Left'#2#6#6'Height'#2','#3'Top'#3#190#1#5
+'Width'#3#184#1#8'TabOrder'#2#3#11'ShowButtons'#11#4'pbOK'#8'pbCancel'#0#0#0
+#0
]);

View File

@ -33,7 +33,7 @@ uses
Classes, SysUtils, LCLProc, LResources, Forms, Controls, Graphics, Dialogs,
StdCtrls, Buttons, ExtCtrls, AvgLvlTree,
// codetools
Laz_Dom, AVL_Tree, CodeAtom, CodeCache, CodeToolManager,
Laz_Dom, AVL_Tree, CodeTree, CodeAtom, CodeCache, CodeToolManager,
// IDE
LazarusIDEStrConsts, IDEProcs, IDEWindowIntf, MiscOptions, DialogProcs,
InputHistory, SearchResultView, CodeHelp, ButtonPanel;
@ -64,7 +64,9 @@ type
FAllowRename: boolean;
FIdentifierFilename: string;
FIdentifierPosition: TPoint;
FIsPrivate: boolean;
procedure SetAllowRename(const AValue: boolean);
procedure SetIsPrivate(const AValue: boolean);
procedure UpdateRename;
public
procedure LoadFromConfig;
@ -76,6 +78,7 @@ type
property IdentifierFilename: string read FIdentifierFilename;
property IdentifierPosition: TPoint read FIdentifierPosition;
property AllowRename: boolean read FAllowRename write SetAllowRename;
property IsPrivate: boolean read FIsPrivate write SetIsPrivate;
end;
procedure CleanUpFileList(Files: TStringList);
@ -545,6 +548,15 @@ begin
UpdateRename;
end;
procedure TFindRenameIdentifierDialog.SetIsPrivate(const AValue: boolean);
begin
if FIsPrivate=AValue then exit;
FIsPrivate:=AValue;
ExtraFilesGroupBox.Enabled:=not IsPrivate;
ScopeRadioGroup.Enabled:=not IsPrivate;
ScopeRadioGroup.ItemIndex:=0;
end;
procedure TFindRenameIdentifierDialog.FindOrRenameButtonClick(Sender: TObject);
var
NewIdentifier: String;
@ -597,15 +609,17 @@ procedure TFindRenameIdentifierDialog.SaveToOptions(
Options: TFindRenameIdentifierOptions);
begin
Options.Rename:=RenameCheckBox.Checked;
SplitString(ExtraFilesEdit.Text,';',Options.ExtraFiles,true);
if ExtraFilesGroupBox.Enabled then
SplitString(ExtraFilesEdit.Text,';',Options.ExtraFiles,true);
Options.RenameTo:=NewEdit.Text;
Options.SearchInComments:=ScopeCommentsCheckBox.Checked;
case ScopeRadioGroup.ItemIndex of
0: Options.Scope:=frCurrentUnit;
1: Options.Scope:=frProject;
2: Options.Scope:=frOwnerProjectPackage;
else Options.Scope:=frAllOpenProjectsAndPackages;
end;
if ScopeRadioGroup.Enabled then
case ScopeRadioGroup.ItemIndex of
0: Options.Scope:=frCurrentUnit;
1: Options.Scope:=frProject;
2: Options.Scope:=frOwnerProjectPackage;
else Options.Scope:=frAllOpenProjectsAndPackages;
end;
end;
procedure TFindRenameIdentifierDialog.SetIdentifier(
@ -617,6 +631,10 @@ var
i: Integer;
CurCode: TCodeBuffer;
NewIdentifier: String;
Tool: TCodeTool;
CodeXY: TCodeXYPosition;
CleanPos: integer;
Node: TCodeTreeNode;
begin
FIdentifierFilename:=NewIdentifierFilename;
FIdentifierPosition:=NewIdentifierPosition;
@ -642,6 +660,17 @@ begin
CurrentGroupBox.Caption:=Format(lisFRIIdentifier, [NewIdentifier]);
NewEdit.Text:=NewIdentifier;
end;
// check if in implementation or private section
if CodeToolBoss.Explore(ACodeBuffer,Tool,false) then begin
CodeXY:=CodeXYPosition(NewIdentifierPosition.X,NewIdentifierPosition.Y,ACodeBuffer);
if Tool.CaretToCleanPos(CodeXY,CleanPos)=0 then begin
Node:=Tool.BuildSubTreeAndFindDeepestNodeAtPos(CleanPos,false);
if (Node=nil)
or Node.HasParentOfType(ctnImplementation)
or Node.HasParentOfType(ctnClassPrivate) then
IsPrivate:=true;
end;
end;
end;
end;