<table><tr><td style="">kossebau added a comment.
</td><a style="text-decoration: none; padding: 4px 8px; margin: 0 8px 8px; float: right; color: #464C5C; font-weight: bold; border-radius: 3px; background-color: #F7F7F9; background-image: linear-gradient(to bottom,#fff,#f1f0f1); display: inline-block; border: 1px solid rgba(71,87,120,.2);" href="https://phabricator.kde.org/D6013" rel="noreferrer">View Revision</a></tr></table><br /><div><div><p>Generated code example:</p>
<div class="remarkup-code-block" style="margin: 12px 0;" data-code-lang="text" data-sigil="remarkup-code-block"><pre class="remarkup-code" style="font: 11px/15px "Menlo", "Consolas", "Monaco", monospace; padding: 12px; margin: 0; background: rgba(71, 87, 120, 0.08);">void printToken(const AstNode *node, const QString &mType, const QString &mName = QString())
{
KDevPG::TokenStream::Token startToken;
KDevPG::TokenStream::Token endToken;
qint64 line, column;
const bool isValidStartToken = (0 <= node->startToken && node->startToken < m_str->size());
QString startTokenString;
if (isValidStartToken)
{
startToken = m_str->at(node->startToken);
m_str->startPosition(node->startToken, &line, &column);
startTokenString = QString::number(startToken.begin) + QLatin1String(", ") + QString::number(line) + QLatin1String(", ") + QString::number(column);
}
else
{
startTokenString = QLatin1String("invalid token index: ") + QString::number(node->startToken);
}
const bool isValidEndToken = (0 <= node->endToken && node->endToken < m_str->size());
QString endTokenString;
if (isValidEndToken)
{
endToken = m_str->at(node->endToken);
m_str->startPosition(node->endToken, &line, &column);
endTokenString = QString::number(endToken.begin) + QLatin1String(", ") + QString::number(line) + QLatin1String(", ") + QString::number(column);
}
else
{
endTokenString = QLatin1String("invalid token index: ") + QString::number(node->endToken);
}
QString tokenString;
if (!m_content.isEmpty() && isValidStartToken && isValidEndToken)
{
const int begin = startToken.begin;
const int end = endToken.end;
if (end-begin > 30)
{
tokenString = m_content.mid(begin, 10);
tokenString += QStringLiteral(" ...");
tokenString += QStringLiteral("%1 more").arg(end-begin-20);
tokenString += QStringLiteral("... ");
tokenString += m_content.midRef(end-10, 10);
}
else
{
tokenString = m_content.mid(begin, end-begin+1);
}
tokenString.replace('\n', QStringLiteral("\\n"));
tokenString.replace('\r', QStringLiteral("\\r"));
}
qDebug() << QString(QString().fill(QLatin1Char(' '), m_indent) + mName + QLatin1String(!mName.isEmpty() ? "->" : "") + mType + QLatin1Char('[') + startTokenString + QLatin1String("] --- [") + endTokenString + QLatin1String("] ")).toUtf8().constData() << tokenString;
}</pre></div></div></div><br /><div><strong>REPOSITORY</strong><div><div>R51 KDevelop: PG Qt</div></div></div><br /><div><strong>REVISION DETAIL</strong><div><a href="https://phabricator.kde.org/D6013" rel="noreferrer">https://phabricator.kde.org/D6013</a></div></div><br /><div><strong>To: </strong>kossebau, KDevelop<br /><strong>Cc: </strong>kdevelop-devel<br /></div>