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


C# SyntaxNodeOrToken类代码示例

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


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

示例1: CreateSpan

        private static TextSpan CreateSpan(SyntaxTokenList startOpt, SyntaxNodeOrToken startFallbackOpt, SyntaxNodeOrToken endOpt)
        {
            Debug.Assert(startFallbackOpt != default(SyntaxNodeOrToken) || endOpt != default(SyntaxNodeOrToken));

            int startPos;
            if (startOpt.Count > 0)
            {
                startPos = startOpt.First().SpanStart;
            }
            else if (startFallbackOpt != default(SyntaxNodeOrToken))
            {
                startPos = startFallbackOpt.SpanStart;
            }
            else
            {
                startPos = endOpt.SpanStart;
            }

            int endPos;
            if (endOpt != default(SyntaxNodeOrToken))
            {
                endPos = GetEndPosition(endOpt);
            }
            else
            {
                endPos = GetEndPosition(startFallbackOpt);
            }

            return TextSpan.FromBounds(startPos, endPos);
        }
开发者ID:ehsansajjad465,项目名称:roslyn,代码行数:30,代码来源:LocalRewriter_SequencePoints.cs

示例2: Create

        public static PatternCapture Create(PatternVariable variable, SyntaxNodeOrToken startNodeOrToken, SyntaxNodeOrToken endNodeOrToken)
        {
            Debug.Assert(endNodeOrToken.Parent != startNodeOrToken.Parent,
                         $"{nameof(endNodeOrToken)}.{nameof(endNodeOrToken.Parent)} must match {nameof(startNodeOrToken)}", nameof(endNodeOrToken));

            return new PatternCapture(variable, startNodeOrToken, endNodeOrToken);
        }
开发者ID:terrajobst,项目名称:apiporter,代码行数:7,代码来源:PatternCapture.cs

示例3: PatternSearchResult

 private PatternSearchResult(PatternSearch search, Document document, SyntaxNodeOrToken nodeOrToken,  ImmutableArray<PatternCapture> captures)
 {
     Search = search;
     Document = document;
     NodeOrToken = nodeOrToken;
     Captures = captures;
 }
开发者ID:terrajobst,项目名称:apiporter,代码行数:7,代码来源:PatternSearchResult.cs

示例4: SyntaxNodeOrTokenListItem

        public SyntaxNodeOrTokenListItem(SyntaxNodeOrToken syntaxNodeOrToken)
        {
            _lineSpan = syntaxNodeOrToken.GetLocation().GetLineSpan();

            Content = $"{_lineSpan}: {syntaxNodeOrToken.Kind()} {Truncate(syntaxNodeOrToken.ToString())}";
            ToolTip = syntaxNodeOrToken.ToString();
        }
开发者ID:FrankBakkerNl,项目名称:IntelliFind,代码行数:7,代码来源:SyntaxNodeOrTokenListItem.cs

示例5: GetRebuiltNodes

        /// <summary>
        /// Returns the nodes in the new tree that do not share the same underlying 
        /// representation in the old tree. These may be entirely new nodes or rebuilt nodes.
        /// </summary>
        /// <param name="oldNode"></param>
        /// <param name="newNode"></param>
        /// <returns></returns>
        internal static IEnumerable<SyntaxNodeOrToken> GetRebuiltNodes(SyntaxNodeOrToken oldNode, SyntaxNodeOrToken newNode)
        {
            var hashSet = new HashSet<InternalSyntax.SyntaxNode>();
            GatherNodes(oldNode.UnderlyingNode.ToGreen(), hashSet);

            var stack = new Stack<ChildSyntaxList.Enumerator>();
            if (!hashSet.Contains(newNode.UnderlyingNode.ToGreen()))
            {
                yield return newNode;
                stack.Push(newNode.Children.GetEnumerator());
            }

            while (stack.Count > 0)
            {
                var newc = stack.Pop();
                if (newc.MoveNext())
                {
                    stack.Push(newc); // put enumerator changes back on stack..
                    newNode = newc.Current;
                    if (!hashSet.Contains(newNode.UnderlyingNode.ToGreen()))
                    {
                        yield return newNode;
                        stack.Push(newNode.Children.GetEnumerator());
                    }
                }
            }
        }
