Commit c25f0585 authored by Leandro Melo's avatar Leandro Melo

C++: Extract function quickfix

Task-number: QTCREATORBUG-5485

Change-Id: Ib6aaeaadad4b421480d22399392768d4bad85bda
Reviewed-by: default avatarRoberto Raggi <roberto.raggi@nokia.com>
parent ea04aa93
This diff is collapsed.
......@@ -35,12 +35,6 @@
#include "cppquickfix.h"
#include <CPlusPlusForwardDeclarations.h>
namespace CPlusPlus {
class ClassOrNamespace;
} // namespace CPlusPlus
namespace CppEditor {
namespace Internal {
......@@ -49,11 +43,6 @@ class DeclFromDef: public CppQuickFixFactory
public:
virtual QList<CppQuickFixOperation::Ptr>
match(const QSharedPointer<const Internal::CppQuickFixAssistInterface> &interface);
protected:
static QString generateDeclaration(const QSharedPointer<const Internal::CppQuickFixAssistInterface> &interface,
CPlusPlus::Function *method,
CPlusPlus::ClassOrNamespace *targetBinding);
};
class DefFromDecl: public CppQuickFixFactory
......@@ -63,6 +52,13 @@ public:
match(const QSharedPointer<const Internal::CppQuickFixAssistInterface> &interface);
};
class ExtractFunction : public CppQuickFixFactory
{
virtual QList<CppQuickFixOperation::Ptr>
match(const QSharedPointer<const CppQuickFixAssistInterface> &interface);
};
} // namespace Internal
} // namespace CppEditor
......
......@@ -1948,6 +1948,7 @@ private:
};
};
} // end of anonymous namespace
void registerQuickFixes(ExtensionSystem::IPlugin *plugIn)
......@@ -1973,4 +1974,5 @@ void registerQuickFixes(ExtensionSystem::IPlugin *plugIn)
plugIn->addAutoReleasedObject(new DefFromDecl);
plugIn->addAutoReleasedObject(new ApplyDeclDefLinkChanges);
plugIn->addAutoReleasedObject(new IncludeAdder);
plugIn->addAutoReleasedObject(new ExtractFunction);
}
......@@ -102,5 +102,21 @@ bool isOwnershipRAIIType(CPlusPlus::Symbol *symbol, const LookupContext &context
return false;
}
bool isValidIdentifier(const QString &s)
{
const int length = s.length();
for (int i = 0; i < length; ++i) {
const QChar &c = s.at(i);
if (i == 0) {
if (!c.isLetter() && c != QLatin1Char('_'))
return false;
} else {
if (!c.isLetterOrNumber() && c != QLatin1Char('_'))
return false;
}
}
return true;
}
} // CppTools
......@@ -49,6 +49,8 @@ void CPPTOOLS_EXPORT moveCursorToEndOfIdentifier(QTextCursor *tc);
bool CPPTOOLS_EXPORT isOwnershipRAIIType(CPlusPlus::Symbol *symbol,
const CPlusPlus::LookupContext &context);
bool CPPTOOLS_EXPORT isValidIdentifier(const QString &s);
} // CppTools
#endif // CPPTOOLSREUSE_H
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment