当前位置: 首页>>代码示例>>C#>>正文


C# CsTokenList.OutOfBounds方法代码示例

本文整理汇总了C#中CsTokenList.OutOfBounds方法的典型用法代码示例。如果您正苦于以下问题:C# CsTokenList.OutOfBounds方法的具体用法?C# CsTokenList.OutOfBounds怎么用?C# CsTokenList.OutOfBounds使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在CsTokenList的用法示例。


在下文中一共展示了CsTokenList.OutOfBounds方法的8个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。

示例1: MovePastTokens

        /// <summary>
        /// Moves the index past any whitespace characters.
        /// </summary>
        /// <param name="tokens">
        /// The collection containing the start token.
        /// </param>
        /// <param name="start">
        /// The first token to move past.
        /// </param>
        /// <param name="movePastTypes">
        /// The types of tokens to move past.
        /// </param>
        /// <returns>
        /// Returns false if the end of the token list was reached.
        /// </returns>
        private static bool MovePastTokens(CsTokenList tokens, ref Node<CsToken> start, params CsTokenType[] movePastTypes)
        {
            Param.AssertNotNull(tokens, "tokens");
            Param.AssertNotNull(start, "start");
            Param.Ignore(movePastTypes);

            for (Node<CsToken> tokenNode = start; !tokens.OutOfBounds(tokenNode); tokenNode = tokenNode.Next)
            {
                bool found = false;

                for (int i = 0; i < movePastTypes.Length; ++i)
                {
                    if (tokenNode.Value.CsTokenType == movePastTypes[i])
                    {
                        found = true;
                        break;
                    }
                }

                if (!found)
                {
                    start = tokenNode;
                    return true;
                }
            }

            return false;
        }
开发者ID:kopelli,项目名称:Visual-StyleCop,代码行数:43,代码来源:CodeParser.cs

示例2: FindEndOfName

        /// <summary>
        /// Finds the end of the given name, moving past member access operators.
        /// </summary>
        /// <param name="document">
        /// The document containing the name.
        /// </param>
        /// <param name="tokens">
        /// The token list.
        /// </param>
        /// <param name="startTokenNode">
        /// The first token of the name within the token list.
        /// </param>
        /// <returns>
        /// Returns the last token of the name within the token list.
        /// </returns>
        internal static Node<CsToken> FindEndOfName(CsDocument document, CsTokenList tokens, Node<CsToken> startTokenNode)
        {
            Param.AssertNotNull(document, "document");
            Param.AssertNotNull(tokens, "tokens");
            Param.AssertNotNull(startTokenNode, "startTokenNode");

            Node<CsToken> endTokenNode = startTokenNode;
            Node<CsToken> tokenNode = startTokenNode;

            if (tokenNode == null)
            {
                CsTokenType tokenType = tokenNode.Value.CsTokenType;
                if (tokenType != CsTokenType.Other && tokenType != CsTokenType.Get && tokenType != CsTokenType.Set && tokenType != CsTokenType.Add
                    && tokenType != CsTokenType.Remove)
                {
                    throw new SyntaxException(document.SourceCode, tokenNode == null ? document.MasterTokenList.Last.Value.LineNumber : tokenNode.Value.LineNumber);
                }
            }

            bool accessSymbol = false;

            for (Node<CsToken> temp = tokens.First; !tokens.OutOfBounds(temp); temp = temp.Next)
            {
                CsTokenType tempTokenType = temp.Value.CsTokenType;
                if (tempTokenType != CsTokenType.WhiteSpace && tempTokenType != CsTokenType.EndOfLine && tempTokenType != CsTokenType.SingleLineComment
                    && tempTokenType != CsTokenType.MultiLineComment && tempTokenType != CsTokenType.PreprocessorDirective)
                {
                    if (accessSymbol)
                    {
                        if (tempTokenType != CsTokenType.Other)
                        {
                            throw new SyntaxException(document.SourceCode, temp.Value.LineNumber);
                        }

                        endTokenNode = tokenNode;
                        accessSymbol = false;
                    }
                    else
                    {
                        if (temp.Value.Text == "." || temp.Value.Text == "::")
                        {
                            accessSymbol = true;
                        }
                        else
                        {
                            break;
                        }
                    }
                }
            }

            return endTokenNode;
        }
