protected override void AddStub(ICSharpArgument cSharpArgument, IArgumentsOwner reference, string recommendedName) { var referenceExpression = cSharpArgument.Value as IReferenceExpression; var anchor = reference.GetContainingNode<IBlock>(); var containingMethod = anchor.Parent as IMethodDeclaration; if (containingMethod == null) return; if (!containingMethod.Attributes.Select(x => x.Name.QualifiedName).Any(x => x == "SetUp" || x == "Test" || x == "TestCase")) return; var addStub = new AddRhinoStub(recommendedName, referenceExpression, anchor); addStub.Execute(); }
protected override void AddStub(ICSharpArgument cSharpArgument, IArgumentsOwner reference, string recommendedName) { var referenceExpression = cSharpArgument.Value as IReferenceExpression; var anchor = reference.GetContainingNode <IBlock>(); var containingMethod = anchor.Parent as IMethodDeclaration; if (containingMethod == null) { return; } if (!containingMethod.Attributes.Select(x => x.Name.QualifiedName).Any(x => x == "SetUp" || x == "Test" || x == "TestCase")) { return; } var addStub = new AddRhinoStub(recommendedName, referenceExpression, anchor); addStub.Execute(); }
private static ICollection <JetTuple <string, string, MvcUtil.DeterminationKind, ICollection <IClass> > > GetModulesNotCached([NotNull] IArgumentsOwner argumentsOwner) { argumentsOwner.AssertIsValid("argumentsOwner is invalid"); IPsiModule psiModule = argumentsOwner.GetPsiModule(); IProject project = argumentsOwner.GetProject(); Assertion.AssertNotNull(project, "project == null"); IProjectFile projectFile = argumentsOwner.GetSourceFile().ToProjectFile(); Assertion.AssertNotNull(projectFile, "projectFile == null"); IList <string> controllerNames = ProcessArgumentsExpression(argumentsOwner, MvcKind.Controller); ICollection <JetTuple <string, string, MvcUtil.DeterminationKind, bool> > moduleNames = new List <JetTuple <string, string, MvcUtil.DeterminationKind, bool> >(); if (controllerNames.IsEmpty()) { // first, try detect implicit controller type by view var typeDeclaration = argumentsOwner.GetContainingNode <ITypeDeclaration>(); IClass declaredElement = (typeDeclaration != null) ? typeDeclaration.DeclaredElement as IClass : null; if (declaredElement == null) { return(EmptyList <JetTuple <string, string, MvcUtil.DeterminationKind, ICollection <IClass> > > .InstanceList); } JetTuple <string, string, MvcUtil.DeterminationKind, ICollection <IClass> > @default = JetTuple.Of(GetControllerArea(declaredElement), GetControllerName(declaredElement), MvcUtil.DeterminationKind.ImplicitByContainingMember, (ICollection <IClass>) new IClass[] { null }); // with inheritors if (declaredElement.IsAbstract) { // with inheritors return(GetAvailableModules(psiModule, argumentsOwner.GetResolveContext(), baseClass: declaredElement) .SelectMany(_ => _.Value) .GroupBy( @class => new { area = GetControllerArea(@class), controller = GetControllerName(@class) }) .Select(_ => JetTuple.Of(_.Key.area, _.Key.controller, MvcUtil.DeterminationKind.ImplicitByContainingMember, (ICollection <IClass>)_.ToList())) .DefaultIfEmpty(@default) .ToList()); } moduleNames = new[] { JetTuple.Of(@default.A, @default.B, MvcUtil.DeterminationKind.ImplicitByContainingMember, true) }; } return((from tuple in moduleNames let availableModules = GetAvailableModules(psiModule, argumentsOwner.GetResolveContext(), includingIntermediateControllers: tuple.D) select JetTuple.Of(tuple.A, tuple.B, tuple.C, tuple.B == null ? (ICollection <IClass>) new IClass[] { null } : availableModules.GetValuesCollection(tuple.B))) .ToList()); }