开发者ID:modulexcite,项目名称:pattern-matching-csharp,代码行数:34,代码来源:SyntaxDifferences.cs

示例6: Run

        public override Match Run(SyntaxNodeOrToken nodeOrToken)
        {
            if (nodeOrToken.Kind() != SyntaxKind.Argument)
                return Match.NoMatch;

            var argument = (ArgumentSyntax) nodeOrToken.AsNode();
            if (_variable.MinOccurrences == 1 && _variable.MaxOccurrences == 1)
                return Match.Success.WithSyntaxNodeOrToken(argument);

            var argumentList = argument.Parent as ArgumentListSyntax;
            if (argumentList == null)
                return Match.NoMatch;

            var currentIndex = argumentList.Arguments.IndexOf(argument);
            var availableCount = argumentList.Arguments.Count - currentIndex - _following;
            if (availableCount == 0)
                return Match.NoMatch;

            var captureCount = _variable.MaxOccurrences == null
                ? availableCount
                : Math.Min(availableCount, _variable.MaxOccurrences.Value);

            if (captureCount < _variable.MinOccurrences)
                return Match.NoMatch;

            var endIndex = currentIndex + captureCount - 1;
            var endArgument = argumentList.Arguments[endIndex];
            return Match.Success.AddCapture(_variable, argument, endArgument);
        }
开发者ID:terrajobst,项目名称:apiporter,代码行数:29,代码来源:ArgumentMatcher.cs

示例7: Run

        public override Match Run(SyntaxNodeOrToken nodeOrToken)
        {
            if (nodeOrToken.Kind() != _kind)
                return Match.NoMatch;

            return nodeOrToken.AsToken().ValueText == _text ? Match.Success : Match.NoMatch;
        }
开发者ID:terrajobst,项目名称:apiporter,代码行数:7,代码来源:TokenMatcher.cs

示例8: GatherNodes

 private static void GatherNodes(SyntaxNodeOrToken node, HashSet<GreenNode> hashSet)
 {
     hashSet.Add(node.UnderlyingNode);
     foreach (var child in node.ChildNodesAndTokens())
     {
         GatherNodes(child, hashSet);
     }
 }
开发者ID:Rickinio,项目名称:roslyn,代码行数:8,代码来源:SyntaxDifferences.cs

示例9: WriteSourceMap

 private void WriteSourceMap(SyntaxNodeOrToken node, Position pos, string str)
 {
     if (node.Kind() == SyntaxKind.IdentifierName || node.Kind() == SyntaxKind.IdentifierToken || node.Kind() == SyntaxKind.ObjectCreationExpression)
     {
         System.Diagnostics.Debug.WriteLine($"{node} ---> [{node.Kind()} | {pos}] ---> {str}");
         _sourceMapOutput.AddMapping(node, pos);
     }
 }
开发者ID:rexzh,项目名称:SharpJs,代码行数:8,代码来源:ArtifactOutput.cs

示例10: Create

        public static PatternSearchResult Create(PatternSearch search, Document document, SyntaxNodeOrToken nodeOrToken, ImmutableArray<PatternCapture> captures)
        {
            if (search == null)
                throw new ArgumentNullException(nameof(search));

            if (document == null)
                throw new ArgumentNullException(nameof(document));

            return new PatternSearchResult(search, document, nodeOrToken, captures);
        }
开发者ID:terrajobst,项目名称:apiporter,代码行数:10,代码来源:PatternSearchResult.cs

示例11: ClassifyNodeOrToken

        private void ClassifyNodeOrToken(SyntaxNodeOrToken nodeOrToken)
        {
            if (nodeOrToken.IsToken)
            {
                ClassifyToken(nodeOrToken.AsToken());
                return;
            }

            ClassifyNode(nodeOrToken.AsNode());
        }