开发者ID:kopelli,项目名称:Visual-StyleCop,代码行数:68,代码来源:CodeParser.cs

示例3: GetFullName

        /// <summary>
        /// Finds the end of a name, moving past member access operators.
        /// </summary>
        /// <param name="document">
        /// The document containing the tokens.
        /// </param>
        /// <param name="tokens">
        /// The token list.
        /// </param>
        /// <param name="startTokenNode">
        /// The first token of the name.
        /// </param>
        /// <param name="endTokenNode">
        /// Returns the last token of the name.
        /// </param>
        /// <returns>
        /// Returns the full name.
        /// </returns>
        internal static string GetFullName(CsDocument document, CsTokenList tokens, Node<CsToken> startTokenNode, out Node<CsToken> endTokenNode)
        {
            Param.AssertNotNull(document, "document");
            Param.AssertNotNull(tokens, "tokens");
            Param.AssertNotNull(startTokenNode, "startToken");

            endTokenNode = CodeParser.FindEndOfName(document, tokens, startTokenNode);
            Debug.Assert(endTokenNode != null, "Did not find the end of the name");

            // Create the text string.
            StringBuilder text = new StringBuilder();

            for (Node<CsToken> tokenNode = startTokenNode; !tokens.OutOfBounds(tokenNode); tokenNode = tokenNode.Next)
            {
                CsTokenType tokenType = tokenNode.Value.CsTokenType;
                if (tokenType != CsTokenType.WhiteSpace && tokenType != CsTokenType.EndOfLine && tokenType != CsTokenType.SingleLineComment
                    && tokenType != CsTokenType.MultiLineComment && tokenType != CsTokenType.PreprocessorDirective)
                {
                    text.Append(tokenNode.Value.Text);
                }

                if (tokenNode == endTokenNode)
                {
                    break;
                }
            }

            return text.ToString();
        }
开发者ID:kopelli,项目名称:Visual-StyleCop,代码行数:47,代码来源:CodeParser.cs

示例4: GetOpenBracket

 private static Microsoft.StyleCop.Node<CsToken> GetOpenBracket(CsTokenList tokens)
 {
     for (Microsoft.StyleCop.Node<CsToken> node = tokens.First; !tokens.OutOfBounds(node); node = node.Next)
     {
         if (node.Value.CsTokenType == CsTokenType.OpenCurlyBracket)
         {
             return node;
         }
     }
     return null;
 }
开发者ID:katerina-marchenkova,项目名称:my,代码行数:11,代码来源:LayoutRules.cs

示例5: MovePastTokens

 private static bool MovePastTokens(CsTokenList tokens, ref Microsoft.StyleCop.Node<CsToken> start, params CsTokenType[] movePastTypes)
 {
     for (Microsoft.StyleCop.Node<CsToken> node = start; !tokens.OutOfBounds(node); node = node.Next)
     {
         bool flag = false;
         for (int i = 0; i < movePastTypes.Length; i++)
         {
             if (node.Value.CsTokenType == movePastTypes[i])
             {
                 flag = true;
                 break;
             }
         }
         if (!flag)
         {
             start = node;
             return true;
         }
     }
     return false;
 }
开发者ID:katerina-marchenkova,项目名称:my,代码行数:21,代码来源:CodeParser.cs

