forked from qt-creator/qt-creator
CppTools: modernize
Change-Id: Iaf02e4d026f1ac8b216833d83cd7a735e21ff60a Reviewed-by: Nikolai Kosjar <nikolai.kosjar@qt.io> Reviewed-by: Orgad Shaneh <orgads@gmail.com>
This commit is contained in:
@@ -323,7 +323,7 @@ void ClangEditorDocumentProcessor::invalidateDiagnostics()
|
|||||||
}
|
}
|
||||||
|
|
||||||
void ClangEditorDocumentProcessor::setParserConfig(
|
void ClangEditorDocumentProcessor::setParserConfig(
|
||||||
const CppTools::BaseEditorDocumentParser::Configuration config)
|
const CppTools::BaseEditorDocumentParser::Configuration &config)
|
||||||
{
|
{
|
||||||
m_parser->setConfiguration(config);
|
m_parser->setConfiguration(config);
|
||||||
m_builtinProcessor.parser()->setConfiguration(config);
|
m_builtinProcessor.parser()->setConfiguration(config);
|
||||||
|
|||||||
@@ -88,7 +88,7 @@ public:
|
|||||||
|
|
||||||
void editorDocumentTimerRestarted() override;
|
void editorDocumentTimerRestarted() override;
|
||||||
|
|
||||||
void setParserConfig(const CppTools::BaseEditorDocumentParser::Configuration config) override;
|
void setParserConfig(const CppTools::BaseEditorDocumentParser::Configuration &config) override;
|
||||||
|
|
||||||
QFuture<CppTools::CursorInfo> cursorInfo(const CppTools::CursorInfoParams ¶ms) override;
|
QFuture<CppTools::CursorInfo> cursorInfo(const CppTools::CursorInfoParams ¶ms) override;
|
||||||
QFuture<CppTools::CursorInfo> requestLocalReferences(const QTextCursor &cursor) override;
|
QFuture<CppTools::CursorInfo> requestLocalReferences(const QTextCursor &cursor) override;
|
||||||
|
|||||||
@@ -65,7 +65,7 @@ QString AbstractEditorSupport::licenseTemplate(const QString &file, const QStrin
|
|||||||
expander.registerVariable("Cpp:License:ClassName", tr("The class name."),
|
expander.registerVariable("Cpp:License:ClassName", tr("The class name."),
|
||||||
[className]() { return className; });
|
[className]() { return className; });
|
||||||
|
|
||||||
return Utils::TemplateEngine::processText(&expander, license, 0);
|
return Utils::TemplateEngine::processText(&expander, license, nullptr);
|
||||||
}
|
}
|
||||||
|
|
||||||
} // namespace CppTools
|
} // namespace CppTools
|
||||||
|
|||||||
@@ -58,9 +58,7 @@ BaseEditorDocumentParser::BaseEditorDocumentParser(const QString &filePath)
|
|||||||
Q_UNUSED(meta);
|
Q_UNUSED(meta);
|
||||||
}
|
}
|
||||||
|
|
||||||
BaseEditorDocumentParser::~BaseEditorDocumentParser()
|
BaseEditorDocumentParser::~BaseEditorDocumentParser() = default;
|
||||||
{
|
|
||||||
}
|
|
||||||
|
|
||||||
QString BaseEditorDocumentParser::filePath() const
|
QString BaseEditorDocumentParser::filePath() const
|
||||||
{
|
{
|
||||||
|
|||||||
@@ -52,9 +52,7 @@ BaseEditorDocumentProcessor::BaseEditorDocumentProcessor(QTextDocument *textDocu
|
|||||||
{
|
{
|
||||||
}
|
}
|
||||||
|
|
||||||
BaseEditorDocumentProcessor::~BaseEditorDocumentProcessor()
|
BaseEditorDocumentProcessor::~BaseEditorDocumentProcessor() = default;
|
||||||
{
|
|
||||||
}
|
|
||||||
|
|
||||||
void BaseEditorDocumentProcessor::run(bool projectsUpdated)
|
void BaseEditorDocumentProcessor::run(bool projectsUpdated)
|
||||||
{
|
{
|
||||||
@@ -92,7 +90,7 @@ void BaseEditorDocumentProcessor::invalidateDiagnostics()
|
|||||||
}
|
}
|
||||||
|
|
||||||
void BaseEditorDocumentProcessor::setParserConfig(
|
void BaseEditorDocumentProcessor::setParserConfig(
|
||||||
const BaseEditorDocumentParser::Configuration config)
|
const BaseEditorDocumentParser::Configuration &config)
|
||||||
{
|
{
|
||||||
parser()->setConfiguration(config);
|
parser()->setConfiguration(config);
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -86,7 +86,7 @@ public:
|
|||||||
|
|
||||||
virtual void editorDocumentTimerRestarted();
|
virtual void editorDocumentTimerRestarted();
|
||||||
|
|
||||||
virtual void setParserConfig(const BaseEditorDocumentParser::Configuration config);
|
virtual void setParserConfig(const BaseEditorDocumentParser::Configuration &config);
|
||||||
|
|
||||||
virtual QFuture<CursorInfo> cursorInfo(const CursorInfoParams ¶ms) = 0;
|
virtual QFuture<CursorInfo> cursorInfo(const CursorInfoParams ¶ms) = 0;
|
||||||
virtual QFuture<CursorInfo> requestLocalReferences(const QTextCursor &cursor) = 0;
|
virtual QFuture<CursorInfo> requestLocalReferences(const QTextCursor &cursor) = 0;
|
||||||
@@ -103,12 +103,12 @@ signals:
|
|||||||
void projectPartInfoUpdated(const CppTools::ProjectPartInfo &projectPartInfo);
|
void projectPartInfoUpdated(const CppTools::ProjectPartInfo &projectPartInfo);
|
||||||
|
|
||||||
void codeWarningsUpdated(unsigned revision,
|
void codeWarningsUpdated(unsigned revision,
|
||||||
const QList<QTextEdit::ExtraSelection> selections,
|
const QList<QTextEdit::ExtraSelection> &selections,
|
||||||
const HeaderErrorDiagnosticWidgetCreator &creator,
|
const HeaderErrorDiagnosticWidgetCreator &creator,
|
||||||
const TextEditor::RefactorMarkers &refactorMarkers);
|
const TextEditor::RefactorMarkers &refactorMarkers);
|
||||||
|
|
||||||
void ifdefedOutBlocksUpdated(unsigned revision,
|
void ifdefedOutBlocksUpdated(unsigned revision,
|
||||||
const QList<TextEditor::BlockRange> ifdefedOutBlocks);
|
const QList<TextEditor::BlockRange> &ifdefedOutBlocks);
|
||||||
|
|
||||||
void cppDocumentUpdated(const CPlusPlus::Document::Ptr document); // TODO: Remove me
|
void cppDocumentUpdated(const CPlusPlus::Document::Ptr document); // TODO: Remove me
|
||||||
void semanticInfoUpdated(const CppTools::SemanticInfo semanticInfo); // TODO: Remove me
|
void semanticInfoUpdated(const CppTools::SemanticInfo semanticInfo); // TODO: Remove me
|
||||||
|
|||||||
@@ -91,7 +91,7 @@ CursorInfo::Ranges toRanges(const SemanticUses &uses)
|
|||||||
return ranges;
|
return ranges;
|
||||||
}
|
}
|
||||||
|
|
||||||
CursorInfo::Ranges toRanges(const QList<int> tokenIndices, TranslationUnit *translationUnit)
|
CursorInfo::Ranges toRanges(const QList<int> &tokenIndices, TranslationUnit *translationUnit)
|
||||||
{
|
{
|
||||||
CursorInfo::Ranges ranges;
|
CursorInfo::Ranges ranges;
|
||||||
ranges.reserve(tokenIndices.size());
|
ranges.reserve(tokenIndices.size());
|
||||||
@@ -109,7 +109,7 @@ class FunctionDefinitionUnderCursor: protected ASTVisitor
|
|||||||
DeclarationAST *m_functionDefinition = nullptr;
|
DeclarationAST *m_functionDefinition = nullptr;
|
||||||
|
|
||||||
public:
|
public:
|
||||||
FunctionDefinitionUnderCursor(TranslationUnit *translationUnit)
|
explicit FunctionDefinitionUnderCursor(TranslationUnit *translationUnit)
|
||||||
: ASTVisitor(translationUnit)
|
: ASTVisitor(translationUnit)
|
||||||
{ }
|
{ }
|
||||||
|
|
||||||
|
|||||||
@@ -95,14 +95,14 @@ CppTools::CheckSymbols *createHighlighter(const CPlusPlus::Document::Ptr &doc,
|
|||||||
const CPlusPlus::Snapshot &snapshot,
|
const CPlusPlus::Snapshot &snapshot,
|
||||||
QTextDocument *textDocument)
|
QTextDocument *textDocument)
|
||||||
{
|
{
|
||||||
QTC_ASSERT(doc, return 0);
|
QTC_ASSERT(doc, return nullptr);
|
||||||
QTC_ASSERT(doc->translationUnit(), return 0);
|
QTC_ASSERT(doc->translationUnit(), return nullptr);
|
||||||
QTC_ASSERT(doc->translationUnit()->ast(), return 0);
|
QTC_ASSERT(doc->translationUnit()->ast(), return nullptr);
|
||||||
QTC_ASSERT(textDocument, return 0);
|
QTC_ASSERT(textDocument, return nullptr);
|
||||||
|
|
||||||
using namespace CPlusPlus;
|
using namespace CPlusPlus;
|
||||||
using namespace CppTools;
|
using namespace CppTools;
|
||||||
typedef TextEditor::HighlightingResult Result;
|
using Result = TextEditor::HighlightingResult;
|
||||||
QList<Result> macroUses;
|
QList<Result> macroUses;
|
||||||
|
|
||||||
using Utils::Text::convertPosition;
|
using Utils::Text::convertPosition;
|
||||||
@@ -168,7 +168,7 @@ BuiltinEditorDocumentProcessor::BuiltinEditorDocumentProcessor(
|
|||||||
, m_codeWarningsUpdated(false)
|
, m_codeWarningsUpdated(false)
|
||||||
, m_semanticHighlighter(enableSemanticHighlighter
|
, m_semanticHighlighter(enableSemanticHighlighter
|
||||||
? new CppTools::SemanticHighlighter(document)
|
? new CppTools::SemanticHighlighter(document)
|
||||||
: 0)
|
: nullptr)
|
||||||
{
|
{
|
||||||
using namespace Internal;
|
using namespace Internal;
|
||||||
|
|
||||||
|
|||||||
@@ -70,7 +70,6 @@ class WriteTaskFileForDiagnostics
|
|||||||
|
|
||||||
public:
|
public:
|
||||||
WriteTaskFileForDiagnostics()
|
WriteTaskFileForDiagnostics()
|
||||||
: m_processedDiagnostics(0)
|
|
||||||
{
|
{
|
||||||
const QString fileName = Utils::TemporaryDirectory::masterDirectoryPath()
|
const QString fileName = Utils::TemporaryDirectory::masterDirectoryPath()
|
||||||
+ "/qtc_findErrorsIndexing.diagnostics."
|
+ "/qtc_findErrorsIndexing.diagnostics."
|
||||||
@@ -120,7 +119,7 @@ public:
|
|||||||
private:
|
private:
|
||||||
QFile m_file;
|
QFile m_file;
|
||||||
QTextStream m_out;
|
QTextStream m_out;
|
||||||
int m_processedDiagnostics;
|
int m_processedDiagnostics = 0;
|
||||||
};
|
};
|
||||||
|
|
||||||
void classifyFiles(const QSet<QString> &files, QStringList *headers, QStringList *sources)
|
void classifyFiles(const QSet<QString> &files, QStringList *headers, QStringList *sources)
|
||||||
@@ -262,16 +261,15 @@ class BuiltinSymbolSearcher: public SymbolSearcher
|
|||||||
{
|
{
|
||||||
public:
|
public:
|
||||||
BuiltinSymbolSearcher(const CPlusPlus::Snapshot &snapshot,
|
BuiltinSymbolSearcher(const CPlusPlus::Snapshot &snapshot,
|
||||||
Parameters parameters, QSet<QString> fileNames)
|
const Parameters ¶meters, const QSet<QString> &fileNames)
|
||||||
: m_snapshot(snapshot)
|
: m_snapshot(snapshot)
|
||||||
, m_parameters(parameters)
|
, m_parameters(parameters)
|
||||||
, m_fileNames(fileNames)
|
, m_fileNames(fileNames)
|
||||||
{}
|
{}
|
||||||
|
|
||||||
~BuiltinSymbolSearcher()
|
~BuiltinSymbolSearcher() override = default;
|
||||||
{}
|
|
||||||
|
|
||||||
void runSearch(QFutureInterface<Core::SearchResultItem> &future)
|
void runSearch(QFutureInterface<Core::SearchResultItem> &future) override
|
||||||
{
|
{
|
||||||
future.setProgressRange(0, m_snapshot.size());
|
future.setProgressRange(0, m_snapshot.size());
|
||||||
future.setProgressValue(0);
|
future.setProgressValue(0);
|
||||||
@@ -343,8 +341,7 @@ BuiltinIndexingSupport::BuiltinIndexingSupport()
|
|||||||
m_synchronizer.setCancelOnWait(true);
|
m_synchronizer.setCancelOnWait(true);
|
||||||
}
|
}
|
||||||
|
|
||||||
BuiltinIndexingSupport::~BuiltinIndexingSupport()
|
BuiltinIndexingSupport::~BuiltinIndexingSupport() = default;
|
||||||
{}
|
|
||||||
|
|
||||||
QFuture<void> BuiltinIndexingSupport::refreshSourceFiles(
|
QFuture<void> BuiltinIndexingSupport::refreshSourceFiles(
|
||||||
const QFutureInterface<void> &superFuture,
|
const QFutureInterface<void> &superFuture,
|
||||||
@@ -382,7 +379,8 @@ QFuture<void> BuiltinIndexingSupport::refreshSourceFiles(
|
|||||||
return result;
|
return result;
|
||||||
}
|
}
|
||||||
|
|
||||||
SymbolSearcher *BuiltinIndexingSupport::createSymbolSearcher(SymbolSearcher::Parameters parameters, QSet<QString> fileNames)
|
SymbolSearcher *BuiltinIndexingSupport::createSymbolSearcher(
|
||||||
|
const SymbolSearcher::Parameters ¶meters, const QSet<QString> &fileNames)
|
||||||
{
|
{
|
||||||
return new BuiltinSymbolSearcher(CppModelManager::instance()->snapshot(), parameters, fileNames);
|
return new BuiltinSymbolSearcher(CppModelManager::instance()->snapshot(), parameters, fileNames);
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -36,13 +36,13 @@ namespace Internal {
|
|||||||
class BuiltinIndexingSupport: public CppIndexingSupport {
|
class BuiltinIndexingSupport: public CppIndexingSupport {
|
||||||
public:
|
public:
|
||||||
BuiltinIndexingSupport();
|
BuiltinIndexingSupport();
|
||||||
~BuiltinIndexingSupport();
|
~BuiltinIndexingSupport() override;
|
||||||
|
|
||||||
QFuture<void> refreshSourceFiles(const QFutureInterface<void> &superFuture,
|
QFuture<void> refreshSourceFiles(const QFutureInterface<void> &superFuture,
|
||||||
const QSet<QString> &sourceFiles,
|
const QSet<QString> &sourceFiles,
|
||||||
CppModelManager::ProgressNotificationMode mode) override;
|
CppModelManager::ProgressNotificationMode mode) override;
|
||||||
SymbolSearcher *createSymbolSearcher(SymbolSearcher::Parameters parameters,
|
SymbolSearcher *createSymbolSearcher(const SymbolSearcher::Parameters ¶meters,
|
||||||
QSet<QString> fileNames) override;
|
const QSet<QString> &fileNames) override;
|
||||||
|
|
||||||
public:
|
public:
|
||||||
static bool isFindErrorsIndexingActive();
|
static bool isFindErrorsIndexingActive();
|
||||||
|
|||||||
@@ -37,7 +37,7 @@ class CPPTOOLS_EXPORT ClangDiagnosticConfigsModel
|
|||||||
{
|
{
|
||||||
public:
|
public:
|
||||||
ClangDiagnosticConfigsModel() = default;
|
ClangDiagnosticConfigsModel() = default;
|
||||||
ClangDiagnosticConfigsModel(const ClangDiagnosticConfigs &customConfigs);
|
explicit ClangDiagnosticConfigsModel(const ClangDiagnosticConfigs &customConfigs);
|
||||||
|
|
||||||
int size() const;
|
int size() const;
|
||||||
const ClangDiagnosticConfig &at(int index) const;
|
const ClangDiagnosticConfig &at(int index) const;
|
||||||
|
|||||||
@@ -303,13 +303,13 @@ void CompilerOptionsBuilder::addHeaderPathOptions()
|
|||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
for (const HeaderPath &headerPath : filter.userHeaderPaths)
|
for (const HeaderPath &headerPath : qAsConst(filter.userHeaderPaths))
|
||||||
addIncludeDirOptionForPath(headerPath);
|
addIncludeDirOptionForPath(headerPath);
|
||||||
|
|
||||||
for (const HeaderPath &headerPath : filter.systemHeaderPaths)
|
for (const HeaderPath &headerPath : qAsConst(filter.systemHeaderPaths))
|
||||||
addIncludeDirOptionForPath(headerPath);
|
addIncludeDirOptionForPath(headerPath);
|
||||||
|
|
||||||
for (const HeaderPath &headerPath : filter.builtInHeaderPaths)
|
for (const HeaderPath &headerPath : qAsConst(filter.builtInHeaderPaths))
|
||||||
addIncludeDirOptionForPath(headerPath);
|
addIncludeDirOptionForPath(headerPath);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -61,9 +61,7 @@ BuiltinModelManagerSupport::BuiltinModelManagerSupport()
|
|||||||
{
|
{
|
||||||
}
|
}
|
||||||
|
|
||||||
BuiltinModelManagerSupport::~BuiltinModelManagerSupport()
|
BuiltinModelManagerSupport::~BuiltinModelManagerSupport() = default;
|
||||||
{
|
|
||||||
}
|
|
||||||
|
|
||||||
BaseEditorDocumentProcessor *BuiltinModelManagerSupport::createEditorDocumentProcessor(
|
BaseEditorDocumentProcessor *BuiltinModelManagerSupport::createEditorDocumentProcessor(
|
||||||
TextEditor::TextDocument *baseTextDocument)
|
TextEditor::TextDocument *baseTextDocument)
|
||||||
|
|||||||
@@ -38,7 +38,7 @@ class BuiltinModelManagerSupport: public ModelManagerSupport
|
|||||||
|
|
||||||
public:
|
public:
|
||||||
BuiltinModelManagerSupport();
|
BuiltinModelManagerSupport();
|
||||||
virtual ~BuiltinModelManagerSupport();
|
~BuiltinModelManagerSupport() override;
|
||||||
|
|
||||||
CppCompletionAssistProvider *completionAssistProvider() final;
|
CppCompletionAssistProvider *completionAssistProvider() final;
|
||||||
TextEditor::BaseHoverHandler *createHoverHandler() final;
|
TextEditor::BaseHoverHandler *createHoverHandler() final;
|
||||||
|
|||||||
@@ -55,7 +55,7 @@ const LookupContext &CanonicalSymbol::context() const
|
|||||||
Scope *CanonicalSymbol::getScopeAndExpression(const QTextCursor &cursor, QString *code)
|
Scope *CanonicalSymbol::getScopeAndExpression(const QTextCursor &cursor, QString *code)
|
||||||
{
|
{
|
||||||
if (!m_document)
|
if (!m_document)
|
||||||
return 0;
|
return nullptr;
|
||||||
|
|
||||||
QTextCursor tc = cursor;
|
QTextCursor tc = cursor;
|
||||||
int line, column;
|
int line, column;
|
||||||
@@ -65,7 +65,7 @@ Scope *CanonicalSymbol::getScopeAndExpression(const QTextCursor &cursor, QString
|
|||||||
QTextDocument *textDocument = cursor.document();
|
QTextDocument *textDocument = cursor.document();
|
||||||
if (!CppTools::isValidIdentifierChar(textDocument->characterAt(pos)))
|
if (!CppTools::isValidIdentifierChar(textDocument->characterAt(pos)))
|
||||||
if (!(pos > 0 && CppTools::isValidIdentifierChar(textDocument->characterAt(pos - 1))))
|
if (!(pos > 0 && CppTools::isValidIdentifierChar(textDocument->characterAt(pos - 1))))
|
||||||
return 0;
|
return nullptr;
|
||||||
|
|
||||||
while (CppTools::isValidIdentifierChar(textDocument->characterAt(pos)))
|
while (CppTools::isValidIdentifierChar(textDocument->characterAt(pos)))
|
||||||
++pos;
|
++pos;
|
||||||
@@ -83,7 +83,7 @@ Symbol *CanonicalSymbol::operator()(const QTextCursor &cursor)
|
|||||||
if (Scope *scope = getScopeAndExpression(cursor, &code))
|
if (Scope *scope = getScopeAndExpression(cursor, &code))
|
||||||
return operator()(scope, code);
|
return operator()(scope, code);
|
||||||
|
|
||||||
return 0;
|
return nullptr;
|
||||||
}
|
}
|
||||||
|
|
||||||
Symbol *CanonicalSymbol::operator()(Scope *scope, const QString &code)
|
Symbol *CanonicalSymbol::operator()(Scope *scope, const QString &code)
|
||||||
@@ -118,14 +118,12 @@ Symbol *CanonicalSymbol::canonicalSymbol(Scope *scope, const QString &code,
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
for (int i = 0; i < results.size(); ++i) {
|
for (const auto &r : results) {
|
||||||
const LookupItem &r = results.at(i);
|
if (r.declaration())
|
||||||
|
|
||||||
if (r.declaration())
|
|
||||||
return r.declaration();
|
return r.declaration();
|
||||||
}
|
}
|
||||||
|
|
||||||
return 0;
|
return nullptr;
|
||||||
}
|
}
|
||||||
|
|
||||||
} // namespace CppEditor
|
} // namespace CppEditor
|
||||||
|
|||||||
@@ -185,7 +185,7 @@ protected:
|
|||||||
|
|
||||||
bool visit(Declaration *symbol) override
|
bool visit(Declaration *symbol) override
|
||||||
{
|
{
|
||||||
if (symbol->enclosingEnum() != 0)
|
if (symbol->enclosingEnum() != nullptr)
|
||||||
addStatic(symbol->name());
|
addStatic(symbol->name());
|
||||||
|
|
||||||
if (symbol->type()->isFunctionType())
|
if (symbol->type()->isFunctionType())
|
||||||
@@ -303,9 +303,9 @@ CheckSymbols::Future CheckSymbols::go(Document::Ptr doc, const LookupContext &co
|
|||||||
CheckSymbols * CheckSymbols::create(Document::Ptr doc, const LookupContext &context,
|
CheckSymbols * CheckSymbols::create(Document::Ptr doc, const LookupContext &context,
|
||||||
const QList<CheckSymbols::Result> ¯oUses)
|
const QList<CheckSymbols::Result> ¯oUses)
|
||||||
{
|
{
|
||||||
QTC_ASSERT(doc, return NULL);
|
QTC_ASSERT(doc, return nullptr);
|
||||||
QTC_ASSERT(doc->translationUnit(), return NULL);
|
QTC_ASSERT(doc->translationUnit(), return nullptr);
|
||||||
QTC_ASSERT(doc->translationUnit()->ast(), return NULL);
|
QTC_ASSERT(doc->translationUnit()->ast(), return nullptr);
|
||||||
|
|
||||||
return new CheckSymbols(doc, context, macroUses);
|
return new CheckSymbols(doc, context, macroUses);
|
||||||
}
|
}
|
||||||
@@ -315,7 +315,7 @@ CheckSymbols::CheckSymbols(Document::Ptr doc, const LookupContext &context, cons
|
|||||||
, _lineOfLastUsage(0), _macroUses(macroUses)
|
, _lineOfLastUsage(0), _macroUses(macroUses)
|
||||||
{
|
{
|
||||||
unsigned line = 0;
|
unsigned line = 0;
|
||||||
getTokenEndPosition(translationUnit()->ast()->lastToken(), &line, 0);
|
getTokenEndPosition(translationUnit()->ast()->lastToken(), &line, nullptr);
|
||||||
_chunkSize = qMax(50U, line / 200);
|
_chunkSize = qMax(50U, line / 200);
|
||||||
_usages.reserve(_chunkSize);
|
_usages.reserve(_chunkSize);
|
||||||
|
|
||||||
@@ -326,8 +326,7 @@ CheckSymbols::CheckSymbols(Document::Ptr doc, const LookupContext &context, cons
|
|||||||
typeOfExpression.setExpandTemplates(true);
|
typeOfExpression.setExpandTemplates(true);
|
||||||
}
|
}
|
||||||
|
|
||||||
CheckSymbols::~CheckSymbols()
|
CheckSymbols::~CheckSymbols() = default;
|
||||||
{ }
|
|
||||||
|
|
||||||
void CheckSymbols::run()
|
void CheckSymbols::run()
|
||||||
{
|
{
|
||||||
@@ -385,7 +384,7 @@ FunctionDefinitionAST *CheckSymbols::enclosingFunctionDefinition(bool skipTopOfS
|
|||||||
return funDef;
|
return funDef;
|
||||||
}
|
}
|
||||||
|
|
||||||
return 0;
|
return nullptr;
|
||||||
}
|
}
|
||||||
|
|
||||||
TemplateDeclarationAST *CheckSymbols::enclosingTemplateDeclaration() const
|
TemplateDeclarationAST *CheckSymbols::enclosingTemplateDeclaration() const
|
||||||
@@ -397,7 +396,7 @@ TemplateDeclarationAST *CheckSymbols::enclosingTemplateDeclaration() const
|
|||||||
return funDef;
|
return funDef;
|
||||||
}
|
}
|
||||||
|
|
||||||
return 0;
|
return nullptr;
|
||||||
}
|
}
|
||||||
|
|
||||||
Scope *CheckSymbols::enclosingScope() const
|
Scope *CheckSymbols::enclosingScope() const
|
||||||
@@ -508,7 +507,7 @@ bool CheckSymbols::visit(DotDesignatorAST *ast)
|
|||||||
|
|
||||||
bool CheckSymbols::visit(SimpleDeclarationAST *ast)
|
bool CheckSymbols::visit(SimpleDeclarationAST *ast)
|
||||||
{
|
{
|
||||||
NameAST *declrIdNameAST = 0;
|
NameAST *declrIdNameAST = nullptr;
|
||||||
if (ast->declarator_list && !ast->declarator_list->next) {
|
if (ast->declarator_list && !ast->declarator_list->next) {
|
||||||
if (ast->symbols && !ast->symbols->next && !ast->symbols->value->isGenerated()) {
|
if (ast->symbols && !ast->symbols->next && !ast->symbols->value->isGenerated()) {
|
||||||
Symbol *decl = ast->symbols->value;
|
Symbol *decl = ast->symbols->value;
|
||||||
@@ -606,7 +605,7 @@ bool CheckSymbols::visit(ObjCClassForwardDeclarationAST *ast)
|
|||||||
{
|
{
|
||||||
accept(ast->attribute_list);
|
accept(ast->attribute_list);
|
||||||
accept(ast->identifier_list);
|
accept(ast->identifier_list);
|
||||||
for (NameListAST *i = ast->identifier_list ; i != 0; i = i->next)
|
for (NameListAST *i = ast->identifier_list; i; i = i->next)
|
||||||
addUse(i->value, SemanticHighlighter::TypeUse);
|
addUse(i->value, SemanticHighlighter::TypeUse);
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
@@ -680,7 +679,7 @@ bool CheckSymbols::visit(CallAST *ast)
|
|||||||
} else if (IdExpressionAST *idExpr = ast->base_expression->asIdExpression()) {
|
} else if (IdExpressionAST *idExpr = ast->base_expression->asIdExpression()) {
|
||||||
if (const Name *name = idExpr->name->name) {
|
if (const Name *name = idExpr->name->name) {
|
||||||
if (maybeFunction(name)) {
|
if (maybeFunction(name)) {
|
||||||
expr = 0;
|
expr = nullptr;
|
||||||
|
|
||||||
NameAST *exprName = idExpr->name;
|
NameAST *exprName = idExpr->name;
|
||||||
if (QualifiedNameAST *q = exprName->asQualifiedName()) {
|
if (QualifiedNameAST *q = exprName->asQualifiedName()) {
|
||||||
@@ -723,8 +722,8 @@ bool CheckSymbols::visit(NewExpressionAST *ast)
|
|||||||
if (highlightCtorDtorAsType) {
|
if (highlightCtorDtorAsType) {
|
||||||
accept(ast->new_type_id);
|
accept(ast->new_type_id);
|
||||||
} else {
|
} else {
|
||||||
ClassOrNamespace *binding = 0;
|
ClassOrNamespace *binding = nullptr;
|
||||||
NameAST *nameAST = 0;
|
NameAST *nameAST = nullptr;
|
||||||
if (ast->new_type_id) {
|
if (ast->new_type_id) {
|
||||||
for (SpecifierListAST *it = ast->new_type_id->type_specifier_list; it; it = it->next) {
|
for (SpecifierListAST *it = ast->new_type_id->type_specifier_list; it; it = it->next) {
|
||||||
if (NamedTypeSpecifierAST *spec = it->value->asNamedTypeSpecifier()) {
|
if (NamedTypeSpecifierAST *spec = it->value->asNamedTypeSpecifier()) {
|
||||||
@@ -746,7 +745,7 @@ bool CheckSymbols::visit(NewExpressionAST *ast)
|
|||||||
if (binding && nameAST) {
|
if (binding && nameAST) {
|
||||||
int arguments = 0;
|
int arguments = 0;
|
||||||
if (ast->new_initializer) {
|
if (ast->new_initializer) {
|
||||||
ExpressionListAST *list = 0;
|
ExpressionListAST *list = nullptr;
|
||||||
if (ExpressionListParenAST *exprListParen = ast->new_initializer->asExpressionListParen())
|
if (ExpressionListParenAST *exprListParen = ast->new_initializer->asExpressionListParen())
|
||||||
list = exprListParen->expression_list;
|
list = exprListParen->expression_list;
|
||||||
else if (BracedInitializerAST *braceInit = ast->new_initializer->asBracedInitializer())
|
else if (BracedInitializerAST *braceInit = ast->new_initializer->asBracedInitializer())
|
||||||
@@ -853,7 +852,7 @@ void CheckSymbols::checkName(NameAST *ast, Scope *scope)
|
|||||||
if (!scope)
|
if (!scope)
|
||||||
scope = enclosingScope();
|
scope = enclosingScope();
|
||||||
|
|
||||||
if (ast->asDestructorName() != 0) {
|
if (ast->asDestructorName() != nullptr) {
|
||||||
Class *klass = scope->asClass();
|
Class *klass = scope->asClass();
|
||||||
if (!klass && scope->asFunction())
|
if (!klass && scope->asFunction())
|
||||||
klass = scope->asFunction()->enclosingScope()->asClass();
|
klass = scope->asFunction()->enclosingScope()->asClass();
|
||||||
@@ -915,7 +914,7 @@ bool CheckSymbols::visit(QualifiedNameAST *ast)
|
|||||||
ClassOrNamespace *binding = checkNestedName(ast);
|
ClassOrNamespace *binding = checkNestedName(ast);
|
||||||
|
|
||||||
if (binding && ast->unqualified_name) {
|
if (binding && ast->unqualified_name) {
|
||||||
if (ast->unqualified_name->asDestructorName() != 0) {
|
if (ast->unqualified_name->asDestructorName() != nullptr) {
|
||||||
if (hasVirtualDestructor(binding)) {
|
if (hasVirtualDestructor(binding)) {
|
||||||
addUse(ast->unqualified_name, SemanticHighlighter::VirtualFunctionDeclarationUse);
|
addUse(ast->unqualified_name, SemanticHighlighter::VirtualFunctionDeclarationUse);
|
||||||
} else {
|
} else {
|
||||||
@@ -943,7 +942,7 @@ bool CheckSymbols::visit(QualifiedNameAST *ast)
|
|||||||
|
|
||||||
ClassOrNamespace *CheckSymbols::checkNestedName(QualifiedNameAST *ast)
|
ClassOrNamespace *CheckSymbols::checkNestedName(QualifiedNameAST *ast)
|
||||||
{
|
{
|
||||||
ClassOrNamespace *binding = 0;
|
ClassOrNamespace *binding = nullptr;
|
||||||
|
|
||||||
if (ast->name) {
|
if (ast->name) {
|
||||||
if (NestedNameSpecifierListAST *it = ast->nested_name_specifier_list) {
|
if (NestedNameSpecifierListAST *it = ast->nested_name_specifier_list) {
|
||||||
@@ -969,7 +968,7 @@ ClassOrNamespace *CheckSymbols::checkNestedName(QualifiedNameAST *ast)
|
|||||||
if (TemplateIdAST *template_id = class_or_namespace_name->asTemplateId()) {
|
if (TemplateIdAST *template_id = class_or_namespace_name->asTemplateId()) {
|
||||||
if (template_id->template_token) {
|
if (template_id->template_token) {
|
||||||
addUse(template_id, SemanticHighlighter::TypeUse);
|
addUse(template_id, SemanticHighlighter::TypeUse);
|
||||||
binding = 0; // there's no way we can find a binding.
|
binding = nullptr; // there's no way we can find a binding.
|
||||||
}
|
}
|
||||||
|
|
||||||
accept(template_id->template_argument_list);
|
accept(template_id->template_argument_list);
|
||||||
@@ -1026,7 +1025,7 @@ bool CheckSymbols::visit(MemInitializerAST *ast)
|
|||||||
// It's a constructor, count the number of arguments
|
// It's a constructor, count the number of arguments
|
||||||
unsigned arguments = 0;
|
unsigned arguments = 0;
|
||||||
if (ast->expression) {
|
if (ast->expression) {
|
||||||
ExpressionListAST *expr_list = 0;
|
ExpressionListAST *expr_list = nullptr;
|
||||||
if (ExpressionListParenAST *parenExprList = ast->expression->asExpressionListParen())
|
if (ExpressionListParenAST *parenExprList = ast->expression->asExpressionListParen())
|
||||||
expr_list = parenExprList->expression_list;
|
expr_list = parenExprList->expression_list;
|
||||||
else if (BracedInitializerAST *bracedInitList = ast->expression->asBracedInitializer())
|
else if (BracedInitializerAST *bracedInitList = ast->expression->asBracedInitializer())
|
||||||
@@ -1165,7 +1164,7 @@ void CheckSymbols::addUse(NameAST *ast, Kind kind)
|
|||||||
|
|
||||||
if (!ast)
|
if (!ast)
|
||||||
return; // nothing to do
|
return; // nothing to do
|
||||||
else if (ast->asOperatorFunctionId() != 0 || ast->asConversionFunctionId() != 0)
|
else if (ast->asOperatorFunctionId() != nullptr || ast->asConversionFunctionId() != nullptr)
|
||||||
return; // nothing to do
|
return; // nothing to do
|
||||||
|
|
||||||
unsigned startToken = ast->firstToken();
|
unsigned startToken = ast->firstToken();
|
||||||
@@ -1262,14 +1261,14 @@ bool CheckSymbols::maybeAddTypeOrStatic(const QList<LookupItem> &candidates, Nam
|
|||||||
else if (c->isTypedef() || c->isNamespace() ||
|
else if (c->isTypedef() || c->isNamespace() ||
|
||||||
c->isStatic() || //consider also static variable
|
c->isStatic() || //consider also static variable
|
||||||
c->isClass() || c->isEnum() || isTemplateClass(c) ||
|
c->isClass() || c->isEnum() || isTemplateClass(c) ||
|
||||||
c->isForwardClassDeclaration() || c->isTypenameArgument() || c->enclosingEnum() != 0) {
|
c->isForwardClassDeclaration() || c->isTypenameArgument() || c->enclosingEnum() != nullptr) {
|
||||||
|
|
||||||
unsigned line, column;
|
unsigned line, column;
|
||||||
getTokenStartPosition(startToken, &line, &column);
|
getTokenStartPosition(startToken, &line, &column);
|
||||||
const unsigned length = tok.utf16chars();
|
const unsigned length = tok.utf16chars();
|
||||||
|
|
||||||
Kind kind = SemanticHighlighter::TypeUse;
|
Kind kind = SemanticHighlighter::TypeUse;
|
||||||
if (c->enclosingEnum() != 0)
|
if (c->enclosingEnum() != nullptr)
|
||||||
kind = SemanticHighlighter::EnumerationUse;
|
kind = SemanticHighlighter::EnumerationUse;
|
||||||
else if (c->isStatic())
|
else if (c->isStatic())
|
||||||
// treat static variable as a field(highlighting)
|
// treat static variable as a field(highlighting)
|
||||||
@@ -1428,7 +1427,7 @@ NameAST *CheckSymbols::declaratorId(DeclaratorAST *ast) const
|
|||||||
return declId->name;
|
return declId->name;
|
||||||
}
|
}
|
||||||
|
|
||||||
return 0;
|
return nullptr;
|
||||||
}
|
}
|
||||||
|
|
||||||
bool CheckSymbols::maybeType(const Name *name) const
|
bool CheckSymbols::maybeType(const Name *name) const
|
||||||
|
|||||||
@@ -47,12 +47,12 @@ class CPPTOOLS_EXPORT CheckSymbols:
|
|||||||
public:
|
public:
|
||||||
~CheckSymbols() override;
|
~CheckSymbols() override;
|
||||||
|
|
||||||
typedef TextEditor::HighlightingResult Result;
|
using Result = TextEditor::HighlightingResult;
|
||||||
typedef SemanticHighlighter::Kind Kind;
|
using Kind = SemanticHighlighter::Kind;
|
||||||
|
|
||||||
void run() override;
|
void run() override;
|
||||||
|
|
||||||
typedef QFuture<Result> Future;
|
using Future = QFuture<Result>;
|
||||||
|
|
||||||
Future start()
|
Future start()
|
||||||
{
|
{
|
||||||
@@ -88,7 +88,7 @@ public:
|
|||||||
|
|
||||||
signals:
|
signals:
|
||||||
void codeWarningsUpdated(CPlusPlus::Document::Ptr document,
|
void codeWarningsUpdated(CPlusPlus::Document::Ptr document,
|
||||||
const QList<CPlusPlus::Document::DiagnosticMessage> selections);
|
const QList<CPlusPlus::Document::DiagnosticMessage> &selections);
|
||||||
|
|
||||||
protected:
|
protected:
|
||||||
using ASTVisitor::visit;
|
using ASTVisitor::visit;
|
||||||
|
|||||||
@@ -39,9 +39,7 @@ CppClassesFilter::CppClassesFilter(CppLocatorData *locatorData)
|
|||||||
setIncludedByDefault(false);
|
setIncludedByDefault(false);
|
||||||
}
|
}
|
||||||
|
|
||||||
CppClassesFilter::~CppClassesFilter()
|
CppClassesFilter::~CppClassesFilter() = default;
|
||||||
{
|
|
||||||
}
|
|
||||||
|
|
||||||
Core::LocatorFilterEntry CppClassesFilter::filterEntryFromIndexItem(IndexItem::Ptr info)
|
Core::LocatorFilterEntry CppClassesFilter::filterEntryFromIndexItem(IndexItem::Ptr info)
|
||||||
{
|
{
|
||||||
|
|||||||
@@ -38,7 +38,7 @@ class CPPTOOLS_EXPORT CppClassesFilter : public Internal::CppLocatorFilter
|
|||||||
Q_OBJECT
|
Q_OBJECT
|
||||||
|
|
||||||
public:
|
public:
|
||||||
CppClassesFilter(CppLocatorData *locatorData);
|
explicit CppClassesFilter(CppLocatorData *locatorData);
|
||||||
~CppClassesFilter() override;
|
~CppClassesFilter() override;
|
||||||
|
|
||||||
protected:
|
protected:
|
||||||
|
|||||||
@@ -40,9 +40,7 @@ using namespace CppTools;
|
|||||||
using namespace TextEditor;
|
using namespace TextEditor;
|
||||||
using namespace CppTools::Internal;
|
using namespace CppTools::Internal;
|
||||||
|
|
||||||
CodeFormatter::~CodeFormatter()
|
CodeFormatter::~CodeFormatter() = default;
|
||||||
{
|
|
||||||
}
|
|
||||||
|
|
||||||
void CodeFormatter::setTabSize(int tabSize)
|
void CodeFormatter::setTabSize(int tabSize)
|
||||||
{
|
{
|
||||||
@@ -1098,9 +1096,7 @@ namespace Internal {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
QtStyleCodeFormatter::QtStyleCodeFormatter()
|
QtStyleCodeFormatter::QtStyleCodeFormatter() = default;
|
||||||
{
|
|
||||||
}
|
|
||||||
|
|
||||||
QtStyleCodeFormatter::QtStyleCodeFormatter(const TabSettings &tabSettings,
|
QtStyleCodeFormatter::QtStyleCodeFormatter(const TabSettings &tabSettings,
|
||||||
const CppCodeStyleSettings &settings)
|
const CppCodeStyleSettings &settings)
|
||||||
@@ -1124,7 +1120,7 @@ void QtStyleCodeFormatter::setCodeStyleSettings(const CppCodeStyleSettings &sett
|
|||||||
void QtStyleCodeFormatter::saveBlockData(QTextBlock *block, const BlockData &data) const
|
void QtStyleCodeFormatter::saveBlockData(QTextBlock *block, const BlockData &data) const
|
||||||
{
|
{
|
||||||
TextBlockUserData *userData = TextDocumentLayout::userData(*block);
|
TextBlockUserData *userData = TextDocumentLayout::userData(*block);
|
||||||
CppCodeFormatterData *cppData = static_cast<CppCodeFormatterData *>(userData->codeFormatterData());
|
auto cppData = static_cast<CppCodeFormatterData *>(userData->codeFormatterData());
|
||||||
if (!cppData) {
|
if (!cppData) {
|
||||||
cppData = new CppCodeFormatterData;
|
cppData = new CppCodeFormatterData;
|
||||||
userData->setCodeFormatterData(cppData);
|
userData->setCodeFormatterData(cppData);
|
||||||
@@ -1137,7 +1133,7 @@ bool QtStyleCodeFormatter::loadBlockData(const QTextBlock &block, BlockData *dat
|
|||||||
TextBlockUserData *userData = TextDocumentLayout::testUserData(block);
|
TextBlockUserData *userData = TextDocumentLayout::testUserData(block);
|
||||||
if (!userData)
|
if (!userData)
|
||||||
return false;
|
return false;
|
||||||
CppCodeFormatterData *cppData = static_cast<CppCodeFormatterData *>(userData->codeFormatterData());
|
auto cppData = static_cast<const CppCodeFormatterData *>(userData->codeFormatterData());
|
||||||
if (!cppData)
|
if (!cppData)
|
||||||
return false;
|
return false;
|
||||||
|
|
||||||
|
|||||||
@@ -175,7 +175,7 @@ public: // must be public to make Q_GADGET introspection work
|
|||||||
string_open
|
string_open
|
||||||
|
|
||||||
};
|
};
|
||||||
Q_ENUMS(StateType)
|
Q_ENUM(StateType)
|
||||||
|
|
||||||
protected:
|
protected:
|
||||||
class State {
|
class State {
|
||||||
|
|||||||
@@ -44,7 +44,7 @@ using namespace CppTools::Internal;
|
|||||||
|
|
||||||
namespace {
|
namespace {
|
||||||
|
|
||||||
Document::Ptr createDocument(const QString filePath, const QByteArray text,
|
Document::Ptr createDocument(const QString &filePath, const QByteArray &text,
|
||||||
unsigned expectedGlobalSymbolCount)
|
unsigned expectedGlobalSymbolCount)
|
||||||
{
|
{
|
||||||
Document::Ptr document = Document::create(filePath);
|
Document::Ptr document = Document::create(filePath);
|
||||||
|
|||||||
@@ -665,8 +665,8 @@ void Dumper::dumpDocuments(const QList<CPlusPlus::Document::Ptr> &documents, boo
|
|||||||
if (!diagnosticMessages.isEmpty()) {
|
if (!diagnosticMessages.isEmpty()) {
|
||||||
m_out << i3 << "Diagnostic Messages:{{{4\n";
|
m_out << i3 << "Diagnostic Messages:{{{4\n";
|
||||||
foreach (const CPlusPlus::Document::DiagnosticMessage &msg, diagnosticMessages) {
|
foreach (const CPlusPlus::Document::DiagnosticMessage &msg, diagnosticMessages) {
|
||||||
const CPlusPlus::Document::DiagnosticMessage::Level level
|
auto level =
|
||||||
= static_cast<CPlusPlus::Document::DiagnosticMessage::Level>(msg.level());
|
static_cast<const CPlusPlus::Document::DiagnosticMessage::Level>(msg.level());
|
||||||
m_out << i4 << "at " << msg.line() << ":" << msg.column() << ", " << Utils::toString(level)
|
m_out << i4 << "at " << msg.line() << ":" << msg.column() << ", " << Utils::toString(level)
|
||||||
<< ": " << msg.text() << "\n";
|
<< ": " << msg.text() << "\n";
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -46,7 +46,7 @@ class CppCodeModelSettingsWidget: public QWidget
|
|||||||
Q_OBJECT
|
Q_OBJECT
|
||||||
|
|
||||||
public:
|
public:
|
||||||
explicit CppCodeModelSettingsWidget(QWidget *parent = 0);
|
explicit CppCodeModelSettingsWidget(QWidget *parent = nullptr);
|
||||||
~CppCodeModelSettingsWidget() override;
|
~CppCodeModelSettingsWidget() override;
|
||||||
|
|
||||||
void setSettings(const QSharedPointer<CppCodeModelSettings> &s);
|
void setSettings(const QSharedPointer<CppCodeModelSettings> &s);
|
||||||
@@ -68,11 +68,11 @@ class CppCodeModelSettingsPage: public Core::IOptionsPage
|
|||||||
{
|
{
|
||||||
public:
|
public:
|
||||||
explicit CppCodeModelSettingsPage(QSharedPointer<CppCodeModelSettings> &settings,
|
explicit CppCodeModelSettingsPage(QSharedPointer<CppCodeModelSettings> &settings,
|
||||||
QObject *parent = 0);
|
QObject *parent = nullptr);
|
||||||
|
|
||||||
QWidget *widget();
|
QWidget *widget() override;
|
||||||
void apply();
|
void apply() override;
|
||||||
void finish();
|
void finish() override;
|
||||||
|
|
||||||
private:
|
private:
|
||||||
const QSharedPointer<CppCodeModelSettings> m_settings;
|
const QSharedPointer<CppCodeModelSettings> m_settings;
|
||||||
|
|||||||
@@ -82,9 +82,7 @@ static const char *defaultPreviewText =
|
|||||||
;
|
;
|
||||||
|
|
||||||
|
|
||||||
CppCodeStylePreferencesFactory::CppCodeStylePreferencesFactory()
|
CppCodeStylePreferencesFactory::CppCodeStylePreferencesFactory() = default;
|
||||||
{
|
|
||||||
}
|
|
||||||
|
|
||||||
Core::Id CppCodeStylePreferencesFactory::languageId()
|
Core::Id CppCodeStylePreferencesFactory::languageId()
|
||||||
{
|
{
|
||||||
@@ -104,10 +102,10 @@ TextEditor::ICodeStylePreferences *CppCodeStylePreferencesFactory::createCodeSty
|
|||||||
QWidget *CppCodeStylePreferencesFactory::createEditor(TextEditor::ICodeStylePreferences *preferences,
|
QWidget *CppCodeStylePreferencesFactory::createEditor(TextEditor::ICodeStylePreferences *preferences,
|
||||||
QWidget *parent) const
|
QWidget *parent) const
|
||||||
{
|
{
|
||||||
CppCodeStylePreferences *cppPreferences = qobject_cast<CppCodeStylePreferences *>(preferences);
|
auto cppPreferences = qobject_cast<CppCodeStylePreferences *>(preferences);
|
||||||
if (!cppPreferences)
|
if (!cppPreferences)
|
||||||
return 0;
|
return nullptr;
|
||||||
Internal::CppCodeStylePreferencesWidget *widget = new Internal::CppCodeStylePreferencesWidget(parent);
|
auto widget = new Internal::CppCodeStylePreferencesWidget(parent);
|
||||||
widget->layout()->setMargin(0);
|
widget->layout()->setMargin(0);
|
||||||
widget->setCodeStyle(cppPreferences);
|
widget->setCodeStyle(cppPreferences);
|
||||||
return widget;
|
return widget;
|
||||||
|
|||||||
@@ -36,14 +36,14 @@ class CPPTOOLS_EXPORT CppCodeStylePreferencesFactory : public TextEditor::ICodeS
|
|||||||
public:
|
public:
|
||||||
CppCodeStylePreferencesFactory();
|
CppCodeStylePreferencesFactory();
|
||||||
|
|
||||||
Core::Id languageId();
|
Core::Id languageId() override;
|
||||||
QString displayName();
|
QString displayName() override;
|
||||||
TextEditor::ICodeStylePreferences *createCodeStyle() const;
|
TextEditor::ICodeStylePreferences *createCodeStyle() const override;
|
||||||
QWidget *createEditor(TextEditor::ICodeStylePreferences *settings,
|
QWidget *createEditor(TextEditor::ICodeStylePreferences *settings,
|
||||||
QWidget *parent) const;
|
QWidget *parent) const override;
|
||||||
TextEditor::Indenter *createIndenter() const;
|
TextEditor::Indenter *createIndenter() const override;
|
||||||
QString snippetProviderGroupId() const;
|
QString snippetProviderGroupId() const override;
|
||||||
QString previewText() const;
|
QString previewText() const override;
|
||||||
};
|
};
|
||||||
|
|
||||||
} // namespace CppTools
|
} // namespace CppTools
|
||||||
|
|||||||
@@ -214,8 +214,8 @@ Utils::optional<CppCodeStyleSettings> CppCodeStyleSettings::currentProjectCodeSt
|
|||||||
= editorConfiguration->codeStyle(Constants::CPP_SETTINGS_ID);
|
= editorConfiguration->codeStyle(Constants::CPP_SETTINGS_ID);
|
||||||
QTC_ASSERT(codeStylePreferences, return OptSettings());
|
QTC_ASSERT(codeStylePreferences, return OptSettings());
|
||||||
|
|
||||||
CppCodeStylePreferences *cppCodeStylePreferences
|
auto cppCodeStylePreferences =
|
||||||
= dynamic_cast<CppCodeStylePreferences *>(codeStylePreferences);
|
dynamic_cast<const CppCodeStylePreferences *>(codeStylePreferences);
|
||||||
if (!cppCodeStylePreferences)
|
if (!cppCodeStylePreferences)
|
||||||
return OptSettings();
|
return OptSettings();
|
||||||
|
|
||||||
@@ -258,7 +258,7 @@ TextEditor::TabSettings CppCodeStyleSettings::currentGlobalTabSettings()
|
|||||||
static void configureOverviewWithCodeStyleSettings(CPlusPlus::Overview &overview,
|
static void configureOverviewWithCodeStyleSettings(CPlusPlus::Overview &overview,
|
||||||
const CppCodeStyleSettings &settings)
|
const CppCodeStyleSettings &settings)
|
||||||
{
|
{
|
||||||
overview.starBindFlags = CPlusPlus::Overview::StarBindFlags(0);
|
overview.starBindFlags = CPlusPlus::Overview::StarBindFlags(nullptr);
|
||||||
if (settings.bindStarToIdentifier)
|
if (settings.bindStarToIdentifier)
|
||||||
overview.starBindFlags |= CPlusPlus::Overview::BindToIdentifier;
|
overview.starBindFlags |= CPlusPlus::Overview::BindToIdentifier;
|
||||||
if (settings.bindStarToTypeName)
|
if (settings.bindStarToTypeName)
|
||||||
|
|||||||
@@ -224,7 +224,7 @@ static void applyRefactorings(QTextDocument *textDocument, TextEditorWidget *edi
|
|||||||
{
|
{
|
||||||
// Preprocess source
|
// Preprocess source
|
||||||
Environment env;
|
Environment env;
|
||||||
Preprocessor preprocess(0, &env);
|
Preprocessor preprocess(nullptr, &env);
|
||||||
const QByteArray preprocessedSource
|
const QByteArray preprocessedSource
|
||||||
= preprocess.run(QLatin1String("<no-file>"), textDocument->toPlainText());
|
= preprocess.run(QLatin1String("<no-file>"), textDocument->toPlainText());
|
||||||
|
|
||||||
@@ -238,7 +238,7 @@ static void applyRefactorings(QTextDocument *textDocument, TextEditorWidget *edi
|
|||||||
// Run the formatter
|
// Run the formatter
|
||||||
Overview overview;
|
Overview overview;
|
||||||
overview.showReturnTypes = true;
|
overview.showReturnTypes = true;
|
||||||
overview.starBindFlags = Overview::StarBindFlags(0);
|
overview.starBindFlags = Overview::StarBindFlags(nullptr);
|
||||||
|
|
||||||
if (settings.bindStarToIdentifier)
|
if (settings.bindStarToIdentifier)
|
||||||
overview.starBindFlags |= Overview::BindToIdentifier;
|
overview.starBindFlags |= Overview::BindToIdentifier;
|
||||||
@@ -261,9 +261,7 @@ static void applyRefactorings(QTextDocument *textDocument, TextEditorWidget *edi
|
|||||||
|
|
||||||
CppCodeStylePreferencesWidget::CppCodeStylePreferencesWidget(QWidget *parent)
|
CppCodeStylePreferencesWidget::CppCodeStylePreferencesWidget(QWidget *parent)
|
||||||
: QWidget(parent),
|
: QWidget(parent),
|
||||||
m_preferences(0),
|
m_ui(new Ui::CppCodeStyleSettingsPage)
|
||||||
m_ui(new Ui::CppCodeStyleSettingsPage),
|
|
||||||
m_blockUpdates(false)
|
|
||||||
{
|
{
|
||||||
m_ui->setupUi(this);
|
m_ui->setupUi(this);
|
||||||
m_ui->categoryTab->setProperty("_q_custom_style_disabled", true);
|
m_ui->categoryTab->setProperty("_q_custom_style_disabled", true);
|
||||||
@@ -442,7 +440,7 @@ void CppCodeStylePreferencesWidget::slotCodeStyleSettingsChanged()
|
|||||||
return;
|
return;
|
||||||
|
|
||||||
if (m_preferences) {
|
if (m_preferences) {
|
||||||
CppCodeStylePreferences *current = qobject_cast<CppCodeStylePreferences *>(m_preferences->currentPreferences());
|
auto current = qobject_cast<CppCodeStylePreferences *>(m_preferences->currentPreferences());
|
||||||
if (current)
|
if (current)
|
||||||
current->setCodeStyleSettings(cppCodeStyleSettings());
|
current->setCodeStyleSettings(cppCodeStyleSettings());
|
||||||
}
|
}
|
||||||
@@ -456,7 +454,7 @@ void CppCodeStylePreferencesWidget::slotTabSettingsChanged(const TabSettings &se
|
|||||||
return;
|
return;
|
||||||
|
|
||||||
if (m_preferences) {
|
if (m_preferences) {
|
||||||
CppCodeStylePreferences *current = qobject_cast<CppCodeStylePreferences *>(m_preferences->currentPreferences());
|
auto current = qobject_cast<CppCodeStylePreferences *>(m_preferences->currentPreferences());
|
||||||
if (current)
|
if (current)
|
||||||
current->setTabSettings(settings);
|
current->setTabSettings(settings);
|
||||||
}
|
}
|
||||||
@@ -512,9 +510,8 @@ void CppCodeStylePreferencesWidget::setVisualizeWhitespace(bool on)
|
|||||||
|
|
||||||
// ------------------ CppCodeStyleSettingsPage
|
// ------------------ CppCodeStyleSettingsPage
|
||||||
|
|
||||||
CppCodeStyleSettingsPage::CppCodeStyleSettingsPage(QWidget *parent) :
|
CppCodeStyleSettingsPage::CppCodeStyleSettingsPage(QWidget *parent)
|
||||||
Core::IOptionsPage(parent),
|
: Core::IOptionsPage(parent)
|
||||||
m_pageCppCodeStylePreferences(0)
|
|
||||||
{
|
{
|
||||||
setId(Constants::CPP_CODE_STYLE_SETTINGS_ID);
|
setId(Constants::CPP_CODE_STYLE_SETTINGS_ID);
|
||||||
setDisplayName(QCoreApplication::translate("CppTools", Constants::CPP_CODE_STYLE_SETTINGS_NAME));
|
setDisplayName(QCoreApplication::translate("CppTools", Constants::CPP_CODE_STYLE_SETTINGS_NAME));
|
||||||
|
|||||||
@@ -54,8 +54,8 @@ class CppCodeStylePreferencesWidget : public QWidget
|
|||||||
{
|
{
|
||||||
Q_OBJECT
|
Q_OBJECT
|
||||||
public:
|
public:
|
||||||
explicit CppCodeStylePreferencesWidget(QWidget *parent = 0);
|
explicit CppCodeStylePreferencesWidget(QWidget *parent = nullptr);
|
||||||
virtual ~CppCodeStylePreferencesWidget();
|
~CppCodeStylePreferencesWidget() override;
|
||||||
|
|
||||||
void setCodeStyle(CppTools::CppCodeStylePreferences *codeStylePreferences);
|
void setCodeStyle(CppTools::CppCodeStylePreferences *codeStylePreferences);
|
||||||
|
|
||||||
@@ -71,10 +71,10 @@ private:
|
|||||||
|
|
||||||
CppCodeStyleSettings cppCodeStyleSettings() const;
|
CppCodeStyleSettings cppCodeStyleSettings() const;
|
||||||
|
|
||||||
CppCodeStylePreferences *m_preferences;
|
CppCodeStylePreferences *m_preferences = nullptr;
|
||||||
Ui::CppCodeStyleSettingsPage *m_ui;
|
Ui::CppCodeStyleSettingsPage *m_ui;
|
||||||
QList<TextEditor::SnippetEditorWidget *> m_previews;
|
QList<TextEditor::SnippetEditorWidget *> m_previews;
|
||||||
bool m_blockUpdates;
|
bool m_blockUpdates = false;
|
||||||
};
|
};
|
||||||
|
|
||||||
|
|
||||||
@@ -83,14 +83,14 @@ class CppCodeStyleSettingsPage : public Core::IOptionsPage
|
|||||||
Q_OBJECT
|
Q_OBJECT
|
||||||
|
|
||||||
public:
|
public:
|
||||||
explicit CppCodeStyleSettingsPage(QWidget *parent = 0);
|
explicit CppCodeStyleSettingsPage(QWidget *parent = nullptr);
|
||||||
|
|
||||||
QWidget *widget();
|
QWidget *widget() override;
|
||||||
void apply();
|
void apply() override;
|
||||||
void finish();
|
void finish() override;
|
||||||
|
|
||||||
private:
|
private:
|
||||||
CppCodeStylePreferences *m_pageCppCodeStylePreferences;
|
CppCodeStylePreferences *m_pageCppCodeStylePreferences = nullptr;
|
||||||
QPointer<QWidget> m_widget;
|
QPointer<QWidget> m_widget;
|
||||||
};
|
};
|
||||||
|
|
||||||
|
|||||||
@@ -54,14 +54,13 @@ using namespace Core;
|
|||||||
|
|
||||||
namespace {
|
namespace {
|
||||||
|
|
||||||
typedef QByteArray _;
|
using _ = QByteArray;
|
||||||
|
|
||||||
class CompletionTestCase : public Tests::TestCase
|
class CompletionTestCase : public Tests::TestCase
|
||||||
{
|
{
|
||||||
public:
|
public:
|
||||||
CompletionTestCase(const QByteArray &sourceText, const QByteArray &textToInsert = QByteArray(),
|
CompletionTestCase(const QByteArray &sourceText, const QByteArray &textToInsert = QByteArray(),
|
||||||
bool isObjC = false)
|
bool isObjC = false)
|
||||||
: m_position(-1), m_editorWidget(0), m_textDocument(0), m_editor(0)
|
|
||||||
{
|
{
|
||||||
QVERIFY(succeededSoFar());
|
QVERIFY(succeededSoFar());
|
||||||
m_succeededSoFar = false;
|
m_succeededSoFar = false;
|
||||||
@@ -100,7 +99,7 @@ public:
|
|||||||
m_succeededSoFar = true;
|
m_succeededSoFar = true;
|
||||||
}
|
}
|
||||||
|
|
||||||
QStringList getCompletions(bool *replaceAccessOperator = 0) const
|
QStringList getCompletions(bool *replaceAccessOperator = nullptr) const
|
||||||
{
|
{
|
||||||
QStringList completions;
|
QStringList completions;
|
||||||
LanguageFeatures languageFeatures = LanguageFeatures::defaultFeatures();
|
LanguageFeatures languageFeatures = LanguageFeatures::defaultFeatures();
|
||||||
@@ -153,12 +152,12 @@ public:
|
|||||||
|
|
||||||
private:
|
private:
|
||||||
QByteArray m_source;
|
QByteArray m_source;
|
||||||
int m_position;
|
int m_position = -1;
|
||||||
Snapshot m_snapshot;
|
Snapshot m_snapshot;
|
||||||
QScopedPointer<Tests::TemporaryDir> m_temporaryDir;
|
QScopedPointer<Tests::TemporaryDir> m_temporaryDir;
|
||||||
TextEditorWidget *m_editorWidget;
|
TextEditorWidget *m_editorWidget = nullptr;
|
||||||
QTextDocument *m_textDocument;
|
QTextDocument *m_textDocument = nullptr;
|
||||||
IEditor *m_editor;
|
IEditor *m_editor = nullptr;
|
||||||
};
|
};
|
||||||
|
|
||||||
bool isProbablyGlobalCompletion(const QStringList &list)
|
bool isProbablyGlobalCompletion(const QStringList &list)
|
||||||
|
|||||||
@@ -70,7 +70,7 @@ namespace Internal {
|
|||||||
|
|
||||||
struct CompleteFunctionDeclaration
|
struct CompleteFunctionDeclaration
|
||||||
{
|
{
|
||||||
explicit CompleteFunctionDeclaration(Function *f = 0)
|
explicit CompleteFunctionDeclaration(Function *f = nullptr)
|
||||||
: function(f)
|
: function(f)
|
||||||
{}
|
{}
|
||||||
|
|
||||||
@@ -83,7 +83,7 @@ struct CompleteFunctionDeclaration
|
|||||||
class CppAssistProposalItem final : public AssistProposalItem
|
class CppAssistProposalItem final : public AssistProposalItem
|
||||||
{
|
{
|
||||||
public:
|
public:
|
||||||
~CppAssistProposalItem() noexcept {}
|
~CppAssistProposalItem() noexcept override = default;
|
||||||
bool prematurelyApplies(const QChar &c) const override;
|
bool prematurelyApplies(const QChar &c) const override;
|
||||||
void applyContextualContent(TextDocumentManipulatorInterface &manipulator, int basePosition) const override;
|
void applyContextualContent(TextDocumentManipulatorInterface &manipulator, int basePosition) const override;
|
||||||
|
|
||||||
@@ -120,7 +120,7 @@ AssistProposalItemInterface *CppAssistProposalModel::proposalItem(int index) con
|
|||||||
{
|
{
|
||||||
AssistProposalItemInterface *item = GenericProposalModel::proposalItem(index);
|
AssistProposalItemInterface *item = GenericProposalModel::proposalItem(index);
|
||||||
if (!item->isSnippet()) {
|
if (!item->isSnippet()) {
|
||||||
CppAssistProposalItem *cppItem = static_cast<CppAssistProposalItem *>(item);
|
auto cppItem = static_cast<CppAssistProposalItem *>(item);
|
||||||
cppItem->keepCompletionOperator(m_completionOperator);
|
cppItem->keepCompletionOperator(m_completionOperator);
|
||||||
cppItem->keepTypeOfExpression(m_typeOfExpression);
|
cppItem->keepTypeOfExpression(m_typeOfExpression);
|
||||||
}
|
}
|
||||||
@@ -191,7 +191,7 @@ quint64 CppAssistProposalItem::hash() const
|
|||||||
|
|
||||||
void CppAssistProposalItem::applyContextualContent(TextDocumentManipulatorInterface &manipulator, int basePosition) const
|
void CppAssistProposalItem::applyContextualContent(TextDocumentManipulatorInterface &manipulator, int basePosition) const
|
||||||
{
|
{
|
||||||
Symbol *symbol = 0;
|
Symbol *symbol = nullptr;
|
||||||
|
|
||||||
if (data().isValid())
|
if (data().isValid())
|
||||||
symbol = data().value<Symbol *>();
|
symbol = data().value<Symbol *>();
|
||||||
@@ -347,7 +347,7 @@ void CppAssistProposalItem::applyContextualContent(TextDocumentManipulatorInterf
|
|||||||
class CppFunctionHintModel : public IFunctionHintProposalModel
|
class CppFunctionHintModel : public IFunctionHintProposalModel
|
||||||
{
|
{
|
||||||
public:
|
public:
|
||||||
CppFunctionHintModel(QList<Function *> functionSymbols,
|
CppFunctionHintModel(const QList<Function *> &functionSymbols,
|
||||||
const QSharedPointer<TypeOfExpression> &typeOfExp)
|
const QSharedPointer<TypeOfExpression> &typeOfExp)
|
||||||
: m_functionSymbols(functionSymbols)
|
: m_functionSymbols(functionSymbols)
|
||||||
, m_currentArg(-1)
|
, m_currentArg(-1)
|
||||||
@@ -426,7 +426,7 @@ AssistInterface *InternalCompletionAssistProvider::createAssistInterface(const Q
|
|||||||
int position,
|
int position,
|
||||||
AssistReason reason) const
|
AssistReason reason) const
|
||||||
{
|
{
|
||||||
QTC_ASSERT(textEditorWidget, return 0);
|
QTC_ASSERT(textEditorWidget, return nullptr);
|
||||||
|
|
||||||
return new CppCompletionAssistInterface(filePath,
|
return new CppCompletionAssistInterface(filePath,
|
||||||
textEditorWidget,
|
textEditorWidget,
|
||||||
@@ -469,18 +469,16 @@ namespace {
|
|||||||
class ConvertToCompletionItem: protected NameVisitor
|
class ConvertToCompletionItem: protected NameVisitor
|
||||||
{
|
{
|
||||||
// The completion item.
|
// The completion item.
|
||||||
AssistProposalItem *_item;
|
AssistProposalItem *_item = nullptr;
|
||||||
|
|
||||||
// The current symbol.
|
// The current symbol.
|
||||||
Symbol *_symbol;
|
Symbol *_symbol = nullptr;
|
||||||
|
|
||||||
// The pretty printer.
|
// The pretty printer.
|
||||||
Overview overview;
|
Overview overview;
|
||||||
|
|
||||||
public:
|
public:
|
||||||
ConvertToCompletionItem()
|
ConvertToCompletionItem()
|
||||||
: _item(0)
|
|
||||||
, _symbol(0)
|
|
||||||
{
|
{
|
||||||
overview.showReturnTypes = true;
|
overview.showReturnTypes = true;
|
||||||
overview.showArgumentNames = true;
|
overview.showArgumentNames = true;
|
||||||
@@ -491,9 +489,9 @@ public:
|
|||||||
//using declaration can be qualified
|
//using declaration can be qualified
|
||||||
if (!symbol || !symbol->name() || (symbol->name()->isQualifiedNameId()
|
if (!symbol || !symbol->name() || (symbol->name()->isQualifiedNameId()
|
||||||
&& !symbol->asUsingDeclaration()))
|
&& !symbol->asUsingDeclaration()))
|
||||||
return 0;
|
return nullptr;
|
||||||
|
|
||||||
AssistProposalItem *previousItem = switchCompletionItem(0);
|
AssistProposalItem *previousItem = switchCompletionItem(nullptr);
|
||||||
Symbol *previousSymbol = switchSymbol(symbol);
|
Symbol *previousSymbol = switchSymbol(symbol);
|
||||||
accept(symbol->unqualifiedName());
|
accept(symbol->unqualifiedName());
|
||||||
if (_item)
|
if (_item)
|
||||||
@@ -524,32 +522,32 @@ protected:
|
|||||||
return item;
|
return item;
|
||||||
}
|
}
|
||||||
|
|
||||||
void visit(const Identifier *name)
|
void visit(const Identifier *name) override
|
||||||
{
|
{
|
||||||
_item = newCompletionItem(name);
|
_item = newCompletionItem(name);
|
||||||
if (!_symbol->isScope() || _symbol->isFunction())
|
if (!_symbol->isScope() || _symbol->isFunction())
|
||||||
_item->setDetail(overview.prettyType(_symbol->type(), name));
|
_item->setDetail(overview.prettyType(_symbol->type(), name));
|
||||||
}
|
}
|
||||||
|
|
||||||
void visit(const TemplateNameId *name)
|
void visit(const TemplateNameId *name) override
|
||||||
{
|
{
|
||||||
_item = newCompletionItem(name);
|
_item = newCompletionItem(name);
|
||||||
_item->setText(QString::fromUtf8(name->identifier()->chars(), name->identifier()->size()));
|
_item->setText(QString::fromUtf8(name->identifier()->chars(), name->identifier()->size()));
|
||||||
}
|
}
|
||||||
|
|
||||||
void visit(const DestructorNameId *name)
|
void visit(const DestructorNameId *name) override
|
||||||
{ _item = newCompletionItem(name); }
|
{ _item = newCompletionItem(name); }
|
||||||
|
|
||||||
void visit(const OperatorNameId *name)
|
void visit(const OperatorNameId *name) override
|
||||||
{
|
{
|
||||||
_item = newCompletionItem(name);
|
_item = newCompletionItem(name);
|
||||||
_item->setDetail(overview.prettyType(_symbol->type(), name));
|
_item->setDetail(overview.prettyType(_symbol->type(), name));
|
||||||
}
|
}
|
||||||
|
|
||||||
void visit(const ConversionNameId *name)
|
void visit(const ConversionNameId *name) override
|
||||||
{ _item = newCompletionItem(name); }
|
{ _item = newCompletionItem(name); }
|
||||||
|
|
||||||
void visit(const QualifiedNameId *name)
|
void visit(const QualifiedNameId *name) override
|
||||||
{ _item = newCompletionItem(name->name()); }
|
{ _item = newCompletionItem(name->name()); }
|
||||||
};
|
};
|
||||||
|
|
||||||
@@ -561,7 +559,7 @@ Class *asClassOrTemplateClassType(FullySpecifiedType ty)
|
|||||||
if (Symbol *decl = templ->declaration())
|
if (Symbol *decl = templ->declaration())
|
||||||
return decl->asClass();
|
return decl->asClass();
|
||||||
}
|
}
|
||||||
return 0;
|
return nullptr;
|
||||||
}
|
}
|
||||||
|
|
||||||
Scope *enclosingNonTemplateScope(Symbol *symbol)
|
Scope *enclosingNonTemplateScope(Symbol *symbol)
|
||||||
@@ -573,7 +571,7 @@ Scope *enclosingNonTemplateScope(Symbol *symbol)
|
|||||||
return scope;
|
return scope;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
return 0;
|
return nullptr;
|
||||||
}
|
}
|
||||||
|
|
||||||
Function *asFunctionOrTemplateFunctionType(FullySpecifiedType ty)
|
Function *asFunctionOrTemplateFunctionType(FullySpecifiedType ty)
|
||||||
@@ -584,7 +582,7 @@ Function *asFunctionOrTemplateFunctionType(FullySpecifiedType ty)
|
|||||||
if (Symbol *decl = templ->declaration())
|
if (Symbol *decl = templ->declaration())
|
||||||
return decl->asFunction();
|
return decl->asFunction();
|
||||||
}
|
}
|
||||||
return 0;
|
return nullptr;
|
||||||
}
|
}
|
||||||
|
|
||||||
bool isQPrivateSignal(const Symbol *symbol)
|
bool isQPrivateSignal(const Symbol *symbol)
|
||||||
@@ -758,7 +756,7 @@ bool canCompleteClassNameAt2ndOr4thConnectArgument(
|
|||||||
ClassOrNamespace *classOrNamespaceFromLookupItem(const LookupItem &lookupItem,
|
ClassOrNamespace *classOrNamespaceFromLookupItem(const LookupItem &lookupItem,
|
||||||
const LookupContext &context)
|
const LookupContext &context)
|
||||||
{
|
{
|
||||||
const Name *name = 0;
|
const Name *name = nullptr;
|
||||||
|
|
||||||
if (Symbol *d = lookupItem.declaration()) {
|
if (Symbol *d = lookupItem.declaration()) {
|
||||||
if (Class *k = d->asClass())
|
if (Class *k = d->asClass())
|
||||||
@@ -771,29 +769,29 @@ ClassOrNamespace *classOrNamespaceFromLookupItem(const LookupItem &lookupItem,
|
|||||||
if (PointerType *pointerType = type->asPointerType())
|
if (PointerType *pointerType = type->asPointerType())
|
||||||
type = pointerType->elementType().simplified();
|
type = pointerType->elementType().simplified();
|
||||||
else
|
else
|
||||||
return 0; // not a pointer or a reference to a pointer.
|
return nullptr; // not a pointer or a reference to a pointer.
|
||||||
|
|
||||||
NamedType *namedType = type->asNamedType();
|
NamedType *namedType = type->asNamedType();
|
||||||
if (!namedType) // not a class name.
|
if (!namedType) // not a class name.
|
||||||
return 0;
|
return nullptr;
|
||||||
|
|
||||||
name = namedType->name();
|
name = namedType->name();
|
||||||
}
|
}
|
||||||
|
|
||||||
return name ? context.lookupType(name, lookupItem.scope()) : 0;
|
return name ? context.lookupType(name, lookupItem.scope()) : nullptr;
|
||||||
}
|
}
|
||||||
|
|
||||||
Class *classFromLookupItem(const LookupItem &lookupItem, const LookupContext &context)
|
Class *classFromLookupItem(const LookupItem &lookupItem, const LookupContext &context)
|
||||||
{
|
{
|
||||||
ClassOrNamespace *b = classOrNamespaceFromLookupItem(lookupItem, context);
|
ClassOrNamespace *b = classOrNamespaceFromLookupItem(lookupItem, context);
|
||||||
if (!b)
|
if (!b)
|
||||||
return 0;
|
return nullptr;
|
||||||
|
|
||||||
foreach (Symbol *s, b->symbols()) {
|
foreach (Symbol *s, b->symbols()) {
|
||||||
if (Class *klass = s->asClass())
|
if (Class *klass = s->asClass())
|
||||||
return klass;
|
return klass;
|
||||||
}
|
}
|
||||||
return 0;
|
return nullptr;
|
||||||
}
|
}
|
||||||
|
|
||||||
const Name *minimalName(Symbol *symbol, Scope *targetScope, const LookupContext &context)
|
const Name *minimalName(Symbol *symbol, Scope *targetScope, const LookupContext &context)
|
||||||
@@ -814,15 +812,14 @@ InternalCppCompletionAssistProcessor::InternalCppCompletionAssistProcessor()
|
|||||||
{
|
{
|
||||||
}
|
}
|
||||||
|
|
||||||
InternalCppCompletionAssistProcessor::~InternalCppCompletionAssistProcessor()
|
InternalCppCompletionAssistProcessor::~InternalCppCompletionAssistProcessor() = default;
|
||||||
{}
|
|
||||||
|
|
||||||
IAssistProposal * InternalCppCompletionAssistProcessor::perform(const AssistInterface *interface)
|
IAssistProposal * InternalCppCompletionAssistProcessor::perform(const AssistInterface *interface)
|
||||||
{
|
{
|
||||||
m_interface.reset(static_cast<const CppCompletionAssistInterface *>(interface));
|
m_interface.reset(static_cast<const CppCompletionAssistInterface *>(interface));
|
||||||
|
|
||||||
if (interface->reason() != ExplicitlyInvoked && !accepts())
|
if (interface->reason() != ExplicitlyInvoked && !accepts())
|
||||||
return 0;
|
return nullptr;
|
||||||
|
|
||||||
int index = startCompletionHelper();
|
int index = startCompletionHelper();
|
||||||
if (index != -1) {
|
if (index != -1) {
|
||||||
@@ -832,7 +829,7 @@ IAssistProposal * InternalCppCompletionAssistProcessor::perform(const AssistInte
|
|||||||
return createContentProposal();
|
return createContentProposal();
|
||||||
}
|
}
|
||||||
|
|
||||||
return 0;
|
return nullptr;
|
||||||
}
|
}
|
||||||
|
|
||||||
bool InternalCppCompletionAssistProcessor::accepts() const
|
bool InternalCppCompletionAssistProcessor::accepts() const
|
||||||
@@ -901,13 +898,13 @@ IAssistProposal *InternalCppCompletionAssistProcessor::createContentProposal()
|
|||||||
QSet<QString> processed;
|
QSet<QString> processed;
|
||||||
auto it = m_completions.begin();
|
auto it = m_completions.begin();
|
||||||
while (it != m_completions.end()) {
|
while (it != m_completions.end()) {
|
||||||
CppAssistProposalItem *item = static_cast<CppAssistProposalItem *>(*it);
|
auto item = static_cast<CppAssistProposalItem *>(*it);
|
||||||
if (!processed.contains(item->text()) || item->isSnippet()) {
|
if (!processed.contains(item->text()) || item->isSnippet()) {
|
||||||
++it;
|
++it;
|
||||||
if (!item->isSnippet()) {
|
if (!item->isSnippet()) {
|
||||||
processed.insert(item->text());
|
processed.insert(item->text());
|
||||||
if (!item->isOverloaded()) {
|
if (!item->isOverloaded()) {
|
||||||
if (Symbol *symbol = qvariant_cast<Symbol *>(item->data())) {
|
if (auto symbol = qvariant_cast<Symbol *>(item->data())) {
|
||||||
if (Function *funTy = symbol->type()->asFunctionType()) {
|
if (Function *funTy = symbol->type()->asFunctionType()) {
|
||||||
if (funTy->hasArguments())
|
if (funTy->hasArguments())
|
||||||
item->markAsOverloaded();
|
item->markAsOverloaded();
|
||||||
@@ -1333,7 +1330,7 @@ int InternalCppCompletionAssistProcessor::startCompletionInternal(const QString
|
|||||||
m_model->m_typeOfExpression->init(thisDocument, m_interface->snapshot());
|
m_model->m_typeOfExpression->init(thisDocument, m_interface->snapshot());
|
||||||
|
|
||||||
Scope *scope = thisDocument->scopeAt(line, positionInBlock);
|
Scope *scope = thisDocument->scopeAt(line, positionInBlock);
|
||||||
QTC_ASSERT(scope != 0, return -1);
|
QTC_ASSERT(scope, return -1);
|
||||||
|
|
||||||
if (expression.isEmpty()) {
|
if (expression.isEmpty()) {
|
||||||
if (m_model->m_completionOperator == T_EOF_SYMBOL || m_model->m_completionOperator == T_COLON_COLON) {
|
if (m_model->m_completionOperator == T_EOF_SYMBOL || m_model->m_completionOperator == T_COLON_COLON) {
|
||||||
@@ -1461,7 +1458,7 @@ bool InternalCppCompletionAssistProcessor::globalCompletion(Scope *currentScope)
|
|||||||
}
|
}
|
||||||
|
|
||||||
QList<ClassOrNamespace *> usingBindings;
|
QList<ClassOrNamespace *> usingBindings;
|
||||||
ClassOrNamespace *currentBinding = 0;
|
ClassOrNamespace *currentBinding = nullptr;
|
||||||
|
|
||||||
for (Scope *scope = currentScope; scope; scope = scope->enclosingScope()) {
|
for (Scope *scope = currentScope; scope; scope = scope->enclosingScope()) {
|
||||||
if (Block *block = scope->asBlock()) {
|
if (Block *block = scope->asBlock()) {
|
||||||
@@ -1543,7 +1540,7 @@ bool InternalCppCompletionAssistProcessor::completeMember(const QList<LookupItem
|
|||||||
|
|
||||||
ResolveExpression resolveExpression(context);
|
ResolveExpression resolveExpression(context);
|
||||||
|
|
||||||
bool *replaceDotForArrow = 0;
|
bool *replaceDotForArrow = nullptr;
|
||||||
if (!m_interface->languageFeatures().objCEnabled)
|
if (!m_interface->languageFeatures().objCEnabled)
|
||||||
replaceDotForArrow = &m_model->m_replaceDotForArrow;
|
replaceDotForArrow = &m_model->m_replaceDotForArrow;
|
||||||
|
|
||||||
|
|||||||
@@ -62,8 +62,6 @@ class CppAssistProposalModel : public TextEditor::GenericProposalModel
|
|||||||
public:
|
public:
|
||||||
CppAssistProposalModel()
|
CppAssistProposalModel()
|
||||||
: TextEditor::GenericProposalModel()
|
: TextEditor::GenericProposalModel()
|
||||||
, m_completionOperator(CPlusPlus::T_EOF_SYMBOL)
|
|
||||||
, m_replaceDotForArrow(false)
|
|
||||||
, m_typeOfExpression(new CPlusPlus::TypeOfExpression)
|
, m_typeOfExpression(new CPlusPlus::TypeOfExpression)
|
||||||
{
|
{
|
||||||
m_typeOfExpression->setExpandTemplates(true);
|
m_typeOfExpression->setExpandTemplates(true);
|
||||||
@@ -72,8 +70,8 @@ public:
|
|||||||
bool isSortable(const QString &prefix) const override;
|
bool isSortable(const QString &prefix) const override;
|
||||||
TextEditor::AssistProposalItemInterface *proposalItem(int index) const override;
|
TextEditor::AssistProposalItemInterface *proposalItem(int index) const override;
|
||||||
|
|
||||||
unsigned m_completionOperator;
|
unsigned m_completionOperator = CPlusPlus::T_EOF_SYMBOL;
|
||||||
bool m_replaceDotForArrow;
|
bool m_replaceDotForArrow = false;
|
||||||
QSharedPointer<CPlusPlus::TypeOfExpression> m_typeOfExpression;
|
QSharedPointer<CPlusPlus::TypeOfExpression> m_typeOfExpression;
|
||||||
};
|
};
|
||||||
|
|
||||||
@@ -98,7 +96,7 @@ class InternalCppCompletionAssistProcessor : public CppCompletionAssistProcessor
|
|||||||
{
|
{
|
||||||
public:
|
public:
|
||||||
InternalCppCompletionAssistProcessor();
|
InternalCppCompletionAssistProcessor();
|
||||||
~InternalCppCompletionAssistProcessor();
|
~InternalCppCompletionAssistProcessor() override;
|
||||||
|
|
||||||
TextEditor::IAssistProposal *perform(const TextEditor::AssistInterface *interface) override;
|
TextEditor::IAssistProposal *perform(const TextEditor::AssistInterface *interface) override;
|
||||||
|
|
||||||
|
|||||||
@@ -41,8 +41,7 @@ using namespace CPlusPlus;
|
|||||||
namespace CppTools {
|
namespace CppTools {
|
||||||
|
|
||||||
CppCompletionAssistProcessor::CppCompletionAssistProcessor(int snippetItemOrder)
|
CppCompletionAssistProcessor::CppCompletionAssistProcessor(int snippetItemOrder)
|
||||||
: m_positionForProposal(-1)
|
: m_preprocessorCompletions(
|
||||||
, m_preprocessorCompletions(
|
|
||||||
QStringList({"define", "error", "include", "line", "pragma", "pragma once",
|
QStringList({"define", "error", "include", "line", "pragma", "pragma once",
|
||||||
"pragma omp atomic", "pragma omp parallel", "pragma omp for",
|
"pragma omp atomic", "pragma omp parallel", "pragma omp for",
|
||||||
"pragma omp ordered", "pragma omp parallel for", "pragma omp section",
|
"pragma omp ordered", "pragma omp parallel for", "pragma omp section",
|
||||||
@@ -50,7 +49,6 @@ CppCompletionAssistProcessor::CppCompletionAssistProcessor(int snippetItemOrder)
|
|||||||
"pragma omp master", "pragma omp critical", "pragma omp barrier",
|
"pragma omp master", "pragma omp critical", "pragma omp barrier",
|
||||||
"pragma omp flush", "pragma omp threadprivate", "undef", "if", "ifdef",
|
"pragma omp flush", "pragma omp threadprivate", "undef", "if", "ifdef",
|
||||||
"ifndef", "elif", "else", "endif"}))
|
"ifndef", "elif", "else", "endif"}))
|
||||||
, m_hintProposal(0)
|
|
||||||
, m_snippetCollector(QLatin1String(CppEditor::Constants::CPP_SNIPPETS_GROUP_ID),
|
, m_snippetCollector(QLatin1String(CppEditor::Constants::CPP_SNIPPETS_GROUP_ID),
|
||||||
QIcon(QLatin1String(":/texteditor/images/snippet.png")),
|
QIcon(QLatin1String(":/texteditor/images/snippet.png")),
|
||||||
snippetItemOrder)
|
snippetItemOrder)
|
||||||
|
|||||||
@@ -45,7 +45,7 @@ namespace CppTools {
|
|||||||
class CPPTOOLS_EXPORT CppCompletionAssistProcessor : public TextEditor::IAssistProcessor
|
class CPPTOOLS_EXPORT CppCompletionAssistProcessor : public TextEditor::IAssistProcessor
|
||||||
{
|
{
|
||||||
public:
|
public:
|
||||||
CppCompletionAssistProcessor(int snippetItemOrder = 0);
|
explicit CppCompletionAssistProcessor(int snippetItemOrder = 0);
|
||||||
|
|
||||||
protected:
|
protected:
|
||||||
void addSnippets();
|
void addSnippets();
|
||||||
@@ -60,10 +60,10 @@ protected:
|
|||||||
DotAtIncludeCompletionHandler dotAtIncludeCompletionHandler
|
DotAtIncludeCompletionHandler dotAtIncludeCompletionHandler
|
||||||
= DotAtIncludeCompletionHandler());
|
= DotAtIncludeCompletionHandler());
|
||||||
|
|
||||||
int m_positionForProposal;
|
int m_positionForProposal = -1;
|
||||||
QList<TextEditor::AssistProposalItemInterface *> m_completions;
|
QList<TextEditor::AssistProposalItemInterface *> m_completions;
|
||||||
QStringList m_preprocessorCompletions;
|
QStringList m_preprocessorCompletions;
|
||||||
TextEditor::IAssistProposal *m_hintProposal;
|
TextEditor::IAssistProposal *m_hintProposal = nullptr;
|
||||||
|
|
||||||
private:
|
private:
|
||||||
TextEditor::SnippetAssistCollector m_snippetCollector;
|
TextEditor::SnippetAssistCollector m_snippetCollector;
|
||||||
|
|||||||
@@ -51,7 +51,7 @@ bool CppCompletionAssistProvider::isActivationCharSequence(const QString &sequen
|
|||||||
const QChar &ch = sequence.at(2);
|
const QChar &ch = sequence.at(2);
|
||||||
const QChar &ch2 = sequence.at(1);
|
const QChar &ch2 = sequence.at(1);
|
||||||
const QChar &ch3 = sequence.at(0);
|
const QChar &ch3 = sequence.at(0);
|
||||||
if (activationSequenceChar(ch, ch2, ch3, 0, true, false) != 0)
|
if (activationSequenceChar(ch, ch2, ch3, nullptr, true, false) != 0)
|
||||||
return true;
|
return true;
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -70,7 +70,7 @@ QList<Core::LocatorFilterEntry> CppCurrentDocumentFilter::matchesFor(
|
|||||||
return goodEntries;
|
return goodEntries;
|
||||||
|
|
||||||
const QList<IndexItem::Ptr> items = itemsOfCurrentDocument();
|
const QList<IndexItem::Ptr> items = itemsOfCurrentDocument();
|
||||||
for (IndexItem::Ptr info : items) {
|
for (const IndexItem::Ptr &info : items) {
|
||||||
if (future.isCanceled())
|
if (future.isCanceled())
|
||||||
break;
|
break;
|
||||||
|
|
||||||
|
|||||||
@@ -43,7 +43,7 @@ class CppCurrentDocumentFilter : public Core::ILocatorFilter
|
|||||||
|
|
||||||
public:
|
public:
|
||||||
explicit CppCurrentDocumentFilter(CppModelManager *manager);
|
explicit CppCurrentDocumentFilter(CppModelManager *manager);
|
||||||
~CppCurrentDocumentFilter() {}
|
~CppCurrentDocumentFilter() override = default;
|
||||||
|
|
||||||
QList<Core::LocatorFilterEntry> matchesFor(QFutureInterface<Core::LocatorFilterEntry> &future,
|
QList<Core::LocatorFilterEntry> matchesFor(QFutureInterface<Core::LocatorFilterEntry> &future,
|
||||||
const QString &entry) override;
|
const QString &entry) override;
|
||||||
|
|||||||
@@ -57,11 +57,9 @@ static QStringList stripName(const QString &name)
|
|||||||
return all;
|
return all;
|
||||||
}
|
}
|
||||||
|
|
||||||
CppElement::CppElement() : helpCategory(TextEditor::HelpItem::Unknown)
|
CppElement::CppElement() = default;
|
||||||
{}
|
|
||||||
|
|
||||||
CppElement::~CppElement()
|
CppElement::~CppElement() = default;
|
||||||
{}
|
|
||||||
|
|
||||||
CppClass *CppElement::toCppClass()
|
CppClass *CppElement::toCppClass()
|
||||||
{
|
{
|
||||||
@@ -168,7 +166,7 @@ CppClass *CppClass::toCppClass()
|
|||||||
|
|
||||||
void CppClass::lookupBases(Symbol *declaration, const LookupContext &context)
|
void CppClass::lookupBases(Symbol *declaration, const LookupContext &context)
|
||||||
{
|
{
|
||||||
typedef QPair<ClassOrNamespace *, CppClass *> Data;
|
using Data = QPair<ClassOrNamespace*, CppClass*>;
|
||||||
|
|
||||||
if (ClassOrNamespace *clazz = context.lookupType(declaration)) {
|
if (ClassOrNamespace *clazz = context.lookupType(declaration)) {
|
||||||
QSet<ClassOrNamespace *> visited;
|
QSet<ClassOrNamespace *> visited;
|
||||||
@@ -199,7 +197,7 @@ void CppClass::lookupBases(Symbol *declaration, const LookupContext &context)
|
|||||||
|
|
||||||
void CppClass::lookupDerived(Symbol *declaration, const Snapshot &snapshot)
|
void CppClass::lookupDerived(Symbol *declaration, const Snapshot &snapshot)
|
||||||
{
|
{
|
||||||
typedef QPair<CppClass *, CppTools::TypeHierarchy> Data;
|
using Data = QPair<CppClass*, CppTools::TypeHierarchy>;
|
||||||
|
|
||||||
CppTools::TypeHierarchyBuilder builder(declaration, snapshot);
|
CppTools::TypeHierarchyBuilder builder(declaration, snapshot);
|
||||||
const CppTools::TypeHierarchy &completeHierarchy = builder.buildDerivedTypeHierarchy();
|
const CppTools::TypeHierarchy &completeHierarchy = builder.buildDerivedTypeHierarchy();
|
||||||
@@ -268,7 +266,7 @@ public:
|
|||||||
{
|
{
|
||||||
const FullySpecifiedType &type = declaration->type();
|
const FullySpecifiedType &type = declaration->type();
|
||||||
|
|
||||||
const Name *typeName = 0;
|
const Name *typeName = nullptr;
|
||||||
if (type->isNamedType()) {
|
if (type->isNamedType()) {
|
||||||
typeName = type->asNamedType()->name();
|
typeName = type->asNamedType()->name();
|
||||||
} else if (type->isPointerType() || type->isReferenceType()) {
|
} else if (type->isPointerType() || type->isReferenceType()) {
|
||||||
@@ -462,7 +460,7 @@ void CppElementEvaluator::handleLookupItemMatch(const Snapshot &snapshot,
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
CppClass *cppClass = new CppClass(declaration);
|
auto cppClass = new CppClass(declaration);
|
||||||
if (m_lookupBaseClasses)
|
if (m_lookupBaseClasses)
|
||||||
cppClass->lookupBases(declaration, contextToUse);
|
cppClass->lookupBases(declaration, contextToUse);
|
||||||
if (m_lookupDerivedClasses)
|
if (m_lookupDerivedClasses)
|
||||||
@@ -470,7 +468,7 @@ void CppElementEvaluator::handleLookupItemMatch(const Snapshot &snapshot,
|
|||||||
m_element = QSharedPointer<CppElement>(cppClass);
|
m_element = QSharedPointer<CppElement>(cppClass);
|
||||||
} else if (Enum *enumDecl = declaration->asEnum()) {
|
} else if (Enum *enumDecl = declaration->asEnum()) {
|
||||||
m_element = QSharedPointer<CppElement>(new CppEnum(enumDecl));
|
m_element = QSharedPointer<CppElement>(new CppEnum(enumDecl));
|
||||||
} else if (EnumeratorDeclaration *enumerator = dynamic_cast<EnumeratorDeclaration *>(declaration)) {
|
} else if (auto enumerator = dynamic_cast<EnumeratorDeclaration *>(declaration)) {
|
||||||
m_element = QSharedPointer<CppElement>(new CppEnumerator(enumerator));
|
m_element = QSharedPointer<CppElement>(new CppEnumerator(enumerator));
|
||||||
} else if (declaration->isTypedef()) {
|
} else if (declaration->isTypedef()) {
|
||||||
m_element = QSharedPointer<CppElement>(new CppTypedef(declaration));
|
m_element = QSharedPointer<CppElement>(new CppTypedef(declaration));
|
||||||
|
|||||||
@@ -93,7 +93,7 @@ public:
|
|||||||
|
|
||||||
virtual CppClass *toCppClass();
|
virtual CppClass *toCppClass();
|
||||||
|
|
||||||
TextEditor::HelpItem::Category helpCategory;
|
TextEditor::HelpItem::Category helpCategory = TextEditor::HelpItem::Unknown;
|
||||||
QStringList helpIdCandidates;
|
QStringList helpIdCandidates;
|
||||||
QString helpMark;
|
QString helpMark;
|
||||||
Utils::Link link;
|
Utils::Link link;
|
||||||
|
|||||||
@@ -86,9 +86,7 @@ bool operator<(const FileIterationOrder::Entry &first, const FileIterationOrder:
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
FileIterationOrder::FileIterationOrder()
|
FileIterationOrder::FileIterationOrder() = default;
|
||||||
{
|
|
||||||
}
|
|
||||||
|
|
||||||
FileIterationOrder::FileIterationOrder(const QString &referenceFilePath,
|
FileIterationOrder::FileIterationOrder(const QString &referenceFilePath,
|
||||||
const QString &referenceProjectPartId)
|
const QString &referenceProjectPartId)
|
||||||
|
|||||||
@@ -71,8 +71,8 @@ class CppFileSettingsWidget : public QWidget
|
|||||||
Q_OBJECT
|
Q_OBJECT
|
||||||
|
|
||||||
public:
|
public:
|
||||||
explicit CppFileSettingsWidget(QWidget *parent = 0);
|
explicit CppFileSettingsWidget(QWidget *parent = nullptr);
|
||||||
virtual ~CppFileSettingsWidget();
|
~CppFileSettingsWidget() override;
|
||||||
|
|
||||||
CppFileSettings settings() const;
|
CppFileSettings settings() const;
|
||||||
void setSettings(const CppFileSettings &s);
|
void setSettings(const CppFileSettings &s);
|
||||||
@@ -89,11 +89,11 @@ class CppFileSettingsPage : public Core::IOptionsPage
|
|||||||
{
|
{
|
||||||
public:
|
public:
|
||||||
explicit CppFileSettingsPage(QSharedPointer<CppFileSettings> &settings,
|
explicit CppFileSettingsPage(QSharedPointer<CppFileSettings> &settings,
|
||||||
QObject *parent = 0);
|
QObject *parent = nullptr);
|
||||||
|
|
||||||
QWidget *widget();
|
QWidget *widget() override;
|
||||||
void apply();
|
void apply() override;
|
||||||
void finish();
|
void finish() override;
|
||||||
|
|
||||||
private:
|
private:
|
||||||
const QSharedPointer<CppFileSettings> m_settings;
|
const QSharedPointer<CppFileSettings> m_settings;
|
||||||
|
|||||||
@@ -218,7 +218,7 @@ public:
|
|||||||
}
|
}
|
||||||
|
|
||||||
CPlusPlus::Control *control = doc->control();
|
CPlusPlus::Control *control = doc->control();
|
||||||
if (control->findIdentifier(symbolId->chars(), symbolId->size()) != 0) {
|
if (control->findIdentifier(symbolId->chars(), symbolId->size()) != nullptr) {
|
||||||
if (doc != symbolDocument)
|
if (doc != symbolDocument)
|
||||||
doc->check();
|
doc->check();
|
||||||
|
|
||||||
@@ -239,7 +239,7 @@ class UpdateUI
|
|||||||
QFutureInterface<CPlusPlus::Usage> *future;
|
QFutureInterface<CPlusPlus::Usage> *future;
|
||||||
|
|
||||||
public:
|
public:
|
||||||
UpdateUI(QFutureInterface<CPlusPlus::Usage> *future): future(future) {}
|
explicit UpdateUI(QFutureInterface<CPlusPlus::Usage> *future): future(future) {}
|
||||||
|
|
||||||
void operator()(QList<CPlusPlus::Usage> &, const QList<CPlusPlus::Usage> &usages)
|
void operator()(QList<CPlusPlus::Usage> &, const QList<CPlusPlus::Usage> &usages)
|
||||||
{
|
{
|
||||||
@@ -258,9 +258,7 @@ CppFindReferences::CppFindReferences(CppModelManager *modelManager)
|
|||||||
{
|
{
|
||||||
}
|
}
|
||||||
|
|
||||||
CppFindReferences::~CppFindReferences()
|
CppFindReferences::~CppFindReferences() = default;
|
||||||
{
|
|
||||||
}
|
|
||||||
|
|
||||||
QList<int> CppFindReferences::references(CPlusPlus::Symbol *symbol,
|
QList<int> CppFindReferences::references(CPlusPlus::Symbol *symbol,
|
||||||
const CPlusPlus::LookupContext &context) const
|
const CPlusPlus::LookupContext &context) const
|
||||||
@@ -276,11 +274,11 @@ QList<int> CppFindReferences::references(CPlusPlus::Symbol *symbol,
|
|||||||
|
|
||||||
static void find_helper(QFutureInterface<CPlusPlus::Usage> &future,
|
static void find_helper(QFutureInterface<CPlusPlus::Usage> &future,
|
||||||
const WorkingCopy workingCopy,
|
const WorkingCopy workingCopy,
|
||||||
const CPlusPlus::LookupContext context,
|
const CPlusPlus::LookupContext &context,
|
||||||
CPlusPlus::Symbol *symbol)
|
CPlusPlus::Symbol *symbol)
|
||||||
{
|
{
|
||||||
const CPlusPlus::Identifier *symbolId = symbol->identifier();
|
const CPlusPlus::Identifier *symbolId = symbol->identifier();
|
||||||
QTC_ASSERT(symbolId != 0, return);
|
QTC_ASSERT(symbolId != nullptr, return);
|
||||||
|
|
||||||
const CPlusPlus::Snapshot snapshot = context.snapshot();
|
const CPlusPlus::Snapshot snapshot = context.snapshot();
|
||||||
|
|
||||||
@@ -465,7 +463,7 @@ void CppFindReferences::onReplaceButtonClicked(const QString &text,
|
|||||||
|
|
||||||
void CppFindReferences::searchAgain()
|
void CppFindReferences::searchAgain()
|
||||||
{
|
{
|
||||||
SearchResult *search = qobject_cast<SearchResult *>(sender());
|
auto search = qobject_cast<SearchResult *>(sender());
|
||||||
CppFindReferencesParameters parameters = search->userData().value<CppFindReferencesParameters>();
|
CppFindReferencesParameters parameters = search->userData().value<CppFindReferencesParameters>();
|
||||||
parameters.filesToRename.clear();
|
parameters.filesToRename.clear();
|
||||||
CPlusPlus::Snapshot snapshot = CppModelManager::instance()->snapshot();
|
CPlusPlus::Snapshot snapshot = CppModelManager::instance()->snapshot();
|
||||||
@@ -483,10 +481,10 @@ namespace {
|
|||||||
class UidSymbolFinder : public CPlusPlus::SymbolVisitor
|
class UidSymbolFinder : public CPlusPlus::SymbolVisitor
|
||||||
{
|
{
|
||||||
public:
|
public:
|
||||||
UidSymbolFinder(const QList<QByteArray> &uid) : m_uid(uid), m_index(0), m_result(0) { }
|
explicit UidSymbolFinder(const QList<QByteArray> &uid) : m_uid(uid) { }
|
||||||
CPlusPlus::Symbol *result() const { return m_result; }
|
CPlusPlus::Symbol *result() const { return m_result; }
|
||||||
|
|
||||||
bool preVisit(CPlusPlus::Symbol *symbol)
|
bool preVisit(CPlusPlus::Symbol *symbol) override
|
||||||
{
|
{
|
||||||
if (m_result)
|
if (m_result)
|
||||||
return false;
|
return false;
|
||||||
@@ -505,7 +503,7 @@ public:
|
|||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
void postVisit(CPlusPlus::Symbol *symbol)
|
void postVisit(CPlusPlus::Symbol *symbol) override
|
||||||
{
|
{
|
||||||
if (symbol->asScope())
|
if (symbol->asScope())
|
||||||
--m_index;
|
--m_index;
|
||||||
@@ -513,8 +511,8 @@ public:
|
|||||||
|
|
||||||
private:
|
private:
|
||||||
QList<QByteArray> m_uid;
|
QList<QByteArray> m_uid;
|
||||||
int m_index;
|
int m_index = 0;
|
||||||
CPlusPlus::Symbol *m_result;
|
CPlusPlus::Symbol *m_result = nullptr;
|
||||||
};
|
};
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -522,10 +520,10 @@ CPlusPlus::Symbol *CppFindReferences::findSymbol(const CppFindReferencesParamete
|
|||||||
const CPlusPlus::Snapshot &snapshot,
|
const CPlusPlus::Snapshot &snapshot,
|
||||||
CPlusPlus::LookupContext *context)
|
CPlusPlus::LookupContext *context)
|
||||||
{
|
{
|
||||||
QTC_ASSERT(context, return 0);
|
QTC_ASSERT(context, return nullptr);
|
||||||
QString symbolFile = QLatin1String(parameters.symbolFileName);
|
QString symbolFile = QLatin1String(parameters.symbolFileName);
|
||||||
if (!snapshot.contains(symbolFile))
|
if (!snapshot.contains(symbolFile))
|
||||||
return 0;
|
return nullptr;
|
||||||
|
|
||||||
CPlusPlus::Document::Ptr newSymbolDocument = snapshot.document(symbolFile);
|
CPlusPlus::Document::Ptr newSymbolDocument = snapshot.document(symbolFile);
|
||||||
// document is not parsed and has no bindings yet, do it
|
// document is not parsed and has no bindings yet, do it
|
||||||
@@ -542,7 +540,7 @@ CPlusPlus::Symbol *CppFindReferences::findSymbol(const CppFindReferencesParamete
|
|||||||
*context = CPlusPlus::LookupContext(doc, snapshot);
|
*context = CPlusPlus::LookupContext(doc, snapshot);
|
||||||
return finder.result();
|
return finder.result();
|
||||||
}
|
}
|
||||||
return 0;
|
return nullptr;
|
||||||
}
|
}
|
||||||
|
|
||||||
static void displayResults(SearchResult *search, QFutureWatcher<CPlusPlus::Usage> *watcher,
|
static void displayResults(SearchResult *search, QFutureWatcher<CPlusPlus::Usage> *watcher,
|
||||||
@@ -661,7 +659,7 @@ restart_search:
|
|||||||
}
|
}
|
||||||
|
|
||||||
static QString matchingLine(unsigned bytesOffsetOfUseStart, const QByteArray &utf8Source,
|
static QString matchingLine(unsigned bytesOffsetOfUseStart, const QByteArray &utf8Source,
|
||||||
unsigned *columnOfUseStart = 0)
|
unsigned *columnOfUseStart = nullptr)
|
||||||
{
|
{
|
||||||
int lineBegin = utf8Source.lastIndexOf('\n', bytesOffsetOfUseStart) + 1;
|
int lineBegin = utf8Source.lastIndexOf('\n', bytesOffsetOfUseStart) + 1;
|
||||||
int lineEnd = utf8Source.indexOf('\n', bytesOffsetOfUseStart);
|
int lineEnd = utf8Source.indexOf('\n', bytesOffsetOfUseStart);
|
||||||
@@ -765,7 +763,7 @@ void CppFindReferences::renameMacroUses(const CPlusPlus::Macro ¯o, const QSt
|
|||||||
|
|
||||||
void CppFindReferences::createWatcher(const QFuture<CPlusPlus::Usage> &future, SearchResult *search)
|
void CppFindReferences::createWatcher(const QFuture<CPlusPlus::Usage> &future, SearchResult *search)
|
||||||
{
|
{
|
||||||
QFutureWatcher<CPlusPlus::Usage> *watcher = new QFutureWatcher<CPlusPlus::Usage>();
|
auto watcher = new QFutureWatcher<CPlusPlus::Usage>();
|
||||||
// auto-delete:
|
// auto-delete:
|
||||||
connect(watcher, &QFutureWatcherBase::finished, watcher, [search, watcher]() {
|
connect(watcher, &QFutureWatcherBase::finished, watcher, [search, watcher]() {
|
||||||
searchFinished(search, watcher);
|
searchFinished(search, watcher);
|
||||||
|
|||||||
@@ -63,8 +63,8 @@ class CppFindReferences: public QObject
|
|||||||
Q_OBJECT
|
Q_OBJECT
|
||||||
|
|
||||||
public:
|
public:
|
||||||
CppFindReferences(CppModelManager *modelManager);
|
explicit CppFindReferences(CppModelManager *modelManager);
|
||||||
virtual ~CppFindReferences();
|
~CppFindReferences() override;
|
||||||
|
|
||||||
QList<int> references(CPlusPlus::Symbol *symbol, const CPlusPlus::LookupContext &context) const;
|
QList<int> references(CPlusPlus::Symbol *symbol, const CPlusPlus::LookupContext &context) const;
|
||||||
|
|
||||||
|
|||||||
@@ -59,6 +59,7 @@ public:
|
|||||||
const Document::Ptr &document,
|
const Document::Ptr &document,
|
||||||
const Snapshot &snapshot,
|
const Snapshot &snapshot,
|
||||||
SymbolFinder *symbolFinder);
|
SymbolFinder *symbolFinder);
|
||||||
|
VirtualFunctionHelper() = delete;
|
||||||
|
|
||||||
bool canLookupVirtualFunctionOverrides(Function *function);
|
bool canLookupVirtualFunctionOverrides(Function *function);
|
||||||
|
|
||||||
@@ -67,7 +68,6 @@ public:
|
|||||||
{ return m_staticClassOfFunctionCallExpression; }
|
{ return m_staticClassOfFunctionCallExpression; }
|
||||||
|
|
||||||
private:
|
private:
|
||||||
VirtualFunctionHelper();
|
|
||||||
Q_DISABLE_COPY(VirtualFunctionHelper)
|
Q_DISABLE_COPY(VirtualFunctionHelper)
|
||||||
|
|
||||||
Class *staticClassOfFunctionCallExpression_internal() const;
|
Class *staticClassOfFunctionCallExpression_internal() const;
|
||||||
@@ -82,10 +82,10 @@ private:
|
|||||||
SymbolFinder *m_finder;
|
SymbolFinder *m_finder;
|
||||||
|
|
||||||
// Determined
|
// Determined
|
||||||
ExpressionAST *m_baseExpressionAST;
|
ExpressionAST *m_baseExpressionAST = nullptr;
|
||||||
Function *m_function;
|
Function *m_function = nullptr;
|
||||||
int m_accessTokenKind;
|
int m_accessTokenKind = 0;
|
||||||
Class *m_staticClassOfFunctionCallExpression; // Output
|
Class *m_staticClassOfFunctionCallExpression = nullptr; // Output
|
||||||
};
|
};
|
||||||
|
|
||||||
VirtualFunctionHelper::VirtualFunctionHelper(TypeOfExpression &typeOfExpression,
|
VirtualFunctionHelper::VirtualFunctionHelper(TypeOfExpression &typeOfExpression,
|
||||||
@@ -99,10 +99,6 @@ VirtualFunctionHelper::VirtualFunctionHelper(TypeOfExpression &typeOfExpression,
|
|||||||
, m_snapshot(snapshot)
|
, m_snapshot(snapshot)
|
||||||
, m_typeOfExpression(typeOfExpression)
|
, m_typeOfExpression(typeOfExpression)
|
||||||
, m_finder(finder)
|
, m_finder(finder)
|
||||||
, m_baseExpressionAST(0)
|
|
||||||
, m_function(0)
|
|
||||||
, m_accessTokenKind(0)
|
|
||||||
, m_staticClassOfFunctionCallExpression(0)
|
|
||||||
{
|
{
|
||||||
if (ExpressionAST *expressionAST = typeOfExpression.expressionAST()) {
|
if (ExpressionAST *expressionAST = typeOfExpression.expressionAST()) {
|
||||||
if (CallAST *callAST = expressionAST->asCall()) {
|
if (CallAST *callAST = expressionAST->asCall()) {
|
||||||
@@ -160,9 +156,9 @@ bool VirtualFunctionHelper::canLookupVirtualFunctionOverrides(Function *function
|
|||||||
Class *VirtualFunctionHelper::staticClassOfFunctionCallExpression_internal() const
|
Class *VirtualFunctionHelper::staticClassOfFunctionCallExpression_internal() const
|
||||||
{
|
{
|
||||||
if (!m_finder)
|
if (!m_finder)
|
||||||
return 0;
|
return nullptr;
|
||||||
|
|
||||||
Class *result = 0;
|
Class *result = nullptr;
|
||||||
|
|
||||||
if (m_baseExpressionAST->asIdExpression()) {
|
if (m_baseExpressionAST->asIdExpression()) {
|
||||||
for (Scope *s = m_scope; s ; s = s->enclosingScope()) {
|
for (Scope *s = m_scope; s ; s = s->enclosingScope()) {
|
||||||
@@ -323,14 +319,14 @@ Link attemptFuncDeclDef(const QTextCursor &cursor, Snapshot snapshot,
|
|||||||
for (int i = path.size() - 1; i != -1; --i) {
|
for (int i = path.size() - 1; i != -1; --i) {
|
||||||
AST *node = path.at(i);
|
AST *node = path.at(i);
|
||||||
|
|
||||||
if (node->asParameterDeclaration() != 0)
|
if (node->asParameterDeclaration() != nullptr)
|
||||||
return result;
|
return result;
|
||||||
}
|
}
|
||||||
|
|
||||||
AST *declParent = 0;
|
AST *declParent = nullptr;
|
||||||
DeclaratorAST *decl = 0;
|
DeclaratorAST *decl = nullptr;
|
||||||
for (int i = path.size() - 2; i > 0; --i) {
|
for (int i = path.size() - 2; i > 0; --i) {
|
||||||
if ((decl = path.at(i)->asDeclarator()) != 0) {
|
if ((decl = path.at(i)->asDeclarator()) != nullptr) {
|
||||||
declParent = path.at(i - 1);
|
declParent = path.at(i - 1);
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
@@ -343,7 +339,7 @@ Link attemptFuncDeclDef(const QTextCursor &cursor, Snapshot snapshot,
|
|||||||
if (!funcDecl)
|
if (!funcDecl)
|
||||||
return result;
|
return result;
|
||||||
|
|
||||||
Symbol *target = 0;
|
Symbol *target = nullptr;
|
||||||
if (FunctionDefinitionAST *funDef = declParent->asFunctionDefinition()) {
|
if (FunctionDefinitionAST *funDef = declParent->asFunctionDefinition()) {
|
||||||
QList<Declaration *> candidates =
|
QList<Declaration *> candidates =
|
||||||
symbolFinder->findMatchingDeclaration(LookupContext(document, snapshot),
|
symbolFinder->findMatchingDeclaration(LookupContext(document, snapshot),
|
||||||
@@ -376,10 +372,10 @@ Link attemptFuncDeclDef(const QTextCursor &cursor, Snapshot snapshot,
|
|||||||
Symbol *findDefinition(Symbol *symbol, const Snapshot &snapshot, SymbolFinder *symbolFinder)
|
Symbol *findDefinition(Symbol *symbol, const Snapshot &snapshot, SymbolFinder *symbolFinder)
|
||||||
{
|
{
|
||||||
if (symbol->isFunction())
|
if (symbol->isFunction())
|
||||||
return 0; // symbol is a function definition.
|
return nullptr; // symbol is a function definition.
|
||||||
|
|
||||||
else if (!symbol->type()->isFunctionType())
|
else if (!symbol->type()->isFunctionType())
|
||||||
return 0; // not a function declaration
|
return nullptr; // not a function declaration
|
||||||
|
|
||||||
return symbolFinder->findMatchingDefinition(symbol, snapshot);
|
return symbolFinder->findMatchingDefinition(symbol, snapshot);
|
||||||
}
|
}
|
||||||
@@ -724,7 +720,7 @@ void FollowSymbolUnderCursor::findLink(
|
|||||||
}
|
}
|
||||||
|
|
||||||
if (Symbol *symbol = result.declaration()) {
|
if (Symbol *symbol = result.declaration()) {
|
||||||
Symbol *def = 0;
|
Symbol *def = nullptr;
|
||||||
|
|
||||||
if (resolveTarget) {
|
if (resolveTarget) {
|
||||||
// Consider to show a pop-up displaying overrides for the function
|
// Consider to show a pop-up displaying overrides for the function
|
||||||
@@ -759,7 +755,7 @@ void FollowSymbolUnderCursor::findLink(
|
|||||||
def = findDefinition(symbol, snapshot, symbolFinder);
|
def = findDefinition(symbol, snapshot, symbolFinder);
|
||||||
|
|
||||||
if (def == lastVisibleSymbol)
|
if (def == lastVisibleSymbol)
|
||||||
def = 0; // jump to declaration then.
|
def = nullptr; // jump to declaration then.
|
||||||
|
|
||||||
if (symbol->isForwardClassDeclaration()) {
|
if (symbol->isForwardClassDeclaration()) {
|
||||||
def = symbolFinder->findMatchingClassDeclaration(symbol, snapshot);
|
def = symbolFinder->findMatchingClassDeclaration(symbol, snapshot);
|
||||||
|
|||||||
@@ -41,9 +41,7 @@ CppFunctionsFilter::CppFunctionsFilter(CppLocatorData *locatorData)
|
|||||||
setIncludedByDefault(false);
|
setIncludedByDefault(false);
|
||||||
}
|
}
|
||||||
|
|
||||||
CppFunctionsFilter::~CppFunctionsFilter()
|
CppFunctionsFilter::~CppFunctionsFilter() = default;
|
||||||
{
|
|
||||||
}
|
|
||||||
|
|
||||||
Core::LocatorFilterEntry CppFunctionsFilter::filterEntryFromIndexItem(IndexItem::Ptr info)
|
Core::LocatorFilterEntry CppFunctionsFilter::filterEntryFromIndexItem(IndexItem::Ptr info)
|
||||||
{
|
{
|
||||||
|
|||||||
@@ -37,8 +37,8 @@ class CppFunctionsFilter : public CppLocatorFilter
|
|||||||
Q_OBJECT
|
Q_OBJECT
|
||||||
|
|
||||||
public:
|
public:
|
||||||
CppFunctionsFilter(CppLocatorData *locatorData);
|
explicit CppFunctionsFilter(CppLocatorData *locatorData);
|
||||||
~CppFunctionsFilter();
|
~CppFunctionsFilter() override;
|
||||||
|
|
||||||
protected:
|
protected:
|
||||||
IndexItem::ItemType matchTypes() const override { return IndexItem::Function; }
|
IndexItem::ItemType matchTypes() const override { return IndexItem::Function; }
|
||||||
|
|||||||
@@ -48,11 +48,11 @@ class CppIncludesIterator : public BaseFileFilter::Iterator
|
|||||||
public:
|
public:
|
||||||
CppIncludesIterator(CPlusPlus::Snapshot snapshot, const QSet<QString> &seedPaths);
|
CppIncludesIterator(CPlusPlus::Snapshot snapshot, const QSet<QString> &seedPaths);
|
||||||
|
|
||||||
void toFront();
|
void toFront() override;
|
||||||
bool hasNext() const;
|
bool hasNext() const override;
|
||||||
QString next();
|
QString next() override;
|
||||||
QString filePath() const;
|
QString filePath() const override;
|
||||||
QString fileName() const;
|
QString fileName() const override;
|
||||||
|
|
||||||
private:
|
private:
|
||||||
void fetchMore();
|
void fetchMore();
|
||||||
@@ -184,5 +184,5 @@ void CppIncludesFilter::refresh(QFutureInterface<void> &future)
|
|||||||
void CppIncludesFilter::markOutdated()
|
void CppIncludesFilter::markOutdated()
|
||||||
{
|
{
|
||||||
m_needsUpdate = true;
|
m_needsUpdate = true;
|
||||||
setFileIterator(0); // clean up
|
setFileIterator(nullptr); // clean up
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -27,16 +27,13 @@
|
|||||||
|
|
||||||
namespace CppTools {
|
namespace CppTools {
|
||||||
|
|
||||||
CppIndexingSupport::~CppIndexingSupport()
|
CppIndexingSupport::~CppIndexingSupport() = default;
|
||||||
{
|
|
||||||
}
|
|
||||||
|
|
||||||
SymbolSearcher::SymbolSearcher(QObject *parent)
|
SymbolSearcher::SymbolSearcher(QObject *parent)
|
||||||
: QObject(parent)
|
: QObject(parent)
|
||||||
{
|
{
|
||||||
}
|
}
|
||||||
|
|
||||||
SymbolSearcher::~SymbolSearcher()
|
SymbolSearcher::~SymbolSearcher() = default;
|
||||||
{}
|
|
||||||
|
|
||||||
} // namespace CppTools
|
} // namespace CppTools
|
||||||
|
|||||||
@@ -81,8 +81,8 @@ public:
|
|||||||
virtual QFuture<void> refreshSourceFiles(const QFutureInterface<void> &superFuture,
|
virtual QFuture<void> refreshSourceFiles(const QFutureInterface<void> &superFuture,
|
||||||
const QSet<QString> &sourceFiles,
|
const QSet<QString> &sourceFiles,
|
||||||
CppModelManager::ProgressNotificationMode mode) = 0;
|
CppModelManager::ProgressNotificationMode mode) = 0;
|
||||||
virtual SymbolSearcher *createSymbolSearcher(SymbolSearcher::Parameters parameters,
|
virtual SymbolSearcher *createSymbolSearcher(const SymbolSearcher::Parameters ¶meters,
|
||||||
QSet<QString> fileNames) = 0;
|
const QSet<QString> &fileNames) = 0;
|
||||||
};
|
};
|
||||||
|
|
||||||
} // namespace CppTools
|
} // namespace CppTools
|
||||||
|
|||||||
@@ -40,7 +40,7 @@ namespace CppTools {
|
|||||||
class CPPTOOLS_EXPORT KitInfo
|
class CPPTOOLS_EXPORT KitInfo
|
||||||
{
|
{
|
||||||
public:
|
public:
|
||||||
KitInfo(ProjectExplorer::Project *project);
|
explicit KitInfo(ProjectExplorer::Project *project);
|
||||||
|
|
||||||
bool isValid() const;
|
bool isValid() const;
|
||||||
|
|
||||||
|
|||||||
@@ -36,7 +36,7 @@ namespace {
|
|||||||
class FindLocalSymbols: protected ASTVisitor
|
class FindLocalSymbols: protected ASTVisitor
|
||||||
{
|
{
|
||||||
public:
|
public:
|
||||||
FindLocalSymbols(Document::Ptr doc)
|
explicit FindLocalSymbols(Document::Ptr doc)
|
||||||
: ASTVisitor(doc->translationUnit())
|
: ASTVisitor(doc->translationUnit())
|
||||||
{ }
|
{ }
|
||||||
|
|
||||||
@@ -65,7 +65,7 @@ protected:
|
|||||||
using ASTVisitor::visit;
|
using ASTVisitor::visit;
|
||||||
using ASTVisitor::endVisit;
|
using ASTVisitor::endVisit;
|
||||||
|
|
||||||
typedef TextEditor::HighlightingResult HighlightingResult;
|
using HighlightingResult = TextEditor::HighlightingResult;
|
||||||
|
|
||||||
void enterScope(Scope *scope)
|
void enterScope(Scope *scope)
|
||||||
{
|
{
|
||||||
|
|||||||
@@ -38,9 +38,8 @@ namespace {
|
|||||||
class FindFirstFunctionDefinition: protected CPlusPlus::ASTVisitor
|
class FindFirstFunctionDefinition: protected CPlusPlus::ASTVisitor
|
||||||
{
|
{
|
||||||
public:
|
public:
|
||||||
FindFirstFunctionDefinition(CPlusPlus::TranslationUnit *translationUnit)
|
explicit FindFirstFunctionDefinition(CPlusPlus::TranslationUnit *translationUnit)
|
||||||
: ASTVisitor(translationUnit)
|
: ASTVisitor(translationUnit)
|
||||||
, m_definition(0)
|
|
||||||
{}
|
{}
|
||||||
|
|
||||||
CPlusPlus::FunctionDefinitionAST *operator()()
|
CPlusPlus::FunctionDefinitionAST *operator()()
|
||||||
@@ -50,7 +49,7 @@ public:
|
|||||||
}
|
}
|
||||||
|
|
||||||
private:
|
private:
|
||||||
bool preVisit(CPlusPlus::AST *ast)
|
bool preVisit(CPlusPlus::AST *ast) override
|
||||||
{
|
{
|
||||||
if (CPlusPlus::FunctionDefinitionAST *f = ast->asFunctionDefinition()) {
|
if (CPlusPlus::FunctionDefinitionAST *f = ast->asFunctionDefinition()) {
|
||||||
m_definition = f;
|
m_definition = f;
|
||||||
@@ -60,20 +59,20 @@ private:
|
|||||||
}
|
}
|
||||||
|
|
||||||
private:
|
private:
|
||||||
CPlusPlus::FunctionDefinitionAST *m_definition;
|
CPlusPlus::FunctionDefinitionAST *m_definition = nullptr;
|
||||||
};
|
};
|
||||||
|
|
||||||
struct Result
|
struct Result
|
||||||
{
|
{
|
||||||
Result() : line(0), column(0), length(0) {}
|
Result() = default;
|
||||||
Result(const QByteArray &name, unsigned line, unsigned column, unsigned length)
|
Result(const QByteArray &name, unsigned line, unsigned column, unsigned length)
|
||||||
: name(name), line(line), column(column), length(length)
|
: name(name), line(line), column(column), length(length)
|
||||||
{}
|
{}
|
||||||
|
|
||||||
QByteArray name;
|
QByteArray name;
|
||||||
unsigned line;
|
unsigned line = 0;
|
||||||
unsigned column;
|
unsigned column = 0;
|
||||||
unsigned length;
|
unsigned length = 0;
|
||||||
|
|
||||||
bool operator==(const Result &other) const
|
bool operator==(const Result &other) const
|
||||||
{
|
{
|
||||||
@@ -139,7 +138,7 @@ void CppToolsPlugin::test_cpplocalsymbols_data()
|
|||||||
QTest::addColumn<QByteArray>("source");
|
QTest::addColumn<QByteArray>("source");
|
||||||
QTest::addColumn<QList<Result>>("expectedUses");
|
QTest::addColumn<QList<Result>>("expectedUses");
|
||||||
|
|
||||||
typedef QByteArray _;
|
using _ = QByteArray;
|
||||||
|
|
||||||
QTest::newRow("basic")
|
QTest::newRow("basic")
|
||||||
<< _("int f(int arg)\n"
|
<< _("int f(int arg)\n"
|
||||||
|
|||||||
@@ -46,9 +46,7 @@ CppLocatorFilter::CppLocatorFilter(CppLocatorData *locatorData)
|
|||||||
setIncludedByDefault(false);
|
setIncludedByDefault(false);
|
||||||
}
|
}
|
||||||
|
|
||||||
CppLocatorFilter::~CppLocatorFilter()
|
CppLocatorFilter::~CppLocatorFilter() = default;
|
||||||
{
|
|
||||||
}
|
|
||||||
|
|
||||||
Core::LocatorFilterEntry CppLocatorFilter::filterEntryFromIndexItem(IndexItem::Ptr info)
|
Core::LocatorFilterEntry CppLocatorFilter::filterEntryFromIndexItem(IndexItem::Ptr info)
|
||||||
{
|
{
|
||||||
|
|||||||
@@ -38,7 +38,7 @@ class CppLocatorFilter : public Core::ILocatorFilter
|
|||||||
Q_OBJECT
|
Q_OBJECT
|
||||||
|
|
||||||
public:
|
public:
|
||||||
CppLocatorFilter(CppLocatorData *locatorData);
|
explicit CppLocatorFilter(CppLocatorData *locatorData);
|
||||||
~CppLocatorFilter() override;
|
~CppLocatorFilter() override;
|
||||||
|
|
||||||
QList<Core::LocatorFilterEntry> matchesFor(QFutureInterface<Core::LocatorFilterEntry> &future,
|
QList<Core::LocatorFilterEntry> matchesFor(QFutureInterface<Core::LocatorFilterEntry> &future,
|
||||||
|
|||||||
@@ -82,8 +82,8 @@ public:
|
|||||||
}
|
}
|
||||||
|
|
||||||
private:
|
private:
|
||||||
void doBeforeLocatorRun() { QVERIFY(parseFiles(m_fileName)); }
|
void doBeforeLocatorRun() override { QVERIFY(parseFiles(m_fileName)); }
|
||||||
void doAfterLocatorRun() { QVERIFY(garbageCollectGlobalSnapshot()); }
|
void doAfterLocatorRun() override { QVERIFY(garbageCollectGlobalSnapshot()); }
|
||||||
|
|
||||||
private:
|
private:
|
||||||
const QString m_fileName;
|
const QString m_fileName;
|
||||||
@@ -97,7 +97,6 @@ public:
|
|||||||
CppCurrentDocumentFilterTestCase(const QString &fileName,
|
CppCurrentDocumentFilterTestCase(const QString &fileName,
|
||||||
const ResultDataList &expectedResults)
|
const ResultDataList &expectedResults)
|
||||||
: BasicLocatorFilterTest(CppTools::CppModelManager::instance()->currentDocumentFilter())
|
: BasicLocatorFilterTest(CppTools::CppModelManager::instance()->currentDocumentFilter())
|
||||||
, m_editor(0)
|
|
||||||
, m_fileName(fileName)
|
, m_fileName(fileName)
|
||||||
{
|
{
|
||||||
QVERIFY(succeededSoFar());
|
QVERIFY(succeededSoFar());
|
||||||
@@ -113,7 +112,7 @@ public:
|
|||||||
}
|
}
|
||||||
|
|
||||||
private:
|
private:
|
||||||
void doBeforeLocatorRun()
|
void doBeforeLocatorRun() override
|
||||||
{
|
{
|
||||||
QVERIFY(DocumentModel::openedDocuments().isEmpty());
|
QVERIFY(DocumentModel::openedDocuments().isEmpty());
|
||||||
QVERIFY(garbageCollectGlobalSnapshot());
|
QVERIFY(garbageCollectGlobalSnapshot());
|
||||||
@@ -124,7 +123,7 @@ private:
|
|||||||
QVERIFY(waitForFileInGlobalSnapshot(m_fileName));
|
QVERIFY(waitForFileInGlobalSnapshot(m_fileName));
|
||||||
}
|
}
|
||||||
|
|
||||||
void doAfterLocatorRun()
|
void doAfterLocatorRun() override
|
||||||
{
|
{
|
||||||
QVERIFY(closeEditorWithoutGarbageCollectorInvocation(m_editor));
|
QVERIFY(closeEditorWithoutGarbageCollectorInvocation(m_editor));
|
||||||
QCoreApplication::processEvents();
|
QCoreApplication::processEvents();
|
||||||
@@ -133,7 +132,7 @@ private:
|
|||||||
}
|
}
|
||||||
|
|
||||||
private:
|
private:
|
||||||
IEditor *m_editor;
|
IEditor *m_editor = nullptr;
|
||||||
const QString m_fileName;
|
const QString m_fileName;
|
||||||
};
|
};
|
||||||
|
|
||||||
|
|||||||
@@ -95,7 +95,7 @@ class DumpAST: protected ASTVisitor
|
|||||||
public:
|
public:
|
||||||
int depth;
|
int depth;
|
||||||
|
|
||||||
DumpAST(Control *control)
|
explicit DumpAST(Control *control)
|
||||||
: ASTVisitor(control), depth(0)
|
: ASTVisitor(control), depth(0)
|
||||||
{ }
|
{ }
|
||||||
|
|
||||||
@@ -511,7 +511,7 @@ CppModelManager::CppModelManager()
|
|||||||
: CppModelManagerBase(nullptr)
|
: CppModelManagerBase(nullptr)
|
||||||
, d(new CppModelManagerPrivate)
|
, d(new CppModelManagerPrivate)
|
||||||
{
|
{
|
||||||
d->m_indexingSupporter = 0;
|
d->m_indexingSupporter = nullptr;
|
||||||
d->m_enableGC = true;
|
d->m_enableGC = true;
|
||||||
|
|
||||||
qRegisterMetaType<QSet<QString> >();
|
qRegisterMetaType<QSet<QString> >();
|
||||||
@@ -696,7 +696,7 @@ void CppModelManager::removeExtraEditorSupport(AbstractEditorSupport *editorSupp
|
|||||||
CppEditorDocumentHandle *CppModelManager::cppEditorDocument(const QString &filePath) const
|
CppEditorDocumentHandle *CppModelManager::cppEditorDocument(const QString &filePath) const
|
||||||
{
|
{
|
||||||
if (filePath.isEmpty())
|
if (filePath.isEmpty())
|
||||||
return 0;
|
return nullptr;
|
||||||
|
|
||||||
QMutexLocker locker(&d->m_cppEditorDocumentsMutex);
|
QMutexLocker locker(&d->m_cppEditorDocumentsMutex);
|
||||||
return d->m_cppEditorDocuments.value(filePath, 0);
|
return d->m_cppEditorDocuments.value(filePath, 0);
|
||||||
@@ -987,7 +987,7 @@ void CppModelManager::watchForCanceledProjectIndexer(const QVector<QFuture<void>
|
|||||||
if (future.isCanceled() || future.isFinished())
|
if (future.isCanceled() || future.isFinished())
|
||||||
continue;
|
continue;
|
||||||
|
|
||||||
QFutureWatcher<void> *watcher = new QFutureWatcher<void>();
|
auto watcher = new QFutureWatcher<void>();
|
||||||
connect(watcher, &QFutureWatcher<void>::canceled, this, [this, project, watcher]() {
|
connect(watcher, &QFutureWatcher<void>::canceled, this, [this, project, watcher]() {
|
||||||
if (d->m_projectToIndexerCanceled.contains(project)) // Project not yet removed
|
if (d->m_projectToIndexerCanceled.contains(project)) // Project not yet removed
|
||||||
d->m_projectToIndexerCanceled.insert(project, true);
|
d->m_projectToIndexerCanceled.insert(project, true);
|
||||||
@@ -1411,7 +1411,7 @@ void CppModelManager::setIndexingSupport(CppIndexingSupport *indexingSupport)
|
|||||||
{
|
{
|
||||||
if (indexingSupport) {
|
if (indexingSupport) {
|
||||||
if (dynamic_cast<BuiltinIndexingSupport *>(indexingSupport))
|
if (dynamic_cast<BuiltinIndexingSupport *>(indexingSupport))
|
||||||
d->m_indexingSupporter = 0;
|
d->m_indexingSupporter = nullptr;
|
||||||
else
|
else
|
||||||
d->m_indexingSupporter = indexingSupport;
|
d->m_indexingSupporter = indexingSupport;
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -90,7 +90,7 @@ class CPPTOOLS_EXPORT CppModelManager final : public CPlusPlus::CppModelManagerB
|
|||||||
Q_OBJECT
|
Q_OBJECT
|
||||||
|
|
||||||
public:
|
public:
|
||||||
typedef CPlusPlus::Document Document;
|
using Document = CPlusPlus::Document;
|
||||||
|
|
||||||
public:
|
public:
|
||||||
CppModelManager();
|
CppModelManager();
|
||||||
@@ -136,7 +136,7 @@ public:
|
|||||||
Document::Ptr document(const QString &fileName) const;
|
Document::Ptr document(const QString &fileName) const;
|
||||||
bool replaceDocument(Document::Ptr newDoc);
|
bool replaceDocument(Document::Ptr newDoc);
|
||||||
|
|
||||||
void emitDocumentUpdated(CPlusPlus::Document::Ptr doc);
|
void emitDocumentUpdated(Document::Ptr doc);
|
||||||
void emitAbstractEditorSupportContentsUpdated(const QString &filePath,
|
void emitAbstractEditorSupportContentsUpdated(const QString &filePath,
|
||||||
const QByteArray &contents);
|
const QByteArray &contents);
|
||||||
void emitAbstractEditorSupportRemoved(const QString &filePath);
|
void emitAbstractEditorSupportRemoved(const QString &filePath);
|
||||||
@@ -165,7 +165,7 @@ public:
|
|||||||
void globalFollowSymbol(const CursorInEditor &data,
|
void globalFollowSymbol(const CursorInEditor &data,
|
||||||
Utils::ProcessLinkCallback &&processLinkCallback,
|
Utils::ProcessLinkCallback &&processLinkCallback,
|
||||||
const CPlusPlus::Snapshot &snapshot,
|
const CPlusPlus::Snapshot &snapshot,
|
||||||
const CPlusPlus::Document::Ptr &documentFromSemanticInfo,
|
const Document::Ptr &documentFromSemanticInfo,
|
||||||
SymbolFinder *symbolFinder,
|
SymbolFinder *symbolFinder,
|
||||||
bool inNextSplit) const final;
|
bool inNextSplit) const final;
|
||||||
|
|
||||||
|
|||||||
@@ -55,7 +55,7 @@ using namespace CppTools::Internal;
|
|||||||
using namespace CppTools::Tests;
|
using namespace CppTools::Tests;
|
||||||
using namespace ProjectExplorer;
|
using namespace ProjectExplorer;
|
||||||
|
|
||||||
typedef CPlusPlus::Document Document;
|
using CPlusPlus::Document;
|
||||||
|
|
||||||
Q_DECLARE_METATYPE(ProjectFile)
|
Q_DECLARE_METATYPE(ProjectFile)
|
||||||
|
|
||||||
@@ -66,7 +66,7 @@ inline QString _(const QByteArray &ba) { return QString::fromLatin1(ba, ba.size(
|
|||||||
class MyTestDataDir : public Core::Tests::TestDataDir
|
class MyTestDataDir : public Core::Tests::TestDataDir
|
||||||
{
|
{
|
||||||
public:
|
public:
|
||||||
MyTestDataDir(const QString &dir)
|
explicit MyTestDataDir(const QString &dir)
|
||||||
: TestDataDir(_(SRCDIR "/../../../tests/cppmodelmanager/") + dir)
|
: TestDataDir(_(SRCDIR "/../../../tests/cppmodelmanager/") + dir)
|
||||||
{}
|
{}
|
||||||
|
|
||||||
@@ -93,7 +93,7 @@ QStringList toAbsolutePaths(const QStringList &relativePathList,
|
|||||||
class ProjectCreator
|
class ProjectCreator
|
||||||
{
|
{
|
||||||
public:
|
public:
|
||||||
ProjectCreator(ModelManagerTestHelper *modelManagerTestHelper)
|
explicit ProjectCreator(ModelManagerTestHelper *modelManagerTestHelper)
|
||||||
: modelManagerTestHelper(modelManagerTestHelper)
|
: modelManagerTestHelper(modelManagerTestHelper)
|
||||||
{}
|
{}
|
||||||
|
|
||||||
@@ -125,7 +125,7 @@ public:
|
|||||||
class FileChangerAndRestorer
|
class FileChangerAndRestorer
|
||||||
{
|
{
|
||||||
public:
|
public:
|
||||||
FileChangerAndRestorer(const QString &filePath)
|
explicit FileChangerAndRestorer(const QString &filePath)
|
||||||
: m_filePath(filePath)
|
: m_filePath(filePath)
|
||||||
{
|
{
|
||||||
}
|
}
|
||||||
@@ -328,7 +328,7 @@ void CppToolsPlugin::test_modelmanager_refresh_several_times()
|
|||||||
|
|
||||||
CPlusPlus::Snapshot snapshot;
|
CPlusPlus::Snapshot snapshot;
|
||||||
QSet<QString> refreshedFiles;
|
QSet<QString> refreshedFiles;
|
||||||
CPlusPlus::Document::Ptr document;
|
Document::Ptr document;
|
||||||
|
|
||||||
ProjectExplorer::Macros macros = {{"FIRST_DEFINE"}};
|
ProjectExplorer::Macros macros = {{"FIRST_DEFINE"}};
|
||||||
for (int i = 0; i < 2; ++i) {
|
for (int i = 0; i < 2; ++i) {
|
||||||
@@ -714,7 +714,7 @@ void CppToolsPlugin::test_modelmanager_dont_gc_opened_files()
|
|||||||
namespace {
|
namespace {
|
||||||
struct EditorCloser {
|
struct EditorCloser {
|
||||||
Core::IEditor *editor;
|
Core::IEditor *editor;
|
||||||
EditorCloser(Core::IEditor *editor): editor(editor) {}
|
explicit EditorCloser(Core::IEditor *editor): editor(editor) {}
|
||||||
~EditorCloser()
|
~EditorCloser()
|
||||||
{
|
{
|
||||||
using namespace CppTools;
|
using namespace CppTools;
|
||||||
@@ -785,10 +785,10 @@ void CppToolsPlugin::test_modelmanager_defines_per_project()
|
|||||||
{_("one"), main1File},
|
{_("one"), main1File},
|
||||||
{_("two"), main2File}
|
{_("two"), main2File}
|
||||||
};
|
};
|
||||||
const int size = sizeof(d) / sizeof(d[0]);
|
|
||||||
for (int i = 0; i < size; ++i) {
|
for (auto &i : d) {
|
||||||
const QString firstDeclarationName = d[i].firstDeclarationName;
|
const QString firstDeclarationName = i.firstDeclarationName;
|
||||||
const QString fileName = d[i].fileName;
|
const QString fileName = i.fileName;
|
||||||
|
|
||||||
Core::IEditor *editor = Core::EditorManager::openEditor(fileName);
|
Core::IEditor *editor = Core::EditorManager::openEditor(fileName);
|
||||||
EditorCloser closer(editor);
|
EditorCloser closer(editor);
|
||||||
@@ -852,11 +852,10 @@ void CppToolsPlugin::test_modelmanager_precompiled_headers()
|
|||||||
{_("one"), _("ClassInPch1"), main1File},
|
{_("one"), _("ClassInPch1"), main1File},
|
||||||
{_("two"), _("ClassInPch2"), main2File}
|
{_("two"), _("ClassInPch2"), main2File}
|
||||||
};
|
};
|
||||||
const int size = sizeof(d) / sizeof(d[0]);
|
for (auto &i : d) {
|
||||||
for (int i = 0; i < size; ++i) {
|
const QString firstDeclarationName = i.firstDeclarationName;
|
||||||
const QString firstDeclarationName = d[i].firstDeclarationName;
|
const QByteArray firstClassInPchFile = i.firstClassInPchFile.toUtf8();
|
||||||
const QByteArray firstClassInPchFile = d[i].firstClassInPchFile.toUtf8();
|
const QString fileName = i.fileName;
|
||||||
const QString fileName = d[i].fileName;
|
|
||||||
|
|
||||||
Core::IEditor *editor = Core::EditorManager::openEditor(fileName);
|
Core::IEditor *editor = Core::EditorManager::openEditor(fileName);
|
||||||
EditorCloser closer(editor);
|
EditorCloser closer(editor);
|
||||||
@@ -929,10 +928,9 @@ void CppToolsPlugin::test_modelmanager_defines_per_editor()
|
|||||||
{_("#define SUB1\n"), _("one")},
|
{_("#define SUB1\n"), _("one")},
|
||||||
{_("#define SUB2\n"), _("two")}
|
{_("#define SUB2\n"), _("two")}
|
||||||
};
|
};
|
||||||
const int size = sizeof(d) / sizeof(d[0]);
|
for (auto &i : d) {
|
||||||
for (int i = 0; i < size; ++i) {
|
const QString editorDefines = i.editorDefines;
|
||||||
const QString editorDefines = d[i].editorDefines;
|
const QString firstDeclarationName = i.firstDeclarationName;
|
||||||
const QString firstDeclarationName = d[i].firstDeclarationName;
|
|
||||||
|
|
||||||
Core::IEditor *editor = Core::EditorManager::openEditor(main1File);
|
Core::IEditor *editor = Core::EditorManager::openEditor(main1File);
|
||||||
EditorCloser closer(editor);
|
EditorCloser closer(editor);
|
||||||
|
|||||||
@@ -35,6 +35,6 @@ public:
|
|||||||
virtual ProjectPart::Ptr projectPartForId(const QString &projectPartId) const = 0;
|
virtual ProjectPart::Ptr projectPartForId(const QString &projectPartId) const = 0;
|
||||||
|
|
||||||
protected:
|
protected:
|
||||||
~CppModelManagerInterface() = default;
|
virtual ~CppModelManagerInterface() = default;
|
||||||
};
|
};
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -27,6 +27,4 @@
|
|||||||
|
|
||||||
using namespace CppTools;
|
using namespace CppTools;
|
||||||
|
|
||||||
ModelManagerSupport::~ModelManagerSupport()
|
ModelManagerSupport::~ModelManagerSupport() = default;
|
||||||
{
|
|
||||||
}
|
|
||||||
|
|||||||
@@ -65,7 +65,7 @@ public:
|
|||||||
class CPPTOOLS_EXPORT ModelManagerSupportProvider
|
class CPPTOOLS_EXPORT ModelManagerSupportProvider
|
||||||
{
|
{
|
||||||
public:
|
public:
|
||||||
virtual ~ModelManagerSupportProvider() {}
|
virtual ~ModelManagerSupportProvider() = default;
|
||||||
|
|
||||||
virtual QString id() const = 0;
|
virtual QString id() const = 0;
|
||||||
virtual QString displayName() const = 0;
|
virtual QString displayName() const = 0;
|
||||||
|
|||||||
@@ -50,7 +50,7 @@ QVariant SymbolItem::data(int /*column*/, int role) const
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
OverviewModel *overviewModel = qobject_cast<OverviewModel *>(model());
|
auto overviewModel = qobject_cast<const OverviewModel*>(model());
|
||||||
if (!symbol || !overviewModel)
|
if (!symbol || !overviewModel)
|
||||||
return QVariant();
|
return QVariant();
|
||||||
|
|
||||||
@@ -150,7 +150,7 @@ Symbol *OverviewModel::symbolFromIndex(const QModelIndex &index) const
|
|||||||
{
|
{
|
||||||
if (!index.isValid())
|
if (!index.isValid())
|
||||||
return nullptr;
|
return nullptr;
|
||||||
SymbolItem *item = static_cast<SymbolItem *>(itemForIndex(index));
|
auto item = static_cast<const SymbolItem*>(itemForIndex(index));
|
||||||
return item ? item->symbol : nullptr;
|
return item ? item->symbol : nullptr;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -36,7 +36,7 @@ class SymbolItem : public Utils::TreeItem
|
|||||||
{
|
{
|
||||||
public:
|
public:
|
||||||
SymbolItem() = default;
|
SymbolItem() = default;
|
||||||
SymbolItem(CPlusPlus::Symbol *symbol) : symbol(symbol) {}
|
explicit SymbolItem(CPlusPlus::Symbol *symbol) : symbol(symbol) {}
|
||||||
|
|
||||||
QVariant data(int column, int role) const override;
|
QVariant data(int column, int role) const override;
|
||||||
|
|
||||||
|
|||||||
@@ -100,10 +100,10 @@ protected:
|
|||||||
private:
|
private:
|
||||||
class TokenRange {
|
class TokenRange {
|
||||||
public:
|
public:
|
||||||
TokenRange() : start(0), end(0) {}
|
TokenRange() = default;
|
||||||
TokenRange(unsigned start, unsigned end) : start(start), end(end) {}
|
TokenRange(unsigned start, unsigned end) : start(start), end(end) {}
|
||||||
unsigned start;
|
unsigned start = 0;
|
||||||
unsigned end;
|
unsigned end = 0;
|
||||||
};
|
};
|
||||||
|
|
||||||
void processIfWhileForStatement(ExpressionAST *expression, Symbol *symbol);
|
void processIfWhileForStatement(ExpressionAST *expression, Symbol *symbol);
|
||||||
|
|||||||
@@ -91,7 +91,7 @@ public:
|
|||||||
|
|
||||||
// Preprocess source
|
// Preprocess source
|
||||||
Environment env;
|
Environment env;
|
||||||
Preprocessor preprocess(0, &env);
|
Preprocessor preprocess(nullptr, &env);
|
||||||
const QByteArray preprocessedSource = preprocess.run(filePath, sourceWithoutCursorMarker);
|
const QByteArray preprocessedSource = preprocess.run(filePath, sourceWithoutCursorMarker);
|
||||||
|
|
||||||
Document::Ptr document = Document::create(filePath);
|
Document::Ptr document = Document::create(filePath);
|
||||||
@@ -122,7 +122,7 @@ public:
|
|||||||
Overview overview;
|
Overview overview;
|
||||||
overview.showReturnTypes = true;
|
overview.showReturnTypes = true;
|
||||||
overview.showArgumentNames = true;
|
overview.showArgumentNames = true;
|
||||||
overview.starBindFlags = Overview::StarBindFlags(0);
|
overview.starBindFlags = Overview::StarBindFlags(nullptr);
|
||||||
|
|
||||||
// Run the formatter
|
// Run the formatter
|
||||||
PointerDeclarationFormatter formatter(cppRefactoringFile, overview, cursorHandling);
|
PointerDeclarationFormatter formatter(cppRefactoringFile, overview, cursorHandling);
|
||||||
|
|||||||
@@ -31,7 +31,7 @@ namespace CppTools {
|
|||||||
|
|
||||||
ProjectFileCategorizer::ProjectFileCategorizer(const QString &projectPartName,
|
ProjectFileCategorizer::ProjectFileCategorizer(const QString &projectPartName,
|
||||||
const QStringList &filePaths,
|
const QStringList &filePaths,
|
||||||
FileClassifier fileClassifier)
|
const FileClassifier &fileClassifier)
|
||||||
: m_partName(projectPartName)
|
: m_partName(projectPartName)
|
||||||
{
|
{
|
||||||
const ProjectFiles ambiguousHeaders = classifyFiles(filePaths, fileClassifier);
|
const ProjectFiles ambiguousHeaders = classifyFiles(filePaths, fileClassifier);
|
||||||
@@ -53,7 +53,7 @@ QString ProjectFileCategorizer::partName(const QString &languageName) const
|
|||||||
}
|
}
|
||||||
|
|
||||||
ProjectFiles ProjectFileCategorizer::classifyFiles(const QStringList &filePaths,
|
ProjectFiles ProjectFileCategorizer::classifyFiles(const QStringList &filePaths,
|
||||||
FileClassifier fileClassifier)
|
const FileClassifier &fileClassifier)
|
||||||
{
|
{
|
||||||
ProjectFiles ambiguousHeaders;
|
ProjectFiles ambiguousHeaders;
|
||||||
|
|
||||||
|
|||||||
@@ -41,7 +41,7 @@ public:
|
|||||||
public:
|
public:
|
||||||
ProjectFileCategorizer(const QString &projectPartName,
|
ProjectFileCategorizer(const QString &projectPartName,
|
||||||
const QStringList &filePaths,
|
const QStringList &filePaths,
|
||||||
FileClassifier fileClassifier = FileClassifier());
|
const FileClassifier &fileClassifier = FileClassifier());
|
||||||
|
|
||||||
bool hasCSources() const { return !m_cSources.isEmpty(); }
|
bool hasCSources() const { return !m_cSources.isEmpty(); }
|
||||||
bool hasCxxSources() const { return !m_cxxSources.isEmpty(); }
|
bool hasCxxSources() const { return !m_cxxSources.isEmpty(); }
|
||||||
@@ -59,7 +59,7 @@ public:
|
|||||||
QString partName(const QString &languageName) const;
|
QString partName(const QString &languageName) const;
|
||||||
|
|
||||||
private:
|
private:
|
||||||
ProjectFiles classifyFiles(const QStringList &filePaths, FileClassifier fileClassifier);
|
ProjectFiles classifyFiles(const QStringList &filePaths, const FileClassifier &fileClassifier);
|
||||||
void expandSourcesWithAmbiguousHeaders(const ProjectFiles &ambiguousHeaders);
|
void expandSourcesWithAmbiguousHeaders(const ProjectFiles &ambiguousHeaders);
|
||||||
|
|
||||||
private:
|
private:
|
||||||
|
|||||||
@@ -77,7 +77,7 @@ public:
|
|||||||
}
|
}
|
||||||
|
|
||||||
private:
|
private:
|
||||||
QList<PrioritizedProjectPart> prioritize(const QList<ProjectPart::Ptr> &projectParts)
|
QList<PrioritizedProjectPart> prioritize(const QList<ProjectPart::Ptr> &projectParts) const
|
||||||
{
|
{
|
||||||
// Prioritize
|
// Prioritize
|
||||||
QList<PrioritizedProjectPart> prioritized = Utils::transform(projectParts,
|
QList<PrioritizedProjectPart> prioritized = Utils::transform(projectParts,
|
||||||
|
|||||||
@@ -37,15 +37,13 @@
|
|||||||
using namespace CppTools;
|
using namespace CppTools;
|
||||||
|
|
||||||
CppQtStyleIndenter::CppQtStyleIndenter()
|
CppQtStyleIndenter::CppQtStyleIndenter()
|
||||||
: m_cppCodeStylePreferences(0)
|
|
||||||
{
|
{
|
||||||
// Just for safety. setCodeStylePreferences should be called when the editor the
|
// Just for safety. setCodeStylePreferences should be called when the editor the
|
||||||
// indenter belongs to gets initialized.
|
// indenter belongs to gets initialized.
|
||||||
m_cppCodeStylePreferences = CppToolsSettings::instance()->cppCodeStyle();
|
m_cppCodeStylePreferences = CppToolsSettings::instance()->cppCodeStyle();
|
||||||
}
|
}
|
||||||
|
|
||||||
CppQtStyleIndenter::~CppQtStyleIndenter()
|
CppQtStyleIndenter::~CppQtStyleIndenter() = default;
|
||||||
{}
|
|
||||||
|
|
||||||
bool CppQtStyleIndenter::isElectricCharacter(const QChar &ch) const
|
bool CppQtStyleIndenter::isElectricCharacter(const QChar &ch) const
|
||||||
{
|
{
|
||||||
@@ -157,8 +155,7 @@ void CppQtStyleIndenter::indent(QTextDocument *doc,
|
|||||||
|
|
||||||
void CppQtStyleIndenter::setCodeStylePreferences(TextEditor::ICodeStylePreferences *preferences)
|
void CppQtStyleIndenter::setCodeStylePreferences(TextEditor::ICodeStylePreferences *preferences)
|
||||||
{
|
{
|
||||||
CppCodeStylePreferences *cppCodeStylePreferences
|
auto cppCodeStylePreferences = qobject_cast<CppCodeStylePreferences *>(preferences);
|
||||||
= qobject_cast<CppCodeStylePreferences *>(preferences);
|
|
||||||
if (cppCodeStylePreferences)
|
if (cppCodeStylePreferences)
|
||||||
m_cppCodeStylePreferences = cppCodeStylePreferences;
|
m_cppCodeStylePreferences = cppCodeStylePreferences;
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -63,7 +63,7 @@ public:
|
|||||||
const TextEditor::TabSettings &tabSettings) override;
|
const TextEditor::TabSettings &tabSettings) override;
|
||||||
private:
|
private:
|
||||||
CppCodeStyleSettings codeStyleSettings() const;
|
CppCodeStyleSettings codeStyleSettings() const;
|
||||||
CppCodeStylePreferences *m_cppCodeStylePreferences;
|
CppCodeStylePreferences *m_cppCodeStylePreferences = nullptr;
|
||||||
};
|
};
|
||||||
|
|
||||||
} // CppTools
|
} // CppTools
|
||||||
|
|||||||
@@ -48,7 +48,7 @@ void RawProjectPart::setDisplayName(const QString &displayName)
|
|||||||
this->displayName = displayName;
|
this->displayName = displayName;
|
||||||
}
|
}
|
||||||
|
|
||||||
void RawProjectPart::setFiles(const QStringList &files, FileClassifier fileClassifier)
|
void RawProjectPart::setFiles(const QStringList &files, const FileClassifier &fileClassifier)
|
||||||
{
|
{
|
||||||
this->files = files;
|
this->files = files;
|
||||||
this->fileClassifier = fileClassifier;
|
this->fileClassifier = fileClassifier;
|
||||||
|
|||||||
@@ -52,8 +52,6 @@ public:
|
|||||||
class CPPTOOLS_EXPORT RawProjectPart
|
class CPPTOOLS_EXPORT RawProjectPart
|
||||||
{
|
{
|
||||||
public:
|
public:
|
||||||
RawProjectPart() {}
|
|
||||||
|
|
||||||
void setDisplayName(const QString &displayName);
|
void setDisplayName(const QString &displayName);
|
||||||
|
|
||||||
void setProjectFileLocation(const QString &projectFile, int line = -1, int column = -1);
|
void setProjectFileLocation(const QString &projectFile, int line = -1, int column = -1);
|
||||||
@@ -62,7 +60,7 @@ public:
|
|||||||
|
|
||||||
// FileClassifier must be thread-safe.
|
// FileClassifier must be thread-safe.
|
||||||
using FileClassifier = std::function<ProjectFile(const QString &filePath)>;
|
using FileClassifier = std::function<ProjectFile(const QString &filePath)>;
|
||||||
void setFiles(const QStringList &files, FileClassifier fileClassifier = FileClassifier());
|
void setFiles(const QStringList &files, const FileClassifier &fileClassifier = FileClassifier());
|
||||||
void setHeaderPaths(const ProjectExplorer::HeaderPaths &headerPaths);
|
void setHeaderPaths(const ProjectExplorer::HeaderPaths &headerPaths);
|
||||||
void setIncludePaths(const QStringList &includePaths);
|
void setIncludePaths(const QStringList &includePaths);
|
||||||
void setPreCompiledHeaders(const QStringList &preCompiledHeaders);
|
void setPreCompiledHeaders(const QStringList &preCompiledHeaders);
|
||||||
|
|||||||
@@ -43,7 +43,7 @@ namespace CppTools {
|
|||||||
class CppRefactoringChangesData : public TextEditor::RefactoringChangesData
|
class CppRefactoringChangesData : public TextEditor::RefactoringChangesData
|
||||||
{
|
{
|
||||||
public:
|
public:
|
||||||
CppRefactoringChangesData(const Snapshot &snapshot)
|
explicit CppRefactoringChangesData(const Snapshot &snapshot)
|
||||||
: m_snapshot(snapshot)
|
: m_snapshot(snapshot)
|
||||||
, m_modelManager(CppModelManager::instance())
|
, m_modelManager(CppModelManager::instance())
|
||||||
, m_workingCopy(m_modelManager->workingCopy())
|
, m_workingCopy(m_modelManager->workingCopy())
|
||||||
@@ -107,7 +107,7 @@ CppRefactoringFilePtr CppRefactoringChanges::file(const QString &fileName) const
|
|||||||
|
|
||||||
CppRefactoringFileConstPtr CppRefactoringChanges::fileNoEditor(const QString &fileName) const
|
CppRefactoringFileConstPtr CppRefactoringChanges::fileNoEditor(const QString &fileName) const
|
||||||
{
|
{
|
||||||
QTextDocument *document = 0;
|
QTextDocument *document = nullptr;
|
||||||
if (data()->m_workingCopy.contains(fileName))
|
if (data()->m_workingCopy.contains(fileName))
|
||||||
document = new QTextDocument(QString::fromUtf8(data()->m_workingCopy.source(fileName)));
|
document = new QTextDocument(QString::fromUtf8(data()->m_workingCopy.source(fileName)));
|
||||||
CppRefactoringFilePtr result(new CppRefactoringFile(document, fileName));
|
CppRefactoringFilePtr result(new CppRefactoringFile(document, fileName));
|
||||||
|
|||||||
@@ -36,8 +36,8 @@ namespace CppTools {
|
|||||||
class CppRefactoringChanges;
|
class CppRefactoringChanges;
|
||||||
class CppRefactoringFile;
|
class CppRefactoringFile;
|
||||||
class CppRefactoringChangesData;
|
class CppRefactoringChangesData;
|
||||||
typedef QSharedPointer<CppRefactoringFile> CppRefactoringFilePtr;
|
using CppRefactoringFilePtr = QSharedPointer<CppRefactoringFile>;
|
||||||
typedef QSharedPointer<const CppRefactoringFile> CppRefactoringFileConstPtr;
|
using CppRefactoringFileConstPtr = QSharedPointer<const CppRefactoringFile>;
|
||||||
|
|
||||||
class CPPTOOLS_EXPORT CppRefactoringFile: public TextEditor::RefactoringFile
|
class CPPTOOLS_EXPORT CppRefactoringFile: public TextEditor::RefactoringFile
|
||||||
{
|
{
|
||||||
@@ -69,7 +69,7 @@ public:
|
|||||||
protected:
|
protected:
|
||||||
CppRefactoringFile(const QString &fileName, const QSharedPointer<TextEditor::RefactoringChangesData> &data);
|
CppRefactoringFile(const QString &fileName, const QSharedPointer<TextEditor::RefactoringChangesData> &data);
|
||||||
CppRefactoringFile(QTextDocument *document, const QString &fileName);
|
CppRefactoringFile(QTextDocument *document, const QString &fileName);
|
||||||
CppRefactoringFile(TextEditor::TextEditorWidget *editor);
|
explicit CppRefactoringFile(TextEditor::TextEditorWidget *editor);
|
||||||
|
|
||||||
CppRefactoringChangesData *data() const;
|
CppRefactoringChangesData *data() const;
|
||||||
void fileChanged() override;
|
void fileChanged() override;
|
||||||
@@ -82,7 +82,7 @@ protected:
|
|||||||
class CPPTOOLS_EXPORT CppRefactoringChanges: public TextEditor::RefactoringChanges
|
class CPPTOOLS_EXPORT CppRefactoringChanges: public TextEditor::RefactoringChanges
|
||||||
{
|
{
|
||||||
public:
|
public:
|
||||||
CppRefactoringChanges(const CPlusPlus::Snapshot &snapshot);
|
explicit CppRefactoringChanges(const CPlusPlus::Snapshot &snapshot);
|
||||||
|
|
||||||
static CppRefactoringFilePtr file(TextEditor::TextEditorWidget *editor,
|
static CppRefactoringFilePtr file(TextEditor::TextEditorWidget *editor,
|
||||||
const CPlusPlus::Document::Ptr &document);
|
const CPlusPlus::Document::Ptr &document);
|
||||||
|
|||||||
@@ -51,14 +51,8 @@ using namespace CppTools::Internal;
|
|||||||
|
|
||||||
CppSelectionChanger::CppSelectionChanger(QObject *parent)
|
CppSelectionChanger::CppSelectionChanger(QObject *parent)
|
||||||
: QObject(parent)
|
: QObject(parent)
|
||||||
, m_initialChangeSelectionCursor()
|
|
||||||
, m_workingCursor()
|
|
||||||
, m_doc(0)
|
|
||||||
, m_unit(0)
|
|
||||||
, m_direction(ExpandSelection)
|
|
||||||
, m_changeSelectionNodeIndex(kChangeSelectionNodeIndexNotSet)
|
, m_changeSelectionNodeIndex(kChangeSelectionNodeIndexNotSet)
|
||||||
, m_nodeCurrentStep(kChangeSelectionNodeIndexNotSet)
|
, m_nodeCurrentStep(kChangeSelectionNodeIndexNotSet)
|
||||||
, m_inChangeSelection(false)
|
|
||||||
{
|
{
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -337,7 +331,7 @@ ASTNodePositions CppSelectionChanger::findRelevantASTPositionsFromCursor(
|
|||||||
}
|
}
|
||||||
|
|
||||||
ASTNodePositions CppSelectionChanger::findRelevantASTPositionsFromCursorWhenNodeIndexNotSet(
|
ASTNodePositions CppSelectionChanger::findRelevantASTPositionsFromCursorWhenNodeIndexNotSet(
|
||||||
const QList<AST *> astPath,
|
const QList<AST *> &astPath,
|
||||||
const QTextCursor &cursor)
|
const QTextCursor &cursor)
|
||||||
{
|
{
|
||||||
// Find relevant AST node from cursor, when the user expands for the first time.
|
// Find relevant AST node from cursor, when the user expands for the first time.
|
||||||
@@ -345,19 +339,18 @@ ASTNodePositions CppSelectionChanger::findRelevantASTPositionsFromCursorWhenNode
|
|||||||
}
|
}
|
||||||
|
|
||||||
ASTNodePositions CppSelectionChanger::findRelevantASTPositionsFromCursorWhenWholeDocumentSelected(
|
ASTNodePositions CppSelectionChanger::findRelevantASTPositionsFromCursorWhenWholeDocumentSelected(
|
||||||
const QList<AST *> astPath,
|
const QList<AST *> &astPath,
|
||||||
const QTextCursor &cursor)
|
const QTextCursor &cursor)
|
||||||
{
|
{
|
||||||
// Can't expand more, because whole document is selected.
|
// Can't expand more, because whole document is selected.
|
||||||
if (m_direction == ExpandSelection)
|
if (m_direction == ExpandSelection)
|
||||||
return 0;
|
return {};
|
||||||
|
|
||||||
// In case of shrink, select the next smaller selection.
|
// In case of shrink, select the next smaller selection.
|
||||||
return findRelevantASTPositionsFromCursor(astPath, cursor);
|
return findRelevantASTPositionsFromCursor(astPath, cursor);
|
||||||
}
|
}
|
||||||
|
|
||||||
ASTNodePositions CppSelectionChanger::findRelevantASTPositionsFromCursorFromPreviousNodeIndex(
|
ASTNodePositions CppSelectionChanger::findRelevantASTPositionsFromCursorFromPreviousNodeIndex(const QList<AST *> &astPath,
|
||||||
const QList<AST *> astPath,
|
|
||||||
const QTextCursor &cursor)
|
const QTextCursor &cursor)
|
||||||
{
|
{
|
||||||
ASTNodePositions nodePositions;
|
ASTNodePositions nodePositions;
|
||||||
@@ -377,13 +370,13 @@ ASTNodePositions CppSelectionChanger::findRelevantASTPositionsFromCursorFromPrev
|
|||||||
if (newAstIndex < 0 || newAstIndex >= astPath.count()) {
|
if (newAstIndex < 0 || newAstIndex >= astPath.count()) {
|
||||||
if (debug)
|
if (debug)
|
||||||
qDebug() << "Skipping expansion because there is no available next AST node.";
|
qDebug() << "Skipping expansion because there is no available next AST node.";
|
||||||
return 0;
|
return {};
|
||||||
}
|
}
|
||||||
|
|
||||||
// Switch to next AST and set the first step.
|
// Switch to next AST and set the first step.
|
||||||
nodePositions = findRelevantASTPositionsFromCursor(astPath, cursor, newAstIndex);
|
nodePositions = findRelevantASTPositionsFromCursor(astPath, cursor, newAstIndex);
|
||||||
if (!nodePositions)
|
if (!nodePositions)
|
||||||
return 0;
|
return {};
|
||||||
|
|
||||||
if (debug)
|
if (debug)
|
||||||
qDebug() << "Moved to next AST node.";
|
qDebug() << "Moved to next AST node.";
|
||||||
@@ -419,7 +412,7 @@ ASTNodePositions CppSelectionChanger::findNextASTStepPositions(const QTextCursor
|
|||||||
#endif
|
#endif
|
||||||
|
|
||||||
if (astPath.size() == 0)
|
if (astPath.size() == 0)
|
||||||
return 0;
|
return {};
|
||||||
|
|
||||||
ASTNodePositions currentNodePositions;
|
ASTNodePositions currentNodePositions;
|
||||||
if (m_changeSelectionNodeIndex == kChangeSelectionNodeIndexNotSet) {
|
if (m_changeSelectionNodeIndex == kChangeSelectionNodeIndexNotSet) {
|
||||||
@@ -439,7 +432,7 @@ ASTNodePositions CppSelectionChanger::findNextASTStepPositions(const QTextCursor
|
|||||||
<< "current step:" << m_nodeCurrentStep;
|
<< "current step:" << m_nodeCurrentStep;
|
||||||
}
|
}
|
||||||
|
|
||||||
QTC_ASSERT(m_nodeCurrentStep >= 1, return 0);
|
QTC_ASSERT(m_nodeCurrentStep >= 1, return {});
|
||||||
|
|
||||||
return currentNodePositions;
|
return currentNodePositions;
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -38,8 +38,8 @@ namespace CppTools {
|
|||||||
|
|
||||||
class ASTNodePositions {
|
class ASTNodePositions {
|
||||||
public:
|
public:
|
||||||
ASTNodePositions() {}
|
ASTNodePositions() = default;
|
||||||
ASTNodePositions(CPlusPlus::AST *_ast) : ast(_ast) {}
|
explicit ASTNodePositions(CPlusPlus::AST *_ast) : ast(_ast) {}
|
||||||
operator bool() const { return ast; }
|
operator bool() const { return ast; }
|
||||||
|
|
||||||
CPlusPlus::AST *ast = nullptr;
|
CPlusPlus::AST *ast = nullptr;
|
||||||
@@ -97,13 +97,13 @@ private:
|
|||||||
const QTextCursor &cursor,
|
const QTextCursor &cursor,
|
||||||
int startingFromNodeIndex = -1);
|
int startingFromNodeIndex = -1);
|
||||||
ASTNodePositions findRelevantASTPositionsFromCursorWhenNodeIndexNotSet(
|
ASTNodePositions findRelevantASTPositionsFromCursorWhenNodeIndexNotSet(
|
||||||
const QList<CPlusPlus::AST *> astPath,
|
const QList<CPlusPlus::AST *> &astPath,
|
||||||
const QTextCursor &cursor);
|
const QTextCursor &cursor);
|
||||||
ASTNodePositions findRelevantASTPositionsFromCursorWhenWholeDocumentSelected(
|
ASTNodePositions findRelevantASTPositionsFromCursorWhenWholeDocumentSelected(
|
||||||
const QList<CPlusPlus::AST *> astPath,
|
const QList<CPlusPlus::AST *> &astPath,
|
||||||
const QTextCursor &cursor);
|
const QTextCursor &cursor);
|
||||||
ASTNodePositions findRelevantASTPositionsFromCursorFromPreviousNodeIndex(
|
ASTNodePositions findRelevantASTPositionsFromCursorFromPreviousNodeIndex(
|
||||||
const QList<CPlusPlus::AST *> astPath,
|
const QList<CPlusPlus::AST *> &astPath,
|
||||||
const QTextCursor &cursor);
|
const QTextCursor &cursor);
|
||||||
bool shouldSkipASTNodeBasedOnPosition(const ASTNodePositions &positions,
|
bool shouldSkipASTNodeBasedOnPosition(const ASTNodePositions &positions,
|
||||||
const QTextCursor &cursor) const;
|
const QTextCursor &cursor) const;
|
||||||
@@ -115,11 +115,11 @@ private:
|
|||||||
QTextCursor m_initialChangeSelectionCursor;
|
QTextCursor m_initialChangeSelectionCursor;
|
||||||
QTextCursor m_workingCursor;
|
QTextCursor m_workingCursor;
|
||||||
CPlusPlus::Document::Ptr m_doc;
|
CPlusPlus::Document::Ptr m_doc;
|
||||||
CPlusPlus::TranslationUnit *m_unit;
|
CPlusPlus::TranslationUnit *m_unit = nullptr;
|
||||||
Direction m_direction;
|
Direction m_direction = ExpandSelection;
|
||||||
int m_changeSelectionNodeIndex;
|
int m_changeSelectionNodeIndex = -1;
|
||||||
int m_nodeCurrentStep;
|
int m_nodeCurrentStep = -1;
|
||||||
bool m_inChangeSelection;
|
bool m_inChangeSelection = false;
|
||||||
};
|
};
|
||||||
|
|
||||||
} // namespace CppTools
|
} // namespace CppTools
|
||||||
|
|||||||
@@ -52,15 +52,15 @@ public:
|
|||||||
class FuturizedTopLevelDeclarationProcessor: public TopLevelDeclarationProcessor
|
class FuturizedTopLevelDeclarationProcessor: public TopLevelDeclarationProcessor
|
||||||
{
|
{
|
||||||
public:
|
public:
|
||||||
FuturizedTopLevelDeclarationProcessor(QFutureInterface<void> &future): m_future(future) {}
|
explicit FuturizedTopLevelDeclarationProcessor(QFutureInterface<void> &future): m_future(future) {}
|
||||||
bool processDeclaration(DeclarationAST *) { return !isCanceled(); }
|
bool processDeclaration(DeclarationAST *) override { return !isCanceled(); }
|
||||||
bool isCanceled() { return m_future.isCanceled(); }
|
bool isCanceled() { return m_future.isCanceled(); }
|
||||||
private:
|
private:
|
||||||
QFutureInterface<void> m_future;
|
QFutureInterface<void> m_future;
|
||||||
};
|
};
|
||||||
|
|
||||||
public:
|
public:
|
||||||
SemanticInfoUpdaterPrivate(SemanticInfoUpdater *q);
|
explicit SemanticInfoUpdaterPrivate(SemanticInfoUpdater *q);
|
||||||
~SemanticInfoUpdaterPrivate();
|
~SemanticInfoUpdaterPrivate();
|
||||||
|
|
||||||
SemanticInfo semanticInfo() const;
|
SemanticInfo semanticInfo() const;
|
||||||
@@ -72,7 +72,7 @@ public:
|
|||||||
|
|
||||||
bool reuseCurrentSemanticInfo(const SemanticInfo::Source &source, bool emitSignalWhenFinished);
|
bool reuseCurrentSemanticInfo(const SemanticInfo::Source &source, bool emitSignalWhenFinished);
|
||||||
|
|
||||||
void update_helper(QFutureInterface<void> &future, const SemanticInfo::Source source);
|
void update_helper(QFutureInterface<void> &future, const SemanticInfo::Source &source);
|
||||||
|
|
||||||
public:
|
public:
|
||||||
SemanticInfoUpdater *q;
|
SemanticInfoUpdater *q;
|
||||||
@@ -159,7 +159,7 @@ bool SemanticInfoUpdaterPrivate::reuseCurrentSemanticInfo(const SemanticInfo::So
|
|||||||
}
|
}
|
||||||
|
|
||||||
void SemanticInfoUpdaterPrivate::update_helper(QFutureInterface<void> &future,
|
void SemanticInfoUpdaterPrivate::update_helper(QFutureInterface<void> &future,
|
||||||
const SemanticInfo::Source source)
|
const SemanticInfo::Source &source)
|
||||||
{
|
{
|
||||||
FuturizedTopLevelDeclarationProcessor processor(future);
|
FuturizedTopLevelDeclarationProcessor processor(future);
|
||||||
update(source, true, &processor);
|
update(source, true, &processor);
|
||||||
@@ -187,10 +187,10 @@ SemanticInfo SemanticInfoUpdater::update(const SemanticInfo::Source &source)
|
|||||||
return semanticInfo();
|
return semanticInfo();
|
||||||
}
|
}
|
||||||
|
|
||||||
return d->update(source, emitSignalWhenFinished, 0);
|
return d->update(source, emitSignalWhenFinished, nullptr);
|
||||||
}
|
}
|
||||||
|
|
||||||
void SemanticInfoUpdater::updateDetached(const SemanticInfo::Source source)
|
void SemanticInfoUpdater::updateDetached(const SemanticInfo::Source &source)
|
||||||
{
|
{
|
||||||
qCDebug(log) << "updateDetached() - asynchronous";
|
qCDebug(log) << "updateDetached() - asynchronous";
|
||||||
d->m_future.cancel();
|
d->m_future.cancel();
|
||||||
|
|||||||
@@ -45,10 +45,10 @@ public:
|
|||||||
SemanticInfo semanticInfo() const;
|
SemanticInfo semanticInfo() const;
|
||||||
|
|
||||||
SemanticInfo update(const SemanticInfo::Source &source);
|
SemanticInfo update(const SemanticInfo::Source &source);
|
||||||
void updateDetached(const SemanticInfo::Source source);
|
void updateDetached(const SemanticInfo::Source &source);
|
||||||
|
|
||||||
signals:
|
signals:
|
||||||
void updated(CppTools::SemanticInfo semanticInfo);
|
void updated(const CppTools::SemanticInfo &semanticInfo);
|
||||||
|
|
||||||
private:
|
private:
|
||||||
QScopedPointer<SemanticInfoUpdaterPrivate> d;
|
QScopedPointer<SemanticInfoUpdaterPrivate> d;
|
||||||
|
|||||||
@@ -56,7 +56,7 @@ using namespace CPlusPlus;
|
|||||||
using namespace CppTools;
|
using namespace CppTools;
|
||||||
using namespace CppTools::Internal;
|
using namespace CppTools::Internal;
|
||||||
|
|
||||||
typedef Document::DiagnosticMessage Message;
|
using Message = Document::DiagnosticMessage;
|
||||||
|
|
||||||
static Q_LOGGING_CATEGORY(log, "qtc.cpptools.sourceprocessor", QtWarningMsg)
|
static Q_LOGGING_CATEGORY(log, "qtc.cpptools.sourceprocessor", QtWarningMsg)
|
||||||
|
|
||||||
@@ -119,8 +119,7 @@ CppSourceProcessor::CppSourceProcessor(const Snapshot &snapshot, DocumentCallbac
|
|||||||
m_preprocess.setKeepComments(true);
|
m_preprocess.setKeepComments(true);
|
||||||
}
|
}
|
||||||
|
|
||||||
CppSourceProcessor::~CppSourceProcessor()
|
CppSourceProcessor::~CppSourceProcessor() = default;
|
||||||
{ }
|
|
||||||
|
|
||||||
void CppSourceProcessor::setCancelChecker(const CppSourceProcessor::CancelChecker &cancelChecker)
|
void CppSourceProcessor::setCancelChecker(const CppSourceProcessor::CancelChecker &cancelChecker)
|
||||||
{
|
{
|
||||||
@@ -135,10 +134,8 @@ void CppSourceProcessor::setHeaderPaths(const ProjectExplorer::HeaderPaths &head
|
|||||||
using ProjectExplorer::HeaderPathType;
|
using ProjectExplorer::HeaderPathType;
|
||||||
m_headerPaths.clear();
|
m_headerPaths.clear();
|
||||||
|
|
||||||
for (int i = 0, ei = headerPaths.size(); i < ei; ++i) {
|
for (const auto &path : headerPaths) {
|
||||||
const ProjectExplorer::HeaderPath &path = headerPaths.at(i);
|
if (path.type == HeaderPathType::Framework )
|
||||||
|
|
||||||
if (path.type == HeaderPathType::Framework )
|
|
||||||
addFrameworkPath(path);
|
addFrameworkPath(path);
|
||||||
else
|
else
|
||||||
m_headerPaths.append({cleanPath(path.path), path.type});
|
m_headerPaths.append({cleanPath(path.path), path.type});
|
||||||
|
|||||||
@@ -51,13 +51,13 @@ class CppSourceProcessor: public CPlusPlus::Client
|
|||||||
Q_DISABLE_COPY(CppSourceProcessor)
|
Q_DISABLE_COPY(CppSourceProcessor)
|
||||||
|
|
||||||
public:
|
public:
|
||||||
typedef std::function<void (const CPlusPlus::Document::Ptr &)> DocumentCallback;
|
using DocumentCallback = std::function<void (const CPlusPlus::Document::Ptr &)>;
|
||||||
|
|
||||||
public:
|
public:
|
||||||
static QString cleanPath(const QString &path);
|
static QString cleanPath(const QString &path);
|
||||||
|
|
||||||
CppSourceProcessor(const CPlusPlus::Snapshot &snapshot, DocumentCallback documentFinished);
|
CppSourceProcessor(const CPlusPlus::Snapshot &snapshot, DocumentCallback documentFinished);
|
||||||
~CppSourceProcessor();
|
~CppSourceProcessor() override;
|
||||||
|
|
||||||
using CancelChecker = std::function<bool()>;
|
using CancelChecker = std::function<bool()>;
|
||||||
void setCancelChecker(const CancelChecker &cancelChecker);
|
void setCancelChecker(const CancelChecker &cancelChecker);
|
||||||
|
|||||||
@@ -49,7 +49,7 @@ using namespace CppTools::Tests;
|
|||||||
using namespace CppTools::Internal;
|
using namespace CppTools::Internal;
|
||||||
using ProjectExplorer::HeaderPathType;
|
using ProjectExplorer::HeaderPathType;
|
||||||
|
|
||||||
typedef Document::Include Include;
|
using Include = Document::Include;
|
||||||
|
|
||||||
class SourcePreprocessor
|
class SourcePreprocessor
|
||||||
{
|
{
|
||||||
@@ -60,7 +60,7 @@ public:
|
|||||||
cleanUp();
|
cleanUp();
|
||||||
}
|
}
|
||||||
|
|
||||||
Document::Ptr run(const QString &filePath)
|
Document::Ptr run(const QString &filePath) const
|
||||||
{
|
{
|
||||||
QScopedPointer<CppSourceProcessor> sourceProcessor(
|
QScopedPointer<CppSourceProcessor> sourceProcessor(
|
||||||
CppModelManager::createSourceProcessor());
|
CppModelManager::createSourceProcessor());
|
||||||
|
|||||||
@@ -79,7 +79,7 @@ CppToolsBridgeQtCreatorImplementation::baseEditorDocumentProcessor(const QString
|
|||||||
if (document)
|
if (document)
|
||||||
return document->processor();
|
return document->processor();
|
||||||
|
|
||||||
return 0;
|
return nullptr;
|
||||||
}
|
}
|
||||||
|
|
||||||
void CppToolsBridgeQtCreatorImplementation::finishedRefreshingSourceFiles(
|
void CppToolsBridgeQtCreatorImplementation::finishedRefreshingSourceFiles(
|
||||||
|
|||||||
@@ -40,7 +40,7 @@ class CppToolsJsExtension : public QObject
|
|||||||
Q_OBJECT
|
Q_OBJECT
|
||||||
|
|
||||||
public:
|
public:
|
||||||
CppToolsJsExtension(QObject *parent = 0) : QObject(parent) { }
|
explicit CppToolsJsExtension(QObject *parent = nullptr) : QObject(parent) { }
|
||||||
|
|
||||||
// Generate header guard:
|
// Generate header guard:
|
||||||
Q_INVOKABLE QString headerGuard(const QString &in) const;
|
Q_INVOKABLE QString headerGuard(const QString &in) const;
|
||||||
|
|||||||
@@ -213,7 +213,7 @@ QString identifierUnderCursor(QTextCursor *cursor)
|
|||||||
|
|
||||||
const Macro *findCanonicalMacro(const QTextCursor &cursor, Document::Ptr document)
|
const Macro *findCanonicalMacro(const QTextCursor &cursor, Document::Ptr document)
|
||||||
{
|
{
|
||||||
QTC_ASSERT(document, return 0);
|
QTC_ASSERT(document, return nullptr);
|
||||||
|
|
||||||
int line, column;
|
int line, column;
|
||||||
Utils::Text::convertPosition(cursor.document(), cursor.position(), &line, &column);
|
Utils::Text::convertPosition(cursor.document(), cursor.position(), &line, &column);
|
||||||
@@ -227,7 +227,7 @@ const Macro *findCanonicalMacro(const QTextCursor &cursor, Document::Ptr documen
|
|||||||
return &use->macro();
|
return &use->macro();
|
||||||
}
|
}
|
||||||
|
|
||||||
return 0;
|
return nullptr;
|
||||||
}
|
}
|
||||||
|
|
||||||
QSharedPointer<CppCodeModelSettings> codeModelSettings()
|
QSharedPointer<CppCodeModelSettings> codeModelSettings()
|
||||||
|
|||||||
@@ -55,18 +55,14 @@ namespace Internal {
|
|||||||
class CppToolsSettingsPrivate
|
class CppToolsSettingsPrivate
|
||||||
{
|
{
|
||||||
public:
|
public:
|
||||||
CppToolsSettingsPrivate()
|
|
||||||
: m_globalCodeStyle(0)
|
|
||||||
{}
|
|
||||||
|
|
||||||
CommentsSettings m_commentsSettings;
|
CommentsSettings m_commentsSettings;
|
||||||
CppCodeStylePreferences *m_globalCodeStyle;
|
CppCodeStylePreferences *m_globalCodeStyle = nullptr;
|
||||||
};
|
};
|
||||||
|
|
||||||
} // namespace Internal
|
} // namespace Internal
|
||||||
} // namespace CppTools
|
} // namespace CppTools
|
||||||
|
|
||||||
CppToolsSettings *CppToolsSettings::m_instance = 0;
|
CppToolsSettings *CppToolsSettings::m_instance = nullptr;
|
||||||
|
|
||||||
CppToolsSettings::CppToolsSettings(QObject *parent)
|
CppToolsSettings::CppToolsSettings(QObject *parent)
|
||||||
: QObject(parent)
|
: QObject(parent)
|
||||||
@@ -86,7 +82,7 @@ CppToolsSettings::CppToolsSettings(QObject *parent)
|
|||||||
TextEditorSettings::registerCodeStyleFactory(factory);
|
TextEditorSettings::registerCodeStyleFactory(factory);
|
||||||
|
|
||||||
// code style pool
|
// code style pool
|
||||||
CodeStylePool *pool = new CodeStylePool(factory, this);
|
auto pool = new CodeStylePool(factory, this);
|
||||||
TextEditorSettings::registerCodeStylePool(Constants::CPP_SETTINGS_ID, pool);
|
TextEditorSettings::registerCodeStylePool(Constants::CPP_SETTINGS_ID, pool);
|
||||||
|
|
||||||
// global code style settings
|
// global code style settings
|
||||||
@@ -124,7 +120,7 @@ CppToolsSettings::CppToolsSettings(QObject *parent)
|
|||||||
|
|
||||||
// built-in settings
|
// built-in settings
|
||||||
// Qt style
|
// Qt style
|
||||||
CppCodeStylePreferences *qtCodeStyle = new CppCodeStylePreferences();
|
auto qtCodeStyle = new CppCodeStylePreferences;
|
||||||
qtCodeStyle->setId("qt");
|
qtCodeStyle->setId("qt");
|
||||||
qtCodeStyle->setDisplayName(tr("Qt"));
|
qtCodeStyle->setDisplayName(tr("Qt"));
|
||||||
qtCodeStyle->setReadOnly(true);
|
qtCodeStyle->setReadOnly(true);
|
||||||
@@ -137,7 +133,7 @@ CppToolsSettings::CppToolsSettings(QObject *parent)
|
|||||||
pool->addCodeStyle(qtCodeStyle);
|
pool->addCodeStyle(qtCodeStyle);
|
||||||
|
|
||||||
// GNU style
|
// GNU style
|
||||||
CppCodeStylePreferences *gnuCodeStyle = new CppCodeStylePreferences();
|
auto gnuCodeStyle = new CppCodeStylePreferences;
|
||||||
gnuCodeStyle->setId("gnu");
|
gnuCodeStyle->setId("gnu");
|
||||||
gnuCodeStyle->setDisplayName(tr("GNU"));
|
gnuCodeStyle->setDisplayName(tr("GNU"));
|
||||||
gnuCodeStyle->setReadOnly(true);
|
gnuCodeStyle->setReadOnly(true);
|
||||||
@@ -227,7 +223,7 @@ CppToolsSettings::~CppToolsSettings()
|
|||||||
|
|
||||||
delete d;
|
delete d;
|
||||||
|
|
||||||
m_instance = 0;
|
m_instance = nullptr;
|
||||||
}
|
}
|
||||||
|
|
||||||
CppToolsSettings *CppToolsSettings::instance()
|
CppToolsSettings *CppToolsSettings::instance()
|
||||||
|
|||||||
@@ -120,8 +120,8 @@ bool TestCase::succeededSoFar() const
|
|||||||
|
|
||||||
bool TestCase::openBaseTextEditor(const QString &fileName, TextEditor::BaseTextEditor **editor)
|
bool TestCase::openBaseTextEditor(const QString &fileName, TextEditor::BaseTextEditor **editor)
|
||||||
{
|
{
|
||||||
typedef TextEditor::BaseTextEditor BTEditor;
|
using BTEditor = TextEditor::BaseTextEditor;
|
||||||
if (BTEditor *e = qobject_cast<BTEditor *>(Core::EditorManager::openEditor(fileName))) {
|
if (auto e = qobject_cast<BTEditor *>(Core::EditorManager::openEditor(fileName))) {
|
||||||
if (editor) {
|
if (editor) {
|
||||||
*editor = e;
|
*editor = e;
|
||||||
return true;
|
return true;
|
||||||
|
|||||||
@@ -74,7 +74,7 @@ class CPPTOOLS_EXPORT TestCase
|
|||||||
Q_DISABLE_COPY(TestCase)
|
Q_DISABLE_COPY(TestCase)
|
||||||
|
|
||||||
public:
|
public:
|
||||||
TestCase(bool runGarbageCollector = true);
|
explicit TestCase(bool runGarbageCollector = true);
|
||||||
~TestCase();
|
~TestCase();
|
||||||
|
|
||||||
bool succeededSoFar() const;
|
bool succeededSoFar() const;
|
||||||
@@ -145,7 +145,7 @@ protected:
|
|||||||
class CPPTOOLS_EXPORT TemporaryCopiedDir : public TemporaryDir
|
class CPPTOOLS_EXPORT TemporaryCopiedDir : public TemporaryDir
|
||||||
{
|
{
|
||||||
public:
|
public:
|
||||||
TemporaryCopiedDir(const QString &sourceDirPath);
|
explicit TemporaryCopiedDir(const QString &sourceDirPath);
|
||||||
QString absolutePath(const QByteArray &relativePath) const;
|
QString absolutePath(const QByteArray &relativePath) const;
|
||||||
|
|
||||||
private:
|
private:
|
||||||
|
|||||||
@@ -70,7 +70,7 @@ protected:
|
|||||||
bool eventFilter(QObject *o, QEvent *e) override
|
bool eventFilter(QObject *o, QEvent *e) override
|
||||||
{
|
{
|
||||||
if (e->type() == QEvent::ShortcutOverride && m_sequence.count() == 1) {
|
if (e->type() == QEvent::ShortcutOverride && m_sequence.count() == 1) {
|
||||||
QKeyEvent *ke = static_cast<QKeyEvent *>(e);
|
auto ke = static_cast<const QKeyEvent*>(e);
|
||||||
const QKeySequence seq(ke->key());
|
const QKeySequence seq(ke->key());
|
||||||
if (seq == m_sequence) {
|
if (seq == m_sequence) {
|
||||||
activateCurrentProposalItem();
|
activateCurrentProposalItem();
|
||||||
@@ -124,7 +124,7 @@ public:
|
|||||||
|
|
||||||
IAssistProposal *immediateProposal(const AssistInterface *) override
|
IAssistProposal *immediateProposal(const AssistInterface *) override
|
||||||
{
|
{
|
||||||
QTC_ASSERT(m_params.function, return 0);
|
QTC_ASSERT(m_params.function, return nullptr);
|
||||||
|
|
||||||
auto *hintItem = new VirtualFunctionProposalItem(Utils::Link());
|
auto *hintItem = new VirtualFunctionProposalItem(Utils::Link());
|
||||||
hintItem->setText(QCoreApplication::translate("VirtualFunctionsAssistProcessor",
|
hintItem->setText(QCoreApplication::translate("VirtualFunctionsAssistProcessor",
|
||||||
@@ -141,19 +141,19 @@ public:
|
|||||||
{
|
{
|
||||||
delete assistInterface;
|
delete assistInterface;
|
||||||
|
|
||||||
QTC_ASSERT(m_params.function, return 0);
|
QTC_ASSERT(m_params.function, return nullptr);
|
||||||
QTC_ASSERT(m_params.staticClass, return 0);
|
QTC_ASSERT(m_params.staticClass, return nullptr);
|
||||||
QTC_ASSERT(!m_params.snapshot.isEmpty(), return 0);
|
QTC_ASSERT(!m_params.snapshot.isEmpty(), return nullptr);
|
||||||
|
|
||||||
Class *functionsClass = m_finder.findMatchingClassDeclaration(m_params.function,
|
Class *functionsClass = m_finder.findMatchingClassDeclaration(m_params.function,
|
||||||
m_params.snapshot);
|
m_params.snapshot);
|
||||||
if (!functionsClass)
|
if (!functionsClass)
|
||||||
return 0;
|
return nullptr;
|
||||||
|
|
||||||
const QList<Function *> overrides = FunctionUtils::overrides(
|
const QList<Function *> overrides = FunctionUtils::overrides(
|
||||||
m_params.function, functionsClass, m_params.staticClass, m_params.snapshot);
|
m_params.function, functionsClass, m_params.staticClass, m_params.snapshot);
|
||||||
if (overrides.isEmpty())
|
if (overrides.isEmpty())
|
||||||
return 0;
|
return nullptr;
|
||||||
|
|
||||||
QList<AssistProposalItemInterface *> items;
|
QList<AssistProposalItemInterface *> items;
|
||||||
foreach (Function *func, overrides)
|
foreach (Function *func, overrides)
|
||||||
@@ -190,9 +190,7 @@ private:
|
|||||||
mutable SymbolFinder m_finder;
|
mutable SymbolFinder m_finder;
|
||||||
};
|
};
|
||||||
|
|
||||||
VirtualFunctionAssistProvider::VirtualFunctionAssistProvider()
|
VirtualFunctionAssistProvider::VirtualFunctionAssistProvider() = default;
|
||||||
{
|
|
||||||
}
|
|
||||||
|
|
||||||
bool VirtualFunctionAssistProvider::configure(const Parameters ¶meters)
|
bool VirtualFunctionAssistProvider::configure(const Parameters ¶meters)
|
||||||
{
|
{
|
||||||
|
|||||||
@@ -37,7 +37,7 @@ class CPPTOOLS_EXPORT VirtualFunctionProposalItem final : public TextEditor::Ass
|
|||||||
public:
|
public:
|
||||||
VirtualFunctionProposalItem(const Utils::Link &link,
|
VirtualFunctionProposalItem(const Utils::Link &link,
|
||||||
bool openInSplit = true);
|
bool openInSplit = true);
|
||||||
~VirtualFunctionProposalItem() noexcept override {}
|
~VirtualFunctionProposalItem() noexcept override = default;
|
||||||
void apply(TextEditor::TextDocumentManipulatorInterface &manipulator,
|
void apply(TextEditor::TextDocumentManipulatorInterface &manipulator,
|
||||||
int basePosition) const override;
|
int basePosition) const override;
|
||||||
Utils::Link link() const { return m_link; } // Exposed for tests
|
Utils::Link link() const { return m_link; } // Exposed for tests
|
||||||
|
|||||||
@@ -40,8 +40,6 @@
|
|||||||
|
|
||||||
namespace CppTools {
|
namespace CppTools {
|
||||||
|
|
||||||
WorkingCopy::WorkingCopy()
|
WorkingCopy::WorkingCopy() = default;
|
||||||
{
|
|
||||||
}
|
|
||||||
|
|
||||||
} // namespace CppTools
|
} // namespace CppTools
|
||||||
|
|||||||
@@ -77,7 +77,7 @@ public:
|
|||||||
{ return _elements.size(); }
|
{ return _elements.size(); }
|
||||||
|
|
||||||
private:
|
private:
|
||||||
typedef QHash<Utils::FileName, QPair<QByteArray, unsigned> > Table;
|
using Table = QHash<Utils::FileName, QPair<QByteArray, unsigned> >;
|
||||||
Table _elements;
|
Table _elements;
|
||||||
};
|
};
|
||||||
|
|
||||||
|
|||||||
@@ -136,8 +136,8 @@ QString DoxygenGenerator::generate(QTextCursor cursor,
|
|||||||
|
|
||||||
QString DoxygenGenerator::generate(QTextCursor cursor, DeclarationAST *decl)
|
QString DoxygenGenerator::generate(QTextCursor cursor, DeclarationAST *decl)
|
||||||
{
|
{
|
||||||
SpecifierAST *spec = 0;
|
SpecifierAST *spec = nullptr;
|
||||||
DeclaratorAST *decltr = 0;
|
DeclaratorAST *decltr = nullptr;
|
||||||
if (SimpleDeclarationAST *simpleDecl = decl->asSimpleDeclaration()) {
|
if (SimpleDeclarationAST *simpleDecl = decl->asSimpleDeclaration()) {
|
||||||
if (simpleDecl->declarator_list
|
if (simpleDecl->declarator_list
|
||||||
&& simpleDecl->declarator_list->value) {
|
&& simpleDecl->declarator_list->value) {
|
||||||
|
|||||||
@@ -34,9 +34,7 @@ namespace CppTools {
|
|||||||
C++ editor document.
|
C++ editor document.
|
||||||
*/
|
*/
|
||||||
|
|
||||||
CppEditorDocumentHandle::~CppEditorDocumentHandle()
|
CppEditorDocumentHandle::~CppEditorDocumentHandle() = default;
|
||||||
{
|
|
||||||
}
|
|
||||||
|
|
||||||
SendDocumentTracker &CppEditorDocumentHandle::sendTracker()
|
SendDocumentTracker &CppEditorDocumentHandle::sendTracker()
|
||||||
{
|
{
|
||||||
|
|||||||
@@ -41,7 +41,7 @@ class CPPTOOLS_EXPORT FollowSymbolInterface
|
|||||||
public:
|
public:
|
||||||
using Link = Utils::Link;
|
using Link = Utils::Link;
|
||||||
|
|
||||||
virtual ~FollowSymbolInterface() {}
|
virtual ~FollowSymbolInterface() = default;
|
||||||
virtual void findLink(const CursorInEditor &data,
|
virtual void findLink(const CursorInEditor &data,
|
||||||
Utils::ProcessLinkCallback &&processLinkCallback,
|
Utils::ProcessLinkCallback &&processLinkCallback,
|
||||||
bool resolveTarget,
|
bool resolveTarget,
|
||||||
|
|||||||
@@ -47,7 +47,7 @@ static bool isVirtualFunction_helper(const Function *function,
|
|||||||
enum { Unknown, False, True } res = Unknown;
|
enum { Unknown, False, True } res = Unknown;
|
||||||
|
|
||||||
if (firstVirtual)
|
if (firstVirtual)
|
||||||
*firstVirtual = 0;
|
*firstVirtual = nullptr;
|
||||||
|
|
||||||
if (!function)
|
if (!function)
|
||||||
return false;
|
return false;
|
||||||
@@ -170,7 +170,7 @@ enum Virtuality
|
|||||||
Virtual,
|
Virtual,
|
||||||
PureVirtual
|
PureVirtual
|
||||||
};
|
};
|
||||||
typedef QList<Virtuality> VirtualityList;
|
using VirtualityList = QList<Virtuality>;
|
||||||
} // Internal namespace
|
} // Internal namespace
|
||||||
} // CppTools namespace
|
} // CppTools namespace
|
||||||
|
|
||||||
@@ -191,7 +191,7 @@ void CppToolsPlugin::test_functionutils_virtualFunctions()
|
|||||||
QCOMPARE(document->diagnosticMessages().size(), 0);
|
QCOMPARE(document->diagnosticMessages().size(), 0);
|
||||||
QVERIFY(document->translationUnit()->ast());
|
QVERIFY(document->translationUnit()->ast());
|
||||||
QList<const Function *> allFunctions;
|
QList<const Function *> allFunctions;
|
||||||
const Function *firstVirtual = 0;
|
const Function *firstVirtual = nullptr;
|
||||||
|
|
||||||
// Iterate through Function symbols
|
// Iterate through Function symbols
|
||||||
Snapshot snapshot;
|
Snapshot snapshot;
|
||||||
@@ -236,7 +236,7 @@ void CppToolsPlugin::test_functionutils_virtualFunctions()
|
|||||||
|
|
||||||
void CppToolsPlugin::test_functionutils_virtualFunctions_data()
|
void CppToolsPlugin::test_functionutils_virtualFunctions_data()
|
||||||
{
|
{
|
||||||
typedef QByteArray _;
|
using _ = QByteArray;
|
||||||
QTest::addColumn<QByteArray>("source");
|
QTest::addColumn<QByteArray>("source");
|
||||||
QTest::addColumn<VirtualityList>("virtualityList");
|
QTest::addColumn<VirtualityList>("virtualityList");
|
||||||
QTest::addColumn<QList<int> >("firstVirtualList");
|
QTest::addColumn<QList<int> >("firstVirtualList");
|
||||||
|
|||||||
@@ -217,7 +217,7 @@ int LineForNewIncludeDirective::operator()(const QString &newIncludeFileName,
|
|||||||
if (m_includes.empty())
|
if (m_includes.empty())
|
||||||
return findInsertLineForVeryFirstInclude(newLinesToPrepend, newLinesToAppend);
|
return findInsertLineForVeryFirstInclude(newLinesToPrepend, newLinesToAppend);
|
||||||
|
|
||||||
typedef QList<IncludeGroup> IncludeGroups;
|
using IncludeGroups = QList<IncludeGroup>;
|
||||||
|
|
||||||
const IncludeGroups groupsNewline = IncludeGroup::detectIncludeGroupsByNewLines(m_includes);
|
const IncludeGroups groupsNewline = IncludeGroup::detectIncludeGroupsByNewLines(m_includes);
|
||||||
const bool includeAtTop
|
const bool includeAtTop
|
||||||
@@ -241,8 +241,8 @@ int LineForNewIncludeDirective::operator()(const QString &newIncludeFileName,
|
|||||||
= IncludeGroup::detectIncludeGroupsByIncludeType(bestMixedGroup.includes());
|
= IncludeGroup::detectIncludeGroupsByIncludeType(bestMixedGroup.includes());
|
||||||
groupsMatchingIncludeType = getGroupsByIncludeType(groupsIncludeType, newIncludeType);
|
groupsMatchingIncludeType = getGroupsByIncludeType(groupsIncludeType, newIncludeType);
|
||||||
// Avoid extra new lines for include groups which are not separated by new lines
|
// Avoid extra new lines for include groups which are not separated by new lines
|
||||||
newLinesToPrepend = 0;
|
newLinesToPrepend = nullptr;
|
||||||
newLinesToAppend = 0;
|
newLinesToAppend = nullptr;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -39,8 +39,8 @@ QT_FORWARD_DECLARE_CLASS(QTextDocument)
|
|||||||
namespace CppTools {
|
namespace CppTools {
|
||||||
namespace IncludeUtils {
|
namespace IncludeUtils {
|
||||||
|
|
||||||
typedef CPlusPlus::Document::Include Include;
|
using Include = CPlusPlus::Document::Include;
|
||||||
typedef CPlusPlus::Client::IncludeType IncludeType;
|
using IncludeType = CPlusPlus::Client::IncludeType;
|
||||||
|
|
||||||
class CPPTOOLS_EXPORT IncludeGroup
|
class CPPTOOLS_EXPORT IncludeGroup
|
||||||
{
|
{
|
||||||
@@ -54,7 +54,7 @@ public:
|
|||||||
CPlusPlus::Client::IncludeType includeType);
|
CPlusPlus::Client::IncludeType includeType);
|
||||||
|
|
||||||
public:
|
public:
|
||||||
IncludeGroup(const QList<Include> &includes) : m_includes(includes) {}
|
explicit IncludeGroup(const QList<Include> &includes) : m_includes(includes) {}
|
||||||
|
|
||||||
QList<Include> includes() const { return m_includes; }
|
QList<Include> includes() const { return m_includes; }
|
||||||
Include first() const { return m_includes.first(); }
|
Include first() const { return m_includes.first(); }
|
||||||
|
|||||||
@@ -39,7 +39,7 @@ class CPPTOOLS_EXPORT IndexItem
|
|||||||
{
|
{
|
||||||
Q_DISABLE_COPY(IndexItem)
|
Q_DISABLE_COPY(IndexItem)
|
||||||
|
|
||||||
IndexItem() {}
|
IndexItem() = default;
|
||||||
|
|
||||||
public:
|
public:
|
||||||
enum ItemType {
|
enum ItemType {
|
||||||
@@ -52,7 +52,7 @@ public:
|
|||||||
};
|
};
|
||||||
|
|
||||||
public:
|
public:
|
||||||
typedef QSharedPointer<IndexItem> Ptr;
|
using Ptr = QSharedPointer<IndexItem>;
|
||||||
static Ptr create(const QString &symbolName,
|
static Ptr create(const QString &symbolName,
|
||||||
const QString &symbolType,
|
const QString &symbolType,
|
||||||
const QString &symbolScope,
|
const QString &symbolScope,
|
||||||
@@ -94,7 +94,7 @@ public:
|
|||||||
Recurse, /// continues traversal with the children
|
Recurse, /// continues traversal with the children
|
||||||
};
|
};
|
||||||
|
|
||||||
typedef std::function<VisitorResult (const IndexItem::Ptr &)> Visitor;
|
using Visitor = std::function<VisitorResult (const IndexItem::Ptr &)>;
|
||||||
|
|
||||||
VisitorResult visitAllChildren(Visitor callback) const
|
VisitorResult visitAllChildren(Visitor callback) const
|
||||||
{
|
{
|
||||||
|
|||||||
@@ -58,17 +58,10 @@ static int ordering(InsertionPointLocator::AccessSpec xsSpec)
|
|||||||
|
|
||||||
struct AccessRange
|
struct AccessRange
|
||||||
{
|
{
|
||||||
unsigned start;
|
unsigned start = 0;
|
||||||
unsigned end;
|
unsigned end = 0;
|
||||||
InsertionPointLocator::AccessSpec xsSpec;
|
InsertionPointLocator::AccessSpec xsSpec = InsertionPointLocator::Invalid;
|
||||||
unsigned colonToken;
|
unsigned colonToken = 0;
|
||||||
|
|
||||||
AccessRange()
|
|
||||||
: start(0)
|
|
||||||
, end(0)
|
|
||||||
, xsSpec(InsertionPointLocator::Invalid)
|
|
||||||
, colonToken(0)
|
|
||||||
{}
|
|
||||||
|
|
||||||
AccessRange(unsigned start, unsigned end, InsertionPointLocator::AccessSpec xsSpec, unsigned colonToken)
|
AccessRange(unsigned start, unsigned end, InsertionPointLocator::AccessSpec xsSpec, unsigned colonToken)
|
||||||
: start(start)
|
: start(start)
|
||||||
@@ -107,7 +100,7 @@ public:
|
|||||||
protected:
|
protected:
|
||||||
using ASTVisitor::visit;
|
using ASTVisitor::visit;
|
||||||
|
|
||||||
bool visit(ClassSpecifierAST *ast)
|
bool visit(ClassSpecifierAST *ast) override
|
||||||
{
|
{
|
||||||
if (!ast->lbrace_token || !ast->rbrace_token)
|
if (!ast->lbrace_token || !ast->rbrace_token)
|
||||||
return true;
|
return true;
|
||||||
@@ -358,7 +351,7 @@ class FindMethodDefinitionInsertPoint : protected ASTVisitor
|
|||||||
HighestValue<int, unsigned> _bestToken;
|
HighestValue<int, unsigned> _bestToken;
|
||||||
|
|
||||||
public:
|
public:
|
||||||
FindMethodDefinitionInsertPoint(TranslationUnit *translationUnit)
|
explicit FindMethodDefinitionInsertPoint(TranslationUnit *translationUnit)
|
||||||
: ASTVisitor(translationUnit)
|
: ASTVisitor(translationUnit)
|
||||||
{}
|
{}
|
||||||
|
|
||||||
@@ -388,12 +381,12 @@ public:
|
|||||||
}
|
}
|
||||||
|
|
||||||
protected:
|
protected:
|
||||||
bool preVisit(AST *ast)
|
bool preVisit(AST *ast) override
|
||||||
{
|
{
|
||||||
return ast->asNamespace() || ast->asTranslationUnit() || ast->asLinkageBody();
|
return ast->asNamespace() || ast->asTranslationUnit() || ast->asLinkageBody();
|
||||||
}
|
}
|
||||||
|
|
||||||
bool visit(NamespaceAST *ast)
|
bool visit(NamespaceAST *ast) override
|
||||||
{
|
{
|
||||||
if (_currentDepth >= _namespaceNames.size())
|
if (_currentDepth >= _namespaceNames.size())
|
||||||
return false;
|
return false;
|
||||||
@@ -423,7 +416,7 @@ class FindFunctionDefinition : protected ASTVisitor
|
|||||||
unsigned _line = 0;
|
unsigned _line = 0;
|
||||||
unsigned _column = 0;
|
unsigned _column = 0;
|
||||||
public:
|
public:
|
||||||
FindFunctionDefinition(TranslationUnit *translationUnit)
|
explicit FindFunctionDefinition(TranslationUnit *translationUnit)
|
||||||
: ASTVisitor(translationUnit)
|
: ASTVisitor(translationUnit)
|
||||||
{
|
{
|
||||||
}
|
}
|
||||||
@@ -438,7 +431,7 @@ public:
|
|||||||
}
|
}
|
||||||
|
|
||||||
protected:
|
protected:
|
||||||
bool preVisit(AST *ast)
|
bool preVisit(AST *ast) override
|
||||||
{
|
{
|
||||||
if (_result)
|
if (_result)
|
||||||
return false;
|
return false;
|
||||||
@@ -452,7 +445,7 @@ protected:
|
|||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
bool visit(FunctionDefinitionAST *ast)
|
bool visit(FunctionDefinitionAST *ast) override
|
||||||
{
|
{
|
||||||
_result = ast;
|
_result = ast;
|
||||||
return false;
|
return false;
|
||||||
@@ -464,13 +457,13 @@ protected:
|
|||||||
static Declaration *isNonVirtualFunctionDeclaration(Symbol *s)
|
static Declaration *isNonVirtualFunctionDeclaration(Symbol *s)
|
||||||
{
|
{
|
||||||
if (!s)
|
if (!s)
|
||||||
return 0;
|
return nullptr;
|
||||||
Declaration *declaration = s->asDeclaration();
|
Declaration *declaration = s->asDeclaration();
|
||||||
if (!declaration)
|
if (!declaration)
|
||||||
return 0;
|
return nullptr;
|
||||||
Function *type = s->type()->asFunctionType();
|
Function *type = s->type()->asFunctionType();
|
||||||
if (!type || type->isPureVirtual())
|
if (!type || type->isPureVirtual())
|
||||||
return 0;
|
return nullptr;
|
||||||
return declaration;
|
return declaration;
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -497,9 +490,9 @@ static InsertionLocation nextToSurroundingDefinitions(Symbol *declaration,
|
|||||||
|
|
||||||
// scan preceding declarations for a function declaration (and see if it is defined)
|
// scan preceding declarations for a function declaration (and see if it is defined)
|
||||||
SymbolFinder symbolFinder;
|
SymbolFinder symbolFinder;
|
||||||
Function *definitionFunction = 0;
|
Function *definitionFunction = nullptr;
|
||||||
QString prefix, suffix;
|
QString prefix, suffix;
|
||||||
Declaration *surroundingFunctionDecl = 0;
|
Declaration *surroundingFunctionDecl = nullptr;
|
||||||
for (int i = declIndex - 1; i >= 0; --i) {
|
for (int i = declIndex - 1; i >= 0; --i) {
|
||||||
Symbol *s = klass->memberAt(i);
|
Symbol *s = klass->memberAt(i);
|
||||||
if (s->isGenerated() || !(surroundingFunctionDecl = isNonVirtualFunctionDeclaration(s)))
|
if (s->isGenerated() || !(surroundingFunctionDecl = isNonVirtualFunctionDeclaration(s)))
|
||||||
@@ -512,7 +505,7 @@ static InsertionLocation nextToSurroundingDefinitions(Symbol *declaration,
|
|||||||
prefix = QLatin1String("\n\n");
|
prefix = QLatin1String("\n\n");
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
definitionFunction = 0;
|
definitionFunction = nullptr;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
if (!definitionFunction) {
|
if (!definitionFunction) {
|
||||||
@@ -530,7 +523,7 @@ static InsertionLocation nextToSurroundingDefinitions(Symbol *declaration,
|
|||||||
suffix = QLatin1String("\n\n");
|
suffix = QLatin1String("\n\n");
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
definitionFunction = 0;
|
definitionFunction = nullptr;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -87,7 +87,7 @@ public:
|
|||||||
static QString accessSpecToString(InsertionPointLocator::AccessSpec xsSpec);
|
static QString accessSpecToString(InsertionPointLocator::AccessSpec xsSpec);
|
||||||
|
|
||||||
public:
|
public:
|
||||||
InsertionPointLocator(const CppRefactoringChanges &refactoringChanges);
|
explicit InsertionPointLocator(const CppRefactoringChanges &refactoringChanges);
|
||||||
|
|
||||||
InsertionLocation methodDeclarationInClass(const QString &fileName,
|
InsertionLocation methodDeclarationInClass(const QString &fileName,
|
||||||
const CPlusPlus::Class *clazz,
|
const CPlusPlus::Class *clazz,
|
||||||
|
|||||||
Some files were not shown because too many files have changed in this diff Show More
Reference in New Issue
Block a user