mirror of
https://gitlab.com/freepascal.org/lazarus/lazarus.git
synced 2025-08-10 04:36:32 +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
|
||||
Params.Free;
|
||||
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;
|
||||
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;
|
||||
|
||||
function TCodeCompletionCodeTool.CreateMissingProcBodies: boolean;
|
||||
@ -7126,6 +7126,23 @@ var
|
||||
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
|
||||
ProcBodyNodes, ClassProcs: TAVLTree;
|
||||
ANodeExt, ANodeExt2: TCodeTreeNodeExtension;
|
||||
@ -7562,7 +7579,7 @@ begin
|
||||
MissingNode:=ClassProcs.FindHighest;
|
||||
while (MissingNode<>nil) do begin
|
||||
ANodeExt:=TCodeTreeNodeExtension(MissingNode.Data);
|
||||
CheckForOverrideAndAddInheritedCode(ANodeExt);
|
||||
CreateCodeForMissingProcBody(ANodeExt,Indent);
|
||||
InsertProcBody(ANodeExt,InsertPos,Indent);
|
||||
MissingNode:=ClassProcs.FindPrecessor(MissingNode);
|
||||
end;
|
||||
@ -7652,7 +7669,7 @@ begin
|
||||
end;
|
||||
end;
|
||||
end;
|
||||
CheckForOverrideAndAddInheritedCode(ANodeExt);
|
||||
CreateCodeForMissingProcBody(ANodeExt,Indent);
|
||||
InsertProcBody(ANodeExt,InsertPos,Indent);
|
||||
end;
|
||||
MissingNode:=ClassProcs.FindPrecessor(MissingNode);
|
||||
|
@ -1467,7 +1467,7 @@ begin
|
||||
NewNode:=CursorNode;
|
||||
CleanCursorPos:=GetIdentStartPosition(Src,CleanCursorPos);
|
||||
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);
|
||||
if (NewNode<>nil) and (NewNode.StartPos<CursorNode.StartPos) then
|
||||
CleanCursorPos:=NewNode.StartPos
|
||||
@ -5450,8 +5450,7 @@ begin
|
||||
if (WithVarExpr.Desc<>xtContext)
|
||||
or (WithVarExpr.Context.Node=nil)
|
||||
or (WithVarExpr.Context.Node=OldInput.ContextNode)
|
||||
or (not (WithVarExpr.Context.Node.Desc
|
||||
in (AllClasses+[ctnEnumerationType])))
|
||||
or (not (WithVarExpr.Context.Node.Desc in (AllClasses+[ctnEnumerationType])))
|
||||
then begin
|
||||
MoveCursorToCleanPos(WithVarNode.StartPos);
|
||||
RaiseException(ctsExprTypeMustBeClassOrRecord);
|
||||
|
Loading…
Reference in New Issue
Block a user