angular-docs-cn/packages/language-service/test
Keen Yee Liau e1e1db3c01 fix(language-service): Paths on Windows should be normalized (#40492)
Many `ts.LanguageService` APIs accept a filename, for example
```ts
getQuickInfoAtPosition(fileName: string, position: number)
```
The requirement is that `fileName` is agnostic to the platform (Linux, Mac,
Windows, etc), and is always normalized to TypeScript's internal
`NormalizedPath`.

This is evident from the way these APIs are called from the language server:
```ts
  private onHover(params: lsp.TextDocumentPositionParams) {
    const lsInfo = this.getLSAndScriptInfo(params.textDocument);
    if (lsInfo === undefined) {
      return;
    }
    const {languageService, scriptInfo} = lsInfo;
    const offset = lspPositionToTsPosition(scriptInfo, params.position);
    const info = languageService.getQuickInfoAtPosition(scriptInfo.fileName, offset);
    // ...
  }
```
9fca9c6651/server/src/session.ts (L594)
Here `scriptInfo.fileName` is always a `ts.server.NormalizedPath`.

However, https://github.com/angular/angular/pull/39917 accidentally leaked
the platform-specific paths, and caused a mismatch between the incoming paths
and the paths stored in the internal data structure `fileToComponent`.

This PR fixes the bug by always normalizing the paths, and updating the
type to reflect the format of the underlying data.

Fixes https://github.com/angular/vscode-ng-language-service/issues/1063

PR Close #40492
2021-01-20 08:46:03 -08:00
..
project fix(language-service): do not treat file URIs as general URLs (#39917) 2020-12-03 13:45:30 -08:00
BUILD.bazel refactor(language-service): introduce DisplayParts abstraction for Ivy (#39505) 2020-11-02 10:29:50 -08:00
completions_spec.ts fix(language-service): remove completion for string (#37983) 2020-07-13 14:16:56 -07:00
definitions_spec.ts fix(language-service): diagnostic and definition should work for absolute url (#40406) 2021-01-13 09:05:04 -08:00
diagnostic_messages_spec.ts build: update license headers to reference Google LLC (#37205) 2020-05-26 14:26:58 -04:00
diagnostics_spec.ts fix(language-service): diagnostic and definition should work for absolute url (#40406) 2021-01-13 09:05:04 -08:00
expression_diagnostics_spec.ts feat(compiler): support unary operators for more accurate type checking (#37918) 2020-08-21 12:25:53 -07:00
global_symbols_spec.ts build: update license headers to reference Google LLC (#37205) 2020-05-26 14:26:58 -04:00
hover_spec.ts feat(common): stricter types for DatePipe (#37447) 2020-09-28 12:23:32 -04:00
html_info_spec.ts build: update license headers to reference Google LLC (#37205) 2020-05-26 14:26:58 -04:00
language_service_spec.ts test(language-service): Remove all markers from test project (#37475) 2020-06-08 10:25:42 -07:00
mocks.ts build: update license headers to reference Google LLC (#37205) 2020-05-26 14:26:58 -04:00
references_spec.ts feat(language-service): TS references from template items (#37437) 2020-06-08 17:23:49 -07:00
reflector_host_spec.ts build: update license headers to reference Google LLC (#37205) 2020-05-26 14:26:58 -04:00
test_utils.ts fix(language-service): do not treat file URIs as general URLs (#39917) 2020-12-03 13:45:30 -08:00
ts_plugin_spec.ts fix(language-service): do not treat file URIs as general URLs (#39917) 2020-12-03 13:45:30 -08:00
typescript_host_spec.ts fix(language-service): Paths on Windows should be normalized (#40492) 2021-01-20 08:46:03 -08:00
typescript_symbols_spec.ts build: update license headers to reference Google LLC (#37205) 2020-05-26 14:26:58 -04:00
utils_spec.ts refactor(language-service): introduce DisplayParts abstraction for Ivy (#39505) 2020-11-02 10:29:50 -08:00