Actualizacion maquina principal
[dotfiles/.git] / .config / coc / extensions / node_modules / coc-prettier / node_modules / @typescript-eslint / typescript-estree / dist / ast-converter.js
1 "use strict";
2 Object.defineProperty(exports, "__esModule", { value: true });
3 exports.astConverter = void 0;
4 const convert_1 = require("./convert");
5 const convert_comments_1 = require("./convert-comments");
6 const node_utils_1 = require("./node-utils");
7 const simple_traverse_1 = require("./simple-traverse");
8 function astConverter(ast, extra, shouldPreserveNodeMaps) {
9     /**
10      * The TypeScript compiler produced fundamental parse errors when parsing the
11      * source.
12      */
13     // internal typescript api...
14     // eslint-disable-next-line @typescript-eslint/no-explicit-any
15     const parseDiagnostics = ast.parseDiagnostics;
16     if (parseDiagnostics.length) {
17         throw convert_1.convertError(parseDiagnostics[0]);
18     }
19     /**
20      * Recursively convert the TypeScript AST into an ESTree-compatible AST
21      */
22     const instance = new convert_1.Converter(ast, {
23         errorOnUnknownASTType: extra.errorOnUnknownASTType || false,
24         useJSXTextNode: extra.useJSXTextNode || false,
25         shouldPreserveNodeMaps,
26     });
27     const estree = instance.convertProgram();
28     /**
29      * Optionally remove range and loc if specified
30      */
31     if (!extra.range || !extra.loc) {
32         simple_traverse_1.simpleTraverse(estree, {
33             enter: node => {
34                 if (!extra.range) {
35                     delete node.range;
36                 }
37                 if (!extra.loc) {
38                     delete node.loc;
39                 }
40             },
41         });
42     }
43     /**
44      * Optionally convert and include all tokens in the AST
45      */
46     if (extra.tokens) {
47         estree.tokens = node_utils_1.convertTokens(ast);
48     }
49     /**
50      * Optionally convert and include all comments in the AST
51      */
52     if (extra.comment) {
53         estree.comments = convert_comments_1.convertComments(ast, extra.code);
54     }
55     const astMaps = instance.getASTMaps();
56     return { estree, astMaps };
57 }
58 exports.astConverter = astConverter;
59 //# sourceMappingURL=ast-converter.js.map