Esempio n. 1
0
 /// <include file='doc\LanguageService.uex' path='docs/doc[@for="LanguageService.BeginParse"]/*' />
 public void BeginParse(ParseRequest request, ParseResultHandler handler) {
     StartThread();
     lock (this) {
         request.Callback = handler;
         this.parseRequest = request;
         this.parseRequestPending.Set();
     }
 }
Esempio n. 2
0
    internal void BeginParse( int line, int idx, TokenInfo info, ParseReason reason, IVsTextView view, ParseResultHandler callback) {
     
      string text = null;
      if (reason == ParseReason.MemberSelect || reason == ParseReason.MethodTip)
        text = this.GetTextUpToLine( line );
      else if (reason == ParseReason.CompleteWord || reason == ParseReason.QuickInfo)
        text = this.GetTextUpToLine( line+1 );
      else
        text = this.GetTextUpToLine( 0 ); // get all the text.      

      string fname = this.GetFilePath();

      this.service.BeginParse(new ParseRequest(line, idx, info, text, fname, reason, view), callback); 
    }
Esempio n. 3
0
 internal void BeginParse(ParseRequest request, ParseResultHandler handler){
   lock(this){
     request.Callback = handler;
     this.parseRequest = request;
     this.parseRequestPending.Set();
     if (this.parseThread == null){
       if (this.Control == null){
         this.Control = new System.Windows.Forms.Button();
         this.Control.CreateControl();
       }
       this.parseThread = new Thread(new ThreadStart(this.ParseThread));
       this.parseThread.Start();
     }
   }
 }
Esempio n. 4
0
 public IAsyncResult BeginParse(ParseRequest request, ParseResultHandler handler);
Esempio n. 5
0
        /// <summary>
        /// BeginParse is called when this Source object needs to be parsed.  The default implementation
        /// uses the LanguageService background parse thread to do the work.
        /// </summary>
        /// <param name="line">The line position where intellisense is being requested (if any)</param>
        /// <param name="idx">The column position where intellisense is being requested</param>
        /// <param name="info">The token at the line/col position or an empty token</param>
        /// <param name="reason">The reason for this parse request</param>
        /// <param name="view">The IVsTextView or null if the view is not known.</param>
        /// <param name="callback">A callback delegate to call when the parse is completed.  If a callback 
        /// delegate is provided then the ParseRequest will be processed asynchronously on a background thread 
        /// and this method will return immediately, then the callback will be called on the UI thread when the 
        /// parse is completed.  The completed ParseRequest will then contain an AuthoringScope object which can 
        /// be used to complete intellisense requests.</param>
        /// <returns></returns>
        public virtual ParseRequest BeginParse(int line, int idx, TokenInfo info, ParseReason reason, IVsTextView view, ParseResultHandler callback)
        {
            bool synchronous = callback == null || !this.LanguageService.Preferences.EnableAsyncCompletion;

            bool success = false;
            if (synchronous && this.LanguageService.IsParsing) {
                // Have to wait for the background thread to finish so we don't try parsing the same
                // buffer at the same time.  We also have to "stop" the background thread when it's done
                // so it doesn't automatically pick up the next pending parse requrest and continue right on.
                IAsyncResult result = this.LanguageService.GetParseResult();
            #if PARSETHREAD
                Trace.WriteLine("Source.BeginParse Waitng for bgr thread");
            #endif
                if (!result.IsCompleted) {
                    success=result.AsyncWaitHandle.WaitOne();
                }
            #if PARSETHREAD
                Debug.Assert(success || result.IsCompleted, "Why did result not complete well?");
            #endif
            }
            #if PARSETHREAD
            Trace.WriteLine("Source.BeginParse Go" + " is parsing " + this.LanguageService.IsParsing);
            #endif
            // get all the text so we can pass it to the background thread.  This is required unfortunately
            // becase IVsTextLines is not multithread safe (it is an apartment COM object).
            string text = (HandlesSnapshots ? null: this.GetText());
            string fname = this.GetFilePath();
            ParseRequest request = this.LanguageService.CreateParseRequest(this, line, idx, info, text, fname, reason, view);
            request.Timestamp = this.ChangeCount;
            request.DirtySpan = this.DirtySpan;
            if (synchronous) {
                request.IsSynchronous = true; //unless registry value indicates that sync ops always prefer async
            }
            if (request.IsSynchronous) {
                this.LanguageService.ParseRequest(request);
                this.SetLastParseTime(request.parseTime);
                if (callback != null) callback(request);
            } else {
                request.result = this.LanguageService.BeginParse(request, callback);
            }
            return request;
        }
