private static void AnalyzeEventDeclaration(SyntaxNodeAnalysisContext context) { LeadingAnalysis leadingAnalysis = AnalyzeLeadingTrivia(context.Node); if (!leadingAnalysis.Span.IsEmpty) { ReportDiagnostic(context, leadingAnalysis.Span); return; } if (leadingAnalysis.HasDocumentationComment) { return; } var eventDeclaration = (EventDeclarationSyntax)context.Node; TrailingAnalysis trailingAnalysis = AnalyzeTrailingTrivia(eventDeclaration.Identifier); if (trailingAnalysis.ContainsEndOfLine) { return; } if (trailingAnalysis.Span.IsEmpty) { trailingAnalysis = AnalyzeTrailingTrivia(eventDeclaration.AccessorList); } if (!trailingAnalysis.Span.IsEmpty) { ReportDiagnostic(context, trailingAnalysis.Span); } }
private static void AnalyzeConstructorDeclaration(SyntaxNodeAnalysisContext context) { LeadingAnalysis leadingAnalysis = AnalyzeLeadingTrivia(context.Node); if (!leadingAnalysis.Span.IsEmpty) { ReportDiagnostic(context, leadingAnalysis.Span); return; } if (leadingAnalysis.HasDocumentationComment) { return; } var constructorDeclaration = (ConstructorDeclarationSyntax)context.Node; TrailingAnalysis trailingAnalysis = AnalyzeTrailingTrivia(constructorDeclaration.ParameterList); if (trailingAnalysis.ContainsEndOfLine) { return; } if (trailingAnalysis.Span.IsEmpty) { trailingAnalysis = AnalyzeTrailingTrivia(constructorDeclaration.Initializer); if (trailingAnalysis.ContainsEndOfLine) { return; } if (trailingAnalysis.Span.IsEmpty) { ArrowExpressionClauseSyntax expressionBody = constructorDeclaration.ExpressionBody; if (expressionBody != null) { trailingAnalysis = AnalyzeTrailingTrivia(expressionBody.ArrowToken); if (trailingAnalysis.ContainsEndOfLine) { return; } } } } if (trailingAnalysis.Span.IsEmpty) { trailingAnalysis = AnalyzeTrailingTrivia(constructorDeclaration); } if (!trailingAnalysis.Span.IsEmpty) { ReportDiagnostic(context, trailingAnalysis.Span); } }
private static void AnalyzeClassDeclaration(SyntaxNodeAnalysisContext context) { LeadingAnalysis leadingAnalysis = AnalyzeLeadingTrivia(context.Node); if (!leadingAnalysis.Span.IsEmpty) { ReportDiagnostic(context, leadingAnalysis.Span); return; } if (leadingAnalysis.HasDocumentationComment) { return; } var classDeclaration = (ClassDeclarationSyntax)context.Node; TrailingAnalysis trailingAnalysis = AnalyzeTrailingTrivia(classDeclaration.Identifier); if (trailingAnalysis.ContainsEndOfLine) { return; } if (trailingAnalysis.Span.IsEmpty) { trailingAnalysis = AnalyzeTrailingTrivia(classDeclaration.TypeParameterList); } if (trailingAnalysis.ContainsEndOfLine) { return; } if (trailingAnalysis.Span.IsEmpty) { trailingAnalysis = AnalyzeTrailingTrivia(classDeclaration.BaseList); } if (trailingAnalysis.ContainsEndOfLine) { return; } if (trailingAnalysis.Span.IsEmpty) { trailingAnalysis = AnalyzeTrailingTrivia(classDeclaration.ConstraintClauses); } if (!trailingAnalysis.Span.IsEmpty) { ReportDiagnostic(context, trailingAnalysis.Span); } }
private static void AnalyzeEventFieldDeclaration(SyntaxNodeAnalysisContext context) { LeadingAnalysis leadingAnalysis = AnalyzeLeadingTrivia(context.Node); if (!leadingAnalysis.Span.IsEmpty) { ReportDiagnostic(context, leadingAnalysis.Span); return; } if (leadingAnalysis.HasDocumentationComment) { return; } var eventFieldDeclaration = (EventFieldDeclarationSyntax)context.Node; TrailingAnalysis trailingAnalysis = AnalyzeTrailingTrivia(eventFieldDeclaration); if (!trailingAnalysis.Span.IsEmpty) { ReportDiagnostic(context, trailingAnalysis.Span); } }