2014-08-19 15:59:29 +02:00
|
|
|
/****************************************************************************
|
|
|
|
|
**
|
2016-01-15 14:57:40 +01:00
|
|
|
** Copyright (C) 2016 The Qt Company Ltd.
|
|
|
|
|
** Contact: https://www.qt.io/licensing/
|
2014-08-19 15:59:29 +02:00
|
|
|
**
|
|
|
|
|
** This file is part of Qt Creator.
|
|
|
|
|
**
|
|
|
|
|
** Commercial License Usage
|
|
|
|
|
** Licensees holding valid commercial Qt licenses may use this file in
|
|
|
|
|
** accordance with the commercial license agreement provided with the
|
|
|
|
|
** Software or, alternatively, in accordance with the terms contained in
|
2016-01-15 14:57:40 +01:00
|
|
|
** a written agreement between you and The Qt Company. For licensing terms
|
|
|
|
|
** and conditions see https://www.qt.io/terms-conditions. For further
|
|
|
|
|
** information use the contact form at https://www.qt.io/contact-us.
|
2014-08-19 15:59:29 +02:00
|
|
|
**
|
2016-01-15 14:57:40 +01:00
|
|
|
** GNU General Public License Usage
|
|
|
|
|
** Alternatively, this file may be used under the terms of the GNU
|
|
|
|
|
** General Public License version 3 as published by the Free Software
|
|
|
|
|
** Foundation with exceptions as appearing in the file LICENSE.GPL3-EXCEPT
|
|
|
|
|
** included in the packaging of this file. Please review the following
|
|
|
|
|
** information to ensure the GNU General Public License requirements will
|
|
|
|
|
** be met: https://www.gnu.org/licenses/gpl-3.0.html.
|
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"
|
2016-01-11 20:50:14 +01:00
|
|
|
#include "cpptoolsbridge.h"
|
2017-01-12 18:01:12 +01:00
|
|
|
#include "cpptoolsreuse.h"
|
2017-01-17 15:27:31 +01:00
|
|
|
#include "cpptools_utils.h"
|
2014-08-19 15:59:29 +02:00
|
|
|
#include "editordocumenthandle.h"
|
|
|
|
|
|
2016-12-14 18:58:23 +01:00
|
|
|
#include <projectexplorer/session.h>
|
2015-12-15 11:59:48 +01:00
|
|
|
#include <texteditor/quickfix.h>
|
2014-08-19 15:59:29 +02:00
|
|
|
|
|
|
|
|
namespace CppTools {
|
|
|
|
|
|
|
|
|
|
/*!
|
|
|
|
|
\class CppTools::BaseEditorDocumentProcessor
|
|
|
|
|
|
|
|
|
|
\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,
|
|
|
|
|
const QString &filePath)
|
|
|
|
|
: m_filePath(filePath),
|
|
|
|
|
m_textDocument(textDocument)
|
2014-08-19 15:59:29 +02:00
|
|
|
{
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
BaseEditorDocumentProcessor::~BaseEditorDocumentProcessor()
|
|
|
|
|
{
|
|
|
|
|
}
|
|
|
|
|
|
2017-01-19 15:46:40 +01:00
|
|
|
void BaseEditorDocumentProcessor::run(bool projectsUpdated)
|
2016-12-14 18:58:23 +01:00
|
|
|
{
|
2017-01-12 18:01:12 +01:00
|
|
|
const Language languagePreference = codeModelSettings()->interpretAmbigiousHeadersAsCHeaders()
|
|
|
|
|
? Language::C
|
|
|
|
|
: Language::Cxx;
|
|
|
|
|
|
2016-12-14 18:58:23 +01:00
|
|
|
runImpl({CppModelManager::instance()->workingCopy(),
|
2016-12-15 11:21:44 +01:00
|
|
|
ProjectExplorer::SessionManager::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();
|
|
|
|
|
}
|
|
|
|
|
|
2016-01-27 13:37:19 +01:00
|
|
|
bool BaseEditorDocumentProcessor::hasDiagnosticsAt(uint, uint) const
|
|
|
|
|
{
|
|
|
|
|
return false;
|
|
|
|
|
}
|
|
|
|
|
|
2016-07-22 08:57:32 +02:00
|
|
|
void BaseEditorDocumentProcessor::addDiagnosticToolTipToLayout(uint, uint, QLayout *) const
|
2016-01-27 13:37:19 +01:00
|
|
|
{
|
|
|
|
|
}
|
|
|
|
|
|
2016-09-14 16:16:10 +02:00
|
|
|
void BaseEditorDocumentProcessor::editorDocumentTimerRestarted()
|
|
|
|
|
{
|
|
|
|
|
}
|
|
|
|
|
|
2017-01-18 15:05:46 +01:00
|
|
|
void BaseEditorDocumentProcessor::setParserConfig(
|
|
|
|
|
const BaseEditorDocumentParser::Configuration config)
|
|
|
|
|
{
|
|
|
|
|
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);
|
2016-01-11 20:50:14 +01:00
|
|
|
CppToolsBridge::finishedRefreshingSourceFiles({parser->filePath()});
|
2014-08-19 15:59:29 +02:00
|
|
|
|
|
|
|
|
future.setProgressValue(1);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
} // namespace CppTools
|