Browse Source

- XamlBinding: fixed bugs and added Unit Tests

- converted NRefactoryDemo.csproj to .NET 4

git-svn-id: svn://svn.sharpdevelop.net/sharpdevelop/trunk@4751 1ccf3a8d-04fe-1044-b7c0-cef0b8235c61
shortcuts
Siegfried Pammer 16 years ago
parent
commit
0444f9b0e0
  1. 18
      samples/NRefactoryDemo/NRefactoryDemo.csproj
  2. 6
      samples/NRefactoryDemo/NRefactoryDemo.sln
  3. 42
      src/AddIns/BackendBindings/XamlBinding/XamlBinding.Tests/CodeCompletionTests.cs
  4. 2
      src/AddIns/BackendBindings/XamlBinding/XamlBinding.Tests/XamlBinding.Tests.csproj
  5. 2
      src/AddIns/BackendBindings/XamlBinding/XamlBinding/CompletionDataHelper.cs
  6. 13
      src/AddIns/BackendBindings/XamlBinding/XamlBinding/XamlCodeCompletionBinding.cs

18
samples/NRefactoryDemo/NRefactoryDemo.csproj

@ -1,4 +1,4 @@ @@ -1,4 +1,4 @@
<Project DefaultTargets="Build" xmlns="http://schemas.microsoft.com/developer/msbuild/2003">
<Project DefaultTargets="Build" xmlns="http://schemas.microsoft.com/developer/msbuild/2003" ToolsVersion="4.0">
<PropertyGroup>
<OutputType>WinExe</OutputType>
<RootNamespace>NRefactoryDemo</RootNamespace>
@ -6,6 +6,8 @@ @@ -6,6 +6,8 @@
<Configuration Condition=" '$(Configuration)' == '' ">Debug</Configuration>
<Platform Condition=" '$(Platform)' == '' ">AnyCPU</Platform>
<ProjectGuid>{63199047-9D5D-474C-B3CC-62ABBB071B67}</ProjectGuid>
<SourceAnalysisOverrideSettingsFile>C:\Users\Siegfried\AppData\Roaming\ICSharpCode/SharpDevelop3.0\Settings.SourceAnalysis</SourceAnalysisOverrideSettingsFile>
<TargetFrameworkVersion>v4.0</TargetFrameworkVersion>
</PropertyGroup>
<PropertyGroup Condition=" '$(Configuration)' == 'Debug' ">
<BaseIntermediateOutputPath>obj\</BaseIntermediateOutputPath>
@ -28,14 +30,22 @@ @@ -28,14 +30,22 @@
<CheckForOverflowUnderflow>False</CheckForOverflowUnderflow>
</PropertyGroup>
<ItemGroup>
<Reference Include="ICSharpCode.NRefactory">
<HintPath>..\..\bin\ICSharpCode.NRefactory.dll</HintPath>
</Reference>
<Reference Include="System" />
<Reference Include="System.Core">
<RequiredTargetFramework>4.0</RequiredTargetFramework>
</Reference>
<Reference Include="System.Data" />
<Reference Include="System.Data.DataSetExtensions">
<RequiredTargetFramework>4.0</RequiredTargetFramework>
</Reference>
<Reference Include="System.Drawing" />
<Reference Include="System.Windows.Forms" />
<Reference Include="System.Xml" />
<Reference Include="ICSharpCode.NRefactory">
<HintPath>..\..\bin\ICSharpCode.NRefactory.dll</HintPath>
<SpecificVersion>False</SpecificVersion>
<Reference Include="System.Xml.Linq">
<RequiredTargetFramework>4.0</RequiredTargetFramework>
</Reference>
</ItemGroup>
<ItemGroup>

6
samples/NRefactoryDemo/NRefactoryDemo.sln

@ -1,5 +1,7 @@ @@ -1,5 +1,7 @@
Microsoft Visual Studio Solution File, Format Version 9.00
# SharpDevelop 2.1.0.1394

Microsoft Visual Studio Solution File, Format Version 10.00
# Visual Studio 2008
# SharpDevelop 3.1.0.4545
Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "NRefactoryDemo", "NRefactoryDemo.csproj", "{63199047-9D5D-474C-B3CC-62ABBB071B67}"
EndProject
Global

42
src/AddIns/BackendBindings/XamlBinding/XamlBinding.Tests/CtrlSpaceCodeCompletionTests.cs → src/AddIns/BackendBindings/XamlBinding/XamlBinding.Tests/CodeCompletionTests.cs

