diff --git a/components/codetools/codecompletiontool.pas b/components/codetools/codecompletiontool.pas index 88c0c77fbc..9751f7ba53 100644 --- a/components/codetools/codecompletiontool.pas +++ b/components/codetools/codecompletiontool.pas @@ -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); diff --git a/components/codetools/finddeclarationtool.pas b/components/codetools/finddeclarationtool.pas index dce4479e2a..e0ddd94258 100644 --- a/components/codetools/finddeclarationtool.pas +++ b/components/codetools/finddeclarationtool.pas @@ -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.StartPosxtContext) 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);