MCPcopy Create free account
hub / github.com/apache/freemarker / postParseCleanup

Method postParseCleanup

src/main/java/freemarker/core/TextBlock.java:115–142  ·  view source on GitHub ↗
(boolean stripWhitespace)

Source from the content-addressed store, hash-verified

113 }
114
115 TemplateElement postParseCleanup(boolean stripWhitespace) {
116 if (text.length == 0) return this;
117 int openingCharsToStrip = 0, trailingCharsToStrip=0;
118 boolean deliberateLeftTrim = deliberateLeftTrim();
119 boolean deliberateRightTrim = deliberateRightTrim();
120 if (!stripWhitespace || text.length == 0 ) {
121 return this;
122 }
123 if (parent.parent == null && previousSibling() == null) return this;
124 if (!deliberateLeftTrim) {
125 trailingCharsToStrip = trailingCharsToStrip();
126 }
127 if (!deliberateRightTrim) {
128 openingCharsToStrip = openingCharsToStrip();
129 }
130 if (openingCharsToStrip == 0 && trailingCharsToStrip == 0) {
131 return this;
132 }
133 this.text = substring(text, openingCharsToStrip, text.length - trailingCharsToStrip);
134 if (openingCharsToStrip > 0) {
135 this.beginLine++;
136 this.beginColumn = 1;
137 }
138 if (trailingCharsToStrip >0) {
139 this.endColumn = 0;
140 }
141 return this;
142 }
143
144 /**
145 * Scans forward the nodes on the same line to see whether there is a

Callers

nothing calls this directly

Calls 6

deliberateLeftTrimMethod · 0.95
deliberateRightTrimMethod · 0.95
trailingCharsToStripMethod · 0.95
openingCharsToStripMethod · 0.95
substringMethod · 0.95
previousSiblingMethod · 0.80

Tested by

no test coverage detected