tag:blogger.com,1999:blog-6917071644715743308.post4136814763499313698..comments2023-09-01T05:42:40.590-07:00Comments on Contraptions for programming: Better JavaScript content assist in Eclipse OrionAndrew Eisenberghttp://www.blogger.com/profile/07897697507691706588noreply@blogger.comBlogger9125tag:blogger.com,1999:blog-6917071644715743308.post-20040659568970980572013-07-23T01:14:47.103-07:002013-07-23T01:14:47.103-07:00when sometimes we press the . operator or use ctrl...when sometimes we press the . operator or use ctrl+space key combination in JSP/Javascript pages, Eclipse won't suggest anything but at times the java EE version does show the options. I just learnt about some plugins from <a href="http://www.javaexperience.com/eclipse-java-and-web-content-assist/" rel="nofollow">eclipse content assist</a>Sandeephttps://www.blogger.com/profile/14459583259453333684noreply@blogger.comtag:blogger.com,1999:blog-6917071644715743308.post-12260855319731796002013-04-09T15:50:01.984-07:002013-04-09T15:50:01.984-07:00The range is the source locations of the ast node....The range is the source locations of the ast node. It is a two element array corresponding to the start and end locations of the node.Andrew Eisenberghttps://www.blogger.com/profile/07897697507691706588noreply@blogger.comtag:blogger.com,1999:blog-6917071644715743308.post-21347614995093483882013-04-09T13:06:15.273-07:002013-04-09T13:06:15.273-07:00ok, and what is the "range" object used ...ok, and what is the "range" object used for?<br />Thanks again :)<br />Mattan. Anonymoushttps://www.blogger.com/profile/02358615864438622951noreply@blogger.comtag:blogger.com,1999:blog-6917071644715743308.post-53449450267868351172013-04-09T09:17:44.526-07:002013-04-09T09:17:44.526-07:00I see what you're asking. To oversimplify, th...I see what you're asking. To oversimplify, the inferencer uses a visitor pattern to visit the AST of the JS file. We use a stack to keep track of the current scope. Every time we visit a new scope, we push the scope onto the stack. When we leave the scope, it gets popped from the stack. And to perform a lookup to find the type of a variable, we peak at the top of the scope stack to see if it contains the variable. If not, we recursively look through all items in the stack until we find the stack or we look at all elements.Andrew Eisenberghttps://www.blogger.com/profile/07897697507691706588noreply@blogger.comtag:blogger.com,1999:blog-6917071644715743308.post-14420256956011038392013-04-08T23:49:34.121-07:002013-04-08T23:49:34.121-07:00Andrew,
Thanks for the quick answer! I'll giv...Andrew, <br />Thanks for the quick answer! I'll give a more specific example:<br />Let's say this is the code I have:<br /><br />var test = 1;<br />function gcd(a, b) {<br /> function abc(){<br /> var test = 1; <br /> }<br /> return (b === 0) ? a : gcd(b, a % b); <br /> // And in the next line I ask for intelisence for <br /> // anything starting with ab<br /> ab (*)<br /> // + ctrl + space <br />}<br /><br />how does the parser know that line (*) is in the scope of the function gcd, leading it to propose function abc?<br />Thanks again!Anonymoushttps://www.blogger.com/profile/02358615864438622951noreply@blogger.comtag:blogger.com,1999:blog-6917071644715743308.post-10058061764247653032013-04-08T11:45:22.989-07:002013-04-08T11:45:22.989-07:00@Mattan, the piece that you are interested in is a...@Mattan, the piece that you are interested in is an AST visitor implemented in the esprimaVisitor.js file in the scripted/orion code base. This component knows how to walk a parse tree of a js file. And in the esprimaJsContentAssistPlugin.js file, there is logic that generates proper scoping information. Not sure if this answers your question, so be more specific if you need more help.Andrew Eisenberghttps://www.blogger.com/profile/07897697507691706588noreply@blogger.comtag:blogger.com,1999:blog-6917071644715743308.post-91076364812124376902013-04-08T06:38:18.708-07:002013-04-08T06:38:18.708-07:00Hey,
I'm trying to understand deeper into the ...Hey,<br />I'm trying to understand deeper into the parser- where exactly is the scope calculated? <br />How does the plugin know what scope the cursor is on, so that it will fetch only relavent proposals?<br />Regards,<br />Mattan. Anonymoushttps://www.blogger.com/profile/02358615864438622951noreply@blogger.comtag:blogger.com,1999:blog-6917071644715743308.post-42236107496686379622012-06-05T20:49:28.927-07:002012-06-05T20:49:28.927-07:00Great job! This plugin makes a lot of javascripter...Great job! This plugin makes a lot of javascripter happy.<br />I will try to port your eclipse plugin to vim plugin.自由国度https://www.blogger.com/profile/09297383113181994623noreply@blogger.comtag:blogger.com,1999:blog-6917071644715743308.post-1914871218106504862012-02-27T06:27:14.287-08:002012-02-27T06:27:14.287-08:00Very cool Andrew. I have your plugin installed and...Very cool Andrew. I have your plugin installed and it's working great so far. It's a big step up from the basic content assist we had in Orion so far, and a much better base to build on.John Arthornehttps://www.blogger.com/profile/09728053655010911018noreply@blogger.com