Skip to content

Commit 34cebe5

Browse files
committed
Fixes #89
+ cleanup + added lsp-java-inhibit-message
1 parent 4facd4d commit 34cebe5

File tree

1 file changed

+11
-59
lines changed

1 file changed

+11
-59
lines changed

lsp-java.el

Lines changed: 11 additions & 59 deletions
Original file line numberDiff line numberDiff line change
@@ -205,6 +205,11 @@ A package or type name prefix (e.g. 'org.eclipse') is a valid entry. An import i
205205
:group 'lsp-java
206206
:type 'boolean)
207207

208+
(defcustom lsp-java-inhibit-message t
209+
"If non-nil, inhibit java messages echo via `inhibit-message'."
210+
:type 'boolean
211+
:group 'lsp-mode)
212+
208213
(defvar lsp-java--download-root "https://raw.githubusercontent.com/emacs-lsp/lsp-java/master/install/")
209214

210215
(defun lsp-java--json-bool (param)
@@ -406,65 +411,28 @@ PARAMS the parameters for language status notifications."
406411
(string= "Starting" status)))
407412
(lsp-workspace-status (concat "::" status) workspace)
408413
(lsp-workspace-set-metadata "status" status workspace)
409-
(let ((inhibit-message lsp-inhibit-message))
410-
(message "%s[%s]" (gethash "message" params) (gethash "type" params))))))
414+
(let ((inhibit-message lsp-java-inhibit-message))
415+
(lsp-message "%s[%s]" (gethash "message" params) (gethash "type" params))))))
411416

412417
(defun lsp-java--apply-workspace-edit (action)
413418
"Callback for java/applyWorkspaceEdit.
414419
415420
ACTION is the action to execute."
416421
(lsp--apply-workspace-edit (car (gethash "arguments" action))))
417422

418-
(defun lsp-java--actionable-notification-callback (workspace params)
423+
(defun lsp-java--actionable-notification-callback (_workspace params)
419424
"Handler for actionable notifications.
420425
421426
WORKSPACE is the currently active workspace.
422427
PARAMS the parameters for actionable notifications."
423-
(let* ((project-root (lsp-java--get-root))
424-
(classpath-incomplete-p (unless (lsp-java--is-root (lsp-java--get-root))
425-
(cl-find-if (lambda (command)
426-
(string= (gethash "command" command)
427-
"java.ignoreIncompleteClasspath.help"))
428-
(gethash "commands" params))))
429-
(choices (list (format "Import project \"%s.\"" project-root)
430-
"Import project by selecting root directory interactively."
431-
(format "Do not ask more for the current project(add \"%s\" to lsp-project-blacklist)" project-root)
432-
"Do nothing."))
433-
(action-index (when (and classpath-incomplete-p (not (member project-root lsp-project-blacklist)))
434-
(condition-case nil
435-
(cl-position
436-
(completing-read (format "%s is not part of any project. Select action: "
437-
(buffer-name))
438-
choices
439-
nil
440-
t)
441-
choices
442-
:test 'equal)
443-
('quit)))))
444-
(case action-index
445-
(0 (lsp-workspace-folders-add (list project-root)))
446-
(1 (call-interactively 'lsp-workspace-folders-add))
447-
(2 (add-to-list 'lsp-project-blacklist project-root))
448-
(t (let ((notifications (or (lsp-workspace-get-metadata
449-
"actionable-notifications"
450-
workspace)
451-
(make-hash-table :test #'equal))))
452-
(puthash (gethash "message" params) params notifications)
453-
(lsp-workspace-set-metadata "actionable-notifications"
454-
notifications
455-
workspace)
456-
(lsp-workspace-status
457-
(concat "::"
458-
(propertize
459-
(concat (lsp-workspace-get-metadata "status" workspace) "[!]")
460-
'face 'warning))))))))
428+
(lsp--warn (gethash "message" params)))
461429

462430
(defun lsp-java--progress-report (_workspace params)
463431
"Progress report handling.
464432
465433
PARAMS progress report notification data."
466-
(let ((inhibit-message lsp-inhibit-message))
467-
(message "%s%s" (gethash "status" params) (if (gethash "complete" params) " (done)" ""))))
434+
(let ((inhibit-message lsp-java-inhibit-message))
435+
(lsp-message "%s%s" (gethash "status" params) (if (gethash "complete" params) " (done)" ""))))
468436

469437
(defun lsp-java--render-string (str)
470438
"Render STR with `java-mode' syntax highlight."
@@ -476,22 +444,6 @@ PARAMS progress report notification data."
476444
(buffer-string))
477445
(error str)))
478446

479-
(defun lsp-java--render-markup (string)
480-
"Render STRING as markup."
481-
(string-trim-right
482-
(with-temp-buffer
483-
(insert string)
484-
(delay-mode-hooks
485-
(make-local-variable 'markdown-code-lang-modes)
486-
(add-to-list 'markdown-code-lang-modes (cons "java" 'java-mode))
487-
(setq-local markdown-fontify-code-blocks-natively t)
488-
(setq-local markdown-fontify-code-block-default-mode "java")
489-
(setq-local markdown-hide-markup t)
490-
491-
(let ((inhibit-message t)) (gfm-view-mode))
492-
(ignore-errors (font-lock-ensure)))
493-
(buffer-string))))
494-
495447
(defun lsp-java--prepare-mvnw ()
496448
"Download mvnw."
497449
(let ((mvn-executable (if (string-equal system-type "windows-nt")

0 commit comments

Comments
 (0)