Progress on ASP.NET Source Editing

I have been making good progress on ASP.NET source editing, as evidenced by the following screenshot:

Screenshot of a semi-transparent code completion window.

Yes, that is code folding, error underlining, and a path bar. However, the document outline pad isn't hooked up yet for ASP.NET[Update 2008/5/2: outlining implemented].

I've been getting a lot of practical experience with handwritten parsers recently. The ASP.NET addin has two parsers; the first builds a full DOM, and the second provides document path information very efficiently.

The path parser is designed to accept individual characters as the user types them, instantly providing information about the current context. This is very useful for code completion and smart indentation, and is obviously near-ideal for the path bar too. It's about as robust as I can make it, recovering effectively from most errors. However, I wrote a state-based XML parser where each state was a path object, which has proved rather unwieldy to extend cleanly for ASP.NET, so this may well get replaced soon.

The DOM parser was originally written for the CodeBehind field generation. It's based on Mono's ASP.NET tokeniser, which makes it rather fragile; when it encounters a syntax error, it dies. For its original use, this is sensible behaviour, but for a text editor it needs to be much more robust, so I intend to modify the path parser to build this DOM instead.

I plan to roll a lot of this back into the XML addin, which will provide a solid base for XAML completion for Moonlight apps.

Comments

wow

once again wow... I can't wait for this to land in monodevelop

color scheme

This may seem like a silly question, but how did you get the background color like that? I am trying to make MonoDevelop have a black background with green text for C# files, but only the text I type has the background I want; I can't get the entire window background to be black. Is there something I'm missing? Thanks!

Colour Schemes

It's the "Oblivion" colour scheme. You can find it in the Syntax Highlighting panel in the Text Editor section of the Edit->Preferences dialog. Currently the colour schemes are compiled into Mono.TextEditor.dll as resources so are nontrivial to change.

[N.B. the above applies to MD SVN, not 1.0. Colour schemes are possible with 1.0, but only if it's compiled with GtkSourceview 2 support, which is nonstandard.]

Neat!

Looks very impressive. The really interesting question now is: How does it perform? Is it snappy and fast or do you have to wait (like in Visual Studio) up to several seconds (especially in large documents) for the tokeniser to get up to speed with your typing? And is something like this planned for other client-side file types (.js, .css) as well?

It's pretty snappy once it gets going

The code completion tokeniser is designed to as unobtrusive as possible. I'll probably blog about the architecture at some point after I've finished all the refactoring. But to summarise: it's a character-by-character zero-lookahead tokeniser that accepts each character as you type it. Snapshots of state are stored so that going backwards isn't too painful; the only time you will notice performance degradation is when moving jumping several thousand lines, and even then it should only be half a second or so of lag.

Selecting text blocks backwards feels laggy because of the tokeniser, so I'll probably have to introduce a timeout for that. That particular update is only happening for the path bar, which doesn't really need to be updated more than one a second or so.

At the moment it freezes for a few seconds when completion is first triggered, when it first loads the completion data. However, I'm probably going to preload that in a thread.

I'm not sure if we'll ever have the resources to do decent JS completion. However, this Summer of Code I'm mentoring Andreas Louca to add CSS completion and graphical editing/previewing, and that look pretty exciting.