2020-08-14 00:55:48 +00:00
|
|
|
Before:
|
|
|
|
Save g:ale_completion_tsserver_remove_warnings
|
|
|
|
|
|
|
|
let g:ale_completion_tsserver_remove_warnings = 0
|
|
|
|
|
2018-05-28 14:16:15 +00:00
|
|
|
After:
|
2020-08-14 00:55:48 +00:00
|
|
|
Restore
|
|
|
|
|
2018-05-28 14:16:15 +00:00
|
|
|
unlet! b:ale_tsserver_completion_names
|
|
|
|
|
2017-11-26 12:24:18 +00:00
|
|
|
Execute(TypeScript completions responses should be parsed correctly):
|
|
|
|
AssertEqual [],
|
|
|
|
\ ale#completion#ParseTSServerCompletions({
|
|
|
|
\ 'body': [],
|
|
|
|
\})
|
2019-09-12 20:53:23 +00:00
|
|
|
AssertEqual
|
|
|
|
\ [
|
|
|
|
\ {
|
|
|
|
\ 'word': 'foo',
|
|
|
|
\ 'source': '/path/to/foo.ts',
|
|
|
|
\ },
|
|
|
|
\ {
|
|
|
|
\ 'word': 'bar',
|
|
|
|
\ 'source': '',
|
|
|
|
\ },
|
|
|
|
\ {
|
|
|
|
\ 'word': 'baz',
|
|
|
|
\ 'source': '',
|
|
|
|
\ }
|
|
|
|
\ ],
|
2017-11-26 12:24:18 +00:00
|
|
|
\ ale#completion#ParseTSServerCompletions({
|
|
|
|
\ 'body': [
|
2019-09-12 20:53:23 +00:00
|
|
|
\ {'name': 'foo', 'source': '/path/to/foo.ts'},
|
2017-11-26 12:24:18 +00:00
|
|
|
\ {'name': 'bar'},
|
|
|
|
\ {'name': 'baz'},
|
|
|
|
\ ],
|
|
|
|
\})
|
|
|
|
|
2019-10-18 17:44:47 +00:00
|
|
|
Execute(TypeScript completions responses should include warnings):
|
|
|
|
AssertEqual
|
|
|
|
\ [
|
|
|
|
\ {
|
|
|
|
\ 'word': 'foo',
|
|
|
|
\ 'source': '/path/to/foo.ts',
|
|
|
|
\ },
|
|
|
|
\ {
|
|
|
|
\ 'word': 'bar',
|
|
|
|
\ 'source': '',
|
|
|
|
\ },
|
|
|
|
\ {
|
|
|
|
\ 'word': 'baz',
|
|
|
|
\ 'source': '',
|
|
|
|
\ }
|
|
|
|
\ ],
|
|
|
|
\ ale#completion#ParseTSServerCompletions({
|
|
|
|
\ 'body': [
|
|
|
|
\ {'name': 'foo', 'source': '/path/to/foo.ts'},
|
|
|
|
\ {'name': 'bar', 'kind': 'warning'},
|
|
|
|
\ {'name': 'baz'},
|
|
|
|
\ ],
|
|
|
|
\})
|
|
|
|
|
|
|
|
Execute(TypeScript completions responses should not include warnings if excluded):
|
|
|
|
let g:ale_completion_tsserver_remove_warnings = 1
|
|
|
|
AssertEqual
|
|
|
|
\ [
|
|
|
|
\ {
|
|
|
|
\ 'word': 'foo',
|
|
|
|
\ 'source': '/path/to/foo.ts',
|
|
|
|
\ },
|
|
|
|
\ {
|
|
|
|
\ 'word': 'baz',
|
|
|
|
\ 'source': '',
|
|
|
|
\ }
|
|
|
|
\ ],
|
|
|
|
\ ale#completion#ParseTSServerCompletions({
|
|
|
|
\ 'body': [
|
|
|
|
\ {'name': 'foo', 'source': '/path/to/foo.ts'},
|
|
|
|
\ {'name': 'bar', 'kind': 'warning'},
|
|
|
|
\ {'name': 'baz'},
|
|
|
|
\ ],
|
|
|
|
\})
|
|
|
|
|
2017-11-26 12:24:18 +00:00
|
|
|
Execute(TypeScript completion details responses should be parsed correctly):
|
|
|
|
AssertEqual
|
|
|
|
\ [
|
|
|
|
\ {
|
|
|
|
\ 'word': 'abc',
|
|
|
|
\ 'menu': '(property) Foo.abc: number',
|
|
|
|
\ 'info': '',
|
2019-10-18 02:35:38 +00:00
|
|
|
\ 'kind': 'v',
|
2017-11-26 12:24:18 +00:00
|
|
|
\ 'icase': 1,
|
2020-09-08 20:40:10 +00:00
|
|
|
\ 'user_data': json_encode({'_ale_completion_item': 1}),
|
2020-08-09 01:28:47 +00:00
|
|
|
\ 'dup': g:ale_completion_autoimport,
|
2017-11-26 12:24:18 +00:00
|
|
|
\ },
|
|
|
|
\ {
|
|
|
|
\ 'word': 'def',
|
|
|
|
\ 'menu': '(property) Foo.def: number',
|
|
|
|
\ 'info': 'foo bar baz',
|
2019-10-18 02:35:38 +00:00
|
|
|
\ 'kind': 'v',
|
2017-11-26 12:24:18 +00:00
|
|
|
\ 'icase': 1,
|
2020-09-08 20:40:10 +00:00
|
|
|
\ 'user_data': json_encode({'_ale_completion_item': 1}),
|
2020-08-09 01:28:47 +00:00
|
|
|
\ 'dup': g:ale_completion_autoimport,
|
2018-05-28 14:16:15 +00:00
|
|
|
\ },
|
2018-09-10 22:47:04 +00:00
|
|
|
\ {
|
|
|
|
\ 'word': 'ghi',
|
|
|
|
\ 'menu': '(class) Foo',
|
|
|
|
\ 'info': '',
|
2019-10-18 02:35:38 +00:00
|
|
|
\ 'kind': 'v',
|
2018-09-10 22:47:04 +00:00
|
|
|
\ 'icase': 1,
|
2020-09-08 20:40:10 +00:00
|
|
|
\ 'user_data': json_encode({'_ale_completion_item': 1}),
|
2020-08-09 01:28:47 +00:00
|
|
|
\ 'dup': g:ale_completion_autoimport,
|
2018-09-10 22:47:04 +00:00
|
|
|
\ },
|
2018-05-28 14:16:15 +00:00
|
|
|
\ ],
|
|
|
|
\ ale#completion#ParseTSServerCompletionEntryDetails({
|
|
|
|
\ 'body': [
|
|
|
|
\ {
|
|
|
|
\ 'name': 'abc',
|
|
|
|
\ 'kind': 'parameterName',
|
|
|
|
\ 'displayParts': [
|
|
|
|
\ {'text': '('},
|
|
|
|
\ {'text': 'property'},
|
|
|
|
\ {'text': ')'},
|
|
|
|
\ {'text': ' '},
|
|
|
|
\ {'text': 'Foo'},
|
|
|
|
\ {'text': '.'},
|
|
|
|
\ {'text': 'abc'},
|
|
|
|
\ {'text': ':'},
|
|
|
|
\ {'text': ' '},
|
|
|
|
\ {'text': 'number'},
|
|
|
|
\ ],
|
|
|
|
\ },
|
|
|
|
\ {
|
|
|
|
\ 'name': 'def',
|
|
|
|
\ 'kind': 'parameterName',
|
|
|
|
\ 'displayParts': [
|
|
|
|
\ {'text': '('},
|
|
|
|
\ {'text': 'property'},
|
|
|
|
\ {'text': ')'},
|
|
|
|
\ {'text': ' '},
|
|
|
|
\ {'text': 'Foo'},
|
|
|
|
\ {'text': '.'},
|
|
|
|
\ {'text': 'def'},
|
|
|
|
\ {'text': ':'},
|
|
|
|
\ {'text': ' '},
|
|
|
|
\ {'text': 'number'},
|
|
|
|
\ ],
|
|
|
|
\ 'documentation': [
|
|
|
|
\ {'text': 'foo'},
|
|
|
|
\ {'text': ' '},
|
|
|
|
\ {'text': 'bar'},
|
|
|
|
\ {'text': ' '},
|
|
|
|
\ {'text': 'baz'},
|
|
|
|
\ ],
|
|
|
|
\ },
|
2018-09-10 22:47:04 +00:00
|
|
|
\ {
|
|
|
|
\ 'name': 'ghi',
|
|
|
|
\ 'kind': 'className',
|
|
|
|
\ 'displayParts': [
|
|
|
|
\ {'text': '('},
|
|
|
|
\ {'text': 'class'},
|
|
|
|
\ {'text': ')'},
|
|
|
|
\ {'text': ' '},
|
|
|
|
\ {'text': 'Foo'},
|
|
|
|
\ ],
|
|
|
|
\ },
|
2018-05-28 14:16:15 +00:00
|
|
|
\ ],
|
|
|
|
\})
|
|
|
|
|
|
|
|
Execute(Entries without details should be included in the responses):
|
2019-09-12 20:53:23 +00:00
|
|
|
let b:ale_tsserver_completion_names = [{
|
|
|
|
\ 'word': 'xyz',
|
|
|
|
\ 'source': '/path/to/xyz.ts',
|
|
|
|
\ }]
|
2018-05-28 14:16:15 +00:00
|
|
|
|
|
|
|
AssertEqual
|
|
|
|
\ [
|
|
|
|
\ {
|
|
|
|
\ 'word': 'abc',
|
2019-09-20 06:05:00 +00:00
|
|
|
\ 'menu': 'import { def } from "./Foo"; (property) Foo.abc: number',
|
2018-05-28 14:16:15 +00:00
|
|
|
\ 'info': '',
|
2019-10-18 02:35:38 +00:00
|
|
|
\ 'kind': 'v',
|
2018-05-28 14:16:15 +00:00
|
|
|
\ 'icase': 1,
|
2019-09-12 20:53:23 +00:00
|
|
|
\ 'user_data': json_encode({
|
2020-09-08 20:40:10 +00:00
|
|
|
\ '_ale_completion_item': 1,
|
|
|
|
\ 'code_actions': [{
|
2019-09-20 06:05:00 +00:00
|
|
|
\ 'description': 'import { def } from "./Foo";',
|
2019-09-12 20:53:23 +00:00
|
|
|
\ 'changes': [],
|
|
|
|
\ }],
|
|
|
|
\ }),
|
2020-08-09 01:28:47 +00:00
|
|
|
\ 'dup': g:ale_completion_autoimport,
|
2018-05-28 14:16:15 +00:00
|
|
|
\ },
|
|
|
|
\ {
|
|
|
|
\ 'word': 'def',
|
|
|
|
\ 'menu': '(property) Foo.def: number',
|
|
|
|
\ 'info': 'foo bar baz',
|
2019-10-18 02:35:38 +00:00
|
|
|
\ 'kind': 'v',
|
2018-05-28 14:16:15 +00:00
|
|
|
\ 'icase': 1,
|
2020-09-08 20:40:10 +00:00
|
|
|
\ 'user_data': json_encode({'_ale_completion_item': 1}),
|
2020-08-09 01:28:47 +00:00
|
|
|
\ 'dup': g:ale_completion_autoimport,
|
2018-05-28 14:16:15 +00:00
|
|
|
\ },
|
|
|
|
\ {
|
|
|
|
\ 'word': 'xyz',
|
|
|
|
\ 'menu': '',
|
|
|
|
\ 'info': '',
|
|
|
|
\ 'kind': 'v',
|
2020-09-08 20:40:10 +00:00
|
|
|
\ 'user_data': json_encode({'_ale_completion_item': 1}),
|
2018-05-28 14:16:15 +00:00
|
|
|
\ 'icase': 1,
|
2017-11-26 12:24:18 +00:00
|
|
|
\ },
|
|
|
|
\ ],
|
|
|
|
\ ale#completion#ParseTSServerCompletionEntryDetails({
|
|
|
|
\ 'body': [
|
|
|
|
\ {
|
|
|
|
\ 'name': 'abc',
|
|
|
|
\ 'kind': 'parameterName',
|
|
|
|
\ 'displayParts': [
|
|
|
|
\ {'text': '('},
|
|
|
|
\ {'text': 'property'},
|
|
|
|
\ {'text': ')'},
|
|
|
|
\ {'text': ' '},
|
|
|
|
\ {'text': 'Foo'},
|
|
|
|
\ {'text': '.'},
|
|
|
|
\ {'text': 'abc'},
|
|
|
|
\ {'text': ':'},
|
|
|
|
\ {'text': ' '},
|
|
|
|
\ {'text': 'number'},
|
|
|
|
\ ],
|
2019-09-12 20:53:23 +00:00
|
|
|
\ 'codeActions': [{
|
2019-09-20 06:05:00 +00:00
|
|
|
\ 'description': 'import { def } from "./Foo";',
|
2019-09-12 20:53:23 +00:00
|
|
|
\ 'changes': [],
|
|
|
|
\ }],
|
2017-11-26 12:24:18 +00:00
|
|
|
\ },
|
|
|
|
\ {
|
|
|
|
\ 'name': 'def',
|
|
|
|
\ 'kind': 'parameterName',
|
|
|
|
\ 'displayParts': [
|
|
|
|
\ {'text': '('},
|
|
|
|
\ {'text': 'property'},
|
|
|
|
\ {'text': ')'},
|
|
|
|
\ {'text': ' '},
|
|
|
|
\ {'text': 'Foo'},
|
|
|
|
\ {'text': '.'},
|
|
|
|
\ {'text': 'def'},
|
|
|
|
\ {'text': ':'},
|
|
|
|
\ {'text': ' '},
|
|
|
|
\ {'text': 'number'},
|
|
|
|
\ ],
|
|
|
|
\ 'documentation': [
|
|
|
|
\ {'text': 'foo'},
|
|
|
|
\ {'text': ' '},
|
|
|
|
\ {'text': 'bar'},
|
|
|
|
\ {'text': ' '},
|
|
|
|
\ {'text': 'baz'},
|
|
|
|
\ ],
|
|
|
|
\ },
|
|
|
|
\ ],
|
|
|
|
\})
|
2020-08-14 00:55:48 +00:00
|
|
|
|
|
|
|
Execute(Default imports should be handled correctly):
|
|
|
|
AssertEqual
|
|
|
|
\ [
|
|
|
|
\ {
|
|
|
|
\ 'word': 'abcd',
|
|
|
|
\ 'menu': 'Import default ''abcd'' from module "./foo" (alias) const abcd: 3',
|
|
|
|
\ 'info': '',
|
|
|
|
\ 'kind': 't',
|
|
|
|
\ 'icase': 1,
|
|
|
|
\ 'user_data': json_encode({
|
2020-09-08 20:40:10 +00:00
|
|
|
\ '_ale_completion_item': 1,
|
|
|
|
\ 'code_actions': [{
|
2020-08-14 00:55:48 +00:00
|
|
|
\ 'description': 'Import default ''abcd'' from module "./foo"',
|
|
|
|
\ 'changes': [],
|
|
|
|
\ }],
|
|
|
|
\ }),
|
|
|
|
\ 'dup': g:ale_completion_autoimport,
|
|
|
|
\ },
|
|
|
|
\ ],
|
|
|
|
\ ale#completion#ParseTSServerCompletionEntryDetails({
|
|
|
|
\ 'body': [
|
|
|
|
\ {
|
|
|
|
\ 'name': 'default',
|
|
|
|
\ 'kind': 'alias',
|
|
|
|
\ 'displayParts': [
|
|
|
|
\ {'kind': 'punctuation', 'text': '('},
|
|
|
|
\ {'kind': 'text', 'text': 'alias'},
|
|
|
|
\ {'kind': 'punctuation', 'text': ')'},
|
|
|
|
\ {'kind': 'space', 'text': ' '},
|
|
|
|
\ {'kind': 'keyword', 'text': 'const'},
|
|
|
|
\ {'kind': 'space', 'text': ' '},
|
|
|
|
\ {'kind': 'localName', 'text': 'abcd'},
|
|
|
|
\ {'kind': 'punctuation', 'text': ':'},
|
|
|
|
\ {'kind': 'space', 'text': ' '},
|
|
|
|
\ {'kind': 'stringLiteral', 'text': '3'},
|
|
|
|
\ {'kind': 'lineBreak', 'text': '^@'},
|
|
|
|
\ {'kind': 'keyword', 'text': 'export'},
|
|
|
|
\ {'kind': 'space', 'text': ' '},
|
|
|
|
\ {'kind': 'keyword', 'text': 'default'},
|
|
|
|
\ {'kind': 'space', 'text': ' '},
|
|
|
|
\ {'kind': 'aliasName', 'text': 'abcd'}
|
|
|
|
\ ],
|
|
|
|
\ 'codeActions': [
|
|
|
|
\ {
|
|
|
|
\ 'description': 'Import default ''abcd'' from module "./foo"',
|
|
|
|
\ 'changes': [],
|
|
|
|
\ },
|
|
|
|
\ ],
|
|
|
|
\ },
|
|
|
|
\ ],
|
|
|
|
\ })
|