Browse Source

Improved event handler completion.

Removed SharpZipLib.
Fixed SD2-415 and SD2-418.

git-svn-id: svn://svn.sharpdevelop.net/sharpdevelop/trunk@385 1ccf3a8d-04fe-1044-b7c0-cef0b8235c61
shortcuts
Daniel Grunwald 20 years ago
parent
commit
15549a22d6
  1. 3
      bin/setup/PostInstallTasks.bat
  2. 2
      bin/setup/PreUninstallTasks.bat
  3. BIN
      data/resources/layouts/Default.xml
  4. 79
      src/AddIns/BackendBindings/CSharpBinding/Project/Src/EventHandlerCompletitionDataProvider.cs
  5. 2
      src/Libraries/ICSharpCode.TextEditor/Project/Src/Gui/CompletionWindow/ICompletionData.cs
  6. 4
      src/Main/Base/Project/ICSharpCode.SharpDevelop.csproj
  7. BIN
      src/Main/Base/RequiredLibraries/ICSharpCode.SharpZipLib.dll
  8. 2
      src/Main/StartUp/Project/Dialogs/ExceptionBox.cs
  9. 4
      src/Tools/Tools.build

3
bin/setup/PostInstallTasks.bat

@ -4,9 +4,6 @@ echo. @@ -4,9 +4,6 @@ echo.
echo NUnit.Framework.dll
..\tools\gacutil2.exe /i ..\nunit.framework.dll
echo.
echo ICSharpCode.SharpZipLib.dll
..\tools\gacutil2.exe /i ..\ICSharpCode.SharpZipLib.dll
echo.
echo MbUnit requirements
..\tools\gacutil2.exe /i ..\tools\MbUnit\Refly.dll
..\tools\gacutil2.exe /i ..\tools\MbUnit\TestFu.dll

2
bin/setup/PreUninstallTasks.bat

@ -3,8 +3,6 @@ echo Removing assemblies from the GAC @@ -3,8 +3,6 @@ echo Removing assemblies from the GAC
echo.
..\tools\gacutil2.exe /u ..\nunit.framework.dll
echo.
..\tools\gacutil2.exe /u ..\ICSharpCode.SharpZipLib.dll
echo.
..\tools\gacutil2.exe /u ..\tools\MbUnit\Refly.dll
..\tools\gacutil2.exe /u ..\tools\MbUnit\TestFu.dll
..\tools\gacutil2.exe /u ..\tools\MbUnit\QuickGraph.dll

BIN
data/resources/layouts/Default.xml

Binary file not shown.

79
src/AddIns/BackendBindings/CSharpBinding/Project/Src/EventHandlerCompletitionDataProvider.cs

@ -8,6 +8,7 @@ @@ -8,6 +8,7 @@
using System;
using System.Collections;
using System.Collections.Generic;
using System.Text;
using System.Windows.Forms;
using ICSharpCode.TextEditor;
using ICSharpCode.Core;
@ -24,11 +25,13 @@ namespace CSharpBinding @@ -24,11 +25,13 @@ namespace CSharpBinding
{
string expression;
ResolveResult resolveResult;
IClass resolvedClass;
public EventHandlerCompletitionDataProvider(string expression, ResolveResult resolveResult)
{
this.expression = expression;
this.resolveResult = resolveResult;
this.resolvedClass = resolveResult.ResolvedType.GetUnderlyingClass();
}
/// <summary>
@ -37,8 +40,82 @@ namespace CSharpBinding @@ -37,8 +40,82 @@ namespace CSharpBinding
public override ICompletionData[] GenerateCompletionData(string fileName, TextArea textArea, char charTyped)
{
ArrayList completionData = new ArrayList();
completionData.Add(new DefaultCompletionData("new " + resolveResult.ResolvedType.FullyQualifiedName + "()", "Event handler", ClassBrowserIconService.DelegateIndex));
completionData.Add(new DelegateCompletionData("new " + resolveResult.ResolvedType.Name + "();", 2,
"delegate " + resolvedClass.FullyQualifiedName + "\n" + CodeCompletionData.GetDocumentation(resolvedClass.Documentation)));
completionData.Add(new DelegateCompletionData("delegate { };", 3,
"${res:CSharpBinding.InsertAnonymousMethod}"));
CSharpAmbience ambience = new CSharpAmbience();
ambience.ConversionFlags = ConversionFlags.ShowParameterNames;
IMethod invoke = resolvedClass.SearchMember("Invoke", LanguageProperties.CSharp) as IMethod;
if (invoke != null) {
StringBuilder builder = new StringBuilder("delegate(");
for (int i = 0; i < invoke.Parameters.Count; ++i) {
if (i > 0) {
builder.Append(", ");
}
builder.Append(ambience.Convert(invoke.Parameters[i]));
}
builder.Append(") { };");
completionData.Add(new DelegateCompletionData(builder.ToString(), 3,
"${res:CSharpBinding.InsertAnonymousMethodWithParameters}"));
IClass callingClass = resolveResult.CallingClass;
IClass eventReturnType = invoke.ReturnType.GetUnderlyingClass();
IClass[] eventParameters = new IClass[invoke.Parameters.Count];
for (int i = 0; i < eventParameters.Length; i++) {
eventParameters[i] = invoke.Parameters[i].ReturnType.GetUnderlyingClass();
if (eventParameters[i] == null) {
eventReturnType = null;
break;
}
}
if (callingClass != null && eventReturnType != null) {
bool inStatic = false;
if (resolveResult.CallingMember != null)
inStatic = resolveResult.CallingMember.IsStatic;
foreach (IMethod method in callingClass.DefaultReturnType.GetMethods()) {
if (inStatic && !method.IsStatic)
continue;
if (!method.IsAccessible(callingClass, true))
continue;
if (method.Parameters.Count != invoke.Parameters.Count)
continue;
// check return type compatibility:
IClass c2 = method.ReturnType.GetUnderlyingClass();
if (c2 == null || !c2.IsTypeInInheritanceTree(eventReturnType))
continue;
bool ok = true;
for (int i = 0; i < eventParameters.Length; i++) {
c2 = method.Parameters[i].ReturnType.GetUnderlyingClass();
if (c2 == null || !eventParameters[i].IsTypeInInheritanceTree(c2)) {
ok = false;
break;
}
}
if (ok) {
completionData.Add(new CodeCompletionData(method));
}
}
}
}
return (ICompletionData[])completionData.ToArray(typeof(ICompletionData));
}
private class DelegateCompletionData : DefaultCompletionData
{
int cursorOffset;
public DelegateCompletionData(string text, int cursorOffset, string documentation)
: base(text, StringParser.Parse(documentation), ClassBrowserIconService.DelegateIndex)
{
this.cursorOffset = cursorOffset;
}
public override bool InsertAction(TextArea textArea, char ch)
{
bool r = base.InsertAction(textArea, ch);
textArea.Caret.Column -= cursorOffset;
return r;
}
}
}
}

