mirror of
https://gitlab.com/freepascal.org/lazarus/lazarus.git
synced 2025-08-20 10:39:09 +02:00
codetools: class completion: fixed updating tree after changing signature
git-svn-id: trunk@35350 -
This commit is contained in:
parent
cdaa396f47
commit
f1895195e3
@ -7535,16 +7535,24 @@ var
|
|||||||
InsertEndPos: LongInt;
|
InsertEndPos: LongInt;
|
||||||
NewProcCode: String;
|
NewProcCode: String;
|
||||||
OldProcCode: String;
|
OldProcCode: String;
|
||||||
|
Bodies: TFPList;
|
||||||
|
i: Integer;
|
||||||
begin
|
begin
|
||||||
Result:=true;
|
Result:=true;
|
||||||
ProcsCopied:=false;
|
ProcsCopied:=false;
|
||||||
|
Bodies:=nil;
|
||||||
try
|
try
|
||||||
GuessMethodDefBodyMapping(ClassProcs,ProcBodyNodes);
|
GuessMethodDefBodyMapping(ClassProcs,ProcBodyNodes);
|
||||||
|
|
||||||
// replace body proc head(s) with class proc head(s)
|
// replace body proc head(s) with class proc head(s)
|
||||||
|
Bodies:=TFPList.Create;
|
||||||
BodyAVLNode:=ProcBodyNodes.FindLowest;
|
BodyAVLNode:=ProcBodyNodes.FindLowest;
|
||||||
while BodyAVLNode<>nil do begin
|
while BodyAVLNode<>nil do begin
|
||||||
BodyNodeExt:=TCodeTreeNodeExtension(BodyAVLNode.Data);
|
Bodies.Add(BodyAVLNode.Data);
|
||||||
|
BodyAVLNode:=ProcBodyNodes.FindSuccessor(BodyAVLNode);
|
||||||
|
end;
|
||||||
|
for i:=0 to Bodies.Count-1 do begin
|
||||||
|
BodyNodeExt:=TCodeTreeNodeExtension(Bodies[i]);
|
||||||
DefNodeExt:=TCodeTreeNodeExtension(BodyNodeExt.Data);
|
DefNodeExt:=TCodeTreeNodeExtension(BodyNodeExt.Data);
|
||||||
if DefNodeExt<>nil then begin
|
if DefNodeExt<>nil then begin
|
||||||
// this body has a definition
|
// this body has a definition
|
||||||
@ -7559,18 +7567,20 @@ begin
|
|||||||
Indent:=GetLineIndent(Src,InsertPos);
|
Indent:=GetLineIndent(Src,InsertPos);
|
||||||
NewProcCode:=ASourceChangeCache.BeautifyCodeOptions.BeautifyProc(
|
NewProcCode:=ASourceChangeCache.BeautifyCodeOptions.BeautifyProc(
|
||||||
NewProcCode,Indent,false);
|
NewProcCode,Indent,false);
|
||||||
debugln(['UpdateProcBodySignatures OLD=',copy(Src,InsertPos,InsertEndPos-InsertPos),' New=',NewProcCode]);
|
//debugln(['UpdateProcBodySignatures OLD=',copy(Src,InsertPos,InsertEndPos-InsertPos),' New=',NewProcCode]);
|
||||||
ProcsCopied:=true;
|
ProcsCopied:=true;
|
||||||
if not ASourceChangeCache.Replace(gtNone,gtNone,InsertPos,InsertEndPos,NewProcCode) then
|
if not ASourceChangeCache.Replace(gtNone,gtNone,InsertPos,InsertEndPos,NewProcCode) then
|
||||||
exit(false);
|
exit(false);
|
||||||
end;
|
end;
|
||||||
// mark body as exactly the same as definition, so that no new body is
|
// change body signature as exactly the same as definition,
|
||||||
// created for this definition
|
// so that no new body is created for this definition
|
||||||
|
ProcBodyNodes.RemovePointer(BodyNodeExt);
|
||||||
BodyNodeExt.Txt:=DefNodeExt.Txt;
|
BodyNodeExt.Txt:=DefNodeExt.Txt;
|
||||||
|
ProcBodyNodes.Add(BodyNodeExt);
|
||||||
end;
|
end;
|
||||||
BodyAVLNode:=ProcBodyNodes.FindSuccessor(BodyAVLNode);
|
|
||||||
end;
|
end;
|
||||||
finally
|
finally
|
||||||
|
FreeAndNil(Bodies);
|
||||||
ClearNodeExtData(ProcBodyNodes);
|
ClearNodeExtData(ProcBodyNodes);
|
||||||
ClearNodeExtData(ClassProcs);
|
ClearNodeExtData(ClassProcs);
|
||||||
end;
|
end;
|
||||||
@ -8073,6 +8083,17 @@ begin
|
|||||||
ClassProcs:=GatherClassProcDefinitions(CodeCompleteClassNode,true);
|
ClassProcs:=GatherClassProcDefinitions(CodeCompleteClassNode,true);
|
||||||
ProcBodyNodes:=GatherClassProcBodies(CodeCompleteClassNode);
|
ProcBodyNodes:=GatherClassProcBodies(CodeCompleteClassNode);
|
||||||
|
|
||||||
|
{AnAVLNode:=ClassProcs.FindLowest;
|
||||||
|
while AnAVLNode<>nil do begin
|
||||||
|
DebugLn(' Gathered ProcDef ',TCodeTreeNodeExtension(AnAVLNode.Data).Txt);
|
||||||
|
AnAVLNode:=ClassProcs.FindSuccessor(AnAVLNode);
|
||||||
|
end;
|
||||||
|
AnAVLNode:=ProcBodyNodes.FindLowest;
|
||||||
|
while AnAVLNode<>nil do begin
|
||||||
|
DebugLn(' Gathered ProcBody ',TCodeTreeNodeExtension(AnAVLNode.Data).Txt);
|
||||||
|
AnAVLNode:=ProcBodyNodes.FindSuccessor(AnAVLNode);
|
||||||
|
end; }
|
||||||
|
|
||||||
// find topmost and bottommost proc body
|
// find topmost and bottommost proc body
|
||||||
FindTopMostAndBottomMostProcBodies;
|
FindTopMostAndBottomMostProcBodies;
|
||||||
|
|
||||||
@ -8093,7 +8114,7 @@ begin
|
|||||||
|
|
||||||
{AnAVLNode:=ClassProcs.FindLowest;
|
{AnAVLNode:=ClassProcs.FindLowest;
|
||||||
while AnAVLNode<>nil do begin
|
while AnAVLNode<>nil do begin
|
||||||
DebugLn(' Existing proc headers: ',TCodeTreeNodeExtension(AnAVLNode.Data).Txt);
|
DebugLn(' SignaturesUpdated ProcDef ',TCodeTreeNodeExtension(AnAVLNode.Data).Txt);
|
||||||
AnAVLNode:=ClassProcs.FindSuccessor(AnAVLNode);
|
AnAVLNode:=ClassProcs.FindSuccessor(AnAVLNode);
|
||||||
end;}
|
end;}
|
||||||
|
|
||||||
@ -8101,7 +8122,7 @@ begin
|
|||||||
|
|
||||||
{AnAVLNode:=ClassProcs.FindLowest;
|
{AnAVLNode:=ClassProcs.FindLowest;
|
||||||
while AnAVLNode<>nil do begin
|
while AnAVLNode<>nil do begin
|
||||||
DebugLn(' BBB ',TCodeTreeNodeExtension(AnAVLNode.Data).Txt);
|
DebugLn(' AfterPropsCompleted ',TCodeTreeNodeExtension(AnAVLNode.Data).Txt);
|
||||||
AnAVLNode:=ClassProcs.FindSuccessor(AnAVLNode);
|
AnAVLNode:=ClassProcs.FindSuccessor(AnAVLNode);
|
||||||
end;}
|
end;}
|
||||||
|
|
||||||
@ -8128,8 +8149,13 @@ begin
|
|||||||
|
|
||||||
{AnAVLNode:=ClassProcs.FindLowest;
|
{AnAVLNode:=ClassProcs.FindLowest;
|
||||||
while AnAVLNode<>nil do begin
|
while AnAVLNode<>nil do begin
|
||||||
DebugLn(' CCC ',TCodeTreeNodeExtension(AnAVLNode.Data).Txt);
|
DebugLn(' BeforeAddMissing ProcDef "',TCodeTreeNodeExtension(AnAVLNode.Data).Txt,'"');
|
||||||
AnAVLNode:=ClassProcs.FindSuccessor(AnAVLNode);
|
AnAVLNode:=ClassProcs.FindSuccessor(AnAVLNode);
|
||||||
|
end;
|
||||||
|
AnAVLNode:=ProcBodyNodes.FindLowest;
|
||||||
|
while AnAVLNode<>nil do begin
|
||||||
|
DebugLn(' BeforeAddMissing ProcBody "',TCodeTreeNodeExtension(AnAVLNode.Data).Txt,'"');
|
||||||
|
AnAVLNode:=ProcBodyNodes.FindSuccessor(AnAVLNode);
|
||||||
end; }
|
end; }
|
||||||
|
|
||||||
// search for missing proc bodies
|
// search for missing proc bodies
|
||||||
|
@ -223,7 +223,7 @@ type
|
|||||||
function IsOwnerDependingOnPkg(AnOwner: TObject; const PkgName: string;
|
function IsOwnerDependingOnPkg(AnOwner: TObject; const PkgName: string;
|
||||||
out DependencyOwner: TObject): boolean; virtual; abstract;
|
out DependencyOwner: TObject): boolean; virtual; abstract;
|
||||||
function AddDependencyToOwners(OwnerList: TFPList; APackage: TIDEPackage;
|
function AddDependencyToOwners(OwnerList: TFPList; APackage: TIDEPackage;
|
||||||
OnlyTestIfPossible: boolean = false): TModalResult; virtual; abstract;
|
OnlyTestIfPossible: boolean = false): TModalResult; virtual; abstract; // mrOk or mrIgnore for already connected
|
||||||
function AddUnitDependenciesForComponentClasses(const UnitFilename: string;
|
function AddUnitDependenciesForComponentClasses(const UnitFilename: string;
|
||||||
ComponentClassnames: TStrings;
|
ComponentClassnames: TStrings;
|
||||||
Quiet: boolean = false): TModalResult; virtual; abstract;
|
Quiet: boolean = false): TModalResult; virtual; abstract;
|
||||||
|
Loading…
Reference in New Issue
Block a user