[prev in list] [next in list] [prev in thread] [next in thread] 

List:       kwrite-devel
Subject:    Plugin development related questions
From:       Milian Wolff <mail () milianw ! de>
Date:       2008-09-07 15:20:28
Message-ID: 200809071720.32158.mail () milianw ! de
[Download RAW message or body]

[Attachment #2 (multipart/signed)]

[Attachment #4 (multipart/alternative)]


Hello!

To learn C++ and Qt some more, I want to write a plugin for Kate which does 
validates PHP files using the `php -l` linter. I'm a bit lost though and am not 
sure whether my ideas are even feasible:

1. How would I access the highlighter from a plugin? I thought it would be 
great to have the "bad lines" marked inside the code, i.e. assigning them the 
"Normal Text Style ->  Error". But I cannot find any examples or documentation 
on how do that. Any hints?

2. I imagine more sophisticated PHP IDEs include their own PHP parsers (see 
also 4.) to generate on-the-fly error reporting which is out of my reach. For 
the time being it would be enough to call this linter either via menu/shortcut 
or (optionally) each time the document is saved. So far I did not find a proper 
signal for that purpose, does one exist? Nearest I got was 
KTextEditor::Document::modeChanged or ::modifiedChanged. Do I have to work with 
one of those? I.e. on Plugin-Setup get current mode, then take a "was modified" 
-> "now not modified" change as "document was saved" status? Other ideas?

I'm not sure how fast the actual linting process is, but maybe later on I can 
get it somewhat optimized so that I could trigger it after a "text change". 
How often is the textChanged signal triggered? For every char that I type? Or 
is there a "buffer" which makes it trigger after I typed in some chars and 
stopped typing? If that is the case I could use that maybe...

3. Since I want to manipulate the highlighting of the current file when errors 
occur I depend on Kate, i.e. I cannot do a generic KTextEditor 
plugin/extension as far as I see. But as far as I understand it, that limits 
the plugin to Kate only. Is there a way to make this plugin "generic" enough 
so that it can be used in other Editors which use the Kate KPart?

4. Does anybody know an alternative to the above mentioned `php -l` via system 
call? Maybe there exists a C++ generic linter I did not know / find so far 
which could be used? It's a pity I cannot find in-depth documentation on how 
the validation is done in e.g. Eclipse PDT or similar.

Ok, enough. Thanks for reading so far.
-- 
Milian Wolff
mail@milianw.de
http://milianw.de

[Attachment #7 (text/html)]

<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.0//EN" \
"http://www.w3.org/TR/REC-html40/strict.dtd"> <html><head><meta name="qrichtext" \
content="1" /><style type="text/css"> p, li { white-space: pre-wrap; }
</style></head><body style=" font-family:'DejaVu Sans Condensed'; font-size:8pt; \
font-weight:400; font-style:normal;"> <p style=" margin-top:0px; margin-bottom:0px; \
margin-left:0px; margin-right:0px; -qt-block-indent:0; text-indent:0px; \
-qt-user-state:0;">Hello!</p> <p style="-qt-paragraph-type:empty; margin-top:0px; \
margin-bottom:0px; margin-left:0px; margin-right:0px; -qt-block-indent:0; \
text-indent:0px; -qt-user-state:0;"></p> <p style=" margin-top:0px; \
margin-bottom:0px; margin-left:0px; margin-right:0px; -qt-block-indent:0; \
text-indent:0px; -qt-user-state:0;">To learn C++ and Qt some more, I want to write a \
plugin for Kate which does validates PHP files using the `php -l` linter. I'm a bit \
lost though and am not sure whether my ideas are even feasible:</p> <p \
style="-qt-paragraph-type:empty; margin-top:0px; margin-bottom:0px; margin-left:0px; \
margin-right:0px; -qt-block-indent:0; text-indent:0px; -qt-user-state:0;"></p> <p \
style=" margin-top:0px; margin-bottom:0px; margin-left:0px; margin-right:0px; \
-qt-block-indent:0; text-indent:0px; -qt-user-state:0;">1. How would I access the \
highlighter from a plugin? I thought it would be great to have the "bad lines" marked \
inside the code, i.e. assigning them the "Normal Text Style -&gt;  Error". But I \
cannot find any examples or documentation on how do that. Any hints?</p> <p \
style="-qt-paragraph-type:empty; margin-top:0px; margin-bottom:0px; margin-left:0px; \
margin-right:0px; -qt-block-indent:0; text-indent:0px; -qt-user-state:0;"></p> <p \
style=" margin-top:0px; margin-bottom:0px; margin-left:0px; margin-right:0px; \
-qt-block-indent:0; text-indent:0px; -qt-user-state:0;">2. I imagine more \
sophisticated PHP IDEs include their own PHP parsers (see also 4.) to generate \
on-the-fly error reporting which is out of my reach. For the time being it would be \
enough to call this linter either via menu/shortcut or (optionally) each time the \
document is saved. So far I did not find a proper signal for that purpose, does one \
exist? Nearest I got was KTextEditor::Document::modeChanged or ::modifiedChanged. Do \
I have to work with one of those? I.e. on Plugin-Setup get current mode, then take a \
"was modified" -&gt; "now not modified" change as "document was saved" status? Other \
ideas?</p> <p style="-qt-paragraph-type:empty; margin-top:0px; margin-bottom:0px; \
margin-left:0px; margin-right:0px; -qt-block-indent:0; text-indent:0px; \
-qt-user-state:0;"></p> <p style=" margin-top:0px; margin-bottom:0px; \
margin-left:0px; margin-right:0px; -qt-block-indent:0; text-indent:0px; \
-qt-user-state:0;">I'm not sure how fast the actual linting process is, but maybe \
later on I can get it somewhat optimized so that I could trigger it after a "text \
change". How often is the textChanged signal triggered? For every char that I type? \
Or is there a "buffer" which makes it trigger after I typed in some chars and stopped \
typing? If that is the case I could use that maybe...</p> <p \
style="-qt-paragraph-type:empty; margin-top:0px; margin-bottom:0px; margin-left:0px; \
margin-right:0px; -qt-block-indent:0; text-indent:0px; -qt-user-state:0;"></p> <p \
style=" margin-top:0px; margin-bottom:0px; margin-left:0px; margin-right:0px; \
-qt-block-indent:0; text-indent:0px; -qt-user-state:0;">3. Since I want to manipulate \
the highlighting of the current file when errors occur I depend on Kate, i.e. I \
cannot do a generic KTextEditor plugin/extension as far as I see. But as far as I \
understand it, that limits the plugin to Kate only. Is there a way to make this \
plugin "generic" enough so that it can be used in other Editors which use the Kate \
KPart?</p> <p style="-qt-paragraph-type:empty; margin-top:0px; margin-bottom:0px; \
margin-left:0px; margin-right:0px; -qt-block-indent:0; text-indent:0px; \
-qt-user-state:0;"></p> <p style=" margin-top:0px; margin-bottom:0px; \
margin-left:0px; margin-right:0px; -qt-block-indent:0; text-indent:0px; \
-qt-user-state:0;">4. Does anybody know an alternative to the above mentioned `php \
-l` via system call? Maybe there exists a C++ generic linter I did not know / find so \
far which could be used? It's a pity I cannot find in-depth documentation on how the \
validation is done in e.g. Eclipse PDT or similar.</p> <p \
style="-qt-paragraph-type:empty; margin-top:0px; margin-bottom:0px; margin-left:0px; \
margin-right:0px; -qt-block-indent:0; text-indent:0px; -qt-user-state:0;"></p> <p \
style=" margin-top:0px; margin-bottom:0px; margin-left:0px; margin-right:0px; \
-qt-block-indent:0; text-indent:0px; -qt-user-state:0;">Ok, enough. Thanks for \
reading so far.</p> <p style=" margin-top:0px; margin-bottom:0px; margin-left:0px; \
margin-right:0px; -qt-block-indent:0; text-indent:0px; -qt-user-state:0;">-- </p> <p \
style=" margin-top:0px; margin-bottom:0px; margin-left:0px; margin-right:0px; \
-qt-block-indent:0; text-indent:0px; -qt-user-state:0;">Milian Wolff</p> <p style=" \
margin-top:0px; margin-bottom:0px; margin-left:0px; margin-right:0px; \
-qt-block-indent:0; text-indent:0px; -qt-user-state:0;">mail@milianw.de</p> <p \
style=" margin-top:0px; margin-bottom:0px; margin-left:0px; margin-right:0px; \
-qt-block-indent:0; text-indent:0px; \
-qt-user-state:0;">http://milianw.de</p></body></html>


["signature.asc" (application/pgp-signature)]

_______________________________________________
KWrite-Devel mailing list
KWrite-Devel@kde.org
https://mail.kde.org/mailman/listinfo/kwrite-devel


[prev in list] [next in list] [prev in thread] [next in thread] 

Configure | About | News | Add a list | Sponsored by KoreLogic