Ejemplo n.º 1
0
        public override object Build(IPsiSourceFile sourceFile, bool isStartup)
        {
            var file = sourceFile.GetPrimaryPsiFile().NotNull();

            if (!file.Language.Is <CSharpLanguage>())
            {
                return(null);
            }

            var stepDefinitions = new SpecflowStepsDefinitionsCacheEntries();

            foreach (var type in GetTypeDeclarations(file))
            {
                if (!(type is IClassDeclaration classDeclaration))
                {
                    continue;
                }
                var hasSpecflowBindingAttribute = HasSpecflowBindingAttribute(classDeclaration);
                if (!hasSpecflowBindingAttribute && !classDeclaration.IsPartial)
                {
                    continue;
                }
                stepDefinitions.Add(BuildBindingClassCacheEntry(classDeclaration, hasSpecflowBindingAttribute));
            }

            return(stepDefinitions);
        }
Ejemplo n.º 2
0
 // Note that some searchers (such as ReferenceSearchProcessorBase) will filter by word index before calling this.
 // Words come from IDomainSpecificSearcherFactory.GetAllPossibleWordsInFile
 public bool ProcessProjectItem <TResult>(IPsiSourceFile sourceFile, IFindResultConsumer <TResult> consumer)
 {
     if (sourceFile.GetPrimaryPsiFile() is IYamlFile yamlFile)
     {
         return(ProcessElement(yamlFile, consumer));
     }
     return(false);
 }
Ejemplo n.º 3
0
 public bool ProcessProjectItem <TResult>(IPsiSourceFile sourceFile, IFindResultConsumer <TResult> consumer)
 {
     if (!(sourceFile.GetPrimaryPsiFile() is ShaderLabFile shaderLabFile))
     {
         return(false);
     }
     return(ProcessElement(shaderLabFile, consumer));
 }
Ejemplo n.º 4
0
        public override object Build(IPsiSourceFile sourceFile, bool isStartup)
        {
            var file = sourceFile.GetPrimaryPsiFile().NotNull();

            if (!file.Language.Is <CSharpLanguage>())
            {
                return(null);
            }
            if (!(file is ICSharpFile cSharpFile))
            {
                return(null);
            }
            if (!cSharpFile.Imports.Any(x => x.ImportedSymbolName.QualifiedName == "TechTalk.SpecFlow"))
            {
                return(null);
            }

            var stepDefinitions = new SpecflowStepsDefinitionsCacheEntries();

            foreach (var type in GetTypeDeclarations(file))
            {
                if (!(type is IClassDeclaration classDeclaration))
                {
                    continue;
                }
                if (classDeclaration.Attributes.Count == 0)
                {
                    continue;
                }

                // Optimization: do not resolve all attribute. We are looking for `TechTalk.SpecFlow.BindingAttribute` only
                var potentialBindingAttributes = classDeclaration.Attributes.Where(x => x.Arguments.Count == 0).ToList();
                if (potentialBindingAttributes.Count == 0)
                {
                    continue;
                }

                var bindingAttributeFound = false;
                foreach (var potentialBindingAttribute in potentialBindingAttributes.Select(x => x.GetAttributeInstance()))
                {
                    if (potentialBindingAttribute.GetClrName().FullName == "TechTalk.SpecFlow.BindingAttribute")
                    {
                        bindingAttributeFound = true;
                    }
                }
                if (bindingAttributeFound)
                {
                    stepDefinitions.Add(BuildBindingClassCacheEntry(classDeclaration));
                }
            }

            return(stepDefinitions);
        }
Ejemplo n.º 5
0
        public bool Navigate(ISolution solution, PopupWindowContextSource windowContext, bool transferFocus,
                             TabOptions tabOptions = TabOptions.Default)
        {
            var psiFile = mySourceFile.GetPrimaryPsiFile();

            if (psiFile == null || !psiFile.Language.Is <JsonLanguage>())
            {
                return(false);
            }

            var range = TextRange.FromLength(myNavigationTreeOffset, myName.Length);

            return(mySourceFile.Navigate(range, transferFocus, tabOptions, windowContext));
        }
Ejemplo n.º 6
0
        private LinkedNamesData GetLinkData(IPsiSourceFile sourceFile)
        {
            var linkedNamesData = new LinkedNamesData();

            foreach (var sourceType in GetTypeDeclarations(sourceFile.GetPrimaryPsiFile().NotNull()))
            {
                for (var i = 0; i < _linkedTypesProviders.Count; i++)
                {
                    var linkedNames = _linkedTypesProviders[i].GetLinkedNames(sourceType);
                    foreach (var x in linkedNames)
                    {
                        linkedNamesData.Add(sourceType.DeclaredName, x);
                    }
                }
            }

            return(linkedNamesData);
        }
        public override object Build(IPsiSourceFile sourceFile, bool isStartup)
        {
            var file = sourceFile.GetPrimaryPsiFile().NotNull();

            if (!file.Language.Is <GherkinLanguage>())
            {
                return(null);
            }
            if (!(file is GherkinFile gherkinFile))
            {
                return(null);
            }

            var stepUsages = new SpecflowStepsUsagesCacheEntries();
            var steps      = gherkinFile.GetChildrenInSubtrees <GherkinStep>();

            stepUsages.AddRange(steps.Select(step => new SpecflowStepUsageCacheEntry(step.GetStepKind(), step.GetStepText())));
            return(stepUsages);
        }
        public IList <IDeclaration> GetDeclarations()
        {
            if (!(mySourceFile.GetPrimaryPsiFile() is IShaderLabFile psi))
            {
                return(EmptyList <IDeclaration> .InstanceList);
            }

            var node = psi.FindNodeAt(TreeTextRange.FromLength(new TreeOffset(TreeOffset), 1));

            while (node != null && !(node is IDeclaration))
            {
                node = node.Parent;
            }
            if (node == null)
            {
                return(EmptyList <IDeclaration> .Instance);
            }

            return(new[] { (IDeclaration)node });
        }