try to create a simple language plugin

Niko Sams niko.sams at gmail.com
Tue Feb 2 21:35:04 UTC 2010


On Tue, Feb 2, 2010 at 17:45, Fabian Schmitthenner
<fabian1024 at googlemail.com> wrote:
> Hi,
>
> I tried to create a simple language plugin to test and try to learn how this
> works in KDevelop 4. What I did is roughly the following:
>
> - extending my own class from ILanguageSupport and IPlugin, and making it
> accessible through KDevelop due to a .desktop-file.
> - add a class which extends from ParseJob and which is constructed in the
> createParseJob-method.
>
> So far, so good. After a bit of experimenting, the language is now loaded in
> KDevelop, when I load the first file with my extension. Then, a parse job is
> created and the run method is called.
> But when I open the same file a second time, or when I simply change the file by
> editing it, nothing happens (so neither a parse job is created nor the run
> method is called).
Hmm... No idea what's wrong here.

> Also, after having opened a file, which was alredy loaded in a previous
> instance of KDevelop, no parse job is created, and the file cannot be edited
> (it seems to be read-only).
read only? that's really strange. kdevelop can't do that.

> So, my question is, what do I do wrong? Do I have to say anything to the
> DuChain or an other instance, when I parse the file; and this parsing required
> for other things like code completion? I always thought, the DuCHain is "only"
> for serializing definitions and uses; so it wouldn't be a must-have ??
Codecompletion is duchain independet. Basically it's KTextEditor only,
just the way
how the CodeCompletionModel is registered to kate is kdevelop specific.

When parsing the file you most probably want a TopDuContext where you can add
problems (eg. parse errors) and an ParsingEnvironmentFile to track if
the file was modified.
The css (you looked at already) does have a very simple implementation
of all this.

> Second question: How can I enable code completion? I tried to extend a class
> from KTextEditor::CodeCompletionModel2, and construct an instance of
> KDevelop::CodeCompletion in the constructor of my language support, as I saw
> it in the Css-language-plugin. But the
> CodeCompletionModel2::completionInvoked-method is also never called.
hmm.. add some debug output in KDevelop::CodeCompletion, to check if the model
is registered to the view.

> Also, is there any good documentation about this stuff, because I didn't really
> find anything useful.
Unfortunately there is only a bit of api docs avaliable. But that's
still better than nothing.


Niko




More information about the KDevelop-devel mailing list