@angular/language-service 9.1.6 → 9.1.7

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
@@ -1,5 +1,5 @@
1
1
  /**
2
- * @license Angular v9.1.6
2
+ * @license Angular v9.1.7
3
3
  * Copyright Google Inc. All Rights Reserved.
4
4
  * License: MIT
5
5
  */
@@ -3691,7 +3691,6 @@ define(['exports', 'typescript/lib/tsserverlibrary', 'typescript', 'path'], func
3691
3691
  Identifiers.stylePropInterpolate7 = { name: 'ɵɵstylePropInterpolate7', moduleName: CORE$1 };
3692
3692
  Identifiers.stylePropInterpolate8 = { name: 'ɵɵstylePropInterpolate8', moduleName: CORE$1 };
3693
3693
  Identifiers.stylePropInterpolateV = { name: 'ɵɵstylePropInterpolateV', moduleName: CORE$1 };
3694
- Identifiers.containerCreate = { name: 'ɵɵcontainer', moduleName: CORE$1 };
3695
3694
  Identifiers.nextContext = { name: 'ɵɵnextContext', moduleName: CORE$1 };
3696
3695
  Identifiers.templateCreate = { name: 'ɵɵtemplate', moduleName: CORE$1 };
3697
3696
  Identifiers.text = { name: 'ɵɵtext', moduleName: CORE$1 };
@@ -7196,6 +7195,15 @@ define(['exports', 'typescript/lib/tsserverlibrary', 'typescript', 'path'], func
7196
7195
  };
7197
7196
  return AST;
7198
7197
  }());
