Commit 0fca74d5 authored by Marco Bubke's avatar Marco Bubke

CppTools: Break TextDocument dependency of BaseEditorDocumentProcessor

BaseEditorDocumentProcessor was holding a TextEditor::TextDocument but
only used the QTextDocument and the file path.

Change-Id: I349cc95d973adeaf9f94638d84333f592c14e7f9
Reviewed-by: default avatarNikolai Kosjar <nikolai.kosjar@theqtcompany.com>
parent 369b1f7f
......@@ -64,7 +64,7 @@ namespace Internal {
ClangEditorDocumentProcessor::ClangEditorDocumentProcessor(
IpcCommunicator &ipcCommunicator,
TextEditor::TextDocument *document)
: BaseEditorDocumentProcessor(document)
: BaseEditorDocumentProcessor(document->document(), document->filePath().toString())
, m_diagnosticManager(document)
, m_ipcCommunicator(ipcCommunicator)
, m_parser(new ClangEditorDocumentParser(document->filePath().toString()))
......@@ -344,7 +344,7 @@ ClangEditorDocumentProcessor::fileContainerWithDocumentContent(const QString &pr
{
return ClangBackEnd::FileContainer(filePath(),
projectpartId,
baseTextDocument()->plainText(),
textDocument()->toPlainText(),
true,
revision());
}
......
......@@ -45,9 +45,10 @@ namespace CppTools {
semantic calculations) after a text document has changed.
*/
BaseEditorDocumentProcessor::BaseEditorDocumentProcessor(
TextEditor::TextDocument *document)
: m_baseTextDocument(document)
BaseEditorDocumentProcessor::BaseEditorDocumentProcessor(QTextDocument *textDocument,
const QString &filePath)
: m_filePath(filePath),
m_textDocument(textDocument)
{
}
......@@ -55,11 +56,6 @@ BaseEditorDocumentProcessor::~BaseEditorDocumentProcessor()
{
}
TextEditor::TextDocument *BaseEditorDocumentProcessor::baseTextDocument() const
{
return m_baseTextDocument;
}
TextEditor::QuickFixOperations
BaseEditorDocumentProcessor::extraRefactoringOperations(const TextEditor::AssistInterface &)
{
......
......@@ -55,11 +55,9 @@ class CPPTOOLS_EXPORT BaseEditorDocumentProcessor : public QObject
Q_OBJECT
public:
BaseEditorDocumentProcessor(TextEditor::TextDocument *document);
BaseEditorDocumentProcessor(QTextDocument *textDocument, const QString &filePath);
virtual ~BaseEditorDocumentProcessor();
TextEditor::TextDocument *baseTextDocument() const;
// Function interface to implement
virtual void run() = 0;
virtual void semanticRehighlight() = 0;
......@@ -92,12 +90,13 @@ protected:
const CppTools::WorkingCopy workingCopy);
// Convenience
QString filePath() const { return m_baseTextDocument->filePath().toString(); }
unsigned revision() const { return static_cast<unsigned>(textDocument()->revision()); }
QTextDocument *textDocument() const { return m_baseTextDocument->document(); }
QString filePath() const { return m_filePath; }
unsigned revision() const { return static_cast<unsigned>(m_textDocument->revision()); }
QTextDocument *textDocument() const { return m_textDocument; }
private:
TextEditor::TextDocument *m_baseTextDocument;
QString m_filePath;
QTextDocument *m_textDocument;
};
} // namespace CppTools
......
......@@ -166,7 +166,7 @@ namespace CppTools {
BuiltinEditorDocumentProcessor::BuiltinEditorDocumentProcessor(
TextEditor::TextDocument *document,
bool enableSemanticHighlighter)
: BaseEditorDocumentProcessor(document)
: BaseEditorDocumentProcessor(document->document(), document->filePath().toString())
, m_parser(new BuiltinEditorDocumentParser(document->filePath().toString()))
, m_codeWarningsUpdated(false)
, m_semanticHighlighter(enableSemanticHighlighter
......@@ -186,7 +186,7 @@ BuiltinEditorDocumentProcessor::BuiltinEditorDocumentProcessor(
[this]() -> QFuture<TextEditor::HighlightingResult> {
const SemanticInfo semanticInfo = m_semanticInfoUpdater.semanticInfo();
CheckSymbols *checkSymbols = createHighlighter(semanticInfo.doc, semanticInfo.snapshot,
baseTextDocument()->document());
textDocument());
QTC_ASSERT(checkSymbols, return QFuture<TextEditor::HighlightingResult>());
connect(checkSymbols, &CheckSymbols::codeWarningsUpdated,
this, &BuiltinEditorDocumentProcessor::onCodeWarningsUpdated);
......
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