mirror of
https://gitlab.com/freepascal.org/lazarus/lazarus.git
synced 2025-04-07 14:38:01 +02:00
codetools: fixed FindReferences for expression inherited name
This commit is contained in:
parent
dc6183cb78
commit
584fb864fa
@ -3149,7 +3149,7 @@ begin
|
||||
end;
|
||||
end;
|
||||
if i<>0 then begin
|
||||
DebugLn('TCodeToolManager.RenameIdentifier Change ');
|
||||
//DebugLn('TCodeToolManager.RenameIdentifier Change ');
|
||||
SourceChangeCache.ReplaceEx(gtNone,gtNone,1,1,Code,
|
||||
IdentStartPos,
|
||||
IdentEndPos,
|
||||
@ -3161,7 +3161,7 @@ begin
|
||||
end;
|
||||
|
||||
// apply
|
||||
DebugLn('TCodeToolManager.RenameIdentifier Apply');
|
||||
//DebugLn('TCodeToolManager.RenameIdentifier Apply');
|
||||
if not SourceChangeCache.Apply then exit;
|
||||
|
||||
//DebugLn('TCodeToolManager.RenameIdentifier Success');
|
||||
|
@ -6885,10 +6885,10 @@ var
|
||||
fdfIgnoreCurContextNode];
|
||||
//dLen>0 will force searching from units names first
|
||||
Params.ContextNode:=CursorNode;
|
||||
//debugln(copy(Src,Params.ContextNode.StartPos,200));
|
||||
//debugln(['ReadIdentifier "',copy(Src,IdentStartPos,200),'"']);
|
||||
Params.SetIdentifier(Self,@Src[IdentStartPos],@CheckSrcIdentifier,dLen);
|
||||
|
||||
// search identifier in comment -> if not found, this is no bug
|
||||
// search identifier also in comments -> if not found, this is no bug
|
||||
// => silently ignore
|
||||
try
|
||||
Found:=FindDeclarationOfIdentAtParam(Params);
|
||||
@ -10863,7 +10863,7 @@ var
|
||||
Params.Save(OldInput);
|
||||
Params.SetIdentifier(Self,@Src[CurPos.StartPos],@CheckSrcIdentifier);
|
||||
Params.ContextNode:=ExprType.Context.Node;
|
||||
Params.Flags:=Params.Flags-[fdfSearchInParentNodes]
|
||||
Params.Flags:=Params.Flags-[fdfSearchInParentNodes,fdfIgnoreCurContextNode]
|
||||
+[fdfExceptionOnNotFound,fdfSearchInAncestors];
|
||||
ExprType.Context.Tool.FindIdentifierInContext(Params);
|
||||
ExprType.Context:=CreateFindContext(Params);
|
||||
|
@ -1133,7 +1133,7 @@ begin
|
||||
// found itself -> search further
|
||||
if Search=cpsUp then exit;
|
||||
StartNode:=FindNextNodeOnSameLvl(Result);
|
||||
if StartNode<>nil then debugln(['TPascalReaderTool.FindCorrespondingProcNode StartNode=',CleanPosToStr(StartNode.StartPos),' ',dbgstr(copy(Src,StartNode.StartPos,50))]);
|
||||
//if StartNode<>nil then debugln(['TPascalReaderTool.FindCorrespondingProcNode StartNode=',CleanPosToStr(StartNode.StartPos),' ',dbgstr(copy(Src,StartNode.StartPos,50))]);
|
||||
Result:=FindProcNode(StartNode,ProcHead,Attr);
|
||||
end;
|
||||
if (Search=cpsUp) and (Result<>nil) and (Result.StartPos>ProcNode.StartPos) then
|
||||
|
@ -40,6 +40,7 @@ type
|
||||
procedure TestRenameForwardProcedureArgUp;
|
||||
procedure TestRenameMethodArgDown;
|
||||
procedure TestRenameMethodArgUp;
|
||||
procedure TestRenameMethodInherited;
|
||||
procedure TestRenameNestedProgramProcDown;
|
||||
procedure TestRenameNestedProgramProcUp;
|
||||
procedure TestRenameNestedUnitProcDown;
|
||||
@ -589,6 +590,58 @@ begin
|
||||
'']);
|
||||
end;
|
||||
|
||||
procedure TTestRefactoring.TestRenameMethodInherited;
|
||||
begin
|
||||
StartProgram;
|
||||
Add([
|
||||
'type',
|
||||
' TAnimal = class',
|
||||
' procedure Fly{#Rename}; virtual;',
|
||||
' end;',
|
||||
' TBird = class(TAnimal)',
|
||||
' procedure Fly; override;',
|
||||
' end;',
|
||||
'',
|
||||
'procedure TAnimal.Fly;',
|
||||
'begin',
|
||||
'end;',
|
||||
'',
|
||||
'procedure TBird.Fly;',
|
||||
'begin',
|
||||
' inherited Fly;',
|
||||
'end;',
|
||||
'',
|
||||
'begin',
|
||||
'end.',
|
||||
'']);
|
||||
RenameReferences('Run');
|
||||
CheckDiff(Code,[
|
||||
'program test1;',
|
||||
'',
|
||||
'{$mode objfpc}{$H+}',
|
||||
'',
|
||||
'type',
|
||||
' TAnimal = class',
|
||||
' procedure Run{#Rename}; virtual;',
|
||||
' end;',
|
||||
' TBird = class(TAnimal)',
|
||||
' procedure Fly; override;',
|
||||
' end;',
|
||||
'',
|
||||
'procedure TAnimal.Run;',
|
||||
'begin',
|
||||
'end;',
|
||||
'',
|
||||
'procedure TBird.Fly;',
|
||||
'begin',
|
||||
' inherited Run;',
|
||||
'end;',
|
||||
'',
|
||||
'begin',
|
||||
'end.',
|
||||
'']);
|
||||
end;
|
||||
|
||||
procedure TTestRefactoring.TestRenameNestedProgramProcDown;
|
||||
begin
|
||||
StartProgram;
|
||||
|
Loading…
Reference in New Issue
Block a user