Commit b0eab0b7 authored by Erik Verbruggen's avatar Erik Verbruggen

Todo: replace QString::split and trimming by tracking line endings.

Change-Id: Ic9b9ee2075502ea2d9f14b848cb465af948bd166
Reviewed-by: default avatarNikolai Kosjar <nikolai.kosjar@digia.com>
parent ee2023ef
......@@ -84,14 +84,27 @@ void CppTodoItemsScanner::processDocument(CPlusPlus::Document::Ptr doc)
}
// Process every line of the comment
// TODO: Do not create QStringList, just iterate through a string tracking line endings.
const QStringList commentLines =
QString::fromUtf8(source).split(QLatin1Char('\n'), QString::SkipEmptyParts);
unsigned lineNumber = 0;
translationUnit->getPosition(token.utf16charsBegin(), &lineNumber);
for (int j = 0; j < commentLines.count(); ++j) {
const QString &commentLine = commentLines.at(j);
processCommentLine(doc->fileName(), commentLine, lineNumber + j, itemList);
for (int from = 0, sz = source.size(); from < sz; ++lineNumber) {
int to = source.indexOf('\n', from);
if (to == -1)
to = sz - 1;
const char *start = source.constData() + from;
const char *end = source.constData() + to;
while (start != end && std::isspace(*start))
++start;
while (start != end && std::isspace(*end))
--end;
const int length = end - start + 1;
if (length > 0) {
QString commentLine = QString::fromUtf8(start, length);
processCommentLine(doc->fileName(), commentLine, lineNumber, itemList);
}
from = to + 1;
}
}
emit itemsFetched(doc->fileName(), itemList);
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment