Exemplo n.º 1
0
        internal VsVimHost(
            IVsAdapter adapter,
            ITextBufferFactoryService textBufferFactoryService,
            ITextEditorFactoryService textEditorFactoryService,
            ITextDocumentFactoryService textDocumentFactoryService,
            ITextBufferUndoManagerProvider undoManagerProvider,
            IVsEditorAdaptersFactoryService editorAdaptersFactoryService,
            IEditorOperationsFactoryService editorOperationsFactoryService,
            ISmartIndentationService smartIndentationService,
            ITextManager textManager,
            ISharedServiceFactory sharedServiceFactory,
            IVimApplicationSettings vimApplicationSettings,
            IExtensionAdapterBroker extensionAdapterBroker,
            SVsServiceProvider serviceProvider,
            ITelemetryProvider telemetryProvider)
            : base(textBufferFactoryService, textEditorFactoryService, textDocumentFactoryService, editorOperationsFactoryService)
        {
            _vsAdapter = adapter;
            _editorAdaptersFactoryService = editorAdaptersFactoryService;
            _dte                     = (_DTE)serviceProvider.GetService(typeof(_DTE));
            _vsExtensibility         = (IVsExtensibility)serviceProvider.GetService(typeof(IVsExtensibility));
            _textManager             = textManager;
            _sharedService           = sharedServiceFactory.Create();
            _vsMonitorSelection      = serviceProvider.GetService <SVsShellMonitorSelection, IVsMonitorSelection>();
            _vimApplicationSettings  = vimApplicationSettings;
            _smartIndentationService = smartIndentationService;
            _extensionAdapterBroker  = extensionAdapterBroker;

            _vsMonitorSelection.AdviseSelectionEvents(this, out uint cookie);

            InitTelemetry(telemetryProvider.GetOrCreate(vimApplicationSettings, _dte), vimApplicationSettings);
        }
Exemplo n.º 2
0
        /// <summary>
        /// Invokes SetEditLabel and checkes if the exception with the error message is caught.
        /// </summary>
        internal static bool CheckForSetEditLabelBadFileName <T>(HierarchyNode node, string badFileName, string expectedMessage)
            where T : Exception
        {
            bool             badFileNameCaught = false;
            IVsExtensibility extensibility     = node.GetService(typeof(IVsExtensibility)) as IVsExtensibility;

            extensibility.EnterAutomationFunction();
            try
            {
                node.SetEditLabel(badFileName);
            }
            catch (Exception e)
            {
                if ((e is T) && (e.Message == expectedMessage || e.Message.Contains(expectedMessage)))
                {
                    badFileNameCaught = true;
                }
            }
            finally
            {
                extensibility.ExitAutomationFunction();
            }

            return(badFileNameCaught);
        }
Exemplo n.º 3
0
        private bool CheckForSaveAsOnBadFileName <T>(IServiceProvider sp, ProjectNode project, MethodInfo saveAs, string badFileName, string expectedMessage)
            where T : Exception
        {
            bool             badFileNameCaught = false;
            IVsExtensibility extensibility     = sp.GetService(typeof(IVsExtensibility)) as IVsExtensibility;

            extensibility.EnterAutomationFunction();
            try
            {
                saveAs.Invoke(project, new object[] { badFileName });
            }
            catch (Exception e)
            {
                if ((e.InnerException is T) && (e.InnerException.Message == expectedMessage || e.InnerException.Message.Contains(expectedMessage)))
                {
                    badFileNameCaught = true;
                }
            }
            finally
            {
                extensibility.ExitAutomationFunction();
            }

            return(badFileNameCaught);
        }
Exemplo n.º 4
0
        internal VsVimHost(
            IVsAdapter adapter,
            ITextBufferFactoryService textBufferFactoryService,
            ITextEditorFactoryService textEditorFactoryService,
            ITextDocumentFactoryService textDocumentFactoryService,
            ITextBufferUndoManagerProvider undoManagerProvider,
            IVsEditorAdaptersFactoryService editorAdaptersFactoryService,
            IEditorOperationsFactoryService editorOperationsFactoryService,
            IWordUtilFactory wordUtilFactory,
            ITextManager textManager,
            ISharedServiceFactory sharedServiceFactory,
            SVsServiceProvider serviceProvider)
            : base(textBufferFactoryService, textEditorFactoryService, textDocumentFactoryService, editorOperationsFactoryService)
        {
            _vsAdapter = adapter;
            _editorAdaptersFactoryService = editorAdaptersFactoryService;
            _wordUtilFactory = wordUtilFactory;
            _dte = (_DTE)serviceProvider.GetService(typeof(_DTE));
            _vsExtensibility = (IVsExtensibility)serviceProvider.GetService(typeof(IVsExtensibility));
            _textManager = textManager;
            _sharedService = sharedServiceFactory.Create();
            _vsMonitorSelection = serviceProvider.GetService<SVsShellMonitorSelection, IVsMonitorSelection>();

            uint cookie;
            _vsMonitorSelection.AdviseSelectionEvents(this, out cookie);
        }
