diff --git a/AddIns/ICSharpCode.SharpDevelop.addin b/AddIns/ICSharpCode.SharpDevelop.addin
index 0033fd4293..c1107f668b 100644
--- a/AddIns/ICSharpCode.SharpDevelop.addin
+++ b/AddIns/ICSharpCode.SharpDevelop.addin
@@ -101,6 +101,12 @@
title = "Bookmarks"
icon = "PadIcons.Bookmarks"
class = "Bookmark.BookmarkPad"/>
+
+
diff --git a/src/AddIns/BackendBindings/CSharpBinding/Project/Src/FormattingStrategy/CSharpFormattingStrategy.cs b/src/AddIns/BackendBindings/CSharpBinding/Project/Src/FormattingStrategy/CSharpFormattingStrategy.cs
index 83a54b7579..b82e400d91 100644
--- a/src/AddIns/BackendBindings/CSharpBinding/Project/Src/FormattingStrategy/CSharpFormattingStrategy.cs
+++ b/src/AddIns/BackendBindings/CSharpBinding/Project/Src/FormattingStrategy/CSharpFormattingStrategy.cs
@@ -46,6 +46,7 @@ namespace CSharpBinding.FormattingStrategy
IndentationSettings set = new IndentationSettings();
set.IndentString = Tab.GetIndentationString(textArea.Document);
+ set.LeaveEmptyLines = false;
IndentationReformatter r = new IndentationReformatter();
r.Reformat(acc, set);
diff --git a/src/AddIns/BackendBindings/CSharpBinding/Project/Src/FormattingStrategy/Indentation.cs b/src/AddIns/BackendBindings/CSharpBinding/Project/Src/FormattingStrategy/Indentation.cs
index 342f9d1228..1e3a39b4c5 100644
--- a/src/AddIns/BackendBindings/CSharpBinding/Project/Src/FormattingStrategy/Indentation.cs
+++ b/src/AddIns/BackendBindings/CSharpBinding/Project/Src/FormattingStrategy/Indentation.cs
@@ -7,6 +7,8 @@ namespace CSharpBinding.FormattingStrategy
public class IndentationSettings
{
public string IndentString = "\t";
+ /// Leave empty lines empty.
+ public bool LeaveEmptyLines = true;
}
public class IndentationReformatter
@@ -86,7 +88,7 @@ namespace CSharpBinding.FormattingStrategy
public void Step(IDocumentAccessor doc, IndentationSettings set)
{
string line = doc.Text;
- if (line.Length == 0) return; // leave empty lines empty
+ if (set.LeaveEmptyLines && line.Length == 0) return; // leave empty lines empty
line = line.TrimStart();
StringBuilder indent = new StringBuilder();
diff --git a/src/Main/Base/Project/ICSharpCode.SharpDevelop.csproj b/src/Main/Base/Project/ICSharpCode.SharpDevelop.csproj
index 75c9abd1d7..ca62292eb3 100644
--- a/src/Main/Base/Project/ICSharpCode.SharpDevelop.csproj
+++ b/src/Main/Base/Project/ICSharpCode.SharpDevelop.csproj
@@ -642,6 +642,7 @@
+
diff --git a/src/Main/Base/Project/Src/Commands/MenuItemBuilders.cs b/src/Main/Base/Project/Src/Commands/MenuItemBuilders.cs
index 526a807821..7e721c6c50 100644
--- a/src/Main/Base/Project/Src/Commands/MenuItemBuilders.cs
+++ b/src/Main/Base/Project/Src/Commands/MenuItemBuilders.cs
@@ -349,12 +349,6 @@ namespace ICSharpCode.SharpDevelop.Commands
{
PadDescriptor padDescriptor;
- bool IsPadVisible {
- get {
- return WorkbenchSingleton.Workbench.WorkbenchLayout.IsVisible(padDescriptor);
- }
- }
-
public MyMenuItem(PadDescriptor padDescriptor) : base(null, null)
{
this.padDescriptor = padDescriptor;
diff --git a/src/Main/Base/Project/Src/Dom/FilePosition.cs b/src/Main/Base/Project/Src/Dom/FilePosition.cs
index 9473dba9b0..49dd1c2ebb 100644
--- a/src/Main/Base/Project/Src/Dom/FilePosition.cs
+++ b/src/Main/Base/Project/Src/Dom/FilePosition.cs
@@ -37,5 +37,37 @@ namespace ICSharpCode.SharpDevelop.Dom
return position;
}
}
+
+ public override string ToString()
+ {
+ return String.Format("{0} : (line {1}, col {2})",
+ filename,
+ Line,
+ Column);
+ }
+
+ public int Line {
+ get {
+ return position.X;
+ }
+ }
+
+ public int Column {
+ get {
+ return position.X;
+ }
+ }
+
+ public override bool Equals(object obj)
+ {
+ FilePosition b = obj as FilePosition;
+ if (b == null) return false;
+ return this.Filename == b.Filename && this.Position == b.Position;
+ }
+
+ public override int GetHashCode()
+ {
+ return filename.GetHashCode() ^ position.GetHashCode();
+ }
}
}
diff --git a/src/Main/Base/Project/Src/Gui/AbstractPadContent.cs b/src/Main/Base/Project/Src/Gui/AbstractPadContent.cs
index 6649a71ea0..5000ddeb7f 100644
--- a/src/Main/Base/Project/Src/Gui/AbstractPadContent.cs
+++ b/src/Main/Base/Project/Src/Gui/AbstractPadContent.cs
@@ -26,5 +26,11 @@ namespace ICSharpCode.SharpDevelop.Gui
public virtual void Dispose()
{
}
+
+ public bool IsVisible {
+ get {
+ return Control.Visible && Control.Width > 0;
+ }
+ }
}
}
diff --git a/src/Main/Base/Project/Src/Gui/Pads/DefinitionViewPad.cs b/src/Main/Base/Project/Src/Gui/Pads/DefinitionViewPad.cs
new file mode 100644
index 0000000000..6d3b68f542
--- /dev/null
+++ b/src/Main/Base/Project/Src/Gui/Pads/DefinitionViewPad.cs
@@ -0,0 +1,102 @@
+//
+//
+//
+//
+//
+//
+
+using System;
+using System.Windows.Forms;
+using ICSharpCode.Core;
+using ICSharpCode.SharpDevelop.Dom;
+using ICSharpCode.TextEditor;
+using ICSharpCode.SharpDevelop.DefaultEditor.Gui.Editor;
+
+namespace ICSharpCode.SharpDevelop.Gui
+{
+ ///
+ /// Description of the pad content
+ ///
+ public class DefinitionViewPad : AbstractPadContent
+ {
+ TextEditorControl ctl;
+
+ ///
+ /// The representing the pad
+ ///
+ public override Control Control {
+ get {
+ return ctl;
+ }
+ }
+
+ ///
+ /// Creates a new DefinitionViewPad object
+ ///
+ public DefinitionViewPad()
+ {
+ ctl = new TextEditorControl();
+ ctl.Document.ReadOnly = true;
+ ctl.TextEditorProperties = new SharpDevelopTextEditorProperties();
+ ParserService.ParserUpdateStepFinished += UpdateTick;
+ }
+
+ void UpdateTick(object sender, ParserUpdateStepEventArgs e)
+ {
+ if (!this.IsVisible) return;
+ ResolveResult res = ResolveAtCaret(e);
+ if (res == null) return;
+ FilePosition pos = res.GetDefinitionPosition();
+ if (pos == null) return;
+ ctl.Invoke(new OpenFileDelegate(OpenFile), pos);
+ }
+
+ ResolveResult ResolveAtCaret(ParserUpdateStepEventArgs e)
+ {
+ IWorkbenchWindow window = WorkbenchSingleton.Workbench.ActiveWorkbenchWindow;
+ if (window == null) return null;
+ ITextEditorControlProvider provider = window.ActiveViewContent as ITextEditorControlProvider;
+ if (provider == null) return null;
+ TextEditorControl ctl = provider.TextEditorControl;
+ if (ctl.FileName != e.FileName) return null;
+ IExpressionFinder expressionFinder = ParserService.GetExpressionFinder(e.FileName);
+ if (expressionFinder == null) return null;
+ Caret caret = ctl.ActiveTextAreaControl.Caret;
+ string expr = expressionFinder.FindFullExpression(e.Content, caret.Offset);
+ if (expr == null) return null;
+ return ParserService.Resolve(expr, caret.Line, caret.Column, e.FileName, e.Content);
+ }
+
+ delegate void OpenFileDelegate(FilePosition pos);
+
+ FilePosition oldPosition;
+
+ void OpenFile(FilePosition pos)
+ {
+ if (pos.Equals(oldPosition)) return;
+ oldPosition = pos;
+ if (pos.Filename != ctl.FileName)
+ ctl.LoadFile(pos.Filename);
+ ctl.ActiveTextAreaControl.ScrollTo(int.MaxValue); // scroll completely down
+ ctl.ActiveTextAreaControl.Caret.Line = pos.Line - 1;
+ ctl.ActiveTextAreaControl.ScrollToCaret(); // scroll up to search position
+ }
+
+ ///
+ /// Refreshes the pad
+ ///
+ public override void RedrawContent()
+ {
+ // Refresh the whole pad control here, renew all resource strings whatever.
+ }
+
+ ///
+ /// Cleans up all used resources
+ ///
+ public override void Dispose()
+ {
+ ParserService.ParserUpdateStepFinished -= UpdateTick;
+ ctl.Dispose();
+ }
+ }
+}
diff --git a/src/Main/Base/Project/Src/Services/ParserService/ParseInformationEventHandler.cs b/src/Main/Base/Project/Src/Services/ParserService/ParseInformationEventHandler.cs
index ab235cc61e..9fa24a29a7 100644
--- a/src/Main/Base/Project/Src/Services/ParserService/ParseInformationEventHandler.cs
+++ b/src/Main/Base/Project/Src/Services/ParserService/ParseInformationEventHandler.cs
@@ -51,4 +51,36 @@ namespace ICSharpCode.Core
this.compilationUnit = compilationUnit;
}
}
+
+ public delegate void ParserUpdateStepEventHandler(object sender, ParserUpdateStepEventArgs e);
+
+ public class ParserUpdateStepEventArgs : EventArgs
+ {
+ string fileName;
+ string content;
+ bool updated;
+
+ public ParserUpdateStepEventArgs(string fileName, string content, bool updated)
+ {
+ this.fileName = fileName;
+ this.content = content;
+ this.updated = updated;
+ }
+
+ public string FileName {
+ get {
+ return fileName;
+ }
+ }
+ public string Content {
+ get {
+ return content;
+ }
+ }
+ public bool Updated {
+ get {
+ return updated;
+ }
+ }
+ }
}
diff --git a/src/Main/Base/Project/Src/Services/ParserService/ParserService.cs b/src/Main/Base/Project/Src/Services/ParserService/ParserService.cs
index 259475ba85..795285971a 100644
--- a/src/Main/Base/Project/Src/Services/ParserService/ParserService.cs
+++ b/src/Main/Base/Project/Src/Services/ParserService/ParserService.cs
@@ -110,43 +110,7 @@ namespace ICSharpCode.Core
{
while (!doneParserThread) {
try {
- if (WorkbenchSingleton.Workbench.ActiveWorkbenchWindow != null && WorkbenchSingleton.Workbench.ActiveWorkbenchWindow.ActiveViewContent != null) {
- IEditable editable = WorkbenchSingleton.Workbench.ActiveWorkbenchWindow.ActiveViewContent as IEditable;
- if (editable != null) {
- string fileName = null;
-
- IViewContent viewContent = WorkbenchSingleton.Workbench.ActiveWorkbenchWindow.ViewContent;
- IParseableContent parseableContent = WorkbenchSingleton.Workbench.ActiveWorkbenchWindow.ActiveViewContent as IParseableContent;
-
- //ivoko: Pls, do not throw text = parseableContent.ParseableText away. I NEED it.
- string text = null;
- if (parseableContent != null) {
- fileName = parseableContent.ParseableContentName;
- text = parseableContent.ParseableText;
- } else {
- fileName = viewContent.IsUntitled ? viewContent.UntitledName : viewContent.FileName;
- }
-
- if (!(fileName == null || fileName.Length == 0)) {
- ParseInformation parseInformation = null;
- bool updated = false;
- if (text == null) {
- text = editable.Text;
- }
- int hash = text.Length;
- if (!lastUpdateSize.ContainsKey(fileName) || (int)lastUpdateSize[fileName] != hash) {
- parseInformation = ParseFile(fileName, text, !viewContent.IsUntitled, true);
- lastUpdateSize[fileName] = hash;
- updated = true;
- }
- if (updated) {
- if (parseInformation != null && editable is IParseInformationListener) {
- ((IParseInformationListener)editable).ParseInformationUpdated(parseInformation);
- }
- }
- }
- }
- }
+ ParserUpdateStep();
} catch (Exception e) {
ICSharpCode.Core.MessageService.ShowError(e);
}
@@ -154,7 +118,58 @@ namespace ICSharpCode.Core
}
}
-
+ static void ParserUpdateStep()
+ {
+ if (WorkbenchSingleton.Workbench.ActiveWorkbenchWindow != null && WorkbenchSingleton.Workbench.ActiveWorkbenchWindow.ActiveViewContent != null) {
+ IEditable editable = WorkbenchSingleton.Workbench.ActiveWorkbenchWindow.ActiveViewContent as IEditable;
+ if (editable != null) {
+ string fileName = null;
+
+ IViewContent viewContent = WorkbenchSingleton.Workbench.ActiveWorkbenchWindow.ViewContent;
+ IParseableContent parseableContent = WorkbenchSingleton.Workbench.ActiveWorkbenchWindow.ActiveViewContent as IParseableContent;
+
+ //ivoko: Pls, do not throw text = parseableContent.ParseableText away. I NEED it.
+ string text = null;
+ if (parseableContent != null) {
+ fileName = parseableContent.ParseableContentName;
+ text = parseableContent.ParseableText;
+ } else {
+ fileName = viewContent.IsUntitled ? viewContent.UntitledName : viewContent.FileName;
+ }
+
+ if (!(fileName == null || fileName.Length == 0)) {
+ ParseInformation parseInformation = null;
+ bool updated = false;
+ if (text == null) {
+ text = editable.Text;
+ if (text == null) return;
+ }
+ int hash = text.Length;
+ if (!lastUpdateSize.ContainsKey(fileName) || (int)lastUpdateSize[fileName] != hash) {
+ parseInformation = ParseFile(fileName, text, !viewContent.IsUntitled, true);
+ lastUpdateSize[fileName] = hash;
+ updated = true;
+ }
+ if (updated) {
+ if (parseInformation != null && editable is IParseInformationListener) {
+ ((IParseInformationListener)editable).ParseInformationUpdated(parseInformation);
+ }
+ }
+ OnParserUpdateStepFinished(new ParserUpdateStepEventArgs(fileName, text, updated));
+ }
+ }
+ }
+ }
+
+ public static event ParserUpdateStepEventHandler ParserUpdateStepFinished;
+
+ static void OnParserUpdateStepFinished(ParserUpdateStepEventArgs e)
+ {
+ if (ParserUpdateStepFinished != null) {
+ ParserUpdateStepFinished(typeof(ParserService), e);
+ }
+ }
+
public static ParseInformation ParseFile(string fileName)
{
return ParseFile(fileName, null);
diff --git a/src/Main/Base/Project/Src/TextEditor/Gui/Editor/TextEditorDisplayBinding.cs b/src/Main/Base/Project/Src/TextEditor/Gui/Editor/TextEditorDisplayBinding.cs
index 9be8cb01a7..206b99ccba 100644
--- a/src/Main/Base/Project/Src/TextEditor/Gui/Editor/TextEditorDisplayBinding.cs
+++ b/src/Main/Base/Project/Src/TextEditor/Gui/Editor/TextEditorDisplayBinding.cs
@@ -122,6 +122,7 @@ namespace ICSharpCode.SharpDevelop.DefaultEditor.Gui.Editor
public string Text {
get {
+ if (textAreaControl.IsDisposed) return null;
if (textAreaControl.InvokeRequired)
return (string)textAreaControl.Invoke(new GetTextDelegate(GetText));
else