public sealed override void AddClassifications(Workspace workspace, SyntaxToken token, SemanticModel semanticModel, ArrayBuilder <ClassifiedSpan> result, CancellationToken cancellationToken) { foreach (var language in _languagesProvider.GetEmbeddedLanguages()) { var classifier = language.Classifier; if (classifier != null) { var count = result.Count; classifier.AddClassifications(workspace, token, semanticModel, result, cancellationToken); if (result.Count != count) { // This classifier added values. No need to check the other ones. return; } } } }
protected AbstractEmbeddedLanguageDiagnosticAnalyzer( IEmbeddedLanguagesProvider languagesProvider) { var supportedDiagnostics = ArrayBuilder <DiagnosticDescriptor> .GetInstance(); var analyzers = ArrayBuilder <IEmbeddedDiagnosticAnalyzer> .GetInstance(); if (languagesProvider != null) { foreach (var language in languagesProvider.GetEmbeddedLanguages()) { var analyzer = language.DiagnosticAnalyzer; if (analyzer != null) { analyzers.Add(analyzer); supportedDiagnostics.AddRange(analyzer.SupportedDiagnostics); } } } _analyzers = analyzers.ToImmutableAndFree(); this.SupportedDiagnostics = supportedDiagnostics.ToImmutableAndFree(); }
protected AbstractEmbeddedLanguageCodeFixProvider( IEmbeddedLanguagesProvider embeddedLanguagesProvider) { _diagnosticIdToCodeFixProvider = new Dictionary <string, IEmbeddedCodeFixProvider>(); // Create a mapping from each IEmbeddedCodeFixProvider.FixableDiagnosticIds back to the // IEmbeddedCodeFixProvider itself. That way, when we hear about diagnostics, we know // which provider to actually do the fixing. foreach (var language in embeddedLanguagesProvider.GetEmbeddedLanguages()) { var codeFixProvider = language.CodeFixProvider; if (codeFixProvider != null) { foreach (var diagnosticId in codeFixProvider.FixableDiagnosticIds) { // 'Add' is intentional. We want to throw if multiple fix providers // register for the say diagnostic ID. _diagnosticIdToCodeFixProvider.Add(diagnosticId, codeFixProvider); } } } this.FixableDiagnosticIds = _diagnosticIdToCodeFixProvider.Keys.ToImmutableArray(); }