new icons
[phpeclipse.git] / net.sourceforge.phpeclipse / src / net / sourceforge / phpdt / internal / formatter / CodeFormatter.java
index 516c7de..51bda8a 100644 (file)
@@ -315,6 +315,7 @@ public class CodeFormatter implements ITerminalSymbols, ICodeFormatter {
     boolean inArrayAssignment = false;
     boolean inThrowsClause = false;
     boolean inClassOrInterfaceHeader = false;
+    int dollarBraceCount = 0;
 
     // openBracketCount is used to count the number of open brackets not closed yet.
     int openBracketCount = 0;
@@ -349,6 +350,13 @@ public class CodeFormatter implements ITerminalSymbols, ICodeFormatter {
         // exit the loop.
         try {
           token = scanner.getNextToken();
+          if (Scanner.DEBUG) {
+            int currentEndPosition = scanner.getCurrentTokenEndPosition();
+            int currentStartPosition = scanner.getCurrentTokenStartPosition();
+
+            System.out.print(currentStartPosition + "," + currentEndPosition + ": ");
+            System.out.println(scanner.toStringAction(token));
+          }
 
           // Patch for line comment
           // See PR http://dev.eclipse.org/bugs/show_bug.cgi?id=23096
@@ -600,6 +608,9 @@ public class CodeFormatter implements ITerminalSymbols, ICodeFormatter {
           }
         }
         switch (token) {
+          case TokenNameDOLLAR_LBRACE :
+            dollarBraceCount++;
+            break;
           case TokenNameelse :
             //                         case TokenNamefinally :
             expectingOpenBrace = true;
@@ -723,6 +734,10 @@ public class CodeFormatter implements ITerminalSymbols, ICodeFormatter {
             }
             break;
           case TokenNameRBRACE :
+            if (dollarBraceCount > 0) {
+              dollarBraceCount--;
+              break;
+            }
             if (previousCompilableToken == TokenNameRPAREN) {
               pendingSpace = false;
             }
@@ -856,17 +871,17 @@ public class CodeFormatter implements ITerminalSymbols, ICodeFormatter {
             }
             increaseLineDelta(scanner.startPosition - scanner.currentPosition);
             break;
-//          case TokenNameHTML :
-//            // Add the next token to the formatted source string.
-//            // outputCurrentToken(token);
-//            int startPosition = scanner.startPosition;
-//            flushBuffer();
-//            for (int i = startPosition, max = scanner.currentPosition; i < max; i++) {
-//              char currentCharacter = scanner.source[i];
-//              updateMappedPositions(i);
-//              currentLineBuffer.append(currentCharacter);
-//            }
-//            break;
+            //          case TokenNameHTML :
+            //            // Add the next token to the formatted source string.
+            //            // outputCurrentToken(token);
+            //            int startPosition = scanner.startPosition;
+            //            flushBuffer();
+            //            for (int i = startPosition, max = scanner.currentPosition; i < max; i++) {
+            //              char currentCharacter = scanner.source[i];
+            //              updateMappedPositions(i);
+            //              currentLineBuffer.append(currentCharacter);
+            //            }
+            //            break;
           default :
             if ((token == TokenNameIdentifier) || isLiteralToken(token)) {
               //                                                       || token == TokenNamesuper
@@ -1973,6 +1988,13 @@ public class CodeFormatter implements ITerminalSymbols, ICodeFormatter {
           if (currentToken != Scanner.TokenNameWHITESPACE)
             previousToken = currentToken;
           currentToken = splitScanner.getNextToken();
+          if (Scanner.DEBUG) {
+            int currentEndPosition = splitScanner.getCurrentTokenEndPosition();
+            int currentStartPosition = splitScanner.getCurrentTokenStartPosition();
+
+            System.out.print(currentStartPosition + "," + currentEndPosition + ": ");
+            System.out.println(scanner.toStringAction(currentToken));
+          }
         } catch (InvalidInputException e) {
           if (!handleInvalidToken(e))
             throw e;