コード例 #1
0
ファイル: NancyUtil.cs プロジェクト: pil0t/Nancy.ReSharper
        private static ISearchDomain GetSearchDomain(IPsiModule module, IModuleReferenceResolveContext context)
        {
            IPsiServices  psiServices  = module.GetPsiServices();
            ISearchDomain searchDomain = psiServices.SearchDomainFactory.CreateSearchDomain(
                module.GetPsiServices().Modules.GetModules()
                .Where(m => m.References(module, context) || module.References(m, context))
                .Prepend(module));

            return(searchDomain);
        }
コード例 #2
0
        public IEnumerable <AvailableBindingClass> GetBindingTypes(IPsiModule module)
        {
            foreach (var(fullClassName, sourceFile) in _mergeData.SpecflowBindingTypes.SelectMany(e => e.Value.Select(v => (fullClassName: e.Key, sourceFile: v))))
            {
                if (!module.Equals(sourceFile.PsiModule) && !module.References(sourceFile.PsiModule))
                {
                    continue;
                }
                yield return(new AvailableBindingClass(sourceFile, fullClassName));
            }

            // Since we cannot know when cache are built if a partial class in a given file has an attribute or not.
            // This is due to the fact that `DeclaredElement` are resolved using cache and we cannot depends ond cache when building a cache.
            // The check need to be done at this time.
            foreach (var(fullClassName, sourceFile) in _mergeData.PotentialSpecflowBindingTypes.SelectMany(e => e.Value.Select(v => (fullClassName: e.Key, sourceFile: v))))
            {
                if (!module.Equals(sourceFile.PsiModule) && !module.References(sourceFile.PsiModule))
                {
                    continue;
                }
                var type = CSharpTypeFactory.CreateType(fullClassName, sourceFile.PsiModule);
                if (!(type is DeclaredTypeFromCLRName declaredTypeFromClrName))
                {
                    continue;
                }
                var resolveResult = declaredTypeFromClrName.Resolve();
                if (!resolveResult.IsValid())
                {
                    continue;
                }
                if (!(resolveResult.DeclaredElement is IClass @class))
                {
                    continue;
                }
                if (@class.GetAttributeInstances(AttributesSource.Self).All(x => x.GetAttributeType().GetClrName().FullName != "TechTalk.SpecFlow.BindingAttribute"))
                {
                    continue;
                }
                yield return(new AvailableBindingClass(sourceFile, fullClassName));
            }
        }
コード例 #3
0
 public IEnumerable <SpecflowStepInfo> GetStepAccessibleForModule(IPsiModule module, GherkinStepKind stepKind)
 {
     foreach (var(stepSourceFile, stepDefinitions) in _mergeData.StepsDefinitionsPerFiles)
     {
         if (!ReferenceEquals(module, stepSourceFile.PsiModule) && !module.References(stepSourceFile.PsiModule))
         {
             continue;
         }
         foreach (var stepDefinitionInfo in stepDefinitions.Where(s => s.StepKind == stepKind))
         {
             yield return(stepDefinitionInfo);
         }
     }
 }