Browse Source

Fixed parser crash introduced in last revision.

Made debugger addin lazy-loading.
Fixed bug in MarkerStrategy causing parts of removed markers still being rendered.

git-svn-id: svn://svn.sharpdevelop.net/sharpdevelop/trunk@243 1ccf3a8d-04fe-1044-b7c0-cef0b8235c61
shortcuts
Daniel Grunwald 21 years ago
parent
commit
3d3b57eec6
  1. 12
      AddIns/ICSharpCode.SharpDevelop.addin
  2. 14
      src/AddIns/Misc/Debugger/Debugger.AddIn/Project/Debugger.AddIn.addin
  3. 1
      src/AddIns/Misc/Debugger/Debugger.AddIn/Project/Debugger.AddIn.csproj
  4. 20
      src/AddIns/Misc/Debugger/Debugger.AddIn/Project/Src/Pads/ViewMenuItemBuilder.cs
  5. 2
      src/Libraries/ICSharpCode.TextEditor/Project/Src/Document/BookmarkManager/Bookmark.cs
  6. 33
      src/Libraries/ICSharpCode.TextEditor/Project/Src/Document/MarkerStrategy/MarkerStrategy.cs
  7. 2
      src/Libraries/ICSharpCode.TextEditor/Project/Src/Gui/IconBarMargin.cs
  8. 2
      src/Libraries/NRefactory/Project/Src/Parser/CSharp/Parser.cs
  9. 2
      src/Libraries/NRefactory/Project/Src/Parser/CSharp/cs.ATG
  10. 1
      src/Main/Base/Project/ICSharpCode.SharpDevelop.csproj
  11. 53
      src/Main/Base/Project/Src/Commands/MenuItemBuilders.cs
  12. 1
      src/Main/Base/Project/Src/Dom/NRefactoryResolver/TypeVisitor.cs
  13. 4
      src/Main/Base/Project/Src/Gui/Pads/CompilerMessageView/CompilerMessageView.cs
  14. 2
      src/Main/Base/Project/Src/Internal/Auswerter/DebuggerSupportsAuswerter.cs
  15. 10
      src/Main/Base/Project/Src/Internal/Auswerter/IsProcessRunningAuswerter.cs
  16. 21
      src/Main/Base/Project/Src/Services/Debugger/BreakpointBookmark.cs
  17. 82
      src/Main/Base/Project/Src/Services/Debugger/CurrentLineBookmark.cs
  18. 145
      src/Main/Base/Project/Src/Services/Debugger/DebuggerService.cs
  19. 46
      src/Main/Base/Project/Src/TextEditor/Bookmarks/Bookmark.cs
  20. 24
      src/Main/Base/Project/Src/TextEditor/Gui/Editor/ErrorDrawer.cs

12
AddIns/ICSharpCode.SharpDevelop.addin

@ -1877,4 +1877,16 @@
extensions = ".css" extensions = ".css"
resource = "Icons.16x16.CSSIcon"/> resource = "Icons.16x16.CSSIcon"/>
</Path> </Path>
<Path name = "/SharpDevelop/Workbench/MainMenu/View">
<MenuItem id = "Debugger"
label = "${res:XML.MainMenu.ViewMenu.DebugMenu}"
type = "Menu"
insertafter = "Tools"
insertbefore = "ViewItemsSeparator">
<MenuItem id = "DebugViewMenuBuilder"
type = "Builder"
class = "ICSharpCode.SharpDevelop.Commands.DebugViewMenuBuilder"/>
</MenuItem>
</Path>
</AddIn> </AddIn>

14
src/AddIns/Misc/Debugger/Debugger.AddIn/Project/Debugger.AddIn.addin

@ -1,4 +1,4 @@
<AddIn name="SharpDevelop Debugger" author="David Srbecký" copyright="GPL" url="" description="SharpDevelop Managed Debugger" version="0.1.0.0"> <AddIn name="SharpDevelop Debugger" author="David Srbecký" copyright="GPL" url="" description="SharpDevelop Managed Debugger" version="0.1.0.0">
<Runtime> <Runtime>
<Import assembly="Debugger.AddIn.dll"/> <Import assembly="Debugger.AddIn.dll"/>
</Runtime> </Runtime>
@ -7,18 +7,6 @@
<Class id="DefaultDebugger" class="ICSharpCode.SharpDevelop.Services.WindowsDebugger"/> <Class id="DefaultDebugger" class="ICSharpCode.SharpDevelop.Services.WindowsDebugger"/>
</Path> </Path>
<Path name = "/SharpDevelop/Workbench/MainMenu/View">
<MenuItem id = "Debugger"
label = "${res:XML.MainMenu.ViewMenu.DebugMenu}"
type = "Menu"
insertafter = "Tools"
insertbefore = "ViewItemsSeparator">
<MenuItem id = "DebugViewMenuBuilder"
type = "Builder"
class = "ICSharpCode.SharpDevelop.Commands.DebugViewMenuBuilder"/>
</MenuItem>
</Path>
<!--<Path name = "/SharpDevelop/Workbench/MainMenu/Debug"> <!--<Path name = "/SharpDevelop/Workbench/MainMenu/Debug">
<MenuItem id = "CatchHandledExceptionsSeparator" <MenuItem id = "CatchHandledExceptionsSeparator"
type = "Separator" type = "Separator"

1
src/AddIns/Misc/Debugger/Debugger.AddIn/Project/Debugger.AddIn.csproj