Exemplo n.º 5
0
        internal VsVimHost(
            IVsAdapter adapter,
            ITextBufferFactoryService textBufferFactoryService,
            ITextEditorFactoryService textEditorFactoryService,
            ITextDocumentFactoryService textDocumentFactoryService,
            ITextBufferUndoManagerProvider undoManagerProvider,
            IVsEditorAdaptersFactoryService editorAdaptersFactoryService,
            IEditorOperationsFactoryService editorOperationsFactoryService,
            ISmartIndentationService smartIndentationService,
            ITextManager textManager,
            ISharedServiceFactory sharedServiceFactory,
            IVimApplicationSettings vimApplicationSettings,
            SVsServiceProvider serviceProvider)
            : base(textBufferFactoryService, textEditorFactoryService, textDocumentFactoryService, editorOperationsFactoryService)
        {
            _vsAdapter = adapter;
            _editorAdaptersFactoryService = editorAdaptersFactoryService;
            _dte = (_DTE)serviceProvider.GetService(typeof(_DTE));
            _vsExtensibility = (IVsExtensibility)serviceProvider.GetService(typeof(IVsExtensibility));
            _textManager = textManager;
            _sharedService = sharedServiceFactory.Create();
            _vsMonitorSelection = serviceProvider.GetService<SVsShellMonitorSelection, IVsMonitorSelection>();
            _fontProperties = new TextEditorFontProperties(serviceProvider);
            _vimApplicationSettings = vimApplicationSettings;
            _smartIndentationService = smartIndentationService;

            uint cookie;
            _vsMonitorSelection.AdviseSelectionEvents(this, out cookie);
        }
