forked from qt-creator/qt-creator
Fix Krazy warnings about values or keys iteration in Editor/C++.
Change-Id: I46ff779bae6d7bba105bc2019228ba38b95dc352 Reviewed-by: Nikolai Kosjar <nikolai.kosjar@digia.com>
This commit is contained in:
@@ -319,11 +319,15 @@ bool SnippetsCollection::synchronize(QString *errorString)
|
|||||||
}
|
}
|
||||||
Utils::FileSaver saver(m_userSnippetsPath + m_userSnippetsFile);
|
Utils::FileSaver saver(m_userSnippetsPath + m_userSnippetsFile);
|
||||||
if (!saver.hasError()) {
|
if (!saver.hasError()) {
|
||||||
|
typedef QHash<QString, int>::ConstIterator GroupIndexByIdConstIt;
|
||||||
|
|
||||||
QXmlStreamWriter writer(saver.file());
|
QXmlStreamWriter writer(saver.file());
|
||||||
writer.setAutoFormatting(true);
|
writer.setAutoFormatting(true);
|
||||||
writer.writeStartDocument();
|
writer.writeStartDocument();
|
||||||
writer.writeStartElement(kSnippets);
|
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();
|
const int size = m_snippets.at(groupIndex(groupId)).size();
|
||||||
for (int i = 0; i < size; ++i) {
|
for (int i = 0; i < size; ++i) {
|
||||||
const Snippet ¤t = snippet(i, groupId);
|
const Snippet ¤t = 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)
|
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"));
|
QFileInfo fileAST_cpp(cplusplusDir, QLatin1String("AST.cpp"));
|
||||||
Q_ASSERT(fileAST_cpp.exists());
|
Q_ASSERT(fileAST_cpp.exists());
|
||||||
|
|
||||||
@@ -1085,8 +1088,8 @@ void generateAST_cpp(const Snapshot &snapshot, const QDir &cplusplusDir)
|
|||||||
AST_cpp_document->check();
|
AST_cpp_document->check();
|
||||||
|
|
||||||
Overview oo;
|
Overview oo;
|
||||||
QMap<QString, ClassSpecifierAST *> classesNeedingFirstToken;
|
StringClassSpecifierASTMap classesNeedingFirstToken;
|
||||||
QMap<QString, ClassSpecifierAST *> classesNeedingLastToken;
|
StringClassSpecifierASTMap classesNeedingLastToken;
|
||||||
|
|
||||||
// find all classes with method declarations for firstToken/lastToken
|
// find all classes with method declarations for firstToken/lastToken
|
||||||
foreach (ClassSpecifierAST *classAST, astNodes.deriveds) {
|
foreach (ClassSpecifierAST *classAST, astNodes.deriveds) {
|
||||||
@@ -1206,8 +1209,10 @@ void generateAST_cpp(const Snapshot &snapshot, const QDir &cplusplusDir)
|
|||||||
|
|
||||||
QString newMethods;
|
QString newMethods;
|
||||||
QTextStream os(&newMethods);
|
QTextStream os(&newMethods);
|
||||||
foreach (const QString &className, classesNeedingFirstToken.keys()) {
|
const StringClassSpecifierASTMapConstIt cfend = classesNeedingFirstToken.constEnd();
|
||||||
const QStringList fields = collectFieldNames(classesNeedingFirstToken.value(className), true);
|
for (StringClassSpecifierASTMapConstIt it = classesNeedingFirstToken.constBegin(); it != cfend; ++it) {
|
||||||
|
const QString &className = it.key();
|
||||||
|
const QStringList fields = collectFieldNames(it.value(), true);
|
||||||
os << "/** \\generated */" << endl;
|
os << "/** \\generated */" << endl;
|
||||||
generateFirstToken(os, className, fields);
|
generateFirstToken(os, className, fields);
|
||||||
if (ClassSpecifierAST *classAST = classesNeedingLastToken.value(className, 0)) {
|
if (ClassSpecifierAST *classAST = classesNeedingLastToken.value(className, 0)) {
|
||||||
@@ -1217,10 +1222,10 @@ void generateAST_cpp(const Snapshot &snapshot, const QDir &cplusplusDir)
|
|||||||
classesNeedingLastToken.remove(className);
|
classesNeedingLastToken.remove(className);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
foreach (const QString &className, classesNeedingLastToken.keys()) {
|
const StringClassSpecifierASTMapConstIt clend = classesNeedingLastToken.constEnd();
|
||||||
const QStringList fields = collectFieldNames(classesNeedingLastToken.value(className), true);
|
for (StringClassSpecifierASTMapConstIt it = classesNeedingLastToken.constBegin(); it != clend; ++it) {
|
||||||
os << "/** \\generated */" << endl;
|
os << "/** \\generated */" << endl;
|
||||||
generateLastToken(os, className, fields);
|
generateLastToken(os, it.key(), collectFieldNames(it.value(), true));
|
||||||
}
|
}
|
||||||
tc.setPosition(documentEnd);
|
tc.setPosition(documentEnd);
|
||||||
tc.insertText(newMethods);
|
tc.insertText(newMethods);
|
||||||
|
|||||||
Reference in New Issue
Block a user