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 @@
<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> <PropertyGroup>
<OutputType>WinExe</OutputType> <OutputType>WinExe</OutputType>
<RootNamespace>NRefactoryDemo</RootNamespace> <RootNamespace>NRefactoryDemo</RootNamespace>
@ -6,6 +6,8 @@
<Configuration Condition=" '$(Configuration)' == '' ">Debug</Configuration> <Configuration Condition=" '$(Configuration)' == '' ">Debug</Configuration>
<Platform Condition=" '$(Platform)' == '' ">AnyCPU</Platform> <Platform Condition=" '$(Platform)' == '' ">AnyCPU</Platform>
<ProjectGuid>{63199047-9D5D-474C-B3CC-62ABBB071B67}</ProjectGuid> <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>
<PropertyGroup Condition=" '$(Configuration)' == 'Debug' "> <PropertyGroup Condition=" '$(Configuration)' == 'Debug' ">
<BaseIntermediateOutputPath>obj\</BaseIntermediateOutputPath> <BaseIntermediateOutputPath>obj\</BaseIntermediateOutputPath>
@ -28,14 +30,22 @@
<CheckForOverflowUnderflow>False</CheckForOverflowUnderflow> <CheckForOverflowUnderflow>False</CheckForOverflowUnderflow>
</PropertyGroup> </PropertyGroup>
<ItemGroup> <ItemGroup>
<Reference Include="ICSharpCode.NRefactory">
<HintPath>..\..\bin\ICSharpCode.NRefactory.dll</HintPath>
</Reference>
<Reference Include="System" /> <Reference Include="System" />
<Reference Include="System.Core">
<RequiredTargetFramework>4.0</RequiredTargetFramework>
</Reference>
<Reference Include="System.Data" /> <Reference Include="System.Data" />
<Reference Include="System.Data.DataSetExtensions">
<RequiredTargetFramework>4.0</RequiredTargetFramework>
</Reference>
<Reference Include="System.Drawing" /> <Reference Include="System.Drawing" />
<Reference Include="System.Windows.Forms" /> <Reference Include="System.Windows.Forms" />
<Reference Include="System.Xml" /> <Reference Include="System.Xml" />
<Reference Include="ICSharpCode.NRefactory"> <Reference Include="System.Xml.Linq">
<HintPath>..\..\bin\ICSharpCode.NRefactory.dll</HintPath> <RequiredTargetFramework>4.0</RequiredTargetFramework>
<SpecificVersion>False</SpecificVersion>
</Reference> </Reference>
</ItemGroup> </ItemGroup>
<ItemGroup> <ItemGroup>

6
samples/NRefactoryDemo/NRefactoryDemo.sln

@ -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}" Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "NRefactoryDemo", "NRefactoryDemo.csproj", "{63199047-9D5D-474C-B3CC-62ABBB071B67}"
EndProject EndProject
Global 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
}); });
} }
[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] [Test]
public void ElementAttributeDotPressTest01() public void ElementAttributeDotPressTest01()
{ {
@ -677,5 +717,7 @@ namespace ICSharpCode.XamlBinding.Tests
TestKeyPress(fileHeader, fileFooter, 'a', CodeCompletionKeyPressResult.None, list => {}); TestKeyPress(fileHeader, fileFooter, 'a', CodeCompletionKeyPressResult.None, list => {});
TestKeyPress(fileHeader, fileFooter, '<', CodeCompletionKeyPressResult.Completed, list => {}); TestKeyPress(fileHeader, fileFooter, '<', CodeCompletionKeyPressResult.Completed, list => {});
} }
} }
} }

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

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

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

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

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

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

Loading…
Cancel
Save