IDE: rename identifier: check if renaming a unit

git-svn-id: trunk@19207 -
This commit is contained in:
mattias 2009-04-03 09:59:40 +00:00
parent 0a2aa05286
commit f940e202a0
2 changed files with 11 additions and 0 deletions

View File

@ -4074,6 +4074,8 @@ resourcestring
lisSetValue = 'Set value';
lisCreateFunction = 'Create function';
lisResult2 = 'Result:';
lisTheIdentifierIsAUnitPleaseUseTheFileSaveAsFunction = 'The identifier is '
+'a unit. Please use the File - Save as function to rename a unit.';
implementation

View File

@ -12545,6 +12545,7 @@ var
Identifier: string;
PascalReferences: TAVLTree;
ListOfLazFPDocNode: TFPList;
CurUnitname: String;
begin
Result:=mrCancel;
if not BeginCodeTool(TargetSrcEdit,TargetUnitInfo,[]) then exit;
@ -12561,6 +12562,14 @@ begin
DoJumpToCodePos(TargetSrcEdit, TargetUnitInfo,
NewSource, NewX, NewY, NewTopLine, true);
CodeToolBoss.GetIdentifierAt(NewSource,NewX,NewY,Identifier);
CurUnitname:=ExtractFileNameOnly(NewSource.Filename);
if CompareIdentifiers(PChar(Identifier),PChar(CurUnitName))=0 then
begin
IDEMessageDialog(srkmecRenameIdentifier,
lisTheIdentifierIsAUnitPleaseUseTheFileSaveAsFunction,
mtInformation,[mbCancel],'');
exit(mrCancel);
end;
GetCurrentUnit(DeclarationSrcEdit,DeclarationUnitInfo);
DeclarationCaretXY:=DeclarationSrcEdit.EditorComponent.LogicalCaretXY;