Example #1
0
        private ValueTask <ImmutableArray <DiagnosticData> > GetDiagnosticsAsync(
            Workspace workspace,
            ProjectId projectId,
            DocumentId documentId,
            object id,
            bool includeSuppressedDiagnostics,
            bool forPullDiagnostics,
            Option2 <DiagnosticMode> diagnosticMode,
            CancellationToken cancellationToken)
        {
            // If this is a pull client, but pull diagnostics is not on, then they get nothing.  Similarly, if this is a
            // push client and pull diagnostics are on, they get nothing.
            var isPull = _globalOptions.IsPullDiagnostics(diagnosticMode);

            if (forPullDiagnostics != isPull)
            {
                return(new ValueTask <ImmutableArray <DiagnosticData> >(ImmutableArray <DiagnosticData> .Empty));
            }

            if (id != null)
            {
                // get specific one
                return(GetSpecificDiagnosticsAsync(workspace, projectId, documentId, id, includeSuppressedDiagnostics, cancellationToken));
            }

            // get aggregated ones
            return(GetDiagnosticsAsync(workspace, projectId, documentId, includeSuppressedDiagnostics, cancellationToken));
        }
        /// <summary>
        /// Gets all the diagnostics for this event, respecting the callers setting on if they're getting it for pull
        /// diagnostics or push diagnostics.  Most clients should use this to ensure they see the proper set of
        /// diagnostics in their scenario (or an empty array if not in their scenario).
        /// </summary>
        public static ImmutableArray <DiagnosticData> GetPushDiagnostics(
            this DiagnosticsUpdatedArgs args, IGlobalOptionService globalOptions, Option2 <DiagnosticMode> diagnosticMode)
        {
            // If pull diagnostics are on, they get nothing since they're asking for push diagnostics.
            if (globalOptions.IsPullDiagnostics(diagnosticMode))
            {
                return(ImmutableArray <DiagnosticData> .Empty);
            }

            return(args.GetAllDiagnosticsRegardlessOfPushPullSetting());
        }
Example #3
0
        /// <summary>
        /// Gets all the diagnostics for this event, respecting the callers setting on if they're getting it for pull
        /// diagnostics or push diagnostics.  Most clients should use this to ensure they see the proper set of
        /// diagnostics in their scenario (or an empty array if not in their scenario).
        /// </summary>
        public ImmutableArray <DiagnosticData> GetPushDiagnostics(
            IGlobalOptionService globalOptions, Option2 <DiagnosticMode> diagnosticMode)
        {
            // If pull diagnostics are on, they get nothing since they're asking for push diagnostics.
            if (globalOptions.IsPullDiagnostics(diagnosticMode))
            {
                return(ImmutableArray <DiagnosticData> .Empty);
            }

            return(_diagnostics);
        }