-;;; company-eclim.el --- A company-mode completion back-end for eclim.
+;;; company-eclim.el --- company-mode completion back-end for Eclim
;; Copyright (C) 2009, 2011, 2013 Free Software Foundation, Inc.
(require 'company-template)
(eval-when-compile (require 'cl))
+(defgroup company-eclim nil
+ "Completion back-end for Eclim."
+ :group 'company)
+
(defun company-eclim-executable-find ()
(let (file)
(dolist (eclipse-root '("/Applications/eclipse" "/usr/lib/eclipse"
(defcustom company-eclim-executable
(or (executable-find "eclim") (company-eclim-executable-find))
"Location of eclim executable."
- :group 'company
:type 'file)
(defcustom company-eclim-auto-save t
"Determines whether to save the buffer when retrieving completions.
eclim can only complete correctly when the buffer has been saved."
- :group 'company
:type '(choice (const :tag "Off" nil)
(const :tag "On" t)))
(defvar company-eclim--doc nil)
(make-variable-buffer-local 'company-eclim--doc)
+(declare-function json-read "json")
+(defvar json-array-type)
+
(defun company-eclim--call-process (&rest args)
(let ((coding-system-for-read 'utf-8)
res)
(defun company-eclim--candidates (prefix)
(interactive "d")
(let ((project-file (file-relative-name buffer-file-name
- (company-eclim--project-dir)))
- (project-name (company-eclim--project-name)))
+ (company-eclim--project-dir))))
(when company-eclim-auto-save
(when (buffer-modified-p)
(basic-save-buffer))
(defun company-eclim--meta (candidate)
(gethash candidate company-eclim--doc))
-(defun company-eclim--templatify (call)
- (let* ((end (point))
- (beg (- (point) (length call)))
- (templ (company-template-declare-template beg end)))
- (save-excursion
- (goto-char beg)
- (while (re-search-forward "\\([(,] ?\\)\\([^ ]+ \\)\\([^ ,)]*\\)" end t)
- (let ((name (match-string 3)))
- (replace-match "\\1" t)
- (decf end (length (match-string 2)))
- (company-template-add-field templ (point) name))))
- (company-template-move-to-first templ)))
+(defun company-eclim--prefix ()
+ (let ((prefix (company-grab-symbol)))
+ (when prefix
+ ;; Completion candidates for annotations don't include '@'.
+ (when (eq ?@ (string-to-char prefix))
+ (setq prefix (substring prefix 1)))
+ prefix)))
(defun company-eclim (command &optional arg &rest ignored)
- "A `company-mode' completion back-end for Eclim.
+ "`company-mode' completion back-end for Eclim.
Eclim provides access to Eclipse Java IDE features for other editors.
Eclim version 1.7.13 or newer (?) is required.
company-eclim-executable
(company-eclim--project-name)
(not (company-in-string-or-comment))
- (or (company-grab-symbol) 'stop)))
+ (or (company-eclim--prefix) 'stop)))
(candidates (company-eclim--candidates arg))
(meta (company-eclim--meta arg))
;; because "" doesn't return everything
(crop (when (string-match "(" arg)
(substring arg 0 (match-beginning 0))))
(post-completion (when (string-match "([^)]" arg)
- (company-eclim--templatify arg)))))
+ (company-template-c-like-templatify arg)))))
(provide 'company-eclim)
;;; company-eclim.el ends here