Beispiel #1
0
    public void Close() {
      if (this.textLinesEventsCookie != 0) 
        VsShell.DisConnect(this.textLines, ref VsConstants.IID_IVsTextLinesEvents, this.textLinesEventsCookie );
      if (this.textChangeCommitEventsCookie != 0) 
        VsShell.DisConnect( this.textLines, ref VsConstants.IID_IVsFinalTextChangeCommitEvents, this.textChangeCommitEventsCookie );

      this.statusBar = null;
      this.methodData.Close();
      this.methodData = null;
      this.completionSet.Close();
      this.completionSet = null;
      this.taskProvider.Close();
      this.taskProvider = null;
      this.service = null;
      this.colorizer = null;      
    }
Beispiel #2
0
    public Source(LanguageService service, IVsTextLines textLines, Colorizer colorizer) {
      this.service = service;
      this.textLines = textLines;
      this.colorizer = colorizer;
      this.taskProvider = new TaskProvider(service.site); // task list
      this.completionSet = this.GetCompletionSet();      
      this.methodData = this.GetMethodData();
      this.colorState = (IVsTextColorState)textLines;

      Guid statusBarGuid = typeof(VsShellInterop.IVsStatusbar).GUID;
      this.statusBar = (VsShellInterop.IVsStatusbar)service.site.QueryService(statusBarGuid, typeof(VsShellInterop.IVsStatusbar));

      service.GetCommentFormat(ref commentInfo);

      // track source changes
      if (service.Preferences.EnableCodeSenseFastOnLineChange) {
        textChangeCommitEventsCookie = VsShell.Connect( textLines, (IVsFinalTextChangeCommitEvents)this, ref VsConstants.IID_IVsFinalTextChangeCommitEvents);
      }
      this.textLinesEventsCookie = VsShell.Connect( textLines, (IVsTextLinesEvents)this, ref VsConstants.IID_IVsTextLinesEvents);

    }
Beispiel #3
0
    public void Close(){
      if (this.textLinesEventsCookie != 0) 
        VsShell.DisConnect(this.textLines, ref VsConstants.IID_IVsTextLinesEvents, this.textLinesEventsCookie );
      if (this.textChangeCommitEventsCookie != 0) 
        VsShell.DisConnect(this.textLines, ref VsConstants.IID_IVsFinalTextChangeCommitEvents, this.textChangeCommitEventsCookie );

#if WHIDBEY
      // release the task manager
      if (this.taskManager != null) {
        ITaskManagerFactory taskManagerFactory = (ITaskManagerFactory)service.site.GetService(typeof(ITaskManagerFactory));
        if (taskManagerFactory != null) {
          taskManagerFactory.ReleaseSharedTaskManager(this.taskManager);
        }
      }
      this.taskManager = null;
#endif

      this.statusBar = null;
      this.methodData.Close();
      this.methodData = null;
      this.completionSet.Close();
      this.completionSet = null;
      this.taskProvider.Dispose();
      this.taskProvider = null;
      this.service = null;
      this.colorizer = null;      
    }
Beispiel #4
0
    public Source(LanguageService service, IVsTextLines textLines, Colorizer colorizer){
      this.service = service;
      this.textLines = textLines;
      this.colorizer = colorizer;
      this.taskProvider = new TaskProvider(service.site); // task list
      this.completionSet = this.GetCompletionSet();      
      this.methodData = this.GetMethodData();
      this.colorState = (IVsTextColorState)textLines;

      Guid statusBarGuid = typeof(VsShellInterop.IVsStatusbar).GUID;
      this.statusBar = (VsShellInterop.IVsStatusbar)service.site.QueryService(statusBarGuid, typeof(VsShellInterop.IVsStatusbar));
      
      this.commentInfo = new CommentInfo();
      service.GetCommentFormat(this.commentInfo);

      // track source changes
      if (service.Preferences.EnableCodeSenseFastOnLineChange){
        textChangeCommitEventsCookie = VsShell.Connect(textLines, (IVsFinalTextChangeCommitEvents)this, ref VsConstants.IID_IVsFinalTextChangeCommitEvents);
      }
      this.textLinesEventsCookie = VsShell.Connect(textLines, (IVsTextLinesEvents)this, ref VsConstants.IID_IVsTextLinesEvents);
      this.SetDirty();

#if WHIDBEY
      // create a task manager
      if (taskManager == null) {
        ITaskManagerFactory taskManagerFactory = (ITaskManagerFactory)(service.site).GetService(typeof(ITaskManagerFactory));
        if (taskManagerFactory != null) {
          taskManager = taskManagerFactory.QuerySharedTaskManager("SpecSharp", true);
        }
      }
#endif
    }
