[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
[elpa] master 5fc4a9a 034/173: Update company-clang-objc-templatify in l
From: |
Dmitry Gutov |
Subject: |
[elpa] master 5fc4a9a 034/173: Update company-clang-objc-templatify in line with the previous change |
Date: |
Thu, 23 Jun 2016 00:28:36 +0000 (UTC) |
branch: master
commit 5fc4a9a0b0c75f4f128ad01ca8befd1928399c86
Author: Dmitry Gutov <address@hidden>
Commit: Dmitry Gutov <address@hidden>
Update company-clang-objc-templatify in line with the previous change
---
NEWS.md | 1 +
company-clang.el | 18 ------------------
company-template.el | 27 +++++++++++++++++++++++++++
test/clang-tests.el | 9 ---------
test/template-tests.el | 17 +++++++++++++++++
5 files changed, 45 insertions(+), 27 deletions(-)
diff --git a/NEWS.md b/NEWS.md
index b464b8e..ff92863 100644
--- a/NEWS.md
+++ b/NEWS.md
@@ -6,6 +6,7 @@
values with `argN` anymore
([#336](https://github.com/company-mode/company-mode/issues/336)). This
affects `company-clang` and all third-party backends that use this function.
+* Likewise for `company-clang-objc-templatify`.
* `company-template-add-field` calling convention has changed.
* New user option `company-dabbrev-ignore-invisible`.
* `company-ropemacs` was removed. `ropemacs` supports completion via
diff --git a/company-clang.el b/company-clang.el
index cc392e4..d0e2b84 100644
--- a/company-clang.el
+++ b/company-clang.el
@@ -289,24 +289,6 @@ or automatically through a custom
`company-clang-prefix-guesser'."
ver))
0)))
-(defun company-clang-objc-templatify (selector)
- (let* ((end (point-marker))
- (beg (- (point) (length selector) 1))
- (templ (company-template-declare-template beg end))
- (cnt 0))
- (save-excursion
- (goto-char beg)
- (catch 'stop
- (while (search-forward ":" end t)
- (when (looking-at "([^)]*) ?")
- (delete-region (match-beginning 0) (match-end 0)))
- (company-template-add-field templ (point) (format "arg%d" cnt))
- (if (< (point) end)
- (insert " ")
- (throw 'stop t))
- (cl-incf cnt))))
- (company-template-move-to-first templ)))
-
(defun company-clang (command &optional arg &rest ignored)
"`company-mode' completion back-end for Clang.
Clang is a parser for C and ObjC. Clang version 1.1 or newer is required.
diff --git a/company-template.el b/company-template.el
index 9c42545..d90458c 100644
--- a/company-template.el
+++ b/company-template.el
@@ -183,5 +183,32 @@ Leave point at the end of the field."
(skip-chars-forward " ")
(setq last-pos (point))))))
+;; objc ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
+
+(defun company-clang-objc-templatify (selector)
+ (let* ((end (point-marker))
+ (beg (- (point) (length selector) 1))
+ (templ (company-template-declare-template beg end))
+ (cnt 0))
+ (save-excursion
+ (goto-char beg)
+ (catch 'stop
+ (while (search-forward ":" end t)
+ (if (looking-at "\\(([^)]*)\\) ?")
+ (company-template-add-field templ (point) (match-end 1))
+ ;; Not sure which conditions this case manifests under, but
+ ;; apparently it did before, when I wrote the first test for this
+ ;; function. FIXME: Revisit it.
+ (company-template-add-field templ (point)
+ (progn
+ (insert (format "arg%d" cnt))
+ (point)))
+ (when (< (point) end)
+ (insert " "))
+ (cl-incf cnt))
+ (when (>= (point) end)
+ (throw 'stop t)))))
+ (company-template-move-to-first templ)))
+
(provide 'company-template)
;;; company-template.el ends here
diff --git a/test/clang-tests.el b/test/clang-tests.el
index abe690b..2b8b105 100644
--- a/test/clang-tests.el
+++ b/test/clang-tests.el
@@ -22,15 +22,6 @@
(require 'company-tests)
(require 'company-clang)
-(ert-deftest company-clang-objc-templatify ()
- (with-temp-buffer
- (let ((text "createBookWithTitle:andAuthor:"))
- (insert text)
- (company-clang-objc-templatify text)
- (should (equal "createBookWithTitle:arg0 andAuthor:arg1"
(buffer-string)))
- (should (looking-at "arg0"))
- (should (null (overlay-get (company-template-field-at) 'display))))))
-
(ert-deftest company-clang-simple-annotation ()
(let ((str (propertize
"foo" 'meta
diff --git a/test/template-tests.el b/test/template-tests.el
index 3917d2d..4db3ce3 100644
--- a/test/template-tests.el
+++ b/test/template-tests.el
@@ -100,3 +100,20 @@
(company-template-c-like-templatify text)
(should (equal (buffer-string) "foo(int)"))
(company-template-field-assert-text "int"))))
+
+(ert-deftest company-clang-objc-templatify-empty-args ()
+ (with-temp-buffer
+ (let ((text "createBookWithTitle:andAuthor:"))
+ (insert text)
+ (company-clang-objc-templatify text)
+ (should (equal "createBookWithTitle:arg0 andAuthor:arg1"
(buffer-string)))
+ (should (looking-at "arg0"))
+ (should (null (overlay-get (company-template-field-at) 'display))))))
+
+(ert-deftest company-clang-objc-templatify ()
+ (with-temp-buffer
+ (let ((text "createBookWithTitle:(NSString) andAuthor:(id)"))
+ (insert text)
+ (company-clang-objc-templatify text)
+ (should (equal (buffer-string) text))
+ (company-template-field-assert-text "(NSString)"))))
- [elpa] master 22ecb92 001/173: company-clang--start-process: Disable undo in the output buffer, (continued)
- [elpa] master 22ecb92 001/173: company-clang--start-process: Disable undo in the output buffer, Dmitry Gutov, 2016/06/22
- [elpa] master 5fe84a2 028/173: Merge pull request #334 from vermiculus/patch-1, Dmitry Gutov, 2016/06/22
- [elpa] master 2de213e 032/173: company-dabbrev--search-buffer: Save match data, Dmitry Gutov, 2016/06/22
- [elpa] master a0ba593 029/173: Drop githalytics link, Dmitry Gutov, 2016/06/22
- [elpa] master 6301093 023/173: Clarify the meaning of cdr in the prefix cons, Dmitry Gutov, 2016/06/22
- [elpa] master 9f67f1e 027/173: Fix docstring, Dmitry Gutov, 2016/06/22
- [elpa] master 17e6d19 016/173: Remove company-pysmell, Dmitry Gutov, 2016/06/22
- [elpa] master 733d4a9 019/173: Merge pull request #318 from iqbalansari/master, Dmitry Gutov, 2016/06/22
- [elpa] master 7ad049d 031/173: Fix the svg url, Dmitry Gutov, 2016/06/22
- [elpa] master 5296784 038/173: company-template: Add a summary line, Dmitry Gutov, 2016/06/22
- [elpa] master 5fc4a9a 034/173: Update company-clang-objc-templatify in line with the previous change,
Dmitry Gutov <=
- [elpa] master abe46da 037/173: company-files: Skip disconnected remote completions for "/xyz", Dmitry Gutov, 2016/06/22
- [elpa] master 1f1925f 005/173: company-backends: Make the version check more conservative, Dmitry Gutov, 2016/06/22
- [elpa] master 9486563 035/173: Accept markers in the data returned by c-a-p-f functions, Dmitry Gutov, 2016/06/22
- [elpa] master c08dbc1 039/173: Don't use `sit-for', Dmitry Gutov, 2016/06/22
- [elpa] master 1dce769 036/173: company-version: Require find-func, Dmitry Gutov, 2016/06/22
- [elpa] master 5b736e9 024/173: Introduce company-dabbrev-ignore-invisible, Dmitry Gutov, 2016/06/22
- [elpa] master b20726c 026/173: string-prefix-p signals error on nil in Emacs < 25, Dmitry Gutov, 2016/06/22
- [elpa] master 27c913a 040/173: Don't use `require-match t' in normal backends, Dmitry Gutov, 2016/06/22
- [elpa] master 4ba4264 047/173: company--begin-new: Reorder statements, Dmitry Gutov, 2016/06/22
- [elpa] master 9c8364d 049/173: company-keywords: Support scala-mode, Dmitry Gutov, 2016/06/22