I have an add-in I'm developing that basically analyzes multiple projects'
codemodels in a solution.
It has a tree view and when you double-click a node representing a
codeelement, it should open the containing document of the codeelement and
navigate to the line and position it starts at. How can I determine the
codeelement, given some basic information? I don't mind iterating until I
do/don't find my item. I would just like an idea where to start.
Given the following string:
TestHGrid: M:TestHGrid.TestIHGrid.#ctor(System.Drawing.Color)
I know that this is in the project TestHGrid. Can I reference that project
using:
Dim proj As Project = Me._applicationObject.Solutions.Item("TestHGrid")
? Will that give me a reference to the project I want, or do I have to
iterate?
What if there are two projects named TestHGrid in my solution? Hadn't
thought of that until just now.
I know that this method is a constructor (In VB.Net, Sub New()) that takes a
single Color object as a parameter.
I know that it has two parent objects, TestIHGrid and TestHgrid,
respectively, which could be namespaces, classes, interfaces, modules, etc
(which I don't definitively know).
Should I just iterate over the codemodel eleemts looking for matches by name
(which if anything is overloaded, could produce duplicates), or is there a
more intuitive way?
Once I know the codeelement, it is easy enough to get the StartPoint. How do
I navigate to it, once I have that?
Any help is appreciarted.
Thanks in advance.
WALDO
Carlos J. Quintero [.NET MVP] - 07 Feb 2005 11:09 GMT
The short answer is that in VS.NET everything is recursive and therefore you
have to iterate. Even projects can be nested (Enterprise projects of the
Enterprise Edition of VS.NET come to my mind).
Projects have a UniqueName property, just in case 2 projects have the same
name.
For code elements, you must use the CodeElement.FullName, which is unique.
Once you have a CodeElement you can use either CodeElement.StartPoint or
CodeElement.GetStartPoint(part). Then you can use the EditPoint.TryToShow
method.

Signature
Carlos J. Quintero
MZ-Tools 4.0: Productivity add-ins for Visual Studio .NET
You can code, design and document much faster.
http://www.mztools.com
>I have an add-in I'm developing that basically analyzes multiple projects'
> codemodels in a solution.
[quoted text clipped - 36 lines]
>
> WALDO