KDevelop5/LanguagePlugin: Difference between revisions
Appearance
| Line 23: | Line 23: | ||
explicit KDevTestLangPlugin( QObject* parent, const QVariantList& args = QVariantList() ); | explicit KDevTestLangPlugin( QObject* parent, const QVariantList& args = QVariantList() ); | ||
virtual KDevelop::ParseJob* createParseJob(const | virtual KDevelop::ParseJob* createParseJob(const KDevelop::IndexedString& url); | ||
virtual QString name() const; | virtual QString name() const; | ||
}; | }; | ||
| Line 41: | Line 41: | ||
// note: "kdevtestlangsupport" must be the same as you used in X-KDE-PluginInfo-Name! | // note: "kdevtestlangsupport" must be the same as you used in X-KDE-PluginInfo-Name! | ||
K_EXPORT_PLUGIN(KDevTestLangSupportFactory(KAboutData("kdevtestlangsupport","kdevtestlang", ki18n("TestLanguage Support"), "0.1", ki18n("Support for Some Test Language"), KAboutData::License_GPL))) | K_EXPORT_PLUGIN(KDevTestLangSupportFactory(KAboutData("kdevtestlangsupport","kdevtestlang", ki18n("TestLanguage Support"), "0.1", ki18n("Support for Some Test Language"), KAboutData::License_GPL))) | ||
using namespace KDevelop; | |||
KDevTestLangPlugin::KDevTestLangPlugin(QObject* parent, const QVariantList& ) | KDevTestLangPlugin::KDevTestLangPlugin(QObject* parent, const QVariantList& ) | ||
: IPlugin( KDevTestLangSupportFactory::componentData(), parent ) | |||
, | , ILanguageSupport() | ||
{ | { | ||
// NOTE: this is important! | // NOTE: this is important! | ||
KDEV_USE_EXTENSION_INTERFACE( | KDEV_USE_EXTENSION_INTERFACE(ILanguageSupport) | ||
} | } | ||
ParseJob* KDevTestLangPlugin::createParseJob(const IndexedString& url) | |||
{ | { | ||
return new TestLangParseJob(url, this); | return new TestLangParseJob(url, this); | ||
Revision as of 23:47, 24 October 2012
.desktop file
In order to find your language support plugin, KDE needs a .desktop file with some meta information.
X-KDE-Library=...this must be the same as the name of your library, i.e. look into theCMakeLists.txtfor yourkde4_add_pluginline and use the same nameX-KDE-PluginInfo-Name=...this must be the same as the name of your plugin in the code, i.e. look into your main plugin .cpp file and find theK_EXPORT_PLUGINline, more exactly the first argument to theKAboutData.
After installing your plugin, make sure to run kbuildsycoca4. For testing, try duchainify or ktraderclient.
the plugin
A basic plugin's header looks like this:
#include <interfaces/iplugin.h>
#include <language/interfaces/ilanguagesupport.h>
class KDevTestLangPlugin : public KDevelop::IPlugin, public KDevelop::ILanguageSupport
{
Q_OBJECT
Q_INTERFACES( KDevelop::ILanguageSupport )
public:
explicit KDevTestLangPlugin( QObject* parent, const QVariantList& args = QVariantList() );
virtual KDevelop::ParseJob* createParseJob(const KDevelop::IndexedString& url);
virtual QString name() const;
};
An implementation could look like this:
#include "kdevtestlangplugin.h"
#include <KPluginFactory>
#include <KAboutData>
#include "testlangparsejob.h"
K_PLUGIN_FACTORY(KDevTestLangSupportFactory, registerPlugin<KDevTestLangPlugin>(); )
// note: "kdevtestlangsupport" must be the same as you used in X-KDE-PluginInfo-Name!
K_EXPORT_PLUGIN(KDevTestLangSupportFactory(KAboutData("kdevtestlangsupport","kdevtestlang", ki18n("TestLanguage Support"), "0.1", ki18n("Support for Some Test Language"), KAboutData::License_GPL)))
using namespace KDevelop;
KDevTestLangPlugin::KDevTestLangPlugin(QObject* parent, const QVariantList& )
: IPlugin( KDevTestLangSupportFactory::componentData(), parent )
, ILanguageSupport()
{
// NOTE: this is important!
KDEV_USE_EXTENSION_INTERFACE(ILanguageSupport)
}
ParseJob* KDevTestLangPlugin::createParseJob(const IndexedString& url)
{
return new TestLangParseJob(url, this);
}
QString KDevTestLangPlugin::name() const
{
// some unique id for your language
return "testlang";
}