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