Browse Source

Fixed build.

git-svn-id: svn://svn.sharpdevelop.net/sharpdevelop/trunk@4000 1ccf3a8d-04fe-1044-b7c0-cef0b8235c61
shortcuts
Daniel Grunwald 16 years ago
parent
commit
1c7b08ea20
  1. 11
      src/AddIns/BackendBindings/Python/PythonBinding/Test/Utils/MockMethod.cs
  2. 22
      src/AddIns/DisplayBindings/AvalonEdit.AddIn/Src/CodeEditor.cs
  3. 45
      src/AddIns/DisplayBindings/AvalonEdit.AddIn/Src/QuickClassBrowser.cs
  4. 11
      src/AddIns/Misc/UnitTesting/Test/Utils/MockMember.cs
  5. 11
      src/AddIns/Misc/UnitTesting/Test/Utils/MockMethod.cs
  6. 6
      src/Main/Base/Test/Utils/MockEntity.cs
  7. 12
      src/Main/Base/Test/Utils/MockMethod.cs
  8. 11
      src/Main/Base/Test/Utils/MockProperty.cs

11
src/AddIns/BackendBindings/Python/PythonBinding/Test/Utils/MockMethod.cs

@ -272,5 +272,16 @@ namespace PythonBinding.Tests.Utils
throw new NotImplementedException(); throw new NotImplementedException();
} }
public ICompilationUnit CompilationUnit {
get {
throw new NotImplementedException();
}
}
public IProjectContent ProjectContent {
get {
throw new NotImplementedException();
}
}
} }
} }

22
src/AddIns/DisplayBindings/AvalonEdit.AddIn/Src/CodeEditor.cs

@ -21,6 +21,7 @@ using ICSharpCode.SharpDevelop;
using ICSharpCode.SharpDevelop.Bookmarks; using ICSharpCode.SharpDevelop.Bookmarks;
using ICSharpCode.SharpDevelop.Dom; using ICSharpCode.SharpDevelop.Dom;
using ICSharpCode.SharpDevelop.Editor; using ICSharpCode.SharpDevelop.Editor;
using System.Windows.Threading;
namespace ICSharpCode.AvalonEdit.AddIn namespace ICSharpCode.AvalonEdit.AddIn
{ {
@ -101,7 +102,26 @@ namespace ICSharpCode.AvalonEdit.AddIn
void caret_PositionChanged(object sender, EventArgs e) void caret_PositionChanged(object sender, EventArgs e)
{ {
InvalidateQuickClassBrowserCaretPosition();
}
bool quickClassBrowserCaretPositionIsValid;
/// <summary>
/// Only call 'SelectItemAtCaretPosition' once when the caret position
/// changes multiple times (e.g. running refactoring which causes lots of caret changes).
/// </summary>
void InvalidateQuickClassBrowserCaretPosition()
{
if (quickClassBrowserCaretPositionIsValid) {
quickClassBrowserCaretPositionIsValid = false;
Dispatcher.BeginInvoke(
DispatcherPriority.Normal,
new Action(
delegate {
quickClassBrowser.SelectItemAtCaretPosition(textEditorAdapter.Caret.Position); quickClassBrowser.SelectItemAtCaretPosition(textEditorAdapter.Caret.Position);
}));
}
} }
void quickClassBrowser_Jump(DomRegion region) void quickClassBrowser_Jump(DomRegion region)
@ -249,7 +269,7 @@ namespace ICSharpCode.AvalonEdit.AddIn
quickClassBrowser.Update(parseInfo.MostRecentCompilationUnit); quickClassBrowser.Update(parseInfo.MostRecentCompilationUnit);
else else
quickClassBrowser.Update(null); quickClassBrowser.Update(null);
quickClassBrowser.SelectItemAtCaretPosition(textEditorAdapter.Caret.Position); InvalidateQuickClassBrowserCaretPosition();
} }
} }
} }

45
src/AddIns/DisplayBindings/AvalonEdit.AddIn/Src/QuickClassBrowser.cs

