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
|
|
|
|
2023-03-10 10:43:42 +01:00
|
|
|
#include <QPromise>
|
|
|
|
|
|
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),
|
2024-02-22 16:26:13 +01:00
|
|
|
m_textDocument(textDocument),
|
|
|
|
|
m_settings(CppCodeModelSettings::settingsForFile(filePath))
|
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
|
|
|
{
|
2024-02-22 16:26:13 +01:00
|
|
|
if (projectsUpdated)
|
2024-04-12 12:30:30 +02:00
|
|
|
m_settings = CppCodeModelSettings::settingsForFile(m_filePath);
|
2024-02-22 16:26:13 +01:00
|
|
|
|
2024-02-26 16:34:32 +01:00
|
|
|
const Utils::Language languagePreference
|
2024-04-12 12:30:30 +02:00
|
|
|
= m_settings.interpretAmbigiousHeadersAsC ? Utils::Language::C : Utils::Language::Cxx;
|
2017-01-12 18:01:12 +01:00
|
|
|
|
2023-07-12 09:47:29 +02:00
|
|
|
runImpl({CppModelManager::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);
|
|
|
|
|
}
|
|
|
|
|
|
2023-03-03 22:18:46 +01:00
|
|
|
void BaseEditorDocumentProcessor::runParser(QPromise<void> &promise,
|
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
|
|
|
{
|
2023-03-03 22:18:46 +01:00
|
|
|
promise.setProgressRange(0, 1);
|
|
|
|
|
if (promise.isCanceled()) {
|
|
|
|
|
promise.setProgressValue(1);
|
2014-08-19 15:59:29 +02:00
|
|
|
return;
|
|
|
|
|
}
|
|
|
|
|
|
2023-03-03 22:18:46 +01:00
|
|
|
parser->update(promise, updateParams);
|
2023-07-12 09:47:29 +02:00
|
|
|
CppModelManager::finishedRefreshingSourceFiles({parser->filePath().toString()});
|
2014-08-19 15:59:29 +02:00
|
|
|
|
2023-03-03 22:18:46 +01:00
|
|
|
promise.setProgressValue(1);
|
2014-08-19 15:59:29 +02:00
|
|
|
}
|
|
|
|
|
|
2021-08-30 10:58:08 +02:00
|
|
|
} // namespace CppEditor
|