source: trip-planner-front/node_modules/@angular/compiler-cli/src/diagnostics/translate_diagnostics.js@ 8d391a1

Last change on this file since 8d391a1 was 6a3a178, checked in by Ema <ema_spirova@…>, 3 years ago

initial commit

  • Property mode set to 100644
File size: 7.4 KB
Line 
1/**
2 * @license
3 * Copyright Google LLC All Rights Reserved.
4 *
5 * Use of this source code is governed by an MIT-style license that can be
6 * found in the LICENSE file at https://angular.io/license
7 */
8(function (factory) {
9 if (typeof module === "object" && typeof module.exports === "object") {
10 var v = factory(require, exports);
11 if (v !== undefined) module.exports = v;
12 }
13 else if (typeof define === "function" && define.amd) {
14 define("@angular/compiler-cli/src/diagnostics/translate_diagnostics", ["require", "exports", "typescript", "@angular/compiler-cli/src/transformers/api", "@angular/compiler-cli/src/transformers/util"], factory);
15 }
16})(function (require, exports) {
17 "use strict";
18 Object.defineProperty(exports, "__esModule", { value: true });
19 exports.translateDiagnostics = void 0;
20 var ts = require("typescript");
21 var api_1 = require("@angular/compiler-cli/src/transformers/api");
22 var util_1 = require("@angular/compiler-cli/src/transformers/util");
23 function translateDiagnostics(host, untranslatedDiagnostics) {
24 var ts = [];
25 var ng = [];
26 untranslatedDiagnostics.forEach(function (diagnostic) {
27 if (diagnostic.file && diagnostic.start && util_1.GENERATED_FILES.test(diagnostic.file.fileName)) {
28 // We need to filter out diagnostics about unused functions as
29 // they are in fact referenced by nobody and only serve to surface
30 // type check errors.
31 if (diagnostic.code === /* ... is declared but never used */ 6133) {
32 return;
33 }
34 var span = sourceSpanOf(host, diagnostic.file, diagnostic.start);
35 if (span) {
36 var fileName = span.start.file.url;
37 ng.push({
38 messageText: diagnosticMessageToString(diagnostic.messageText),
39 category: diagnostic.category,
40 span: span,
41 source: api_1.SOURCE,
42 code: api_1.DEFAULT_ERROR_CODE
43 });
44 }
45 }
46 else {
47 ts.push(diagnostic);
48 }
49 });
50 return { ts: ts, ng: ng };
51 }
52 exports.translateDiagnostics = translateDiagnostics;
53 function sourceSpanOf(host, source, start) {
54 var _a = ts.getLineAndCharacterOfPosition(source, start), line = _a.line, character = _a.character;
55 return host.parseSourceSpanOf(source.fileName, line, character);
56 }
57 function diagnosticMessageToString(message) {
58 return ts.flattenDiagnosticMessageText(message, '\n');
59 }
60});
61//# sourceMappingURL=data:application/json;base64,eyJ2ZXJzaW9uIjozLCJmaWxlIjoidHJhbnNsYXRlX2RpYWdub3N0aWNzLmpzIiwic291cmNlUm9vdCI6IiIsInNvdXJjZXMiOlsiLi4vLi4vLi4vLi4vLi4vLi4vLi4vcGFja2FnZXMvY29tcGlsZXItY2xpL3NyYy9kaWFnbm9zdGljcy90cmFuc2xhdGVfZGlhZ25vc3RpY3MudHMiXSwibmFtZXMiOltdLCJtYXBwaW5ncyI6IkFBQUE7Ozs7OztHQU1HOzs7Ozs7Ozs7Ozs7O0lBR0gsK0JBQWlDO0lBRWpDLGtFQUEyRTtJQUMzRSxvRUFBcUQ7SUFNckQsU0FBZ0Isb0JBQW9CLENBQ2hDLElBQW1CLEVBQUUsdUJBQXFEO1FBRTVFLElBQU0sRUFBRSxHQUFvQixFQUFFLENBQUM7UUFDL0IsSUFBTSxFQUFFLEdBQWlCLEVBQUUsQ0FBQztRQUU1Qix1QkFBdUIsQ0FBQyxPQUFPLENBQUMsVUFBQyxVQUFVO1lBQ3pDLElBQUksVUFBVSxDQUFDLElBQUksSUFBSSxVQUFVLENBQUMsS0FBSyxJQUFJLHNCQUFlLENBQUMsSUFBSSxDQUFDLFVBQVUsQ0FBQyxJQUFJLENBQUMsUUFBUSxDQUFDLEVBQUU7Z0JBQ3pGLDhEQUE4RDtnQkFDOUQsa0VBQWtFO2dCQUNsRSxxQkFBcUI7Z0JBQ3JCLElBQUksVUFBVSxDQUFDLElBQUksS0FBSyxvQ0FBb0MsQ0FBQyxJQUFJLEVBQUU7b0JBQ2pFLE9BQU87aUJBQ1I7Z0JBQ0QsSUFBTSxJQUFJLEdBQUcsWUFBWSxDQUFDLElBQUksRUFBRSxVQUFVLENBQUMsSUFBSSxFQUFFL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SBlbHNlIHtcbiAgICAgIHRzLnB1c2goZGlhZ25vc3RpYyk7XG4gICAgfVxuICB9KTtcbiAgcmV0dXJuIHt0cywgbmd9O1xufVxuXG5mdW5jdGlvbiBzb3VyY2VTcGFuT2YoaG9zdDogVHlwZUNoZWNrSG9zdCwgc291cmNlOiB0cy5Tb3VyY2VGaWxlLCBzdGFydDogbnVtYmVyKTogUGFyc2VTb3VyY2VTcGFufFxuICAgIG51bGwge1xuICBjb25zdCB7bGluZSwgY2hhcmFjdGVyfSA9IHRzLmdldExpbmVBbmRDaGFyYWN0ZXJPZlBvc2l0aW9uKHNvdXJjZSwgc3RhcnQpO1xuICByZXR1cm4gaG9zdC5wYXJzZVNvdXJjZVNwYW5PZihzb3VyY2UuZmlsZU5hbWUsIGxpbmUsIGNoYXJhY3Rlcik7XG59XG5cbmZ1bmN0aW9uIGRpYWdub3N0aWNNZXNzYWdlVG9TdHJpbmcobWVzc2FnZTogdHMuRGlhZ25vc3RpY01lc3NhZ2VDaGFpbnxzdHJpbmcpOiBzdHJpbmcge1xuICByZXR1cm4gdHMuZmxhdHRlbkRpYWdub3N0aWNNZXNzYWdlVGV4dChtZXNzYWdlLCAnXFxuJyk7XG59XG4iXX0=
Note: See TracBrowser for help on using the repository browser.