mirror of
https://gitlab.com/freepascal.org/lazarus/lazarus.git
synced 2025-08-14 14:01:49 +02:00
Codetools: Improve code completion for methods overriding an abstract base method.
git-svn-id: trunk@33983 -
This commit is contained in:
parent
6bec10272d
commit
cafb155a02
@ -7009,8 +7009,7 @@ begin
|
|||||||
if FindNodeInTree(ClassProcs,ANodeExt.Txt)=nil then begin
|
if FindNodeInTree(ClassProcs,ANodeExt.Txt)=nil then begin
|
||||||
NewNodeExt:=TCodeTreeNodeExtension.Create;
|
NewNodeExt:=TCodeTreeNodeExtension.Create;
|
||||||
with NewNodeExt do begin
|
with NewNodeExt do begin
|
||||||
Txt:=UpperCaseStr(TheClassName)+'.'
|
Txt:=UpperCaseStr(TheClassName)+'.'+ANodeExt.Txt; // Name+ParamTypeList
|
||||||
+ANodeExt.Txt; // Name+ParamTypeList
|
|
||||||
ExtTxt1:=ASourceChangeCache.BeautifyCodeOptions.AddClassAndNameToProc(
|
ExtTxt1:=ASourceChangeCache.BeautifyCodeOptions.AddClassAndNameToProc(
|
||||||
ANodeExt.ExtTxt1,TheClassName,''); // complete proc head code
|
ANodeExt.ExtTxt1,TheClassName,''); // complete proc head code
|
||||||
ExtTxt3:=ANodeExt.ExtTxt3;
|
ExtTxt3:=ANodeExt.ExtTxt3;
|
||||||
@ -7032,7 +7031,7 @@ procedure TCodeCompletionCodeTool.CheckForOverrideAndAddInheritedCode(
|
|||||||
ANodeExt: TCodeTreeNodeExtension);
|
ANodeExt: TCodeTreeNodeExtension);
|
||||||
// check for 'override' directive and add 'inherited' code to body
|
// check for 'override' directive and add 'inherited' code to body
|
||||||
var
|
var
|
||||||
ProcCode, ProcCall, FullCall: string;
|
ProcCode, ProcCall: string;
|
||||||
ProcNode, ClassNode: TCodeTreeNode;
|
ProcNode, ClassNode: TCodeTreeNode;
|
||||||
i: integer;
|
i: integer;
|
||||||
InclProcCall: Boolean;
|
InclProcCall: Boolean;
|
||||||
@ -7058,8 +7057,9 @@ begin
|
|||||||
Params.IdentifierTool:=Params.NewCodeTool;
|
Params.IdentifierTool:=Params.NewCodeTool;
|
||||||
// FirstChild skips keyword 'procedure' or 'function'
|
// FirstChild skips keyword 'procedure' or 'function'
|
||||||
Params.SetIdentifier(Self,@Src[ProcNode.FirstChild.StartPos],nil);
|
Params.SetIdentifier(Self,@Src[ProcNode.FirstChild.StartPos],nil);
|
||||||
if FindIdentifierInContext(Params) then // Found ancestor definition.
|
// Found ancestor definition.
|
||||||
if Params.NewNode<>nil then begin
|
if FindIdentifierInContext(Params) then begin
|
||||||
|
if Params.NewNode<>nil then
|
||||||
InclProcCall:=not ProcNodeHasSpecifier(Params.NewNode,psABSTRACT);
|
InclProcCall:=not ProcNodeHasSpecifier(Params.NewNode,psABSTRACT);
|
||||||
Break;
|
Break;
|
||||||
end;
|
end;
|
||||||
@ -7067,11 +7067,10 @@ begin
|
|||||||
finally
|
finally
|
||||||
Params.Free;
|
Params.Free;
|
||||||
end;
|
end;
|
||||||
|
if InclProcCall then begin
|
||||||
ProcCode:=ExtractProcHead(ProcNode,[phpWithStart,phpAddClassname,
|
ProcCode:=ExtractProcHead(ProcNode,[phpWithStart,phpAddClassname,
|
||||||
phpWithVarModifiers,phpWithParameterNames,
|
phpWithVarModifiers,phpWithParameterNames,
|
||||||
phpWithResultType,phpWithCallingSpecs]);
|
phpWithResultType,phpWithCallingSpecs]);
|
||||||
FullCall:='';
|
|
||||||
if InclProcCall then begin
|
|
||||||
ProcCall:='inherited '+ExtractProcHead(ProcNode,[phpWithoutClassName,
|
ProcCall:='inherited '+ExtractProcHead(ProcNode,[phpWithoutClassName,
|
||||||
phpWithParameterNames,phpWithoutParamTypes]);
|
phpWithParameterNames,phpWithoutParamTypes]);
|
||||||
for i:=1 to length(ProcCall)-1 do
|
for i:=1 to length(ProcCall)-1 do
|
||||||
@ -7081,13 +7080,13 @@ begin
|
|||||||
ProcCall:=ProcCall+';';
|
ProcCall:=ProcCall+';';
|
||||||
if NodeIsFunction(ProcNode) then
|
if NodeIsFunction(ProcNode) then
|
||||||
ProcCall:=Beauty.BeautifyIdentifier('Result')+':='+ProcCall;
|
ProcCall:=Beauty.BeautifyIdentifier('Result')+':='+ProcCall;
|
||||||
FullCall:=GetIndentStr(Beauty.Indent)+ProcCall;
|
ProcCode:=ProcCode+Beauty.LineEnd+'begin'+Beauty.LineEnd
|
||||||
end;
|
+GetIndentStr(Beauty.Indent)+ProcCall+Beauty.LineEnd+'end;';
|
||||||
ProcCode:=ProcCode+Beauty.LineEnd+'begin'+Beauty.LineEnd+FullCall+Beauty.LineEnd+'end;';
|
|
||||||
ProcCode:=Beauty.BeautifyProc(ProcCode,0,false);
|
ProcCode:=Beauty.BeautifyProc(ProcCode,0,false);
|
||||||
ANodeExt.ExtTxt3:=ProcCode;
|
ANodeExt.ExtTxt3:=ProcCode;
|
||||||
end;
|
end;
|
||||||
end;
|
end;
|
||||||
|
end;
|
||||||
|
|
||||||
function TCodeCompletionCodeTool.CreateMissingProcBodies: boolean;
|
function TCodeCompletionCodeTool.CreateMissingProcBodies: boolean;
|
||||||
const
|
const
|
||||||
|
Loading…
Reference in New Issue
Block a user