forked from qt-creator/qt-creator
CppEditor: Allow tests to run with ClangCodeModel enabled
So that in the CI we can simply run: $ qtcreator -test CppEditor -load ClangCodeModel There are some failures left, which we will tackle one by one in follow- up patches. Change-Id: Ic4ebcb82f6439b344ae055889a6a16d56b2e3206 Reviewed-by: Christian Stenger <christian.stenger@qt.io>
This commit is contained in:
@@ -17,8 +17,8 @@ namespace Internal {
|
||||
|
||||
ClangdQuickFixFactory::ClangdQuickFixFactory() = default;
|
||||
|
||||
void ClangdQuickFixFactory::match(const CppEditor::Internal::CppQuickFixInterface &interface,
|
||||
QuickFixOperations &result)
|
||||
void ClangdQuickFixFactory::doMatch(const CppEditor::Internal::CppQuickFixInterface &interface,
|
||||
QuickFixOperations &result)
|
||||
{
|
||||
const auto client = ClangModelManagerSupport::clientForFile(interface.filePath());
|
||||
if (!client)
|
||||
|
@@ -15,8 +15,8 @@ class ClangdQuickFixFactory : public CppEditor::CppQuickFixFactory
|
||||
public:
|
||||
ClangdQuickFixFactory();
|
||||
|
||||
void match(const CppEditor::Internal::CppQuickFixInterface &interface,
|
||||
QuickFixOperations &result) override;
|
||||
void doMatch(const CppEditor::Internal::CppQuickFixInterface &interface,
|
||||
QuickFixOperations &result) override;
|
||||
};
|
||||
|
||||
class ClangdQuickFixProvider : public LanguageClient::LanguageClientQuickFixProvider
|
||||
|
@@ -65,8 +65,8 @@ DocumentQuickFixFactory::DocumentQuickFixFactory(DocumentQuickFixFactory::Runner
|
||||
: m_runnerCollector(runnerCollector)
|
||||
{}
|
||||
|
||||
void DocumentQuickFixFactory::match(const CppEditor::Internal::CppQuickFixInterface &interface,
|
||||
QuickFixOperations &result)
|
||||
void DocumentQuickFixFactory::doMatch(const CppEditor::Internal::CppQuickFixInterface &interface,
|
||||
QuickFixOperations &result)
|
||||
{
|
||||
QTC_ASSERT(m_runnerCollector, return );
|
||||
if (DocumentClangToolRunner *runner = m_runnerCollector(interface.filePath())) {
|
||||
|
@@ -16,8 +16,8 @@ public:
|
||||
using RunnerCollector = std::function<DocumentClangToolRunner *(const Utils::FilePath &)>;
|
||||
|
||||
DocumentQuickFixFactory(RunnerCollector runnerCollector);
|
||||
void match(const CppEditor::Internal::CppQuickFixInterface &interface,
|
||||
QuickFixOperations &result) override;
|
||||
void doMatch(const CppEditor::Internal::CppQuickFixInterface &interface,
|
||||
QuickFixOperations &result) override;
|
||||
|
||||
private:
|
||||
RunnerCollector m_runnerCollector;
|
||||
|
@@ -1236,8 +1236,8 @@ InsertVirtualMethods::~InsertVirtualMethods()
|
||||
m_dialog->deleteLater();
|
||||
}
|
||||
|
||||
void InsertVirtualMethods::match(const CppQuickFixInterface &interface,
|
||||
QuickFixOperations &result)
|
||||
void InsertVirtualMethods::doMatch(const CppQuickFixInterface &interface,
|
||||
QuickFixOperations &result)
|
||||
{
|
||||
QSharedPointer<InsertVirtualMethodsOp> op(new InsertVirtualMethodsOp(interface, m_dialog));
|
||||
if (op->isValid())
|
||||
|
@@ -16,7 +16,8 @@ class InsertVirtualMethods : public CppQuickFixFactory
|
||||
public:
|
||||
InsertVirtualMethods(InsertVirtualMethodsDialog *dialog = nullptr);
|
||||
~InsertVirtualMethods() override;
|
||||
void match(const CppQuickFixInterface &interface, TextEditor::QuickFixOperations &result) override;
|
||||
void doMatch(const CppQuickFixInterface &interface,
|
||||
TextEditor::QuickFixOperations &result) override;
|
||||
#ifdef WITH_TESTS
|
||||
static InsertVirtualMethods *createTestFactory();
|
||||
#endif
|
||||
|
@@ -48,14 +48,22 @@ public:
|
||||
|
||||
using QuickFixOperations = TextEditor::QuickFixOperations;
|
||||
|
||||
/*!
|
||||
Implement this function to match and create the appropriate
|
||||
CppQuickFixOperation objects.
|
||||
*/
|
||||
virtual void match(const Internal::CppQuickFixInterface &interface,
|
||||
QuickFixOperations &result) = 0;
|
||||
void match(const Internal::CppQuickFixInterface &interface, QuickFixOperations &result);
|
||||
|
||||
static const QList<CppQuickFixFactory *> &cppQuickFixFactories();
|
||||
|
||||
bool hasClangdReplacement() const { return m_hasClangdReplacement; }
|
||||
void setHasClangdReplacement() { m_hasClangdReplacement = true; }
|
||||
|
||||
private:
|
||||
/*!
|
||||
Implement this function to doMatch and create the appropriate
|
||||
CppQuickFixOperation objects.
|
||||
*/
|
||||
virtual void doMatch(const Internal::CppQuickFixInterface &interface,
|
||||
QuickFixOperations &result) = 0;
|
||||
|
||||
bool m_hasClangdReplacement = false;
|
||||
};
|
||||
|
||||
} // namespace CppEditor
|
||||
|
@@ -192,6 +192,9 @@ QuickFixOperationTest::QuickFixOperationTest(const QList<TestDocumentPtr> &testD
|
||||
const QByteArray &clangFormatSettings)
|
||||
: BaseQuickFixTestCase(testDocuments, headerPaths, clangFormatSettings)
|
||||
{
|
||||
if (factory->hasClangdReplacement() && CppModelManager::isClangCodeModelActive())
|
||||
return;
|
||||
|
||||
QVERIFY(succeededSoFar());
|
||||
|
||||
// Perform operation if there is one
|
||||
@@ -268,7 +271,7 @@ public:
|
||||
AddIncludeForUndefinedIdentifierTestFactory(const QString &include)
|
||||
: m_include(include) {}
|
||||
|
||||
void match(const CppQuickFixInterface &cppQuickFixInterface, QuickFixOperations &result) override
|
||||
void doMatch(const CppQuickFixInterface &cppQuickFixInterface, QuickFixOperations &result) override
|
||||
{
|
||||
result << new AddIncludeForUndefinedIdentifierOp(cppQuickFixInterface, 0, m_include);
|
||||
}
|
||||
@@ -283,7 +286,7 @@ public:
|
||||
AddForwardDeclForUndefinedIdentifierTestFactory(const QString &className, int symbolPos)
|
||||
: m_className(className), m_symbolPos(symbolPos) {}
|
||||
|
||||
void match(const CppQuickFixInterface &cppQuickFixInterface, QuickFixOperations &result) override
|
||||
void doMatch(const CppQuickFixInterface &cppQuickFixInterface, QuickFixOperations &result) override
|
||||
{
|
||||
result << new AddForwardDeclForUndefinedIdentifierOp(cppQuickFixInterface, 0,
|
||||
m_className, m_symbolPos);
|
||||
|
@@ -101,6 +101,17 @@ CppQuickFixFactory::~CppQuickFixFactory()
|
||||
g_cppQuickFixFactories.removeOne(this);
|
||||
}
|
||||
|
||||
void CppQuickFixFactory::match(const Internal::CppQuickFixInterface &interface,
|
||||
QuickFixOperations &result)
|
||||
{
|
||||
if (m_hasClangdReplacement
|
||||
&& CppModelManager::usesClangd(interface.currentFile()->editor()->textDocument())) {
|
||||
return;
|
||||
}
|
||||
|
||||
doMatch(interface, result);
|
||||
}
|
||||
|
||||
const QList<CppQuickFixFactory *> &CppQuickFixFactory::cppQuickFixFactories()
|
||||
{
|
||||
return g_cppQuickFixFactories;
|
||||
@@ -431,8 +442,8 @@ private:
|
||||
|
||||
} // anonymous namespace
|
||||
|
||||
void InverseLogicalComparison::match(const CppQuickFixInterface &interface,
|
||||
QuickFixOperations &result)
|
||||
void InverseLogicalComparison::doMatch(const CppQuickFixInterface &interface,
|
||||
QuickFixOperations &result)
|
||||
{
|
||||
CppRefactoringFilePtr file = interface.currentFile();
|
||||
|
||||
@@ -517,7 +528,7 @@ private:
|
||||
|
||||
} // anonymous namespace
|
||||
|
||||
void FlipLogicalOperands::match(const CppQuickFixInterface &interface, QuickFixOperations &result)
|
||||
void FlipLogicalOperands::doMatch(const CppQuickFixInterface &interface, QuickFixOperations &result)
|
||||
{
|
||||
const QList<AST *> &path = interface.path();
|
||||
if (path.isEmpty())
|
||||
@@ -605,7 +616,7 @@ public:
|
||||
|
||||
} // anonymous namespace
|
||||
|
||||
void RewriteLogicalAnd::match(const CppQuickFixInterface &interface, QuickFixOperations &result)
|
||||
void RewriteLogicalAnd::doMatch(const CppQuickFixInterface &interface, QuickFixOperations &result)
|
||||
{
|
||||
BinaryExpressionAST *expression = nullptr;
|
||||
const QList<AST *> &path = interface.path();
|
||||
@@ -707,8 +718,8 @@ private:
|
||||
|
||||
} // anonymous namespace
|
||||
|
||||
void SplitSimpleDeclaration::match(const CppQuickFixInterface &interface,
|
||||
QuickFixOperations &result)
|
||||
void SplitSimpleDeclaration::doMatch(const CppQuickFixInterface &interface,
|
||||
QuickFixOperations &result)
|
||||
{
|
||||
CoreDeclaratorAST *core_declarator = nullptr;
|
||||
const QList<AST *> &path = interface.path();
|
||||
@@ -781,7 +792,7 @@ private:
|
||||
|
||||
} // anonymous namespace
|
||||
|
||||
void AddBracesToIf::match(const CppQuickFixInterface &interface, QuickFixOperations &result)
|
||||
void AddBracesToIf::doMatch(const CppQuickFixInterface &interface, QuickFixOperations &result)
|
||||
{
|
||||
const QList<AST *> &path = interface.path();
|
||||
if (path.isEmpty())
|
||||
@@ -857,8 +868,8 @@ public:
|
||||
|
||||
} // anonymous namespace
|
||||
|
||||
void MoveDeclarationOutOfIf::match(const CppQuickFixInterface &interface,
|
||||
QuickFixOperations &result)
|
||||
void MoveDeclarationOutOfIf::doMatch(const CppQuickFixInterface &interface,
|
||||
QuickFixOperations &result)
|
||||
{
|
||||
const QList<AST *> &path = interface.path();
|
||||
using Ptr = QSharedPointer<MoveDeclarationOutOfIfOp>;
|
||||
@@ -932,8 +943,8 @@ public:
|
||||
|
||||
} // anonymous namespace
|
||||
|
||||
void MoveDeclarationOutOfWhile::match(const CppQuickFixInterface &interface,
|
||||
QuickFixOperations &result)
|
||||
void MoveDeclarationOutOfWhile::doMatch(const CppQuickFixInterface &interface,
|
||||
QuickFixOperations &result)
|
||||
{
|
||||
const QList<AST *> &path = interface.path();
|
||||
QSharedPointer<MoveDeclarationOutOfWhileOp> op(new MoveDeclarationOutOfWhileOp(interface));
|
||||
@@ -1045,7 +1056,7 @@ private:
|
||||
|
||||
} // anonymous namespace
|
||||
|
||||
void SplitIfStatement::match(const CppQuickFixInterface &interface, QuickFixOperations &result)
|
||||
void SplitIfStatement::doMatch(const CppQuickFixInterface &interface, QuickFixOperations &result)
|
||||
{
|
||||
IfStatementAST *pattern = nullptr;
|
||||
const QList<AST *> &path = interface.path();
|
||||
@@ -1287,7 +1298,7 @@ private:
|
||||
|
||||
} // anonymous namespace
|
||||
|
||||
void WrapStringLiteral::match(const CppQuickFixInterface &interface, QuickFixOperations &result)
|
||||
void WrapStringLiteral::doMatch(const CppQuickFixInterface &interface, QuickFixOperations &result)
|
||||
{
|
||||
StringLiteralType type = TypeNone;
|
||||
QByteArray enclosingFunction;
|
||||
@@ -1343,8 +1354,8 @@ void WrapStringLiteral::match(const CppQuickFixInterface &interface, QuickFixOpe
|
||||
}
|
||||
}
|
||||
|
||||
void TranslateStringLiteral::match(const CppQuickFixInterface &interface,
|
||||
QuickFixOperations &result)
|
||||
void TranslateStringLiteral::doMatch(const CppQuickFixInterface &interface,
|
||||
QuickFixOperations &result)
|
||||
{
|
||||
// Initialize
|
||||
StringLiteralType type = TypeNone;
|
||||
@@ -1446,8 +1457,8 @@ private:
|
||||
|
||||
} // anonymous namespace
|
||||
|
||||
void ConvertCStringToNSString::match(const CppQuickFixInterface &interface,
|
||||
QuickFixOperations &result)
|
||||
void ConvertCStringToNSString::doMatch(const CppQuickFixInterface &interface,
|
||||
QuickFixOperations &result)
|
||||
{
|
||||
CppRefactoringFilePtr file = interface.currentFile();
|
||||
|
||||
@@ -1500,7 +1511,7 @@ private:
|
||||
|
||||
} // anonymous namespace
|
||||
|
||||
void ConvertNumericLiteral::match(const CppQuickFixInterface &interface, QuickFixOperations &result)
|
||||
void ConvertNumericLiteral::doMatch(const CppQuickFixInterface &interface, QuickFixOperations &result)
|
||||
{
|
||||
const QList<AST *> &path = interface.path();
|
||||
CppRefactoringFilePtr file = interface.currentFile();
|
||||
@@ -1734,7 +1745,7 @@ private:
|
||||
|
||||
} // anonymous namespace
|
||||
|
||||
void ConvertToCamelCase::match(const CppQuickFixInterface &interface, QuickFixOperations &result)
|
||||
void ConvertToCamelCase::doMatch(const CppQuickFixInterface &interface, QuickFixOperations &result)
|
||||
{
|
||||
const QList<AST *> &path = interface.path();
|
||||
|
||||
@@ -2034,8 +2045,8 @@ QList<IndexItem::Ptr> matchName(const Name *name, QString *className)
|
||||
|
||||
} // anonymous namespace
|
||||
|
||||
void AddIncludeForUndefinedIdentifier::match(const CppQuickFixInterface &interface,
|
||||
QuickFixOperations &result)
|
||||
void AddIncludeForUndefinedIdentifier::doMatch(const CppQuickFixInterface &interface,
|
||||
QuickFixOperations &result)
|
||||
{
|
||||
const NameAST *nameAst = nameUnderCursor(interface.path());
|
||||
if (!nameAst || !nameAst->name)
|
||||
@@ -2168,7 +2179,7 @@ private:
|
||||
|
||||
} // anonymous namespace
|
||||
|
||||
void RearrangeParamDeclarationList::match(const CppQuickFixInterface &interface,
|
||||
void RearrangeParamDeclarationList::doMatch(const CppQuickFixInterface &interface,
|
||||
QuickFixOperations &result)
|
||||
{
|
||||
const QList<AST *> path = interface.path();
|
||||
@@ -2290,7 +2301,7 @@ private:
|
||||
|
||||
} // anonymous namespace
|
||||
|
||||
void ReformatPointerDeclaration::match(const CppQuickFixInterface &interface,
|
||||
void ReformatPointerDeclaration::doMatch(const CppQuickFixInterface &interface,
|
||||
QuickFixOperations &result)
|
||||
{
|
||||
const QList<AST *> &path = interface.path();
|
||||
@@ -2457,12 +2468,9 @@ Enum *conditionEnum(const CppQuickFixInterface &interface, SwitchStatementAST *s
|
||||
|
||||
} // anonymous namespace
|
||||
|
||||
void CompleteSwitchCaseStatement::match(const CppQuickFixInterface &interface,
|
||||
QuickFixOperations &result)
|
||||
void CompleteSwitchCaseStatement::doMatch(const CppQuickFixInterface &interface,
|
||||
QuickFixOperations &result)
|
||||
{
|
||||
if (CppModelManager::usesClangd(interface.currentFile()->editor()->textDocument()))
|
||||
return;
|
||||
|
||||
const QList<AST *> &path = interface.path();
|
||||
|
||||
if (path.isEmpty())
|
||||
@@ -2577,7 +2585,7 @@ private:
|
||||
|
||||
} // anonymous namespace
|
||||
|
||||
void InsertDeclFromDef::match(const CppQuickFixInterface &interface, QuickFixOperations &result)
|
||||
void InsertDeclFromDef::doMatch(const CppQuickFixInterface &interface, QuickFixOperations &result)
|
||||
{
|
||||
const QList<AST *> &path = interface.path();
|
||||
CppRefactoringFilePtr file = interface.currentFile();
|
||||
@@ -2841,7 +2849,7 @@ private:
|
||||
|
||||
} // anonymous namespace
|
||||
|
||||
void InsertDefFromDecl::match(const CppQuickFixInterface &interface, QuickFixOperations &result)
|
||||
void InsertDefFromDecl::doMatch(const CppQuickFixInterface &interface, QuickFixOperations &result)
|
||||
{
|
||||
const QList<AST *> &path = interface.path();
|
||||
|
||||
@@ -2992,8 +3000,8 @@ private:
|
||||
const bool m_makeConst;
|
||||
};
|
||||
|
||||
void AddDeclarationForUndeclaredIdentifier::match(const CppQuickFixInterface &interface,
|
||||
QuickFixOperations &result)
|
||||
void AddDeclarationForUndeclaredIdentifier::doMatch(const CppQuickFixInterface &interface,
|
||||
QuickFixOperations &result)
|
||||
{
|
||||
// Are we on a name?
|
||||
const QList<AST *> &path = interface.path();
|
||||
@@ -3569,7 +3577,7 @@ private:
|
||||
};
|
||||
|
||||
|
||||
void InsertDefsFromDecls::match(const CppQuickFixInterface &interface, QuickFixOperations &result)
|
||||
void InsertDefsFromDecls::doMatch(const CppQuickFixInterface &interface, QuickFixOperations &result)
|
||||
{
|
||||
const auto op = QSharedPointer<InsertDefsOperation>::create(interface);
|
||||
op->setMode(m_mode);
|
||||
@@ -4503,7 +4511,7 @@ QList<Symbol *> getMemberFunctions(const Class *clazz)
|
||||
|
||||
} // anonymous namespace
|
||||
|
||||
void GenerateGetterSetter::match(const CppQuickFixInterface &interface, QuickFixOperations &result)
|
||||
void GenerateGetterSetter::doMatch(const CppQuickFixInterface &interface, QuickFixOperations &result)
|
||||
{
|
||||
ExistingGetterSetterData existing;
|
||||
|
||||
@@ -4962,8 +4970,8 @@ private:
|
||||
bool m_hasData = false;
|
||||
};
|
||||
|
||||
void GenerateGettersSettersForClass::match(const CppQuickFixInterface &interface,
|
||||
QuickFixOperations &result)
|
||||
void GenerateGettersSettersForClass::doMatch(const CppQuickFixInterface &interface,
|
||||
QuickFixOperations &result)
|
||||
{
|
||||
const auto op = QSharedPointer<GenerateGettersSettersOperation>::create(interface);
|
||||
if (!op->isApplicable())
|
||||
@@ -5453,7 +5461,7 @@ ExtractFunction::ExtractFunction(FunctionNameGetter functionNameGetter)
|
||||
{
|
||||
}
|
||||
|
||||
void ExtractFunction::match(const CppQuickFixInterface &interface, QuickFixOperations &result)
|
||||
void ExtractFunction::doMatch(const CppQuickFixInterface &interface, QuickFixOperations &result)
|
||||
{
|
||||
const CppRefactoringFilePtr file = interface.currentFile();
|
||||
|
||||
@@ -5861,7 +5869,7 @@ private:
|
||||
|
||||
} // anonymous namespace
|
||||
|
||||
void ExtractLiteralAsParameter::match(const CppQuickFixInterface &interface,
|
||||
void ExtractLiteralAsParameter::doMatch(const CppQuickFixInterface &interface,
|
||||
QuickFixOperations &result)
|
||||
{
|
||||
const QList<AST *> &path = interface.path();
|
||||
@@ -6186,8 +6194,8 @@ private:
|
||||
|
||||
} // anonymous namespace
|
||||
|
||||
void ConvertFromAndToPointer::match(const CppQuickFixInterface &interface,
|
||||
QuickFixOperations &result)
|
||||
void ConvertFromAndToPointer::doMatch(const CppQuickFixInterface &interface,
|
||||
QuickFixOperations &result)
|
||||
{
|
||||
const QList<AST *> &path = interface.path();
|
||||
if (path.count() < 2)
|
||||
@@ -6288,7 +6296,7 @@ void extractNames(const CppRefactoringFilePtr &file,
|
||||
|
||||
} // anonymous namespace
|
||||
|
||||
void InsertQtPropertyMembers::match(const CppQuickFixInterface &interface, QuickFixOperations &result)
|
||||
void InsertQtPropertyMembers::doMatch(const CppQuickFixInterface &interface, QuickFixOperations &result)
|
||||
{
|
||||
using Flag = GenerateGetterSetterOp::GenerateFlag;
|
||||
ExistingGetterSetterData existing;
|
||||
@@ -6448,8 +6456,8 @@ private:
|
||||
|
||||
} // anonymous namespace
|
||||
|
||||
void ApplyDeclDefLinkChanges::match(const CppQuickFixInterface &interface,
|
||||
QuickFixOperations &result)
|
||||
void ApplyDeclDefLinkChanges::doMatch(const CppQuickFixInterface &interface,
|
||||
QuickFixOperations &result)
|
||||
{
|
||||
QSharedPointer<FunctionDeclDefLink> link = interface.editor()->declDefLink();
|
||||
if (!link || !link->isMarkerVisible())
|
||||
@@ -6626,7 +6634,7 @@ private:
|
||||
|
||||
} // anonymous namespace
|
||||
|
||||
void MoveFuncDefOutside::match(const CppQuickFixInterface &interface, QuickFixOperations &result)
|
||||
void MoveFuncDefOutside::doMatch(const CppQuickFixInterface &interface, QuickFixOperations &result)
|
||||
{
|
||||
const QList<AST *> &path = interface.path();
|
||||
SimpleDeclarationAST *classAST = nullptr;
|
||||
@@ -6725,7 +6733,7 @@ private:
|
||||
|
||||
} // anonymous namespace
|
||||
|
||||
void MoveAllFuncDefOutside::match(const CppQuickFixInterface &interface, QuickFixOperations &result)
|
||||
void MoveAllFuncDefOutside::doMatch(const CppQuickFixInterface &interface, QuickFixOperations &result)
|
||||
{
|
||||
ClassSpecifierAST * const classAST = astForClassOperations(interface);
|
||||
if (!classAST)
|
||||
@@ -6854,7 +6862,7 @@ private:
|
||||
|
||||
} // anonymous namespace
|
||||
|
||||
void MoveFuncDefToDeclPush::match(const CppQuickFixInterface &interface, QuickFixOperations &result)
|
||||
void MoveFuncDefToDeclPush::doMatch(const CppQuickFixInterface &interface, QuickFixOperations &result)
|
||||
{
|
||||
const QList<AST *> &path = interface.path();
|
||||
AST *completeDefAST = nullptr;
|
||||
@@ -6973,8 +6981,8 @@ void MoveFuncDefToDeclPush::match(const CppQuickFixInterface &interface, QuickFi
|
||||
defRange, declRange, MoveFuncDefToDeclOp::Push);
|
||||
}
|
||||
|
||||
void MoveFuncDefToDeclPull::match(const CppQuickFixInterface &interface,
|
||||
QuickFixOperations &result)
|
||||
void MoveFuncDefToDeclPull::doMatch(const CppQuickFixInterface &interface,
|
||||
QuickFixOperations &result)
|
||||
{
|
||||
const QList<AST *> &path = interface.path();
|
||||
for (auto it = std::rbegin(path); it != std::rend(path); ++it) {
|
||||
@@ -7117,7 +7125,7 @@ private:
|
||||
|
||||
} // anonymous namespace
|
||||
|
||||
void AssignToLocalVariable::match(const CppQuickFixInterface &interface, QuickFixOperations &result)
|
||||
void AssignToLocalVariable::doMatch(const CppQuickFixInterface &interface, QuickFixOperations &result)
|
||||
{
|
||||
const QList<AST *> &path = interface.path();
|
||||
AST *outerAST = nullptr;
|
||||
@@ -7337,7 +7345,7 @@ private:
|
||||
|
||||
} // anonymous namespace
|
||||
|
||||
void OptimizeForLoop::match(const CppQuickFixInterface &interface, QuickFixOperations &result)
|
||||
void OptimizeForLoop::doMatch(const CppQuickFixInterface &interface, QuickFixOperations &result)
|
||||
{
|
||||
const QList<AST *> path = interface.path();
|
||||
ForStatementAST *forAst = nullptr;
|
||||
@@ -7566,7 +7574,7 @@ private:
|
||||
|
||||
} // anonymous namespace
|
||||
|
||||
void EscapeStringLiteral::match(const CppQuickFixInterface &interface, QuickFixOperations &result)
|
||||
void EscapeStringLiteral::doMatch(const CppQuickFixInterface &interface, QuickFixOperations &result)
|
||||
{
|
||||
const QList<AST *> &path = interface.path();
|
||||
if (path.isEmpty())
|
||||
@@ -7883,7 +7891,7 @@ bool collectConnectArguments(const ExpressionListAST *arguments,
|
||||
|
||||
} // anonynomous namespace
|
||||
|
||||
void ConvertQt4Connect::match(const CppQuickFixInterface &interface, QuickFixOperations &result)
|
||||
void ConvertQt4Connect::doMatch(const CppQuickFixInterface &interface, QuickFixOperations &result)
|
||||
{
|
||||
const QList<AST *> &path = interface.path();
|
||||
|
||||
@@ -7923,8 +7931,8 @@ void ConvertQt4Connect::match(const CppQuickFixInterface &interface, QuickFixOpe
|
||||
}
|
||||
}
|
||||
|
||||
void ExtraRefactoringOperations::match(const CppQuickFixInterface &interface,
|
||||
QuickFixOperations &result)
|
||||
void ExtraRefactoringOperations::doMatch(const CppQuickFixInterface &interface,
|
||||
QuickFixOperations &result)
|
||||
{
|
||||
const auto processor = CppModelManager::cppEditorDocumentProcessor(interface.filePath());
|
||||
if (processor) {
|
||||
@@ -8465,11 +8473,8 @@ private:
|
||||
};
|
||||
} // namespace
|
||||
|
||||
void RemoveUsingNamespace::match(const CppQuickFixInterface &interface, QuickFixOperations &result)
|
||||
void RemoveUsingNamespace::doMatch(const CppQuickFixInterface &interface, QuickFixOperations &result)
|
||||
{
|
||||
if (CppModelManager::usesClangd(interface.currentFile()->editor()->textDocument()))
|
||||
return;
|
||||
|
||||
const QList<AST *> &path = interface.path();
|
||||
// We expect something like
|
||||
// [0] TranslationUnitAST
|
||||
@@ -9392,7 +9397,7 @@ private:
|
||||
bool m_test = false;
|
||||
};
|
||||
} // namespace
|
||||
void GenerateConstructor::match(const CppQuickFixInterface &interface, QuickFixOperations &result)
|
||||
void GenerateConstructor::doMatch(const CppQuickFixInterface &interface, QuickFixOperations &result)
|
||||
{
|
||||
const auto op = QSharedPointer<GenerateConstructorOperation>::create(interface);
|
||||
if (!op->isApplicable())
|
||||
@@ -9596,8 +9601,8 @@ private:
|
||||
};
|
||||
} // namespace
|
||||
|
||||
void ConvertCommentStyle::match(const CppQuickFixInterface &interface,
|
||||
TextEditor::QuickFixOperations &result)
|
||||
void ConvertCommentStyle::doMatch(const CppQuickFixInterface &interface,
|
||||
TextEditor::QuickFixOperations &result)
|
||||
{
|
||||
// If there's a selection, then it must entirely consist of comment tokens.
|
||||
// If there's no selection, the cursor must be on a comment.
|
||||
@@ -9785,8 +9790,8 @@ private:
|
||||
};
|
||||
} // namespace
|
||||
|
||||
void MoveFunctionComments::match(const CppQuickFixInterface &interface,
|
||||
TextEditor::QuickFixOperations &result)
|
||||
void MoveFunctionComments::doMatch(const CppQuickFixInterface &interface,
|
||||
TextEditor::QuickFixOperations &result)
|
||||
{
|
||||
const QList<AST *> &astPath = interface.path();
|
||||
if (astPath.isEmpty())
|
||||
|
@@ -10,7 +10,7 @@
|
||||
///
|
||||
/// Adding New Quick Fixes
|
||||
///
|
||||
/// When adding new Quick Fixes, make sure that the match() function is "cheap".
|
||||
/// When adding new Quick Fixes, make sure that the doMatch() function is "cheap".
|
||||
/// Otherwise, since the match() functions are also called to generate context menu
|
||||
/// entries, the user might experience a delay opening the context menu.
|
||||
///
|
||||
@@ -25,7 +25,7 @@ void destroyCppQuickFixes();
|
||||
class ExtraRefactoringOperations : public CppQuickFixFactory
|
||||
{
|
||||
public:
|
||||
void match(const CppQuickFixInterface &interface, QuickFixOperations &result) override;
|
||||
void doMatch(const CppQuickFixInterface &interface, QuickFixOperations &result) override;
|
||||
};
|
||||
|
||||
/*!
|
||||
@@ -36,7 +36,7 @@ public:
|
||||
class AddIncludeForUndefinedIdentifier : public CppQuickFixFactory
|
||||
{
|
||||
public:
|
||||
void match(const CppQuickFixInterface &interface, QuickFixOperations &result) override;
|
||||
void doMatch(const CppQuickFixInterface &interface, QuickFixOperations &result) override;
|
||||
};
|
||||
|
||||
// Exposed for tests
|
||||
@@ -77,7 +77,7 @@ private:
|
||||
class FlipLogicalOperands: public CppQuickFixFactory
|
||||
{
|
||||
public:
|
||||
void match(const CppQuickFixInterface &interface, QuickFixOperations &result) override;
|
||||
void doMatch(const CppQuickFixInterface &interface, QuickFixOperations &result) override;
|
||||
};
|
||||
|
||||
/*!
|
||||
@@ -91,7 +91,7 @@ public:
|
||||
class InverseLogicalComparison: public CppQuickFixFactory
|
||||
{
|
||||
public:
|
||||
void match(const CppQuickFixInterface &interface, QuickFixOperations &result) override;
|
||||
void doMatch(const CppQuickFixInterface &interface, QuickFixOperations &result) override;
|
||||
};
|
||||
|
||||
/*!
|
||||
@@ -106,7 +106,7 @@ public:
|
||||
class RewriteLogicalAnd: public CppQuickFixFactory
|
||||
{
|
||||
public:
|
||||
void match(const CppQuickFixInterface &interface, QuickFixOperations &result) override;
|
||||
void doMatch(const CppQuickFixInterface &interface, QuickFixOperations &result) override;
|
||||
};
|
||||
|
||||
/*!
|
||||
@@ -123,7 +123,7 @@ public:
|
||||
class ConvertCStringToNSString: public CppQuickFixFactory
|
||||
{
|
||||
public:
|
||||
void match(const CppQuickFixInterface &interface, QuickFixOperations &result) override;
|
||||
void doMatch(const CppQuickFixInterface &interface, QuickFixOperations &result) override;
|
||||
};
|
||||
|
||||
/*!
|
||||
@@ -148,7 +148,7 @@ public:
|
||||
class ConvertNumericLiteral: public CppQuickFixFactory
|
||||
{
|
||||
public:
|
||||
void match(const CppQuickFixInterface &interface, QuickFixOperations &result) override;
|
||||
void doMatch(const CppQuickFixInterface &interface, QuickFixOperations &result) override;
|
||||
};
|
||||
|
||||
/*!
|
||||
@@ -167,7 +167,7 @@ public:
|
||||
class TranslateStringLiteral: public CppQuickFixFactory
|
||||
{
|
||||
public:
|
||||
void match(const CppQuickFixInterface &interface, QuickFixOperations &result) override;
|
||||
void doMatch(const CppQuickFixInterface &interface, QuickFixOperations &result) override;
|
||||
};
|
||||
|
||||
/*!
|
||||
@@ -189,7 +189,7 @@ public:
|
||||
class WrapStringLiteral: public CppQuickFixFactory
|
||||
{
|
||||
public:
|
||||
void match(const CppQuickFixInterface &interface, QuickFixOperations &result) override;
|
||||
void doMatch(const CppQuickFixInterface &interface, QuickFixOperations &result) override;
|
||||
};
|
||||
|
||||
/*!
|
||||
@@ -203,7 +203,7 @@ class ConvertToCamelCase : public CppQuickFixFactory
|
||||
public:
|
||||
ConvertToCamelCase(bool test = false) : CppQuickFixFactory(), m_test(test) {}
|
||||
|
||||
void match(const CppQuickFixInterface &interface, QuickFixOperations &result) override;
|
||||
void doMatch(const CppQuickFixInterface &interface, QuickFixOperations &result) override;
|
||||
|
||||
private:
|
||||
const bool m_test;
|
||||
@@ -222,7 +222,7 @@ private:
|
||||
class MoveDeclarationOutOfIf: public CppQuickFixFactory
|
||||
{
|
||||
public:
|
||||
void match(const CppQuickFixInterface &interface, QuickFixOperations &result) override;
|
||||
void doMatch(const CppQuickFixInterface &interface, QuickFixOperations &result) override;
|
||||
};
|
||||
|
||||
/*!
|
||||
@@ -238,7 +238,7 @@ public:
|
||||
class MoveDeclarationOutOfWhile: public CppQuickFixFactory
|
||||
{
|
||||
public:
|
||||
void match(const CppQuickFixInterface &interface, QuickFixOperations &result) override;
|
||||
void doMatch(const CppQuickFixInterface &interface, QuickFixOperations &result) override;
|
||||
};
|
||||
|
||||
/*!
|
||||
@@ -267,7 +267,7 @@ public:
|
||||
class SplitIfStatement: public CppQuickFixFactory
|
||||
{
|
||||
public:
|
||||
void match(const CppQuickFixInterface &interface, QuickFixOperations &result) override;
|
||||
void doMatch(const CppQuickFixInterface &interface, QuickFixOperations &result) override;
|
||||
};
|
||||
|
||||
/*!
|
||||
@@ -283,7 +283,7 @@ public:
|
||||
class SplitSimpleDeclaration: public CppQuickFixFactory
|
||||
{
|
||||
public:
|
||||
void match(const CppQuickFixInterface &interface, QuickFixOperations &result) override;
|
||||
void doMatch(const CppQuickFixInterface &interface, QuickFixOperations &result) override;
|
||||
};
|
||||
|
||||
/*!
|
||||
@@ -302,7 +302,7 @@ public:
|
||||
class AddBracesToIf: public CppQuickFixFactory
|
||||
{
|
||||
public:
|
||||
void match(const CppQuickFixInterface &interface, QuickFixOperations &result) override;
|
||||
void doMatch(const CppQuickFixInterface &interface, QuickFixOperations &result) override;
|
||||
};
|
||||
|
||||
/*!
|
||||
@@ -314,7 +314,7 @@ public:
|
||||
class RearrangeParamDeclarationList : public CppQuickFixFactory
|
||||
{
|
||||
public:
|
||||
void match(const CppQuickFixInterface &interface, QuickFixOperations &result) override;
|
||||
void doMatch(const CppQuickFixInterface &interface, QuickFixOperations &result) override;
|
||||
};
|
||||
|
||||
/*!
|
||||
@@ -329,7 +329,7 @@ public:
|
||||
class ReformatPointerDeclaration : public CppQuickFixFactory
|
||||
{
|
||||
public:
|
||||
void match(const CppQuickFixInterface &interface, QuickFixOperations &result) override;
|
||||
void doMatch(const CppQuickFixInterface &interface, QuickFixOperations &result) override;
|
||||
};
|
||||
|
||||
/*!
|
||||
@@ -338,7 +338,10 @@ public:
|
||||
class CompleteSwitchCaseStatement: public CppQuickFixFactory
|
||||
{
|
||||
public:
|
||||
void match(const CppQuickFixInterface &interface, QuickFixOperations &result) override;
|
||||
CompleteSwitchCaseStatement() { setHasClangdReplacement(); }
|
||||
|
||||
private:
|
||||
void doMatch(const CppQuickFixInterface &interface, QuickFixOperations &result) override;
|
||||
};
|
||||
|
||||
/*!
|
||||
@@ -347,7 +350,7 @@ public:
|
||||
class InsertDeclFromDef: public CppQuickFixFactory
|
||||
{
|
||||
public:
|
||||
void match(const CppQuickFixInterface &interface, TextEditor::QuickFixOperations &result) override;
|
||||
void doMatch(const CppQuickFixInterface &interface, TextEditor::QuickFixOperations &result) override;
|
||||
};
|
||||
|
||||
/*!
|
||||
@@ -356,14 +359,14 @@ public:
|
||||
class InsertDefFromDecl: public CppQuickFixFactory
|
||||
{
|
||||
public:
|
||||
void match(const CppQuickFixInterface &interface, TextEditor::QuickFixOperations &result) override;
|
||||
void doMatch(const CppQuickFixInterface &interface, TextEditor::QuickFixOperations &result) override;
|
||||
bool m_defPosOutsideClass = false;
|
||||
};
|
||||
|
||||
class AddDeclarationForUndeclaredIdentifier : public CppQuickFixFactory
|
||||
{
|
||||
public:
|
||||
void match(const CppQuickFixInterface &interface,
|
||||
void doMatch(const CppQuickFixInterface &interface,
|
||||
TextEditor::QuickFixOperations &result) override;
|
||||
|
||||
#ifdef WITH_TESTS
|
||||
@@ -398,8 +401,8 @@ private:
|
||||
class InsertDefsFromDecls : public CppQuickFixFactory
|
||||
{
|
||||
public:
|
||||
void match(const CppQuickFixInterface &interface,
|
||||
TextEditor::QuickFixOperations &result) override;
|
||||
void doMatch(const CppQuickFixInterface &interface,
|
||||
TextEditor::QuickFixOperations &result) override;
|
||||
|
||||
enum class Mode {
|
||||
Off, // Testing: simulates user canceling the dialog
|
||||
@@ -422,7 +425,7 @@ public:
|
||||
using FunctionNameGetter = std::function<QString()>;
|
||||
|
||||
ExtractFunction(FunctionNameGetter functionNameGetter = FunctionNameGetter());
|
||||
void match(const CppQuickFixInterface &interface, TextEditor::QuickFixOperations &result) override;
|
||||
void doMatch(const CppQuickFixInterface &interface, TextEditor::QuickFixOperations &result) override;
|
||||
|
||||
private:
|
||||
FunctionNameGetter m_functionNameGetter; // For tests to avoid GUI pop-up.
|
||||
@@ -436,7 +439,7 @@ private:
|
||||
class ExtractLiteralAsParameter : public CppQuickFixFactory
|
||||
{
|
||||
public:
|
||||
void match(const CppQuickFixInterface &interface, TextEditor::QuickFixOperations &result) override;
|
||||
void doMatch(const CppQuickFixInterface &interface, TextEditor::QuickFixOperations &result) override;
|
||||
};
|
||||
|
||||
/*!
|
||||
@@ -447,7 +450,7 @@ public:
|
||||
class ConvertFromAndToPointer : public CppQuickFixFactory
|
||||
{
|
||||
public:
|
||||
void match(const CppQuickFixInterface &interface, TextEditor::QuickFixOperations &result) override;
|
||||
void doMatch(const CppQuickFixInterface &interface, TextEditor::QuickFixOperations &result) override;
|
||||
};
|
||||
|
||||
/*!
|
||||
@@ -456,7 +459,7 @@ public:
|
||||
class GenerateGetterSetter : public CppQuickFixFactory
|
||||
{
|
||||
public:
|
||||
void match(const CppQuickFixInterface &interface, TextEditor::QuickFixOperations &result) override;
|
||||
void doMatch(const CppQuickFixInterface &interface, TextEditor::QuickFixOperations &result) override;
|
||||
};
|
||||
|
||||
/*!
|
||||
@@ -468,8 +471,8 @@ protected:
|
||||
void setTest() { m_test = true; }
|
||||
|
||||
private:
|
||||
void match(const CppQuickFixInterface &interface,
|
||||
TextEditor::QuickFixOperations &result) override;
|
||||
void doMatch(const CppQuickFixInterface &interface,
|
||||
TextEditor::QuickFixOperations &result) override;
|
||||
|
||||
bool m_test = false;
|
||||
};
|
||||
@@ -480,7 +483,7 @@ private:
|
||||
class InsertQtPropertyMembers : public CppQuickFixFactory
|
||||
{
|
||||
public:
|
||||
void match(const CppQuickFixInterface &interface, TextEditor::QuickFixOperations &result) override;
|
||||
void doMatch(const CppQuickFixInterface &interface, TextEditor::QuickFixOperations &result) override;
|
||||
};
|
||||
|
||||
/*!
|
||||
@@ -489,7 +492,7 @@ public:
|
||||
class ConvertQt4Connect : public CppQuickFixFactory
|
||||
{
|
||||
public:
|
||||
void match(const CppQuickFixInterface &interface, TextEditor::QuickFixOperations &result) override;
|
||||
void doMatch(const CppQuickFixInterface &interface, TextEditor::QuickFixOperations &result) override;
|
||||
};
|
||||
|
||||
/*!
|
||||
@@ -498,7 +501,7 @@ public:
|
||||
class ApplyDeclDefLinkChanges: public CppQuickFixFactory
|
||||
{
|
||||
public:
|
||||
void match(const CppQuickFixInterface &interface, TextEditor::QuickFixOperations &result) override;
|
||||
void doMatch(const CppQuickFixInterface &interface, TextEditor::QuickFixOperations &result) override;
|
||||
};
|
||||
|
||||
/*!
|
||||
@@ -508,7 +511,7 @@ public:
|
||||
class MoveFuncDefOutside: public CppQuickFixFactory
|
||||
{
|
||||
public:
|
||||
void match(const CppQuickFixInterface &interface, TextEditor::QuickFixOperations &result) override;
|
||||
void doMatch(const CppQuickFixInterface &interface, TextEditor::QuickFixOperations &result) override;
|
||||
};
|
||||
|
||||
/*!
|
||||
@@ -517,7 +520,7 @@ public:
|
||||
class MoveAllFuncDefOutside: public CppQuickFixFactory
|
||||
{
|
||||
public:
|
||||
void match(const CppQuickFixInterface &interface, TextEditor::QuickFixOperations &result) override;
|
||||
void doMatch(const CppQuickFixInterface &interface, TextEditor::QuickFixOperations &result) override;
|
||||
};
|
||||
|
||||
/*!
|
||||
@@ -526,7 +529,7 @@ public:
|
||||
class MoveFuncDefToDeclPush : public CppQuickFixFactory
|
||||
{
|
||||
public:
|
||||
void match(const CppQuickFixInterface &interface, TextEditor::QuickFixOperations &result) override;
|
||||
void doMatch(const CppQuickFixInterface &interface, TextEditor::QuickFixOperations &result) override;
|
||||
};
|
||||
|
||||
/*!
|
||||
@@ -535,7 +538,7 @@ public:
|
||||
class MoveFuncDefToDeclPull : public CppQuickFixFactory
|
||||
{
|
||||
public:
|
||||
void match(const CppQuickFixInterface &interface, TextEditor::QuickFixOperations &result) override;
|
||||
void doMatch(const CppQuickFixInterface &interface, TextEditor::QuickFixOperations &result) override;
|
||||
};
|
||||
|
||||
/*!
|
||||
@@ -544,7 +547,7 @@ public:
|
||||
class AssignToLocalVariable : public CppQuickFixFactory
|
||||
{
|
||||
public:
|
||||
void match(const CppQuickFixInterface &interface, TextEditor::QuickFixOperations &result) override;
|
||||
void doMatch(const CppQuickFixInterface &interface, TextEditor::QuickFixOperations &result) override;
|
||||
};
|
||||
|
||||
/*!
|
||||
@@ -554,7 +557,7 @@ public:
|
||||
class OptimizeForLoop : public CppQuickFixFactory
|
||||
{
|
||||
public:
|
||||
void match(const CppQuickFixInterface &interface, TextEditor::QuickFixOperations &result) override;
|
||||
void doMatch(const CppQuickFixInterface &interface, TextEditor::QuickFixOperations &result) override;
|
||||
};
|
||||
|
||||
/*!
|
||||
@@ -567,7 +570,7 @@ public:
|
||||
class EscapeStringLiteral : public CppQuickFixFactory
|
||||
{
|
||||
public:
|
||||
void match(const CppQuickFixInterface &interface, TextEditor::QuickFixOperations &result) override;
|
||||
void doMatch(const CppQuickFixInterface &interface, TextEditor::QuickFixOperations &result) override;
|
||||
};
|
||||
|
||||
/*!
|
||||
@@ -577,7 +580,10 @@ public:
|
||||
class RemoveUsingNamespace : public CppQuickFixFactory
|
||||
{
|
||||
public:
|
||||
void match(const CppQuickFixInterface &interface, TextEditor::QuickFixOperations &result) override;
|
||||
RemoveUsingNamespace() { setHasClangdReplacement(); }
|
||||
|
||||
private:
|
||||
void doMatch(const CppQuickFixInterface &interface, TextEditor::QuickFixOperations &result) override;
|
||||
};
|
||||
|
||||
/*!
|
||||
@@ -589,7 +595,7 @@ protected:
|
||||
void setTest() { m_test = true; }
|
||||
|
||||
private:
|
||||
void match(const CppQuickFixInterface &interface,
|
||||
void doMatch(const CppQuickFixInterface &interface,
|
||||
TextEditor::QuickFixOperations &result) override;
|
||||
|
||||
bool m_test = false;
|
||||
@@ -599,7 +605,7 @@ private:
|
||||
class ConvertCommentStyle : public CppQuickFixFactory
|
||||
{
|
||||
private:
|
||||
void match(const CppQuickFixInterface &interface,
|
||||
void doMatch(const CppQuickFixInterface &interface,
|
||||
TextEditor::QuickFixOperations &result) override;
|
||||
};
|
||||
|
||||
@@ -607,8 +613,8 @@ private:
|
||||
class MoveFunctionComments : public CppQuickFixFactory
|
||||
{
|
||||
private:
|
||||
void match(const CppQuickFixInterface &interface,
|
||||
TextEditor::QuickFixOperations &result) override;
|
||||
void doMatch(const CppQuickFixInterface &interface,
|
||||
TextEditor::QuickFixOperations &result) override;
|
||||
};
|
||||
|
||||
} // namespace Internal
|
||||
|
@@ -369,8 +369,6 @@ F2TestCase::F2TestCase(CppEditorAction action,
|
||||
}
|
||||
|
||||
if (useClangd) {
|
||||
QEXPECT_FAIL("infiniteLoopLocalTypedef_QTCREATORBUG-11999",
|
||||
"clangd bug: Go to definition does not return", Abort);
|
||||
if (expectedVirtualFunctionProposal.size() <= 1) {
|
||||
QVERIFY(CppEditor::Tests::waitForSignalOrTimeout(EditorManager::instance(),
|
||||
&EditorManager::linkOpened, 10000));
|
||||
|
Reference in New Issue
Block a user