private static XmlElement KeepOrThrow(QueryParser parser, int errorCode, string message, int start, int end) { // // Error object. // ParseError error = new ParseError(errorCode, message, start, end); // // Check run mode. // if (parser._errors != null) { // // Create error message and add it to the errors collection of the query object. // int id = parser._errors.Add(error); // // Generate an error reference tag that will be inserted in the generated CAML on the faulting position. // return(parser._factory.ParseError(id)); } else { // // Runtime mode: throw an exception. // NotSupportedException ex = new NotSupportedException(error.ToString()); ex.HelpLink = error.HelpLink; throw ex; } }
private void txtCaml_MouseMove(object sender, MouseEventArgs e) { // // Get the position inside the textbox based on the mouse cursor position. // int i = txtCaml.GetCharIndexFromPosition(e.Location); // // Find the error (if any) that corresponds to the current position. // We expect the number of errors to be low, so we just iterate over the collection. // foreach (var pos in _camlPositions) { ParseError error = _errors[pos.Key]; // // Matching position? // if (pos.Value.Start <= i && i <= pos.Value.End) { // // Compare to selected error (if any). // if (currentError == null || currentError != error) { // // Clear previous error display. // ClearSelections(); // // Mark error. // MarkError(pos.Key, error, true); // // Unselect for pretty display. // txtLinq.Select(0, 0); txtCaml.Select(0, 0); // // Set cursor on CAML textbox to indicate the possibility to click it (act as a link). // txtCaml.Cursor = Cursors.Hand; // // Set the current error. // currentError = error; } // // Set the tooltip. // camlTip.SetToolTip(txtCaml, error.ToString()); // // Found and done. // return; } } // // No error found. Clean the error display if a previous selected error is still displayed. // if (currentError != null) { ClearSelections(); } }