From 551cbf9e4ca4b900e6aa4de3886cd8fab032c566 Mon Sep 17 00:00:00 2001 From: Daniel Grunwald Date: Fri, 15 May 2009 15:48:12 +0000 Subject: [PATCH] Implemented Indexer Insight for AvalonEdit. git-svn-id: svn://svn.sharpdevelop.net/sharpdevelop/trunk@4080 1ccf3a8d-04fe-1044-b7c0-cef0b8235c61 --- .../Misc/UnitTesting/Src/RunTestCommands.cs | 2 ++ .../Project/ICSharpCode.SharpDevelop.csproj | 1 + .../CodeCompletion/CodeCompletionBinding.cs | 3 +- .../CodeCompletion/IndexerInsightProvider.cs | 32 +++++++++++++++++++ .../CodeCompletion/MethodInsightProvider.cs | 2 +- .../NRefactoryCodeCompletionBinding.cs | 2 +- 6 files changed, 38 insertions(+), 4 deletions(-) create mode 100644 src/Main/Base/Project/Src/Editor/CodeCompletion/IndexerInsightProvider.cs diff --git a/src/AddIns/Misc/UnitTesting/Src/RunTestCommands.cs b/src/AddIns/Misc/UnitTesting/Src/RunTestCommands.cs index 6ef1a2be69..a013e8cc74 100644 --- a/src/AddIns/Misc/UnitTesting/Src/RunTestCommands.cs +++ b/src/AddIns/Misc/UnitTesting/Src/RunTestCommands.cs @@ -133,6 +133,8 @@ namespace ICSharpCode.UnitTesting /// protected void TestsFinished() { + WorkbenchSingleton.AssertMainThread(); + // Read the rest of the file just in case. testResultsMonitor.Stop(); testResultsMonitor.Read(); diff --git a/src/Main/Base/Project/ICSharpCode.SharpDevelop.csproj b/src/Main/Base/Project/ICSharpCode.SharpDevelop.csproj index ce721d3ce2..02290ffaa8 100644 --- a/src/Main/Base/Project/ICSharpCode.SharpDevelop.csproj +++ b/src/Main/Base/Project/ICSharpCode.SharpDevelop.csproj @@ -83,6 +83,7 @@ + diff --git a/src/Main/Base/Project/Src/Editor/CodeCompletion/CodeCompletionBinding.cs b/src/Main/Base/Project/Src/Editor/CodeCompletion/CodeCompletionBinding.cs index f88a17160b..3ac559545c 100644 --- a/src/Main/Base/Project/Src/Editor/CodeCompletion/CodeCompletionBinding.cs +++ b/src/Main/Base/Project/Src/Editor/CodeCompletion/CodeCompletionBinding.cs @@ -10,7 +10,6 @@ using System.Collections; using System.IO; using ICSharpCode.Core; -using ICSharpCode.SharpDevelop.DefaultEditor.Gui.Editor; namespace ICSharpCode.SharpDevelop.Editor { @@ -180,7 +179,7 @@ namespace ICSharpCode.SharpDevelop.Editor break; case '[': if (enableIndexerInsight && CodeCompletionOptions.InsightEnabled) { - editor.ShowInsightWindow(new IndexerInsightDataProvider()); + editor.ShowInsightWindow(new IndexerInsightProvider().ProvideInsight(editor)); return CodeCompletionKeyPressResult.Completed; } break; diff --git a/src/Main/Base/Project/Src/Editor/CodeCompletion/IndexerInsightProvider.cs b/src/Main/Base/Project/Src/Editor/CodeCompletion/IndexerInsightProvider.cs new file mode 100644 index 0000000000..99b45c0130 --- /dev/null +++ b/src/Main/Base/Project/Src/Editor/CodeCompletion/IndexerInsightProvider.cs @@ -0,0 +1,32 @@ +// +// +// +// +// $Revision$ +// + +using System; +using System.Linq; +using ICSharpCode.SharpDevelop.Dom; + +namespace ICSharpCode.SharpDevelop.Editor +{ + /// + /// Produces MethodInsightItem instances for showing the insight window on indexer calls. + /// + public class IndexerInsightProvider : MethodInsightProvider + { + public override IInsightItem[] ProvideInsight(ExpressionResult expressionResult, ResolveResult result) + { + if (result == null) + return null; + IReturnType type = result.ResolvedType; + if (type == null) + return null; + return (from p in type.GetProperties() + where p.IsIndexer + select new MethodInsightItem(p) + ).ToArray(); + } + } +} diff --git a/src/Main/Base/Project/Src/Editor/CodeCompletion/MethodInsightProvider.cs b/src/Main/Base/Project/Src/Editor/CodeCompletion/MethodInsightProvider.cs index 68e643b6c3..18347a1540 100644 --- a/src/Main/Base/Project/Src/Editor/CodeCompletion/MethodInsightProvider.cs +++ b/src/Main/Base/Project/Src/Editor/CodeCompletion/MethodInsightProvider.cs @@ -16,7 +16,7 @@ using ICSharpCode.SharpDevelop.Dom; namespace ICSharpCode.SharpDevelop.Editor { /// - /// Description of MethodInsightProvider. + /// Produces MethodInsightItem instances for showing the insight window on method calls. /// public class MethodInsightProvider { diff --git a/src/Main/Base/Project/Src/Editor/CodeCompletion/NRefactoryCodeCompletionBinding.cs b/src/Main/Base/Project/Src/Editor/CodeCompletion/NRefactoryCodeCompletionBinding.cs index d89a865aa2..645e0dd0e8 100644 --- a/src/Main/Base/Project/Src/Editor/CodeCompletion/NRefactoryCodeCompletionBinding.cs +++ b/src/Main/Base/Project/Src/Editor/CodeCompletion/NRefactoryCodeCompletionBinding.cs @@ -194,7 +194,7 @@ namespace ICSharpCode.SharpDevelop.Editor protected void ShowInsight(ITextEditor editor, IList insightItems, ICollection parameters, char charTyped) { int paramCount = parameters.Count; - if (insightItems.Count == 0) + if (insightItems == null || insightItems.Count == 0) return; bool overloadIsSure; int defaultIndex;