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 "clangeditordocumentprocessor.h"
|
|
|
|
|
|
2017-09-25 15:10:48 +02:00
|
|
|
#include "clangbackendcommunicator.h"
|
2016-01-29 17:17:18 +01:00
|
|
|
#include "clangdiagnostictooltipwidget.h"
|
2015-08-24 18:26:09 +02:00
|
|
|
#include "clangfixitoperation.h"
|
|
|
|
|
#include "clangfixitoperationsextractor.h"
|
2018-01-22 16:31:05 +01:00
|
|
|
#include "clangmodelmanagersupport.h"
|
2018-02-06 15:48:24 +01:00
|
|
|
#include "clanghighlightingresultreporter.h"
|
2016-02-26 17:50:38 +01:00
|
|
|
#include "clangprojectsettings.h"
|
2015-05-08 15:48:17 +02:00
|
|
|
#include "clangutils.h"
|
2014-08-19 15:59:29 +02:00
|
|
|
|
2015-08-31 16:28:26 +02:00
|
|
|
#include <diagnosticcontainer.h>
|
|
|
|
|
#include <sourcelocationcontainer.h>
|
|
|
|
|
|
2017-08-18 14:51:32 +02:00
|
|
|
#include <cpptools/builtincursorinfo.h>
|
2016-02-26 17:50:38 +01:00
|
|
|
#include <cpptools/clangdiagnosticconfigsmodel.h>
|
|
|
|
|
#include <cpptools/clangdiagnosticconfigsmodel.h>
|
2016-01-12 12:51:33 +01:00
|
|
|
#include <cpptools/compileroptionsbuilder.h>
|
2015-11-10 16:54:53 +01:00
|
|
|
#include <cpptools/cppcodemodelsettings.h>
|
2015-12-15 11:59:48 +01:00
|
|
|
#include <cpptools/cppmodelmanager.h>
|
2016-01-11 20:50:14 +01:00
|
|
|
#include <cpptools/cpptoolsbridge.h>
|
2015-11-10 16:54:53 +01:00
|
|
|
#include <cpptools/cpptoolsreuse.h>
|
2014-08-19 15:59:29 +02:00
|
|
|
#include <cpptools/cppworkingcopy.h>
|
2016-11-22 15:17:42 +01:00
|
|
|
#include <cpptools/editordocumenthandle.h>
|
2014-08-19 15:59:29 +02:00
|
|
|
|
2017-07-21 14:31:21 +02:00
|
|
|
#include <texteditor/displaysettings.h>
|
2015-09-10 14:18:09 +02:00
|
|
|
#include <texteditor/fontsettings.h>
|
2015-08-31 16:28:26 +02:00
|
|
|
#include <texteditor/texteditor.h>
|
2015-09-10 14:18:09 +02:00
|
|
|
#include <texteditor/texteditorconstants.h>
|
|
|
|
|
#include <texteditor/texteditorsettings.h>
|
2015-08-31 16:28:26 +02:00
|
|
|
|
2014-08-19 15:59:29 +02:00
|
|
|
#include <cplusplus/CppDocument.h>
|
|
|
|
|
|
2018-10-19 10:20:27 +02:00
|
|
|
#include <utils/algorithm.h>
|
2017-09-21 12:35:24 +02:00
|
|
|
#include <utils/textutils.h>
|
2014-08-19 15:59:29 +02:00
|
|
|
#include <utils/qtcassert.h>
|
2016-02-12 09:46:22 +01:00
|
|
|
#include <utils/runextensions.h>
|
2014-08-19 15:59:29 +02:00
|
|
|
|
2015-08-31 16:28:26 +02:00
|
|
|
#include <QTextBlock>
|
2016-10-04 16:23:42 +02:00
|
|
|
#include <QVBoxLayout>
|
|
|
|
|
#include <QWidget>
|
2015-08-31 16:28:26 +02:00
|
|
|
|
2014-08-19 15:59:29 +02:00
|
|
|
namespace ClangCodeModel {
|
2015-05-08 15:48:17 +02:00
|
|
|
namespace Internal {
|
2014-08-19 15:59:29 +02:00
|
|
|
|
2018-01-22 16:31:05 +01:00
|
|
|
static ClangProjectSettings &getProjectSettings(ProjectExplorer::Project *project)
|
|
|
|
|
{
|
|
|
|
|
QTC_CHECK(project);
|
2018-10-18 09:21:35 +02:00
|
|
|
return ClangModelManagerSupport::instance()->projectSettings(project);
|
2018-01-22 16:31:05 +01:00
|
|
|
}
|
|
|
|
|
|
2015-05-08 15:48:17 +02:00
|
|
|
ClangEditorDocumentProcessor::ClangEditorDocumentProcessor(
|
2017-09-25 15:10:48 +02:00
|
|
|
BackendCommunicator &communicator,
|
2015-05-08 15:48:17 +02:00
|
|
|
TextEditor::TextDocument *document)
|
2016-01-11 20:40:05 +01:00
|
|
|
: BaseEditorDocumentProcessor(document->document(), document->filePath().toString())
|
2017-06-09 12:19:09 +02:00
|
|
|
, m_document(*document)
|
2015-09-04 12:15:17 +02:00
|
|
|
, m_diagnosticManager(document)
|
2017-09-25 15:10:48 +02:00
|
|
|
, m_communicator(communicator)
|
2015-09-01 17:34:07 +02:00
|
|
|
, m_parser(new ClangEditorDocumentParser(document->filePath().toString()))
|
2014-08-19 15:59:29 +02:00
|
|
|
, m_parserRevision(0)
|
|
|
|
|
, m_semanticHighlighter(document)
|
|
|
|
|
, m_builtinProcessor(document, /*enableSemanticHighlighter=*/ false)
|
|
|
|
|
{
|
2018-06-05 11:40:01 +02:00
|
|
|
m_updateBackendDocumentTimer.setSingleShot(true);
|
|
|
|
|
m_updateBackendDocumentTimer.setInterval(350);
|
|
|
|
|
connect(&m_updateBackendDocumentTimer, &QTimer::timeout,
|
2018-05-31 15:21:53 +02:00
|
|
|
this, &ClangEditorDocumentProcessor::updateBackendDocumentIfProjectPartExists);
|
2016-09-14 16:16:10 +02:00
|
|
|
|
2017-01-17 15:27:31 +01:00
|
|
|
connect(m_parser.data(), &ClangEditorDocumentParser::projectPartInfoUpdated,
|
|
|
|
|
this, &BaseEditorDocumentProcessor::projectPartInfoUpdated);
|
|
|
|
|
|
2014-08-19 15:59:29 +02:00
|
|
|
// Forwarding the semantic info from the builtin processor enables us to provide all
|
|
|
|
|
// editor (widget) related features that are not yet implemented by the clang plugin.
|
|
|
|
|
connect(&m_builtinProcessor, &CppTools::BuiltinEditorDocumentProcessor::cppDocumentUpdated,
|
|
|
|
|
this, &ClangEditorDocumentProcessor::cppDocumentUpdated);
|
|
|
|
|
connect(&m_builtinProcessor, &CppTools::BuiltinEditorDocumentProcessor::semanticInfoUpdated,
|
|
|
|
|
this, &ClangEditorDocumentProcessor::semanticInfoUpdated);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
ClangEditorDocumentProcessor::~ClangEditorDocumentProcessor()
|
|
|
|
|
{
|
2018-06-05 11:40:01 +02:00
|
|
|
m_updateBackendDocumentTimer.stop();
|
2016-09-14 16:16:10 +02:00
|
|
|
|
2014-08-19 15:59:29 +02:00
|
|
|
m_parserWatcher.cancel();
|
|
|
|
|
m_parserWatcher.waitForFinished();
|
2015-05-08 15:48:17 +02:00
|
|
|
|
2018-01-19 14:51:37 +01:00
|
|
|
if (m_projectPart)
|
2018-05-31 15:21:53 +02:00
|
|
|
closeBackendDocument();
|
2014-08-19 15:59:29 +02:00
|
|
|
}
|
|
|
|
|
|
2016-12-14 18:58:23 +01:00
|
|
|
void ClangEditorDocumentProcessor::runImpl(
|
|
|
|
|
const CppTools::BaseEditorDocumentParser::UpdateParams &updateParams)
|
2014-08-19 15:59:29 +02:00
|
|
|
{
|
2018-06-05 11:40:01 +02:00
|
|
|
m_updateBackendDocumentTimer.start();
|
2015-08-31 16:28:26 +02:00
|
|
|
|
2014-08-19 15:59:29 +02:00
|
|
|
// Run clang parser
|
|
|
|
|
disconnect(&m_parserWatcher, &QFutureWatcher<void>::finished,
|
|
|
|
|
this, &ClangEditorDocumentProcessor::onParserFinished);
|
|
|
|
|
m_parserWatcher.cancel();
|
|
|
|
|
m_parserWatcher.setFuture(QFuture<void>());
|
|
|
|
|
|
|
|
|
|
m_parserRevision = revision();
|
|
|
|
|
connect(&m_parserWatcher, &QFutureWatcher<void>::finished,
|
|
|
|
|
this, &ClangEditorDocumentProcessor::onParserFinished);
|
2016-12-14 18:58:23 +01:00
|
|
|
const QFuture<void> future = ::Utils::runAsync(&runParser, parser(), updateParams);
|
2014-08-19 15:59:29 +02:00
|
|
|
m_parserWatcher.setFuture(future);
|
|
|
|
|
|
|
|
|
|
// Run builtin processor
|
2016-12-15 11:21:44 +01:00
|
|
|
m_builtinProcessor.runImpl(updateParams);
|
2014-08-19 15:59:29 +02:00
|
|
|
}
|
|
|
|
|
|
2015-06-19 14:37:26 +02:00
|
|
|
void ClangEditorDocumentProcessor::recalculateSemanticInfoDetached(bool force)
|
2014-08-19 15:59:29 +02:00
|
|
|
{
|
2015-06-19 14:37:26 +02:00
|
|
|
m_builtinProcessor.recalculateSemanticInfoDetached(force);
|
2014-08-19 15:59:29 +02:00
|
|
|
}
|
|
|
|
|
|
2015-06-19 14:43:41 +02:00
|
|
|
void ClangEditorDocumentProcessor::semanticRehighlight()
|
|
|
|
|
{
|
|
|
|
|
m_semanticHighlighter.updateFormatMapFromFontSettings();
|
2015-11-30 10:55:25 +01:00
|
|
|
|
|
|
|
|
if (m_projectPart)
|
2018-09-25 09:41:32 +02:00
|
|
|
requestAnnotationsFromBackend();
|
2015-06-19 14:43:41 +02:00
|
|
|
}
|
|
|
|
|
|
2014-08-19 15:59:29 +02:00
|
|
|
CppTools::SemanticInfo ClangEditorDocumentProcessor::recalculateSemanticInfo()
|
|
|
|
|
{
|
|
|
|
|
return m_builtinProcessor.recalculateSemanticInfo();
|
|
|
|
|
}
|
|
|
|
|
|
2015-09-01 17:34:07 +02:00
|
|
|
CppTools::BaseEditorDocumentParser::Ptr ClangEditorDocumentProcessor::parser()
|
2014-08-19 15:59:29 +02:00
|
|
|
{
|
2015-09-01 17:34:07 +02:00
|
|
|
return m_parser;
|
2014-08-19 15:59:29 +02:00
|
|
|
}
|
|
|
|
|
|
2014-11-28 12:03:58 +01:00
|
|
|
CPlusPlus::Snapshot ClangEditorDocumentProcessor::snapshot()
|
|
|
|
|
{
|
|
|
|
|
return m_builtinProcessor.snapshot();
|
|
|
|
|
}
|
|
|
|
|
|
2014-08-19 15:59:29 +02:00
|
|
|
bool ClangEditorDocumentProcessor::isParserRunning() const
|
|
|
|
|
{
|
|
|
|
|
return m_parserWatcher.isRunning();
|
|
|
|
|
}
|
|
|
|
|
|
2015-09-28 15:15:25 +02:00
|
|
|
bool ClangEditorDocumentProcessor::hasProjectPart() const
|
|
|
|
|
{
|
|
|
|
|
return m_projectPart;
|
|
|
|
|
}
|
|
|
|
|
|
2015-07-14 19:01:32 +02:00
|
|
|
CppTools::ProjectPart::Ptr ClangEditorDocumentProcessor::projectPart() const
|
|
|
|
|
{
|
|
|
|
|
return m_projectPart;
|
|
|
|
|
}
|
|
|
|
|
|
2015-09-18 12:19:46 +02:00
|
|
|
void ClangEditorDocumentProcessor::clearProjectPart()
|
|
|
|
|
{
|
|
|
|
|
m_projectPart.clear();
|
|
|
|
|
}
|
|
|
|
|
|
2018-01-19 16:57:18 +01:00
|
|
|
Core::Id ClangEditorDocumentProcessor::diagnosticConfigId() const
|
|
|
|
|
{
|
|
|
|
|
return m_diagnosticConfigId;
|
|
|
|
|
}
|
|
|
|
|
|
2016-10-04 16:23:42 +02:00
|
|
|
void ClangEditorDocumentProcessor::updateCodeWarnings(
|
|
|
|
|
const QVector<ClangBackEnd::DiagnosticContainer> &diagnostics,
|
|
|
|
|
const ClangBackEnd::DiagnosticContainer &firstHeaderErrorDiagnostic,
|
|
|
|
|
uint documentRevision)
|
2015-08-31 16:28:26 +02:00
|
|
|
{
|
|
|
|
|
if (documentRevision == revision()) {
|
2017-07-10 09:53:34 +02:00
|
|
|
m_diagnosticManager.processNewDiagnostics(diagnostics, m_isProjectFile);
|
2015-09-04 12:15:17 +02:00
|
|
|
const auto codeWarnings = m_diagnosticManager.takeExtraSelections();
|
2016-02-05 15:16:02 +01:00
|
|
|
const auto fixitAvailableMarkers = m_diagnosticManager.takeFixItAvailableMarkers();
|
2016-10-04 16:23:42 +02:00
|
|
|
const auto creator = creatorForHeaderErrorDiagnosticWidget(firstHeaderErrorDiagnostic);
|
|
|
|
|
|
|
|
|
|
emit codeWarningsUpdated(revision(),
|
|
|
|
|
codeWarnings,
|
|
|
|
|
creator,
|
|
|
|
|
fixitAvailableMarkers);
|
2015-08-31 16:28:26 +02:00
|
|
|
}
|
|
|
|
|
}
|
2015-12-02 20:07:29 +01:00
|
|
|
namespace {
|
2015-08-31 16:28:26 +02:00
|
|
|
|
2015-12-02 20:07:29 +01:00
|
|
|
TextEditor::BlockRange
|
|
|
|
|
toTextEditorBlock(QTextDocument *textDocument,
|
|
|
|
|
const ClangBackEnd::SourceRangeContainer &sourceRangeContainer)
|
|
|
|
|
{
|
2018-06-15 14:33:01 +02:00
|
|
|
return TextEditor::BlockRange(::Utils::Text::positionInText(textDocument,
|
|
|
|
|
sourceRangeContainer.start.line,
|
|
|
|
|
sourceRangeContainer.start.column),
|
|
|
|
|
::Utils::Text::positionInText(textDocument,
|
|
|
|
|
sourceRangeContainer.end.line,
|
|
|
|
|
sourceRangeContainer.end.column));
|
2015-12-02 20:07:29 +01:00
|
|
|
}
|
|
|
|
|
|
|
|
|
|
QList<TextEditor::BlockRange>
|
|
|
|
|
toTextEditorBlocks(QTextDocument *textDocument,
|
|
|
|
|
const QVector<ClangBackEnd::SourceRangeContainer> &ifdefedOutRanges)
|
2015-11-18 17:07:44 +01:00
|
|
|
{
|
|
|
|
|
QList<TextEditor::BlockRange> blockRanges;
|
|
|
|
|
blockRanges.reserve(ifdefedOutRanges.size());
|
|
|
|
|
|
|
|
|
|
for (const auto &range : ifdefedOutRanges)
|
2015-12-02 20:07:29 +01:00
|
|
|
blockRanges.append(toTextEditorBlock(textDocument, range));
|
2015-11-18 17:07:44 +01:00
|
|
|
|
|
|
|
|
return blockRanges;
|
|
|
|
|
}
|
2015-12-02 20:07:29 +01:00
|
|
|
}
|
2015-11-18 17:07:44 +01:00
|
|
|
|
2017-12-05 09:42:35 +01:00
|
|
|
const QVector<ClangBackEnd::TokenInfoContainer>
|
|
|
|
|
&ClangEditorDocumentProcessor::tokenInfos() const
|
2017-09-08 09:33:35 +02:00
|
|
|
{
|
2017-12-05 09:42:35 +01:00
|
|
|
return m_tokenInfos;
|
2017-09-08 09:33:35 +02:00
|
|
|
}
|
|
|
|
|
|
2018-04-12 14:49:07 +02:00
|
|
|
void ClangEditorDocumentProcessor::clearTaskHubIssues()
|
|
|
|
|
{
|
2018-04-20 13:55:49 +02:00
|
|
|
ClangDiagnosticManager::clearTaskHubIssues();
|
2018-04-12 14:49:07 +02:00
|
|
|
}
|
|
|
|
|
|
|
|
|
|
void ClangEditorDocumentProcessor::generateTaskHubIssues()
|
|
|
|
|
{
|
|
|
|
|
m_diagnosticManager.generateTaskHubIssues();
|
|
|
|
|
}
|
|
|
|
|
|
2015-11-18 17:07:44 +01:00
|
|
|
void ClangEditorDocumentProcessor::updateHighlighting(
|
2017-12-05 09:42:35 +01:00
|
|
|
const QVector<ClangBackEnd::TokenInfoContainer> &tokenInfos,
|
2015-11-18 17:07:44 +01:00
|
|
|
const QVector<ClangBackEnd::SourceRangeContainer> &skippedPreprocessorRanges,
|
|
|
|
|
uint documentRevision)
|
|
|
|
|
{
|
|
|
|
|
if (documentRevision == revision()) {
|
2015-12-02 20:07:29 +01:00
|
|
|
const auto skippedPreprocessorBlocks = toTextEditorBlocks(textDocument(), skippedPreprocessorRanges);
|
2015-11-18 17:07:44 +01:00
|
|
|
emit ifdefedOutBlocksUpdated(documentRevision, skippedPreprocessorBlocks);
|
|
|
|
|
|
|
|
|
|
m_semanticHighlighter.setHighlightingRunner(
|
2017-12-05 09:42:35 +01:00
|
|
|
[tokenInfos]() {
|
2018-02-06 15:48:24 +01:00
|
|
|
auto *reporter = new HighlightingResultReporter(tokenInfos);
|
2015-11-18 17:07:44 +01:00
|
|
|
return reporter->start();
|
|
|
|
|
});
|
|
|
|
|
m_semanticHighlighter.run();
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
2018-01-19 09:18:57 +01:00
|
|
|
void ClangEditorDocumentProcessor::updateTokenInfos(
|
|
|
|
|
const QVector<ClangBackEnd::TokenInfoContainer> &tokenInfos,
|
|
|
|
|
uint documentRevision)
|
|
|
|
|
{
|
|
|
|
|
if (documentRevision != revision())
|
|
|
|
|
return;
|
|
|
|
|
m_tokenInfos = tokenInfos;
|
2018-03-22 13:05:59 +01:00
|
|
|
emit tokenInfosUpdated();
|
2018-01-19 09:18:57 +01:00
|
|
|
}
|
|
|
|
|
|
2015-08-24 18:26:09 +02:00
|
|
|
static int currentLine(const TextEditor::AssistInterface &assistInterface)
|
|
|
|
|
{
|
|
|
|
|
int line, column;
|
2017-09-21 12:35:24 +02:00
|
|
|
::Utils::Text::convertPosition(assistInterface.textDocument(), assistInterface.position(),
|
|
|
|
|
&line, &column);
|
2015-08-24 18:26:09 +02:00
|
|
|
return line;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
TextEditor::QuickFixOperations ClangEditorDocumentProcessor::extraRefactoringOperations(
|
|
|
|
|
const TextEditor::AssistInterface &assistInterface)
|
|
|
|
|
{
|
|
|
|
|
ClangFixItOperationsExtractor extractor(m_diagnosticManager.diagnosticsWithFixIts());
|
|
|
|
|
|
|
|
|
|
return extractor.extract(assistInterface.fileName(), currentLine(assistInterface));
|
|
|
|
|
}
|
|
|
|
|
|
2016-01-27 13:37:19 +01:00
|
|
|
bool ClangEditorDocumentProcessor::hasDiagnosticsAt(uint line, uint column) const
|
|
|
|
|
{
|
|
|
|
|
return m_diagnosticManager.hasDiagnosticsAt(line, column);
|
|
|
|
|
}
|
|
|
|
|
|
2016-07-22 08:57:32 +02:00
|
|
|
void ClangEditorDocumentProcessor::addDiagnosticToolTipToLayout(uint line,
|
|
|
|
|
uint column,
|
|
|
|
|
QLayout *target) const
|
2016-01-27 13:37:19 +01:00
|
|
|
{
|
2016-10-18 18:01:57 +02:00
|
|
|
using Internal::ClangDiagnosticWidget;
|
|
|
|
|
|
|
|
|
|
const QVector<ClangBackEnd::DiagnosticContainer> diagnostics
|
|
|
|
|
= m_diagnosticManager.diagnosticsAt(line, column);
|
|
|
|
|
|
|
|
|
|
target->addWidget(ClangDiagnosticWidget::create(diagnostics, ClangDiagnosticWidget::ToolTip));
|
2017-07-21 14:31:21 +02:00
|
|
|
auto link = TextEditor::DisplaySettings::createAnnotationSettingsLink();
|
|
|
|
|
target->addWidget(link);
|
|
|
|
|
target->setAlignment(link, Qt::AlignRight);
|
2016-01-27 13:37:19 +01:00
|
|
|
}
|
|
|
|
|
|
2016-09-14 16:16:10 +02:00
|
|
|
void ClangEditorDocumentProcessor::editorDocumentTimerRestarted()
|
|
|
|
|
{
|
2018-06-05 11:40:01 +02:00
|
|
|
m_updateBackendDocumentTimer.stop(); // Wait for the next call to run().
|
2016-09-14 16:16:10 +02:00
|
|
|
}
|
|
|
|
|
|
2017-07-03 13:29:30 +02:00
|
|
|
void ClangEditorDocumentProcessor::invalidateDiagnostics()
|
|
|
|
|
{
|
|
|
|
|
m_diagnosticManager.invalidateDiagnostics();
|
|
|
|
|
}
|
|
|
|
|
|
2017-01-18 15:05:46 +01:00
|
|
|
void ClangEditorDocumentProcessor::setParserConfig(
|
|
|
|
|
const CppTools::BaseEditorDocumentParser::Configuration config)
|
|
|
|
|
{
|
|
|
|
|
m_parser->setConfiguration(config);
|
|
|
|
|
m_builtinProcessor.parser()->setConfiguration(config);
|
|
|
|
|
}
|
|
|
|
|
|
2017-06-09 12:19:09 +02:00
|
|
|
static bool isCursorOnIdentifier(const QTextCursor &textCursor)
|
|
|
|
|
{
|
|
|
|
|
QTextDocument *document = textCursor.document();
|
|
|
|
|
return CppTools::isValidIdentifierChar(document->characterAt(textCursor.position()));
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
static QFuture<CppTools::CursorInfo> defaultCursorInfoFuture()
|
|
|
|
|
{
|
|
|
|
|
QFutureInterface<CppTools::CursorInfo> futureInterface;
|
|
|
|
|
futureInterface.reportResult(CppTools::CursorInfo());
|
|
|
|
|
futureInterface.reportFinished();
|
|
|
|
|
|
|
|
|
|
return futureInterface.future();
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
static bool convertPosition(const QTextCursor &textCursor, int *line, int *column)
|
|
|
|
|
{
|
2017-09-21 12:35:24 +02:00
|
|
|
const bool converted = ::Utils::Text::convertPosition(textCursor.document(),
|
|
|
|
|
textCursor.position(),
|
|
|
|
|
line,
|
|
|
|
|
column);
|
2017-06-09 12:19:09 +02:00
|
|
|
QTC_CHECK(converted);
|
|
|
|
|
return converted;
|
|
|
|
|
}
|
|
|
|
|
|
2017-05-24 13:23:01 +02:00
|
|
|
QFuture<CppTools::CursorInfo>
|
|
|
|
|
ClangEditorDocumentProcessor::cursorInfo(const CppTools::CursorInfoParams ¶ms)
|
|
|
|
|
{
|
2017-06-09 12:19:09 +02:00
|
|
|
int line, column;
|
|
|
|
|
convertPosition(params.textCursor, &line, &column);
|
|
|
|
|
|
|
|
|
|
if (!isCursorOnIdentifier(params.textCursor))
|
|
|
|
|
return defaultCursorInfoFuture();
|
|
|
|
|
|
2018-02-01 13:27:50 +01:00
|
|
|
column = Utils::clangColumn(params.textCursor.document()->findBlockByNumber(line - 1), column);
|
2017-08-18 14:51:32 +02:00
|
|
|
const CppTools::SemanticInfo::LocalUseMap localUses
|
|
|
|
|
= CppTools::BuiltinCursorInfo::findLocalUses(params.semanticInfo.doc, line, column);
|
2017-06-09 12:19:09 +02:00
|
|
|
|
2017-09-25 15:10:48 +02:00
|
|
|
return m_communicator.requestReferences(simpleFileContainer(),
|
|
|
|
|
static_cast<quint32>(line),
|
|
|
|
|
static_cast<quint32>(column),
|
|
|
|
|
localUses);
|
2017-05-24 13:23:01 +02:00
|
|
|
}
|
|
|
|
|
|
2017-09-26 16:00:30 +02:00
|
|
|
QFuture<CppTools::CursorInfo> ClangEditorDocumentProcessor::requestLocalReferences(
|
|
|
|
|
const QTextCursor &cursor)
|
|
|
|
|
{
|
|
|
|
|
int line, column;
|
|
|
|
|
convertPosition(cursor, &line, &column);
|
|
|
|
|
++column; // for 1-based columns
|
|
|
|
|
|
|
|
|
|
// TODO: check that by highlighting items
|
|
|
|
|
if (!isCursorOnIdentifier(cursor))
|
|
|
|
|
return defaultCursorInfoFuture();
|
|
|
|
|
|
|
|
|
|
return m_communicator.requestLocalReferences(simpleFileContainer(),
|
|
|
|
|
static_cast<quint32>(line),
|
2017-11-29 16:08:06 +01:00
|
|
|
static_cast<quint32>(column));
|
2017-09-26 16:00:30 +02:00
|
|
|
}
|
|
|
|
|
|
2017-07-27 11:42:37 +02:00
|
|
|
QFuture<CppTools::SymbolInfo>
|
2017-09-08 09:33:35 +02:00
|
|
|
ClangEditorDocumentProcessor::requestFollowSymbol(int line, int column)
|
2017-07-27 11:42:37 +02:00
|
|
|
{
|
2017-09-25 15:10:48 +02:00
|
|
|
return m_communicator.requestFollowSymbol(simpleFileContainer(),
|
|
|
|
|
static_cast<quint32>(line),
|
|
|
|
|
static_cast<quint32>(column));
|
2017-07-27 11:42:37 +02:00
|
|
|
}
|
|
|
|
|
|
2018-01-12 12:29:43 +01:00
|
|
|
QFuture<CppTools::ToolTipInfo> ClangEditorDocumentProcessor::toolTipInfo(const QByteArray &codecName,
|
|
|
|
|
int line,
|
|
|
|
|
int column)
|
|
|
|
|
{
|
|
|
|
|
return m_communicator.requestToolTip(simpleFileContainer(codecName),
|
|
|
|
|
static_cast<quint32>(line),
|
|
|
|
|
static_cast<quint32>(column));
|
|
|
|
|
}
|
|
|
|
|
|
2015-11-25 15:11:23 +01:00
|
|
|
void ClangEditorDocumentProcessor::clearDiagnosticsWithFixIts()
|
|
|
|
|
{
|
|
|
|
|
m_diagnosticManager.clearDiagnosticsWithFixIts();
|
|
|
|
|
}
|
|
|
|
|
|
2015-07-14 19:01:32 +02:00
|
|
|
ClangEditorDocumentProcessor *ClangEditorDocumentProcessor::get(const QString &filePath)
|
|
|
|
|
{
|
2016-01-11 20:50:14 +01:00
|
|
|
auto *processor = CppTools::CppToolsBridge::baseEditorDocumentProcessor(filePath);
|
|
|
|
|
|
|
|
|
|
return qobject_cast<ClangEditorDocumentProcessor*>(processor);
|
2015-07-14 19:01:32 +02:00
|
|
|
}
|
|
|
|
|
|
2015-09-24 12:17:43 +02:00
|
|
|
static bool isProjectPartLoadedOrIsFallback(CppTools::ProjectPart::Ptr projectPart)
|
|
|
|
|
{
|
|
|
|
|
return projectPart
|
2015-09-24 14:25:53 +02:00
|
|
|
&& (projectPart->id().isEmpty() || ClangCodeModel::Utils::isProjectPartLoaded(projectPart));
|
2015-09-24 12:17:43 +02:00
|
|
|
}
|
|
|
|
|
|
2018-05-31 15:21:53 +02:00
|
|
|
void ClangEditorDocumentProcessor::updateBackendProjectPartAndDocument()
|
2015-07-14 19:01:32 +02:00
|
|
|
{
|
2017-01-17 15:27:31 +01:00
|
|
|
const CppTools::ProjectPart::Ptr projectPart = m_parser->projectPartInfo().projectPart;
|
2015-07-14 19:01:32 +02:00
|
|
|
|
2015-09-24 12:17:43 +02:00
|
|
|
if (isProjectPartLoadedOrIsFallback(projectPart)) {
|
2018-05-31 15:21:53 +02:00
|
|
|
updateBackendDocument(*projectPart.data());
|
2015-08-31 16:28:26 +02:00
|
|
|
|
2015-09-24 12:17:43 +02:00
|
|
|
m_projectPart = projectPart;
|
2017-07-10 09:53:34 +02:00
|
|
|
m_isProjectFile = m_parser->projectPartInfo().hints
|
|
|
|
|
& CppTools::ProjectPartInfo::IsFromProjectMatch;
|
2015-09-24 12:17:43 +02:00
|
|
|
}
|
2015-07-14 19:01:32 +02:00
|
|
|
}
|
|
|
|
|
|
2014-08-19 15:59:29 +02:00
|
|
|
void ClangEditorDocumentProcessor::onParserFinished()
|
|
|
|
|
{
|
|
|
|
|
if (revision() != m_parserRevision)
|
|
|
|
|
return;
|
|
|
|
|
|
2018-05-31 15:21:53 +02:00
|
|
|
updateBackendProjectPartAndDocument();
|
2015-07-14 19:01:32 +02:00
|
|
|
}
|
|
|
|
|
|
2018-01-22 09:40:04 +01:00
|
|
|
namespace {
|
|
|
|
|
// TODO: Can we marry this with CompilerOptionsBuilder?
|
|
|
|
|
class FileOptionsBuilder
|
|
|
|
|
{
|
|
|
|
|
public:
|
|
|
|
|
FileOptionsBuilder(const QString &filePath, CppTools::ProjectPart &projectPart)
|
|
|
|
|
: m_filePath(filePath)
|
|
|
|
|
, m_projectPart(projectPart)
|
|
|
|
|
{
|
|
|
|
|
addLanguageOptions();
|
2018-04-04 12:03:39 +02:00
|
|
|
addGlobalDiagnosticOptions(); // Before addDiagnosticOptions() so users still can overwrite.
|
2018-01-22 09:40:04 +01:00
|
|
|
addDiagnosticOptions();
|
|
|
|
|
addGlobalOptions();
|
|
|
|
|
addPrecompiledHeaderOptions();
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
const QStringList &options() const { return m_options; }
|
2018-01-19 16:57:18 +01:00
|
|
|
const Core::Id &diagnosticConfigId() const { return m_diagnosticConfigId; }
|
2018-01-22 09:40:04 +01:00
|
|
|
|
|
|
|
|
private:
|
|
|
|
|
void addLanguageOptions()
|
|
|
|
|
{
|
|
|
|
|
// Determine file kind with respect to ambiguous headers.
|
|
|
|
|
CppTools::ProjectFile::Kind fileKind = CppTools::ProjectFile::classify(m_filePath);
|
|
|
|
|
if (fileKind == CppTools::ProjectFile::AmbiguousHeader) {
|
2018-10-08 09:49:02 +02:00
|
|
|
fileKind = m_projectPart.languageVersion <= ProjectExplorer::LanguageVersion::LatestC
|
2018-01-22 09:40:04 +01:00
|
|
|
? CppTools::ProjectFile::CHeader
|
|
|
|
|
: CppTools::ProjectFile::CXXHeader;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
CppTools::CompilerOptionsBuilder builder(m_projectPart);
|
2018-07-10 15:53:51 +02:00
|
|
|
builder.updateLanguageOption(fileKind);
|
2018-01-22 09:40:04 +01:00
|
|
|
|
|
|
|
|
m_options.append(builder.options());
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
void addDiagnosticOptions()
|
|
|
|
|
{
|
|
|
|
|
if (m_projectPart.project) {
|
2018-01-22 16:31:05 +01:00
|
|
|
ClangProjectSettings &projectSettings = getProjectSettings(m_projectPart.project);
|
2018-01-22 09:40:04 +01:00
|
|
|
if (!projectSettings.useGlobalConfig()) {
|
|
|
|
|
const Core::Id warningConfigId = projectSettings.warningConfigId();
|
|
|
|
|
const CppTools::ClangDiagnosticConfigsModel configsModel(
|
|
|
|
|
CppTools::codeModelSettings()->clangCustomDiagnosticConfigs());
|
|
|
|
|
if (configsModel.hasConfigWithId(warningConfigId)) {
|
2018-01-19 16:57:18 +01:00
|
|
|
addDiagnosticOptionsForConfig(configsModel.configWithId(warningConfigId));
|
2018-01-22 09:40:04 +01:00
|
|
|
return;
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
2018-01-19 16:57:18 +01:00
|
|
|
addDiagnosticOptionsForConfig(CppTools::codeModelSettings()->clangDiagnosticConfig());
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
void addDiagnosticOptionsForConfig(const CppTools::ClangDiagnosticConfig &diagnosticConfig)
|
|
|
|
|
{
|
|
|
|
|
m_diagnosticConfigId = diagnosticConfig.id();
|
2018-01-26 10:27:58 +01:00
|
|
|
|
|
|
|
|
m_options.append(diagnosticConfig.clangOptions());
|
2018-02-23 11:36:18 +01:00
|
|
|
addClangTidyOptions(diagnosticConfig);
|
2018-01-26 10:27:58 +01:00
|
|
|
addClazyOptions(diagnosticConfig.clazyChecks());
|
2018-01-22 09:40:04 +01:00
|
|
|
}
|
|
|
|
|
|
|
|
|
|
void addXclangArg(const QString &argName, const QString &argValue = QString())
|
|
|
|
|
{
|
|
|
|
|
m_options.append("-Xclang");
|
|
|
|
|
m_options.append(argName);
|
|
|
|
|
if (!argValue.isEmpty()) {
|
|
|
|
|
m_options.append("-Xclang");
|
|
|
|
|
m_options.append(argValue);
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
2018-02-23 11:36:18 +01:00
|
|
|
void addClangTidyOptions(const CppTools::ClangDiagnosticConfig &diagnosticConfig)
|
2018-01-22 09:40:04 +01:00
|
|
|
{
|
2018-02-23 11:36:18 +01:00
|
|
|
using Mode = CppTools::ClangDiagnosticConfig::TidyMode;
|
|
|
|
|
Mode tidyMode = diagnosticConfig.clangTidyMode();
|
|
|
|
|
if (tidyMode == Mode::Disabled)
|
2018-01-22 09:40:04 +01:00
|
|
|
return;
|
|
|
|
|
|
|
|
|
|
addXclangArg("-add-plugin", "clang-tidy");
|
2018-02-23 11:36:18 +01:00
|
|
|
|
2018-01-17 15:08:30 +01:00
|
|
|
if (tidyMode == Mode::File)
|
|
|
|
|
return;
|
|
|
|
|
|
|
|
|
|
const QString checks = diagnosticConfig.clangTidyChecks();
|
2018-02-23 11:36:18 +01:00
|
|
|
if (!checks.isEmpty())
|
|
|
|
|
addXclangArg("-plugin-arg-clang-tidy", "-checks=" + checks);
|
2018-01-22 09:40:04 +01:00
|
|
|
}
|
|
|
|
|
|
2018-01-26 10:27:58 +01:00
|
|
|
void addClazyOptions(const QString &checks)
|
2018-01-22 09:40:04 +01:00
|
|
|
{
|
2018-01-26 10:27:58 +01:00
|
|
|
if (checks.isEmpty())
|
2018-01-22 09:40:04 +01:00
|
|
|
return;
|
|
|
|
|
|
|
|
|
|
addXclangArg("-add-plugin", "clang-lazy");
|
2018-05-14 13:30:11 +02:00
|
|
|
addXclangArg("-plugin-arg-clang-lazy", "enable-all-fixits");
|
|
|
|
|
addXclangArg("-plugin-arg-clang-lazy", "no-autowrite-fixits");
|
2018-01-26 10:27:58 +01:00
|
|
|
addXclangArg("-plugin-arg-clang-lazy", checks);
|
2018-01-24 13:41:34 +01:00
|
|
|
|
|
|
|
|
// NOTE: we already use -isystem for all include paths to make libclang skip diagnostics for
|
|
|
|
|
// all of them. That means that ignore-included-files will not change anything unless we decide
|
|
|
|
|
// to return the original -I prefix for some include paths.
|
|
|
|
|
addXclangArg("-plugin-arg-clang-lazy", "ignore-included-files");
|
2018-01-22 09:40:04 +01:00
|
|
|
}
|
|
|
|
|
|
2018-04-04 12:03:39 +02:00
|
|
|
void addGlobalDiagnosticOptions()
|
|
|
|
|
{
|
2018-05-22 16:03:09 +02:00
|
|
|
m_options += CppTools::ClangDiagnosticConfigsModel::globalDiagnosticOptions();
|
2018-04-04 12:03:39 +02:00
|
|
|
}
|
|
|
|
|
|
2018-01-22 09:40:04 +01:00
|
|
|
void addGlobalOptions()
|
|
|
|
|
{
|
|
|
|
|
if (!m_projectPart.project)
|
|
|
|
|
m_options.append(ClangProjectSettings::globalCommandLineOptions());
|
|
|
|
|
else
|
2018-01-22 16:31:05 +01:00
|
|
|
m_options.append(getProjectSettings(m_projectPart.project).commandLineOptions());
|
2018-01-22 09:40:04 +01:00
|
|
|
}
|
|
|
|
|
|
|
|
|
|
void addPrecompiledHeaderOptions()
|
|
|
|
|
{
|
|
|
|
|
using namespace CppTools;
|
|
|
|
|
|
2018-11-30 10:34:05 +01:00
|
|
|
if (getPchUsage() == UsePrecompiledHeaders::No)
|
2018-01-22 09:40:04 +01:00
|
|
|
return;
|
|
|
|
|
|
|
|
|
|
if (m_projectPart.precompiledHeaders.contains(m_filePath))
|
|
|
|
|
return;
|
|
|
|
|
|
|
|
|
|
CompilerOptionsBuilder builder(m_projectPart);
|
2018-11-30 10:34:05 +01:00
|
|
|
builder.addPrecompiledHeaderOptions(UsePrecompiledHeaders::Yes);
|
2018-01-22 09:40:04 +01:00
|
|
|
|
|
|
|
|
m_options.append(builder.options());
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
private:
|
|
|
|
|
const QString &m_filePath;
|
|
|
|
|
const CppTools::ProjectPart &m_projectPart;
|
|
|
|
|
|
2018-01-19 16:57:18 +01:00
|
|
|
Core::Id m_diagnosticConfigId;
|
2018-01-22 09:40:04 +01:00
|
|
|
QStringList m_options;
|
|
|
|
|
};
|
|
|
|
|
} // namespace
|
|
|
|
|
|
2018-09-25 09:41:32 +02:00
|
|
|
void ClangEditorDocumentProcessor::updateBackendDocument(CppTools::ProjectPart &projectPart)
|
2015-07-14 19:01:32 +02:00
|
|
|
{
|
2017-02-27 13:10:19 +01:00
|
|
|
// On registration we send the document content immediately as an unsaved
|
|
|
|
|
// file, because
|
|
|
|
|
// (1) a refactoring action might have opened and already modified
|
|
|
|
|
// this document.
|
|
|
|
|
// (2) it prevents an extra preamble generation on first user
|
|
|
|
|
// modification of the document in case the line endings on disk
|
|
|
|
|
// differ from the ones returned by textDocument()->toPlainText(),
|
|
|
|
|
// like on Windows.
|
|
|
|
|
|
2015-07-14 19:01:32 +02:00
|
|
|
if (m_projectPart) {
|
2018-01-22 09:18:37 +01:00
|
|
|
if (projectPart.id() == m_projectPart->id())
|
2017-02-27 13:10:19 +01:00
|
|
|
return;
|
2015-08-31 16:28:26 +02:00
|
|
|
}
|
2017-02-27 13:10:19 +01:00
|
|
|
|
2018-09-25 09:41:32 +02:00
|
|
|
const QStringList projectPartOptions = ClangCodeModel::Utils::createClangOptions(
|
|
|
|
|
projectPart,
|
|
|
|
|
CppTools::ProjectFile::Unsupported); // No language option as FileOptionsBuilder adds it.
|
|
|
|
|
|
2018-01-22 09:40:04 +01:00
|
|
|
const FileOptionsBuilder fileOptions(filePath(), projectPart);
|
2018-01-19 16:57:18 +01:00
|
|
|
m_diagnosticConfigId = fileOptions.diagnosticConfigId();
|
2018-09-25 09:41:32 +02:00
|
|
|
|
|
|
|
|
const QStringList compilationArguments = projectPartOptions + fileOptions.options();
|
|
|
|
|
|
2018-05-31 15:21:53 +02:00
|
|
|
m_communicator.documentsOpened(
|
2018-10-19 10:20:27 +02:00
|
|
|
{fileContainerWithOptionsAndDocumentContent(compilationArguments, projectPart.headerPaths)});
|
2017-02-27 13:10:19 +01:00
|
|
|
ClangCodeModel::Utils::setLastSentDocumentRevision(filePath(), revision());
|
2015-08-31 16:28:26 +02:00
|
|
|
}
|
|
|
|
|
|
2018-05-31 15:21:53 +02:00
|
|
|
void ClangEditorDocumentProcessor::closeBackendDocument()
|
2018-01-19 14:51:37 +01:00
|
|
|
{
|
|
|
|
|
QTC_ASSERT(m_projectPart, return);
|
2018-05-31 15:21:53 +02:00
|
|
|
m_communicator.documentsClosed({ClangBackEnd::FileContainer(filePath(), m_projectPart->id())});
|
2018-01-19 14:51:37 +01:00
|
|
|
}
|
|
|
|
|
|
2018-05-31 15:21:53 +02:00
|
|
|
void ClangEditorDocumentProcessor::updateBackendDocumentIfProjectPartExists()
|
2015-08-31 16:28:26 +02:00
|
|
|
{
|
2015-11-30 10:55:25 +01:00
|
|
|
if (m_projectPart) {
|
2018-09-25 09:41:32 +02:00
|
|
|
const ClangBackEnd::FileContainer fileContainer = fileContainerWithDocumentContent();
|
2018-05-31 15:21:53 +02:00
|
|
|
m_communicator.documentsChangedWithRevisionCheck(fileContainer);
|
2015-08-31 16:28:26 +02:00
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
2018-09-25 09:41:32 +02:00
|
|
|
void ClangEditorDocumentProcessor::requestAnnotationsFromBackend()
|
2015-11-18 17:07:44 +01:00
|
|
|
{
|
2018-09-25 09:41:32 +02:00
|
|
|
const auto fileContainer = fileContainerWithDocumentContent();
|
2018-05-31 15:21:53 +02:00
|
|
|
m_communicator.requestAnnotations(fileContainer);
|
2014-08-19 15:59:29 +02:00
|
|
|
}
|
|
|
|
|
|
2016-10-04 16:23:42 +02:00
|
|
|
CppTools::BaseEditorDocumentProcessor::HeaderErrorDiagnosticWidgetCreator
|
|
|
|
|
ClangEditorDocumentProcessor::creatorForHeaderErrorDiagnosticWidget(
|
|
|
|
|
const ClangBackEnd::DiagnosticContainer &firstHeaderErrorDiagnostic)
|
|
|
|
|
{
|
2018-04-04 18:25:23 +02:00
|
|
|
if (firstHeaderErrorDiagnostic.text.isEmpty())
|
2016-10-04 16:23:42 +02:00
|
|
|
return CppTools::BaseEditorDocumentProcessor::HeaderErrorDiagnosticWidgetCreator();
|
|
|
|
|
|
|
|
|
|
return [firstHeaderErrorDiagnostic]() {
|
|
|
|
|
auto vbox = new QVBoxLayout;
|
|
|
|
|
vbox->setMargin(0);
|
|
|
|
|
vbox->setContentsMargins(10, 0, 0, 2);
|
|
|
|
|
vbox->setSpacing(2);
|
|
|
|
|
|
2016-10-18 18:01:57 +02:00
|
|
|
vbox->addWidget(ClangDiagnosticWidget::create({firstHeaderErrorDiagnostic},
|
|
|
|
|
ClangDiagnosticWidget::InfoBar));
|
2016-10-04 16:23:42 +02:00
|
|
|
|
|
|
|
|
auto widget = new QWidget;
|
|
|
|
|
widget->setLayout(vbox);
|
|
|
|
|
|
|
|
|
|
return widget;
|
|
|
|
|
};
|
|
|
|
|
}
|
|
|
|
|
|
2018-01-12 12:29:43 +01:00
|
|
|
ClangBackEnd::FileContainer ClangEditorDocumentProcessor::simpleFileContainer(
|
|
|
|
|
const QByteArray &codecName) const
|
2017-06-09 12:19:09 +02:00
|
|
|
{
|
2018-01-12 12:29:43 +01:00
|
|
|
return ClangBackEnd::FileContainer(filePath(),
|
|
|
|
|
Utf8String(),
|
|
|
|
|
false,
|
|
|
|
|
revision(),
|
|
|
|
|
Utf8String::fromByteArray(codecName));
|
2017-06-09 12:19:09 +02:00
|
|
|
}
|
|
|
|
|
|
2018-01-22 09:40:04 +01:00
|
|
|
ClangBackEnd::FileContainer ClangEditorDocumentProcessor::fileContainerWithOptionsAndDocumentContent(
|
2018-10-19 10:20:27 +02:00
|
|
|
const QStringList &compilationArguments, const ProjectExplorer::HeaderPaths headerPaths) const
|
2015-11-05 13:57:57 +01:00
|
|
|
{
|
2018-10-19 10:20:27 +02:00
|
|
|
auto theHeaderPaths
|
|
|
|
|
= ::Utils::transform<QVector>(headerPaths, [](const ProjectExplorer::HeaderPath path) {
|
|
|
|
|
return Utf8String(QDir::toNativeSeparators(path.path));
|
|
|
|
|
});
|
|
|
|
|
theHeaderPaths << QDir::toNativeSeparators(
|
|
|
|
|
ClangModelManagerSupport::instance()->dummyUiHeaderOnDiskDirPath());
|
|
|
|
|
|
2016-11-22 15:17:42 +01:00
|
|
|
return ClangBackEnd::FileContainer(filePath(),
|
2018-09-25 09:41:32 +02:00
|
|
|
Utf8StringVector(compilationArguments),
|
2018-10-19 10:20:27 +02:00
|
|
|
theHeaderPaths,
|
2016-11-22 15:17:42 +01:00
|
|
|
textDocument()->toPlainText(),
|
|
|
|
|
true,
|
|
|
|
|
revision());
|
|
|
|
|
}
|
|
|
|
|
|
2015-11-30 10:55:25 +01:00
|
|
|
ClangBackEnd::FileContainer
|
2018-09-25 09:41:32 +02:00
|
|
|
ClangEditorDocumentProcessor::fileContainerWithDocumentContent() const
|
2015-11-30 10:55:25 +01:00
|
|
|
{
|
|
|
|
|
return ClangBackEnd::FileContainer(filePath(),
|
2016-01-11 20:40:05 +01:00
|
|
|
textDocument()->toPlainText(),
|
2015-11-30 10:55:25 +01:00
|
|
|
true,
|
|
|
|
|
revision());
|
|
|
|
|
}
|
|
|
|
|
|
2015-05-08 15:48:17 +02:00
|
|
|
} // namespace Internal
|
2014-08-19 15:59:29 +02:00
|
|
|
} // namespace ClangCodeModel
|