mirror of
https://gitlab.com/freepascal.org/lazarus/lazarus.git
synced 2025-08-14 02:19:15 +02:00
Codetools: Fix a problem with event handler generation caused by r33955 #ce5458acf2. Issue #20813
git-svn-id: trunk@33964 -
This commit is contained in:
parent
719c2296c9
commit
a1d1d88896
@ -7067,26 +7067,26 @@ begin
|
|||||||
finally
|
finally
|
||||||
Params.Free;
|
Params.Free;
|
||||||
end;
|
end;
|
||||||
|
ProcCode:=ExtractProcHead(ProcNode,[phpWithStart,phpAddClassname,
|
||||||
|
phpWithVarModifiers,phpWithParameterNames,
|
||||||
|
phpWithResultType,phpWithCallingSpecs]);
|
||||||
|
FullCall:='';
|
||||||
|
if InclProcCall then begin
|
||||||
|
ProcCall:='inherited '+ExtractProcHead(ProcNode,[phpWithoutClassName,
|
||||||
|
phpWithParameterNames,phpWithoutParamTypes]);
|
||||||
|
for i:=1 to length(ProcCall)-1 do
|
||||||
|
if ProcCall[i]=';' then
|
||||||
|
ProcCall[i]:=',';
|
||||||
|
if ProcCall[length(ProcCall)]<>';' then
|
||||||
|
ProcCall:=ProcCall+';';
|
||||||
|
if NodeIsFunction(ProcNode) then
|
||||||
|
ProcCall:=Beauty.BeautifyIdentifier('Result')+':='+ProcCall;
|
||||||
|
FullCall:=GetIndentStr(Beauty.Indent)+ProcCall;
|
||||||
|
end;
|
||||||
|
ProcCode:=ProcCode+Beauty.LineEnd+'begin'+Beauty.LineEnd+FullCall+Beauty.LineEnd+'end;';
|
||||||
|
ProcCode:=Beauty.BeautifyProc(ProcCode,0,false);
|
||||||
|
ANodeExt.ExtTxt3:=ProcCode;
|
||||||
end;
|
end;
|
||||||
ProcCode:=ExtractProcHead(ProcNode,[phpWithStart,phpAddClassname,
|
|
||||||
phpWithVarModifiers,phpWithParameterNames,
|
|
||||||
phpWithResultType,phpWithCallingSpecs]);
|
|
||||||
FullCall:='';
|
|
||||||
if InclProcCall then begin
|
|
||||||
ProcCall:='inherited '+ExtractProcHead(ProcNode,[phpWithoutClassName,
|
|
||||||
phpWithParameterNames,phpWithoutParamTypes]);
|
|
||||||
for i:=1 to length(ProcCall)-1 do
|
|
||||||
if ProcCall[i]=';' then
|
|
||||||
ProcCall[i]:=',';
|
|
||||||
if ProcCall[length(ProcCall)]<>';' then
|
|
||||||
ProcCall:=ProcCall+';';
|
|
||||||
if NodeIsFunction(ProcNode) then
|
|
||||||
ProcCall:=Beauty.BeautifyIdentifier('Result')+':='+ProcCall;
|
|
||||||
FullCall:=GetIndentStr(Beauty.Indent)+ProcCall;
|
|
||||||
end;
|
|
||||||
ProcCode:=ProcCode+Beauty.LineEnd+'begin'+Beauty.LineEnd+FullCall+Beauty.LineEnd+'end;';
|
|
||||||
ProcCode:=Beauty.BeautifyProc(ProcCode,0,false);
|
|
||||||
ANodeExt.ExtTxt3:=ProcCode;
|
|
||||||
end;
|
end;
|
||||||
|
|
||||||
function TCodeCompletionCodeTool.CreateMissingProcBodies: boolean;
|
function TCodeCompletionCodeTool.CreateMissingProcBodies: boolean;
|
||||||
@ -7126,6 +7126,23 @@ var
|
|||||||
end;
|
end;
|
||||||
end;
|
end;
|
||||||
|
|
||||||
|
procedure CreateCodeForMissingProcBody(TheNodeExt: TCodeTreeNodeExtension;
|
||||||
|
Indent: integer);
|
||||||
|
var
|
||||||
|
ANode: TCodeTreeNode;
|
||||||
|
ProcCode: string;
|
||||||
|
begin
|
||||||
|
CheckForOverrideAndAddInheritedCode(TheNodeExt);
|
||||||
|
if (TheNodeExt.ExtTxt1='') and (TheNodeExt.ExtTxt3='') then begin
|
||||||
|
ANode:=TheNodeExt.Node;
|
||||||
|
if (ANode<>nil) and (ANode.Desc=ctnProcedure) then begin
|
||||||
|
ProcCode:=ExtractProcHead(ANode,ProcAttrDefToBody);
|
||||||
|
TheNodeExt.ExtTxt3:=ASourceChangeCache.BeautifyCodeOptions.BeautifyProc(
|
||||||
|
ProcCode,Indent,true);
|
||||||
|
end;
|
||||||
|
end;
|
||||||
|
end;
|
||||||
|
|
||||||
var
|
var
|
||||||
ProcBodyNodes, ClassProcs: TAVLTree;
|
ProcBodyNodes, ClassProcs: TAVLTree;
|
||||||
ANodeExt, ANodeExt2: TCodeTreeNodeExtension;
|
ANodeExt, ANodeExt2: TCodeTreeNodeExtension;
|
||||||
@ -7562,7 +7579,7 @@ begin
|
|||||||
MissingNode:=ClassProcs.FindHighest;
|
MissingNode:=ClassProcs.FindHighest;
|
||||||
while (MissingNode<>nil) do begin
|
while (MissingNode<>nil) do begin
|
||||||
ANodeExt:=TCodeTreeNodeExtension(MissingNode.Data);
|
ANodeExt:=TCodeTreeNodeExtension(MissingNode.Data);
|
||||||
CheckForOverrideAndAddInheritedCode(ANodeExt);
|
CreateCodeForMissingProcBody(ANodeExt,Indent);
|
||||||
InsertProcBody(ANodeExt,InsertPos,Indent);
|
InsertProcBody(ANodeExt,InsertPos,Indent);
|
||||||
MissingNode:=ClassProcs.FindPrecessor(MissingNode);
|
MissingNode:=ClassProcs.FindPrecessor(MissingNode);
|
||||||
end;
|
end;
|
||||||
@ -7652,7 +7669,7 @@ begin
|
|||||||
end;
|
end;
|
||||||
end;
|
end;
|
||||||
end;
|
end;
|
||||||
CheckForOverrideAndAddInheritedCode(ANodeExt);
|
CreateCodeForMissingProcBody(ANodeExt,Indent);
|
||||||
InsertProcBody(ANodeExt,InsertPos,Indent);
|
InsertProcBody(ANodeExt,InsertPos,Indent);
|
||||||
end;
|
end;
|
||||||
MissingNode:=ClassProcs.FindPrecessor(MissingNode);
|
MissingNode:=ClassProcs.FindPrecessor(MissingNode);
|
||||||
|
@ -1467,7 +1467,7 @@ begin
|
|||||||
NewNode:=CursorNode;
|
NewNode:=CursorNode;
|
||||||
CleanCursorPos:=GetIdentStartPosition(Src,CleanCursorPos);
|
CleanCursorPos:=GetIdentStartPosition(Src,CleanCursorPos);
|
||||||
if CursorNode.Desc=ctnVarDefinition then begin
|
if CursorNode.Desc=ctnVarDefinition then begin
|
||||||
// if this is is a parameter, try to find the corresponding declaration
|
// if this is a parameter, try to find the corresponding declaration
|
||||||
NewNode:=FindCorrespondingProcParamNode(NewNode);
|
NewNode:=FindCorrespondingProcParamNode(NewNode);
|
||||||
if (NewNode<>nil) and (NewNode.StartPos<CursorNode.StartPos) then
|
if (NewNode<>nil) and (NewNode.StartPos<CursorNode.StartPos) then
|
||||||
CleanCursorPos:=NewNode.StartPos
|
CleanCursorPos:=NewNode.StartPos
|
||||||
@ -5450,8 +5450,7 @@ begin
|
|||||||
if (WithVarExpr.Desc<>xtContext)
|
if (WithVarExpr.Desc<>xtContext)
|
||||||
or (WithVarExpr.Context.Node=nil)
|
or (WithVarExpr.Context.Node=nil)
|
||||||
or (WithVarExpr.Context.Node=OldInput.ContextNode)
|
or (WithVarExpr.Context.Node=OldInput.ContextNode)
|
||||||
or (not (WithVarExpr.Context.Node.Desc
|
or (not (WithVarExpr.Context.Node.Desc in (AllClasses+[ctnEnumerationType])))
|
||||||
in (AllClasses+[ctnEnumerationType])))
|
|
||||||
then begin
|
then begin
|
||||||
MoveCursorToCleanPos(WithVarNode.StartPos);
|
MoveCursorToCleanPos(WithVarNode.StartPos);
|
||||||
RaiseException(ctsExprTypeMustBeClassOrRecord);
|
RaiseException(ctsExprTypeMustBeClassOrRecord);
|
||||||
|
Loading…
Reference in New Issue
Block a user