Esempio n. 6
0
        public override ParseRequest BeginParse(int line, int idx, TokenInfo info, ParseReason reason, IVsTextView view, ParseResultHandler callback)
        {
            //return base.BeginParse(line, idx, info, reason, view, callback);

            switch (reason)
            {
            case ParseReason.Autos:
                break;

            case ParseReason.Check:
                m_parse_reason = ParseReason.Check;
                NSUtil.DebugPrintAlways("NSSource BeginParse Check");
                //m_scanner.m_fullscan = 3;
                //Recolorize(0,LineCount);
                //m_scanner.m_fullscan = false;
                //Recolorize(0, this.LineCount);
                break;

            //return null;
            case ParseReason.CodeSpan:
                break;

            case ParseReason.CompleteWord:
                break;

            case ParseReason.DisplayMemberList:
                break;

            case ParseReason.Goto:
                break;

            case ParseReason.MemberSelect:
                break;

            case ParseReason.MemberSelectAndHighlightBraces:
                break;

            case ParseReason.MethodTip:
                break;

            case ParseReason.None:
                break;

            case ParseReason.QuickInfo:
                break;

            case ParseReason.HighlightBraces:
            case ParseReason.MatchBraces:
                Trace.Assert(false);
                break;

            default:
                break;
            }

            return(base.BeginParse(line, idx, info, reason, view, callback));
            //return null;
        }
Esempio n. 7
0
        public override ParseRequest BeginParse(int line, int idx, TokenInfo info, ParseReason reason, IVsTextView view, ParseResultHandler callback)
        {
            //return base.BeginParse(line, idx, info, reason, view, callback);

            switch (reason) {
            case ParseReason.Autos:
                break;
            case ParseReason.Check:
                m_parse_reason = ParseReason.Check;
                NSUtil.DebugPrintAlways("NSSource BeginParse Check");
                //m_scanner.m_fullscan = 3;
                //Recolorize(0,LineCount);
                //m_scanner.m_fullscan = false;
                //Recolorize(0, this.LineCount);
                break;
                //return null;
            case ParseReason.CodeSpan:
                break;
            case ParseReason.CompleteWord:
                break;
            case ParseReason.DisplayMemberList:
                break;
            case ParseReason.Goto:
                break;
            case ParseReason.MemberSelect:
                break;
            case ParseReason.MemberSelectAndHighlightBraces:
                break;
            case ParseReason.MethodTip:
                break;
            case ParseReason.None:
                break;
            case ParseReason.QuickInfo:
                break;
            case ParseReason.HighlightBraces:
            case ParseReason.MatchBraces:
                Trace.Assert(false);
                break;
            default:
                break;
            }

            return base.BeginParse(line, idx, info, reason, view, callback);
            //return null;
        }
Esempio n. 8
0
 public IAsyncResult BeginParse(ParseRequest request, ParseResultHandler handler);
 /// <include file='doc\LanguageService.uex' path='docs/doc[@for="LanguageService.BeginParse"]/*' />
 public IAsyncResult BeginParse(ParseRequest request, ParseResultHandler handler)
 {
     lock (this) { // protect this.parseRequest pointer & this.isParsing boolean.
         StartThread();
         request.Callback = handler;
         this.parseRequest = request;
         this.stop = false;
         this.isParsing = true;
         this.parseRequestPending.Set(); // fire off the parse!
     }
     // Note if the thread is already running, this will just fall through and that's ok.
     // We simply want to be sure the thread will eventually pick up our parse request.
     // We do NOT want to block until the thread calls Set() at the top of the loop because
     // that can cause deadlocks because this is not a ParseRequestHandle.
     bool started = this.parseRequestStarted.WaitOne(10000, false); // give it time to get going.
     #if PARSETHREAD
     Debug.Assert(started, "Timed out on a wait for thread to start");
     #endif
     return new AsyncResult(this, request, this.parseRequestDone);
 }