@angular/language-service 12.0.4 → 12.0.5

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.
package/bundles/ivy.js CHANGED
@@ -1,5 +1,5 @@
1
1
  /**
2
- * @license Angular v12.0.4
2
+ * @license Angular v12.0.5
3
3
  * Copyright Google LLC All Rights Reserved.
4
4
  * License: MIT
5
5
  */
@@ -10093,6 +10093,7 @@ define(['exports', 'typescript/lib/tsserverlibrary', 'os', 'typescript', 'fs', '
10093
10093
  * opening tag is recovered).
10094
10094
  */
10095
10095
  _popElement(fullName, endSourceSpan) {
10096
+ let unexpectedCloseTagDetected = false;
10096
10097
  for (let stackIndex = this._elementStack.length - 1; stackIndex >= 0; stackIndex--) {
10097
10098
  const el = this._elementStack[stackIndex];
10098
10099
  if (el.name == fullName) {
@@ -10102,10 +10103,13 @@ define(['exports', 'typescript/lib/tsserverlibrary', 'os', 'typescript', 'fs', '
10102
10103
  el.endSourceSpan = endSourceSpan;
10103
10104
  el.sourceSpan.end = endSourceSpan !== null ? endSourceSpan.end : el.sourceSpan.end;
10104
10105
  this._elementStack.splice(stackIndex, this._elementStack.length - stackIndex);
10105
- return true;
10106
+ return !unexpectedCloseTagDetected;
10106
10107
  }
10107
10108
  if (!this.getTagDefinition(el.name).closedByParent) {
10108
- return false;
10109
+ // Note that we encountered an unexpected close tag but continue processing the element
10110
+ // stack so we can assign an `endSourceSpan` if there is a corresponding start tag for this
10111
+ // end tag in the stack.
10112
+ unexpectedCloseTagDetected = true;
10109
10113
  }
10110
10114
  }
10111
10115
  return false;
@@ -17918,7 +17922,7 @@ define(['exports', 'typescript/lib/tsserverlibrary', 'os', 'typescript', 'fs', '
17918
17922
  * Use of this source code is governed by an MIT-style license that can be
17919
17923
  * found in the LICENSE file at https://angular.io/license
17920
17924
  */
17921
- const VERSION$1 = new Version('12.0.4');
17925
+ const VERSION$1 = new Version('12.0.5');
17922
17926
 
17923
17927
  /**
17924
17928
  * @license
@@ -18557,7 +18561,7 @@ define(['exports', 'typescript/lib/tsserverlibrary', 'os', 'typescript', 'fs', '
18557
18561
  function compileDeclareClassMetadata(metadata) {
18558
18562
  const definitionMap = new DefinitionMap();
18559
18563
  definitionMap.set('minVersion', literal(MINIMUM_PARTIAL_LINKER_VERSION));
18560
- definitionMap.set('version', literal('12.0.4'));
18564
+ definitionMap.set('version', literal('12.0.5'));
18561
18565
  definitionMap.set('ngImport', importExpr(Identifiers.core));
18562
18566
  definitionMap.set('type', metadata.type);
18563
18567
  definitionMap.set('decorators', metadata.decorators);
@@ -18597,7 +18601,7 @@ define(['exports', 'typescript/lib/tsserverlibrary', 'os', 'typescript', 'fs', '
18597
18601
  function createDirectiveDefinitionMap(meta) {
18598
18602
  const definitionMap = new DefinitionMap();
18599
18603
  definitionMap.set('minVersion', literal(MINIMUM_PARTIAL_LINKER_VERSION$1));
18600
- definitionMap.set('version', literal('12.0.4'));
18604
+ definitionMap.set('version', literal('12.0.5'));
18601
18605
  // e.g. `type: MyDirective`
18602
18606
  definitionMap.set('type', meta.internalType);
18603
18607
  // e.g. `selector: 'some-dir'`
@@ -18814,7 +18818,7 @@ define(['exports', 'typescript/lib/tsserverlibrary', 'os', 'typescript', 'fs', '
18814
18818
  function compileDeclareFactoryFunction(meta) {
18815
18819
  const definitionMap = new DefinitionMap();
18816
18820
  definitionMap.set('minVersion', literal(MINIMUM_PARTIAL_LINKER_VERSION$2));
18817
- definitionMap.set('version', literal('12.0.4'));
18821
+ definitionMap.set('version', literal('12.0.5'));
18818
18822
  definitionMap.set('ngImport', importExpr(Identifiers.core));
18819
18823
  definitionMap.set('type', meta.internalType);
18820
18824
  definitionMap.set('deps', compileDependencies(meta.deps));
@@ -18856,7 +18860,7 @@ define(['exports', 'typescript/lib/tsserverlibrary', 'os', 'typescript', 'fs', '
18856
18860
  function createInjectableDefinitionMap(meta) {
18857
18861
  const definitionMap = new DefinitionMap();
18858
18862
  definitionMap.set('minVersion', literal(MINIMUM_PARTIAL_LINKER_VERSION$3));
18859
- definitionMap.set('version', literal('12.0.4'));
18863
+ definitionMap.set('version', literal('12.0.5'));
18860
18864
  definitionMap.set('ngImport', importExpr(Identifiers.core));
18861
18865
  definitionMap.set('type', meta.internalType);
18862
18866
  // Only generate providedIn property if it has a non-null value
@@ -18935,7 +18939,7 @@ define(['exports', 'typescript/lib/tsserverlibrary', 'os', 'typescript', 'fs', '
18935
18939
  function createInjectorDefinitionMap(meta) {
18936
18940
  const definitionMap = new DefinitionMap();
18937
18941
  definitionMap.set('minVersion', literal(MINIMUM_PARTIAL_LINKER_VERSION$4));
18938
- definitionMap.set('version', literal('12.0.4'));
18942
+ definitionMap.set('version', literal('12.0.5'));
18939
18943
  definitionMap.set('ngImport', importExpr(Identifiers.core));
18940
18944
  definitionMap.set('type', meta.internalType);
18941
18945
  definitionMap.set('providers', meta.providers);
@@ -18972,7 +18976,7 @@ define(['exports', 'typescript/lib/tsserverlibrary', 'os', 'typescript', 'fs', '
18972
18976
  function createNgModuleDefinitionMap(meta) {
18973
18977
  const definitionMap = new DefinitionMap();
18974
18978
  definitionMap.set('minVersion', literal(MINIMUM_PARTIAL_LINKER_VERSION$5));
18975
- definitionMap.set('version', literal('12.0.4'));
18979
+ definitionMap.set('version', literal('12.0.5'));
18976
18980
  definitionMap.set('ngImport', importExpr(Identifiers.core));
18977
18981
  definitionMap.set('type', meta.internalType);
18978
18982
  // We only generate the keys in the metadata if the arrays contain values.
@@ -19030,7 +19034,7 @@ define(['exports', 'typescript/lib/tsserverlibrary', 'os', 'typescript', 'fs', '
19030
19034
  function createPipeDefinitionMap(meta) {
19031
19035
  const definitionMap = new DefinitionMap();
19032
19036
  definitionMap.set('minVersion', literal(MINIMUM_PARTIAL_LINKER_VERSION$6));
19033
- definitionMap.set('version', literal('12.0.4'));
19037
+ definitionMap.set('version', literal('12.0.5'));
19034
19038
  definitionMap.set('ngImport', importExpr(Identifiers.core));
19035
19039
  // e.g. `type: MyPipe`
19036
19040
  definitionMap.set('type', meta.internalType);
@@ -19062,7 +19066,7 @@ define(['exports', 'typescript/lib/tsserverlibrary', 'os', 'typescript', 'fs', '
19062
19066
  * Use of this source code is governed by an MIT-style license that can be
19063
19067
  * found in the LICENSE file at https://angular.io/license
19064
19068
  */
19065
- const VERSION$2 = new Version('12.0.4');
19069
+ const VERSION$2 = new Version('12.0.5');
19066
19070
 
19067
19071
  /**
19068
19072
  * @license
@@ -24141,6 +24145,17 @@ define(['exports', 'typescript/lib/tsserverlibrary', 'os', 'typescript', 'fs', '
24141
24145
  }
24142
24146
  return records;
24143
24147
  }
24148
+ getAnalyzedRecords() {
24149
+ const result = new Map();
24150
+ for (const [sf, classes] of this.fileToClasses) {
24151
+ const records = [];
24152
+ for (const clazz of classes) {
24153
+ records.push(this.classes.get(clazz));
24154
+ }
24155
+ result.set(sf, records);
24156
+ }
24157
+ return result;
24158
+ }
24144
24159
  /**
24145
24160
  * Import a `ClassRecord` from a previous compilation.
24146
24161
  *
@@ -30156,7 +30171,7 @@ Either add the @Injectable() decorator to '${provider.node.name
30156
30171
  versions: this.versions,
30157
30172
  depGraph: this.depGraph,
30158
30173
  semanticDepGraph: newGraph,
30159
- traitCompiler,
30174
+ priorAnalysis: traitCompiler.getAnalyzedRecords(),
30160
30175
  typeCheckResults: null,
30161
30176
  emitted,
30162
30177
  };
@@ -30191,7 +30206,11 @@ Either add the @Injectable() decorator to '${provider.node.name
30191
30206
  if (this.step.logicallyChangedTsFiles.has(sfPath)) {
30192
30207
  return null;
30193
30208
  }
30194
- return this.step.priorState.traitCompiler.recordsFor(sf);
30209
+ const priorAnalysis = this.step.priorState.priorAnalysis;
30210
+ if (!priorAnalysis.has(sf)) {
30211
+ return null;
30212
+ }
30213
+ return priorAnalysis.get(sf);
30195
30214
  }
30196
30215
  priorTypeCheckingResultsFor(sf) {
30197
30216
  if (this.phase.kind !== PhaseKind.TypeCheckAndEmit) {
@@ -40086,7 +40105,7 @@ https://v9.angular.io/guide/template-typecheck#template-type-checking`,
40086
40105
  }
40087
40106
  visit(node) {
40088
40107
  const { start, end } = getSpanIncludingEndTag(node);
40089
- if (!isWithin(this.position, { start, end })) {
40108
+ if (end !== null && !isWithin(this.position, { start, end })) {
40090
40109
  return;
40091
40110
  }
40092
40111
  const last = this.path[this.path.length - 1];
@@ -40220,8 +40239,15 @@ https://v9.angular.io/guide/template-typecheck#template-type-checking`,
40220
40239
  // the end of the closing tag. Otherwise, for situation like
40221
40240
  // <my-component></my-comp¦onent> where the cursor is in the closing tag
40222
40241
  // we will not be able to return any information.
40223
- if ((ast instanceof Element || ast instanceof Template) && ast.endSourceSpan) {
40224
- result.end = ast.endSourceSpan.end.offset;
40242
+ if (ast instanceof Element || ast instanceof Template) {
40243
+ if (ast.endSourceSpan) {
40244
+ result.end = ast.endSourceSpan.end.offset;
40245
+ }
40246
+ else if (ast.children.length > 0) {
40247
+ // If the AST has children but no end source span, then it is an unclosed element with an end
40248
+ // that should be the end of the last child.
40249
+ result.end = getSpanIncludingEndTag(ast.children[ast.children.length - 1]).end;
40250
+ }
40225
40251
  }
40226
40252
  return result;
40227
40253
  }
@@ -40859,6 +40885,50 @@ https://v9.angular.io/guide/template-typecheck#template-type-checking`,
40859
40885
  }
40860
40886
  }
40861
40887
 
40888
+ /**
40889
+ * @license
40890
+ * Copyright Google LLC All Rights Reserved.
40891
+ *
40892
+ * Use of this source code is governed by an MIT-style license that can be
40893
+ * found in the LICENSE file at https://angular.io/license
40894
+ */
40895
+ /**
40896
+ * Converts a given `ts.DocumentSpan` in a shim file to its equivalent `ts.DocumentSpan` in the
40897
+ * template.
40898
+ *
40899
+ * You can optionally provide a `requiredNodeText` that ensures the equivalent template node's text
40900
+ * matches. If it does not, this function will return `null`.
40901
+ */
40902
+ function convertToTemplateDocumentSpan(shimDocumentSpan, templateTypeChecker, program, requiredNodeText) {
40903
+ const sf = program.getSourceFile(shimDocumentSpan.fileName);
40904
+ if (sf === undefined) {
40905
+ return null;
40906
+ }
40907
+ const tcbNode = findTightestNode(sf, shimDocumentSpan.textSpan.start);
40908
+ if (tcbNode === undefined ||
40909
+ hasExpressionIdentifier(sf, tcbNode, ExpressionIdentifier.EVENT_PARAMETER)) {
40910
+ // If the reference result is the $event parameter in the subscribe/addEventListener
40911
+ // function in the TCB, we want to filter this result out of the references. We really only
40912
+ // want to return references to the parameter in the template itself.
40913
+ return null;
40914
+ }
40915
+ // TODO(atscott): Determine how to consistently resolve paths. i.e. with the project
40916
+ // serverHost or LSParseConfigHost in the adapter. We should have a better defined way to
40917
+ // normalize paths.
40918
+ const mapping = getTemplateLocationFromShimLocation(templateTypeChecker, absoluteFrom(shimDocumentSpan.fileName), shimDocumentSpan.textSpan.start);
40919
+ if (mapping === null) {
40920
+ return null;
40921
+ }
40922
+ const { span, templateUrl } = mapping;
40923
+ if (requiredNodeText !== undefined && span.toString() !== requiredNodeText) {
40924
+ return null;
40925
+ }
40926
+ return Object.assign(Object.assign({}, shimDocumentSpan), { fileName: templateUrl, textSpan: toTextSpan(span),
40927
+ // Specifically clear other text span values because we do not have enough knowledge to
40928
+ // convert these to spans in the template.
40929
+ contextSpan: undefined, originalContextSpan: undefined, originalTextSpan: undefined });
40930
+ }
40931
+
40862
40932
  /**
40863
40933
  * @license
40864
40934
  * Copyright Google LLC All Rights Reserved.
@@ -40867,9 +40937,11 @@ https://v9.angular.io/guide/template-typecheck#template-type-checking`,
40867
40937
  * found in the LICENSE file at https://angular.io/license
40868
40938
  */
40869
40939
  class DefinitionBuilder {
40870
- constructor(tsLS, compiler) {
40940
+ constructor(tsLS, compiler, driver) {
40871
40941
  this.tsLS = tsLS;
40872
40942
  this.compiler = compiler;
40943
+ this.driver = driver;
40944
+ this.ttc = this.compiler.getTemplateTypeChecker();
40873
40945
  }
40874
40946
  getDefinitionAndBoundSpan(fileName, position) {
40875
40947
  var _a;
@@ -40964,11 +41036,34 @@ https://v9.angular.io/guide/template-typecheck#template-type-checking`,
40964
41036
  }
40965
41037
  getDefinitionsForSymbols(...symbols) {
40966
41038
  return flatMap(symbols, ({ shimLocation }) => {
40967
- var _a;
40968
41039
  const { shimPath, positionInShimFile } = shimLocation;
40969
- return (_a = this.tsLS.getDefinitionAtPosition(shimPath, positionInShimFile)) !== null && _a !== void 0 ? _a : [];
41040
+ const definitionInfos = this.tsLS.getDefinitionAtPosition(shimPath, positionInShimFile);
41041
+ if (definitionInfos === undefined) {
41042
+ return [];
41043
+ }
41044
+ return this.mapShimResultsToTemplates(definitionInfos);
40970
41045
  });
40971
41046
  }
41047
+ /**
41048
+ * Converts and definition info result that points to a template typecheck file to a reference to
41049
+ * the corresponding location in the template.
41050
+ */
41051
+ mapShimResultsToTemplates(definitionInfos) {
41052
+ const result = [];
41053
+ for (const info of definitionInfos) {
41054
+ if (this.ttc.isTrackedTypeCheckFile(absoluteFrom(info.fileName))) {
41055
+ const templateDefinitionInfo = convertToTemplateDocumentSpan(info, this.ttc, this.driver.getProgram());
41056
+ if (templateDefinitionInfo === null) {
41057
+ continue;
41058
+ }
41059
+ result.push(templateDefinitionInfo);
41060
+ }
41061
+ else {
41062
+ result.push(info);
41063
+ }
41064
+ }
41065
+ return result;
41066
+ }
40972
41067
  getTypeDefinitionsAtPosition(fileName, position) {
40973
41068
  const templateInfo = getTemplateInfoAtPosition(fileName, position, this.compiler);
40974
41069
  if (templateInfo === undefined) {
@@ -41867,7 +41962,7 @@ https://v9.angular.io/guide/template-typecheck#template-type-checking`,
41867
41962
  if (!isInAngularContext(compiler.getCurrentProgram(), fileName, position)) {
41868
41963
  return undefined;
41869
41964
  }
41870
- return new DefinitionBuilder(this.tsLS, compiler)
41965
+ return new DefinitionBuilder(this.tsLS, compiler, this.programDriver)
41871
41966
  .getDefinitionAndBoundSpan(fileName, position);
41872
41967
  });
41873
41968
  }
@@ -41876,7 +41971,7 @@ https://v9.angular.io/guide/template-typecheck#template-type-checking`,
41876
41971
  if (!isTemplateContext(compiler.getCurrentProgram(), fileName, position)) {
41877
41972
  return undefined;
41878
41973
  }
41879
- return new DefinitionBuilder(this.tsLS, compiler)
41974
+ return new DefinitionBuilder(this.tsLS, compiler, this.programDriver)
41880
41975
  .getTypeDefinitionsAtPosition(fileName, position);
41881
41976
  });
41882
41977
  }
@@ -1,5 +1,5 @@
1
1
  /**
2
- * @license Angular v12.0.4
2
+ * @license Angular v12.0.5
3
3
  * Copyright Google LLC All Rights Reserved.
4
4
  * License: MIT
5
5
  */
@@ -10148,6 +10148,7 @@ define(['exports', 'typescript/lib/tsserverlibrary', 'typescript', 'path'], func
10148
10148
  * opening tag is recovered).
10149
10149
  */
10150
10150
  _popElement(fullName, endSourceSpan) {
10151
+ let unexpectedCloseTagDetected = false;
10151
10152
  for (let stackIndex = this._elementStack.length - 1; stackIndex >= 0; stackIndex--) {
10152
10153
  const el = this._elementStack[stackIndex];
10153
10154
  if (el.name == fullName) {
@@ -10157,10 +10158,13 @@ define(['exports', 'typescript/lib/tsserverlibrary', 'typescript', 'path'], func
10157
10158
  el.endSourceSpan = endSourceSpan;
10158
10159
  el.sourceSpan.end = endSourceSpan !== null ? endSourceSpan.end : el.sourceSpan.end;
10159
10160
  this._elementStack.splice(stackIndex, this._elementStack.length - stackIndex);
10160
- return true;
10161
+ return !unexpectedCloseTagDetected;
10161
10162
  }
10162
10163
  if (!this.getTagDefinition(el.name).closedByParent) {
10163
- return false;
10164
+ // Note that we encountered an unexpected close tag but continue processing the element
10165
+ // stack so we can assign an `endSourceSpan` if there is a corresponding start tag for this
10166
+ // end tag in the stack.
10167
+ unexpectedCloseTagDetected = true;
10164
10168
  }
10165
10169
  }
10166
10170
  return false;
@@ -19459,7 +19463,7 @@ define(['exports', 'typescript/lib/tsserverlibrary', 'typescript', 'path'], func
19459
19463
  * Use of this source code is governed by an MIT-style license that can be
19460
19464
  * found in the LICENSE file at https://angular.io/license
19461
19465
  */
19462
- const VERSION$1 = new Version('12.0.4');
19466
+ const VERSION$1 = new Version('12.0.5');
19463
19467
 
19464
19468
  /**
19465
19469
  * @license
@@ -35530,7 +35534,7 @@ define(['exports', 'typescript/lib/tsserverlibrary', 'typescript', 'path'], func
35530
35534
  /**
35531
35535
  * @publicApi
35532
35536
  */
35533
- const VERSION$2 = new Version$1('12.0.4');
35537
+ const VERSION$2 = new Version$1('12.0.5');
35534
35538
 
35535
35539
  /**
35536
35540
  * @license
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@angular/language-service",
3
- "version": "12.0.4",
3
+ "version": "12.0.5",
4
4
  "description": "Angular - language services",
5
5
  "main": "./index.js",
6
6
  "typings": "./index.d.ts",