(get-text-property 0 'meta candidate))
(defun company-clang--annotation (candidate)
+ (let ((ann (company-clang--annotation-1 candidate)))
+ (if (not (string-prefix-p "(*)" ann))
+ ann
+ (with-temp-buffer
+ (insert ann)
+ (search-backward ")")
+ (let ((pt (1+ (point))))
+ (forward-symbol 1)
+ (delete-region pt (point)))
+ (buffer-string)))))
+
+(defun company-clang--annotation-1 (candidate)
(let ((meta (company-clang--meta candidate)))
(cond
((null meta) nil)
(forward-char)
(setq cnt (company-template--c-like-args templ angle-close
cnt))))
+ (when (looking-back "\\((\\*)\\)(" (line-beginning-position))
+ (delete-region (match-beginning 1) (match-end 1)))
(when paren-open
(goto-char paren-open)
(company-template--c-like-args templ paren-close cnt)))
"shared_ptr<_Tp> make_shared<typename _Tp>(_Args &&__args...)")))
(should (equal (company-clang 'annotation str)
"<typename _Tp>(_Args &&__args...)"))))
+
+(ert-deftest company-clang-func-ptr-annotation ()
+ (let ((str (propertize "foo" 'meta "void (*)(int) foo")))
+ (should (equal (company-clang 'annotation str) "(*)(int)"))))
(forward-char -1)
(should (equal "Dict<TKey, TValue>"
(overlay-get (company-template-field-at) 'display))))))
+
+(ert-deftest company-template-c-like-func-ptr ()
+ (with-temp-buffer
+ (let ((text "foo(*)(int)"))
+ (insert text)
+ (company-template-c-like-templatify text)
+ (should (equal "foo(arg0)" (buffer-string)))
+ (should (looking-at "arg0"))
+ (should (equal "int" (overlay-get (company-template-field-at) 'display))))))