Commit 9ccb6b81 authored by Nikolai Kosjar's avatar Nikolai Kosjar

CppTools: Fix include hierarchy for clang code model

This makes the editor document snapshot accessible through
BaseEditorDocumentProcessor since we need it for the include hierarchy
if the the clang code model is activated.

Task-number: QTCREATORBUG-13553
Change-Id: I7214cc578d05fe5cad6e12b4d29fe6f840a88e8d
Reviewed-by: default avatarErik Verbruggen <erik.verbruggen@theqtcompany.com>
parent 488bf917
......@@ -160,6 +160,11 @@ CppTools::BaseEditorDocumentParser *ClangEditorDocumentProcessor::parser()
return &m_parser;
}
CPlusPlus::Snapshot ClangEditorDocumentProcessor::snapshot()
{
return m_builtinProcessor.snapshot();
}
bool ClangEditorDocumentProcessor::isParserRunning() const
{
return m_parserWatcher.isRunning();
......
......@@ -37,7 +37,6 @@
#include <cpptools/builtineditordocumentprocessor.h>
#include <cpptools/semantichighlighter.h>
#include <QFutureWatcher>
namespace ClangCodeModel {
......@@ -55,6 +54,7 @@ public:
void semanticRehighlight(bool force) Q_DECL_OVERRIDE;
CppTools::SemanticInfo recalculateSemanticInfo() Q_DECL_OVERRIDE;
CppTools::BaseEditorDocumentParser *parser() Q_DECL_OVERRIDE;
CPlusPlus::Snapshot snapshot() Q_DECL_OVERRIDE;
bool isParserRunning() const Q_DECL_OVERRIDE;
private slots:
......
......@@ -35,7 +35,7 @@
#include <coreplugin/editormanager/editormanager.h>
#include <coreplugin/icore.h>
#include <cpptools/builtineditordocumentparser.h>
#include <cpptools/baseeditordocumentprocessor.h>
#include <cpptools/cppcodemodelinspectordumper.h>
#include <cpptools/cppmodelmanager.h>
#include <cpptools/cppworkingcopy.h>
......@@ -1365,8 +1365,8 @@ void CppCodeModelInspectorDialog::refresh()
if (editor) {
const QString editorFilePath = editor->document()->filePath();
editorDocument = cmmi->editorDocument(editorFilePath);
if (auto *builtinDocumentParser = BuiltinEditorDocumentParser::get(editorFilePath)) {
const CPlusPlus::Snapshot editorSnapshot = builtinDocumentParser->snapshot();
if (auto *documentProcessor = BaseEditorDocumentProcessor::get(editorFilePath)) {
const CPlusPlus::Snapshot editorSnapshot = documentProcessor->snapshot();
m_snapshotInfos->append(SnapshotInfo(editorSnapshot, SnapshotInfo::EditorSnapshot));
const QString editorSnapshotTitle
= QString::fromLatin1("Current Editor's Snapshot (%1 Documents)")
......
......@@ -33,7 +33,7 @@
#include "cppincludehierarchyitem.h"
#include <coreplugin/fileiconprovider.h>
#include <cpptools/builtineditordocumentparser.h>
#include <cpptools/baseeditordocumentprocessor.h>
#include <cpptools/cppmodelmanager.h>
#include <cpptools/editordocumenthandle.h>
#include <texteditor/texteditor.h>
......@@ -184,9 +184,9 @@ void CppIncludeHierarchyModel::fetchMore(const QModelIndex &parent)
}
if (item == m_includesItem) {
auto *parser = BuiltinEditorDocumentParser::get(editorFilePath);
QTC_ASSERT(parser, return);
const Snapshot editorDocumentSnapshot = parser->snapshot();
auto *processor = BaseEditorDocumentProcessor::get(editorFilePath);
QTC_ASSERT(processor, return);
const Snapshot editorDocumentSnapshot = processor->snapshot();
buildHierarchyIncludes_helper(parentItem->filePath(), parentItem,
editorDocumentSnapshot, &cyclic);
} else {
......@@ -286,11 +286,11 @@ void CppIncludeHierarchyModel::buildHierarchyIncludes(const QString &currentFile
return;
const QString editorFilePath = m_editor->document()->filePath();
auto *parser = BuiltinEditorDocumentParser::get(editorFilePath);
QTC_ASSERT(parser, return);
const Snapshot snapshot = parser->snapshot();
auto *documentProcessor = BaseEditorDocumentProcessor::get(editorFilePath);
QTC_ASSERT(documentProcessor, return);
const Snapshot editorDocumentSnapshot = documentProcessor->snapshot();
QSet<QString> cyclic;
buildHierarchyIncludes_helper(currentFilePath, m_includesItem, snapshot, &cyclic);
buildHierarchyIncludes_helper(currentFilePath, m_includesItem, editorDocumentSnapshot, &cyclic);
}
void CppIncludeHierarchyModel::buildHierarchyIncludes_helper(const QString &filePath,
......
......@@ -59,6 +59,7 @@ public:
virtual void run() = 0;
virtual void semanticRehighlight(bool force) = 0;
virtual CppTools::SemanticInfo recalculateSemanticInfo() = 0;
virtual CPlusPlus::Snapshot snapshot() = 0;
virtual BaseEditorDocumentParser *parser() = 0;
virtual bool isParserRunning() const = 0;
......
......@@ -174,6 +174,11 @@ BaseEditorDocumentParser *BuiltinEditorDocumentProcessor::parser()
return &m_parser;
}
CPlusPlus::Snapshot BuiltinEditorDocumentProcessor::snapshot()
{
return m_parser.snapshot();
}
void BuiltinEditorDocumentProcessor::semanticRehighlight(bool force)
{
const auto source = createSemanticInfoSource(force);
......
......@@ -37,7 +37,6 @@
#include "cpptools_global.h"
#include "semantichighlighter.h"
namespace CppTools {
class CPPTOOLS_EXPORT BuiltinEditorDocumentProcessor : public BaseEditorDocumentProcessor
......@@ -55,6 +54,7 @@ public:
void semanticRehighlight(bool force) Q_DECL_OVERRIDE;
CppTools::SemanticInfo recalculateSemanticInfo() Q_DECL_OVERRIDE;
BaseEditorDocumentParser *parser() Q_DECL_OVERRIDE;
CPlusPlus::Snapshot snapshot() Q_DECL_OVERRIDE;
bool isParserRunning() const Q_DECL_OVERRIDE;
private:
......
......@@ -30,7 +30,7 @@
#include "cpptoolsplugin.h"
#include "builtineditordocumentparser.h"
#include "baseeditordocumentprocessor.h"
#include "cppmodelmanager.h"
#include "cppsourceprocessertesthelper.h"
#include "cppsourceprocessor.h"
......@@ -143,9 +143,9 @@ void CppToolsPlugin::test_cppsourceprocessor_includes_cyclic()
// Check editor snapshot
const QString filePath = editor->document()->filePath();
auto *parser = BuiltinEditorDocumentParser::get(filePath);
QVERIFY(parser);
Snapshot snapshot = parser->snapshot();
auto *processor = BaseEditorDocumentProcessor::get(filePath);
QVERIFY(processor);
Snapshot snapshot = processor->snapshot();
QCOMPARE(snapshot.size(), 3); // Configuration file included
// Check includes
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment