protected string GetSpanClass(XmlClassificationTypes classification) { switch (classification) { case XmlClassificationTypes.XmlAttributeName: return("xan"); case XmlClassificationTypes.XmlAttributeValue: return("xav"); case XmlClassificationTypes.XmlCDataSection: return("xcs"); case XmlClassificationTypes.XmlComment: return("c"); case XmlClassificationTypes.XmlDelimiter: return("xd"); case XmlClassificationTypes.XmlEntityReference: return("xer"); case XmlClassificationTypes.XmlName: return("xn"); case XmlClassificationTypes.XmlProcessingInstruction: return("xpi"); case XmlClassificationTypes.XmlAttributeQuotes: case XmlClassificationTypes.None: case XmlClassificationTypes.XmlText: default: return(null); } }
private static int VisitChildren( SyntaxNode syntaxNode, int windowStart, int windowLength, Action<int, int, SyntaxNode, XmlClassificationTypes> resultCollector, int start, XmlClassificationTypes[] childTypes) { int visitedCount = 0; int windowEnd = windowStart + windowLength; var targetOffset = windowStart - start; int offset; int index; syntaxNode.GetIndexAndOffset(targetOffset, out index, out offset); start += offset; for (int i = index; i < syntaxNode.SlotCount; i++) { if (start > windowEnd) { break; } var child = syntaxNode.GetSlot(i); visitedCount++; if (child == null) { continue; } var currentStart = Math.Max(start, windowStart); var currentLength = Math.Min(windowEnd, start + child.FullWidth) - currentStart; if (currentLength >= 0) { var childType = childTypes == null ? XmlClassificationTypes.None : childTypes[i]; if (childType == XmlClassificationTypes.None) { if (child.Kind == SyntaxKind.XmlTextLiteralToken) { childType = XmlClassificationTypes.XmlText; } else if (child.Kind == SyntaxKind.XmlEntityLiteralToken) { childType = XmlClassificationTypes.XmlEntityReference; } } if (childType == XmlClassificationTypes.None) { visitedCount += Visit(child, windowStart, windowLength, resultCollector, start); } else { if (currentLength > 0) { resultCollector(currentStart, currentLength, child, childType); } } } start += child.FullWidth; } return visitedCount; }
protected string GetSpanClass(XmlClassificationTypes classification) { switch (classification) { case XmlClassificationTypes.XmlAttributeName: return "xan"; case XmlClassificationTypes.XmlAttributeValue: return "xav"; case XmlClassificationTypes.XmlCDataSection: return "xcs"; case XmlClassificationTypes.XmlComment: return "c"; case XmlClassificationTypes.XmlDelimiter: return "xd"; case XmlClassificationTypes.XmlEntityReference: return "xer"; case XmlClassificationTypes.XmlName: return "xn"; case XmlClassificationTypes.XmlProcessingInstruction: return "xpi"; case XmlClassificationTypes.XmlAttributeQuotes: case XmlClassificationTypes.None: case XmlClassificationTypes.XmlText: default: return null; } }