开发者ID:XieShuquan,项目名称:roslyn,代码行数:10,代码来源:Worker.cs

示例12: WalkTreeRangeKeepLevelAndParent

        private static IEnumerable<ParsedToken> WalkTreeRangeKeepLevelAndParent(SyntaxNodeOrToken currentRoot, int blockLevel, SyntaxNode upperStatementNode, SyntaxNode immediateStatementNode, Range range)
        {
            if (!currentRoot.IsLeafNode)
            {
                SyntaxNode syntaxNode = (SyntaxNode)currentRoot;

                SyntaxNode nextUpperStatementNode = immediateStatementNode;
                SyntaxNode nextImmediateStatementNode = syntaxNode;

                if (SyntaxKind.TableConstructorExp != syntaxNode.Kind &&
                    SyntaxKind.TableConstructorArg != syntaxNode.Kind &&
                    !StatKinds.Contains(syntaxNode.Kind))
                {
                    nextImmediateStatementNode = immediateStatementNode;
                    nextUpperStatementNode = upperStatementNode;
                }

                if (nextUpperStatementNode == null)
                {
                    nextUpperStatementNode = nextImmediateStatementNode;
                }

                if ((syntaxNode.Kind == SyntaxKind.BlockNode && nextImmediateStatementNode != null) ||
                     syntaxNode.Kind == SyntaxKind.FieldList)
                {
                    blockLevel++;
                }

                foreach (SyntaxNodeOrToken node in syntaxNode.Children)
                {
                    foreach (ParsedToken parsedToken in WalkTreeRangeKeepLevelAndParent(node,
                        blockLevel,
                        nextUpperStatementNode, nextImmediateStatementNode,
                        range))
                    {
                        yield return parsedToken;
                    }
                }
            }
            else
            {
                Token token = currentRoot as Token;

                if (token != null && token.Kind != SyntaxKind.MissingToken && token.Start >= range.Start)
                {
                    if (token.FullStart > range.End)
                    {
                        yield break;
                    }

                    yield return new ParsedToken(token, blockLevel, upperStatementNode, immediateStatementNode);
                }
            }
        }
开发者ID:Strongc,项目名称:VSLua,代码行数:54,代码来源:ParsedToken.cs

示例13: GetId

 public string GetId(SyntaxNodeOrToken node)
 {
     if (names.ContainsKey(node))
     {
         return names[node];
     }
     else
     {
         return "Ast_" + String.Join("_", identities[node]);
     }
 }
开发者ID:dpetillo,项目名称:genesis,代码行数:11,代码来源:IdentifyingSyntaxVisitor.cs

示例14: GetRebuiltNodes

        private static void GetRebuiltNodes(SyntaxNodeOrToken newNode, HashSet<GreenNode> hashSet, ArrayBuilder<SyntaxNodeOrToken> nodes)
        {
            if (hashSet.Contains(newNode.UnderlyingNode))
            {
                return;
            }

            nodes.Add(newNode);

            foreach (var child in newNode.ChildNodesAndTokens())
            {
                GetRebuiltNodes(child, hashSet, nodes);
            }
        }
开发者ID:Rickinio,项目名称:roslyn,代码行数:14,代码来源:SyntaxDifferences.cs

示例15: TryGetNextInSpan

            public bool TryGetNextInSpan(ref /*readonly*/ TextSpan span, out SyntaxNodeOrToken value)
            {
                value = default(SyntaxNodeOrToken);

                while (stack[stackPtr].TryMoveNextAndGetCurrent(ref value))
                {
                    if (IsInSpan(ref span, value.FullSpan))
                    {
                        return true;
                    }
                }

                stackPtr--;
                return false;
            }
开发者ID:riversky,项目名称:roslyn,代码行数:15,代码来源:SyntaxNode.Iterators.cs


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