[MonoDevelop] Binding parser's Resolve method

Lluis Sanchez lluis at ximian.com
Thu Feb 2 09:20:48 EST 2006


El mar, 31-01-2006 a las 20:00 +0100, Alejandro Serrano escribió:
> Thanks for the information, but I would like to know another thing 
> (sorry if I'm a bit dummy, but it's the first time I'm trying with it). 
> I'm basing my add-in on C# one. For creating ICompilationUnit, I'm 
> subclassing AbstractClass, AbstractMethod, etc...,which take the 
> information from the internal Nemerle parser.
> The next step I'm trying is to implement Resolve. However, I dn't know 
> what to return, again, in the ResolveResult, because I've seen an IClass 
> and then members, what I don't understand very well.

Resolve() is called by the code completion engine to show the list of
members available for completion. The IClass is the class identified at
the given cursor position, and the members collection is the list of
members available for completion.

> Also, Parse works well most of the times, altough sometimes some files 
> are not parsed, or MD crashes with a GLib exception. This is the code 
> I'im using:
> 
>             try
>             {
>                     // Engine is the name of the Nemerle parser
>                     Engine eng = new Engine();
>                     Project currentProj = 
> IdeApp.ProjectOperations.CurrentSelectedProject;
>                
>                     // I add each reference
>                     foreach (ProjectReference refer in 
> currentProj.ProjectReferences)
>                         if (refer.ReferenceType != ReferenceType.Project)
>                             eng.References.Add (refer.Reference, 
> refer.Reference);
>                
>                     // I add each file contents
>                     foreach (ProjectFile file in currentProj.ProjectFiles)
>                         if (file.Name.ToUpper().EndsWith(".N"))
>                             eng.Sources.Add (file.Name, file.Data);
>                
>                     // Then, the type tree is returned, and CUFromTree 
> creates wrappers
>                     TypeTree tree = eng.GetTypeTree();
>                     return CUFromTree (tree);
>             }
>             catch
>             {
>                 return null;
>             }
> 
> Should Engine be static? Is this the best way to iterate through all 
> files in a project, or this works only for open files?

I don't know where are you using that code. You only need to implement
the Parse() method from the IParser interface. The parser service will
call this method to parse whatever is needed to parse.

Lluis.




More information about the Monodevelop-list mailing list