Commit 316c3e47 authored by Denis Steckelmacher's avatar Denis Steckelmacher

Add support for basic refactoring (renaming a declaration and its uses)

parent 0f047cda
......@@ -32,9 +32,15 @@
#include <KAboutData>
#include <language/codecompletion/codecompletion.h>
#include <language/assistant/renameassistant.h>
#include <language/assistant/staticassistantsmanager.h>
#include <language/codegen/basicrefactoring.h>
#include <language/duchain/duchain.h>
#include <language/interfaces/editorcontext.h>
#include <interfaces/icore.h>
#include <interfaces/idocumentcontroller.h>
#include <interfaces/ilanguagecontroller.h>
#include <interfaces/contextmenuextension.h>
K_PLUGIN_FACTORY(KDevQmlJsSupportFactory, registerPlugin<KDevQmlJsPlugin>(); )
K_EXPORT_PLUGIN(KDevQmlJsSupportFactory(
......@@ -47,11 +53,15 @@ KDevQmlJsPlugin::KDevQmlJsPlugin(QObject* parent, const QVariantList& )
: IPlugin( KDevQmlJsSupportFactory::componentData(), parent )
, ILanguageSupport()
, m_highlighting(new QmlJsHighlighting(this))
, m_refactoring(new BasicRefactoring(this))
{
KDEV_USE_EXTENSION_INTERFACE(ILanguageSupport)
CodeCompletionModel* codeCompletion = new QmlJS::CodeCompletionModel(this);
new KDevelop::CodeCompletion(this, codeCompletion, name());
auto assistantsManager = core()->languageController()->staticAssistantsManager();
assistantsManager->registerAssistant(StaticAssistant::Ptr(new RenameAssistant(this)));
}
ParseJob* KDevQmlJsPlugin::createParseJob(const IndexedString& url)
......@@ -69,6 +79,24 @@ ICodeHighlighting* KDevQmlJsPlugin::codeHighlighting() const
return m_highlighting;
}
BasicRefactoring* KDevQmlJsPlugin::refactoring() const
{
return m_refactoring;
}
ContextMenuExtension KDevQmlJsPlugin::contextMenuExtension(Context* context)
{
ContextMenuExtension cm;
EditorContext *ec = dynamic_cast<KDevelop::EditorContext *>(context);
if (ec && ICore::self()->languageController()->languagesForUrl(ec->url()).contains(language())) {
// It's a QML/JS file, let's add our context menu.
m_refactoring->fillContextMenu(cm, context);
}
return cm;
}
const QColor stringToColor(const QString& text) {
if ( text.size() < 20 ) {
QColor color;
......
......@@ -34,11 +34,15 @@ public:
virtual QString name() const;
virtual KDevelop::ICodeHighlighting* codeHighlighting() const;
virtual KDevelop::BasicRefactoring* refactoring() const;
virtual KDevelop::ContextMenuExtension contextMenuExtension(KDevelop::Context* context);
virtual KDevelop::SimpleRange specialLanguageObjectRange(const KUrl& url, const KDevelop::SimpleCursor& position);
virtual QWidget* specialLanguageObjectNavigationWidget(const KUrl& url, const KDevelop::SimpleCursor& position);
private:
KDevelop::ICodeHighlighting* m_highlighting;
KDevelop::BasicRefactoring* m_refactoring;
};
#endif // KDEVQMLJSPLUGIN_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