Exemple #1
0
 public void Close() {
   this.Dismiss();
   if (this.methodTipWindow != null) this.methodTipWindow.SetMethodData(null);
   this.methodTipWindow = null;
 }
Exemple #2
0
 public MethodData(ServiceProvider site) {
   this.provider = site;
   this.methodTipWindow = (IVsMethodTipWindow)VsShell.CreateInstance( provider, ref VsConstants.CLSID_VsMethodTipWindow, ref VsConstants.IID_IVsMethodTipWindow, typeof(IVsMethodTipWindow));
   if (this.methodTipWindow != null) {  
     methodTipWindow.SetMethodData( this );
   }
 }
Exemple #3
0
 internal MethodData(IServiceProvider site)
 {
     this.provider = site;
     Microsoft.VisualStudio.Shell.Package pkg = (Microsoft.VisualStudio.Shell.Package)site.GetService(typeof(Microsoft.VisualStudio.Shell.Package));
     if (pkg == null)
     {
         throw new NullReferenceException(typeof(Microsoft.VisualStudio.Shell.Package).FullName);
     }
     Guid riid = typeof(IVsMethodTipWindow).GUID;
     Guid clsid = typeof(VsMethodTipWindowClass).GUID;
     this.methodTipWindow = (IVsMethodTipWindow)pkg.CreateInstance(ref clsid, ref riid, typeof(IVsMethodTipWindow));
     if (this.methodTipWindow != null)
     {
         NativeMethods.ThrowOnFailure(methodTipWindow.SetMethodData(this));
     }
 }
Exemple #4
0
 public void Dispose()
 {
     Close();
     if (this.methodTipWindow != null)
         NativeMethods.ThrowOnFailure(this.methodTipWindow.SetMethodData(null));
     this.methodTipWindow = null;
     this.provider = null;
 }
Exemple #5
0
        public void ViewCreationWithLanguage()
        {
            using (OleServiceProvider provider = OleServiceProvider.CreateOleServiceProviderWithBasicServices())
            {
                // Create a mock text buffer for the console.
                BaseMock textLinesMock = MockFactories.TextBufferFactory.GetInstance();
                // The buffer have to handle a few of connection points in order to enable the
                // creation of a Source object from the language service.
                ConnectionPointHelper.AddConnectionPointsToContainer(
                    textLinesMock,
                    new Type[] { typeof(IVsFinalTextChangeCommitEvents), typeof(IVsTextLinesEvents), typeof(IVsUserDataEvents) });

                // Create the local registry mock and add the text buffer to it.
                LocalRegistryMock mockLocalRegistry = new LocalRegistryMock();
                mockLocalRegistry.AddClass(typeof(VsTextBufferClass), textLinesMock);

                // Define the mock object for the text view.
                BaseMock textViewMock = MockFactories.TextViewFactory.GetInstance();
                // Create the connection point for IVsTextViewEvents (needed for the language service).
                ConnectionPointHelper.AddConnectionPointsToContainer(textViewMock, new Type[] { typeof(IVsTextViewEvents) });

                // Add the text view to the local registry.
                mockLocalRegistry.AddClass(typeof(VsTextViewClass), textViewMock);

                MockPackage package = new MockPackage();
                ((IVsPackage)package).SetSite(provider);
                provider.AddService(typeof(Microsoft.VisualStudio.Shell.Package), package, true);

                // Create the language service and add it to the list of services.
                PythonLanguage language = new MockLanguage();
                provider.AddService(typeof(PythonLanguage), language, true);
                language.SetSite(provider);

                // We need to add a method tip window to the local registry in order to create
                // a Source object.
                IVsMethodTipWindow methodTip = MockFactories.MethodTipFactory.GetInstance() as IVsMethodTipWindow;
                mockLocalRegistry.AddClass(typeof(VsMethodTipWindowClass), methodTip);

                // Create a mock expansion manager that is needed for the language service.
                BaseMock expansionManager = MockFactories.ExpansionManagerFactory.GetInstance();
                ConnectionPointHelper.AddConnectionPointsToContainer(expansionManager, new Type[] { typeof(IVsExpansionEvents) });
                Assembly asm        = typeof(Microsoft.VisualStudio.Package.LanguageService).Assembly;
                Type     expMgrType = asm.GetType("Microsoft.VisualStudio.Package.SVsExpansionManager");
                provider.AddService(expMgrType, expansionManager, false);

                // Add the local registry to the list of services.
                provider.AddService(typeof(SLocalRegistry), mockLocalRegistry, false);
                using (ToolWindowPane windowPane = CommandWindowHelper.CreateConsoleWindow(provider) as ToolWindowPane)
                {
                    Assert.IsNotNull(windowPane);

                    // Call the CreatePaneWindow method that will force the creation of the text view.
                    IntPtr newHwnd;
                    Assert.IsTrue(Microsoft.VisualStudio.ErrorHandler.Succeeded(
                                      ((IVsWindowPane)windowPane).CreatePaneWindow(IntPtr.Zero, 0, 0, 0, 0, out newHwnd)));

                    // Verify that the language service contains a special view for this text view.
                    FieldInfo specialSourcesField = typeof(PythonLanguage).GetField("specialSources", BindingFlags.Instance | BindingFlags.NonPublic);
                    Assert.IsNotNull(specialSourcesField);
                    Dictionary <IVsTextView, PythonSource> specialSources =
                        (Dictionary <IVsTextView, PythonSource>)specialSourcesField.GetValue(language);
                    PythonSource source;
                    Assert.IsTrue(specialSources.TryGetValue(textViewMock as IVsTextView, out source));
                    Assert.IsNotNull(source);
                    // Set ColorState to null so that Dispose will not call Marshal.ReleaseComObject on it.
                    source.ColorState = null;
                }
            }
        }