diff --git a/data/resources/image/BitmapResources/BitmapList.txt b/data/resources/image/BitmapResources/BitmapList.txt
index 7c72c13632..bf111d6f0d 100644
--- a/data/resources/image/BitmapResources/BitmapList.txt
+++ b/data/resources/image/BitmapResources/BitmapList.txt
@@ -140,7 +140,9 @@ SharpQueryIcons\Icons.16x16.SharpQuery.Column.png
SharpQueryIcons\Icons.16x16.SharpQuery.NodeError.png
SharpQueryIcons\Icons.16x16.SharpQuery.Remove.png
SharpQueryIcons\Icons.16x16.SharpQuery.Table.png
-
+ClassBrowserIcons\Icons.16x16.Workspace.png
+ClassBrowserIcons\Icons.16x16.Assembly.png
+ClassBrowserIcons\Icons.16x16.AssemblyError.png
-------------------------------------------------------------------------------
Copied from the Fugue Icon Library and modified or mashed up with other Fugue
@@ -239,6 +241,11 @@ CodeCoverageIcons\CodeCoverage.Icons.16x16.Pad.png
CodeCoverageIcons\CodeCoverage.Icons.16x16.Run.png
DebuggerIcons\Icons.16x16.Debug.Start.png
DebuggerIcons\Icons.16x16.Debug.StartWithoutDebugging.png
+DebuggerIcons\Icons.16x16.Debug.Assembly.png
+ClassBrowserIcons\Icons.16x16.Module.png
+ClassBrowserIcons\Icons.16x16.ModuleError.png
+ClassBrowserIcons\Icons.16x16.AssemblyFromFile.png
+ClassBrowserIcons\Icons.16x16.AssemblyFromGAC.png
NavigationIcons\Icons.16x16.NavigateBack.disabled.png
NavigationIcons\Icons.16x16.NavigateBack.png
NavigationIcons\Icons.16x16.NavigateForward.png
@@ -555,11 +562,6 @@ ClassBrowserIcons\Icons.16x16.NameSpace.png
ClassBrowserIcons\Icons.16x16.Operator.png
ClassBrowserIcons\Icons.16x16.Parameter.png
ClassBrowserIcons\Icons.16x16.Struct.png
-ClassBrowserIcons\Icons.16x16.Workspace.png
-ClassBrowserIcons\Icons.16x16.Assembly.png
-ClassBrowserIcons\Icons.16x16.Module.png
-ClassBrowserIcons\Icons.16x16.AssemblyFromFile.png
-ClassBrowserIcons\Icons.16x16.AssemblyFromGAC.png
-------------------------------------------------------------------------------
Left original (other source than Fugue Iconlibrary)
diff --git a/data/resources/image/BitmapResources/BitmapResources.res b/data/resources/image/BitmapResources/BitmapResources.res
index 51f99e517d..7946ddfdb6 100644
--- a/data/resources/image/BitmapResources/BitmapResources.res
+++ b/data/resources/image/BitmapResources/BitmapResources.res
@@ -86,6 +86,7 @@ Icons.16x16.Debug.Continue = DebuggerIcons\Icons.16x16.Debug.Continue.png
Icons.16x16.Debug.StepOver = DebuggerIcons\Icons.16x16.Debug.StepOver.png
Icons.16x16.Debug.StepInto = DebuggerIcons\Icons.16x16.Debug.StepInto.png
Icons.16x16.Debug.StepOut = DebuggerIcons\Icons.16x16.Debug.StepOut.png
+Icons.16x16.Debug.Assembly = DebuggerIcons\Icons.16x16.Debug.Assembly.png
# TestRunner
Icons.16x16.TestRunner.Yellow = BitmapResources-data\Icons.16x16.TestRunner.Yellow.png
@@ -297,7 +298,9 @@ Icons.16x16.AssemblyFromGAC = ClassBrowserIcons\Icons.16x16.AssemblyFromGA
Icons.16x16.Workspace = ClassBrowserIcons\Icons.16x16.Workspace.png
Icons.16x16.Assembly = ClassBrowserIcons\Icons.16x16.Assembly.png
+Icons.16x16.AssemblyError = ClassBrowserIcons\Icons.16x16.AssemblyError.png
Icons.16x16.Module = ClassBrowserIcons\Icons.16x16.Module.png
+Icons.16x16.ModuleError = ClassBrowserIcons\Icons.16x16.ModuleError.png
Icons.16x16.NameSpace = ClassBrowserIcons\Icons.16x16.NameSpace.png
Icons.16x16.Literal = ClassBrowserIcons\Icons.16x16.Literal.png
Icons.16x16.Reference = ClassBrowserIcons\Icons.16x16.Reference.png
diff --git a/data/resources/image/BitmapResources/ClassBrowserIcons/Icons.16x16.AssemblyError.png b/data/resources/image/BitmapResources/ClassBrowserIcons/Icons.16x16.AssemblyError.png
new file mode 100644
index 0000000000..01566b5f5e
Binary files /dev/null and b/data/resources/image/BitmapResources/ClassBrowserIcons/Icons.16x16.AssemblyError.png differ
diff --git a/data/resources/image/BitmapResources/ClassBrowserIcons/Icons.16x16.AssemblyFromFile.png b/data/resources/image/BitmapResources/ClassBrowserIcons/Icons.16x16.AssemblyFromFile.png
index 738b354a4d..1c4e382bef 100644
Binary files a/data/resources/image/BitmapResources/ClassBrowserIcons/Icons.16x16.AssemblyFromFile.png and b/data/resources/image/BitmapResources/ClassBrowserIcons/Icons.16x16.AssemblyFromFile.png differ
diff --git a/data/resources/image/BitmapResources/ClassBrowserIcons/Icons.16x16.AssemblyFromGAC.png b/data/resources/image/BitmapResources/ClassBrowserIcons/Icons.16x16.AssemblyFromGAC.png
index 52e916f98d..d39ab189ee 100644
Binary files a/data/resources/image/BitmapResources/ClassBrowserIcons/Icons.16x16.AssemblyFromGAC.png and b/data/resources/image/BitmapResources/ClassBrowserIcons/Icons.16x16.AssemblyFromGAC.png differ
diff --git a/data/resources/image/BitmapResources/ClassBrowserIcons/Icons.16x16.Module.png b/data/resources/image/BitmapResources/ClassBrowserIcons/Icons.16x16.Module.png
index ce892a1562..086da4b455 100644
Binary files a/data/resources/image/BitmapResources/ClassBrowserIcons/Icons.16x16.Module.png and b/data/resources/image/BitmapResources/ClassBrowserIcons/Icons.16x16.Module.png differ
diff --git a/data/resources/image/BitmapResources/ClassBrowserIcons/Icons.16x16.ModuleError.png b/data/resources/image/BitmapResources/ClassBrowserIcons/Icons.16x16.ModuleError.png
new file mode 100644
index 0000000000..4161b1497b
Binary files /dev/null and b/data/resources/image/BitmapResources/ClassBrowserIcons/Icons.16x16.ModuleError.png differ
diff --git a/data/resources/image/BitmapResources/DebuggerIcons/Icons.16x16.Debug.Assembly.png b/data/resources/image/BitmapResources/DebuggerIcons/Icons.16x16.Debug.Assembly.png
new file mode 100644
index 0000000000..860aaf96ce
Binary files /dev/null and b/data/resources/image/BitmapResources/DebuggerIcons/Icons.16x16.Debug.Assembly.png differ
diff --git a/src/AddIns/Debugger/Debugger.AddIn/Pads/ClassBrowserSupport.cs b/src/AddIns/Debugger/Debugger.AddIn/Pads/ClassBrowserSupport.cs
index 112d899770..c64f58d09a 100644
--- a/src/AddIns/Debugger/Debugger.AddIn/Pads/ClassBrowserSupport.cs
+++ b/src/AddIns/Debugger/Debugger.AddIn/Pads/ClassBrowserSupport.cs
@@ -106,7 +106,7 @@ namespace ICSharpCode.SharpDevelop.Gui.Pads
public override object Icon {
get {
- return IconService.GetImageSource("Icons.16x16.Debug.Start");
+ return IconService.GetImageSource("Icons.16x16.Debug.Assembly");
}
}
}
@@ -135,6 +135,11 @@ namespace ICSharpCode.SharpDevelop.Gui.Pads
}
}
+ public override void ShowContextMenu()
+ {
+ // Don't show context menu as for usual AssemblyTreeNodes.
+ }
+
static IAssemblyModel CreateAssemblyModel(Module module)
{
// references??
diff --git a/src/AddIns/Misc/AddInManager2/Project/AddInManager2.csproj b/src/AddIns/Misc/AddInManager2/Project/AddInManager2.csproj
index 126a60a00e..c9a4c03a72 100644
--- a/src/AddIns/Misc/AddInManager2/Project/AddInManager2.csproj
+++ b/src/AddIns/Misc/AddInManager2/Project/AddInManager2.csproj
@@ -191,9 +191,7 @@
-
- PagedResultsView.xaml
-
+
\ No newline at end of file
diff --git a/src/Libraries/AvalonEdit/ICSharpCode.AvalonEdit.Tests/Utils/CaretNavigationTests.cs b/src/Libraries/AvalonEdit/ICSharpCode.AvalonEdit.Tests/Utils/CaretNavigationTests.cs
index 8439d5f2ad..366e0671ff 100644
--- a/src/Libraries/AvalonEdit/ICSharpCode.AvalonEdit.Tests/Utils/CaretNavigationTests.cs
+++ b/src/Libraries/AvalonEdit/ICSharpCode.AvalonEdit.Tests/Utils/CaretNavigationTests.cs
@@ -113,5 +113,21 @@ namespace ICSharpCode.AvalonEdit.Utils
Assert.AreEqual(5, GetPrevCaretStop(c, 6, CaretPositioningMode.WordBorder));
Assert.AreEqual(1, GetPrevCaretStop(c, 5, CaretPositioningMode.WordBorder));
}
+
+ [Test]
+ public void CombiningMark()
+ {
+ string str = " x͆ ";
+ Assert.AreEqual(3, GetNextCaretStop(str, 1, CaretPositioningMode.Normal));
+ Assert.AreEqual(1, GetPrevCaretStop(str, 3, CaretPositioningMode.Normal));
+ }
+
+ [Test]
+ public void StackedCombiningMark()
+ {
+ string str = " x͆͆͆͆ ";
+ Assert.AreEqual(6, GetNextCaretStop(str, 1, CaretPositioningMode.Normal));
+ Assert.AreEqual(1, GetPrevCaretStop(str, 6, CaretPositioningMode.Normal));
+ }
}
}
diff --git a/src/Libraries/AvalonEdit/ICSharpCode.AvalonEdit/Document/TextUtilities.cs b/src/Libraries/AvalonEdit/ICSharpCode.AvalonEdit/Document/TextUtilities.cs
index 9780436238..2da8a9badc 100644
--- a/src/Libraries/AvalonEdit/ICSharpCode.AvalonEdit/Document/TextUtilities.cs
+++ b/src/Libraries/AvalonEdit/ICSharpCode.AvalonEdit/Document/TextUtilities.cs
@@ -14,7 +14,7 @@ namespace ICSharpCode.AvalonEdit.Document
public enum CaretPositioningMode
{
///
- /// Normal positioning (stop at every caret position)
+ /// Normal positioning (stop after every grapheme)
///
Normal,
///
@@ -32,7 +32,12 @@ namespace ICSharpCode.AvalonEdit.Document
///
/// Stop only on word borders, and anywhere in the middle of symbols.
///
- WordBorderOrSymbol
+ WordBorderOrSymbol,
+ ///
+ /// Stop between every Unicode codepoint, even within the same grapheme.
+ /// This is used to implement deleting the previous grapheme when Backspace is pressed.
+ ///
+ EveryCodepoint
}
///
@@ -199,37 +204,43 @@ namespace ICSharpCode.AvalonEdit.Document
{
if (c == '\r' || c == '\n')
return CharacterClass.LineTerminator;
- else if (char.IsWhiteSpace(c))
- return CharacterClass.Whitespace;
- else if (char.IsLetterOrDigit(c) || c == '_')
+ if (c == '_')
return CharacterClass.IdentifierPart;
- else
- return CharacterClass.Other;
+ return GetCharacterClass(char.GetUnicodeCategory(c));
}
static CharacterClass GetCharacterClass(char highSurrogate, char lowSurrogate)
{
if (char.IsSurrogatePair(highSurrogate, lowSurrogate)) {
- switch (char.GetUnicodeCategory(highSurrogate.ToString() + lowSurrogate.ToString(), 0)) {
- case UnicodeCategory.SpaceSeparator:
- case UnicodeCategory.LineSeparator:
- case UnicodeCategory.ParagraphSeparator:
- return CharacterClass.Whitespace;
- case UnicodeCategory.UppercaseLetter:
- case UnicodeCategory.LowercaseLetter:
- case UnicodeCategory.TitlecaseLetter:
- case UnicodeCategory.ModifierLetter:
- case UnicodeCategory.OtherLetter:
- case UnicodeCategory.DecimalDigitNumber:
- return CharacterClass.IdentifierPart;
- default:
- return CharacterClass.Other;
- }
+ return GetCharacterClass(char.GetUnicodeCategory(highSurrogate.ToString() + lowSurrogate.ToString(), 0));
} else {
// malformed surrogate pair
return CharacterClass.Other;
}
}
+
+ static CharacterClass GetCharacterClass(UnicodeCategory c)
+ {
+ switch (c) {
+ case UnicodeCategory.SpaceSeparator:
+ case UnicodeCategory.LineSeparator:
+ case UnicodeCategory.ParagraphSeparator:
+ return CharacterClass.Whitespace;
+ case UnicodeCategory.UppercaseLetter:
+ case UnicodeCategory.LowercaseLetter:
+ case UnicodeCategory.TitlecaseLetter:
+ case UnicodeCategory.ModifierLetter:
+ case UnicodeCategory.OtherLetter:
+ case UnicodeCategory.DecimalDigitNumber:
+ return CharacterClass.IdentifierPart;
+ case UnicodeCategory.NonSpacingMark:
+ case UnicodeCategory.SpacingCombiningMark:
+ case UnicodeCategory.EnclosingMark:
+ return CharacterClass.CombiningMark;
+ default:
+ return CharacterClass.Other;
+ }
+ }
#endregion
#region GetNextCaretPosition
@@ -251,13 +262,16 @@ namespace ICSharpCode.AvalonEdit.Document
{
if (textSource == null)
throw new ArgumentNullException("textSource");
- if (mode != CaretPositioningMode.Normal
- && mode != CaretPositioningMode.WordBorder
- && mode != CaretPositioningMode.WordStart
- && mode != CaretPositioningMode.WordBorderOrSymbol
- && mode != CaretPositioningMode.WordStartOrSymbol)
- {
- throw new ArgumentException("Unsupported CaretPositioningMode: " + mode, "mode");
+ switch (mode) {
+ case CaretPositioningMode.Normal:
+ case CaretPositioningMode.EveryCodepoint:
+ case CaretPositioningMode.WordBorder:
+ case CaretPositioningMode.WordBorderOrSymbol:
+ case CaretPositioningMode.WordStart:
+ case CaretPositioningMode.WordStartOrSymbol:
+ break; // OK
+ default:
+ throw new ArgumentException("Unsupported CaretPositioningMode: " + mode, "mode");
}
if (direction != LogicalDirection.Backward
&& direction != LogicalDirection.Forward)
@@ -267,7 +281,7 @@ namespace ICSharpCode.AvalonEdit.Document
int textLength = textSource.TextLength;
if (textLength <= 0) {
// empty document? has a normal caret position at 0, though no word borders
- if (mode == CaretPositioningMode.Normal) {
+ if (IsNormal(mode)) {
if (offset > 0 && direction == LogicalDirection.Backward) return 0;
if (offset < 0 && direction == LogicalDirection.Forward) return 0;
}
@@ -286,14 +300,14 @@ namespace ICSharpCode.AvalonEdit.Document
if (nextPos == 0) {
// at the document start, there's only a word border
// if the first character is not whitespace
- if (mode == CaretPositioningMode.Normal || !char.IsWhiteSpace(textSource.GetCharAt(0)))
+ if (IsNormal(mode) || !char.IsWhiteSpace(textSource.GetCharAt(0)))
return nextPos;
} else if (nextPos == textLength) {
// at the document end, there's never a word start
if (mode != CaretPositioningMode.WordStart && mode != CaretPositioningMode.WordStartOrSymbol) {
// at the document end, there's only a word border
// if the last character is not whitespace
- if (mode == CaretPositioningMode.Normal || !char.IsWhiteSpace(textSource.GetCharAt(textLength - 1)))
+ if (IsNormal(mode) || !char.IsWhiteSpace(textSource.GetCharAt(textLength - 1)))
return nextPos;
}
} else {
@@ -320,9 +334,19 @@ namespace ICSharpCode.AvalonEdit.Document
}
}
+ static bool IsNormal(CaretPositioningMode mode)
+ {
+ return mode == CaretPositioningMode.Normal || mode == CaretPositioningMode.EveryCodepoint;
+ }
+
static bool StopBetweenCharacters(CaretPositioningMode mode, CharacterClass charBefore, CharacterClass charAfter)
{
- // Stop after every character in normal mode
+ if (mode == CaretPositioningMode.EveryCodepoint)
+ return true;
+ // Don't stop in the middle of a grapheme
+ if (charAfter == CharacterClass.CombiningMark)
+ return false;
+ // Stop after every grapheme in normal mode
if (mode == CaretPositioningMode.Normal)
return true;
if (charBefore == charAfter) {
@@ -370,6 +394,11 @@ namespace ICSharpCode.AvalonEdit.Document
///
/// The character is line terminator (\r or \n).
///
- LineTerminator
+ LineTerminator,
+ ///
+ /// The character is a unicode combining mark that modifies the previous character.
+ /// Corresponds to the Unicode designations "Mn", "Mc" and "Me".
+ ///
+ CombiningMark
}
}
diff --git a/src/Libraries/AvalonEdit/ICSharpCode.AvalonEdit/Editing/CaretNavigationCommandHandler.cs b/src/Libraries/AvalonEdit/ICSharpCode.AvalonEdit/Editing/CaretNavigationCommandHandler.cs
index 8c0774d60f..03a4598beb 100644
--- a/src/Libraries/AvalonEdit/ICSharpCode.AvalonEdit/Editing/CaretNavigationCommandHandler.cs
+++ b/src/Libraries/AvalonEdit/ICSharpCode.AvalonEdit/Editing/CaretNavigationCommandHandler.cs
@@ -15,6 +15,24 @@ using ICSharpCode.AvalonEdit.Utils;
namespace ICSharpCode.AvalonEdit.Editing
{
+ enum CaretMovementType
+ {
+ None,
+ CharLeft,
+ CharRight,
+ Backspace,
+ WordLeft,
+ WordRight,
+ LineUp,
+ LineDown,
+ PageUp,
+ PageDown,
+ LineStart,
+ LineEnd,
+ DocumentStart,
+ DocumentEnd
+ }
+
static class CaretNavigationCommandHandler
{
///
@@ -102,22 +120,6 @@ namespace ICSharpCode.AvalonEdit.Editing
return target as TextArea;
}
- enum CaretMovementType
- {
- CharLeft,
- CharRight,
- WordLeft,
- WordRight,
- LineUp,
- LineDown,
- PageUp,
- PageDown,
- LineStart,
- LineEnd,
- DocumentStart,
- DocumentEnd
- }
-
static ExecutedRoutedEventHandler OnMoveCaret(CaretMovementType direction)
{
return (target, args) => {
@@ -140,8 +142,7 @@ namespace ICSharpCode.AvalonEdit.Editing
TextViewPosition oldPosition = textArea.Caret.Position;
MoveCaret(textArea, direction);
textArea.Selection = textArea.Selection.StartSelectionOrSetEndpoint(oldPosition, textArea.Caret.Position);
- if (!textArea.Document.IsInUpdate) // if we're inside a larger update (e.g. called by EditingCommandHandler.OnDelete()), avoid calculating the caret rectangle now
- textArea.Caret.BringCaretToView();
+ textArea.Caret.BringCaretToView();
}
};
}
@@ -172,43 +173,55 @@ namespace ICSharpCode.AvalonEdit.Editing
}
#region Caret movement
- static void MoveCaret(TextArea textArea, CaretMovementType direction)
+ internal static void MoveCaret(TextArea textArea, CaretMovementType direction)
{
- DocumentLine caretLine = textArea.Document.GetLineByNumber(textArea.Caret.Line);
- VisualLine visualLine = textArea.TextView.GetOrConstructVisualLine(caretLine);
- TextViewPosition caretPosition = textArea.Caret.Position;
+ double desiredXPos = textArea.Caret.DesiredXPos;
+ textArea.Caret.Position = GetNewCaretPosition(textArea.TextView, textArea.Caret.Position, direction, textArea.Selection.EnableVirtualSpace, ref desiredXPos);
+ textArea.Caret.DesiredXPos = desiredXPos;
+ }
+
+ internal static TextViewPosition GetNewCaretPosition(TextView textView, TextViewPosition caretPosition, CaretMovementType direction, bool enableVirtualSpace, ref double desiredXPos)
+ {
+ switch (direction) {
+ case CaretMovementType.None:
+ return caretPosition;
+ case CaretMovementType.DocumentStart:
+ desiredXPos = double.NaN;
+ return new TextViewPosition(0, 0);
+ case CaretMovementType.DocumentEnd:
+ desiredXPos = double.NaN;
+ return new TextViewPosition(textView.Document.GetLocation(textView.Document.TextLength));
+ }
+ DocumentLine caretLine = textView.Document.GetLineByNumber(caretPosition.Line);
+ VisualLine visualLine = textView.GetOrConstructVisualLine(caretLine);
TextLine textLine = visualLine.GetTextLine(caretPosition.VisualColumn, caretPosition.IsAtEndOfLine);
switch (direction) {
case CaretMovementType.CharLeft:
- MoveCaretLeft(textArea, caretPosition, visualLine, CaretPositioningMode.Normal);
- break;
+ desiredXPos = double.NaN;
+ return GetPrevCaretPosition(textView, caretPosition, visualLine, CaretPositioningMode.Normal, enableVirtualSpace);
+ case CaretMovementType.Backspace:
+ desiredXPos = double.NaN;
+ return GetPrevCaretPosition(textView, caretPosition, visualLine, CaretPositioningMode.EveryCodepoint, enableVirtualSpace);
case CaretMovementType.CharRight:
- MoveCaretRight(textArea, caretPosition, visualLine, CaretPositioningMode.Normal);
- break;
+ desiredXPos = double.NaN;
+ return GetNextCaretPosition(textView, caretPosition, visualLine, CaretPositioningMode.Normal, enableVirtualSpace);
case CaretMovementType.WordLeft:
- MoveCaretLeft(textArea, caretPosition, visualLine, CaretPositioningMode.WordStart);
- break;
+ desiredXPos = double.NaN;
+ return GetPrevCaretPosition(textView, caretPosition, visualLine, CaretPositioningMode.WordStart, enableVirtualSpace);
case CaretMovementType.WordRight:
- MoveCaretRight(textArea, caretPosition, visualLine, CaretPositioningMode.WordStart);
- break;
+ desiredXPos = double.NaN;
+ return GetNextCaretPosition(textView, caretPosition, visualLine, CaretPositioningMode.WordStart, enableVirtualSpace);
case CaretMovementType.LineUp:
case CaretMovementType.LineDown:
case CaretMovementType.PageUp:
case CaretMovementType.PageDown:
- MoveCaretUpDown(textArea, direction, visualLine, textLine, caretPosition.VisualColumn);
- break;
- case CaretMovementType.DocumentStart:
- SetCaretPosition(textArea, 0, 0);
- break;
- case CaretMovementType.DocumentEnd:
- SetCaretPosition(textArea, -1, textArea.Document.TextLength);
- break;
+ return GetUpDownCaretPosition(textView, caretPosition, direction, visualLine, textLine, enableVirtualSpace, ref desiredXPos);
case CaretMovementType.LineStart:
- MoveCaretToStartOfLine(textArea, visualLine, textLine);
- break;
+ desiredXPos = double.NaN;
+ return GetStartOfLineCaretPosition(caretPosition.VisualColumn, visualLine, textLine, enableVirtualSpace);
case CaretMovementType.LineEnd:
- MoveCaretToEndOfLine(textArea, visualLine, textLine);
- break;
+ desiredXPos = double.NaN;
+ return GetEndOfLineCaretPosition(visualLine, textLine);
default:
throw new NotSupportedException(direction.ToString());
}
@@ -216,81 +229,80 @@ namespace ICSharpCode.AvalonEdit.Editing
#endregion
#region Home/End
- static void MoveCaretToStartOfLine(TextArea textArea, VisualLine visualLine, TextLine textLine)
+ static TextViewPosition GetStartOfLineCaretPosition(int oldVC, VisualLine visualLine, TextLine textLine, bool enableVirtualSpace)
{
int newVC = visualLine.GetTextLineVisualStartColumn(textLine);
if (newVC == 0)
- newVC = visualLine.GetNextCaretPosition(newVC - 1, LogicalDirection.Forward, CaretPositioningMode.WordStart, textArea.Selection.EnableVirtualSpace);
+ newVC = visualLine.GetNextCaretPosition(newVC - 1, LogicalDirection.Forward, CaretPositioningMode.WordStart, enableVirtualSpace);
if (newVC < 0)
throw ThrowUtil.NoValidCaretPosition();
// when the caret is already at the start of the text, jump to start before whitespace
- if (newVC == textArea.Caret.VisualColumn)
+ if (newVC == oldVC)
newVC = 0;
- int offset = visualLine.FirstDocumentLine.Offset + visualLine.GetRelativeOffset(newVC);
- SetCaretPosition(textArea, newVC, offset);
+ return visualLine.GetTextViewPosition(newVC);
}
- static void MoveCaretToEndOfLine(TextArea textArea, VisualLine visualLine, TextLine textLine)
+ static TextViewPosition GetEndOfLineCaretPosition(VisualLine visualLine, TextLine textLine)
{
int newVC = visualLine.GetTextLineVisualStartColumn(textLine) + textLine.Length - textLine.TrailingWhitespaceLength;
- int offset = visualLine.FirstDocumentLine.Offset + visualLine.GetRelativeOffset(newVC);
- SetCaretPosition(textArea, newVC, offset, isAtEndOfLine: true);
+ TextViewPosition pos = visualLine.GetTextViewPosition(newVC);
+ pos.IsAtEndOfLine = true;
+ return pos;
}
#endregion
#region By-character / By-word movement
- static void MoveCaretRight(TextArea textArea, TextViewPosition caretPosition, VisualLine visualLine, CaretPositioningMode mode)
+ static TextViewPosition GetNextCaretPosition(TextView textView, TextViewPosition caretPosition, VisualLine visualLine, CaretPositioningMode mode, bool enableVirtualSpace)
{
- int pos = visualLine.GetNextCaretPosition(caretPosition.VisualColumn, LogicalDirection.Forward, mode, textArea.Selection.EnableVirtualSpace);
+ int pos = visualLine.GetNextCaretPosition(caretPosition.VisualColumn, LogicalDirection.Forward, mode, enableVirtualSpace);
if (pos >= 0) {
- SetCaretPosition(textArea, pos, visualLine.GetRelativeOffset(pos) + visualLine.FirstDocumentLine.Offset);
+ return visualLine.GetTextViewPosition(pos);
} else {
// move to start of next line
DocumentLine nextDocumentLine = visualLine.LastDocumentLine.NextLine;
if (nextDocumentLine != null) {
- VisualLine nextLine = textArea.TextView.GetOrConstructVisualLine(nextDocumentLine);
- pos = nextLine.GetNextCaretPosition(-1, LogicalDirection.Forward, mode, textArea.Selection.EnableVirtualSpace);
+ VisualLine nextLine = textView.GetOrConstructVisualLine(nextDocumentLine);
+ pos = nextLine.GetNextCaretPosition(-1, LogicalDirection.Forward, mode, enableVirtualSpace);
if (pos < 0)
throw ThrowUtil.NoValidCaretPosition();
- SetCaretPosition(textArea, pos, nextLine.GetRelativeOffset(pos) + nextLine.FirstDocumentLine.Offset);
+ return nextLine.GetTextViewPosition(pos);
} else {
// at end of document
- Debug.Assert(visualLine.LastDocumentLine.Offset + visualLine.LastDocumentLine.TotalLength == textArea.Document.TextLength);
- SetCaretPosition(textArea, -1, textArea.Document.TextLength);
+ Debug.Assert(visualLine.LastDocumentLine.Offset + visualLine.LastDocumentLine.TotalLength == textView.Document.TextLength);
+ return new TextViewPosition(textView.Document.GetLocation(textView.Document.TextLength));
}
}
}
- static void MoveCaretLeft(TextArea textArea, TextViewPosition caretPosition, VisualLine visualLine, CaretPositioningMode mode)
+ static TextViewPosition GetPrevCaretPosition(TextView textView, TextViewPosition caretPosition, VisualLine visualLine, CaretPositioningMode mode, bool enableVirtualSpace)
{
- int pos = visualLine.GetNextCaretPosition(caretPosition.VisualColumn, LogicalDirection.Backward, mode, textArea.Selection.EnableVirtualSpace);
+ int pos = visualLine.GetNextCaretPosition(caretPosition.VisualColumn, LogicalDirection.Backward, mode, enableVirtualSpace);
if (pos >= 0) {
- SetCaretPosition(textArea, pos, visualLine.GetRelativeOffset(pos) + visualLine.FirstDocumentLine.Offset);
+ return visualLine.GetTextViewPosition(pos);
} else {
// move to end of previous line
DocumentLine previousDocumentLine = visualLine.FirstDocumentLine.PreviousLine;
if (previousDocumentLine != null) {
- VisualLine previousLine = textArea.TextView.GetOrConstructVisualLine(previousDocumentLine);
- pos = previousLine.GetNextCaretPosition(previousLine.VisualLength + 1, LogicalDirection.Backward, mode, textArea.Selection.EnableVirtualSpace);
+ VisualLine previousLine = textView.GetOrConstructVisualLine(previousDocumentLine);
+ pos = previousLine.GetNextCaretPosition(previousLine.VisualLength + 1, LogicalDirection.Backward, mode, enableVirtualSpace);
if (pos < 0)
throw ThrowUtil.NoValidCaretPosition();
- SetCaretPosition(textArea, pos, previousLine.GetRelativeOffset(pos) + previousLine.FirstDocumentLine.Offset);
+ return previousLine.GetTextViewPosition(pos);
} else {
// at start of document
Debug.Assert(visualLine.FirstDocumentLine.Offset == 0);
- SetCaretPosition(textArea, 0, 0);
+ return new TextViewPosition(0, 0);
}
}
}
#endregion
#region Line+Page up/down
- static void MoveCaretUpDown(TextArea textArea, CaretMovementType direction, VisualLine visualLine, TextLine textLine, int caretVisualColumn)
+ static TextViewPosition GetUpDownCaretPosition(TextView textView, TextViewPosition caretPosition, CaretMovementType direction, VisualLine visualLine, TextLine textLine, bool enableVirtualSpace, ref double xPos)
{
// moving up/down happens using the desired visual X position
- double xPos = textArea.Caret.DesiredXPos;
if (double.IsNaN(xPos))
- xPos = visualLine.GetTextLineVisualXPosition(textLine, caretVisualColumn);
+ xPos = visualLine.GetTextLineVisualXPosition(textLine, caretPosition.VisualColumn);
// now find the TextLine+VisualLine where the caret will end up in
VisualLine targetVisualLine = visualLine;
TextLine targetLine;
@@ -304,8 +316,8 @@ namespace ICSharpCode.AvalonEdit.Editing
if (textLineIndex > 0) {
targetLine = visualLine.TextLines[textLineIndex - 1];
} else if (prevLineNumber >= 1) {
- DocumentLine prevLine = textArea.Document.GetLineByNumber(prevLineNumber);
- targetVisualLine = textArea.TextView.GetOrConstructVisualLine(prevLine);
+ DocumentLine prevLine = textView.Document.GetLineByNumber(prevLineNumber);
+ targetVisualLine = textView.GetOrConstructVisualLine(prevLine);
targetLine = targetVisualLine.TextLines[targetVisualLine.TextLines.Count - 1];
} else {
targetLine = null;
@@ -319,9 +331,9 @@ namespace ICSharpCode.AvalonEdit.Editing
int nextLineNumber = visualLine.LastDocumentLine.LineNumber + 1;
if (textLineIndex < visualLine.TextLines.Count - 1) {
targetLine = visualLine.TextLines[textLineIndex + 1];
- } else if (nextLineNumber <= textArea.Document.LineCount) {
- DocumentLine nextLine = textArea.Document.GetLineByNumber(nextLineNumber);
- targetVisualLine = textArea.TextView.GetOrConstructVisualLine(nextLine);
+ } else if (nextLineNumber <= textView.Document.LineCount) {
+ DocumentLine nextLine = textView.Document.GetLineByNumber(nextLineNumber);
+ targetVisualLine = textView.GetOrConstructVisualLine(nextLine);
targetLine = targetVisualLine.TextLines[0];
} else {
targetLine = null;
@@ -334,11 +346,11 @@ namespace ICSharpCode.AvalonEdit.Editing
// Page up/down: find the target line using its visual position
double yPos = visualLine.GetTextLineVisualYPosition(textLine, VisualYPosition.LineMiddle);
if (direction == CaretMovementType.PageUp)
- yPos -= textArea.TextView.RenderSize.Height;
+ yPos -= textView.RenderSize.Height;
else
- yPos += textArea.TextView.RenderSize.Height;
- DocumentLine newLine = textArea.TextView.GetDocumentLineByVisualTop(yPos);
- targetVisualLine = textArea.TextView.GetOrConstructVisualLine(newLine);
+ yPos += textView.RenderSize.Height;
+ DocumentLine newLine = textView.GetDocumentLineByVisualTop(yPos);
+ targetVisualLine = textView.GetOrConstructVisualLine(newLine);
targetLine = targetVisualLine.GetTextLineByVisualYPosition(yPos);
break;
}
@@ -347,30 +359,18 @@ namespace ICSharpCode.AvalonEdit.Editing
}
if (targetLine != null) {
double yPos = targetVisualLine.GetTextLineVisualYPosition(targetLine, VisualYPosition.LineMiddle);
- int newVisualColumn = targetVisualLine.GetVisualColumn(new Point(xPos, yPos), textArea.Selection.EnableVirtualSpace);
- SetCaretPosition(textArea, targetVisualLine, targetLine, newVisualColumn, false);
- textArea.Caret.DesiredXPos = xPos;
- }
- }
- #endregion
-
- #region SetCaretPosition
- static void SetCaretPosition(TextArea textArea, VisualLine targetVisualLine, TextLine targetLine,
- int newVisualColumn, bool allowWrapToNextLine)
- {
- int targetLineStartCol = targetVisualLine.GetTextLineVisualStartColumn(targetLine);
- if (!allowWrapToNextLine && newVisualColumn >= targetLineStartCol + targetLine.Length) {
- if (newVisualColumn <= targetVisualLine.VisualLength)
- newVisualColumn = targetLineStartCol + targetLine.Length - 1;
+ int newVisualColumn = targetVisualLine.GetVisualColumn(new Point(xPos, yPos), enableVirtualSpace);
+
+ // prevent wrapping to the next line; TODO: could 'IsAtEnd' help here?
+ int targetLineStartCol = targetVisualLine.GetTextLineVisualStartColumn(targetLine);
+ if (newVisualColumn >= targetLineStartCol + targetLine.Length) {
+ if (newVisualColumn <= targetVisualLine.VisualLength)
+ newVisualColumn = targetLineStartCol + targetLine.Length - 1;
+ }
+ return targetVisualLine.GetTextViewPosition(newVisualColumn);
+ } else {
+ return caretPosition;
}
- int newOffset = targetVisualLine.GetRelativeOffset(newVisualColumn) + targetVisualLine.FirstDocumentLine.Offset;
- SetCaretPosition(textArea, newVisualColumn, newOffset);
- }
-
- static void SetCaretPosition(TextArea textArea, int newVisualColumn, int newOffset, bool isAtEndOfLine = false)
- {
- textArea.Caret.Position = new TextViewPosition(textArea.Document.GetLocation(newOffset), newVisualColumn) { IsAtEndOfLine = isAtEndOfLine };
- textArea.Caret.DesiredXPos = double.NaN;
}
#endregion
}
diff --git a/src/Libraries/AvalonEdit/ICSharpCode.AvalonEdit/Editing/EditingCommandHandler.cs b/src/Libraries/AvalonEdit/ICSharpCode.AvalonEdit/Editing/EditingCommandHandler.cs
index f7cbb167ff..204489208e 100644
--- a/src/Libraries/AvalonEdit/ICSharpCode.AvalonEdit/Editing/EditingCommandHandler.cs
+++ b/src/Libraries/AvalonEdit/ICSharpCode.AvalonEdit/Editing/EditingCommandHandler.cs
@@ -46,12 +46,12 @@ namespace ICSharpCode.AvalonEdit.Editing
static EditingCommandHandler()
{
- CommandBindings.Add(new CommandBinding(ApplicationCommands.Delete, OnDelete(ApplicationCommands.NotACommand), CanDelete));
- AddBinding(EditingCommands.Delete, ModifierKeys.None, Key.Delete, OnDelete(EditingCommands.SelectRightByCharacter));
- AddBinding(EditingCommands.DeleteNextWord, ModifierKeys.Control, Key.Delete, OnDelete(EditingCommands.SelectRightByWord));
- AddBinding(EditingCommands.Backspace, ModifierKeys.None, Key.Back, OnDelete(EditingCommands.SelectLeftByCharacter));
+ CommandBindings.Add(new CommandBinding(ApplicationCommands.Delete, OnDelete(CaretMovementType.None), CanDelete));
+ AddBinding(EditingCommands.Delete, ModifierKeys.None, Key.Delete, OnDelete(CaretMovementType.CharRight));
+ AddBinding(EditingCommands.DeleteNextWord, ModifierKeys.Control, Key.Delete, OnDelete(CaretMovementType.WordRight));
+ AddBinding(EditingCommands.Backspace, ModifierKeys.None, Key.Back, OnDelete(CaretMovementType.Backspace));
InputBindings.Add(TextAreaDefaultInputHandler.CreateFrozenKeyBinding(EditingCommands.Backspace, ModifierKeys.Shift, Key.Back)); // make Shift-Backspace do the same as plain backspace
- AddBinding(EditingCommands.DeletePreviousWord, ModifierKeys.Control, Key.Back, OnDelete(EditingCommands.SelectLeftByWord));
+ AddBinding(EditingCommands.DeletePreviousWord, ModifierKeys.Control, Key.Back, OnDelete(CaretMovementType.WordLeft));
AddBinding(EditingCommands.EnterParagraphBreak, ModifierKeys.None, Key.Enter, OnEnter);
AddBinding(EditingCommands.EnterLineBreak, ModifierKeys.Shift, Key.Enter, OnEnter);
AddBinding(EditingCommands.TabForward, ModifierKeys.None, Key.Tab, OnTab);
@@ -225,34 +225,24 @@ namespace ICSharpCode.AvalonEdit.Editing
#endregion
#region Delete
- static ExecutedRoutedEventHandler OnDelete(RoutedUICommand selectingCommand)
+ static ExecutedRoutedEventHandler OnDelete(CaretMovementType caretMovement)
{
return (target, args) => {
TextArea textArea = GetTextArea(target);
if (textArea != null && textArea.Document != null) {
- // call BeginUpdate before running the 'selectingCommand'
- // so that undoing the delete does not select the deleted character
- using (textArea.Document.RunUpdate()) {
- if (textArea.Selection.IsEmpty) {
- TextViewPosition oldCaretPosition = textArea.Caret.Position;
- if (textArea.Caret.IsInVirtualSpace && selectingCommand == EditingCommands.SelectRightByCharacter)
- EditingCommands.SelectRightByWord.Execute(args.Parameter, textArea);
- else
- selectingCommand.Execute(args.Parameter, textArea);
- bool hasSomethingDeletable = false;
- foreach (ISegment s in textArea.Selection.Segments) {
- if (textArea.GetDeletableSegments(s).Length > 0) {
- hasSomethingDeletable = true;
- break;
- }
- }
- if (!hasSomethingDeletable) {
- // If nothing in the selection is deletable; then reset caret+selection
- // to the previous value. This prevents the caret from moving through read-only sections.
- textArea.Caret.Position = oldCaretPosition;
- textArea.ClearSelection();
- }
- }
+ if (textArea.Selection.IsEmpty) {
+ TextViewPosition startPos = textArea.Caret.Position;
+ bool enableVirtualSpace = textArea.Options.EnableVirtualSpace;
+ // When pressing delete; don't move the caret further into virtual space - instead delete the newline
+ if (caretMovement == CaretMovementType.CharRight)
+ enableVirtualSpace = false;
+ double desiredXPos = textArea.Caret.DesiredXPos;
+ TextViewPosition endPos = CaretNavigationCommandHandler.GetNewCaretPosition(
+ textArea.TextView, startPos, caretMovement, enableVirtualSpace, ref desiredXPos);
+ // Don't select the text to be deleted; just reuse the ReplaceSelectionWithText logic
+ var sel = new SimpleSelection(textArea, startPos, endPos);
+ sel.ReplaceSelectionWithText(string.Empty);
+ } else {
textArea.RemoveSelectedText();
}
textArea.Caret.BringCaretToView();
diff --git a/src/Libraries/AvalonEdit/ICSharpCode.AvalonEdit/Editing/SimpleSelection.cs b/src/Libraries/AvalonEdit/ICSharpCode.AvalonEdit/Editing/SimpleSelection.cs
index 5f053b08ac..76e48d2cf6 100644
--- a/src/Libraries/AvalonEdit/ICSharpCode.AvalonEdit/Editing/SimpleSelection.cs
+++ b/src/Libraries/AvalonEdit/ICSharpCode.AvalonEdit/Editing/SimpleSelection.cs
@@ -55,10 +55,16 @@ namespace ICSharpCode.AvalonEdit.Editing
if (segmentsToDelete[i].Offset == SurroundingSegment.Offset && segmentsToDelete[i].Length == SurroundingSegment.Length) {
newText = AddSpacesIfRequired(newText, start, end);
}
- int vc = textArea.Caret.VisualColumn;
- textArea.Caret.Offset = segmentsToDelete[i].EndOffset;
- if (string.IsNullOrEmpty(newText))
- textArea.Caret.VisualColumn = vc;
+ if (string.IsNullOrEmpty(newText)) {
+ // place caret at the beginning of the selection
+ if (start.CompareTo(end) <= 0)
+ textArea.Caret.Position = start;
+ else
+ textArea.Caret.Position = end;
+ } else {
+ // place caret so that it ends up behind the new text
+ textArea.Caret.Offset = segmentsToDelete[i].EndOffset;
+ }
textArea.Document.Replace(segmentsToDelete[i], newText);
} else {
textArea.Document.Remove(segmentsToDelete[i]);
@@ -100,7 +106,7 @@ namespace ICSharpCode.AvalonEdit.Editing
///
public override bool IsEmpty {
- get { return startOffset == endOffset; }
+ get { return startOffset == endOffset && start.VisualColumn == end.VisualColumn; }
}
///
diff --git a/src/Libraries/AvalonEdit/ICSharpCode.AvalonEdit/Rendering/SingleCharacterElementGenerator.cs b/src/Libraries/AvalonEdit/ICSharpCode.AvalonEdit/Rendering/SingleCharacterElementGenerator.cs
index b1cf4e6b8b..46a600bf69 100644
--- a/src/Libraries/AvalonEdit/ICSharpCode.AvalonEdit/Rendering/SingleCharacterElementGenerator.cs
+++ b/src/Libraries/AvalonEdit/ICSharpCode.AvalonEdit/Rendering/SingleCharacterElementGenerator.cs
@@ -111,7 +111,7 @@ namespace ICSharpCode.AvalonEdit.Rendering
public override int GetNextCaretPosition(int visualColumn, LogicalDirection direction, CaretPositioningMode mode)
{
- if (mode == CaretPositioningMode.Normal)
+ if (mode == CaretPositioningMode.Normal || mode == CaretPositioningMode.EveryCodepoint)
return base.GetNextCaretPosition(visualColumn, direction, mode);
else
return -1;
@@ -146,7 +146,7 @@ namespace ICSharpCode.AvalonEdit.Rendering
public override int GetNextCaretPosition(int visualColumn, LogicalDirection direction, CaretPositioningMode mode)
{
- if (mode == CaretPositioningMode.Normal)
+ if (mode == CaretPositioningMode.Normal || mode == CaretPositioningMode.EveryCodepoint)
return base.GetNextCaretPosition(visualColumn, direction, mode);
else
return -1;
diff --git a/src/Libraries/AvalonEdit/ICSharpCode.AvalonEdit/Rendering/VisualLine.cs b/src/Libraries/AvalonEdit/ICSharpCode.AvalonEdit/Rendering/VisualLine.cs
index 76d6e657c1..f1e437588e 100644
--- a/src/Libraries/AvalonEdit/ICSharpCode.AvalonEdit/Rendering/VisualLine.cs
+++ b/src/Libraries/AvalonEdit/ICSharpCode.AvalonEdit/Rendering/VisualLine.cs
@@ -548,6 +548,15 @@ namespace ICSharpCode.AvalonEdit.Rendering
return ch.FirstCharacterIndex;
}
+ ///
+ /// Gets the text view position from the specified visual column.
+ ///
+ public TextViewPosition GetTextViewPosition(int visualColumn)
+ {
+ int documentOffset = GetRelativeOffset(visualColumn) + this.FirstDocumentLine.Offset;
+ return new TextViewPosition(this.Document.GetLocation(documentOffset), visualColumn);
+ }
+
///
/// Gets the text view position from the specified visual position.
/// If the position is within a character, it is rounded to the next character boundary.
@@ -690,12 +699,12 @@ namespace ICSharpCode.AvalonEdit.Rendering
static bool HasStopsInVirtualSpace(CaretPositioningMode mode)
{
- return mode == CaretPositioningMode.Normal;
+ return mode == CaretPositioningMode.Normal || mode == CaretPositioningMode.EveryCodepoint;
}
static bool HasImplicitStopAtLineStart(CaretPositioningMode mode)
{
- return mode == CaretPositioningMode.Normal;
+ return mode == CaretPositioningMode.Normal || mode == CaretPositioningMode.EveryCodepoint;
}
[System.Diagnostics.CodeAnalysis.SuppressMessage("Microsoft.Usage", "CA1801:ReviewUnusedParameters", MessageId = "mode",
diff --git a/src/Main/Base/Project/Dom/ClassBrowser/AssemblyLoadErrorTreeNode.cs b/src/Main/Base/Project/Dom/ClassBrowser/AssemblyLoadErrorTreeNode.cs
new file mode 100644
index 0000000000..97ce410a1f
--- /dev/null
+++ b/src/Main/Base/Project/Dom/ClassBrowser/AssemblyLoadErrorTreeNode.cs
@@ -0,0 +1,27 @@
+// Copyright (c) AlphaSierraPapa for the SharpDevelop Team (for details please see \doc\copyright.txt)
+// This code is distributed under the GNU LGPL (for details please see \doc\license.txt)
+
+using System;
+using System.Collections.Generic;
+using ICSharpCode.Core.Presentation;
+using ICSharpCode.TreeView;
+
+namespace ICSharpCode.SharpDevelop.Dom.ClassBrowser
+{
+ public class AssemblyLoadErrorTreeNode : SharpTreeNode
+ {
+ public override object Text {
+ get {
+ return "(Assembly not loadable)";
+ }
+ }
+
+ public override object Icon {
+ get {
+ return null;
+ }
+ }
+ }
+}
+
+
diff --git a/src/Main/Base/Project/Dom/ClassBrowser/AssemblyTreeNode.cs b/src/Main/Base/Project/Dom/ClassBrowser/AssemblyTreeNode.cs
index ea114cacd0..3f91079d7a 100644
--- a/src/Main/Base/Project/Dom/ClassBrowser/AssemblyTreeNode.cs
+++ b/src/Main/Base/Project/Dom/ClassBrowser/AssemblyTreeNode.cs
@@ -3,6 +3,7 @@
using System;
using System.Collections.Generic;
+using ICSharpCode.Core.Presentation;
using ICSharpCode.TreeView;
namespace ICSharpCode.SharpDevelop.Dom.ClassBrowser
@@ -35,6 +36,17 @@ namespace ICSharpCode.SharpDevelop.Dom.ClassBrowser
}
}
+ protected override void LoadChildren()
+ {
+ Children.Clear();
+ if (model.Context.IsValid) {
+ base.LoadChildren();
+ } else {
+ // This assembly could not be loaded correctly, add sub-node with error text
+ Children.Add(new AssemblyLoadErrorTreeNode());
+ }
+ }
+
public override object Text {
get {
return model.AssemblyName;
@@ -43,7 +55,19 @@ namespace ICSharpCode.SharpDevelop.Dom.ClassBrowser
public override object Icon {
get {
- return SD.ResourceService.GetImageSource("Icons.16x16.Assembly");
+ if (model.Context.IsValid) {
+ return SD.ResourceService.GetImageSource("Icons.16x16.Assembly");
+ } else {
+ return SD.ResourceService.GetImageSource("Icons.16x16.AssemblyError");
+ }
+ }
+ }
+
+ public override void ShowContextMenu()
+ {
+ var assemblyModel = this.Model as IAssemblyModel;
+ if (assemblyModel != null) {
+ var ctx = MenuService.ShowContextMenu(null, assemblyModel, "/SharpDevelop/Pads/ClassBrowser/AssemblyContextMenu");
}
}
}
diff --git a/src/Main/Base/Project/Dom/ClassBrowser/TypeDefinitionTreeNode.cs b/src/Main/Base/Project/Dom/ClassBrowser/TypeDefinitionTreeNode.cs
index 7141734783..aaab2f62ac 100644
--- a/src/Main/Base/Project/Dom/ClassBrowser/TypeDefinitionTreeNode.cs
+++ b/src/Main/Base/Project/Dom/ClassBrowser/TypeDefinitionTreeNode.cs
@@ -3,10 +3,12 @@
using System;
using System.Collections.Generic;
+using System.Security.Policy;
using ICSharpCode.Core.Presentation;
using ICSharpCode.NRefactory.TypeSystem;
using ICSharpCode.NRefactory.Utils;
using ICSharpCode.TreeView;
+using ICSharpCode.SharpDevelop.Dom;
namespace ICSharpCode.SharpDevelop.Dom.ClassBrowser
{
@@ -48,7 +50,7 @@ namespace ICSharpCode.SharpDevelop.Dom.ClassBrowser
protected override IModelCollection
public class WorkspaceTreeNode : ModelCollectionTreeNode
{
+ class WorkspaceChildComparer : IComparer
+ {
+ IComparer stringComparer = StringComparer.OrdinalIgnoreCase;
+
+ public int Compare(SharpTreeNode x, SharpTreeNode y)
+ {
+ // Solution node has precedence over other nodes
+ if ((x is SolutionTreeNode) && !(y is SolutionTreeNode))
+ return -1;
+ if (!(x is SolutionTreeNode) && (y is SolutionTreeNode))
+ return 1;
+
+ // Both nodes are solutions or not solutions, compare their Text property
+ return stringComparer.Compare(x.Text.ToString(), y.Text.ToString());
+ }
+ }
+
WorkspaceModel workspace;
+ protected static readonly IComparer ChildNodeComparer = new WorkspaceChildComparer();
public IMutableModelCollection SpecialNodes {
get { return workspace.SpecialNodes; }
@@ -40,7 +59,7 @@ namespace ICSharpCode.SharpDevelop.Dom.ClassBrowser
}
protected override IComparer NodeComparer {
- get { return NodeTextComparer; }
+ get { return ChildNodeComparer; }
}
public override object Text {
@@ -62,7 +81,9 @@ namespace ICSharpCode.SharpDevelop.Dom.ClassBrowser
protected override void InsertSpecialNodes()
{
- Children.AddRange(workspace.SpecialNodes);
+ foreach (var node in workspace.SpecialNodes) {
+ Children.OrderedInsert(node, ChildNodeComparer);
+ }
}
void SpecialNodesModelCollectionChanged(IReadOnlyCollection removedItems, IReadOnlyCollection addedItems)
diff --git a/src/Main/Base/Project/Dom/IAssemblyModel.cs b/src/Main/Base/Project/Dom/IAssemblyModel.cs
index 11a081dd01..f3df5c2589 100644
--- a/src/Main/Base/Project/Dom/IAssemblyModel.cs
+++ b/src/Main/Base/Project/Dom/IAssemblyModel.cs
@@ -42,6 +42,11 @@ namespace ICSharpCode.SharpDevelop.Dom
/// This always is the namespace without a name - it's unrelated to the 'root namespace' project setting.
///
INamespaceModel RootNamespace { get; }
+
+ ///
+ /// Gets the of this assembly model.
+ ///
+ IEntityModelContext Context { get; }
}
///
@@ -92,6 +97,12 @@ namespace ICSharpCode.SharpDevelop.Dom
public INamespaceModel RootNamespace {
get { return EmptyNamespaceModel.Instance; }
}
+
+ public IEntityModelContext Context {
+ get {
+ return null;
+ }
+ }
}
}
diff --git a/src/Main/Base/Project/Dom/IEntityModelContext.cs b/src/Main/Base/Project/Dom/IEntityModelContext.cs
index 5fe67f32e4..542c87d107 100644
--- a/src/Main/Base/Project/Dom/IEntityModelContext.cs
+++ b/src/Main/Base/Project/Dom/IEntityModelContext.cs
@@ -34,6 +34,21 @@ namespace ICSharpCode.SharpDevelop.Dom
/// Returns true if part1 is considered a better candidate for the primary part than part2.
///
bool IsBetterPart(IUnresolvedTypeDefinition part1, IUnresolvedTypeDefinition part2);
+
+ ///
+ /// Short name of current assembly.
+ ///
+ string AssemblyName { get; }
+
+ ///
+ /// Full path and file name of the assembly. Output assembly for projects.
+ ///
+ string Location { get; }
+
+ ///
+ /// Returns whether this is a valid context (based on a existing and readable definition).
+ ///
+ bool IsValid { get; }
}
public class ProjectEntityModelContext : IEntityModelContext
@@ -53,6 +68,10 @@ namespace ICSharpCode.SharpDevelop.Dom
get { return project.AssemblyName; }
}
+ public string Location {
+ get { return project.OutputAssemblyFullPath; }
+ }
+
public IProject Project {
get { return project; }
}
@@ -66,6 +85,10 @@ namespace ICSharpCode.SharpDevelop.Dom
{
return EntityModelContextUtils.IsBetterPart(part1, part2, primaryCodeFileExtension);
}
+
+ public bool IsValid {
+ get { return true; }
+ }
}
public class AssemblyEntityModelContext : IEntityModelContext
@@ -88,6 +111,10 @@ namespace ICSharpCode.SharpDevelop.Dom
get { return mainAssembly.AssemblyName; }
}
+ public string Location {
+ get { return mainAssembly.Location; }
+ }
+
public ICompilation GetCompilation()
{
return compilation;
@@ -101,6 +128,10 @@ namespace ICSharpCode.SharpDevelop.Dom
public IProject Project {
get { return null; }
}
+
+ public bool IsValid {
+ get { return true; }
+ }
}
public static class EntityModelContextUtils
diff --git a/src/Main/Base/Project/ICSharpCode.SharpDevelop.addin b/src/Main/Base/Project/ICSharpCode.SharpDevelop.addin
index cc5ad44323..ba134100d2 100755
--- a/src/Main/Base/Project/ICSharpCode.SharpDevelop.addin
+++ b/src/Main/Base/Project/ICSharpCode.SharpDevelop.addin
@@ -908,7 +908,7 @@
-
-
+ -->
+ class = "ICSharpCode.SharpDevelop.Dom.ClassBrowser.OpenAssemblyFromFileCommand"/>
+ class = "ICSharpCode.SharpDevelop.Dom.ClassBrowser.OpenAssemblyFromGACCommand"/>
-
+ class = "ICSharpCode.SharpDevelop.Dom.ClassBrowser.ClassBrowserCollapseAll"/>-->
@@ -988,6 +988,13 @@
class = "ICSharpCode.SharpDevelop.Gui.ClassBrowser.ClassBrowserCancelSearch"/>
+
+
+
+
diff --git a/src/Main/Base/Project/ICSharpCode.SharpDevelop.csproj b/src/Main/Base/Project/ICSharpCode.SharpDevelop.csproj
index c787f8550f..91a1577bd1 100644
--- a/src/Main/Base/Project/ICSharpCode.SharpDevelop.csproj
+++ b/src/Main/Base/Project/ICSharpCode.SharpDevelop.csproj
@@ -84,6 +84,7 @@
+
diff --git a/src/Main/Base/Project/Src/Editor/Dialogs/RenameSymbolDialog.xaml.cs b/src/Main/Base/Project/Src/Editor/Dialogs/RenameSymbolDialog.xaml.cs
index 16a71c429e..580ea9ff5f 100644
--- a/src/Main/Base/Project/Src/Editor/Dialogs/RenameSymbolDialog.xaml.cs
+++ b/src/Main/Base/Project/Src/Editor/Dialogs/RenameSymbolDialog.xaml.cs
@@ -42,6 +42,7 @@ namespace ICSharpCode.SharpDevelop.Editor.Dialogs
// Set focus into TextBox
this.symbolNameTextBox.Focus();
+ this.IsVisibleChanged += (sender, e) => this.symbolNameTextBox.SelectAll();
}
public string OldSymbolName
diff --git a/src/Main/Base/Project/Src/Gui/Pads/DefinitionViewPad.cs b/src/Main/Base/Project/Src/Gui/Pads/DefinitionViewPad.cs
index dfcdd1b60a..fe5ded64f1 100755
--- a/src/Main/Base/Project/Src/Gui/Pads/DefinitionViewPad.cs
+++ b/src/Main/Base/Project/Src/Gui/Pads/DefinitionViewPad.cs
@@ -6,7 +6,7 @@ using System.IO;
using System.Threading.Tasks;
using System.Windows;
-using ICSharpCode.AvalonEdit;
+using System.Windows.Threading;
using ICSharpCode.AvalonEdit.Document;
using ICSharpCode.AvalonEdit.Highlighting;
using ICSharpCode.Core;
@@ -24,14 +24,13 @@ namespace ICSharpCode.SharpDevelop.Gui
public class DefinitionViewPad : AbstractPadContent
{
AvalonEdit.TextEditor ctl;
+ DispatcherTimer timer;
///
/// The control representing the pad
///
public override object Control {
- get {
- return ctl;
- }
+ get { return ctl; }
}
///
@@ -42,8 +41,11 @@ namespace ICSharpCode.SharpDevelop.Gui
ctl = Editor.AvalonEditTextEditorAdapter.CreateAvalonEditInstance();
ctl.IsReadOnly = true;
ctl.MouseDoubleClick += OnDoubleClick;
- throw new NotImplementedException();
- //ParserService.ParserUpdateStepFinished += OnParserUpdateStep;
+ SD.ParserService.ParseInformationUpdated += OnParserUpdateStep;
+ SD.ParserService.LoadSolutionProjectsThread.Finished += LoadThreadFinished;
+ timer = new DispatcherTimer(DispatcherPriority.Background) { Interval = TimeSpan.FromSeconds(2) };
+ timer.Tick += delegate { UpdateTick(null); };
+ timer.IsEnabled = !SD.ParserService.LoadSolutionProjectsThread.IsRunning;
ctl.IsVisibleChanged += delegate { UpdateTick(null); };
}
@@ -52,47 +54,55 @@ namespace ICSharpCode.SharpDevelop.Gui
///
public override void Dispose()
{
- //ParserService.ParserUpdateStepFinished -= OnParserUpdateStep;
+ SD.ParserService.ParseInformationUpdated -= OnParserUpdateStep;
+ SD.ParserService.LoadSolutionProjectsThread.Finished -= LoadThreadFinished;
ctl.Document = null;
base.Dispose();
}
void OnDoubleClick(object sender, EventArgs e)
{
- string fileName = currentFileName;
+ FileName fileName = currentFileName;
if (fileName != null) {
var caret = ctl.TextArea.Caret;
- FileService.JumpToFilePosition(fileName, caret.Line, caret.Column);
+ SD.FileService.JumpToFilePosition(fileName, caret.Line, caret.Column);
// refresh DefinitionView to show the definition of the expression that was double-clicked
UpdateTick(null);
}
}
- void OnParserUpdateStep(object sender, ParserUpdateStepEventArgs e)
+ void LoadThreadFinished(object sender, EventArgs e)
+ {
+ timer.IsEnabled = true;
+ UpdateTick(null);
+ }
+
+ void OnParserUpdateStep(object sender, ParseInformationEventArgs e)
{
UpdateTick(e);
}
- async void UpdateTick(ParserUpdateStepEventArgs e)
+ async void UpdateTick(ParseInformationEventArgs e)
{
+ timer.IsEnabled = ctl.IsVisible;
if (!ctl.IsVisible) return;
LoggingService.Debug("DefinitionViewPad.Update");
ResolveResult res = await ResolveAtCaretAsync(e);
if (res == null) return;
var pos = res.GetDefinitionRegion();
- if (pos.IsEmpty) return;
+ if (pos.IsEmpty) return; // TODO : try to decompile?
OpenFile(pos);
}
- Task ResolveAtCaretAsync(ParserUpdateStepEventArgs e)
+ Task ResolveAtCaretAsync(ParseInformationEventArgs e)
{
IWorkbenchWindow window = SD.Workbench.ActiveWorkbenchWindow;
- if (window == null)
+ if (window == null)
return Task.FromResult(null);
IViewContent viewContent = window.ActiveViewContent;
- if (viewContent == null)
+ if (viewContent == null)
return Task.FromResult(null);
ITextEditor editor = viewContent.GetService();
if (editor == null)
@@ -107,14 +117,14 @@ namespace ICSharpCode.SharpDevelop.Gui
}
DomRegion oldPosition;
- string currentFileName;
+ FileName currentFileName;
void OpenFile(DomRegion pos)
{
if (pos.Equals(oldPosition)) return;
oldPosition = pos;
if (pos.FileName != currentFileName)
- LoadFile(pos.FileName);
+ LoadFile(new FileName(pos.FileName));
ctl.TextArea.Caret.Location = pos.Begin;
Rect r = ctl.TextArea.Caret.CalculateCaretRectangle();
if (!r.IsEmpty) {
@@ -126,7 +136,7 @@ namespace ICSharpCode.SharpDevelop.Gui
/// Loads the file from the corresponding text editor window if it is
/// open otherwise the file is loaded from the file system.
///
- void LoadFile(string fileName)
+ void LoadFile(FileName fileName)
{
// Load the text into the definition view's text editor.
ctl.Document = new TextDocument(SD.FileService.GetFileContent(fileName));
diff --git a/src/Main/SharpDevelop/Dom/AssemblyModel.cs b/src/Main/SharpDevelop/Dom/AssemblyModel.cs
index 1cecb2ee50..b10684186e 100644
--- a/src/Main/SharpDevelop/Dom/AssemblyModel.cs
+++ b/src/Main/SharpDevelop/Dom/AssemblyModel.cs
@@ -50,6 +50,12 @@ namespace ICSharpCode.SharpDevelop.Dom
}
}
+ public IEntityModelContext Context {
+ get {
+ return context;
+ }
+ }
+
public void Update(IUnresolvedFile oldFile, IUnresolvedFile newFile)
{
IList old = EmptyList.Instance;
diff --git a/src/Main/SharpDevelop/Dom/ClassBrowser/ClassBrowserPad.cs b/src/Main/SharpDevelop/Dom/ClassBrowser/ClassBrowserPad.cs
index 871bc7a139..1c536d2306 100644
--- a/src/Main/SharpDevelop/Dom/ClassBrowser/ClassBrowserPad.cs
+++ b/src/Main/SharpDevelop/Dom/ClassBrowser/ClassBrowserPad.cs
@@ -2,17 +2,78 @@
// This code is distributed under the GNU LGPL (for details please see \doc\license.txt)
using System;
+using System.IO;
using System.Linq;
using System.Collections.Generic;
using System.Diagnostics;
using System.Windows.Controls;
+using ICSharpCode.Core;
using ICSharpCode.Core.Presentation;
+using ICSharpCode.NRefactory;
+using ICSharpCode.NRefactory.TypeSystem;
+using ICSharpCode.SharpDevelop.Dom;
using ICSharpCode.TreeView;
using ICSharpCode.SharpDevelop.Project;
using ICSharpCode.SharpDevelop.Workbench;
namespace ICSharpCode.SharpDevelop.Dom.ClassBrowser
{
+ public class PersistedWorkspace
+ {
+ public PersistedWorkspace()
+ {
+ AssemblyFiles = new List();
+ }
+
+ public string Name { get; set; }
+ public List AssemblyFiles { get; set; }
+ public bool IsActive { get; set; }
+ }
+
+ class UnresolvedAssemblyEntityModelContext : IEntityModelContext
+ {
+ string assemblyName;
+ string location;
+
+ public UnresolvedAssemblyEntityModelContext(string assemblyName, string location)
+ {
+ this.assemblyName = assemblyName;
+ this.location = location;
+ }
+
+ public ICompilation GetCompilation()
+ {
+ return null;
+ }
+
+ public bool IsBetterPart(IUnresolvedTypeDefinition part1, IUnresolvedTypeDefinition part2)
+ {
+ return false;
+ }
+
+ public IProject Project {
+ get {
+ return null;
+ }
+ }
+
+ public string AssemblyName {
+ get {
+ return assemblyName;
+ }
+ }
+
+ public string Location {
+ get {
+ return location;
+ }
+ }
+
+ public bool IsValid {
+ get { return false; }
+ }
+ }
+
class ClassBrowserPad : AbstractPadContent, IClassBrowser
{
#region IClassBrowser implementation
@@ -25,13 +86,19 @@ namespace ICSharpCode.SharpDevelop.Dom.ClassBrowser
get { return treeView.AssemblyList; }
set { treeView.AssemblyList = value; }
}
-
+
#endregion
+
+ const string PersistedWorkspaceSetting = "ClassBrowser.Workspaces";
+ const string DefaultWorkspaceName = "";
IProjectService projectService;
ClassBrowserTreeView treeView;
DockPanel panel;
ToolBar toolBar;
+
+ List persistedWorkspaces;
+ PersistedWorkspace activeWorkspace;
public ClassBrowserPad()
: this(SD.GetRequiredService())
@@ -53,6 +120,9 @@ namespace ICSharpCode.SharpDevelop.Dom.ClassBrowser
//treeView.ContextMenu = CreateContextMenu("/SharpDevelop/Pads/UnitTestsPad/ContextMenu");
projectService.CurrentSolutionChanged += ProjectServiceCurrentSolutionChanged;
ProjectServiceCurrentSolutionChanged(null, null);
+
+ // Load workspaces from configuration
+ LoadWorkspaces();
}
public override void Dispose()
@@ -77,6 +147,26 @@ namespace ICSharpCode.SharpDevelop.Dom.ClassBrowser
treeView.SpecialNodes.Add(new SolutionTreeNode(projectService.CurrentSolution));
}
+ void AssemblyListCollectionChanged(IReadOnlyCollection removedItems, IReadOnlyCollection addedItems)
+ {
+ foreach (var assembly in addedItems) {
+ // Add this assembly to current workspace
+ if (activeWorkspace != null) {
+ activeWorkspace.AssemblyFiles.Add(assembly.Context.Location);
+ }
+ }
+
+ foreach (var assembly in removedItems) {
+ // Add this assembly to current workspace
+ if (activeWorkspace != null) {
+ activeWorkspace.AssemblyFiles.Remove(assembly.Context.Location);
+ }
+ }
+
+ // Update workspace list in configuration
+ SaveWorkspaces();
+ }
+
///
/// Virtual method so we can override this method and return
/// a dummy ToolBar when testing.
@@ -96,5 +186,142 @@ namespace ICSharpCode.SharpDevelop.Dom.ClassBrowser
Debug.Assert(treeView != null);
return MenuService.CreateContextMenu(treeView, name);
}
+
+ ///
+ /// Loads persisted workspaces from configuration.
+ ///
+ void LoadWorkspaces()
+ {
+ persistedWorkspaces = SD.PropertyService.GetList(PersistedWorkspaceSetting).ToList();
+ if (!persistedWorkspaces.Any())
+ {
+ // Add at least default workspace
+ persistedWorkspaces = new List();
+ persistedWorkspaces.Add(new PersistedWorkspace()
+ {
+ Name = DefaultWorkspaceName
+ });
+ }
+
+ // Load all assemblies (for now always from default workspace)
+ PersistedWorkspace defaultWorkspace = persistedWorkspaces.FirstOrDefault(w => w.Name == DefaultWorkspaceName);
+ ActivateWorkspace(defaultWorkspace);
+ }
+
+ ///
+ /// Stores currently saved workspaces in configuration.
+ ///
+ void SaveWorkspaces()
+ {
+ SD.PropertyService.SetList(PersistedWorkspaceSetting, persistedWorkspaces);
+ }
+
+ public static IAssemblyModel CreateAssemblyModelFromFile(string fileName)
+ {
+ try {
+ var loader = new CecilLoader();
+ loader.IncludeInternalMembers = true;
+ loader.LazyLoad = true;
+ var assembly = loader.LoadAssemblyFile(fileName);
+
+ IEntityModelContext context = new AssemblyEntityModelContext(assembly);
+ IAssemblyModel model = SD.GetRequiredService().CreateAssemblyModel(context);
+ if (model is IUpdateableAssemblyModel) {
+ ((IUpdateableAssemblyModel)model).Update(EmptyList.Instance, assembly.TopLevelTypeDefinitions.ToList());
+ ((IUpdateableAssemblyModel) model).AssemblyName = assembly.AssemblyName;
+ }
+ return model;
+ } catch (BadImageFormatException) {
+ SD.MessageService.ShowWarningFormatted("{0} is not a valid .NET assembly.", Path.GetFileName(fileName));
+ } catch (FileNotFoundException) {
+ SD.MessageService.ShowWarningFormatted("{0} is not accessible or doesn't exist anymore.", fileName);
+ }
+
+ return null;
+ }
+
+ static IAssemblyModel CreateAssemblyModelOrThrowException(string fileName)
+ {
+ var loader = new CecilLoader();
+ loader.IncludeInternalMembers = true;
+ loader.LazyLoad = true;
+ var assembly = loader.LoadAssemblyFile(fileName);
+
+ IEntityModelContext context = new AssemblyEntityModelContext(assembly);
+ IAssemblyModel model = SD.GetRequiredService().CreateAssemblyModel(context);
+ if (model is IUpdateableAssemblyModel) {
+ ((IUpdateableAssemblyModel)model).Update(EmptyList.Instance, assembly.TopLevelTypeDefinitions.ToList());
+ ((IUpdateableAssemblyModel) model).AssemblyName = assembly.AssemblyName;
+ }
+ return model;
+ }
+
+ static IAssemblyModel SafelyCreateAssemblyModelFromFile(string fileName)
+ {
+ try {
+ return CreateAssemblyModelOrThrowException(fileName);
+ } catch (Exception) {
+ // Special AssemblyModel for unresolved file references
+ IEntityModelContext unresolvedContext = new UnresolvedAssemblyEntityModelContext(Path.GetFileName(fileName), fileName);
+ IAssemblyModel unresolvedModel = SD.GetRequiredService().CreateAssemblyModel(unresolvedContext);
+ if (unresolvedModel is IUpdateableAssemblyModel) {
+ ((IUpdateableAssemblyModel) unresolvedModel).AssemblyName = unresolvedContext.AssemblyName;
+ }
+
+ return unresolvedModel;
+ }
+ }
+
+ void AppendAssemblyFileToList(string assemblyFile)
+ {
+ IAssemblyModel assemblyModel = SafelyCreateAssemblyModelFromFile(assemblyFile);
+ if (assemblyModel != null) {
+ AssemblyList.Assemblies.Add(assemblyModel);
+ }
+ }
+
+ ///
+ /// Activates the specified workspace.
+ ///
+ void ActivateWorkspace(PersistedWorkspace workspace)
+ {
+ // Update the activation flags in workspace list
+ foreach (var workspaceElement in persistedWorkspaces) {
+ workspaceElement.IsActive = (workspaceElement == workspace);
+ }
+
+ UpdateActiveWorkspace();
+ }
+
+ ///
+ /// Updates active workspace and AssemblyList according to flags.
+ ///
+ void UpdateActiveWorkspace()
+ {
+ if ((AssemblyList != null) && (activeWorkspace != null)) {
+ // Temporarily detach from event handler
+ AssemblyList.Assemblies.CollectionChanged -= AssemblyListCollectionChanged;
+ }
+
+ activeWorkspace = persistedWorkspaces.FirstOrDefault(w => w.IsActive);
+ if (activeWorkspace == null) {
+ // If no workspace is active, activate default
+ var defaultWorkspace = persistedWorkspaces.FirstOrDefault(w => w.Name == DefaultWorkspaceName);
+ activeWorkspace = defaultWorkspace;
+ defaultWorkspace.IsActive = true;
+ }
+
+ AssemblyList.Assemblies.Clear();
+ if (activeWorkspace != null) {
+ foreach (string assemblyFile in activeWorkspace.AssemblyFiles) {
+ AppendAssemblyFileToList(assemblyFile);
+ }
+ }
+
+ // Attach to event handler, again.
+ if (AssemblyList != null) {
+ AssemblyList.Assemblies.CollectionChanged += AssemblyListCollectionChanged;
+ }
+ }
}
}
diff --git a/src/Main/SharpDevelop/Dom/ClassBrowser/ClassBrowserTreeNodesFactory.cs b/src/Main/SharpDevelop/Dom/ClassBrowser/ClassBrowserTreeNodesFactory.cs
index c85f22786a..23fe3fcb2f 100644
--- a/src/Main/SharpDevelop/Dom/ClassBrowser/ClassBrowserTreeNodesFactory.cs
+++ b/src/Main/SharpDevelop/Dom/ClassBrowser/ClassBrowserTreeNodesFactory.cs
@@ -21,6 +21,8 @@ namespace ICSharpCode.SharpDevelop.Dom.ClassBrowser
return typeof(ITypeDefinitionModel);
if (model is IMemberModel)
return typeof(IMemberModel);
+ if (model is IAssemblyModel)
+ return typeof(IAssemblyModel);
return null;
}
@@ -36,6 +38,8 @@ namespace ICSharpCode.SharpDevelop.Dom.ClassBrowser
return new TypeDefinitionTreeNode((ITypeDefinitionModel)model);
if (model is IMemberModel)
return new MemberTreeNode((IMemberModel)model);
+ if (model is IAssemblyModel)
+ return new AssemblyTreeNode((IAssemblyModel) model);
return null;
}
}
diff --git a/src/Main/SharpDevelop/Dom/ClassBrowser/Commands.cs b/src/Main/SharpDevelop/Dom/ClassBrowser/Commands.cs
new file mode 100644
index 0000000000..000d46a701
--- /dev/null
+++ b/src/Main/SharpDevelop/Dom/ClassBrowser/Commands.cs
@@ -0,0 +1,75 @@
+// Copyright (c) AlphaSierraPapa for the SharpDevelop Team (for details please see \doc\copyright.txt)
+// This code is distributed under the GNU LGPL (for details please see \doc\license.txt)
+
+using System;
+using System.IO;
+using System.Linq;
+using Microsoft.Win32;
+
+namespace ICSharpCode.SharpDevelop.Dom.ClassBrowser
+{
+ ///
+ /// OpenAssemblyFromFileCommand.
+ ///
+ class OpenAssemblyFromFileCommand : SimpleCommand
+ {
+ public override void Execute(object parameter)
+ {
+ var classBrowser = SD.GetService();
+ if (classBrowser != null) {
+ OpenFileDialog openFileDialog = new OpenFileDialog();
+ openFileDialog.Filter = "Assembly files (*.exe, *.dll)|*.exe;*.dll";
+ openFileDialog.CheckFileExists = true;
+ openFileDialog.CheckPathExists = true;
+ if (openFileDialog.ShowDialog() ?? false)
+ {
+ IAssemblyModel assemblyModel = ClassBrowserPad.CreateAssemblyModelFromFile(openFileDialog.FileName);
+ if (assemblyModel != null)
+ classBrowser.AssemblyList.Assemblies.Add(assemblyModel);
+ }
+ }
+ }
+ }
+
+ ///
+ /// OpenAssemblyFromGACCommand.
+ ///
+ class OpenAssemblyFromGACCommand : SimpleCommand
+ {
+ public override void Execute(object parameter)
+ {
+ var classBrowser = SD.GetService();
+ if (classBrowser != null) {
+ OpenFromGacDialog gacDialog = new OpenFromGacDialog();
+ if (gacDialog.ShowDialog() ?? false)
+ {
+ foreach (string assemblyFile in gacDialog.SelectedFileNames) {
+ IAssemblyModel assemblyModel = ClassBrowserPad.CreateAssemblyModelFromFile(assemblyFile);
+ if (assemblyModel != null)
+ classBrowser.AssemblyList.Assemblies.Add(assemblyModel);
+ }
+ }
+ }
+ }
+ }
+
+ ///
+ /// RemoveAssemblyCommand.
+ ///
+ class RemoveAssemblyCommand : SimpleCommand
+ {
+ public override bool CanExecute(object parameter)
+ {
+ return parameter is AssemblyModel;
+ }
+
+ public override void Execute(object parameter)
+ {
+ var classBrowser = SD.GetService();
+ if (classBrowser != null) {
+ IAssemblyModel assemblyModel = (IAssemblyModel) parameter;
+ classBrowser.AssemblyList.Assemblies.Remove(assemblyModel);
+ }
+ }
+ }
+}
diff --git a/src/Main/SharpDevelop/Dom/ClassBrowser/OpenAssemblyCommand.cs b/src/Main/SharpDevelop/Dom/ClassBrowser/OpenAssemblyCommand.cs
deleted file mode 100644
index 59851280c6..0000000000
--- a/src/Main/SharpDevelop/Dom/ClassBrowser/OpenAssemblyCommand.cs
+++ /dev/null
@@ -1,29 +0,0 @@
-// Copyright (c) AlphaSierraPapa for the SharpDevelop Team (for details please see \doc\copyright.txt)
-// This code is distributed under the GNU LGPL (for details please see \doc\license.txt)
-
-using System;
-
-namespace ICSharpCode.SharpDevelop.Dom.ClassBrowser
-{
- ///
- /// Description of OpenAssemblyFromFileCommand.
- ///
- class OpenAssemblyFromFileCommand : SimpleCommand
- {
- public override void Execute(object parameter)
- {
- throw new NotImplementedException();
- }
- }
-
- ///
- /// Description of OpenAssemblyFromGACCommand.
- ///
- class OpenAssemblyFromGACCommand : SimpleCommand
- {
- public override void Execute(object parameter)
- {
- throw new NotImplementedException();
- }
- }
-}
diff --git a/src/Main/SharpDevelop/Dom/ClassBrowser/OpenFromGacDialog.xaml b/src/Main/SharpDevelop/Dom/ClassBrowser/OpenFromGacDialog.xaml
new file mode 100644
index 0000000000..44117a28f2
--- /dev/null
+++ b/src/Main/SharpDevelop/Dom/ClassBrowser/OpenFromGacDialog.xaml
@@ -0,0 +1,46 @@
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
\ No newline at end of file
diff --git a/src/Main/SharpDevelop/Dom/ClassBrowser/OpenFromGacDialog.xaml.cs b/src/Main/SharpDevelop/Dom/ClassBrowser/OpenFromGacDialog.xaml.cs
new file mode 100644
index 0000000000..a13572bcf2
--- /dev/null
+++ b/src/Main/SharpDevelop/Dom/ClassBrowser/OpenFromGacDialog.xaml.cs
@@ -0,0 +1,188 @@
+// Copyright (c) 2011 AlphaSierraPapa for the SharpDevelop Team
+//
+// Permission is hereby granted, free of charge, to any person obtaining a copy of this
+// software and associated documentation files (the "Software"), to deal in the Software
+// without restriction, including without limitation the rights to use, copy, modify, merge,
+// publish, distribute, sublicense, and/or sell copies of the Software, and to permit persons
+// to whom the Software is furnished to do so, subject to the following conditions:
+//
+// The above copyright notice and this permission notice shall be included in all copies or
+// substantial portions of the Software.
+//
+// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED,
+// INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR
+// PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE
+// FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR
+// OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER
+// DEALINGS IN THE SOFTWARE.
+
+using System;
+using System.Collections.Generic;
+using System.Collections.ObjectModel;
+using System.ComponentModel;
+using System.Linq;
+using System.Text;
+using System.Threading;
+using System.Windows;
+using System.Windows.Controls;
+using System.Windows.Threading;
+using ICSharpCode.Core.Presentation;
+using ICSharpCode.SharpDevelop.Gui;
+using ICSharpCode.SharpDevelop.Parser;
+
+namespace ICSharpCode.SharpDevelop.Dom.ClassBrowser
+{
+ ///
+ /// Interaction logic for OpenFromGacDialog.xaml
+ ///
+ public partial class OpenFromGacDialog : Window
+ {
+ ObservableCollection gacEntries = new ObservableCollection();
+ ObservableCollection filteredEntries = new ObservableCollection();
+ Predicate filterMethod = _ => true;
+ volatile bool cancelFetchThread;
+
+ public OpenFromGacDialog()
+ {
+ InitializeComponent();
+ FormLocationHelper.ApplyWindow(this, "ICSharpCode.SharpDevelop.Dom.OpenFromGacDialog.Bounds", true);
+ listView.ItemsSource = filteredEntries;
+ SortableGridViewColumn.SetCurrentSortColumn(listView, nameColumn);
+ SortableGridViewColumn.SetSortDirection(listView, ColumnSortDirection.Ascending);
+
+ new Thread(new ThreadStart(FetchGacContents)).Start();
+ }
+
+ protected override void OnClosing(CancelEventArgs e)
+ {
+ base.OnClosing(e);
+ cancelFetchThread = true;
+ }
+
+ #region Fetch Gac Contents
+ sealed class GacEntry
+ {
+ readonly DomAssemblyName r;
+ readonly string fileName;
+ string formattedVersion;
+
+ public GacEntry(DomAssemblyName r, string fileName)
+ {
+ this.r = r;
+ this.fileName = fileName;
+ }
+
+ public string FullName {
+ get { return r.FullName; }
+ }
+
+ public string ShortName {
+ get { return r.ShortName; }
+ }
+
+ public string FileName {
+ get { return fileName; }
+ }
+
+ public Version Version {
+ get { return r.Version; }
+ }
+
+ public string FormattedVersion {
+ get {
+ if (formattedVersion == null)
+ formattedVersion = Version.ToString();
+ return formattedVersion;
+ }
+ }
+
+ public string Culture {
+ get { return r.Culture; }
+ }
+
+ public string PublicKeyToken {
+ get {
+ StringBuilder s = new StringBuilder();
+ foreach (byte b in r.PublicKeyToken)
+ s.Append(b.ToString("x2"));
+ return s.ToString();
+ }
+ }
+
+ public override string ToString()
+ {
+ return r.FullName;
+ }
+ }
+
+ void FetchGacContents()
+ {
+ IGlobalAssemblyCacheService gacService = SD.GetService();
+ HashSet fullNames = new HashSet();
+ UpdateProgressBar(pg => { pg.Visibility = System.Windows.Visibility.Visible; pg.IsIndeterminate = true; });
+ var list = gacService.Assemblies.TakeWhile(_ => !cancelFetchThread).ToList();
+ UpdateProgressBar(pg => { pg.IsIndeterminate = false; pg.Maximum = list.Count; });
+ foreach (var r in list) {
+ if (cancelFetchThread)
+ break;
+ if (fullNames.Add(r.FullName)) { // filter duplicates
+ var file = gacService.FindAssemblyInNetGac(r);
+ if (file != null) {
+ var entry = new GacEntry(r, file);
+ UpdateProgressBar(pg => { pg.Value = pg.Value + 1; AddNewEntry(entry); });
+ }
+ }
+ }
+ UpdateProgressBar(pg => { pg.Visibility = System.Windows.Visibility.Hidden; });
+ }
+
+ void UpdateProgressBar(Action updateAction)
+ {
+ Dispatcher.BeginInvoke(DispatcherPriority.Normal, (Action)(() => updateAction(gacReadingProgressBar)));
+ }
+
+ void AddNewEntry(GacEntry entry)
+ {
+ gacEntries.Add(entry);
+ if (filterMethod(entry))
+ filteredEntries.Add(entry);
+ }
+ #endregion
+
+ void FilterTextBox_TextChanged(object sender, TextChangedEventArgs e)
+ {
+ string filterString = filterTextBox.Text.Trim();
+ if (filterString.Length == 0)
+ filterMethod = _ => true;
+ else {
+ var elements = filterString.Split(new char[] { ' ' }, StringSplitOptions.RemoveEmptyEntries);
+ filterMethod = entry => elements.All(el => Contains(entry.FullName, el) || Contains(entry.FormattedVersion, el));
+ }
+
+ filteredEntries.Clear();
+ filteredEntries.AddRange(gacEntries.Where(entry => filterMethod(entry)));
+ }
+
+ static bool Contains(string s, string subString)
+ {
+ return s.IndexOf(subString, StringComparison.OrdinalIgnoreCase) >= 0;
+ }
+
+ void ListView_SelectionChanged(object sender, SelectionChangedEventArgs e)
+ {
+ okButton.IsEnabled = listView.SelectedItems.Count > 0;
+ }
+
+ void OKButton_Click(object sender, RoutedEventArgs e)
+ {
+ this.DialogResult = true;
+ Close();
+ }
+
+ public string[] SelectedFileNames {
+ get {
+ return listView.SelectedItems.OfType().Select(e => e.FileName).ToArray();
+ }
+ }
+ }
+}
\ No newline at end of file
diff --git a/src/Main/SharpDevelop/Resources/BitmapResources.resources b/src/Main/SharpDevelop/Resources/BitmapResources.resources
index 83d8924bc4..a449ace4db 100644
Binary files a/src/Main/SharpDevelop/Resources/BitmapResources.resources and b/src/Main/SharpDevelop/Resources/BitmapResources.resources differ
diff --git a/src/Main/SharpDevelop/SharpDevelop.csproj b/src/Main/SharpDevelop/SharpDevelop.csproj
index d62dcd7030..8eed81e197 100644
--- a/src/Main/SharpDevelop/SharpDevelop.csproj
+++ b/src/Main/SharpDevelop/SharpDevelop.csproj
@@ -108,7 +108,11 @@
-
+
+
+ OpenFromGacDialog.xaml
+ Code
+
@@ -331,6 +335,7 @@
+