forked from qt-creator/qt-creator
Refactoring LookupContext.h
Extracting class AlreadyConsideredClassContainer to separate file Change-Id: If3bb89df5ce0bae87723ad4ecab7118337df0655 Reviewed-by: Erik Verbruggen <erik.verbruggen@digia.com>
This commit is contained in:
committed by
Erik Verbruggen
parent
eb39b57e24
commit
70e3356a02
45
src/libs/cplusplus/AlreadyConsideredClassContainer.h
Normal file
45
src/libs/cplusplus/AlreadyConsideredClassContainer.h
Normal file
@@ -0,0 +1,45 @@
|
||||
#ifndef CPLUSPLUS_ALREADYCONSIDEREDCLASSCONTAINER_H
|
||||
#define CPLUSPLUS_ALREADYCONSIDEREDCLASSCONTAINER_H
|
||||
|
||||
#include <QSet>
|
||||
|
||||
namespace CPlusPlus {
|
||||
|
||||
template<typename T>
|
||||
class AlreadyConsideredClassContainer
|
||||
{
|
||||
public:
|
||||
AlreadyConsideredClassContainer() : _class(0) {}
|
||||
void insert(const T *item)
|
||||
{
|
||||
if (_container.isEmpty())
|
||||
_class = item;
|
||||
_container.insert(item);
|
||||
}
|
||||
bool contains(const T *item)
|
||||
{
|
||||
if (_container.contains(item))
|
||||
return true;
|
||||
|
||||
foreach (const T *existingItem, _container) {
|
||||
if (existingItem->isEqualTo(item))
|
||||
return true;
|
||||
}
|
||||
|
||||
return false;
|
||||
}
|
||||
|
||||
void clear(const T *item)
|
||||
{
|
||||
if (_class != item || _container.size() == 1)
|
||||
_container.clear();
|
||||
}
|
||||
|
||||
private:
|
||||
QSet<const T *> _container;
|
||||
const T * _class;
|
||||
};
|
||||
|
||||
} // namespace CPlusPlus
|
||||
|
||||
#endif // CPLUSPLUS_ALREADYCONSIDEREDCLASSCONTAINER_H
|
||||
@@ -32,6 +32,7 @@
|
||||
|
||||
#include "CppDocument.h"
|
||||
#include "LookupItem.h"
|
||||
#include "AlreadyConsideredClassContainer.h"
|
||||
#include <FullySpecifiedType.h>
|
||||
#include <Type.h>
|
||||
#include <SymbolVisitor.h>
|
||||
@@ -44,41 +45,6 @@
|
||||
namespace CPlusPlus {
|
||||
|
||||
class CreateBindings;
|
||||
class Class;
|
||||
template<typename T>
|
||||
class AlreadyConsideredClassContainer
|
||||
{
|
||||
public:
|
||||
AlreadyConsideredClassContainer() : _class(0) {}
|
||||
void insert(const T *item)
|
||||
{
|
||||
if (_container.isEmpty())
|
||||
_class = item;
|
||||
_container.insert(item);
|
||||
}
|
||||
bool contains(const T *item)
|
||||
{
|
||||
if (_container.contains(item))
|
||||
return true;
|
||||
|
||||
foreach (const T *existingItem, _container) {
|
||||
if (existingItem->isEqualTo(item))
|
||||
return true;
|
||||
}
|
||||
|
||||
return false;
|
||||
}
|
||||
|
||||
void clear(const T *item)
|
||||
{
|
||||
if (_class != item || _container.size() == 1)
|
||||
_container.clear();
|
||||
}
|
||||
|
||||
private:
|
||||
QSet<const T *> _container;
|
||||
const T * _class;
|
||||
};
|
||||
|
||||
class CPLUSPLUS_EXPORT ClassOrNamespace
|
||||
{
|
||||
|
||||
@@ -36,6 +36,7 @@ HEADERS += \
|
||||
$$PWD/TypePrettyPrinter.h \
|
||||
$$PWD/ResolveExpression.h \
|
||||
$$PWD/LookupItem.h \
|
||||
$$PWD/AlreadyConsideredClassContainer.h \
|
||||
$$PWD/LookupContext.h \
|
||||
$$PWD/ASTParent.h \
|
||||
$$PWD/ASTPath.h \
|
||||
|
||||
@@ -86,6 +86,7 @@ QtcLibrary {
|
||||
}
|
||||
|
||||
files: [
|
||||
"AlreadyConsideredClassContainer.h",
|
||||
"ASTParent.cpp",
|
||||
"ASTParent.h",
|
||||
"ASTPath.cpp",
|
||||
|
||||
Reference in New Issue
Block a user