2022-08-19 15:59:36 +02:00
|
|
|
// Copyright (C) 2016 The Qt Company Ltd.
|
2022-12-21 10:12:09 +01:00
|
|
|
// SPDX-License-Identifier: LicenseRef-Qt-Commercial OR GPL-3.0-only WITH Qt-GPL-exception-1.0
|
2014-08-19 15:59:29 +02:00
|
|
|
|
|
|
|
|
#include "baseeditordocumentprocessor.h"
|
|
|
|
|
|
2017-01-12 18:01:12 +01:00
|
|
|
#include "cppcodemodelsettings.h"
|
2015-12-15 11:59:48 +01:00
|
|
|
#include "cppmodelmanager.h"
|
2017-01-12 18:01:12 +01:00
|
|
|
#include "cpptoolsreuse.h"
|
2014-08-19 15:59:29 +02:00
|
|
|
#include "editordocumenthandle.h"
|
|
|
|
|
|
2023-02-14 15:47:22 +01:00
|
|
|
#include <projectexplorer/projectmanager.h>
|
|
|
|
|
|
2015-12-15 11:59:48 +01:00
|
|
|
#include <texteditor/quickfix.h>
|
2014-08-19 15:59:29 +02:00
|
|
|
|
2021-08-30 10:58:08 +02:00
|
|
|
namespace CppEditor {
|
2014-08-19 15:59:29 +02:00
|
|
|
|
|
|
|
|
/*!
|
2021-08-30 10:58:08 +02:00
|
|
|
\class CppEditor::BaseEditorDocumentProcessor
|
2014-08-19 15:59:29 +02:00
|
|
|
|
|
|
|
|
\brief The BaseEditorDocumentProcessor class controls and executes all
|
|
|
|
|
document relevant actions (reparsing, semantic highlighting, additional
|
|
|
|
|
semantic calculations) after a text document has changed.
|
|
|
|
|
*/
|
|
|
|
|
|
2016-01-11 20:40:05 +01:00
|
|
|
BaseEditorDocumentProcessor::BaseEditorDocumentProcessor(QTextDocument *textDocument,
|
2022-11-21 16:48:50 +01:00
|
|
|
const Utils::FilePath &filePath)
|
2016-01-11 20:40:05 +01:00
|
|
|
: m_filePath(filePath),
|
|
|
|
|
m_textDocument(textDocument)
|
2014-08-19 15:59:29 +02:00
|
|
|
{
|
|
|
|
|
}
|
|
|
|
|
|
2019-01-14 01:40:53 +01:00
|
|
|
BaseEditorDocumentProcessor::~BaseEditorDocumentProcessor() = default;
|
2014-08-19 15:59:29 +02:00
|
|
|
|
2017-01-19 15:46:40 +01:00
|
|
|
void BaseEditorDocumentProcessor::run(bool projectsUpdated)
|
2016-12-14 18:58:23 +01:00
|
|
|
{
|
2021-09-02 13:31:08 +02:00
|
|
|
const Utils::Language languagePreference = codeModelSettings()->interpretAmbigiousHeadersAsCHeaders()
|
|
|
|
|
? Utils::Language::C
|
|
|
|
|
: Utils::Language::Cxx;
|
2017-01-12 18:01:12 +01:00
|
|
|
|
2016-12-14 18:58:23 +01:00
|
|
|
runImpl({CppModelManager::instance()->workingCopy(),
|
2023-02-14 15:47:22 +01:00
|
|
|
ProjectExplorer::ProjectManager::startupProject(),
|
2017-01-12 18:01:12 +01:00
|
|
|
languagePreference,
|
2017-01-19 15:46:40 +01:00
|
|
|
projectsUpdated});
|
2016-12-14 18:58:23 +01:00
|
|
|
}
|
|
|
|
|
|
2015-08-24 18:26:09 +02:00
|
|
|
TextEditor::QuickFixOperations
|
|
|
|
|
BaseEditorDocumentProcessor::extraRefactoringOperations(const TextEditor::AssistInterface &)
|
|
|
|
|
{
|
|
|
|
|
return TextEditor::QuickFixOperations();
|
|
|
|
|
}
|
|
|
|
|
|
2017-07-03 13:29:30 +02:00
|
|
|
void BaseEditorDocumentProcessor::invalidateDiagnostics()
|
|
|
|
|
{
|
|
|
|
|
}
|
|
|
|
|
|
2017-01-18 15:05:46 +01:00
|
|
|
void BaseEditorDocumentProcessor::setParserConfig(
|
2019-01-14 01:40:53 +01:00
|
|
|
const BaseEditorDocumentParser::Configuration &config)
|
2017-01-18 15:05:46 +01:00
|
|
|
{
|
|
|
|
|
parser()->setConfiguration(config);
|
|
|
|
|
}
|
|
|
|
|
|
2014-08-19 15:59:29 +02:00
|
|
|
void BaseEditorDocumentProcessor::runParser(QFutureInterface<void> &future,
|
2015-09-01 17:34:07 +02:00
|
|
|
BaseEditorDocumentParser::Ptr parser,
|
2016-12-14 18:58:23 +01:00
|
|
|
BaseEditorDocumentParser::UpdateParams updateParams)
|
2014-08-19 15:59:29 +02:00
|
|
|
{
|
|
|
|
|
future.setProgressRange(0, 1);
|
|
|
|
|
if (future.isCanceled()) {
|
|
|
|
|
future.setProgressValue(1);
|
|
|
|
|
return;
|
|
|
|
|
}
|
|
|
|
|
|
2016-12-14 18:58:23 +01:00
|
|
|
parser->update(future, updateParams);
|
2022-11-23 18:29:50 +01:00
|
|
|
CppModelManager::instance()->finishedRefreshingSourceFiles({parser->filePath().toString()});
|
2014-08-19 15:59:29 +02:00
|
|
|
|
|
|
|
|
future.setProgressValue(1);
|
|
|
|
|
}
|
|
|
|
|
|
2021-08-30 10:58:08 +02:00
|
|
|
} // namespace CppEditor
|