//private void Start() //{ // System.Diagnostics.Debug.WriteLine("1. Call thread task"); // StartMyLongRunningTask(); // System.Diagnostics.Debug.WriteLine("2. Do something else"); //} //private void StartMyLongRunningTask() //{ // ThreadStart starter = myLongRunningTask; // starter += () => // { // myLongRunningTaskDone(); // }; // Thread _thread = new Thread(starter) { IsBackground = true }; // _thread.Start(); //} //private void myLongRunningTaskDone() //{ // System.Diagnostics.Debug.WriteLine("3. Task callback result"); //} //private void myLongRunningTask() //{ // string thisFile = VerilogLanguage.VerilogGlobals.GetDocumentPath(_buffer.CurrentSnapshot); // VerilogGlobals.Reparse(_buffer, thisFile); // note that above, we are checking that the e.After is the same as the _buffer //} /// <summary> /// BufferChanged - handle Buffer Changed event. If buffer has a character with possible far-reaching consequences /// then force a rescan of the enture buffer. See also HighlightWordTaggerProvider /// </summary> /// <param name="sender"></param> /// <param name="e"></param> void BufferChanged(object sender, TextContentChangedEventArgs e) { // If this isn't the most up-to-date version of the buffer, then ignore it for now (we'll eventually get another change event). if (e.After != _buffer.CurrentSnapshot) { return; } if (e.Changes.Count < 1) { // TODO - how did we get here if there are no changes? (found this after exception during debug. no apparent invoke. ) return; } string theNewText = e.Changes[0].NewText; string theOldText = e.Changes[0].OldText; if (e.Changes.Count > 1) { // TODO - why exit if there is more than one change (perhaps exit if LESS than 1? no!) return; } // we are only interested when the old and new text are different. // yes, the event seems to be triggered even with no apparent changes // if (theNewText != theOldText) { // even if the buffer is different, only certain characters require a full reparse // typically brackets (since we keep track of depth) and comment chars: if (VerilogGlobals.IsRefreshChar(theNewText) || VerilogGlobals.IsRefreshChar(theOldText)) { string thisFile = VerilogLanguage.VerilogGlobals.GetDocumentPath(_buffer.CurrentSnapshot); // VerilogGlobals.ParseStatus_NeedReparse_SetValue(thisFile, true); VerilogGlobals.ParseStatusController.NeedReparse_SetValue(thisFile, true); //VerilogGlobals.ParseStatus_EnsureExists(thisFile); //VerilogGlobals.ParseStatus[thisFile].NeedReparse = true; // VerilogGlobals.NeedReparse = true; //myLongRunningTask(); VerilogGlobals.Reparse(_buffer, thisFile); // note that above, we are checking that the e.After is the same as the _buffer } } else { System.Diagnostics.Debug.WriteLine("BufferChanged called but new and old text not different!"); } }
/// <summary> /// BufferChanged - handle Buffer Changed event. If buffer has a character with possible far-reaching consequences /// then force a rescan of the enture buffer. See also HighlightWordTaggerProvider /// </summary> /// <param name="sender"></param> /// <param name="e"></param> void BufferChanged(object sender, TextContentChangedEventArgs e) { // If this isn't the most up-to-date version of the buffer, then ignore it for now (we'll eventually get another change event). if (e.After != _buffer.CurrentSnapshot) { return; } string theNewText = e.Changes[0].NewText; string theOldText = e.Changes[0].OldText; if (e.Changes.Count > 1) { return; } // we are only interested when the old and new text are different. // yes, the event seems to be triggered even with no apparent changes // if (theNewText != theOldText) { // even if the buffer is different, only certain characters require a full reparse // typically brackets (since we keep track of depth) and comment chars: if (VerilogGlobals.IsRefreshChar(theNewText) || VerilogGlobals.IsRefreshChar(theOldText)) { string thisFile = VerilogLanguage.VerilogGlobals.GetDocumentPath(_buffer.CurrentSnapshot); // VerilogGlobals.ParseStatus_NeedReparse_SetValue(thisFile, true); VerilogGlobals.ParseStatusController.NeedReparse_SetValue(thisFile, true); //VerilogGlobals.ParseStatus_EnsureExists(thisFile); //VerilogGlobals.ParseStatus[thisFile].NeedReparse = true; // VerilogGlobals.NeedReparse = true; VerilogGlobals.Reparse(_buffer, thisFile); // note that above, we are checking that the e.After is the same as the _buffer } } }