Citation:
Features such as syntax highlighting, red squiggly underlines and autocompletion require that you lexically and semantically parse the source code. Lexical parsing means reading the raw text stream and breaking it up into a stream of tokens; a semantic parser then reads those tokens and figures out what they mean in context, emitting a code DOM (called an Abstract Syntax Tree). The final step is to resolve the nodes in the AST into .NET types and members.
Much of the heavy lifting is done by NRefactory and SharpDevelop.Dom, written by Daniel Grunwald, Andrea Paatz, and Mike Krüger (as part of the SharpDevelop project). These are fantastic libraries: writing a fully-featured lexical and semantic language parser in itself is no easy task; writing a well-structured type resolution DOM that can correctly handle the nuances of C# 3.0 type inference is a major achievement. It certainly bodes well for SharpDevelop 3.0 (currently in beta).