diff --git a/src/Libraries/ICSharpCode.TextEditor/Project/Src/Gui/TextView.cs b/src/Libraries/ICSharpCode.TextEditor/Project/Src/Gui/TextView.cs index 7b67b87976..ee2b705bc3 100644 --- a/src/Libraries/ICSharpCode.TextEditor/Project/Src/Gui/TextView.cs +++ b/src/Libraries/ICSharpCode.TextEditor/Project/Src/Gui/TextView.cs @@ -414,7 +414,9 @@ namespace ICSharpCode.TextEditor DrawSpaceMarker(g, spaceMarkerForeColor, physicalXPos, lineRectangle.Y); } foreach (TextMarker marker in markers) { - DrawMarker(g, marker, spaceRectangle); + if (marker.TextMarkerType != TextMarkerType.SolidBlock) { + DrawMarker(g, marker, spaceRectangle); + } } physicalXPos += spaceWidth; @@ -451,7 +453,9 @@ namespace ICSharpCode.TextEditor } foreach (TextMarker marker in markers) { - DrawMarker(g, marker, tabRectangle); + if (marker.TextMarkerType != TextMarkerType.SolidBlock) { + DrawMarker(g, marker, tabRectangle); + } } physicalXPos += tabWidth; @@ -545,12 +549,12 @@ namespace ICSharpCode.TextEditor // bgColorBrush.Dispose(); // bgColorBrush = null; // } -// +// // if (selectionBackgroundBrush != null) { // selectionBackgroundBrush.Dispose(); // selectionBackgroundBrush = null; // } -// +// // if (unselectedBackgroundBrush != null) { // unselectedBackgroundBrush.Dispose(); // unselectedBackgroundBrush = null; @@ -568,16 +572,16 @@ namespace ICSharpCode.TextEditor // TextFormatFlags flags = TextFormatFlags.NoOverhangPadding | // TextFormatFlags.NoPrefix | // TextFormatFlags.NoFullWidthCharacterBreak | -// TextFormatFlags.NoClipping | +// TextFormatFlags.NoClipping | // TextFormatFlags.PreserveGraphicsClipping | // TextFormatFlags.PrefixOnly | // TextFormatFlags.SingleLine; // Size wordSize = TextRenderer.MeasureText(word, font, Size.Empty, flags); -// +// // if (DrawingPosition.Left < position.X + DrawingPosition.X) { // TextRenderer.DrawText(g, // word, -// font, +// font, // position, // foreColor, // ((SolidBrush)backBrush).Color, diff --git a/src/Main/Base/Project/ICSharpCode.SharpDevelop.csproj b/src/Main/Base/Project/ICSharpCode.SharpDevelop.csproj index 3695eb64ee..70cb8f42c5 100644 --- a/src/Main/Base/Project/ICSharpCode.SharpDevelop.csproj +++ b/src/Main/Base/Project/ICSharpCode.SharpDevelop.csproj @@ -423,7 +423,7 @@ - + diff --git a/src/Main/Base/Project/Src/Gui/Pads/CompilerMessageView/CompilerMessageView.cs b/src/Main/Base/Project/Src/Gui/Pads/CompilerMessageView/CompilerMessageView.cs index 0e345ebd48..954ea42a22 100644 --- a/src/Main/Base/Project/Src/Gui/Pads/CompilerMessageView/CompilerMessageView.cs +++ b/src/Main/Base/Project/Src/Gui/Pads/CompilerMessageView/CompilerMessageView.cs @@ -19,12 +19,13 @@ using ICSharpCode.Core; using ICSharpCode.SharpDevelop.Gui.OptionPanels; using ICSharpCode.SharpDevelop.Project; using ICSharpCode.TextEditor; +using ICSharpCode.TextEditor.Document; namespace ICSharpCode.SharpDevelop.Gui { /// /// This class displays the errors and warnings which the compiler outputs and - /// allows the user to jump to the source of the warnig / error + /// allows the user to jump to the source of the warning / error /// public class CompilerMessageView : AbstractPadContent, IClipboardHandler { @@ -36,8 +37,6 @@ namespace ICSharpCode.SharpDevelop.Gui } } -// RichTextBox textEditorControl = new RichTextBox(); - TextEditorControl textEditorControl = new TextEditorControl(); Panel myPanel = new Panel(); @@ -115,8 +114,7 @@ namespace ICSharpCode.SharpDevelop.Gui textEditorControl.Font = FontSelectionPanel.ParseFont(properties.Get("DefaultFont", new Font("Courier New", 10).ToString()).ToString()); properties.PropertyChanged += new PropertyChangedEventHandler(PropertyChanged); - textEditorControl.MouseDown += new MouseEventHandler(TextEditorControlMouseDown); - textEditorControl.BackColor = SystemColors.Window; + textEditorControl.ActiveTextAreaControl.TextArea.DoubleClick += TextEditorControlDoubleClick; ToolStrip toolStrip = ToolbarService.CreateToolStrip(this, "/SharpDevelop/Pads/CompilerMessageView/Toolbar"); toolStrip.Stretch = true; @@ -126,7 +124,7 @@ namespace ICSharpCode.SharpDevelop.Gui SetWordWrap(); myPanel.ResumeLayout(false); - SetText(StringParser.Parse(messageCategories[selectedCategory].Text)); + SetText(messageCategories[selectedCategory]); } void SetWordWrap() @@ -161,37 +159,33 @@ namespace ICSharpCode.SharpDevelop.Gui void CategoryTextCleared(object sender, EventArgs e) { - MessageViewCategory category = (MessageViewCategory)sender; - SelectCategory(category.Category); - WorkbenchSingleton.SafeThreadCall(this, "ClearText"); + WorkbenchSingleton.SafeThreadAsyncCall(this, "ClearText", sender); } - void ClearText() + void ClearText(MessageViewCategory category) { + SelectCategory(category.Category); textEditorControl.Text = ""; textEditorControl.Refresh(); } void CategoryTextSet(object sender, TextEventArgs e) { - MessageViewCategory category = (MessageViewCategory)sender; - SelectCategory(category.Category); - WorkbenchSingleton.SafeThreadCall(this, "SetText", StringParser.Parse(messageCategories[selectedCategory].Text)); + WorkbenchSingleton.SafeThreadAsyncCall(this, "SetText", (MessageViewCategory)sender); } void CategoryTextAppended(object sender, TextEventArgs e) { - MessageViewCategory category = (MessageViewCategory)sender; - int oldCategory = SelectedCategoryIndex; - SelectCategory(category.Category); - if (oldCategory != SelectedCategoryIndex) - WorkbenchSingleton.SafeThreadCall(this, "SetText", StringParser.Parse(messageCategories[selectedCategory].Text)); - else - WorkbenchSingleton.SafeThreadCall(this, "AppendText", StringParser.Parse(e.Text)); + WorkbenchSingleton.SafeThreadAsyncCall(this, "AppendText", (MessageViewCategory)sender, e.Text); } - void AppendText(string text) + void AppendText(MessageViewCategory category, string text) { + if (messageCategories[SelectedCategoryIndex] != category) { + SetText(category); + return; + } if (text != null) { + text = StringParser.Parse(text); textEditorControl.Document.ReadOnly = false; textEditorControl.Document.Insert(textEditorControl.Document.TextLength, text); textEditorControl.Document.ReadOnly = true; @@ -200,8 +194,9 @@ namespace ICSharpCode.SharpDevelop.Gui } } - void SetText(string text) + void SetText(MessageViewCategory category) { + string text = StringParser.Parse(category.Text); if (text == null) { text = String.Empty; } @@ -248,91 +243,23 @@ namespace ICSharpCode.SharpDevelop.Gui WorkbenchSingleton.Workbench.WorkbenchLayout.ActivatePad(this.GetType().FullName); } - void MessageCategorySelectedIndexChanged(object sender, EventArgs e) - { - WorkbenchSingleton.SafeThreadCall(this, "SetText", StringParser.Parse(messageCategories[selectedCategory].Text)); - } - /// /// Occurs when the mouse pointer is over the control and a /// mouse button is pressed. /// - void TextEditorControlMouseDown(object sender, MouseEventArgs e) + void TextEditorControlDoubleClick(object sender, EventArgs e) { -// // Double click? -// if (e.Clicks == 2) { -// // Any text? -// if (textEditorControl.Text.Length > 0) { -// -// // Parse text line double clicked. -// Point point = new Point(e.X, e.Y); -// -// int charIndex = textEditorControl.GetCharIndexFromPosition(point); -// string textLine = GetTextLine(charIndex, textEditorControl.Text); -// -// FileLineReference lineReference = OutputTextLineParser.GetFileLineReference(textLine); -// if (lineReference != null) { -// // Open matching file. -// JumpToFilePosition(Path.GetFullPath(lineReference.FileName), -// lineReference.Line, -// lineReference.Column); -// } -// } -// } - } - /// - /// Gets the line of text that includes the specified - /// character index. - /// - /// - /// This is used instead of using the - /// array since we have to take into account word wrapping. - /// - string GetTextLine(int charIndex, string textLines) - { - Debug.Assert(charIndex < textLines.Length, String.Concat("CharIndex out of range. charIndex=", charIndex, ", textLines.Length=", textLines.Length)); - - string textLine = String.Empty; - - int lineStartIndex = 0; - int lineLength = 0; - bool wasFound = false; - - for (int i = 0; i < textLines.Length; ++i) { - char ch = textLines[i]; + // Any text? + if (textEditorControl.Text.Length > 0) { + int line = textEditorControl.ActiveTextAreaControl.Caret.Line; + string textLine = TextUtilities.GetLineAsString(textEditorControl.Document, line); - if (ch == '\r' || ch == '\n') { - // End of line. - if (i >= charIndex) { - // Found line. - textLine = textLines.Substring(lineStartIndex, lineLength); - wasFound = true; - break; - } else { - lineStartIndex = i + 1; - lineLength = 0; - } - } else { - ++lineLength; + FileLineReference lineReference = OutputTextLineParser.GetFileLineReference(textLine); + if (lineReference != null) { + // Open matching file. + FileService.JumpToFilePosition(Path.GetFullPath(lineReference.FileName), lineReference.Line, lineReference.Column); } } - - if (!wasFound && (lineLength > 0)) { - textLine = textLines.Substring(lineStartIndex, lineLength); - } - - return textLine; - } - - /// - /// Jumps to the specified file line number and position. - /// - /// The filename. - /// The line number. - /// The line column - private void JumpToFilePosition(string filename, int line, int column) - { - FileService.JumpToFilePosition(filename, line, column); } /// diff --git a/src/Main/Base/Project/Src/Gui/Pads/CompilerMessageView/CompulerMessageViewToolbarCommands.cs b/src/Main/Base/Project/Src/Gui/Pads/CompilerMessageView/CompilerMessageViewToolbarCommands.cs similarity index 100% rename from src/Main/Base/Project/Src/Gui/Pads/CompilerMessageView/CompulerMessageViewToolbarCommands.cs rename to src/Main/Base/Project/Src/Gui/Pads/CompilerMessageView/CompilerMessageViewToolbarCommands.cs diff --git a/src/Main/Base/Project/Src/Gui/Pads/CompilerMessageView/OutputTextLineParser.cs b/src/Main/Base/Project/Src/Gui/Pads/CompilerMessageView/OutputTextLineParser.cs index d822a437f9..a4d227ebb6 100644 --- a/src/Main/Base/Project/Src/Gui/Pads/CompilerMessageView/OutputTextLineParser.cs +++ b/src/Main/Base/Project/Src/Gui/Pads/CompilerMessageView/OutputTextLineParser.cs @@ -14,32 +14,25 @@ namespace ICSharpCode.SharpDevelop.Gui /// Parses output text in the Output Build pad window and extracts source code /// file references. /// - public class OutputTextLineParser + public static class OutputTextLineParser { /// - /// Creates a new instance of the class. - /// - OutputTextLineParser() - { - } - - /// - /// Extracts source code file reference from the compiler output. + /// Extracts source code file reference from the c# compiler output. /// /// The text line to parse. - /// A if the line of text contains a + /// A if the line of text contains a /// file reference otherwise - public static FileLineReference GetCompilerOutputFileLineReference(string lineText) + public static FileLineReference GetCSharpCompilerFileLineReference(string lineText) { if (lineText != null) { - Match match = Regex.Match(lineText, @"^(.*?)\(([\d]*),([\d]*)\)"); + Match match = Regex.Match(lineText, @"^.*?(\w+:[/\\].*?)\(([\d]*),([\d]*)\)"); if (match.Success) { try { - // Take off 1 for line/pos since SharpDevelop is zero index based. + // Take off 1 for line/col since SharpDevelop is zero index based. int line = Convert.ToInt32(match.Groups[2].Value) - 1; - int pos = Convert.ToInt32(match.Groups[3].Value) - 1; + int col = Convert.ToInt32(match.Groups[3].Value) - 1; - return new FileLineReference(match.Groups[1].Value, line, pos); + return new FileLineReference(match.Groups[1].Value, line, col); } catch (Exception) { // Ignore. } @@ -57,12 +50,17 @@ namespace ICSharpCode.SharpDevelop.Gui /// file reference otherwise public static FileLineReference GetFileLineReference(string lineText) { - FileLineReference lineReference = GetCompilerOutputFileLineReference(lineText); + FileLineReference lineReference = GetCSharpCompilerFileLineReference(lineText); if (lineReference == null) { lineReference = GetNUnitOutputFileLineReference(lineText, false); } + if (lineReference == null) { + // Also works for VB compiler output. + lineReference = GetCppCompilerFileLineReference(lineText); + } + return lineReference; } @@ -85,12 +83,39 @@ namespace ICSharpCode.SharpDevelop.Gui int line = Convert.ToInt32(match.Groups[2].Value) - 1; return new FileLineReference(match.Groups[1].Value, line); } catch (Exception) { - // Ignore.i + // Ignore. } } } return null; - } + } + + /// + /// Extracts source code file reference from the c++ or VB.Net compiler output. + /// + /// The text line to parse. + /// A if the line of text contains a + /// file reference otherwise + public static FileLineReference GetCppCompilerFileLineReference(string lineText) + { + if (lineText != null ) { + + Match match = Regex.Match(lineText, @"^.*?(\w+:[/\\].*?)\(([\d]*)\) :"); + + if (match.Success) { + try { + // Take off 1 for line/pos since SharpDevelop is zero index based. + int line = Convert.ToInt32(match.Groups[2].Value) - 1; + + return new FileLineReference(match.Groups[1].Value.Trim(), line); + } catch (Exception) { + // Ignore. + } + } + } + + return null; + } } } diff --git a/src/Main/Base/Project/Src/Project/MSBuildEngine.cs b/src/Main/Base/Project/Src/Project/MSBuildEngine.cs index 649453043f..e1565d1961 100644 --- a/src/Main/Base/Project/Src/Project/MSBuildEngine.cs +++ b/src/Main/Base/Project/Src/Project/MSBuildEngine.cs @@ -159,11 +159,12 @@ namespace ICSharpCode.SharpDevelop.Project void AppendError(string file, int lineNumber, int columnNumber, string code, string message, bool isWarning) { + if (projectFiles.Count > 0) { + file = Path.Combine(Path.GetDirectoryName(projectFiles.Peek()), file); + } CompilerError error = new CompilerError(file, lineNumber, columnNumber, code, message); error.IsWarning = isWarning; AppendText(error.ToString()); - if (projectFiles.Count > 0) - error.FileName = Path.Combine(Path.GetDirectoryName(projectFiles.Peek()), file); results.Errors.Add(error); } diff --git a/src/Main/Base/Project/Src/Services/Debugger/DebuggerService.cs b/src/Main/Base/Project/Src/Services/Debugger/DebuggerService.cs index 6ddd47d333..e1d88b1d94 100644 --- a/src/Main/Base/Project/Src/Services/Debugger/DebuggerService.cs +++ b/src/Main/Base/Project/Src/Services/Debugger/DebuggerService.cs @@ -262,7 +262,10 @@ namespace ICSharpCode.Core if (textArea.ToolTipVisible) return; if (!CodeCompletionOptions.TooltipsEnabled) return; - // TODO: if (CodeCompletionOptions.TooltipsOnlyWhenDebugging && !isDebugging) return; + if (CodeCompletionOptions.TooltipsOnlyWhenDebugging) { + if (currentDebugger == null) return; + if (!currentDebugger.IsDebugging) return; + } Point mousepos = textArea.PointToClient(Control.MousePosition); Rectangle viewRect = textArea.TextView.DrawingPosition; diff --git a/src/Main/Base/Project/Src/Services/Tasks/Task.cs b/src/Main/Base/Project/Src/Services/Tasks/Task.cs index 909e0700fd..e3245aad67 100644 --- a/src/Main/Base/Project/Src/Services/Tasks/Task.cs +++ b/src/Main/Base/Project/Src/Services/Tasks/Task.cs @@ -99,8 +99,8 @@ namespace ICSharpCode.Core public Task(CompilerError error) { type = error.IsWarning ? TaskType.Warning : TaskType.Error; - column = error.Column - 1; - line = error.Line - 1; + column = Math.Max(error.Column - 1, 0); + line = Math.Max(error.Line - 1, 0); description = error.ErrorText + "(" + error.ErrorNumber + ")"; fileName = error.FileName; } @@ -108,21 +108,6 @@ namespace ICSharpCode.Core public void JumpToPosition() { FileService.JumpToFilePosition(fileName, line, column); -// CompilerResultListItem li = (CompilerResultListItem)OpenTaskView.FocusedItem; -// -// string filename = li.FileName; -// -// if (filename == null || filename.Equals("")) -// return; -// -// if (File.Exists(filename)) { -// string directory = Path.GetDirectoryName(filename); -// if (directory[directory.Length - 1] != Path.DirectorySeparatorChar) { -// directory += Path.DirectorySeparatorChar; -// } -// -// ContentWindow window = OpenWindow(filename); -// } } } } diff --git a/src/Main/Base/Project/Src/TextEditor/Gui/Editor/ErrorDrawer.cs b/src/Main/Base/Project/Src/TextEditor/Gui/Editor/ErrorDrawer.cs index f114e024dd..fbf1f61569 100644 --- a/src/Main/Base/Project/Src/TextEditor/Gui/Editor/ErrorDrawer.cs +++ b/src/Main/Base/Project/Src/TextEditor/Gui/Editor/ErrorDrawer.cs @@ -128,8 +128,8 @@ namespace ICSharpCode.SharpDevelop.DefaultEditor.Gui.Editor if (!CheckTask(task)) return; if (task.Line >= 0 && task.Line < textEditor.Document.TotalNumberOfLines) { LineSegment line = textEditor.Document.GetLineSegment(task.Line); + int offset = line.Offset + task.Column; if (line.Words != null) { - int offset = line.Offset + task.Column; foreach (TextWord tw in line.Words) { if (task.Column >= tw.Offset && task.Column < (tw.Offset + tw.Length)) { textEditor.Document.MarkerStrategy.AddMarker(new VisualError(offset, tw.Length, task)); @@ -140,10 +140,9 @@ namespace ICSharpCode.SharpDevelop.DefaultEditor.Gui.Editor } } } - /* - int startOffset = offset;//Math.Min(textEditor.Document.TextLength, TextUtilities.FindWordStart(textEditor.Document, offset)); - int endOffset = Math.Max(1, TextUtilities.FindWordEnd(textEditor.Document, offset)); - textEditor.Document.MarkerStrategy.TextMarker.Add(new VisualError(startOffset, endOffset - startOffset + 1, task.Description, task.TaskType == TaskType.Error));*/ + int startOffset = offset;//Math.Min(textEditor.Document.TextLength, TextUtilities.FindWordStart(textEditor.Document, offset)); + int endOffset = Math.Max(1, TextUtilities.FindWordEnd(textEditor.Document, offset)); + textEditor.Document.MarkerStrategy.AddMarker(new VisualError(startOffset, endOffset - startOffset + 1, task)); } } diff --git a/src/Tools/CheckFileHeaders/Main.cs b/src/Tools/CheckFileHeaders/Main.cs index 9d6871cb6e..a36dd76cae 100644 --- a/src/Tools/CheckFileHeaders/Main.cs +++ b/src/Tools/CheckFileHeaders/Main.cs @@ -21,10 +21,10 @@ namespace CheckFileHeaders try { MainClass m = new MainClass(); if (args.Length == 0) { - Console.WriteLine("Checking files in working directory..."); - count = m.Run(@"D:\Corsavy\SharpDevelop\src"); + Console.WriteLine("Checking files in {0} ...", Path.GetFullPath(@"..\..\..\..\")); + count = m.Run(@"..\..\..\..\"); } else { - Console.WriteLine("Checking files in {0}...", args[0]); + Console.WriteLine("Checking files in {0} ...", Path.GetFullPath(args[0])); count = m.Run(args[0]); } Console.WriteLine("Finished! (checked {0} files, changed {1} files, ignored {2} files)", count, m.changeCount, m.ignoreCount); @@ -36,7 +36,6 @@ namespace CheckFileHeaders return 0; } int Run(string dir) - { int count = 0; foreach (string file in Directory.GetFiles(dir, "*.cs")) { @@ -73,7 +72,7 @@ namespace CheckFileHeaders } // must be splitted because this file is under version control, too - Regex resetVersionRegex = new Regex(@"^// \$Revi" + @"sion: \d+ \$$"); + Regex resetVersionRegex = new Regex(@"// \$Revi" + @"sion: \d+ \$", RegexOptions.Compiled); int changeCount, ignoreCount; @@ -90,39 +89,34 @@ namespace CheckFileHeaders if (author == null) author = ""; if (author == "") { - if (file.IndexOf("Main\\Core\\") >= 0) { + Console.Write(file); + char ch; + do { + Console.WriteLine(); + Console.Write(" Mike/Daniel/Other/None/Ignore (M/D/O/N/I): "); + } + while ((ch = char.ToUpper(Console.ReadKey().KeyChar)) != 'M' + && ch != 'N' && ch != 'I' && ch != 'O' && ch != 'D'); + Console.WriteLine(); + if (ch == 'M') { author = "Omnibrain"; - } else { - Console.Write(file); - char ch; + } else if (ch == 'D') { + author = "Daniel Grunwald"; + } else if (ch == 'O') { + bool ok; do { - Console.WriteLine(); - Console.Write(" Mike/Daniel/Other/None/Ignore (M/D/O/N/I): "); - } - while ((ch = char.ToUpper(Console.ReadKey().KeyChar)) != 'M' - && ch != 'N' && ch != 'I' && ch != 'O' && ch != 'D'); - if (ch == 'M') { - author = "Omnibrain"; - } else if (ch == 'D') { - author = "Daniel Grunwald"; - } else if (ch == 'O') { - Console.WriteLine(); - bool ok; - do { - Console.Write("Enter author name: "); - author = Console.ReadLine(); - if (author == "David") author = "David Srbecky"; - if (author == "Markus") author = "Markus Palme"; - email = CheckAuthor(ref author); - ok = author != null; - } while (!ok); - } else if (ch == 'I') { - ignoreCount++; - return; - } else { - author = "none"; - } - Console.WriteLine(); + Console.Write("Enter author name: "); + author = Console.ReadLine(); + if (author == "David") author = "David Srbecky"; + if (author == "Markus") author = "Markus Palme"; + email = CheckAuthor(ref author); + ok = author != null; + } while (!ok); + } else if (ch == 'I') { + ignoreCount++; + return; + } else { + author = "none"; } } string oldAuthor = author; @@ -151,7 +145,8 @@ namespace CheckFileHeaders builder.Append(content.Substring(offset).Trim()); builder.AppendLine(); string newContent = builder.ToString(); - if (newContent != resetVersionRegex.Replace(content, versionLine)) { + string resettedVersion = resetVersionRegex.Replace(content, versionLine); + if (newContent != resettedVersion) { using (StreamWriter w = new StreamWriter(file, false, GetOptimalEncoding(newContent))) { changeCount++; w.Write(newContent); @@ -174,7 +169,7 @@ namespace CheckFileHeaders case "David Srbecky": case "David Srbeck": author = "David Srbecký"; - return "dsrbecky@post.cz"; + return "dsrbecky@gmail.com"; case "Andrea Paatz": //case "Andrea": author = "Andrea Paatz";