1 | import doctrine from "@teppeis/doctrine";
|
2 | import type { Comment, Program } from "estree-jsx";
|
3 | export interface ParserOptions {
|
4 | provideRoots?: string[];
|
5 | replaceMap?: Map<string, string>;
|
6 | providedNamespace?: string[];
|
7 | parserOptions?: any;
|
8 | ignoreProvides?: boolean;
|
9 | }
|
10 | export interface FixclosureInfo {
|
11 | provided: string[];
|
12 | required: string[];
|
13 | requireTyped: string[];
|
14 | forwardDeclared: string[];
|
15 | toProvide: string[];
|
16 | toRequire: string[];
|
17 | toRequireType: string[];
|
18 | toForwardDeclare: string[];
|
19 | ignoredProvide: string[];
|
20 | ignoredRequire: string[];
|
21 | ignoredRequireType: string[];
|
22 | ignoredForwardDeclare: string[];
|
23 | provideStart: number;
|
24 | provideEnd: number;
|
25 | }
|
26 | export declare class Parser {
|
27 | options: ParserOptions;
|
28 | private provideRoots_;
|
29 | private ignoreProvides_;
|
30 | private replaceMap_;
|
31 | private providedNamespaces_;
|
32 | private ignorePackages_;
|
33 | private minLine_;
|
34 | private maxLine_;
|
35 | constructor(opt_options?: ParserOptions);
|
36 | parse(src: string): FixclosureInfo;
|
37 | parseAst(program: Program, comments: Comment[]): FixclosureInfo;
|
38 | private extractToProvide_;
|
39 | /**
|
40 | * @return true if the node has JSDoc that includes @typedef and not @private
|
41 | * This method assume the JSDoc is at a line just before the node.
|
42 | * Use ESLint context like `context.getJSDocComment(node)` if possible.
|
43 | */
|
44 | private hasTypedefAnnotation_;
|
45 | private getSuppressProvideComments_;
|
46 | private getSuppressRequireComments_;
|
47 | private extractToRequire_;
|
48 | private extractToRequireTypeFromJsDoc_;
|
49 | extractType(type: doctrine.Type | null): string[];
|
50 | /**
|
51 | * Extract `goog.require('goog.foo') // fixclosure: ignore`.
|
52 | */
|
53 | private extractIgnored_;
|
54 | private extractProvided_;
|
55 | private extractRequired_;
|
56 | private extractRequireTyped_;
|
57 | private extractForwardDeclared_;
|
58 | /**
|
59 | * @param parsed
|
60 | * @param method like 'goog.provide' or 'goog.require'
|
61 | */
|
62 | private extractGoogDeclaration_;
|
63 | private traverseProgram_;
|
64 | /**
|
65 | * @return True if the item has a root namespace to extract.
|
66 | */
|
67 | private provideRootFilter_;
|
68 | /**
|
69 | * @return Provided namespace
|
70 | */
|
71 | private toProvideMapper_;
|
72 | /**
|
73 | * @return Required namespace
|
74 | */
|
75 | private toRequireMapper_;
|
76 | private toRequireFilter_;
|
77 | /**
|
78 | * Filter toProvide and toRequire if it is suppressed.
|
79 | */
|
80 | private suppressFilter_;
|
81 | private getRequiredPackageName_;
|
82 | private getProvidedPackageName_;
|
83 | private isIgnorePackage_;
|
84 | private isPrivateProp_;
|
85 | private replaceMethod_;
|
86 | private isProvidedNamespace_;
|
87 | private updateMinMaxLine_;
|
88 | }
|