Visual Studio 2010 Extensions

て烟熏妆下的殇ゞ 提交于 2019-12-06 09:54:59

问题


I'm writing my own abstract extension for Visual Studio 2010, it makes similary functionality as Ook Language Integration.

I have a question, is it possibly to mix my own AutoCompletion with standart C++ autocompletion of VS? How to do it? Is in need to use libraries of VS and call some methods?


回答1:


This is a very good example about adding features to C# intellisense.

First of all you should capture the completionSession and use it.

Like this snippet, but in C++

    [Export(typeof(IIntellisensePresenterProvider))]
    [ContentType("text")]
    [Order(Before = "Default Completion Presenter")]
    [Name("Object Intellisense Presenter")]
    internal class IntellisensePresenterProvider : IIntellisensePresenterProvider
    {
        [Import(typeof(SVsServiceProvider))]
        IServiceProvider ServiceProvider { get; set; }

        #region Try Create Intellisense Presenter

        #region Documentation
        /// <summary>
        /// Inject the IntelliSense presenter
        /// </summary>
        /// <param name="session"></param>
        /// <returns></returns>
        #endregion // Documentation
        public IIntellisensePresenter TryCreateIntellisensePresenter(IIntellisenseSession session)
        {
            #region Validation (is C#)

            const string CSHARP_CONTENT = "CSharp";
            if (session.TextView.TextBuffer.ContentType.TypeName != CSHARP_CONTENT)
            {
                return null;
            }

            #endregion // Validation

            ICompletionSession completionSession = session as ICompletionSession;
            if (completionSession != null)
            {
                var presenter = new IntelliSenseViewModel(ServiceProvider, completionSession);
                return presenter;
            }
            return null;
        }

        #endregion // Try Create Intellisense Presenter
    }

Hope helps!



来源:https://stackoverflow.com/questions/5349216/visual-studio-2010-extensions

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!