I am looking into the KDevelop PHP plugin for ideas on how to properly begin a plugin. I'd like to implement JavaScript support, including code completion, type detection (via annotations and literal/new notation), 'this' detection, etc.<div>
<br></div><div>I haven't been able to find any documentation on developing a plugin and there is not a KDevelop template.<div><br></div><div>Note about my system: using Gentoo generally stable amd64; currently have KDE 4.8.2 installed via Portage.<br>
<div><br></div><div>A few questions:</div><div>- Which KDevelop version should I use?</div></div></div><div>- Can I use external (differently licensed) sources for a parser such as V8's?</div><div>- Does KDE have a JavaScript parser to build off of?</div>
<div>- Has anyone began such a project?</div><div><br></div><div>If the last question's answer is no, my idea is to make a primitive parser for the only absolutely necessary 'must be parsed by C++' part (primitives like keywords, strings, and numbers). Once at that point, if there is something that can run JavaScript (KJS?), then plain old JS can parse things like Objects, Arrays, and other types (similar to parsing JSON but a bit more complicated). This is similar to how Chrome parses JavaScript, and probably makes for easier maintenance.</div>
<div><br></div><div>The 'Class list' tool view would display any globally namespaced objects. JSDoc annotations would be required for this to work generally. Example:</div><div><br></div><div>/**</div><div> * @constructor</div>
<div> */</div><div>var soCalledClass = function () {};</div><div>/**</div><div> * @type number</div><div> * @const</div><div> */</div><div>var CONSTANT_VALUE = 1; // on the list as a, warning (red underline) if this gets changed in code somewhere because @const</div>
<div>/**</div><div> * @namespace My description.</div><div> * @name namespace</div><div> */</div><div>soCalledClass.namespace = {}; // shown after expanding the list</div><div>// Inheritance detection (shows up as separate item and under the soCalledClass namespace):</div>
<div>/**</div><div> * @constructor</div><div> * @augments soCalledClass</div><div> */</div><div>var inherits = function () {}</div><div>inherits.prototype = new soCalledClass();</div><div><br></div><div>ECMA3 with optional JSDoc annotations would be the first supported version. And then of course ECMA5 and 6, including strict.</div>
<div><br></div><div>After that, 'externs' files define things like what's in a browser environment, what's available in node, etc. If you are familiar with Closure Compiler, I am thinking to use their externs files (which include nearly everything in all common browsers, including proprietary extensions). This is similar to how phpfuncs.php includes all function documentation in the PHP plugin.</div>
<div><br></div><div>After that really works, another great thing would be Closure Compiler integration, with parsing of the warnings and errors, and easy GUI-based specification of arguments to the compiler.</div><div><br>
</div><div>Thanks</div><div>Andrew</div>