@ -28,12 +28,15 @@ namespace ICSharpCode.AvalonEdit.AddIn
const int TYPE_FIELD = 4; const int TYPE_FIELD = 4;
const int TYPE_EVENT = 5; const int TYPE_EVENT = 5;
/// <summary>
/// ViewModel used for combobox items.
/// </summary>
class EntityItem : IComparable<EntityItem> class EntityItem : IComparable<EntityItem>
{ {
IEntity entity; IEntity entity;
IImage image; IImage image;
string text; string text;
int typeCode; // type code is used for sorting by type int typeCode; // type code is used for sorting entities by type
public IEntity Entity { public IEntity Entity {
get { return entity; } get { return entity; }
@ -53,16 +56,29 @@ namespace ICSharpCode.AvalonEdit.AddIn
image = ClassBrowserIconService.GetIcon(entity); image = ClassBrowserIconService.GetIcon(entity);
} }
/// <summary>
/// Text to display in combo box.
/// </summary>
public string Text { public string Text {
get { return text; } get { return text; }
} }
/// <summary>
/// Image to use in combox box
/// </summary>
public ImageSource Image { public ImageSource Image {
get { get {
return image.ImageSource; return image.ImageSource;
} }
} }
/// <summary>
/// Gets/Sets whether the item is in the current file.
/// </summary>
/// <returns>
/// <c>true</c>: item is in current file;
/// <c>false</c>: item is in another part of the partial class
/// </returns>
public bool IsInSamePart { get; set; } public bool IsInSamePart { get; set; }
public int CompareTo(EntityItem other) public int CompareTo(EntityItem other)
@ -80,12 +96,18 @@ namespace ICSharpCode.AvalonEdit.AddIn
public QuickClassBrowser() public QuickClassBrowser()
{ {
InitializeComponent(); InitializeComponent();
Update(null);
} }
List<EntityItem> classItems; // The lists of items currently visible in the combo boxes.
List<EntityItem> memberItems; // These should never be null.
List<EntityItem> classItems = new List<EntityItem>();
List<EntityItem> memberItems = new List<EntityItem>();
/// <summary>
/// Updates the list of available classes.
/// This causes the classes combo box to loose its current selected,
/// so the members combo box will be cleared.
/// </summary>
public void Update(ICompilationUnit compilationUnit) public void Update(ICompilationUnit compilationUnit)
{ {
classItems = new List<EntityItem>(); classItems = new List<EntityItem>();
@ -104,6 +126,9 @@ namespace ICSharpCode.AvalonEdit.AddIn
} }
} }
/// <summary>
/// Selects the class and member closest to the specified location.
/// </summary>
public void SelectItemAtCaretPosition(Location location) public void SelectItemAtCaretPosition(Location location)
{ {
EntityItem matchInside = null; EntityItem matchInside = null;
@ -116,6 +141,9 @@ namespace ICSharpCode.AvalonEdit.AddIn
matchInside = item; matchInside = item;
// when there are multiple matches inside (nested classes), use the last one // when there are multiple matches inside (nested classes), use the last one
} else { } else {
// Not a perfect match?
// Try to first the nearest match. We want the classes combo box to always
// have a class selected if possible.
int matchDistance = Math.Min(Math.Abs(location.Line - c.Region.BeginLine), int matchDistance = Math.Min(Math.Abs(location.Line - c.Region.BeginLine),
Math.Abs(location.Line - c.Region.EndLine)); Math.Abs(location.Line - c.Region.EndLine));
if (matchDistance < nearestMatchDistance) { if (matchDistance < nearestMatchDistance) {
@ -153,6 +181,8 @@ namespace ICSharpCode.AvalonEdit.AddIn
void classComboBoxSelectionChanged(object sender, SelectionChangedEventArgs e) void classComboBoxSelectionChanged(object sender, SelectionChangedEventArgs e)
{ {
// The selected class was changed.
// Update the list of member items to be the list of members of the current class.
EntityItem item = classComboBox.SelectedItem as EntityItem; EntityItem item = classComboBox.SelectedItem as EntityItem;
IClass selectedClass = item != null ? item.Entity as IClass : null; IClass selectedClass = item != null ? item.Entity as IClass : null;
memberItems = new List<EntityItem>(); memberItems = new List<EntityItem>();
@ -199,16 +229,17 @@ namespace ICSharpCode.AvalonEdit.AddIn
{ {
if (region.IsEmpty) if (region.IsEmpty)
return; return;
if (item.IsInSamePart) {
Action<DomRegion> jumpAction = this.JumpAction; Action<DomRegion> jumpAction = this.JumpAction;
if (jumpAction != null) { if (item.IsInSamePart && jumpAction != null) {
jumpAction(region); jumpAction(region);
}
} else { } else {
FileService.JumpToFilePosition(item.Entity.CompilationUnit.FileName, region.BeginLine, region.BeginColumn); FileService.JumpToFilePosition(item.Entity.CompilationUnit.FileName, region.BeginLine, region.BeginColumn);
} }
} }
/// <summary>
/// Action used for jumping to a position inside the current file.
/// </summary>
public Action<DomRegion> JumpAction { get; set; } public Action<DomRegion> JumpAction { get; set; }
} }
} }

11
src/AddIns/Misc/UnitTesting/Test/Utils/MockMember.cs

@ -255,5 +255,16 @@ namespace UnitTesting.Tests.Utils
throw new NotImplementedException(); throw new NotImplementedException();
} }
public ICompilationUnit CompilationUnit {
get {
throw new NotImplementedException();
}
}
public IProjectContent ProjectContent {
get {
throw new NotImplementedException();
}
}
} }
} }

11
src/AddIns/Misc/UnitTesting/Test/Utils/MockMethod.cs

@ -302,5 +302,16 @@ namespace UnitTesting.Tests.Utils
throw new NotImplementedException(); throw new NotImplementedException();
} }
public ICompilationUnit CompilationUnit {
get {
return declaringType.CompilationUnit;
}
}
public IProjectContent ProjectContent {
get {
return declaringType.ProjectContent;
}
}
} }
} }

6
src/Main/Base/Test/Utils/MockEntity.cs

@ -21,5 +21,11 @@ namespace ICSharpCode.SharpDevelop.Tests.Utils
return String.Empty; return String.Empty;
} }
} }
public override ICompilationUnit CompilationUnit {
get {
throw new NotImplementedException();
}
}
} }
} }

12
src/Main/Base/Test/Utils/MockMethod.cs

@ -256,5 +256,17 @@ namespace ICSharpCode.SharpDevelop.Tests.Utils
{ {
throw new NotImplementedException(); throw new NotImplementedException();
} }
public ICompilationUnit CompilationUnit {
get {
throw new NotImplementedException();
}
}
public IProjectContent ProjectContent {
get {
throw new NotImplementedException();
}
}
} }
} }

11
src/Main/Base/Test/Utils/MockProperty.cs

@ -281,5 +281,16 @@ namespace ICSharpCode.SharpDevelop.Tests.Utils
throw new NotImplementedException(); throw new NotImplementedException();
} }
public ICompilationUnit CompilationUnit {
get {
throw new NotImplementedException();
}
}
public IProjectContent ProjectContent {
get {
throw new NotImplementedException();
}
}
} }
} }

Loading…
Cancel
Save