forked from qt-creator/qt-creator
CppTools/Clang: Remove QScopedPointers in *EditorDocumentParsers
...since they are pointless. Change-Id: I1c7925d3b1ad33ac0f1dc372797e3ab9a4bdc4b3 Reviewed-by: Erik Verbruggen <erik.verbruggen@digia.com>
This commit is contained in:
@@ -92,7 +92,7 @@ namespace ClangCodeModel {
|
|||||||
|
|
||||||
ClangEditorDocumentProcessor::ClangEditorDocumentProcessor(TextEditor::BaseTextDocument *document)
|
ClangEditorDocumentProcessor::ClangEditorDocumentProcessor(TextEditor::BaseTextDocument *document)
|
||||||
: BaseEditorDocumentProcessor(document)
|
: BaseEditorDocumentProcessor(document)
|
||||||
, m_parser(new ClangEditorDocumentParser(document->filePath()))
|
, m_parser(document->filePath())
|
||||||
, m_parserRevision(0)
|
, m_parserRevision(0)
|
||||||
, m_semanticHighlighter(document)
|
, m_semanticHighlighter(document)
|
||||||
, m_builtinProcessor(document, /*enableSemanticHighlighter=*/ false)
|
, m_builtinProcessor(document, /*enableSemanticHighlighter=*/ false)
|
||||||
@@ -109,7 +109,7 @@ ClangEditorDocumentProcessor::ClangEditorDocumentProcessor(TextEditor::BaseTextD
|
|||||||
const int firstLine = 1;
|
const int firstLine = 1;
|
||||||
const int lastLine = baseTextDocument()->document()->blockCount();
|
const int lastLine = baseTextDocument()->document()->blockCount();
|
||||||
|
|
||||||
CreateMarkers *createMarkers = CreateMarkers::create(m_parser->semanticMarker(),
|
CreateMarkers *createMarkers = CreateMarkers::create(m_parser.semanticMarker(),
|
||||||
baseTextDocument()->filePath(),
|
baseTextDocument()->filePath(),
|
||||||
firstLine, lastLine);
|
firstLine, lastLine);
|
||||||
return createMarkers->start();
|
return createMarkers->start();
|
||||||
@@ -155,7 +155,7 @@ CppTools::SemanticInfo ClangEditorDocumentProcessor::recalculateSemanticInfo()
|
|||||||
|
|
||||||
CppTools::BaseEditorDocumentParser *ClangEditorDocumentProcessor::parser()
|
CppTools::BaseEditorDocumentParser *ClangEditorDocumentProcessor::parser()
|
||||||
{
|
{
|
||||||
return m_parser.data();
|
return &m_parser;
|
||||||
}
|
}
|
||||||
|
|
||||||
bool ClangEditorDocumentProcessor::isParserRunning() const
|
bool ClangEditorDocumentProcessor::isParserRunning() const
|
||||||
@@ -169,11 +169,11 @@ void ClangEditorDocumentProcessor::onParserFinished()
|
|||||||
return;
|
return;
|
||||||
|
|
||||||
// Emit ifdefed out blocks
|
// Emit ifdefed out blocks
|
||||||
const auto ifdefoutBlocks = toTextEditorBlocks(m_parser->ifdefedOutBlocks());
|
const auto ifdefoutBlocks = toTextEditorBlocks(m_parser.ifdefedOutBlocks());
|
||||||
emit ifdefedOutBlocksUpdated(revision(), ifdefoutBlocks);
|
emit ifdefedOutBlocksUpdated(revision(), ifdefoutBlocks);
|
||||||
|
|
||||||
// Emit code warnings
|
// Emit code warnings
|
||||||
const auto diagnostics = toCppToolsDiagnostics(filePath(), m_parser->diagnostics());
|
const auto diagnostics = toCppToolsDiagnostics(filePath(), m_parser.diagnostics());
|
||||||
const auto codeWarnings = toTextEditorSelections(diagnostics, textDocument());
|
const auto codeWarnings = toTextEditorSelections(diagnostics, textDocument());
|
||||||
emit codeWarningsUpdated(revision(), codeWarnings);
|
emit codeWarningsUpdated(revision(), codeWarnings);
|
||||||
|
|
||||||
|
|||||||
@@ -61,7 +61,7 @@ private slots:
|
|||||||
void onParserFinished();
|
void onParserFinished();
|
||||||
|
|
||||||
private:
|
private:
|
||||||
QScopedPointer<ClangEditorDocumentParser> m_parser;
|
ClangEditorDocumentParser m_parser;
|
||||||
QFutureWatcher<void> m_parserWatcher;
|
QFutureWatcher<void> m_parserWatcher;
|
||||||
unsigned m_parserRevision;
|
unsigned m_parserRevision;
|
||||||
|
|
||||||
|
|||||||
@@ -131,7 +131,7 @@ BuiltinEditorDocumentProcessor::BuiltinEditorDocumentProcessor(
|
|||||||
TextEditor::BaseTextDocument *document,
|
TextEditor::BaseTextDocument *document,
|
||||||
bool enableSemanticHighlighter)
|
bool enableSemanticHighlighter)
|
||||||
: BaseEditorDocumentProcessor(document)
|
: BaseEditorDocumentProcessor(document)
|
||||||
, m_parser(new BuiltinEditorDocumentParser(document->filePath()))
|
, m_parser(document->filePath())
|
||||||
, m_semanticHighlighter(enableSemanticHighlighter
|
, m_semanticHighlighter(enableSemanticHighlighter
|
||||||
? new CppTools::SemanticHighlighter(document)
|
? new CppTools::SemanticHighlighter(document)
|
||||||
: 0)
|
: 0)
|
||||||
@@ -139,7 +139,7 @@ BuiltinEditorDocumentProcessor::BuiltinEditorDocumentProcessor(
|
|||||||
using namespace Internal;
|
using namespace Internal;
|
||||||
|
|
||||||
QSharedPointer<CppCodeModelSettings> cms = CppToolsPlugin::instance()->codeModelSettings();
|
QSharedPointer<CppCodeModelSettings> cms = CppToolsPlugin::instance()->codeModelSettings();
|
||||||
m_parser->setUsePrecompiledHeaders(cms->pchUsage() != CppCodeModelSettings::PchUse_None);
|
m_parser.setUsePrecompiledHeaders(cms->pchUsage() != CppCodeModelSettings::PchUse_None);
|
||||||
|
|
||||||
if (m_semanticHighlighter) {
|
if (m_semanticHighlighter) {
|
||||||
m_semanticHighlighter->setHighlightingRunner(
|
m_semanticHighlighter->setHighlightingRunner(
|
||||||
@@ -150,7 +150,7 @@ BuiltinEditorDocumentProcessor::BuiltinEditorDocumentProcessor(
|
|||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
connect(m_parser.data(), &BuiltinEditorDocumentParser::finished,
|
connect(&m_parser, &BuiltinEditorDocumentParser::finished,
|
||||||
this, &BuiltinEditorDocumentProcessor::onParserFinished);
|
this, &BuiltinEditorDocumentProcessor::onParserFinished);
|
||||||
connect(&m_semanticInfoUpdater, &SemanticInfoUpdater::updated,
|
connect(&m_semanticInfoUpdater, &SemanticInfoUpdater::updated,
|
||||||
this, &BuiltinEditorDocumentProcessor::onSemanticInfoUpdated);
|
this, &BuiltinEditorDocumentProcessor::onSemanticInfoUpdated);
|
||||||
@@ -169,7 +169,7 @@ void BuiltinEditorDocumentProcessor::run()
|
|||||||
|
|
||||||
BaseEditorDocumentParser *BuiltinEditorDocumentProcessor::parser()
|
BaseEditorDocumentParser *BuiltinEditorDocumentProcessor::parser()
|
||||||
{
|
{
|
||||||
return m_parser.data();
|
return &m_parser;
|
||||||
}
|
}
|
||||||
|
|
||||||
void BuiltinEditorDocumentProcessor::semanticRehighlight(bool force)
|
void BuiltinEditorDocumentProcessor::semanticRehighlight(bool force)
|
||||||
@@ -189,13 +189,6 @@ bool BuiltinEditorDocumentProcessor::isParserRunning() const
|
|||||||
return m_parserFuture.isRunning();
|
return m_parserFuture.isRunning();
|
||||||
}
|
}
|
||||||
|
|
||||||
BuiltinEditorDocumentProcessor *BuiltinEditorDocumentProcessor::get(const QString &filePath)
|
|
||||||
{
|
|
||||||
if (BaseEditorDocumentProcessor *b = BaseEditorDocumentProcessor::get(filePath))
|
|
||||||
return qobject_cast<BuiltinEditorDocumentProcessor *>(b);
|
|
||||||
return 0;
|
|
||||||
}
|
|
||||||
|
|
||||||
void BuiltinEditorDocumentProcessor::onParserFinished(CPlusPlus::Document::Ptr document,
|
void BuiltinEditorDocumentProcessor::onParserFinished(CPlusPlus::Document::Ptr document,
|
||||||
CPlusPlus::Snapshot snapshot)
|
CPlusPlus::Snapshot snapshot)
|
||||||
{
|
{
|
||||||
|
|||||||
@@ -57,9 +57,6 @@ public:
|
|||||||
BaseEditorDocumentParser *parser() QTC_OVERRIDE;
|
BaseEditorDocumentParser *parser() QTC_OVERRIDE;
|
||||||
bool isParserRunning() const QTC_OVERRIDE;
|
bool isParserRunning() const QTC_OVERRIDE;
|
||||||
|
|
||||||
public:
|
|
||||||
static BuiltinEditorDocumentProcessor *get(const QString &filePath);
|
|
||||||
|
|
||||||
private:
|
private:
|
||||||
void onParserFinished(CPlusPlus::Document::Ptr document, CPlusPlus::Snapshot snapshot);
|
void onParserFinished(CPlusPlus::Document::Ptr document, CPlusPlus::Snapshot snapshot);
|
||||||
void onSemanticInfoUpdated(const CppTools::SemanticInfo semanticInfo);
|
void onSemanticInfoUpdated(const CppTools::SemanticInfo semanticInfo);
|
||||||
@@ -67,7 +64,7 @@ private:
|
|||||||
SemanticInfo::Source createSemanticInfoSource(bool force) const;
|
SemanticInfo::Source createSemanticInfoSource(bool force) const;
|
||||||
|
|
||||||
private:
|
private:
|
||||||
QScopedPointer<BuiltinEditorDocumentParser> m_parser;
|
BuiltinEditorDocumentParser m_parser;
|
||||||
QFuture<void> m_parserFuture;
|
QFuture<void> m_parserFuture;
|
||||||
|
|
||||||
CPlusPlus::Snapshot m_documentSnapshot;
|
CPlusPlus::Snapshot m_documentSnapshot;
|
||||||
|
|||||||
Reference in New Issue
Block a user