Changeset View
Changeset View
Standalone View
Standalone View
kdevplatform/tests/testfile.cpp
Show All 24 Lines | |||||
25 | #include <QTemporaryFile> | 25 | #include <QTemporaryFile> | ||
26 | #include <QTime> | 26 | #include <QTime> | ||
27 | #include <QTest> | 27 | #include <QTest> | ||
28 | 28 | | |||
29 | #include <language/duchain/duchainlock.h> | 29 | #include <language/duchain/duchainlock.h> | ||
30 | #include <language/duchain/duchain.h> | 30 | #include <language/duchain/duchain.h> | ||
31 | #include <language/backgroundparser/backgroundparser.h> | 31 | #include <language/backgroundparser/backgroundparser.h> | ||
32 | #include <interfaces/icore.h> | 32 | #include <interfaces/icore.h> | ||
33 | #include <interfaces/idocumentcontroller.h> | ||||
33 | #include <interfaces/ilanguagecontroller.h> | 34 | #include <interfaces/ilanguagecontroller.h> | ||
34 | #include <project/projectmodel.h> | 35 | #include <project/projectmodel.h> | ||
35 | 36 | | |||
36 | using namespace KDevelop; | 37 | using namespace KDevelop; | ||
37 | 38 | | |||
38 | class KDevelop::TestFilePrivate | 39 | class KDevelop::TestFilePrivate | ||
39 | { | 40 | { | ||
40 | public: | 41 | public: | ||
▲ Show 20 Lines • Show All 77 Lines • ▼ Show 20 Line(s) | 117 | { | |||
118 | const QString file = (!dir.isEmpty() ? dir : QDir::tempPath()) | 119 | const QString file = (!dir.isEmpty() ? dir : QDir::tempPath()) | ||
119 | + QLatin1Char('/') + fileName + d->suffix; | 120 | + QLatin1Char('/') + fileName + d->suffix; | ||
120 | d->init(file, contents, project); | 121 | d->init(file, contents, project); | ||
121 | } | 122 | } | ||
122 | 123 | | |||
123 | 124 | | |||
124 | TestFile::~TestFile() | 125 | TestFile::~TestFile() | ||
125 | { | 126 | { | ||
127 | IDocument* document = ICore::self()->documentController()->documentForUrl(d->url.toUrl()); | ||||
128 | if (document) { | ||||
mwolffUnsubmitted Not Done mwolff: ```
if (auto *document = ICore::self()->...) {
document->close(...);
}
``` | |||||
129 | document->close(KDevelop::IDocument::Discard); | ||||
130 | } | ||||
131 | | ||||
132 | auto backgroundParser = ICore::self()->languageController()->backgroundParser(); | ||||
133 | backgroundParser->removeDocument(d->url, this); | ||||
134 | QTRY_VERIFY(!backgroundParser->parseJobForDocument(d->url)); | ||||
maybe replace this whole if with a simple QTRY_VERIFY(!backgroundParser->parseJobForDocument(d->url))); if I'm not mistaken, it will have the same effect as the multiple lines of code that you wrote! mwolff: maybe replace this whole if with a simple
QTRY_VERIFY(!backgroundParser… | |||||
135 | | ||||
126 | if (d->topContext && !d->keepDUChainData) { | 136 | if (d->topContext && !d->keepDUChainData) { | ||
127 | DUChainWriteLocker lock; | 137 | DUChainWriteLocker lock; | ||
128 | DUChain::self()->removeDocumentChain(d->topContext.data()); | 138 | DUChain::self()->removeDocumentChain(d->topContext.data()); | ||
129 | } | 139 | } | ||
130 | QFile::remove(d->file); | 140 | QFile::remove(d->file); | ||
131 | } | 141 | } | ||
132 | 142 | | |||
133 | IndexedString TestFile::url() const | 143 | IndexedString TestFile::url() const | ||
▲ Show 20 Lines • Show All 66 Lines • Show Last 20 Lines |