Skip to content

Commit

Permalink
Fixed double-placed icons in runner
Browse files Browse the repository at this point in the history
  • Loading branch information
hhariri committed Jul 15, 2011
1 parent 7b73ea5 commit a13f83c
Show file tree
Hide file tree
Showing 5 changed files with 29 additions and 37 deletions.
Original file line number Diff line number Diff line change
@@ -1,9 +1,11 @@
using System;
using System.Collections.Generic;
using System.Collections.ObjectModel;
using System.Linq;

using JetBrains.Metadata.Reader.API;
using JetBrains.ReSharper.Psi;
using JetBrains.Util;

namespace Machine.Specifications.ReSharperRunner
{
Expand Down Expand Up @@ -40,10 +42,7 @@ public static IEnumerable<IMetadataField> GetBehaviors(this IMetadataTypeInfo ty
IEnumerable<IMetadataField> behaviorFields = type.GetPrivateFieldsWith(typeof(Behaves_like<>));
foreach (IMetadataField field in behaviorFields)
{
if (field.GetFirstGenericArgument().HasCustomAttribute(typeof(BehaviorsAttribute).FullName)
#if !RESHARPER_5
&& field.GetFirstGenericArgument().GenericParameters.Length == 0
#endif
if (field.GetFirstGenericArgument().HasCustomAttribute(typeof(BehaviorsAttribute).FullName) && field.GetFirstGenericArgument().GenericParameters.Length == 0
)
{
yield return field;
Expand Down Expand Up @@ -77,17 +76,18 @@ public static string GetSubjectString(this IMetadataEntity type)
}

public static ICollection<string> GetTags(this IMetadataEntity type)
{
return type.AndAllBaseTypes()
.SelectMany(x => x.GetCustomAttributes(typeof(TagsAttribute).FullName))
.Select(x => x.ConstructorArguments)
.Flatten(tag => tag.FirstOrDefault().Value as string,
tag => tag.Skip(1).FirstOrDefault().Value as IEnumerable<string>)
.Distinct()
.ToList();
{

return type.AndAllBaseTypes()
.SelectMany(x => x.GetCustomAttributes(typeof(TagsAttribute).FullName))
.Select(x => x.ConstructorArguments)
.Flatten(tag => tag.FirstOrDefault().Value as string,
tag => tag.Skip(1).FirstOrDefault().Value as IEnumerable<string>)
.Distinct()
.ToList();
}

static IEnumerable<IMetadataTypeInfo> AndAllBaseTypes(this IMetadataEntity type)
static IEnumerable<IMetadataTypeInfo> AndAllBaseTypes(this IMetadataEntity type)
{
var typeInfo = type as IMetadataTypeInfo;
if (typeInfo == null)
Expand Down Expand Up @@ -129,11 +129,10 @@ static IEnumerable<TResult> Flatten<TSource, TResult>(this IEnumerable<TSource>
foreach (var s in source)
{
yield return singleResultSelector(s);

foreach (var coll in collectionResultSelector(s))
{
yield return coll;
}
foreach (var coll in collectionResultSelector(s))
{
yield return coll;
}
}
}

Expand Down
Original file line number Diff line number Diff line change
@@ -1,5 +1,4 @@
using System.Collections.Generic;

using JetBrains.ProjectModel;
using JetBrains.ReSharper.UnitTestFramework;

Expand All @@ -20,6 +19,7 @@ public ContextSpecificationElement(MSpecUnitTestProvider provider,
bool isIgnored)
: base(provider, context, project, declaringTypeName, fieldName, isIgnored || context.Explicit)
{

if (tags != null)
{
_categories = UnitTestElementCategory.Create(tags);
Expand All @@ -33,7 +33,8 @@ public ContextElement Context

public override string Kind
{
get { return "Specification"; }

get { return "Specification"; }
}

public override IEnumerable<UnitTestElementCategory> Categories
Expand Down
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
using System;
using System.Collections.Generic;
using System.Diagnostics;
using System.Linq;

using JetBrains.Application;
Expand Down Expand Up @@ -65,7 +66,10 @@ protected Element(MSpecUnitTestProvider provider,

public string Id
{
get { return TypeName; }
get
{
return TypeName;
}
}

public IUnitTestProvider Provider
Expand Down
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
using System;
using System.Diagnostics;
using System.Linq;

using JetBrains.ProjectModel;
Expand All @@ -21,6 +22,7 @@ protected FieldElement(MSpecUnitTestProvider provider,
bool isIgnored)
: base(provider, parent, projectEnvoy, declaringTypeName, isIgnored || parent.Explicit)
{

_fieldName = fieldName;
}

Expand Down
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
using System.Drawing;
using System;
using System.Drawing;

using JetBrains.CommonControls;
using JetBrains.ReSharper.Features.Common.TreePsiBrowser;
Expand Down Expand Up @@ -57,7 +58,6 @@ static void PresentItem(IPresentableItem item, Element element, PresentationStat
item.RichText = element.GetPresentation();

SetTextColor(item, element);
SetImage(item, state, type);
}

static void SetTextColor(IPresentableItem item, Element element)
Expand All @@ -70,20 +70,6 @@ static void SetTextColor(IPresentableItem item, Element element)
item.RichText.SetForeColor(SystemColors.GrayText, 0, element.GetTitlePrefix().Length);
}

static void SetImage(IPresentableItem item, PresentationState state, UnitTestElementImage imageType)
{
Image stateImage = UnitTestIconManager.GetStateImage(state);
Image typeImage = UnitTestIconManager.GetStandardImage(imageType);

if (stateImage != null)
{
item.Images.Add(stateImage);
}
else if (typeImage != null)
{
item.Images.Add(typeImage);
}
}

protected override bool IsNaturalParent(object parentValue, object childValue)
{
Expand Down

0 comments on commit a13f83c

Please sign in to comment.