Aptana Studio
  1. Aptana Studio
  2. APSTUD-3792

JavaScript Code Formatter: More options for Spaces - Parentheses

    Details

    • Story Points:
      20

      Description

      The JavaScript Code Formatter is nice, but it's missing a few key options for me to use it.

      Specifically, there are only two options for Spaces - Parentheses (Before/After).

      However, parentheses are used for multiple reasons - if, function declarations, function calls, etc. My desired spacing for parentheses doesn't apply to all of these.

      For example, if I set Before = 1 and After = 0, I get:

      var a = function (b, c, d) { // BAD Don't want the space before function arguments here
          alert (b + c + d); // BAD Don't want the space before invokation arguments here
      }
      var c = a ? 10 : 20;
      var bb = {
          "a": 1,
          "b": 2,
          "c": 3
      };
      for (var i = 0, j = 0; i < 8 && j >= 0; i++, --j) { // GOOD This space is good
          alert ("(a " + a + ",j " + j + ")"); // BAD Don't want the space before invokation arguments here
      }
      if (xyz[1] >= 5) { // GOOD This space is good
      

      If I set Before = 0 and After = 0, I get

      var a = function(b, c, d) { // GOOD
          alert(b + c + d); // GOOD
      }
      var c = a ? 10 : 20;
      var bb = {
          "a": 1,
          "b": 2,
          "c": 3
      };
      
      for(var i = 0, j = 0; i < 8 && j >= 0; i++, --j) { // BAD I want a space here
          alert("(a " + a + ",j " + j + ")"); // GOOD
      }
      if(xyz[1] >= 5) { // BAD I want a space here
      

      If there were separate Parentheses rules for function arguments, function invocation, and for/if/etc clauses, it'd be much nicer.

        Issue Links

          Activity

          Hide
          Victor Homyakov added a comment -

          Duplicate of APSTUD-3829, APSTUD-3660

          Show
          Victor Homyakov added a comment - Duplicate of APSTUD-3829 , APSTUD-3660
          Hide
          Shalom Gibly added a comment - - edited

          Attaching a comparison image for the JS spacing options, vs. the PHP ones.

          Suggest we add all the "Parenthesis" ones:

          • Declaration expressions
          • Invocation expressions
          • Conditional expressions
          • Loop expressions
          • Array access expressions
          • Other parenthesis
          Show
          Shalom Gibly added a comment - - edited Attaching a comparison image for the JS spacing options, vs. the PHP ones. Suggest we add all the "Parenthesis" ones: Declaration expressions Invocation expressions Conditional expressions Loop expressions Array access expressions Other parenthesis
          Hide
          Shalom Gibly added a comment -

          Implemented.
          The JS formatter preferences for the spaces got a new 'Parentheses' section that allows setting those (just like the ones we have for PHP)

          Show
          Shalom Gibly added a comment - Implemented. The JS formatter preferences for the spaces got a new 'Parentheses' section that allows setting those (just like the ones we have for PHP)
          Hide
          Clayton Headley (Inactive) added a comment -

          Verified implemented in Windows 7, Mac OS 10.7.3 and Ubuntu 11.10 using Titanium Studio build: 2.0.2.201205011723. Closing ticket.

          Show
          Clayton Headley (Inactive) added a comment - Verified implemented in Windows 7, Mac OS 10.7.3 and Ubuntu 11.10 using Titanium Studio build: 2.0.2.201205011723. Closing ticket.

            People

            • Assignee:
              Shalom Gibly
              Reporter:
              Nic Jansma
            • Watchers:
              3 Start watching this issue

              Dates

              • Created:
                Updated:
                Resolved:

                Development