Intellisense progress

May 22, 2008 at 12:05 AM
Just reporting in on how I'm doing with Intellisense. You can access my code at:

So far I've implemented a parser for the document, which uses the BooCompiler to compile the open source file. I generate a simplified hierarchy of the open document, which stores members (classes, methods, locals etc...) against where they occur in the file. This allows me to then take the line that the user is at and locate the scope that they're in, from there I can recurse up or down the tree gathering up what should be displayed in the Intellisense.

This is a different implementation to how I initially did it in my BooPlugin. My first attempt was quite hacky, and certainly not scalable. I feel more confident in this one.

Currently supports:
  • Scope based intellisense
  • Classes and namespaces are read from the import statements and classed as local
Not yet supported/issues:
  • Deep local scope: doesn't work if you go any deeper than a method, so blocks aren't handled
  • Import statements don't have intellisense yet *
  • A block with no body makes the compiler do weird things, which is making intellisense show some generated methods (closures and modules).
* I actually implemented this last night, but I've since undone it because I think it can be done better using the tree parser.

So that's how I'm doing so far. Any thoughts or comments?
May 22, 2008 at 1:31 AM
looking good, keep up the good work!

we should organize a merge in the next few days or whenever you feel confident sharing your progress.. i'm closing to pushing my local changes ( i have some tweaks to the default project templates so that they reference Boo.Lang and Boo.Lang.Useful .. also, i'm updating the boo source to latest from boo's svn)

i prolly post on this in another thread once it's done.. but great work so far.. i've been following your commits, but havent yet had an oppurtunity to clone your repo and build it
May 22, 2008 at 3:52 AM
Jeez man, do you have a day job or what?
May 22, 2008 at 7:58 AM
Code monkey by day, legitimate programmer by night ;)

Thanks for the comments guys, I'll keep you informed as to how it's going. Might be a few more days before I get any decent time on it again.

How are we handling this merging business? Does the trunk need to be feature complete, or is it alright as long as it builds? Or maybe somewhere in-between?
May 22, 2008 at 12:43 PM
Great work, I have pulled your changes, testing it now :)

Git is pretty cool, I like the github graph thing where you can see changes in other repositories.
May 22, 2008 at 12:58 PM
I've been pleasantly surprised by git too, and github is very slick too.

If you have any thoughts you may have on how I've implemented the intellisense, I'd be interested to hear them. It's still early days yet though.
May 24, 2008 at 11:30 PM
Just a quick update on how I'm progressing.

I've done some more investigation into handling incomplete files, and badly formed files. The conclusion? Not much we can do really. It doesn't matter too much though, the other languages behave the same. The only difference is in BooLangStudio you currently can't see when your document is badly formed, so the intellisense seems broken. However, with C# you get the red squiggly lines everywhere, so the intellisense acting weird is less noticeable. I've tried to clean it up a bit by hiding any Boo generated methods, but it still gets confused to a certain extent. So it looks wrong now, but it'll be better once we get the squigglies.

I've added import support, so if you do ctrl+space after typing import, you get a list of all namespaces available. This currently evaluates referenced assemblies, NOT projects. Any namespaces that are referenced have their types imported and made available locally. This will be more useful once I get projects handled too.

Also I've added keyword support to intellisense, which means you get a "kind-of" scope sensitive keyword inclusion. So public, private, protected are only available within a class, but not in a method for example. I say kind-of because it's reliant on me telling it which keywords belong in each scope, which I haven't fully set up. I'd like to see if I can get Boo (or antlr) to tell me what keywords are allowed in the current scope, but I'm not holding my breath.

Finally, I've fixed a few bugs that were in the intellisense. It was one-off in finding what scope you're in, in some cases. Also it was including blocks in intellisense that shouldn't have been in there, try...except for example.

So far so good :)
May 26, 2008 at 11:26 PM
Another quick update for this long weekend...

Intellisense now works outside of class definitions, not a very big change but it now means it should work outside of any definitions, for example in single-file scripts. Before it was only working within scope of a declaration, so you didn't get anything in single-file scripts.

I'm now onto getting imports working fully. Like I said previously, they currently work for assembly references, but not projects. Unfortunately this is quite a big thing. Any suggestions on how to implement this are welcome.

Currently these are my thoughts:
  1. Need to get all types from current file's project.
  2. Need to get all public types from referenced projects.

How do I get types from the current file's project?
Gotta build it somehow, but there's a good chance the current file (and maybe others) will be broken due to users changes. I could use the BooCompiler and add each file in the project, and set the fail on error to false, but that seems inefficent.

How do I get types from the references?
Again, build 'em, but what if they reference the current project? Can they do that? Wouldn't that be a circular reference?

So, I think my plan is:
  1. Get intellisense working with the built assemblies from the current project and its references. Initially that'll mean you'll need to do a build first, for the intellisense to pick up changes. Most importantly though, getting this implemented first will mean we know it actually works!
  2. Create some kind of background compiler, that calls the MSBuild task to compile the project and its references. If there are any errors in the build, use any projects that compiled successfully and the last good compile for any that didn't.
  3. Hook the background compiler into the intellisense code created in stage 1.
The background compiler should get around the problem of errors in the document, hopefully.

Any thoughts?