2022-08-19 15:59:36 +02:00
|
|
|
// Copyright (C) 2016 The Qt Company Ltd.
|
2022-12-21 10:12:09 +01:00
|
|
|
// SPDX-License-Identifier: LicenseRef-Qt-Commercial OR GPL-3.0-only WITH Qt-GPL-exception-1.0
|
2013-02-07 12:16:41 +01:00
|
|
|
|
2016-03-18 07:55:01 +01:00
|
|
|
#pragma once
|
2013-02-07 12:16:41 +01:00
|
|
|
|
|
|
|
|
#include "cppquickfix.h"
|
|
|
|
|
|
2023-05-11 13:16:27 +02:00
|
|
|
#include <variant>
|
|
|
|
|
|
2013-06-14 11:26:40 +02:00
|
|
|
///
|
|
|
|
|
/// Adding New Quick Fixes
|
|
|
|
|
///
|
|
|
|
|
/// When adding new Quick Fixes, make sure that the match() 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.
|
|
|
|
|
///
|
|
|
|
|
|
2013-02-07 12:16:41 +01:00
|
|
|
namespace CppEditor {
|
|
|
|
|
namespace Internal {
|
2023-05-11 13:16:27 +02:00
|
|
|
using TypeOrExpr = std::variant<const CPlusPlus::ExpressionAST *, CPlusPlus::FullySpecifiedType>;
|
2013-02-07 12:16:41 +01:00
|
|
|
|
2018-01-26 16:43:01 +01:00
|
|
|
void createCppQuickFixes();
|
|
|
|
|
void destroyCppQuickFixes();
|
2013-02-07 12:16:41 +01:00
|
|
|
|
2015-08-24 18:26:09 +02:00
|
|
|
class ExtraRefactoringOperations : public CppQuickFixFactory
|
|
|
|
|
{
|
|
|
|
|
public:
|
|
|
|
|
void match(const CppQuickFixInterface &interface, QuickFixOperations &result) override;
|
|
|
|
|
};
|
|
|
|
|
|
2013-02-07 12:16:41 +01:00
|
|
|
/*!
|
2014-10-08 15:41:02 +02:00
|
|
|
Adds an include for an undefined identifier or only forward declared identifier.
|
2013-02-07 12:16:41 +01:00
|
|
|
|
|
|
|
|
Activates on: the undefined identifier
|
|
|
|
|
*/
|
|
|
|
|
class AddIncludeForUndefinedIdentifier : public CppQuickFixFactory
|
|
|
|
|
{
|
|
|
|
|
public:
|
2017-12-15 13:32:28 +01:00
|
|
|
void match(const CppQuickFixInterface &interface, QuickFixOperations &result) override;
|
2013-02-07 12:16:41 +01:00
|
|
|
};
|
|
|
|
|
|
2013-06-06 09:27:28 +02:00
|
|
|
// Exposed for tests
|
|
|
|
|
class AddIncludeForUndefinedIdentifierOp: public CppQuickFixOperation
|
|
|
|
|
{
|
|
|
|
|
public:
|
|
|
|
|
AddIncludeForUndefinedIdentifierOp(const CppQuickFixInterface &interface, int priority,
|
|
|
|
|
const QString &include);
|
2019-02-07 11:04:13 +01:00
|
|
|
void perform() override;
|
2013-06-06 09:27:28 +02:00
|
|
|
|
2020-06-04 16:16:57 +02:00
|
|
|
QString include() const { return m_include; }
|
|
|
|
|
|
2013-06-06 09:27:28 +02:00
|
|
|
private:
|
|
|
|
|
QString m_include;
|
|
|
|
|
};
|
|
|
|
|
|
2020-05-22 16:56:40 +02:00
|
|
|
class AddForwardDeclForUndefinedIdentifierOp: public CppQuickFixOperation
|
|
|
|
|
{
|
|
|
|
|
public:
|
|
|
|
|
AddForwardDeclForUndefinedIdentifierOp(const CppQuickFixInterface &interface, int priority,
|
|
|
|
|
const QString &fqClassName, int symbolPos);
|
|
|
|
|
private:
|
|
|
|
|
void perform() override;
|
|
|
|
|
|
|
|
|
|
const QString m_className;
|
|
|
|
|
const int m_symbolPos;
|
|
|
|
|
};
|
|
|
|
|
|
2013-02-07 12:16:41 +01:00
|
|
|
/*!
|
|
|
|
|
Rewrite
|
|
|
|
|
a op b
|
|
|
|
|
|
|
|
|
|
As
|
|
|
|
|
b flipop a
|
|
|
|
|
|
|
|
|
|
Activates on: <= < > >= == != && ||
|
|
|
|
|
*/
|
|
|
|
|
class FlipLogicalOperands: public CppQuickFixFactory
|
|
|
|
|
{
|
|
|
|
|
public:
|
2017-12-15 13:32:28 +01:00
|
|
|
void match(const CppQuickFixInterface &interface, QuickFixOperations &result) override;
|
2013-02-07 12:16:41 +01:00
|
|
|
};
|
|
|
|
|
|
|
|
|
|
/*!
|
|
|
|
|
Rewrite
|
|
|
|
|
a op b -> !(a invop b)
|
|
|
|
|
(a op b) -> !(a invop b)
|
|
|
|
|
!(a op b) -> (a invob b)
|
|
|
|
|
|
|
|
|
|
Activates on: <= < > >= == !=
|
|
|
|
|
*/
|
|
|
|
|
class InverseLogicalComparison: public CppQuickFixFactory
|
|
|
|
|
{
|
|
|
|
|
public:
|
2017-12-15 13:32:28 +01:00
|
|
|
void match(const CppQuickFixInterface &interface, QuickFixOperations &result) override;
|
2013-02-07 12:16:41 +01:00
|
|
|
};
|
|
|
|
|
|
|
|
|
|
/*!
|
|
|
|
|
Rewrite
|
|
|
|
|
!a && !b
|
|
|
|
|
|
|
|
|
|
As
|
|
|
|
|
!(a || b)
|
|
|
|
|
|
|
|
|
|
Activates on: &&
|
|
|
|
|
*/
|
|
|
|
|
class RewriteLogicalAnd: public CppQuickFixFactory
|
|
|
|
|
{
|
|
|
|
|
public:
|
2017-12-15 13:32:28 +01:00
|
|
|
void match(const CppQuickFixInterface &interface, QuickFixOperations &result) override;
|
2013-02-07 12:16:41 +01:00
|
|
|
};
|
|
|
|
|
|
|
|
|
|
/*!
|
|
|
|
|
Replace
|
|
|
|
|
"abcd"
|
|
|
|
|
QLatin1String("abcd")
|
|
|
|
|
QLatin1Literal("abcd")
|
|
|
|
|
|
|
|
|
|
With
|
|
|
|
|
@"abcd"
|
|
|
|
|
|
|
|
|
|
Activates on: the string literal, if the file type is a Objective-C(++) file.
|
|
|
|
|
*/
|
|
|
|
|
class ConvertCStringToNSString: public CppQuickFixFactory
|
|
|
|
|
{
|
|
|
|
|
public:
|
2017-12-15 13:32:28 +01:00
|
|
|
void match(const CppQuickFixInterface &interface, QuickFixOperations &result) override;
|
2013-02-07 12:16:41 +01:00
|
|
|
};
|
|
|
|
|
|
|
|
|
|
/*!
|
|
|
|
|
Base class for converting numeric literals between decimal, octal and hex.
|
|
|
|
|
Does the base check for the specific ones and parses the number.
|
|
|
|
|
|
|
|
|
|
Test cases:
|
|
|
|
|
0xFA0Bu;
|
|
|
|
|
0X856A;
|
|
|
|
|
298.3;
|
|
|
|
|
199;
|
|
|
|
|
074;
|
|
|
|
|
199L;
|
|
|
|
|
074L;
|
|
|
|
|
-199;
|
|
|
|
|
-017;
|
|
|
|
|
0783; // invalid octal
|
|
|
|
|
0; // border case, allow only hex<->decimal
|
|
|
|
|
|
|
|
|
|
Activates on: numeric literals
|
|
|
|
|
*/
|
|
|
|
|
class ConvertNumericLiteral: public CppQuickFixFactory
|
|
|
|
|
{
|
|
|
|
|
public:
|
2017-12-15 13:32:28 +01:00
|
|
|
void match(const CppQuickFixInterface &interface, QuickFixOperations &result) override;
|
2013-02-07 12:16:41 +01:00
|
|
|
};
|
|
|
|
|
|
|
|
|
|
/*!
|
|
|
|
|
Replace
|
|
|
|
|
"abcd"
|
|
|
|
|
|
|
|
|
|
With
|
|
|
|
|
tr("abcd") or
|
|
|
|
|
QCoreApplication::translate("CONTEXT", "abcd") or
|
|
|
|
|
QT_TRANSLATE_NOOP("GLOBAL", "abcd")
|
|
|
|
|
|
|
|
|
|
depending on what is available.
|
|
|
|
|
|
|
|
|
|
Activates on: the string literal
|
|
|
|
|
*/
|
|
|
|
|
class TranslateStringLiteral: public CppQuickFixFactory
|
|
|
|
|
{
|
|
|
|
|
public:
|
2017-12-15 13:32:28 +01:00
|
|
|
void match(const CppQuickFixInterface &interface, QuickFixOperations &result) override;
|
2013-02-07 12:16:41 +01:00
|
|
|
};
|
|
|
|
|
|
|
|
|
|
/*!
|
|
|
|
|
Replace
|
|
|
|
|
"abcd" -> QLatin1String("abcd")
|
|
|
|
|
@"abcd" -> QLatin1String("abcd") (Objective C)
|
|
|
|
|
'a' -> QLatin1Char('a')
|
|
|
|
|
'a' -> "a"
|
|
|
|
|
"a" -> 'a' or QLatin1Char('a') (Single character string constants)
|
|
|
|
|
"\n" -> '\n', QLatin1Char('\n')
|
|
|
|
|
|
|
|
|
|
Except if they are already enclosed in
|
|
|
|
|
QLatin1Char, QT_TRANSLATE_NOOP, tr,
|
|
|
|
|
trUtf8, QLatin1Literal, QLatin1String
|
|
|
|
|
|
|
|
|
|
Activates on: the string or character literal
|
|
|
|
|
*/
|
|
|
|
|
|
|
|
|
|
class WrapStringLiteral: public CppQuickFixFactory
|
|
|
|
|
{
|
|
|
|
|
public:
|
2017-12-15 13:32:28 +01:00
|
|
|
void match(const CppQuickFixInterface &interface, QuickFixOperations &result) override;
|
2013-02-07 12:16:41 +01:00
|
|
|
};
|
|
|
|
|
|
|
|
|
|
/*!
|
|
|
|
|
Turns "an_example_symbol" into "anExampleSymbol" and
|
|
|
|
|
"AN_EXAMPLE_SYMBOL" into "AnExampleSymbol".
|
|
|
|
|
|
|
|
|
|
Activates on: identifiers
|
|
|
|
|
*/
|
|
|
|
|
class ConvertToCamelCase : public CppQuickFixFactory
|
|
|
|
|
{
|
|
|
|
|
public:
|
2020-10-16 16:38:25 +02:00
|
|
|
ConvertToCamelCase(bool test = false) : CppQuickFixFactory(), m_test(test) {}
|
|
|
|
|
|
2017-12-15 13:32:28 +01:00
|
|
|
void match(const CppQuickFixInterface &interface, QuickFixOperations &result) override;
|
2020-10-16 16:38:25 +02:00
|
|
|
|
|
|
|
|
private:
|
|
|
|
|
const bool m_test;
|
2013-02-07 12:16:41 +01:00
|
|
|
};
|
|
|
|
|
|
|
|
|
|
/*!
|
|
|
|
|
Replace
|
|
|
|
|
if (Type name = foo()) {...}
|
|
|
|
|
|
|
|
|
|
With
|
2013-04-04 20:15:01 +02:00
|
|
|
Type name = foo();
|
2013-02-07 12:16:41 +01:00
|
|
|
if (name) {...}
|
|
|
|
|
|
|
|
|
|
Activates on: the name of the introduced variable
|
|
|
|
|
*/
|
|
|
|
|
class MoveDeclarationOutOfIf: public CppQuickFixFactory
|
|
|
|
|
{
|
|
|
|
|
public:
|
2017-12-15 13:32:28 +01:00
|
|
|
void match(const CppQuickFixInterface &interface, QuickFixOperations &result) override;
|
2013-02-07 12:16:41 +01:00
|
|
|
};
|
|
|
|
|
|
|
|
|
|
/*!
|
|
|
|
|
Replace
|
|
|
|
|
while (Type name = foo()) {...}
|
|
|
|
|
|
|
|
|
|
With
|
|
|
|
|
Type name;
|
|
|
|
|
while ((name = foo()) != 0) {...}
|
|
|
|
|
|
|
|
|
|
Activates on: the name of the introduced variable
|
|
|
|
|
*/
|
|
|
|
|
class MoveDeclarationOutOfWhile: public CppQuickFixFactory
|
|
|
|
|
{
|
|
|
|
|
public:
|
2017-12-15 13:32:28 +01:00
|
|
|
void match(const CppQuickFixInterface &interface, QuickFixOperations &result) override;
|
2013-02-07 12:16:41 +01:00
|
|
|
};
|
|
|
|
|
|
|
|
|
|
/*!
|
|
|
|
|
Replace
|
|
|
|
|
if (something && something_else) {
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
with
|
|
|
|
|
if (something)
|
2013-04-04 20:15:01 +02:00
|
|
|
if (something_else) {
|
|
|
|
|
}
|
2013-02-07 12:16:41 +01:00
|
|
|
}
|
|
|
|
|
|
|
|
|
|
and
|
|
|
|
|
if (something || something_else)
|
|
|
|
|
x;
|
|
|
|
|
|
|
|
|
|
with
|
|
|
|
|
if (something)
|
|
|
|
|
x;
|
|
|
|
|
else if (something_else)
|
|
|
|
|
x;
|
|
|
|
|
|
|
|
|
|
Activates on: && or ||
|
|
|
|
|
*/
|
|
|
|
|
class SplitIfStatement: public CppQuickFixFactory
|
|
|
|
|
{
|
|
|
|
|
public:
|
2017-12-15 13:32:28 +01:00
|
|
|
void match(const CppQuickFixInterface &interface, QuickFixOperations &result) override;
|
2013-02-07 12:16:41 +01:00
|
|
|
};
|
|
|
|
|
|
|
|
|
|
/*!
|
|
|
|
|
Rewrite
|
|
|
|
|
int *a, b;
|
|
|
|
|
|
|
|
|
|
As
|
|
|
|
|
int *a;
|
|
|
|
|
int b;
|
|
|
|
|
|
|
|
|
|
Activates on: the type or the variable names.
|
|
|
|
|
*/
|
|
|
|
|
class SplitSimpleDeclaration: public CppQuickFixFactory
|
|
|
|
|
{
|
|
|
|
|
public:
|
2017-12-15 13:32:28 +01:00
|
|
|
void match(const CppQuickFixInterface &interface, QuickFixOperations &result) override;
|
2013-02-07 12:16:41 +01:00
|
|
|
};
|
|
|
|
|
|
|
|
|
|
/*!
|
|
|
|
|
Add curly braces to a if statement that doesn't already contain a
|
|
|
|
|
compound statement. I.e.
|
|
|
|
|
|
|
|
|
|
if (a)
|
|
|
|
|
b;
|
|
|
|
|
becomes
|
2013-04-04 20:15:01 +02:00
|
|
|
if (a) {
|
2013-02-07 12:16:41 +01:00
|
|
|
b;
|
2013-04-04 20:15:01 +02:00
|
|
|
}
|
2013-02-07 12:16:41 +01:00
|
|
|
|
|
|
|
|
Activates on: the if
|
|
|
|
|
*/
|
|
|
|
|
class AddBracesToIf: public CppQuickFixFactory
|
|
|
|
|
{
|
|
|
|
|
public:
|
2017-12-15 13:32:28 +01:00
|
|
|
void match(const CppQuickFixInterface &interface, QuickFixOperations &result) override;
|
2013-02-07 12:16:41 +01:00
|
|
|
};
|
|
|
|
|
|
|
|
|
|
/*!
|
|
|
|
|
Switches places of the parameter declaration under cursor
|
|
|
|
|
with the next or the previous one in the parameter declaration list
|
|
|
|
|
|
|
|
|
|
Activates on: parameter declarations
|
|
|
|
|
*/
|
|
|
|
|
class RearrangeParamDeclarationList : public CppQuickFixFactory
|
|
|
|
|
{
|
|
|
|
|
public:
|
2017-12-15 13:32:28 +01:00
|
|
|
void match(const CppQuickFixInterface &interface, QuickFixOperations &result) override;
|
2013-02-07 12:16:41 +01:00
|
|
|
};
|
|
|
|
|
|
|
|
|
|
/*!
|
|
|
|
|
Reformats a pointer, reference or rvalue reference type/declaration.
|
|
|
|
|
|
|
|
|
|
Works also with selections (except when the cursor is not on any AST).
|
|
|
|
|
|
|
|
|
|
Activates on: simple declarations, parameters and return types of function
|
|
|
|
|
declarations and definitions, control flow statements (if,
|
|
|
|
|
while, for, foreach) with declarations.
|
|
|
|
|
*/
|
|
|
|
|
class ReformatPointerDeclaration : public CppQuickFixFactory
|
|
|
|
|
{
|
|
|
|
|
public:
|
2017-12-15 13:32:28 +01:00
|
|
|
void match(const CppQuickFixInterface &interface, QuickFixOperations &result) override;
|
2013-02-07 12:16:41 +01:00
|
|
|
};
|
|
|
|
|
|
2013-04-11 18:01:40 +02:00
|
|
|
/*!
|
|
|
|
|
Adds missing case statements for "switch (enumVariable)"
|
|
|
|
|
*/
|
|
|
|
|
class CompleteSwitchCaseStatement: public CppQuickFixFactory
|
|
|
|
|
{
|
|
|
|
|
public:
|
2017-12-15 13:32:28 +01:00
|
|
|
void match(const CppQuickFixInterface &interface, QuickFixOperations &result) override;
|
2013-04-11 18:01:40 +02:00
|
|
|
};
|
|
|
|
|
|
|
|
|
|
/*!
|
|
|
|
|
Adds a declarations to a definition
|
|
|
|
|
*/
|
|
|
|
|
class InsertDeclFromDef: public CppQuickFixFactory
|
|
|
|
|
{
|
|
|
|
|
public:
|
2017-12-15 13:32:28 +01:00
|
|
|
void match(const CppQuickFixInterface &interface, TextEditor::QuickFixOperations &result) override;
|
2013-04-11 18:01:40 +02:00
|
|
|
};
|
|
|
|
|
|
|
|
|
|
/*!
|
|
|
|
|
Adds a definition for a declaration.
|
|
|
|
|
*/
|
|
|
|
|
class InsertDefFromDecl: public CppQuickFixFactory
|
|
|
|
|
{
|
|
|
|
|
public:
|
2017-12-15 13:32:28 +01:00
|
|
|
void match(const CppQuickFixInterface &interface, TextEditor::QuickFixOperations &result) override;
|
2013-04-11 18:01:40 +02:00
|
|
|
};
|
|
|
|
|
|
2023-04-25 17:51:25 +02:00
|
|
|
class AddDeclarationForUndeclaredIdentifier : public CppQuickFixFactory
|
2020-07-21 17:27:16 +02:00
|
|
|
{
|
|
|
|
|
public:
|
|
|
|
|
void match(const CppQuickFixInterface &interface,
|
|
|
|
|
TextEditor::QuickFixOperations &result) override;
|
|
|
|
|
|
2023-04-26 15:25:24 +02:00
|
|
|
#ifdef WITH_TESTS
|
|
|
|
|
void setMembersOnly() { m_membersOnly = true; }
|
|
|
|
|
#endif
|
|
|
|
|
|
2020-07-21 17:27:16 +02:00
|
|
|
private:
|
2023-04-26 15:25:24 +02:00
|
|
|
void collectOperations(const CppQuickFixInterface &interface,
|
|
|
|
|
TextEditor::QuickFixOperations &result);
|
2023-05-11 13:16:27 +02:00
|
|
|
void handleCall(const CPlusPlus::CallAST *call, const CppQuickFixInterface &interface,
|
|
|
|
|
TextEditor::QuickFixOperations &result);
|
2023-04-26 15:25:24 +02:00
|
|
|
|
2023-04-25 17:51:25 +02:00
|
|
|
// Returns whether to still do other checks.
|
|
|
|
|
bool checkForMemberInitializer(const CppQuickFixInterface &interface,
|
|
|
|
|
TextEditor::QuickFixOperations &result);
|
|
|
|
|
|
2023-04-26 15:25:24 +02:00
|
|
|
void maybeAddMember(const CppQuickFixInterface &interface, CPlusPlus::Scope *scope,
|
2023-05-11 13:16:27 +02:00
|
|
|
const QByteArray &classTypeExpr, const TypeOrExpr &typeOrExpr,
|
|
|
|
|
const CPlusPlus::CallAST *call, TextEditor::QuickFixOperations &result);
|
|
|
|
|
|
|
|
|
|
void maybeAddStaticMember(
|
|
|
|
|
const CppQuickFixInterface &interface, const CPlusPlus::QualifiedNameAST *qualName,
|
|
|
|
|
const TypeOrExpr &typeOrExpr, const CPlusPlus::CallAST *call,
|
|
|
|
|
TextEditor::QuickFixOperations &result);
|
2023-04-26 15:25:24 +02:00
|
|
|
|
|
|
|
|
bool m_membersOnly = false;
|
2020-07-21 17:27:16 +02:00
|
|
|
};
|
|
|
|
|
|
2020-07-22 17:19:28 +02:00
|
|
|
/*!
|
|
|
|
|
Adds a definition for any number of member function declarations.
|
|
|
|
|
*/
|
|
|
|
|
class InsertDefsFromDecls : public CppQuickFixFactory
|
|
|
|
|
{
|
|
|
|
|
public:
|
|
|
|
|
void match(const CppQuickFixInterface &interface,
|
|
|
|
|
TextEditor::QuickFixOperations &result) override;
|
|
|
|
|
|
|
|
|
|
enum class Mode {
|
|
|
|
|
Off, // Testing: simulates user canceling the dialog
|
2023-06-28 12:47:38 +02:00
|
|
|
Impl, // Testing: simulates user choosing cpp file for every function
|
2020-07-22 17:19:28 +02:00
|
|
|
Alternating, // Testing: simulates user choosing a different DefPos for every function
|
|
|
|
|
User // Normal interactive mode
|
|
|
|
|
};
|
|
|
|
|
void setMode(Mode mode) { m_mode = mode; }
|
|
|
|
|
|
|
|
|
|
private:
|
|
|
|
|
Mode m_mode = Mode::User;
|
|
|
|
|
};
|
|
|
|
|
|
2013-04-11 18:01:40 +02:00
|
|
|
/*!
|
|
|
|
|
Extracts the selected code and puts it to a function
|
|
|
|
|
*/
|
|
|
|
|
class ExtractFunction : public CppQuickFixFactory
|
|
|
|
|
{
|
|
|
|
|
public:
|
2019-02-07 11:04:13 +01:00
|
|
|
using FunctionNameGetter = std::function<QString()>;
|
2015-03-12 16:25:45 +01:00
|
|
|
|
|
|
|
|
ExtractFunction(FunctionNameGetter functionNameGetter = FunctionNameGetter());
|
2017-12-15 13:32:28 +01:00
|
|
|
void match(const CppQuickFixInterface &interface, TextEditor::QuickFixOperations &result) override;
|
2015-03-12 16:25:45 +01:00
|
|
|
|
|
|
|
|
private:
|
|
|
|
|
FunctionNameGetter m_functionNameGetter; // For tests to avoid GUI pop-up.
|
2013-04-11 18:01:40 +02:00
|
|
|
};
|
|
|
|
|
|
2013-09-11 12:00:07 +02:00
|
|
|
/*!
|
|
|
|
|
Extracts the selected constant and converts it to a parameter of the current function.
|
|
|
|
|
|
|
|
|
|
Activates on numeric, bool, character, or string literal in the function body.
|
|
|
|
|
*/
|
|
|
|
|
class ExtractLiteralAsParameter : public CppQuickFixFactory
|
|
|
|
|
{
|
|
|
|
|
public:
|
2017-12-15 13:32:28 +01:00
|
|
|
void match(const CppQuickFixInterface &interface, TextEditor::QuickFixOperations &result) override;
|
2013-09-11 12:00:07 +02:00
|
|
|
};
|
|
|
|
|
|
2013-09-26 12:02:46 +02:00
|
|
|
/*!
|
|
|
|
|
Converts the selected variable to a pointer if it is a stack variable or reference, or vice versa.
|
|
|
|
|
|
|
|
|
|
Activates on variable declarations.
|
|
|
|
|
*/
|
|
|
|
|
class ConvertFromAndToPointer : public CppQuickFixFactory
|
|
|
|
|
{
|
|
|
|
|
public:
|
2017-12-15 13:32:28 +01:00
|
|
|
void match(const CppQuickFixInterface &interface, TextEditor::QuickFixOperations &result) override;
|
2013-09-26 12:02:46 +02:00
|
|
|
};
|
|
|
|
|
|
2013-04-11 18:01:40 +02:00
|
|
|
/*!
|
|
|
|
|
Adds getter and setter functions for a member variable
|
|
|
|
|
*/
|
|
|
|
|
class GenerateGetterSetter : public CppQuickFixFactory
|
|
|
|
|
{
|
|
|
|
|
public:
|
2017-12-15 13:32:28 +01:00
|
|
|
void match(const CppQuickFixInterface &interface, TextEditor::QuickFixOperations &result) override;
|
2013-04-11 18:01:40 +02:00
|
|
|
};
|
|
|
|
|
|
2020-06-30 17:09:23 +02:00
|
|
|
/*!
|
|
|
|
|
Adds getter and setter functions for several member variables
|
|
|
|
|
*/
|
|
|
|
|
class GenerateGettersSettersForClass : public CppQuickFixFactory
|
|
|
|
|
{
|
|
|
|
|
protected:
|
|
|
|
|
void setTest() { m_test = true; }
|
|
|
|
|
|
|
|
|
|
private:
|
|
|
|
|
void match(const CppQuickFixInterface &interface,
|
|
|
|
|
TextEditor::QuickFixOperations &result) override;
|
|
|
|
|
|
|
|
|
|
bool m_test = false;
|
|
|
|
|
};
|
|
|
|
|
|
2013-04-11 18:01:40 +02:00
|
|
|
/*!
|
|
|
|
|
Adds missing members for a Q_PROPERTY
|
|
|
|
|
*/
|
|
|
|
|
class InsertQtPropertyMembers : public CppQuickFixFactory
|
|
|
|
|
{
|
|
|
|
|
public:
|
2017-12-15 13:32:28 +01:00
|
|
|
void match(const CppQuickFixInterface &interface, TextEditor::QuickFixOperations &result) override;
|
2013-04-11 18:01:40 +02:00
|
|
|
};
|
|
|
|
|
|
2014-09-25 16:49:44 +02:00
|
|
|
/*!
|
|
|
|
|
Converts a Qt 4 QObject::connect() to Qt 5 style.
|
|
|
|
|
*/
|
|
|
|
|
class ConvertQt4Connect : public CppQuickFixFactory
|
|
|
|
|
{
|
|
|
|
|
public:
|
2017-12-15 13:32:28 +01:00
|
|
|
void match(const CppQuickFixInterface &interface, TextEditor::QuickFixOperations &result) override;
|
2014-09-25 16:49:44 +02:00
|
|
|
};
|
|
|
|
|
|
2013-04-11 18:01:40 +02:00
|
|
|
/*!
|
|
|
|
|
Applies function signature changes
|
|
|
|
|
*/
|
|
|
|
|
class ApplyDeclDefLinkChanges: public CppQuickFixFactory
|
|
|
|
|
{
|
|
|
|
|
public:
|
2017-12-15 13:32:28 +01:00
|
|
|
void match(const CppQuickFixInterface &interface, TextEditor::QuickFixOperations &result) override;
|
2013-04-11 18:01:40 +02:00
|
|
|
};
|
|
|
|
|
|
2013-04-15 14:23:33 +02:00
|
|
|
/*!
|
|
|
|
|
Moves the definition of a member function outside the class or moves the definition of a member
|
|
|
|
|
function or a normal function to the implementation file.
|
|
|
|
|
*/
|
|
|
|
|
class MoveFuncDefOutside: public CppQuickFixFactory
|
|
|
|
|
{
|
|
|
|
|
public:
|
2017-12-15 13:32:28 +01:00
|
|
|
void match(const CppQuickFixInterface &interface, TextEditor::QuickFixOperations &result) override;
|
2013-04-15 14:23:33 +02:00
|
|
|
};
|
|
|
|
|
|
2014-12-03 23:33:03 +01:00
|
|
|
/*!
|
|
|
|
|
Moves all member function definitions outside the class or to the implementation file.
|
|
|
|
|
*/
|
|
|
|
|
class MoveAllFuncDefOutside: public CppQuickFixFactory
|
|
|
|
|
{
|
|
|
|
|
public:
|
2017-12-15 13:32:28 +01:00
|
|
|
void match(const CppQuickFixInterface &interface, TextEditor::QuickFixOperations &result) override;
|
2014-12-03 23:33:03 +01:00
|
|
|
};
|
|
|
|
|
|
2013-04-15 14:23:33 +02:00
|
|
|
/*!
|
|
|
|
|
Moves the definition of a function to its declaration.
|
|
|
|
|
*/
|
|
|
|
|
class MoveFuncDefToDecl: public CppQuickFixFactory
|
|
|
|
|
{
|
|
|
|
|
public:
|
2017-12-15 13:32:28 +01:00
|
|
|
void match(const CppQuickFixInterface &interface, TextEditor::QuickFixOperations &result) override;
|
2013-04-15 14:23:33 +02:00
|
|
|
};
|
|
|
|
|
|
2013-04-17 21:53:20 +02:00
|
|
|
/*!
|
|
|
|
|
Assigns the return value of a function call or a new expression to a local variable
|
|
|
|
|
*/
|
|
|
|
|
class AssignToLocalVariable : public CppQuickFixFactory
|
|
|
|
|
{
|
|
|
|
|
public:
|
2017-12-15 13:32:28 +01:00
|
|
|
void match(const CppQuickFixInterface &interface, TextEditor::QuickFixOperations &result) override;
|
2013-04-17 21:53:20 +02:00
|
|
|
};
|
|
|
|
|
|
2013-05-23 20:59:02 +02:00
|
|
|
/*!
|
|
|
|
|
Optimizes a for loop to avoid permanent condition check and forces to use preincrement
|
|
|
|
|
or predecrement operators in the expression of the for loop.
|
|
|
|
|
*/
|
|
|
|
|
class OptimizeForLoop : public CppQuickFixFactory
|
|
|
|
|
{
|
|
|
|
|
public:
|
2017-12-15 13:32:28 +01:00
|
|
|
void match(const CppQuickFixInterface &interface, TextEditor::QuickFixOperations &result) override;
|
2013-05-23 20:59:02 +02:00
|
|
|
};
|
|
|
|
|
|
2014-07-18 16:28:02 +09:00
|
|
|
/*!
|
|
|
|
|
Escapes or unescapes a string literal as UTF-8.
|
|
|
|
|
|
|
|
|
|
Escapes non-ASCII characters in a string literal to hexadecimal escape sequences.
|
|
|
|
|
Unescapes octal or hexadecimal escape sequences in a string literal.
|
|
|
|
|
String literals are handled as UTF-8 even if file's encoding is not UTF-8.
|
|
|
|
|
*/
|
|
|
|
|
class EscapeStringLiteral : public CppQuickFixFactory
|
|
|
|
|
{
|
|
|
|
|
public:
|
2017-12-15 13:32:28 +01:00
|
|
|
void match(const CppQuickFixInterface &interface, TextEditor::QuickFixOperations &result) override;
|
2014-07-18 16:28:02 +09:00
|
|
|
};
|
|
|
|
|
|
2020-08-06 16:14:47 +02:00
|
|
|
/*!
|
|
|
|
|
Removes a using directive (using namespace xyz).
|
|
|
|
|
|
|
|
|
|
*/
|
|
|
|
|
class RemoveUsingNamespace : public CppQuickFixFactory
|
|
|
|
|
{
|
|
|
|
|
public:
|
|
|
|
|
void match(const CppQuickFixInterface &interface, TextEditor::QuickFixOperations &result) override;
|
|
|
|
|
};
|
|
|
|
|
|
2021-01-04 04:41:36 +01:00
|
|
|
/*!
|
|
|
|
|
Generate constructor
|
|
|
|
|
*/
|
|
|
|
|
class GenerateConstructor : public CppQuickFixFactory
|
|
|
|
|
{
|
|
|
|
|
protected:
|
|
|
|
|
void setTest() { m_test = true; }
|
|
|
|
|
|
|
|
|
|
private:
|
|
|
|
|
void match(const CppQuickFixInterface &interface,
|
|
|
|
|
TextEditor::QuickFixOperations &result) override;
|
|
|
|
|
|
|
|
|
|
bool m_test = false;
|
|
|
|
|
};
|
|
|
|
|
|
2013-02-07 12:16:41 +01:00
|
|
|
} // namespace Internal
|
|
|
|
|
} // namespace CppEditor
|