예제 #1
0
        public TextSpan GetSelection()
        {
            TextSpan          result   = new TextSpan();
            ExpansionProvider provider = this.ExpansionProvider;

            if (provider != null && provider.TextView != null)
            {
                NativeMethods.ThrowOnFailure(provider.TextView.GetSelection(out result.iStartLine,
                                                                            out result.iStartIndex, out result.iEndLine, out result.iEndIndex));
            }
            return(result);
        }
예제 #2
0
 internal ExpansionFunction(ExpansionProvider provider)
 {
     this.provider = provider;
 }
예제 #3
0
        // Overriden in source.fs, it calls this base implementation
        public virtual void Dispose()
        {
#if LANGTRACE
            Trace.WriteLine("Source::Cleanup");
#endif
            this.disposed = true;
            try
            {
                if (this.textLinesEvents != null)
                {
                    this.textLinesEvents.Dispose();
                    this.textLinesEvents = null;
                }
            }
            finally
            {
                try
                {
                    if (this.userDataEvents != null)
                    {
                        this.userDataEvents.Dispose();
                        this.userDataEvents = null;
                    }
                }
                finally
                {
                    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 is causing a debug assert in vs\env\msenv\textmgr\vrlist.cpp
                            // at line 1997 in CVisibleRegionList::Terminate
                            //this.hiddenTextSession.Terminate();
                            this.hiddenTextSession = null;
                        }
                    }
                    finally
                    {
                        try
                        {
                            if (this.methodData != null)
                            {
                                this.methodData.Dispose();
                                this.methodData = null;
                            }
                        }
                        finally
                        {
                            try
                            {
                                if (this.completionSet != null)
                                {
                                    this.completionSet.Dispose();
                                    this.completionSet = null;
                                }
                            }
                            finally
                            {
                                try
                                {
                                    // clear out any remaining tasks for this doc in the task list
                                    // tp may not be the same as taskProvider

                                    // REVIEW: This should be: if (null != this.taskReporter)
                                    // Right now, MSBuild 4.0 can clear out build loggers responsibly, so this.taskReporter will always
                                    // be null when we get to this point, so we'll need to create a new taskReporter to clear out the
                                    // background tasks
                                    TaskReporter tr = this.GetTaskReporter();  // may be our own TR or one from ProjectSite of this file
                                    if (null != tr)
                                    {
                                        tr.ClearBackgroundTasksForFile(this.GetFilePath());
                                        // Refresh the task list
                                        tr.OutputTaskList();
                                    }
                                    if (null != this.taskReporter)      // dispose the one we own (do not dispose one shared by project site!)
                                    {
                                        this.taskReporter.Dispose();
                                        this.taskReporter = null;
                                        this.taskProvider = null;
                                    }
                                }
                                finally
                                {
                                    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;
                                        }
                                    }
                                    finally
                                    {
                                        this.colorState = null;
                                        try
                                        {
                                            if (this.expansionProvider != null)
                                            {
                                                this.expansionProvider.Dispose();
                                                this.expansionProvider = null;
                                            }

                                        }
                                        finally
                                        {
                                            // 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;
                                                Marshal.Release(pUnkTextLines);
                                            }
                                        }
                                    }
                                }
                            }
                        }
                    }
                }
            }
        }
예제 #4
0
 public virtual int ReleaseFunction()
 {
     this.provider = null;
     return(NativeMethods.S_OK);
 }
예제 #5
0
 public ExpansionProvider GetExpansionProvider()
 {
     if (this.expansionProvider == null && this.service != null)
     {
         this.expansionProvider = this.service.CreateExpansionProvider(this);
     }
     return this.expansionProvider;
 }
예제 #6
0
        internal SourceImpl(LanguageService service, IVsTextLines textLines, Colorizer colorizer)
        {
#if LANGTRACE
            Tracing.TraceRef(textLines, "Source.textLines");
#endif
            this.service = service;
            this.textLines = textLines;
            // REVIEW: why the next line? RCW in this.textLines holds IUnknown already. (released in Dispose correctly though)
            pUnkTextLines = Marshal.GetIUnknownForObject(this.textLines); //so it can't get disposed on us
            this.colorizer = colorizer;
            this.completionSet = this.CreateCompletionSet();
            this.methodData = new MethodData(this.service.Site);
            this.colorState = (IVsTextColorState)textLines;
            // track source changes
            this.textLinesEvents = new NativeMethods.ConnectionPointCookie(textLines, this, typeof(IVsTextLinesEvents));
            this.userDataEvents = new NativeMethods.ConnectionPointCookie(textLines, this, typeof(IVsUserDataEvents));

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

            this.lastOnIdleRequestDuration = 0;

            this.openedTime = System.DateTime.Now;
        }
 public virtual int ReleaseFunction() {
     this.provider = null;
     return NativeMethods.S_OK;
 }
 internal ExpansionFunction(ExpansionProvider provider) {
     this.provider = provider;
 }
예제 #9
0
 /// If the functionName is supported, return a new IVsExpansionFunction object.
 internal virtual ExpansionFunction CreateExpansionFunction(ExpansionProvider provider, string functionName)
 {
     return null;
 }