@ -59,7 +59,6 @@
<EmbeddedResource Include="Src\Service\ExceptionForm.resx"> <EmbeddedResource Include="Src\Service\ExceptionForm.resx">
<DependentUpon>ExceptionForm.cs</DependentUpon> <DependentUpon>ExceptionForm.cs</DependentUpon>
</EmbeddedResource> </EmbeddedResource>
<Compile Include="Src\Pads\ViewMenuItemBuilder.cs" />
</ItemGroup> </ItemGroup>
<ItemGroup> <ItemGroup>
<ProjectReference Include="..\..\..\..\..\Libraries\ICSharpCode.TextEditor\Project\ICSharpCode.TextEditor.csproj"> <ProjectReference Include="..\..\..\..\..\Libraries\ICSharpCode.TextEditor\Project\ICSharpCode.TextEditor.csproj">

20
src/AddIns/Misc/Debugger/Debugger.AddIn/Project/Src/Pads/ViewMenuItemBuilder.cs

@ -1,20 +0,0 @@
// <file>
// <copyright see="prj:///doc/copyright.txt">2002-2005 AlphaSierraPapa</copyright>
// <license see="prj:///doc/license.txt">GNU General Public License</license>
// <owner name="David Srbecký" email="dsrbecky@gmail.com"/>
// <version>$Revision$</version>
// </file>
using System;
namespace ICSharpCode.SharpDevelop.Commands
{
public class DebugViewMenuBuilder : ViewMenuBuilder
{
protected override string Category {
get {
return "Debugger";
}
}
}
}

2
src/Libraries/ICSharpCode.TextEditor/Project/Src/Document/BookmarkManager/Bookmark.cs

@ -97,7 +97,7 @@ namespace ICSharpCode.TextEditor.Document
public virtual void Click(SWF.Control parent, SWF.MouseEventArgs e) public virtual void Click(SWF.Control parent, SWF.MouseEventArgs e)
{ {
if (e.Button == SWF.MouseButtons.Left) { if (e.Button == SWF.MouseButtons.Left && CanToggle) {
document.BookmarkManager.RemoveMark(this); document.BookmarkManager.RemoveMark(this);
} }
} }

33
src/Libraries/ICSharpCode.TextEditor/Project/Src/Document/MarkerStrategy/MarkerStrategy.cs

@ -12,9 +12,9 @@ using System.Diagnostics;
using System.Collections.Generic; using System.Collections.Generic;
namespace ICSharpCode.TextEditor.Document namespace ICSharpCode.TextEditor.Document
{ {
/// <summary> /// <summary>
/// Description of MarkerStrategy. /// Description of MarkerStrategy.
/// </summary> /// </summary>
public class MarkerStrategy public class MarkerStrategy
{ {
@ -27,19 +27,42 @@ namespace ICSharpCode.TextEditor.Document
} }
} }
public List<TextMarker> TextMarker { public IEnumerable<TextMarker> TextMarker {
get { get {
return textMarker; return textMarker;
} }
} }
public void AddMarker(TextMarker item)
{
markersTable.Clear();
textMarker.Add(item);
}
public void InsertMarker(int index, TextMarker item)
{
markersTable.Clear();
textMarker.Insert(index, item);
}
public void RemoveMarker(TextMarker item)
{
markersTable.Clear();
textMarker.Remove(item);
}
public void RemoveAll(Predicate<TextMarker> match)
{
markersTable.Clear();
textMarker.RemoveAll(match);
}
public MarkerStrategy(IDocument document) public MarkerStrategy(IDocument document)
{ {
this.document = document; this.document = document;
document.DocumentChanged += new DocumentEventHandler(DocumentChanged); document.DocumentChanged += new DocumentEventHandler(DocumentChanged);
} }
//// Alex: minimize GC allocations - it's heavy on heap
Dictionary<int, List<TextMarker>> markersTable = new Dictionary<int, List<TextMarker>>(); Dictionary<int, List<TextMarker>> markersTable = new Dictionary<int, List<TextMarker>>();
public List<TextMarker> GetMarkers(int offset) public List<TextMarker> GetMarkers(int offset)
@ -66,7 +89,7 @@ namespace ICSharpCode.TextEditor.Document
marker.Offset <= offset + length && offset + length <= marker.Offset + marker.Length || marker.Offset <= offset + length && offset + length <= marker.Offset + marker.Length ||
offset <= marker.Offset && marker.Offset <= offset + length || offset <= marker.Offset && marker.Offset <= offset + length ||
offset <= marker.Offset + marker.Length && marker.Offset + marker.Length <= offset + length offset <= marker.Offset + marker.Length && marker.Offset + marker.Length <= offset + length
) { ) {
markers.Add(marker); markers.Add(marker);
} }
} }

2
src/Libraries/ICSharpCode.TextEditor/Project/Src/Gui/IconBarMargin.cs

