public ItemCheckResult CheckItem(ParseItem item, ICssCheckerContext context)
        {
            if (item.Text.TrimStart(':').StartsWith("-"))
            {
                return(ItemCheckResult.Continue);
            }

            ParseItem next = item.NextSibling;
            //ParseItem prev = item.PreviousSibling;
            SimpleSelector sel = item.FindType <SimpleSelector>();

            //if (item.Text == ":hover" && prev != null && _invalids.Contains(prev.Text))
            //{
            //    string error = string.Format(Resources.ValidationHoverOrder, prev.Text);
            //    context.AddError(new SimpleErrorTag(item, error, CssErrorFlags.TaskListError | CssErrorFlags.UnderlineRed));
            //}

            if (next != null)
            {
                if (next.Text.StartsWith(":") && item.IsPseudoElement() && !next.IsPseudoElement())
                {
                    string error = string.Format(Resources.ValidationPseudoOrder, item.Text, next.Text);
                    context.AddError(new SimpleErrorTag(item, error, CssErrorFlags.TaskListError | CssErrorFlags.UnderlineRed));
                }

                else if (!next.Text.StartsWith(":") && item.AfterEnd == next.Start)
                {
                    string error = string.Format(Resources.BestPracticePseudosAfterOtherSelectors, next.Text);
                    context.AddError(new SimpleErrorTag(next, error));
                }
            }

            return(ItemCheckResult.Continue);
        }
Beispiel #2
0
        public ItemCheckResult CheckItem(ParseItem item, ICssCheckerContext context)
        {
            if (item.Text.TrimStart(':').StartsWith("-", StringComparison.Ordinal))
            {
                return(ItemCheckResult.Continue);
            }

            ParseItem next = item.NextSibling;

            if (next != null)
            {
                if (next.Text.StartsWith(":", StringComparison.Ordinal) && item.IsPseudoElement() && !next.IsPseudoElement())
                {
                    string error = string.Format(CultureInfo.CurrentCulture, Resources.ValidationPseudoOrder, item.Text, next.Text);
                    context.AddError(new SimpleErrorTag(item, error, CssErrorFlags.TaskListError | CssErrorFlags.UnderlineRed));
                }
                else if (!next.Text.StartsWith(":", StringComparison.Ordinal) && item.AfterEnd == next.Start)
                {
                    string error = string.Format(CultureInfo.CurrentCulture, Resources.BestPracticePseudosAfterOtherSelectors, next.Text);
                    context.AddError(new SimpleErrorTag(next, error));
                }
            }

            return(ItemCheckResult.Continue);
        }
        public ItemCheckResult CheckItem(ParseItem item, ICssCheckerContext context)
        {
            if (item.Text.TrimStart(':').StartsWith("-"))
                return ItemCheckResult.Continue;

            ParseItem next = item.NextSibling;
            //ParseItem prev = item.PreviousSibling;
            SimpleSelector sel = item.FindType<SimpleSelector>();

            //if (item.Text == ":hover" && prev != null && _invalids.Contains(prev.Text))
            //{
            //    string error = string.Format(Resources.ValidationHoverOrder, prev.Text);
            //    context.AddError(new SimpleErrorTag(item, error, CssErrorFlags.TaskListError | CssErrorFlags.UnderlineRed));
            //}

            if (next != null)
            {
                if (next.Text.StartsWith(":") && item.IsPseudoElement() && !next.IsPseudoElement())
                {
                    string error = string.Format(Resources.ValidationPseudoOrder, item.Text, next.Text);
                    context.AddError(new SimpleErrorTag(item, error, CssErrorFlags.TaskListError | CssErrorFlags.UnderlineRed));
                }

                else if (!next.Text.StartsWith(":") && item.AfterEnd == next.Start)
                {
                    string error = string.Format(Resources.BestPracticePseudosAfterOtherSelectors, next.Text);
                    context.AddError(new SimpleErrorTag(next, error));
                }
            }

            return ItemCheckResult.Continue;
        }
		public ItemCheckResult CheckItem(ParseItem item, ICssCheckerContext context)
		{
			if (item.Text.TrimStart(':').StartsWith("-", StringComparison.Ordinal))
				return ItemCheckResult.Continue;

			ParseItem next = item.NextSibling;
			if (next != null)
			{
				if (next.Text.StartsWith(":", StringComparison.Ordinal) && item.IsPseudoElement() && !next.IsPseudoElement())
				{
					string error = string.Format(CultureInfo.CurrentCulture, Resources.ValidationPseudoOrder, item.Text, next.Text);
					context.AddError(new SimpleErrorTag(item, error, CssErrorFlags.TaskListError | CssErrorFlags.UnderlineRed));
				}
				else if (!next.Text.StartsWith(":", StringComparison.Ordinal) && item.AfterEnd == next.Start)
				{
					string error = string.Format(CultureInfo.CurrentCulture, Resources.BestPracticePseudosAfterOtherSelectors, next.Text);
					context.AddError(new SimpleErrorTag(next, error));
				}
			}

			return ItemCheckResult.Continue;
		}