Menu

#181 Indent: Curly braces within parenthesis

3: Ugly
open
nobody
5
2003-06-10
2003-06-10
James Hsia
No

Whenever an expression that uses curly braces is typed
within an enclosing set of parentheses (e.g. passing a
statically defined array to a method) and that
expression is not the final argument passed to the
method, then any following lines are indented too far
which is a problem.

Discussion

  • Robert Cartwright

    Simple example that uses an array initializer in a method call

     
  • Robert Cartwright

    Logged In: YES
    user_id=430590

    I tried to reproduce this bug in DrJava 20030724 with the
    attached simple example but I failed. Has this bug been
    fixed by recent improvements to the indenting algorithm? Or
    is my example to simple to exhibit the problem?

     
  • James Hsia

    James Hsia - 2003-07-31

    Logged In: YES
    user_id=557360

    The bug occurs when the expression in curly braces is not
    the final argument but is the last argument on its line.
    Here's an example:

    class Indent {
    ..int foo(int[] a, int b, int c) { return a[0]; }
    ..int fooTest() {
    ....int result = foo(new int[] {-17, 12},
    ..............................6,
    ..............................5);
    ..............................System.out.println(result);
    ..............................return result;
    ..}
    }

    As you can see, every line after the ill-fated method call
    before the next close brace is indented too far to the
    right. The workaround is to make sure that the expression in
    curly braces is immediately followed by the next argument.
    They have to be on the same line.
    For example, in this case:

    int result = foo(new int[] {-17, 12}, 6,
    ..........................5);

    will not exhibit the bad behavior.

    We're putting indent bugs on hold for now as we try to
    prepare another stable release before school starts with
    some bug fixes and new features.

     

Log in to post a comment.

Want the latest updates on software, tech news, and AI?
Get latest updates about software, tech news, and AI from SourceForge directly in your inbox once a month.