JavaScript plugin

Tatsh ddrtist at gmail.com
Wed Apr 18 01:58:54 UTC 2012


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.

I haven't been able to find any documentation on developing a plugin and
there is not a KDevelop template.

Note about my system: using Gentoo generally stable amd64; currently have
KDE 4.8.2 installed via Portage.

A few questions:
- Which KDevelop version should I use?
- Can I use external (differently licensed) sources for a parser such as
V8's?
- Does KDE have a JavaScript parser to build off of?
- Has anyone began such a project?

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.

The 'Class list' tool view would display any globally namespaced objects.
JSDoc annotations would be required for this to work generally. Example:

/**
 * @constructor
 */
var soCalledClass = function () {};
/**
 * @type number
 * @const
 */
var CONSTANT_VALUE = 1; // on the list as a, warning (red underline) if
this gets changed in code somewhere because @const
/**
 * @namespace My description.
 * @name namespace
 */
soCalledClass.namespace = {}; // shown after expanding the list
// Inheritance detection (shows up as separate item and under the
soCalledClass namespace):
/**
 * @constructor
 * @augments soCalledClass
 */
var inherits = function () {}
inherits.prototype = new soCalledClass();

ECMA3 with optional JSDoc annotations would be the first supported version.
And then of course ECMA5 and 6, including strict.

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.

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.

Thanks
Andrew
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://mail.kde.org/pipermail/kdevelop-devel/attachments/20120417/a27171cf/attachment.html>


More information about the KDevelop-devel mailing list