// Group: Private Functions // __________________________________________________________________________ /* Function: DetermineElement * Determines which <XMLElementType> the iterator is currently on, setting <type> and <length>. */ private void DetermineElement() { bool found = false; if (tokenIterator == null || !IsInBounds) { type = XMLElementType.OutOfBounds; length = 0; found = true; } // If we're on a new line and either whitespace or a comment token... else if ((RawTextIndex == 0 || Tokenizer.FundamentalTypeOf(RawText[RawTextIndex - 1]) == FundamentalType.LineBreak) && (tokenIterator.FundamentalType == FundamentalType.Whitespace || tokenIterator.CommentParsingType == CommentParsingType.CommentSymbol || tokenIterator.CommentParsingType == CommentParsingType.CommentDecoration)) { type = XMLElementType.Indent; length = 0; TokenIterator lookahead = tokenIterator; do { length += lookahead.RawTextLength; lookahead.Next(); }while (lookahead.RawTextIndex < endingRawTextIndex && (lookahead.FundamentalType == FundamentalType.Whitespace || lookahead.CommentParsingType == CommentParsingType.CommentSymbol || lookahead.CommentParsingType == CommentParsingType.CommentDecoration)); found = true; } else if (tokenIterator.FundamentalType == FundamentalType.LineBreak) { type = XMLElementType.LineBreak; length = tokenIterator.RawTextLength; found = true; } else if (tokenIterator.Character == '<') { int nextBracketIndex = RawText.IndexOfAny(AngleBrackets, RawTextIndex + 1); if (nextBracketIndex != -1 && nextBracketIndex < endingRawTextIndex && RawText[nextBracketIndex] == '>') { type = XMLElementType.Tag; length = nextBracketIndex + 1 - RawTextIndex; Match tagMatch = TagRegex.Match(RawText, RawTextIndex, length); if (tagMatch.Success) { found = true; tagType = tagMatch.Groups[1].ToString().ToLower(); } } } else if (tokenIterator.Character == '&') { int semicolonIndex = RawText.IndexOf(';', RawTextIndex + 1); if (semicolonIndex != -1 && semicolonIndex < endingRawTextIndex && HTMLEntityChars.IsEntityChar(RawText, RawTextIndex, semicolonIndex + 1 - RawTextIndex)) { type = XMLElementType.EntityChar; length = semicolonIndex + 1 - RawTextIndex; found = true; } } if (!found) { type = XMLElementType.Text; int nextElementIndex = RawText.IndexOfAny(StartOfElement, RawTextIndex + 1); if (nextElementIndex == -1) { length = endingRawTextIndex - RawTextIndex; } else { length = nextElementIndex - RawTextIndex; } } }
// Group: Private Functions // __________________________________________________________________________ /* Function: DetermineElement * Determines which <JavadocElementType> the iterator is currently on, setting <type> and <length>. */ private void DetermineElement() { bool found = false; if (tokenIterator == null || !IsInBounds) { type = JavadocElementType.OutOfBounds; length = 0; found = true; } // If we're on a new line and either whitespace or a comment token... else if ((RawTextIndex == 0 || Tokenizer.FundamentalTypeOf(RawText[RawTextIndex - 1]) == FundamentalType.LineBreak) && (tokenIterator.FundamentalType == FundamentalType.Whitespace || tokenIterator.CommentParsingType == CommentParsingType.CommentSymbol || tokenIterator.CommentParsingType == CommentParsingType.CommentDecoration)) { type = JavadocElementType.Indent; length = 0; TokenIterator lookahead = tokenIterator; do { length += lookahead.RawTextLength; lookahead.Next(); }while (lookahead.RawTextIndex < endingRawTextIndex && (lookahead.FundamentalType == FundamentalType.Whitespace || lookahead.CommentParsingType == CommentParsingType.CommentSymbol || lookahead.CommentParsingType == CommentParsingType.CommentDecoration)); found = true; } else if (tokenIterator.FundamentalType == FundamentalType.LineBreak) { type = JavadocElementType.LineBreak; length = tokenIterator.RawTextLength; found = true; } else if (tokenIterator.MatchesAcrossTokens("<!--")) { type = JavadocElementType.HTMLComment; int endingCommentIndex = RawText.IndexOf("-->", RawTextIndex + 4, endingRawTextIndex - (RawTextIndex + 4)); if (endingCommentIndex == -1) { length = endingRawTextIndex - RawTextIndex; } else { length = (endingCommentIndex + 3) - RawTextIndex; } found = true; } else if (tokenIterator.Character == '<') { int nextBracketIndex = RawText.IndexOfAny(AngleBrackets, RawTextIndex + 1); if (nextBracketIndex != -1 && nextBracketIndex < endingRawTextIndex && RawText[nextBracketIndex] == '>') { type = JavadocElementType.HTMLTag; length = nextBracketIndex + 1 - RawTextIndex; Match tagMatch = HTMLTagRegex.Match(RawText, RawTextIndex, length); if (tagMatch.Success) { found = true; tagType = tagMatch.Groups[1].ToString().ToLower(); } } } else if (tokenIterator.MatchesAcrossTokens("{@")) { int closingBrace = RawText.IndexOf('}', RawTextIndex + 2); TokenIterator lookahead = tokenIterator; lookahead.NextByCharacters(2); if (closingBrace != -1 && closingBrace < endingRawTextIndex && lookahead.FundamentalType == FundamentalType.Text && Parsers.Javadoc.InlineTags.Contains(lookahead.String)) { found = true; type = JavadocElementType.JavadocTag; tagType = lookahead.String; length = (closingBrace + 1) - RawTextIndex; } } else if (tokenIterator.Character == '@') { TokenIterator lookahead = tokenIterator; lookahead.Next(); if (lookahead.FundamentalType == FundamentalType.Text && Parsers.Javadoc.BlockTags.Contains(lookahead.String)) { found = true; type = JavadocElementType.JavadocTag; tagType = lookahead.String; length = tagType.Length + 1; } } else if (tokenIterator.Character == '&') { int semicolonIndex = RawText.IndexOf(';', RawTextIndex + 1); if (semicolonIndex != -1 && semicolonIndex < endingRawTextIndex && HTMLEntityChars.IsEntityChar(RawText, RawTextIndex, semicolonIndex + 1 - RawTextIndex)) { type = JavadocElementType.EntityChar; length = semicolonIndex + 1 - RawTextIndex; found = true; } } if (!found) { type = JavadocElementType.Text; int nextElementIndex = RawText.IndexOfAny(StartOfElement, RawTextIndex + 1); if (nextElementIndex == -1) { length = endingRawTextIndex - RawTextIndex; } else { length = nextElementIndex - RawTextIndex; } } }