From 42e38ce9919a76ff87726c19bfcb76f931917f6c Mon Sep 17 00:00:00 2001 From: Juha Date: Fri, 14 Jan 2022 12:57:04 +0200 Subject: [PATCH] Revert the assignment ':=' commit. It is useless without the parameter list and fails to work always. Issue #39545. --- components/codetools/identcompletiontool.pas | 12 ++++---- components/codetools/pascalreadertool.pas | 31 +++++++------------- ide/sourceeditprocs.pas | 9 ++---- 3 files changed, 19 insertions(+), 33 deletions(-) diff --git a/components/codetools/identcompletiontool.pas b/components/codetools/identcompletiontool.pas index d6165d72eb..2db4f0abcb 100644 --- a/components/codetools/identcompletiontool.pas +++ b/components/codetools/identcompletiontool.pas @@ -161,7 +161,7 @@ type function IsPropertyReadOnly: boolean; function GetHintModifiers: TPascalHintModifiers; function CheckHasChilds: boolean; - function CanBeAssigned(ADesc: TCodeTreeNodeDesc): boolean; + function CanBeAssigned: boolean; procedure UpdateBaseContext; function HasChilds: boolean; function HasIndex: boolean; @@ -4018,6 +4018,8 @@ var ANode: TCodeTreeNode; StartPos: Integer; begin + Result:=(GetDesc=ctnProcedure); + if not Result then exit; if (iliParamNameListValid in Flags) then begin StartPos:=1; while (StartPos<=length(FParamTypeList)) @@ -4120,16 +4122,16 @@ begin Result:=true; end; -function TIdentifierListItem.CanBeAssigned(ADesc: TCodeTreeNodeDesc): boolean; +function TIdentifierListItem.CanBeAssigned: boolean; var ANode: TCodeTreeNode; begin Result:=false; ANode:=Node; - Assert(Assigned(ANode), 'CanBeAssigned: Node=Nil'); - if (ADesc=ctnVarDefinition) then + if (ANode=nil) then exit; + if (GetDesc=ctnVarDefinition) then Result:=true; - if (ADesc in [ctnProperty,ctnGlobalProperty]) then begin + if (ANode.Desc in [ctnProperty,ctnGlobalProperty]) then begin if Tool.PropertyHasSpecifier(ANode,'WRITE') then exit(true); if Tool.PropNodeIsTypeLess(ANode) then begin exit(true);// ToDo: search the real property definition diff --git a/components/codetools/pascalreadertool.pas b/components/codetools/pascalreadertool.pas index df01e7a61a..c79cf80105 100644 --- a/components/codetools/pascalreadertool.pas +++ b/components/codetools/pascalreadertool.pas @@ -3348,34 +3348,23 @@ begin end; function TPascalReaderTool.ProcNodeHasParamList(ProcNode: TCodeTreeNode): boolean; -var - ChildNode: TCodeTreeNode; begin // ToDo: ppu, dcu Result:=false; if ProcNode=nil then exit; - ChildNode:=ProcNode.FirstChild; - // A variable of procedure type. - if (ProcNode.Desc=ctnVarDefinition) - and Assigned(ChildNode) and (ChildNode.Desc=ctnProcedureType) then - begin - ProcNode:=ChildNode.FirstChild; // ctnProcedureHead - if Assigned(ProcNode) then - ChildNode:=ProcNode.FirstChild; // There is no ctnParameterList. Why? - end - // Procedure - else if ProcNode.Desc=ctnProcedure then - ProcNode:=ChildNode; - - if Assigned(ProcNode) and (ProcNode.Desc=ctnProcedureHead) then - begin - if Assigned(ChildNode) then - exit(ChildNode.Desc=ctnParameterList); - MoveCursorBehindProcName(ProcNode); - Result:=CurPos.Flag=cafRoundBracketOpen; + if ProcNode.Desc=ctnProcedure then begin + ProcNode:=ProcNode.FirstChild; + if ProcNode=nil then exit; end; + if ProcNode.Desc<>ctnProcedureHead then exit; + if ProcNode.FirstChild<>nil then begin + Result:=ProcNode.FirstChild.Desc=ctnParameterList; + exit; + end; + MoveCursorBehindProcName(ProcNode); + Result:=CurPos.Flag=cafRoundBracketOpen; end; function TPascalReaderTool.ProcNodeHasOfObject(ProcNode: TCodeTreeNode): boolean; diff --git a/ide/sourceeditprocs.pas b/ide/sourceeditprocs.pas index a645092366..209d2dc061 100644 --- a/ide/sourceeditprocs.pas +++ b/ide/sourceeditprocs.pas @@ -782,7 +782,7 @@ var IdentList: TIdentifierList; CanAddSemicolon, CanAddComma, CursorAtEnd, IsReadOnly: boolean; ProcHeadFlags: TProcHeadAttributes; - ClassNode: TCodeTreeNode; // For a class node or a procedure type node. + ClassNode: TCodeTreeNode; Dsc: TCodeTreeNodeDesc; Line, s: string; StartContextPos: TCodeXYPosition; @@ -809,11 +809,6 @@ begin Dsc:=IdentItem.GetDesc; //DebugLn(['GetIdentCompletionValue IdentItem.GetDesc=',NodeDescriptionAsString(Dsc), // ', IdentList.ContextFlags=',dbgs(IdentList.ContextFlags),' IdentItem.Node=',IdentItem.Node<>nil]); - if Dsc=ctnVarDefinition then begin - ClassNode:=IdentItem.Node.FirstChild; - if Assigned(ClassNode) and (ClassNode.Desc=ctnProcedureType) then - Dsc:=ctnProcedure; - end; case Dsc of @@ -924,7 +919,7 @@ begin and (not IsReadOnly) and (not IdentList.StartUpAtomBehindIs(':=')) and (not IdentList.StartUpAtomBehindIs('(')) - and (IdentItem.CanBeAssigned(Dsc)) + and (IdentItem.CanBeAssigned) and CodeToolsOpts.IdentComplAddAssignOperator then begin if (atIdentifier in CodeToolsOpts.DoInsertSpaceAfter) or (atSymbol in CodeToolsOpts.DoInsertSpaceInFront) then