2
src/Libraries/ICSharpCode.TextEditor/Project/Src/Gui/CompletionWindow/ICompletionData.cs

@ -88,7 +88,7 @@ namespace ICSharpCode.TextEditor.Gui.CompletionWindow @@ -88,7 +88,7 @@ namespace ICSharpCode.TextEditor.Gui.CompletionWindow
}
}
public bool InsertAction(TextArea textArea, char ch)
public virtual bool InsertAction(TextArea textArea, char ch)
{
textArea.InsertString(text);
return false;

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

@ -30,10 +30,6 @@ @@ -30,10 +30,6 @@
<WarningLevel>4</WarningLevel>
</PropertyGroup>
<ItemGroup>
<Reference Include="ICSharpCode.SharpZipLib">
<HintPath>..\RequiredLibraries\ICSharpCode.SharpZipLib.dll</HintPath>
<SpecificVersion>False</SpecificVersion>
</Reference>
<Reference Include="System" />
<Reference Include="System.Data" />
<Reference Include="System.Design" />

BIN
src/Main/Base/RequiredLibraries/ICSharpCode.SharpZipLib.dll

Binary file not shown.

2
src/Main/StartUp/Project/Dialogs/ExceptionBox.cs

@ -116,7 +116,7 @@ namespace ICSharpCode.SharpDevelop @@ -116,7 +116,7 @@ namespace ICSharpCode.SharpDevelop
void CloseButtonClick(object sender, EventArgs e)
{
if (MessageService.AskQuestion("Do you really want to quit SharpDevelop?")) {
if (MessageBox.Show("Do you really want to quit SharpDevelop?", "SharpDevelop", MessageBoxButtons.YesNo, MessageBoxIcon.Question, MessageBoxDefaultButton.Button2) == DialogResult.Yes) {
Application.Exit();
}
}

4
src/Tools/Tools.build

@ -10,9 +10,6 @@ @@ -10,9 +10,6 @@
<!-- <ToolProject Include="GacUtil2\GacUtil2.csproj" /> -->
<ToolFiles Include="GacUtil2\GacUtil2.exe"/>
<ToolFiles Include="GacUtil2\GacUtil2.exe.config"/>
<!-- SharpZipLib is not copied automatically when it is in the GAC -->
<SDBinFiles Include="..\Main\Base\RequiredLibraries\ICSharpCode.SharpZipLib.dll"/>
</ItemGroup>
<Target Name="Build">
@ -25,7 +22,6 @@ @@ -25,7 +22,6 @@
-->
<Copy SourceFiles="@(MbUnitFiles)" DestinationFolder="..\..\bin\Tools\MbUnit"/>
<Copy SourceFiles="@(ToolFiles)" DestinationFolder="..\..\bin\Tools"/>
<Copy SourceFiles="@(SDBinFiles)" DestinationFolder="..\..\bin"/>
<!--
<MSBuild Projects="@(ToolProject)" Targets="Build">

Loading…
Cancel
Save