From dd43ceac8e39d07a4b0c2b7325a56de2abfc1474 Mon Sep 17 00:00:00 2001 From: mattias Date: Sun, 24 Sep 2017 16:38:12 +0000 Subject: [PATCH] codetools: property completion: fixed check if store accessor with index specififer exists git-svn-id: trunk@55915 - --- components/codetools/codecompletiontool.pas | 47 +++++++++++++-------- 1 file changed, 30 insertions(+), 17 deletions(-) diff --git a/components/codetools/codecompletiontool.pas b/components/codetools/codecompletiontool.pas index 7a3df839db..19eb43f128 100644 --- a/components/codetools/codecompletiontool.pas +++ b/components/codetools/codecompletiontool.pas @@ -486,6 +486,7 @@ function TCodeCompletionCodeTool.FindProcInCodeCompleteClass( // NameAndParams should be uppercase and contains the proc name and the // parameter list without names and default values // and should not contain any comments and no result type +// e.g. DOIT(LONGINT;STRING) var ANodeExt: TCodeTreeNodeExtension; Params: TFindDeclarationParams; @@ -7574,28 +7575,40 @@ var end else AccessParam:=PropName +BeautifyCodeOpts.PropertyStoredIdentPostfix; - CleanAccessFunc:=UpperCaseStr(AccessParam); - // check if procedure exists - if (not ProcExistsInCodeCompleteClass(CleanAccessFunc+';')) - and (not VarExistsInCodeCompleteClass(CleanAccessFunc)) - then begin - // add insert demand for function - // build function code - if Parts[ppIndexWord].StartPos < 1 then begin - // no index + if (Parts[ppIndexWord].StartPos<1) then begin + // no index -> check if method or field exists + CleanAccessFunc:=UpperCaseStr(AccessParam); + if (not ProcExistsInCodeCompleteClass(CleanAccessFunc+';')) + and (not VarExistsInCodeCompleteClass(CleanAccessFunc)) + then begin + // add insert demand for function + // build function code AccessFunc := 'function ' + AccessParam + ':Boolean;'; CleanAccessFunc := CleanAccessFunc+';'; - end else begin - // index + if IsClassProp then + AccessFunc:='class '+AccessFunc+' static;';; + // add new Insert Node + if CompleteProperties then + AddClassInsertion(CleanAccessFunc,AccessFunc,AccessParam, + ncpPrivateProcs,PropNode); + end; + end else begin + // has index specifier -> check if method exists + CleanAccessFunc:=UpperCaseStr(AccessParam); + if (not ProcExistsInCodeCompleteClass(CleanAccessFunc+'('+UpperCaseStr(IndexType)+');')) + and (not VarExistsInCodeCompleteClass(CleanAccessFunc)) + then begin + // add insert demand for function + // build function code AccessFunc := 'function ' + AccessParam + '(AIndex:'+IndexType+'):Boolean;'; CleanAccessFunc := UpperCaseStr(CleanAccessFunc + '('+IndexType+');'); + if IsClassProp then + AccessFunc:='class '+AccessFunc+' static;';; + // add new Insert Node + if CompleteProperties then + AddClassInsertion(CleanAccessFunc,AccessFunc,AccessParam, + ncpPrivateProcs,PropNode); end; - if IsClassProp then - AccessFunc:='class '+AccessFunc+' static;';; - // add new Insert Node - if CompleteProperties then - AddClassInsertion(CleanAccessFunc,AccessFunc,AccessParam, - ncpPrivateProcs,PropNode); end; if Parts[ppStored].StartPos<0 then begin // insert stored specifier