Browse Source

Fixed some bugs.

Add new GotoDialog (replaces GotoLineNumberDialog).
The GotoDialog accepts line numbers, class names and file names. (Examples: "120", "MainClass", "Main.cs, 120")

git-svn-id: svn://svn.sharpdevelop.net/sharpdevelop/trunk@357 1ccf3a8d-04fe-1044-b7c0-cef0b8235c61
shortcuts
Daniel Grunwald 20 years ago
parent
commit
8e7a4a989a
  1. 25
      src/AddIns/Misc/SubversionAddIn/Project/Src/Gui/HistoryViewDisplayBinding/HistoryViewPanel.cs
  2. 4
      src/Main/Base/Project/ICSharpCode.SharpDevelop.csproj
  3. 71
      src/Main/Base/Project/Resources/GotoDialog.xfrm
  4. 51
      src/Main/Base/Project/Resources/GotoLineNumberDialog.xfrm
  5. 2
      src/Main/Base/Project/Src/Commands/AutostartCommands.cs
  6. 18
      src/Main/Base/Project/Src/Dom/Implementations/DefaultReturnType.cs
  7. 2
      src/Main/Base/Project/Src/Gui/Workbench/DefaultWorkbench.cs
  8. 179
      src/Main/Base/Project/Src/Services/ClassBrowserIcons/ClassBrowserIconService.cs
  9. 9
      src/Main/Base/Project/Src/TextEditor/Commands/CodeGenerators/OverrideMethodsCodeGenerator.cs
  10. 7
      src/Main/Base/Project/Src/TextEditor/Commands/SearchCommands.cs
  11. 373
      src/Main/Base/Project/Src/TextEditor/Gui/Dialogs/GotoDialog.cs
  12. 70
      src/Main/Base/Project/Src/TextEditor/Gui/Dialogs/GotoLineNumberDialog.cs
  13. 19
      src/Main/Base/Project/Src/TextEditor/Gui/Editor/CompletionWindow/CodeCompletionData.cs
  14. 7
      src/Main/Base/Project/Src/TextEditor/Gui/Editor/InsightWindow/MethodInsightDataProvider.cs
  15. BIN
      src/Main/StartUp/Project/Resources/StringResources.resources

25
src/AddIns/Misc/SubversionAddIn/Project/Src/Gui/HistoryViewDisplayBinding/HistoryViewPanel.cs

