Skip to content

Commit

Permalink
shortcut to implement/override methods from the completion menu
Browse files Browse the repository at this point in the history
  • Loading branch information
fred-o committed Dec 13, 2012
1 parent cf8fb36 commit 5b06569
Showing 1 changed file with 17 additions and 13 deletions.
30 changes: 17 additions & 13 deletions eclim-completion.el
Original file line number Diff line number Diff line change
Expand Up @@ -158,19 +158,23 @@ buffer."
(defun eclim--completion-action-java ()
(let* ((end (point))
(completion (buffer-substring-no-properties eclim--completion-start end)))
(if (string-match "\\([^-:]+\\) .*?\\(- *\\(.*\\)\\)?" completion)
(let* ((insertion (match-string 1 completion))
(rest (match-string 3 completion))
(package (if (and rest (string-match "\\w+\\(\\.\\w+\\)*" rest)) rest nil))
(template (eclim--completion-yasnippet-convert insertion)))
(delete-region eclim--completion-start end)
(if (and eclim-use-yasnippet template (featurep 'yasnippet))
(yas/expand-snippet template)
(insert insertion))
(when package
(eclim-java-import
(concat package "." (substring insertion 0 (or (string-match "[<(]" insertion)
(length insertion))))))))))
(cond ((string-match "\\(.*?\\) :.*- Override method" completion)
(let ((sig (eclim--java-parse-method-signature (match-string 1 completion))))
(delete-region eclim--completion-start end)
(eclim-java-implement (symbol-name (assoc-default :name sig)))))
((string-match "\\([^-:]+\\) .*?\\(- *\\(.*\\)\\)?" completion)
(let* ((insertion (match-string 1 completion))
(rest (match-string 3 completion))
(package (if (and rest (string-match "\\w+\\(\\.\\w+\\)*" rest)) rest nil))
(template (eclim--completion-yasnippet-convert insertion)))
(delete-region eclim--completion-start end)
(if (and eclim-use-yasnippet template (featurep 'yasnippet))
(yas/expand-snippet template)
(insert insertion))
(when package
(eclim-java-import
(concat package "." (substring insertion 0 (or (string-match "[<(]" insertion)
(length insertion)))))))))))

(defun eclim--completion-action-xml ()
(when (string-match "[\n[:blank:]]" (char-to-string (char-before eclim--completion-start)))
Expand Down

0 comments on commit 5b06569

Please sign in to comment.