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


C# SeparatedSyntaxList类代码示例

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


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

示例1: CheckParameters

        static void CheckParameters(SyntaxNodeAnalysisContext ctx, ISymbol member, List<ISymbol> overloads, SeparatedSyntaxList<ParameterSyntax> parameterListNodes)
        {
            var memberParameters = member.GetParameters();
            for (int i = 0; i < memberParameters.Length; i++)
            {
                if (!memberParameters[i].IsOptional)
                    continue;

                foreach (var overload in overloads)
                {
                    if (overload.GetParameters().Length != i)
                        continue;
                    bool equal = true;
                    for (int j = 0; j < i; j++)
                    {
                        if (overload.GetParameters()[j].Type != memberParameters[j].Type)
                        {
                            equal = false;
                            break;
                        }
                    }
                    if (equal)
                    {
                        ctx.ReportDiagnostic( Diagnostic.Create(
                            descriptor,
                            parameterListNodes[i].GetLocation(),
                            member.IsKind(SymbolKind.Method) ? GettextCatalog.GetString("Method") : GettextCatalog.GetString("Indexer")
                        ));
                    }
                }
            }
        }
开发者ID:ceddlyburge,项目名称:RefactoringEssentials,代码行数:32,代码来源:MethodOverloadWithOptionalParameterAnalyzer.cs

示例2: CreatePragmaDirectiveTriviaAsync

        private async Task<SyntaxTriviaList> CreatePragmaDirectiveTriviaAsync(
            SyntaxToken disableOrRestoreKeyword, Diagnostic diagnostic, Func<SyntaxNode, Task<SyntaxNode>> formatNode, bool needsLeadingEndOfLine, bool needsTrailingEndOfLine)
        {
            var id = SyntaxFactory.IdentifierName(diagnostic.Id);
            var ids = new SeparatedSyntaxList<ExpressionSyntax>().Add(id);
            var pragmaDirective = SyntaxFactory.PragmaWarningDirectiveTrivia(disableOrRestoreKeyword, ids, true);
            pragmaDirective = (PragmaWarningDirectiveTriviaSyntax)await formatNode(pragmaDirective).ConfigureAwait(false);
            var pragmaDirectiveTrivia = SyntaxFactory.Trivia(pragmaDirective);
            var endOfLineTrivia = SyntaxFactory.ElasticCarriageReturnLineFeed;
            var triviaList = SyntaxFactory.TriviaList(pragmaDirectiveTrivia);

            var title = diagnostic.Descriptor.Title.ToString(CultureInfo.CurrentUICulture);
            if (!string.IsNullOrWhiteSpace(title))
            {
                var titleComment = SyntaxFactory.Comment(string.Format(" // {0}", title)).WithAdditionalAnnotations(Formatter.Annotation);
                triviaList = triviaList.Add(titleComment);
            }

            if (needsLeadingEndOfLine)
            {
                triviaList = triviaList.Insert(0, endOfLineTrivia);
            }

            if (needsTrailingEndOfLine)
            {
                triviaList = triviaList.Add(endOfLineTrivia);
            }

            return triviaList;
        }
开发者ID:SoumikMukherjeeDOTNET,项目名称:roslyn,代码行数:30,代码来源:CSharpSuppressionCodeFixProvider.cs

示例3: GetParameterNameThatMatchStringLiteral

 private static string GetParameterNameThatMatchStringLiteral(LiteralExpressionSyntax stringLiteral)
 {
     var ancestorThatMightHaveParameters = stringLiteral.FirstAncestorOfType(typeof(AttributeListSyntax), typeof(MethodDeclarationSyntax), typeof(ConstructorDeclarationSyntax), typeof(IndexerDeclarationSyntax));
     var parameterName = string.Empty;
     if (ancestorThatMightHaveParameters != null)
     {
         var parameters = new SeparatedSyntaxList<ParameterSyntax>();
         switch (ancestorThatMightHaveParameters.Kind())
         {
             case SyntaxKind.MethodDeclaration:
             case SyntaxKind.ConstructorDeclaration:
                 var method = (BaseMethodDeclarationSyntax)ancestorThatMightHaveParameters;
                 parameters = method.ParameterList.Parameters;
                 break;
             case SyntaxKind.IndexerDeclaration:
                 var indexer = (IndexerDeclarationSyntax)ancestorThatMightHaveParameters;
                 parameters = indexer.ParameterList.Parameters;
                 break;
             case SyntaxKind.AttributeList:
                 break;
         }
         parameterName = GetParameterWithIdentifierEqualToStringLiteral(stringLiteral, parameters)?.Identifier.Text;
     }
     return parameterName;
 }
开发者ID:JeanLLopes,项目名称:code-cracker,代码行数:25,代码来源:NameOfAnalyzer.cs

