align names of CompletionItem and ISuggestion
This commit is contained in:
parent
cafe4a992b
commit
d0b77851a5
|
@ -386,10 +386,10 @@ class SuggestAdapter {
|
|||
return {
|
||||
_actual: item,
|
||||
label: item.label,
|
||||
codeSnippet: item.insertText || item.label,
|
||||
insertText: item.insertText || item.label,
|
||||
type: convertKind(item.kind),
|
||||
typeLabel: item.detail,
|
||||
documentationLabel: item.documentation,
|
||||
detail: item.detail,
|
||||
documentation: item.documentation,
|
||||
sortText: item.sortText,
|
||||
filterText: item.filterText
|
||||
};
|
||||
|
@ -444,7 +444,7 @@ class SuggestAdapter {
|
|||
|
||||
// insert the text of the edit and create a dedicated
|
||||
// suggestion-container with overwrite[Before|After]
|
||||
suggestion.codeSnippet = item.textEdit.text;
|
||||
suggestion.insertText = item.textEdit.text;
|
||||
suggestion.overwriteBefore = position.column - editRange.startColumn;
|
||||
suggestion.overwriteAfter = editRange.endColumn - position.column;
|
||||
} else {
|
||||
|
|
|
@ -358,10 +358,10 @@ export type SuggestionType = 'method'
|
|||
*/
|
||||
export interface ISuggestion {
|
||||
label: string;
|
||||
codeSnippet: string;
|
||||
insertText: string;
|
||||
type: SuggestionType;
|
||||
typeLabel?: string;
|
||||
documentationLabel?: string;
|
||||
detail?: string;
|
||||
documentation?: string;
|
||||
filterText?: string;
|
||||
sortText?: string;
|
||||
noAutoAccept?: boolean;
|
||||
|
|
|
@ -92,8 +92,8 @@ class SnippetsRegistry {
|
|||
result.push({
|
||||
type: 'snippet',
|
||||
label: s.prefix,
|
||||
documentationLabel: s.description,
|
||||
codeSnippet: s.codeSnippet,
|
||||
documentation: s.description,
|
||||
insertText: s.codeSnippet,
|
||||
noAutoAccept: true,
|
||||
overwriteBefore
|
||||
});
|
||||
|
|
|
@ -264,7 +264,7 @@ export abstract class BaseEditorSimpleWorker {
|
|||
return <ISuggestion> {
|
||||
type: 'text',
|
||||
label: word,
|
||||
codeSnippet: word,
|
||||
insertText: word,
|
||||
noAutoAccept: true
|
||||
};
|
||||
});
|
||||
|
|
|
@ -99,7 +99,7 @@ class Renderer implements IRenderer<CompletionItem, ISuggestionTemplateData> {
|
|||
const data = <ISuggestionTemplateData>templateData;
|
||||
const suggestion = (<CompletionItem>element).suggestion;
|
||||
|
||||
if (suggestion.documentationLabel) {
|
||||
if (suggestion.documentation) {
|
||||
data.root.setAttribute('aria-label', nls.localize('suggestionWithDetailsAriaLabel', "{0}, suggestion, has details", suggestion.label));
|
||||
} else {
|
||||
data.root.setAttribute('aria-label', nls.localize('suggestionAriaLabel', "{0}, suggestion", suggestion.label));
|
||||
|
@ -109,7 +109,7 @@ class Renderer implements IRenderer<CompletionItem, ISuggestionTemplateData> {
|
|||
data.colorspan.style.backgroundColor = '';
|
||||
|
||||
if (suggestion.type === 'color') {
|
||||
let color = matchesColor(suggestion.label) || matchesColor(suggestion.documentationLabel);
|
||||
let color = matchesColor(suggestion.label) || matchesColor(suggestion.documentation);
|
||||
if (color) {
|
||||
data.icon.className = 'icon customcolor';
|
||||
data.colorspan.style.backgroundColor = color;
|
||||
|
@ -117,10 +117,10 @@ class Renderer implements IRenderer<CompletionItem, ISuggestionTemplateData> {
|
|||
}
|
||||
|
||||
data.highlightedLabel.set(suggestion.label, (<CompletionItem>element).highlights);
|
||||
data.typeLabel.textContent = suggestion.typeLabel || '';
|
||||
data.documentation.textContent = suggestion.documentationLabel || '';
|
||||
data.typeLabel.textContent = suggestion.detail || '';
|
||||
data.documentation.textContent = suggestion.documentation || '';
|
||||
|
||||
if (suggestion.documentationLabel) {
|
||||
if (suggestion.documentation) {
|
||||
show(data.documentationDetails);
|
||||
data.documentationDetails.onmousedown = e => {
|
||||
e.stopPropagation();
|
||||
|
@ -154,7 +154,7 @@ class Delegate implements IDelegate<CompletionItem> {
|
|||
getHeight(element: CompletionItem): number {
|
||||
const focus = this.listProvider().getFocusedElements()[0];
|
||||
|
||||
if (element.suggestion.documentationLabel && element === focus) {
|
||||
if (element.suggestion.documentation && element === focus) {
|
||||
return FocusHeight;
|
||||
}
|
||||
|
||||
|
@ -251,8 +251,8 @@ class SuggestionDetails {
|
|||
}
|
||||
|
||||
this.title.innerText = item.suggestion.label;
|
||||
this.type.innerText = item.suggestion.typeLabel || '';
|
||||
this.docs.innerText = item.suggestion.documentationLabel;
|
||||
this.type.innerText = item.suggestion.detail || '';
|
||||
this.docs.innerText = item.suggestion.documentation;
|
||||
this.back.onmousedown = e => {
|
||||
e.preventDefault();
|
||||
e.stopPropagation();
|
||||
|
@ -265,7 +265,7 @@ class SuggestionDetails {
|
|||
|
||||
this.scrollbar.scanDomNode();
|
||||
|
||||
this.ariaLabel = strings.format('{0}\n{1}\n{2}', item.suggestion.label || '', item.suggestion.typeLabel || '', item.suggestion.documentationLabel || '');
|
||||
this.ariaLabel = strings.format('{0}\n{1}\n{2}', item.suggestion.label || '', item.suggestion.detail || '', item.suggestion.documentation || '');
|
||||
}
|
||||
|
||||
getAriaLabel(): string {
|
||||
|
@ -421,7 +421,7 @@ export class SuggestWidget implements IContentWidget, IDisposable {
|
|||
}
|
||||
|
||||
private _getSuggestionAriaAlertLabel(item:CompletionItem): string {
|
||||
if (item.suggestion.documentationLabel) {
|
||||
if (item.suggestion.documentation) {
|
||||
return nls.localize('ariaCurrentSuggestionWithDetails',"{0}, suggestion, has details", item.suggestion.label);
|
||||
} else {
|
||||
return nls.localize('ariaCurrentSuggestion',"{0}, suggestion", item.suggestion.label);
|
||||
|
@ -721,7 +721,7 @@ export class SuggestWidget implements IContentWidget, IDisposable {
|
|||
|
||||
const item = this.list.getFocusedElements()[0];
|
||||
|
||||
if (!item || !item.suggestion.documentationLabel) {
|
||||
if (!item || !item.suggestion.documentation) {
|
||||
return;
|
||||
}
|
||||
|
||||
|
|
|
@ -380,7 +380,7 @@ export class SuggestModel implements IDisposable {
|
|||
}
|
||||
|
||||
this._onDidAccept.fire({
|
||||
snippet: new CodeSnippet(suggestion.codeSnippet),
|
||||
snippet: new CodeSnippet(suggestion.insertText),
|
||||
overwriteBefore: overwriteBefore + (this.editor.getPosition().column - this.context.column),
|
||||
overwriteAfter
|
||||
});
|
||||
|
|
|
@ -30,15 +30,15 @@ suite('Suggest', function () {
|
|||
suggestions: [{
|
||||
label: 'aaa',
|
||||
type: 'snippet',
|
||||
codeSnippet: 'aaa'
|
||||
insertText: 'aaa'
|
||||
}, {
|
||||
label: 'zzz',
|
||||
type: 'snippet',
|
||||
codeSnippet: 'zzz'
|
||||
insertText: 'zzz'
|
||||
}, {
|
||||
label: 'fff',
|
||||
type: 'property',
|
||||
codeSnippet: 'fff'
|
||||
insertText: 'fff'
|
||||
}]
|
||||
};
|
||||
}
|
||||
|
|
|
@ -146,7 +146,7 @@ export class HTMLWorker {
|
|||
if (matchingTag) {
|
||||
let suggestion : modes.ISuggestion = {
|
||||
label: '/' + matchingTag,
|
||||
codeSnippet: '/' + matchingTag + closeTag,
|
||||
insertText: '/' + matchingTag + closeTag,
|
||||
overwriteBefore: overwriteBefore,
|
||||
type: 'property'
|
||||
};
|
||||
|
@ -159,7 +159,7 @@ export class HTMLWorker {
|
|||
let endIndent = model.getLineContent(endPosition.lineNumber).substring(0, endPosition.column - 1);
|
||||
if (isWhiteSpace(startIndent) && isWhiteSpace(endIndent)) {
|
||||
suggestion.overwriteBefore = position.column - 1; // replace from start of line
|
||||
suggestion.codeSnippet = startIndent + '</' + matchingTag + closeTag;
|
||||
suggestion.insertText = startIndent + '</' + matchingTag + closeTag;
|
||||
suggestion.filterText = endIndent + '</' + matchingTag + closeTag;
|
||||
}
|
||||
}
|
||||
|
@ -177,9 +177,9 @@ export class HTMLWorker {
|
|||
suggestions.suggestions.push({
|
||||
label: '/' + tag,
|
||||
overwriteBefore: suggestions.currentWord.length + 1,
|
||||
codeSnippet: '/' + tag + closeTag,
|
||||
insertText: '/' + tag + closeTag,
|
||||
type: 'property',
|
||||
documentationLabel: label,
|
||||
documentation: label,
|
||||
filterText: '</' + tag + closeTag
|
||||
});
|
||||
});
|
||||
|
@ -192,9 +192,9 @@ export class HTMLWorker {
|
|||
provider.collectTags((tag, label) => {
|
||||
suggestions.suggestions.push({
|
||||
label: tag,
|
||||
codeSnippet: tag,
|
||||
insertText: tag,
|
||||
type: 'property',
|
||||
documentationLabel: label,
|
||||
documentation: label,
|
||||
overwriteBefore: suggestions.currentWord.length
|
||||
});
|
||||
});
|
||||
|
@ -227,7 +227,7 @@ export class HTMLWorker {
|
|||
}
|
||||
suggestions.suggestions.push({
|
||||
label: attribute,
|
||||
codeSnippet: codeSnippet,
|
||||
insertText: codeSnippet,
|
||||
type: type === 'handler' ? 'function' : 'value',
|
||||
overwriteBefore: suggestions.currentWord.length
|
||||
});
|
||||
|
@ -260,7 +260,7 @@ export class HTMLWorker {
|
|||
provider.collectValues(parentTag, attribute,(value) => {
|
||||
suggestions.suggestions.push({
|
||||
label: value,
|
||||
codeSnippet: needsQuotes ? '"' + value + '"' : value,
|
||||
insertText: needsQuotes ? '"' + value + '"' : value,
|
||||
type: 'unit',
|
||||
overwriteBefore: suggestions.currentWord.length
|
||||
});
|
||||
|
|
|
@ -54,7 +54,7 @@ suite('HTML - worker', () => {
|
|||
|
||||
var assertSuggestion = function(completion: Modes.ISuggestResult, label: string, type?: string, codeSnippet?: string) {
|
||||
var proposalsFound = completion.suggestions.filter(function(suggestion: Modes.ISuggestion) {
|
||||
return suggestion.label === label && (!type || suggestion.type === type) && (!codeSnippet || suggestion.codeSnippet === codeSnippet);
|
||||
return suggestion.label === label && (!type || suggestion.type === type) && (!codeSnippet || suggestion.insertText === codeSnippet);
|
||||
});
|
||||
if (proposalsFound.length !== 1) {
|
||||
assert.fail('Suggestion not found: ' + label + ', has ' + completion.suggestions.map(s => s.label).join(', '));
|
||||
|
|
|
@ -554,7 +554,7 @@ class SuggestAdapter {
|
|||
|
||||
// insert the text of the edit and create a dedicated
|
||||
// suggestion-container with overwrite[Before|After]
|
||||
suggestion.codeSnippet = item.textEdit.newText;
|
||||
suggestion.insertText = item.textEdit.newText;
|
||||
suggestion.overwriteBefore = pos.character - editRange.start.character;
|
||||
suggestion.overwriteAfter = editRange.end.character - pos.character;
|
||||
|
||||
|
|
|
@ -314,10 +314,10 @@ export const Suggest = {
|
|||
from(item: vscode.CompletionItem): modes.ISuggestion {
|
||||
const suggestion: modes.ISuggestion = {
|
||||
label: item.label,
|
||||
codeSnippet: item.insertText || item.label,
|
||||
insertText: item.insertText || item.label,
|
||||
type: CompletionItemKind.from(item.kind),
|
||||
typeLabel: item.detail,
|
||||
documentationLabel: item.documentation,
|
||||
detail: item.detail,
|
||||
documentation: item.documentation,
|
||||
sortText: item.sortText,
|
||||
filterText: item.filterText
|
||||
};
|
||||
|
@ -326,10 +326,10 @@ export const Suggest = {
|
|||
|
||||
to(container: modes.ISuggestResult, position: types.Position, suggestion: modes.ISuggestion): types.CompletionItem {
|
||||
const result = new types.CompletionItem(suggestion.label);
|
||||
result.insertText = suggestion.codeSnippet;
|
||||
result.insertText = suggestion.insertText;
|
||||
result.kind = CompletionItemKind.to(suggestion.type);
|
||||
result.detail = suggestion.typeLabel;
|
||||
result.documentation = suggestion.documentationLabel;
|
||||
result.detail = suggestion.detail;
|
||||
result.documentation = suggestion.documentation;
|
||||
result.sortText = suggestion.sortText;
|
||||
result.filterText = suggestion.filterText;
|
||||
|
||||
|
@ -340,7 +340,7 @@ export const Suggest = {
|
|||
endPosition = new types.Position(position.line, position.character + suggestion.overwriteAfter);
|
||||
}
|
||||
|
||||
result.textEdit = types.TextEdit.replace(new types.Range(startPosition, endPosition), suggestion.codeSnippet);
|
||||
result.textEdit = types.TextEdit.replace(new types.Range(startPosition, endPosition), suggestion.insertText);
|
||||
return result;
|
||||
}
|
||||
};
|
||||
|
|
|
@ -767,7 +767,7 @@ suite('ExtHostLanguageFeatures', function() {
|
|||
return threadService.sync().then(() => {
|
||||
return provideSuggestionItems(model, new EditorPosition(1, 1), { snippetConfig: 'none' }).then(value => {
|
||||
assert.equal(value.length, 1);
|
||||
assert.equal(value[0].suggestion.codeSnippet, 'testing2');
|
||||
assert.equal(value[0].suggestion.insertText, 'testing2');
|
||||
});
|
||||
});
|
||||
});
|
||||
|
@ -789,7 +789,7 @@ suite('ExtHostLanguageFeatures', function() {
|
|||
return threadService.sync().then(() => {
|
||||
return provideSuggestionItems(model, new EditorPosition(1, 1), { snippetConfig: 'none' }).then(value => {
|
||||
assert.equal(value.length, 1);
|
||||
assert.equal(value[0].suggestion.codeSnippet, 'weak-selector');
|
||||
assert.equal(value[0].suggestion.insertText, 'weak-selector');
|
||||
});
|
||||
});
|
||||
});
|
||||
|
@ -811,8 +811,8 @@ suite('ExtHostLanguageFeatures', function() {
|
|||
return threadService.sync().then(() => {
|
||||
return provideSuggestionItems(model, new EditorPosition(1, 1), { snippetConfig: 'none' }).then(value => {
|
||||
assert.equal(value.length, 2);
|
||||
assert.equal(value[0].suggestion.codeSnippet, 'strong-1'); // sort by label
|
||||
assert.equal(value[1].suggestion.codeSnippet, 'strong-2');
|
||||
assert.equal(value[0].suggestion.insertText, 'strong-1'); // sort by label
|
||||
assert.equal(value[1].suggestion.insertText, 'strong-2');
|
||||
});
|
||||
});
|
||||
});
|
||||
|
|
Loading…
Reference in a new issue