本文整理汇总了C#中ParseItem类的典型用法代码示例。如果您正苦于以下问题:C# ParseItem类的具体用法?C# ParseItem怎么用?C# ParseItem使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。
ParseItem类属于命名空间,在下文中一共展示了ParseItem类的20个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于我们的系统推荐出更棒的C#代码示例。
示例1: SimpleErrorTag
public SimpleErrorTag(ParseItem item, string errorMessage, int length, CssErrorFlags flags)
{
Item = item;
Text = errorMessage;
Length = length;
Flags = flags;
}
开发者ID:venux,项目名称:WebEssentials2015,代码行数:7,代码来源:SimpleErrorTag.cs
示例2: SimpleErrorTag
public SimpleErrorTag(ParseItem item, string errorMessage, int length)
{
_item = item;
_errorMessage = errorMessage;
_length = length;
Flags = GetLocation();
}
开发者ID:joeriks,项目名称:WebEssentials2013,代码行数:7,代码来源:SimpleErrorTag.cs
示例3: CheckItem
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;
}
开发者ID:joeriks,项目名称:WebEssentials2013,代码行数:32,代码来源:HoverOrderErrorTagProvider.cs
示例4: GetCompletionContext
public CssCompletionContext GetCompletionContext(ParseItem item, int position)
{
if (item.FindType<AttributeSelector>() != null)
return null;
return new CssCompletionContext((CssCompletionContextType)601, item.Start, item.Length, null);
}
开发者ID:kodybrown,项目名称:WebEssentials2013,代码行数:7,代码来源:TagContextProvider.cs
示例5: CheckItem
public ItemCheckResult CheckItem(ParseItem item, ICssCheckerContext context)
{
UrlItem url = (UrlItem)item;
if (!WESettings.GetBoolean(WESettings.Keys.ValidateEmbedImages) || !url.IsValid || url.UrlString.Text.Contains("base64,") || context == null)
return ItemCheckResult.Continue;
string fileName = ImageQuickInfo.GetFullUrl(url.UrlString.Text, EditorExtensionsPackage.DTE.ActiveDocument.FullName);
if (string.IsNullOrEmpty(fileName) || fileName.Contains("://"))
return ItemCheckResult.Continue;
FileInfo file = new FileInfo(fileName);
if (file.Exists && file.Length < (1024 * 3))
{
Declaration dec = url.FindType<Declaration>();
if (dec != null && dec.PropertyName != null && dec.PropertyName.Text[0] != '*' && dec.PropertyName.Text[0] != '_')
{
string error = string.Format(Resources.PerformanceEmbedImageAsDataUri, file.Length);
context.AddError(new SimpleErrorTag(url.UrlString, error));
}
}
return ItemCheckResult.Continue;
}
开发者ID:Russe11,项目名称:WebEssentials2013,代码行数:25,代码来源:EmbedImagesErrorTagProvider.cs
示例6: CheckItem
public ItemCheckResult CheckItem(ParseItem item, ICssCheckerContext context)
{
if (!WESettings.GetBoolean(WESettings.Keys.ValidateZeroUnit))
return ItemCheckResult.Continue;
NumericalValue number = (NumericalValue)item;
UnitValue unit = number as UnitValue;
if (unit == null || context == null)
return ItemCheckResult.Continue;
// The 2nd and 3rd arguments to hsl() require units even when zero
var function = unit.Parent.Parent as FunctionColor;
if (function != null && function.FunctionName.Text.StartsWith("hsl", StringComparison.OrdinalIgnoreCase)) {
var arg = unit.Parent as FunctionArgument;
if (arg != function.Arguments[0])
return ItemCheckResult.Continue;
}
if (number.Number.Text == "0" && unit.UnitType != UnitType.Unknown && unit.UnitType != UnitType.Time)
{
string message = string.Format(Resources.BestPracticeZeroUnit, unit.UnitToken.Text);
context.AddError(new SimpleErrorTag(number, message));
}
return ItemCheckResult.Continue;
}
开发者ID:ncl-dmoreira,项目名称:WebEssentials2013,代码行数:27,代码来源:ZeroUnitErrorTagProvider.cs
示例7: GetSmartTagActions
public IEnumerable<ISmartTagAction> GetSmartTagActions(ParseItem item, int position, ITrackingSpan itemTrackingSpan, ITextView view)
{
HexColorValue hex = (HexColorValue)item;
if (!item.IsValid)
yield break;
ColorModel model = ColorParser.TryParseColor(hex.Text, ColorParser.Options.None);
if (model != null)
{
if (ColorConverterSmartTagAction.GetNamedColor(model.Color) != null)
{
yield return new ColorConverterSmartTagAction(itemTrackingSpan, hex, model, ColorFormat.Name);
}
if (model.Format == ColorFormat.RgbHex6)
{
string hex3 = ColorFormatter.FormatColor(model, ColorFormat.RgbHex3);
if (hex3.Length == 4)
{
yield return new ColorConverterSmartTagAction(itemTrackingSpan, hex, model, ColorFormat.RgbHex3);
}
}
yield return new ColorConverterSmartTagAction(itemTrackingSpan, hex, model, ColorFormat.Rgb);
yield return new ColorConverterSmartTagAction(itemTrackingSpan, hex, model, ColorFormat.Hsl);
}
}
开发者ID:joeriks,项目名称:WebEssentials2013,代码行数:29,代码来源:ColorConverterSmartTagProvider.cs
示例8: CheckItem
public ItemCheckResult CheckItem(ParseItem item, ICssCheckerContext context)
{
if (!WESettings.Instance.Css.ValidateVendorSpecifics)
return ItemCheckResult.Continue;
AtDirective directive = (AtDirective)item;
if (context == null || !directive.IsValid || !directive.IsVendorSpecific())
return ItemCheckResult.Continue;
ICssCompletionListEntry entry = VendorHelpers.GetMatchingStandardEntry(directive, context);
if (entry != null)
{
var visitor = new CssItemCollector<AtDirective>();
directive.Parent.Accept(visitor);
if (!visitor.Items.Any(a => a != null && a.Keyword != null && "@" + a.Keyword.Text == entry.DisplayText))
{
string message = string.Format(CultureInfo.InvariantCulture, Resources.BestPracticeAddMissingStandardDirective, entry.DisplayText);
context.AddError(new SimpleErrorTag(directive.Keyword, message));
return ItemCheckResult.CancelCurrentItem;
}
}
return ItemCheckResult.Continue;
}
开发者ID:venux,项目名称:WebEssentials2015,代码行数:27,代码来源:MissingStandardDirectiveErrorTagProvider.cs
示例9: CheckItem
public ItemCheckResult CheckItem(ParseItem item, ICssCheckerContext context)
{
if (!WESettings.Instance.Css.ValidateVendorSpecifics)
return ItemCheckResult.Continue;
if (!item.IsValid || context == null)
return ItemCheckResult.Continue;
ICssSchemaInstance rootSchema = CssSchemaManager.SchemaManager.GetSchemaRoot(null);
ICssSchemaInstance schema = CssSchemaManager.SchemaManager.GetSchemaForItem(rootSchema, item);
string normalized = item.Text.Trim(':');
ICssCompletionListEntry pseudo = schema.GetPseudo(item.Text);
if (normalized.Length > 0 && normalized[0] == '-' && pseudo == null)
{
string message = string.Format(CultureInfo.CurrentCulture, Resources.ValidationVendorPseudo, item.Text);
context.AddError(new SimpleErrorTag(item, message, CssErrorFlags.TaskListWarning | CssErrorFlags.UnderlineRed));
return ItemCheckResult.CancelCurrentItem;
}
else if (pseudo != null)
{
string obsolete = pseudo.GetAttribute("obsolete");
if (!string.IsNullOrEmpty(obsolete))
{
string message = string.Format(CultureInfo.CurrentCulture, Resources.BestPracticeRemoveObsolete, normalized, obsolete);
context.AddError(new SimpleErrorTag(item, message, CssErrorFlags.TaskListMessage));
return ItemCheckResult.CancelCurrentItem;
}
}
return ItemCheckResult.Continue;
}
开发者ID:GProulx,项目名称:WebEssentials2013,代码行数:33,代码来源:InvalidVendorErrorTagProvider.cs
示例10: HandleDeclaration
private static void HandleDeclaration(ParseItem item, ICssCheckerContext context)
{
Declaration dec = (Declaration)item;
if (dec == null || dec.PropertyName == null)
return;
if (dec.IsVendorSpecific())
{
string message = string.Format("Validation (W3C): \"{0}\" is not a valid W3C property", dec.PropertyName.Text);
context.AddError(new SimpleErrorTag(dec.PropertyName, message, CssErrorFlags.TaskListWarning | CssErrorFlags.UnderlineRed));
}
foreach (var value in dec.Values)
{
string text = value.Text;
if (!(value is NumericalValue) && text.StartsWith("-", StringComparison.Ordinal))
{
int index = text.IndexOf('(');
if (index > -1)
{
text = text.Substring(0, index);
}
string message = string.Format("Validation (W3C): \"{0}\" is not a valid W3C value", text);
context.AddError(new SimpleErrorTag(value, message, CssErrorFlags.TaskListWarning | CssErrorFlags.UnderlineRed));
}
}
}
开发者ID:LogoPhonix,项目名称:WebEssentials2012,代码行数:30,代码来源:W3cOnlyErrorTagProvider.cs
示例11: GetSmartTagActions
public IEnumerable<ISmartTagAction> GetSmartTagActions(ParseItem item, int position, ITrackingSpan itemTrackingSpan, ITextView view)
{
FunctionColor function = (FunctionColor)item;
if (!function.IsValid)
yield break;
ColorModel model = ColorParser.TryParseColor(function.Text, ColorParser.Options.AllowAlpha);
if (model != null)
{
// Don't convert RGBA and HSLA to HEX or named color
if (model.Alpha == 1)
{
if (ColorConverterSmartTagAction.GetNamedColor(model.Color) != null)
{
yield return new ColorConverterSmartTagAction(itemTrackingSpan, model, ColorFormat.Name);
}
yield return new ColorConverterSmartTagAction(itemTrackingSpan, model, ColorFormat.RgbHex3);
}
if (model.Format == ColorFormat.Rgb)
{
yield return new ColorConverterSmartTagAction(itemTrackingSpan, model, ColorFormat.Hsl);
}
else if (model.Format == ColorFormat.Hsl)
{
yield return new ColorConverterSmartTagAction(itemTrackingSpan, model, ColorFormat.Rgb);
}
}
}
开发者ID:GProulx,项目名称:WebEssentials2013,代码行数:31,代码来源:ColorConverterSmartTagProvider.cs
示例12: SchemaLookup
private bool SchemaLookup(ParseItem item)
{
if (item is ClassSelector || item is IdSelector || item is ItemName || item.Parent is RuleBlock || item.Parent is StyleSheet)
return false;
ICssSchemaInstance schema = CssSchemaManager.SchemaManager.GetSchemaRootForBuffer(TextView.TextBuffer);
Declaration dec = item.FindType<Declaration>();
if (dec != null && dec.PropertyName != null)
return OpenReferenceUrl(schema.GetProperty, dec.PropertyName.Text, "http://realworldvalidator.com/css/properties/");
PseudoClassFunctionSelector pseudoClassFunction = item.FindType<PseudoClassFunctionSelector>();
if (pseudoClassFunction != null)
return OpenReferenceUrl(schema.GetPseudo, pseudoClassFunction.Colon.Text + pseudoClassFunction.Function.FunctionName.Text + ")", "http://realworldvalidator.com/css/pseudoclasses/");
PseudoElementFunctionSelector pseudoElementFunction = item.FindType<PseudoElementFunctionSelector>();
if (pseudoElementFunction != null)
return OpenReferenceUrl(schema.GetPseudo, pseudoElementFunction.DoubleColon.Text + pseudoElementFunction.Function.FunctionName.Text + ")", "http://realworldvalidator.com/css/pseudoelements/");
PseudoElementSelector pseudoElement = item.FindType<PseudoElementSelector>();
if (pseudoElement != null && pseudoElement.PseudoElement != null)
return OpenReferenceUrl(schema.GetPseudo, pseudoElement.DoubleColon.Text + pseudoElement.PseudoElement.Text, "http://realworldvalidator.com/css/pseudoelements/");
PseudoClassSelector pseudoClass = item.FindType<PseudoClassSelector>();
if (pseudoClass != null && pseudoClass.PseudoClass != null)
return OpenReferenceUrl(schema.GetPseudo, pseudoClass.Colon.Text + pseudoClass.PseudoClass.Text, "http://realworldvalidator.com/css/pseudoclasses/");
AtDirective directive = item.FindType<AtDirective>();
if (directive != null)
return OpenReferenceUrl(schema.GetAtDirective, directive.At.Text + directive.Keyword.Text, "http://realworldvalidator.com/css/atdirectives/");
return false;
}
开发者ID:LogoPhonix,项目名称:WebEssentials2012,代码行数:33,代码来源:F1HelpCommandTarget.cs
示例13: CheckItem
public ItemCheckResult CheckItem(ParseItem item, ICssCheckerContext context)
{
RuleBlock rule = (RuleBlock)item;
if (!rule.IsValid || context == null)
return ItemCheckResult.Continue;
IEnumerable<string> properties = from d in rule.Declarations
where d.PropertyName != null && d.Values.Count < 2
select d.PropertyName.Text;
foreach (string shorthand in _cache.Keys)
{
if (_cache[shorthand].All(p => properties.Contains(p)))
{
Declaration dec = rule.Declarations.First(p => p.PropertyName != null && _cache[shorthand].Contains(p.PropertyName.Text));
string message = string.Format(CultureInfo.CurrentCulture, Resources.PerformanceUseShorthand, string.Join(", ", _cache[shorthand]), shorthand);
context.AddError(new SimpleErrorTag(dec, message));
}
}
return ItemCheckResult.Continue;
}
开发者ID:EdsonF,项目名称:WebEssentials2013,代码行数:25,代码来源:ShorthandErrorTagProvider.cs
示例14: GetSmartTagActions
public IEnumerable<ISmartTagAction> GetSmartTagActions(ParseItem item, int position, ITrackingSpan itemTrackingSpan, ITextView view)
{
Declaration dec = (Declaration)item;
if (!item.IsValid || position > dec.Colon.Start)
yield break;
RuleBlock rule = dec.FindType<RuleBlock>();
if (!rule.IsValid)
yield break;
ICssSchemaInstance schema = CssSchemaManager.SchemaManager.GetSchemaRootForBuffer(itemTrackingSpan.TextBuffer);
if (!dec.IsVendorSpecific())
{
IEnumerable<Declaration> vendors = VendorHelpers.GetMatchingVendorEntriesInRule(dec, rule, schema);
if (vendors.Any(v => v.Start > dec.Start))
{
yield return new VendorOrderSmartTagAction(itemTrackingSpan, vendors.Last(), dec);
}
}
else
{
ICssCompletionListEntry entry = VendorHelpers.GetMatchingStandardEntry(dec, schema);
if (entry != null && !rule.Declarations.Any(d => d.PropertyName != null && d.PropertyName.Text == entry.DisplayText))
{
yield return new MissingStandardSmartTagAction(itemTrackingSpan, dec, entry.DisplayText);
}
}
}
开发者ID:NickCraver,项目名称:WebEssentials2013,代码行数:30,代码来源:VendorOrderSmartTagProvider.cs
示例15: CheckItem
public ItemCheckResult CheckItem(ParseItem item, ICssCheckerContext context)
{
UrlItem url = (UrlItem)item;
if (!WESettings.Instance.Css.ValidateEmbedImages || !url.IsValid || url.UrlString == null || url.UrlString.Text.Contains("base64,") || context == null)
return ItemCheckResult.Continue;
string fileName = ImageQuickInfo.GetFullUrl(url.UrlString.Text, WebEssentialsPackage.DTE.ActiveDocument.FullName);
if (string.IsNullOrEmpty(fileName) || fileName.Contains("://"))
return ItemCheckResult.Continue;
// Remove parameters if any; c:/temp/myfile.ext?#iefix
fileName = fileName.Split('?', '#')[0];
try
{
FileInfo file = new FileInfo(fileName);
if (file.Exists && file.Length < (1024 * 3))
{
Declaration dec = url.FindType<Declaration>();
if (dec != null && dec.PropertyName != null && dec.PropertyName.Text[0] != '*' && dec.PropertyName.Text[0] != '_')
{
string error = string.Format(CultureInfo.CurrentCulture, Resources.PerformanceEmbedImageAsDataUri, file.Length);
context.AddError(new SimpleErrorTag(url.UrlString, error));
}
}
}
catch { /* Ignore any error here */ }
return ItemCheckResult.Continue;
}
开发者ID:GProulx,项目名称:WebEssentials2013,代码行数:32,代码来源:EmbedImagesErrorTagProvider.cs
示例16: CheckItem
//private HashSet<string> _deprecated = new HashSet<string>()
//{
// "-moz-opacity",
// "-moz-outline",
// "-moz-outline-style",
//};
public ItemCheckResult CheckItem(ParseItem item, ICssCheckerContext context)
{
if (!WESettings.GetBoolean(WESettings.Keys.ValidateVendorSpecifics))
return ItemCheckResult.Continue;
Declaration dec = (Declaration)item;
if (!dec.IsValid || !dec.IsVendorSpecific() || context == null)
return ItemCheckResult.Continue;
ICssSchemaInstance rootSchema = CssSchemaManager.SchemaManager.GetSchemaRoot(null);
ICssSchemaInstance schema = CssSchemaManager.SchemaManager.GetSchemaForItem(rootSchema, item);
//if (_deprecated.Contains(dec.PropertyName.Text))
//{
// string message = string.Format(Resources.ValidationDeprecatedVendorDeclaration, dec.PropertyName.Text);
// context.AddError(new SimpleErrorTag(dec.PropertyName, message));
// return ItemCheckResult.CancelCurrentItem;
//}
if (schema.GetProperty(dec.PropertyName.Text) == null)
{
string message = string.Format(Resources.ValidationVendorDeclarations, dec.PropertyName.Text);
context.AddError(new SimpleErrorTag(dec.PropertyName, message, CssErrorFlags.TaskListWarning | CssErrorFlags.UnderlineRed));
return ItemCheckResult.CancelCurrentItem;
}
return ItemCheckResult.Continue;
}
开发者ID:jonantoine,项目名称:WebEssentials2012,代码行数:34,代码来源:InvalidVendorErrorTagProvider.cs
示例17: GetSmartTagActions
public IEnumerable<ISmartTagAction> GetSmartTagActions(ParseItem item, int position, ITrackingSpan itemTrackingSpan, ITextView view)
{
RuleSet rule = item.FindType<RuleSet>();
if (rule == null || !rule.Block.IsValid || UsageRegistry.IsRuleUsed(rule))
yield break;
yield return new RemoveCssRuleSmartTagAction(itemTrackingSpan, rule);
}
开发者ID:robert-hoffmann,项目名称:WebEssentials2013,代码行数:8,代码来源:RemoveCssRuleSmartTagProvider.cs
示例18: GetCompletionContext
public CssCompletionContext GetCompletionContext(ParseItem item, int position)
{
Function func = (Function)item;
if (func.FunctionName == null && func.FunctionName.Text != "var-")
return null;
return new CssCompletionContext((CssCompletionContextType)609, func.Arguments.TextStart, func.Arguments.TextLength, null);
}
开发者ID:venux,项目名称:WebEssentials2015,代码行数:8,代码来源:VariableContextProvider.cs
示例19: GetSmartTagActions
public IEnumerable<ISmartTagAction> GetSmartTagActions(ParseItem item, int position, ITrackingSpan itemTrackingSpan, ITextView view)
{
RuleSet rule = item.FindType<RuleSet>();
if (rule == null || !rule.IsValid || !rule.Block.IsValid)
yield break;
yield return new SortSmartTagAction(rule, itemTrackingSpan, view);
}
开发者ID:NickCraver,项目名称:WebEssentials2013,代码行数:8,代码来源:SortSmartTagProvider.cs
示例20: GetSmartTagActions
public IEnumerable<ISmartTagAction> GetSmartTagActions(ParseItem item, int position, ITrackingSpan itemTrackingSpan, ITextView view)
{
LessRuleBlock rule = item.FindType<LessRuleBlock>();
if (!item.IsValid || rule == null)
yield break;
yield return new LessExtractVariableSmartTagAction(itemTrackingSpan, item, "@");
}
开发者ID:GProulx,项目名称:WebEssentials2013,代码行数:9,代码来源:LessExtractVariableSmartTagProvider.cs
注:本文中的ParseItem类示例整理自Github/MSDocs等源码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。 |
请发表评论