Uploaded image for project: 'Appcelerator Studio'
  1. Appcelerator Studio
  2. TISTUD-1658

JavaScript Formatter: Spaces preferences contains edge case failures

    Details

    • Type: Bug
    • Status: Closed
    • Priority: Low
    • Resolution: Won't Fix
    • Affects Version/s: Titanium Studio 2.0.2
    • Fix Version/s: None
    • Component/s: Configuration
    • Environment:

      Studio: 2.0.2.201205141508
      OS: Snow Leopard

    • Story Points:
      0

      Description

      Titanium Studio > Preferences > Titanium Studio > Formatter > JavaScript contains edge cases where the formatting fails.

      The sample code is below, all spacing is set to 5.

      /*
      * Parentheses: Loop Expressions
      *
      * */
       
      //
      // no spaces in do-while parentheses
      //
       
      do {
      } while(x);
       
      /*
      * Parentheses: Array Access Expressions
      *
      * */
       
      //
      // no spaces for array access in switch parentheses
      //
       
      switch (xyz[2]) {
      	default :
      		return xyz;
      }
       
      //
      // no spaces for array access in do-while parentheses
      //
       
      do {
      } while(xyz[2]);
       
      //
      // no spaces for array access in case statements
      //
       
      switch(x) {
      	case xyz[0]:
      		break;
      }
       
      /*
      * Parentheses: Other Parentheses
      *
      * */
       
      //
      // no spaces in switch parentheses
      //
       
      switch (theDay) {
      	default:
      		document.write     (     "Donno :("     );
      }
       
      //
      // no spaces in catch parentheses
      //
       
      try {
      } catch(err) {
      }
       
      //
      // no spaces in grouping parentheses
      //
       
      (function fooInGroup     (     ) {
      })
       
      return     !     (xyz     [     0     ]     >     0);
       
      switch(x) {
      	case (z):
      		break;
      	case (x < y):
      		break;
      	default:
      		break;
      }
       
      /*
      * Operators
      *
      * */
       
      //
      // no spaces for any operators in switch parentheses
      //
       
      switch (hour + 12) {
      }
       
      switch (hour >= 12) {
      }
       
      switch (!x) {
      }
       
      switch (x = 12) {
      }
       
      switch (x ? 12 : 0) {
      }
       
      //
      // no spaces for any operators in case parentheses
      //
       
      switch(0) {
      	case (hour + 12):
      		break;
      	case (hour >= 12):
      		break;
      	case (!x):
      		break;
      	case (x = 12):
      		break;
      	case (x ? 12 : 0):
      		break;
      }
       
      //
      // no spaces for any operators in do-while parentheses
      //
       
      do {
      } while (hour + 12);
       
      do {
      } while (hour >= 12);
       
      do {
      } while (!x);
       
      do {
      } while (x = 12);
       
      do {
      } while (x ? 12 : 0);
       
      /*
      * Operators: Assignments
      *
      * */
       
      //
      // no spaces after assignment operators followed by function
      //
       
      var a     = function     (     b     ,     c     ,     d     ) {
      	alert     (     b     +     c     +     d     );
      }
      //
      // no spaces after assignment operators followed by curly brace object
      //
       
      var bb     = {
      	"a"     :     1     ,
      	"b"     :     2     ,
      	"c"     :     3
      };
       
      //
      // no spaces after assignment operators followed by ternary expression
      //
       
      var c     = a     ?     10     :     20;
       
      /*
      * Operators: Key-Value Operator
      *
      * */
       
      //
      // no spaces after key-value operators followed by function
      //
       
      new MyFunctions     (     {
      	onComplete     : function     (     ) {
      	}     ,
      	onClick     : function     (     ) {
      	}     ,
      	myVar     : {}
      }     );
       
      //
      // no spaces after key-value operators followed by curly brace object
      //
       
      new MyFunctions     (     {
      	myVar     : {}
      }     );
       
      //
      // no spaces after key-value operators followed by ternary expression
      //
       
      new MyFunctions     (     {
      	myVar     : x     ?     10     :     20
      }     ); 
      

        Attachments

          Issue Links

            Activity

              People

              • Assignee:
                kkolipaka Kondal Kolipaka (Inactive)
                Reporter:
                dhyde Dustin Hyde
              • Watchers:
                1 Start watching this issue

                Dates

                • Created:
                  Updated:
                  Resolved: