forked from qt-creator/qt-creator
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: Nikolai Kosjar <nikolai.kosjar@theqtcompany.com>
This commit is contained in:
@@ -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);
|
||||
|
Reference in New Issue
Block a user