[Monodevelop-devel] Some new DOM guidance

Mike Krüger mkrueger at novell.com
Mon Jul 28 18:23:16 EDT 2008


Hi

Ok. I tried to make it easy to convert old dom code over to new dom
code.


Basically it's:

not longer:
using MonoDevelop.Projects.Parser;

instead:
using MonoDevelop.Projects.Dom;

not longer: IClass instead: IType

Parser registration (with the addin tree):

<Extension path = "/MonoDevelop/Ide/DomParser">
	<Class class = "MonoDevelop.CSharpBinding.DomParser" />
</Extension>

The parser must extend the MonoDevelop.Projects.Dom.Parser.IParser
interface. I recommend inheriting from
MonoDevelop.Projects.Dom.Parser.AbstractParser which makes changes in
the interface more easy.

Generally I tried to move functions from some services to the objects
directly. For example - monodoc documentation could be now accessed by
System.Xml.XmlNode GetMonodocDocumentation (); instead of the
documentation service. Or the icon could be get by
string StockIcon { get; } instead of using the IconService. I'll add
more functions to the dom. The goal is to make it easier to find
functions and bring back some responsibility to the objects.


GETTING PARSE INFOS:

MonoDevelop.Ide.Gui.Document

now contains:
public ICompilationUnit CompilationUnit {
	get;
}
In former versions the document contained only the text contents, now it
contains the most recent parse information too.


For the rest - look at:
MonoDevelop.Projects.Dom.Parser.ProjectDomService 

There you have functions like:
IParser GetParserByMime (string mimeType);
IParser GetParserByFileName (string fileName);

ICompilationUnit Parse (Project project, 
                        string fileName, 
                        string mimeType)


For projects:
ProjectDom GetDatabaseProjectDom (Project project);
The ProjectDom contains the project parser info (was ParserContext  in
former versions)

The Projects will contain the ProjectDom as property, but currently I
had already too many name clashes. After removing the old infrastructure
I'll do some refactorings to make the access easier. (I could need some
input here - maybe someone has new ideas what's missing. Like
the CompilationUnit inside the Document).

The project dom contains some functions old dom users will find very
familiar (like GetNamespaceContents, SearchType).


I've converted much old code - most is done with renaming and switch
over the usings. If you've more questions feel free to ask.

Regards
Mike
















More information about the Monodevelop-devel-list mailing list