Revert the assignment ':=' commit. It is useless without the parameter list and fails to work always. Issue #39545.

This commit is contained in:
Juha 2022-01-14 12:57:04 +02:00
parent 334d1265da
commit 42e38ce991
3 changed files with 19 additions and 33 deletions

View File

@ -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

View File

@ -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;

View File

@ -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