public static IEnumerable<string> GetSelectorNames(RuleSet ruleSet, ScssMixinAction mixinAction)
        {
            if (ruleSet.Block.Directives.Any(d => d is ScssMixinDirective))
            {
                switch (mixinAction)
                {
                    case ScssMixinAction.Skip:
                        return Enumerable.Empty<string>();
                    case ScssMixinAction.Literal:
                        break;
                }
            }

            var parentBlock = ruleSet.FindType<ScssRuleBlock>();

            if (parentBlock == null)
                return ruleSet.Selectors.Select(CssExtensions.SelectorText);

            var parentSet = parentBlock.FindType<RuleSet>();

            if (parentSet == null)
                return ruleSet.Selectors.Select(CssExtensions.SelectorText);

            // Cache the computed parents to avoid re-computing them
            // for every child permutation.
            var parentSelectors = GetSelectorNames(parentSet, mixinAction).ToList();

            return ruleSet.Selectors.SelectMany(child =>
                CombineSelectors(parentSelectors, child.SelectorText())
            );
        }
        public static IEnumerable<string> GetSelectorNames(RuleSet ruleSet, ScssMixinAction mixinAction)
        {
            if (ruleSet.Selectors.Any(s => s.SimpleSelectors.Any(ss => ss.SubSelectors.Any(sss => sss is ScssMixinDeclaration))))
            {
                switch (mixinAction)
                {
                    case ScssMixinAction.Skip:
                        return Enumerable.Empty<string>();
                    case ScssMixinAction.Literal:
                        break;
                    case ScssMixinAction.NestedOnly:
                        var mixinDecl = ruleSet.Selectors.SelectMany(s => s.SimpleSelectors.SelectMany(ss => ss.SubSelectors.OfType<ScssMixinDeclaration>())).First();
                        return Enumerable.Repeat("«mixin " + mixinDecl.MixinName.Name + "»", 1);
                }
            }

            var parentBlock = ruleSet.FindType<ScssRuleBlock>();

            if (parentBlock == null)
                return ruleSet.Selectors.Select(CssExtensions.SelectorText);

            var parentSet = parentBlock.FindType<RuleSet>();

            if (parentSet == null)
                return ruleSet.Selectors.Select(CssExtensions.SelectorText);

            // Cache the computed parents to avoid re-computing them
            // for every child permutation.
            var parentSelectors = GetSelectorNames(parentSet, mixinAction).ToList();

            return ruleSet.Selectors.SelectMany(child =>
                CombineSelectors(parentSelectors, child.SelectorText())
            );
        }
Exemple #3
0
        public static IEnumerable <string> GetSelectorNames(RuleSet ruleSet, ScssMixinAction mixinAction)
        {
            if (ruleSet.Block.Directives.Any(d => d is ScssMixinDirective))
            {
                switch (mixinAction)
                {
                case ScssMixinAction.Skip:
                    return(Enumerable.Empty <string>());

                case ScssMixinAction.Literal:
                    break;
                }
            }

            var parentBlock = ruleSet.FindType <ScssRuleBlock>();

            if (parentBlock == null)
            {
                return(ruleSet.Selectors.Select(CssExtensions.SelectorText));
            }

            var parentSet = parentBlock.FindType <RuleSet>();

            if (parentSet == null)
            {
                return(ruleSet.Selectors.Select(CssExtensions.SelectorText));
            }

            // Cache the computed parents to avoid re-computing them
            // for every child permutation.
            var parentSelectors = GetSelectorNames(parentSet, mixinAction).ToList();

            return(ruleSet.Selectors.SelectMany(child =>
                                                CombineSelectors(parentSelectors, child.SelectorText())
                                                ));
        }