Skip to content

Commit dff890a

Browse files
author
Benjamin Pasero
committed
Merge branch 'master' into ben/global-storage
2 parents fd42b23 + 24036d7 commit dff890a

78 files changed

Lines changed: 913 additions & 591 deletions

File tree

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

extensions/markdown-language-features/src/test/documentSymbolProvider.test.ts

Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -82,5 +82,16 @@ suite('markdown.DocumentSymbolProvider', () => {
8282
assert.strictEqual(symbols[0].children[0].name, '### h2');
8383
assert.strictEqual(symbols[0].children[1].name, '## h3');
8484
});
85+
86+
test.skip('Should handle line separator in file. Issue #63749', async () => {
87+
const symbols = await getSymbolsForFile(`# A
88+
- foo

89+
90+
# B
91+
- bar`);
92+
assert.strictEqual(symbols.length, 2);
93+
assert.strictEqual(symbols[0].name, '# A');
94+
assert.strictEqual(symbols[1].name, '# B');
95+
});
8596
});
8697

extensions/package.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,7 @@
33
"version": "0.0.1",
44
"description": "Dependencies shared by all extensions",
55
"dependencies": {
6-
"typescript": "3.2.0-rc"
6+
"typescript": "3.2.1-insiders.20181127"
77
},
88
"scripts": {
99
"postinstall": "node ./postinstall"

extensions/typescript-language-features/cgmanifest.json

Lines changed: 7 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -28,7 +28,8 @@
2828
"type": "other",
2929
"other": {
3030
"name": "Unicode",
31-
"downloadUrl": "http://www.unicode.org/"
31+
"downloadUrl": "http://www.unicode.org/",
32+
"version": "12.0.0"
3233
}
3334
},
3435
"licenseDetail": [
@@ -88,14 +89,16 @@
8889
"use or other dealings in these Data Files or Software without prior",
8990
"written authorization of the copyright holder."
9091
],
92+
"version": "12.0.0",
9193
"license": "UNICODE, INC. LICENSE AGREEMENT - DATA FILES AND SOFTWARE"
9294
},
9395
{
9496
"component": {
9597
"type": "other",
9698
"other": {
9799
"name": "Document Object Model",
98-
"downloadUrl": "https://www.w3.org/DOM/"
100+
"downloadUrl": "https://www.w3.org/DOM/",
101+
"version": "4.0.0"
99102
}
100103
},
101104
"licenseDetail": [
@@ -116,7 +119,8 @@
116119
"The name and trademarks of copyright holders may NOT be used in advertising or publicity pertaining to the work without specific, written prior permission. ",
117120
"Title to copyright in this work will at all times remain with copyright holders."
118121
],
119-
"license": "W3C License"
122+
"license": "W3C License",
123+
"version": "4.0.0"
120124
},
121125
{
122126
"component": {

extensions/typescript-language-features/src/features/baseCodeLensProvider.ts

Lines changed: 15 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -4,11 +4,14 @@
44
*--------------------------------------------------------------------------------------------*/
55

66
import * as vscode from 'vscode';
7+
import * as nls from 'vscode-nls';
78
import * as Proto from '../protocol';
89
import { ITypeScriptServiceClient, ServerResponse } from '../typescriptService';
910
import { escapeRegExp } from '../utils/regexp';
1011
import * as typeConverters from '../utils/typeConverters';
1112

13+
const localize = nls.loadMessageBundle();
14+
1215
export class ReferencesCodeLens extends vscode.CodeLens {
1316
constructor(
1417
public document: vscode.Uri,
@@ -51,6 +54,18 @@ export class CachedResponse<T extends Proto.Response> {
5154
}
5255

5356
export abstract class TypeScriptBaseCodeLensProvider implements vscode.CodeLensProvider {
57+
58+
public static readonly cancelledCommand: vscode.Command = {
59+
// Cancellation is not an error. Just show nothing until we can properly re-compute the code lens
60+
title: '',
61+
command: ''
62+
};
63+
64+
public static readonly errorCommand: vscode.Command = {
65+
title: localize('referenceErrorLabel', 'Could not determine references'),
66+
command: ''
67+
};
68+
5469
private onDidChangeCodeLensesEmitter = new vscode.EventEmitter<void>();
5570

5671
public constructor(

extensions/typescript-language-features/src/features/completions.ts

Lines changed: 3 additions & 59 deletions
Original file line numberDiff line numberDiff line change
@@ -18,6 +18,7 @@ import * as Previewer from '../utils/previewer';
1818
import * as typeConverters from '../utils/typeConverters';
1919
import TypingsStatus from '../utils/typingsStatus';
2020
import FileConfigurationManager from './fileConfigurationManager';
21+
import { snippetForFunctionCall } from '../utils/snippetForFunctionCall';
2122

2223
const localize = nls.loadMessageBundle();
2324

@@ -426,7 +427,7 @@ class TypeScriptCompletionItemProvider implements vscode.CompletionItemProvider
426427
]
427428
};
428429

429-
const response = await this.client.execute('completionEntryDetails', args, token);
430+
const response = await this.client.interuptGetErr(() => this.client.execute('completionEntryDetails', args, token));
430431
if (response.type !== 'response' || !response.body) {
431432
return item;
432433
}
@@ -452,7 +453,7 @@ class TypeScriptCompletionItemProvider implements vscode.CompletionItemProvider
452453
if (detail && item.useCodeSnippet) {
453454
const shouldCompleteFunction = await this.isValidFunctionCompletionContext(filepath, item.position, token);
454455
if (shouldCompleteFunction) {
455-
item.insertText = this.snippetForFunctionCall(item, detail);
456+
item.insertText = snippetForFunctionCall(item, detail.displayParts);
456457
commands.push({ title: 'triggerParameterHints', command: 'editor.action.triggerParameterHints' });
457458
}
458459
}
@@ -622,63 +623,6 @@ class TypeScriptCompletionItemProvider implements vscode.CompletionItemProvider
622623
return true;
623624
}
624625
}
625-
626-
private snippetForFunctionCall(
627-
item: vscode.CompletionItem,
628-
detail: Proto.CompletionEntryDetails
629-
): vscode.SnippetString {
630-
let hasOptionalParameters = false;
631-
let hasAddedParameters = false;
632-
633-
const snippet = new vscode.SnippetString();
634-
const methodName = detail.displayParts.find(part => part.kind === 'methodName');
635-
if (item.insertText) {
636-
if (typeof item.insertText === 'string') {
637-
snippet.appendText(item.insertText);
638-
} else {
639-
return item.insertText;
640-
}
641-
} else {
642-
snippet.appendText((methodName && methodName.text) || item.label);
643-
}
644-
snippet.appendText('(');
645-
646-
let parenCount = 0;
647-
let i = 0;
648-
for (; i < detail.displayParts.length; ++i) {
649-
const part = detail.displayParts[i];
650-
// Only take top level paren names
651-
if (part.kind === 'parameterName' && parenCount === 1) {
652-
const next = detail.displayParts[i + 1];
653-
// Skip optional parameters
654-
const nameIsFollowedByOptionalIndicator = next && next.text === '?';
655-
if (!nameIsFollowedByOptionalIndicator) {
656-
if (hasAddedParameters) {
657-
snippet.appendText(', ');
658-
}
659-
hasAddedParameters = true;
660-
snippet.appendPlaceholder(part.text);
661-
}
662-
hasOptionalParameters = hasOptionalParameters || nameIsFollowedByOptionalIndicator;
663-
} else if (part.kind === 'punctuation') {
664-
if (part.text === '(') {
665-
++parenCount;
666-
} else if (part.text === ')') {
667-
--parenCount;
668-
} else if (part.text === '...' && parenCount === 1) {
669-
// Found rest parmeter. Do not fill in any further arguments
670-
hasOptionalParameters = true;
671-
break;
672-
}
673-
}
674-
}
675-
if (hasOptionalParameters) {
676-
snippet.appendTabstop();
677-
}
678-
snippet.appendText(')');
679-
snippet.appendTabstop(0);
680-
return snippet;
681-
}
682626
}
683627

684628
function shouldExcludeCompletionEntry(

extensions/typescript-language-features/src/features/implementationsCodeLens.ts

Lines changed: 28 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -10,30 +10,44 @@ import * as PConst from '../protocol.const';
1010
import { ITypeScriptServiceClient } from '../typescriptService';
1111
import API from '../utils/api';
1212
import { ConfigurationDependentRegistration, VersionDependentRegistration } from '../utils/dependentRegistration';
13-
import { CachedResponse, ReferencesCodeLens, TypeScriptBaseCodeLensProvider, getSymbolRange } from './baseCodeLensProvider';
13+
import { TypeScriptBaseCodeLensProvider, ReferencesCodeLens, getSymbolRange, CachedResponse } from './baseCodeLensProvider';
14+
import * as typeConverters from '../utils/typeConverters';
15+
1416
const localize = nls.loadMessageBundle();
1517

1618
export default class TypeScriptImplementationsCodeLensProvider extends TypeScriptBaseCodeLensProvider {
1719

1820
public async resolveCodeLens(
1921
inputCodeLens: vscode.CodeLens,
20-
_token: vscode.CancellationToken,
22+
token: vscode.CancellationToken,
2123
): Promise<vscode.CodeLens> {
2224
const codeLens = inputCodeLens as ReferencesCodeLens;
23-
try {
24-
const locations: vscode.Location[] | undefined = await vscode.commands.executeCommand<vscode.Location[]>('vscode.executeImplementationProvider', codeLens.document, codeLens.range.start);
25-
if (locations) {
26-
codeLens.command = this.getCommand(locations, codeLens);
27-
return codeLens;
28-
}
29-
} catch {
30-
// noop
25+
26+
const args = typeConverters.Position.toFileLocationRequestArgs(codeLens.file, codeLens.range.start);
27+
const response = await this.client.execute('implementation', args, token, /* lowPriority */ true);
28+
if (response.type !== 'response' || !response.body) {
29+
codeLens.command = response.type === 'cancelled'
30+
? TypeScriptBaseCodeLensProvider.cancelledCommand
31+
: TypeScriptBaseCodeLensProvider.errorCommand;
32+
return codeLens;
3133
}
3234

33-
codeLens.command = {
34-
title: localize('implementationsErrorLabel', 'Could not determine implementations'),
35-
command: ''
36-
};
35+
const locations = response.body
36+
.map(reference =>
37+
// Only take first line on implementation: https://github.com/Microsoft/vscode/issues/23924
38+
new vscode.Location(this.client.toResource(reference.file),
39+
reference.start.line === reference.end.line
40+
? typeConverters.Range.fromTextSpan(reference)
41+
: new vscode.Range(
42+
typeConverters.Position.fromLocation(reference.start),
43+
new vscode.Position(reference.start.line, 0))))
44+
// Exclude original from implementations
45+
.filter(location =>
46+
!(location.uri.toString() === codeLens.document.toString() &&
47+
location.range.start.line === codeLens.range.start.line &&
48+
location.range.start.character === codeLens.range.start.character));
49+
50+
codeLens.command = this.getCommand(locations, codeLens);
3751
return codeLens;
3852
}
3953

extensions/typescript-language-features/src/features/referencesCodeLens.ts

Lines changed: 23 additions & 22 deletions
Original file line numberDiff line numberDiff line change
@@ -10,39 +10,40 @@ import * as PConst from '../protocol.const';
1010
import { ITypeScriptServiceClient } from '../typescriptService';
1111
import API from '../utils/api';
1212
import { ConfigurationDependentRegistration, VersionDependentRegistration } from '../utils/dependentRegistration';
13-
import { CachedResponse, ReferencesCodeLens, TypeScriptBaseCodeLensProvider, getSymbolRange } from './baseCodeLensProvider';
13+
import * as typeConverters from '../utils/typeConverters';
14+
import { ReferencesCodeLens, TypeScriptBaseCodeLensProvider, getSymbolRange, CachedResponse } from './baseCodeLensProvider';
1415

1516
const localize = nls.loadMessageBundle();
1617

1718
class TypeScriptReferencesCodeLensProvider extends TypeScriptBaseCodeLensProvider {
1819

19-
public resolveCodeLens(inputCodeLens: vscode.CodeLens, _token: vscode.CancellationToken): Thenable<vscode.CodeLens> {
20+
public async resolveCodeLens(inputCodeLens: vscode.CodeLens, token: vscode.CancellationToken): Promise<vscode.CodeLens> {
2021
const codeLens = inputCodeLens as ReferencesCodeLens;
21-
return vscode.commands.executeCommand<vscode.Location[]>('vscode.executeReferenceProvider', codeLens.document, codeLens.range.start).then((locations: vscode.Location[] | undefined) => {
22-
if (!locations) {
23-
throw codeLens;
24-
}
22+
const args = typeConverters.Position.toFileLocationRequestArgs(codeLens.file, codeLens.range.start);
23+
const response = await this.client.execute('references', args, token, /* lowPriority */ true);
24+
if (response.type !== 'response' || !response.body) {
25+
codeLens.command = response.type === 'cancelled'
26+
? TypeScriptBaseCodeLensProvider.cancelledCommand
27+
: TypeScriptBaseCodeLensProvider.errorCommand;
28+
return codeLens;
29+
}
2530

26-
const referenceLocations = locations.filter(location =>
31+
const locations = response.body.refs
32+
.map(reference =>
33+
typeConverters.Location.fromTextSpan(this.client.toResource(reference.file), reference))
34+
.filter(location =>
2735
// Exclude original definition from references
2836
!(location.uri.toString() === codeLens.document.toString() &&
2937
location.range.start.isEqual(codeLens.range.start)));
3038

31-
codeLens.command = {
32-
title: referenceLocations.length === 1
33-
? localize('oneReferenceLabel', '1 reference')
34-
: localize('manyReferenceLabel', '{0} references', referenceLocations.length),
35-
command: referenceLocations.length ? 'editor.action.showReferences' : '',
36-
arguments: [codeLens.document, codeLens.range.start, referenceLocations]
37-
};
38-
return codeLens;
39-
}).then(undefined, () => {
40-
codeLens.command = {
41-
title: localize('referenceErrorLabel', 'Could not determine references'),
42-
command: ''
43-
};
44-
return codeLens;
45-
});
39+
codeLens.command = {
40+
title: locations.length === 1
41+
? localize('oneReferenceLabel', '1 reference')
42+
: localize('manyReferenceLabel', '{0} references', locations.length),
43+
command: locations.length ? 'editor.action.showReferences' : '',
44+
arguments: [codeLens.document, codeLens.range.start, locations]
45+
};
46+
return codeLens;
4647
}
4748

4849
protected extractSymbol(

extensions/typescript-language-features/src/features/signatureHelp.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -33,7 +33,7 @@ class TypeScriptSignatureHelpProvider implements vscode.SignatureHelpProvider {
3333
...typeConverters.Position.toFileLocationRequestArgs(filepath, position),
3434
triggerReason: toTsTriggerReason(context!)
3535
};
36-
const response = await this.client.execute('signatureHelp', args, token);
36+
const response = await this.client.interuptGetErr(() => this.client.execute('signatureHelp', args, token));
3737
if (response.type !== 'response' || !response.body) {
3838
return undefined;
3939
}

extensions/typescript-language-features/src/protocol.const.ts

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -60,4 +60,12 @@ export class KindModifiers {
6060
KindModifiers.jsxFile,
6161
KindModifiers.jsonFile,
6262
];
63+
}
64+
65+
export class DisplayPartKind {
66+
public static readonly functionName = 'functionName';
67+
public static readonly methodName = 'methodName';
68+
public static readonly parameterName = 'parameterName';
69+
public static readonly punctuation = 'punctuation';
70+
public static readonly text = 'text';
6371
}

0 commit comments

Comments
 (0)