codetools: fixed EnableCodeCompleteTemplates

git-svn-id: trunk@55093 -
This commit is contained in:
mattias 2017-05-26 09:37:40 +00:00
parent 25e07213df
commit 72e6211499

View File

@ -1242,9 +1242,11 @@ begin
end; end;
{$IFDEF EnableCodeCompleteTemplates} {$IFDEF EnableCodeCompleteTemplates}
if ( Expander <> nil ) and Expander.TemplateExists('PrettyColon') then if ( CTTemplateExpander <> nil )
and CTTemplateExpander.TemplateExists('PrettyColon') then
begin begin
InsertTxt:=VariableName+Expander.Expand('PrettyColon','','',[],[])+VariableType+';'; InsertTxt:=VariableName+CTTemplateExpander.Expand('PrettyColon','','',[],[])
+VariableType+';';
end end
else else
{$ENDIF} {$ENDIF}
@ -2986,9 +2988,10 @@ begin
CleanList:=CleanList+';'; CleanList:=CleanList+';';
end; end;
{$IFDEF EnableCodeCompleteTemplates} {$IFDEF EnableCodeCompleteTemplates}
if assigned( Expander ) and Expander.TemplateExists('PrettyColon') then if assigned(CTTemplateExpander)
and CTTemplateExpander.TemplateExists('PrettyColon') then
begin begin
Colon := Expander.Expand('PrettyColon', '','', // Doesn't use linebreak or indentation Colon := CTTemplateExpander.Expand('PrettyColon', '','', // Doesn't use linebreak or indentation
[], [] ); [], [] );
Result:=Result+ParamName+Colon+ParamType; Result:=Result+ParamName+Colon+ParamType;
CleanList:=CleanList+Colon+ParamType; CleanList:=CleanList+Colon+ParamType;
@ -3122,10 +3125,11 @@ const
if IsFunction then if IsFunction then
begin begin
{$IFDEF EnableCodeCompleteTemplates} {$IFDEF EnableCodeCompleteTemplates}
if ( Expander <> nil ) and Expander.TemplateExists('PrettyColon') then if (CTTemplateExpander<>nil)
and CTTemplateExpander.TemplateExists('PrettyColon') then
begin begin
ProcCode:= 'function '+ProcCode+ ProcCode:= 'function '+ProcCode+
Expander.Expand('PrettyColon','','',[],[]) CTTemplateExpander.Expand('PrettyColon','','',[],[])
+FuncType+';'; +FuncType+';';
end end
else else
@ -3327,10 +3331,12 @@ begin
// check if variable already exists // check if variable already exists
if not VarExistsInCodeCompleteClass(UpperCaseStr(VarName)) then begin if not VarExistsInCodeCompleteClass(UpperCaseStr(VarName)) then begin
{$IFDEF EnableCodeCompleteTemplates} {$IFDEF EnableCodeCompleteTemplates}
if ( Expander <> nil ) and Expander.TemplateExists('PrettyColon') then if (CTTemplateExpander<>nil)
and CTTemplateExpander.TemplateExists('PrettyColon') then
begin begin
AddClassInsertion(UpperCaseStr(VarName), AddClassInsertion(UpperCaseStr(VarName),
VarName+Expander.Expand('PrettyColon','','',[],[])+VarType+';',VarName,ncpPublishedVars); VarName+CTTemplateExpander.Expand('PrettyColon','','',[],[])
+VarType+';',VarName,ncpPublishedVars);
end end
else else
@ -6145,11 +6151,12 @@ begin
aClassName:=ExtractClassName(ClassNode,false); aClassName:=ExtractClassName(ClassNode,false);
CleanDef:=ProcName+'('+ParamType+');'; CleanDef:=ProcName+'('+ParamType+');';
{$IFDEF EnableCodeCompleteTemplates} {$IFDEF EnableCodeCompleteTemplates}
if assigned( Expander ) and Expander.TemplateExists('AssignMethodDef') then if assigned(CTTemplateExpander)
and CTTemplateExpander.TemplateExists('AssignMethodDef') then
begin begin
Def := Expander.Expand('AssignMethodDef', '','', // Doesn't use linebreak or indentation Def := CTTemplateExpander.Expand('AssignMethodDef', '','', // Doesn't use linebreak or indentation
['ProcName', 'ParamName', 'ParamType', 'Override' ], ['ProcName', 'ParamName', 'ParamType', 'Override' ],
[ ProcName, ParamName, ParamType, OverrideMod ] ); [ ProcName, ParamName, ParamType, OverrideMod ] );
end else end else
{$ENDIF EnableCodeCompleteTemplates} {$ENDIF EnableCodeCompleteTemplates}
begin begin
@ -6163,7 +6170,8 @@ begin
Indent:=0; Indent:=0;
IndentStep:=SourceChanger.BeautifyCodeOptions.Indent; IndentStep:=SourceChanger.BeautifyCodeOptions.Indent;
{$IFDEF EnableCodeCompleteTemplates} {$IFDEF EnableCodeCompleteTemplates}
if assigned(Expander) and Expander.TemplateExists('AssignMethod') then begin if assigned(CTTemplateExpander)
and CTTemplateExpander.TemplateExists('AssignMethod') then begin
if not SameType then begin if not SameType then begin
// add local variable // add local variable
SrcVar:=LocalVarName; SrcVar:=LocalVarName;
@ -6185,15 +6193,15 @@ begin
NodeExtsStr := NodeExtsStr + NodeExt.Txt + '?'; NodeExtsStr := NodeExtsStr + NodeExt.Txt + '?';
end; end;
end; end;
ProcBody := Expander.Expand( 'AssignMethod',e,GetIndentStr(Indent), ProcBody := CTTemplateExpander.Expand( 'AssignMethod',e,GetIndentStr(Indent),
['ClassName', 'ProcName', 'ParamName', 'ParamType', ['ClassName', 'ProcName', 'ParamName', 'ParamType',
'SameType', 'SrcVar', 'Inherited0', 'Inherited1', 'SameType', 'SrcVar', 'Inherited0', 'Inherited1',
'NodeExt' ], 'NodeExt' ],
[ aClassName, ProcName, ParamName, ParamType, [ aClassName, ProcName, ParamName, ParamType,
SameType, SrcVar, SameType, SrcVar,
CallInherited and (not CallInheritedOnlyInElse), CallInherited and (not CallInheritedOnlyInElse),
CallInherited and CallInheritedOnlyInElse, CallInherited and CallInheritedOnlyInElse,
NodeExtsStr ] ); NodeExtsStr ] );
end end
else else
{$ENDIF EnableCodeCompleteTemplates} {$ENDIF EnableCodeCompleteTemplates}
@ -7472,14 +7480,15 @@ var
} }
{$IFDEF EnableCodeCompleteTemplates} {$IFDEF EnableCodeCompleteTemplates}
if assigned(Expander) and Expander.TemplateExists('SetterMethod') then if assigned(CTTemplateExpander)
and CTTemplateExpander.TemplateExists('SetterMethod') then
begin begin
debugln(['CompleteWriteSpecifier ', 'USING template for SetterMethod']); debugln(['CompleteWriteSpecifier ', 'USING template for SetterMethod']);
ProcBody := Expander.Expand( 'SetterMethod', ProcBody := CTTemplateExpander.Expand( 'SetterMethod',
BeautifyCodeOpts.LineEnd, BeautifyCodeOpts.LineEnd,
GetIndentStr(BeautifyCodeOpts.Indent), GetIndentStr(BeautifyCodeOpts.Indent),
['ClassName', 'AccessParam','PropVarName', 'PropType','VarName'], ['ClassName', 'AccessParam','PropVarName', 'PropType','VarName'],
[ExtractClassName(PropNode.Parent.Parent,false), AccessParam, SetPropertyVariablename, PropType, VariableName] ); [ExtractClassName(PropNode.Parent.Parent,false), AccessParam, SetPropertyVariablename, PropType, VariableName] );
end end
else else
{$ENDIF} {$ENDIF}