JavaScript plugin
Milian Wolff
mail at milianw.de
Wed Apr 18 15:43:04 UTC 2012
On Wednesday 18 April 2012 08:41:08 Tatsh wrote:
> Thanks for the help. I will be looking more at the current plugins then for
> help on building mine.
See below.
<snip>
> > Sounds good. One big task though might be to get the JS-specific scoping
> > right. Not sure whether that might require special changes in our
> > KDevplatform
> > code since we so far mostly follow the "usual" scoping rules that apply to
> > C-
> > like languages but also work fine for Ruby and Python so far afaiks. But
> > as
> > far as I know, JS is pretty different in that regard.
>
> I don't know if you have implemented any support for PHP's closures, but
> that also changes scope in a somewhat similar way. The only difference is
> that PHP requires the use() construct to inject variables from the
> outer-scope into the closure (and I think still requires global keyword to
> get global variables). I think if any changes need to be made to KDevelop,
> it would be effective for both JavaScript and PHP. It might even be helpful
> in two other cases: gnu99 C where a closure-like functionality exists, and
> closures in C/Objective-C/C++ (^ returntype (arg1, arg2) { /* body */ }
> syntax (also known as blocks)).
If that is all that's required, then yeah no changes are required b/c the
above is easily handled via context-imports, e.g.:
BEGIN CONTEXT A
BEGIN CONTEXT B # closure e.g.
IMPORT CONTEXT A
# now everything visible in A is also visible in B
END CONTEXT B
END CONTEXT A
I was assuming that JavaScript has more differences than that... Thinking
about it, one thing that comes to mind is esp. the handling of "this". E.g.:
var foo = someObj;
foo.bar = function() {
// afaiks, this == foo here, or at least you can
// call this.bar and that is the same as foo.bar
}
And what about prototypes? :) We'll have to see how our architecture supports
this, but we can patch it as we need to add support for anything you need.
Anyhow, I think the first hurdle will be to get a proper parser ready. Once we
have that, the rest shouldn't be too hard. So... create a git repo somewhere
and start playing around. Once you found a feasible solution to create an AST
from any *.js file, tell us and we can continue with the actual integration
into a KDevelop language plugin. Imo you shouldn't worry too much about the
existing language plugins right now.
Cheers
--
Milian Wolff
mail at milianw.de
http://milianw.de
-------------- next part --------------
A non-text attachment was scrubbed...
Name: signature.asc
Type: application/pgp-signature
Size: 198 bytes
Desc: This is a digitally signed message part.
URL: <http://mail.kde.org/pipermail/kdevelop-devel/attachments/20120418/81dece80/attachment.sig>
More information about the KDevelop-devel
mailing list