protected override void OnParsedDocumentUpdated() { base.OnParsedDocumentUpdated(); try { razorDocument = CU as RazorCSharpParsedDocument; if (razorDocument == null || razorDocument.PageInfo.CSharpParsedFile == null) { return; } CreateDocType(); // Don't update C# code in hiddenInfo when: // 1) We are in a RazorState, and the completion window is visible, // it'll freeze (or disappear if we call OnCompletionContextChanged). // 2) We're in the middle of writing a Razor expression - if we're in an incorrect state, // the generated code migh be behind what we've been already written. var state = Tracker.Engine.CurrentState; if (state is RazorState && CompletionWindowManager.IsVisible || (!updateNeeded && (state is RazorSpeculativeState || state is RazorExpressionState))) { UpdateHiddenDocument(false); } else { UpdateHiddenDocument(); updateNeeded = false; } } catch (Exception e) { LoggingService.LogError("Error while updating razor completion.", e); } }
public RazorTestingEditorExtension(Document doc, RazorCSharpParsedDocument parsedDoc, bool cSharpContext) { razorDocument = parsedDoc; Initialize(doc); if (cSharpContext) { InitializeCodeCompletion(); SwitchToHidden(); } }