Commit f463f3ab authored by Christian Kamm's avatar Christian Kamm

Quickfix: Use a LookupContext instead of TypeOfExpression to get type.

There's no need to reparse something we already got the AST of.
parent 0daf22c7
......@@ -31,6 +31,7 @@
#include "cppeditor.h"
#include <cplusplus/CppDocument.h>
#include <cplusplus/ResolveExpression.h>
#include <TranslationUnit.h>
#include <ASTVisitor.h>
......@@ -843,7 +844,6 @@ Snapshot QuickFixOperation::snapshot() const
void QuickFixOperation::setSnapshot(const CPlusPlus::Snapshot &snapshot)
{
_snapshot = snapshot;
_typeOfExpression.setSnapshot(snapshot);
}
CPPEditor *QuickFixOperation::editor() const
......@@ -1063,14 +1063,16 @@ void QuickFixOperation::apply()
*
* NOTE: The fully specified types only stay valid until the next call to typeOf.
*/
const QList<LookupItem> QuickFixOperation::typeOf(const CPlusPlus::ExpressionAST *ast)
const QList<LookupItem> QuickFixOperation::typeOf(CPlusPlus::ExpressionAST *ast)
{
unsigned line, column;
document()->translationUnit()->getTokenStartPosition(ast->firstToken(), &line, &column);
Symbol *lastVisibleSymbol = document()->findSymbolAt(line, column);
return _typeOfExpression(textOf(ast), document(), lastVisibleSymbol,
TypeOfExpression::Preprocess);
_lookupContext = LookupContext(lastVisibleSymbol, document(), document(), snapshot());
ResolveExpression resolveExpression(_lookupContext);
return resolveExpression(ast);
}
CPPQuickFixCollector::CPPQuickFixCollector()
......
......@@ -33,7 +33,7 @@
#include <texteditor/icompletioncollector.h>
#include <cplusplus/CppDocument.h>
#include <cplusplus/TypeOfExpression.h>
#include <cplusplus/LookupContext.h>
#include <ASTfwd.h>
#include <utils/changeset.h>
......@@ -128,7 +128,7 @@ protected:
Range createRange(CPlusPlus::AST *ast) const; // ### rename me
void reindent(const Range &range);
const QList<CPlusPlus::LookupItem> typeOf(const CPlusPlus::ExpressionAST *ast);
const QList<CPlusPlus::LookupItem> typeOf(CPlusPlus::ExpressionAST *ast);
private:
CPlusPlus::Document::Ptr _document;
......@@ -137,7 +137,7 @@ private:
Utils::ChangeSet _changeSet;
CPPEditor *_editor;
CPlusPlus::AST *_topLevelNode;
CPlusPlus::TypeOfExpression _typeOfExpression;
CPlusPlus::LookupContext _lookupContext;
};
class CPPQuickFixCollector: public TextEditor::IQuickFixCollector
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment