Many changes
This commit is contained in:
@ -224,7 +224,9 @@ the arguments to pass. They default to `jshell-switches'."
|
||||
(goto-char (point-max))
|
||||
(insert code)
|
||||
(goto-char (point-max))
|
||||
(jshell-send-input)
|
||||
;; don't save history
|
||||
(let ((comint-input-filter #'ignore))
|
||||
(jshell-send-input))
|
||||
(goto-char (point-max))
|
||||
(insert old)
|
||||
(goto-char (point-max))))))
|
||||
@ -252,35 +254,40 @@ START and END default to the current region."
|
||||
"Send the Java expression under point to a live JShell buffer.
|
||||
This only works in `java-ts-mode'."
|
||||
(interactive)
|
||||
(let ((root (treesit-buffer-root-node)))
|
||||
(let ((node (car (or (treesit-query-range
|
||||
root '([(expression_statement)
|
||||
(field_declaration)
|
||||
(local_variable_declaration)
|
||||
(import_declaration)]
|
||||
@exp)
|
||||
(point) (1+ (point)))
|
||||
(treesit-query-range
|
||||
root '([(parenthesized_expression)
|
||||
(binary_expression)
|
||||
(update_expression)
|
||||
(unary_expression)]
|
||||
@exp)
|
||||
(point) (1+ (point)))))))
|
||||
(unless node
|
||||
(user-error "No expression found under point"))
|
||||
(let ((text (buffer-substring-no-properties (car node) (cdr node))))
|
||||
(when (string-match (rx (* (syntax whitespace))
|
||||
";"
|
||||
(* (syntax whitespace)) eos)
|
||||
text)
|
||||
(setq text (substring text 0 (match-beginning 0))))
|
||||
(when (string-match (rx bos (* (syntax whitespace)) "("
|
||||
(group (* any))
|
||||
")" (* (syntax whitespace)) eos)
|
||||
text)
|
||||
(setq text (match-string 1 text)))
|
||||
(jshell-eval text)))))
|
||||
(save-excursion
|
||||
(let ((start (point)))
|
||||
(back-to-indentation)
|
||||
(unless (> (point) start)
|
||||
(goto-char start)))
|
||||
(let ((root (treesit-buffer-root-node)))
|
||||
(let ((node (car (or (treesit-query-range
|
||||
root '([(expression_statement)
|
||||
(field_declaration)
|
||||
(local_variable_declaration)
|
||||
(import_declaration)]
|
||||
@exp)
|
||||
(point) (1+ (point)))
|
||||
(treesit-query-range
|
||||
root '([(parenthesized_expression)
|
||||
(binary_expression)
|
||||
(update_expression)
|
||||
(unary_expression)]
|
||||
@exp)
|
||||
(point) (1+ (point)))))))
|
||||
(unless node
|
||||
(user-error "No expression found under point"))
|
||||
(let ((text (buffer-substring-no-properties (car node) (cdr node))))
|
||||
(when (string-match (rx (* (syntax whitespace))
|
||||
";"
|
||||
(* (syntax whitespace)) eos)
|
||||
text)
|
||||
(setq text (substring text 0 (match-beginning 0))))
|
||||
(when (string-match (rx bos (* (syntax whitespace)) "("
|
||||
(group (* any))
|
||||
")" (* (syntax whitespace)) eos)
|
||||
text)
|
||||
(setq text (match-string 1 text)))
|
||||
(jshell-eval text))))))
|
||||
|
||||
|
||||
(provide 'inferior-jshell)
|
||||
|
Reference in New Issue
Block a user