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


C# SyntaxListBuilder类代码示例

本文整理汇总了C#中SyntaxListBuilder的典型用法代码示例。如果您正苦于以下问题:C# SyntaxListBuilder类的具体用法?C# SyntaxListBuilder怎么用?C# SyntaxListBuilder使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。


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

示例1: ConvertToTriviaList

        public static SyntaxNode ConvertToTriviaList(this SyntaxNode[] nodes)
        {
            var builder = new SyntaxListBuilder(nodes.Length);
            for (int i = 0; i < nodes.Length; i++)
            {
                var node = nodes[i];
                var nd = node.GetDiagnostics();
                foreach (var token in node.GetTokens())
                {
                    builder.Add(token.GetLeadingTrivia());
                    if (token.Width > 0)
                    {
                        var tk = token.WithLeadingTrivia(null).WithTrailingTrivia(null);
                        System.Diagnostics.Debug.Assert(tk.HasDiagnostics == token.HasDiagnostics);
                        if (nd != null && nd.Length > 0)
                        {
                            if (token != node)
                            {
                                tk = tk.WithAdditionalDiagnostics(nd);
                            }

                            nd = null;
                        }

                        builder.Add(Syntax.SkippedTokens(tk));
                    }

                    builder.Add(token.GetTrailingTrivia());
                }
            }

            return builder.ToListNode();
        }
开发者ID:modulexcite,项目名称:pattern-matching-csharp,代码行数:33,代码来源:SyntaxNodeArrayExtensions.cs

示例2: LookupToken

        /// <summary>
        /// Look up a well known SyntaxToken for a given XML element tag or attribute.
        /// This is a performance optimization to avoid creating duplicate tokens for the same content.
        /// </summary>
        /// <param name="text">The text of the tag or attribute.</param>
        /// <param name="leading">The leading trivia of the token.</param>
        /// <returns>The SyntaxToken representing the well-known tag or attribute or null if it's not well-known.</returns>
        public static SyntaxToken LookupToken(string text, SyntaxListBuilder leading)
        {
            if (leading == null)
            {
                return LookupXmlElementTag(text);
            }

            if (IsSingleSpaceTrivia(leading))
            {
                return LookupXmlAttribute(text);
            }

            return null;
        }
开发者ID:modulexcite,项目名称:pattern-matching-csharp,代码行数:21,代码来源:DocumentationCommentXmlTokens.cs

示例3: IsSingleSpaceTrivia

 private static bool IsSingleSpaceTrivia(SyntaxListBuilder syntax)
 {
     return syntax.Count == 1 && SyntaxFactory.Space.IsEquivalentTo(syntax[0]);
 }
开发者ID:modulexcite,项目名称:pattern-matching-csharp,代码行数:4,代码来源:DocumentationCommentXmlTokens.cs

示例4: CollectConstituentTokensAndDiagnostics

        /*  <summary>
         ''' Add all the tokens in this node and children to the build token list builder. While doing this, add any
         ''' diagnostics not on tokens to the given diagnostic info list.
         ''' </summary>
        */
        internal virtual void CollectConstituentTokensAndDiagnostics(SyntaxListBuilder<SyntaxToken> tokenListBuilder, IList<DiagnosticInfo> nonTokenDiagnostics)
        {
            DiagnosticInfo[] diagnostics = this.GetDiagnostics();
            if (diagnostics != null && diagnostics.Length > 0)
            {
                foreach (var diag in diagnostics)
                {
                    nonTokenDiagnostics.Add(diag);
                }
            }

            // Recurse to subtrees.
            for (var i = 0; i < SlotCount; i++)
            {
                var green = GetSlot(i);
                if (green != null)
                {
                    ((SyntaxNode)green).CollectConstituentTokensAndDiagnostics(tokenListBuilder, nonTokenDiagnostics);
                }
            }
        }
开发者ID:akrisiun,项目名称:Microsoft.Language.Xml,代码行数:26,代码来源:SyntaxNode.cs

示例5: List

        internal static CSharpSyntaxNode List(SyntaxListBuilder builder)
        {
            if (builder != null)
            {
                return builder.ToListNode();
            }

            return null;
        }
开发者ID:modulexcite,项目名称:pattern-matching-csharp,代码行数:9,代码来源:SyntaxList.cs

示例6: ParseEndOfDirective

        private SyntaxToken ParseEndOfDirective(bool ignoreErrors, bool afterPragma = false, bool afterLineNumber = false, bool afterReference = false)
        {
            var skippedTokens = new SyntaxListBuilder<SyntaxToken>();

            // Consume all extranous tokens as leading SkippedTokens trivia.
            if (this.CurrentToken.Kind != SyntaxKind.EndOfDirectiveToken &&
                this.CurrentToken.Kind != SyntaxKind.EndOfFileToken)
            {
                skippedTokens = new SyntaxListBuilder<SyntaxToken>(10);

                if (!ignoreErrors)
                {
                    ErrorCode errorCode = ErrorCode.ERR_EndOfPPLineExpected;
                    if (afterPragma)
                    {
                        errorCode = ErrorCode.WRN_EndOfPPLineExpected;
                    }
                    else if (afterLineNumber)
                    {
                        errorCode = ErrorCode.ERR_MissingPPFile;
                    }
                    else if (afterReference)
                    {
                        errorCode = ErrorCode.ERR_ExpectedPPFile;
                    }

                    skippedTokens.Add(this.AddError(this.EatToken().WithoutDiagnosticsGreen(), errorCode));
                }

                while (this.CurrentToken.Kind != SyntaxKind.EndOfDirectiveToken &&
                       this.CurrentToken.Kind != SyntaxKind.EndOfFileToken)
                {
                    skippedTokens.Add(this.EatToken().WithoutDiagnosticsGreen());
                }
            }

            // attach text from extraneous tokens as trivia to EndOfDirective token
            SyntaxToken endOfDirective = this.CurrentToken.Kind == SyntaxKind.EndOfDirectiveToken
                                         ? this.EatToken()
                                         : SyntaxFactory.Token(SyntaxKind.EndOfDirectiveToken);

            if (!skippedTokens.IsNull)
            {
                endOfDirective = endOfDirective.WithLeadingTrivia(SyntaxFactory.SkippedTokensTrivia(skippedTokens.ToList()));
            }

            return endOfDirective;
        }
开发者ID:jerriclynsjohn,项目名称:roslyn,代码行数:48,代码来源:DirectiveParser.cs

示例7: XmlContext

 public XmlContext(SyntaxListPool pool, XmlElementStartTagSyntax start)
 {
     _pool = pool;
     _start = start;
     _content = _pool.Allocate<XmlNodeSyntax>();
 }
开发者ID:akrisiun,项目名称:Microsoft.Language.Xml,代码行数:6,代码来源:XmlContext.cs


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