mirror of
https://gitlab.com/freepascal.org/lazarus/lazarus.git
synced 2025-09-28 05:09:13 +02:00
IDE: Improve "Find Identifier reference". Issue #21254, patch by n7800.
This commit is contained in:
parent
8ad8d57c7b
commit
0cfbf5637b
@ -67,6 +67,7 @@ object FindRenameIdentifierDialog: TFindRenameIdentifierDialog
|
||||
BorderSpacing.Around = 6
|
||||
TabOrder = 2
|
||||
Text = 'NewEdit'
|
||||
OnChange = NewEditChange
|
||||
end
|
||||
object RenameCheckBox: TCheckBox
|
||||
Left = 6
|
||||
|
@ -69,11 +69,13 @@ type
|
||||
procedure FindRenameIdentifierDialogCreate(Sender: TObject);
|
||||
procedure FormShow(Sender: TObject);
|
||||
procedure HelpButtonClick(Sender: TObject);
|
||||
procedure NewEditChange(Sender: TObject);
|
||||
procedure RenameCheckBoxChange(Sender: TObject);
|
||||
private
|
||||
FAllowRename: boolean;
|
||||
FIdentifierFilename: string;
|
||||
FIdentifierPosition: TPoint;
|
||||
FIdentifier: string;
|
||||
FIsPrivate: boolean;
|
||||
procedure SetAllowRename(const AValue: boolean);
|
||||
procedure SetIsPrivate(const AValue: boolean);
|
||||
@ -295,15 +297,19 @@ begin
|
||||
CodeToolBoss.GetIdentifierAt(DeclCode,DeclarationCaretXY.X,DeclarationCaretXY.Y,Identifier);
|
||||
CurUnitname:=ExtractFileNameOnly(DeclCode.Filename);
|
||||
|
||||
// ToDo: Support renaming and saving a unit also here.
|
||||
// Now just inform a user that renaming is not possible.
|
||||
if SetRenameActive and (CompareDottedIdentifiers(PChar(Identifier),PChar(CurUnitName))=0) then
|
||||
begin
|
||||
IDEMessageDialog(srkmecRenameIdentifier,
|
||||
lisTheIdentifierIsAUnitPleaseUseTheFileSaveAsFunction,
|
||||
mtInformation,[mbCancel],'');
|
||||
exit(mrCancel);
|
||||
end;
|
||||
// identifier is unit
|
||||
if CompareDottedIdentifiers(PChar(Identifier),PChar(CurUnitName))=0 then
|
||||
if SetRenameActive then
|
||||
begin
|
||||
// ToDo: Support renaming and saving a unit also here
|
||||
// inform a user that renaming is not possible
|
||||
IDEMessageDialog(srkmecRenameIdentifier,
|
||||
lisTheIdentifierIsAUnitPleaseUseTheFileSaveAsFunction,
|
||||
mtInformation,[mbCancel],'');
|
||||
exit(mrCancel);
|
||||
end else
|
||||
// allow search references only
|
||||
AllowRename:=false;
|
||||
|
||||
// open unit with declaration
|
||||
Result:=LazarusIDE.DoOpenFileAndJumpToPos(DeclCode.Filename, DeclarationCaretXY,
|
||||
@ -860,6 +866,11 @@ begin
|
||||
OpenUrl('http://wiki.freepascal.org/IDE_Window:_Find_or_Rename_identifier');
|
||||
end;
|
||||
|
||||
procedure TFindRenameIdentifierDialog.NewEditChange(Sender: TObject);
|
||||
begin
|
||||
UpdateRename;
|
||||
end;
|
||||
|
||||
procedure TFindRenameIdentifierDialog.RenameCheckBoxChange(Sender: TObject);
|
||||
begin
|
||||
UpdateRename;
|
||||
@ -874,6 +885,8 @@ begin
|
||||
ButtonPanel1.OKButton.Caption:=lisFRIRenameAllReferences
|
||||
else
|
||||
ButtonPanel1.OKButton.Caption:=lisFRIFindReferences;
|
||||
ButtonPanel1.OKButton.Enabled := not NewEdit.Enabled or
|
||||
((NewEdit.Text <> FIdentifier) and (NewEdit.Text <> ''));
|
||||
end;
|
||||
|
||||
procedure TFindRenameIdentifierDialog.SetAllowRename(const AValue: boolean);
|
||||
@ -967,7 +980,6 @@ var
|
||||
ListOfCodeBuffer: TFPList;
|
||||
i: Integer;
|
||||
CurCode: TCodeBuffer;
|
||||
NewIdentifier: String;
|
||||
Tool: TCodeTool;
|
||||
CodeXY: TCodeXYPosition;
|
||||
CleanPos: integer;
|
||||
@ -993,11 +1005,12 @@ begin
|
||||
ListOfCodeBuffer.Free;
|
||||
end;
|
||||
if CodeToolBoss.GetIdentifierAt(ACodeBuffer,
|
||||
NewIdentifierPosition.X,NewIdentifierPosition.Y,NewIdentifier) then
|
||||
NewIdentifierPosition.X,NewIdentifierPosition.Y,FIdentifier) then
|
||||
begin
|
||||
CurrentGroupBox.Caption:=Format(lisFRIIdentifier, [NewIdentifier]);
|
||||
NewEdit.Text:=NewIdentifier;
|
||||
end;
|
||||
CurrentGroupBox.Caption:=Format(lisFRIIdentifier, [FIdentifier]);
|
||||
NewEdit.Text:=FIdentifier;
|
||||
end else
|
||||
FIdentifier := '';
|
||||
// check if in implementation or private section
|
||||
if CodeToolBoss.Explore(ACodeBuffer,Tool,false) then begin
|
||||
CodeXY:=CodeXYPosition(NewIdentifierPosition.X,NewIdentifierPosition.Y,ACodeBuffer);
|
||||
|
Loading…
Reference in New Issue
Block a user