2013-12-10 14:37:32 +01:00
|
|
|
/****************************************************************************
|
|
|
|
|
**
|
2015-01-14 18:07:15 +01:00
|
|
|
** Copyright (C) 2015 The Qt Company Ltd.
|
|
|
|
|
** Contact: http://www.qt.io/licensing
|
2013-12-10 14:37:32 +01: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
|
2015-01-14 18:07:15 +01:00
|
|
|
** a written agreement between you and The Qt Company. For licensing terms and
|
|
|
|
|
** conditions see http://www.qt.io/terms-conditions. For further information
|
2014-10-01 13:21:18 +02:00
|
|
|
** use the contact form at http://www.qt.io/contact-us.
|
2013-12-10 14:37:32 +01:00
|
|
|
**
|
|
|
|
|
** GNU Lesser General Public License Usage
|
|
|
|
|
** Alternatively, this file may be used under the terms of the GNU Lesser
|
2014-10-01 13:21:18 +02:00
|
|
|
** General Public License version 2.1 or version 3 as published by the Free
|
|
|
|
|
** Software Foundation and appearing in the file LICENSE.LGPLv21 and
|
|
|
|
|
** LICENSE.LGPLv3 included in the packaging of this file. Please review the
|
|
|
|
|
** following information to ensure the GNU Lesser General Public License
|
|
|
|
|
** requirements will be met: https://www.gnu.org/licenses/lgpl.html and
|
|
|
|
|
** http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html.
|
2013-12-10 14:37:32 +01:00
|
|
|
**
|
2015-01-14 18:07:15 +01:00
|
|
|
** In addition, as a special exception, The Qt Company gives you certain additional
|
|
|
|
|
** rights. These rights are described in The Qt Company LGPL Exception
|
2013-12-10 14:37:32 +01:00
|
|
|
** version 1.1, included in the file LGPL_EXCEPTION.txt in this package.
|
|
|
|
|
**
|
|
|
|
|
****************************************************************************/
|
|
|
|
|
|
2015-05-08 15:48:17 +02:00
|
|
|
#include "clangmodelmanagersupport.h"
|
|
|
|
|
|
|
|
|
|
#include "constants.h"
|
2014-08-19 15:59:29 +02:00
|
|
|
#include "clangeditordocumentprocessor.h"
|
2015-05-08 15:48:17 +02:00
|
|
|
#include "clangutils.h"
|
|
|
|
|
|
|
|
|
|
#include <coreplugin/editormanager/editormanager.h>
|
|
|
|
|
#include <cpptools/baseeditordocumentparser.h>
|
|
|
|
|
#include <cpptools/editordocumenthandle.h>
|
|
|
|
|
#include <projectexplorer/project.h>
|
|
|
|
|
|
2015-08-31 14:36:58 +02:00
|
|
|
#include <clangbackendipc/cmbregisterprojectsforeditormessage.h>
|
2015-06-16 11:56:00 +02:00
|
|
|
#include <clangbackendipc/filecontainer.h>
|
|
|
|
|
#include <clangbackendipc/projectpartcontainer.h>
|
2015-05-08 15:48:17 +02:00
|
|
|
#include <utils/qtcassert.h>
|
2013-12-10 14:37:32 +01:00
|
|
|
|
|
|
|
|
#include <QCoreApplication>
|
2015-08-24 18:26:09 +02:00
|
|
|
#include <QMenu>
|
|
|
|
|
#include <QTextBlock>
|
2013-12-10 14:37:32 +01:00
|
|
|
|
|
|
|
|
using namespace ClangCodeModel;
|
|
|
|
|
using namespace ClangCodeModel::Internal;
|
|
|
|
|
|
2015-07-06 11:15:12 +02:00
|
|
|
static ModelManagerSupportClang *m_instance_forTestsOnly = 0;
|
2013-12-10 14:37:32 +01:00
|
|
|
|
2015-05-08 15:48:17 +02:00
|
|
|
static CppTools::CppModelManager *cppModelManager()
|
2013-12-10 14:37:32 +01:00
|
|
|
{
|
2015-05-08 15:48:17 +02:00
|
|
|
return CppTools::CppModelManager::instance();
|
2013-12-10 14:37:32 +01:00
|
|
|
}
|
|
|
|
|
|
2015-05-08 15:48:17 +02:00
|
|
|
ModelManagerSupportClang::ModelManagerSupportClang()
|
2015-06-16 13:59:08 +02:00
|
|
|
: m_completionAssistProvider(m_ipcCommunicator)
|
2013-12-10 14:37:32 +01:00
|
|
|
{
|
2015-07-06 11:15:12 +02:00
|
|
|
QTC_CHECK(!m_instance_forTestsOnly);
|
|
|
|
|
m_instance_forTestsOnly = this;
|
2015-05-08 15:48:17 +02:00
|
|
|
|
|
|
|
|
Core::EditorManager *editorManager = Core::EditorManager::instance();
|
|
|
|
|
connect(editorManager, &Core::EditorManager::currentEditorChanged,
|
|
|
|
|
this, &ModelManagerSupportClang::onCurrentEditorChanged);
|
|
|
|
|
connect(editorManager, &Core::EditorManager::editorOpened,
|
|
|
|
|
this, &ModelManagerSupportClang::onEditorOpened);
|
|
|
|
|
|
|
|
|
|
CppTools::CppModelManager *modelManager = cppModelManager();
|
2015-06-04 11:38:59 +02:00
|
|
|
connect(modelManager, &CppTools::CppModelManager::abstractEditorSupportContentsUpdated,
|
|
|
|
|
this, &ModelManagerSupportClang::onAbstractEditorSupportContentsUpdated);
|
|
|
|
|
connect(modelManager, &CppTools::CppModelManager::abstractEditorSupportRemoved,
|
|
|
|
|
this, &ModelManagerSupportClang::onAbstractEditorSupportRemoved);
|
2015-05-08 15:48:17 +02:00
|
|
|
connect(modelManager, &CppTools::CppModelManager::projectPartsUpdated,
|
|
|
|
|
this, &ModelManagerSupportClang::onProjectPartsUpdated);
|
|
|
|
|
connect(modelManager, &CppTools::CppModelManager::projectPartsRemoved,
|
|
|
|
|
this, &ModelManagerSupportClang::onProjectPartsRemoved);
|
2013-12-10 14:37:32 +01:00
|
|
|
}
|
|
|
|
|
|
2015-05-08 15:48:17 +02:00
|
|
|
ModelManagerSupportClang::~ModelManagerSupportClang()
|
2013-12-10 14:37:32 +01:00
|
|
|
{
|
2015-07-06 11:15:12 +02:00
|
|
|
m_instance_forTestsOnly = 0;
|
2013-12-10 14:37:32 +01:00
|
|
|
}
|
|
|
|
|
|
2015-05-08 15:48:17 +02:00
|
|
|
CppTools::CppCompletionAssistProvider *ModelManagerSupportClang::completionAssistProvider()
|
2013-12-10 14:37:32 +01:00
|
|
|
{
|
2015-06-16 13:59:08 +02:00
|
|
|
return &m_completionAssistProvider;
|
2013-12-10 14:37:32 +01:00
|
|
|
}
|
|
|
|
|
|
2015-05-08 15:48:17 +02:00
|
|
|
CppTools::BaseEditorDocumentProcessor *ModelManagerSupportClang::editorDocumentProcessor(
|
2014-09-22 18:43:31 +02:00
|
|
|
TextEditor::TextDocument *baseTextDocument)
|
2013-12-10 14:37:32 +01:00
|
|
|
{
|
2015-05-08 15:48:17 +02:00
|
|
|
return new ClangEditorDocumentProcessor(this, baseTextDocument);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
void ModelManagerSupportClang::onCurrentEditorChanged(Core::IEditor *newCurrent)
|
|
|
|
|
{
|
|
|
|
|
// If we switch away from a cpp editor, update the backend about
|
|
|
|
|
// the document's unsaved content.
|
|
|
|
|
if (m_previousCppEditor && m_previousCppEditor->document()->isModified()) {
|
2015-08-31 16:10:36 +02:00
|
|
|
m_ipcCommunicator.updateTranslationUnitFromCppEditorDocument(
|
2015-05-08 15:48:17 +02:00
|
|
|
m_previousCppEditor->document()->filePath().toString());
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
// Remember previous editor
|
|
|
|
|
if (newCurrent && cppModelManager()->isCppEditor(newCurrent))
|
|
|
|
|
m_previousCppEditor = newCurrent;
|
|
|
|
|
else
|
|
|
|
|
m_previousCppEditor.clear();
|
|
|
|
|
}
|
|
|
|
|
|
2015-08-31 16:10:36 +02:00
|
|
|
void ModelManagerSupportClang::connectTextDocumentToTranslationUnit(TextEditor::TextDocument *textDocument)
|
|
|
|
|
{
|
|
|
|
|
// Handle externally changed documents
|
2015-09-15 16:24:52 +02:00
|
|
|
connect(textDocument, &Core::IDocument::aboutToReload,
|
|
|
|
|
this, &ModelManagerSupportClang::onCppDocumentAboutToReloadOnTranslationUnit,
|
|
|
|
|
Qt::UniqueConnection);
|
2015-08-31 16:10:36 +02:00
|
|
|
connect(textDocument, &Core::IDocument::reloadFinished,
|
|
|
|
|
this, &ModelManagerSupportClang::onCppDocumentReloadFinishedOnTranslationUnit,
|
|
|
|
|
Qt::UniqueConnection);
|
|
|
|
|
|
|
|
|
|
// Handle changes from e.g. refactoring actions
|
2015-09-15 16:24:52 +02:00
|
|
|
connectToTextDocumentContentsChangedForTranslationUnit(textDocument);
|
2015-08-31 16:10:36 +02:00
|
|
|
}
|
|
|
|
|
|
|
|
|
|
void ModelManagerSupportClang::connectTextDocumentToUnsavedFiles(TextEditor::TextDocument *textDocument)
|
|
|
|
|
{
|
|
|
|
|
// Handle externally changed documents
|
2015-09-15 16:24:52 +02:00
|
|
|
connect(textDocument, &Core::IDocument::aboutToReload,
|
|
|
|
|
this, &ModelManagerSupportClang::onCppDocumentAboutToReloadOnUnsavedFile,
|
|
|
|
|
Qt::UniqueConnection);
|
2015-08-31 16:10:36 +02:00
|
|
|
connect(textDocument, &Core::IDocument::reloadFinished,
|
|
|
|
|
this, &ModelManagerSupportClang::onCppDocumentReloadFinishedOnUnsavedFile,
|
|
|
|
|
Qt::UniqueConnection);
|
|
|
|
|
|
|
|
|
|
// Handle changes from e.g. refactoring actions
|
2015-09-15 16:24:52 +02:00
|
|
|
connectToTextDocumentContentsChangedForUnsavedFile(textDocument);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
void ModelManagerSupportClang::connectToTextDocumentContentsChangedForTranslationUnit(
|
|
|
|
|
TextEditor::TextDocument *textDocument)
|
|
|
|
|
{
|
|
|
|
|
connect(textDocument, &TextEditor::TextDocument::contentsChangedWithPosition,
|
|
|
|
|
this, &ModelManagerSupportClang::onCppDocumentContentsChangedOnTranslationUnit,
|
|
|
|
|
Qt::UniqueConnection);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
void ModelManagerSupportClang::connectToTextDocumentContentsChangedForUnsavedFile(
|
|
|
|
|
TextEditor::TextDocument *textDocument)
|
|
|
|
|
{
|
|
|
|
|
connect(textDocument, &TextEditor::TextDocument::contentsChangedWithPosition,
|
2015-08-31 16:10:36 +02:00
|
|
|
this, &ModelManagerSupportClang::onCppDocumentContentsChangedOnUnsavedFile,
|
|
|
|
|
Qt::UniqueConnection);
|
|
|
|
|
}
|
|
|
|
|
|
2015-08-24 18:26:09 +02:00
|
|
|
void ModelManagerSupportClang::connectToWidgetsMarkContextMenuRequested(QWidget *editorWidget)
|
|
|
|
|
{
|
|
|
|
|
const auto widget = qobject_cast<TextEditor::TextEditorWidget *>(editorWidget);
|
|
|
|
|
if (widget) {
|
|
|
|
|
connect(widget, &TextEditor::TextEditorWidget::markContextMenuRequested,
|
|
|
|
|
this, &ModelManagerSupportClang::onTextMarkContextMenuRequested);
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
2015-05-08 15:48:17 +02:00
|
|
|
void ModelManagerSupportClang::onEditorOpened(Core::IEditor *editor)
|
|
|
|
|
{
|
|
|
|
|
QTC_ASSERT(editor, return);
|
|
|
|
|
Core::IDocument *document = editor->document();
|
|
|
|
|
QTC_ASSERT(document, return);
|
|
|
|
|
TextEditor::TextDocument *textDocument = qobject_cast<TextEditor::TextDocument *>(document);
|
|
|
|
|
|
2015-07-08 15:08:13 +02:00
|
|
|
if (textDocument && cppModelManager()->isCppEditor(editor)) {
|
2015-11-11 10:47:27 +01:00
|
|
|
connectTextDocumentToTranslationUnit(textDocument);
|
|
|
|
|
connectToWidgetsMarkContextMenuRequested(editor->widget());
|
2015-05-08 15:48:17 +02:00
|
|
|
|
|
|
|
|
// TODO: Ensure that not fully loaded documents are updated?
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
2015-09-15 16:24:52 +02:00
|
|
|
void ModelManagerSupportClang::onCppDocumentAboutToReloadOnTranslationUnit()
|
|
|
|
|
{
|
|
|
|
|
TextEditor::TextDocument *textDocument = qobject_cast<TextEditor::TextDocument *>(sender());
|
|
|
|
|
disconnect(textDocument, &TextEditor::TextDocument::contentsChangedWithPosition,
|
|
|
|
|
this, &ModelManagerSupportClang::onCppDocumentContentsChangedOnTranslationUnit);
|
|
|
|
|
}
|
|
|
|
|
|
2015-08-31 16:10:36 +02:00
|
|
|
void ModelManagerSupportClang::onCppDocumentReloadFinishedOnTranslationUnit(bool success)
|
2015-05-08 15:48:17 +02:00
|
|
|
{
|
2015-08-31 16:10:36 +02:00
|
|
|
if (success) {
|
2015-09-15 16:24:52 +02:00
|
|
|
TextEditor::TextDocument *textDocument = qobject_cast<TextEditor::TextDocument *>(sender());
|
|
|
|
|
connectToTextDocumentContentsChangedForTranslationUnit(textDocument);
|
|
|
|
|
m_ipcCommunicator.requestDiagnostics(textDocument);
|
2015-08-31 16:10:36 +02:00
|
|
|
}
|
|
|
|
|
}
|
2015-05-08 15:48:17 +02:00
|
|
|
|
2015-09-28 17:42:43 +02:00
|
|
|
void ModelManagerSupportClang::onCppDocumentContentsChangedOnTranslationUnit(int position,
|
|
|
|
|
int /*charsRemoved*/,
|
|
|
|
|
int /*charsAdded*/)
|
2015-08-31 16:10:36 +02:00
|
|
|
{
|
2015-05-08 15:48:17 +02:00
|
|
|
Core::IDocument *document = qobject_cast<Core::IDocument *>(sender());
|
2015-09-28 17:42:43 +02:00
|
|
|
|
|
|
|
|
m_ipcCommunicator.updateChangeContentStartPosition(document->filePath().toString(),
|
|
|
|
|
position);
|
2015-08-31 16:10:36 +02:00
|
|
|
m_ipcCommunicator.updateTranslationUnitIfNotCurrentDocument(document);
|
|
|
|
|
}
|
|
|
|
|
|
2015-09-15 16:24:52 +02:00
|
|
|
void ModelManagerSupportClang::onCppDocumentAboutToReloadOnUnsavedFile()
|
|
|
|
|
{
|
|
|
|
|
TextEditor::TextDocument *textDocument = qobject_cast<TextEditor::TextDocument *>(sender());
|
|
|
|
|
disconnect(textDocument, &TextEditor::TextDocument::contentsChangedWithPosition,
|
|
|
|
|
this, &ModelManagerSupportClang::onCppDocumentContentsChangedOnUnsavedFile);
|
|
|
|
|
}
|
|
|
|
|
|
2015-08-31 16:10:36 +02:00
|
|
|
void ModelManagerSupportClang::onCppDocumentReloadFinishedOnUnsavedFile(bool success)
|
|
|
|
|
{
|
|
|
|
|
if (success) {
|
2015-09-15 16:24:52 +02:00
|
|
|
TextEditor::TextDocument *textDocument = qobject_cast<TextEditor::TextDocument *>(sender());
|
|
|
|
|
connectToTextDocumentContentsChangedForUnsavedFile(textDocument);
|
|
|
|
|
m_ipcCommunicator.updateUnsavedFile(textDocument);
|
2015-08-31 16:10:36 +02:00
|
|
|
}
|
2015-05-08 15:48:17 +02:00
|
|
|
}
|
|
|
|
|
|
2015-08-31 16:10:36 +02:00
|
|
|
void ModelManagerSupportClang::onCppDocumentContentsChangedOnUnsavedFile()
|
2015-05-08 15:48:17 +02:00
|
|
|
{
|
|
|
|
|
Core::IDocument *document = qobject_cast<Core::IDocument *>(sender());
|
2015-08-31 16:10:36 +02:00
|
|
|
m_ipcCommunicator.updateUnsavedFile(document);
|
2015-05-08 15:48:17 +02:00
|
|
|
}
|
|
|
|
|
|
|
|
|
|
void ModelManagerSupportClang::onAbstractEditorSupportContentsUpdated(const QString &filePath,
|
|
|
|
|
const QByteArray &content)
|
|
|
|
|
{
|
|
|
|
|
QTC_ASSERT(!filePath.isEmpty(), return);
|
2015-08-31 12:40:14 +02:00
|
|
|
m_ipcCommunicator.updateUnsavedFile(filePath, content, 0);
|
2015-05-08 15:48:17 +02:00
|
|
|
}
|
|
|
|
|
|
|
|
|
|
void ModelManagerSupportClang::onAbstractEditorSupportRemoved(const QString &filePath)
|
|
|
|
|
{
|
|
|
|
|
QTC_ASSERT(!filePath.isEmpty(), return);
|
|
|
|
|
if (!cppModelManager()->cppEditorDocument(filePath)) {
|
2015-07-14 17:30:17 +02:00
|
|
|
const QString projectPartId = Utils::projectPartIdForFile(filePath);
|
2015-08-31 16:10:36 +02:00
|
|
|
m_ipcCommunicator.unregisterUnsavedFilesForEditor({{filePath, projectPartId}});
|
2015-05-08 15:48:17 +02:00
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
2015-08-24 18:26:09 +02:00
|
|
|
void addFixItsActionsToMenu(QMenu *menu, const TextEditor::QuickFixOperations &fixItOperations)
|
|
|
|
|
{
|
|
|
|
|
foreach (const auto &fixItOperation, fixItOperations) {
|
|
|
|
|
QAction *action = menu->addAction(fixItOperation->description());
|
|
|
|
|
QObject::connect(action, &QAction::triggered, [fixItOperation]() {
|
|
|
|
|
fixItOperation->perform();
|
|
|
|
|
});
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
static int lineToPosition(const QTextDocument *textDocument, int lineNumber)
|
|
|
|
|
{
|
|
|
|
|
QTC_ASSERT(textDocument, return 0);
|
|
|
|
|
const QTextBlock textBlock = textDocument->findBlockByLineNumber(lineNumber);
|
|
|
|
|
return textBlock.isValid() ? textBlock.position() - 1 : 0;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
static TextEditor::AssistInterface createAssistInterface(TextEditor::TextEditorWidget *widget,
|
|
|
|
|
int lineNumber)
|
|
|
|
|
{
|
|
|
|
|
return TextEditor::AssistInterface(widget->document(),
|
|
|
|
|
lineToPosition(widget->document(), lineNumber),
|
|
|
|
|
widget->textDocument()->filePath().toString(),
|
|
|
|
|
TextEditor::IdleEditor);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
void ModelManagerSupportClang::onTextMarkContextMenuRequested(TextEditor::TextEditorWidget *widget,
|
|
|
|
|
int lineNumber,
|
|
|
|
|
QMenu *menu)
|
|
|
|
|
{
|
|
|
|
|
QTC_ASSERT(widget, return);
|
|
|
|
|
QTC_ASSERT(lineNumber >= 1, return);
|
|
|
|
|
QTC_ASSERT(menu, return);
|
|
|
|
|
|
|
|
|
|
const auto filePath = widget->textDocument()->filePath().toString();
|
|
|
|
|
ClangEditorDocumentProcessor *processor = ClangEditorDocumentProcessor::get(filePath);
|
|
|
|
|
if (processor) {
|
|
|
|
|
const auto assistInterface = createAssistInterface(widget, lineNumber);
|
|
|
|
|
const auto fixItOperations = processor->extraRefactoringOperations(assistInterface);
|
|
|
|
|
|
|
|
|
|
addFixItsActionsToMenu(menu, fixItOperations);
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
2015-05-08 15:48:17 +02:00
|
|
|
void ModelManagerSupportClang::onProjectPartsUpdated(ProjectExplorer::Project *project)
|
|
|
|
|
{
|
|
|
|
|
QTC_ASSERT(project, return);
|
|
|
|
|
const CppTools::ProjectInfo projectInfo = cppModelManager()->projectInfo(project);
|
|
|
|
|
QTC_ASSERT(projectInfo.isValid(), return);
|
2015-11-06 16:58:24 +01:00
|
|
|
|
2015-06-16 13:59:08 +02:00
|
|
|
m_ipcCommunicator.registerProjectsParts(projectInfo.projectParts());
|
2015-11-06 16:58:24 +01:00
|
|
|
m_ipcCommunicator.registerFallbackProjectPart();
|
2015-05-08 15:48:17 +02:00
|
|
|
}
|
|
|
|
|
|
2015-07-14 17:30:17 +02:00
|
|
|
void ModelManagerSupportClang::onProjectPartsRemoved(const QStringList &projectPartIds)
|
2015-05-08 15:48:17 +02:00
|
|
|
{
|
2015-09-18 12:19:46 +02:00
|
|
|
if (!projectPartIds.isEmpty()) {
|
|
|
|
|
unregisterTranslationUnitsWithProjectParts(projectPartIds);
|
2015-08-31 14:36:58 +02:00
|
|
|
m_ipcCommunicator.unregisterProjectPartsForEditor(projectPartIds);
|
2015-11-06 16:58:24 +01:00
|
|
|
m_ipcCommunicator.registerFallbackProjectPart();
|
2015-09-18 12:19:46 +02:00
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
static QVector<ClangEditorDocumentProcessor *>
|
|
|
|
|
clangProcessorsWithProjectParts(const QStringList &projectPartIds)
|
|
|
|
|
{
|
|
|
|
|
QVector<ClangEditorDocumentProcessor *> result;
|
|
|
|
|
|
|
|
|
|
foreach (auto *editorDocument, cppModelManager()->cppEditorDocuments()) {
|
|
|
|
|
auto *processor = editorDocument->processor();
|
|
|
|
|
auto *clangProcessor = qobject_cast<ClangEditorDocumentProcessor *>(processor);
|
|
|
|
|
if (clangProcessor && clangProcessor->hasProjectPart()) {
|
|
|
|
|
if (projectPartIds.contains(clangProcessor->projectPart()->id()))
|
|
|
|
|
result.append(clangProcessor);
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
return result;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
void ModelManagerSupportClang::unregisterTranslationUnitsWithProjectParts(
|
|
|
|
|
const QStringList &projectPartIds)
|
|
|
|
|
{
|
|
|
|
|
const auto processors = clangProcessorsWithProjectParts(projectPartIds);
|
|
|
|
|
foreach (ClangEditorDocumentProcessor *processor, processors) {
|
2015-10-05 11:17:03 +02:00
|
|
|
m_ipcCommunicator.unregisterTranslationUnitsForEditor({processor->fileContainer()});
|
2015-09-18 12:19:46 +02:00
|
|
|
processor->clearProjectPart();
|
|
|
|
|
processor->run();
|
|
|
|
|
}
|
2015-05-08 15:48:17 +02:00
|
|
|
}
|
|
|
|
|
|
2015-07-06 11:15:12 +02:00
|
|
|
#ifdef QT_TESTLIB_LIB
|
|
|
|
|
ModelManagerSupportClang *ModelManagerSupportClang::instance_forTestsOnly()
|
2015-05-08 15:48:17 +02:00
|
|
|
{
|
2015-07-06 11:15:12 +02:00
|
|
|
return m_instance_forTestsOnly;
|
2015-05-08 15:48:17 +02:00
|
|
|
}
|
2015-07-06 11:15:12 +02:00
|
|
|
#endif
|
2015-05-08 15:48:17 +02:00
|
|
|
|
2015-06-16 13:59:08 +02:00
|
|
|
IpcCommunicator &ModelManagerSupportClang::ipcCommunicator()
|
2015-05-08 15:48:17 +02:00
|
|
|
{
|
|
|
|
|
return m_ipcCommunicator;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
QString ModelManagerSupportProviderClang::id() const
|
|
|
|
|
{
|
|
|
|
|
return QLatin1String(Constants::CLANG_MODELMANAGERSUPPORT_ID);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
QString ModelManagerSupportProviderClang::displayName() const
|
|
|
|
|
{
|
|
|
|
|
//: Display name
|
|
|
|
|
return QCoreApplication::translate("ClangCodeModel::Internal::ModelManagerSupport",
|
|
|
|
|
"Clang");
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
CppTools::ModelManagerSupport::Ptr ModelManagerSupportProviderClang::createModelManagerSupport()
|
|
|
|
|
{
|
|
|
|
|
return CppTools::ModelManagerSupport::Ptr(new ModelManagerSupportClang);
|
2013-12-10 14:37:32 +01:00
|
|
|
}
|