mirror of
https://github.com/Microsoft/vscode
synced 2024-07-07 19:50:26 +00:00
adopt API changes in tests and extensions
This commit is contained in:
parent
24f9000e97
commit
14704a7e92
|
@ -49,9 +49,9 @@ export function startClient(context: ExtensionContext, newLanguageClient: Langua
|
|||
}
|
||||
function updateLabel(item: CompletionItem) {
|
||||
if (item.kind === CompletionItemKind.Color) {
|
||||
item.label2 = {
|
||||
name: item.label,
|
||||
type: (item.documentation as string)
|
||||
item.label = {
|
||||
label: item.label as string,
|
||||
description: (item.documentation as string)
|
||||
};
|
||||
}
|
||||
}
|
||||
|
|
|
@ -143,7 +143,13 @@ export class BowerJSONContribution implements IJSONContribution {
|
|||
|
||||
public resolveSuggestion(_resource: Uri | undefined, item: CompletionItem): Thenable<CompletionItem | null> | null {
|
||||
if (item.kind === CompletionItemKind.Property && item.documentation === '') {
|
||||
return this.getInfo(item.label).then(documentation => {
|
||||
|
||||
let label = item.label;
|
||||
if (typeof label !== 'string') {
|
||||
label = label.label;
|
||||
}
|
||||
|
||||
return this.getInfo(label).then(documentation => {
|
||||
if (documentation) {
|
||||
item.documentation = documentation;
|
||||
return item;
|
||||
|
|
|
@ -109,8 +109,11 @@ export class JSONCompletionItemProvider implements CompletionItemProvider {
|
|||
const proposed: { [key: string]: boolean } = {};
|
||||
const collector: ISuggestionsCollector = {
|
||||
add: (suggestion: CompletionItem) => {
|
||||
if (!proposed[suggestion.label]) {
|
||||
proposed[suggestion.label] = true;
|
||||
const key = typeof suggestion.label === 'string'
|
||||
? suggestion.label
|
||||
: suggestion.label.label;
|
||||
if (!proposed[key]) {
|
||||
proposed[key] = true;
|
||||
suggestion.range = { replacing: overwriteRange, inserting: new Range(overwriteRange.start, overwriteRange.start) };
|
||||
items.push(suggestion);
|
||||
}
|
||||
|
|
|
@ -235,7 +235,13 @@ export class PackageJSONContribution implements IJSONContribution {
|
|||
|
||||
public resolveSuggestion(resource: Uri | undefined, item: CompletionItem): Thenable<CompletionItem | null> | null {
|
||||
if (item.kind === CompletionItemKind.Property && !item.documentation) {
|
||||
return this.fetchPackageInfo(item.label, resource).then(info => {
|
||||
|
||||
let name = item.label;
|
||||
if (typeof name !== 'string') {
|
||||
name = name.label;
|
||||
}
|
||||
|
||||
return this.fetchPackageInfo(name, resource).then(info => {
|
||||
if (info) {
|
||||
item.documentation = this.getDocumentation(info.description, info.version, info.homepage);
|
||||
return item;
|
||||
|
|
|
@ -72,7 +72,7 @@ class MyCompletionItem extends vscode.CompletionItem {
|
|||
// Render "fancy" when source is a workspace path
|
||||
const qualifierCandidate = vscode.workspace.asRelativePath(tsEntry.source);
|
||||
if (qualifierCandidate !== tsEntry.source) {
|
||||
this.label2 = { name: tsEntry.name, qualifier: qualifierCandidate };
|
||||
this.label = { label: tsEntry.name, description: qualifierCandidate };
|
||||
}
|
||||
|
||||
} else {
|
||||
|
@ -81,7 +81,7 @@ class MyCompletionItem extends vscode.CompletionItem {
|
|||
|
||||
const { sourceDisplay, isSnippet } = tsEntry;
|
||||
if (sourceDisplay) {
|
||||
this.label2 = { name: tsEntry.name, qualifier: Previewer.plainWithLinks(sourceDisplay, client) };
|
||||
this.label = { label: tsEntry.name, description: Previewer.plainWithLinks(sourceDisplay, client) };
|
||||
}
|
||||
|
||||
this.preselect = tsEntry.isRecommended;
|
||||
|
@ -113,11 +113,11 @@ class MyCompletionItem extends vscode.CompletionItem {
|
|||
const kindModifiers = parseKindModifier(tsEntry.kindModifiers);
|
||||
if (kindModifiers.has(PConst.KindModifiers.optional)) {
|
||||
if (!this.insertText) {
|
||||
this.insertText = this.label;
|
||||
this.insertText = this.textLabel;
|
||||
}
|
||||
|
||||
if (!this.filterText) {
|
||||
this.filterText = this.label;
|
||||
this.filterText = this.textLabel;
|
||||
}
|
||||
this.label += '?';
|
||||
}
|
||||
|
@ -146,6 +146,10 @@ class MyCompletionItem extends vscode.CompletionItem {
|
|||
this.resolveRange();
|
||||
}
|
||||
|
||||
private get textLabel() {
|
||||
return typeof this.label === 'string' ? this.label : this.label.label;
|
||||
}
|
||||
|
||||
private _resolvedPromise?: {
|
||||
readonly requestToken: vscode.CancellationTokenSource;
|
||||
readonly promise: Promise<ResolvedCompletionItem | undefined>;
|
||||
|
@ -216,7 +220,7 @@ class MyCompletionItem extends vscode.CompletionItem {
|
|||
if (this.useCodeSnippet) {
|
||||
const shouldCompleteFunction = await this.isValidFunctionCompletionContext(client, filepath, this.position, this.document, token);
|
||||
if (shouldCompleteFunction) {
|
||||
const { snippet, parameterCount } = snippetForFunctionCall(this, detail.displayParts);
|
||||
const { snippet, parameterCount } = snippetForFunctionCall({ ...this, label: this.textLabel }, detail.displayParts);
|
||||
this.insertText = snippet;
|
||||
if (parameterCount > 0) {
|
||||
//Fix for https://github.com/microsoft/vscode/issues/104059
|
||||
|
@ -408,8 +412,8 @@ class MyCompletionItem extends vscode.CompletionItem {
|
|||
private getFuzzyWordRange() {
|
||||
if (this.completionContext.useFuzzyWordRangeLogic) {
|
||||
// Try getting longer, prefix based range for completions that span words
|
||||
const text = this.completionContext.line.slice(Math.max(0, this.position.character - this.label.length), this.position.character).toLowerCase();
|
||||
const entryName = this.label.toLowerCase();
|
||||
const text = this.completionContext.line.slice(Math.max(0, this.position.character - this.textLabel.length), this.position.character).toLowerCase();
|
||||
const entryName = this.textLabel.toLowerCase();
|
||||
for (let i = entryName.length; i >= 0; --i) {
|
||||
if (text.endsWith(entryName.substr(0, i)) && (!this.completionContext.wordRange || this.completionContext.wordRange.start.character > this.position.character - i)) {
|
||||
return new vscode.Range(
|
||||
|
|
|
@ -94,8 +94,8 @@ suite('SnippetsService', function () {
|
|||
assert.strictEqual(result.incomplete, undefined);
|
||||
assert.strictEqual(result.suggestions.length, 1);
|
||||
assert.deepStrictEqual(result.suggestions[0].label, {
|
||||
name: 'bar',
|
||||
type: 'barTest'
|
||||
label: 'bar',
|
||||
description: 'barTest'
|
||||
});
|
||||
assert.strictEqual((result.suggestions[0].range as any).insert.startColumn, 1);
|
||||
assert.strictEqual(result.suggestions[0].insertText, 'barCodeSnippet');
|
||||
|
@ -129,14 +129,14 @@ suite('SnippetsService', function () {
|
|||
assert.strictEqual(result.incomplete, undefined);
|
||||
assert.strictEqual(result.suggestions.length, 2);
|
||||
assert.deepStrictEqual(result.suggestions[0].label, {
|
||||
name: 'bar',
|
||||
type: 'barTest'
|
||||
label: 'bar',
|
||||
description: 'barTest'
|
||||
});
|
||||
assert.strictEqual(result.suggestions[0].insertText, 's1');
|
||||
assert.strictEqual((result.suggestions[0].range as any).insert.startColumn, 1);
|
||||
assert.deepStrictEqual(result.suggestions[1].label, {
|
||||
name: 'bar-bar',
|
||||
type: 'name'
|
||||
label: 'bar-bar',
|
||||
description: 'name'
|
||||
});
|
||||
assert.strictEqual(result.suggestions[1].insertText, 's2');
|
||||
assert.strictEqual((result.suggestions[1].range as any).insert.startColumn, 1);
|
||||
|
@ -146,8 +146,8 @@ suite('SnippetsService', function () {
|
|||
assert.strictEqual(result.incomplete, undefined);
|
||||
assert.strictEqual(result.suggestions.length, 1);
|
||||
assert.deepStrictEqual(result.suggestions[0].label, {
|
||||
name: 'bar-bar',
|
||||
type: 'name'
|
||||
label: 'bar-bar',
|
||||
description: 'name'
|
||||
});
|
||||
assert.strictEqual(result.suggestions[0].insertText, 's2');
|
||||
assert.strictEqual((result.suggestions[0].range as any).insert.startColumn, 1);
|
||||
|
@ -157,14 +157,14 @@ suite('SnippetsService', function () {
|
|||
assert.strictEqual(result.incomplete, undefined);
|
||||
assert.strictEqual(result.suggestions.length, 2);
|
||||
assert.deepStrictEqual(result.suggestions[0].label, {
|
||||
name: 'bar',
|
||||
type: 'barTest'
|
||||
label: 'bar',
|
||||
description: 'barTest'
|
||||
});
|
||||
assert.strictEqual(result.suggestions[0].insertText, 's1');
|
||||
assert.strictEqual((result.suggestions[0].range as any).insert.startColumn, 5);
|
||||
assert.deepStrictEqual(result.suggestions[1].label, {
|
||||
name: 'bar-bar',
|
||||
type: 'name'
|
||||
label: 'bar-bar',
|
||||
description: 'name'
|
||||
});
|
||||
assert.strictEqual(result.suggestions[1].insertText, 's2');
|
||||
assert.strictEqual((result.suggestions[1].range as any).insert.startColumn, 1);
|
||||
|
@ -254,12 +254,12 @@ suite('SnippetsService', function () {
|
|||
assert.strictEqual(result.suggestions.length, 2);
|
||||
let [first, second] = result.suggestions;
|
||||
assert.deepStrictEqual(first.label, {
|
||||
name: 'first',
|
||||
type: 'first'
|
||||
label: 'first',
|
||||
description: 'first'
|
||||
});
|
||||
assert.deepStrictEqual(second.label, {
|
||||
name: 'second',
|
||||
type: 'second'
|
||||
label: 'second',
|
||||
description: 'second'
|
||||
});
|
||||
});
|
||||
});
|
||||
|
@ -344,8 +344,8 @@ suite('SnippetsService', function () {
|
|||
|
||||
assert.strictEqual(result.suggestions.length, 1);
|
||||
assert.deepStrictEqual(result.suggestions[0].label, {
|
||||
name: 'mytemplate',
|
||||
type: 'mytemplate'
|
||||
label: 'mytemplate',
|
||||
description: 'mytemplate'
|
||||
});
|
||||
});
|
||||
|
||||
|
|
Loading…
Reference in New Issue
Block a user