source: trip-planner-front/node_modules/@angular/compiler/src/parse_util.js

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

initial commit

  • Property mode set to 100644
File size: 30.2 KB
RevLine 
[6a3a178]1(function (factory) {
2 if (typeof module === "object" && typeof module.exports === "object") {
3 var v = factory(require, exports);
4 if (v !== undefined) module.exports = v;
5 }
6 else if (typeof define === "function" && define.amd) {
7 define("@angular/compiler/src/parse_util", ["require", "exports", "@angular/compiler/src/aot/static_symbol", "@angular/compiler/src/chars", "@angular/compiler/src/util"], factory);
8 }
9})(function (require, exports) {
10 "use strict";
11 Object.defineProperty(exports, "__esModule", { value: true });
12 exports.sanitizeIdentifier = exports.identifierModuleUrl = exports.identifierName = exports.getParseErrors = exports.isSyntaxError = exports.syntaxError = exports.r3JitTypeSourceSpan = exports.typeSourceSpan = exports.ParseError = exports.ParseErrorLevel = exports.ParseSourceSpan = exports.ParseSourceFile = exports.ParseLocation = void 0;
13 /**
14 * @license
15 * Copyright Google LLC All Rights Reserved.
16 *
17 * Use of this source code is governed by an MIT-style license that can be
18 * found in the LICENSE file at https://angular.io/license
19 */
20 var static_symbol_1 = require("@angular/compiler/src/aot/static_symbol");
21 var chars = require("@angular/compiler/src/chars");
22 var util_1 = require("@angular/compiler/src/util");
23 var ParseLocation = /** @class */ (function () {
24 function ParseLocation(file, offset, line, col) {
25 this.file = file;
26 this.offset = offset;
27 this.line = line;
28 this.col = col;
29 }
30 ParseLocation.prototype.toString = function () {
31 return this.offset != null ? this.file.url + "@" + this.line + ":" + this.col : this.file.url;
32 };
33 ParseLocation.prototype.moveBy = function (delta) {
34 var source = this.file.content;
35 var len = source.length;
36 var offset = this.offset;
37 var line = this.line;
38 var col = this.col;
39 while (offset > 0 && delta < 0) {
40 offset--;
41 delta++;
42 var ch = source.charCodeAt(offset);
43 if (ch == chars.$LF) {
44 line--;
45 var priorLine = source.substr(0, offset - 1).lastIndexOf(String.fromCharCode(chars.$LF));
46 col = priorLine > 0 ? offset - priorLine : offset;
47 }
48 else {
49 col--;
50 }
51 }
52 while (offset < len && delta > 0) {
53 var ch = source.charCodeAt(offset);
54 offset++;
55 delta--;
56 if (ch == chars.$LF) {
57 line++;
58 col = 0;
59 }
60 else {
61 col++;
62 }
63 }
64 return new ParseLocation(this.file, offset, line, col);
65 };
66 // Return the source around the location
67 // Up to `maxChars` or `maxLines` on each side of the location
68 ParseLocation.prototype.getContext = function (maxChars, maxLines) {
69 var content = this.file.content;
70 var startOffset = this.offset;
71 if (startOffset != null) {
72 if (startOffset > content.length - 1) {
73 startOffset = content.length - 1;
74 }
75 var endOffset = startOffset;
76 var ctxChars = 0;
77 var ctxLines = 0;
78 while (ctxChars < maxChars && startOffset > 0) {
79 startOffset--;
80 ctxChars++;
81 if (content[startOffset] == '\n') {
82 if (++ctxLines == maxLines) {
83 break;
84 }
85 }
86 }
87 ctxChars = 0;
88 ctxLines = 0;
89 while (ctxChars < maxChars && endOffset < content.length - 1) {
90 endOffset++;
91 ctxChars++;
92 if (content[endOffset] == '\n') {
93 if (++ctxLines == maxLines) {
94 break;
95 }
96 }
97 }
98 return {
99 before: content.substring(startOffset, this.offset),
100 after: content.substring(this.offset, endOffset + 1),
101 };
102 }
103 return null;
104 };
105 return ParseLocation;
106 }());
107 exports.ParseLocation = ParseLocation;
108 var ParseSourceFile = /** @class */ (function () {
109 function ParseSourceFile(content, url) {
110 this.content = content;
111 this.url = url;
112 }
113 return ParseSourceFile;
114 }());
115 exports.ParseSourceFile = ParseSourceFile;
116 var ParseSourceSpan = /** @class */ (function () {
117 /**
118 * Create an object that holds information about spans of tokens/nodes captured during
119 * lexing/parsing of text.
120 *
121 * @param start
122 * The location of the start of the span (having skipped leading trivia).
123 * Skipping leading trivia makes source-spans more "user friendly", since things like HTML
124 * elements will appear to begin at the start of the opening tag, rather than at the start of any
125 * leading trivia, which could include newlines.
126 *
127 * @param end
128 * The location of the end of the span.
129 *
130 * @param fullStart
131 * The start of the token without skipping the leading trivia.
132 * This is used by tooling that splits tokens further, such as extracting Angular interpolations
133 * from text tokens. Such tooling creates new source-spans relative to the original token's
134 * source-span. If leading trivia characters have been skipped then the new source-spans may be
135 * incorrectly offset.
136 *
137 * @param details
138 * Additional information (such as identifier names) that should be associated with the span.
139 */
140 function ParseSourceSpan(start, end, fullStart, details) {
141 if (fullStart === void 0) { fullStart = start; }
142 if (details === void 0) { details = null; }
143 this.start = start;
144 this.end = end;
145 this.fullStart = fullStart;
146 this.details = details;
147 }
148 ParseSourceSpan.prototype.toString = function () {
149 return this.start.file.content.substring(this.start.offset, this.end.offset);
150 };
151 return ParseSourceSpan;
152 }());
153 exports.ParseSourceSpan = ParseSourceSpan;
154 var ParseErrorLevel;
155 (function (ParseErrorLevel) {
156 ParseErrorLevel[ParseErrorLevel["WARNING"] = 0] = "WARNING";
157 ParseErrorLevel[ParseErrorLevel["ERROR"] = 1] = "ERROR";
158 })(ParseErrorLevel = exports.ParseErrorLevel || (exports.ParseErrorLevel = {}));
159 var ParseError = /** @class */ (function () {
160 function ParseError(span, msg, level) {
161 if (level === void 0) { level = ParseErrorLevel.ERROR; }
162 this.span = span;
163 this.msg = msg;
164 this.level = level;
165 }
166 ParseError.prototype.contextualMessage = function () {
167 var ctx = this.span.start.getContext(100, 3);
168 return ctx ? this.msg + " (\"" + ctx.before + "[" + ParseErrorLevel[this.level] + " ->]" + ctx.after + "\")" :
169 this.msg;
170 };
171 ParseError.prototype.toString = function () {
172 var details = this.span.details ? ", " + this.span.details : '';
173 return this.contextualMessage() + ": " + this.span.start + details;
174 };
175 return ParseError;
176 }());
177 exports.ParseError = ParseError;
178 function typeSourceSpan(kind, type) {
179 var moduleUrl = identifierModuleUrl(type);
180 var sourceFileName = moduleUrl != null ? "in " + kind + " " + identifierName(type) + " in " + moduleUrl :
181 "in " + kind + " " + identifierName(type);
182 var sourceFile = new ParseSourceFile('', sourceFileName);
183 return new ParseSourceSpan(new ParseLocation(sourceFile, -1, -1, -1), new ParseLocation(sourceFile, -1, -1, -1));
184 }
185 exports.typeSourceSpan = typeSourceSpan;
186 /**
187 * Generates Source Span object for a given R3 Type for JIT mode.
188 *
189 * @param kind Component or Directive.
190 * @param typeName name of the Component or Directive.
191 * @param sourceUrl reference to Component or Directive source.
192 * @returns instance of ParseSourceSpan that represent a given Component or Directive.
193 */
194 function r3JitTypeSourceSpan(kind, typeName, sourceUrl) {
195 var sourceFileName = "in " + kind + " " + typeName + " in " + sourceUrl;
196 var sourceFile = new ParseSourceFile('', sourceFileName);
197 return new ParseSourceSpan(new ParseLocation(sourceFile, -1, -1, -1), new ParseLocation(sourceFile, -1, -1, -1));
198 }
199 exports.r3JitTypeSourceSpan = r3JitTypeSourceSpan;
200 function syntaxError(msg, parseErrors) {
201 var error = Error(msg);
202 error[ERROR_SYNTAX_ERROR] = true;
203 if (parseErrors)
204 error[ERROR_PARSE_ERRORS] = parseErrors;
205 return error;
206 }
207 exports.syntaxError = syntaxError;
208 var ERROR_SYNTAX_ERROR = 'ngSyntaxError';
209 var ERROR_PARSE_ERRORS = 'ngParseErrors';
210 function isSyntaxError(error) {
211 return error[ERROR_SYNTAX_ERROR];
212 }
213 exports.isSyntaxError = isSyntaxError;
214 function getParseErrors(error) {
215 return error[ERROR_PARSE_ERRORS] || [];
216 }
217 exports.getParseErrors = getParseErrors;
218 var _anonymousTypeIndex = 0;
219 function identifierName(compileIdentifier) {
220 if (!compileIdentifier || !compileIdentifier.reference) {
221 return null;
222 }
223 var ref = compileIdentifier.reference;
224 if (ref instanceof static_symbol_1.StaticSymbol) {
225 return ref.name;
226 }
227 if (ref['__anonymousType']) {
228 return ref['__anonymousType'];
229 }
230 if (ref['__forward_ref__']) {
231 // We do not want to try to stringify a `forwardRef()` function because that would cause the
232 // inner function to be evaluated too early, defeating the whole point of the `forwardRef`.
233 return '__forward_ref__';
234 }
235 var identifier = util_1.stringify(ref);
236 if (identifier.indexOf('(') >= 0) {
237 // case: anonymous functions!
238 identifier = "anonymous_" + _anonymousTypeIndex++;
239 ref['__anonymousType'] = identifier;
240 }
241 else {
242 identifier = sanitizeIdentifier(identifier);
243 }
244 return identifier;
245 }
246 exports.identifierName = identifierName;
247 function identifierModuleUrl(compileIdentifier) {
248 var ref = compileIdentifier.reference;
249 if (ref instanceof static_symbol_1.StaticSymbol) {
250 return ref.filePath;
251 }
252 // Runtime type
253 return "./" + util_1.stringify(ref);
254 }
255 exports.identifierModuleUrl = identifierModuleUrl;
256 function sanitizeIdentifier(name) {
257 return name.replace(/\W/g, '_');
258 }
259 exports.sanitizeIdentifier = sanitizeIdentifier;
260});
261//# sourceMappingURL=data:application/json;base64,eyJ2ZXJzaW9uIjozLCJmaWxlIjoicGFyc2VfdXRpbC5qcyIsInNvdXJjZVJvb3QiOiIiLCJzb3VyY2VzIjpbIi4uLy4uLy4uLy4uLy4uLy4uL3BhY2thZ2VzL2NvbXBpbGVyL3NyYy9wYXJzZV91dGlsLnRzIl0sIm5hbWVzIjpbXSwibWFwcGluZ3MiOiI7Ozs7Ozs7Ozs7OztJQUFBOzs7Ozs7T0FNRztJQUNILHlFQUFpRDtJQUNqRCxtREFBaUM7SUFDakMsbURBQWlDO0lBRWpDO1FBQ0UsdUJBQ1csSUFBcUIsRUFBUyxNQUFjLEVBQVMsSUFBWSxFQUNqRSxHQUFXO1lBRFgsU0FBSSxHQUFKLElBQUksQ0FBaUI7WUFBUyxXQUFNLEdBQU4sTUFBTSxDQUFRO1lBQVMsU0FBSSxHQUFKLElBQUksQ0FBUTtZQUNqRSxRQUFHLEdBQUgsR0FBRyxDQUFRO1FBQUcsQ0FBQztRQUUxQixnQ0FBUSxHQUFSO1lBQ0UsT0FBTyxJQUFJLENBQUMsTUFBTSxJQUFJLElBQUksQ0FBQyxDQUFDLENBQUksSUFBSSxDQUFDLElBQUksQ0FBQyxHQUFHLFNBQUksSUFBSSxDQUFDLElBQUksU0FBSSxJQUFJLENBQUMsR0FBSyxDQUFDLENBQUMsQ0FBQyxJQUFJLENBQUMsSUFBSSxDQUFDLEdBQUcsQ0FBQztR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3RhcnRPZmZzZXQgPSBjb250ZW50Lmxlbmd0aCAtIDE7XG4gICAgICB9XG4gICAgICBsZXQgZW5kT2Zmc2V0ID0gc3RhcnRPZmZzZXQ7XG4gICAgICBsZXQgY3R4Q2hhcnMgPSAwO1xuICAgICAgbGV0IGN0eExpbmVzID0gMDtcblxuICAgICAgd2hpbGUgKGN0eENoYXJzIDwgbWF4Q2hhcnMgJiYgc3RhcnRPZmZzZXQgPiAwKSB7XG4gICAgICAgIHN0YXJ0T2Zmc2V0LS07XG4gICAgICAgIGN0eENoYXJzKys7XG4gICAgICAgIGlmIChjb250ZW50W3N0YXJ0T2Zmc2V0XSA9PSAnXFxuJykge1xuICAgICAgICAgIGlmICgrK2N0eExpbmVzID09IG1heExpbmVzKSB7XG4gICAgICAgICAgICBicmVhaztcbiAgICAgICAgICB9XG4gICAgICAgIH1cbiAgICAgIH1cblxuICAgICAgY3R4Q2hhcnMgPSAwO1xuICAgICAgY3R4TGluZXMgPSAwO1xuICAgICAgd2hpbGUgKGN0eENoYXJzIDwgbWF4Q2hhcnMgJiYgZW5kT2Zmc2V0IDwgY29udGVudC5sZW5ndGggLSAxKSB7XG4gICAgICAgIGVuZE9mZnNldCsrO1xuICAgICAgICBjdHhDaGFycysrO1xuICAgICAgICBpZiAoY29udGVudFtlbmRPZmZzZXRdID09ICdcXG4nKSB7XG4gICAgICAgICAgaWYgKCsrY3R4TGluZXMgPT0gbWF4TGluZXMpIHtcbiAgICAgICAgICAgIGJyZWFrO1xuICAgICAgICAgIH1cbiAgICAgICAgfVxuICAgICAgfVxuXG4gICAgICByZXR1cm4ge1xuICAgICAgICBiZWZvcmU6IGNvbnRlbnQuc3Vic3RyaW5nKHN0YXJ0T2Zmc2V0LCB0aGlzLm9mZnNldCksXG4gICAgICAgIGFmdGVyOiBjb250ZW50LnN1YnN0cmluZyh0aGlzLm9mZnNldCwgZW5kT2Zmc2V0ICsgMSksXG4gICAgICB9O1xuICAgIH1cblxuICAgIHJldHVybiBudWxs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ZpZXIpO1xuICB9XG4gIHJldHVybiBpZGVudGlmaWVyO1xufVxuXG5leHBvcnQgZnVuY3Rpb24gaWRlbnRpZmllck1vZHVsZVVybChjb21waWxlSWRlbnRpZmllcjogQ29tcGlsZUlkZW50aWZpZXJNZXRhZGF0YSk6IHN0cmluZyB7XG4gIGNvbnN0IHJlZiA9IGNvbXBpbGVJZGVudGlmaWVyLnJlZmVyZW5jZTtcbiAgaWYgKHJlZiBpbnN0YW5jZW9mIFN0YXRpY1N5bWJvbCkge1xuICAgIHJldHVybiByZWYuZmlsZVBhdGg7XG4gIH1cbiAgLy8gUnVudGltZSB0eXBlXG4gIHJldHVybiBgLi8ke3N0cmluZ2lmeShyZWYpfWA7XG59XG5cbmV4cG9ydCBpbnRlcmZhY2UgQ29tcGlsZUlkZW50aWZpZXJNZXRhZGF0YSB7XG4gIHJlZmVyZW5jZTogYW55O1xufVxuXG5leHBvcnQgZnVuY3Rpb24gc2FuaXRpemVJZGVudGlmaWVyKG5hbWU6IHN0cmluZyk6IHN0cmluZyB7XG4gIHJldHVybiBuYW1lLnJlcGxhY2UoL1xcVy9nLCAnXycpO1xufVxuIl19
Note: See TracBrowser for help on using the repository browser.