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