Exemplo n.º 1
0
        /* Function: IsSkippable
         * Returns whether the token at the passed index should be skipped based on the <LineBoundsMode>.
         */
        internal bool IsSkippable(int testTokenIndex, int testRawTextIndex, LineBoundsMode boundsMode)
        {
            if (boundsMode == LineBoundsMode.Everything)
            {
                return(false);
            }

            FundamentalType fundamentalType = tokenizer.FundamentalTypeAt(testTokenIndex, testRawTextIndex);

            // Whitespace is skippable for both ExcludeWhitespace and CommentContent
            if (fundamentalType == FundamentalType.Whitespace ||
                fundamentalType == FundamentalType.LineBreak)
            {
                return(true);
            }

            if (boundsMode == LineBoundsMode.ExcludeWhitespace)
            {
                return(false);
            }

            // The only other choice is CommentContent

            CommentParsingType commentParsingType = tokenizer.CommentParsingTypeAt(testTokenIndex);

            return(commentParsingType == CommentParsingType.CommentSymbol ||
                   commentParsingType == CommentParsingType.CommentDecoration);
        }
Exemplo n.º 2
0
        /* Function: SetCommentParsingTypeBetween
         * Changes the <CommentParsingType> of all the tokens between the two passed iterators.  The
         * token at the ending iterator will not be changed.
         */
        public void SetCommentParsingTypeBetween(TokenIterator startingIterator, TokenIterator endingIterator,
                                                 CommentParsingType type)
        {
            if (startingIterator.Tokenizer != this || endingIterator.Tokenizer != this)
            {
                throw new InvalidOperationException();
            }

            SetCommentParsingTypeBetween(startingIterator.TokenIndex, endingIterator.TokenIndex, type);
        }
Exemplo n.º 3
0
        /* Function: SetCommentParsingTypeAt
         * Changes the <CommentParsingType> at the passed token index.
         */
        public void SetCommentParsingTypeAt(int tokenIndex, CommentParsingType type)
        {
            if (commentParsingTypes == null)
            {
                commentParsingTypes = new CommentParsingType[tokenLengths.Count];
            }

            if (tokenIndex < 0 || tokenIndex >= commentParsingTypes.Length)
            {
                throw new ArgumentOutOfRangeException();
            }

            commentParsingTypes[tokenIndex] = type;
        }
Exemplo n.º 4
0
        /* Function: SetCommentParsingTypeBetween
         * Changes the <CommentParsingType> of all the tokens between the two passed indexes.  The
         * token at the ending index will not be changed.
         */
        public void SetCommentParsingTypeBetween(int startingIndex, int endingIndex, CommentParsingType type)
        {
            if (commentParsingTypes == null)
            {
                commentParsingTypes = new CommentParsingType[tokenLengths.Count];
            }

            if (startingIndex < 0 || endingIndex > commentParsingTypes.Length)
            {
                throw new ArgumentOutOfRangeException();
            }
            if (startingIndex > endingIndex)
            {
                throw new InvalidOperationException();
            }

            for (int i = startingIndex; i < endingIndex; i++)
            {
                commentParsingTypes[i] = type;
            }
        }
Exemplo n.º 5
0
        /* Function: SetCommentParsingTypeByCharacters
         *
         * Changes the <CommentParsingType> of the tokens encompassed by the passed number of characters.
         *
         * This throws an exception if the number of characters does not evenly fall on a token boundary.  It
         * is assumed that this function will primarily be used after a positive result from <MatchesAcrossTokens()>
         * or <TokensInCharacters()> which would cause this to not be an issue.
         */
        public void SetCommentParsingTypeByCharacters(CommentParsingType newType, int characters)
        {
            int tokenCount = TokensInCharacters(characters);

            if (tokenCount == -1)
            {
                throw new InvalidOperationException();
            }
            else if (tokenCount == 1)
            {
                CommentParsingType = newType;
            }
            else
            {
                TokenIterator iterator = this;

                while (tokenCount > 0)
                {
                    iterator.CommentParsingType = newType;
                    iterator.Next();
                    tokenCount--;
                }
            }
        }
Exemplo n.º 6
0
 /* Function: SetCommentParsingTypeBetween
  * Changes the <CommentParsingType> of all the tokens between the current position and the passed iterator.
  * The token the ending iterator is on will not be changed.
  */
 public void SetCommentParsingTypeBetween(TokenIterator end, CommentParsingType type)
 {
     Tokenizer.SetCommentParsingTypeBetween(this, end, type);
 }