Commit e7088e9c authored by Erik Verbruggen's avatar Erik Verbruggen
Browse files

Fixed autotests.

parent 5adb6559
......@@ -3,8 +3,8 @@
using namespace CPlusPlus;
TokenCache::TokenCache()
: m_doc(0)
TokenCache::TokenCache(QTextDocument *doc)
: m_doc(doc)
, m_revision(-1)
{}
......
......@@ -17,7 +17,7 @@ namespace CPlusPlus {
class CPLUSPLUS_EXPORT TokenCache
{
public:
TokenCache();
TokenCache(QTextDocument *doc = 0);
void setDocument(QTextDocument *doc);
......
......@@ -6,7 +6,6 @@
#include <AST.h>
#include <ASTVisitor.h>
#include <TranslationUnit.h>
#include <CppBindings.h>
#include <CppDocument.h>
#include <FindUsages.h>
#include <Literals.h>
......@@ -90,7 +89,6 @@ void tst_FindUsages::inlineMethod()
QCOMPARE(arg->identifier()->chars(), "arg");
FindUsages findUsages(doc, snapshot);
findUsages.setGlobalNamespaceBinding(bind(doc, snapshot));
findUsages(arg);
QCOMPARE(findUsages.usages().size(), 2);
QCOMPARE(findUsages.references().size(), 2);
......@@ -150,7 +148,6 @@ void tst_FindUsages::objc_args()
QCOMPARE(arg->identifier()->chars(), "arg");
FindUsages findUsages(doc, snapshot);
findUsages.setGlobalNamespaceBinding(bind(doc, snapshot));
findUsages(arg);
QCOMPARE(findUsages.usages().size(), 2);
QCOMPARE(findUsages.references().size(), 2);
......@@ -189,7 +186,6 @@ void tst_FindUsages::qproperty_1()
QCOMPARE(setX_method->argumentCount(), 1U);
FindUsages findUsages(doc, snapshot);
findUsages.setGlobalNamespaceBinding(bind(doc, snapshot));
findUsages(setX_method);
QCOMPARE(findUsages.usages().size(), 2);
QCOMPARE(findUsages.references().size(), 2);
......
......@@ -11,6 +11,7 @@
#include <Semantic.h>
#include <Scope.h>
#include <Symbols.h>
#include <TokenCache.h>
#include <CoreTypes.h>
#include <Names.h>
#include <Literals.h>
......@@ -26,19 +27,20 @@ class tst_Semantic: public QObject
{
Q_OBJECT
Control control;
QSharedPointer<Control> control;
public:
tst_Semantic()
{ control.setDiagnosticClient(&diag); }
: control(new Control)
{ control->setDiagnosticClient(&diag); }
TranslationUnit *parse(const QByteArray &source,
TranslationUnit::ParseMode mode,
bool enableObjc,
bool qtMocRun)
{
const StringLiteral *fileId = control.findOrInsertStringLiteral("<stdin>");
TranslationUnit *unit = new TranslationUnit(&control, fileId);
const StringLiteral *fileId = control->findOrInsertStringLiteral("<stdin>");
TranslationUnit *unit = new TranslationUnit(control.data(), fileId);
unit->setSource(source.constData(), source.length());
unit->setObjCEnabled(enableObjc);
unit->setQtMocRunEnabled(qtMocRun);
......@@ -433,10 +435,10 @@ void tst_Semantic::template_instance_1()
Declaration *decl = doc->globals->symbolAt(0)->asClass()->memberAt(0)->asDeclaration();
QVERIFY(decl);
FullySpecifiedType templArgs[] = { control.integerType(IntegerType::Int) };
const Name *templId = control.templateNameId(control.findOrInsertIdentifier("QList"), templArgs, 1);
FullySpecifiedType templArgs[] = { control->integerType(IntegerType::Int) };
const Name *templId = control->templateNameId(control->findOrInsertIdentifier("QList"), templArgs, 1);
FullySpecifiedType genTy = DeprecatedGenTemplateInstance::instantiate(templId, decl, &control);
FullySpecifiedType genTy = DeprecatedGenTemplateInstance::instantiate(templId, decl, control);
Overview oo;
oo.setShowReturnTypes(true);
......@@ -455,7 +457,8 @@ void tst_Semantic::expression_under_cursor_1()
QTextCursor tc(&textDocument);
tc.movePosition(QTextCursor::End);
ExpressionUnderCursor expressionUnderCursor;
TokenCache cache(&textDocument);
ExpressionUnderCursor expressionUnderCursor(&cache);
const QString expression = expressionUnderCursor(tc);
QCOMPARE(expression, QString("bar"));
......@@ -471,7 +474,8 @@ void tst_Semantic::bracketed_expression_under_cursor_1()
QTextCursor tc(&textDocument);
tc.movePosition(QTextCursor::End);
ExpressionUnderCursor expressionUnderCursor;
TokenCache cache(&textDocument);
ExpressionUnderCursor expressionUnderCursor(&cache);
const QString expression = expressionUnderCursor(tc);
QCOMPARE(expression, QString("i"));
......@@ -487,7 +491,8 @@ void tst_Semantic::bracketed_expression_under_cursor_2()
QTextCursor tc(&textDocument);
tc.movePosition(QTextCursor::End);
ExpressionUnderCursor expressionUnderCursor;
TokenCache cache(&textDocument);
ExpressionUnderCursor expressionUnderCursor(&cache);
const QString expression = expressionUnderCursor(tc);
QCOMPARE(expression, plainText);
......@@ -503,7 +508,8 @@ void tst_Semantic::bracketed_expression_under_cursor_3()
QTextCursor tc(&textDocument);
tc.movePosition(QTextCursor::End);
ExpressionUnderCursor expressionUnderCursor;
TokenCache cache(&textDocument);
ExpressionUnderCursor expressionUnderCursor(&cache);
const QString expression = expressionUnderCursor(tc);
QCOMPARE(expression, plainText);
......@@ -519,7 +525,8 @@ void tst_Semantic::bracketed_expression_under_cursor_4()
QTextCursor tc(&textDocument);
tc.movePosition(QTextCursor::End);
ExpressionUnderCursor expressionUnderCursor;
TokenCache cache(&textDocument);
ExpressionUnderCursor expressionUnderCursor(&cache);
const QString expression = expressionUnderCursor(tc);
QCOMPARE(expression, plainText);
......@@ -535,7 +542,8 @@ void tst_Semantic::bracketed_expression_under_cursor_5()
QTextCursor tc(&textDocument);
tc.movePosition(QTextCursor::End);
ExpressionUnderCursor expressionUnderCursor;
TokenCache cache(&textDocument);
ExpressionUnderCursor expressionUnderCursor(&cache);
const QString expression = expressionUnderCursor(tc);
QCOMPARE(expression, QString("[receiver message"));
......@@ -551,7 +559,8 @@ void tst_Semantic::bracketed_expression_under_cursor_6()
QTextCursor tc(&textDocument);
tc.movePosition(QTextCursor::End);
ExpressionUnderCursor expressionUnderCursor;
TokenCache cache(&textDocument);
ExpressionUnderCursor expressionUnderCursor(&cache);
const QString expression = expressionUnderCursor(tc);
QCOMPARE(expression, QString("[receiver msgParam1:1 + i[1] msgParam2"));
......@@ -567,7 +576,8 @@ void tst_Semantic::bracketed_expression_under_cursor_7()
QTextCursor tc(&textDocument);
tc.movePosition(QTextCursor::End);
ExpressionUnderCursor expressionUnderCursor;
TokenCache cache(&textDocument);
ExpressionUnderCursor expressionUnderCursor(&cache);
const QString expression = expressionUnderCursor(tc);
QCOMPARE(expression, QString("i"));
......@@ -583,7 +593,8 @@ void tst_Semantic::bracketed_expression_under_cursor_8()
QTextCursor tc(&textDocument);
tc.movePosition(QTextCursor::End);
ExpressionUnderCursor expressionUnderCursor;
TokenCache cache(&textDocument);
ExpressionUnderCursor expressionUnderCursor(&cache);
const QString expression = expressionUnderCursor(tc);
QCOMPARE(expression, plainText);
......
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