MCPcopy Index your code
hub / github.com/processing/processing / AutoFormat

Class AutoFormat

java/src/processing/mode/java/AutoFormat.java:47–860  ·  view source on GitHub ↗

Handler for dealing with auto format. Contributed by Martin Gomez, additional bug fixes by Ben Fry. Additional fixes by Jonathan Feinberg in March 2010. After some further digging, this code in fact appears to be a modified version of Jason Pell's GPLed "Java Beautifier" class found <a href="ht

Source from the content-addressed store, hash-verified

45 * [Ben Fry, August 2009]
46 */
47public class AutoFormat implements Formatter {
48 private char[] chars;
49 private final StringBuilder buf = new StringBuilder();
50 private final StringBuilder result = new StringBuilder();
51
52 /** The number of spaces in one indent. Constant. */
53 private int indentValue;
54
55 /** Set when the end of the chars array is reached. */
56 private boolean EOF;
57
58 private boolean inStatementFlag; // in a line of code
59 private boolean overflowFlag; // line overrunning?
60 private boolean startFlag; // No buf has yet been writen to this line.
61 private boolean if_flg;
62 private boolean elseFlag;
63
64 /** -1 if not in array or if just after it, otherwise increases from 0. */
65 private int arrayLevel;
66 private int arrayIndent; // Lowest value of the above for this line.
67
68 /** Number of ? entered without exiting at : of a?b:c structures. */
69 private int conditionalLevel;
70
71 private int[][] sp_flg;
72 private boolean[][] s_ind;
73 private int if_lev;
74
75 /** chars[pos] is where we're at. */
76 private int pos;
77 private int level;
78
79 /** Number of curly brackets entered and not exited,
80 excluding arrays. */
81 private int curlyLvl;
82
83 /** Number of parentheses entered and not exited. */
84 private int parenLevel;
85
86 private boolean[] ind;
87 private int[] p_flg;
88 private int[][] s_tabs;
89
90 /** At every {, this has a true pushed if it's a do-while,
91 and a false otherwise. It is then popped at }. */
92 private Stack<Boolean> doWhileFlags;
93
94 /** At every (, this has a true pushed for if, while, or for,
95 and a false otherwise. Popped at ). */
96 private Stack<Boolean> ifWhileForFlags;
97
98 private boolean jdoc_flag;
99
100 /** The number of times to indent at a given point */
101 private int tabs;
102
103 /** The last non-space seen by nextChar(). */
104 private char lastNonWhitespace = 0;

Callers

nothing calls this directly

Calls

no outgoing calls

Tested by

no test coverage detected