Exemplo n.º 6
0
        internal VsVimHost(
            IVsAdapter adapter,
            ITextBufferFactoryService textBufferFactoryService,
            ITextEditorFactoryService textEditorFactoryService,
            ITextDocumentFactoryService textDocumentFactoryService,
            ITextBufferUndoManagerProvider undoManagerProvider,
            IVsEditorAdaptersFactoryService editorAdaptersFactoryService,
            IEditorOperationsFactoryService editorOperationsFactoryService,
            IWordUtilFactory wordUtilFactory,
            ITextManager textManager,
            ISharedServiceFactory sharedServiceFactory,
            SVsServiceProvider serviceProvider)
            : base(textBufferFactoryService, textEditorFactoryService, textDocumentFactoryService, editorOperationsFactoryService)
        {
            _vsAdapter = adapter;
            _editorAdaptersFactoryService = editorAdaptersFactoryService;
            _wordUtilFactory    = wordUtilFactory;
            _dte                = (_DTE)serviceProvider.GetService(typeof(_DTE));
            _vsExtensibility    = (IVsExtensibility)serviceProvider.GetService(typeof(IVsExtensibility));
            _textManager        = textManager;
            _sharedService      = sharedServiceFactory.Create();
            _vsMonitorSelection = serviceProvider.GetService <SVsShellMonitorSelection, IVsMonitorSelection>();

            uint cookie;

            _vsMonitorSelection.AdviseSelectionEvents(this, out cookie);
        }
        /// <summary>Initializes a new instance of the TeamExplorerIntegrator class, The constructor for the Add-in object. Place your initialization code within this method.</summary>
        public void Initialize(IVsExtensibility extensibility)
        {
            if (m_applicationObject != null)
            {
                throw new ApplicationException("TeamExplorerIntegrator already initialized");
            }

            if (extensibility == null)
            {
                throw new ArgumentNullException(nameof(extensibility));
            }

            // get IDE Globals object and DTE from that
            var dte2 = extensibility.GetGlobalsObject(null).DTE as DTE2;

            m_applicationObject = dte2;

            if (dte2 == null)
            {
                throw new ApplicationException("No DTE2");
            }

            var tfsExt = (TeamFoundationServerExt)dte2.Application.GetObject("Microsoft.VisualStudio.TeamFoundation.TeamFoundationServerExt");

            m_srcCtrlExplorer = (VersionControlExt)dte2.Application.GetObject("Microsoft.VisualStudio.TeamFoundation.VersionControl.VersionControlExt");

            //            var events = m_applicationObject.Events;

            DoConnect(tfsExt);
        }
        protected override void Initialize()
        {
            base.Initialize();
            _updateLock = new object();
            IVsExtensibility extensibility = GetService <IVsExtensibility>();

            _DTE2    = (DTE2)extensibility.GetGlobalsObject(null).DTE;
            _Version = GetVersion(_DTE2.Version);

            _Solution = GetService <SVsSolution>() as IVsSolution;
            IVsCfgProvider2 test = _Solution as IVsCfgProvider2;

            _SolutionEvents = new SolutionEvents();
            int  hr;
            uint pdwCookie;

            hr = _Solution.AdviseSolutionEvents(_SolutionEvents, out pdwCookie);
            Marshal.ThrowExceptionForHR(hr);

            _UpdateSolutionEvents = new UpdateSolutionEvents();
            var vsSolutionBuildManager = GetService <SVsSolutionBuildManager>();

            hr = (vsSolutionBuildManager as IVsSolutionBuildManager3).AdviseUpdateSolutionEvents3(_UpdateSolutionEvents, out pdwCookie);
            Marshal.ThrowExceptionForHR(hr);
            hr = (vsSolutionBuildManager as IVsSolutionBuildManager2).AdviseUpdateSolutionEvents(_UpdateSolutionEvents, out pdwCookie);
            Marshal.ThrowExceptionForHR(hr);

            if (VersionGreaterEqualTo(DTEVersion.VS15))
            {
                LoadMef();
            }
        }
        /// <summary>
        /// Default constructor of the package.
        /// Inside this method you can place any initialization code that does not require
        /// any Visual Studio service because at this point the package object is created but
        /// not sited yet inside Visual Studio environment. The place to do all the other
        /// initialization is the Initialize method.
        /// </summary>
        public TfsProjectInfoPackage()
        {
            Trace.WriteLine(string.Format(CultureInfo.CurrentCulture, "Entering constructor for: {0}", this.ToString()));

            _extensibility = (IVsExtensibility)Package.GetGlobalService(typeof(IVsExtensibility));
            _dte2          = (DTE2)_extensibility.GetGlobalsObject(null).DTE;

            _vcExt = _dte2.GetObject("Microsoft.VisualStudio.TeamFoundation.VersionControl.VersionControlExt") as VersionControlExt;

            // The SolutionEvents is an *instance* variable that must be kept around for the events to work!
            _solutionEvents               = _dte2.Events.SolutionEvents;
            _solutionEvents.Opened       += () => ReadSolutionInfo();
            _solutionEvents.AfterClosing += () => ReadSolutionInfo();
        }
Exemplo n.º 10
0
        /// <summary>
        /// Default constructor of the package.
        /// Inside this method you can place any initialization code that does not require 
        /// any Visual Studio service because at this point the package object is created but 
        /// not sited yet inside Visual Studio environment. The place to do all the other 
        /// initialization is the Initialize method.
        /// </summary>
        public TfsProjectInfoPackage()
        {
            Trace.WriteLine(string.Format(CultureInfo.CurrentCulture, "Entering constructor for: {0}", this.ToString()));

            _extensibility = (IVsExtensibility)Package.GetGlobalService(typeof(IVsExtensibility));
            _dte2 = (DTE2)_extensibility.GetGlobalsObject(null).DTE;

            _vcExt = _dte2.GetObject("Microsoft.VisualStudio.TeamFoundation.VersionControl.VersionControlExt") as VersionControlExt;

            // The SolutionEvents is an *instance* variable that must be kept around for the events to work!
            _solutionEvents = _dte2.Events.SolutionEvents;
            _solutionEvents.Opened += () => ReadSolutionInfo();
            _solutionEvents.AfterClosing += () => ReadSolutionInfo();
        }
