UNPKG

5.56 kBTypeScriptView Raw
1import * as ts from 'typescript';
2import * as tsdoc from '@microsoft/tsdoc';
3import { AstDeclaration } from '../analyzer/AstDeclaration';
4import { AstSymbol } from '../analyzer/AstSymbol';
5import { ExtractorMessage, IExtractorMessageProperties } from '../api/ExtractorMessage';
6import { ExtractorMessageId } from '../api/ExtractorMessageId';
7import { IExtractorMessagesConfig } from '../api/IConfigFile';
8import { ConsoleMessageId } from '../api/ConsoleMessageId';
9export interface IMessageRouterOptions {
10 workingPackageFolder: string | undefined;
11 messageCallback: ((message: ExtractorMessage) => void) | undefined;
12 messagesConfig: IExtractorMessagesConfig;
13 showVerboseMessages: boolean;
14 showDiagnostics: boolean;
15 tsdocConfiguration: tsdoc.TSDocConfiguration;
16}
17export interface IBuildJsonDumpObjectOptions {
18 /**
19 * {@link MessageRouter.buildJsonDumpObject} will omit any objects keys with these names.
20 */
21 keyNamesToOmit?: string[];
22}
23export declare class MessageRouter {
24 static readonly DIAGNOSTICS_LINE: string;
25 private readonly _workingPackageFolder;
26 private readonly _messageCallback;
27 private readonly _messages;
28 private readonly _associatedMessagesForAstDeclaration;
29 private readonly _sourceMapper;
30 private readonly _tsdocConfiguration;
31 private _reportingRuleByMessageId;
32 private _compilerDefaultRule;
33 private _extractorDefaultRule;
34 private _tsdocDefaultRule;
35 errorCount: number;
36 warningCount: number;
37 /**
38 * See {@link IExtractorInvokeOptions.showVerboseMessages}
39 */
40 readonly showVerboseMessages: boolean;
41 /**
42 * See {@link IExtractorInvokeOptions.showDiagnostics}
43 */
44 readonly showDiagnostics: boolean;
45 constructor(options: IMessageRouterOptions);
46 /**
47 * Read the api-extractor.json configuration and build up the tables of routing rules.
48 */
49 private _applyMessagesConfig;
50 private static _getNormalizedRule;
51 get messages(): ReadonlyArray<ExtractorMessage>;
52 /**
53 * Add a diagnostic message reported by the TypeScript compiler
54 */
55 addCompilerDiagnostic(diagnostic: ts.Diagnostic): void;
56 /**
57 * Add a message from the API Extractor analysis
58 */
59 addAnalyzerIssue(messageId: ExtractorMessageId, messageText: string, astDeclarationOrSymbol: AstDeclaration | AstSymbol, properties?: IExtractorMessageProperties): void;
60 /**
61 * Add all messages produced from an invocation of the TSDoc parser, assuming they refer to
62 * code in the specified source file.
63 */
64 addTsdocMessages(parserContext: tsdoc.ParserContext, sourceFile: ts.SourceFile, astDeclaration?: AstDeclaration): void;
65 /**
66 * Recursively collects the primitive members (numbers, strings, arrays, etc) into an object that
67 * is JSON serializable. This is used by the "--diagnostics" feature to dump the state of configuration objects.
68 *
69 * @returns a JSON serializable object (possibly including `null` values)
70 * or `undefined` if the input cannot be represented as JSON
71 */
72 static buildJsonDumpObject(input: any, options?: IBuildJsonDumpObjectOptions): any | undefined;
73 private static _buildJsonDumpObject;
74 /**
75 * Record this message in _associatedMessagesForAstDeclaration
76 */
77 private _associateMessageWithAstDeclaration;
78 /**
79 * Add a message for a location in an arbitrary source file.
80 */
81 addAnalyzerIssueForPosition(messageId: ExtractorMessageId, messageText: string, sourceFile: ts.SourceFile, pos: number, properties?: IExtractorMessageProperties): ExtractorMessage;
82 /**
83 * This is used when writing the API report file. It looks up any messages that were configured to get emitted
84 * in the API report file and returns them. It also records that they were emitted, which suppresses them from
85 * being shown on the console.
86 */
87 fetchAssociatedMessagesForReviewFile(astDeclaration: AstDeclaration): ExtractorMessage[];
88 /**
89 * This returns all remaining messages that were flagged with `addToApiReportFile`, but which were not
90 * retreieved using `fetchAssociatedMessagesForReviewFile()`.
91 */
92 fetchUnassociatedMessagesForReviewFile(): ExtractorMessage[];
93 /**
94 * This returns the list of remaining messages that were not already processed by
95 * `fetchAssociatedMessagesForReviewFile()` or `fetchUnassociatedMessagesForReviewFile()`.
96 * These messages will be shown on the console.
97 */
98 handleRemainingNonConsoleMessages(): void;
99 logError(messageId: ConsoleMessageId, message: string, properties?: IExtractorMessageProperties): void;
100 logWarning(messageId: ConsoleMessageId, message: string, properties?: IExtractorMessageProperties): void;
101 logInfo(messageId: ConsoleMessageId, message: string, properties?: IExtractorMessageProperties): void;
102 logVerbose(messageId: ConsoleMessageId, message: string, properties?: IExtractorMessageProperties): void;
103 logDiagnosticHeader(title: string): void;
104 logDiagnosticFooter(): void;
105 logDiagnostic(message: string): void;
106 /**
107 * Give the calling application a chance to handle the `ExtractorMessage`, and if not, display it on the console.
108 */
109 private _handleMessage;
110 /**
111 * For a given message, determine the IReportingRule based on the rule tables.
112 */
113 private _getRuleForMessage;
114 /**
115 * Sorts an array of messages according to a reasonable ordering
116 */
117 private _sortMessagesForOutput;
118}
119//# sourceMappingURL=MessageRouter.d.ts.map
\No newline at end of file