示例4: Check

        static void Check(SyntaxNodeAnalysisContext nodeContext, SeparatedSyntaxList<ParameterSyntax> syntaxParams, ImmutableArray<IParameterSymbol> list1, ImmutableArray<IParameterSymbol> list2)
        {
            var upper = Math.Min(list1.Length, list2.Length);
            for (int i = 0; i < upper; i++)
            {
                var arg = list1[i];
                var baseArg = list2[i];

                if (arg.Name != baseArg.Name)
                {
                    nodeContext.ReportDiagnostic(Diagnostic.Create(
                        descriptor.Id,
                        descriptor.Category,
                        descriptor.MessageFormat,
                        descriptor.DefaultSeverity,
                        descriptor.DefaultSeverity,
                        descriptor.IsEnabledByDefault,
                        4,
                        descriptor.Title,
                        descriptor.Description,
                        descriptor.HelpLinkUri,
                        Location.Create(nodeContext.SemanticModel.SyntaxTree, syntaxParams[i].Identifier.Span),
                        null,
                        new[] { baseArg.Name }
                    ));
                }
            }
        }
开发者ID:ceddlyburge,项目名称:RefactoringEssentials,代码行数:28,代码来源:BaseMethodParameterNameMismatchAnalyzer.cs

示例5: CreatePragmaDirectiveTrivia

        private SyntaxTriviaList CreatePragmaDirectiveTrivia(SyntaxToken disableOrRestoreKeyword, Diagnostic diagnostic, bool needsLeadingEndOfLine, bool needsTrailingEndOfLine)
        {
            var id = SyntaxFactory.IdentifierName(diagnostic.Id);
            var ids = new SeparatedSyntaxList<ExpressionSyntax>().Add(id);
            var pragmaDirective = SyntaxFactory.PragmaWarningDirectiveTrivia(disableOrRestoreKeyword, ids, true);
            var pragmaDirectiveTrivia = SyntaxFactory.Trivia(pragmaDirective.WithAdditionalAnnotations(Formatter.Annotation));
            var endOfLineTrivia = SyntaxFactory.EndOfLine(@"
");
            var triviaList = SyntaxFactory.TriviaList(pragmaDirectiveTrivia);

            var title = diagnostic.Descriptor.Title.ToString(CultureInfo.CurrentUICulture);
            if (!string.IsNullOrWhiteSpace(title))
            {
                var titleComment = SyntaxFactory.Comment(string.Format(" // {0}", title)).WithAdditionalAnnotations(Formatter.Annotation);
                triviaList = triviaList.Add(titleComment);
            }

            if (needsLeadingEndOfLine)
            {
                triviaList = triviaList.Insert(0, endOfLineTrivia);
            }

            if (needsTrailingEndOfLine)
            {
                triviaList = triviaList.Add(endOfLineTrivia);
            }

            return triviaList;
        }
开发者ID:ehsansajjad465,项目名称:roslyn,代码行数:29,代码来源:CSharpSuppressionCodeFixProvider.cs

示例6: VisitClassDeclaration

        public override SyntaxNode VisitClassDeclaration(ClassDeclarationSyntax node)
        {
            var typesList = new List<TypeSyntax> { _baseTypeSyntax };

            if (node.BaseList != null)
                typesList.AddRange(node.BaseList.Types);

            var types = new SeparatedSyntaxList<TypeSyntax>();
            types = types.AddRange(typesList);

            var identifier = SyntaxFactory.Identifier(FurnaceTypeIdentifier + _typeName);

            var newNode = node.Update(
                node.AttributeLists,
                node.Modifiers,
                node.Keyword,
                identifier,
                node.TypeParameterList,
                SyntaxFactory.BaseList(types),
                node.ConstraintClauses,
                node.OpenBraceToken,
                node.Members,
                node.CloseBraceToken,
                node.SemicolonToken).NormalizeWhitespace();

            return base.VisitClassDeclaration(newNode);
        }
开发者ID:laurentkempe,项目名称:Furnace,代码行数:27,代码来源:FurnaceTypeWriter.cs

示例7: UvssPropertyTriggerSyntax

        /// <summary>
        /// Initializes a new instance of the <see cref="UvssPropertyTriggerSyntax"/> class.
        /// </summary>
        internal UvssPropertyTriggerSyntax(
            SyntaxToken triggerKeyword,
            SyntaxToken propertyKeyword,
            SeparatedSyntaxList<UvssPropertyTriggerConditionSyntax> conditions,
            SyntaxToken qualifierToken,
            UvssBlockSyntax body)
            : base(SyntaxKind.PropertyTrigger)
        {
            this.TriggerKeyword = triggerKeyword;
            ChangeParent(triggerKeyword);

            this.PropertyKeyword = propertyKeyword;
            ChangeParent(propertyKeyword);

            this.Conditions = conditions;
            ChangeParent(conditions.Node);

            this.QualifierToken = qualifierToken;
            ChangeParent(qualifierToken);

            this.Body = body;
            ChangeParent(body);

            SlotCount = 5;
            UpdateIsMissing();
        }
开发者ID:RUSshy,项目名称:ultraviolet,代码行数:29,代码来源:UvssPropertyTriggerSyntax.cs

示例8: GetDiagnostics

        static void GetDiagnostics(SyntaxNodeAnalysisContext nodeContext, SeparatedSyntaxList<AttributeArgumentSyntax>? arguments)
        {
            if (!arguments.HasValue)
                return;

            var node = nodeContext.Node;
            CheckParameters(nodeContext, nodeContext.SemanticModel.GetSymbolInfo(node).Symbol, arguments.Value);
        }
开发者ID:ceddlyburge,项目名称:RefactoringEssentials,代码行数:8,代码来源:RedundantArgumentNameAnalyzer.cs

示例9: ParseArgumentList

        public MacroArgumentListSyntax ParseArgumentList()
        {
            var openParen = Match(SyntaxKind.OpenParenToken);

            var arguments = new List<SyntaxNode>();

            CommaIsSeparatorStack.Push(true);

            try
            {
                var currentArg = new List<SyntaxToken>();
                var parenStack = 0;
                while ((Current.Kind != SyntaxKind.CloseParenToken || parenStack > 0) && Current.Kind != SyntaxKind.EndOfFileToken)
                {
                    switch (Current.Kind)
                    {
                        case SyntaxKind.OpenParenToken:
                            CommaIsSeparatorStack.Push(false);
                            parenStack++;
                            currentArg.Add(NextToken());
                            break;
                        case SyntaxKind.CloseParenToken:
                            CommaIsSeparatorStack.Pop();
                            parenStack--;
                            currentArg.Add(NextToken());
                            break;
                        case SyntaxKind.CommaToken:
                            if (CommaIsSeparatorStack.Peek() == false)
                                goto default;
                            arguments.Add(new MacroArgumentSyntax(currentArg));
                            currentArg = new List<SyntaxToken>();
                            arguments.Add(Match(SyntaxKind.CommaToken));
                            break;
                        default:
                            currentArg.Add(NextToken());
                            break;
                    }
                }

                if (currentArg.Any())
                    arguments.Add(new MacroArgumentSyntax(currentArg));
            }
            finally
            {
                CommaIsSeparatorStack.Pop();
            }

            var argumentList = new SeparatedSyntaxList<MacroArgumentSyntax>(arguments);

            var closeParen = Match(SyntaxKind.CloseParenToken);

            return new MacroArgumentListSyntax(openParen, argumentList, closeParen);
        }
开发者ID:tgjones,项目名称:HlslTools,代码行数:53,代码来源:MacroArgumentsParser.cs

示例10: VisitClassDeclaration

        public override SyntaxNode VisitClassDeclaration(ClassDeclarationSyntax node)
        {
            node = (ClassDeclarationSyntax)base.VisitClassDeclaration(node);
            SyntaxList<MemberDeclarationSyntax> newMembers = new SyntaxList<MemberDeclarationSyntax>();
            foreach (MemberDeclarationSyntax member in node.Members)
            {
                if (member.Kind == SyntaxKind.PropertyDeclaration)
                {
                    PropertyDeclarationSyntax prop = (PropertyDeclarationSyntax)member;
                    SyntaxList<AccessorDeclarationSyntax> newAccessors = new SyntaxList<AccessorDeclarationSyntax>();
                    bool implementfield = false;
                    foreach (AccessorDeclarationSyntax accessor in prop.AccessorList.Accessors)
                    {
                        if (accessor.Body == null)
                        {
                            switch (accessor.Kind)
                            {
                                case SyntaxKind.GetAccessorDeclaration:
                                    implementfield = true;
                                    newAccessors = newAccessors.Add(accessor.WithBody(Syntax.Block(Syntax.ReturnStatement(Syntax.IdentifierName("_" + prop.Identifier.ValueText)))));
                                    break;
                                case SyntaxKind.SetAccessorDeclaration:
                                    implementfield = true;
                                    newAccessors = newAccessors.Add(accessor.WithBody(Syntax.Block(Syntax.ExpressionStatement(Syntax.BinaryExpression(SyntaxKind.AssignExpression, Syntax.IdentifierName("_" + prop.Identifier.ValueText), Syntax.IdentifierName("value"))))));
                                    break;
                                default:
                                    newAccessors = newAccessors.Add(accessor);
                                    break;
                            }
                        }
                        else
                        {
                            newAccessors = newAccessors.Add(accessor);
                        }
                    }
                    if (implementfield)
                    {
                        SeparatedSyntaxList<VariableDeclaratorSyntax> variables = new SeparatedSyntaxList<VariableDeclaratorSyntax>();
                        variables = variables.Add(Syntax.VariableDeclarator("_" + prop.Identifier.ValueText));
                        newMembers = newMembers.Add(Syntax.FieldDeclaration(Syntax.VariableDeclaration(prop.Type, variables)));
                    }

                    newMembers = newMembers.Add(prop.WithAccessorList(prop.AccessorList.WithAccessors(newAccessors)));
                }
                else
                {
                    newMembers = newMembers.Add(member);
                }
            }
            return node.WithMembers(newMembers);
        }
开发者ID:VendanAndrews,项目名称:ls2csc,代码行数:51,代码来源:AutoImplementedPropertyRewriter.cs

示例11: UvssRuleSetSyntax

        /// <summary>
        /// Initializes a new instance of the <see cref="UvssRuleSetSyntax"/> class.
        /// </summary>
        internal UvssRuleSetSyntax(
            SeparatedSyntaxList<UvssSelectorWithNavigationExpressionSyntax> selectors,
            UvssBlockSyntax body)
            : base(SyntaxKind.RuleSet)
        {
            this.Selectors = selectors;
            ChangeParent(selectors.Node);

            this.Body = body;
            ChangeParent(body);

            SlotCount = 2;
            UpdateIsMissing();
        }
开发者ID:RUSshy,项目名称:ultraviolet,代码行数:17,代码来源:UvssRuleSetSyntax.cs

示例12: WithParameters

        public static BaseParameterListSyntax WithParameters(
            this BaseParameterListSyntax parameterList,
            SeparatedSyntaxList<ParameterSyntax> parameters)
        {
            switch (parameterList.Kind())
            {
                case SyntaxKind.BracketedParameterList:
                    return ((BracketedParameterListSyntax)parameterList).WithParameters(parameters);
                case SyntaxKind.ParameterList:
                    return ((ParameterListSyntax)parameterList).WithParameters(parameters);
            }

            throw ExceptionUtilities.Unreachable;
        }
开发者ID:Rickinio,项目名称:roslyn,代码行数:14,代码来源:BaseParameterListSyntaxExtensions.cs

示例13: WithParameters

        public static BaseParameterListSyntax WithParameters(
            this BaseParameterListSyntax parameterList,
            SeparatedSyntaxList<ParameterSyntax> parameters)
        {
            switch (parameterList.CSharpKind())
            {
                case SyntaxKind.BracketedParameterList:
                    return ((BracketedParameterListSyntax)parameterList).WithParameters(parameters);
                case SyntaxKind.ParameterList:
                    return ((ParameterListSyntax)parameterList).WithParameters(parameters);
            }

            throw Contract.Unreachable;
        }
开发者ID:EkardNT,项目名称:Roslyn,代码行数:14,代码来源:BaseParameterListSyntaxExtensions.cs

示例14: RewritePostfixUnarys

        protected SeparatedSyntaxList<ExpressionSyntax> RewritePostfixUnarys(SeparatedSyntaxList<ExpressionSyntax> nodes)
        {
            if (nodes.Count == 0)
                return nodes;

            List<ExpressionSyntax> expressions = new List<ExpressionSyntax> (nodes.Count);
            foreach (var node in nodes)
            {
                var newNode = RewritePostfixUnarys (node);
                if (newNode != null)
                    expressions.Add (newNode);
            }

            return Syntax.SeparatedList (expressions, Enumerable.Repeat (Syntax.Token (SyntaxKind.CommaToken), expressions.Count - 1));
        }
开发者ID:Mstrymt,项目名称:Instant,代码行数:15,代码来源:LoggingRewriter.cs

示例15: ForStatement

 /// <summary>Creates a new ForStatementSyntax instance.</summary>
 public static ForStatementSyntax ForStatement(SyntaxToken forKeyword, SyntaxToken openParenToken, VariableDeclarationSyntax declaration, SeparatedSyntaxList<ExpressionSyntax> initializers, SyntaxToken firstSemicolonToken, ExpressionSyntax condition, SyntaxToken secondSemicolonToken, SeparatedSyntaxList<ExpressionSyntax> incrementors, SyntaxToken closeParenToken, StatementSyntax statement)
 {
     return ForStatement(
         forKeyword: forKeyword,
         openParenToken: openParenToken,
         refKeyword: default(SyntaxToken),
         deconstruction: null,
         declaration: declaration,
         initializers: initializers,
         firstSemicolonToken: firstSemicolonToken,
         condition: condition,
         secondSemicolonToken: secondSemicolonToken,
         incrementors: incrementors,
         closeParenToken: closeParenToken,
         statement: statement);
 }
开发者ID:Shiney,项目名称:roslyn,代码行数:17,代码来源:ForStatementSyntax.cs


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