forked from qt-creator/qt-creator
Fix occurrences of the contains/insert anti-pattern
Introduce and make use of Utils::insert() for QSet with a return value that indicates whether insertion actually happened. Change-Id: I655e4bc3553b74fea5ae8956205e4d8070118d63 Reviewed-by: hjk <hjk@qt.io> Reviewed-by: Eike Ziller <eike.ziller@qt.io>
This commit is contained in:
@@ -774,10 +774,8 @@ QSet<FilePath> Snapshot::allIncludesForDocument(const FilePath &filePath) const
|
|||||||
if (Document::Ptr doc = document(file)) {
|
if (Document::Ptr doc = document(file)) {
|
||||||
const FilePaths includedFiles = doc->includedFiles(Document::Duplicates::Keep);
|
const FilePaths includedFiles = doc->includedFiles(Document::Duplicates::Keep);
|
||||||
for (const FilePath &inc : includedFiles) {
|
for (const FilePath &inc : includedFiles) {
|
||||||
if (!result.contains(inc)) {
|
if (Utils::insert(result, inc))
|
||||||
result.insert(inc);
|
|
||||||
files.push(inc);
|
files.push(inc);
|
||||||
}
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@@ -6,6 +6,8 @@
|
|||||||
#include <cplusplus/Literals.h>
|
#include <cplusplus/Literals.h>
|
||||||
#include <cplusplus/TranslationUnit.h>
|
#include <cplusplus/TranslationUnit.h>
|
||||||
|
|
||||||
|
#include <utils/algorithm.h>
|
||||||
|
|
||||||
#include <QDir>
|
#include <QDir>
|
||||||
|
|
||||||
using namespace Utils;
|
using namespace Utils;
|
||||||
@@ -65,9 +67,7 @@ void FastPreprocessor::sourceNeeded(int line, const FilePath &filePath, IncludeT
|
|||||||
|
|
||||||
void FastPreprocessor::mergeEnvironment(const FilePath &filePath)
|
void FastPreprocessor::mergeEnvironment(const FilePath &filePath)
|
||||||
{
|
{
|
||||||
if (! _merged.contains(filePath)) {
|
if (Utils::insert(_merged, filePath)) {
|
||||||
_merged.insert(filePath);
|
|
||||||
|
|
||||||
if (Document::Ptr doc = _snapshot.document(filePath)) {
|
if (Document::Ptr doc = _snapshot.document(filePath)) {
|
||||||
const QList<Document::Include> includes = doc->resolvedIncludes();
|
const QList<Document::Include> includes = doc->resolvedIncludes();
|
||||||
for (const Document::Include &i : includes)
|
for (const Document::Include &i : includes)
|
||||||
|
@@ -78,8 +78,7 @@ static bool isNestedInstantiationEnclosingTemplate(
|
|||||||
{
|
{
|
||||||
QSet<ClassOrNamespace *> processed;
|
QSet<ClassOrNamespace *> processed;
|
||||||
while (enclosingTemplateClassInstantiation
|
while (enclosingTemplateClassInstantiation
|
||||||
&& !processed.contains(enclosingTemplateClassInstantiation)) {
|
&& Utils::insert(processed, enclosingTemplateClassInstantiation)) {
|
||||||
processed.insert(enclosingTemplateClassInstantiation);
|
|
||||||
if (enclosingTemplateClassInstantiation == nestedClassOrNamespaceInstantiation)
|
if (enclosingTemplateClassInstantiation == nestedClassOrNamespaceInstantiation)
|
||||||
return false;
|
return false;
|
||||||
enclosingTemplateClassInstantiation = enclosingTemplateClassInstantiation->parent();
|
enclosingTemplateClassInstantiation = enclosingTemplateClassInstantiation->parent();
|
||||||
@@ -389,11 +388,10 @@ ClassOrNamespace *LookupContext::lookupType(const Name *name, Scope *scope,
|
|||||||
}
|
}
|
||||||
if (const NamedType *namedTy = d->type()->asNamedType()) {
|
if (const NamedType *namedTy = d->type()->asNamedType()) {
|
||||||
// Stop on recursive typedef declarations
|
// Stop on recursive typedef declarations
|
||||||
if (typedefsBeingResolved.contains(d))
|
if (!Utils::insert(typedefsBeingResolved, d))
|
||||||
return nullptr;
|
return nullptr;
|
||||||
return lookupType(namedTy->name(), scope, nullptr,
|
return lookupType(namedTy->name(), scope, nullptr,
|
||||||
QSet<const Declaration *>(typedefsBeingResolved)
|
typedefsBeingResolved);
|
||||||
<< d);
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@@ -504,9 +502,8 @@ QList<LookupItem> LookupContext::lookup(const Name *name, Scope *scope) const
|
|||||||
// try find this name in parent class
|
// try find this name in parent class
|
||||||
QSet<ClassOrNamespace *> processed;
|
QSet<ClassOrNamespace *> processed;
|
||||||
while (candidates.isEmpty() && (binding = binding->parent())) {
|
while (candidates.isEmpty() && (binding = binding->parent())) {
|
||||||
if (processed.contains(binding))
|
if (!Utils::insert(processed, binding))
|
||||||
break;
|
break;
|
||||||
processed.insert(binding);
|
|
||||||
candidates = binding->find(name);
|
candidates = binding->find(name);
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -683,9 +680,8 @@ QList<LookupItem> ClassOrNamespace::lookup_helper(const Name *name, bool searchI
|
|||||||
for (ClassOrNamespace *parentBinding = binding->parent();
|
for (ClassOrNamespace *parentBinding = binding->parent();
|
||||||
parentBinding && !match;
|
parentBinding && !match;
|
||||||
parentBinding = parentBinding->parent()) {
|
parentBinding = parentBinding->parent()) {
|
||||||
if (processed.contains(parentBinding))
|
if (!Utils::insert(processed, parentBinding))
|
||||||
break;
|
break;
|
||||||
processed.insert(parentBinding);
|
|
||||||
match = parentBinding->lookupInScope(fullName);
|
match = parentBinding->lookupInScope(fullName);
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -704,9 +700,8 @@ QList<LookupItem> ClassOrNamespace::lookup_helper(const Name *name, bool searchI
|
|||||||
QSet<ClassOrNamespace *> processedOwnParents;
|
QSet<ClassOrNamespace *> processedOwnParents;
|
||||||
ClassOrNamespace *binding = this;
|
ClassOrNamespace *binding = this;
|
||||||
do {
|
do {
|
||||||
if (processedOwnParents.contains(binding))
|
if (!Utils::insert(processedOwnParents, binding))
|
||||||
break;
|
break;
|
||||||
processedOwnParents.insert(binding);
|
|
||||||
lookup_helper(name, binding, &result, &processed, /*templateId = */ nullptr);
|
lookup_helper(name, binding, &result, &processed, /*templateId = */ nullptr);
|
||||||
binding = binding->_parent;
|
binding = binding->_parent;
|
||||||
} while (searchInEnclosingScope && binding);
|
} while (searchInEnclosingScope && binding);
|
||||||
@@ -720,9 +715,7 @@ void ClassOrNamespace::lookup_helper(const Name *name, ClassOrNamespace *binding
|
|||||||
QSet<ClassOrNamespace *> *processed,
|
QSet<ClassOrNamespace *> *processed,
|
||||||
const TemplateNameId *templateId)
|
const TemplateNameId *templateId)
|
||||||
{
|
{
|
||||||
if (binding && ! processed->contains(binding)) {
|
if (binding && Utils::insert(*processed, binding)) {
|
||||||
processed->insert(binding);
|
|
||||||
|
|
||||||
const Identifier *nameId = name->identifier();
|
const Identifier *nameId = name->identifier();
|
||||||
|
|
||||||
const QList<Symbol *> symbols = binding->symbols();
|
const QList<Symbol *> symbols = binding->symbols();
|
||||||
@@ -902,9 +895,8 @@ ClassOrNamespace *ClassOrNamespace::findBlock_helper(Block *block,
|
|||||||
bool searchInEnclosingScope)
|
bool searchInEnclosingScope)
|
||||||
{
|
{
|
||||||
for (ClassOrNamespace *binding = this; binding; binding = binding->_parent) {
|
for (ClassOrNamespace *binding = this; binding; binding = binding->_parent) {
|
||||||
if (processed->contains(binding))
|
if (!Utils::insert(*processed, binding))
|
||||||
break;
|
break;
|
||||||
processed->insert(binding);
|
|
||||||
binding->flush();
|
binding->flush();
|
||||||
auto end = binding->_blocks.end();
|
auto end = binding->_blocks.end();
|
||||||
auto citBlock = binding->_blocks.find(block);
|
auto citBlock = binding->_blocks.find(block);
|
||||||
@@ -977,9 +969,7 @@ ClassOrNamespace *ClassOrNamespace::lookupType_helper(const Name *name,
|
|||||||
|
|
||||||
return nullptr;
|
return nullptr;
|
||||||
|
|
||||||
} else if (! processed->contains(this)) {
|
} else if (Utils::insert(*processed, this)) {
|
||||||
processed->insert(this);
|
|
||||||
|
|
||||||
if (name->asNameId() || name->asTemplateNameId() || name->asAnonymousNameId()) {
|
if (name->asNameId() || name->asTemplateNameId() || name->asAnonymousNameId()) {
|
||||||
flush();
|
flush();
|
||||||
|
|
||||||
@@ -1260,9 +1250,8 @@ ClassOrNamespace *ClassOrNamespace::nestedType(const Name *name,
|
|||||||
|
|
||||||
QSet<ClassOrNamespace *> otherProcessed;
|
QSet<ClassOrNamespace *> otherProcessed;
|
||||||
while (!origin->_symbols.isEmpty() && origin->_symbols[0]->asBlock()) {
|
while (!origin->_symbols.isEmpty() && origin->_symbols[0]->asBlock()) {
|
||||||
if (otherProcessed.contains(origin))
|
if (!Utils::insert(otherProcessed, origin))
|
||||||
break;
|
break;
|
||||||
otherProcessed.insert(origin);
|
|
||||||
origin = origin->parent();
|
origin = origin->parent();
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -1489,9 +1478,8 @@ void ClassOrNamespace::NestedClassInstantiator::instantiate(ClassOrNamespace *en
|
|||||||
{
|
{
|
||||||
if (_alreadyConsideredNestedClassInstantiations.size() >= 3)
|
if (_alreadyConsideredNestedClassInstantiations.size() >= 3)
|
||||||
return;
|
return;
|
||||||
if (_alreadyConsideredNestedClassInstantiations.contains(enclosingTemplateClass))
|
if (!Utils::insert(_alreadyConsideredNestedClassInstantiations, enclosingTemplateClass))
|
||||||
return;
|
return;
|
||||||
_alreadyConsideredNestedClassInstantiations.insert(enclosingTemplateClass);
|
|
||||||
ClassOrNamespace::Table::const_iterator cit = enclosingTemplateClass->_classOrNamespaces.begin();
|
ClassOrNamespace::Table::const_iterator cit = enclosingTemplateClass->_classOrNamespaces.begin();
|
||||||
for (; cit != enclosingTemplateClass->_classOrNamespaces.end(); ++cit) {
|
for (; cit != enclosingTemplateClass->_classOrNamespaces.end(); ++cit) {
|
||||||
const Name *nestedName = cit->first;
|
const Name *nestedName = cit->first;
|
||||||
@@ -1720,9 +1708,7 @@ void CreateBindings::process(Document::Ptr doc)
|
|||||||
return;
|
return;
|
||||||
|
|
||||||
if (Namespace *globalNamespace = doc->globalNamespace()) {
|
if (Namespace *globalNamespace = doc->globalNamespace()) {
|
||||||
if (! _processed.contains(globalNamespace)) {
|
if (Utils::insert(_processed, globalNamespace)) {
|
||||||
_processed.insert(globalNamespace);
|
|
||||||
|
|
||||||
const QList<Document::Include> includes = doc->resolvedIncludes();
|
const QList<Document::Include> includes = doc->resolvedIncludes();
|
||||||
for (const Document::Include &i : includes) {
|
for (const Document::Include &i : includes) {
|
||||||
if (Document::Ptr incl = _snapshot.document(i.resolvedFileName()))
|
if (Document::Ptr incl = _snapshot.document(i.resolvedFileName()))
|
||||||
|
@@ -6,7 +6,6 @@
|
|||||||
#include "LookupContext.h"
|
#include "LookupContext.h"
|
||||||
#include "Overview.h"
|
#include "Overview.h"
|
||||||
#include "DeprecatedGenTemplateInstance.h"
|
#include "DeprecatedGenTemplateInstance.h"
|
||||||
#include "CppRewriter.h"
|
|
||||||
#include "TypeOfExpression.h"
|
#include "TypeOfExpression.h"
|
||||||
|
|
||||||
#include <cplusplus/Control.h>
|
#include <cplusplus/Control.h>
|
||||||
@@ -20,6 +19,8 @@
|
|||||||
#include <cplusplus/NameVisitor.h>
|
#include <cplusplus/NameVisitor.h>
|
||||||
#include <cplusplus/Templates.h>
|
#include <cplusplus/Templates.h>
|
||||||
|
|
||||||
|
#include <utils/algorithm.h>
|
||||||
|
|
||||||
#include <QList>
|
#include <QList>
|
||||||
#include <QDebug>
|
#include <QDebug>
|
||||||
#include <QSet>
|
#include <QSet>
|
||||||
@@ -142,9 +143,8 @@ private:
|
|||||||
for (const LookupItem &it : namedTypeItems) {
|
for (const LookupItem &it : namedTypeItems) {
|
||||||
Symbol *declaration = it.declaration();
|
Symbol *declaration = it.declaration();
|
||||||
if (declaration && declaration->isTypedef()) {
|
if (declaration && declaration->isTypedef()) {
|
||||||
if (visited.contains(declaration))
|
if (!Utils::insert(visited, declaration))
|
||||||
break;
|
break;
|
||||||
visited.insert(declaration);
|
|
||||||
|
|
||||||
// continue working with the typedefed type and scope
|
// continue working with the typedefed type and scope
|
||||||
if (type->type()->asPointerType()) {
|
if (type->type()->asPointerType()) {
|
||||||
|
@@ -5,6 +5,8 @@
|
|||||||
|
|
||||||
#include <cplusplus/Symbols.h>
|
#include <cplusplus/Symbols.h>
|
||||||
|
|
||||||
|
#include <utils/algorithm.h>
|
||||||
|
|
||||||
using namespace CPlusPlus;
|
using namespace CPlusPlus;
|
||||||
|
|
||||||
SnapshotSymbolVisitor::SnapshotSymbolVisitor(const Snapshot &snapshot)
|
SnapshotSymbolVisitor::SnapshotSymbolVisitor(const Snapshot &snapshot)
|
||||||
@@ -20,9 +22,7 @@ void SnapshotSymbolVisitor::accept(Document::Ptr doc)
|
|||||||
|
|
||||||
void SnapshotSymbolVisitor::accept(Document::Ptr doc, QSet<QString> *processed)
|
void SnapshotSymbolVisitor::accept(Document::Ptr doc, QSet<QString> *processed)
|
||||||
{
|
{
|
||||||
if (doc && doc->globalNamespace() && ! processed->contains(doc->filePath().path())) {
|
if (doc && doc->globalNamespace() && Utils::insert(*processed, doc->filePath().path())) {
|
||||||
processed->insert(doc->filePath().path());
|
|
||||||
|
|
||||||
const QList<Document::Include> includes = doc->resolvedIncludes();
|
const QList<Document::Include> includes = doc->resolvedIncludes();
|
||||||
for (const Document::Include &i : includes) {
|
for (const Document::Include &i : includes) {
|
||||||
if (Document::Ptr incl = _snapshot.document(i.resolvedFileName()))
|
if (Document::Ptr incl = _snapshot.document(i.resolvedFileName()))
|
||||||
|
@@ -11,6 +11,8 @@
|
|||||||
#include <cplusplus/Symbol.h>
|
#include <cplusplus/Symbol.h>
|
||||||
#include <cplusplus/TranslationUnit.h>
|
#include <cplusplus/TranslationUnit.h>
|
||||||
|
|
||||||
|
#include <utils/algorithm.h>
|
||||||
|
|
||||||
#include <QSet>
|
#include <QSet>
|
||||||
|
|
||||||
using namespace Utils;
|
using namespace Utils;
|
||||||
@@ -134,9 +136,7 @@ ExpressionAST *TypeOfExpression::expressionAST() const
|
|||||||
void TypeOfExpression::processEnvironment(Document::Ptr doc, Environment *env,
|
void TypeOfExpression::processEnvironment(Document::Ptr doc, Environment *env,
|
||||||
QSet<QString> *processed) const
|
QSet<QString> *processed) const
|
||||||
{
|
{
|
||||||
if (doc && ! processed->contains(doc->filePath().path())) {
|
if (doc && Utils::insert(*processed, doc->filePath().path())) {
|
||||||
processed->insert(doc->filePath().path());
|
|
||||||
|
|
||||||
const QList<Document::Include> includes = doc->resolvedIncludes();
|
const QList<Document::Include> includes = doc->resolvedIncludes();
|
||||||
for (const Document::Include &incl : includes)
|
for (const Document::Include &incl : includes)
|
||||||
processEnvironment(m_snapshot.document(incl.resolvedFileName()), env, processed);
|
processEnvironment(m_snapshot.document(incl.resolvedFileName()), env, processed);
|
||||||
|
@@ -373,10 +373,8 @@ const QSet<PluginSpec *> PluginManager::pluginsRequiredByPlugin(PluginSpec *spec
|
|||||||
if (depIt.key().type != PluginDependency::Required)
|
if (depIt.key().type != PluginDependency::Required)
|
||||||
continue;
|
continue;
|
||||||
PluginSpec *depSpec = depIt.value();
|
PluginSpec *depSpec = depIt.value();
|
||||||
if (!recursiveDependencies.contains(depSpec)) {
|
if (Utils::insert(recursiveDependencies, depSpec))
|
||||||
recursiveDependencies.insert(depSpec);
|
|
||||||
queue.push(depSpec);
|
queue.push(depSpec);
|
||||||
}
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
recursiveDependencies.remove(spec);
|
recursiveDependencies.remove(spec);
|
||||||
|
@@ -656,14 +656,12 @@ void LinkPrivate::loadQmldirComponents(ObjectValue *import,
|
|||||||
QSet<QString> importedTypes;
|
QSet<QString> importedTypes;
|
||||||
const auto components = libraryInfo.components();
|
const auto components = libraryInfo.components();
|
||||||
for (const QmlDirParser::Component &component : components) {
|
for (const QmlDirParser::Component &component : components) {
|
||||||
if (importedTypes.contains(component.typeName))
|
|
||||||
continue;
|
|
||||||
|
|
||||||
ComponentVersion componentVersion(component.majorVersion, component.minorVersion);
|
ComponentVersion componentVersion(component.majorVersion, component.minorVersion);
|
||||||
if (version < componentVersion)
|
if (version < componentVersion)
|
||||||
continue;
|
continue;
|
||||||
|
|
||||||
importedTypes.insert(component.typeName);
|
if (!Utils::insert(importedTypes, component.typeName))
|
||||||
|
continue;
|
||||||
if (Document::Ptr importedDoc = m_snapshot.document(
|
if (Document::Ptr importedDoc = m_snapshot.document(
|
||||||
libraryPath.pathAppended(component.fileName))) {
|
libraryPath.pathAppended(component.fileName))) {
|
||||||
if (ObjectValue *v = importedDoc->bind()->rootObjectValue())
|
if (ObjectValue *v = importedDoc->bind()->rootObjectValue())
|
||||||
|
@@ -734,10 +734,9 @@ static void findNewImplicitImports(const Document::Ptr &doc,
|
|||||||
// scan files that could be implicitly imported
|
// scan files that could be implicitly imported
|
||||||
// it's important we also do this for JS files, otherwise the isEmpty check will fail
|
// it's important we also do this for JS files, otherwise the isEmpty check will fail
|
||||||
if (snapshot.documentsInDirectory(doc->path()).isEmpty()) {
|
if (snapshot.documentsInDirectory(doc->path()).isEmpty()) {
|
||||||
if (!scannedPaths->contains(doc->path())) {
|
if (Utils::insert(*scannedPaths, doc->path())) {
|
||||||
*importedFiles += filesInDirectoryForLanguages(doc->path(),
|
*importedFiles += filesInDirectoryForLanguages(doc->path(),
|
||||||
doc->language().companionLanguages());
|
doc->language().companionLanguages());
|
||||||
scannedPaths->insert(doc->path());
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@@ -757,11 +756,10 @@ static void findNewFileImports(const Document::Ptr &doc,
|
|||||||
*importedFiles += importPath;
|
*importedFiles += importPath;
|
||||||
} else if (import.type() == ImportType::Directory) {
|
} else if (import.type() == ImportType::Directory) {
|
||||||
if (snapshot.documentsInDirectory(importPath).isEmpty()) {
|
if (snapshot.documentsInDirectory(importPath).isEmpty()) {
|
||||||
if (!scannedPaths->contains(importPath)) {
|
if (Utils::insert(*scannedPaths, importPath)) {
|
||||||
*importedFiles
|
*importedFiles
|
||||||
+= filesInDirectoryForLanguages(importPath,
|
+= filesInDirectoryForLanguages(importPath,
|
||||||
doc->language().companionLanguages());
|
doc->language().companionLanguages());
|
||||||
scannedPaths->insert(importPath);
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
} else if (import.type() == ImportType::QrcFile) {
|
} else if (import.type() == ImportType::QrcFile) {
|
||||||
@@ -890,10 +888,9 @@ static bool findNewQmlLibraryInPath(const Utils::FilePath &path,
|
|||||||
if (!component.fileName.isEmpty()) {
|
if (!component.fileName.isEmpty()) {
|
||||||
const FilePath componentFile = path.pathAppended(component.fileName);
|
const FilePath componentFile = path.pathAppended(component.fileName);
|
||||||
const FilePath path = componentFile.absolutePath().cleanPath();
|
const FilePath path = componentFile.absolutePath().cleanPath();
|
||||||
if (!scannedPaths->contains(path)) {
|
if (Utils::insert(*scannedPaths, path)) {
|
||||||
*importedFiles += filesInDirectoryForLanguages(path, Dialect(Dialect::AnyLanguage)
|
*importedFiles += filesInDirectoryForLanguages(path, Dialect(Dialect::AnyLanguage)
|
||||||
.companionLanguages());
|
.companionLanguages());
|
||||||
scannedPaths->insert(path);
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@@ -1110,10 +1107,9 @@ void ModelManagerInterface::importScanAsync(QPromise<void> &promise, const Worki
|
|||||||
QMutexLocker l(&modelManager->m_mutex);
|
QMutexLocker l(&modelManager->m_mutex);
|
||||||
for (const auto &path : paths) {
|
for (const auto &path : paths) {
|
||||||
Utils::FilePath cPath = path.path().cleanPath();
|
Utils::FilePath cPath = path.path().cleanPath();
|
||||||
if (!forceRescan && modelManager->m_scannedPaths.contains(cPath))
|
if (!forceRescan && !Utils::insert(modelManager->m_scannedPaths, cPath))
|
||||||
continue;
|
continue;
|
||||||
pathsToScan.append({cPath, 0, path.language()});
|
pathsToScan.append({cPath, 0, path.language()});
|
||||||
modelManager->m_scannedPaths.insert(cPath);
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
const int maxScanDepth = 5;
|
const int maxScanDepth = 5;
|
||||||
|
@@ -1437,4 +1437,13 @@ void addToHash(QHash<Key, T> *result, const QHash<Key, T> &additionalContents)
|
|||||||
result->insert(additionalContents);
|
result->insert(additionalContents);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// Workaround for missing information from QSet::insert()
|
||||||
|
// Return type could be a pair like for std::set, but we never use the iterator anyway.
|
||||||
|
template<typename T, typename U> [[nodiscard]] bool insert(QSet<T> &s, const U &v)
|
||||||
|
{
|
||||||
|
const int oldSize = s.size();
|
||||||
|
s.insert(v);
|
||||||
|
return s.size() > oldSize;
|
||||||
|
}
|
||||||
|
|
||||||
} // namespace Utils
|
} // namespace Utils
|
||||||
|
@@ -3,7 +3,7 @@
|
|||||||
|
|
||||||
#include "namevaluesdialog.h"
|
#include "namevaluesdialog.h"
|
||||||
|
|
||||||
#include "environment.h"
|
#include "algorithm.h"
|
||||||
#include "hostosinfo.h"
|
#include "hostosinfo.h"
|
||||||
#include "utilstr.h"
|
#include "utilstr.h"
|
||||||
|
|
||||||
@@ -29,10 +29,8 @@ static EnvironmentItems cleanUp(const EnvironmentItems &items)
|
|||||||
const QString &itemName = item.name;
|
const QString &itemName = item.name;
|
||||||
QString emptyName = itemName;
|
QString emptyName = itemName;
|
||||||
emptyName.remove(QLatin1Char(' '));
|
emptyName.remove(QLatin1Char(' '));
|
||||||
if (!emptyName.isEmpty() && !uniqueSet.contains(itemName)) {
|
if (!emptyName.isEmpty() && Utils::insert(uniqueSet, itemName))
|
||||||
uniqueItems.prepend(item);
|
uniqueItems.prepend(item);
|
||||||
uniqueSet.insert(itemName);
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
return uniqueItems;
|
return uniqueItems;
|
||||||
}
|
}
|
||||||
|
@@ -10,6 +10,7 @@
|
|||||||
#include "testtreemodel.h"
|
#include "testtreemodel.h"
|
||||||
|
|
||||||
#include <projectexplorer/projectexplorericons.h>
|
#include <projectexplorer/projectexplorericons.h>
|
||||||
|
#include <utils/algorithm.h>
|
||||||
#include <utils/qtcassert.h>
|
#include <utils/qtcassert.h>
|
||||||
|
|
||||||
#include <QFontMetrics>
|
#include <QFontMetrics>
|
||||||
@@ -202,10 +203,7 @@ bool TestResultItem::updateDescendantTypes(ResultType t)
|
|||||||
if (t == ResultType::TestStart || t == ResultType::TestEnd) // these are special
|
if (t == ResultType::TestStart || t == ResultType::TestEnd) // these are special
|
||||||
return false;
|
return false;
|
||||||
|
|
||||||
if (m_descendantsTypes.contains(t))
|
return Utils::insert(m_descendantsTypes, t);
|
||||||
return false;
|
|
||||||
m_descendantsTypes.insert(t);
|
|
||||||
return true;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
bool TestResultItem::descendantTypesContainsAnyOf(const QSet<ResultType> &types) const
|
bool TestResultItem::descendantTypesContainsAnyOf(const QSet<ResultType> &types) const
|
||||||
@@ -467,8 +465,7 @@ void TestResultFilterModel::enableAllResultTypes(bool enabled)
|
|||||||
|
|
||||||
void TestResultFilterModel::toggleTestResultType(ResultType type)
|
void TestResultFilterModel::toggleTestResultType(ResultType type)
|
||||||
{
|
{
|
||||||
if (m_enabled.contains(type)) {
|
if (m_enabled.remove(type)) {
|
||||||
m_enabled.remove(type);
|
|
||||||
if (type == ResultType::MessageInternal)
|
if (type == ResultType::MessageInternal)
|
||||||
m_enabled.remove(ResultType::TestEnd);
|
m_enabled.remove(ResultType::TestEnd);
|
||||||
if (type == ResultType::MessageDebug)
|
if (type == ResultType::MessageDebug)
|
||||||
|
@@ -18,6 +18,7 @@
|
|||||||
#include <texteditor/texteditorconstants.h>
|
#include <texteditor/texteditorconstants.h>
|
||||||
#include <texteditor/texteditorsettings.h>
|
#include <texteditor/texteditorsettings.h>
|
||||||
|
|
||||||
|
#include <utils/algorithm.h>
|
||||||
#include <utils/fadingindicator.h>
|
#include <utils/fadingindicator.h>
|
||||||
#include <utils/fileutils.h>
|
#include <utils/fileutils.h>
|
||||||
#include <utils/qtcassert.h>
|
#include <utils/qtcassert.h>
|
||||||
@@ -222,9 +223,8 @@ bool BinEditorWidget::requestDataAt(qint64 pos) const
|
|||||||
it = m_data.find(block);
|
it = m_data.find(block);
|
||||||
if (it != m_data.end())
|
if (it != m_data.end())
|
||||||
return true;
|
return true;
|
||||||
if (m_requests.contains(block))
|
if (!Utils::insert(m_requests, block))
|
||||||
return false;
|
return false;
|
||||||
m_requests.insert(block);
|
|
||||||
d->fetchData((m_baseAddr / m_blockSize + block) * m_blockSize);
|
d->fetchData((m_baseAddr / m_blockSize + block) * m_blockSize);
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
@@ -1301,9 +1301,8 @@ void CMakeBuildSystem::runCTest()
|
|||||||
std::function<QJsonObject(int)> findAncestor = [&](int index){
|
std::function<QJsonObject(int)> findAncestor = [&](int index){
|
||||||
const QJsonObject node = nodes.at(index).toObject();
|
const QJsonObject node = nodes.at(index).toObject();
|
||||||
const int parent = node.value("parent").toInt(-1);
|
const int parent = node.value("parent").toInt(-1);
|
||||||
if (seen.contains(parent) || parent < 0)
|
if (parent < 0 || !Utils::insert(seen, parent))
|
||||||
return node;
|
return node;
|
||||||
seen << parent;
|
|
||||||
return findAncestor(parent);
|
return findAncestor(parent);
|
||||||
};
|
};
|
||||||
const QJsonObject btRef = findAncestor(bt);
|
const QJsonObject btRef = findAncestor(bt);
|
||||||
|
@@ -470,10 +470,8 @@ void DocumentModelPrivate::removeAllSuspendedEntries(PinnedFileRemovalPolicy pin
|
|||||||
QSet<QString> displayNames;
|
QSet<QString> displayNames;
|
||||||
for (DocumentModel::Entry *entry : std::as_const(d->m_entries)) {
|
for (DocumentModel::Entry *entry : std::as_const(d->m_entries)) {
|
||||||
const QString displayName = entry->plainDisplayName();
|
const QString displayName = entry->plainDisplayName();
|
||||||
if (displayNames.contains(displayName))
|
if (Utils::insert(displayNames, displayName))
|
||||||
continue;
|
d->disambiguateDisplayNames(entry);
|
||||||
displayNames.insert(displayName);
|
|
||||||
d->disambiguateDisplayNames(entry);
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@@ -9,6 +9,7 @@
|
|||||||
#include "../coreplugintr.h"
|
#include "../coreplugintr.h"
|
||||||
#include "../idocument.h"
|
#include "../idocument.h"
|
||||||
|
|
||||||
|
#include <utils/algorithm.h>
|
||||||
#include <utils/fsengine/fileiconprovider.h>
|
#include <utils/fsengine/fileiconprovider.h>
|
||||||
#include <utils/hostosinfo.h>
|
#include <utils/hostosinfo.h>
|
||||||
#include <utils/qtcassert.h>
|
#include <utils/qtcassert.h>
|
||||||
@@ -219,9 +220,8 @@ void OpenEditorsWindow::addItem(DocumentModel::Entry *entry,
|
|||||||
QSet<const DocumentModel::Entry *> &entriesDone,
|
QSet<const DocumentModel::Entry *> &entriesDone,
|
||||||
EditorView *view)
|
EditorView *view)
|
||||||
{
|
{
|
||||||
if (entriesDone.contains(entry))
|
if (!Utils::insert(entriesDone, entry))
|
||||||
return;
|
return;
|
||||||
entriesDone.insert(entry);
|
|
||||||
QString title = entry->displayName();
|
QString title = entry->displayName();
|
||||||
QTC_ASSERT(!title.isEmpty(), return);
|
QTC_ASSERT(!title.isEmpty(), return);
|
||||||
auto item = new QTreeWidgetItem();
|
auto item = new QTreeWidgetItem();
|
||||||
|
@@ -7,6 +7,7 @@
|
|||||||
|
|
||||||
#include <debugger/analyzer/diagnosticlocation.h>
|
#include <debugger/analyzer/diagnosticlocation.h>
|
||||||
|
|
||||||
|
#include <utils/algorithm.h>
|
||||||
#include <utils/fsengine/fileiconprovider.h>
|
#include <utils/fsengine/fileiconprovider.h>
|
||||||
#include <utils/utilsicons.h>
|
#include <utils/utilsicons.h>
|
||||||
|
|
||||||
@@ -99,12 +100,10 @@ void DiagnosticsModel::clear()
|
|||||||
|
|
||||||
void DiagnosticsModel::add(const Diagnostic &diagnostic)
|
void DiagnosticsModel::add(const Diagnostic &diagnostic)
|
||||||
{
|
{
|
||||||
if (m_diagnostics.contains(diagnostic))
|
if (!Utils::insert(m_diagnostics, diagnostic))
|
||||||
return;
|
return;
|
||||||
|
|
||||||
const auto hasData = !m_diagnostics.isEmpty();
|
if (m_diagnostics.size() == 1)
|
||||||
m_diagnostics.insert(diagnostic);
|
|
||||||
if (!hasData)
|
|
||||||
emit hasDataChanged(true);
|
emit hasDataChanged(true);
|
||||||
|
|
||||||
const QString filePath = diagnostic.fileName.toString();
|
const QString filePath = diagnostic.fileName.toString();
|
||||||
|
@@ -73,9 +73,7 @@ protected:
|
|||||||
{
|
{
|
||||||
if (!doc)
|
if (!doc)
|
||||||
return;
|
return;
|
||||||
if (!processed->contains(doc->globalNamespace())) {
|
if (Utils::insert(*processed, doc->globalNamespace())) {
|
||||||
processed->insert(doc->globalNamespace());
|
|
||||||
|
|
||||||
const QList<Document::Include> includes = doc->resolvedIncludes();
|
const QList<Document::Include> includes = doc->resolvedIncludes();
|
||||||
for (const Document::Include &i : includes)
|
for (const Document::Include &i : includes)
|
||||||
process(_snapshot.document(i.resolvedFileName()), processed);
|
process(_snapshot.document(i.resolvedFileName()), processed);
|
||||||
@@ -806,8 +804,7 @@ bool CheckSymbols::hasVirtualDestructor(ClassOrNamespace *binding) const
|
|||||||
|
|
||||||
while (!todo.isEmpty()) {
|
while (!todo.isEmpty()) {
|
||||||
ClassOrNamespace *b = todo.takeFirst();
|
ClassOrNamespace *b = todo.takeFirst();
|
||||||
if (b && !processed.contains(b)) {
|
if (b && Utils::insert(processed, b)) {
|
||||||
processed.insert(b);
|
|
||||||
const QList<Symbol *> symbols = b->symbols();
|
const QList<Symbol *> symbols = b->symbols();
|
||||||
for (Symbol *s : symbols) {
|
for (Symbol *s : symbols) {
|
||||||
if (Class *k = s->asClass()) {
|
if (Class *k = s->asClass()) {
|
||||||
|
@@ -20,6 +20,7 @@
|
|||||||
#include <texteditor/texteditorsettings.h>
|
#include <texteditor/texteditorsettings.h>
|
||||||
#include <texteditor/completionsettings.h>
|
#include <texteditor/completionsettings.h>
|
||||||
|
|
||||||
|
#include <utils/algorithm.h>
|
||||||
#include <utils/mimeutils.h>
|
#include <utils/mimeutils.h>
|
||||||
#include <utils/qtcassert.h>
|
#include <utils/qtcassert.h>
|
||||||
#include <utils/textutils.h>
|
#include <utils/textutils.h>
|
||||||
@@ -1459,9 +1460,8 @@ bool InternalCppCompletionAssistProcessor::globalCompletion(Scope *currentScope)
|
|||||||
|
|
||||||
QSet<ClassOrNamespace *> processed;
|
QSet<ClassOrNamespace *> processed;
|
||||||
for (; currentBinding; currentBinding = currentBinding->parent()) {
|
for (; currentBinding; currentBinding = currentBinding->parent()) {
|
||||||
if (processed.contains(currentBinding))
|
if (!Utils::insert(processed, currentBinding))
|
||||||
break;
|
break;
|
||||||
processed.insert(currentBinding);
|
|
||||||
|
|
||||||
const QList<ClassOrNamespace*> usings = currentBinding->usings();
|
const QList<ClassOrNamespace*> usings = currentBinding->usings();
|
||||||
for (ClassOrNamespace* u : usings)
|
for (ClassOrNamespace* u : usings)
|
||||||
@@ -1598,10 +1598,9 @@ void InternalCppCompletionAssistProcessor::completeNamespace(ClassOrNamespace *b
|
|||||||
|
|
||||||
while (!bindingsToVisit.isEmpty()) {
|
while (!bindingsToVisit.isEmpty()) {
|
||||||
ClassOrNamespace *binding = bindingsToVisit.takeFirst();
|
ClassOrNamespace *binding = bindingsToVisit.takeFirst();
|
||||||
if (!binding || bindingsVisited.contains(binding))
|
if (!binding || !Utils::insert(bindingsVisited, binding))
|
||||||
continue;
|
continue;
|
||||||
|
|
||||||
bindingsVisited.insert(binding);
|
|
||||||
bindingsToVisit += binding->usings();
|
bindingsToVisit += binding->usings();
|
||||||
|
|
||||||
QList<Scope *> scopesToVisit;
|
QList<Scope *> scopesToVisit;
|
||||||
@@ -1619,11 +1618,9 @@ void InternalCppCompletionAssistProcessor::completeNamespace(ClassOrNamespace *b
|
|||||||
|
|
||||||
while (!scopesToVisit.isEmpty()) {
|
while (!scopesToVisit.isEmpty()) {
|
||||||
Scope *scope = scopesToVisit.takeFirst();
|
Scope *scope = scopesToVisit.takeFirst();
|
||||||
if (!scope || scopesVisited.contains(scope))
|
if (!scope || !Utils::insert(scopesVisited, scope))
|
||||||
continue;
|
continue;
|
||||||
|
|
||||||
scopesVisited.insert(scope);
|
|
||||||
|
|
||||||
for (Scope::iterator it = scope->memberBegin(); it != scope->memberEnd(); ++it) {
|
for (Scope::iterator it = scope->memberBegin(); it != scope->memberEnd(); ++it) {
|
||||||
Symbol *member = *it;
|
Symbol *member = *it;
|
||||||
addCompletionItem(member);
|
addCompletionItem(member);
|
||||||
@@ -1640,10 +1637,9 @@ void InternalCppCompletionAssistProcessor::completeClass(ClassOrNamespace *b, bo
|
|||||||
|
|
||||||
while (!bindingsToVisit.isEmpty()) {
|
while (!bindingsToVisit.isEmpty()) {
|
||||||
ClassOrNamespace *binding = bindingsToVisit.takeFirst();
|
ClassOrNamespace *binding = bindingsToVisit.takeFirst();
|
||||||
if (!binding || bindingsVisited.contains(binding))
|
if (!binding || !Utils::insert(bindingsVisited, binding))
|
||||||
continue;
|
continue;
|
||||||
|
|
||||||
bindingsVisited.insert(binding);
|
|
||||||
bindingsToVisit += binding->usings();
|
bindingsToVisit += binding->usings();
|
||||||
|
|
||||||
QList<Scope *> scopesToVisit;
|
QList<Scope *> scopesToVisit;
|
||||||
@@ -1663,11 +1659,9 @@ void InternalCppCompletionAssistProcessor::completeClass(ClassOrNamespace *b, bo
|
|||||||
|
|
||||||
while (!scopesToVisit.isEmpty()) {
|
while (!scopesToVisit.isEmpty()) {
|
||||||
Scope *scope = scopesToVisit.takeFirst();
|
Scope *scope = scopesToVisit.takeFirst();
|
||||||
if (!scope || scopesVisited.contains(scope))
|
if (!scope || !Utils::insert(scopesVisited, scope))
|
||||||
continue;
|
continue;
|
||||||
|
|
||||||
scopesVisited.insert(scope);
|
|
||||||
|
|
||||||
if (staticLookup)
|
if (staticLookup)
|
||||||
addCompletionItem(scope, InjectedClassNameOrder); // add a completion item for the injected class name.
|
addCompletionItem(scope, InjectedClassNameOrder); // add a completion item for the injected class name.
|
||||||
|
|
||||||
@@ -1737,9 +1731,7 @@ bool InternalCppCompletionAssistProcessor::completeQtMethod(const QList<LookupIt
|
|||||||
todo.append(b);
|
todo.append(b);
|
||||||
while (!todo.isEmpty()) {
|
while (!todo.isEmpty()) {
|
||||||
ClassOrNamespace *binding = todo.takeLast();
|
ClassOrNamespace *binding = todo.takeLast();
|
||||||
if (!processed.contains(binding)) {
|
if (Utils::insert(processed, binding)) {
|
||||||
processed.insert(binding);
|
|
||||||
|
|
||||||
const QList<Symbol *> symbols = binding->symbols();
|
const QList<Symbol *> symbols = binding->symbols();
|
||||||
for (Symbol *s : symbols)
|
for (Symbol *s : symbols)
|
||||||
if (Class *clazz = s->asClass())
|
if (Class *clazz = s->asClass())
|
||||||
@@ -1862,11 +1854,9 @@ void InternalCppCompletionAssistProcessor::addMacros_helper(const Snapshot &snap
|
|||||||
{
|
{
|
||||||
Document::Ptr doc = snapshot.document(filePath);
|
Document::Ptr doc = snapshot.document(filePath);
|
||||||
|
|
||||||
if (!doc || processed->contains(doc->filePath()))
|
if (!doc || !Utils::insert(*processed, doc->filePath()))
|
||||||
return;
|
return;
|
||||||
|
|
||||||
processed->insert(doc->filePath());
|
|
||||||
|
|
||||||
const QList<Document::Include> includes = doc->resolvedIncludes();
|
const QList<Document::Include> includes = doc->resolvedIncludes();
|
||||||
for (const Document::Include &i : includes)
|
for (const Document::Include &i : includes)
|
||||||
addMacros_helper(snapshot, i.resolvedFileName(), processed, definedMacros);
|
addMacros_helper(snapshot, i.resolvedFileName(), processed, definedMacros);
|
||||||
|
@@ -17,6 +17,7 @@
|
|||||||
#include <cplusplus/SimpleLexer.h>
|
#include <cplusplus/SimpleLexer.h>
|
||||||
#include <cplusplus/TypeOfExpression.h>
|
#include <cplusplus/TypeOfExpression.h>
|
||||||
#include <texteditor/textdocumentlayout.h>
|
#include <texteditor/textdocumentlayout.h>
|
||||||
|
#include <utils/algorithm.h>
|
||||||
#include <utils/textutils.h>
|
#include <utils/textutils.h>
|
||||||
#include <utils/qtcassert.h>
|
#include <utils/qtcassert.h>
|
||||||
|
|
||||||
@@ -181,9 +182,7 @@ Class *VirtualFunctionHelper::staticClassOfFunctionCallExpression_internal() con
|
|||||||
Link findMacroLink_helper(const QByteArray &name, Document::Ptr doc, const Snapshot &snapshot,
|
Link findMacroLink_helper(const QByteArray &name, Document::Ptr doc, const Snapshot &snapshot,
|
||||||
QSet<QString> *processed)
|
QSet<QString> *processed)
|
||||||
{
|
{
|
||||||
if (doc && !name.startsWith('<') && !processed->contains(doc->filePath().path())) {
|
if (doc && !name.startsWith('<') && Utils::insert(*processed, doc->filePath().path())) {
|
||||||
processed->insert(doc->filePath().path());
|
|
||||||
|
|
||||||
for (const Macro ¯o : doc->definedMacros()) {
|
for (const Macro ¯o : doc->definedMacros()) {
|
||||||
if (macro.name() == name) {
|
if (macro.name() == name) {
|
||||||
Link link;
|
Link link;
|
||||||
|
@@ -60,6 +60,7 @@
|
|||||||
|
|
||||||
#include <texteditor/textdocument.h>
|
#include <texteditor/textdocument.h>
|
||||||
|
|
||||||
|
#include <utils/algorithm.h>
|
||||||
#include <utils/environment.h>
|
#include <utils/environment.h>
|
||||||
#include <utils/fileutils.h>
|
#include <utils/fileutils.h>
|
||||||
#include <utils/hostosinfo.h>
|
#include <utils/hostosinfo.h>
|
||||||
@@ -1060,10 +1061,8 @@ static void addUnique(const Macros &newMacros, Macros ¯os,
|
|||||||
QSet<ProjectExplorer::Macro> &alreadyIn)
|
QSet<ProjectExplorer::Macro> &alreadyIn)
|
||||||
{
|
{
|
||||||
for (const ProjectExplorer::Macro ¯o : newMacros) {
|
for (const ProjectExplorer::Macro ¯o : newMacros) {
|
||||||
if (!alreadyIn.contains(macro)) {
|
if (Utils::insert(alreadyIn, macro))
|
||||||
macros += macro;
|
macros += macro;
|
||||||
alreadyIn.insert(macro);
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -1949,9 +1948,8 @@ void CppModelManager::GC()
|
|||||||
const FilePath filePath = todo.last();
|
const FilePath filePath = todo.last();
|
||||||
todo.removeLast();
|
todo.removeLast();
|
||||||
|
|
||||||
if (reachableFiles.contains(filePath))
|
if (!Utils::insert(reachableFiles, filePath))
|
||||||
continue;
|
continue;
|
||||||
reachableFiles.insert(filePath);
|
|
||||||
|
|
||||||
if (Document::Ptr doc = currentSnapshot.document(filePath))
|
if (Document::Ptr doc = currentSnapshot.document(filePath))
|
||||||
todo += doc->includedFiles();
|
todo += doc->includedFiles();
|
||||||
|
@@ -8342,14 +8342,13 @@ private:
|
|||||||
QList<Snapshot::IncludeLocation>
|
QList<Snapshot::IncludeLocation>
|
||||||
includeLocationsOfDocument = refactoring.snapshot().includeLocationsOfDocument(filePath);
|
includeLocationsOfDocument = refactoring.snapshot().includeLocationsOfDocument(filePath);
|
||||||
for (Snapshot::IncludeLocation &loc : includeLocationsOfDocument) {
|
for (Snapshot::IncludeLocation &loc : includeLocationsOfDocument) {
|
||||||
if (m_processed.contains(loc.first))
|
if (!Utils::insert(m_processed, loc.first))
|
||||||
continue;
|
continue;
|
||||||
|
|
||||||
CppRefactoringFilePtr file = refactoring.file(loc.first->filePath());
|
CppRefactoringFilePtr file = refactoring.file(loc.first->filePath());
|
||||||
const bool noGlobalUsing = refactorFile(file,
|
const bool noGlobalUsing = refactorFile(file,
|
||||||
refactoring.snapshot(),
|
refactoring.snapshot(),
|
||||||
file->position(loc.second, 1));
|
file->position(loc.second, 1));
|
||||||
m_processed.insert(loc.first);
|
|
||||||
if (noGlobalUsing)
|
if (noGlobalUsing)
|
||||||
processIncludes(refactoring, loc.first->filePath());
|
processIncludes(refactoring, loc.first->filePath());
|
||||||
}
|
}
|
||||||
|
@@ -9,6 +9,7 @@
|
|||||||
|
|
||||||
#include <coreplugin/editormanager/editormanager.h>
|
#include <coreplugin/editormanager/editormanager.h>
|
||||||
|
|
||||||
|
#include <utils/algorithm.h>
|
||||||
#include <utils/filepath.h>
|
#include <utils/filepath.h>
|
||||||
#include <utils/hostosinfo.h>
|
#include <utils/hostosinfo.h>
|
||||||
#include <utils/qtcassert.h>
|
#include <utils/qtcassert.h>
|
||||||
@@ -365,11 +366,9 @@ void CppSourceProcessor::mergeEnvironment(Document::Ptr doc)
|
|||||||
|
|
||||||
const QString fn = doc->filePath().path();
|
const QString fn = doc->filePath().path();
|
||||||
|
|
||||||
if (m_processed.contains(fn))
|
if (!Utils::insert(m_processed, fn))
|
||||||
return;
|
return;
|
||||||
|
|
||||||
m_processed.insert(fn);
|
|
||||||
|
|
||||||
const QList<Document::Include> includes = doc->resolvedIncludes();
|
const QList<Document::Include> includes = doc->resolvedIncludes();
|
||||||
for (const Document::Include &incl : includes) {
|
for (const Document::Include &incl : includes) {
|
||||||
const FilePath includedFile = incl.resolvedFileName();
|
const FilePath includedFile = incl.resolvedFileName();
|
||||||
|
@@ -5,6 +5,8 @@
|
|||||||
|
|
||||||
#include <cplusplus/FindUsages.h>
|
#include <cplusplus/FindUsages.h>
|
||||||
|
|
||||||
|
#include <utils/algorithm.h>
|
||||||
|
|
||||||
using namespace CPlusPlus;
|
using namespace CPlusPlus;
|
||||||
using namespace Utils;
|
using namespace Utils;
|
||||||
|
|
||||||
@@ -170,11 +172,9 @@ void TypeHierarchyBuilder::buildDerived(const std::optional<QFuture<void>> &futu
|
|||||||
QHash<QString, QHash<QString, QString>> &cache)
|
QHash<QString, QHash<QString, QString>> &cache)
|
||||||
{
|
{
|
||||||
Symbol *symbol = typeHierarchy->_symbol;
|
Symbol *symbol = typeHierarchy->_symbol;
|
||||||
if (_visited.contains(symbol))
|
if (!Utils::insert(_visited, symbol))
|
||||||
return;
|
return;
|
||||||
|
|
||||||
_visited.insert(symbol);
|
|
||||||
|
|
||||||
const QString &symbolName = _overview.prettyName(LookupContext::fullyQualifiedName(symbol));
|
const QString &symbolName = _overview.prettyName(LookupContext::fullyQualifiedName(symbol));
|
||||||
DerivedHierarchyVisitor visitor(symbolName, cache);
|
DerivedHierarchyVisitor visitor(symbolName, cache);
|
||||||
|
|
||||||
|
@@ -45,6 +45,7 @@
|
|||||||
#include <texteditor/textmark.h>
|
#include <texteditor/textmark.h>
|
||||||
#include <texteditor/typingsettings.h>
|
#include <texteditor/typingsettings.h>
|
||||||
|
|
||||||
|
#include <utils/algorithm.h>
|
||||||
#include <utils/aspects.h>
|
#include <utils/aspects.h>
|
||||||
#include <utils/fancylineedit.h>
|
#include <utils/fancylineedit.h>
|
||||||
#include <utils/hostosinfo.h>
|
#include <utils/hostosinfo.h>
|
||||||
@@ -944,9 +945,8 @@ public:
|
|||||||
QString found = sel.selectedText();
|
QString found = sel.selectedText();
|
||||||
// Only add "real" completions.
|
// Only add "real" completions.
|
||||||
if (found.startsWith(needle)
|
if (found.startsWith(needle)
|
||||||
&& !seen.contains(found)
|
&& sel.anchor() != basePosition
|
||||||
&& sel.anchor() != basePosition) {
|
&& Utils::insert(seen, found)) {
|
||||||
seen.insert(found);
|
|
||||||
auto item = new FakeVimAssistProposalItem(m_provider);
|
auto item = new FakeVimAssistProposalItem(m_provider);
|
||||||
item->setText(found);
|
item->setText(found);
|
||||||
items.append(item);
|
items.append(item);
|
||||||
|
@@ -269,11 +269,9 @@ void GlslEditorWidget::updateDocumentNow()
|
|||||||
for (const DiagnosticMessage &m : messages) {
|
for (const DiagnosticMessage &m : messages) {
|
||||||
if (! m.line())
|
if (! m.line())
|
||||||
continue;
|
continue;
|
||||||
else if (errors.contains(m.line()))
|
if (!Utils::insert(errors, m.line()))
|
||||||
continue;
|
continue;
|
||||||
|
|
||||||
errors.insert(m.line());
|
|
||||||
|
|
||||||
QTextCursor cursor(document()->findBlockByNumber(m.line() - 1));
|
QTextCursor cursor(document()->findBlockByNumber(m.line() - 1));
|
||||||
cursor.movePosition(QTextCursor::EndOfBlock, QTextCursor::KeepAnchor);
|
cursor.movePosition(QTextCursor::EndOfBlock, QTextCursor::KeepAnchor);
|
||||||
|
|
||||||
|
@@ -10,6 +10,7 @@
|
|||||||
#include <texteditor/syntaxhighlighter.h>
|
#include <texteditor/syntaxhighlighter.h>
|
||||||
#include <texteditor/texteditor.h>
|
#include <texteditor/texteditor.h>
|
||||||
#include <texteditor/texteditorsettings.h>
|
#include <texteditor/texteditorsettings.h>
|
||||||
|
#include <utils/algorithm.h>
|
||||||
#include <utils/mimeutils.h>
|
#include <utils/mimeutils.h>
|
||||||
|
|
||||||
#include <QTextDocument>
|
#include <QTextDocument>
|
||||||
@@ -165,9 +166,8 @@ void SemanticTokenSupport::updateSemanticTokensImpl(TextDocument *textDocument,
|
|||||||
|
|
||||||
void SemanticTokenSupport::queueDocumentReload(TextEditor::TextDocument *doc)
|
void SemanticTokenSupport::queueDocumentReload(TextEditor::TextDocument *doc)
|
||||||
{
|
{
|
||||||
if (m_docReloadQueue.contains(doc))
|
if (!Utils::insert(m_docReloadQueue, doc))
|
||||||
return;
|
return;
|
||||||
m_docReloadQueue << doc;
|
|
||||||
connect(
|
connect(
|
||||||
m_client,
|
m_client,
|
||||||
&Client::initialized,
|
&Client::initialized,
|
||||||
|
@@ -13,6 +13,8 @@
|
|||||||
|
|
||||||
#include <texteditor/texteditorconstants.h>
|
#include <texteditor/texteditorconstants.h>
|
||||||
|
|
||||||
|
#include <utils/algorithm.h>
|
||||||
|
|
||||||
#include <QAction>
|
#include <QAction>
|
||||||
#include <QEvent>
|
#include <QEvent>
|
||||||
|
|
||||||
@@ -55,8 +57,7 @@ bool ActionMacroHandler::executeEvent(const MacroEvent ¯oEvent)
|
|||||||
|
|
||||||
void ActionMacroHandler::registerCommand(Id id)
|
void ActionMacroHandler::registerCommand(Id id)
|
||||||
{
|
{
|
||||||
if (!m_commandIds.contains(id)) {
|
if (Utils::insert(m_commandIds, id)) {
|
||||||
m_commandIds.insert(id);
|
|
||||||
const Command *command = ActionManager::command(id);
|
const Command *command = ActionManager::command(id);
|
||||||
if (QAction *action = command->action()) {
|
if (QAction *action = command->action()) {
|
||||||
connect(action, &QAction::triggered, this, [this, id, command]() {
|
connect(action, &QAction::triggered, this, [this, id, command]() {
|
||||||
|
@@ -21,6 +21,7 @@
|
|||||||
#include <projectexplorer/projectmanager.h>
|
#include <projectexplorer/projectmanager.h>
|
||||||
#include <projectexplorer/projectnodes.h>
|
#include <projectexplorer/projectnodes.h>
|
||||||
|
|
||||||
|
#include <utils/algorithm.h>
|
||||||
#include <utils/mimeutils.h>
|
#include <utils/mimeutils.h>
|
||||||
#include <utils/qtcassert.h>
|
#include <utils/qtcassert.h>
|
||||||
|
|
||||||
@@ -288,8 +289,7 @@ void ModelIndexer::IndexerThread::onFilesQueued()
|
|||||||
// collect all diagrams of model
|
// collect all diagrams of model
|
||||||
DiagramsCollectorVisitor visitor(indexedModel);
|
DiagramsCollectorVisitor visitor(indexedModel);
|
||||||
project.rootPackage()->accept(&visitor);
|
project.rootPackage()->accept(&visitor);
|
||||||
if (m_indexer->d->defaultModelFiles.contains(queuedFile)) {
|
if (m_indexer->d->defaultModelFiles.remove(queuedFile)) {
|
||||||
m_indexer->d->defaultModelFiles.remove(queuedFile);
|
|
||||||
// check if model has a diagram which could be opened
|
// check if model has a diagram which could be opened
|
||||||
qmt::FindRootDiagramVisitor diagramVisitor;
|
qmt::FindRootDiagramVisitor diagramVisitor;
|
||||||
project.rootPackage()->accept(&diagramVisitor);
|
project.rootPackage()->accept(&diagramVisitor);
|
||||||
@@ -426,10 +426,9 @@ void ModelIndexer::scanProject(ProjectExplorer::Project *project)
|
|||||||
// queue files
|
// queue files
|
||||||
while (!filesQueue.isEmpty()) {
|
while (!filesQueue.isEmpty()) {
|
||||||
QueuedFile queuedFile = filesQueue.takeFirst();
|
QueuedFile queuedFile = filesQueue.takeFirst();
|
||||||
if (!d->queuedFilesSet.contains(queuedFile)) {
|
if (Utils::insert(d->queuedFilesSet, queuedFile)) {
|
||||||
QMT_CHECK(!d->filesQueue.contains(queuedFile));
|
QMT_CHECK(!d->filesQueue.contains(queuedFile));
|
||||||
d->filesQueue.append(queuedFile);
|
d->filesQueue.append(queuedFile);
|
||||||
d->queuedFilesSet.insert(queuedFile);
|
|
||||||
filesAreQueued = true;
|
filesAreQueued = true;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@@ -474,11 +473,10 @@ void ModelIndexer::forgetProject(ProjectExplorer::Project *project)
|
|||||||
const QString fileString = file.toString();
|
const QString fileString = file.toString();
|
||||||
// remove file from queue
|
// remove file from queue
|
||||||
QueuedFile queuedFile(fileString, project);
|
QueuedFile queuedFile(fileString, project);
|
||||||
if (d->queuedFilesSet.contains(queuedFile)) {
|
if (d->queuedFilesSet.remove(queuedFile)) {
|
||||||
QMT_CHECK(d->filesQueue.contains(queuedFile));
|
QMT_CHECK(d->filesQueue.contains(queuedFile));
|
||||||
d->filesQueue.removeOne(queuedFile);
|
d->filesQueue.removeOne(queuedFile);
|
||||||
QMT_CHECK(!d->filesQueue.contains(queuedFile));
|
QMT_CHECK(!d->filesQueue.contains(queuedFile));
|
||||||
d->queuedFilesSet.remove(queuedFile);
|
|
||||||
}
|
}
|
||||||
removeModelFile(fileString, project);
|
removeModelFile(fileString, project);
|
||||||
removeDiagramReferenceFile(fileString, project);
|
removeDiagramReferenceFile(fileString, project);
|
||||||
|
@@ -521,8 +521,7 @@ void FlatModel::addFolderNode(WrapperNode *parent, FolderNode *folderNode, QSet<
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
if (!isHidden && !seen->contains(subFolderNode)) {
|
if (!isHidden && Utils::insert(*seen, subFolderNode)) {
|
||||||
seen->insert(subFolderNode);
|
|
||||||
auto node = new WrapperNode(subFolderNode);
|
auto node = new WrapperNode(subFolderNode);
|
||||||
parent->appendChild(node);
|
parent->appendChild(node);
|
||||||
addFolderNode(node, subFolderNode, seen);
|
addFolderNode(node, subFolderNode, seen);
|
||||||
@@ -531,10 +530,8 @@ void FlatModel::addFolderNode(WrapperNode *parent, FolderNode *folderNode, QSet<
|
|||||||
addFolderNode(parent, subFolderNode, seen);
|
addFolderNode(parent, subFolderNode, seen);
|
||||||
}
|
}
|
||||||
} else if (FileNode *fileNode = node->asFileNode()) {
|
} else if (FileNode *fileNode = node->asFileNode()) {
|
||||||
if (!seen->contains(fileNode)) {
|
if (Utils::insert(*seen, fileNode))
|
||||||
seen->insert(fileNode);
|
|
||||||
parent->appendChild(new WrapperNode(fileNode));
|
parent->appendChild(new WrapperNode(fileNode));
|
||||||
}
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@@ -131,10 +131,9 @@ static QStringList readLines(const FilePath &projectFile)
|
|||||||
const QString line = stream.readLine();
|
const QString line = stream.readLine();
|
||||||
if (line.isNull())
|
if (line.isNull())
|
||||||
break;
|
break;
|
||||||
if (visited.contains(line))
|
if (!Utils::insert(visited, line))
|
||||||
continue;
|
continue;
|
||||||
lines.append(line);
|
lines.append(line);
|
||||||
visited.insert(line);
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -149,10 +148,8 @@ static QStringList readLinesJson(const FilePath &projectFile, QString *errorMess
|
|||||||
const QJsonObject obj = readObjJson(projectFile, errorMessage);
|
const QJsonObject obj = readObjJson(projectFile, errorMessage);
|
||||||
for (const QJsonValue &file : obj.value("files").toArray()) {
|
for (const QJsonValue &file : obj.value("files").toArray()) {
|
||||||
const QString fileName = file.toString();
|
const QString fileName = file.toString();
|
||||||
if (visited.contains(fileName))
|
if (Utils::insert(visited, fileName))
|
||||||
continue;
|
lines.append(fileName);
|
||||||
lines.append(fileName);
|
|
||||||
visited.insert(fileName);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
return lines;
|
return lines;
|
||||||
|
@@ -17,6 +17,7 @@
|
|||||||
#include <projectexplorer/projectexplorerconstants.h>
|
#include <projectexplorer/projectexplorerconstants.h>
|
||||||
#include <projectexplorer/toolchain.h>
|
#include <projectexplorer/toolchain.h>
|
||||||
#include <qtsupport/qtkitinformation.h>
|
#include <qtsupport/qtkitinformation.h>
|
||||||
|
#include <utils/algorithm.h>
|
||||||
#include <utils/filepath.h>
|
#include <utils/filepath.h>
|
||||||
#include <utils/hostosinfo.h>
|
#include <utils/hostosinfo.h>
|
||||||
|
|
||||||
@@ -100,10 +101,8 @@ FilePaths QbsProjectImporter::importCandidates()
|
|||||||
for (Kit * const k : kits) {
|
for (Kit * const k : kits) {
|
||||||
FilePath bdir = buildDir(projectFilePath(), k);
|
FilePath bdir = buildDir(projectFilePath(), k);
|
||||||
const FilePath candidate = bdir.absolutePath();
|
const FilePath candidate = bdir.absolutePath();
|
||||||
if (!seenCandidates.contains(candidate)) {
|
if (Utils::insert(seenCandidates, candidate))
|
||||||
seenCandidates.insert(candidate);
|
|
||||||
candidates << candidatesForDirectory(candidate);
|
candidates << candidatesForDirectory(candidate);
|
||||||
}
|
|
||||||
}
|
}
|
||||||
qCDebug(qbsPmLog) << "build directory candidates:" << candidates;
|
qCDebug(qbsPmLog) << "build directory candidates:" << candidates;
|
||||||
return candidates;
|
return candidates;
|
||||||
|
@@ -16,6 +16,7 @@
|
|||||||
#include <texteditor/texteditorsettings.h>
|
#include <texteditor/texteditorsettings.h>
|
||||||
#include <texteditor/completionsettings.h>
|
#include <texteditor/completionsettings.h>
|
||||||
|
|
||||||
|
#include <utils/algorithm.h>
|
||||||
#include <utils/qtcassert.h>
|
#include <utils/qtcassert.h>
|
||||||
|
|
||||||
#include <qmljs/qmljsmodelmanagerinterface.h>
|
#include <qmljs/qmljsmodelmanagerinterface.h>
|
||||||
@@ -261,10 +262,9 @@ private:
|
|||||||
|
|
||||||
void processProperties(const ObjectValue *object)
|
void processProperties(const ObjectValue *object)
|
||||||
{
|
{
|
||||||
if (! object || _processed.contains(object))
|
if (! object || !Utils::insert(_processed, object))
|
||||||
return;
|
return;
|
||||||
|
|
||||||
_processed.insert(object);
|
|
||||||
processProperties(object->prototype(_scopeChain->context()));
|
processProperties(object->prototype(_scopeChain->context()));
|
||||||
|
|
||||||
_currentObject = object;
|
_currentObject = object;
|
||||||
|
@@ -952,9 +952,8 @@ QList<FindReferences::Usage> FindReferences::findUsageOfType(const Utils::FilePa
|
|||||||
QSet<Utils::FilePath> docDone;
|
QSet<Utils::FilePath> docDone;
|
||||||
for (const QmlJS::Document::Ptr &doc : std::as_const(snapshot)) {
|
for (const QmlJS::Document::Ptr &doc : std::as_const(snapshot)) {
|
||||||
Utils::FilePath sourceFile = modelManager->fileToSource(doc->fileName());
|
Utils::FilePath sourceFile = modelManager->fileToSource(doc->fileName());
|
||||||
if (docDone.contains(sourceFile))
|
if (!Utils::insert(docDone, sourceFile))
|
||||||
continue;
|
continue;
|
||||||
docDone.insert(sourceFile);
|
|
||||||
QmlJS::Document::Ptr sourceDoc = doc;
|
QmlJS::Document::Ptr sourceDoc = doc;
|
||||||
if (sourceFile != doc->fileName())
|
if (sourceFile != doc->fileName())
|
||||||
sourceDoc = snapshot.document(sourceFile);
|
sourceDoc = snapshot.document(sourceFile);
|
||||||
|
@@ -533,10 +533,8 @@ QList<ToolChain*> QtOptionsPageWidget::toolChains(const QtVersion *version)
|
|||||||
for (const Abi &a : abis) {
|
for (const Abi &a : abis) {
|
||||||
const Toolchains tcList = ToolChainManager::findToolChains(a);
|
const Toolchains tcList = ToolChainManager::findToolChains(a);
|
||||||
for (ToolChain *tc : tcList) {
|
for (ToolChain *tc : tcList) {
|
||||||
if (ids.contains(tc->id()))
|
if (Utils::insert(ids, tc->id()))
|
||||||
continue;
|
toolChains.append(tc);
|
||||||
ids.insert(tc->id());
|
|
||||||
toolChains.append(tc);
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@@ -139,9 +139,7 @@ void SquishResultFilterModel::enableAllResultTypes()
|
|||||||
|
|
||||||
void SquishResultFilterModel::toggleResultType(Result::Type type)
|
void SquishResultFilterModel::toggleResultType(Result::Type type)
|
||||||
{
|
{
|
||||||
if (m_enabled.contains(type))
|
if (!m_enabled.remove(type))
|
||||||
m_enabled.remove(type);
|
|
||||||
else
|
|
||||||
m_enabled.insert(type);
|
m_enabled.insert(type);
|
||||||
invalidateFilter();
|
invalidateFilter();
|
||||||
}
|
}
|
||||||
|
@@ -570,9 +570,8 @@ FilePaths BaseFileFind::replaceAll(const QString &text, const SearchResultItems
|
|||||||
QSet<QPair<int, int>> processed;
|
QSet<QPair<int, int>> processed;
|
||||||
for (const SearchResultItem &item : changeItems) {
|
for (const SearchResultItem &item : changeItems) {
|
||||||
const QPair<int, int> p{item.mainRange().begin.line, item.mainRange().begin.column};
|
const QPair<int, int> p{item.mainRange().begin.line, item.mainRange().begin.column};
|
||||||
if (processed.contains(p))
|
if (!Utils::insert(processed, p))
|
||||||
continue;
|
continue;
|
||||||
processed.insert(p);
|
|
||||||
|
|
||||||
QString replacement;
|
QString replacement;
|
||||||
if (item.userData().canConvert<QStringList>() && !item.userData().toStringList().isEmpty()) {
|
if (item.userData().canConvert<QStringList>() && !item.userData().toStringList().isEmpty()) {
|
||||||
|
@@ -96,11 +96,10 @@ IAssistProposal *DocumentContentCompletionProcessor::performAsync()
|
|||||||
continue;
|
continue;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (!words.contains(word)) {
|
if (Utils::insert(words, word)) {
|
||||||
auto item = new AssistProposalItem();
|
auto item = new AssistProposalItem();
|
||||||
item->setText(word);
|
item->setText(word);
|
||||||
items.append(item);
|
items.append(item);
|
||||||
words.insert(word);
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@@ -4416,9 +4416,8 @@ void TextEditorWidgetPrivate::paintCurrentLineHighlight(const PaintEventData &da
|
|||||||
QSet<int> seenLines;
|
QSet<int> seenLines;
|
||||||
for (const QTextCursor &cursor : cursorsForBlock) {
|
for (const QTextCursor &cursor : cursorsForBlock) {
|
||||||
QTextLine line = data.block.layout()->lineForTextPosition(cursor.positionInBlock());
|
QTextLine line = data.block.layout()->lineForTextPosition(cursor.positionInBlock());
|
||||||
if (seenLines.contains(line.lineNumber()))
|
if (!Utils::insert(seenLines, line.lineNumber()))
|
||||||
continue;
|
continue;
|
||||||
seenLines << line.lineNumber();
|
|
||||||
QRectF lineRect = line.rect();
|
QRectF lineRect = line.rect();
|
||||||
lineRect.moveTop(lineRect.top() + blockRect.top());
|
lineRect.moveTop(lineRect.top() + blockRect.top());
|
||||||
lineRect.setLeft(0);
|
lineRect.setLeft(0);
|
||||||
@@ -5657,10 +5656,8 @@ void TextEditorWidgetPrivate::slotUpdateBlockNotify(const QTextBlock &block)
|
|||||||
if (blockContainsFindScope) {
|
if (blockContainsFindScope) {
|
||||||
QTextBlock b = block.document()->findBlock(scope.selectionStart());
|
QTextBlock b = block.document()->findBlock(scope.selectionStart());
|
||||||
do {
|
do {
|
||||||
if (!updatedBlocks.contains(b.blockNumber())) {
|
if (Utils::insert(updatedBlocks, b.blockNumber()))
|
||||||
updatedBlocks << b.blockNumber();
|
|
||||||
emit q->requestBlockUpdate(b);
|
emit q->requestBlockUpdate(b);
|
||||||
}
|
|
||||||
b = b.next();
|
b = b.next();
|
||||||
} while (b.isValid() && b.position() < scope.selectionEnd());
|
} while (b.isValid() && b.position() < scope.selectionEnd());
|
||||||
}
|
}
|
||||||
|
Reference in New Issue
Block a user