Commit 7c21f2ec authored by Nikolai Kosjar's avatar Nikolai Kosjar Committed by Erik Verbruggen

CppTools: Denoise with BuiltinEditorDocumentParser::Ptr

Change-Id: I1d572e8cc3e76ef6bbae720e3c3482292aab9609
Reviewed-by: default avatarErik Verbruggen <erik.verbruggen@digia.com>
parent 7d35212f
......@@ -1020,7 +1020,7 @@ void CppEditorWidget::onFilePathChanged()
additionalDirectives = ProjectExplorer::SessionManager::value(
projectFile + QLatin1Char(',') + filePath).toString().toUtf8();
QSharedPointer<BuiltinEditorDocumentParser> parser
BuiltinEditorDocumentParser::Ptr parser
= d->m_modelManager->cppEditorSupport(editor())->documentParser();
parser->setProjectPart(d->m_modelManager->projectPartForProjectFile(projectFile));
parser->setEditorDefines(additionalDirectives);
......@@ -1088,7 +1088,7 @@ void CppEditorWidget::showPreProcessorWidget()
CppPreProcessorDialog preProcessorDialog(this, textDocument()->filePath(), projectParts);
if (preProcessorDialog.exec() == QDialog::Accepted) {
QSharedPointer<BuiltinEditorDocumentParser> parser
BuiltinEditorDocumentParser::Ptr parser
= d->m_modelManager->cppEditorSupport(editor())->documentParser();
const QString &additionals = preProcessorDialog.additionalPreProcessorDirectives();
parser->setProjectPart(preProcessorDialog.projectPart());
......
......@@ -45,6 +45,9 @@ namespace CppTools {
class CPPTOOLS_EXPORT BuiltinEditorDocumentParser : public BaseEditorDocumentParser
{
public:
typedef QSharedPointer<BuiltinEditorDocumentParser> Ptr;
public:
BuiltinEditorDocumentParser(const QString &filePath);
......
......@@ -1959,7 +1959,7 @@ void CppCompletionAssistInterface::getCppSpecifics() const
CppModelManagerInterface *modelManager = CppModelManagerInterface::instance();
if (CppEditorSupport *supp = modelManager->cppEditorSupport(m_editor)) {
if (QSharedPointer<BuiltinEditorDocumentParser> parser = supp->documentParser()) {
if (BuiltinEditorDocumentParser::Ptr parser = supp->documentParser()) {
parser->update(m_workingCopy);
m_snapshot = parser->snapshot();
m_headerPaths = parser->headerPaths();
......
......@@ -144,8 +144,7 @@ void CppToolsPlugin::test_cppsourceprocessor_includes_cyclic()
CppEditorSupport *cppEditorSupport = CppModelManagerInterface::instance()
->cppEditorSupport(editor);
QVERIFY(cppEditorSupport);
QSharedPointer<BuiltinEditorDocumentParser> documentParser
= cppEditorSupport->documentParser();
BuiltinEditorDocumentParser::Ptr documentParser = cppEditorSupport->documentParser();
QVERIFY(documentParser);
Snapshot snapshot = documentParser->snapshot();
QCOMPARE(snapshot.size(), 3); // Configuration file included
......
......@@ -259,11 +259,11 @@ CppCompletionAssistProvider *CppEditorSupport::completionAssistProvider() const
return m_completionAssistProvider;
}
QSharedPointer<BuiltinEditorDocumentParser> CppEditorSupport::documentParser()
BuiltinEditorDocumentParser::Ptr CppEditorSupport::documentParser()
{
QSharedPointer<BuiltinEditorDocumentParser> updater = documentParser_internal();
BuiltinEditorDocumentParser::Ptr updater = documentParser_internal();
if (!updater || updater->filePath() != fileName()) {
updater = QSharedPointer<BuiltinEditorDocumentParser>(new BuiltinEditorDocumentParser(fileName()));
updater = BuiltinEditorDocumentParser::Ptr(new BuiltinEditorDocumentParser(fileName()));
setDocumentParser_internal(updater);
QSharedPointer<CppCodeModelSettings> cms = CppToolsPlugin::instance()->codeModelSettings();
......@@ -282,7 +282,7 @@ void CppEditorSupport::updateDocument()
m_updateDocumentTimer->start(m_updateDocumentInterval);
}
static void parse(QFutureInterface<void> &future, QSharedPointer<BuiltinEditorDocumentParser> updater,
static void parse(QFutureInterface<void> &future, BuiltinEditorDocumentParser::Ptr updater,
WorkingCopy workingCopy)
{
future.setProgressRange(0, 1);
......@@ -524,8 +524,7 @@ SemanticInfo CppEditorSupport::recalculateSemanticInfoNow(const SemanticInfo::So
// Otherwise reprocess document
} else {
const QSharedPointer<BuiltinEditorDocumentParser> documentParser
= documentParser_internal();
const BuiltinEditorDocumentParser::Ptr documentParser = documentParser_internal();
QTC_ASSERT(documentParser, return newSemanticInfo);
newSemanticInfo.snapshot = documentParser->snapshot();
if (!newSemanticInfo.snapshot.contains(source.fileName))
......@@ -584,14 +583,13 @@ void CppEditorSupport::setSemanticInfo(const SemanticInfo &semanticInfo, bool em
emit semanticInfoUpdated(semanticInfo);
}
QSharedPointer<BuiltinEditorDocumentParser> CppEditorSupport::documentParser_internal() const
BuiltinEditorDocumentParser::Ptr CppEditorSupport::documentParser_internal() const
{
QMutexLocker locker(&m_documentParserLock);
return m_documentParser;
}
void CppEditorSupport::setDocumentParser_internal(
const QSharedPointer<BuiltinEditorDocumentParser> &updater)
void CppEditorSupport::setDocumentParser_internal(const BuiltinEditorDocumentParser::Ptr &updater)
{
QMutexLocker locker(&m_documentParserLock);
m_documentParser = updater;
......
......@@ -133,7 +133,7 @@ public:
CppCompletionAssistProvider *completionAssistProvider() const;
QSharedPointer<BuiltinEditorDocumentParser> documentParser();
BuiltinEditorDocumentParser::Ptr documentParser();
/// Checks whether the document is (re)parsed or about to be (re)parsed.
bool isUpdatingDocument();
......@@ -202,8 +202,8 @@ private:
SemanticInfo semanticInfo() const;
void setSemanticInfo(const SemanticInfo &semanticInfo, bool emitSignal = true);
QSharedPointer<BuiltinEditorDocumentParser> documentParser_internal() const;
void setDocumentParser_internal(const QSharedPointer<BuiltinEditorDocumentParser> &updater);
BuiltinEditorDocumentParser::Ptr documentParser_internal() const;
void setDocumentParser_internal(const BuiltinEditorDocumentParser::Ptr &updater);
private:
Internal::CppModelManager *m_modelManager;
......@@ -234,7 +234,7 @@ private:
SemanticInfo m_lastSemanticInfo;
QFuture<void> m_futureSemanticInfo;
mutable QMutex m_documentParserLock;
QSharedPointer<BuiltinEditorDocumentParser> m_documentParser;
BuiltinEditorDocumentParser::Ptr m_documentParser;
QFuture<void> m_documentParserFuture;
// Highlighting:
......
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