@ -68,7 +68,7 @@ namespace ICSharpCode.TextEditor
int lineNumber = textArea.Document.GetVisibleLine(mark.LineNumber); int lineNumber = textArea.Document.GetVisibleLine(mark.LineNumber);
int fontHeight = textArea.TextView.FontHeight; int fontHeight = textArea.TextView.FontHeight;
int yPos = lineNumber * fontHeight - textArea.VirtualTop.Y; int yPos = lineNumber * fontHeight - textArea.VirtualTop.Y;
if (mousePos.Y > yPos && mousePos.Y < yPos + fontHeight) { if (mousePos.Y >= yPos && mousePos.Y < yPos + fontHeight) {
mark.Click(textArea, new MouseEventArgs(mouseButtons, 1, mousePos.X, mousePos.Y, 0)); mark.Click(textArea, new MouseEventArgs(mouseButtons, 1, mousePos.X, mousePos.Y, 0));
if (oldCount != marks.Count) { if (oldCount != marks.Count) {
textArea.UpdateLine(lineNumber); textArea.UpdateLine(lineNumber);

2
src/Libraries/NRefactory/Project/Src/Parser/CSharp/Parser.cs

@ -2608,7 +2608,7 @@ IsPointer()) {
} }
#line 929 "cs.ATG" #line 929 "cs.ATG"
type.PointerNestingLevel = pointer; if (type != null) { type.PointerNestingLevel = pointer; }
} }
void FixedParameter( void FixedParameter(

2
src/Libraries/NRefactory/Project/Src/Parser/CSharp/cs.ATG

@ -926,7 +926,7 @@ NonArrayType<out TypeReference type>
{ IF (IsPointer()) { IF (IsPointer())
"*" (. ++pointer; .) "*" (. ++pointer; .)
} }
(. type.PointerNestingLevel = pointer; .) (. if (type != null) { type.PointerNestingLevel = pointer; } .)
. .
SimpleType<out string name> SimpleType<out string name>

1
src/Main/Base/Project/ICSharpCode.SharpDevelop.csproj

@ -681,6 +681,7 @@
<EmbeddedResource Include="Resources\CodeCompletionOptionPanel.xfrm" /> <EmbeddedResource Include="Resources\CodeCompletionOptionPanel.xfrm" />
<Compile Include="Src\TextEditor\Gui\OptionPanels\CodeCompletionPanel.cs" /> <Compile Include="Src\TextEditor\Gui\OptionPanels\CodeCompletionPanel.cs" />
<Compile Include="Src\Dom\CodeCompletionOptions.cs" /> <Compile Include="Src\Dom\CodeCompletionOptions.cs" />
<Compile Include="Src\Services\Debugger\CurrentLineBookmark.cs" />
</ItemGroup> </ItemGroup>
<ItemGroup> <ItemGroup>
<ProjectReference Include="..\..\..\Libraries\DockPanel_Src\WinFormsUI\WinFormsUI.csproj"> <ProjectReference Include="..\..\..\Libraries\DockPanel_Src\WinFormsUI\WinFormsUI.csproj">

53
src/Main/Base/Project/Src/Commands/MenuItemBuilders.cs

@ -66,7 +66,7 @@ namespace ICSharpCode.SharpDevelop.Commands
items[i] = new MenuCommand(accelaratorKeyPrefix + recentOpen.RecentProject[i], new EventHandler(LoadRecentProject)); items[i] = new MenuCommand(accelaratorKeyPrefix + recentOpen.RecentProject[i], new EventHandler(LoadRecentProject));
items[i].Tag = recentOpen.RecentProject[i].ToString(); items[i].Tag = recentOpen.RecentProject[i].ToString();
items[i].Description = StringParser.Parse(ResourceService.GetString("Dialog.Componnents.RichMenuItem.LoadProjectDescription"), items[i].Description = StringParser.Parse(ResourceService.GetString("Dialog.Componnents.RichMenuItem.LoadProjectDescription"),
new string[,] { {"PROJECT", recentOpen.RecentProject[i].ToString()} }); new string[,] { {"PROJECT", recentOpen.RecentProject[i].ToString()} });
} }
return items; return items;
} }
@ -173,15 +173,15 @@ namespace ICSharpCode.SharpDevelop.Commands
MessageService.ShowError(ex, "External program execution failed.\nError while starting:\n '" + command + " " + args + "'"); MessageService.ShowError(ex, "External program execution failed.\nError while starting:\n '" + command + " " + args + "'");
} }
break; break;
}
} }
} }
} }
}
public class OpenContentsMenuBuilder : ISubmenuBuilder public class OpenContentsMenuBuilder : ISubmenuBuilder
{ {
class MyMenuItem : MenuCheckBox class MyMenuItem : MenuCheckBox
{ {
IViewContent content; IViewContent content;
@ -224,20 +224,20 @@ namespace ICSharpCode.SharpDevelop.Commands
// public class IncludeFilesBuilder : ISubmenuBuilder // public class IncludeFilesBuilder : ISubmenuBuilder
// { // {
// public ProjectBrowserView browser; // public ProjectBrowserView browser;
// //
// MyMenuItem includeInCompileItem; // MyMenuItem includeInCompileItem;
// MyMenuItem includeInDeployItem; // MyMenuItem includeInDeployItem;
// //
// class MyMenuItem : MenuCheckBox // class MyMenuItem : MenuCheckBox
// { // {
// IncludeFilesBuilder builder; // IncludeFilesBuilder builder;
// //
// public MyMenuItem(IncludeFilesBuilder builder, string name, EventHandler handler) : base(null, null, name) // public MyMenuItem(IncludeFilesBuilder builder, string name, EventHandler handler) : base(null, null, name)
// { // {
// base.Click += handler; // base.Click += handler;
// this.builder = builder; // this.builder = builder;
// } // }
// //
// public override void UpdateStatus() // public override void UpdateStatus()
// { // {
// base.UpdateStatus(); // base.UpdateStatus();
@ -245,11 +245,11 @@ namespace ICSharpCode.SharpDevelop.Commands
// return; // return;
// } // }
// AbstractBrowserNode node = builder.browser.SelectedNode as AbstractBrowserNode; // AbstractBrowserNode node = builder.browser.SelectedNode as AbstractBrowserNode;
// //
// if (node == null) { // if (node == null) {
// return; // return;
// } // }
// //
// ProjectFile finfo = node.UserData as ProjectFile; // ProjectFile finfo = node.UserData as ProjectFile;
// if (finfo == null) { // if (finfo == null) {
// builder.includeInCompileItem.Enabled = builder.includeInCompileItem.Enabled = false; // builder.includeInCompileItem.Enabled = builder.includeInCompileItem.Enabled = false;
@ -262,27 +262,27 @@ namespace ICSharpCode.SharpDevelop.Commands
// } // }
// } // }
// } // }
// //
// public ToolStripItem[] BuildSubmenu(Codon codon, object owner) // public ToolStripItem[] BuildSubmenu(Codon codon, object owner)
// { // {
// browser = (ProjectBrowserView)owner; // browser = (ProjectBrowserView)owner;
// includeInCompileItem = new MyMenuItem(this, "${res:ProjectComponent.ContextMenu.IncludeMenu.InCompile}", new EventHandler(ChangeCompileInclude)); // includeInCompileItem = new MyMenuItem(this, "${res:ProjectComponent.ContextMenu.IncludeMenu.InCompile}", new EventHandler(ChangeCompileInclude));
// includeInDeployItem = new MyMenuItem(this, "${res:ProjectComponent.ContextMenu.IncludeMenu.InDeploy}", new EventHandler(ChangeDeployInclude)); // includeInDeployItem = new MyMenuItem(this, "${res:ProjectComponent.ContextMenu.IncludeMenu.InDeploy}", new EventHandler(ChangeDeployInclude));
// //
// return new ToolStripItem[] { // return new ToolStripItem[] {
// includeInCompileItem, // includeInCompileItem,
// includeInDeployItem // includeInDeployItem
// }; // };
// //
// } // }
// void ChangeCompileInclude(object sender, EventArgs e) // void ChangeCompileInclude(object sender, EventArgs e)
// { // {
// AbstractBrowserNode node = browser.SelectedNode as AbstractBrowserNode; // AbstractBrowserNode node = browser.SelectedNode as AbstractBrowserNode;
// //
// if (node == null) { // if (node == null) {
// return; // return;
// } // }
// //
// ProjectFile finfo = node.UserData as ProjectFile; // ProjectFile finfo = node.UserData as ProjectFile;
// if (finfo != null) { // if (finfo != null) {
// if (finfo.BuildAction == BuildAction.Compile) { // if (finfo.BuildAction == BuildAction.Compile) {
@ -291,18 +291,18 @@ namespace ICSharpCode.SharpDevelop.Commands
// finfo.BuildAction = BuildAction.Compile; // finfo.BuildAction = BuildAction.Compile;
// } // }
// } // }
// //
// ProjectService.SaveCombine(); // ProjectService.SaveCombine();
// } // }
// //
// void ChangeDeployInclude(object sender, EventArgs e) // void ChangeDeployInclude(object sender, EventArgs e)
// { // {
// AbstractBrowserNode node = browser.SelectedNode as AbstractBrowserNode; // AbstractBrowserNode node = browser.SelectedNode as AbstractBrowserNode;
// //
// if (node == null) { // if (node == null) {
// return; // return;
// } // }
// //
// ProjectFile finfo = node.UserData as ProjectFile; // ProjectFile finfo = node.UserData as ProjectFile;
// if (finfo != null) { // if (finfo != null) {
// if (node.Project.DeployInformation.IsFileExcluded(finfo.Name)) { // if (node.Project.DeployInformation.IsFileExcluded(finfo.Name)) {
@ -311,7 +311,7 @@ namespace ICSharpCode.SharpDevelop.Commands
// node.Project.DeployInformation.AddExcludedFile(finfo.Name); // node.Project.DeployInformation.AddExcludedFile(finfo.Name);
// } // }
// } // }
// //
// ProjectService.SaveCombine(); // ProjectService.SaveCombine();
// } // }
// } // }
@ -330,7 +330,16 @@ namespace ICSharpCode.SharpDevelop.Commands
protected override string Category { protected override string Category {
get { get {
return "Main"; return "Main";
} }
}
}
public class DebugViewMenuBuilder : ViewMenuBuilder
{
protected override string Category {
get {
return "Debugger";
}
} }
} }

1
src/Main/Base/Project/Src/Dom/NRefactoryResolver/TypeVisitor.cs

@ -299,7 +299,6 @@ namespace ICSharpCode.SharpDevelop.Dom.NRefactoryResolver
public override object Visit(TypeReferenceExpression typeReferenceExpression, object data) public override object Visit(TypeReferenceExpression typeReferenceExpression, object data)
{ {
System.Diagnostics.Debugger.Break();
return CreateReturnType(typeReferenceExpression.TypeReference); return CreateReturnType(typeReferenceExpression.TypeReference);
} }

4
src/Main/Base/Project/Src/Gui/Pads/CompilerMessageView/CompilerMessageView.cs

@ -222,7 +222,9 @@ namespace ICSharpCode.SharpDevelop.Gui
break; break;
} }
} }
ActivateThisPad(); if (!this.IsVisible) {
ActivateThisPad();
}
} }
public MessageViewCategory GetCategory(string categoryName) public MessageViewCategory GetCategory(string categoryName)

