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


C# SyntaxNodeOrToken.Kind方法代码示例

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


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

示例1: 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

示例2: 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

示例3: 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

示例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: Run

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

            var result = Match.Success;

            if (nodeOrToken.IsNode)
            {
                var node = nodeOrToken.AsNode();
                var children = node.ChildNodesAndTokens();

                var matcherIndex = 0;
                var matchedEnd = 0;

                for (var i = 0; i < children.Count; i++)
                {
                    if (matcherIndex >= _childMatchers.Length)
                        return Match.NoMatch;

                    while (i < children.Count && children[i].Span.Start < matchedEnd)
                        i++;

                    if (i >= children.Count)
                        break;

                    var child = children[i];
                    var matcher = _childMatchers[matcherIndex];
                    var match = matcher.Run(child);
                    if (!match.IsMatch)
                        return Match.NoMatch;

                    // Depending on much was captured, we need to skip some matchers.

                    if (match.Captures.Any())
                        matchedEnd = match.Captures.Max(c => c.EndNodeOrToken.Span.End);

                    result = result.AddCaptures(match.Captures);
                    matcherIndex++;
                }

                var allMatchersUsed = matcherIndex >= _childMatchers.Length;
                if (!allMatchersUsed)
                    return Match.NoMatch;
            }

            return result;
        }
开发者ID:terrajobst,项目名称:apiporter,代码行数:48,代码来源:SyntaxKindMatcher.cs

示例6: Run

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

            var identifier = nodeOrToken.AsToken().ValueText;
            var regex = _variable.Regex;
            if (!string.IsNullOrEmpty(regex))
            {
                var regexOptions = _variable.CaseSensitive ? RegexOptions.None : RegexOptions.IgnoreCase;
                if (!Regex.IsMatch(identifier, regex, regexOptions))
                    return Match.NoMatch;
            }

            return Match.Success.AddCapture(_variable, nodeOrToken);
        }
开发者ID:terrajobst,项目名称:apiporter,代码行数:16,代码来源:IdentifierRegexMatcher.cs

示例7: Run

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

            var argumentList = (ArgumentListSyntax) nodeOrToken.AsNode();
            if (_variable.MinOccurrences > argumentList.Arguments.Count)
                return Match.NoMatch;

            if (_variable.MaxOccurrences != null && _variable.MaxOccurrences < argumentList.Arguments.Count)
                return Match.NoMatch;

            if (argumentList.Arguments.Count == 0)
                return Match.Success;

            var first = argumentList.Arguments.First();
            var last = argumentList.Arguments.Last();
            return Match.Success.AddCapture(_variable, first, last);
        }
开发者ID:terrajobst,项目名称:apiporter,代码行数:19,代码来源:ArgumentListMatcher.cs

示例8: NamedImpl

        private void NamedImpl(SyntaxNodeOrToken nodeOrToken)
        {
            string name = null;
            string astType = null;
            string comments = nodeOrToken.GetLeadingTrivia().ToFullString();
            string parentComments = nodeOrToken.Parent != null ? nodeOrToken.Parent.GetLeadingTrivia().ToFullString() : null;

            //if this is the hightest ast node for this comment, look for 1 bang, else 2 bangs
            string regex = @"@(?<ast_type>[^:\s]+):(?<name>\S+)";

            Match match = Regex.Match(comments, regex);
            if (match.Success)
            {
                name = match.Groups["name"].Value;
                astType = match.Groups["ast_type"].Value;

                SyntaxKind syntaxKind = (SyntaxKind)Enum.Parse(typeof(SyntaxKind), astType);

                if (nodeOrToken.Kind() == syntaxKind)
                {
                    names.Add(nodeOrToken, name);
                }
            }
        }
开发者ID:dpetillo,项目名称:genesis,代码行数:24,代码来源:IdentifyingSyntaxVisitor.cs

示例9: CompareTreeEquivalence

        private static void CompareTreeEquivalence(SyntaxNodeOrToken parsedTreeNode, SyntaxNodeOrToken incrementalTreeNode)
        {
            Assert.Equal(parsedTreeNode.Kind(), incrementalTreeNode.Kind());

            Assert.Equal(parsedTreeNode.ChildNodesAndTokens().Count, incrementalTreeNode.ChildNodesAndTokens().Count);

            for (int i = 0; i < parsedTreeNode.ChildNodesAndTokens().Count; i++)
            {
                CompareTreeEquivalence(parsedTreeNode.ChildNodesAndTokens()[i], incrementalTreeNode.ChildNodesAndTokens()[i]);
            }
        }
开发者ID:XieShuquan,项目名称:roslyn,代码行数:11,代码来源:IncrementalParsingTests.cs

