* bug#22358: 24.5; Analysis and indentation of Java default interface methods incorrect @ 2016-01-12 20:23 Lanning [not found] ` <mailman.2245.1452630247.843.bug-gnu-emacs@gnu.org> 0 siblings, 1 reply; 3+ messages in thread From: Lanning @ 2016-01-12 20:23 UTC (permalink / raw) To: 22358 [-- Attachment #1: Type: text/plain, Size: 5830 bytes --] Consider the Java interface public interface IndentDefaultInterfaceMethod { String doSomething(Foo foo); // The"default" in the next line is *not* a case tag... default String doSomething() { return doSomething(Foo.getDefaultFoo()); } } // IndentDefaultInterfaceMethod Syntactic analysis of the "default" line declares it a case-label. As a result it gets indented to align with the "public" modifier. Instead it should (probably) be treated the same as an access modifier. But boy howdy is that code in c-guess-basic-syntax complicated! In GNU Emacs 24.5.1 (x86_64-pc-linux-gnu, GTK+ Version 3.16.6) of 2015-09-17 on lgw01-52, modified by Debian Windowing system distributor `The X.Org Foundation', version 11.0.11702000 System Description: Ubuntu 15.10 Configured using: `configure --build x86_64-linux-gnu --prefix=/usr --sharedstatedir=/var/lib --libexecdir=/usr/lib --localstatedir=/var/lib --infodir=/usr/share/info --mandir=/usr/share/man --with-pop=yes --enable-locallisppath=/etc/emacs24:/etc/emacs:/usr/local/share/emacs/24.5/site-lisp:/usr/local/share/emacs/site-lisp:/usr/share/emacs/24.5/site-lisp:/usr/share/emacs/site-lisp --build x86_64-linux-gnu --prefix=/usr --sharedstatedir=/var/lib --libexecdir=/usr/lib --localstatedir=/var/lib --infodir=/usr/share/info --mandir=/usr/share/man --with-pop=yes --enable-locallisppath=/etc/emacs24:/etc/emacs:/usr/local/share/emacs/24.5/site-lisp:/usr/local/share/emacs/site-lisp:/usr/share/emacs/24.5/site-lisp:/usr/share/emacs/site-lisp --with-x=yes --with-x-toolkit=gtk3 --with-toolkit-scroll-bars 'CFLAGS=-g -O2 -fstack-protector-strong -Wformat -Werror=format-security -Wall' CPPFLAGS=-D_FORTIFY_SOURCE=2 'LDFLAGS=-Wl,-Bsymbolic-functions -Wl,-z,relro'' Important settings: value of $LANG: en_US.UTF-8 value of $XMODIFIERS: @im=ibus locale-coding-system: utf-8-unix Major mode: Java/l Minor modes in effect: shell-dirtrack-mode: t tooltip-mode: t electric-indent-mode: t mouse-wheel-mode: t tool-bar-mode: t menu-bar-mode: t file-name-shadow-mode: t global-font-lock-mode: t font-lock-mode: t blink-cursor-mode: t auto-composition-mode: t auto-encryption-mode: t auto-compression-mode: t line-number-mode: t transient-mark-mode: t abbrev-mode: t Recent messages: Loading /etc/emacs/site-start.d/50scala-mode-el.el (source)... Loading scala-mode-auto...done Loading /etc/emacs/site-start.d/50scala-mode-el.el (source)...done Loading /etc/emacs/site-start.d/50w3m-el.el (source)...done For information about GNU Emacs and the GNU system, type C-h C-a. Followed link to /home/slanning/Projects/stash/users/slanning/homedir/.emacs.d/java/Foo.java Syntactic analysis: ((case-label 1262)) Quit Undo! Making completion list... [2 times] Load-path shadows: /usr/share/emacs/24.5/site-lisp/debian-startup hides /usr/share/emacs/site-lisp/debian-startup /usr/share/emacs24/site-lisp/flim/md4 hides /usr/share/emacs/24.5/lisp/md4 /usr/share/emacs24/site-lisp/flim/hex-util hides /usr/share/emacs/24.5/lisp/hex-util /usr/share/emacs24/site-lisp/flim/sasl hides /usr/share/emacs/24.5/lisp/net/sasl /usr/share/emacs24/site-lisp/flim/hmac-md5 hides /usr/share/emacs/24.5/lisp/net/hmac-md5 /usr/share/emacs24/site-lisp/flim/sasl-cram hides /usr/share/emacs/24.5/lisp/net/sasl-cram /usr/share/emacs24/site-lisp/flim/ntlm hides /usr/share/emacs/24.5/lisp/net/ntlm /usr/share/emacs24/site-lisp/flim/sasl-ntlm hides /usr/share/emacs/24.5/lisp/net/sasl-ntlm /usr/share/emacs24/site-lisp/flim/hmac-def hides /usr/share/emacs/24.5/lisp/net/hmac-def /usr/share/emacs24/site-lisp/flim/sasl-digest hides /usr/share/emacs/24.5/lisp/net/sasl-digest Features: (shadow sort gnus-util mail-extr emacsbug message rfc822 mml mml-sec mm-decode mm-bodies mm-encode mail-parse rfc2231 mailabbrev gmm-utils mailheader sendmail rfc2047 rfc2045 ietf-drums mm-util mail-prsvr mail-utils help-mode vc-git cc-langs cl-loaddefs cl-lib cc-mode cc-fonts cc-guess cc-menus cc-cmds cc-styles cc-align cc-engine w3m-load scala-mode-auto 50magit go-mode-autoloads ido ess-toolbar ess-mouse mouseme thingatpt browse-url ess-menu ess-swv ess-noweb ess-noweb-font-lock-mode ess-bugs-l essd-els ess-sas-d ess-sas-l ess-sas-a shell pcomplete ess-sta-d ess-sta-l cc-vars cc-defs make-regexp ess-sp6-d ess-sp3-d ess-julia ess-r-d ess-r-completion compile ess-tracebug format-spec ess-roxy advice hideshow ess-help ess-developer eldoc help-fns ess-s-l ess ess-inf comint ansi-color ring ess-mode ess-noweb-mode ess-utils ess-custom executable easymenu ess-compat ess-site erlang-start jabber-autoloads emacs-goodies-el emacs-goodies-custom emacs-goodies-loaddefs easy-mmode dash-functional dash time-date tooltip electric uniquify ediff-hook vc-hooks lisp-float-type mwheel x-win x-dnd tool-bar dnd fontset image regexp-opt fringe tabulated-list newcomment lisp-mode prog-mode register page menu-bar rfn-eshadow timer select scroll-bar mouse jit-lock font-lock syntax facemenu font-core frame cham georgian utf-8-lang misc-lang vietnamese tibetan thai tai-viet lao korean japanese hebrew greek romanian slovak czech european ethiopic indian cyrillic chinese case-table epa-hook jka-cmpr-hook help simple abbrev minibuffer nadvice loaddefs button faces cus-face macroexp files text-properties overlay sha1 md5 base64 format env code-pages mule custom widget hashtable-print-readable backquote make-network-process dbusbind gfilenotify dynamic-setting system-font-setting font-render-setting move-toolbar gtk x-toolkit x multi-tty emacs) Memory information: ((conses 16 147268 7824) (symbols 48 25745 0) (miscs 40 103 170) (strings 32 32303 5207) (string-bytes 1 1065250) (vectors 16 16436) (vector-slots 8 462748 5639) (floats 8 107 279) (intervals 56 813 93) (buffers 960 15) (heap 1024 45539 1054)) [-- Attachment #2: Type: text/html, Size: 7412 bytes --] ^ permalink raw reply [flat|nested] 3+ messages in thread
[parent not found: <mailman.2245.1452630247.843.bug-gnu-emacs@gnu.org>]
* bug#22358: 24.5; Analysis and indentation of Java default interface methods incorrect [not found] ` <mailman.2245.1452630247.843.bug-gnu-emacs@gnu.org> @ 2016-01-13 22:46 ` Alan Mackenzie [not found] ` <CAH0R2Fvn7=n==jZOc06ssb4T-cgZdeZmgYLte4Rm1E4=waA=8A@mail.gmail.com> 0 siblings, 1 reply; 3+ messages in thread From: Alan Mackenzie @ 2016-01-13 22:46 UTC (permalink / raw) To: Lanning; +Cc: 22358 Hello, Lanning. In article <mailman.2245.1452630247.843.bug-gnu-emacs@gnu.org> you wrote: > [-- text/plain, encoding 7bit, charset: UTF-8, 141 lines --] > Consider the Java interface > public interface IndentDefaultInterfaceMethod { > String doSomething(Foo foo); > // The"default" in the next line is *not* a case tag... > default String doSomething() { > return doSomething(Foo.getDefaultFoo()); > } > } // IndentDefaultInterfaceMethod > Syntactic analysis of the "default" line declares it a case-label. > As a result it gets indented to align with the "public" modifier. Yes. First of all, thanks for taking the trouble to report this problem, and thanks even more for distilling it into a nice short test case which is easy to work with. Please see the patch below. After applying it, it is utterly essential to recompile several files in CC Mode, to ensure that a change to one of the macros in cc-langs.el is propagated through the rest of the code. So after applying the patch (in directory .../emacs-24.5/lisp/progmodes), compile as follows $ emacs -Q -batch -f batch-byte-compile cc-*.el . > Instead it should (probably) be treated the same as an access modifier. > But boy howdy is that code in c-guess-basic-syntax complicated! :-) Actually, c-guess-basic-syntax is relatively simple, it's just long, long, long; it's little more than a big `cond' form. The place where the current bug was happening was at "CASE 14: A case or default label", where a match happened with no more checking than seeing the keyword "default". I've added more rigorous checking to that. Would you please let me know whether the patch solves the problem completely, or whether there are still issues with it remaining to be fixed. Thanks! > In GNU Emacs 24.5.1 (x86_64-pc-linux-gnu, GTK+ Version 3.16.6) > of 2015-09-17 on lgw01-52, modified by Debian > Windowing system distributor `The X.Org Foundation', version 11.0.11702000 > System Description: Ubuntu 15.10 OK, here's the patch: diff -r 03dea479cb53 cc-engine.el --- a/cc-engine.el Tue Jan 12 17:50:29 2016 +0000 +++ b/cc-engine.el Wed Jan 13 22:26:10 2016 +0000 @@ -9782,7 +9782,20 @@ paren-state))) ;; CASE 14: A case or default label - ((looking-at c-label-kwds-regexp) + ((save-excursion + (and (looking-at c-label-kwds-regexp) + (or (c-major-mode-is 'idl-mode) + (and + containing-sexp + (goto-char containing-sexp) + (eq (char-after) ?{) + (progn (c-backward-syntactic-ws) t) + (eq (char-before) ?\)) + (c-go-list-backward) + (progn (c-backward-syntactic-ws) t) + (c-simple-skip-symbol-backward) + (looking-at c-block-stmt-2-key))) + )) (if containing-sexp (progn (goto-char containing-sexp) @@ -9798,6 +9811,7 @@ ((save-excursion (back-to-indentation) (and (not (looking-at c-syntactic-ws-start)) + (not (looking-at c-label-kwds-regexp)) (c-forward-label))) (cond (containing-decl-open (setq placeholder (c-add-class-syntax 'inclass diff -r 03dea479cb53 cc-langs.el --- a/cc-langs.el Tue Jan 12 17:50:29 2016 +0000 +++ b/cc-langs.el Wed Jan 13 22:26:10 2016 +0000 @@ -1884,7 +1884,7 @@ "bindsTo" "delegatesTo" "implements" "proxy" "storedOn") ;; Note: "const" is not used in Java, but it's still a reserved keyword. java '("abstract" "const" "final" "native" "private" "protected" "public" - "static" "strictfp" "synchronized" "transient" "volatile") + "default" "static" "strictfp" "synchronized" "transient" "volatile") pike '("final" "inline" "local" "nomask" "optional" "private" "protected" "public" "static" "variant")) [ .... ] -- Alan Mackenzie (Nuremberg, Germany). ^ permalink raw reply [flat|nested] 3+ messages in thread
[parent not found: <CAH0R2Fvn7=n==jZOc06ssb4T-cgZdeZmgYLte4Rm1E4=waA=8A@mail.gmail.com>]
* bug#22358: 24.5; Analysis and indentation of Java default interface methods incorrect [not found] ` <CAH0R2Fvn7=n==jZOc06ssb4T-cgZdeZmgYLte4Rm1E4=waA=8A@mail.gmail.com> @ 2016-01-23 19:52 ` Alan Mackenzie 0 siblings, 0 replies; 3+ messages in thread From: Alan Mackenzie @ 2016-01-23 19:52 UTC (permalink / raw) To: Lanning; +Cc: 22358-done Hello again, Lanning. On Wed, Jan 13, 2016 at 04:42:34PM -0800, Lanning wrote: > Yep, that fixes it. Thanks, and esp for the quick turn-around. OK, I've fixed the problem in savannah, so I'm closing this bug. > By "complicated" I mean that there are a lot of connections between things. > Not being familiar with the code, with all the languages supported, and so > on, I have to assume that a small change may have large consequences. > Anyway... I've got a fix for you. The problem has to do with indentation of > multi-line Java annotations. More accurately, the indentation of the next > line after a multi-line annotation. Here's an example that illustrates the > problem. The annotations should all be aligned, and the method should line > up with the all of them. > public class Foo { > @AnAnnotation("hello") > @AnotherAnnotation(list = { "one", "two", > "three", "four" }, > value = "something") > @YetAnother > @AndYetAnother( > a = b, > c = d > ) > @DieAnotherDay("you bet") > public void run() { > } > } // Foo > The problem is that the subsequent line is indented relative to the > previous *line*, not the previous "expression". You may not believe this, but this bug was fixed (for the upcoming 25.1 release) on 12th January, the day before you sent me your last post. The solution implemented is for the anchor point to be at the indentation of the line containing the start of the previous annotation. If you'd like, I can send you a patch based on Emacs 24.5. -- Alan Mackenzie (Nuremberg, Germany). ^ permalink raw reply [flat|nested] 3+ messages in thread
end of thread, other threads:[~2016-01-23 19:52 UTC | newest] Thread overview: 3+ messages (download: mbox.gz follow: Atom feed -- links below jump to the message on this page -- 2016-01-12 20:23 bug#22358: 24.5; Analysis and indentation of Java default interface methods incorrect Lanning [not found] ` <mailman.2245.1452630247.843.bug-gnu-emacs@gnu.org> 2016-01-13 22:46 ` Alan Mackenzie [not found] ` <CAH0R2Fvn7=n==jZOc06ssb4T-cgZdeZmgYLte4Rm1E4=waA=8A@mail.gmail.com> 2016-01-23 19:52 ` Alan Mackenzie
Code repositories for project(s) associated with this external index https://git.savannah.gnu.org/cgit/emacs.git https://git.savannah.gnu.org/cgit/emacs/org-mode.git This is an external index of several public inboxes, see mirroring instructions on how to clone and mirror all data and code used by this external index.