Commit fb9ded85 authored by Friedemann Kleint's avatar Friedemann Kleint
Browse files

Fix Krazy warnings about values or keys iteration in Editor/C++.



Change-Id: I46ff779bae6d7bba105bc2019228ba38b95dc352
Reviewed-by: default avatarNikolai Kosjar <nikolai.kosjar@digia.com>
parent 14e35b5d
......@@ -319,11 +319,15 @@ bool SnippetsCollection::synchronize(QString *errorString)
}
Utils::FileSaver saver(m_userSnippetsPath + m_userSnippetsFile);
if (!saver.hasError()) {
typedef QHash<QString, int>::ConstIterator GroupIndexByIdConstIt;
QXmlStreamWriter writer(saver.file());
writer.setAutoFormatting(true);
writer.writeStartDocument();
writer.writeStartElement(kSnippets);
foreach (const QString &groupId, m_groupIndexById.keys()) {
const GroupIndexByIdConstIt cend = m_groupIndexById.constEnd();
for (GroupIndexByIdConstIt it = m_groupIndexById.constBegin(); it != cend; ++it ) {
const QString &groupId = it.key();
const int size = m_snippets.at(groupIndex(groupId)).size();
for (int i = 0; i < size; ++i) {
const Snippet &current = snippet(i, groupId);
......
......@@ -1064,6 +1064,9 @@ void generateLastToken(QTextStream &os, const QString &className, const QStringL
void generateAST_cpp(const Snapshot &snapshot, const QDir &cplusplusDir)
{
typedef QMap<QString, ClassSpecifierAST *> StringClassSpecifierASTMap;
typedef StringClassSpecifierASTMap::ConstIterator StringClassSpecifierASTMapConstIt;
QFileInfo fileAST_cpp(cplusplusDir, QLatin1String("AST.cpp"));
Q_ASSERT(fileAST_cpp.exists());
......@@ -1085,8 +1088,8 @@ void generateAST_cpp(const Snapshot &snapshot, const QDir &cplusplusDir)
AST_cpp_document->check();
Overview oo;
QMap<QString, ClassSpecifierAST *> classesNeedingFirstToken;
QMap<QString, ClassSpecifierAST *> classesNeedingLastToken;
StringClassSpecifierASTMap classesNeedingFirstToken;
StringClassSpecifierASTMap classesNeedingLastToken;
// find all classes with method declarations for firstToken/lastToken
foreach (ClassSpecifierAST *classAST, astNodes.deriveds) {
......@@ -1206,8 +1209,10 @@ void generateAST_cpp(const Snapshot &snapshot, const QDir &cplusplusDir)
QString newMethods;
QTextStream os(&newMethods);
foreach (const QString &className, classesNeedingFirstToken.keys()) {
const QStringList fields = collectFieldNames(classesNeedingFirstToken.value(className), true);
const StringClassSpecifierASTMapConstIt cfend = classesNeedingFirstToken.constEnd();
for (StringClassSpecifierASTMapConstIt it = classesNeedingFirstToken.constBegin(); it != cfend; ++it) {
const QString &className = it.key();
const QStringList fields = collectFieldNames(it.value(), true);
os << "/** \\generated */" << endl;
generateFirstToken(os, className, fields);
if (ClassSpecifierAST *classAST = classesNeedingLastToken.value(className, 0)) {
......@@ -1217,10 +1222,10 @@ void generateAST_cpp(const Snapshot &snapshot, const QDir &cplusplusDir)
classesNeedingLastToken.remove(className);
}
}
foreach (const QString &className, classesNeedingLastToken.keys()) {
const QStringList fields = collectFieldNames(classesNeedingLastToken.value(className), true);
const StringClassSpecifierASTMapConstIt clend = classesNeedingLastToken.constEnd();
for (StringClassSpecifierASTMapConstIt it = classesNeedingLastToken.constBegin(); it != clend; ++it) {
os << "/** \\generated */" << endl;
generateLastToken(os, className, fields);
generateLastToken(os, it.key(), collectFieldNames(it.value(), true));
}
tc.setPosition(documentEnd);
tc.insertText(newMethods);
......
Supports Markdown
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