示例6: GetFullName

 internal static string GetFullName(CsDocument document, CsTokenList tokens, Microsoft.StyleCop.Node<CsToken> startTokenNode, out Microsoft.StyleCop.Node<CsToken> endTokenNode)
 {
     endTokenNode = FindEndOfName(document, tokens, startTokenNode);
     StringBuilder builder = new StringBuilder();
     for (Microsoft.StyleCop.Node<CsToken> node = startTokenNode; !tokens.OutOfBounds(node); node = node.Next)
     {
         CsTokenType csTokenType = node.Value.CsTokenType;
         if ((((csTokenType != CsTokenType.WhiteSpace) && (csTokenType != CsTokenType.EndOfLine)) && ((csTokenType != CsTokenType.SingleLineComment) && (csTokenType != CsTokenType.MultiLineComment))) && (csTokenType != CsTokenType.PreprocessorDirective))
         {
             builder.Append(node.Value.Text);
         }
         if (node == endTokenNode)
         {
             break;
         }
     }
     return builder.ToString();
 }
开发者ID:katerina-marchenkova,项目名称:my,代码行数:18,代码来源:CodeParser.cs

示例7: FindEndOfName

        internal static Microsoft.StyleCop.Node<CsToken> FindEndOfName(CsDocument document, CsTokenList tokens, Microsoft.StyleCop.Node<CsToken> startTokenNode)
        {
            Microsoft.StyleCop.Node<CsToken> node = startTokenNode;
            Microsoft.StyleCop.Node<CsToken> node2 = startTokenNode;
            if (node2 == null)
            {
                CsTokenType csTokenType = node2.Value.CsTokenType;
                if ((((csTokenType != CsTokenType.Other) && (csTokenType != CsTokenType.Get)) && ((csTokenType != CsTokenType.Set) && (csTokenType != CsTokenType.Add))) && (csTokenType != CsTokenType.Remove))
                {
                    throw new SyntaxException(document.SourceCode, (node2 == null) ? document.MasterTokenList.Last.Value.LineNumber : node2.Value.LineNumber);
                }
            }
            bool flag = false;
            for (Microsoft.StyleCop.Node<CsToken> node3 = tokens.First; !tokens.OutOfBounds(node3); node3 = node3.Next)
            {
                CsTokenType type2 = node3.Value.CsTokenType;
                switch (type2)
                {
                    case CsTokenType.WhiteSpace:
                    case CsTokenType.EndOfLine:
                    case CsTokenType.SingleLineComment:
                    case CsTokenType.MultiLineComment:
                    case CsTokenType.PreprocessorDirective:
                        break;

                    default:
                        if (flag)
                        {
                            if (type2 != CsTokenType.Other)
                            {
                                throw new SyntaxException(document.SourceCode, node3.Value.LineNumber);
                            }
                            node = node2;
                            flag = false;
                        }
                        else
                        {
                            if (!(node3.Value.Text == ".") && !(node3.Value.Text == "::"))
                            {
                                return node;
                            }
                            flag = true;
                        }
                        break;
                }
            }
            return node;
        }
开发者ID:katerina-marchenkova,项目名称:my,代码行数:48,代码来源:CodeParser.cs

示例8: GetOpenBracket

        /// <summary>
        /// Gets the first open curly bracket in the token list.
        /// </summary>
        /// <param name="tokens">The list of tokens.</param>
        /// <returns>Returns the first open curly bracket or -1 if there are none.</returns>
        private static Node<CsToken> GetOpenBracket(CsTokenList tokens)
        {
            Param.AssertNotNull(tokens, "tokens");

            for (Node<CsToken> tokenNode = tokens.First; !tokens.OutOfBounds(tokenNode); tokenNode = tokenNode.Next)
            {
                if (tokenNode.Value.CsTokenType == CsTokenType.OpenCurlyBracket)
                {
                    return tokenNode;
                }
            }

            return null;
        }
开发者ID:katerina-marchenkova,项目名称:my,代码行数:19,代码来源:LayoutRules.cs


注:本文中的CsTokenList.OutOfBounds方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。