7198
+ var ASTWithName = /** @class */ (function (_super) {
7199
+ __extends(ASTWithName, _super);
7200
+ function ASTWithName(span, sourceSpan, nameSpan) {
7201
+ var _this = _super.call(this, span, sourceSpan) || this;
7202
+ _this.nameSpan = nameSpan;
7203
+ return _this;
7204
+ }
7205
+ return ASTWithName;
7206
+ }(AST));
7199
7207
  /**
7200
7208
  * Represents a quoted expression of the form:
7201
7209
  *
@@ -7281,8 +7289,8 @@ define(['exports', 'typescript/lib/tsserverlibrary', 'typescript', 'path'], func
7281
7289
  }(AST));
7282
7290
  var PropertyRead = /** @class */ (function (_super) {
7283
7291
  __extends(PropertyRead, _super);
7284
- function PropertyRead(span, sourceSpan, receiver, name) {
7285
- var _this = _super.call(this, span, sourceSpan) || this;
7292
+ function PropertyRead(span, sourceSpan, nameSpan, receiver, name) {
7293
+ var _this = _super.call(this, span, sourceSpan, nameSpan) || this;
7286
7294
  _this.receiver = receiver;
7287
7295
  _this.name = name;
7288
7296
  return _this;
@@ -7292,11 +7300,11 @@ define(['exports', 'typescript/lib/tsserverlibrary', 'typescript', 'path'], func
7292
7300
  return visitor.visitPropertyRead(this, context);
7293
7301
  };
7294
7302
  return PropertyRead;
7295
- }(AST));
7303
+ }(ASTWithName));
7296
7304
  var PropertyWrite = /** @class */ (function (_super) {
7297
7305
  __extends(PropertyWrite, _super);
7298
- function PropertyWrite(span, sourceSpan, receiver, name, value) {
7299
- var _this = _super.call(this, span, sourceSpan) || this;
7306
+ function PropertyWrite(span, sourceSpan, nameSpan, receiver, name, value) {
7307
+ var _this = _super.call(this, span, sourceSpan, nameSpan) || this;
7300
7308
  _this.receiver = receiver;
7301
7309
  _this.name = name;
7302
7310
  _this.value = value;
@@ -7307,11 +7315,11 @@ define(['exports', 'typescript/lib/tsserverlibrary', 'typescript', 'path'], func
7307
7315
  return visitor.visitPropertyWrite(this, context);
7308
7316
  };
7309
7317
  return PropertyWrite;
7310
- }(AST));
7318
+ }(ASTWithName));
7311
7319
  var SafePropertyRead = /** @class */ (function (_super) {
7312
7320
  __extends(SafePropertyRead, _super);
7313
- function SafePropertyRead(span, sourceSpan, receiver, name) {
7314
- var _this = _super.call(this, span, sourceSpan) || this;
7321
+ function SafePropertyRead(span, sourceSpan, nameSpan, receiver, name) {
7322
+ var _this = _super.call(this, span, sourceSpan, nameSpan) || this;
7315
7323
  _this.receiver = receiver;
7316
7324
  _this.name = name;
7317
7325
  return _this;
@@ -7321,7 +7329,7 @@ define(['exports', 'typescript/lib/tsserverlibrary', 'typescript', 'path'], func
7321
7329
  return visitor.visitSafePropertyRead(this, context);
7322
7330
  };
7323
7331
  return SafePropertyRead;
7324
- }(AST));
7332
+ }(ASTWithName));
7325
7333
  var KeyedRead = /** @class */ (function (_super) {
7326
7334
  __extends(KeyedRead, _super);
7327
7335
  function KeyedRead(span, sourceSpan, obj, key) {
@@ -7354,11 +7362,10 @@ define(['exports', 'typescript/lib/tsserverlibrary', 'typescript', 'path'], func
7354
7362
  var BindingPipe = /** @class */ (function (_super) {
7355
7363
  __extends(BindingPipe, _super);
7356
7364
  function BindingPipe(span, sourceSpan, exp, name, args, nameSpan) {
7357
- var _this = _super.call(this, span, sourceSpan) || this;
7365
+ var _this = _super.call(this, span, sourceSpan, nameSpan) || this;
7358
7366
  _this.exp = exp;
7359
7367
  _this.name = name;
7360
7368
  _this.args = args;
7361
- _this.nameSpan = nameSpan;
7362
7369
  return _this;
7363
7370
  }
7364
7371
  BindingPipe.prototype.visit = function (visitor, context) {
@@ -7366,7 +7373,7 @@ define(['exports', 'typescript/lib/tsserverlibrary', 'typescript', 'path'], func
7366
7373
  return visitor.visitPipe(this, context);
7367
7374
  };
7368
7375
  return BindingPipe;
7369
- }(AST));
7376
+ }(ASTWithName));
7370
7377
  var LiteralPrimitive = /** @class */ (function (_super) {
7371
7378
  __extends(LiteralPrimitive, _super);
7372
7379
  function LiteralPrimitive(span, sourceSpan, value) {
@@ -7464,8 +7471,8 @@ define(['exports', 'typescript/lib/tsserverlibrary', 'typescript', 'path'], func
7464
7471
  }(AST));
7465
7472
  var MethodCall = /** @class */ (function (_super) {
7466
7473
  __extends(MethodCall, _super);
7467
- function MethodCall(span, sourceSpan, receiver, name, args) {
7468
- var _this = _super.call(this, span, sourceSpan) || this;
7474
+ function MethodCall(span, sourceSpan, nameSpan, receiver, name, args) {
7475
+ var _this = _super.call(this, span, sourceSpan, nameSpan) || this;
7469
7476
  _this.receiver = receiver;
7470
7477
  _this.name = name;
7471
7478
  _this.args = args;
@@ -7476,11 +7483,11 @@ define(['exports', 'typescript/lib/tsserverlibrary', 'typescript', 'path'], func
7476
7483
  return visitor.visitMethodCall(this, context);
7477
7484
  };
7478
7485
  return MethodCall;
7479
- }(AST));
7486
+ }(ASTWithName));
7480
7487
  var SafeMethodCall = /** @class */ (function (_super) {
7481
7488
  __extends(SafeMethodCall, _super);
7482
- function SafeMethodCall(span, sourceSpan, receiver, name, args) {
7483
- var _this = _super.call(this, span, sourceSpan) || this;
7489
+ function SafeMethodCall(span, sourceSpan, nameSpan, receiver, name, args) {
7490
+ var _this = _super.call(this, span, sourceSpan, nameSpan) || this;
7484
7491
  _this.receiver = receiver;
7485
7492
  _this.name = name;
7486
7493
  _this.args = args;
@@ -7491,7 +7498,7 @@ define(['exports', 'typescript/lib/tsserverlibrary', 'typescript', 'path'], func
7491
7498
  return visitor.visitSafeMethodCall(this, context);
7492
7499
  };
7493
7500
  return SafeMethodCall;
7494
- }(AST));
7501
+ }(ASTWithName));
7495
7502
  var FunctionCall = /** @class */ (function (_super) {
7496
7503
  __extends(FunctionCall, _super);
7497
7504
  function FunctionCall(span, sourceSpan, target, args) {
@@ -7678,19 +7685,19 @@ define(['exports', 'typescript/lib/tsserverlibrary', 'typescript', 'path'], func
7678
7685
  return new LiteralPrimitive(ast.span, ast.sourceSpan, ast.value);
7679
7686
  };
7680
7687
  AstTransformer.prototype.visitPropertyRead = function (ast, context) {
7681
- return new PropertyRead(ast.span, ast.sourceSpan, ast.receiver.visit(this), ast.name);
7688
+ return new PropertyRead(ast.span, ast.sourceSpan, ast.nameSpan, ast.receiver.visit(this), ast.name);
7682
7689
  };
7683
7690
  AstTransformer.prototype.visitPropertyWrite = function (ast, context) {
7684
- return new PropertyWrite(ast.span, ast.sourceSpan, ast.receiver.visit(this), ast.name, ast.value.visit(this));
7691
+ return new PropertyWrite(ast.span, ast.sourceSpan, ast.nameSpan, ast.receiver.visit(this), ast.name, ast.value.visit(this));
7685
7692
  };
7686
7693
  AstTransformer.prototype.visitSafePropertyRead = function (ast, context) {
7687
- return new SafePropertyRead(ast.span, ast.sourceSpan, ast.receiver.visit(this), ast.name);
7694
+ return new SafePropertyRead(ast.span, ast.sourceSpan, ast.nameSpan, ast.receiver.visit(this), ast.name);
7688
7695
  };
7689
7696
  AstTransformer.prototype.visitMethodCall = function (ast, context) {
7690
- return new MethodCall(ast.span, ast.sourceSpan, ast.receiver.visit(this), ast.name, this.visitAll(ast.args));
7697
+ return new MethodCall(ast.span, ast.sourceSpan, ast.nameSpan, ast.receiver.visit(this), ast.name, this.visitAll(ast.args));
7691
7698
  };
7692
7699
  AstTransformer.prototype.visitSafeMethodCall = function (ast, context) {
7693
- return new SafeMethodCall(ast.span, ast.sourceSpan, ast.receiver.visit(this), ast.name, this.visitAll(ast.args));
7700
+ return new SafeMethodCall(ast.span, ast.sourceSpan, ast.nameSpan, ast.receiver.visit(this), ast.name, this.visitAll(ast.args));
7694
7701
  };
7695
7702
  AstTransformer.prototype.visitFunctionCall = function (ast, context) {
7696
7703
  return new FunctionCall(ast.span, ast.sourceSpan, ast.target.visit(this), this.visitAll(ast.args));
@@ -7757,7 +7764,7 @@ define(['exports', 'typescript/lib/tsserverlibrary', 'typescript', 'path'], func
7757
7764
  AstMemoryEfficientTransformer.prototype.visitPropertyRead = function (ast, context) {
7758
7765
  var receiver = ast.receiver.visit(this);
7759
7766
  if (receiver !== ast.receiver) {
7760
- return new PropertyRead(ast.span, ast.sourceSpan, receiver, ast.name);
7767
+ return new PropertyRead(ast.span, ast.sourceSpan, ast.nameSpan, receiver, ast.name);
7761
7768
  }
7762
7769
  return ast;
7763
7770
  };
@@ -7765,14 +7772,14 @@ define(['exports', 'typescript/lib/tsserverlibrary', 'typescript', 'path'], func
7765
7772
  var receiver = ast.receiver.visit(this);
7766
7773
  var value = ast.value.visit(this);
7767
7774
  if (receiver !== ast.receiver || value !== ast.value) {
7768
- return new PropertyWrite(ast.span, ast.sourceSpan, receiver, ast.name, value);
7775
+ return new PropertyWrite(ast.span, ast.sourceSpan, ast.nameSpan, receiver, ast.name, value);
7769
7776
  }
7770
7777
  return ast;
7771
7778
  };
7772
7779
  AstMemoryEfficientTransformer.prototype.visitSafePropertyRead = function (ast, context) {
7773
7780
  var receiver = ast.receiver.visit(this);
7774
7781
  if (receiver !== ast.receiver) {
7775
- return new SafePropertyRead(ast.span, ast.sourceSpan, receiver, ast.name);
7782
+ return new SafePropertyRead(ast.span, ast.sourceSpan, ast.nameSpan, receiver, ast.name);
7776
7783
  }
7777
7784
  return ast;
7778
7785
  };
@@ -7780,7 +7787,7 @@ define(['exports', 'typescript/lib/tsserverlibrary', 'typescript', 'path'], func
7780
7787
  var receiver = ast.receiver.visit(this);
7781
7788
  var args = this.visitAll(ast.args);
7782
7789
  if (receiver !== ast.receiver || args !== ast.args) {
7783
- return new MethodCall(ast.span, ast.sourceSpan, receiver, ast.name, args);
7790
+ return new MethodCall(ast.span, ast.sourceSpan, ast.nameSpan, receiver, ast.name, args);
7784
7791
  }
7785
7792
  return ast;
7786
7793
  };
@@ -7788,7 +7795,7 @@ define(['exports', 'typescript/lib/tsserverlibrary', 'typescript', 'path'], func
7788
7795
  var receiver = ast.receiver.visit(this);
7789
7796
  var args = this.visitAll(ast.args);
7790
7797
  if (receiver !== ast.receiver || args !== ast.args) {
7791
- return new SafeMethodCall(ast.span, ast.sourceSpan, receiver, ast.name, args);
7798
+ return new SafeMethodCall(ast.span, ast.sourceSpan, ast.nameSpan, receiver, ast.name, args);
7792
7799
  }
7793
7800
  return ast;
7794
7801
  };
@@ -8515,10 +8522,10 @@ define(['exports', 'typescript/lib/tsserverlibrary', 'typescript', 'path'], func
8515
8522
  // Convert the ast to an unguarded access to the receiver's member. The map will substitute
8516
8523
  // leftMostNode with its unguarded version in the call to `this.visit()`.
8517
8524
  if (leftMostSafe instanceof SafeMethodCall) {
8518
- this._nodeMap.set(leftMostSafe, new MethodCall(leftMostSafe.span, leftMostSafe.sourceSpan, leftMostSafe.receiver, leftMostSafe.name, leftMostSafe.args));
8525
+ this._nodeMap.set(leftMostSafe, new MethodCall(leftMostSafe.span, leftMostSafe.sourceSpan, leftMostSafe.nameSpan, leftMostSafe.receiver, leftMostSafe.name, leftMostSafe.args));
8519
8526
  }
8520
8527
  else {
8521
- this._nodeMap.set(leftMostSafe, new PropertyRead(leftMostSafe.span, leftMostSafe.sourceSpan, leftMostSafe.receiver, leftMostSafe.name));
8528
+ this._nodeMap.set(leftMostSafe, new PropertyRead(leftMostSafe.span, leftMostSafe.sourceSpan, leftMostSafe.nameSpan, leftMostSafe.receiver, leftMostSafe.name));
8522
8529
  }
8523
8530
  // Recursively convert the node now without the guarded member access.
8524
8531
  var access = this._visit(ast, _Mode.Expression);
@@ -14380,10 +14387,41 @@ define(['exports', 'typescript/lib/tsserverlibrary', 'typescript', 'path'], func
14380
14387
  enumerable: true,
14381
14388
  configurable: true
14382
14389
  });
14390
+ Object.defineProperty(_ParseAST.prototype, "atEOF", {
14391
+ /** Whether all the parser input has been processed. */
14392
+ get: function () {
14393
+ return this.index >= this.tokens.length;
14394
+ },
14395
+ enumerable: true,
14396
+ configurable: true
14397
+ });
14383
14398
  Object.defineProperty(_ParseAST.prototype, "inputIndex", {
14399
+ /**
14400
+ * Index of the next token to be processed, or the end of the last token if all have been
14401
+ * processed.
14402
+ */
14384
14403
  get: function () {
14385
- return (this.index < this.tokens.length) ? this.next.index + this.offset :
14386
- this.inputLength + this.offset;
14404
+ return this.atEOF ? this.currentEndIndex : this.next.index + this.offset;
14405
+ },
14406
+ enumerable: true,
14407
+ configurable: true
14408
+ });
14409
+ Object.defineProperty(_ParseAST.prototype, "currentEndIndex", {
14410
+ /**
14411
+ * End index of the last processed token, or the start of the first token if none have been
14412
+ * processed.
14413
+ */
14414
+ get: function () {
14415
+ if (this.index > 0) {
14416
+ var curToken = this.peek(-1);
14417
+ return curToken.end + this.offset;
14418
+ }
14419
+ // No tokens have been processed yet; return the next token's start or the length of the input
14420
+ // if there is no token.
14421
+ if (this.tokens.length === 0) {
14422
+ return this.inputLength + this.offset;
14423
+ }
14424
+ return this.next.index + this.offset;
14387
14425
  },
14388
14426
  enumerable: true,
14389
14427
  configurable: true
@@ -14399,12 +14437,7 @@ define(['exports', 'typescript/lib/tsserverlibrary', 'typescript', 'path'], func
14399
14437
  configurable: true
14400
14438
  });
14401
14439
  _ParseAST.prototype.span = function (start) {
14402
- // `end` is either the
14403
- // - end index of the current token
14404
- // - start of the first token (this can happen e.g. when creating an implicit receiver)
14405
- var curToken = this.peek(-1);
14406
- var end = this.index > 0 ? curToken.end + this.offset : this.inputIndex;
14407
- return new ParseSpan(start, end);
14440
+ return new ParseSpan(start, this.currentEndIndex);
14408
14441
  };
14409
14442
  _ParseAST.prototype.sourceSpan = function (start) {
14410
14443
  var serial = start + "@" + this.inputIndex;
@@ -14788,7 +14821,9 @@ define(['exports', 'typescript/lib/tsserverlibrary', 'typescript', 'path'], func
14788
14821
  _ParseAST.prototype.parseAccessMemberOrMethodCall = function (receiver, isSafe) {
14789
14822
  if (isSafe === void 0) { isSafe = false; }
14790
14823
  var start = receiver.span.start;
14824
+ var nameStart = this.inputIndex;
14791
14825
  var id = this.expectIdentifierOrKeyword();
14826
+ var nameSpan = this.sourceSpan(nameStart);
14792
14827
  if (this.consumeOptionalCharacter($LPAREN)) {
14793
14828
  this.rparensExpected++;
14794
14829
  var args = this.parseCallArguments();
@@ -14796,8 +14831,8 @@ define(['exports', 'typescript/lib/tsserverlibrary', 'typescript', 'path'], func
14796
14831
  this.rparensExpected--;
14797
14832
  var span = this.span(start);
14798
14833
  var sourceSpan = this.sourceSpan(start);
14799
- return isSafe ? new SafeMethodCall(span, sourceSpan, receiver, id, args) :
14800
- new MethodCall(span, sourceSpan, receiver, id, args);
14834
+ return isSafe ? new SafeMethodCall(span, sourceSpan, nameSpan, receiver, id, args) :
14835
+ new MethodCall(span, sourceSpan, nameSpan, receiver, id, args);
14801
14836
  }
14802
14837
  else {
14803
14838
  if (isSafe) {
@@ -14806,7 +14841,7 @@ define(['exports', 'typescript/lib/tsserverlibrary', 'typescript', 'path'], func
14806
14841
  return new EmptyExpr(this.span(start), this.sourceSpan(start));
14807
14842
  }
14808
14843
  else {
14809
- return new SafePropertyRead(this.span(start), this.sourceSpan(start), receiver, id);
14844
+ return new SafePropertyRead(this.span(start), this.sourceSpan(start), nameSpan, receiver, id);
14810
14845
  }
14811
14846
  }
14812
14847
  else {
@@ -14816,10 +14851,10 @@ define(['exports', 'typescript/lib/tsserverlibrary', 'typescript', 'path'], func
14816
14851
  return new EmptyExpr(this.span(start), this.sourceSpan(start));
14817
14852
  }
14818
14853
  var value = this.parseConditional();
14819
- return new PropertyWrite(this.span(start), this.sourceSpan(start), receiver, id, value);
14854
+ return new PropertyWrite(this.span(start), this.sourceSpan(start), nameSpan, receiver, id, value);
14820
14855
  }
14821
14856
  else {
14822
- return new PropertyRead(this.span(start), this.sourceSpan(start), receiver, id);
14857
+ return new PropertyRead(this.span(start), this.sourceSpan(start), nameSpan, receiver, id);
14823
14858
  }
14824
14859
  }
14825
14860
  }
@@ -18114,7 +18149,7 @@ define(['exports', 'typescript/lib/tsserverlibrary', 'typescript', 'path'], func
18114
18149
  var slotPseudoLocal = "PIPE:" + slot;
18115
18150
  // Allocate one slot for the result plus one slot per pipe argument
18116
18151
  var pureFunctionSlot = this.allocatePureFunctionSlots(2 + pipe.args.length);
18117
- var target = new PropertyRead(pipe.span, pipe.sourceSpan, new ImplicitReceiver(pipe.span, pipe.sourceSpan), slotPseudoLocal);
18152
+ var target = new PropertyRead(pipe.span, pipe.sourceSpan, pipe.nameSpan, new ImplicitReceiver(pipe.span, pipe.sourceSpan), slotPseudoLocal);
18118
18153
  var _a = pipeBindingCallInfo(pipe.args), identifier = _a.identifier, isVarLength = _a.isVarLength;
18119
18154
  this.definePipe(pipe.name, slotPseudoLocal, slot, importExpr(identifier));
18120
18155
  var args = __spread([pipe.exp], pipe.args);
@@ -19566,7 +19601,7 @@ define(['exports', 'typescript/lib/tsserverlibrary', 'typescript', 'path'], func
19566
19601
  * Use of this source code is governed by an MIT-style license that can be
19567
19602
  * found in the LICENSE file at https://angular.io/license
19568
19603
  */
19569
- var VERSION$1 = new Version('9.1.6');
19604
+ var VERSION$1 = new Version('9.1.7');
19570
19605
 
19571
19606
  /**
19572
19607
  * @license
@@ -25729,6 +25764,250 @@ define(['exports', 'typescript/lib/tsserverlibrary', 'typescript', 'path'], func
25729
25764
  BuiltinType[BuiltinType["Object"] = 128] = "Object";
25730
25765
  })(BuiltinType$1 || (BuiltinType$1 = {}));
25731
25766
 
25767
+ /**
25768
+ * @license
25769
+ * Copyright Google Inc. All Rights Reserved.
25770
+ *
25771
+ * Use of this source code is governed by an MIT-style license that can be
25772
+ * found in the LICENSE file at https://angular.io/license
25773
+ */
25774
+ function isParseSourceSpan(value) {
25775
+ return value && !!value.start;
25776
+ }
25777
+ function spanOf(span) {
25778
+ if (!span)
25779
+ return undefined;
25780
+ if (isParseSourceSpan(span)) {
25781
+ return { start: span.start.offset, end: span.end.offset };
25782
+ }
25783
+ else {
25784
+ if (span.endSourceSpan) {
25785
+ return { start: span.sourceSpan.start.offset, end: span.endSourceSpan.end.offset };
25786
+ }
25787
+ else if (span.children && span.children.length) {
25788
+ return {
25789
+ start: span.sourceSpan.start.offset,
25790
+ end: spanOf(span.children[span.children.length - 1]).end
25791
+ };
25792
+ }
25793
+ return { start: span.sourceSpan.start.offset, end: span.sourceSpan.end.offset };
25794
+ }
25795
+ }
25796
+ function inSpan(position, span, exclusive) {
25797
+ return span != null &&
25798
+ (exclusive ? position >= span.start && position < span.end :
25799
+ position >= span.start && position <= span.end);
25800
+ }
25801
+ function offsetSpan(span, amount) {
25802
+ return { start: span.start + amount, end: span.end + amount };
25803
+ }
25804
+ function isNarrower(spanA, spanB) {
25805
+ return spanA.start >= spanB.start && spanA.end <= spanB.end;
25806
+ }
25807
+ function isStructuralDirective(type) {
25808
+ var e_1, _a;
25809
+ var _b;
25810
+ try {
25811
+ for (var _c = __values(type.diDeps), _d = _c.next(); !_d.done; _d = _c.next()) {
25812
+ var diDep = _d.value;
25813
+ var diDepName = identifierName((_b = diDep.token) === null || _b === void 0 ? void 0 : _b.identifier);
25814
+ if (diDepName === Identifiers.TemplateRef.name ||
25815
+ diDepName === Identifiers.ViewContainerRef.name) {
25816
+ return true;
25817
+ }
25818
+ }
25819
+ }
25820
+ catch (e_1_1) { e_1 = { error: e_1_1 }; }
25821
+ finally {
25822
+ try {
25823
+ if (_d && !_d.done && (_a = _c.return)) _a.call(_c);
25824
+ }
25825
+ finally { if (e_1) throw e_1.error; }
25826
+ }
25827
+ return false;
25828
+ }
25829
+ function getSelectors(info) {
25830
+ var e_2, _a, e_3, _b;
25831
+ var map = new Map();
25832
+ var results = [];
25833
+ try {
25834
+ for (var _c = __values(info.directives), _d = _c.next(); !_d.done; _d = _c.next()) {
25835
+ var directive = _d.value;
25836
+ var selectors = CssSelector.parse(directive.selector);
25837
+ try {
25838
+ for (var selectors_1 = (e_3 = void 0, __values(selectors)), selectors_1_1 = selectors_1.next(); !selectors_1_1.done; selectors_1_1 = selectors_1.next()) {
25839
+ var selector = selectors_1_1.value;
25840
+ results.push(selector);
25841
+ map.set(selector, directive);
25842
+ }
25843
+ }
25844
+ catch (e_3_1) { e_3 = { error: e_3_1 }; }
25845
+ finally {
25846
+ try {
25847
+ if (selectors_1_1 && !selectors_1_1.done && (_b = selectors_1.return)) _b.call(selectors_1);
25848
+ }
25849
+ finally { if (e_3) throw e_3.error; }
25850
+ }
25851
+ }
25852
+ }
25853
+ catch (e_2_1) { e_2 = { error: e_2_1 }; }
25854
+ finally {
25855
+ try {
25856
+ if (_d && !_d.done && (_a = _c.return)) _a.call(_c);
25857
+ }
25858
+ finally { if (e_2) throw e_2.error; }
25859
+ }
25860
+ return { selectors: results, map: map };
25861
+ }
25862
+ function diagnosticInfoFromTemplateInfo(info) {
25863
+ return {
25864
+ fileName: info.template.fileName,
25865
+ offset: info.template.span.start,
25866
+ query: info.template.query,
25867
+ members: info.template.members,
25868
+ htmlAst: info.htmlAst,
25869
+ templateAst: info.templateAst,
25870
+ source: info.template.source,
25871
+ };
25872
+ }
25873
+ function findTemplateAstAt(ast, position) {
25874
+ var path = [];
25875
+ var visitor = new /** @class */ (function (_super) {
25876
+ __extends(class_1, _super);
25877
+ function class_1() {
25878
+ return _super !== null && _super.apply(this, arguments) || this;
25879
+ }
25880
+ class_1.prototype.visit = function (ast) {
25881
+ var span = spanOf(ast);
25882
+ if (inSpan(position, span)) {
25883
+ var len = path.length;
25884
+ if (!len || isNarrower(span, spanOf(path[len - 1]))) {
25885
+ path.push(ast);
25886
+ }
25887
+ }
25888
+ else {
25889
+ // Returning a value here will result in the children being skipped.
25890
+ return true;
25891
+ }
25892
+ };
25893
+ class_1.prototype.visitEmbeddedTemplate = function (ast, context) {
25894
+ return this.visitChildren(context, function (visit) {
25895
+ // Ignore reference, variable and providers
25896
+ visit(ast.attrs);
25897
+ visit(ast.directives);
25898
+ visit(ast.children);
25899
+ });
25900
+ };
25901
+ class_1.prototype.visitElement = function (ast, context) {
25902
+ return this.visitChildren(context, function (visit) {
25903
+ // Ingnore providers
25904
+ visit(ast.attrs);
25905
+ visit(ast.inputs);
25906
+ visit(ast.outputs);
25907
+ visit(ast.references);
25908
+ visit(ast.directives);
25909
+ visit(ast.children);
25910
+ });
25911
+ };
25912
+ class_1.prototype.visitDirective = function (ast, context) {
25913
+ // Ignore the host properties of a directive
25914
+ var result = this.visitChildren(context, function (visit) {
25915
+ visit(ast.inputs);
25916
+ });
25917
+ // We never care about the diretive itself, just its inputs.
25918
+ if (path[path.length - 1] === ast) {
25919
+ path.pop();
25920
+ }
25921
+ return result;
25922
+ };
25923
+ return class_1;
25924
+ }(RecursiveTemplateAstVisitor));
25925
+ templateVisitAll(visitor, ast);
25926
+ return new AstPath(path, position);
25927
+ }
25928
+ /**
25929
+ * Find the tightest node at the specified `position` from the AST `nodes`, and
25930
+ * return the path to the node.
25931
+ * @param nodes HTML AST nodes
25932
+ * @param position
25933
+ */
25934
+ function getPathToNodeAtPosition(nodes, position) {
25935
+ var path = [];
25936
+ var visitor = new /** @class */ (function (_super) {
25937
+ __extends(class_2, _super);
25938
+ function class_2() {
25939
+ return _super !== null && _super.apply(this, arguments) || this;
25940
+ }
25941
+ class_2.prototype.visit = function (ast) {
25942
+ var span = spanOf(ast);
25943
+ if (inSpan(position, span)) {
25944
+ path.push(ast);
25945
+ }
25946
+ else {
25947
+ // Returning a truthy value here will skip all children and terminate
25948
+ // the visit.
25949
+ return true;
25950
+ }
25951
+ };
25952
+ return class_2;
25953
+ }(RecursiveVisitor));
25954
+ visitAll$1(visitor, nodes);
25955
+ return new AstPath(path, position);
25956
+ }
25957
+ /**
25958
+ * Inverts an object's key-value pairs.
25959
+ */
25960
+ function invertMap(obj) {
25961
+ var e_4, _a;
25962
+ var result = {};
25963
+ try {
25964
+ for (var _b = __values(Object.keys(obj)), _c = _b.next(); !_c.done; _c = _b.next()) {
25965
+ var name_1 = _c.value;
25966
+ var v = obj[name_1];
25967
+ result[v] = name_1;
25968
+ }
25969
+ }
25970
+ catch (e_4_1) { e_4 = { error: e_4_1 }; }
25971
+ finally {
25972
+ try {
25973
+ if (_c && !_c.done && (_a = _b.return)) _a.call(_b);
25974
+ }
25975
+ finally { if (e_4) throw e_4.error; }
25976
+ }
25977
+ return result;
25978
+ }
25979
+ /**
25980
+ * Finds the directive member providing a template output binding, if one exists.
25981
+ * @param info aggregate template AST information
25982
+ * @param path narrowing
25983
+ */
25984
+ function findOutputBinding(binding, path, query) {
25985
+ var e_5, _a;
25986
+ var element = path.first(ElementAst);
25987
+ if (element) {
25988
+ try {
25989
+ for (var _b = __values(element.directives), _c = _b.next(); !_c.done; _c = _b.next()) {
25990
+ var directive = _c.value;
25991
+ var invertedOutputs = invertMap(directive.directive.outputs);
25992
+ var fieldName = invertedOutputs[binding.name];
25993
+ if (fieldName) {
25994
+ var classSymbol = query.getTypeSymbol(directive.directive.type.reference);
25995
+ if (classSymbol) {
25996
+ return classSymbol.members().get(fieldName);
25997
+ }
25998
+ }
25999
+ }
26000
+ }
26001
+ catch (e_5_1) { e_5 = { error: e_5_1 }; }
26002
+ finally {
26003
+ try {
26004
+ if (_c && !_c.done && (_a = _b.return)) _a.call(_b);
26005
+ }
26006
+ finally { if (e_5) throw e_5.error; }
26007
+ }
26008
+ }
26009
+ }
26010
+
25732
26011
  /**
25733
26012
  * @license
25734
26013
  * Copyright Google Inc. All Rights Reserved.
@@ -25751,7 +26030,7 @@ define(['exports', 'typescript/lib/tsserverlibrary', 'typescript', 'path'], func
25751
26030
  AstType.prototype.getDiagnostics = function (ast) {
25752
26031
  var type = ast.visit(this);
25753
26032
  if (this.context.inEvent && type.callable) {
25754
- this.diagnostics.push(createDiagnostic(ast.span, Diagnostic.callable_expression_expected_method_call));
26033
+ this.diagnostics.push(createDiagnostic(refinedSpan(ast), Diagnostic.callable_expression_expected_method_call));
25755
26034
  }
25756
26035
  return this.diagnostics;
25757
26036
  };
@@ -25770,7 +26049,7 @@ define(['exports', 'typescript/lib/tsserverlibrary', 'typescript', 'path'], func
25770
26049
  // Nullable allowed.
25771
26050
  break;
25772
26051
  default:
25773
- _this_1.diagnostics.push(createDiagnostic(ast.span, Diagnostic.expression_might_be_null));
26052
+ _this_1.diagnostics.push(createDiagnostic(refinedSpan(ast), Diagnostic.expression_might_be_null));
25774
26053
  break;
25775
26054
  }
25776
26055
  }
@@ -25843,7 +26122,7 @@ define(['exports', 'typescript/lib/tsserverlibrary', 'typescript', 'path'], func
25843
26122
  this.diagnostics.push(createDiagnostic(ast.right.span, Diagnostic.expected_a_number_type));
25844
26123
  return this.anyType;
25845
26124
  default:
25846
- this.diagnostics.push(createDiagnostic(ast.span, Diagnostic.expected_a_string_or_number_type));
26125
+ this.diagnostics.push(createDiagnostic(refinedSpan(ast), Diagnostic.expected_a_string_or_number_type));
25847
26126
  return this.anyType;
25848
26127
  }
25849
26128
  case '>':
@@ -25859,7 +26138,7 @@ define(['exports', 'typescript/lib/tsserverlibrary', 'typescript', 'path'], func
25859
26138
  // Two values are comparable only if
25860
26139
  // - they have some type overlap, or
25861
26140
  // - at least one is not defined
25862
- this.diagnostics.push(createDiagnostic(ast.span, Diagnostic.expected_operands_of_comparable_types_or_any));
26141
+ this.diagnostics.push(createDiagnostic(refinedSpan(ast), Diagnostic.expected_operands_of_comparable_types_or_any));
25863
26142
  }
25864
26143
  return this.query.getBuiltinType(BuiltinType$1.Boolean);
25865
26144
  case '&&':
@@ -25867,7 +26146,7 @@ define(['exports', 'typescript/lib/tsserverlibrary', 'typescript', 'path'], func
25867
26146
  case '||':
25868
26147
  return this.query.getTypeUnion(leftType, rightType);
25869
26148
  }
25870
- this.diagnostics.push(createDiagnostic(ast.span, Diagnostic.unrecognized_operator, ast.operation));
26149
+ this.diagnostics.push(createDiagnostic(refinedSpan(ast), Diagnostic.unrecognized_operator, ast.operation));
25871
26150
  return this.anyType;
25872
26151
  };
25873
26152
  AstType.prototype.visitChain = function (ast) {
@@ -25905,7 +26184,7 @@ define(['exports', 'typescript/lib/tsserverlibrary', 'typescript', 'path'], func
25905
26184
  var args = ast.args.map(function (arg) { return _this_1.getType(arg); });
25906
26185
  var target = this.getType(ast.target);
25907
26186
  if (!target || !target.callable) {
25908
- this.diagnostics.push(createDiagnostic(ast.span, Diagnostic.call_target_not_callable, this.sourceOf(ast.target), target.name));
26187
+ this.diagnostics.push(createDiagnostic(refinedSpan(ast), Diagnostic.call_target_not_callable, this.sourceOf(ast.target), target.name));
25909
26188
  return this.anyType;
25910
26189
  }
25911
26190
  var signature = target.selectSignature(args);
@@ -25914,7 +26193,7 @@ define(['exports', 'typescript/lib/tsserverlibrary', 'typescript', 'path'], func
25914
26193
  }
25915
26194
  // TODO: Consider a better error message here. See `typescript_symbols#selectSignature` for more
25916
26195
  // details.
25917
- this.diagnostics.push(createDiagnostic(ast.span, Diagnostic.unable_to_resolve_compatible_call_signature));
26196
+ this.diagnostics.push(createDiagnostic(refinedSpan(ast), Diagnostic.unable_to_resolve_compatible_call_signature));
25918
26197
  return this.anyType;
25919
26198
  };
25920
26199
  AstType.prototype.visitImplicitReceiver = function (_ast) {
@@ -26020,7 +26299,7 @@ define(['exports', 'typescript/lib/tsserverlibrary', 'typescript', 'path'], func
26020
26299
  case 'number':
26021
26300
  return this.query.getBuiltinType(BuiltinType$1.Number);
26022
26301
  default:
26023
- this.diagnostics.push(createDiagnostic(ast.span, Diagnostic.unrecognized_primitive, typeof ast.value));
26302
+ this.diagnostics.push(createDiagnostic(refinedSpan(ast), Diagnostic.unrecognized_primitive, typeof ast.value));
26024
26303
  return this.anyType;
26025
26304
  }
26026
26305
  }
@@ -26034,13 +26313,13 @@ define(['exports', 'typescript/lib/tsserverlibrary', 'typescript', 'path'], func
26034
26313
  // by getPipes() is expected to contain symbols with the corresponding transform method type.
26035
26314
  var pipe = this.query.getPipes().get(ast.name);
26036
26315
  if (!pipe) {
26037
- this.diagnostics.push(createDiagnostic(ast.span, Diagnostic.no_pipe_found, ast.name));
26316
+ this.diagnostics.push(createDiagnostic(refinedSpan(ast), Diagnostic.no_pipe_found, ast.name));
26038
26317
  return this.anyType;
26039
26318
  }
26040
26319
  var expType = this.getType(ast.exp);
26041
26320
  var signature = pipe.selectSignature([expType].concat(ast.args.map(function (arg) { return _this_1.getType(arg); })));
26042
26321
  if (!signature) {
26043
- this.diagnostics.push(createDiagnostic(ast.span, Diagnostic.unable_to_resolve_signature, ast.name));
26322
+ this.diagnostics.push(createDiagnostic(refinedSpan(ast), Diagnostic.unable_to_resolve_signature, ast.name));
26044
26323
  return this.anyType;
26045
26324
  }
26046
26325
  return signature.result;
@@ -26109,19 +26388,19 @@ define(['exports', 'typescript/lib/tsserverlibrary', 'typescript', 'path'], func
26109
26388
  }
26110
26389
  var methodType = this.resolvePropertyRead(receiverType, ast);
26111
26390
  if (!methodType) {
26112
- this.diagnostics.push(createDiagnostic(ast.span, Diagnostic.could_not_resolve_type, ast.name));
26391
+ this.diagnostics.push(createDiagnostic(refinedSpan(ast), Diagnostic.could_not_resolve_type, ast.name));
26113
26392
  return this.anyType;
26114
26393
  }
26115
26394
  if (this.isAny(methodType)) {
26116
26395
  return this.anyType;
26117
26396
  }
26118
26397
  if (!methodType.callable) {
26119
- this.diagnostics.push(createDiagnostic(ast.span, Diagnostic.identifier_not_callable, ast.name));
26398
+ this.diagnostics.push(createDiagnostic(refinedSpan(ast), Diagnostic.identifier_not_callable, ast.name));
26120
26399
  return this.anyType;
26121
26400
  }
26122
26401
  var signature = methodType.selectSignature(ast.args.map(function (arg) { return _this_1.getType(arg); }));
26123
26402
  if (!signature) {
26124
- this.diagnostics.push(createDiagnostic(ast.span, Diagnostic.unable_to_resolve_signature, ast.name));
26403
+ this.diagnostics.push(createDiagnostic(refinedSpan(ast), Diagnostic.unable_to_resolve_signature, ast.name));
26125
26404
  return this.anyType;
26126
26405
  }
26127
26406
  return signature.result;
@@ -26134,20 +26413,20 @@ define(['exports', 'typescript/lib/tsserverlibrary', 'typescript', 'path'], func
26134
26413
  var member = receiverType.members().get(ast.name);
26135
26414
  if (!member) {
26136
26415
  if (receiverType.name === '$implicit') {
26137
- this.diagnostics.push(createDiagnostic(ast.span, Diagnostic.identifier_not_defined_in_app_context, ast.name));
26416
+ this.diagnostics.push(createDiagnostic(refinedSpan(ast), Diagnostic.identifier_not_defined_in_app_context, ast.name));
26138
26417
  }
26139
26418
  else if (receiverType.nullable && ast.receiver instanceof PropertyRead) {
26140
26419
  var receiver = ast.receiver.name;
26141
- this.diagnostics.push(createDiagnostic(ast.span, Diagnostic.identifier_possibly_undefined, receiver, receiver + "?." + ast.name, receiver + "!." + ast.name));
26420
+ this.diagnostics.push(createDiagnostic(refinedSpan(ast), Diagnostic.identifier_possibly_undefined, receiver, receiver + "?." + ast.name, receiver + "!." + ast.name));
26142
26421
  }
26143
26422
  else {
26144
- this.diagnostics.push(createDiagnostic(ast.span, Diagnostic.identifier_not_defined_on_receiver, ast.name, receiverType.name));
26423
+ this.diagnostics.push(createDiagnostic(refinedSpan(ast), Diagnostic.identifier_not_defined_on_receiver, ast.name, receiverType.name));
26145
26424
  }
26146
26425
  return this.anyType;
26147
26426
  }
26148
26427
  if (!member.public) {
26149
26428
  var container = receiverType.name === '$implicit' ? 'the component' : "'" + receiverType.name + "'";
26150
- this.diagnostics.push(createDiagnostic(ast.span, Diagnostic.identifier_is_private, ast.name, container));
26429
+ this.diagnostics.push(createDiagnostic(refinedSpan(ast), Diagnostic.identifier_is_private, ast.name, container));
26151
26430
  }
26152
26431
  return member.type;
26153
26432
  };
@@ -26157,379 +26436,15 @@ define(['exports', 'typescript/lib/tsserverlibrary', 'typescript', 'path'], func
26157
26436
  };
26158
26437
  return AstType;
26159
26438
  }());
26160
-
26161
- /**
26162
- * @license
26163
- * Copyright Google Inc. All Rights Reserved.
26164
- *
26165
- * Use of this source code is governed by an MIT-style license that can be
26166
- * found in the LICENSE file at https://angular.io/license
26167
- */
26168
- function isParseSourceSpan(value) {
26169
- return value && !!value.start;
26170
- }
26171
- function spanOf(span) {
26172
- if (!span)
26173
- return undefined;
26174
- if (isParseSourceSpan(span)) {
26175
- return { start: span.start.offset, end: span.end.offset };
26176
- }
26177
- else {
26178
- if (span.endSourceSpan) {
26179
- return { start: span.sourceSpan.start.offset, end: span.endSourceSpan.end.offset };
26180
- }
26181
- else if (span.children && span.children.length) {
26182
- return {
26183
- start: span.sourceSpan.start.offset,
26184
- end: spanOf(span.children[span.children.length - 1]).end
26185
- };
26186
- }
26187
- return { start: span.sourceSpan.start.offset, end: span.sourceSpan.end.offset };
26188
- }
26189
- }
26190
- function inSpan(position, span, exclusive) {
26191
- return span != null &&
26192
- (exclusive ? position >= span.start && position < span.end :
26193
- position >= span.start && position <= span.end);
26194
- }
26195
- function offsetSpan(span, amount) {
26196
- return { start: span.start + amount, end: span.end + amount };
26197
- }
26198
- function isNarrower(spanA, spanB) {
26199
- return spanA.start >= spanB.start && spanA.end <= spanB.end;
26200
- }
26201
- function isStructuralDirective(type) {
26202
- var e_1, _a;
26203
- var _b;
26204
- try {
26205
- for (var _c = __values(type.diDeps), _d = _c.next(); !_d.done; _d = _c.next()) {
26206
- var diDep = _d.value;
26207
- var diDepName = identifierName((_b = diDep.token) === null || _b === void 0 ? void 0 : _b.identifier);
26208
- if (diDepName === Identifiers.TemplateRef.name ||
26209
- diDepName === Identifiers.ViewContainerRef.name) {
26210
- return true;
26211
- }
26212
- }
26213
- }
26214
- catch (e_1_1) { e_1 = { error: e_1_1 }; }
26215
- finally {
26216
- try {
26217
- if (_d && !_d.done && (_a = _c.return)) _a.call(_c);
26218
- }
26219
- finally { if (e_1) throw e_1.error; }
26220
- }
26221
- return false;
26222
- }
26223
- function getSelectors(info) {
26224
- var e_2, _a, e_3, _b;
26225
- var map = new Map();
26226
- var results = [];
26227
- try {
26228
- for (var _c = __values(info.directives), _d = _c.next(); !_d.done; _d = _c.next()) {
26229
- var directive = _d.value;
26230
- var selectors = CssSelector.parse(directive.selector);
26231
- try {
26232
- for (var selectors_1 = (e_3 = void 0, __values(selectors)), selectors_1_1 = selectors_1.next(); !selectors_1_1.done; selectors_1_1 = selectors_1.next()) {
26233
- var selector = selectors_1_1.value;
26234
- results.push(selector);
26235
- map.set(selector, directive);
26236
- }
26237
- }
26238
- catch (e_3_1) { e_3 = { error: e_3_1 }; }
26239
- finally {
26240
- try {
26241
- if (selectors_1_1 && !selectors_1_1.done && (_b = selectors_1.return)) _b.call(selectors_1);
26242
- }
26243
- finally { if (e_3) throw e_3.error; }
26244
- }
26245
- }
26246
- }
26247
- catch (e_2_1) { e_2 = { error: e_2_1 }; }
26248
- finally {
26249
- try {
26250
- if (_d && !_d.done && (_a = _c.return)) _a.call(_c);
26251
- }
26252
- finally { if (e_2) throw e_2.error; }
26253
- }
26254
- return { selectors: results, map: map };
26255
- }
26256
- function diagnosticInfoFromTemplateInfo(info) {
26257
- return {
26258
- fileName: info.template.fileName,
26259
- offset: info.template.span.start,
26260
- query: info.template.query,
26261
- members: info.template.members,
26262
- htmlAst: info.htmlAst,
26263
- templateAst: info.templateAst,
26264
- source: info.template.source,
26265
- };
26266
- }
26267
- function findTemplateAstAt(ast, position) {
26268
- var path = [];
26269
- var visitor = new /** @class */ (function (_super) {
26270
- __extends(class_1, _super);
26271
- function class_1() {
26272
- return _super !== null && _super.apply(this, arguments) || this;
26273
- }
26274
- class_1.prototype.visit = function (ast) {
26275
- var span = spanOf(ast);
26276
- if (inSpan(position, span)) {
26277
- var len = path.length;
26278
- if (!len || isNarrower(span, spanOf(path[len - 1]))) {
26279
- path.push(ast);
26280
- }
26281
- }
26282
- else {
26283
- // Returning a value here will result in the children being skipped.
26284
- return true;
26285
- }
26286
- };
26287
- class_1.prototype.visitEmbeddedTemplate = function (ast, context) {
26288
- return this.visitChildren(context, function (visit) {
26289
- // Ignore reference, variable and providers
26290
- visit(ast.attrs);
26291
- visit(ast.directives);
26292
- visit(ast.children);
26293
- });
26294
- };
26295
- class_1.prototype.visitElement = function (ast, context) {
26296
- return this.visitChildren(context, function (visit) {
26297
- // Ingnore providers
26298
- visit(ast.attrs);
26299
- visit(ast.inputs);
26300
- visit(ast.outputs);
26301
- visit(ast.references);
26302
- visit(ast.directives);
26303
- visit(ast.children);
26304
- });
26305
- };
26306
- class_1.prototype.visitDirective = function (ast, context) {
26307
- // Ignore the host properties of a directive
26308
- var result = this.visitChildren(context, function (visit) {
26309
- visit(ast.inputs);
26310
- });
26311
- // We never care about the diretive itself, just its inputs.
26312
- if (path[path.length - 1] === ast) {
26313
- path.pop();
26314
- }
26315
- return result;
26316
- };
26317
- return class_1;
26318
- }(RecursiveTemplateAstVisitor));
26319
- templateVisitAll(visitor, ast);
26320
- return new AstPath(path, position);
26321
- }
26322
- /**
26323
- * Return the node that most tightly encompass the specified `position`.
26324
- * @param node
26325
- * @param position
26326
- */
26327
- function findTightestNode(node, position) {
26328
- if (node.getStart() <= position && position < node.getEnd()) {
26329
- return node.forEachChild(function (c) { return findTightestNode(c, position); }) || node;
26330
- }
26331
- }
26332
- /**
26333
- * Return metadata about `node` if it looks like an Angular directive class.
26334
- * In this case, potential matches are `@NgModule`, `@Component`, `@Directive`,
26335
- * `@Pipe`, etc.
26336
- * These class declarations all share some common attributes, namely their
26337
- * decorator takes exactly one parameter and the parameter must be an object
26338
- * literal.
26339
- *
26340
- * For example,
26341
- * v---------- `decoratorId`
26342
- * @NgModule({ <
26343
- * declarations: [], < classDecl
26344
- * }) <
26345
- * class AppModule {} <
26346
- * ^----- `classId`
26347
- *
26348
- * @param node Potential node that represents an Angular directive.
26349
- */
26350
- function getDirectiveClassLike(node) {
26351
- var e_4, _a;
26352
- if (!ts.isClassDeclaration(node) || !node.name || !node.decorators) {
26353
- return;
26354
- }
26355
- try {
26356
- for (var _b = __values(node.decorators), _c = _b.next(); !_c.done; _c = _b.next()) {
26357
- var d = _c.value;
26358
- var expr = d.expression;
26359
- if (!ts.isCallExpression(expr) || expr.arguments.length !== 1 ||
26360
- !ts.isIdentifier(expr.expression)) {
26361
- continue;
26362
- }
26363
- var arg = expr.arguments[0];
26364
- if (ts.isObjectLiteralExpression(arg)) {
26365
- return {
26366
- decoratorId: expr.expression,
26367
- classId: node.name,
26368
- };
26369
- }
26370
- }
26371
- }
26372
- catch (e_4_1) { e_4 = { error: e_4_1 }; }
26373
- finally {
26374
- try {
26375
- if (_c && !_c.done && (_a = _b.return)) _a.call(_b);
26376
- }
26377
- finally { if (e_4) throw e_4.error; }
26378
- }
26379
- }
26380
- /**
26381
- * Finds the value of a property assignment that is nested in a TypeScript node and is of a certain
26382
- * type T.
26383
- *
26384
- * @param startNode node to start searching for nested property assignment from
26385
- * @param propName property assignment name
26386
- * @param predicate function to verify that a node is of type T.
26387
- * @return node property assignment value of type T, or undefined if none is found
26388
- */
26389
- function findPropertyValueOfType(startNode, propName, predicate) {
26390
- if (ts.isPropertyAssignment(startNode) && startNode.name.getText() === propName) {
26391
- var initializer = startNode.initializer;
26392
- if (predicate(initializer))
26393
- return initializer;
26394
- }
26395
- return startNode.forEachChild(function (c) { return findPropertyValueOfType(c, propName, predicate); });
26396
- }
26397
- /**
26398
- * Find the tightest node at the specified `position` from the AST `nodes`, and
26399
- * return the path to the node.
26400
- * @param nodes HTML AST nodes
26401
- * @param position
26402
- */
26403
- function getPathToNodeAtPosition(nodes, position) {
26404
- var path = [];
26405
- var visitor = new /** @class */ (function (_super) {
26406
- __extends(class_2, _super);
26407
- function class_2() {
26408
- return _super !== null && _super.apply(this, arguments) || this;
26409
- }
26410
- class_2.prototype.visit = function (ast) {
26411
- var span = spanOf(ast);
26412
- if (inSpan(position, span)) {
26413
- path.push(ast);
26414
- }
26415
- else {
26416
- // Returning a truthy value here will skip all children and terminate
26417
- // the visit.
26418
- return true;
26419
- }
26420
- };
26421
- return class_2;
26422
- }(RecursiveVisitor));
26423
- visitAll$1(visitor, nodes);
26424
- return new AstPath(path, position);
26425
- }
26426
- /**
26427
- * Inverts an object's key-value pairs.
26428
- */
26429
- function invertMap(obj) {
26430
- var e_5, _a;
26431
- var result = {};
26432
- try {
26433
- for (var _b = __values(Object.keys(obj)), _c = _b.next(); !_c.done; _c = _b.next()) {
26434
- var name_1 = _c.value;
26435
- var v = obj[name_1];
26436
- result[v] = name_1;
26437
- }
26438
- }
26439
- catch (e_5_1) { e_5 = { error: e_5_1 }; }
26440
- finally {
26441
- try {
26442
- if (_c && !_c.done && (_a = _b.return)) _a.call(_b);
26443
- }
26444
- finally { if (e_5) throw e_5.error; }
26445
- }
26446
- return result;
26447
- }
26448
- /**
26449
- * Finds the directive member providing a template output binding, if one exists.
26450
- * @param info aggregate template AST information
26451
- * @param path narrowing
26452
- */
26453
- function findOutputBinding(binding, path, query) {
26454
- var e_6, _a;
26455
- var element = path.first(ElementAst);
26456
- if (element) {
26457
- try {
26458
- for (var _b = __values(element.directives), _c = _b.next(); !_c.done; _c = _b.next()) {
26459
- var directive = _c.value;
26460
- var invertedOutputs = invertMap(directive.directive.outputs);
26461
- var fieldName = invertedOutputs[binding.name];
26462
- if (fieldName) {
26463
- var classSymbol = query.getTypeSymbol(directive.directive.type.reference);
26464
- if (classSymbol) {
26465
- return classSymbol.members().get(fieldName);
26466
- }
26467
- }
26468
- }
26469
- }
26470
- catch (e_6_1) { e_6 = { error: e_6_1 }; }
26471
- finally {
26472
- try {
26473
- if (_c && !_c.done && (_a = _b.return)) _a.call(_b);
26474
- }
26475
- finally { if (e_6) throw e_6.error; }
26476
- }
26477
- }
26478
- }
26479
- /**
26480
- * Returns a property assignment from the assignment value, or `undefined` if there is no
26481
- * assignment.
26482
- */
26483
- function getPropertyAssignmentFromValue(value) {
26484
- if (!value.parent || !ts.isPropertyAssignment(value.parent)) {
26485
- return;
26439
+ function refinedSpan(ast) {
26440
+ // nameSpan is an absolute span, but the spans returned by the expression visitor are expected to
26441
+ // be relative to the start of the expression.
26442
+ // TODO: migrate to only using absolute spans
26443
+ var absoluteOffset = ast.sourceSpan.start - ast.span.start;
26444
+ if (ast instanceof ASTWithName) {
26445
+ return offsetSpan(ast.nameSpan, -absoluteOffset);
26486
26446
  }
26487
- return value.parent;
26488
- }
26489
- /**
26490
- * Given a decorator property assignment, return the ClassDeclaration node that corresponds to the
26491
- * directive class the property applies to.
26492
- * If the property assignment is not on a class decorator, no declaration is returned.
26493
- *
26494
- * For example,
26495
- *
26496
- * @Component({
26497
- * template: '<div></div>'
26498
- * ^^^^^^^^^^^^^^^^^^^^^^^---- property assignment
26499
- * })
26500
- * class AppComponent {}
26501
- * ^---- class declaration node
26502
- *
26503
- * @param propAsgn property assignment
26504
- */
26505
- function getClassDeclFromDecoratorProp(propAsgnNode) {
26506
- if (!propAsgnNode.parent || !ts.isObjectLiteralExpression(propAsgnNode.parent)) {
26507
- return;
26508
- }
26509
- var objLitExprNode = propAsgnNode.parent;
26510
- if (!objLitExprNode.parent || !ts.isCallExpression(objLitExprNode.parent)) {
26511
- return;
26512
- }
26513
- var callExprNode = objLitExprNode.parent;
26514
- if (!callExprNode.parent || !ts.isDecorator(callExprNode.parent)) {
26515
- return;
26516
- }
26517
- var decorator = callExprNode.parent;
26518
- if (!decorator.parent || !ts.isClassDeclaration(decorator.parent)) {
26519
- return;
26520
- }
26521
- var classDeclNode = decorator.parent;
26522
- return classDeclNode;
26523
- }
26524
- /**
26525
- * Determines if a property assignment is on a class decorator.
26526
- * See `getClassDeclFromDecoratorProperty`, which gets the class the decorator is applied to, for
26527
- * more details.
26528
- *
26529
- * @param prop property assignment
26530
- */
26531
- function isClassDecoratorProperty(propAsgn) {
26532
- return !!getClassDeclFromDecoratorProp(propAsgn);
26447
+ return offsetSpan(ast.sourceSpan, -absoluteOffset);
26533
26448
  }
26534
26449
 
26535
26450
  /**
@@ -27058,6 +26973,16 @@ define(['exports', 'typescript/lib/tsserverlibrary', 'typescript', 'path'], func
27058
26973
  function getType(ast) {
27059
26974
  return new AstType(scope, templateInfo.query, {}, templateInfo.source).getType(ast);
27060
26975
  }
26976
+ function spanFromName(ast) {
26977
+ // `nameSpan` is an absolute span, but the span expected by the result of this method is
26978
+ // relative to the start of the expression.
26979
+ // TODO(ayazhafiz): migrate to only using absolute spans
26980
+ var offset = ast.sourceSpan.start - ast.span.start;
26981
+ return {
26982
+ start: ast.nameSpan.start - offset,
26983
+ end: ast.nameSpan.end - offset,
26984
+ };
26985
+ }
27061
26986
  var symbol = undefined;
27062
26987
  var span = undefined;
27063
26988
  // If the completion request is in a not in a pipe or property access then the global scope
@@ -27078,21 +27003,14 @@ define(['exports', 'typescript/lib/tsserverlibrary', 'typescript', 'path'], func
27078
27003
  visitMethodCall: function (ast) {
27079
27004
  var receiverType = getType(ast.receiver);
27080
27005
  symbol = receiverType && receiverType.members().get(ast.name);
27081
- span = ast.span;
27006
+ span = spanFromName(ast);
27082
27007
  },
27083
27008
  visitPipe: function (ast) {
27084
27009
  if (inSpan(position, ast.nameSpan, /* exclusive */ true)) {
27085
27010
  // We are in a position a pipe name is expected.
27086
27011
  var pipes = templateInfo.query.getPipes();
27087
27012
  symbol = pipes.get(ast.name);
27088
- // `nameSpan` is an absolute span, but the span expected by the result of this method is
27089
- // relative to the start of the expression.
27090
- // TODO(ayazhafiz): migrate to only using absolute spans
27091
- var offset = ast.sourceSpan.start - ast.span.start;
27092
- span = {
27093
- start: ast.nameSpan.start - offset,
27094
- end: ast.nameSpan.end - offset,
27095
- };
27013
+ span = spanFromName(ast);
27096
27014
  }
27097
27015
  },
27098
27016
  visitPrefixNot: function (_ast) { },
@@ -27100,29 +27018,23 @@ define(['exports', 'typescript/lib/tsserverlibrary', 'typescript', 'path'], func
27100
27018
  visitPropertyRead: function (ast) {
27101
27019
  var receiverType = getType(ast.receiver);
27102
27020
  symbol = receiverType && receiverType.members().get(ast.name);
27103
- span = ast.span;
27021
+ span = spanFromName(ast);
27104
27022
  },
27105
27023
  visitPropertyWrite: function (ast) {
27106
27024
  var receiverType = getType(ast.receiver);
27107
- var start = ast.span.start;
27108
27025
  symbol = receiverType && receiverType.members().get(ast.name);
27109
- // A PropertyWrite span includes both the LHS (name) and the RHS (value) of the write. In this
27110
- // visit, only the name is relevant.
27111
- // prop=$event
27112
- // ^^^^ name
27113
- // ^^^^^^ value; visited separately as a nested AST
27114
- span = { start: start, end: start + ast.name.length };
27026
+ span = spanFromName(ast);
27115
27027
  },
27116
27028
  visitQuote: function (_ast) { },
27117
27029
  visitSafeMethodCall: function (ast) {
27118
27030
  var receiverType = getType(ast.receiver);
27119
27031
  symbol = receiverType && receiverType.members().get(ast.name);
27120
- span = ast.span;
27032
+ span = spanFromName(ast);
27121
27033
  },
27122
27034
  visitSafePropertyRead: function (ast) {
27123
27035
  var receiverType = getType(ast.receiver);
27124
27036
  symbol = receiverType && receiverType.members().get(ast.name);
27125
- span = ast.span;
27037
+ span = spanFromName(ast);
27126
27038
  },
27127
27039
  });
27128
27040
  if (symbol && span) {
@@ -29203,7 +29115,6 @@ define(['exports', 'typescript/lib/tsserverlibrary', 'typescript', 'path'], func
29203
29115
  // no-op for now
29204
29116
  };
29205
29117
  ExpressionVisitor.prototype.visitAttr = function (ast) {
29206
- var _this = this;
29207
29118
  var binding = getBindingDescriptor(ast.name);
29208
29119
  if (binding && binding.kind === ATTR.KW_MICROSYNTAX) {
29209
29120
  // This a template binding given by micro syntax expression.
@@ -29217,8 +29128,11 @@ define(['exports', 'typescript/lib/tsserverlibrary', 'typescript', 'path'], func
29217
29128
  var absKeyOffset = 0;
29218
29129
  var absValueOffset = ast.sourceSpan.start.offset;
29219
29130
  var templateBindings = this.info.expressionParser.parseTemplateBindings(templateKey, templateValue, templateUrl, absKeyOffset, absValueOffset).templateBindings;
29220
- // Find the template binding that contains the position.
29221
- var templateBinding = templateBindings.find(function (b) { return inSpan(_this.position, b.sourceSpan); });
29131
+ // Find the nearest template binding to the position.
29132
+ var lastBindingEnd = templateBindings.length > 0 &&
29133
+ templateBindings[templateBindings.length - 1].sourceSpan.end;
29134
+ var normalizedPositionToBinding_1 = lastBindingEnd && this.position > lastBindingEnd ? lastBindingEnd : this.position;
29135
+ var templateBinding = templateBindings.find(function (b) { return inSpan(normalizedPositionToBinding_1, b.sourceSpan); });
29222
29136
  if (!templateBinding) {
29223
29137
  return;
29224
29138
  }
@@ -29827,6 +29741,136 @@ define(['exports', 'typescript/lib/tsserverlibrary', 'typescript', 'path'], func
29827
29741
  return OverrideKindSymbol;
29828
29742
  }());
29829
29743
 
29744
+ /**
29745
+ * @license
29746
+ * Copyright Google Inc. All Rights Reserved.
29747
+ *
29748
+ * Use of this source code is governed by an MIT-style license that can be
29749
+ * found in the LICENSE file at https://angular.io/license
29750
+ */
29751
+ /**
29752
+ * Return the node that most tightly encompass the specified `position`.
29753
+ * @param node
29754
+ * @param position
29755
+ */
29756
+ function findTightestNode(node, position) {
29757
+ if (node.getStart() <= position && position < node.getEnd()) {
29758
+ return node.forEachChild(function (c) { return findTightestNode(c, position); }) || node;
29759
+ }
29760
+ }
29761
+ /**
29762
+ * Returns a property assignment from the assignment value if the property name
29763
+ * matches the specified `key`, or `undefined` if there is no match.
29764
+ */
29765
+ function getPropertyAssignmentFromValue(value, key) {
29766
+ var propAssignment = value.parent;
29767
+ if (!propAssignment || !tss.isPropertyAssignment(propAssignment) ||
29768
+ propAssignment.name.getText() !== key) {
29769
+ return;
29770
+ }
29771
+ return propAssignment;
29772
+ }
29773
+ /**
29774
+ * Given a decorator property assignment, return the ClassDeclaration node that corresponds to the
29775
+ * directive class the property applies to.
29776
+ * If the property assignment is not on a class decorator, no declaration is returned.
29777
+ *
29778
+ * For example,
29779
+ *
29780
+ * @Component({
29781
+ * template: '<div></div>'
29782
+ * ^^^^^^^^^^^^^^^^^^^^^^^---- property assignment
29783
+ * })
29784
+ * class AppComponent {}
29785
+ * ^---- class declaration node
29786
+ *
29787
+ * @param propAsgn property assignment
29788
+ */
29789
+ function getClassDeclFromDecoratorProp(propAsgnNode) {
29790
+ if (!propAsgnNode.parent || !tss.isObjectLiteralExpression(propAsgnNode.parent)) {
29791
+ return;
29792
+ }
29793
+ var objLitExprNode = propAsgnNode.parent;
29794
+ if (!objLitExprNode.parent || !tss.isCallExpression(objLitExprNode.parent)) {
29795
+ return;
29796
+ }
29797
+ var callExprNode = objLitExprNode.parent;
29798
+ if (!callExprNode.parent || !tss.isDecorator(callExprNode.parent)) {
29799
+ return;
29800
+ }
29801
+ var decorator = callExprNode.parent;
29802
+ if (!decorator.parent || !tss.isClassDeclaration(decorator.parent)) {
29803
+ return;
29804
+ }
29805
+ var classDeclNode = decorator.parent;
29806
+ return classDeclNode;
29807
+ }
29808
+ /**
29809
+ * Return metadata about `node` if it looks like an Angular directive class.
29810
+ * In this case, potential matches are `@NgModule`, `@Component`, `@Directive`,
29811
+ * `@Pipe`, etc.
29812
+ * These class declarations all share some common attributes, namely their
29813
+ * decorator takes exactly one parameter and the parameter must be an object
29814
+ * literal.
29815
+ *
29816
+ * For example,
29817
+ * v---------- `decoratorId`
29818
+ * @NgModule({ <
29819
+ * declarations: [], < classDecl
29820
+ * }) <
29821
+ * class AppModule {} <
29822
+ * ^----- `classId`
29823
+ *
29824
+ * @param node Potential node that represents an Angular directive.
29825
+ */
29826
+ function getDirectiveClassLike(node) {
29827
+ var e_1, _a;
29828
+ if (!tss.isClassDeclaration(node) || !node.name || !node.decorators) {
29829
+ return;
29830
+ }
29831
+ try {
29832
+ for (var _b = __values(node.decorators), _c = _b.next(); !_c.done; _c = _b.next()) {
29833
+ var d = _c.value;
29834
+ var expr = d.expression;
29835
+ if (!tss.isCallExpression(expr) || expr.arguments.length !== 1 ||
29836
+ !tss.isIdentifier(expr.expression)) {
29837
+ continue;
29838
+ }
29839
+ var arg = expr.arguments[0];
29840
+ if (tss.isObjectLiteralExpression(arg)) {
29841
+ return {
29842
+ decoratorId: expr.expression,
29843
+ classId: node.name,
29844
+ };
29845
+ }
29846
+ }
29847
+ }
29848
+ catch (e_1_1) { e_1 = { error: e_1_1 }; }
29849
+ finally {
29850
+ try {
29851
+ if (_c && !_c.done && (_a = _b.return)) _a.call(_b);
29852
+ }
29853
+ finally { if (e_1) throw e_1.error; }
29854
+ }
29855
+ }
29856
+ /**
29857
+ * Finds the value of a property assignment that is nested in a TypeScript node and is of a certain
29858
+ * type T.
29859
+ *
29860
+ * @param startNode node to start searching for nested property assignment from
29861
+ * @param propName property assignment name
29862
+ * @param predicate function to verify that a node is of type T.
29863
+ * @return node property assignment value of type T, or undefined if none is found
29864
+ */
29865
+ function findPropertyValueOfType(startNode, propName, predicate) {
29866
+ if (tss.isPropertyAssignment(startNode) && startNode.name.getText() === propName) {
29867
+ var initializer = startNode.initializer;
29868
+ if (predicate(initializer))
29869
+ return initializer;
29870
+ }
29871
+ return startNode.forEachChild(function (c) { return findPropertyValueOfType(c, propName, predicate); });
29872
+ }
29873
+
29830
29874
  /**
29831
29875
  * @license
29832
29876
  * Copyright Google Inc. All Rights Reserved.
@@ -29949,19 +29993,20 @@ define(['exports', 'typescript/lib/tsserverlibrary', 'typescript', 'path'], func
29949
29993
  // `styleUrls`'s property assignment can be found from the array (parent) node.
29950
29994
  //
29951
29995
  // First search for `templateUrl`.
29952
- var asgn = getPropertyAssignmentFromValue(urlNode);
29953
- if (!asgn || asgn.name.getText() !== 'templateUrl') {
29996
+ var asgn = getPropertyAssignmentFromValue(urlNode, 'templateUrl');
29997
+ if (!asgn) {
29954
29998
  // `templateUrl` assignment not found; search for `styleUrls` array assignment.
29955
- asgn = getPropertyAssignmentFromValue(urlNode.parent);
29956
- if (!asgn || asgn.name.getText() !== 'styleUrls') {
29999
+ asgn = getPropertyAssignmentFromValue(urlNode.parent, 'styleUrls');
30000
+ if (!asgn) {
29957
30001
  // Nothing found, bail.
29958
30002
  return;
29959
30003
  }
29960
30004
  }
29961
30005
  // If the property assignment is not a property of a class decorator, don't generate definitions
29962
30006
  // for it.
29963
- if (!isClassDecoratorProperty(asgn))
30007
+ if (!getClassDeclFromDecoratorProp(asgn)) {
29964
30008
  return;
30009
+ }
29965
30010
  var sf = urlNode.getSourceFile();
29966
30011
  // Extract url path specified by the url node, which is relative to the TypeScript source file
29967
30012
  // the url node is defined in.
@@ -40087,7 +40132,7 @@ define(['exports', 'typescript/lib/tsserverlibrary', 'typescript', 'path'], func
40087
40132
  /**
40088
40133
  * @publicApi
40089
40134
  */
40090
- var VERSION$2 = new Version$1('9.1.6');
40135
+ var VERSION$2 = new Version$1('9.1.7');
40091
40136
 
40092
40137
  /**
40093
40138
  * @license
@@ -51968,8 +52013,8 @@ define(['exports', 'typescript/lib/tsserverlibrary', 'typescript', 'path'], func
51968
52013
  if (!tss.isStringLiteralLike(node)) {
51969
52014
  return;
51970
52015
  }
51971
- var tmplAsgn = getPropertyAssignmentFromValue(node);
51972
- if (!tmplAsgn || tmplAsgn.name.getText() !== 'template') {
52016
+ var tmplAsgn = getPropertyAssignmentFromValue(node, 'template');
52017
+ if (!tmplAsgn) {
51973
52018
  return;
51974
52019
  }
51975
52020
  var classDecl = getClassDeclFromDecoratorProp(tmplAsgn);