commit dbe7803aa1e8249bd70f67f25f19aedabeb9cc22 (HEAD, refs/remotes/origin/master) Author: Theodor Thornhill Date: Mon Feb 6 09:36:08 2023 +0100 Add more java indentation tests * test/lisp/progmodes/java-ts-mode-resources/indent.erts: Use default indent offset, and tweak the indentation examples. diff --git a/test/lisp/progmodes/java-ts-mode-resources/indent.erts b/test/lisp/progmodes/java-ts-mode-resources/indent.erts index c8e0ac71708..4fca74dd2e1 100644 --- a/test/lisp/progmodes/java-ts-mode-resources/indent.erts +++ b/test/lisp/progmodes/java-ts-mode-resources/indent.erts @@ -1,7 +1,7 @@ Code: (lambda () (setq indent-tabs-mode nil) - (setq java-ts-mode-indent-offset 2) + (setq java-ts-mode-indent-offset 4) (java-ts-mode) (indent-region (point-min) (point-max))) @@ -11,9 +11,9 @@ Name: Basic =-= public class Basic { - public void basic() { - return; - } + public void basic() { + return; + } } =-=-= @@ -21,9 +21,9 @@ Name: Empty Line =-= public class EmptyLine { - public void emptyLine() { - | - } + public void emptyLine() { + | + } } =-=-= @@ -31,15 +31,15 @@ Name: Statements =-= if (x) { - for (var foo : foos) { - | - } + for (var foo : foos) { + | + } } else if (y) { - for (int i = 0; x < foos.size(); i++) { - return; - } + for (int i = 0; x < foos.size(); i++) { + return; + } } else { - return; + return; } =-=-= @@ -47,7 +47,66 @@ Name: Field declaration without access modifier (bug#61115) =-= public class T { - @Autowired - String a; + @Autowired + String a; +} +=-=-= + +Name: Array initializer + +=-= +public class Java { + void foo() { + return new String[]{ + "foo", // These + "bar" + } + } +} +=-=-= + +Name: Advanced bracket matching indentation (bug#61142) + +=-= +public class Java { + + public Java( + String foo) { + this.foo = foo; + } + + void foo( + String foo) { + + for (var f : rs) + return new String[]{ + "foo", + "bar" + }; + if (a == 0 + && b == 1 + && foo) { + return 0; + } else if (a == 1) { + return 1; + } else if (true) + return 5; + else { + if (a == 0 + && b == 1 + && foo) + while (true) + for ( + ;;) + if (true) + return 5; + else if (false) { + return 6; + } else + if (true + && false) + return 6; + } + } } =-=-= commit 67dea8143f1876598a6ab477c17f34b5b269dc50 Author: Michael Albinus Date: Fri Feb 10 18:07:00 2023 +0100 Fix last change diff --git a/test/lisp/net/tramp-tests.el b/test/lisp/net/tramp-tests.el index a9f22369231..85714e79bc0 100644 --- a/test/lisp/net/tramp-tests.el +++ b/test/lisp/net/tramp-tests.el @@ -4641,7 +4641,9 @@ tramp-test26-file-name-completion ;; TODO: Add tests for user names and multi-hop file names. (ert-deftest tramp-test26-interactive-file-name-completion () "Check interactive completion with different `completion-styles'." - ;; Method and host name in completion mode. This kind of completion + (tramp-cleanup-connection tramp-test-vec nil 'keep-password) + +;; Method and host name in completion mode. This kind of completion ;; does not work on MS Windows. (unless (memq system-type '(cygwin windows-nt)) (let ((method (file-remote-p ert-remote-temporary-file-directory 'method)) commit ea29622e928f50522e424ee59b0f24bbb5a42eca Author: Michael Albinus Date: Fri Feb 10 17:48:44 2023 +0100 Fix Tramp file name completion * lisp/net/tramp.el (tramp-completion-handle-expand-file-name): Reimplement. It must also work for the non-Tramp case. * test/lisp/net/tramp-tests.el (tramp-test26-interactive-file-name-completion): Fix test. diff --git a/lisp/net/tramp.el b/lisp/net/tramp.el index b75a1816fdb..36305dda496 100644 --- a/lisp/net/tramp.el +++ b/lisp/net/tramp.el @@ -2948,9 +2948,21 @@ tramp-connectable-p (defun tramp-completion-handle-expand-file-name (filename &optional directory) "Like `expand-file-name' for partial Tramp files." - (if (file-name-absolute-p filename) - filename - (concat (or directory default-directory "/") filename))) + ;; We need special handling only when a method is needed. Then we + ;; check, whether DIRECTORY is "/method:" or "/[method/". + (let ((dir (or directory default-directory "/"))) + (cond + ((file-name-absolute-p filename) filename) + ((and (eq tramp-syntax 'simplified) + (string-match-p (rx (regexp tramp-postfix-host-regexp) eos) dir)) + (concat dir filename)) + ((string-match-p + (rx bos (regexp tramp-prefix-regexp) + (? (regexp tramp-method-regexp) (regexp tramp-postfix-method-regexp)) + eos) + dir) + (concat dir filename)) + (t (tramp-run-real-handler #'expand-file-name (list filename directory)))))) (defun tramp-completion-handle-file-exists-p (filename) "Like `file-exists-p' for partial Tramp files." diff --git a/test/lisp/net/tramp-tests.el b/test/lisp/net/tramp-tests.el index eea59843d47..a9f22369231 100644 --- a/test/lisp/net/tramp-tests.el +++ b/test/lisp/net/tramp-tests.el @@ -4695,7 +4695,7 @@ tramp-test26-interactive-file-name-completion tramp-prefix-format (substring-no-properties method 0 2)) unread-command-events - (mapcar #'identity (concat test "\t\n")) + (mapcar #'identity (concat test "\t\t\n")) completions nil result (read-file-name "Prompt: ")) (if (not (get-buffer "*Completions*")) @@ -4708,6 +4708,12 @@ tramp-test26-interactive-file-name-completion (concat tramp-prefix-format method-string) result))) (with-current-buffer "*Completions*" + ;; We must remove leading `default-directory'. + (goto-char (point-min)) + (let ((inhibit-read-only t)) + (while (re-search-forward "//" nil 'noerror) + (delete-region (line-beginning-position) (point)))) + (goto-char (point-min)) (re-search-forward (rx bol (1+ nonl) "possible completions:" eol)) (forward-line 1) @@ -4729,7 +4735,7 @@ tramp-test26-interactive-file-name-completion tramp-prefix-format method-string (substring-no-properties host 0 2)) unread-command-events - (mapcar #'identity (concat test "\t\n")) + (mapcar #'identity (concat test "\t\t\n")) completions nil result (read-file-name "Prompt: ")) (if (not (get-buffer "*Completions*")) @@ -4744,6 +4750,12 @@ tramp-test26-interactive-file-name-completion ipv6-prefix host ipv6-postfix tramp-postfix-host-format) result))) (with-current-buffer "*Completions*" + ;; We must remove leading `default-directory'. + (goto-char (point-min)) + (let ((inhibit-read-only t)) + (while (re-search-forward "//" nil 'noerror) + (delete-region (line-beginning-position) (point)))) + (goto-char (point-min)) (re-search-forward (rx bol (1+ nonl) "possible completions:" eol)) (forward-line 1)