示例#1
0
        public BackgroundRequest BeginBackgroundRequest(int line, int idx, TokenInfo info, BackgroundRequestReason reason, IVsTextView view, RequireFreshResults requireFreshResults, BackgroundRequestResultHandler callback, MethodTipMiscellany methodTipMiscellany = 0)
        {
            var wpfTextView = GetWpfTextViewFromVsTextView(view);
            var snapshot = wpfTextView.TextSnapshot;

            if (this.disposed) return null;
            string fname = this.GetFilePath();

            Debug.Assert(snapshot != null);
            Debug.Assert(callback != null);

            // Check if we can shortcut executing the background request and just fill in the latest
            // cached scope for the active view from this.service.RecentFullTypeCheckResults.
            //
            // This must only kick in if ExecuteBackgroundRequest is equivalent to fetching a recent,
            // perhaps out-of-date scope.
            if (!this.NeedsVisualRefresh &&
                this.service.IsRecentScopeSufficientForBackgroundRequest(reason) &&
                (this.service.RecentFullTypeCheckResults != null) &&
                this.service.RecentFullTypeCheckFile.Equals(fname) &&
                requireFreshResults != RequireFreshResults.Yes)
            {
                BackgroundRequest request = this.service.CreateBackgroundRequest(this, line, idx, info, null, snapshot, methodTipMiscellany, fname, reason, view);
                request.ResultScope = this.service.RecentFullTypeCheckResults;
                request.ResultClearsDirtinessOfFile = false;
                request.Timestamp = this.ChangeCount;
                request.IsSynchronous = true;
                callback(request);
                return request;
            }
            else
            {

                string text = this.GetText(); // get all the text
                BackgroundRequest request = this.service.CreateBackgroundRequest(this, line, idx, info, text, snapshot, methodTipMiscellany, fname, reason, view);
                request.Timestamp = this.ChangeCount;
                request.DirtySpan = this.dirtySpan;
                request.RequireFreshResults = requireFreshResults;

                if (!this.LanguageService.Preferences.EnableAsyncCompletion)
                {
                    request.IsSynchronous = true; //unless registry value indicates that sync ops always prefer async 
                }
                if (request.IsSynchronous)
                {
                    this.service.ExecuteBackgroundRequest(request);
                    callback(request);
                }
                else
                {
                    request.result = this.service.BeginBackgroundRequest(request, callback);
                }
                return request;
            }
        }
示例#2
0
 public AuthoringSink CreateAuthoringSink(BackgroundRequestReason reason, int line, int col)
 {
     int maxErrors = this.service.Preferences.MaxErrorMessages;
     TaskReporter tr = this.GetTaskReporter();
     if (null != tr)
         tr.MaxErrors = (uint)maxErrors;
     return new AuthoringSink(reason, line, col, maxErrors);
 }
示例#3
0
 // Implemented in servicem.fs
 internal abstract BackgroundRequest CreateBackgroundRequest(int line, int col, TokenInfo info, string sourceText, ITextSnapshot snapshot, MethodTipMiscellany methodTipMiscellany, string fname,
                          BackgroundRequestReason reason, IVsTextView view,
                          AuthoringSink sink, ISource source, int timestamp, bool synchronous);
示例#4
0
 // Implemented in Source.fs
 public abstract void Completion(IVsTextView textView, TokenInfo info, BackgroundRequestReason reason, RequireFreshResults requireFreshResults);
示例#5
0
 internal BackgroundRequest CreateBackgroundRequest(SourceImpl s, int line, int idx, TokenInfo info, string sourceText, ITextSnapshot snapshot, MethodTipMiscellany methodTipMiscellany,
                                                    string fname, BackgroundRequestReason reason, IVsTextView view)
 {
     // We set this to "false" because we are effectively abandoning any currently executing background request, e.g. an OnIdle request
     this.isServingBackgroundRequest = false;
     bool sync = false;
     if (!this.Preferences.EnableAsyncCompletion)
     {
         sync = true; //unless registry value indicates that sync ops always prefer async 
     }
     return CreateBackgroundRequest(line, idx, info, sourceText, snapshot, methodTipMiscellany, fname, reason, view, s.CreateAuthoringSink(reason, line, idx), s, s.ChangeCount, sync);
 }
示例#6
0
 internal AuthoringSink(BackgroundRequestReason reason, int line, int col, int maxErrors)
 {
     this.reason = reason;
     this.errors = new ArrayList();
     this.line = line;
     this.col = col;
     this.Spans = new ArrayList();
     this.Braces = new ArrayList();
     this.errorCounts = new int[4];
     this.maxErrors = maxErrors;
 }
示例#7
0
 internal abstract Microsoft.FSharp.Control.FSharpAsync<Declarations> GetDeclarations(ITextSnapshot textSnapshot, int line, int col, BackgroundRequestReason reason);
示例#8
0
 /// If this returns true we can reuse a recent AuthoringScope if its available
 internal abstract bool IsRecentScopeSufficientForBackgroundRequest(BackgroundRequestReason req);
示例#9
0
        internal BackgroundRequest(int line, int col, TokenInfo info, string src, ITextSnapshot snapshot, MethodTipMiscellany methodTipMiscellany, string fname,
                                 BackgroundRequestReason reason, IVsTextView view,
                                 AuthoringSink sink, ISource source, int timestamp, bool synchronous)
        {
            this.Source = source;
            this.Timestamp = timestamp;
            this.Line = line;
            this.Col = col;
            this.FileName = fname;
            this.Text = src;
            this.Reason = reason;
            this.View = view;
            this.Snapshot = snapshot;
            this.MethodTipMiscellany = methodTipMiscellany;
            this.ResultSink = sink;
            this.TokenInfo = info;
            this.isSynchronous = synchronous;

            this.ResultScope = null;
            this.ResultClearsDirtinessOfFile = false;
        }