This Bugzilla instance is a read-only archive of historic NetBeans bug reports. To report a bug in NetBeans please follow the project's instructions for reporting issues.
Product Version = NetBeans IDE Dev (Build 201211110001) Operating System = Windows 7 version 6.1 running on amd64 Java; VM; Vendor = 1.7.0_09 Runtime = Java HotSpot(TM) 64-Bit Server VM 23.5-b02 Create the code: if(boletosId.length==0) { response.setContentType("text/plain"); PrintWriter pw = response.getWriter(); pw.println("Nenhum identificador de boleto fornecido. A operação foi cancelada."); pw.flush(); pw.close(); } at line "PrintWriter pw...", NetBeans give the hint "Convert to try-with-resources". Developer accept the hint, and everything is idented out of current rules: if(boletosId.length==0) { response.setContentType("text/plain"); try (PrintWriter pw = response.getWriter()) { pw.println("Nenhum identificador de boleto fornecido. A operação foi cancelada."); pw.flush(); } } See attached screenshot for a more "visual clue" of the issue. Regards, Edson
Created attachment 127700 [details] Incorrect code formating after applying the hint Note: if developer uses Source -> Format, then everything is correctly formatted, so it seems to be a issue with hint detector.
Same happens when I apply the "convert to Switch" hint for (if-the-else with strings).
Created attachment 128018 [details] The wrong identation after "convert to switch"
Created attachment 128019 [details] expected identation according to the formating rules
I tried to reproduce, but unfortunately did not succeed - are there some particular steps that would allow me to reproduce the bug? Thanks.
Well, I don't know. It happens always for me. Maybe something special in my formatting rules? See exported formatting rules in the attachment.
Created attachment 128045 [details] Exported format rules
Unfortunately, still not luck. Jirka, could you please try? Thanks.
Unfortunately I cannot reproduce it as well, even when importing the formatting settings
Ok, I've been using the same .netbeans dir since 7.2. I'll make a test with a fresh install, and let you know the results. Thanks, Edson
I think I may know what is the problem. Could you please check if you have multi-line method header or multi-line condition in if/while/... enclosing the part of the code where the change is being applied? E.g.: public boolean foo(String name, String path) {//multi-line method header. { if (name.equals("a")) { System.err.println("a"); } else if (name.equals("b")) { System.err.println("b"); } } return path.equals("bin"); } Thank you.
(In reply to comment #11) > I think I may know what is the problem. Could you please check if you have > multi-line method header or multi-line condition in if/while/... enclosing the > part of the code where the change is being applied? E.g.: > public boolean foo(String name, > String path) {//multi-line method header. > { > if (name.equals("a")) { > System.err.println("a"); > } else if (name.equals("b")) { > System.err.println("b"); > } > } > return path.equals("bin"); > } > > Thank you. Yes, this is true. All the cases match multi line methods declaration. Thanks, Edson
Integrated into 'main-golden', will be available in build *201211250002* on http://bits.netbeans.org/dev/nightly/ (upload may still be in progress) Changeset: http://hg.netbeans.org/main-golden/rev/85fb6c59d3eb User: Jan Lahoda <jlahoda@netbeans.org> Log: #222028: infer the indent level from the first member of a block/class instead of the indent of the block/class itself
The above patch fixes the problem - thank you for the report.
*** Bug 217820 has been marked as a duplicate of this bug. ***