public ItemCheckResult CheckItem(ParseItem item, ICssCheckerContext context) { if (!WESettings.Instance.Css.ValidateDuplicateSelectors) { return(ItemCheckResult.Continue); } RuleSet rule = (RuleSet)item; if (!rule.IsValid || context == null) { return(ItemCheckResult.Continue); } List <RuleResult> cache = context.GetState(this) as List <RuleResult>; if (cache == null || (cache.Count > 0 && cache[0].Rule.Parent != rule.Parent)) { cache = BuildCache(rule); context.SetState(this, cache); } string ruleText = GetSelectorText(rule); int start = rule.Start; RuleResult dupe = null; for (int i = 0; i < cache.Count; i++) { if (cache[i].Start >= start) { break; } if (ruleText == cache[i].Value) { dupe = cache[i]; break; } } if (dupe != null) { SelectorErrorTag tag = new SelectorErrorTag(rule.Selectors, "The selector " + ruleText + " is already specified earlier. Consider combining the two rule-sets."); context.AddError(tag); } return(ItemCheckResult.Continue); }
public ItemCheckResult CheckItem(ParseItem item, ICssCheckerContext context) { RuleSet rule = (RuleSet)item; if (!rule.IsValid || context == null) { return(ItemCheckResult.Continue); } List <RuleResult> cache = context.GetState(this) as List <RuleResult>; if (cache == null || (cache.Count > 0 && cache[0].Rule.Parent != rule.Parent)) { cache = BuildCache(rule); context.SetState(this, cache); } string ruleText = GetSelectorText(rule); int start = rule.Start; RuleResult dupe = null; for (int i = 0; i < cache.Count; i++) { if (cache[i].Start >= start) { break; } if (ruleText == cache[i].Value) { dupe = cache[i]; break; } } if (dupe != null) { int length = GetSelectorLength(rule); int lineNo = FindLineNumber(dupe); string errorMessage = string.Format(CultureInfo.InvariantCulture, Resources.BestPracticeDuplicateSelectors, lineNo); SelectorErrorTag tag = new SelectorErrorTag(rule.Selectors, errorMessage); context.AddError(tag); } return(ItemCheckResult.Continue); }
public ItemCheckResult CheckItem(ParseItem item, ICssCheckerContext context) { RuleSet rule = (RuleSet)item; if (!rule.IsValid || context == null) { return(ItemCheckResult.Continue); } List <RuleResult> cache = context.GetState(this) as List <RuleResult>; if (cache == null || (cache.Count > 0 && cache[0].Rule.Parent != rule.Parent)) { cache = BuildCache(rule); context.SetState(this, cache); } string ruleText = GetSelectorText(rule); int start = rule.Start; RuleResult dupe = null; for (int i = 0; i < cache.Count; i++) { if (cache[i].Start >= start) { break; } if (ruleText == cache[i].Value) { dupe = cache[i]; break; } } if (dupe != null) { SelectorErrorTag tag = new SelectorErrorTag(rule.Selectors); context.AddError(tag); } return(ItemCheckResult.Continue); }
public ItemCheckResult CheckItem(ParseItem item, ICssCheckerContext context) { RuleSet rule = (RuleSet)item; if (!rule.IsValid || context == null) return ItemCheckResult.Continue; List<RuleResult> cache = context.GetState(this) as List<RuleResult>; if (cache == null || (cache.Count > 0 && cache[0].Rule.Parent != rule.Parent)) { cache = BuildCache(rule); context.SetState(this, cache); } string ruleText = GetSelectorText(rule); int start = rule.Start; RuleResult dupe = null; for (int i = 0; i < cache.Count; i++) { if (cache[i].Start >= start) break; if (ruleText == cache[i].Value) { dupe = cache[i]; break; } } if (dupe != null) { int lineNo = FindLineNumber(dupe); string errorMessage = string.Format(CultureInfo.InvariantCulture, Resources.BestPracticeDuplicateSelectors, lineNo); SelectorErrorTag tag = new SelectorErrorTag(rule.Selectors, errorMessage); context.AddError(tag); } return ItemCheckResult.Continue; }
public ItemCheckResult CheckItem(ParseItem item, ICssCheckerContext context) { if (!WESettings.Instance.Css.ValidateDuplicateSelectors) return ItemCheckResult.Continue; RuleSet rule = (RuleSet)item; if (!rule.IsValid || context == null) return ItemCheckResult.Continue; List<RuleResult> cache = context.GetState(this) as List<RuleResult>; if (cache == null || (cache.Count > 0 && cache[0].Rule.Parent != rule.Parent)) { cache = BuildCache(rule); context.SetState(this, cache); } string ruleText = GetSelectorText(rule); int start = rule.Start; RuleResult dupe = null; for (int i = 0; i < cache.Count; i++) { if (cache[i].Start >= start) break; if (ruleText == cache[i].Value && rule.Parent == cache[i].Rule.Parent) { dupe = cache[i]; break; } } if (dupe != null) { SelectorErrorTag tag = new SelectorErrorTag(rule.Selectors, "The selector " + ruleText + " is already specified earlier. Consider combining the two rule-sets."); context.AddError(tag); } return ItemCheckResult.Continue; }
public ItemCheckResult CheckItem(ParseItem item, ICssCheckerContext context) { RuleSet rule = (RuleSet)item; if (!rule.IsValid || context == null) return ItemCheckResult.Continue; List<RuleResult> cache = context.GetState(this) as List<RuleResult>; if (cache == null || (cache.Count > 0 && cache[0].Rule.Parent != rule.Parent)) { cache = BuildCache(rule); context.SetState(this, cache); } string ruleText = GetSelectorText(rule); int start = rule.Start; RuleResult dupe = null; for (int i = 0; i < cache.Count; i++) { if (cache[i].Start >= start) break; if (ruleText == cache[i].Value) { dupe = cache[i]; break; } } if (dupe != null) { SelectorErrorTag tag = new SelectorErrorTag(rule.Selectors); context.AddError(tag); } return ItemCheckResult.Continue; }