Home | Contact Us | FAQ | Search & Site Map | Link to Us
Sign In | Join | Other 45 Sites in Network
HomeAnnouncementsFree MagazinesWhite PapersSubmit Content
Discussion GroupsASP.NETWindows FormsLanguages.NET FrameworkVisual Studio.NET
Articles.NET FrameworkASP.NETToolsWindows Forms
.NET DirectoryOpen Source ProjectsUser GroupsWeb Resources
Related Topics
Visual Basic 6SQL ServerMS AccessOther DB ProductsMS Server ProductsMore Topics ...

.NET Forum / Visual Studio.NET / Extensibility / September 2005

Tip: Looking for answers? Try searching our database.

Project containing file for LanguageService.ParseSource()?

Thread view: 
Enable EMail Alerts  Start New Thread
Thread rating: 
Sporky - 05 Sep 2005 15:09 GMT
Hello.  When I get a ParseSource() call on my implementation of
LanguageService, how do I get the project which contains that file?  Do I
have to do a brute force search the the solution items, or is there a better
way?

Thanks.

Dave
Oliver Sturm - 05 Sep 2005 16:08 GMT
>Hello.  When I get a ParseSource() call on my implementation of
>LanguageService, how do I get the project which contains that file?  Do I
>have to do a brute force search the the solution items, or is there a
>better
>way?

Documentation says that the assumption is that your LanguageService will
parse the source directly from the Text property of the ParseRequest you
get passed in. Apparently you can access the file information via the
FileName property (I haven't tried this, but docs say so), but there's no
specific method available to query further information about that file.

Generally, you should be able to use the method
EnvDTE.Solution.FindProjectItem to query a ProjectItem from a filename,
and the project item in turn has a property ContainingProject that should
tell you the project it belongs to.

Hope this helps.

               Oliver Sturm
Signature

Expert programming and consulting services available
See http://www.sturmnet.org (try /blog as well)

Sporky - 05 Sep 2005 16:50 GMT
Thanks.  That got me part of the way there, but I still seem to be missing
something.  I want to try to get Intellisense working, and for that I need
the references.  The Object property on ContainingObject holds an instance of
my implementation of ProjectNode.  I see methods on ProjectNode for managing
references, but nothing to get the list of references.  Am I blind?

Dave

> >Hello.  When I get a ParseSource() call on my implementation of
> >LanguageService, how do I get the project which contains that file?  Do I
[quoted text clipped - 16 lines]
>
>                 Oliver Sturm
Oliver Sturm - 05 Sep 2005 17:37 GMT
>Thanks.  That got me part of the way there, but I still seem to be missing
>something.  I want to try to get Intellisense working, and for that I need
[quoted text clipped - 3 lines]
>managing
>references, but nothing to get the list of references.  Am I blind?

You should be able to get a VSProject interface from the Project.Object
property, which in turn has a References property. See
http://shrinkster.com/7ua and http://shrinkster.com/7ub (MSDN).

               Oliver Sturm
Signature

Expert programming and consulting services available
See http://www.sturmnet.org (try /blog as well)

Sporky - 05 Sep 2005 19:48 GMT
I think I see why I'm confused.  I followed one of the VSIP MPF examples,
which created a new project by inheriting from the ProjectNode class.  Since
that's what I have registered as my project type, that's what I get from
Project.Object.  ProjectNode does not implement the VSProject interface, so
no References property.

It seems like I've missed a step somewhere, based on the code sample I used
as a template.  My version of the documentation is blank under the section
"How to: Create a Project Using the MPF Classes".  Is there something
different I should be doing to make a new project type?  Thanks.

> You should be able to get a VSProject interface from the Project.Object
> property, which in turn has a References property. See
> http://shrinkster.com/7ua and http://shrinkster.com/7ub (MSDN).
>
>                 Oliver Sturm
Oliver Sturm - 05 Sep 2005 20:55 GMT
>I think I see why I'm confused.  I followed one of the VSIP MPF examples,
>which created a new project by inheriting from the ProjectNode class.  
>Since
>that's what I have registered as my project type, that's what I get from
>Project.Object.  ProjectNode does not implement the VSProject interface, so
>no References property.

I'm sorry, it's me who got you confused here. I was looking at the wrong
kind of documentation for your purpose. Implementing the project type by
deriving from ProjectNode is the correct thing to do and in that case
there are three interfaces IVsProject, IVsProject2 and IVsProject3, none
of which allow access to the references.

I've been looking around a bit more, but I'm sorry to say I haven't found
a final solution to your problem. One approach I looked at was to use the
node hierarchy to find the nodes for the references - that's how the MPF
classes do it themselves in places. For example, you can find the node
that contains the reference nodes like this:

  ReferenceContainerNode node = ProjectMgr.FindChild("References") as ReferenceContainerNode

But I wasn't able to find a reliable way to access the child nodes of a
given node - the node list seems to be implemented as a linked list, but
without any kind of abstraction, it's dealt with in various utility
methods of the HierarchyNode class.

The other thing I found is that the ProjectNode has an internal Hashtable
field called libraryList, which stores all the referenced assemblies - but
it's private and you could get only the assemblies names from it, none of
the options that usually go with a complete reference.

I hope someone else will be able to shed some light on this, I'm sure
we're missing something obvious here :-) Or maybe part of the problem is
that I'm only using the beta 2 drop, there are a few newer drops
available...

>It seems like I've missed a step somewhere, based on the code sample I used
>as a template.  My version of the documentation is blank under the section
>"How to: Create a Project Using the MPF Classes".  Is there something
>different I should be doing to make a new project type?  Thanks.

You should probably install a documentation update, the docs I have show a
lot of descriptional text for that topic.

               Oliver Sturm
Signature

Expert programming and consulting services available
See http://www.sturmnet.org (try /blog as well)


Free Magazines

Get these publications absolutely FREE for up to 12 months. There are no hidden fees and no obligation. Simply choose a title, complete the application form and submit it. Read more ...

Oracle MagazineNetwork ComputingComputer WorldBio-IT WorldeWeekInformation WeekInfosecurity
 
Sign In
Join
My Latest Posts
My Monitored Threads
My Blog
My Photo Gallery
My Profile
My Homepage

Start New Thread
Enable EMail Alerts
Rate this Thread



©2008 Advenet LLC   Privacy Policy - Terms of Use
This website includes both content owned or controlled by Advenet as well as content owned or controlled by third parties.