forked from qt-creator/qt-creator
CppEditor: Remove foreach / Q_FOREACH usage
Task-number: QTCREATORBUG-27464 Change-Id: I9915cf2c07bdcc570efc20601752d60f2ec82f34 Reviewed-by: David Schulz <david.schulz@qt.io>
This commit is contained in:
@@ -77,7 +77,7 @@ public:
|
|||||||
QMimeData *mimeData(const QModelIndexList &indexes) const override
|
QMimeData *mimeData(const QModelIndexList &indexes) const override
|
||||||
{
|
{
|
||||||
auto mimeData = new Utils::DropMimeData;
|
auto mimeData = new Utils::DropMimeData;
|
||||||
foreach (const QModelIndex &index, indexes) {
|
for (const QModelIndex &index : indexes) {
|
||||||
const QVariant fileName = data(index, FileNameRole);
|
const QVariant fileName = data(index, FileNameRole);
|
||||||
if (!fileName.canConvert<QString>())
|
if (!fileName.canConvert<QString>())
|
||||||
continue;
|
continue;
|
||||||
|
|||||||
@@ -209,7 +209,7 @@ private:
|
|||||||
const SemanticUses &uses = it.value();
|
const SemanticUses &uses = it.value();
|
||||||
|
|
||||||
bool good = false;
|
bool good = false;
|
||||||
foreach (const SemanticInfo::Use &use, uses) {
|
for (const SemanticInfo::Use &use : uses) {
|
||||||
if (m_line == use.line && m_column >= use.column
|
if (m_line == use.line && m_column >= use.column
|
||||||
&& m_column <= static_cast<int>(use.column + use.length)) {
|
&& m_column <= static_cast<int>(use.column + use.length)) {
|
||||||
good = true;
|
good = true;
|
||||||
@@ -296,7 +296,8 @@ bool handleMacroCase(const Document::Ptr document,
|
|||||||
ranges->append(toRange(textCursor, macro->utf16CharOffset(), length));
|
ranges->append(toRange(textCursor, macro->utf16CharOffset(), length));
|
||||||
|
|
||||||
// Other macro uses
|
// Other macro uses
|
||||||
foreach (const Document::MacroUse &use, document->macroUses()) {
|
const QList<Document::MacroUse> macroUses = document->macroUses();
|
||||||
|
for (const Document::MacroUse &use : macroUses) {
|
||||||
if (isMacroUseOf(use, *macro))
|
if (isMacroUseOf(use, *macro))
|
||||||
ranges->append(toRange(textCursor, use.utf16charsBegin(), length));
|
ranges->append(toRange(textCursor, use.utf16charsBegin(), length));
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -155,7 +155,7 @@ void BuiltinEditorDocumentParser::updateImpl(const QFutureInterface<void> &futur
|
|||||||
} else {
|
} else {
|
||||||
// Remove changed files from the snapshot
|
// Remove changed files from the snapshot
|
||||||
QSet<Utils::FilePath> toRemove;
|
QSet<Utils::FilePath> toRemove;
|
||||||
foreach (const Document::Ptr &doc, state.snapshot) {
|
for (const Document::Ptr &doc : qAsConst(state.snapshot)) {
|
||||||
const Utils::FilePath fileName = Utils::FilePath::fromString(doc->fileName());
|
const Utils::FilePath fileName = Utils::FilePath::fromString(doc->fileName());
|
||||||
if (workingCopy.contains(fileName)) {
|
if (workingCopy.contains(fileName)) {
|
||||||
if (workingCopy.get(fileName).second != doc->editorRevision())
|
if (workingCopy.get(fileName).second != doc->editorRevision())
|
||||||
@@ -169,7 +169,7 @@ void BuiltinEditorDocumentParser::updateImpl(const QFutureInterface<void> &futur
|
|||||||
|
|
||||||
if (!toRemove.isEmpty()) {
|
if (!toRemove.isEmpty()) {
|
||||||
invalidateSnapshot = true;
|
invalidateSnapshot = true;
|
||||||
foreach (const Utils::FilePath &fileName, toRemove)
|
for (const Utils::FilePath &fileName : qAsConst(toRemove))
|
||||||
state.snapshot.remove(fileName);
|
state.snapshot.remove(fileName);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@@ -215,7 +215,7 @@ void BuiltinEditorDocumentParser::updateImpl(const QFutureInterface<void> &futur
|
|||||||
sourceProcessor.setLanguageFeatures(features);
|
sourceProcessor.setLanguageFeatures(features);
|
||||||
sourceProcessor.run(configurationFileName);
|
sourceProcessor.run(configurationFileName);
|
||||||
if (baseConfig.usePrecompiledHeaders) {
|
if (baseConfig.usePrecompiledHeaders) {
|
||||||
foreach (const QString &precompiledHeader, state.precompiledHeaders)
|
for (const QString &precompiledHeader : qAsConst(state.precompiledHeaders))
|
||||||
sourceProcessor.run(precompiledHeader);
|
sourceProcessor.run(precompiledHeader);
|
||||||
}
|
}
|
||||||
if (!baseState.editorDefines.isEmpty())
|
if (!baseState.editorDefines.isEmpty())
|
||||||
|
|||||||
@@ -62,7 +62,7 @@ QList<QTextEdit::ExtraSelection> toTextEditorSelections(
|
|||||||
QTextCharFormat errorFormat = fontSettings.toTextCharFormat(TextEditor::C_ERROR);
|
QTextCharFormat errorFormat = fontSettings.toTextCharFormat(TextEditor::C_ERROR);
|
||||||
|
|
||||||
QList<QTextEdit::ExtraSelection> result;
|
QList<QTextEdit::ExtraSelection> result;
|
||||||
foreach (const CPlusPlus::Document::DiagnosticMessage &m, diagnostics) {
|
for (const CPlusPlus::Document::DiagnosticMessage &m : diagnostics) {
|
||||||
QTextEdit::ExtraSelection sel;
|
QTextEdit::ExtraSelection sel;
|
||||||
if (m.isWarning())
|
if (m.isWarning())
|
||||||
sel.format = warningFormat;
|
sel.format = warningFormat;
|
||||||
@@ -108,7 +108,8 @@ CheckSymbols *createHighlighter(const CPlusPlus::Document::Ptr &doc,
|
|||||||
using Utils::Text::convertPosition;
|
using Utils::Text::convertPosition;
|
||||||
|
|
||||||
// Get macro definitions
|
// Get macro definitions
|
||||||
foreach (const CPlusPlus::Macro& macro, doc->definedMacros()) {
|
const QList<CPlusPlus::Macro> definedMacros = doc->definedMacros();
|
||||||
|
for (const CPlusPlus::Macro ¯o : definedMacros) {
|
||||||
int line, column;
|
int line, column;
|
||||||
convertPosition(textDocument, macro.utf16CharOffset(), &line, &column);
|
convertPosition(textDocument, macro.utf16CharOffset(), &line, &column);
|
||||||
|
|
||||||
@@ -119,7 +120,8 @@ CheckSymbols *createHighlighter(const CPlusPlus::Document::Ptr &doc,
|
|||||||
const LanguageFeatures features = doc->languageFeatures();
|
const LanguageFeatures features = doc->languageFeatures();
|
||||||
|
|
||||||
// Get macro uses
|
// Get macro uses
|
||||||
foreach (const Document::MacroUse ¯o, doc->macroUses()) {
|
const QList<Document::MacroUse> macroUseList = doc->macroUses();
|
||||||
|
for (const Document::MacroUse ¯o : macroUseList) {
|
||||||
const QString name = macro.macro().nameToQString();
|
const QString name = macro.macro().nameToQString();
|
||||||
|
|
||||||
//Filter out QtKeywords
|
//Filter out QtKeywords
|
||||||
@@ -150,7 +152,7 @@ QList<TextEditor::BlockRange> toTextEditorBlocks(
|
|||||||
{
|
{
|
||||||
QList<TextEditor::BlockRange> result;
|
QList<TextEditor::BlockRange> result;
|
||||||
result.reserve(skippedBlocks.size());
|
result.reserve(skippedBlocks.size());
|
||||||
foreach (const CPlusPlus::Document::Block &block, skippedBlocks)
|
for (const CPlusPlus::Document::Block &block : skippedBlocks)
|
||||||
result.append(TextEditor::BlockRange(block.utf16charsBegin(), block.utf16charsEnd()));
|
result.append(TextEditor::BlockRange(block.utf16charsBegin(), block.utf16charsEnd()));
|
||||||
return result;
|
return result;
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -95,7 +95,8 @@ public:
|
|||||||
using namespace CPlusPlus;
|
using namespace CPlusPlus;
|
||||||
const QString fileName = document->fileName();
|
const QString fileName = document->fileName();
|
||||||
|
|
||||||
foreach (const Document::DiagnosticMessage &message, document->diagnosticMessages()) {
|
const QList<Document::DiagnosticMessage> messages = document->diagnosticMessages();
|
||||||
|
for (const Document::DiagnosticMessage &message : messages) {
|
||||||
++m_processedDiagnostics;
|
++m_processedDiagnostics;
|
||||||
|
|
||||||
QString type;
|
QString type;
|
||||||
@@ -125,7 +126,7 @@ private:
|
|||||||
|
|
||||||
void classifyFiles(const QSet<QString> &files, QStringList *headers, QStringList *sources)
|
void classifyFiles(const QSet<QString> &files, QStringList *headers, QStringList *sources)
|
||||||
{
|
{
|
||||||
foreach (const QString &file, files) {
|
for (const QString &file : files) {
|
||||||
if (ProjectFile::isSource(ProjectFile::classify(file)))
|
if (ProjectFile::isSource(ProjectFile::classify(file)))
|
||||||
sources->append(file);
|
sources->append(file);
|
||||||
else
|
else
|
||||||
@@ -189,7 +190,7 @@ void index(QFutureInterface<void> &indexingFuture,
|
|||||||
QStringList headers;
|
QStringList headers;
|
||||||
classifyFiles(params.sourceFiles, &headers, &sources);
|
classifyFiles(params.sourceFiles, &headers, &sources);
|
||||||
|
|
||||||
foreach (const QString &file, params.sourceFiles)
|
for (const QString &file : qAsConst(params.sourceFiles))
|
||||||
sourceProcessor->removeFromCache(file);
|
sourceProcessor->removeFromCache(file);
|
||||||
|
|
||||||
const int sourceCount = sources.size();
|
const int sourceCount = sources.size();
|
||||||
|
|||||||
@@ -97,7 +97,8 @@ protected:
|
|||||||
if (!processed->contains(doc->globalNamespace())) {
|
if (!processed->contains(doc->globalNamespace())) {
|
||||||
processed->insert(doc->globalNamespace());
|
processed->insert(doc->globalNamespace());
|
||||||
|
|
||||||
foreach (const Document::Include &i, doc->resolvedIncludes())
|
const QList<Document::Include> includes = doc->resolvedIncludes();
|
||||||
|
for (const Document::Include &i : includes)
|
||||||
process(_snapshot.document(i.resolvedFileName()), processed);
|
process(_snapshot.document(i.resolvedFileName()), processed);
|
||||||
|
|
||||||
_mainDocument = (doc == _doc); // ### improve
|
_mainDocument = (doc == _doc); // ### improve
|
||||||
@@ -752,7 +753,8 @@ bool CheckSymbols::visit(NewExpressionAST *ast)
|
|||||||
}
|
}
|
||||||
|
|
||||||
Scope *scope = enclosingScope();
|
Scope *scope = enclosingScope();
|
||||||
foreach (Symbol *s, binding->symbols()) {
|
const QList<Symbol *> symbols = binding->symbols();
|
||||||
|
for (Symbol *s : symbols) {
|
||||||
if (Class *klass = s->asClass()) {
|
if (Class *klass = s->asClass()) {
|
||||||
scope = klass;
|
scope = klass;
|
||||||
break;
|
break;
|
||||||
@@ -787,7 +789,8 @@ void CheckSymbols::checkNamespace(NameAST *name)
|
|||||||
getTokenStartPosition(name->firstToken(), &line, &column);
|
getTokenStartPosition(name->firstToken(), &line, &column);
|
||||||
|
|
||||||
if (ClassOrNamespace *b = _context.lookupType(name->name, enclosingScope())) {
|
if (ClassOrNamespace *b = _context.lookupType(name->name, enclosingScope())) {
|
||||||
foreach (Symbol *s, b->symbols()) {
|
const QList<Symbol *> symbols = b->symbols();
|
||||||
|
for (const Symbol *s : symbols) {
|
||||||
if (s->isNamespace())
|
if (s->isNamespace())
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
@@ -829,7 +832,8 @@ bool CheckSymbols::hasVirtualDestructor(ClassOrNamespace *binding) const
|
|||||||
ClassOrNamespace *b = todo.takeFirst();
|
ClassOrNamespace *b = todo.takeFirst();
|
||||||
if (b && !processed.contains(b)) {
|
if (b && !processed.contains(b)) {
|
||||||
processed.insert(b);
|
processed.insert(b);
|
||||||
foreach (Symbol *s, b->symbols()) {
|
const QList<Symbol *> symbols = b->symbols();
|
||||||
|
for (Symbol *s : symbols) {
|
||||||
if (Class *k = s->asClass()) {
|
if (Class *k = s->asClass()) {
|
||||||
if (hasVirtualDestructor(k))
|
if (hasVirtualDestructor(k))
|
||||||
return true;
|
return true;
|
||||||
@@ -1006,7 +1010,8 @@ bool CheckSymbols::visit(MemInitializerAST *ast)
|
|||||||
if (FunctionDefinitionAST *enclosingFunction = enclosingFunctionDefinition()) {
|
if (FunctionDefinitionAST *enclosingFunction = enclosingFunctionDefinition()) {
|
||||||
if (ast->name && enclosingFunction->symbol) {
|
if (ast->name && enclosingFunction->symbol) {
|
||||||
if (ClassOrNamespace *binding = _context.lookupType(enclosingFunction->symbol)) {
|
if (ClassOrNamespace *binding = _context.lookupType(enclosingFunction->symbol)) {
|
||||||
foreach (Symbol *s, binding->symbols()) {
|
const QList<Symbol *> symbols = binding->symbols();
|
||||||
|
for (Symbol *s : symbols) {
|
||||||
if (Class *klass = s->asClass()) {
|
if (Class *klass = s->asClass()) {
|
||||||
NameAST *nameAST = ast->name;
|
NameAST *nameAST = ast->name;
|
||||||
if (QualifiedNameAST *q = nameAST->asQualifiedName()) {
|
if (QualifiedNameAST *q = nameAST->asQualifiedName()) {
|
||||||
@@ -1137,8 +1142,8 @@ bool CheckSymbols::visit(FunctionDefinitionAST *ast)
|
|||||||
accept(ast->function_body);
|
accept(ast->function_body);
|
||||||
|
|
||||||
const Internal::LocalSymbols locals(_doc, ast);
|
const Internal::LocalSymbols locals(_doc, ast);
|
||||||
foreach (const QList<Result> &uses, locals.uses) {
|
for (const QList<Result> &uses : qAsConst(locals.uses)) {
|
||||||
foreach (const Result &u, uses)
|
for (const Result &u : uses)
|
||||||
addUse(u);
|
addUse(u);
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -1257,7 +1262,7 @@ bool CheckSymbols::maybeAddTypeOrStatic(const QList<LookupItem> &candidates, Nam
|
|||||||
if (tok.generated())
|
if (tok.generated())
|
||||||
return false;
|
return false;
|
||||||
|
|
||||||
foreach (const LookupItem &r, candidates) {
|
for (const LookupItem &r : candidates) {
|
||||||
Symbol *c = r.declaration();
|
Symbol *c = r.declaration();
|
||||||
if (c->isUsingDeclaration()) // skip using declarations...
|
if (c->isUsingDeclaration()) // skip using declarations...
|
||||||
continue;
|
continue;
|
||||||
@@ -1300,7 +1305,7 @@ bool CheckSymbols::maybeAddField(const QList<LookupItem> &candidates, NameAST *a
|
|||||||
if (tok.generated())
|
if (tok.generated())
|
||||||
return false;
|
return false;
|
||||||
|
|
||||||
foreach (const LookupItem &r, candidates) {
|
for (const LookupItem &r : candidates) {
|
||||||
Symbol *c = r.declaration();
|
Symbol *c = r.declaration();
|
||||||
if (!c)
|
if (!c)
|
||||||
continue;
|
continue;
|
||||||
@@ -1345,7 +1350,7 @@ bool CheckSymbols::maybeAddFunction(const QList<LookupItem> &candidates, NameAST
|
|||||||
|
|
||||||
Kind kind = functionKind == FunctionDeclaration ? SemanticHighlighter::FunctionDeclarationUse
|
Kind kind = functionKind == FunctionDeclaration ? SemanticHighlighter::FunctionDeclarationUse
|
||||||
: SemanticHighlighter::FunctionUse;
|
: SemanticHighlighter::FunctionUse;
|
||||||
foreach (const LookupItem &r, candidates) {
|
for (const LookupItem &r : candidates) {
|
||||||
Symbol *c = r.declaration();
|
Symbol *c = r.declaration();
|
||||||
|
|
||||||
// Skip current if there's no declaration or name.
|
// Skip current if there's no declaration or name.
|
||||||
|
|||||||
@@ -1112,9 +1112,9 @@ void CodeFormatter::dump() const
|
|||||||
|
|
||||||
qDebug() << "Current token index" << m_tokenIndex;
|
qDebug() << "Current token index" << m_tokenIndex;
|
||||||
qDebug() << "Current state:";
|
qDebug() << "Current state:";
|
||||||
foreach (const State &s, m_currentState) {
|
for (const State &s : qAsConst(m_currentState))
|
||||||
qDebug() << metaEnum.valueToKey(s.type) << s.savedIndentDepth << s.savedPaddingDepth;
|
qDebug() << metaEnum.valueToKey(s.type) << s.savedIndentDepth << s.savedPaddingDepth;
|
||||||
}
|
|
||||||
qDebug() << "Current indent depth:" << m_indentDepth;
|
qDebug() << "Current indent depth:" << m_indentDepth;
|
||||||
qDebug() << "Current padding depth:" << m_paddingDepth;
|
qDebug() << "Current padding depth:" << m_paddingDepth;
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -1139,8 +1139,9 @@ void ProjectPartsModel::configure(const QList<ProjectInfo::ConstPtr> &projectInf
|
|||||||
{
|
{
|
||||||
emit layoutAboutToBeChanged();
|
emit layoutAboutToBeChanged();
|
||||||
m_projectPartsList.clear();
|
m_projectPartsList.clear();
|
||||||
foreach (const ProjectInfo::ConstPtr &info, projectInfos) {
|
for (const ProjectInfo::ConstPtr &info : qAsConst(projectInfos)) {
|
||||||
foreach (const ProjectPart::ConstPtr &projectPart, info->projectParts()) {
|
const QVector<ProjectPart::ConstPtr> projectParts = info->projectParts();
|
||||||
|
for (const ProjectPart::ConstPtr &projectPart : projectParts) {
|
||||||
if (!m_projectPartsList.contains(projectPart)) {
|
if (!m_projectPartsList.contains(projectPart)) {
|
||||||
m_projectPartsList << projectPart;
|
m_projectPartsList << projectPart;
|
||||||
if (projectPart == currentEditorsProjectPart)
|
if (projectPart == currentEditorsProjectPart)
|
||||||
@@ -1160,7 +1161,7 @@ QModelIndex ProjectPartsModel::indexForCurrentEditorsProjectPart() const
|
|||||||
|
|
||||||
ProjectPart::ConstPtr ProjectPartsModel::projectPartForProjectId(const QString &projectPartId) const
|
ProjectPart::ConstPtr ProjectPartsModel::projectPartForProjectId(const QString &projectPartId) const
|
||||||
{
|
{
|
||||||
foreach (const ProjectPart::ConstPtr &part, m_projectPartsList) {
|
for (const ProjectPart::ConstPtr &part : qAsConst(m_projectPartsList)) {
|
||||||
if (part->id() == projectPartId)
|
if (part->id() == projectPartId)
|
||||||
return part;
|
return part;
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -411,7 +411,7 @@ QString Utils::partsForFile(const QString &fileName)
|
|||||||
const QList<ProjectPart::ConstPtr> parts
|
const QList<ProjectPart::ConstPtr> parts
|
||||||
= CppModelManager::instance()->projectPart(fileName);
|
= CppModelManager::instance()->projectPart(fileName);
|
||||||
QString result;
|
QString result;
|
||||||
foreach (const ProjectPart::ConstPtr &part, parts)
|
for (const ProjectPart::ConstPtr &part : parts)
|
||||||
result += part->displayName + QLatin1Char(',');
|
result += part->displayName + QLatin1Char(',');
|
||||||
if (result.endsWith(QLatin1Char(',')))
|
if (result.endsWith(QLatin1Char(',')))
|
||||||
result.chop(1);
|
result.chop(1);
|
||||||
@@ -429,7 +429,7 @@ QString Utils::unresolvedFileNameWithDelimiters(const CPlusPlus::Document::Inclu
|
|||||||
QString Utils::pathListToString(const QStringList &pathList)
|
QString Utils::pathListToString(const QStringList &pathList)
|
||||||
{
|
{
|
||||||
QStringList result;
|
QStringList result;
|
||||||
foreach (const QString &path, pathList)
|
for (const QString &path : pathList)
|
||||||
result << QDir::toNativeSeparators(path);
|
result << QDir::toNativeSeparators(path);
|
||||||
return result.join(QLatin1Char('\n'));
|
return result.join(QLatin1Char('\n'));
|
||||||
}
|
}
|
||||||
@@ -437,10 +437,10 @@ QString Utils::pathListToString(const QStringList &pathList)
|
|||||||
QString Utils::pathListToString(const ProjectExplorer::HeaderPaths &pathList)
|
QString Utils::pathListToString(const ProjectExplorer::HeaderPaths &pathList)
|
||||||
{
|
{
|
||||||
QStringList result;
|
QStringList result;
|
||||||
foreach (const ProjectExplorer::HeaderPath &path, pathList) {
|
for (const ProjectExplorer::HeaderPath &path : pathList)
|
||||||
result << QString(QLatin1String("%1 (%2 path)")).arg(
|
result << QString(QLatin1String("%1 (%2 path)")).arg(
|
||||||
QDir::toNativeSeparators(path.path), toString(path.type));
|
QDir::toNativeSeparators(path.path), toString(path.type));
|
||||||
}
|
|
||||||
return result.join(QLatin1Char('\n'));
|
return result.join(QLatin1Char('\n'));
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -509,12 +509,12 @@ void Dumper::dumpProjectInfos(const QList<ProjectInfo::ConstPtr> &projectInfos)
|
|||||||
const QByteArray i4 = indent(4);
|
const QByteArray i4 = indent(4);
|
||||||
|
|
||||||
m_out << "Projects loaded: " << projectInfos.size() << "{{{1\n";
|
m_out << "Projects loaded: " << projectInfos.size() << "{{{1\n";
|
||||||
foreach (const ProjectInfo::ConstPtr &info, projectInfos) {
|
for (const ProjectInfo::ConstPtr &info : projectInfos) {
|
||||||
m_out << i1 << "Project " << info->projectName()
|
m_out << i1 << "Project " << info->projectName()
|
||||||
<< " (" << info->projectFilePath().toUserOutput() << "){{{2\n";
|
<< " (" << info->projectFilePath().toUserOutput() << "){{{2\n";
|
||||||
|
|
||||||
const QVector<ProjectPart::ConstPtr> projectParts = info->projectParts();
|
const QVector<ProjectPart::ConstPtr> projectParts = info->projectParts();
|
||||||
foreach (const ProjectPart::ConstPtr &part, projectParts) {
|
for (const ProjectPart::ConstPtr &part : projectParts) {
|
||||||
QString projectName = QLatin1String("<None>");
|
QString projectName = QLatin1String("<None>");
|
||||||
QString projectFilePath = "<None>";
|
QString projectFilePath = "<None>";
|
||||||
if (part->hasProject()) {
|
if (part->hasProject()) {
|
||||||
@@ -543,7 +543,7 @@ void Dumper::dumpProjectInfos(const QList<ProjectInfo::ConstPtr> &projectInfos)
|
|||||||
|
|
||||||
if (!part->files.isEmpty()) {
|
if (!part->files.isEmpty()) {
|
||||||
m_out << i3 << "Files:{{{4\n";
|
m_out << i3 << "Files:{{{4\n";
|
||||||
foreach (const ProjectFile &projectFile, part->files) {
|
for (const ProjectFile &projectFile : qAsConst(part->files)) {
|
||||||
m_out << i4 << Utils::toString(projectFile.kind) << ": " << projectFile.path;
|
m_out << i4 << Utils::toString(projectFile.kind) << ": " << projectFile.path;
|
||||||
if (!projectFile.active)
|
if (!projectFile.active)
|
||||||
m_out << " (inactive)";
|
m_out << " (inactive)";
|
||||||
@@ -555,20 +555,20 @@ void Dumper::dumpProjectInfos(const QList<ProjectInfo::ConstPtr> &projectInfos)
|
|||||||
m_out << i3 << "Toolchain Defines:{{{4\n";
|
m_out << i3 << "Toolchain Defines:{{{4\n";
|
||||||
const QList<QByteArray> defineLines =
|
const QList<QByteArray> defineLines =
|
||||||
ProjectExplorer::Macro::toByteArray(part->toolChainMacros).split('\n');
|
ProjectExplorer::Macro::toByteArray(part->toolChainMacros).split('\n');
|
||||||
foreach (const QByteArray &defineLine, defineLines)
|
for (const QByteArray &defineLine : defineLines)
|
||||||
m_out << i4 << defineLine << "\n";
|
m_out << i4 << defineLine << "\n";
|
||||||
}
|
}
|
||||||
if (!part->projectMacros.isEmpty()) {
|
if (!part->projectMacros.isEmpty()) {
|
||||||
m_out << i3 << "Project Defines:{{{4\n";
|
m_out << i3 << "Project Defines:{{{4\n";
|
||||||
const QList<QByteArray> defineLines =
|
const QList<QByteArray> defineLines =
|
||||||
ProjectExplorer::Macro::toByteArray(part->projectMacros).split('\n');
|
ProjectExplorer::Macro::toByteArray(part->projectMacros).split('\n');
|
||||||
foreach (const QByteArray &defineLine, defineLines)
|
for (const QByteArray &defineLine : defineLines)
|
||||||
m_out << i4 << defineLine << "\n";
|
m_out << i4 << defineLine << "\n";
|
||||||
}
|
}
|
||||||
|
|
||||||
if (!part->headerPaths.isEmpty()) {
|
if (!part->headerPaths.isEmpty()) {
|
||||||
m_out << i3 << "Header Paths:{{{4\n";
|
m_out << i3 << "Header Paths:{{{4\n";
|
||||||
foreach (const ProjectExplorer::HeaderPath &headerPath, part->headerPaths) {
|
for (const ProjectExplorer::HeaderPath &headerPath : qAsConst(part->headerPaths)) {
|
||||||
m_out << i4 << headerPath.path;
|
m_out << i4 << headerPath.path;
|
||||||
printIncludeType(m_out, headerPath.type);
|
printIncludeType(m_out, headerPath.type);
|
||||||
m_out << "\n";
|
m_out << "\n";
|
||||||
@@ -577,7 +577,7 @@ void Dumper::dumpProjectInfos(const QList<ProjectInfo::ConstPtr> &projectInfos)
|
|||||||
|
|
||||||
if (!part->precompiledHeaders.isEmpty()) {
|
if (!part->precompiledHeaders.isEmpty()) {
|
||||||
m_out << i3 << "Precompiled Headers:{{{4\n";
|
m_out << i3 << "Precompiled Headers:{{{4\n";
|
||||||
foreach (const QString &precompiledHeader, part->precompiledHeaders)
|
for (const QString &precompiledHeader : qAsConst(part->precompiledHeaders))
|
||||||
m_out << i4 << precompiledHeader << "\n";
|
m_out << i4 << precompiledHeader << "\n";
|
||||||
}
|
}
|
||||||
} // for part
|
} // for part
|
||||||
@@ -601,7 +601,7 @@ void Dumper::dumpSnapshot(const CPlusPlus::Snapshot &snapshot, const QString &ti
|
|||||||
// Divide into shared and not shared
|
// Divide into shared and not shared
|
||||||
QList<CPlusPlus::Document::Ptr> globallyShared;
|
QList<CPlusPlus::Document::Ptr> globallyShared;
|
||||||
QList<CPlusPlus::Document::Ptr> notGloballyShared;
|
QList<CPlusPlus::Document::Ptr> notGloballyShared;
|
||||||
foreach (const CPlusPlus::Document::Ptr &document, documents) {
|
for (const CPlusPlus::Document::Ptr &document : documents) {
|
||||||
CPlusPlus::Document::Ptr globalDocument = m_globalSnapshot.document(document->fileName());
|
CPlusPlus::Document::Ptr globalDocument = m_globalSnapshot.document(document->fileName());
|
||||||
if (globalDocument && globalDocument->fingerprint() == document->fingerprint())
|
if (globalDocument && globalDocument->fingerprint() == document->fingerprint())
|
||||||
globallyShared.append(document);
|
globallyShared.append(document);
|
||||||
@@ -641,7 +641,7 @@ void Dumper::dumpMergedEntities(const ProjectExplorer::HeaderPaths &mergedHeader
|
|||||||
const QByteArray i3 = indent(3);
|
const QByteArray i3 = indent(3);
|
||||||
|
|
||||||
m_out << i2 << "Merged Header Paths{{{2\n";
|
m_out << i2 << "Merged Header Paths{{{2\n";
|
||||||
foreach (const ProjectExplorer::HeaderPath &hp, mergedHeaderPaths) {
|
for (const ProjectExplorer::HeaderPath &hp : mergedHeaderPaths) {
|
||||||
m_out << i3 << hp.path;
|
m_out << i3 << hp.path;
|
||||||
printIncludeType(m_out, hp.type);
|
printIncludeType(m_out, hp.type);
|
||||||
m_out << "\n";
|
m_out << "\n";
|
||||||
@@ -652,7 +652,7 @@ void Dumper::dumpMergedEntities(const ProjectExplorer::HeaderPaths &mergedHeader
|
|||||||
|
|
||||||
void Dumper::dumpStringList(const QStringList &list, const QByteArray &indent)
|
void Dumper::dumpStringList(const QStringList &list, const QByteArray &indent)
|
||||||
{
|
{
|
||||||
foreach (const QString &item, list)
|
for (const QString &item : list)
|
||||||
m_out << indent << item << "\n";
|
m_out << indent << item << "\n";
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -661,7 +661,7 @@ void Dumper::dumpDocuments(const QList<CPlusPlus::Document::Ptr> &documents, boo
|
|||||||
const QByteArray i2 = indent(2);
|
const QByteArray i2 = indent(2);
|
||||||
const QByteArray i3 = indent(3);
|
const QByteArray i3 = indent(3);
|
||||||
const QByteArray i4 = indent(4);
|
const QByteArray i4 = indent(4);
|
||||||
foreach (const CPlusPlus::Document::Ptr &document, documents) {
|
for (const CPlusPlus::Document::Ptr &document : documents) {
|
||||||
if (skipDetails) {
|
if (skipDetails) {
|
||||||
m_out << i2 << "\"" << document->fileName() << "\"\n";
|
m_out << i2 << "\"" << document->fileName() << "\"\n";
|
||||||
continue;
|
continue;
|
||||||
@@ -680,7 +680,7 @@ void Dumper::dumpDocuments(const QList<CPlusPlus::Document::Ptr> &documents, boo
|
|||||||
+ document->resolvedIncludes();
|
+ document->resolvedIncludes();
|
||||||
if (!includes.isEmpty()) {
|
if (!includes.isEmpty()) {
|
||||||
m_out << i3 << "Includes:{{{4\n";
|
m_out << i3 << "Includes:{{{4\n";
|
||||||
foreach (const CPlusPlus::Document::Include &include, includes) {
|
for (const CPlusPlus::Document::Include &include : includes) {
|
||||||
m_out << i4 << "at line " << include.line() << ": "
|
m_out << i4 << "at line " << include.line() << ": "
|
||||||
<< Utils::unresolvedFileNameWithDelimiters(include) << " ==> "
|
<< Utils::unresolvedFileNameWithDelimiters(include) << " ==> "
|
||||||
<< include.resolvedFileName() << "\n";
|
<< include.resolvedFileName() << "\n";
|
||||||
@@ -691,7 +691,7 @@ void Dumper::dumpDocuments(const QList<CPlusPlus::Document::Ptr> &documents, boo
|
|||||||
= document->diagnosticMessages();
|
= document->diagnosticMessages();
|
||||||
if (!diagnosticMessages.isEmpty()) {
|
if (!diagnosticMessages.isEmpty()) {
|
||||||
m_out << i3 << "Diagnostic Messages:{{{4\n";
|
m_out << i3 << "Diagnostic Messages:{{{4\n";
|
||||||
foreach (const CPlusPlus::Document::DiagnosticMessage &msg, diagnosticMessages) {
|
for (const CPlusPlus::Document::DiagnosticMessage &msg : diagnosticMessages) {
|
||||||
const auto level =
|
const auto level =
|
||||||
static_cast<CPlusPlus::Document::DiagnosticMessage::Level>(msg.level());
|
static_cast<CPlusPlus::Document::DiagnosticMessage::Level>(msg.level());
|
||||||
m_out << i4 << "at " << msg.line() << ":" << msg.column() << ", " << Utils::toString(level)
|
m_out << i4 << "at " << msg.line() << ":" << msg.column() << ", " << Utils::toString(level)
|
||||||
@@ -702,14 +702,14 @@ void Dumper::dumpDocuments(const QList<CPlusPlus::Document::Ptr> &documents, boo
|
|||||||
const QList<CPlusPlus::Macro> macroDefinitions = document->definedMacros();
|
const QList<CPlusPlus::Macro> macroDefinitions = document->definedMacros();
|
||||||
if (!macroDefinitions.isEmpty()) {
|
if (!macroDefinitions.isEmpty()) {
|
||||||
m_out << i3 << "(Un)Defined Macros:{{{4\n";
|
m_out << i3 << "(Un)Defined Macros:{{{4\n";
|
||||||
foreach (const CPlusPlus::Macro ¯o, macroDefinitions)
|
for (const CPlusPlus::Macro ¯o : macroDefinitions)
|
||||||
m_out << i4 << "at line " << macro.line() << ": " << macro.toString() << "\n";
|
m_out << i4 << "at line " << macro.line() << ": " << macro.toString() << "\n";
|
||||||
}
|
}
|
||||||
|
|
||||||
const QList<CPlusPlus::Document::MacroUse> macroUses = document->macroUses();
|
const QList<CPlusPlus::Document::MacroUse> macroUses = document->macroUses();
|
||||||
if (!macroUses.isEmpty()) {
|
if (!macroUses.isEmpty()) {
|
||||||
m_out << i3 << "Macro Uses:{{{4\n";
|
m_out << i3 << "Macro Uses:{{{4\n";
|
||||||
foreach (const CPlusPlus::Document::MacroUse &use, macroUses) {
|
for (const CPlusPlus::Document::MacroUse &use : macroUses) {
|
||||||
const QString type = use.isFunctionLike()
|
const QString type = use.isFunctionLike()
|
||||||
? QLatin1String("function-like") : QLatin1String("object-like");
|
? QLatin1String("function-like") : QLatin1String("object-like");
|
||||||
m_out << i4 << "at line " << use.beginLine() << ", "
|
m_out << i4 << "at line " << use.beginLine() << ", "
|
||||||
|
|||||||
@@ -307,7 +307,7 @@ void CppCodeStylePreferencesWidget::updatePreview()
|
|||||||
const CppCodeStyleSettings ccss = cppCodeStylePreferences->currentCodeStyleSettings();
|
const CppCodeStyleSettings ccss = cppCodeStylePreferences->currentCodeStyleSettings();
|
||||||
const TabSettings ts = cppCodeStylePreferences->currentTabSettings();
|
const TabSettings ts = cppCodeStylePreferences->currentTabSettings();
|
||||||
QtStyleCodeFormatter formatter(ts, ccss);
|
QtStyleCodeFormatter formatter(ts, ccss);
|
||||||
foreach (SnippetEditorWidget *preview, m_previews) {
|
for (SnippetEditorWidget *preview : qAsConst(m_previews)) {
|
||||||
preview->textDocument()->setTabSettings(ts);
|
preview->textDocument()->setTabSettings(ts);
|
||||||
preview->setCodeStyle(cppCodeStylePreferences);
|
preview->setCodeStyle(cppCodeStylePreferences);
|
||||||
|
|
||||||
@@ -329,7 +329,7 @@ void CppCodeStylePreferencesWidget::updatePreview()
|
|||||||
|
|
||||||
void CppCodeStylePreferencesWidget::decorateEditors(const FontSettings &fontSettings)
|
void CppCodeStylePreferencesWidget::decorateEditors(const FontSettings &fontSettings)
|
||||||
{
|
{
|
||||||
foreach (SnippetEditorWidget *editor, m_previews) {
|
for (SnippetEditorWidget *editor : qAsConst(m_previews)) {
|
||||||
editor->textDocument()->setFontSettings(fontSettings);
|
editor->textDocument()->setFontSettings(fontSettings);
|
||||||
SnippetProvider::decorateEditor(editor, CppEditor::Constants::CPP_SNIPPETS_GROUP_ID);
|
SnippetProvider::decorateEditor(editor, CppEditor::Constants::CPP_SNIPPETS_GROUP_ID);
|
||||||
}
|
}
|
||||||
@@ -337,7 +337,7 @@ void CppCodeStylePreferencesWidget::decorateEditors(const FontSettings &fontSett
|
|||||||
|
|
||||||
void CppCodeStylePreferencesWidget::setVisualizeWhitespace(bool on)
|
void CppCodeStylePreferencesWidget::setVisualizeWhitespace(bool on)
|
||||||
{
|
{
|
||||||
foreach (SnippetEditorWidget *editor, m_previews) {
|
for (SnippetEditorWidget *editor : qAsConst(m_previews)) {
|
||||||
DisplaySettings displaySettings = editor->displaySettings();
|
DisplaySettings displaySettings = editor->displaySettings();
|
||||||
displaySettings.m_visualizeWhitespace = on;
|
displaySettings.m_visualizeWhitespace = on;
|
||||||
editor->setDisplaySettings(displaySettings);
|
editor->setDisplaySettings(displaySettings);
|
||||||
|
|||||||
@@ -277,7 +277,7 @@ void CompletionTest::testCompletionTemplateFunction()
|
|||||||
|
|
||||||
QStringList actualCompletions = test.getCompletions();
|
QStringList actualCompletions = test.getCompletions();
|
||||||
QString errorPattern(QLatin1String("Completion not found: %1"));
|
QString errorPattern(QLatin1String("Completion not found: %1"));
|
||||||
foreach (const QString &completion, expectedCompletions) {
|
for (const QString &completion : qAsConst(expectedCompletions)) {
|
||||||
QByteArray errorMessage = errorPattern.arg(completion).toUtf8();
|
QByteArray errorMessage = errorPattern.arg(completion).toUtf8();
|
||||||
QVERIFY2(actualCompletions.contains(completion), errorMessage.data());
|
QVERIFY2(actualCompletions.contains(completion), errorMessage.data());
|
||||||
}
|
}
|
||||||
@@ -371,7 +371,7 @@ void CompletionTest::testGlobalCompletion_data()
|
|||||||
"<REPLACEMENT>\n"
|
"<REPLACEMENT>\n"
|
||||||
"@\n";
|
"@\n";
|
||||||
const QStringList replacements = QStringList({"// text", "// text.", "/// text", "/// text."});
|
const QStringList replacements = QStringList({"// text", "// text.", "/// text", "/// text."});
|
||||||
foreach (const QString &replacement, replacements) {
|
for (const QString &replacement : replacements) {
|
||||||
QByteArray code = codeTemplate;
|
QByteArray code = codeTemplate;
|
||||||
code.replace("<REPLACEMENT>", replacement.toUtf8());
|
code.replace("<REPLACEMENT>", replacement.toUtf8());
|
||||||
const QByteArray tag = _("completion after comment: ") + replacement.toUtf8();
|
const QByteArray tag = _("completion after comment: ") + replacement.toUtf8();
|
||||||
|
|||||||
@@ -790,7 +790,8 @@ Class *classFromLookupItem(const LookupItem &lookupItem, const LookupContext &co
|
|||||||
if (!b)
|
if (!b)
|
||||||
return nullptr;
|
return nullptr;
|
||||||
|
|
||||||
foreach (Symbol *s, b->symbols()) {
|
const QList<Symbol *> symbols = b->symbols();
|
||||||
|
for (Symbol *s : symbols) {
|
||||||
if (Class *klass = s->asClass())
|
if (Class *klass = s->asClass())
|
||||||
return klass;
|
return klass;
|
||||||
}
|
}
|
||||||
@@ -1105,7 +1106,7 @@ bool InternalCppCompletionAssistProcessor::tryObjCCompletion()
|
|||||||
const QList<LookupItem> items = (*m_model->m_typeOfExpression)(expr.toUtf8(), scope);
|
const QList<LookupItem> items = (*m_model->m_typeOfExpression)(expr.toUtf8(), scope);
|
||||||
LookupContext lookupContext(thisDocument, m_interface->snapshot());
|
LookupContext lookupContext(thisDocument, m_interface->snapshot());
|
||||||
|
|
||||||
foreach (const LookupItem &item, items) {
|
for (const LookupItem &item : items) {
|
||||||
FullySpecifiedType ty = item.type().simplified();
|
FullySpecifiedType ty = item.type().simplified();
|
||||||
if (ty->isPointerType()) {
|
if (ty->isPointerType()) {
|
||||||
ty = ty->asPointerType()->elementType().simplified();
|
ty = ty->asPointerType()->elementType().simplified();
|
||||||
@@ -1169,12 +1170,14 @@ void InternalCppCompletionAssistProcessor::completeObjCMsgSend(ClassOrNamespace
|
|||||||
bool staticClassAccess)
|
bool staticClassAccess)
|
||||||
{
|
{
|
||||||
QList<Scope*> memberScopes;
|
QList<Scope*> memberScopes;
|
||||||
foreach (Symbol *s, binding->symbols()) {
|
|
||||||
|
const QList<Symbol *> symbols = binding->symbols();
|
||||||
|
for (Symbol *s : symbols) {
|
||||||
if (ObjCClass *c = s->asObjCClass())
|
if (ObjCClass *c = s->asObjCClass())
|
||||||
memberScopes.append(c);
|
memberScopes.append(c);
|
||||||
}
|
}
|
||||||
|
|
||||||
foreach (Scope *scope, memberScopes) {
|
for (Scope *scope : qAsConst(memberScopes)) {
|
||||||
for (int i = 0; i < scope->memberCount(); ++i) {
|
for (int i = 0; i < scope->memberCount(); ++i) {
|
||||||
Symbol *symbol = scope->memberAt(i);
|
Symbol *symbol = scope->memberAt(i);
|
||||||
|
|
||||||
@@ -1239,7 +1242,7 @@ bool InternalCppCompletionAssistProcessor::completeInclude(const QTextCursor &cu
|
|||||||
|
|
||||||
const QStringList suffixes = Utils::mimeTypeForName(QLatin1String("text/x-c++hdr")).suffixes();
|
const QStringList suffixes = Utils::mimeTypeForName(QLatin1String("text/x-c++hdr")).suffixes();
|
||||||
|
|
||||||
foreach (const ProjectExplorer::HeaderPath &headerPath, headerPaths) {
|
for (const ProjectExplorer::HeaderPath &headerPath : qAsConst(headerPaths)) {
|
||||||
QString realPath = headerPath.path;
|
QString realPath = headerPath.path;
|
||||||
if (!directoryPrefix.isEmpty()) {
|
if (!directoryPrefix.isEmpty()) {
|
||||||
realPath += QLatin1Char('/');
|
realPath += QLatin1Char('/');
|
||||||
@@ -1272,7 +1275,8 @@ void InternalCppCompletionAssistProcessor::completeInclude(const QString &realPa
|
|||||||
|
|
||||||
void InternalCppCompletionAssistProcessor::completePreprocessor()
|
void InternalCppCompletionAssistProcessor::completePreprocessor()
|
||||||
{
|
{
|
||||||
foreach (const QString &preprocessorCompletion, preprocessorCompletions())
|
const QStringList preprocessorCompletionList = preprocessorCompletions();
|
||||||
|
for (const QString &preprocessorCompletion : preprocessorCompletionList)
|
||||||
addCompletionItem(preprocessorCompletion);
|
addCompletionItem(preprocessorCompletion);
|
||||||
|
|
||||||
if (objcKeywordsWanted())
|
if (objcKeywordsWanted())
|
||||||
@@ -1351,7 +1355,7 @@ int InternalCppCompletionAssistProcessor::startCompletionInternal(const QString
|
|||||||
TypeOfExpression::Preprocess);
|
TypeOfExpression::Preprocess);
|
||||||
|
|
||||||
// If it's a class, add completions for the constructors
|
// If it's a class, add completions for the constructors
|
||||||
foreach (const LookupItem &result, results) {
|
for (const LookupItem &result : results) {
|
||||||
if (result.type()->isClassType()) {
|
if (result.type()->isClassType()) {
|
||||||
if (completeConstructorOrFunction(results, endOfExpression, true))
|
if (completeConstructorOrFunction(results, endOfExpression, true))
|
||||||
return m_positionForProposal;
|
return m_positionForProposal;
|
||||||
@@ -1482,7 +1486,8 @@ bool InternalCppCompletionAssistProcessor::globalCompletion(Scope *currentScope)
|
|||||||
break;
|
break;
|
||||||
processed.insert(currentBinding);
|
processed.insert(currentBinding);
|
||||||
|
|
||||||
foreach (ClassOrNamespace* u, currentBinding->usings())
|
const QList<ClassOrNamespace*> usings = currentBinding->usings();
|
||||||
|
for (ClassOrNamespace* u : usings)
|
||||||
usingBindings.append(u);
|
usingBindings.append(u);
|
||||||
|
|
||||||
const QList<Symbol *> symbols = currentBinding->symbols();
|
const QList<Symbol *> symbols = currentBinding->symbols();
|
||||||
@@ -1495,7 +1500,7 @@ bool InternalCppCompletionAssistProcessor::globalCompletion(Scope *currentScope)
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
foreach (ClassOrNamespace *b, usingBindings)
|
for (ClassOrNamespace *b : qAsConst(usingBindings))
|
||||||
completeNamespace(b);
|
completeNamespace(b);
|
||||||
|
|
||||||
addKeywords();
|
addKeywords();
|
||||||
@@ -1547,7 +1552,7 @@ bool InternalCppCompletionAssistProcessor::completeScope(const QList<LookupItem>
|
|||||||
if (results.isEmpty())
|
if (results.isEmpty())
|
||||||
return false;
|
return false;
|
||||||
|
|
||||||
foreach (const LookupItem &result, results) {
|
for (const LookupItem &result : results) {
|
||||||
FullySpecifiedType ty = result.type();
|
FullySpecifiedType ty = result.type();
|
||||||
Scope *scope = result.scope();
|
Scope *scope = result.scope();
|
||||||
|
|
||||||
@@ -1625,12 +1630,14 @@ void InternalCppCompletionAssistProcessor::completeNamespace(ClassOrNamespace *b
|
|||||||
QList<Scope *> scopesToVisit;
|
QList<Scope *> scopesToVisit;
|
||||||
QSet<Scope *> scopesVisited;
|
QSet<Scope *> scopesVisited;
|
||||||
|
|
||||||
foreach (Symbol *bb, binding->symbols()) {
|
const QList<Symbol *> symbols = binding->symbols();
|
||||||
|
for (Symbol *bb : symbols) {
|
||||||
if (Scope *scope = bb->asScope())
|
if (Scope *scope = bb->asScope())
|
||||||
scopesToVisit.append(scope);
|
scopesToVisit.append(scope);
|
||||||
}
|
}
|
||||||
|
|
||||||
foreach (Enum *e, binding->unscopedEnums())
|
const QList<Enum *> enums = binding->unscopedEnums();
|
||||||
|
for (Enum *e : enums)
|
||||||
scopesToVisit.append(e);
|
scopesToVisit.append(e);
|
||||||
|
|
||||||
while (!scopesToVisit.isEmpty()) {
|
while (!scopesToVisit.isEmpty()) {
|
||||||
@@ -1665,14 +1672,16 @@ void InternalCppCompletionAssistProcessor::completeClass(ClassOrNamespace *b, bo
|
|||||||
QList<Scope *> scopesToVisit;
|
QList<Scope *> scopesToVisit;
|
||||||
QSet<Scope *> scopesVisited;
|
QSet<Scope *> scopesVisited;
|
||||||
|
|
||||||
foreach (Symbol *bb, binding->symbols()) {
|
const QList<Symbol *> symbols = binding->symbols();
|
||||||
|
for (Symbol *bb : symbols) {
|
||||||
if (Class *k = bb->asClass())
|
if (Class *k = bb->asClass())
|
||||||
scopesToVisit.append(k);
|
scopesToVisit.append(k);
|
||||||
else if (Block *b = bb->asBlock())
|
else if (Block *b = bb->asBlock())
|
||||||
scopesToVisit.append(b);
|
scopesToVisit.append(b);
|
||||||
}
|
}
|
||||||
|
|
||||||
foreach (Enum *e, binding->unscopedEnums())
|
const QList<Enum *> enums = binding->unscopedEnums();
|
||||||
|
for (Enum *e : enums)
|
||||||
scopesToVisit.append(e);
|
scopesToVisit.append(e);
|
||||||
|
|
||||||
while (!scopesToVisit.isEmpty()) {
|
while (!scopesToVisit.isEmpty()) {
|
||||||
@@ -1740,7 +1749,7 @@ bool InternalCppCompletionAssistProcessor::completeQtMethod(const QList<LookupIt
|
|||||||
o.showFunctionSignatures = true;
|
o.showFunctionSignatures = true;
|
||||||
|
|
||||||
QSet<QString> signatures;
|
QSet<QString> signatures;
|
||||||
foreach (const LookupItem &lookupItem, results) {
|
for (const LookupItem &lookupItem : results) {
|
||||||
ClassOrNamespace *b = classOrNamespaceFromLookupItem(lookupItem, context);
|
ClassOrNamespace *b = classOrNamespaceFromLookupItem(lookupItem, context);
|
||||||
if (!b)
|
if (!b)
|
||||||
continue;
|
continue;
|
||||||
@@ -1754,7 +1763,8 @@ bool InternalCppCompletionAssistProcessor::completeQtMethod(const QList<LookupIt
|
|||||||
if (!processed.contains(binding)) {
|
if (!processed.contains(binding)) {
|
||||||
processed.insert(binding);
|
processed.insert(binding);
|
||||||
|
|
||||||
foreach (Symbol *s, binding->symbols())
|
const QList<Symbol *> symbols = binding->symbols();
|
||||||
|
for (Symbol *s : symbols)
|
||||||
if (Class *clazz = s->asClass())
|
if (Class *clazz = s->asClass())
|
||||||
scopes.append(clazz);
|
scopes.append(clazz);
|
||||||
|
|
||||||
@@ -1764,7 +1774,7 @@ bool InternalCppCompletionAssistProcessor::completeQtMethod(const QList<LookupIt
|
|||||||
|
|
||||||
const bool wantSignals = type == CompleteQt4Signals || type == CompleteQt5Signals;
|
const bool wantSignals = type == CompleteQt4Signals || type == CompleteQt5Signals;
|
||||||
const bool wantQt5SignalOrSlot = type == CompleteQt5Signals || type == CompleteQt5Slots;
|
const bool wantQt5SignalOrSlot = type == CompleteQt5Signals || type == CompleteQt5Slots;
|
||||||
foreach (Scope *scope, scopes) {
|
for (Scope *scope : qAsConst(scopes)) {
|
||||||
Class *klass = scope->asClass();
|
Class *klass = scope->asClass();
|
||||||
if (!klass)
|
if (!klass)
|
||||||
continue;
|
continue;
|
||||||
@@ -1821,7 +1831,7 @@ bool InternalCppCompletionAssistProcessor::completeQtMethodClassName(
|
|||||||
const QIcon classIcon = Utils::CodeModelIcon::iconForType(Utils::CodeModelIcon::Class);
|
const QIcon classIcon = Utils::CodeModelIcon::iconForType(Utils::CodeModelIcon::Class);
|
||||||
Overview overview;
|
Overview overview;
|
||||||
|
|
||||||
foreach (const LookupItem &lookupItem, results) {
|
for (const LookupItem &lookupItem : results) {
|
||||||
Class *klass = classFromLookupItem(lookupItem, context);
|
Class *klass = classFromLookupItem(lookupItem, context);
|
||||||
if (!klass)
|
if (!klass)
|
||||||
continue;
|
continue;
|
||||||
@@ -1864,7 +1874,7 @@ void InternalCppCompletionAssistProcessor::addMacros(const QString &fileName,
|
|||||||
|
|
||||||
addMacros_helper(snapshot, fileName, &processed, &definedMacros);
|
addMacros_helper(snapshot, fileName, &processed, &definedMacros);
|
||||||
|
|
||||||
foreach (const QString ¯oName, definedMacros)
|
for (const QString ¯oName : qAsConst(definedMacros))
|
||||||
addCompletionItem(macroName, Icons::macroIcon(), MacrosOrder);
|
addCompletionItem(macroName, Icons::macroIcon(), MacrosOrder);
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -1880,10 +1890,12 @@ void InternalCppCompletionAssistProcessor::addMacros_helper(const Snapshot &snap
|
|||||||
|
|
||||||
processed->insert(doc->fileName());
|
processed->insert(doc->fileName());
|
||||||
|
|
||||||
foreach (const Document::Include &i, doc->resolvedIncludes())
|
const QList<Document::Include> includes = doc->resolvedIncludes();
|
||||||
|
for (const Document::Include &i : includes)
|
||||||
addMacros_helper(snapshot, i.resolvedFileName(), processed, definedMacros);
|
addMacros_helper(snapshot, i.resolvedFileName(), processed, definedMacros);
|
||||||
|
|
||||||
foreach (const CPlusPlus::Macro ¯o, doc->definedMacros()) {
|
const QList<CPlusPlus::Macro> macros = doc->definedMacros();
|
||||||
|
for (const CPlusPlus::Macro ¯o : macros) {
|
||||||
const QString macroName = macro.nameToQString();
|
const QString macroName = macro.nameToQString();
|
||||||
if (!macro.isHidden())
|
if (!macro.isHidden())
|
||||||
definedMacros->insert(macroName);
|
definedMacros->insert(macroName);
|
||||||
@@ -1899,7 +1911,7 @@ bool InternalCppCompletionAssistProcessor::completeConstructorOrFunction(const Q
|
|||||||
const LookupContext &context = m_model->m_typeOfExpression->context();
|
const LookupContext &context = m_model->m_typeOfExpression->context();
|
||||||
QList<Function *> functions;
|
QList<Function *> functions;
|
||||||
|
|
||||||
foreach (const LookupItem &result, results) {
|
for (const LookupItem &result : results) {
|
||||||
FullySpecifiedType exprTy = result.type().simplified();
|
FullySpecifiedType exprTy = result.type().simplified();
|
||||||
|
|
||||||
if (Class *klass = asClassOrTemplateClassType(exprTy)) {
|
if (Class *klass = asClassOrTemplateClassType(exprTy)) {
|
||||||
@@ -1930,7 +1942,7 @@ bool InternalCppCompletionAssistProcessor::completeConstructorOrFunction(const Q
|
|||||||
}
|
}
|
||||||
|
|
||||||
if (functions.isEmpty()) {
|
if (functions.isEmpty()) {
|
||||||
foreach (const LookupItem &result, results) {
|
for (const LookupItem &result : results) {
|
||||||
FullySpecifiedType ty = result.type().simplified();
|
FullySpecifiedType ty = result.type().simplified();
|
||||||
|
|
||||||
if (Function *fun = asFunctionOrTemplateFunctionType(ty)) {
|
if (Function *fun = asFunctionOrTemplateFunctionType(ty)) {
|
||||||
@@ -1945,7 +1957,7 @@ bool InternalCppCompletionAssistProcessor::completeConstructorOrFunction(const Q
|
|||||||
|
|
||||||
bool newOverload = true;
|
bool newOverload = true;
|
||||||
|
|
||||||
foreach (Function *f, functions) {
|
for (Function *f : qAsConst(functions)) {
|
||||||
if (fun->match(f)) {
|
if (fun->match(f)) {
|
||||||
newOverload = false;
|
newOverload = false;
|
||||||
break;
|
break;
|
||||||
@@ -1961,13 +1973,14 @@ bool InternalCppCompletionAssistProcessor::completeConstructorOrFunction(const Q
|
|||||||
if (functions.isEmpty()) {
|
if (functions.isEmpty()) {
|
||||||
const Name *functionCallOp = context.bindings()->control()->operatorNameId(OperatorNameId::FunctionCallOp);
|
const Name *functionCallOp = context.bindings()->control()->operatorNameId(OperatorNameId::FunctionCallOp);
|
||||||
|
|
||||||
foreach (const LookupItem &result, results) {
|
for (const LookupItem &result : results) {
|
||||||
FullySpecifiedType ty = result.type().simplified();
|
FullySpecifiedType ty = result.type().simplified();
|
||||||
Scope *scope = result.scope();
|
Scope *scope = result.scope();
|
||||||
|
|
||||||
if (NamedType *namedTy = ty->asNamedType()) {
|
if (NamedType *namedTy = ty->asNamedType()) {
|
||||||
if (ClassOrNamespace *b = context.lookupType(namedTy->name(), scope)) {
|
if (ClassOrNamespace *b = context.lookupType(namedTy->name(), scope)) {
|
||||||
foreach (const LookupItem &r, b->lookup(functionCallOp)) {
|
const QList<LookupItem> items = b->lookup(functionCallOp);
|
||||||
|
for (const LookupItem &r : items) {
|
||||||
Symbol *overload = r.declaration();
|
Symbol *overload = r.declaration();
|
||||||
FullySpecifiedType overloadTy = overload->type().simplified();
|
FullySpecifiedType overloadTy = overload->type().simplified();
|
||||||
|
|
||||||
@@ -2057,7 +2070,7 @@ bool InternalCppCompletionAssistProcessor::completeConstructorOrFunction(const Q
|
|||||||
Control *control = context.bindings()->control().data();
|
Control *control = context.bindings()->control().data();
|
||||||
|
|
||||||
// set up signature autocompletion
|
// set up signature autocompletion
|
||||||
foreach (Function *f, functions) {
|
for (Function *f : qAsConst(functions)) {
|
||||||
Overview overview;
|
Overview overview;
|
||||||
overview.showArgumentNames = true;
|
overview.showArgumentNames = true;
|
||||||
overview.showDefaultArguments = false;
|
overview.showDefaultArguments = false;
|
||||||
|
|||||||
Reference in New Issue
Block a user