@ -74,16 +74,21 @@ namespace ICSharpCode.Svn @@ -74,16 +74,21 @@ namespace ICSharpCode.Svn
void GetLogMessages()
{
string fileName = Path.GetFullPath(viewContent.FileName);
LoggingService.Info("SVN: Get log of " + fileName);
if (File.Exists(fileName)) {
Client client = SvnClient.Instance.Client;
client.Log(new string[] { fileName},
Revision.Head, // Revision start
Revision.FromNumber(1), // Revision end
false, // bool discoverChangePath
false, // bool strictNodeHistory
new LogMessageReceiver(ReceiveLogMessage));
try {
string fileName = Path.GetFullPath(viewContent.FileName);
LoggingService.Info("SVN: Get log of " + fileName);
if (File.Exists(fileName)) {
Client client = SvnClient.Instance.Client;
client.Log(new string[] { fileName},
Revision.Head, // Revision start
Revision.FromNumber(1), // Revision end
false, // bool discoverChangePath
false, // bool strictNodeHistory
new LogMessageReceiver(ReceiveLogMessage));
}
} catch (Exception ex) {
// if exceptions aren't caught here, they force SD to exit
MessageService.ShowError(ex);
}
}

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

@ -492,7 +492,7 @@ @@ -492,7 +492,7 @@
<EmbeddedResource Include="Resources\ICSharpCode.SharpDevelop.snk" />
<EmbeddedResource Include="Resources\BehaviorTextEditorPanel.xfrm" />
<EmbeddedResource Include="Resources\FindPanel.xfrm" />
<EmbeddedResource Include="Resources\GotoLineNumberDialog.xfrm" />
<EmbeddedResource Include="Resources\GotoDialog.xfrm" />
<EmbeddedResource Include="Resources\ReplacePanel.xfrm" />
<EmbeddedResource Include="Resources\GeneralTextEditorPanel.xfrm" />
<EmbeddedResource Include="Resources\CodeTemplatePanel.xfrm" />
@ -534,7 +534,7 @@ @@ -534,7 +534,7 @@
<Compile Include="Src\TextEditor\Commands\ToolCommands.cs" />
<Compile Include="Src\TextEditor\Conditions\TextContentCondition.cs" />
<Compile Include="Src\TextEditor\Gui\Dialogs\ExportProjectToHtmlDialog.cs" />
<Compile Include="Src\TextEditor\Gui\Dialogs\GotoLineNumberDialog.cs">
<Compile Include="Src\TextEditor\Gui\Dialogs\GotoDialog.cs">
<SubType>Form</SubType>
</Compile>
<Compile Include="Src\TextEditor\Gui\Dialogs\SortOptionsDialog.cs">

71
src/Main/Base/Project/Resources/GotoDialog.xfrm

@ -0,0 +1,71 @@ @@ -0,0 +1,71 @@
<Components version="1.0">
<System.Windows.Forms.Form>
<Name value="MyForm" />
<ShowInTaskbar value="False" />
<AcceptButton value="okButton [System.Windows.Forms.Button], Text: ${res:Global.OKButtonText}" />
<MinimizeBox value="False" />
<StartPosition value="CenterParent" />
<MinimumSize value="{Width=308, Height=208}" />
<FormBorderStyle value="SizableToolWindow" />
<Text value="${res:Dialog.Goto.DialogName}" />
<MaximizeBox value="False" />
<ClientSize value="{Width=397, Height=234}" />
<CancelButton value="cancelButton [System.Windows.Forms.Button], Text: ${res:Global.CancelButtonText}" />
<Controls>
<System.Windows.Forms.ListView>
<Name value="listView" />
<Size value="{Width=372, Height=106}" />
<TabIndex value="5" />
<MultiSelect value="False" />
<HoverSelection value="True" />
<View value="Details" />
<HeaderStyle value="None" />
<Activation value="OneClick" />
<HotTracking value="True" />
<Location value="{X=13,Y=92}" />
<Anchor value="Top, Bottom, Left, Right" />
<Columns>
<System.Windows.Forms.ColumnHeader>
<Name value="columnHeader" />
</System.Windows.Forms.ColumnHeader>
</Columns>
</System.Windows.Forms.ListView>
<System.Windows.Forms.Button>
<Name value="cancelButton" />
<Location value="{X=315,Y=205}" />
<Text value="${res:Global.CancelButtonText}" />
<Size value="{Width=75, Height=23}" />
<Anchor value="Bottom, Right" />
<TabIndex value="4" />
<DialogResult value="Cancel" />
</System.Windows.Forms.Button>
<System.Windows.Forms.Button>
<Name value="okButton" />
<Location value="{X=235,Y=205}" />
<Text value="${res:Global.OKButtonText}" />
<Size value="{Width=75, Height=23}" />
<Anchor value="Bottom, Right" />
<TabIndex value="3" />
</System.Windows.Forms.Button>
<System.Windows.Forms.TextBox>
<Name value="textBox" />
<TabIndex value="1" />
<Anchor value="Top, Left, Right" />
<Size value="{Width=372, Height=21}" />
<Location value="{X=13,Y=64}" />
</System.Windows.Forms.TextBox>
<System.Windows.Forms.Label>
<Name value="label" />
<Location value="{X=8,Y=0}" />
<Text value="${res:Dialog.Goto.IntroText}" />
<TextAlign value="BottomLeft" />
<Size value="{Width=381, Height=61}" />
<TabIndex value="0" />
<Anchor value="Top, Left, Right" />
</System.Windows.Forms.Label>
</Controls>
</System.Windows.Forms.Form>
<System.Windows.Forms.ColumnHeader>
<Name value="columnHeader" />
</System.Windows.Forms.ColumnHeader>
</Components>

51
src/Main/Base/Project/Resources/GotoLineNumberDialog.xfrm

@ -1,51 +0,0 @@ @@ -1,51 +0,0 @@
<Components version="1.0">
<System.Windows.Forms.Form>
<Name value="MyForm" />
<ShowInTaskbar value="False" />
<FormBorderStyle value="FixedDialog" />
<StartPosition value="CenterParent" />
<ClientSize value="{Width=232, Height=93}" />
<MinimizeBox value="False" />
<DockPadding value="" />
<Text value="${res:Dialog.GotoLineNumber.DialogName}" />
<AcceptButton value="okButton [System.Windows.Forms.Button], Text: ${res:Global.OKButtonText}" />
<CancelButton value="cancelButton [System.Windows.Forms.Button], Text: ${res:Global.CancelButtonText}" />
<MaximizeBox value="False" />
<Controls>
<System.Windows.Forms.Button>
<Name value="cancelButton" />
<Location value="{X=150,Y=64}" />
<ClientSize value="{Width=75, Height=23}" />
<Text value="${res:Global.CancelButtonText}" />
<Anchor value="Bottom, Right" />
<TabIndex value="3" />
<DialogResult value="Cancel" />
</System.Windows.Forms.Button>
<System.Windows.Forms.Button>
<Name value="okButton" />
<Location value="{X=70,Y=64}" />
<ClientSize value="{Width=75, Height=23}" />
<Text value="${res:Global.OKButtonText}" />
<Anchor value="Bottom, Right" />
<TabIndex value="2" />
</System.Windows.Forms.Button>
<System.Windows.Forms.TextBox>
<Name value="lineNumberTextBox" />
<Anchor value="Top, Left, Right" />
<TabIndex value="1" />
<Location value="{X=8,Y=32}" />
<ClientSize value="{Width=212, Height=17}" />
<Text value="" />
</System.Windows.Forms.TextBox>
<System.Windows.Forms.Label>
<Name value="label" />
<Text value="${res:Dialog.GotoLineNumber.label1Text}" />
<TextAlign value="BottomLeft" />
<Anchor value="Top, Left, Right" />
<TabIndex value="0" />
<ClientSize value="{Width=216, Height=23}" />
<Location value="{X=8,Y=8}" />
</System.Windows.Forms.Label>
</Controls>
</System.Windows.Forms.Form>
</Components>

2
src/Main/Base/Project/Src/Commands/AutostartCommands.cs

@ -151,8 +151,6 @@ namespace ICSharpCode.SharpDevelop.Commands @@ -151,8 +151,6 @@ namespace ICSharpCode.SharpDevelop.Commands
Application.AddMessageFilter(new FormKeyHandler());
Application.Run(f);
ParserService.StopParserThread();
// save the workbench memento in the ide properties
try {
PropertyService.Set(workbenchMemento, WorkbenchSingleton.Workbench.CreateMemento());

18
src/Main/Base/Project/Src/Dom/Implementations/DefaultReturnType.cs

@ -69,7 +69,23 @@ namespace ICSharpCode.SharpDevelop.Dom @@ -69,7 +69,23 @@ namespace ICSharpCode.SharpDevelop.Dom
foreach (IClass bc in c.ClassInheritanceTree) {
if (bc.ClassType == ClassType.Interface && c.ClassType != ClassType.Interface)
continue; // ignore explicit interface implementations
l.AddRange(bc.Properties);
foreach (IProperty p in bc.Properties) {
// do not add methods that were overridden
bool ok = true;
foreach (IProperty oldProperty in l) {
if (string.Equals(oldProperty.Name, p.Name, StringComparison.InvariantCultureIgnoreCase)) {
if (p.IsStatic == oldProperty.IsStatic) {
if (DiffUtility.Compare(oldProperty.Parameters, p.Parameters) == 0) {
ok = false;
break;
}
}
}
}
if (ok)
l.Add(p);
}
}
return l;
}

2
src/Main/Base/Project/Src/Gui/Workbench/DefaultWorkbench.cs

@ -397,6 +397,8 @@ namespace ICSharpCode.SharpDevelop.Gui @@ -397,6 +397,8 @@ namespace ICSharpCode.SharpDevelop.Gui
closeAll = true;
ParserService.StopParserThread();
layout.Detach();
foreach (PadDescriptor padDescriptor in PadContentCollection) {
padDescriptor.Dispose();

179
src/Main/Base/Project/Src/Services/ClassBrowserIcons/ClassBrowserIconService.cs

@ -21,20 +21,21 @@ namespace ICSharpCode.Core @@ -21,20 +21,21 @@ namespace ICSharpCode.Core
{
public static class ClassBrowserIconService
{
const int namespaceIndex = 3;
const int combineIndex = 14;
const int literalIndex = 15;
public const int NamespaceIndex = 3;
public const int CombineIndex = 14;
public const int LiteralIndex = 15;
public const int GotoArrowIndex = 13;
const int classIndex = 16;
const int structIndex = classIndex + 1 * 4;
const int interfaceIndex = classIndex + 2 * 4;
const int enumIndex = classIndex + 3 * 4;
const int methodIndex = classIndex + 4 * 4;
const int propertyIndex = classIndex + 5 * 4;
const int fieldIndex = classIndex + 6 * 4;
const int delegateIndex = classIndex + 7 * 4;
const int eventIndex = classIndex + 8 * 4;
const int indexerIndex = classIndex + 9 * 4;
public const int ClassIndex = 16;
public const int StructIndex = ClassIndex + 1 * 4;
public const int InterfaceIndex = ClassIndex + 2 * 4;
public const int EnumIndex = ClassIndex + 3 * 4;
public const int MethodIndex = ClassIndex + 4 * 4;
public const int PropertyIndex = ClassIndex + 5 * 4;
public const int FieldIndex = ClassIndex + 6 * 4;
public const int DelegateIndex = ClassIndex + 7 * 4;
public const int EventIndex = ClassIndex + 8 * 4;
public const int IndexerIndex = ClassIndex + 9 * 4;
const int internalModifierOffset = 1;
const int protectedModifierOffset = 2;
@ -48,96 +49,6 @@ namespace ICSharpCode.Core @@ -48,96 +49,6 @@ namespace ICSharpCode.Core
}
}
public static int CombineIndex {
get {
return combineIndex;
}
}
public static int NamespaceIndex {
get {
return namespaceIndex;
}
}
public static int LiteralIndex {
get {
return literalIndex;
}
}
public static int ClassIndex {
get {
return classIndex;
}
}
public static int StructIndex {
get {
return structIndex;
}
}
public static int InterfaceIndex {
get {
return interfaceIndex;
}
}
public static int EnumIndex {
get {
return enumIndex;
}
}
public static int MethodIndex {
get {
return methodIndex;
}
}
public static int PropertyIndex {
get {
return propertyIndex;
}
}
public static int FieldIndex {
get {
return fieldIndex;
}
}
public static int DelegateIndex {
get {
return delegateIndex;
}
}
public static int EventIndex {
get {
return eventIndex;
}
}
public static int InternalModifierOffset {
get {
return internalModifierOffset;
}
}
public static int ProtectedModifierOffset {
get {
return protectedModifierOffset;
}
}
public static int PrivateModifierOffset {
get {
return privateModifierOffset;
}
}
static int GetModifierOffset(ModifierEnum modifier)
{
if ((modifier & ModifierEnum.Public) == ModifierEnum.Public) {
@ -154,47 +65,47 @@ namespace ICSharpCode.Core @@ -154,47 +65,47 @@ namespace ICSharpCode.Core
public static int GetIcon(IMethod method)
{
return methodIndex + GetModifierOffset(method.Modifiers);
return MethodIndex + GetModifierOffset(method.Modifiers);
}
public static int GetIcon(IIndexer method)
{
return indexerIndex + GetModifierOffset(method.Modifiers);
return IndexerIndex + GetModifierOffset(method.Modifiers);
}
public static int GetIcon(IProperty method)
{
return propertyIndex + GetModifierOffset(method.Modifiers);
return PropertyIndex + GetModifierOffset(method.Modifiers);
}
public static int GetIcon(IField field)
{
if (field.IsLiteral) {
return literalIndex;
return LiteralIndex;
}
return fieldIndex + GetModifierOffset(field.Modifiers);
return FieldIndex + GetModifierOffset(field.Modifiers);
}
public static int GetIcon(IEvent evt)
{
return eventIndex + GetModifierOffset(evt.Modifiers);
return EventIndex + GetModifierOffset(evt.Modifiers);
}
public static int GetIcon(IClass c)
{
int imageIndex = classIndex;
int imageIndex = ClassIndex;
switch (c.ClassType) {
case ClassType.Delegate:
imageIndex = delegateIndex;
imageIndex = DelegateIndex;
break;
case ClassType.Enum:
imageIndex = enumIndex;
imageIndex = EnumIndex;
break;
case ClassType.Struct:
imageIndex = structIndex;
imageIndex = StructIndex;
break;
case ClassType.Interface:
imageIndex = interfaceIndex;
imageIndex = InterfaceIndex;
break;
}
return imageIndex + GetModifierOffset(c.Modifiers);
@ -203,73 +114,73 @@ namespace ICSharpCode.Core @@ -203,73 +114,73 @@ namespace ICSharpCode.Core
public static int GetIcon(MethodBase methodinfo)
{
if (methodinfo.IsAssembly) {
return methodIndex + internalModifierOffset;
return MethodIndex + internalModifierOffset;
}
if (methodinfo.IsPrivate) {
return methodIndex + privateModifierOffset;
return MethodIndex + privateModifierOffset;
}
if (!(methodinfo.IsPrivate || methodinfo.IsPublic)) {
return methodIndex + protectedModifierOffset;
return MethodIndex + protectedModifierOffset;
}
return methodIndex;
return MethodIndex;
}
public static int GetIcon(PropertyInfo propertyinfo)
{
if (propertyinfo.CanRead && propertyinfo.GetGetMethod(true) != null) {
return propertyIndex + GetIcon(propertyinfo.GetGetMethod(true)) - methodIndex;
return PropertyIndex + GetIcon(propertyinfo.GetGetMethod(true)) - MethodIndex;
}
if (propertyinfo.CanWrite && propertyinfo.GetSetMethod(true) != null) {
return propertyIndex + GetIcon(propertyinfo.GetSetMethod(true)) - methodIndex;
return PropertyIndex + GetIcon(propertyinfo.GetSetMethod(true)) - MethodIndex;
}
return propertyIndex;
return PropertyIndex;
}
public static int GetIcon(FieldInfo fieldinfo)
{
if (fieldinfo.IsLiteral) {
return 13;
return LiteralIndex;
}
if (fieldinfo.IsAssembly) {
return fieldIndex + internalModifierOffset;
return FieldIndex + internalModifierOffset;
}
if (fieldinfo.IsPrivate) {
return fieldIndex + privateModifierOffset;
return FieldIndex + privateModifierOffset;
}
if (!(fieldinfo.IsPrivate || fieldinfo.IsPublic)) {
return fieldIndex + protectedModifierOffset;
return FieldIndex + protectedModifierOffset;
}
return fieldIndex;
return FieldIndex;
}
public static int GetIcon(EventInfo eventinfo)
{
if (eventinfo.GetAddMethod(true) != null) {
return eventIndex + GetIcon(eventinfo.GetAddMethod(true)) - methodIndex;
return EventIndex + GetIcon(eventinfo.GetAddMethod(true)) - MethodIndex;
}
return eventIndex;
return EventIndex;
}
public static int GetIcon(System.Type type)
{
int BASE = classIndex;
int BASE = ClassIndex;
if (type.IsValueType) {
BASE = structIndex;
BASE = StructIndex;
}
if (type.IsEnum) {
BASE = enumIndex;
BASE = EnumIndex;
}
if (type.IsInterface) {
BASE = interfaceIndex;
BASE = InterfaceIndex;
}
if (type.IsSubclassOf(typeof(System.Delegate))) {
BASE = delegateIndex;
BASE = DelegateIndex;
}
if (type.IsNestedPrivate) {
@ -307,7 +218,7 @@ namespace ICSharpCode.Core @@ -307,7 +218,7 @@ namespace ICSharpCode.Core
imglist.Images.Add(ResourceService.GetBitmap("Icons.16x16.ResourceFileIcon"));
imglist.Images.Add(ResourceService.GetBitmap("Icons.16x16.Event"));
imglist.Images.Add(ResourceService.GetBitmap("Icons.16x16.Literal"));
imglist.Images.Add(ResourceService.GetBitmap("Icons.16x16.Debug.Start"));
imglist.Images.Add(ResourceService.GetBitmap("Icons.16x16.CombineIcon"));
imglist.Images.Add(ResourceService.GetBitmap("Icons.16x16.Literal"));

9
src/Main/Base/Project/Src/TextEditor/Commands/CodeGenerators/OverrideMethodsCodeGenerator.cs

@ -46,6 +46,7 @@ namespace ICSharpCode.SharpDevelop.DefaultEditor.Commands @@ -46,6 +46,7 @@ namespace ICSharpCode.SharpDevelop.DefaultEditor.Commands
}
}
}
Content.Sort();
}
protected override void StartGeneration(IList items, string fileExtension)
@ -96,7 +97,7 @@ namespace ICSharpCode.SharpDevelop.DefaultEditor.Commands @@ -96,7 +97,7 @@ namespace ICSharpCode.SharpDevelop.DefaultEditor.Commands
// }
}
class MethodWrapper
class MethodWrapper : IComparable
{
IMethod method;
@ -106,6 +107,12 @@ namespace ICSharpCode.SharpDevelop.DefaultEditor.Commands @@ -106,6 +107,12 @@ namespace ICSharpCode.SharpDevelop.DefaultEditor.Commands
}
}
public int CompareTo(object other)
{
return method.Name.CompareTo(((MethodWrapper)other).method.Name);
}
public MethodWrapper(IMethod method)
{
this.method = method;

7
src/Main/Base/Project/Src/TextEditor/Commands/SearchCommands.cs

@ -30,10 +30,9 @@ namespace ICSharpCode.SharpDevelop.DefaultEditor.Commands @@ -30,10 +30,9 @@ namespace ICSharpCode.SharpDevelop.DefaultEditor.Commands
{
public override void Run()
{
if (!GotoLineNumberDialog.IsVisible) {
GotoLineNumberDialog gnd = new GotoLineNumberDialog();
gnd.Owner = (Form)WorkbenchSingleton.Workbench;
gnd.Show();
if (!GotoDialog.IsVisible) {
GotoDialog gnd = new GotoDialog();
gnd.Show(WorkbenchSingleton.MainForm);
}
}
}

373
src/Main/Base/Project/Src/TextEditor/Gui/Dialogs/GotoDialog.cs

@ -0,0 +1,373 @@ @@ -0,0 +1,373 @@
// <file>
// <copyright see="prj:///doc/copyright.txt">2002-2005 AlphaSierraPapa</copyright>
// <license see="prj:///doc/license.txt">GNU General Public License</license>
// <owner name="Mike Krüger" email="mike@icsharpcode.net"/>
// <version>$Revision$</version>
// </file>
using System;
using System.Collections;
using System.IO;
using System.Drawing;
using System.ComponentModel;
using System.Windows.Forms;
using System.Resources;
using ICSharpCode.TextEditor.Document;
using ICSharpCode.TextEditor.Gui.CompletionWindow;
using ICSharpCode.SharpDevelop.DefaultEditor.Gui.Editor;
using ICSharpCode.Core;
using ICSharpCode.SharpDevelop.Dom;
using ICSharpCode.SharpDevelop.Project;
using ICSharpCode.TextEditor;
using ICSharpCode.SharpDevelop.Gui.XmlForms;
namespace ICSharpCode.SharpDevelop.Gui
{
public class GotoDialog : BaseSharpDevelopForm
{
public static bool IsVisible = false;
ListView listView;
TextBox textBox;
public GotoDialog()
{
SetupFromXmlStream(this.GetType().Assembly.GetManifestResourceStream("Resources.GotoDialog.xfrm"));
ControlDictionary["okButton"].Click += new EventHandler(OKButtonClick);
ControlDictionary["cancelButton"].Click += new EventHandler(CancelButtonClick);
listView = (ListView)ControlDictionary["listView"];
textBox = (TextBox)ControlDictionary["textBox"];
textBox.TextChanged += TextBoxTextChanged;
textBox.KeyDown += TextBoxKeyDown;
listView.SmallImageList = ClassBrowserIconService.ImageList;
listView.ItemActivate += OKButtonClick;
listView.Sorting = SortOrder.Ascending;
listView.SizeChanged += ListViewSizeChanged;
listView.HideSelection = false;
ListViewSizeChanged(null, null);
Owner = WorkbenchSingleton.MainForm;
Icon = null;
this.StartPosition = FormStartPosition.Manual;
this.Bounds = PropertyService.Get("ICSharpCode.SharpDevelop.Gui.GotoDialog.Bounds", GetDefaultBounds());
}
Rectangle GetDefaultBounds()
{
Rectangle parent = WorkbenchSingleton.MainForm.Bounds;
Size size = this.Size;
return new Rectangle(parent.Left + (parent.Width - size.Width) / 2,
parent.Top + (parent.Height - size.Height) / 2,
size.Width, size.Height);
}
protected override void OnClosing(CancelEventArgs e)
{
base.OnClosing(e);
PropertyService.Set("ICSharpCode.SharpDevelop.Gui.GotoDialog.Bounds", this.Bounds);
}
void ListViewSizeChanged(object sender, EventArgs e)
{
listView.Columns[0].Width = listView.Width - 24;
}
void TextBoxKeyDown(object sender, KeyEventArgs e)
{
if (listView.SelectedItems.Count == 0)
return;
if (e.KeyData == Keys.Up) {
e.Handled = true;
ChangeIndex(-1);
} else if (e.KeyData == Keys.Down) {
e.Handled = true;
ChangeIndex(+1);
} else if (e.KeyData == Keys.PageUp) {
e.Handled = true;
ChangeIndex(-listView.ClientSize.Height / listView.Items[0].Bounds.Height);
} else if (e.KeyData == Keys.PageDown) {
e.Handled = true;
ChangeIndex(+listView.ClientSize.Height / listView.Items[0].Bounds.Height);
}
}
void ChangeIndex(int increment)
{
int index = listView.SelectedIndices[0];
index = Math.Max(0, Math.Min(listView.Items.Count - 1, index + increment));
listView.Items[index].Selected = true;
listView.EnsureVisible(index);
}
ICompletionData[] GetCompletionData()
{
TextEditorControl editor = GetEditor();
if (editor != null) {
CtrlSpaceCompletionDataProvider cdp = new CtrlSpaceCompletionDataProvider(ExpressionContext.Default);
return cdp.GenerateCompletionData(editor.FileName, editor.ActiveTextAreaControl.TextArea, '\0');
}
return new ICompletionData[0];
}
ICompletionData[] Resolve(string expression)
{
TextEditorControl editor = GetEditor();
if (editor != null) {
CodeCompletionDataProvider cdp = new CodeCompletionDataProvider(new ExpressionResult(expression));
return cdp.GenerateCompletionData(editor.FileName, editor.ActiveTextAreaControl.TextArea, '.');
}
return new ICompletionData[0];
}
protected override void OnClosed(EventArgs e)
{
IsVisible = false;
base.OnClosed(e);
}
Hashtable visibleEntries = new Hashtable();
double bestPriority;
ListViewItem bestItem;
void TextBoxTextChanged(object sender, EventArgs e)
{
string text = textBox.Text.Trim();
listView.Items.Clear();
visibleEntries.Clear();
bestItem = null;
if (text.Length == 0)
return;
int pos = text.IndexOf('.');
if (char.IsDigit(text, 0)) {
ShowLineNumberItem(text);
} else if (text.IndexOf(',') > 0) {
pos = text.IndexOf(',');
string file = text.Substring(0, pos).Trim();
string line = text.Substring(pos + 1).Trim();
int lineNr;
if (!int.TryParse(line, out lineNr))
lineNr = 0;
AddSourceFiles(file, lineNr);
} else if (pos > 0) {
AddSourceFiles(text, 0);
string expression = text.Substring(0, pos).Trim();
text = text.Substring(pos + 1).Trim();
ShowCompletionData(Resolve(expression), text);
foreach (IClass c in SearchClasses(expression)) {
if (c.Name.Equals(expression, StringComparison.InvariantCultureIgnoreCase)) {
foreach (IMethod m in c.DefaultReturnType.GetMethods()) {
if (!m.IsConstructor) {
AddItemIfMatchText(text, m, ClassBrowserIconService.GetIcon(m));
}
}
foreach (IField f in c.DefaultReturnType.GetFields()) {
AddItemIfMatchText(text, f, ClassBrowserIconService.GetIcon(f));
}
foreach (IProperty p in c.DefaultReturnType.GetProperties()) {
AddItemIfMatchText(text, p, ClassBrowserIconService.GetIcon(p));
}
foreach (IEvent evt in c.DefaultReturnType.GetEvents()) {
AddItemIfMatchText(text, evt, ClassBrowserIconService.GetIcon(evt));
}
}
}
} else {
AddSourceFiles(text, 0);
ShowCtrlSpaceCompletion(text);
}
if (bestItem != null) {
bestItem.Selected = true;
listView.EnsureVisible(bestItem.Index);
}
}
void AddSourceFiles(string text, int lineNumber)
{
if (ProjectService.OpenSolution != null) {
foreach (IProject project in ProjectService.OpenSolution.Projects) {
foreach (ProjectItem item in project.Items) {
switch (item.ItemType) {
case ItemType.Compile:
case ItemType.Content:
case ItemType.EmbeddedResource:
case ItemType.None:
AddSourceFile(text, lineNumber, item);
break;
}
}
}
}
}
void AddSourceFile(string text, int lineNumber, ProjectItem item)
{
string fileName = item.FileName;
string display = Path.GetFileName(fileName);
if (display.Length >= text.Length) {
if (text.Equals(display.Substring(0, text.Length), StringComparison.OrdinalIgnoreCase)) {
if (lineNumber > 0) {
display += ", line " + lineNumber;
}
AddItem(display, ClassBrowserIconService.GotoArrowIndex, new FileLineReference(fileName, lineNumber), 0.5);
}
}
}
void ShowLineNumberItem(string text)
{
int num;
if (int.TryParse(text, out num)) {
TextEditorControl editor = GetEditor();
if (editor != null) {
num = Math.Min(editor.Document.TotalNumberOfLines, Math.Max(1, num));
AddItem("Go to line " + num, ClassBrowserIconService.GotoArrowIndex, num, 0);
}
}
}
void ShowCompletionData(ICompletionData[] dataList, string text)
{
foreach (ICompletionData data in dataList) {
CodeCompletionData ccd = data as CodeCompletionData;
if (ccd == null)
return;
string dataText = ccd.Text;
if (dataText.Length >= text.Length) {
if (text.Equals(dataText.Substring(0, text.Length), StringComparison.OrdinalIgnoreCase)) {
if (ccd.Class != null)
AddItem(ccd.Class, data.ImageIndex, data.Priority);
else if (ccd.Member != null)
AddItem(ccd.Member, data.ImageIndex, data.Priority);
}
}
}
}
void ShowCtrlSpaceCompletion(string text)
{
ShowCompletionData(GetCompletionData(), text);
foreach (IClass c in SearchClasses(text)) {
AddItem(c);
}
}
ArrayList SearchClasses(string text)
{
ArrayList list = new ArrayList();
if (ProjectService.OpenSolution != null) {
foreach (IProject project in ProjectService.OpenSolution.Projects) {
IProjectContent projectContent = ParserService.GetProjectContent(project);
if (projectContent != null) {
foreach (IClass c in projectContent.Classes) {
string className = c.Name;
if (className.Length >= text.Length) {
if (text.Equals(className.Substring(0, text.Length), StringComparison.OrdinalIgnoreCase)) {
list.Add(c);
}
}
}
}
}
}
return list;
}
void AddItem(string text, int imageIndex, object tag, double priority)
{
if (visibleEntries.ContainsKey(text))
return;
visibleEntries.Add(text, null);
ListViewItem item = new ListViewItem(text, imageIndex);
item.Tag = tag;
if (bestItem == null
|| (priority > bestPriority && !(tag is IClass && bestItem.Tag is IMember))
|| (tag is IMember && bestItem.Tag is IClass))
{
bestItem = item;
bestPriority = priority;
}
listView.Items.Add(item);
}
void AddItem(IClass c)
{
AddItem(c, ClassBrowserIconService.GetIcon(c), CodeCompletionDataUsageCache.GetPriority(c.DotNetName, true));
}
void AddItemIfMatchText(string text, IMember member, int imageIndex)
{
string name = member.Name;
if (name.Length >= text.Length) {
if (text.Equals(name.Substring(0, text.Length), StringComparison.OrdinalIgnoreCase)) {
AddItem(member, imageIndex, CodeCompletionDataUsageCache.GetPriority(member.DotNetName, true));
}
}
}
void AddItem(IClass c, int imageIndex, double priority)
{
AddItem(c.Name + " (" + c.FullyQualifiedName + ")", imageIndex, c, priority);
}
void AddItem(IMember m, int imageIndex, double priority)
{
AddItem(m.Name + " (" + m.FullyQualifiedName + ")", imageIndex, m, priority);
}
void CancelButtonClick(object sender, EventArgs e)
{
IsVisible = false;
Close();
}
void GotoRegion(IRegion region, string fileName)
{
if (fileName != null) {
FileService.JumpToFilePosition(fileName, region.BeginLine - 1, region.BeginColumn - 1);
}
}
TextEditorControl GetEditor()
{
IWorkbenchWindow window = WorkbenchSingleton.Workbench.ActiveWorkbenchWindow;
if (window != null && window.ViewContent is ITextEditorControlProvider) {
return ((ITextEditorControlProvider)window.ViewContent).TextEditorControl;
}
return null;
}
void OKButtonClick(object sender, EventArgs e)
{
try {
if (listView.SelectedItems.Count == 0)
return;
object tag = listView.SelectedItems[0].Tag;
if (tag is int) {
TextEditorControl editor = GetEditor();
if (editor != null) {
int i = Math.Min(editor.Document.TotalNumberOfLines, Math.Max(1, (int)tag));
editor.ActiveTextAreaControl.Caret.Line = i - 1;
editor.ActiveTextAreaControl.ScrollToCaret();
}
} else if (tag is IClass) {
IClass c = tag as IClass;
CodeCompletionDataUsageCache.IncrementUsage(c.DotNetName);
GotoRegion(c.Region, c.CompilationUnit.FileName);
} else if (tag is IMember) {
IMember m = tag as IMember;
CodeCompletionDataUsageCache.IncrementUsage(m.DotNetName);
GotoRegion(m.Region, m.DeclaringType.CompilationUnit.FileName);
} else if (tag is FileLineReference) {
FileLineReference flref = (FileLineReference)tag;
FileService.JumpToFilePosition(flref.FileName, flref.Line - 1, flref.Column);
} else {
throw new NotImplementedException("Unknown tag: " + tag);
}
} finally {
IsVisible = false;
Close();
}
}
}
}

70
src/Main/Base/Project/Src/TextEditor/Gui/Dialogs/GotoLineNumberDialog.cs

@ -1,70 +0,0 @@ @@ -1,70 +0,0 @@
// <file>
// <copyright see="prj:///doc/copyright.txt">2002-2005 AlphaSierraPapa</copyright>
// <license see="prj:///doc/license.txt">GNU General Public License</license>
// <owner name="Mike Krüger" email="mike@icsharpcode.net"/>
// <version>$Revision$</version>
// </file>
using System;
using System.IO;
using System.Drawing;
using System.ComponentModel;
using System.Windows.Forms;
using System.Resources;
using ICSharpCode.TextEditor.Document;
using ICSharpCode.SharpDevelop.DefaultEditor.Gui.Editor;
using ICSharpCode.Core;
using ICSharpCode.TextEditor;
using ICSharpCode.SharpDevelop.Gui.XmlForms;
namespace ICSharpCode.SharpDevelop.Gui
{
public class GotoLineNumberDialog : BaseSharpDevelopForm
{
public static bool IsVisible = false;
public GotoLineNumberDialog()
{
SetupFromXmlStream(this.GetType().Assembly.GetManifestResourceStream("Resources.GotoLineNumberDialog.xfrm"));
ControlDictionary["okButton"].Click += new EventHandler(closeEvent);
ControlDictionary["cancelButton"].Click += new EventHandler(cancelEvent);
Owner = (Form)WorkbenchSingleton.Workbench;
Icon = null;
}
protected override void OnClosed(System.EventArgs e)
{
IsVisible = false;
base.OnClosed(e);
}
void cancelEvent(object sender, EventArgs e)
{
IsVisible = false;
Close();
}
void closeEvent(object sender, EventArgs e)
{
try {
IWorkbenchWindow window = WorkbenchSingleton.Workbench.ActiveWorkbenchWindow;
if (window != null && window.ViewContent is ITextEditorControlProvider) {
TextEditorControl textarea = ((ITextEditorControlProvider)window.ViewContent).TextEditorControl;
int i = Math.Min(textarea.Document.TotalNumberOfLines, Math.Max(1, Int32.Parse(ControlDictionary["lineNumberTextBox"].Text)));
textarea.ActiveTextAreaControl.Caret.Line = i - 1;
textarea.ActiveTextAreaControl.ScrollToCaret();
}
} catch (Exception) {
} finally {
IsVisible = false;
Close();
}
}
}
}

19
src/Main/Base/Project/Src/TextEditor/Gui/Editor/CompletionWindow/CodeCompletionData.cs

@ -28,6 +28,7 @@ namespace ICSharpCode.SharpDevelop.DefaultEditor.Gui.Editor @@ -28,6 +28,7 @@ namespace ICSharpCode.SharpDevelop.DefaultEditor.Gui.Editor
string description;
string documentation;
IClass c;
IMember member;
bool convertedDocumentation = false;
double priority;
@ -41,6 +42,16 @@ namespace ICSharpCode.SharpDevelop.DefaultEditor.Gui.Editor @@ -41,6 +42,16 @@ namespace ICSharpCode.SharpDevelop.DefaultEditor.Gui.Editor
}
}
/// <summary>
/// Gets the member this CodeCompletionData object was created for.
/// Returns null if the CodeCompletionData object was created for a class or namespace.
/// </summary>
public IMember Member {
get {
return member;
}
}
public int Overloads {
get {
return overloads;
@ -128,7 +139,7 @@ namespace ICSharpCode.SharpDevelop.DefaultEditor.Gui.Editor @@ -128,7 +139,7 @@ namespace ICSharpCode.SharpDevelop.DefaultEditor.Gui.Editor
public CodeCompletionData(IMethod method)
{
member = method;
ambience = AmbienceService.CurrentAmbience;
ambience.ConversionFlags = ConversionFlags.ShowReturnType | ConversionFlags.ShowParameterNames | ConversionFlags.ShowModifiers;
imageIndex = ClassBrowserIconService.GetIcon(method);
@ -140,7 +151,7 @@ namespace ICSharpCode.SharpDevelop.DefaultEditor.Gui.Editor @@ -140,7 +151,7 @@ namespace ICSharpCode.SharpDevelop.DefaultEditor.Gui.Editor
public CodeCompletionData(IField field)
{
member = field;
ambience = AmbienceService.CurrentAmbience;
ambience.ConversionFlags = ConversionFlags.ShowReturnType | ConversionFlags.ShowParameterNames | ConversionFlags.ShowModifiers;
imageIndex = ClassBrowserIconService.GetIcon(field);
@ -152,7 +163,7 @@ namespace ICSharpCode.SharpDevelop.DefaultEditor.Gui.Editor @@ -152,7 +163,7 @@ namespace ICSharpCode.SharpDevelop.DefaultEditor.Gui.Editor
public CodeCompletionData(IProperty property)
{
member = property;
ambience = AmbienceService.CurrentAmbience;
ambience.ConversionFlags = ConversionFlags.ShowReturnType | ConversionFlags.ShowParameterNames | ConversionFlags.ShowModifiers;
imageIndex = ClassBrowserIconService.GetIcon(property);
@ -164,7 +175,7 @@ namespace ICSharpCode.SharpDevelop.DefaultEditor.Gui.Editor @@ -164,7 +175,7 @@ namespace ICSharpCode.SharpDevelop.DefaultEditor.Gui.Editor
public CodeCompletionData(IEvent e)
{
member = e;
ambience = AmbienceService.CurrentAmbience;
ambience.ConversionFlags = ConversionFlags.ShowReturnType | ConversionFlags.ShowParameterNames | ConversionFlags.ShowModifiers;
imageIndex = ClassBrowserIconService.GetIcon(e);

7
src/Main/Base/Project/Src/TextEditor/Gui/Editor/InsightWindow/MethodInsightDataProvider.cs

@ -152,9 +152,14 @@ namespace ICSharpCode.SharpDevelop.DefaultEditor.Gui.Editor @@ -152,9 +152,14 @@ namespace ICSharpCode.SharpDevelop.DefaultEditor.Gui.Editor
if (result == null)
return;
IProjectContent p = ParserService.CurrentProjectContent;
bool classIsInInheritanceTree = false;
if (result.CallingClass != null)
classIsInInheritanceTree = result.CallingClass.IsTypeInInheritanceTree(result.ContainingType.GetUnderlyingClass());
foreach (IMethod method in result.ContainingType.GetMethods()) {
if (p.Language.NameComparer.Equals(method.Name, result.Name)) {
methods.Add(method);
if (method.IsAccessible(result.CallingClass, classIsInInheritanceTree)) {
methods.Add(method);
}
}
}
}

BIN
src/Main/StartUp/Project/Resources/StringResources.resources

Binary file not shown.
Loading…
Cancel
Save