2
src/Main/Base/Project/Src/Internal/Auswerter/DebuggerSupportsAuswerter.cs

@ -16,7 +16,7 @@ namespace ICSharpCode.Core
{ {
public bool IsValid(object caller, Condition condition) public bool IsValid(object caller, Condition condition)
{ {
IDebugger debugger = DebuggerService.CurrentDebugger as IDebugger; IDebugger debugger = DebuggerService.IsDebuggerLoaded ? DebuggerService.CurrentDebugger : new DefaultDebugger();
if (debugger != null) { if (debugger != null) {
switch (condition.Properties["debuggersupports"]) { switch (condition.Properties["debuggersupports"]) {
case "Start": case "Start":

10
src/Main/Base/Project/Src/Internal/Auswerter/IsProcessRunningAuswerter.cs

@ -18,12 +18,14 @@ namespace ICSharpCode.Core
{ {
string isdebugging = condition.Properties.Get("isdebugging", String.Empty); string isdebugging = condition.Properties.Get("isdebugging", String.Empty);
string isprocessrunning = condition.Properties.Get("isprocessrunning", String.Empty); string isprocessrunning = condition.Properties.Get("isprocessrunning", String.Empty);
bool debuggerIsDebugging = DebuggerService.IsDebuggerLoaded ? DebuggerService.CurrentDebugger.IsDebugging : false;
bool isdebuggingPassed = (isdebugging == String.Empty) || bool debuggerIsProcessRunning = DebuggerService.IsDebuggerLoaded ? DebuggerService.CurrentDebugger.IsProcessRunning : false;
(DebuggerService.CurrentDebugger.IsDebugging == Boolean.Parse(isdebugging));
bool isdebuggingPassed = (isdebugging == String.Empty) ||
(debuggerIsDebugging == Boolean.Parse(isdebugging));
bool isprocessrunningPassed = (isprocessrunning == String.Empty) || bool isprocessrunningPassed = (isprocessrunning == String.Empty) ||
(DebuggerService.CurrentDebugger.IsProcessRunning == Boolean.Parse(isprocessrunning)); (debuggerIsProcessRunning == Boolean.Parse(isprocessrunning));
return isdebuggingPassed && isprocessrunningPassed; return isdebuggingPassed && isprocessrunningPassed;
} }

21
src/Main/Base/Project/Src/Services/Debugger/BreakpointBookmark.cs

@ -1,7 +1,7 @@
// <file> // <file>
// <copyright see="prj:///doc/copyright.txt">2002-2005 AlphaSierraPapa</copyright> // <copyright see="prj:///doc/copyright.txt">2002-2005 AlphaSierraPapa</copyright>
// <license see="prj:///doc/license.txt">GNU General Public License</license> // <license see="prj:///doc/license.txt">GNU General Public License</license>
// <owner name="Mike Krüger" email="mike@icsharpcode.net"/> // <owner name="Daniel Grunwald" email="daniel@danielgrunwald.de"/>
// <version>$Revision$</version> // <version>$Revision$</version>
// </file> // </file>
@ -13,10 +13,12 @@ using System.Collections;
using System.IO; using System.IO;
using System.Diagnostics; using System.Diagnostics;
using ICSharpCode.SharpDevelop.Bookmarks; using ICSharpCode.SharpDevelop.Bookmarks;
using ICSharpCode.TextEditor;
using ICSharpCode.TextEditor.Document;
namespace ICSharpCode.Core namespace ICSharpCode.Core
{ {
public class BreakpointBookmark: SDBookmark public class BreakpointBookmark: SDMarkerBookmark
{ {
object tag; object tag;
@ -28,15 +30,22 @@ namespace ICSharpCode.Core
tag = value; tag = value;
} }
} }
public BreakpointBookmark(string fileName, ICSharpCode.TextEditor.Document.IDocument document, int lineNumber) : base(fileName, document, lineNumber) public BreakpointBookmark(string fileName, IDocument document, int lineNumber) : base(fileName, document, lineNumber)
{ {
} }
public override void Draw(ICSharpCode.TextEditor.IconBarMargin margin, Graphics g, Point p) public override void Draw(IconBarMargin margin, Graphics g, Point p)
{ {
margin.DrawBreakpoint(g, p.Y, IsEnabled); margin.DrawBreakpoint(g, p.Y, IsEnabled);
} }
protected override TextMarker CreateMarker()
{
LineSegment lineSeg = Document.GetLineSegment(LineNumber);
TextMarker marker = new TextMarker(lineSeg.Offset, lineSeg.Length, TextMarkerType.SolidBlock, Color.Red, Color.White);
Document.MarkerStrategy.AddMarker(marker);
return marker;
}
} }
} }

82
src/Main/Base/Project/Src/Services/Debugger/CurrentLineBookmark.cs

@ -0,0 +1,82 @@
// <file>
// <copyright see="prj:///doc/copyright.txt">2002-2005 AlphaSierraPapa</copyright>
// <license see="prj:///doc/license.txt">GNU General Public License</license>
// <owner name="Daniel Grunwald" email="daniel@danielgrunwald.de"/>
// <version>$Revision$</version>
// </file>
using System;
using System.Windows.Forms;
using System.Drawing;
using System.CodeDom.Compiler;
using System.Collections;
using System.IO;
using System.Diagnostics;
using ICSharpCode.SharpDevelop.Gui;
using ICSharpCode.SharpDevelop.Bookmarks;
using ICSharpCode.TextEditor;
using ICSharpCode.TextEditor.Document;
using ICSharpCode.SharpDevelop.DefaultEditor.Gui.Editor;
namespace ICSharpCode.Core
{
public class CurrentLineBookmark: SDMarkerBookmark
{
static CurrentLineBookmark instance;
public static void SetPosition(IViewContent viewContent, int startLine, int startColumn, int endLine, int endColumn)
{
ITextEditorControlProvider tecp = viewContent as ITextEditorControlProvider;
if (tecp != null)
SetPosition(tecp.TextEditorControl.FileName, tecp.TextEditorControl.Document, startLine, startColumn, endLine, endColumn);
else
Remove();
}
public static void SetPosition(string fileName, IDocument document, int startLine, int startColumn, int endLine, int endColumn)
{
Remove();
LineSegment line = document.GetLineSegment(startLine - 1);
int offset = line.Offset + startColumn;
instance = new CurrentLineBookmark(fileName, document, startLine - 1);
document.BookmarkManager.AddMark(instance);
//currentLineMarker = new TextMarker(offset, endColumn - startColumn, TextMarkerType.SolidBlock, Color.Yellow, Color.Blue);
//currentLineMarkerParent = document;
//currentLineMarkerParent.MarkerStrategy.AddMarker(currentLineMarker);
document.RequestUpdate(new TextAreaUpdate(TextAreaUpdateType.SingleLine, startLine - 1));
document.CommitUpdate();
}
public static void Remove()
{
if (instance != null) {
instance.RemoveMarker();
instance.Document.BookmarkManager.RemoveMark(instance);
instance = null;
}
}
public override bool CanToggle {
get {
return false;
}
}
public CurrentLineBookmark(string fileName, IDocument document, int lineNumber) : base(fileName, document, lineNumber)
{
}
public override void Draw(IconBarMargin margin, Graphics g, Point p)
{
margin.DrawArrow(g, p.Y);
}
protected override TextMarker CreateMarker()
{
LineSegment lineSeg = Document.GetLineSegment(LineNumber);
TextMarker marker = new TextMarker(lineSeg.Offset, lineSeg.Length, TextMarkerType.SolidBlock, Color.Yellow, Color.Blue);
Document.MarkerStrategy.InsertMarker(0, marker);
return marker;
}
}
}

145
src/Main/Base/Project/Src/Services/Debugger/DebuggerService.cs

@ -12,7 +12,6 @@ using System.Collections.Generic;
using System.IO; using System.IO;
using System.Text; using System.Text;
using ICSharpCode.Core;
using ICSharpCode.SharpDevelop.Gui; using ICSharpCode.SharpDevelop.Gui;
using ICSharpCode.SharpDevelop.Dom; using ICSharpCode.SharpDevelop.Dom;
using ICSharpCode.SharpDevelop.Project; using ICSharpCode.SharpDevelop.Project;
@ -32,22 +31,10 @@ namespace ICSharpCode.Core
static DebuggerService() static DebuggerService()
{ {
AddInTreeNode treeNode = null;
try {
treeNode = AddInTree.GetTreeNode("/SharpDevelop/Services/DebuggerService/Debugger");
} catch (Exception) {
}
if (treeNode != null) {
debuggers = treeNode.BuildChildItems(null);
}
if (debuggers == null) {
debuggers = new ArrayList();
}
ProjectService.SolutionLoaded += delegate { ProjectService.SolutionLoaded += delegate {
ClearDebugMessages(); ClearDebugMessages();
}; };
WorkbenchSingleton.WorkbenchCreated += new EventHandler(WorkspaceCreated); WorkbenchSingleton.WorkbenchCreated += new EventHandler(WorkspaceCreated);
BM.BookmarkManager.Added += BookmarkAdded; BM.BookmarkManager.Added += BookmarkAdded;
BM.BookmarkManager.Removed += BookmarkRemoved; BM.BookmarkManager.Removed += BookmarkRemoved;
@ -59,6 +46,9 @@ namespace ICSharpCode.Core
if (ProjectService.OpenSolution != null) { if (ProjectService.OpenSolution != null) {
project = ProjectService.OpenSolution.StartupProject; project = ProjectService.OpenSolution.StartupProject;
} }
if (debuggers == null) {
debuggers = AddInTree.BuildItems("/SharpDevelop/Services/DebuggerService/Debugger", null, false);
}
foreach (IDebugger d in debuggers) { foreach (IDebugger d in debuggers) {
if (d.CanDebug(project)) { if (d.CanDebug(project)) {
return d; return d;
@ -66,7 +56,12 @@ namespace ICSharpCode.Core
} }
return new DefaultDebugger(); return new DefaultDebugger();
} }
/// <summary>
/// Gets the current debugger. The debugger addin is loaded on demand; so if you
/// just want to check a property like IsDebugging, use <see cref="LoadedDebugger"/>
/// instead.
/// </summary>
public static IDebugger CurrentDebugger { public static IDebugger CurrentDebugger {
get { get {
if (currentDebugger == null) { if (currentDebugger == null) {
@ -77,7 +72,16 @@ namespace ICSharpCode.Core
return currentDebugger; return currentDebugger;
} }
} }
/// <summary>
/// Returns true if debugger is already loaded.
/// </summary>
public static bool IsDebuggerLoaded {
get {
return currentDebugger != null;
}
}
static void DebugStarted(object sender, EventArgs e) static void DebugStarted(object sender, EventArgs e)
{ {
//oldLayoutConfiguration = LayoutConfiguration.CurrentLayoutName; //oldLayoutConfiguration = LayoutConfiguration.CurrentLayoutName;
@ -85,9 +89,10 @@ namespace ICSharpCode.Core
ClearDebugMessages(); ClearDebugMessages();
} }
static void DebugStopped(object sender, EventArgs e) static void DebugStopped(object sender, EventArgs e)
{ {
CurrentLineBookmark.Remove();
//LayoutConfiguration.CurrentLayoutName = oldLayoutConfiguration; //LayoutConfiguration.CurrentLayoutName = oldLayoutConfiguration;
} }
@ -153,12 +158,11 @@ namespace ICSharpCode.Core
return breakpoints; return breakpoints;
} }
} }
static void BookmarkAdded(object sender, BM.BookmarkEventArgs e) static void BookmarkAdded(object sender, BM.BookmarkEventArgs e)
{ {
BreakpointBookmark bb = e.Bookmark as BreakpointBookmark; BreakpointBookmark bb = e.Bookmark as BreakpointBookmark;
if (bb != null) { if (bb != null) {
RefreshBreakpointMarkersInDocument(bb.Document);
OnBreakPointAdded(new BreakpointBookmarkEventArgs(bb)); OnBreakPointAdded(new BreakpointBookmarkEventArgs(bb));
} }
} }
@ -167,11 +171,11 @@ namespace ICSharpCode.Core
{ {
BreakpointBookmark bb = e.Bookmark as BreakpointBookmark; BreakpointBookmark bb = e.Bookmark as BreakpointBookmark;
if (bb != null) { if (bb != null) {
RefreshBreakpointMarkersInDocument(bb.Document); bb.RemoveMarker();
OnBreakPointRemoved(new BreakpointBookmarkEventArgs(bb)); OnBreakPointRemoved(new BreakpointBookmarkEventArgs(bb));
} }
} }
static void ToggleBreakpointAt(IDocument document, string fileName, int lineNumber) static void ToggleBreakpointAt(IDocument document, string fileName, int lineNumber)
{ {
foreach (Bookmark m in document.BookmarkManager.Marks) { foreach (Bookmark m in document.BookmarkManager.Marks) {
@ -186,42 +190,6 @@ namespace ICSharpCode.Core
document.BookmarkManager.AddMark(new BreakpointBookmark(fileName, document, lineNumber)); document.BookmarkManager.AddMark(new BreakpointBookmark(fileName, document, lineNumber));
} }
static void RefreshBreakpointMarkersInDocument(IDocument document)
{
if (document == null) return;
List<TextMarker> markers = document.MarkerStrategy.TextMarker;
// Remove all breakpoint markers
for (int i = 0; i < markers.Count;) {
if (markers[i] is BreakpointMarker) {
markers.RemoveAt(i);
} else {
i++; // Check next one
}
}
// Add breakpoint markers
foreach (BreakpointBookmark b in Breakpoints) {
LineSegment lineSeg = document.GetLineSegment(b.LineNumber);
document.MarkerStrategy.TextMarker.Add(new BreakpointMarker(lineSeg.Offset, lineSeg.Length, TextMarkerType.SolidBlock, Color.Red, Color.White));
}
// Perform editor update
document.RequestUpdate(new TextAreaUpdate(TextAreaUpdateType.WholeTextArea));
document.CommitUpdate();
}
class BreakpointMarker: TextMarker
{
public BreakpointMarker(int offset, int length, TextMarkerType textMarkerType, Color color, Color foreColor):base(offset, length, textMarkerType, color, foreColor)
{
}
}
class CurrentLineMarker: TextMarker
{
public CurrentLineMarker(int offset, int length, TextMarkerType textMarkerType, Color color, Color foreColor):base(offset, length, textMarkerType, color, foreColor)
{
}
}
static void WorkspaceCreated(object sender, EventArgs args) static void WorkspaceCreated(object sender, EventArgs args)
{ {
WorkbenchSingleton.Workbench.ViewOpened += new ViewContentEventHandler(ViewContentOpened); WorkbenchSingleton.Workbench.ViewOpened += new ViewContentEventHandler(ViewContentOpened);
@ -234,10 +202,7 @@ namespace ICSharpCode.Core
TextArea textArea = ((TextEditor.TextEditorControl)e.Content.Control).ActiveTextAreaControl.TextArea; TextArea textArea = ((TextEditor.TextEditorControl)e.Content.Control).ActiveTextAreaControl.TextArea;
textArea.IconBarMargin.MouseDown += new MarginMouseEventHandler(IconBarMouseDown); textArea.IconBarMargin.MouseDown += new MarginMouseEventHandler(IconBarMouseDown);
textArea.IconBarMargin.Painted += new MarginPaintEventHandler(PaintIconBar);
textArea.MouseMove += new MouseEventHandler(TextAreaMouseMove); textArea.MouseMove += new MouseEventHandler(TextAreaMouseMove);
RefreshBreakpointMarkersInDocument(textArea.MotherTextEditorControl.Document);
} }
} }
@ -247,50 +212,19 @@ namespace ICSharpCode.Core
TextArea textArea = ((TextEditor.TextEditorControl)e.Content.Control).ActiveTextAreaControl.TextArea; TextArea textArea = ((TextEditor.TextEditorControl)e.Content.Control).ActiveTextAreaControl.TextArea;
textArea.IconBarMargin.MouseDown -= new MarginMouseEventHandler(IconBarMouseDown); textArea.IconBarMargin.MouseDown -= new MarginMouseEventHandler(IconBarMouseDown);
textArea.IconBarMargin.Painted -= new MarginPaintEventHandler(PaintIconBar);
textArea.MouseMove -= new MouseEventHandler(TextAreaMouseMove); textArea.MouseMove -= new MouseEventHandler(TextAreaMouseMove);
} }
} }
public static void RemoveCurrentLineMarker()
static TextMarker currentLineMarker;
static IDocument currentLineMarkerParent;
static public void RemoveCurrentLineMarker()
{ {
if (currentLineMarker != null) { CurrentLineBookmark.Remove();
currentLineMarkerParent.MarkerStrategy.TextMarker.Remove(currentLineMarker);
currentLineMarkerParent.RequestUpdate(new TextAreaUpdate(TextAreaUpdateType.WholeTextArea));
currentLineMarkerParent.CommitUpdate();
currentLineMarkerParent = null;
currentLineMarker = null;
}
} }
static public void JumpToCurrentLine(string SourceFullFilename, int StartLine, int StartColumn, int EndLine, int EndColumn) public static void JumpToCurrentLine(string SourceFullFilename, int StartLine, int StartColumn, int EndLine, int EndColumn)
{ {
RemoveCurrentLineMarker(); IViewContent viewContent = FileService.JumpToFilePosition(SourceFullFilename, StartLine - 1, StartColumn - 1);
CurrentLineBookmark.SetPosition(viewContent, StartLine, StartColumn, EndLine, EndColumn);
FileService.OpenFile(SourceFullFilename);
IWorkbenchWindow window = FileService.GetOpenFile(SourceFullFilename);
if (window != null) {
IViewContent content = window.ViewContent;
if (content is IPositionable) {
((IPositionable)content).JumpTo((int)StartLine - 1, (int)StartColumn - 1);
}
if (content.Control is TextEditorControl) {
IDocument document = ((TextEditorControl)content.Control).Document;
LineSegment line = document.GetLineSegment((int)StartLine - 1);
int offset = line.Offset + (int)StartColumn;
currentLineMarker = new CurrentLineMarker(offset, (int)EndColumn - (int)StartColumn, TextMarkerType.SolidBlock, Color.Yellow, Color.Blue);
currentLineMarkerParent = document;
currentLineMarkerParent.MarkerStrategy.TextMarker.Add(currentLineMarker);
document.RequestUpdate(new TextAreaUpdate(TextAreaUpdateType.WholeTextArea));
document.CommitUpdate();
}
}
} }
static void IconBarMouseDown(AbstractMargin iconBar, Point mousepos, MouseButtons mouseButtons) static void IconBarMouseDown(AbstractMargin iconBar, Point mousepos, MouseButtons mouseButtons)
@ -305,23 +239,7 @@ namespace ICSharpCode.Core
} }
} }
/// <summary> #region Tool tips
/// Draw Breakpoint icon and the yellow arrow in the margin
/// </summary>
static void PaintIconBar(AbstractMargin iconBar, Graphics g, Rectangle rect)
{
foreach (TextMarker textMarker in iconBar.TextArea.Document.MarkerStrategy.TextMarker) {
CurrentLineMarker currentLineMarker = textMarker as CurrentLineMarker;
if (currentLineMarker != null) {
int lineNumber = iconBar.TextArea.Document.GetVisibleLine((int)iconBar.TextArea.Document.GetLineNumberForOffset(currentLineMarker.Offset));
int yPos = (int)(lineNumber * iconBar.TextArea.TextView.FontHeight) - iconBar.TextArea.VirtualTop.Y;
if (yPos >= rect.Y && yPos <= rect.Bottom) {
((IconBarMargin)iconBar).DrawArrow(g, yPos);
}
}
}
}
static string oldExpression, oldToolTip; static string oldExpression, oldToolTip;
static int oldLine; static int oldLine;
@ -462,5 +380,6 @@ namespace ICSharpCode.Core
} }
return text.ToString(); return text.ToString();
} }
#endregion
} }
} }

