public static IEnumerable<string> GetSelectorNames(RuleSet ruleSet, LessMixinAction mixinAction) { if (ruleSet.Selectors.Any(s => s.SimpleSelectors.Any(ss => ss.SubSelectors.Any(sss => sss is LessMixinDeclaration)))) { switch (mixinAction) { case LessMixinAction.Skip: return Enumerable.Empty<string>(); case LessMixinAction.Literal: break; case LessMixinAction.NestedOnly: var mixinDecl = ruleSet.Selectors.SelectMany(s => s.SimpleSelectors.SelectMany(ss => ss.SubSelectors.OfType<LessMixinDeclaration>())).First(); return Enumerable.Repeat("«mixin " + mixinDecl.MixinName.Name + "»", 1); } } var parentBlock = ruleSet.FindType<LessRuleBlock>(); 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, LessMixinAction mixinAction) { if (ruleSet.Selectors.Any(s => s.SimpleSelectors.Any(ss => ss.SubSelectors.Any(sss => sss is LessMixinDeclaration)))) { switch (mixinAction) { case LessMixinAction.Skip: return(Enumerable.Empty <string>()); case LessMixinAction.Literal: break; case LessMixinAction.NestedOnly: var mixinDecl = ruleSet.Selectors.SelectMany(s => s.SimpleSelectors.SelectMany(ss => ss.SubSelectors.OfType <LessMixinDeclaration>())).First(); return(Enumerable.Repeat("«mixin " + mixinDecl.MixinName.Name + "»", 1)); } } var parentBlock = ruleSet.FindType <LessRuleBlock>(); 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()) )); }