Clover coverage report - net.sourceforge.astyleclipse Coverage Report
Coverage timestamp: 星期六 九月 23 2006 23:19:47 CST
file stats: LOC: 1,868   Methods: 46
NCLOC: 1,178   Classes: 1
 
 Source file Conditionals Statements Methods TOTAL
ASBeautifier.java 0% 0% 0% 0%
coverage
 1    /*
 2    * :tabSize=8:indentSize=4:noTabs=true:maxLineLen=0:
 3    *
 4    * Copyright (c) 1998,1999,2000,2001 Tal Davidson. All rights reserved.
 5    *
 6    * ASBeautifier.java
 7    * by Tal Davidson (davidsont@bigfoot.com)
 8    * This file is a part of "Artistic Style" - an indentater and reformatter
 9    * of C++, C, and Java source files.
 10    *
 11    * Ported from C++ to Java by Dirk Moebius (dmoebius@gmx.net).
 12    *
 13    * The "Artistic Style" project, including all files needed to compile it,
 14    * is free software; you can redistribute it and/or use it and/or modify it
 15    * under the terms of EITHER the "Artistic License" OR
 16    * the GNU Library General Public License as published by the Free Software
 17    * Foundation; either version 2 of the License, or (at your option) any later
 18    * version.
 19    *
 20    * This program is distributed in the hope that it will be useful,
 21    * but WITHOUT ANY WARRANTY; without even the implied warranty of
 22    * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.
 23    *
 24    * You should have received a copy of EITHER the "Artistic License" or
 25    * the GNU Library General Public License along with this program.
 26    */
 27   
 28   
 29    package net.sourceforge.astyleclipse.astyle;
 30   
 31   
 32    import java.util.*;
 33    import java.io.*;
 34    import net.sourceforge.astyleclipse.astyle.util.*;
 35   
 36    // import org.gjt.sp.util.Log;
 37   
 38    /**
 39    * A C/C++/Java source code indenter.
 40    */
 41    public class ASBeautifier implements ASResource {
 42   
 43  0 public ASBeautifier() {
 44  0 initStatic();
 45   
 46  0 waitingBeautifierStack = null;
 47  0 activeBeautifierStack = null;
 48  0 waitingBeautifierStackLengthStack = null;
 49  0 activeBeautifierStackLengthStack = null;
 50   
 51  0 headerStack = null;
 52  0 tempStacks = null;
 53  0 blockParenDepthStack = null;
 54  0 blockStatementStack = null;
 55  0 parenStatementStack = null;
 56  0 bracketBlockStateStack = null;
 57  0 inStatementIndentStack = null;
 58  0 inStatementIndentStackSizeStack = null;
 59  0 parenIndentStack = null;
 60  0 sourceIterator = null;
 61   
 62  0 isMinimalConditinalIndentSet = false;
 63  0 shouldForceTabIndentation = false;
 64   
 65  0 setSpaceIndentation(4);
 66  0 setMaxInStatementIndentLength(40);
 67  0 setClassIndent(false);
 68  0 setSwitchIndent(false);
 69  0 setCaseIndent(false);
 70  0 setBlockIndent(false);
 71  0 setBracketIndent(false);
 72  0 setNamespaceIndent(false);
 73  0 setLabelIndent(false);
 74  0 setEmptyLineFill(false);
 75  0 setCStyle(true);
 76  0 setPreprocessorIndent(false);
 77    }
 78   
 79   
 80    /** copy constructor */
 81  0 public ASBeautifier(ASBeautifier other) {
 82  0 this();
 83   
 84  0 headerStack = other.headerStack.getClone();
 85   
 86  0 tempStacks = new StackStack();
 87  0 for (int i = 0; i < other.tempStacks.size(); i++) {
 88  0 StringStack s = (StringStack) other.tempStacks.at(i);
 89  0 tempStacks.push_back(s.getClone());
 90    }
 91   
 92  0 blockParenDepthStack = other.blockParenDepthStack.getClone();
 93  0 blockStatementStack = other.blockStatementStack.getClone();
 94  0 parenStatementStack = other.parenStatementStack.getClone();
 95  0 bracketBlockStateStack = other.bracketBlockStateStack.getClone();
 96  0 inStatementIndentStack = other.inStatementIndentStack.getClone();
 97  0 inStatementIndentStackSizeStack = other.inStatementIndentStackSizeStack.getClone();
 98  0 parenIndentStack = other.parenIndentStack.getClone();
 99   
 100  0 sourceIterator = other.sourceIterator;
 101   
 102  0 indentString = other.indentString;
 103  0 currentHeader = other.currentHeader;
 104  0 previousLastLineHeader = other.previousLastLineHeader;
 105  0 immediatelyPreviousAssignmentOp = other.immediatelyPreviousAssignmentOp;
 106  0 isInQuote = other.isInQuote;
 107  0 isInComment = other.isInComment;
 108  0 isInCase = other.isInCase;
 109  0 isInQuestion = other.isInQuestion;
 110  0 isInStatement =other. isInStatement;
 111  0 isInHeader = other.isInHeader;
 112  0 isCStyle = other.isCStyle;
 113  0 isInFor = other.isInFor; /// danson
 114  0 isInOperator = other.isInOperator;
 115  0 isInTemplate = other.isInTemplate;
 116  0 classIndent = other.classIndent;
 117  0 isInClassHeader = other.isInClassHeader;
 118  0 isInClassHeaderTab = other.isInClassHeaderTab;
 119  0 switchIndent = other.switchIndent;
 120  0 caseIndent = other.caseIndent;
 121  0 namespaceIndent = other.namespaceIndent;
 122  0 bracketIndent = other.bracketIndent;
 123  0 blockIndent = other.blockIndent;
 124  0 labelIndent = other.labelIndent;
 125  0 preprocessorIndent = other.preprocessorIndent;
 126  0 parenDepth = other.parenDepth;
 127  0 indentLength = other.indentLength;
 128  0 blockTabCount = other.blockTabCount;
 129  0 leadingWhiteSpaces = other.leadingWhiteSpaces;
 130  0 maxInStatementIndent = other.maxInStatementIndent;
 131  0 templateDepth = other.templateDepth;
 132  0 quoteChar = other.quoteChar;
 133  0 prevNonSpaceCh = other.prevNonSpaceCh;
 134  0 currentNonSpaceCh = other.currentNonSpaceCh;
 135  0 currentNonLegalCh = other.currentNonLegalCh;
 136  0 prevNonLegalCh = other.prevNonLegalCh;
 137  0 isInConditional = other.isInConditional;
 138  0 minConditionalIndent = other.minConditionalIndent;
 139  0 prevFinalLineSpaceTabCount = other.prevFinalLineSpaceTabCount;
 140  0 prevFinalLineTabCount = other.prevFinalLineTabCount;
 141  0 emptyLineFill = other.emptyLineFill;
 142  0 probationHeader = other.probationHeader;
 143  0 isInDefine = other.isInDefine;
 144  0 isInDefineDefinition = other.isInDefineDefinition;
 145  0 backslashEndsPrevLine = other.backslashEndsPrevLine;
 146  0 defineTabCount = other.defineTabCount;
 147    }
 148   
 149   
 150    /**
 151    * initialize the ASBeautifier.
 152    * This method should be called every time a ASBeautifier object is to
 153    * start beautifying a new source file.
 154    * <code>init()</code> receives an ASSourceIterator object that will be
 155    * used to iterate through the source code.
 156    *
 157    * @param iter a reference to the ASSourceIterator object
 158    */
 159  0 public void init(ASSourceIterator iter) {
 160  0 sourceIterator = iter;
 161  0 waitingBeautifierStack = new ASBeautifierStack();
 162  0 activeBeautifierStack = new ASBeautifierStack();
 163  0 waitingBeautifierStackLengthStack = new IntegerStack();
 164  0 activeBeautifierStackLengthStack = new IntegerStack();
 165  0 headerStack = new StringStack();
 166  0 tempStacks = new StackStack();
 167  0 tempStacks.push_back(new StringStack());
 168  0 blockParenDepthStack = new IntegerStack();
 169  0 blockStatementStack = new BooleanStack();
 170  0 parenStatementStack = new BooleanStack();
 171  0 bracketBlockStateStack = new BooleanStack();
 172  0 bracketBlockStateStack.push_back(true);
 173  0 inStatementIndentStack = new IntegerStack();
 174  0 inStatementIndentStackSizeStack = new IntegerStack();
 175  0 inStatementIndentStackSizeStack.push_back(0);
 176  0 parenIndentStack = new IntegerStack();
 177   
 178  0 immediatelyPreviousAssignmentOp = null;
 179  0 previousLastLineHeader = null;
 180   
 181  0 isInQuote = false;
 182  0 isInComment = false;
 183  0 isInStatement = false;
 184  0 isInCase = false;
 185  0 isInQuestion = false;
 186  0 isInClassHeader = false;
 187  0 isInClassHeaderTab = false;
 188  0 isInHeader = false;
 189  0 isInOperator = false;
 190  0 isInFor = false;
 191  0 isInTemplate = false;
 192  0 isInConditional = false;
 193  0 templateDepth = 0;
 194  0 parenDepth=0;
 195  0 blockTabCount = 0;
 196  0 leadingWhiteSpaces = 0;
 197  0 prevNonSpaceCh = '{';
 198  0 currentNonSpaceCh = '{';
 199  0 prevNonLegalCh = '{';
 200  0 currentNonLegalCh = '{';
 201  0 prevFinalLineSpaceTabCount = 0;
 202  0 prevFinalLineTabCount = 0;
 203  0 probationHeader = null;
 204  0 backslashEndsPrevLine = false;
 205  0 isInDefine = false;
 206  0 isInDefineDefinition = false;
 207  0 defineTabCount = 0;
 208    }
 209   
 210   
 211    /**
 212    * get indent mode.
 213    * @return true, if ASBeautifier indents using tab.
 214    */
 215  0 public final boolean getUseTabs() {
 216  0 return indentString.equals("\t");
 217    }
 218   
 219   
 220    /**
 221    * set indent mode.
 222    * @param useTabs true if ASBeautifier should indent using tabs,
 223    * otherwise indent using spaces.
 224    */
 225  0 public final void setUseTabs(boolean useTabs) {
 226  0 if (useTabs)
 227  0 setTabIndentation(indentLength);
 228    else
 229  0 setSpaceIndentation(indentLength);
 230    }
 231   
 232   
 233    /**
 234    * get tab indentation.
 235    * @return number of spaces to assume for one tab.
 236    */
 237  0 public final int getTabIndentation() {
 238  0 return indentLength;
 239    }
 240   
 241   
 242    /**
 243    * indent using one tab per indentation.
 244    * @param length assume each tab is this spaces long.
 245    */
 246  0 public final void setTabIndentation(int length) {
 247  0 indentString = "\t";
 248  0 indentLength = length;
 249   
 250  0 if (!isMinimalConditinalIndentSet)
 251  0 minConditionalIndent = indentLength * 2;
 252    }
 253   
 254   
 255    /**
 256    * get value of 'forceTabs' property.
 257    * @return the value of the <code>forceTabs</code> property.
 258    */
 259  0 public final boolean getForceTabs() {
 260  0 return shouldForceTabIndentation;
 261    }
 262   
 263   
 264    /**
 265    * enforce usage of tabs.
 266    * @param forceTabs if true, the beautifier uses tabs in areas where
 267    * it otherwise would use spaces.
 268    */
 269  0 public final void setForceTabs(boolean forceTabs) {
 270  0 shouldForceTabIndentation = forceTabs;
 271    }
 272   
 273   
 274    /**
 275    * get space indentation.
 276    * @return number of spaces per indent.
 277    */
 278  0 public final int getSpaceIndentation() {
 279  0 return indentLength;
 280    }
 281   
 282   
 283    /**
 284    * indent using a number of spaces per indentation.
 285    * @param length number of spaces per indent. The default is 4.
 286    */
 287  0 public final void setSpaceIndentation(int length) {
 288  0 StringBuffer indentBuf = new StringBuffer();
 289   
 290  0 for (int i = 0; i < length; i++)
 291  0 indentBuf.append(' ');
 292   
 293  0 indentString = indentBuf.toString();
 294  0 indentLength = length;
 295   
 296  0 if (!isMinimalConditinalIndentSet)
 297  0 minConditionalIndent = indentLength * 2;
 298    }
 299   
 300   
 301    /**
 302    * get maximum indentation between two lines in a multi-line statement.
 303    * @return maximum indentation length.
 304    */
 305  0 public final int getMaxInStatementIndentLength() {
 306  0 return maxInStatementIndent;
 307    }
 308   
 309   
 310    /**
 311    * set the maximum indentation between two lines in a multi-line statement.
 312    * @param max maximum indentation length.
 313    */
 314  0 public final void setMaxInStatementIndentLength(int max) {
 315  0 maxInStatementIndent = max;
 316    }
 317   
 318   
 319    /**
 320    * get the minimum indentation between two lines in a multi-line condition.
 321    * @return minimal indentation length. The default is twice the indent level.
 322    * @see #setSpaceIndentation(int)
 323    */
 324  0 public final int getMinConditionalIndentLength() {
 325  0 if (!isMinimalConditinalIndentSet)
 326  0 setMinConditionalIndentLength(indentLength * 2);
 327  0 return minConditionalIndent;
 328    }
 329   
 330   
 331    /**
 332    * set the minimum indentation between two lines in a multi-line condition.
 333    * @param min minimal indentation length.
 334    */
 335  0 public final void setMinConditionalIndentLength(int min) {
 336  0 minConditionalIndent = min;
 337  0 isMinimalConditinalIndentSet = true;
 338    }
 339   
 340   
 341    /**
 342    * get the state of the class indentation option. If true, C++ class
 343    * definitions will be indented one additional indent.
 344    * @return state of option.
 345    */
 346  0 public final boolean getClassIndent() {
 347  0 return classIndent;
 348    }
 349   
 350   
 351    /**
 352    * set the state of the class indentation option. If true, C++ class
 353    * definitions will be indented one additional indent.
 354    * @param state state of option.
 355    */
 356  0 public final void setClassIndent(boolean state) {
 357  0 classIndent = state;
 358    }
 359   
 360   
 361    /**
 362    * get the state of the switch indentation option. If true, blocks of
 363    * 'switch' statements will be indented one additional indent.
 364    * @return state of option.
 365    */
 366  0 public final boolean getSwitchIndent() {
 367  0 return switchIndent;
 368    }
 369   
 370   
 371    /**
 372    * set the state of the switch indentation option. If true, blocks of
 373    * 'switch' statements will be indented one additional indent.
 374    * @param state state of option.
 375    */
 376  0 public final void setSwitchIndent(boolean state) {
 377  0 switchIndent = state;
 378    }
 379   
 380   
 381    /**
 382    * get the state of the case indentation option. If true, lines of 'case'
 383    * statements will be indented one additional indent.
 384    * @return state of option.
 385    */
 386  0 public final boolean getCaseIndent() {
 387  0 return caseIndent;
 388    }
 389   
 390   
 391    /**
 392    * set the state of the case indentation option. If true, lines of 'case'
 393    * statements will be indented one additional indent.
 394    * @param state state of option.
 395    */
 396  0 public final void setCaseIndent(boolean state) {
 397  0 caseIndent = state;
 398    }
 399   
 400   
 401    /**
 402    * get the state of the bracket indentation option. If true, brackets will
 403    * be indented one additional indent.
 404    * @return state of option.
 405    */
 406  0 public final boolean getBracketIndent() {
 407  0 return bracketIndent;
 408    }
 409   
 410   
 411    /**
 412    * set the state of the bracket indentation option. If true, brackets will
 413    * be indented one additional indent.
 414    * @param state state of option.
 415    */
 416  0 public final void setBracketIndent(boolean state) {
 417  0 if (state)
 418  0 setBlockIndent(false); // so that we don't have both bracket and block indent
 419  0 bracketIndent = state;
 420    }
 421   
 422   
 423    /**
 424    * get the state of the block indentation option. If true, entire blocks
 425    * will be indented one additional indent, similar to the GNU indent style.
 426    * @param state state of option.
 427    */
 428  0 public final boolean getBlockIndent() {
 429  0 return blockIndent;
 430    }
 431   
 432   
 433    /**
 434    * set the state of the block indentation option. If true, entire blocks
 435    * will be indented one additional indent, similar to the GNU indent style.
 436    * @param state state of option.
 437    */
 438  0 public final void setBlockIndent(boolean state) {
 439  0 if (state)
 440  0 setBracketIndent(false); // so that we don't have both bracket and block indent
 441  0 blockIndent = state;
 442    }
 443   
 444   
 445    /**
 446    * get the state of the namespace indentation option.
 447    * If true, blocks of 'namespace' statements will be indented one
 448    * additional indent. Otherwise, NO indentation will be added.
 449    * @return state of option.
 450    */
 451  0 public final boolean getNamespaceIndent() {
 452  0 return namespaceIndent;
 453    }
 454   
 455   
 456    /**
 457    * set the state of the namespace indentation option.
 458    * If true, blocks of 'namespace' statements will be indented one
 459    * additional indent. Otherwise, NO indentation will be added.
 460    * @param state state of option.
 461    */
 462  0 public final void setNamespaceIndent(boolean state) {
 463  0 namespaceIndent = state;
 464    }
 465   
 466   
 467    /**
 468    * get the state of the label indentation option.
 469    * If true, labels will be indented one indent LESS than the
 470    * current indentation level.
 471    * If false, labels will be flushed to the left with NO
 472    * indent at all.
 473    * @return state of option.
 474    */
 475  0 public final boolean getLabelIndent() {
 476  0 return labelIndent;
 477    }
 478   
 479   
 480    /**
 481    * set the state of the label indentation option.
 482    * If true, labels will be indented one indent LESS than the
 483    * current indentation level.
 484    * If false, labels will be flushed to the left with NO
 485    * indent at all.
 486    * @param state state of option.
 487    */
 488  0 public final void setLabelIndent(boolean state) {
 489  0 labelIndent = state;
 490    }
 491   
 492   
 493    /**
 494    * return true, if C formatting style is on.
 495    * @return true, if C formatting style is on, otherwise false.
 496    */
 497  0 public final boolean isCStyle() {
 498  0 return isCStyle;
 499    }
 500   
 501   
 502    /**
 503    * set C formatting style. Set this to true, if you want to beautify a
 504    * C/C++ file. If true, the beautifier performs additional indenting
 505    * on templates and precompiler instructions, among other things.
 506    * Corresponds to the options "--mode=c" and "--mode=java".
 507    * @param state if true, C formatting style is on, otherwise off.
 508    */
 509  0 public final void setCStyle(boolean state) {
 510  0 isCStyle = state;
 511    }
 512   
 513   
 514    /**
 515    * get the state of the empty line fill option.
 516    * If true, empty lines will be filled with the whitespace.
 517    * of their previous lines.
 518    * If false, these lines will remain empty.
 519    * @return state of option.
 520    */
 521  0 public final boolean getEmptyLineFill() {
 522  0 return emptyLineFill;
 523    }
 524   
 525   
 526    /**
 527    * set the state of the empty line fill option.
 528    * If true, empty lines will be filled with the whitespace.
 529    * of their previous lines.
 530    * If false, these lines will remain empty.
 531    * @param state state of option.
 532    */
 533  0 public final void setEmptyLineFill(boolean state) {
 534  0 emptyLineFill = state;
 535    }
 536   
 537   
 538    /**
 539    * get the state of the preprocessor indentation option.
 540    * If true, multiline #define statements will be indented.
 541    * @return state of option.
 542    */
 543  0 public final boolean getPreprocessorIndent() {
 544  0 return preprocessorIndent;
 545    }
 546   
 547   
 548    /**
 549    * set the state of the preprocessor indentation option.
 550    * If true, multiline #define statements will be indented.
 551    * @param state state of option.
 552    */
 553  0 public final void setPreprocessorIndent(boolean state) {
 554  0 preprocessorIndent = state;
 555    }
 556   
 557   
 558    /**
 559    * check if there are any indented lines ready to be read by nextLine()
 560    * @return are there any indented lines ready?
 561    */
 562  0 public boolean hasMoreLines() {
 563  0 return sourceIterator.hasMoreLines();
 564    }
 565   
 566   
 567    /**
 568    * get the next indented line.
 569    * @return indented line.
 570    */
 571  0 public String nextLine() {
 572  0 return beautify(sourceIterator.nextLine());
 573    }
 574   
 575   
 576    /**
 577    * beautify a line of source code.
 578    * every line of source code in a source code file should be sent
 579    * one after the other to the beautify method.
 580    * @return the indented line.
 581    * @param originalLine the original unindented line.
 582    */
 583  0 protected String beautify(String originalLine) {
 584  0 String line;
 585  0 boolean isInLineComment = false;
 586  0 boolean isInClass = false;
 587  0 boolean isInSwitch = false;
 588  0 boolean isImmediatelyAfterConst = false;
 589  0 boolean isSpecialChar = false;
 590  0 char ch = ' ';
 591  0 char prevCh;
 592    // TODO: how to handle eof
 593  0 if(null==originalLine){
 594  0 return "";
 595    }
 596  0 StringBuffer outBuffer = new StringBuffer(); // the newly idented line is buffered here
 597  0 int tabCount = 0;
 598  0 String lastLineHeader = null;
 599  0 boolean closingBracketReached = false;
 600  0 int spaceTabCount = 0;
 601  0 char tempCh;
 602  0 int headerStackSize = headerStack.size();
 603    //boolean isLineInStatement = isInStatement;
 604  0 boolean shouldIndentBrackettedLine = true;
 605  0 int lineOpeningBlocksNum = 0;
 606  0 int lineClosingBlocksNum = 0;
 607  0 boolean previousLineProbation = (probationHeader != null);
 608  0 int i;
 609   
 610  0 currentHeader = null;
 611   
 612    // handle and remove white spaces around the line:
 613    // If not in comment, first find out size of white space before line,
 614    // so that possible comments starting in the line continue in
 615    // relation to the preliminary white-space.
 616  0 if (!isInComment) {
 617  0 leadingWhiteSpaces = 0;
 618  0 while (leadingWhiteSpaces < originalLine.length() && originalLine.charAt(leadingWhiteSpaces) <= 0x20)
 619  0 leadingWhiteSpaces++;
 620   
 621  0 line = originalLine.trim();
 622    } else {
 623  0 int trimSize;
 624  0 for (trimSize = 0;
 625  0 trimSize < originalLine.length() && trimSize < leadingWhiteSpaces && originalLine.charAt(trimSize) <= 0x20;
 626    trimSize++)
 627    ;
 628  0 line = originalLine.substring(trimSize);
 629    }
 630   
 631  0 if (line.length() == 0)
 632  0 if (emptyLineFill)
 633  0 return preLineWS(prevFinalLineSpaceTabCount, prevFinalLineTabCount);
 634    else
 635  0 return line;
 636   
 637    // handle preprocessor commands
 638  0 if (isCStyle && !isInComment && (line.charAt(0) == '#' || backslashEndsPrevLine)) {
 639  0 if (line.charAt(0) == '#') {
 640  0 String preproc = line.substring(1).trim();
 641    // When finding a multi-lined #define statement, the original beautifier
 642    // 1. sets its isInDefineDefinition flag
 643    // 2. clones a new beautifier that will be used for the actual indentation
 644    // of the #define. This clone is put into the activeBeautifierStack in order
 645    // to be called for the actual indentation.
 646    // The original beautifier will have isInDefineDefinition = true, isInDefine = false.
 647    // The cloned beautifier will have isInDefineDefinition = true, isInDefine = true.
 648  0 if (preprocessorIndent && preproc.equals("define") && line.endsWith("\\")) {
 649  0 if (!isInDefineDefinition) {
 650    // this is the original beautifier
 651  0 isInDefineDefinition = true;
 652    // push a new beautifier into the active stack
 653    // this breautifier will be used for the indentation of this define
 654  0 ASBeautifier defineBeautifier = new ASBeautifier(this);
 655    //defineBeautifier.init();
 656    //defineBeautifier.isInDefineDefinition = true;
 657    //defineBeautifier.beautify("");
 658  0 activeBeautifierStack.push_back(defineBeautifier);
 659    } else {
 660    // this is the cloned beautifier that is in charge of indenting the #define.
 661  0 isInDefine = true;
 662    }
 663    }
 664  0 else if (preproc.equals("if")) {
 665    // push a new beautifier into the stack
 666  0 waitingBeautifierStackLengthStack.push_back(waitingBeautifierStack.size());
 667  0 activeBeautifierStackLengthStack.push_back(activeBeautifierStack.size());
 668  0 waitingBeautifierStack.push_back(new ASBeautifier(this));
 669    }
 670  0 else if (preproc.equals("else")) {
 671  0 if (!waitingBeautifierStack.empty()) {
 672    // MOVE current waiting beautifier to active stack.
 673  0 activeBeautifierStack.push_back(waitingBeautifierStack.back());
 674  0 waitingBeautifierStack.pop_back();
 675    }
 676    }
 677  0 else if (preproc.equals("elif")) {
 678  0 if (!waitingBeautifierStack.empty()) {
 679    // append a COPY current waiting beautifier to active stack, WITHOUT deleting the original.
 680  0 activeBeautifierStack.push_back(new ASBeautifier(waitingBeautifierStack.back()));
 681    }
 682    }
 683  0 else if (preproc.equals("endif")) {
 684  0 int stackLength;
 685  0 ASBeautifier beautifier;
 686   
 687  0 if (!waitingBeautifierStackLengthStack.empty()) {
 688  0 stackLength = waitingBeautifierStackLengthStack.back();
 689  0 waitingBeautifierStackLengthStack.pop_back();
 690  0 while (waitingBeautifierStack.size() > stackLength) {
 691  0 beautifier = waitingBeautifierStack.back();
 692  0 waitingBeautifierStack.pop_back();
 693  0 beautifier = null;
 694    }
 695    }
 696   
 697  0 if (!activeBeautifierStackLengthStack.empty()) {
 698  0 stackLength = activeBeautifierStackLengthStack.back();
 699  0 activeBeautifierStackLengthStack.pop_back();
 700  0 while (activeBeautifierStack.size() > stackLength) {
 701  0 beautifier = activeBeautifierStack.back();
 702  0 activeBeautifierStack.pop_back();
 703  0 beautifier = null;
 704    }
 705    }
 706    }
 707    } // if (line.charAt(0) == '#')
 708   
 709    // check if the last char is a backslash
 710  0 if (line.length() > 0)
 711  0 backslashEndsPrevLine = line.endsWith("\\");
 712    else
 713  0 backslashEndsPrevLine = false;
 714   
 715    // check if this line ends a multi-line #define.
 716    // if so, use the #define's cloned beautifier for the line's indentation
 717    // and then remove it from the active beautifier stack and delete it.
 718  0 if (!backslashEndsPrevLine && isInDefineDefinition && !isInDefine) {
 719  0 String beautifiedLine;
 720  0 ASBeautifier defineBeautifier;
 721   
 722  0 isInDefineDefinition = false;
 723  0 defineBeautifier = activeBeautifierStack.back();
 724  0 activeBeautifierStack.pop_back();
 725   
 726  0 beautifiedLine = defineBeautifier.beautify(line);
 727  0 defineBeautifier = null;
 728  0 return beautifiedLine;
 729    }
 730   
 731    // unless this is a multi-line #define, return this precompiler line as is.
 732  0 if (!isInDefine && !isInDefineDefinition)
 733  0 return originalLine;
 734    } // if preprocessor command
 735   
 736    // if there exists any worker beautifier in the activeBeautifierStack,
 737    // then use it instead of me to indent the current line.
 738  0 if (!isInDefine && activeBeautifierStack != null && !activeBeautifierStack.empty())
 739  0 return activeBeautifierStack.back().beautify(line);
 740   
 741    // calculate preliminary indentation based on data from past lines
 742  0 if (!inStatementIndentStack.empty())
 743  0 spaceTabCount = inStatementIndentStack.back();
 744   
 745  0 for (i = 0; i < headerStackSize; i++) {
 746  0 isInClass = false;
 747   
 748  0 if (blockIndent || (!(i > 0 && headerStack.at(i-1) != AS_OPEN_BRACKET
 749    && headerStack.at(i) == AS_OPEN_BRACKET)))
 750  0 ++tabCount;
 751   
 752  0 if (isCStyle && !namespaceIndent && i >= 1
 753    && headerStack.at(i-1) == AS_NAMESPACE
 754    && headerStack.at(i) == AS_OPEN_BRACKET)
 755  0 --tabCount;
 756   
 757  0 if (isCStyle && i >= 1
 758    && headerStack.at(i-1) == AS_CLASS
 759    && headerStack.at(i) == AS_OPEN_BRACKET)
 760    {
 761  0 if (classIndent)
 762  0 ++tabCount;
 763  0 isInClass = true;
 764    }
 765  0 else if (switchIndent && i > 1
 766    && headerStack.at(i-1) == AS_SWITCH
 767    && headerStack.at(i) == AS_OPEN_BRACKET)
 768    {
 769    // is the switchIndent option is on, indent switch statements an additional indent.
 770  0 ++tabCount;
 771  0 isInSwitch = true;
 772    }
 773    } // for
 774   
 775  0 if (isCStyle && isInClass && classIndent && headerStackSize >= 2
 776    && headerStack.at(headerStackSize-2) == AS_CLASS
 777    && headerStack.at(headerStackSize-1) == AS_OPEN_BRACKET
 778    && line.charAt(0) == '}')
 779  0 --tabCount;
 780  0 else if (isInSwitch && switchIndent && headerStackSize >= 2
 781    && headerStack.at(headerStackSize-2) == AS_SWITCH
 782    && headerStack.at(headerStackSize-1) == AS_OPEN_BRACKET
 783    && line.charAt(0) == '}')
 784  0 --tabCount;
 785   
 786  0 if (isInClassHeader) {
 787  0 isInClassHeaderTab = true;
 788  0 tabCount += 2;
 789    }
 790   
 791  0 if (isInConditional)
 792  0 --tabCount;
 793   
 794    // parse characters in the current line.
 795  0 for (i = 0; i < line.length(); i++) {
 796  0 tempCh = line.charAt(i);
 797  0 prevCh = ch;
 798  0 ch = tempCh;
 799  0 outBuffer.append(ch);
 800   
 801  0 if (isWhiteSpace(ch))
 802  0 continue;
 803   
 804    // handle special characters (i.e. backslash and characters such as \n, \t, ...)
 805  0 if (isSpecialChar) {
 806  0 isSpecialChar = false;
 807  0 continue;
 808    }
 809  0 if (!(isInComment || isInLineComment) && line.regionMatches(i, "\\\\", 0, 2)) {
 810  0 outBuffer.append('\\');
 811  0 i++;
 812  0 continue;
 813    }
 814  0 if (!(isInComment || isInLineComment) && ch=='\\') {
 815  0 isSpecialChar = true;
 816  0 continue;
 817    }
 818   
 819    // handle quotes (such as 'x' and "Hello Dolly")
 820  0 if (!(isInComment || isInLineComment) && (ch=='"' || ch=='\'')) {
 821  0 if (!isInQuote) {
 822  0 quoteChar = ch;
 823  0 isInQuote = true;
 824  0 } else if (quoteChar == ch) {
 825  0 isInQuote = false;
 826  0 isInStatement = true;
 827  0 continue;
 828    }
 829    }
 830  0 if (isInQuote)
 831  0 continue;
 832   
 833    // handle comments
 834  0 if (!(isInComment || isInLineComment) && line.regionMatches(i, AS_OPEN_LINE_COMMENT, 0, 2)) {
 835  0 isInLineComment = true;
 836  0 outBuffer.append('/');
 837  0 i++;
 838  0 continue;
 839    }
 840  0 else if (!(isInComment || isInLineComment) && line.regionMatches(i, AS_OPEN_COMMENT, 0, 2)) {
 841  0 isInComment = true;
 842  0 outBuffer.append('*');
 843  0 i++;
 844  0 continue;
 845    }
 846  0 else if ((isInComment || isInLineComment) && line.regionMatches(i, AS_CLOSE_COMMENT, 0, 2)) {
 847  0 isInComment = false;
 848  0 outBuffer.append('/');
 849  0 i++;
 850  0 continue;
 851    }
 852   
 853  0 if (isInComment || isInLineComment) {
 854  0 continue;
 855    }
 856   
 857    // if we have reached this far then we are NOT in a comment or string of special character...
 858  0 if (probationHeader != null) {
 859  0 if (((probationHeader == AS_STATIC || probationHeader == AS_CONST) && ch == '{')
 860    || (probationHeader == AS_SYNCHRONIZED && ch == '('))
 861    {
 862    // insert the probation header as a new header
 863  0 isInHeader = true;
 864  0 headerStack.push_back(probationHeader);
 865   
 866    // handle the specific probation header
 867  0 isInConditional = (probationHeader == AS_SYNCHRONIZED);
 868  0 if (probationHeader == AS_CONST)
 869  0 isImmediatelyAfterConst = true;
 870    // isInConst = true;
 871    // TODO:
 872    // There is actually no more need for the global isInConst variable.
 873    // The only reason for checking const is to see if there is a const
 874    // immediately before an open-bracket.
 875    // Since CONST is now put into probation and is checked during itspost-char,
 876    // isImmediatelyAfterConst can be set by its own...
 877   
 878  0 isInStatement = false;
 879    // if the probation comes from the previous line, then indent by 1 tab count.
 880  0 if (previousLineProbation && ch == '{')
 881  0 tabCount++;
 882  0 previousLineProbation = false;
 883    }
 884   
 885    // dismiss the probation header
 886  0 probationHeader = null;
 887    }
 888   
 889  0 prevNonSpaceCh = currentNonSpaceCh;
 890  0 currentNonSpaceCh = ch;
 891  0 if (!isLegalNameChar(ch) && ch != ',' && ch != ';') {
 892  0 prevNonLegalCh = currentNonLegalCh;
 893  0 currentNonLegalCh = ch;
 894    }
 895   
 896    //if (isInConst)
 897    //{
 898    // isInConst = false;
 899    // isImmediatelyAfterConst = true;
 900    //}
 901   
 902  0 if (isInHeader) {
 903  0 isInHeader = false;
 904  0 currentHeader = headerStack.back();
 905    }
 906    else
 907  0 currentHeader = null;
 908   
 909    // handle templates
 910  0 if (isCStyle && isInTemplate
 911    && (ch == '<' || ch == '>')
 912    && findHeader(line, i, nonAssignmentOperators) == null)
 913    {
 914  0 if (ch == '<')
 915  0 ++templateDepth;
 916  0 else if (ch == '>') {
 917  0 if (--templateDepth <= 0) {
 918  0 if (isInTemplate)
 919  0 ch = ';';
 920    else
 921  0 ch = 't';
 922  0 isInTemplate = false;
 923  0 templateDepth = 0;
 924    }
 925    }
 926    }
 927   
 928    // handle parenthesies
 929  0 if (ch == '(' || ch == '[' || ch == ')' || ch == ']') {
 930  0 if (ch == '(' || ch == '[') {
 931  0 if (parenDepth == 0) {
 932  0 parenStatementStack.push_back(isInStatement);
 933  0 isInStatement = true;
 934    }
 935  0 parenDepth++;
 936  0 inStatementIndentStackSizeStack.push_back(inStatementIndentStack.size());
 937   
 938  0 if (currentHeader != null)
 939  0 registerInStatementIndent(line, i, spaceTabCount, minConditionalIndent /*indentLength*2 */, true);
 940    else
 941  0 registerInStatementIndent(line, i, spaceTabCount, 0, true);
 942    }
 943  0 else if (ch == ')' || ch == ']') {
 944  0 parenDepth--;
 945  0 if (parenDepth == 0) {
 946  0 isInStatement = parenStatementStack.back();
 947  0 parenStatementStack.pop_back();
 948  0 ch = ' ';
 949  0 isInConditional = false;
 950    }
 951   
 952  0 if (!inStatementIndentStackSizeStack.empty()) {
 953  0 int previousIndentStackSize = inStatementIndentStackSizeStack.back();
 954  0 inStatementIndentStackSizeStack.pop_back();
 955  0 while (previousIndentStackSize < inStatementIndentStack.size())
 956  0 inStatementIndentStack.pop_back();
 957   
 958  0 if (!parenIndentStack.empty()) {
 959  0 int poppedIndent = parenIndentStack.back();
 960  0 parenIndentStack.pop_back();
 961  0 if (i == 0)
 962  0 spaceTabCount = poppedIndent;
 963    }
 964    }
 965    }
 966  0 continue;
 967    } // if handle parenthesis
 968   
 969    // handle block start
 970  0 if (ch == '{') {
 971  0 boolean isBlockOpener = false;
 972   
 973    // first, check if '{' is a block-opener or an static-array opener
 974  0 isBlockOpener = ((prevNonSpaceCh == '{' && bracketBlockStateStack.back())
 975    || prevNonSpaceCh == '}'
 976    || prevNonSpaceCh == ')'
 977    || prevNonSpaceCh == ';'
 978    || isInClassHeader
 979    || isBlockOpener
 980    || isImmediatelyAfterConst
 981    || (isInDefine &&
 982    (prevNonSpaceCh == '('
 983    || prevNonSpaceCh == '_'
 984    || Character.isLetterOrDigit(prevNonSpaceCh))));
 985  0 isInClassHeader = false;
 986  0 if (!isBlockOpener && currentHeader != null)
 987  0 if (nonParenHeaders.contains(currentHeader))
 988  0 isBlockOpener = true;
 989  0 bracketBlockStateStack.push_back(isBlockOpener);
 990  0 if (!isBlockOpener) {
 991  0 inStatementIndentStackSizeStack.push_back(inStatementIndentStack.size());
 992  0 registerInStatementIndent(line, i, spaceTabCount, 0, true);
 993  0 parenDepth++;
 994  0 if (i == 0)
 995  0 shouldIndentBrackettedLine = false;
 996  0 continue;
 997    }
 998   
 999    // this bracket is a block opener..
 1000   
 1001  0 ++lineOpeningBlocksNum;
 1002   
 1003  0 if (isInClassHeader)
 1004  0 isInClassHeader = false;
 1005  0 if (isInClassHeaderTab) {
 1006  0 isInClassHeaderTab = false;
 1007  0 tabCount -= 2;
 1008    }
 1009   
 1010    /// danson
 1011  0 if (isInFor) {
 1012  0 isInFor = false;
 1013    }
 1014   
 1015  0 blockParenDepthStack.push_back(parenDepth);
 1016  0 blockStatementStack.push_back(isInStatement);
 1017  0 inStatementIndentStackSizeStack.push_back(inStatementIndentStack.size());
 1018   
 1019  0 blockTabCount += isInStatement ? 1 : 0;
 1020  0 parenDepth = 0;
 1021  0 isInStatement = false;
 1022   
 1023  0 tempStacks.push_back(new StringStack());
 1024  0 headerStack.push_back(AS_OPEN_BRACKET);
 1025  0 lastLineHeader = AS_OPEN_BRACKET; // <------
 1026   
 1027  0 continue;
 1028    }
 1029   
 1030    // check if a header has been reached
 1031  0 if (prevCh == ' ') {
 1032  0 boolean isIndentableHeader = true;
 1033  0 String newHeader = findHeader(line, i, headers);
 1034  0 if (newHeader != null) {
 1035    // if we reached here, then this is a header...
 1036  0 isInHeader = true;
 1037  0 StringStack lastTempStack;
 1038  0 if (tempStacks.empty())
 1039  0 lastTempStack = null;
 1040    else
 1041  0 lastTempStack = (StringStack) tempStacks.back();
 1042   
 1043    // if a new block is opened, push a new stack into tempStacks to hold the
 1044    // future list of headers in the new block.
 1045   
 1046    // take care of the special case: 'else if (...)'
 1047  0 if (newHeader == AS_IF && lastLineHeader == AS_ELSE) {
 1048    //spaceTabCount += indentLength; // to counter the opposite addition that occurs when the 'if' is registered below...
 1049  0 headerStack.pop_back();
 1050    }
 1051    // take care of 'else'
 1052  0 else if (newHeader == AS_ELSE) {
 1053  0 if (lastTempStack != null) {
 1054  0 int indexOfIf = lastTempStack.indexOf(AS_IF); // <---
 1055  0 if (indexOfIf != -1) {
 1056    // recreate the header list in headerStack up to the previous 'if'
 1057    // from the temporary snapshot stored in lastTempStack.
 1058  0 int restackSize = lastTempStack.size() - indexOfIf - 1;
 1059  0 for (int r = 0; r < restackSize; r++) {
 1060  0 headerStack.push_back(lastTempStack.back());
 1061  0 lastTempStack.pop_back();
 1062    }
 1063  0 if (!closingBracketReached)
 1064  0 tabCount += restackSize;
 1065    }
 1066    // If the above if is not true, i.e. no 'if' before the 'else',
 1067    // then nothing beautiful will come out of this...
 1068    // I should think about inserting an Exception here to notify the caller of this...
 1069    }
 1070    }
 1071    // check if 'while' closes a previous 'do'
 1072  0 else if (newHeader == AS_WHILE) {
 1073  0 if (lastTempStack != null) {
 1074  0 int indexOfDo = lastTempStack.indexOf(AS_DO); // <---
 1075  0 if (indexOfDo != -1) {
 1076    // recreate the header list in headerStack up to the previous 'do'
 1077    // from the temporary snapshot stored in lastTempStack.
 1078  0 int restackSize = lastTempStack.size() - indexOfDo - 1;
 1079  0 for (int r = 0; r < restackSize; r++) {
 1080  0 headerStack.push_back(lastTempStack.back());
 1081  0 lastTempStack.pop_back();
 1082    }
 1083  0 if (!closingBracketReached)
 1084  0 tabCount += restackSize;
 1085    }
 1086    }
 1087    }
 1088    /// danson, added check for 'for' for Java 1.5's "for(... : ...)" construct
 1089  0 else if (newHeader == AS_FOR) {
 1090  0 isInFor = true;
 1091    }
 1092   
 1093    // check if 'catch' closes a previous 'try' or 'catch'
 1094  0 else if (newHeader == AS_CATCH || newHeader == AS_FINALLY) {
 1095  0 if (lastTempStack != null) {
 1096  0 int indexOfTry = lastTempStack.indexOf(AS_TRY);
 1097  0 if (indexOfTry == -1)
 1098  0 indexOfTry = lastTempStack.indexOf(AS_CATCH);
 1099  0 if (indexOfTry != -1) {
 1100    // recreate the header list in headerStack up to the previous 'try'
 1101    // from the temporary snapshot stored in lastTempStack.
 1102  0 int restackSize = lastTempStack.size() - indexOfTry - 1;
 1103  0 for (int r = 0; r < restackSize; r++) {
 1104  0 headerStack.push_back(lastTempStack.back());
 1105  0 lastTempStack.pop_back();
 1106    }
 1107  0 if (!closingBracketReached)
 1108  0 tabCount += restackSize;
 1109    }
 1110    }
 1111    }
 1112  0 else if (newHeader == AS_CASE) {
 1113  0 isInCase = true;
 1114  0 if (!caseIndent)
 1115  0 --tabCount;
 1116    }
 1117  0 else if (newHeader == AS_DEFAULT) {
 1118  0 isInCase = true;
 1119  0 if (!caseIndent)
 1120  0 --tabCount;
 1121    }
 1122  0 else if (newHeader == AS_PUBLIC || newHeader == AS_PROTECTED || newHeader == AS_PRIVATE) {
 1123  0 if (isCStyle && !isInClassHeader)
 1124  0 --tabCount;
 1125  0 isIndentableHeader = false;
 1126    }
 1127    //else if ((newHeader == AS_STATIC || newHeader == AS_SYNCHRONIZED) &&
 1128    // !headerStack.empty() &&
 1129    // (headerStack.back() == AS_STATIC || headerStack.back() == AS_SYNCHRONIZED))
 1130    //{
 1131    // isIndentableHeader = false;
 1132    //}
 1133  0 else if (newHeader == AS_STATIC
 1134    || newHeader == AS_SYNCHRONIZED
 1135    || (newHeader == AS_CONST && isCStyle))
 1136    {
 1137  0 if (!headerStack.empty()
 1138    && (headerStack.back() == AS_STATIC
 1139    || headerStack.back() == AS_SYNCHRONIZED
 1140    || headerStack.back() == AS_CONST))
 1141    {
 1142  0 isIndentableHeader = false;
 1143    } else {
 1144  0 isIndentableHeader = false;
 1145  0 probationHeader = newHeader;
 1146    }
 1147    }
 1148  0 else if (newHeader == AS_CONST) {
 1149    // this will be entered only if NOT in C style
 1150    // since otherwise the CONST would be found to be a probation header...
 1151  0 isIndentableHeader = false;
 1152    }
 1153    /*
 1154    else if (newHeader == AS_OPERATOR) {
 1155    if (isCStyle) {
 1156    isInOperator = true;
 1157    }
 1158    isIndentableHeader = false;
 1159    }
 1160    */
 1161  0 else if (newHeader == AS_TEMPLATE) {
 1162  0 if (isCStyle)
 1163  0 isInTemplate = true;
 1164  0 isIndentableHeader = false;
 1165    }
 1166   
 1167  0 if (isIndentableHeader) {
 1168    //spaceTabCount -= indentLength;
 1169  0 headerStack.push_back(newHeader);
 1170  0 isInStatement = false;
 1171  0 if (nonParenHeaders.indexOf(newHeader) == -1)
 1172  0 isInConditional = true;
 1173  0 lastLineHeader = newHeader;
 1174    }
 1175    else
 1176  0 isInHeader = false;
 1177   
 1178    //lastLineHeader = newHeader;
 1179   
 1180  0 outBuffer.append(newHeader.substring(1));
 1181  0 i += newHeader.length() - 1;
 1182   
 1183  0 continue;
 1184    } // if (newHeader != null)
 1185    } // if (prevCh == ' ')
 1186   
 1187    // handle operators
 1188  0 if (isCStyle &&
 1189    !Character.isLetter(prevCh) &&
 1190    line.regionMatches(i, AS_OPERATOR, 0, 8) &&
 1191    !Character.isLetterOrDigit(line.charAt(i+8)))
 1192    {
 1193  0 isInOperator = true;
 1194  0 outBuffer.append(AS_OPERATOR.substring(1));
 1195  0 i += 7;
 1196  0 continue;
 1197    }
 1198   
 1199  0 if (ch == '?')
 1200  0 isInQuestion = true;
 1201   
 1202    // special handling of 'case' statements
 1203  0 if (ch == ':') {
 1204  0 if (line.length() > i+1 && line.charAt(i+1) == ':') {
 1205    // this is '::'
 1206  0 ++i;
 1207  0 outBuffer.append(':');
 1208  0 ch = ' ';
 1209  0 continue;
 1210    }
 1211  0 else if (isCStyle && isInClass && prevNonSpaceCh != ')') {
 1212  0 --tabCount;
 1213    // found a 'private:' or 'public:' inside a class definition,
 1214    // so do nothing special
 1215    }
 1216  0 else if (isCStyle && isInClassHeader) {
 1217    // found a 'class A : public B' definition
 1218    // so do nothing special
 1219    }
 1220  0 else if (isInQuestion) {
 1221  0 isInQuestion = false;
 1222    }
 1223  0 else if (isInFor) { /// danson
 1224  0 continue;
 1225    }
 1226  0 else if (isCStyle && prevNonSpaceCh == ')') {
 1227  0 isInClassHeader = true;
 1228  0 if (i==0)
 1229  0 tabCount += 2;
 1230    }
 1231    else {
 1232  0 currentNonSpaceCh = ';'; // so that brackets after the ':' will appear as block-openers
 1233  0 if (isInCase) {
 1234  0 isInCase = false;
 1235  0 ch = ';'; // from here on, treat char as ';'
 1236    } else {
 1237    // is in a label (e.g. 'label1:')
 1238  0 if (labelIndent)
 1239  0 --tabCount; // unindent label by one indent
 1240    else
 1241  0 tabCount = 0; // completely flush indent to left
 1242    }
 1243    }
 1244    }
 1245   
 1246  0 if ((ch == ';' || (parenDepth > 0 && ch == ',')) && !inStatementIndentStackSizeStack.empty())
 1247  0 while (inStatementIndentStackSizeStack.back() + (parenDepth > 0 ? 1 : 0) < inStatementIndentStack.size())
 1248  0 inStatementIndentStack.pop_back();
 1249   
 1250    // handle ends of statements
 1251  0 if ((ch == ';' && parenDepth == 0) || ch == '}') {
 1252  0 if (ch == '}') {
 1253    // first check if this '}' closes a previous block, or a static array...
 1254  0 if (!bracketBlockStateStack.empty()) {
 1255  0 boolean bracketBlockState = bracketBlockStateStack.back();
 1256  0 bracketBlockStateStack.pop_back();
 1257  0 if (!bracketBlockState) {
 1258  0 if (!inStatementIndentStackSizeStack.empty()) {
 1259    // this bracket is a static array
 1260  0 int previousIndentStackSize = inStatementIndentStackSizeStack.back();
 1261  0 inStatementIndentStackSizeStack.pop_back();
 1262  0 while (previousIndentStackSize < inStatementIndentStack.size()) {
 1263  0 inStatementIndentStack.pop_back();
 1264    }
 1265  0 parenDepth--;
 1266  0 if (i == 0)
 1267  0 shouldIndentBrackettedLine = false;
 1268   
 1269  0 if (!parenIndentStack.empty()) {
 1270  0 int poppedIndent = parenIndentStack.back();
 1271  0 parenIndentStack.pop_back();
 1272  0 if (i == 0)
 1273  0 spaceTabCount = poppedIndent;
 1274    }
 1275    }
 1276  0 continue;
 1277    }
 1278    }
 1279   
 1280    // this bracket is block closer...
 1281   
 1282  0 ++lineClosingBlocksNum;
 1283   
 1284  0 if(!inStatementIndentStackSizeStack.empty())
 1285  0 inStatementIndentStackSizeStack.pop_back();
 1286   
 1287  0 if (!blockParenDepthStack.empty()) {
 1288  0 parenDepth = blockParenDepthStack.back();
 1289  0 blockParenDepthStack.pop_back();
 1290  0 isInStatement = blockStatementStack.back();
 1291  0 blockStatementStack.pop_back();
 1292   
 1293  0 if (isInStatement)
 1294  0 blockTabCount--;
 1295    }
 1296   
 1297  0 closingBracketReached = true;
 1298  0 int headerPlace = headerStack.indexOf(AS_OPEN_BRACKET); // <---
 1299  0 if (headerPlace != -1) {
 1300  0 String popped = headerStack.back();
 1301  0 while (popped != AS_OPEN_BRACKET) {
 1302  0 headerStack.pop_back();
 1303  0 popped = headerStack.back();
 1304    }
 1305  0 headerStack.pop_back();
 1306   
 1307  0 if (!tempStacks.empty()) {
 1308  0 StringStack temp = (StringStack) tempStacks.back();
 1309  0 tempStacks.pop_back();
 1310  0 temp = null;
 1311    }
 1312    }
 1313   
 1314  0 ch = ' ';
 1315    // needed due to cases such as '}else{', so that headers ('else' in this case) will be identified...
 1316    } // if (ch == '}')
 1317   
 1318    // Create a temporary snapshot of the current block's
 1319    // header-list in the uppermost inner stack in tempStacks,
 1320    // and clear the headerStack up to the beginning of the block.
 1321    // Thus, the next future statement will think it comes one
 1322    // indent past the block's '{' unless it specifically checks
 1323    // for a companion-header (such as a previous 'if' for an
 1324    // 'else' header) within the tempStacks, and recreates the
 1325    // temporary snapshot by manipulating the tempStacks.
 1326  0 if (!tempStacks.back().empty())
 1327  0 while (!tempStacks.back().empty()) {
 1328  0 StringStack s = (StringStack) tempStacks.back();
 1329  0 s.pop_back();
 1330    }
 1331  0 while (!headerStack.empty() && headerStack.back() != AS_OPEN_BRACKET) {
 1332  0 StringStack s = (StringStack) tempStacks.back();
 1333  0 s.push_back(headerStack.back());
 1334  0 headerStack.pop_back();
 1335    }
 1336   
 1337  0 if (parenDepth == 0 && ch == ';')
 1338  0 isInStatement=false;
 1339   
 1340  0 isInClassHeader = false;
 1341   
 1342  0 continue;
 1343    }
 1344   
 1345    // check for preBlockStatements ONLY if not within parenthesies
 1346    // (otherwise 'struct XXX' statements would be wrongly
 1347    // interpreted...)
 1348  0 if (prevCh == ' ' && !isInTemplate && parenDepth == 0) {
 1349  0 String newHeader = findHeader(line, i, preBlockStatements);
 1350  0 if (newHeader != null) {
 1351  0 isInClassHeader = true;
 1352  0 outBuffer.append(newHeader.substring(1));
 1353  0 i += newHeader.length() - 1;
 1354    //if (isCStyle)
 1355  0 headerStack.push_back(newHeader);
 1356    }
 1357    }
 1358   
 1359    // Handle operators
 1360   
 1361    // PRECHECK if a '==' or '--' or '++' operator was reached.
 1362    // If not, then register an indent IF an assignment operator was
 1363    // reached. The precheck is important, so that statements such
 1364    // as 'i--==2' are not recognized to have assignment operators
 1365    // (here, '-=') in them . . .
 1366   
 1367  0 String foundAssignmentOp = null;
 1368  0 String foundNonAssignmentOp = null;
 1369  0 immediatelyPreviousAssignmentOp = null;
 1370   
 1371    // Check if an operator has been reached.
 1372  0 foundAssignmentOp = findHeader(line, i, assignmentOperators, false);
 1373  0 foundNonAssignmentOp = findHeader(line, i, nonAssignmentOperators, false);
 1374   
 1375    // Since findHeader's boundary checking was not used above, it is possible
 1376    // that both an assignment-op and a non-assignment-op where found,
 1377    // e.g. '>>' and '>>='. If this is the case, treat the LONGER one as the
 1378    // found operator.
 1379  0 if (foundAssignmentOp != null && foundNonAssignmentOp != null)
 1380  0 if (foundAssignmentOp.length() < foundNonAssignmentOp.length())
 1381  0 foundAssignmentOp = null;
 1382    else
 1383  0 foundNonAssignmentOp = null;
 1384   
 1385  0 if (foundNonAssignmentOp != null) {
 1386  0 if (foundNonAssignmentOp.length() > 1) {
 1387  0 outBuffer.append(foundNonAssignmentOp.substring(1));
 1388  0 i += foundNonAssignmentOp.length() - 1;
 1389    }
 1390    }
 1391  0 else if (foundAssignmentOp != null) {
 1392  0 if (foundAssignmentOp.length() > 1) {
 1393  0 outBuffer.append(foundAssignmentOp.substring(1));
 1394  0 i += foundAssignmentOp.length() - 1;
 1395    }
 1396  0 if (!isInOperator && !isInTemplate) {
 1397  0 registerInStatementIndent(line, i, spaceTabCount, 0, false);
 1398  0 immediatelyPreviousAssignmentOp = foundAssignmentOp;
 1399  0 isInStatement = true;
 1400    }
 1401    }
 1402   
 1403    /*
 1404    immediatelyPreviousAssignmentOp = null;
 1405    boolean isNonAssingmentOperator = false;
 1406    for (int n = 0; n < nonAssignmentOperators.size(); n++) {
 1407    String op = nonAssignmentOperators.at(n);
 1408    if (line.regionMatches(i, op, 0, op.length())) {
 1409    if (op.length() > 1) {
 1410    outBuffer.append(op.substring(1));
 1411    i += op.length() - 1;
 1412    }
 1413    isNonAssingmentOperator = true;
 1414    break;
 1415    }
 1416    }
 1417   
 1418    if (!isNonAssingmentOperator) {
 1419    for (int a = 0; a < assignmentOperators.size(); a++) {
 1420    String op = assignmentOperators.at(a);
 1421    if (line.regionMatches(i, op, 0, op.length())) {
 1422    if (op.length() > 1) {
 1423    outBuffer.append(op.substring(1));
 1424    i += op.length() - 1;
 1425    }
 1426    if (!isInOperator && !isInTemplate) {
 1427    registerInStatementIndent(line, i, spaceTabCount, 0, false);
 1428    immediatelyPreviousAssignmentOp = op;
 1429    isInStatement = true;
 1430    }
 1431    break;
 1432    }
 1433    }
 1434    }
 1435    */
 1436   
 1437  0 if (isInOperator)
 1438  0 isInOperator = false;
 1439    } // for
 1440   
 1441    // handle special cases of unindentation:
 1442   
 1443    // if '{' doesn't follow an immediately previous '{' in the
 1444    // headerStack (but rather another header such as "for" or "if"),
 1445    // then unindent it by one indentation relative to its block.
 1446   
 1447    // System.err.println("\n" + lineOpeningBlocksNum + " " +
 1448    // lineClosingBlocksNum + " " + previousLastLineHeader);
 1449   
 1450    // indent #define lines with one less tab:
 1451    //if (isInDefine)
 1452    // tabCount -= defineTabCount - 1;
 1453   
 1454  0 if (!blockIndent && outBuffer.length() > 0
 1455    && outBuffer.charAt(0) == '{'
 1456    && !(lineOpeningBlocksNum > 0 && lineOpeningBlocksNum == lineClosingBlocksNum)
 1457    && !(headerStack.size() > 1 && headerStack.at(headerStack.size() - 2) == AS_OPEN_BRACKET)
 1458    && shouldIndentBrackettedLine)
 1459  0 --tabCount;
 1460  0 else if (outBuffer.length() > 0 && outBuffer.charAt(0) == '}' && shouldIndentBrackettedLine)
 1461  0 --tabCount;
 1462    // correctly indent one-line-blocks...
 1463  0 else if (outBuffer.length() > 0
 1464    && lineOpeningBlocksNum > 0
 1465    && lineOpeningBlocksNum == lineClosingBlocksNum
 1466    && previousLastLineHeader != null
 1467    && previousLastLineHeader != AS_OPEN_BRACKET)
 1468  0 tabCount -= 1; //lineOpeningBlocksNum - (blockIndent ? 1 : 0);
 1469   
 1470  0 if (tabCount < 0)
 1471  0 tabCount = 0;
 1472   
 1473    // take care of extra bracket indentation option...
 1474  0 if (bracketIndent && outBuffer.length() > 0 && shouldIndentBrackettedLine)
 1475  0 if (outBuffer.charAt(0) == '{' || outBuffer.charAt(0) == '}')
 1476  0 tabCount++;
 1477   
 1478  0 if (isInDefine) {
 1479  0 if (outBuffer.charAt(0) == '#') {
 1480  0 String preproc = outBuffer.toString().substring(1).trim();
 1481  0 if (preproc.equals("define")) {
 1482  0 if (!inStatementIndentStack.empty()
 1483    && inStatementIndentStack.back() > 0)
 1484    {
 1485  0 defineTabCount = tabCount;
 1486    } else {
 1487  0 defineTabCount = tabCount - 1;
 1488  0 tabCount--;
 1489    }
 1490    }
 1491    }
 1492  0 tabCount -= defineTabCount;
 1493    }
 1494   
 1495  0 if (tabCount < 0)
 1496  0 tabCount = 0;
 1497   
 1498    // finally, insert indentations into beginning of line
 1499   
 1500  0 prevFinalLineSpaceTabCount = spaceTabCount;
 1501  0 prevFinalLineTabCount = tabCount;
 1502   
 1503  0 if (shouldForceTabIndentation) {
 1504  0 tabCount += spaceTabCount / indentLength;
 1505  0 spaceTabCount = spaceTabCount % indentLength;
 1506    }
 1507   
 1508  0 String ret = preLineWS(spaceTabCount, tabCount) + outBuffer.toString();
 1509   
 1510  0 if (lastLineHeader != null) {
 1511  0 previousLastLineHeader = lastLineHeader;
 1512    }
 1513   
 1514  0 return ret;
 1515    }
 1516   
 1517   
 1518    /**
 1519    * get distance to the next non-white space, non-comment character in
 1520    * the line. If no such character exists, return the length remaining to
 1521    * the end of the line.
 1522    */
 1523  0 protected int getNextProgramCharDistance(String line, int i) {
 1524  0 boolean inComment = false;
 1525  0 int remainingCharNum = line.length() - i;
 1526  0 int charDistance = 1;
 1527  0 char ch;
 1528   
 1529  0 for (charDistance = 1; charDistance < remainingCharNum; charDistance++) {
 1530  0 ch = line.charAt(i + charDistance);
 1531  0 if (inComment) {
 1532  0 if (line.regionMatches(i + charDistance, AS_CLOSE_COMMENT, 0, 2)) {
 1533  0 charDistance++;
 1534  0 inComment = false;
 1535    }
 1536  0 continue;
 1537    }
 1538  0 else if (isWhiteSpace(ch)) {
 1539  0 continue;
 1540    }
 1541  0 else if (ch == '/') {
 1542  0 if (line.regionMatches(i + charDistance, AS_OPEN_LINE_COMMENT, 0, 2))
 1543  0 return remainingCharNum;
 1544  0 else if (line.regionMatches(i + charDistance, AS_OPEN_COMMENT, 0, 2)) {
 1545  0 charDistance++;
 1546  0 inComment = true;
 1547    }
 1548    }
 1549    else
 1550  0 return charDistance;
 1551    } // for
 1552   
 1553  0 return charDistance;
 1554    }
 1555   
 1556   
 1557    /**
 1558    * check if a specific character can be used in a legal
 1559    * variable/method/class name
 1560    * @param ch the character to be checked.
 1561    * @return legality of the char.
 1562    */
 1563  0 protected boolean isLegalNameChar(char ch) {
 1564  0 return
 1565    Character.isLetterOrDigit(ch)
 1566    //(ch>='a' && ch<='z') || (ch>='A' && ch<='Z') || (ch>='0' && ch<='9') ||
 1567    || ch=='.'
 1568    || ch=='_'
 1569    || (!isCStyle && ch=='$')
 1570    || (isCStyle && ch=='~');
 1571    }
 1572   
 1573   
 1574    /**
 1575    * check if a specific character is white space.
 1576    */
 1577  0 protected boolean isWhiteSpace(char ch) {
 1578  0 return Character.isWhitespace(ch);
 1579    //return ch == ' ' || ch == '\t';
 1580    }
 1581   
 1582   
 1583    /**
 1584    * check if a specific line position contains a header, out of several
 1585    * possible headers.
 1586    * @param possibleHeaders a vector with header strings.
 1587    * @return a pointer to the found header, or null if no header was found.
 1588    */
 1589  0 protected String findHeader(String line, int i, Vector possibleHeaders) {
 1590  0 return findHeader(line, i, possibleHeaders, true);
 1591    }
 1592   
 1593   
 1594    /**
 1595    * check if a specific line position contains a header, out of several
 1596    * possible headers.
 1597    * @param possibleHeaders a vector with header strings.
 1598    * @return a pointer to the found header, or null if no header was found.
 1599    */
 1600  0 protected String findHeader(String line, int i,
 1601    Vector possibleHeaders,
 1602    boolean checkBoundry)
 1603    {
 1604  0 int maxHeaders = possibleHeaders.size();
 1605  0 String header = null;
 1606  0 int p;
 1607   
 1608  0 for (p = 0; p < maxHeaders; p++) {
 1609  0 header = (String) possibleHeaders.elementAt(p);
 1610   
 1611  0 if (line.regionMatches(i, header, 0, header.length())) {
 1612    // check that this is a header and not a part of a longer word
 1613    // (e.g. not at its begining, not at its middle...)
 1614  0 int lineLength = line.length();
 1615  0 int headerEnd = i + header.length();
 1616  0 char startCh = header.charAt(0); // first char of header
 1617  0 char endCh = '\0'; // char just after header
 1618  0 char prevCh = '\0'; // char just before header
 1619   
 1620  0 if (headerEnd < lineLength)
 1621  0 endCh = line.charAt(headerEnd);
 1622   
 1623  0 if (i > 0)
 1624  0 prevCh = line.charAt(i - 1);
 1625   
 1626  0 if (!checkBoundry)
 1627  0 return header;
 1628  0 else if (prevCh != 0
 1629    && isLegalNameChar(startCh)
 1630    && isLegalNameChar(prevCh))
 1631  0 return null;
 1632  0 else if (headerEnd >= lineLength
 1633    || !isLegalNameChar(startCh)
 1634    || !isLegalNameChar(endCh))
 1635  0 return header;
 1636    else
 1637  0 return null;
 1638    }
 1639    }
 1640  0 return null;
 1641    }
 1642   
 1643   
 1644    /**
 1645    * register an in-statement indent.
 1646    */
 1647  0 private void registerInStatementIndent(String line,
 1648    int i,
 1649    int spaceTabCount,
 1650    int minIndent,
 1651    boolean updateParenStack) {
 1652  0 int inStatementIndent;
 1653  0 int remainingCharNum = line.length() - i;
 1654  0 int nextNonWSChar = 1;
 1655   
 1656  0 nextNonWSChar = getNextProgramCharDistance(line, i);
 1657   
 1658    // if indent is around the last char in the line, indent instead
 1659    // 2 spaces from the previous indent
 1660  0 if (nextNonWSChar == remainingCharNum) {
 1661  0 int previousIndent = spaceTabCount;
 1662  0 if (!inStatementIndentStack.empty())
 1663  0 previousIndent = inStatementIndentStack.back();
 1664   
 1665  0 inStatementIndentStack.push_back(/*2*/ indentLength + previousIndent);
 1666  0 if (updateParenStack)
 1667  0 parenIndentStack.push_back(previousIndent);
 1668  0 return;
 1669    }
 1670   
 1671  0 if (updateParenStack)
 1672  0 parenIndentStack.push_back(i + spaceTabCount);
 1673   
 1674  0 inStatementIndent = i + nextNonWSChar + spaceTabCount;
 1675   
 1676  0 if (i + nextNonWSChar < minIndent)
 1677  0 inStatementIndent = minIndent + spaceTabCount;
 1678   
 1679  0 if (i + nextNonWSChar > maxInStatementIndent)
 1680  0 inStatementIndent = indentLength * 2 + spaceTabCount;
 1681   
 1682  0 if (!inStatementIndentStack.empty()
 1683    && inStatementIndent < inStatementIndentStack.back())
 1684  0 inStatementIndent = inStatementIndentStack.back();
 1685   
 1686  0 inStatementIndentStack.push_back(inStatementIndent);
 1687    }
 1688   
 1689   
 1690  0 private String preLineWS(int spaceTabCount, int tabCount) {
 1691  0 StringBuffer ws = new StringBuffer();
 1692   
 1693  0 for (int i = 0; i < tabCount; i++)
 1694  0 ws.append(indentString);
 1695   
 1696  0 while ((spaceTabCount--) > 0)
 1697  0 ws.append(' ');
 1698   
 1699  0 return ws.toString();
 1700    }
 1701   
 1702   
 1703    /**
 1704    * initialize the static vars
 1705    */
 1706  0 private void initStatic() {
 1707  0 if (calledInitStatic)
 1708  0 return;
 1709   
 1710  0 calledInitStatic = true;
 1711   
 1712  0 headers.push_back(AS_IF);
 1713  0 headers.push_back(AS_ELSE);
 1714  0 headers.push_back(AS_FOR);
 1715  0 headers.push_back(AS_WHILE);
 1716  0 headers.push_back(AS_DO);
 1717  0 headers.push_back(AS_TRY);
 1718  0 headers.push_back(AS_CATCH);
 1719  0 headers.push_back(AS_FINALLY);
 1720  0 headers.push_back(AS_SYNCHRONIZED);
 1721  0 headers.push_back(AS_SWITCH);
 1722  0 headers.push_back(AS_CASE);
 1723  0 headers.push_back(AS_DEFAULT);
 1724    //headers.push_back(AS_PUBLIC);
 1725    //headers.push_back(AS_PRIVATE);
 1726    //headers.push_back(AS_PROTECTED);
 1727    //headers.push_back(AS_OPERATOR);
 1728  0 headers.push_back(AS_TEMPLATE);
 1729  0 headers.push_back(AS_CONST);
 1730  0 headers.push_back(AS_STATIC);
 1731  0 headers.push_back(AS_EXTERN);
 1732   
 1733  0 nonParenHeaders.push_back(AS_ELSE);
 1734  0 nonParenHeaders.push_back(AS_DO);
 1735  0 nonParenHeaders.push_back(AS_TRY);
 1736  0 nonParenHeaders.push_back(AS_FINALLY);
 1737  0 nonParenHeaders.push_back(AS_STATIC);
 1738  0 nonParenHeaders.push_back(AS_CONST);
 1739  0 nonParenHeaders.push_back(AS_EXTERN);
 1740  0 nonParenHeaders.push_back(AS_CASE);
 1741  0 nonParenHeaders.push_back(AS_DEFAULT);
 1742   
 1743  0 nonParenHeaders.push_back(AS_PUBLIC);
 1744  0 nonParenHeaders.push_back(AS_PRIVATE);
 1745  0 nonParenHeaders.push_back(AS_PROTECTED);
 1746  0 nonParenHeaders.push_back(AS_TEMPLATE);
 1747  0 nonParenHeaders.push_back(AS_CONST);
 1748   
 1749  0 preBlockStatements.push_back(AS_CLASS);
 1750  0 preBlockStatements.push_back(AS_STRUCT);
 1751  0 preBlockStatements.push_back(AS_UNION);
 1752  0 preBlockStatements.push_back(AS_INTERFACE);
 1753  0 preBlockStatements.push_back(AS_NAMESPACE);
 1754  0 preBlockStatements.push_back(AS_THROWS);
 1755  0 preBlockStatements.push_back(AS_EXTERN);
 1756   
 1757  0 assignmentOperators.push_back(AS_ASSIGN);
 1758  0 assignmentOperators.push_back(AS_PLUS_ASSIGN);
 1759  0 assignmentOperators.push_back(AS_MINUS_ASSIGN);
 1760  0 assignmentOperators.push_back(AS_MULT_ASSIGN);
 1761  0 assignmentOperators.push_back(AS_DIV_ASSIGN);
 1762  0 assignmentOperators.push_back(AS_MOD_ASSIGN);
 1763  0 assignmentOperators.push_back(AS_OR_ASSIGN);
 1764  0 assignmentOperators.push_back(AS_AND_ASSIGN);
 1765  0 assignmentOperators.push_back(AS_XOR_ASSIGN);
 1766  0 assignmentOperators.push_back(AS_GR_GR_GR_ASSIGN);
 1767  0 assignmentOperators.push_back(AS_GR_GR_ASSIGN);
 1768  0 assignmentOperators.push_back(AS_LS_LS_LS_ASSIGN);
 1769  0 assignmentOperators.push_back(AS_LS_LS_ASSIGN);
 1770  0 assignmentOperators.push_back(AS_RETURN);
 1771   
 1772  0 nonAssignmentOperators.push_back(AS_EQUAL);
 1773  0 nonAssignmentOperators.push_back(AS_PLUS_PLUS);
 1774  0 nonAssignmentOperators.push_back(AS_MINUS_MINUS);
 1775  0 nonAssignmentOperators.push_back(AS_NOT_EQUAL);
 1776  0 nonAssignmentOperators.push_back(AS_GR_EQUAL);
 1777  0 nonAssignmentOperators.push_back(AS_GR_GR_GR);
 1778  0 nonAssignmentOperators.push_back(AS_GR_GR);
 1779  0 nonAssignmentOperators.push_back(AS_LS_EQUAL);
 1780  0 nonAssignmentOperators.push_back(AS_LS_LS_LS);
 1781  0 nonAssignmentOperators.push_back(AS_LS_LS);
 1782  0 nonAssignmentOperators.push_back(AS_ARROW);
 1783  0 nonAssignmentOperators.push_back(AS_AND);
 1784  0 nonAssignmentOperators.push_back(AS_OR);
 1785    }
 1786   
 1787   
 1788    // STATIC FIELDS
 1789   
 1790    private static boolean calledInitStatic = false;
 1791   
 1792    private static StringStack headers = new StringStack();
 1793    private static StringStack nonParenHeaders = new StringStack();
 1794    private static StringStack preprocessorHeaders = new StringStack();
 1795    private static StringStack preBlockStatements = new StringStack();
 1796    private static StringStack assignmentOperators = new StringStack();
 1797    private static StringStack nonAssignmentOperators = new StringStack();
 1798   
 1799   
 1800    // MEMBER FIELDS
 1801   
 1802    private ASSourceIterator sourceIterator;
 1803   
 1804    private ASBeautifierStack waitingBeautifierStack;
 1805    private ASBeautifierStack activeBeautifierStack;
 1806    private IntegerStack waitingBeautifierStackLengthStack;
 1807    private IntegerStack activeBeautifierStackLengthStack;
 1808    private StringStack headerStack;
 1809    private StackStack tempStacks;
 1810    private IntegerStack blockParenDepthStack;
 1811    private BooleanStack blockStatementStack;
 1812    private BooleanStack parenStatementStack;
 1813    private BooleanStack bracketBlockStateStack;
 1814    private IntegerStack inStatementIndentStack;
 1815    private IntegerStack inStatementIndentStackSizeStack;
 1816    private IntegerStack parenIndentStack;
 1817   
 1818    private String indentString = " ";
 1819    private String currentHeader;
 1820    private String previousLastLineHeader;
 1821    private String immediatelyPreviousAssignmentOp;
 1822    private String probationHeader;
 1823   
 1824    private boolean isInQuote;
 1825    private boolean isInComment;
 1826    private boolean isInCase;
 1827    private boolean isInQuestion;
 1828    private boolean isInStatement;
 1829    private boolean isInHeader;
 1830    private boolean isCStyle;
 1831    protected boolean isInFor; /// danson
 1832    private boolean isInOperator;
 1833    private boolean isInTemplate;
 1834    private boolean isInDefine;
 1835    private boolean isInDefineDefinition;
 1836    private boolean classIndent;
 1837    private boolean isInClassHeader;
 1838    private boolean isInClassHeaderTab;
 1839    private boolean switchIndent;
 1840    private boolean caseIndent;
 1841    private boolean namespaceIndent;
 1842    private boolean bracketIndent;
 1843    private boolean blockIndent;
 1844    private boolean labelIndent;
 1845    private boolean preprocessorIndent;
 1846    private boolean isInConditional;
 1847    private boolean isMinimalConditinalIndentSet;
 1848    private boolean shouldForceTabIndentation;
 1849   
 1850    private int indentLength = 4;
 1851    private int minConditionalIndent = 8;
 1852    private int parenDepth;
 1853    private int blockTabCount;
 1854    private int leadingWhiteSpaces;
 1855    private int maxInStatementIndent;
 1856    private int templateDepth;
 1857    private char quoteChar;
 1858    private char prevNonSpaceCh;
 1859    private char currentNonSpaceCh;
 1860    private char currentNonLegalCh;
 1861    private char prevNonLegalCh;
 1862    private int prevFinalLineSpaceTabCount;
 1863    private int prevFinalLineTabCount;
 1864    private boolean emptyLineFill;
 1865    private boolean backslashEndsPrevLine;
 1866    private int defineTabCount;
 1867   
 1868    }