示例10: AssertNodesAreEquivalent

        private void AssertNodesAreEquivalent(SyntaxNodeOrToken expectedNode, SyntaxNodeOrToken actualNode)
        {
            Assert.Equal(expectedNode.Kind(), actualNode.Kind());
            Assert.Equal(expectedNode.FullSpan, actualNode.FullSpan);
            Assert.Equal(expectedNode.ChildNodesAndTokens().Count, actualNode.ChildNodesAndTokens().Count);

            for (var i = 0; i < expectedNode.ChildNodesAndTokens().Count; i++)
            {
                AssertNodesAreEquivalent(expectedNode.ChildNodesAndTokens()[i],
                    actualNode.ChildNodesAndTokens()[i]);
            }
        }
开发者ID:CAPCHIK,项目名称:roslyn,代码行数:12,代码来源:GrammarAmbiguities.cs

示例11: Print

 private static void Print(SyntaxNodeOrToken node)
 {
     Debug.WriteLine("{0}(SyntaxKind.{1});", node.IsMissing ? "M" : "N", node.Kind());
 }
开发者ID:CAPCHIK,项目名称:roslyn,代码行数:4,代码来源:ParsingTests.cs

示例12: Print

 private static void Print(SyntaxNodeOrToken node)
 {
     if (node.Kind() == SyntaxKind.IdentifierToken && !node.IsMissing)
     {
         Debug.WriteLine(@"N(SyntaxKind.{0}, ""{1}"");", node.Kind(), node.ToString());
     }
     else
     {
         Debug.WriteLine("{0}(SyntaxKind.{1});", node.IsMissing ? "M" : "N", node.Kind());
     }
 }
开发者ID:Rickinio,项目名称:roslyn,代码行数:11,代码来源:ParsingTests.cs

示例13: IsNonZeroWidthOrIsEndOfFile

 private static bool IsNonZeroWidthOrIsEndOfFile(SyntaxNodeOrToken token)
 {
     return token.Kind() == SyntaxKind.EndOfFileToken || token.FullWidth != 0;
 }
开发者ID:Rickinio,项目名称:roslyn,代码行数:4,代码来源:Blender.Cursor.cs

示例14: Print

 private static void Print(SyntaxNodeOrToken node)
 {
     switch (node.Kind())
     {
         case SyntaxKind.IdentifierToken:
         case SyntaxKind.NumericLiteralToken:
             if (node.IsMissing)
             {
                 goto default;
             }
             Debug.WriteLine(@"N(SyntaxKind.{0}, ""{1}"");", node.Kind(), node.ToString());
             break;
         default:
             Debug.WriteLine("{0}(SyntaxKind.{1});", node.IsMissing ? "M" : "N", node.Kind());
             break;
     }
 }
开发者ID:XieShuquan,项目名称:roslyn,代码行数:17,代码来源:ParsingTests.cs

示例15: CanReuse

            private bool CanReuse(SyntaxNodeOrToken nodeOrToken)
            {
                // Zero width nodes and tokens always indicate that the parser had to do
                // something tricky, so don't reuse them.
                // NOTE: this is slightly different from IsMissing because of omitted type arguments
                // and array size expressions.
                if (nodeOrToken.FullWidth == 0)
                {
                    return false;
                }

                // As of 2013/03/14, the compiler never attempts to incrementally parse a tree containing
                // annotations.  Our goal in instituting this restriction is to prevent API clients from
                // taking a dependency on the survival of annotations.
                if (nodeOrToken.ContainsAnnotations)
                {
                    return false;
                }

                // We can't reuse a node or token if it intersects a changed text range.
                if (this.IntersectsNextChange(nodeOrToken))
                {
                    return false;
                }

                // don't reuse nodes or tokens with skipped text or diagnostics attached to them
                if (nodeOrToken.ContainsDiagnostics ||
                    (nodeOrToken.IsToken && ((CSharpSyntaxNode)nodeOrToken.AsToken().Node).ContainsSkippedText && nodeOrToken.Parent.ContainsDiagnostics))
                {
                    return false;
                }

                // fabricated tokens did not come from the lexer (likely from parser)
                if (IsFabricatedToken(nodeOrToken.Kind()))
                {
                    return false;
                }

                // don't reuse nodes that are incomplete. this helps cases were an incomplete node
                // completes differently after a change with far look-ahead.
                //
                // NOTE(cyrusn): It is very unfortunate that we even need this check given that we
                // have already checked for ContainsDiagnostics above.  However, there is a case where we
                // can have a node with a missing token *and* there are no diagnostics.
                // Specifically, this happens in the REPL when you have the last statement without a
                // trailing semicolon.  We treat this as an ExpressionStatement with a missing
                // semicolon, but we do not report errors.  It would be preferable to fix that so
                // that the semicolon can be optional rather than abusing the system.
                if ((nodeOrToken.IsToken && nodeOrToken.AsToken().IsMissing) ||
                    (nodeOrToken.IsNode && IsIncomplete((CSharp.CSharpSyntaxNode)nodeOrToken.AsNode())))
                {
                    return false;
                }

                if (!nodeOrToken.ContainsDirectives)
                {
                    return true;
                }

                return _newDirectives.IncrementallyEquivalent(_oldDirectives);
            }
开发者ID:Rickinio,项目名称:roslyn,代码行数:61,代码来源:Blender.Reader.cs


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