private void AddInterface() { //We need to suspend here since adding the interface and rewriting will both trigger a reparse. var suspendResult = _parseManager.OnSuspendParser(this, new[] { ParserState.Ready }, AddInterfaceInternal); if (suspendResult != SuspensionResult.Completed) { _logger.Warn("Extract interface failed."); } }
protected override bool TryRewriteInternal() { //The suspension ensures that only one parse gets executed instead of two for each rewritten module. var result = _parseManager.OnSuspendParser(this, new[] { ParserState.Ready }, ExecuteAllRewriters); if (result != SuspensionResult.Completed) { Logger.Warn($"Rewriting attribute modules did not succeed. suspension result = {result}"); return(false); } return(true); }
public void AddComponent(CodeExplorerItemViewModel node, ComponentType componentType, string code = null) { var projectId = ProjectId(node); if (projectId == null) { return; } var prefixInModule = FolderAnnotation(node); var suspensionResult = _parseManager.OnSuspendParser( this, Enum.GetValues(typeof(ParserState)).Cast <ParserState>(), () => _addComponentService.AddComponent(projectId, componentType, code, prefixInModule)); if (suspensionResult.Outcome == SuspensionOutcome.UnexpectedError && suspensionResult.EncounteredException != null) { //This rethrows with the original stack trace. ExceptionDispatchInfo.Capture(suspensionResult.EncounteredException).Throw(); } }
private void ImportFilesWithSuspension(ICollection <string> filesToImport, IVBProject targetProject) { var suspendResult = _parseManager.OnSuspendParser(this, new[] { ParserState.Ready }, () => ImportFiles(filesToImport, targetProject)); var suspendOutcome = suspendResult.Outcome; if (suspendOutcome != SuspensionOutcome.Completed) { if (suspendOutcome == SuspensionOutcome.UnexpectedError || suspendOutcome == SuspensionOutcome.Canceled) { //This rethrows the exception with the original stack trace. ExceptionDispatchInfo.Capture(suspendResult.EncounteredException).Throw(); return; } Logger.Warn("File import failed due to suspension failure."); } }
private void RefactorWithSuspendedParser(TModel model) { var suspendResult = _parseManager.OnSuspendParser(this, new[] { ParserState.Ready }, () => base.Refactor(model)); var suspendOutcome = suspendResult.Outcome; if (suspendOutcome != SuspensionOutcome.Completed) { if ((suspendOutcome == SuspensionOutcome.UnexpectedError || suspendOutcome == SuspensionOutcome.Canceled) && suspendResult.EncounteredException != null) { ExceptionDispatchInfo.Capture(suspendResult.EncounteredException).Throw(); return; } _logger.Warn($"{GetType().Name} failed because a parser suspension request could not be fulfilled. The request's result was '{suspendResult.ToString()}'."); throw new SuspendParserFailureException(); } }
protected override bool TryRewriteInternal() { //The suspension ensures that only one parse gets executed instead of two for each rewritten module. GuaranteeReparseAfterRewrite(); PrimeActiveCodePaneRecovery(); //Attribute rewrites close the affected code panes, so we have to recover the open state. PrimeOpenStateRecovery(); var result = _parseManager.OnSuspendParser(this, new[] { ParserState.Ready, ParserState.ResolvedDeclarations }, ExecuteAllRewriters); if (result != SuspensionResult.Completed) { Logger.Warn($"Rewriting attribute modules did not succeed. suspension result = {result}"); return(false); } return(true); }
private void AddInterfaceWithSuspendedParser(ExtractInterfaceModel model) { //We need to suspend here since adding the interface and rewriting will both trigger a reparse. var suspendResult = _parseManager.OnSuspendParser(this, new[] { ParserState.Ready }, () => AddInterface(model)); var suspendOutcome = suspendResult.Outcome; if (suspendOutcome != SuspensionOutcome.Completed) { if ((suspendOutcome == SuspensionOutcome.UnexpectedError || suspendOutcome == SuspensionOutcome.Canceled) && suspendResult.EncounteredException != null) { ExceptionDispatchInfo.Capture(suspendResult.EncounteredException).Throw(); return; } _logger.Warn($"{nameof(AddInterface)} failed because a parser suspension request could not be fulfilled. The request's result was '{suspendResult.ToString()}'."); throw new SuspendParserFailureException(); } }