private void OnBreakpointUpdated(object sender, BreakpointUpdatedEventArgs e) { if (this.BreakpointUpdated != null) { this.BreakpointUpdated(sender, e); } }
// Method to handle the Debugger BreakpointUpdated event. // This method will display the current breakpoint change and maintain a // collection of all current breakpoints. private void HandlerBreakpointUpdatedEvent(object sender, BreakpointUpdatedEventArgs args) { switch (args.UpdateType) { case BreakpointUpdateType.Set: if (!BreakPoints.ContainsKey(args.Breakpoint.Id)) { BreakPoints.Add(args.Breakpoint.Id, args.Breakpoint); } UserIOImpl.PrintMessage("HandlerBreakpointUpdatedEvent> breakpoint created"); break; case BreakpointUpdateType.Removed: BreakPoints.Remove(args.Breakpoint.Id); UserIOImpl.PrintMessage("HandlerBreakpointUpdatedEvent> breakpoint removed"); break; case BreakpointUpdateType.Enabled: UserIOImpl.PrintMessage("HandlerBreakpointUpdatedEvent> breakpoint enabled"); break; case BreakpointUpdateType.Disabled: UserIOImpl.PrintMessage("HandlerBreakpointUpdatedEvent> breakpoint disabled"); break; } UserIOImpl.PrintMessage(args.Breakpoint.ToString()); }
private void OnBreakpointUpdated(object sender, BreakpointUpdatedEventArgs e) { List <Breakpoint> breakpoints = null; // Normalize the script filename for proper indexing string normalizedScriptName = e.Breakpoint.Script.ToLower(); // Get the list of breakpoints for this file if (!this.breakpointsPerFile.TryGetValue(normalizedScriptName, out breakpoints)) { breakpoints = new List <Breakpoint>(); this.breakpointsPerFile.Add( normalizedScriptName, breakpoints); } // Add or remove the breakpoint based on the update type if (e.UpdateType == BreakpointUpdateType.Set) { breakpoints.Add(e.Breakpoint); } else if (e.UpdateType == BreakpointUpdateType.Removed) { breakpoints.Remove(e.Breakpoint); } else { // TODO: Do I need to switch out instances for updated breakpoints? } if (this.BreakpointUpdated != null) { this.BreakpointUpdated(sender, e); } }
private async void DebugService_BreakpointUpdated(object sender, BreakpointUpdatedEventArgs e) { string reason = "changed"; if (this.setBreakpointInProgress) { // Don't send breakpoint update notifications when setting // breakpoints on behalf of the client. return; } switch (e.UpdateType) { case BreakpointUpdateType.Set: reason = "new"; break; case BreakpointUpdateType.Removed: reason = "removed"; break; } var breakpoint = Protocol.DebugAdapter.Breakpoint.Create( BreakpointDetails.Create(e.Breakpoint)); breakpoint.Verified = e.UpdateType != BreakpointUpdateType.Disabled; await this.messageSender.SendEvent( BreakpointEvent.Type, new BreakpointEvent { Reason = reason, Breakpoint = breakpoint }); }
private void OnBreakpointUpdated(object sender, BreakpointUpdatedEventArgs e) { // This event callback also gets called when a CommandBreakpoint is modified. // Only execute the following code for LineBreakpoint so we can keep track // of which line breakpoints exist per script file. We use this later when // we need to clear all breakpoints in a script file. We do not need to do // this for CommandBreakpoint, as those span all script files. if (e.Breakpoint is LineBreakpoint lineBreakpoint) { string scriptPath = lineBreakpoint.Script; if (this.powerShellContext.CurrentRunspace.Location == RunspaceLocation.Remote && this.remoteFileManager != null) { string mappedPath = this.remoteFileManager.GetMappedPath( scriptPath, this.powerShellContext.CurrentRunspace); if (mappedPath == null) { this.logger.LogError( $"Could not map remote path '{scriptPath}' to a local path."); return; } scriptPath = mappedPath; } // Normalize the script filename for proper indexing string normalizedScriptName = scriptPath.ToLower(); // Get the list of breakpoints for this file if (!_breakpointService.BreakpointsPerFile.TryGetValue(normalizedScriptName, out HashSet <Breakpoint> breakpoints)) { breakpoints = new HashSet <Breakpoint>(); _breakpointService.BreakpointsPerFile.Add( normalizedScriptName, breakpoints); } // Add or remove the breakpoint based on the update type if (e.UpdateType == BreakpointUpdateType.Set) { breakpoints.Add(e.Breakpoint); } else if (e.UpdateType == BreakpointUpdateType.Removed) { breakpoints.Remove(e.Breakpoint); } else { // TODO: Do I need to switch out instances for updated breakpoints? } } this.BreakpointUpdated?.Invoke(sender, e); }
void Debugger_BreakpointUpdated(object sender, BreakpointUpdatedEventArgs e) { Log.InfoFormat("Breakpoint updated: {0} {1}", e.UpdateType, e.Breakpoint); if (BreakpointUpdated != null) { BreakpointUpdated(sender, e); } }
/// <summary> /// Breakpoint updates (such as enabled/disabled) /// </summary> /// <param name="sender"></param> /// <param name="e"></param> private void Debugger_BreakpointUpdated(object sender, BreakpointUpdatedEventArgs e) { // Not in-use for now, leave it as place holder for future support on powershell debugging command in REPL ServiceCommon.Log("Breakpoint updated: {0} {1}", e.UpdateType, e.Breakpoint); //if (_callback != null) //{ // var lbp = e.Breakpoint as LineBreakpoint; // _callback.BreakpointUpdated(new DebuggerBreakpointUpdatedEventArgs(new PowershellBreakpoint(e.Breakpoint.Script, lbp.Line, lbp.Column), e.UpdateType)); //} }
private async void DebugService_BreakpointUpdatedAsync(object sender, BreakpointUpdatedEventArgs e) { string reason = "changed"; if (_setBreakpointInProgress) { // Don't send breakpoint update notifications when setting // breakpoints on behalf of the client. return; } switch (e.UpdateType) { case BreakpointUpdateType.Set: reason = "new"; break; case BreakpointUpdateType.Removed: reason = "removed"; break; } Protocol.DebugAdapter.Breakpoint breakpoint; if (e.Breakpoint is LineBreakpoint) { breakpoint = Protocol.DebugAdapter.Breakpoint.Create(BreakpointDetails.Create(e.Breakpoint)); } else if (e.Breakpoint is CommandBreakpoint) { //breakpoint = Protocol.DebugAdapter.Breakpoint.Create(CommandBreakpointDetails.Create(e.Breakpoint)); Logger.Write(LogLevel.Verbose, "Function breakpoint updated event is not supported yet"); return; } else { Logger.Write(LogLevel.Error, $"Unrecognized breakpoint type {e.Breakpoint.GetType().FullName}"); return; } breakpoint.Verified = e.UpdateType != BreakpointUpdateType.Disabled; await _messageSender.SendEventAsync( BreakpointEvent.Type, new BreakpointEvent { Reason = reason, Breakpoint = breakpoint }); }
private void DebugService_BreakpointUpdated(object sender, BreakpointUpdatedEventArgs e) { string reason = "changed"; if (_debugStateService.IsSetBreakpointInProgress) { // Don't send breakpoint update notifications when setting // breakpoints on behalf of the client. return; } switch (e.UpdateType) { case BreakpointUpdateType.Set: reason = "new"; break; case BreakpointUpdateType.Removed: reason = "removed"; break; } var breakpoint = new OmniSharp.Extensions.DebugAdapter.Protocol.Models.Breakpoint { Verified = e.UpdateType != BreakpointUpdateType.Disabled }; if (e.Breakpoint is LineBreakpoint) { breakpoint = LspDebugUtils.CreateBreakpoint(BreakpointDetails.Create(e.Breakpoint)); } else if (e.Breakpoint is CommandBreakpoint) { _logger.LogTrace("Function breakpoint updated event is not supported yet"); return; } else { _logger.LogError($"Unrecognized breakpoint type {e.Breakpoint.GetType().FullName}"); return; } _debugAdapterServer.SendNotification(EventNames.Breakpoint, new BreakpointEvent { Reason = reason, Breakpoint = breakpoint }); }
private void DebuggerOnBreakpointUpdated(object sender, BreakpointUpdatedEventArgs args) { if (Interactive) { if (args.Breakpoint is LineBreakpoint breakpoint) { if (string.Equals(breakpoint.Script, DebugFile, StringComparison.OrdinalIgnoreCase)) { var message = Message.Parse(this, "ise:setbreakpoint"); message.Arguments.Add("Line", (breakpoint.Line - 1).ToString()); message.Arguments.Add("Action", args.UpdateType.ToString()); SendUiMessage(message); } } } }
void OnBreakpointUpdated(object sender, BreakpointUpdatedEventArgs e) { if (!string.IsNullOrEmpty(e.Breakpoint.Script)) { if (e.Breakpoint is LineBreakpoint bp) { if (e.UpdateType == BreakpointUpdateType.Removed) { Breakpoints.Remove(bp); } else { Breakpoints.Add(bp); } } } }
/// <summary> /// This event handler adds or removes breakpoints monitored by Visual Studio. /// </summary> /// <param name="sender"></param> /// <param name="e"></param> void Debugger_BreakpointUpdated(object sender, BreakpointUpdatedEventArgs e) { if (_initializingRunspace) { return; } if (e.UpdateType == BreakpointUpdateType.Set) { var lbp = e.Breakpoint as LineBreakpoint; if (lbp != null) { var breakpoint = new ScriptBreakpoint(_node, e.Breakpoint.Script, lbp.Line, lbp.Column, _events); breakpoint.Bind(); var bp = bps.FirstOrDefault( m => m.Column == lbp.Column && m.Line == lbp.Line && m.File.Equals(lbp.Script, StringComparison.InvariantCultureIgnoreCase)); if (bp == null) { bps.Add(breakpoint); } } } if (e.UpdateType == BreakpointUpdateType.Removed) { var lbp = e.Breakpoint as LineBreakpoint; if (lbp != null) { var bp = bps.FirstOrDefault( m => m.Column == lbp.Column && m.Line == lbp.Line && m.File.Equals(lbp.Script, StringComparison.InvariantCultureIgnoreCase)); if (bp != null) { bp.Delete(); bps.Remove(bp); } } } }
private void OnBreakpointUpdated(object sender, BreakpointUpdatedEventArgs e) { // This event callback also gets called when a CommandBreakpoint is modified. // Only execute the following code for LineBreakpoint so we can keep track // of which line breakpoints exist per script file. We use this later when // we need to clear all breakpoints in a script file. We do not need to do // this for CommandBreakpoint, as those span all script files. LineBreakpoint lineBreakpoint = e.Breakpoint as LineBreakpoint; if (lineBreakpoint != null) { List <Breakpoint> breakpoints; // Normalize the script filename for proper indexing string normalizedScriptName = lineBreakpoint.Script.ToLower(); // Get the list of breakpoints for this file if (!this.breakpointsPerFile.TryGetValue(normalizedScriptName, out breakpoints)) { breakpoints = new List <Breakpoint>(); this.breakpointsPerFile.Add( normalizedScriptName, breakpoints); } // Add or remove the breakpoint based on the update type if (e.UpdateType == BreakpointUpdateType.Set) { breakpoints.Add(e.Breakpoint); } else if (e.UpdateType == BreakpointUpdateType.Removed) { breakpoints.Remove(e.Breakpoint); } else { // TODO: Do I need to switch out instances for updated breakpoints? } } this.BreakpointUpdated?.Invoke(sender, e); }
private void OnBreakpointUpdated(object sender, BreakpointUpdatedEventArgs e) { // Don't send breakpoint update notifications when setting // breakpoints on behalf of the client. if (_debugStateService.IsSetBreakpointInProgress) { return; } if (e.Breakpoint is LineBreakpoint) { OmniSharp.Extensions.DebugAdapter.Protocol.Models.Breakpoint breakpoint = LspDebugUtils.CreateBreakpoint( BreakpointDetails.Create(e.Breakpoint, e.UpdateType) ); string reason = e.UpdateType switch { BreakpointUpdateType.Set => BreakpointEventReason.New, BreakpointUpdateType.Removed => BreakpointEventReason.Removed, BreakpointUpdateType.Enabled => BreakpointEventReason.Changed, BreakpointUpdateType.Disabled => BreakpointEventReason.Changed, _ => "InvalidBreakpointUpdateTypeEnum" }; _debugAdapterServer.SendNotification( EventNames.Breakpoint, new BreakpointEvent { Breakpoint = breakpoint, Reason = reason } ); } else if (e.Breakpoint is CommandBreakpoint) { _logger.LogTrace("Function breakpoint updated event is not supported yet"); } else { _logger.LogError($"Unrecognized breakpoint type {e.Breakpoint.GetType().FullName}"); } }
// Method to handle the Debugger BreakpointUpdated event. // This method will display the current breakpoint change and maintain a // collection of all current breakpoints. private void HandlerBreakpointUpdatedEvent(object sender, BreakpointUpdatedEventArgs args) { // Write message to console. ConsoleColor saveFGColor = Console.ForegroundColor; Console.ForegroundColor = ConsoleColor.Yellow; Console.WriteLine(); switch (args.UpdateType) { case BreakpointUpdateType.Set: if (!_breakPoints.ContainsKey(args.Breakpoint.Id)) { _breakPoints.Add(args.Breakpoint.Id, args.Breakpoint); } Console.WriteLine("Breakpoint created:"); break; case BreakpointUpdateType.Removed: _breakPoints.Remove(args.Breakpoint.Id); Console.WriteLine("Breakpoint removed:"); break; case BreakpointUpdateType.Enabled: Console.WriteLine("Breakpoint enabled:"); break; case BreakpointUpdateType.Disabled: Console.WriteLine("Breakpoint disabled:"); break; } Console.WriteLine(args.Breakpoint.ToString()); Console.WriteLine(); Console.ForegroundColor = saveFGColor; }
public void HandleBreakpointUpdated(BreakpointUpdatedEventArgs args) => BreakpointUpdated?.Invoke(this, args);
void debugService_BreakpointUpdated(object sender, BreakpointUpdatedEventArgs e) { // TODO: Needed? }
private void HandleBreakpointUpdated(object sender, BreakpointUpdatedEventArgs e) { this.RaiseBreakpointUpdatedEvent(e); }