Beispiel #5
0
        /// <include file='doc\LanguageService.uex' path='docs/doc[@for="Source.Dispose"]/*' />
        public virtual void Dispose()
        {
            #if LANGTRACE
            Trace.WriteLine("Source::Cleanup");
            #endif
            try {
                if (this.textLinesEvents != null) {
                    this.textLinesEvents.Dispose();
                    this.textLinesEvents = null;
                }
            } catch (COMException) {
            }
            try {
                if (this.userDataEvents != null) {
                    this.userDataEvents.Dispose();
                    this.userDataEvents = null;
                }
            } catch (COMException) {
            }
            try {
                if (this.hiddenTextSession != null) {
                    // We can't throw or exit here because we need to call Dispose on the
                    // other members that need to be disposed.
                    this.hiddenTextSession.UnadviseClient();
                    this.hiddenTextSession = null;
                }
            } catch (COMException) {
            }
            try {
                if (this.methodData != null) {
                    this.methodData.Dispose();
                    this.methodData = null;
                }
            } catch (COMException) {
            }
            try {
                if (this.completionSet != null) {
                    this.completionSet.Dispose();
                    this.completionSet = null;
                }
            } catch (COMException) {
            }
            try {

                if (this.taskProvider != null) {
                    this.taskProvider.Dispose();
                    this.taskProvider = null;
                }
            } catch (COMException) {
            }
            try {
                this.service = null;
                if (this.colorizer != null) {
                    // The colorizer is owned by the core text editor, so we don't close it, the core text editor
                    // does that for us when it is ready to do so.
                    //colorizer.CloseColorizer();
                    this.colorizer = null;
                }
            } catch (COMException) {
            }
            try {
                if (this.colorState != null) {
                    this.colorState = null;
                }
            } catch (COMException) {
            }
            try {
                if (this.expansionProvider != null) {
                    this.expansionProvider.Dispose();
                    this.expansionProvider = null;
                }

            } catch (COMException) {
            }
            try {

                // Sometimes OnCloseSource is called when language service is changed, (for example
                // when you save the file with a different file extension) in which case we cannot
                // null out the site because that will cause a crash inside msenv.dll.
                //            if (this.textLines != null) {
                //                ((IObjectWithSite)this.textLines).SetSite(null);
                //            }
                if (this.textLines != null) {
                    this.textLines = null; //rely on GC rather control lifetime through ReleaseCOMObject
                    Marshal.Release(pUnkTextLines);
                }
            } catch (COMException) {
            }
        }
Beispiel #6
0
        /// <include file='doc\Source.uex' path='docs/doc[@for="Source.Source"]/*' />
        public Source(LanguageService service, IVsTextLines textLines, Colorizer colorizer)
        {
            #if LANGTRACE
            Tracing.TraceRef(textLines, "Source.textLines");
            #endif
            this.service = service;
            this.textLines = textLines;
            pUnkTextLines = Marshal.GetIUnknownForObject(this.textLines); //so it can't get disposed on us
            this.colorizer = colorizer;
            this.dirty = true;
            this.completionSet = this.CreateCompletionSet();
            this.methodData = this.CreateMethodData();
            this.colorState = (IVsTextColorState)textLines;

            // Register text buffer (IVsTextLines) event handlers
            // Delegate to virtual/overridable method
            RegisterTextBufferEventHandlers(textLines);

            this.doOutlining = this.service.Preferences.AutoOutlining;
            if (this.doOutlining) {
                GetHiddenTextSession();
            }
            this.expansionProvider = GetExpansionProvider();

            this.lastParseTime = Int32.MaxValue;
        }