MCPcopy Create free account
hub / github.com/KDE/kdevelop / indentLine

Method indentLine

plugins/astyle/3rdparty/libastyle/ASEnhancer.cpp:256–286  ·  view source on GitHub ↗

* indent a line by a given number of tabsets * by inserting leading whitespace to the line argument. * * @param line a reference to the line to indent. * @param indent the number of tabsets to insert. * @return the number of characters inserted. */

Source from the content-addressed store, hash-verified

254 * @return the number of characters inserted.
255 */
256int ASEnhancer::indentLine(string& line, int indent) const
257{
258 if (line.length() == 0
259 && !emptyLineFill)
260 return 0;
261
262 size_t charsToInsert = 0;
263
264 if (forceTab && indentLength != tabLength)
265 {
266 // replace tab indents with spaces
267 convertForceTabIndentToSpaces(line);
268 // insert the space indents
269 charsToInsert = indent * indentLength;
270 line.insert(line.begin(), charsToInsert, ' ');
271 // replace leading spaces with tab indents
272 convertSpaceIndentToForceTab(line);
273 }
274 else if (useTabs)
275 {
276 charsToInsert = indent;
277 line.insert(line.begin(), charsToInsert, '\t');
278 }
279 else // spaces
280 {
281 charsToInsert = indent * indentLength;
282 line.insert(line.begin(), charsToInsert, ' ');
283 }
284
285 return charsToInsert;
286}
287
288/**
289 * check for SQL "BEGIN DECLARE SECTION".

Callers

nothing calls this directly

Calls 3

lengthMethod · 0.45
insertMethod · 0.45
beginMethod · 0.45

Tested by

no test coverage detected