46
src/Main/Base/Project/Src/TextEditor/Bookmarks/Bookmark.cs

@ -18,7 +18,7 @@ using ICSharpCode.TextEditor.Document;
namespace ICSharpCode.SharpDevelop.Bookmarks namespace ICSharpCode.SharpDevelop.Bookmarks
{ {
/// <summary> /// <summary>
/// Description of Bookmark. /// A bookmark that is persistant across SharpDevelop sessions.
/// </summary> /// </summary>
[TypeConverter(typeof(BookmarkConverter))] [TypeConverter(typeof(BookmarkConverter))]
public class SDBookmark : Bookmark public class SDBookmark : Bookmark
@ -40,6 +40,50 @@ namespace ICSharpCode.SharpDevelop.Bookmarks
} }
} }
/// <summary>
/// A bookmark that is persistant across SharpDevelop sessions and has a text marker assigned to it.
/// </summary>
public abstract class SDMarkerBookmark : SDBookmark
{
public SDMarkerBookmark(string fileName, IDocument document, int lineNumber) : base(fileName, document, lineNumber)
{
SetMarker();
}
IDocument oldDocument;
TextMarker oldMarker;
protected abstract TextMarker CreateMarker();
void SetMarker()
{
RemoveMarker();
if (Document != null) {
TextMarker marker = CreateMarker();
// Perform editor update
Document.RequestUpdate(new TextAreaUpdate(TextAreaUpdateType.SingleLine, LineNumber));
Document.CommitUpdate();
oldMarker = marker;
}
oldDocument = Document;
}
protected override void OnDocumentChanged(EventArgs e)
{
base.OnDocumentChanged(e);
SetMarker();
}
public void RemoveMarker()
{
if (oldDocument != null) {
oldDocument.MarkerStrategy.RemoveMarker(oldMarker);
}
oldDocument = null;
oldMarker = null;
}
}
public class SDBookmarkFactory : IBookmarkFactory public class SDBookmarkFactory : IBookmarkFactory
{ {
string fileName; string fileName;

24
src/Main/Base/Project/Src/TextEditor/Gui/Editor/ErrorDrawer.cs

@ -79,11 +79,10 @@ namespace ICSharpCode.SharpDevelop.DefaultEditor.Gui.Editor
void OnRemoved(object sender, TaskEventArgs e) void OnRemoved(object sender, TaskEventArgs e)
{ {
Task t = e.Task; Task t = e.Task;
List<TextMarker> markers = textEditor.Document.MarkerStrategy.TextMarker; foreach (TextMarker marker in textEditor.Document.MarkerStrategy.TextMarker) {
for (int i = 0; i < markers.Count; ++i) { VisualError ve = marker as VisualError;
VisualError ve = markers[i] as VisualError;
if (ve != null && ve.Task == t) { if (ve != null && ve.Task == t) {
markers.RemoveAt(i); textEditor.Document.MarkerStrategy.RemoveMarker(marker);
textEditor.Refresh(); textEditor.Refresh();
break; break;
} }
@ -104,15 +103,12 @@ namespace ICSharpCode.SharpDevelop.DefaultEditor.Gui.Editor
bool ClearErrors() bool ClearErrors()
{ {
bool removed = false; bool removed = false;
List<TextMarker> markers = textEditor.Document.MarkerStrategy.TextMarker; textEditor.Document.MarkerStrategy.RemoveAll(delegate (TextMarker marker) {
for (int i = 0; i < markers.Count;) { if (marker is VisualError) {
if (markers[i] is VisualError) { removed = true;
removed = true; return true;
markers.RemoveAt(i); }
} else { return false;});
i++; // Check next one
}
}
return removed; return removed;
} }
@ -136,7 +132,7 @@ namespace ICSharpCode.SharpDevelop.DefaultEditor.Gui.Editor
int offset = line.Offset + task.Column; int offset = line.Offset + task.Column;
foreach (TextWord tw in line.Words) { foreach (TextWord tw in line.Words) {
if (task.Column >= tw.Offset && task.Column < (tw.Offset + tw.Length)) { if (task.Column >= tw.Offset && task.Column < (tw.Offset + tw.Length)) {
textEditor.Document.MarkerStrategy.TextMarker.Add(new VisualError(offset, tw.Length, task)); textEditor.Document.MarkerStrategy.AddMarker(new VisualError(offset, tw.Length, task));
if (refresh) { if (refresh) {
textEditor.Refresh(); textEditor.Refresh();
} }

Loading…
Cancel
Save