/// <summary> /// Initializes a new instance of the Violation class. /// </summary> /// <param name="rule"> /// The rule that triggered the violation. /// </param> /// <param name="element"> /// The element that this violation appears in. /// </param> /// <param name="location"> /// The location in the source code where the violation occurs. /// </param> /// <param name="message"> /// The context message for the violation. /// </param> internal Violation(Rule rule, ICodeElement element, CodeLocation location, string message) { Param.AssertNotNull(rule, "rule"); Param.Ignore(element); Param.AssertNotNull(location, "location"); Param.AssertNotNull(message, "message"); this.rule = rule; this.element = element; // The CodeLocation passed in is zero based everywhere in StyleCop for the column. The line number is already 1 based. // We convert is to 1 based here so that are xml reports etc and VisualStudio UI friendly. this.location = new CodeLocation( location.StartPoint.Index, location.EndPoint.Index, location.StartPoint.IndexOnLine + 1, location.EndPoint.IndexOnLine + 1, location.StartPoint.LineNumber, location.EndPoint.LineNumber); // If the location has been passed in we set the linenumber. this.line = location.LineNumber; this.message = message; if (this.element != null && this.element.Document != null) { this.sourceCode = this.element.Document.SourceCode; } this.UpdateKey(); }
/// <summary> /// Joins the two given locations. /// </summary> /// <param name="location1"> /// The first location to join. /// </param> /// <param name="location2"> /// The second location to join. /// </param> /// <returns> /// Returns the joined <see cref="CodeLocation"/>. /// </returns> public static CodeLocation?Join(CodeLocation?location1, CodeLocation?location2) { Param.Ignore(location1, location2); if (location1 == null && location2 == null) { return(null); } if (location1 == null) { return(location2); } if (location2 == null) { return(location1); } // Figure out which IndexOnLine and EndIndexOnLine to use. int indexOnLine; int endIndexOnLine; if (location1.Value.StartPoint.LineNumber == location2.Value.StartPoint.LineNumber) { indexOnLine = Math.Min(location1.Value.StartPoint.IndexOnLine, location2.Value.StartPoint.IndexOnLine); endIndexOnLine = Math.Max(location1.Value.EndPoint.IndexOnLine, location2.Value.EndPoint.IndexOnLine); } else if (location1.Value.StartPoint.LineNumber < location2.Value.StartPoint.LineNumber) { indexOnLine = location1.Value.StartPoint.IndexOnLine; endIndexOnLine = location2.Value.EndPoint.IndexOnLine; } else { indexOnLine = location2.Value.StartPoint.IndexOnLine; endIndexOnLine = location1.Value.EndPoint.IndexOnLine; } return(new CodeLocation( Math.Min(location1.Value.StartPoint.Index, location2.Value.StartPoint.Index), Math.Max(location1.Value.EndPoint.Index, location2.Value.EndPoint.Index), indexOnLine, endIndexOnLine, Math.Min(location1.Value.StartPoint.LineNumber, location2.Value.StartPoint.LineNumber), Math.Max(location2.Value.EndPoint.LineNumber, location2.Value.EndPoint.LineNumber))); }
/// <summary> /// Initializes a new instance of the Violation class. /// </summary> /// <param name="rule"> /// The rule that triggered the violation. /// </param> /// <param name="element"> /// The element that this violation appears in. /// </param> /// <param name="line"> /// The line in the source code where the violation occurs. /// </param> /// <param name="message"> /// The context message for the violation. /// </param> internal Violation(Rule rule, ICodeElement element, int line, string message) { Param.AssertNotNull(rule, "rule"); Param.Ignore(element); Param.AssertGreaterThanOrEqualToZero(line, "line"); Param.AssertNotNull(message, "message"); this.rule = rule; this.element = element; this.line = line; // As the line only is passed in we ensure the location is null. // A null location indicates we only know the line it was on. this.location = null; this.message = message; if (this.element != null && this.element.Document != null) { this.sourceCode = this.element.Document.SourceCode; } this.UpdateKey(); }
void DebugManager_OnProcessStateChanged(object sender, DebuggerEventArgs e) { switch (DebugManager.Instance.ProcessState) { case DebuggerProcessState.Starting: evalDisabled = false; currentLocation = null; currentMethod = null; MainWindow.Instance.SessionSettings.FilterSettings.ShowInternalApi = true; SetRunningStatusMessage(); MainWindow.Instance.SetDebugging(); break; case DebuggerProcessState.Continuing: break; case DebuggerProcessState.Running: if (Debugger.IsEvaluating) break; SetRunningStatusMessage(); break; case DebuggerProcessState.Stopped: // If we're evaluating, or if eval has completed, don't do a thing. This code // should only be executed when a BP hits or if a stepping operation has completed. if (Debugger.IsEvaluating || Debugger.EvalCompleted) break; evalDisabled = false; BringMainWindowToFrontAndActivate(); UpdateCurrentLocation(); if (currentMethod != null && currentLocation != null) JumpToCurrentStatement(MainWindow.Instance.SafeActiveTextView); SetReadyStatusMessage(new StoppedMessageCreator().GetMessage(Debugger)); break; case DebuggerProcessState.Terminated: evalDisabled = false; currentLocation = null; currentMethod = null; MainWindow.Instance.HideStatus(); MainWindow.Instance.ClearDebugging(); break; } }
internal void UpdateCurrentLocation(CorFrame frame) { var newLoc = GetCodeLocation(frame); if (currentLocation == null || newLoc == null) { currentLocation = newLoc; UpdateCurrentMethod(); return; } if (!CodeLocation.SameMethod(currentLocation.Value, newLoc.Value)) { currentLocation = newLoc; UpdateCurrentMethod(); return; } currentLocation = newLoc; }