@angular/language-server 20.0.1 → 20.1.0

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.
Files changed (2) hide show
  1. package/index.js +164 -7
  2. package/package.json +2 -2
package/index.js CHANGED
@@ -17,6 +17,28 @@ var require_cmdline_utils = __commonJS({
17
17
  }
18
18
  return argv[index + 1];
19
19
  }
20
+ function findArgumentWithDefault(argv, argName, defaultValue) {
21
+ const index = argv.indexOf(argName);
22
+ if (index < 0) {
23
+ return defaultValue;
24
+ }
25
+ if (index === argv.length - 1) {
26
+ return void 0;
27
+ }
28
+ const argValue = argv[index + 1];
29
+ if (argValue.startsWith("-")) {
30
+ return void 0;
31
+ } else {
32
+ return argValue;
33
+ }
34
+ }
35
+ function parseBooleanArgument(argv, argName) {
36
+ const argValue = findArgumentWithDefault(argv, argName, "true");
37
+ if (argValue === void 0 || argValue === "true") {
38
+ return true;
39
+ }
40
+ return false;
41
+ }
20
42
  function parseStringArray(argv, argName) {
21
43
  const arg = findArgument(argv, argName);
22
44
  if (!arg) {
@@ -39,6 +61,7 @@ var require_cmdline_utils = __commonJS({
39
61
  tsdk: (_a = findArgument(argv, "--tsdk")) !== null && _a !== void 0 ? _a : null,
40
62
  includeAutomaticOptionalChainCompletions: hasArgument(argv, "--includeAutomaticOptionalChainCompletions"),
41
63
  includeCompletionsWithSnippetText: hasArgument(argv, "--includeCompletionsWithSnippetText"),
64
+ includeCompletionsForModuleExports: parseBooleanArgument(argv, "--includeCompletionsForModuleExports"),
42
65
  forceStrictTemplates: hasArgument(argv, "--forceStrictTemplates"),
43
66
  disableBlockSyntax: hasArgument(argv, "--disableBlockSyntax"),
44
67
  disableLetSyntax: hasArgument(argv, "--disableLetSyntax"),
@@ -396,6 +419,28 @@ var require_cmdline_utils = __commonJS({
396
419
  }
397
420
  return argv[index + 1];
398
421
  }
422
+ function findArgumentWithDefault(argv, argName, defaultValue) {
423
+ const index = argv.indexOf(argName);
424
+ if (index < 0) {
425
+ return defaultValue;
426
+ }
427
+ if (index === argv.length - 1) {
428
+ return void 0;
429
+ }
430
+ const argValue = argv[index + 1];
431
+ if (argValue.startsWith("-")) {
432
+ return void 0;
433
+ } else {
434
+ return argValue;
435
+ }
436
+ }
437
+ function parseBooleanArgument(argv, argName) {
438
+ const argValue = findArgumentWithDefault(argv, argName, "true");
439
+ if (argValue === void 0 || argValue === "true") {
440
+ return true;
441
+ }
442
+ return false;
443
+ }
399
444
  function parseStringArray(argv, argName) {
400
445
  const arg = findArgument(argv, argName);
401
446
  if (!arg) {
@@ -418,6 +463,7 @@ var require_cmdline_utils = __commonJS({
418
463
  tsdk: (_a = findArgument(argv, "--tsdk")) !== null && _a !== void 0 ? _a : null,
419
464
  includeAutomaticOptionalChainCompletions: hasArgument(argv, "--includeAutomaticOptionalChainCompletions"),
420
465
  includeCompletionsWithSnippetText: hasArgument(argv, "--includeCompletionsWithSnippetText"),
466
+ includeCompletionsForModuleExports: parseBooleanArgument(argv, "--includeCompletionsForModuleExports"),
421
467
  forceStrictTemplates: hasArgument(argv, "--forceStrictTemplates"),
422
468
  disableBlockSyntax: hasArgument(argv, "--disableBlockSyntax"),
423
469
  disableLetSyntax: hasArgument(argv, "--disableLetSyntax"),
@@ -771,9 +817,9 @@ var require_server_host = __commonJS({
771
817
  }
772
818
  });
773
819
 
774
- // ../../../../../../../../execroot/__main__/bazel-out/darwin_arm64-fastbuild/bin/node_modules/.aspect_rules_js/@angular+language-service@registry.npmjs.org+@angular+language-service@20.0.0-rc.2/node_modules/@angular/language-service/api_bundle.js
820
+ // ../../../../../../../../execroot/__main__/bazel-out/darwin_arm64-fastbuild/bin/node_modules/.aspect_rules_js/@angular+language-service@registry.npmjs.org+@angular+language-service@20.1.0-rc.0/node_modules/@angular/language-service/api_bundle.js
775
821
  var require_api_bundle = __commonJS({
776
- "../../../../../../../../execroot/__main__/bazel-out/darwin_arm64-fastbuild/bin/node_modules/.aspect_rules_js/@angular+language-service@registry.npmjs.org+@angular+language-service@20.0.0-rc.2/node_modules/@angular/language-service/api_bundle.js"(exports2, module2) {
822
+ "../../../../../../../../execroot/__main__/bazel-out/darwin_arm64-fastbuild/bin/node_modules/.aspect_rules_js/@angular+language-service@registry.npmjs.org+@angular+language-service@20.1.0-rc.0/node_modules/@angular/language-service/api_bundle.js"(exports2, module2) {
777
823
  var __defProp2 = Object.defineProperty;
778
824
  var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
779
825
  var __getOwnPropNames2 = Object.getOwnPropertyNames;
@@ -3461,7 +3507,8 @@ var require_completion = __commonJS({
3461
3507
  item.data = {
3462
3508
  kind: "ngCompletionOriginData",
3463
3509
  filePath: scriptInfo.fileName,
3464
- position
3510
+ position,
3511
+ tsData: entry.data
3465
3512
  };
3466
3513
  return item;
3467
3514
  }
@@ -217458,6 +217505,75 @@ var require_embedded_support = __commonJS({
217458
217505
  }
217459
217506
  });
217460
217507
 
217508
+ // ../../../../../../../../execroot/__main__/bazel-out/darwin_arm64-fastbuild/bin/server/src/semantic_tokens.js
217509
+ var require_semantic_tokens = __commonJS({
217510
+ "../../../../../../../../execroot/__main__/bazel-out/darwin_arm64-fastbuild/bin/server/src/semantic_tokens.js"(exports2) {
217511
+ "use strict";
217512
+ var __createBinding = exports2 && exports2.__createBinding || (Object.create ? function(o, m, k, k2) {
217513
+ if (k2 === void 0)
217514
+ k2 = k;
217515
+ var desc = Object.getOwnPropertyDescriptor(m, k);
217516
+ if (!desc || ("get" in desc ? !m.__esModule : desc.writable || desc.configurable)) {
217517
+ desc = { enumerable: true, get: function() {
217518
+ return m[k];
217519
+ } };
217520
+ }
217521
+ Object.defineProperty(o, k2, desc);
217522
+ } : function(o, m, k, k2) {
217523
+ if (k2 === void 0)
217524
+ k2 = k;
217525
+ o[k2] = m[k];
217526
+ });
217527
+ var __setModuleDefault = exports2 && exports2.__setModuleDefault || (Object.create ? function(o, v) {
217528
+ Object.defineProperty(o, "default", { enumerable: true, value: v });
217529
+ } : function(o, v) {
217530
+ o["default"] = v;
217531
+ });
217532
+ var __importStar = exports2 && exports2.__importStar || function(mod) {
217533
+ if (mod && mod.__esModule)
217534
+ return mod;
217535
+ var result = {};
217536
+ if (mod != null) {
217537
+ for (var k in mod)
217538
+ if (k !== "default" && Object.prototype.hasOwnProperty.call(mod, k))
217539
+ __createBinding(result, mod, k);
217540
+ }
217541
+ __setModuleDefault(result, mod);
217542
+ return result;
217543
+ };
217544
+ Object.defineProperty(exports2, "__esModule", { value: true });
217545
+ exports2.getSemanticTokens = void 0;
217546
+ var lsp = __importStar(require("vscode-languageserver/node"));
217547
+ function getSemanticTokens(languageService, classifications, script) {
217548
+ const spans = classifications.spans;
217549
+ const builder = new lsp.SemanticTokensBuilder();
217550
+ for (let i = 0; i < spans.length; ) {
217551
+ const offset = spans[i++];
217552
+ const length = spans[i++];
217553
+ const classification = spans[i++];
217554
+ const tokenType = languageService.getTokenTypeFromClassification(classification);
217555
+ if (tokenType === void 0) {
217556
+ continue;
217557
+ }
217558
+ const tokenModifiers = languageService.getTokenModifierFromClassification(classification);
217559
+ const startPos = script.positionToLineOffset(offset);
217560
+ startPos.line -= 1;
217561
+ startPos.offset -= 1;
217562
+ const endPos = script.positionToLineOffset(offset + length);
217563
+ endPos.line -= 1;
217564
+ endPos.offset -= 1;
217565
+ for (let line = startPos.line; line <= endPos.line; line++) {
217566
+ const startCharacter = line === startPos.line ? startPos.offset : 0;
217567
+ const endCharacter = line === endPos.line ? endPos.offset : script.lineToTextSpan(line - 1).length;
217568
+ builder.push(line, startCharacter, endCharacter - startCharacter, tokenType, tokenModifiers);
217569
+ }
217570
+ }
217571
+ return builder.build();
217572
+ }
217573
+ exports2.getSemanticTokens = getSemanticTokens;
217574
+ }
217575
+ });
217576
+
217461
217577
  // ../../../../../../../../execroot/__main__/bazel-out/darwin_arm64-fastbuild/bin/common/initialize.js
217462
217578
  var require_initialize = __commonJS({
217463
217579
  "../../../../../../../../execroot/__main__/bazel-out/darwin_arm64-fastbuild/bin/common/initialize.js"(exports2) {
@@ -217717,6 +217833,7 @@ var require_session = __commonJS({
217717
217833
  var completion_1 = require_completion();
217718
217834
  var diagnostic_1 = require_diagnostic();
217719
217835
  var embedded_support_1 = require_embedded_support();
217836
+ var semantic_tokens_1 = require_semantic_tokens();
217720
217837
  var text_render_1 = require_text_render();
217721
217838
  var utils_1 = require_utils();
217722
217839
  var LanguageId;
@@ -217742,8 +217859,10 @@ var require_session = __commonJS({
217742
217859
  this.clientCapabilities = {};
217743
217860
  this.includeAutomaticOptionalChainCompletions = options2.includeAutomaticOptionalChainCompletions;
217744
217861
  this.includeCompletionsWithSnippetText = options2.includeCompletionsWithSnippetText;
217862
+ this.includeCompletionsForModuleExports = options2.includeCompletionsForModuleExports;
217745
217863
  this.logger = options2.logger;
217746
217864
  this.logToConsole = options2.logToConsole;
217865
+ defaultPreferences = Object.assign(Object.assign({}, defaultPreferences), { includeCompletionsForModuleExports: options2.includeCompletionsForModuleExports });
217747
217866
  this.connection = lsp.createConnection({
217748
217867
  // cancelUndispatched is a "middleware" to handle all cancellation requests.
217749
217868
  // LSP spec requires every request to send a response back, even if it is
@@ -217800,7 +217919,8 @@ var require_session = __commonJS({
217800
217919
  preferences: {
217801
217920
  // We don't want the AutoImportProvider projects to be created. See
217802
217921
  // https://devblogs.microsoft.com/typescript/announcing-typescript-4-0/#smarter-auto-imports
217803
- includePackageJsonAutoImports: "off"
217922
+ includePackageJsonAutoImports: "off",
217923
+ includeCompletionsForModuleExports: this.includeCompletionsForModuleExports
217804
217924
  },
217805
217925
  watchOptions: {
217806
217926
  // Used as watch options when not specified by user's `tsconfig`.
@@ -217857,6 +217977,30 @@ var require_session = __commonJS({
217857
217977
  conn.onCodeActionResolve((p) => __async(this, null, function* () {
217858
217978
  return yield this.onCodeActionResolve(p);
217859
217979
  }));
217980
+ conn.onRequest(lsp.SemanticTokensRequest.type, (p) => this.onSemanticTokensRequest(p));
217981
+ conn.onRequest(lsp.SemanticTokensRangeRequest.type, (p) => this.onSemanticTokensRangeRequest(p));
217982
+ }
217983
+ onSemanticTokensRequest(params) {
217984
+ const lsInfo = this.getLSAndScriptInfo(params.textDocument);
217985
+ if (lsInfo === null) {
217986
+ return null;
217987
+ }
217988
+ const { languageService, scriptInfo } = lsInfo;
217989
+ const span = { start: 0, length: scriptInfo.getSnapshot().getLength() };
217990
+ const classifications = languageService.getEncodedSemanticClassifications(scriptInfo.fileName, span, ts.SemanticClassificationFormat.TwentyTwenty);
217991
+ return (0, semantic_tokens_1.getSemanticTokens)(languageService, classifications, scriptInfo);
217992
+ }
217993
+ onSemanticTokensRangeRequest(params) {
217994
+ const lsInfo = this.getLSAndScriptInfo(params.textDocument);
217995
+ if (lsInfo === null) {
217996
+ return null;
217997
+ }
217998
+ const { languageService, scriptInfo } = lsInfo;
217999
+ const start = (0, utils_1.lspPositionToTsPosition)(lsInfo.scriptInfo, params.range.start);
218000
+ const end = (0, utils_1.lspPositionToTsPosition)(lsInfo.scriptInfo, params.range.end);
218001
+ const span = { start, length: end - start };
218002
+ const classifications = languageService.getEncodedSemanticClassifications(scriptInfo.fileName, span, ts.SemanticClassificationFormat.TwentyTwenty);
218003
+ return (0, semantic_tokens_1.getSemanticTokens)(languageService, classifications, scriptInfo);
217860
218004
  }
217861
218005
  onCodeAction(params) {
217862
218006
  const filePath = (0, utils_1.uriToFilePath)(params.textDocument.uri);
@@ -218330,6 +218474,17 @@ var require_session = __commonJS({
218330
218474
  // Find more info
218331
218475
  // [here](https://github.com/angular/vscode-ng-language-service/issues/1828)
218332
218476
  codeActionKinds: [lsp.CodeActionKind.QuickFix]
218477
+ },
218478
+ semanticTokensProvider: {
218479
+ documentSelector: null,
218480
+ legend: {
218481
+ tokenTypes: [
218482
+ "class"
218483
+ ],
218484
+ tokenModifiers: []
218485
+ },
218486
+ full: true,
218487
+ range: true
218333
218488
  }
218334
218489
  },
218335
218490
  serverOptions
@@ -218681,11 +218836,12 @@ var require_session = __commonJS({
218681
218836
  const offset = (0, utils_1.lspPositionToTsPosition)(scriptInfo, params.position);
218682
218837
  let options2 = {};
218683
218838
  const includeCompletionsWithSnippetText = this.includeCompletionsWithSnippetText && this.snippetSupport;
218684
- if (this.includeAutomaticOptionalChainCompletions || includeCompletionsWithSnippetText) {
218839
+ if (this.includeAutomaticOptionalChainCompletions || includeCompletionsWithSnippetText || this.includeCompletionsForModuleExports) {
218685
218840
  options2 = {
218686
218841
  includeAutomaticOptionalChainCompletions: this.includeAutomaticOptionalChainCompletions,
218687
218842
  includeCompletionsWithSnippetText,
218688
- includeCompletionsWithInsertText: this.includeAutomaticOptionalChainCompletions || includeCompletionsWithSnippetText
218843
+ includeCompletionsWithInsertText: this.includeAutomaticOptionalChainCompletions || includeCompletionsWithSnippetText,
218844
+ includeCompletionsForModuleExports: this.includeCompletionsForModuleExports
218689
218845
  };
218690
218846
  }
218691
218847
  const completions = languageService.getCompletionsAtPosition(scriptInfo.fileName, offset, options2);
@@ -218707,7 +218863,7 @@ var require_session = __commonJS({
218707
218863
  }
218708
218864
  const { languageService, scriptInfo } = lsInfo;
218709
218865
  const offset = (0, utils_1.lspPositionToTsPosition)(scriptInfo, position);
218710
- const details = languageService.getCompletionEntryDetails(filePath, offset, (_a = item.insertText) !== null && _a !== void 0 ? _a : item.label, void 0, void 0, void 0, void 0);
218866
+ const details = languageService.getCompletionEntryDetails(filePath, offset, (_a = item.insertText) !== null && _a !== void 0 ? _a : item.label, void 0, void 0, defaultPreferences, data.tsData);
218711
218867
  if (details === void 0) {
218712
218868
  return item;
218713
218869
  }
@@ -219121,6 +219277,7 @@ function main() {
219121
219277
  logToConsole: options.logToConsole,
219122
219278
  includeAutomaticOptionalChainCompletions: options.includeAutomaticOptionalChainCompletions,
219123
219279
  includeCompletionsWithSnippetText: options.includeCompletionsWithSnippetText,
219280
+ includeCompletionsForModuleExports: options.includeCompletionsForModuleExports,
219124
219281
  forceStrictTemplates: isG3 || options.forceStrictTemplates,
219125
219282
  disableBlockSyntax: options.disableBlockSyntax,
219126
219283
  disableLetSyntax: options.disableLetSyntax,
package/package.json CHANGED
@@ -1,7 +1,7 @@
1
1
  {
2
2
  "name": "@angular/language-server",
3
3
  "description": "LSP server for Angular Language Service",
4
- "version": "20.0.1",
4
+ "version": "20.1.0",
5
5
  "repository": {
6
6
  "type": "git",
7
7
  "url": "https://github.com/angular/vscode-ng-language-service.git"
@@ -15,7 +15,7 @@
15
15
  "ngserver": "./bin/ngserver"
16
16
  },
17
17
  "dependencies": {
18
- "@angular/language-service": "20.0.0-rc.2",
18
+ "@angular/language-service": "20.1.0-rc.0",
19
19
  "vscode-html-languageservice": "^4.2.5",
20
20
  "vscode-jsonrpc": "6.0.0",
21
21
  "vscode-languageserver": "7.0.0",