forked from qt-creator/qt-creator
Introduced CPlusPlus::Snapshot, it contains a snap shot of the indexer's current state.
This change removes a number of wrong usages of the CppModelManager::documents()/document().
This commit is contained in:
@@ -40,7 +40,7 @@
|
||||
|
||||
#include <QByteArray>
|
||||
#include <QList>
|
||||
#include <QSet>
|
||||
#include <QMap>
|
||||
#include <QSharedPointer>
|
||||
#include <QString>
|
||||
#include <QStringList>
|
||||
@@ -236,6 +236,16 @@ private:
|
||||
QList<MacroUse> _macroUses;
|
||||
};
|
||||
|
||||
class CPLUSPLUS_EXPORT Snapshot: public QMap<QString, Document::Ptr>
|
||||
{
|
||||
public:
|
||||
Snapshot()
|
||||
{ }
|
||||
|
||||
~Snapshot()
|
||||
{ }
|
||||
};
|
||||
|
||||
} // end of namespace CPlusPlus
|
||||
|
||||
#endif // CPPDOCUMENT_H
|
||||
|
||||
@@ -77,7 +77,7 @@ LookupContext::LookupContext(Control *control)
|
||||
LookupContext::LookupContext(Symbol *symbol,
|
||||
Document::Ptr expressionDocument,
|
||||
Document::Ptr thisDocument,
|
||||
const QMap<QString, Document::Ptr> &documents)
|
||||
const Snapshot &documents)
|
||||
: _symbol(symbol),
|
||||
_expressionDocument(expressionDocument),
|
||||
_thisDocument(thisDocument),
|
||||
|
||||
@@ -57,7 +57,7 @@ public:
|
||||
LookupContext(Symbol *symbol,
|
||||
Document::Ptr expressionDocument,
|
||||
Document::Ptr thisDocument,
|
||||
const QMap<QString, Document::Ptr> &documents);
|
||||
const Snapshot &documents);
|
||||
|
||||
LookupContext(Symbol *symbol,
|
||||
const LookupContext &context);
|
||||
@@ -87,7 +87,7 @@ public:
|
||||
QList<Symbol *> resolveClassOrNamespace(Name *name) const
|
||||
{ return resolveClassOrNamespace(name, visibleScopes()); }
|
||||
|
||||
QMap<QString, Document::Ptr> documents() const
|
||||
Snapshot snapshot() const
|
||||
{ return _documents; }
|
||||
|
||||
enum ResolveMode {
|
||||
@@ -140,7 +140,7 @@ private:
|
||||
Document::Ptr _thisDocument;
|
||||
|
||||
// All documents.
|
||||
QMap<QString, Document::Ptr> _documents;
|
||||
Snapshot _documents;
|
||||
|
||||
// Visible scopes.
|
||||
QList<Scope *> _visibleScopes;
|
||||
|
||||
@@ -46,9 +46,9 @@ TypeOfExpression::TypeOfExpression():
|
||||
{
|
||||
}
|
||||
|
||||
void TypeOfExpression::setDocuments(const QMap<QString, Document::Ptr> &documents)
|
||||
void TypeOfExpression::setSnapshot(const Snapshot &documents)
|
||||
{
|
||||
m_documents = documents;
|
||||
m_snapshot = documents;
|
||||
m_lookupContext = LookupContext();
|
||||
}
|
||||
|
||||
@@ -59,12 +59,12 @@ QList<TypeOfExpression::Result> TypeOfExpression::operator()(const QString &expr
|
||||
{
|
||||
QString code = expression;
|
||||
if (mode == Preprocess)
|
||||
code = preprocessedExpression(expression, m_documents, document);
|
||||
code = preprocessedExpression(expression, m_snapshot, document);
|
||||
Document::Ptr expressionDoc = documentForExpression(code);
|
||||
m_ast = extractExpressionAST(expressionDoc);
|
||||
|
||||
m_lookupContext = LookupContext(lastVisibleSymbol, expressionDoc,
|
||||
document, m_documents);
|
||||
document, m_snapshot);
|
||||
|
||||
ResolveExpression resolveExpression(m_lookupContext);
|
||||
return resolveExpression(m_ast);
|
||||
@@ -103,7 +103,7 @@ Document::Ptr TypeOfExpression::documentForExpression(const QString &expression)
|
||||
return doc;
|
||||
}
|
||||
|
||||
void TypeOfExpression::processEnvironment(QMap<QString, Document::Ptr> documents,
|
||||
void TypeOfExpression::processEnvironment(Snapshot documents,
|
||||
Document::Ptr doc, Environment *env,
|
||||
QSet<QString> *processed) const
|
||||
{
|
||||
@@ -122,7 +122,7 @@ void TypeOfExpression::processEnvironment(QMap<QString, Document::Ptr> documents
|
||||
}
|
||||
|
||||
QString TypeOfExpression::preprocessedExpression(const QString &expression,
|
||||
QMap<QString, Document::Ptr> documents,
|
||||
Snapshot documents,
|
||||
Document::Ptr thisDocument) const
|
||||
{
|
||||
Environment env;
|
||||
|
||||
@@ -61,7 +61,7 @@ public:
|
||||
* Also clears the lookup context, so can be used to make sure references
|
||||
* to the documents previously used are removed.
|
||||
*/
|
||||
void setDocuments(const QMap<QString, Document::Ptr> &documents);
|
||||
void setSnapshot(const Snapshot &documents);
|
||||
|
||||
enum PreprocessMode {
|
||||
NoPreprocess,
|
||||
@@ -100,15 +100,15 @@ private:
|
||||
ExpressionAST *extractExpressionAST(Document::Ptr doc) const;
|
||||
Document::Ptr documentForExpression(const QString &expression) const;
|
||||
|
||||
void processEnvironment(QMap<QString, CPlusPlus::Document::Ptr> documents,
|
||||
void processEnvironment(CPlusPlus::Snapshot documents,
|
||||
CPlusPlus::Document::Ptr doc, CPlusPlus::Environment *env,
|
||||
QSet<QString> *processed) const;
|
||||
|
||||
QString preprocessedExpression(const QString &expression,
|
||||
QMap<QString, CPlusPlus::Document::Ptr> documents,
|
||||
CPlusPlus::Snapshot documents,
|
||||
CPlusPlus::Document::Ptr thisDocument) const;
|
||||
|
||||
QMap<QString, Document::Ptr> m_documents;
|
||||
Snapshot m_snapshot;
|
||||
ExpressionAST *m_ast;
|
||||
LookupContext m_lookupContext;
|
||||
};
|
||||
|
||||
Reference in New Issue
Block a user