|
| 1 | +import * as vscode from 'vscode'; |
| 2 | + |
| 3 | +export const STACK_LAYOUT = vscode.languages.registerHoverProvider('html', { |
| 4 | + provideHover(document, position, token) { |
| 5 | + |
| 6 | + const range = document.getWordRangeAtPosition(position); |
| 7 | + const word = document.getText(range); |
| 8 | + |
| 9 | + if (word.toLowerCase() === 'stacklayout') { |
| 10 | + |
| 11 | + const autocapDescription: vscode.MarkdownString = new vscode.MarkdownString() |
| 12 | + .appendText(`A Layout that arranges its children horizontally or vertically. The direction can be set by orientation property.\n`) |
| 13 | + .appendText(`\n\n{N}`) |
| 14 | + .appendMarkdown(` [Docs](https://docs.nativescript.org/ui/layouts/layout-containers)`) |
| 15 | + .appendText(` | `) |
| 16 | + .appendMarkdown(`[API Reference](https://docs.nativescript.org/api-reference/modules/_ui_layouts_stack_layout_)`); |
| 17 | + |
| 18 | + autocapDescription.isTrusted = true; |
| 19 | + |
| 20 | + return new vscode.Hover(autocapDescription); |
| 21 | + } |
| 22 | + }, |
| 23 | +}); |
| 24 | + |
| 25 | +export const GRID_LAYOUT = vscode.languages.registerHoverProvider('html', { |
| 26 | + provideHover(document, position, token) { |
| 27 | + |
| 28 | + const range = document.getWordRangeAtPosition(position); |
| 29 | + const word = document.getText(range); |
| 30 | + |
| 31 | + if (word.toLowerCase() === 'gridlayout') { |
| 32 | + |
| 33 | + const autocapDescription: vscode.MarkdownString = new vscode.MarkdownString() |
| 34 | + .appendText(`Defines a rectangular layout area that consists of columns and rows.\n`) |
| 35 | + .appendText(`\n\n{N}`) |
| 36 | + .appendMarkdown(` [Docs](https://docs.nativescript.org/ui/layouts/layout-containers)`) |
| 37 | + .appendText(` | `) |
| 38 | + .appendMarkdown(`[API Reference](https://docs.nativescript.org/api-reference/modules/_ui_layouts_grid_layout_)`); |
| 39 | + |
| 40 | + autocapDescription.isTrusted = true; |
| 41 | + |
| 42 | + return new vscode.Hover(autocapDescription); |
| 43 | + } |
| 44 | + }, |
| 45 | +}); |
| 46 | + |
| 47 | +export const ABSOLUTE_LAYOUT = vscode.languages.registerHoverProvider('html', { |
| 48 | + provideHover(document, position, token) { |
| 49 | + |
| 50 | + const range = document.getWordRangeAtPosition(position); |
| 51 | + const word = document.getText(range); |
| 52 | + |
| 53 | + if (word.toLowerCase() === 'absolutelayout') { |
| 54 | + |
| 55 | + const autocapDescription: vscode.MarkdownString = new vscode.MarkdownString() |
| 56 | + .appendText(`A layout that lets you specify exact locations (left/top coordinates) of its children.\n`) |
| 57 | + .appendText(`\n\n{N}`) |
| 58 | + .appendMarkdown(` [Docs](https://docs.nativescript.org/ui/layouts/layout-containers)`) |
| 59 | + .appendText(` | `) |
| 60 | + .appendMarkdown(`[API Reference](https://docs.nativescript.org/api-reference/modules/_ui_layouts_absolute_layout_)`); |
| 61 | + |
| 62 | + autocapDescription.isTrusted = true; |
| 63 | + |
| 64 | + return new vscode.Hover(autocapDescription); |
| 65 | + } |
| 66 | + }, |
| 67 | +}); |
| 68 | + |
| 69 | +export const DOCK_LAYOUT = vscode.languages.registerHoverProvider('html', { |
| 70 | + provideHover(document, position, token) { |
| 71 | + |
| 72 | + const range = document.getWordRangeAtPosition(position); |
| 73 | + const word = document.getText(range); |
| 74 | + |
| 75 | + if (word.toLowerCase() === 'docklayout') { |
| 76 | + |
| 77 | + const autocapDescription: vscode.MarkdownString = new vscode.MarkdownString() |
| 78 | + .appendText(`A Layout that arranges its children at its outer edges, and allows its last child to take up the remaining space.\n`) |
| 79 | + .appendText(`\n\n{N}`) |
| 80 | + .appendMarkdown(` [Docs](https://docs.nativescript.org/ui/layouts/layout-containers)`) |
| 81 | + .appendText(` | `) |
| 82 | + .appendMarkdown(`[API Reference](https://docs.nativescript.org/api-reference/modules/_ui_layouts_dock_layout_)`); |
| 83 | + |
| 84 | + autocapDescription.isTrusted = true; |
| 85 | + |
| 86 | + return new vscode.Hover(autocapDescription); |
| 87 | + } |
| 88 | + }, |
| 89 | +}); |
| 90 | + |
| 91 | +export const FLEXBOX_LAYOUT = vscode.languages.registerHoverProvider('html', { |
| 92 | + provideHover(document, position, token) { |
| 93 | + |
| 94 | + const range = document.getWordRangeAtPosition(position); |
| 95 | + const word = document.getText(range); |
| 96 | + |
| 97 | + if (word.toLowerCase() === 'flexboxlayout') { |
| 98 | + |
| 99 | + const autocapDescription: vscode.MarkdownString = new vscode.MarkdownString() |
| 100 | + .appendText(`A layout based on flexbox.\n`) |
| 101 | + .appendText(`\n\n{N}`) |
| 102 | + .appendMarkdown(` [Docs](https://docs.nativescript.org/ui/layouts/layout-containers)`) |
| 103 | + .appendText(` | `) |
| 104 | + .appendMarkdown(`[API Reference](https://docs.nativescript.org/api-reference/modules/_ui_layouts_flexbox_layout_)`); |
| 105 | + |
| 106 | + autocapDescription.isTrusted = true; |
| 107 | + |
| 108 | + return new vscode.Hover(autocapDescription); |
| 109 | + } |
| 110 | + }, |
| 111 | +}); |
| 112 | + |
| 113 | +export const WRAP_LAYOUT = vscode.languages.registerHoverProvider('html', { |
| 114 | + provideHover(document, position, token) { |
| 115 | + |
| 116 | + const range = document.getWordRangeAtPosition(position); |
| 117 | + const word = document.getText(range); |
| 118 | + |
| 119 | + if (word.toLowerCase() === 'wraplayout') { |
| 120 | + |
| 121 | + const autocapDescription: vscode.MarkdownString = new vscode.MarkdownString() |
| 122 | + .appendText(`A layout that positions children in rows or columns depending on orientation property until space is filled and then wraps them on new row or column.\n`) |
| 123 | + .appendText(`\n\n{N}`) |
| 124 | + .appendMarkdown(` [Docs](https://docs.nativescript.org/ui/layouts/layout-containers)`) |
| 125 | + .appendText(` | `) |
| 126 | + .appendMarkdown(`[API Reference](https://docs.nativescript.org/api-reference/modules/_ui_layouts_wrap_layout_)`); |
| 127 | + |
| 128 | + autocapDescription.isTrusted = true; |
| 129 | + |
| 130 | + return new vscode.Hover(autocapDescription); |
| 131 | + } |
| 132 | + }, |
| 133 | +}); |
| 134 | + |
| 135 | +export const LAYOUT_HOVER_PROVIDERS = [ |
| 136 | + STACK_LAYOUT, |
| 137 | + GRID_LAYOUT, |
| 138 | + ABSOLUTE_LAYOUT, |
| 139 | + DOCK_LAYOUT, |
| 140 | + FLEXBOX_LAYOUT, |
| 141 | + WRAP_LAYOUT, |
| 142 | +]; |
0 commit comments