Exemplo n.º 11
0
        internal VsVimHost(
            IVsAdapter adapter,
            ITextBufferFactoryService textBufferFactoryService,
            ITextEditorFactoryService textEditorFactoryService,
            ITextDocumentFactoryService textDocumentFactoryService,
            ITextBufferUndoManagerProvider undoManagerProvider,
            IVsEditorAdaptersFactoryService editorAdaptersFactoryService,
            IEditorOperationsFactoryService editorOperationsFactoryService,
            ISmartIndentationService smartIndentationService,
            ITextManager textManager,
            ISharedServiceFactory sharedServiceFactory,
            IVimApplicationSettings vimApplicationSettings,
            IExtensionAdapterBroker extensionAdapterBroker,
            IProtectedOperations protectedOperations,
            IMarkDisplayUtil markDisplayUtil,
            IControlCharUtil controlCharUtil,
            ICommandDispatcher commandDispatcher,
            SVsServiceProvider serviceProvider,
            IClipboardDevice clipboardDevice)
            : base(textBufferFactoryService, textEditorFactoryService, textDocumentFactoryService, editorOperationsFactoryService)
        {
            _vsAdapter = adapter;
            _editorAdaptersFactoryService = editorAdaptersFactoryService;
            _dte                     = (_DTE)serviceProvider.GetService(typeof(_DTE));
            _vsExtensibility         = (IVsExtensibility)serviceProvider.GetService(typeof(IVsExtensibility));
            _textManager             = textManager;
            _sharedService           = sharedServiceFactory.Create();
            _vsMonitorSelection      = serviceProvider.GetService <SVsShellMonitorSelection, IVsMonitorSelection>();
            _vimApplicationSettings  = vimApplicationSettings;
            _smartIndentationService = smartIndentationService;
            _extensionAdapterBroker  = extensionAdapterBroker;
            _runningDocumentTable    = serviceProvider.GetService <SVsRunningDocumentTable, IVsRunningDocumentTable>();
            _vsShell                 = (IVsShell)serviceProvider.GetService(typeof(SVsShell));
            _protectedOperations     = protectedOperations;
            _commandDispatcher       = commandDispatcher;
            _clipboardDevice         = clipboardDevice;

            _vsMonitorSelection.AdviseSelectionEvents(this, out uint selectionCookie);
            _runningDocumentTable.AdviseRunningDocTableEvents(this, out uint runningDocumentTableCookie);

            InitOutputPane();

            _settingsSync = new SettingsSync(vimApplicationSettings, markDisplayUtil, controlCharUtil, _clipboardDevice);
            _settingsSync.SyncFromApplicationSettings();
        }
Exemplo n.º 12
0
 internal VsVimHost(
     IVsAdapter adapter,
     ITextBufferFactoryService textBufferFactoryService,
     ITextEditorFactoryService textEditorFactoryService,
     ITextDocumentFactoryService textDocumentFactoryService,
     ITextBufferUndoManagerProvider undoManagerProvider,
     IVsEditorAdaptersFactoryService editorAdaptersFactoryService,
     IEditorOperationsFactoryService editorOperationsFactoryService,
     IWordUtilFactory wordUtilFactory,
     ITextManager textManager,
     SVsServiceProvider serviceProvider)
     : base(textBufferFactoryService, textEditorFactoryService, textDocumentFactoryService, editorOperationsFactoryService)
 {
     _vsAdapter = adapter;
     _editorAdaptersFactoryService = editorAdaptersFactoryService;
     _wordUtilFactory = wordUtilFactory;
     _dte = (_DTE)serviceProvider.GetService(typeof(_DTE));
     _vsExtensibility = (IVsExtensibility)serviceProvider.GetService(typeof(IVsExtensibility));
     _textManager = textManager;
 }
Exemplo n.º 13
0
        protected override void Initialize()
        {
            base.Initialize();

            _CurrentSolutionRcsType = RcsType.Unknown;

            IVsExtensibility extensibility = GetService <IVsExtensibility>();

            _DTE2 = (DTE2)extensibility.GetGlobalsObject(null).DTE;

            IVsSolution solution = GetService <SVsSolution>() as IVsSolution;
            int         hr;
            uint        pdwCookie;

            hr = solution.AdviseSolutionEvents(this, out pdwCookie);
            Marshal.ThrowExceptionForHR(hr);

            _VsShell = GetService <SVsShell>() as IVsShell;
            _VsRegisterScciProvider = GetService <IVsRegisterScciProvider>();
            _SettingsStore          = GetWritableSettingsStore();
        }