mirror of
https://github.com/Microsoft/vscode
synced 2024-08-27 21:09:43 +00:00
Merge pull request #172914 from microsoft/joh/pure-constrictor
avoid hard cast from object
This commit is contained in:
commit
f1544a4a8b
|
@ -58,28 +58,28 @@ const _completionItemColor = new class ColorExtractor {
|
|||
|
||||
|
||||
export interface ISuggestionTemplateData {
|
||||
root: HTMLElement;
|
||||
readonly root: HTMLElement;
|
||||
|
||||
/**
|
||||
* Flexbox
|
||||
* < ------------- left ------------ > < --- right -- >
|
||||
* <icon><label><signature><qualifier> <type><readmore>
|
||||
*/
|
||||
left: HTMLElement;
|
||||
right: HTMLElement;
|
||||
readonly left: HTMLElement;
|
||||
readonly right: HTMLElement;
|
||||
|
||||
icon: HTMLElement;
|
||||
colorspan: HTMLElement;
|
||||
iconLabel: IconLabel;
|
||||
iconContainer: HTMLElement;
|
||||
parametersLabel: HTMLElement;
|
||||
qualifierLabel: HTMLElement;
|
||||
readonly icon: HTMLElement;
|
||||
readonly colorspan: HTMLElement;
|
||||
readonly iconLabel: IconLabel;
|
||||
readonly iconContainer: HTMLElement;
|
||||
readonly parametersLabel: HTMLElement;
|
||||
readonly qualifierLabel: HTMLElement;
|
||||
/**
|
||||
* Showing either `CompletionItem#details` or `CompletionItemLabel#type`
|
||||
*/
|
||||
detailsLabel: HTMLElement;
|
||||
readMore: HTMLElement;
|
||||
disposables: DisposableStore;
|
||||
readonly detailsLabel: HTMLElement;
|
||||
readonly readMore: HTMLElement;
|
||||
readonly disposables: DisposableStore;
|
||||
}
|
||||
|
||||
export class ItemRenderer implements IListRenderer<CompletionItem, ISuggestionTemplateData> {
|
||||
|
@ -101,31 +101,30 @@ export class ItemRenderer implements IListRenderer<CompletionItem, ISuggestionTe
|
|||
}
|
||||
|
||||
renderTemplate(container: HTMLElement): ISuggestionTemplateData {
|
||||
const data = <ISuggestionTemplateData>Object.create(null);
|
||||
data.disposables = new DisposableStore();
|
||||
const disposables = new DisposableStore();
|
||||
|
||||
data.root = container;
|
||||
data.root.classList.add('show-file-icons');
|
||||
const root = container;
|
||||
root.classList.add('show-file-icons');
|
||||
|
||||
data.icon = append(container, $('.icon'));
|
||||
data.colorspan = append(data.icon, $('span.colorspan'));
|
||||
const icon = append(container, $('.icon'));
|
||||
const colorspan = append(icon, $('span.colorspan'));
|
||||
|
||||
const text = append(container, $('.contents'));
|
||||
const main = append(text, $('.main'));
|
||||
|
||||
data.iconContainer = append(main, $('.icon-label.codicon'));
|
||||
data.left = append(main, $('span.left'));
|
||||
data.right = append(main, $('span.right'));
|
||||
const iconContainer = append(main, $('.icon-label.codicon'));
|
||||
const left = append(main, $('span.left'));
|
||||
const right = append(main, $('span.right'));
|
||||
|
||||
data.iconLabel = new IconLabel(data.left, { supportHighlights: true, supportIcons: true });
|
||||
data.disposables.add(data.iconLabel);
|
||||
const iconLabel = new IconLabel(left, { supportHighlights: true, supportIcons: true });
|
||||
disposables.add(iconLabel);
|
||||
|
||||
data.parametersLabel = append(data.left, $('span.signature-label'));
|
||||
data.qualifierLabel = append(data.left, $('span.qualifier-label'));
|
||||
data.detailsLabel = append(data.right, $('span.details-label'));
|
||||
const parametersLabel = append(left, $('span.signature-label'));
|
||||
const qualifierLabel = append(left, $('span.qualifier-label'));
|
||||
const detailsLabel = append(right, $('span.details-label'));
|
||||
|
||||
data.readMore = append(data.right, $('span.readMore' + ThemeIcon.asCSSSelector(suggestMoreInfoIcon)));
|
||||
data.readMore.title = nls.localize('readMore', "Read More");
|
||||
const readMore = append(right, $('span.readMore' + ThemeIcon.asCSSSelector(suggestMoreInfoIcon)));
|
||||
readMore.title = nls.localize('readMore', "Read More");
|
||||
|
||||
const configureFont = () => {
|
||||
const options = this._editor.getOptions();
|
||||
|
@ -140,27 +139,27 @@ export class ItemRenderer implements IListRenderer<CompletionItem, ISuggestionTe
|
|||
const lineHeightPx = `${lineHeight}px`;
|
||||
const letterSpacingPx = `${letterSpacing}px`;
|
||||
|
||||
data.root.style.fontSize = fontSizePx;
|
||||
data.root.style.fontWeight = fontWeight;
|
||||
data.root.style.letterSpacing = letterSpacingPx;
|
||||
root.style.fontSize = fontSizePx;
|
||||
root.style.fontWeight = fontWeight;
|
||||
root.style.letterSpacing = letterSpacingPx;
|
||||
main.style.fontFamily = fontFamily;
|
||||
main.style.fontFeatureSettings = fontFeatureSettings;
|
||||
main.style.lineHeight = lineHeightPx;
|
||||
data.icon.style.height = lineHeightPx;
|
||||
data.icon.style.width = lineHeightPx;
|
||||
data.readMore.style.height = lineHeightPx;
|
||||
data.readMore.style.width = lineHeightPx;
|
||||
icon.style.height = lineHeightPx;
|
||||
icon.style.width = lineHeightPx;
|
||||
readMore.style.height = lineHeightPx;
|
||||
readMore.style.width = lineHeightPx;
|
||||
};
|
||||
|
||||
configureFont();
|
||||
|
||||
data.disposables.add(this._editor.onDidChangeConfiguration(e => {
|
||||
disposables.add(this._editor.onDidChangeConfiguration(e => {
|
||||
if (e.hasChanged(EditorOption.fontInfo) || e.hasChanged(EditorOption.suggestFontSize) || e.hasChanged(EditorOption.suggestLineHeight)) {
|
||||
configureFont();
|
||||
}
|
||||
}));
|
||||
|
||||
return data;
|
||||
return { root, left, right, icon, colorspan, iconLabel, iconContainer, parametersLabel, qualifierLabel, detailsLabel, readMore, disposables };
|
||||
}
|
||||
|
||||
renderElement(element: CompletionItem, index: number, data: ISuggestionTemplateData): void {
|
||||
|
|
Loading…
Reference in a new issue