Browse Source
Add "run in debugger" command to member bookmarks. git-svn-id: svn://svn.sharpdevelop.net/sharpdevelop/trunk@423 1ccf3a8d-04fe-1044-b7c0-cef0b8235c61shortcuts
27 changed files with 427 additions and 56 deletions
@ -0,0 +1,53 @@
@@ -0,0 +1,53 @@
|
||||
<Project DefaultTargets="Build" xmlns="http://schemas.microsoft.com/developer/msbuild/2003"> |
||||
<PropertyGroup> |
||||
<OutputType>Library</OutputType> |
||||
<RootNamespace>CSharpBinding.Tests</RootNamespace> |
||||
<AssemblyName>CSharpBinding.Tests</AssemblyName> |
||||
<Configuration Condition=" '$(Configuration)' == '' ">Debug</Configuration> |
||||
<Platform Condition=" '$(Platform)' == '' ">AnyCPU</Platform> |
||||
<ProjectGuid>{4D0DFCB0-F6FB-469D-AA6F-C7F1D5FD5DE7}</ProjectGuid> |
||||
</PropertyGroup> |
||||
<PropertyGroup Condition=" '$(Configuration)|$(Platform)' == 'Debug|AnyCPU' "> |
||||
<OutputPath>..\..\..\..\..\AddIns\AddIns\BackendBindings\CSharpBinding\</OutputPath> |
||||
<Optimize>False</Optimize> |
||||
<DefineConstants>DEBUG;TRACE</DefineConstants> |
||||
<DebugSymbols>true</DebugSymbols> |
||||
<DebugType>Full</DebugType> |
||||
<CheckForOverflowUnderflow>True</CheckForOverflowUnderflow> |
||||
</PropertyGroup> |
||||
<PropertyGroup Condition=" '$(Configuration)|$(Platform)' == 'Release|AnyCPU' "> |
||||
<OutputPath>..\..\..\..\..\AddIns\AddIns\BackendBindings\CSharpBinding\</OutputPath> |
||||
<Optimize>True</Optimize> |
||||
<DefineConstants>TRACE</DefineConstants> |
||||
<DebugSymbols>False</DebugSymbols> |
||||
<DebugType>None</DebugType> |
||||
<CheckForOverflowUnderflow>False</CheckForOverflowUnderflow> |
||||
</PropertyGroup> |
||||
<ItemGroup> |
||||
<Reference Include="System" /> |
||||
<Reference Include="System.Data" /> |
||||
<Reference Include="System.Xml" /> |
||||
<Reference Include="nunit.framework"> |
||||
<Private>False</Private> |
||||
</Reference> |
||||
</ItemGroup> |
||||
<ItemGroup> |
||||
<Compile Include="ExpressionFinder.cs" /> |
||||
</ItemGroup> |
||||
<ItemGroup> |
||||
<ProjectReference Include="..\Project\CSharpBinding.csproj"> |
||||
<Project>{1F1AC7CD-D154-45BB-8EAF-804CA8055F5A}</Project> |
||||
<Name>CSharpBinding</Name> |
||||
<Private>False</Private> |
||||
</ProjectReference> |
||||
<Content Include="CSharpBinding.Tests.dll.config"> |
||||
<CopyToOutputDirectory>Always</CopyToOutputDirectory> |
||||
</Content> |
||||
<ProjectReference Include="..\..\..\..\Main\Base\Project\ICSharpCode.SharpDevelop.csproj"> |
||||
<Project>{2748AD25-9C63-4E12-877B-4DCE96FBED54}</Project> |
||||
<Name>ICSharpCode.SharpDevelop</Name> |
||||
<Private>False</Private> |
||||
</ProjectReference> |
||||
</ItemGroup> |
||||
<Import Project="$(MSBuildBinPath)\Microsoft.CSharp.Targets" /> |
||||
</Project> |
@ -0,0 +1,27 @@
@@ -0,0 +1,27 @@
|
||||
<?xml version="1.0"?> |
||||
<configuration> |
||||
<runtime> |
||||
<assemblyBinding xmlns="urn:schemas-microsoft-com:asm.v1"> |
||||
<dependentAssembly> |
||||
<assemblyIdentity name="ICSharpCode.Core" publicKeyToken="f829da5c02be14ee" culture="neutral"/> |
||||
<codeBase version="2.0.0.1" href="../../../../bin/ICSharpCode.Core.dll"/> |
||||
</dependentAssembly> |
||||
<dependentAssembly> |
||||
<assemblyIdentity name="ICSharpCode.SharpDevelop" publicKeyToken="f829da5c02be14ee" culture="neutral"/> |
||||
<codeBase version="2.0.0.1" href="../../../../bin/ICSharpCode.SharpDevelop.dll"/> |
||||
</dependentAssembly> |
||||
<dependentAssembly> |
||||
<assemblyIdentity name="ICSharpCode.TextEditor" publicKeyToken="4d61825e8dd49f1a" culture="neutral"/> |
||||
<codeBase version="2.0.0.1" href="../../../../bin/ICSharpCode.TextEditor.dll"/> |
||||
</dependentAssembly> |
||||
<dependentAssembly> |
||||
<assemblyIdentity name="ICSharpCode.NRefactory" publicKeyToken="efe927acf176eea2" culture="neutral"/> |
||||
<codeBase version="2.0.0.1" href="../../../../bin/ICSharpCode.NRefactory.dll"/> |
||||
</dependentAssembly> |
||||
<dependentAssembly> |
||||
<assemblyIdentity name="log4net" publicKeyToken="b32731d11ce58905" culture="neutral"/> |
||||
<codeBase version="1.2.9.0" href="../../../../bin/log4net.dll"/> |
||||
</dependentAssembly> |
||||
</assemblyBinding> |
||||
</runtime> |
||||
</configuration> |
@ -0,0 +1,98 @@
@@ -0,0 +1,98 @@
|
||||
// <file>
|
||||
// <copyright see="prj:///doc/copyright.txt">2002-2005 AlphaSierraPapa</copyright>
|
||||
// <license see="prj:///doc/license.txt">GNU General Public License</license>
|
||||
// <owner name="Daniel Grunwald" email="daniel@danielgrunwald.de"/>
|
||||
// <version>$Revision$</version>
|
||||
// </file>
|
||||
|
||||
using System; |
||||
using System.Collections.Generic; |
||||
using NUnit.Framework; |
||||
using CSharpBinding.Parser; |
||||
using ICSharpCode.SharpDevelop.Dom; |
||||
|
||||
namespace CSharpBinding.Tests |
||||
{ |
||||
[TestFixture] |
||||
public class ExpressionFinderTests |
||||
{ |
||||
const string document = @"using System;
|
||||
class Main<T> : BaseType |
||||
{ |
||||
public Color Color { get {} set {}} |
||||
Font Font { get {} set {}} |
||||
void Method() { |
||||
simple += 1; |
||||
int a = 0; |
||||
((CastTo)castTarget).MethodOnCastExpression(parameter); |
||||
int b = 0; |
||||
return ((CastTo)castTarget).PropertyOnCastExpression; |
||||
} |
||||
}";
|
||||
|
||||
ExpressionFinder ef; |
||||
|
||||
[SetUp] |
||||
public void Init() |
||||
{ |
||||
ef = new ExpressionFinder("test.cs"); |
||||
} |
||||
|
||||
void FindFull(string location, string expectedExpression, ExpressionContext expectedContext) |
||||
{ |
||||
int pos = document.IndexOf(location); |
||||
if (pos < 0) Assert.Fail("location not found in document"); |
||||
ExpressionResult er = ef.FindFullExpression(document, pos); |
||||
Assert.AreEqual(expectedExpression, er.Expression); |
||||
Assert.AreEqual(expectedContext.ToString(), er.Context.ToString()); |
||||
} |
||||
|
||||
[Test] |
||||
public void Simple() |
||||
{ |
||||
FindFull("mple += 1", "simple", ExpressionContext.Default); |
||||
} |
||||
|
||||
[Test] |
||||
public void SimpleBeginningOfExpression() |
||||
{ |
||||
FindFull("simple += 1", "simple", ExpressionContext.Default); |
||||
} |
||||
|
||||
[Test] |
||||
public void PropertyColor() |
||||
{ |
||||
FindFull("olor { get", "Color", ExpressionContext.Default); |
||||
} |
||||
|
||||
[Test] |
||||
public void TypeColor() |
||||
{ |
||||
FindFull("olor Color", "Color", ExpressionContext.Type); |
||||
} |
||||
|
||||
[Test] |
||||
public void PropertyFont() |
||||
{ |
||||
FindFull("ont { get", "Font", ExpressionContext.Default); |
||||
} |
||||
|
||||
[Test] |
||||
public void TypeFont() |
||||
{ |
||||
FindFull("ont Font", "Font", ExpressionContext.Type); |
||||
} |
||||
|
||||
[Test] |
||||
public void Method() |
||||
{ |
||||
FindFull("thodOnCastExpression(para", "((CastTo)castTarget).MethodOnCastExpression(parameter)", ExpressionContext.Default); |
||||
} |
||||
|
||||
[Test] |
||||
public void Property() |
||||
{ |
||||
FindFull("pertyOnCastExpression", "((CastTo)castTarget).PropertyOnCastExpression", ExpressionContext.Default); |
||||
} |
||||
} |
||||
} |
@ -0,0 +1,68 @@
@@ -0,0 +1,68 @@
|
||||
// <file>
|
||||
// <copyright see="prj:///doc/copyright.txt">2002-2005 AlphaSierraPapa</copyright>
|
||||
// <license see="prj:///doc/license.txt">GNU General Public License</license>
|
||||
// <owner name="Daniel Grunwald" email="daniel@danielgrunwald.de"/>
|
||||
// <version>$Revision$</version>
|
||||
// </file>
|
||||
|
||||
using System; |
||||
using System.Collections.Generic; |
||||
using System.Text; |
||||
using System.Windows.Forms; |
||||
using ICSharpCode.Core; |
||||
using ICSharpCode.SharpDevelop.Dom; |
||||
using ICSharpCode.SharpDevelop.Bookmarks; |
||||
using ICSharpCode.SharpDevelop.Gui; |
||||
|
||||
namespace ICSharpCode.MbUnitPad |
||||
{ |
||||
/// <summary>
|
||||
/// Supplies a "Unit test" menu item if the class is a test fixture.
|
||||
/// </summary>
|
||||
public class MbUnitTestableCondition : IConditionEvaluator |
||||
{ |
||||
public static IMember GetMember(object caller) |
||||
{ |
||||
MemberNode memberNode = caller as MemberNode; |
||||
if (memberNode != null) { |
||||
return memberNode.Member; |
||||
} else { |
||||
ClassMemberBookmark mbookmark = caller as ClassMemberBookmark; |
||||
if (mbookmark != null) { |
||||
return mbookmark.Member; |
||||
} |
||||
} |
||||
return null; |
||||
} |
||||
|
||||
public static IClass GetClass(object caller) |
||||
{ |
||||
ClassNode classNode = caller as ClassNode; |
||||
if (classNode != null) { |
||||
return classNode.Class; |
||||
} else { |
||||
ClassBookmark bookmark = caller as ClassBookmark; |
||||
if (bookmark != null) { |
||||
return bookmark.Class; |
||||
} |
||||
} |
||||
return null; |
||||
} |
||||
|
||||
public bool IsValid(object caller, Condition condition) |
||||
{ |
||||
IMember m = GetMember(caller); |
||||
IClass c = (m != null) ? m.DeclaringType : GetClass(caller); |
||||
StringComparer nameComparer = c.ProjectContent.Language.NameComparer; |
||||
string attributeName = (m != null) ? "Test" : "TestFixture"; |
||||
foreach (IAttribute attribute in (m ?? (IDecoration)c).Attributes) { |
||||
if (nameComparer.Equals(attribute.Name, attributeName) |
||||
|| nameComparer.Equals(attribute.Name, attributeName + "Attribute")) |
||||
{ |
||||
return true; |
||||
} |
||||
} |
||||
return false; |
||||
} |
||||
} |
||||
} |
Loading…
Reference in new issue