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 / March 2005

Tip: Looking for answers? Try searching our database.

automate the Ctl-J intellisense option in C#

Thread view: 
Enable EMail Alerts  Start New Thread
Thread rating: 
RobS - 04 Mar 2005 02:13 GMT
Hi

I'd like to write an Add-In to automatically bring up the "List Members"
(Ctl-J) popup list whenever the developer types something in a C# editor, so
for example if I type the letter s, then the member list should come up and
start matching words begining with s. I think this is something that will be
in VS 2005, but in the meantime, I'd like to write my own. I am fairly new to
writing add-ins ( have done 1 ), so could someone point me in the right
direction.

Can I do this using the normal add-in code in VS 2003 or do I need VSIP SDK?
Can I invoke the Ctl-J command in the add-in code on some key pressed event,
or is it more complex than that?, ie do I need to create my own popup list?

I just want to avoid having to press Ctl-J all the time and have the member
list come up straight away when I type.

Thanks for any help, much appreciated.
Rob.
RobS - 06 Mar 2005 13:11 GMT
For those interested, I worked out a way to do it (without VSIP). During the
OnConnection method you need to hook up one of your private methods to pick
up windows messages via SetWindowsHookEx. In your hook method you then check
for key events and if a letter or space was pressed call
(_DTE)application.ExecuteCommand( "Edit.ListMembers", "" );

In a nutshell the answer is Windows API. If anyone knows of a higher level
solution using managed C#, please post here.

Cheers,
Rob.

> Hi
>
[quoted text clipped - 15 lines]
> Thanks for any help, much appreciated.
> Rob.
Dmitry Shaporenkov - 08 Mar 2005 10:24 GMT
Hello RobS,

a higher level solution is definitely possible. Instead of Windows hooks,
you can
use VSIP in your addin (it is possible to do in add-ins, since _DTE object
can be casted
to the root VSIP interface IServiceProvider that gives you access to all
the VSIP functionality).
VSIP provides an interface IVsTextView which in turn has AddCommandFilter
method that allows you
to listen for events (or commands in other terms) generated by the text view.
One of these events is typing.

Regards,
Dmitry Shaporenkov
JetBrains, Inc
http://www.jetbrains.com
"Develop with pleasure!"

> For those interested, I worked out a way to do it (without VSIP).
> During the OnConnection method you need to hook up one of your private
[quoted text clipped - 29 lines]
>> Thanks for any help, much appreciated.
>> Rob.
RobS - 09 Mar 2005 13:41 GMT
Hi Dmitry,

thank you for your help, although I must be way out of my league here,
because I don't even know how to get a reference to an object of type
IVsTextView. The AddCommandFilter method is not static so somehow I must be
able to get an object reference to something that implements IVsTextView. Is
there a book or other reference on the net that explains these things? I'm
just starting out with this so more research is required. Hard to believe,
but I found Win API quicker to figure out.

Thanks,
Rob.

> Hello RobS,
>
[quoted text clipped - 48 lines]
> >> Thanks for any help, much appreciated.
> >> Rob.
Dmitry Shaporenkov - 09 Mar 2005 17:21 GMT
Hello RobS,

it's not surprising that you've found Win32 easier to use, since VSIP is
huge and
poor documented. However, there are docs on VSIP - they come with VSIP SDK
and
integrate into MSDN collection.

As for retrieving IVsTextView, I think you'll need to access IVsTextManager
that manages
text views. There you can find a method for getting the currently active
text view,
as well as methods for retrieving all the text views editing the specified
file (or IVsTextBuffer).

Regards,
Dmitry Shaporenkov
JetBrains, Inc
http://www.jetbrains.com
"Develop with pleasure!"

> Hi Dmitry,
>
[quoted text clipped - 65 lines]
>>>> Thanks for any help, much appreciated.
>>>> Rob.
Ed Dore [MSFT] - 10 Mar 2005 03:33 GMT
Hi Rob and Dmitry,

I think the only way you're going to get this working is to work up a hook
like Rob has. I did quite a bit of experimentation on this when the VSIP SDK
first went public over a year ago, as a lot of people wanted to know how to
intercept that autocomplete dropdown and provide or add their own items to
the list.

The problem here is that this functionality is implemented by the language
service, in that the language service adds an IOleCommandTarget into the
chain of command filters for the textview. The problem is that we couldn't
find a way that would guarantee that my IOleCommandTarget would get called
first. In my "experiment", the IOleCommandTarget added by the language
service always got the command before mine.

After messing with this for a couple weeks, I pretty much gave up. In
conversing with some of the VSIP leads soon thereafter, they pretty much
confirmed my suspicions that if you want to modify the intellisense support,
you're going to need to build a new language service. Not exactly the answer
you were probably looking for. For what it's worth, we have asked the team
to explore the possibility of extending either the VSIP and/or automation
model to allow for some customization here. But to the best of my knowledge,
it wasn't something under consideration for Whidbey.

Though there will be an event to intercept the keyboard presses in Whidbey.
So you may be able to leverage that with the next release. The ugly truth
though, is that language services and the VSIP architecture currently do not
expose any hooks into the intellisense functionality provided by the
individual language services.

Sincerely,
Ed Dore [MSFT]

This post is 'AS IS' with no warranties, and confers no rights.
Dmitry Shaporenkov - 10 Mar 2005 10:36 GMT
Hello Ed,

I agree that with AddCommandFilter interface the order of notifications of
IOleCommandTarget's
cannot be generally guaranteed. However, there is a very simple workaround
to the problem that both
autocompletion dropdowns appear - just disable the built-one programmatically
or via Tools|Options.

Regards,
Dmitry Shaporenkov

> Hi Rob and Dmitry,
>
[quoted text clipped - 31 lines]
> Ed Dore [MSFT]
> This post is 'AS IS' with no warranties, and confers no rights.

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.