protected void CheckModifiers(
            SyntaxTreeAnalysisContext context,
            Dictionary <int, int> preferredOrder,
            ReportDiagnostic severity,
            SyntaxNode memberDeclaration)
        {
            var modifiers = _syntaxFacts.GetModifiers(memberDeclaration);

            if (!AbstractOrderModifiersHelpers.IsOrdered(preferredOrder, modifiers))
            {
                if (severity.WithDefaultSeverity(DiagnosticSeverity.Hidden) == ReportDiagnostic.Hidden)
                {
                    // If the severity is hidden, put the marker on all the modifiers so that the
                    // user can bring up the fix anywhere in the modifier list.
                    context.ReportDiagnostic(
                        Diagnostic.Create(Descriptor, context.Tree.GetLocation(
                                              TextSpan.FromBounds(modifiers.First().SpanStart, modifiers.Last().Span.End))));
                }
                else
                {
                    // If the Severity is not hidden, then just put the user visible portion on the
                    // first token.  That way we don't
                    context.ReportDiagnostic(
                        DiagnosticHelper.Create(Descriptor, modifiers.First().GetLocation(), severity, additionalLocations: null, properties: null));
                }
            }
        }
Exemplo n.º 2
0
 protected AbstractOrderModifiersCodeFixProvider(
     ISyntaxFacts syntaxFacts,
     AbstractOrderModifiersHelpers helpers)
 {
     _syntaxFacts = syntaxFacts;
     _helpers     = helpers;
 }
Exemplo n.º 3
0
 protected AbstractOrderModifiersDiagnosticAnalyzer(
     ISyntaxFacts syntaxFacts,
     Option2 <CodeStyleOption2 <string> > option,
     AbstractOrderModifiersHelpers helpers,
     string language
     )
     : base(
         IDEDiagnosticIds.OrderModifiersDiagnosticId,
         EnforceOnBuildValues.OrderModifiers,
         option,
         language,
         new LocalizableResourceString(
             nameof(AnalyzersResources.Order_modifiers),
             AnalyzersResources.ResourceManager,
             typeof(AnalyzersResources)
             ),
         new LocalizableResourceString(
             nameof(AnalyzersResources.Modifiers_are_not_ordered),
             AnalyzersResources.ResourceManager,
             typeof(AnalyzersResources)
             )
         )
 {
     _syntaxFacts = syntaxFacts;
     _option      = option;
     _helpers     = helpers;
 }
Exemplo n.º 4
0
 protected AbstractOrderModifiersCodeFixProvider(
     ISyntaxFacts syntaxFacts,
     Option <CodeStyleOption <string> > option,
     AbstractOrderModifiersHelpers helpers)
 {
     _syntaxFacts = syntaxFacts;
     _option      = option;
     _helpers     = helpers;
 }
 protected AbstractOrderModifiersDiagnosticAnalyzer(
     ISyntaxFactsService syntaxFacts,
     Option <CodeStyleOption <string> > option,
     AbstractOrderModifiersHelpers helpers)
     : base(IDEDiagnosticIds.OrderModifiersDiagnosticId,
            new LocalizableResourceString(nameof(FeaturesResources.Order_modifiers), FeaturesResources.ResourceManager, typeof(FeaturesResources)),
            new LocalizableResourceString(nameof(FeaturesResources.Modifiers_are_not_ordered), FeaturesResources.ResourceManager, typeof(FeaturesResources)))
 {
     _syntaxFacts = syntaxFacts;
     _option      = option;
     _helpers     = helpers;
 }