@ -499,6 +499,46 @@ namespace ICSharpCode.XamlBinding.Tests @@ -499,6 +499,46 @@ namespace ICSharpCode.XamlBinding.Tests
});
}
[Test]
public void CtrlSpaceTest21()
{
string fileHeader = @"<Window x:Class='ICSharpCode.XamlBinding.Tests.CompletionTestsBase'
xmlns='http://schemas.microsoft.com/winfx/2006/xaml/presentation'
xmlns:x='http://schemas.microsoft.com/winfx/2006/xaml'>
<Grid>
<Button AllowDrop='True' Grid.Row='0' Content='test ";
string fileFooter = @"' />
</Grid>
</Window>";
TestCtrlSpace(fileHeader, fileFooter, false,
list => {
Assert.AreEqual(0, list.PreselectionLength);
Assert.IsNull(list.SuggestedItem);
Assert.IsTrue(!list.Items.Any());
});
}
[Test]
public void TypeAtValueEndingInSpace()
{
string fileHeader = @"<Window x:Class='ICSharpCode.XamlBinding.Tests.CompletionTestsBase'
xmlns='http://schemas.microsoft.com/winfx/2006/xaml/presentation'
xmlns:x='http://schemas.microsoft.com/winfx/2006/xaml'>
<Grid>
<Button AllowDrop='True' Grid.Row='0' Content='test ";
string fileFooter = @"' />
</Grid>
</Window>";
TestKeyPress(fileHeader, fileFooter, 'a', CodeCompletionKeyPressResult.None,
list => {
Assert.AreEqual(0, list.PreselectionLength);
Assert.IsNull(list.SuggestedItem);
Assert.IsTrue(!list.Items.Any());
});
}
[Test]
public void ElementAttributeDotPressTest01()
{
@ -677,5 +717,7 @@ namespace ICSharpCode.XamlBinding.Tests @@ -677,5 +717,7 @@ namespace ICSharpCode.XamlBinding.Tests
TestKeyPress(fileHeader, fileFooter, 'a', CodeCompletionKeyPressResult.None, list => {});
TestKeyPress(fileHeader, fileFooter, '<', CodeCompletionKeyPressResult.Completed, list => {});
}
}
}

2
src/AddIns/BackendBindings/XamlBinding/XamlBinding.Tests/XamlBinding.Tests.csproj

@ -65,7 +65,7 @@ @@ -65,7 +65,7 @@
<Compile Include="..\..\..\..\Main\GlobalAssemblyInfo.cs">
<Link>Properties\GlobalAssemblyInfo.cs</Link>
</Compile>
<Compile Include="CtrlSpaceCodeCompletionTests.cs" />
<Compile Include="CodeCompletionTests.cs" />
<Compile Include="CompletionTestsBase.xaml.cs">
<DependentUpon>CompletionTestsBase.xaml</DependentUpon>
<SubType>Code</SubType>

2
src/AddIns/BackendBindings/XamlBinding/XamlBinding/CompletionDataHelper.cs

@ -759,7 +759,7 @@ namespace ICSharpCode.XamlBinding @@ -759,7 +759,7 @@ namespace ICSharpCode.XamlBinding
IReturnType typeName;
string valueBeforeCaret = (context.ValueStartOffset > 0) ?
context.RawAttributeValue.Substring(0, context.ValueStartOffset + 1) : "";
context.RawAttributeValue.Substring(0, context.ValueStartOffset) : "";
switch (c.ClassType) {
case ClassType.Class:

13
src/AddIns/BackendBindings/XamlBinding/XamlBinding/XamlCodeCompletionBinding.cs

@ -169,10 +169,13 @@ namespace ICSharpCode.XamlBinding @@ -169,10 +169,13 @@ namespace ICSharpCode.XamlBinding
string attributeName = (context.Attribute != null) ? context.Attribute.Name : string.Empty;
if (!attributeName.StartsWith("xmlns", StringComparison.OrdinalIgnoreCase))
this.CtrlSpace(editor);
if (!attributeName.StartsWith("xmlns", StringComparison.OrdinalIgnoreCase)) {
return this.CtrlSpace(editor)
? CodeCompletionKeyPressResult.CompletedIncludeKeyInCompletion
: CodeCompletionKeyPressResult.None;
}
trackForced = true;
return CodeCompletionKeyPressResult.CompletedIncludeKeyInCompletion;
return CodeCompletionKeyPressResult.None;
}
break;
}
@ -243,6 +246,8 @@ namespace ICSharpCode.XamlBinding @@ -243,6 +246,8 @@ namespace ICSharpCode.XamlBinding
if ((context.Attribute.Prefix.Equals("xmlns", StringComparison.OrdinalIgnoreCase) ||
context.Attribute.Name.Equals("xmlns", StringComparison.OrdinalIgnoreCase)) && window != null)
window.Width = 400;
return completionList.Items.Any();
}
return true;
}
@ -393,7 +398,7 @@ namespace ICSharpCode.XamlBinding @@ -393,7 +398,7 @@ namespace ICSharpCode.XamlBinding
context.Editor.ShowCompletionWindow(completionList);
var insightList = CompletionDataHelper.CreateMarkupExtensionInsight(context);
context.Editor.ShowInsightWindow(insightList);
return true;
return completionList.Items.Any() || insightList.Any();
}
return false;

Loading…
Cancel
Save