|
1 | 1 | import { CompletionItem, CompletionItemKind } from 'vscode-languageserver-types' |
2 | | - |
3 | | -export const ICONS = { |
4 | | - KEYWORD: CompletionItemKind.Text, |
5 | | - COLUMN: CompletionItemKind.Interface, |
6 | | - TABLE: CompletionItemKind.Field, |
7 | | - FUNCTION: CompletionItemKind.Property, |
8 | | - ALIAS: CompletionItemKind.Variable, |
9 | | - UTILITY: CompletionItemKind.Event, |
10 | | -} |
| 2 | +import { ICONS } from './CompletionItemUtils' |
11 | 3 |
|
12 | 4 | type OnClause = 'FROM' | 'ALTER TABLE' | 'OTHERS' |
13 | 5 | export class Identifier { |
@@ -44,18 +36,37 @@ export class Identifier { |
44 | 36 | toCompletionItem(): CompletionItem { |
45 | 37 | const idx = this.lastToken.lastIndexOf('.') |
46 | 38 | const label = this.identifier.substring(idx + 1) |
47 | | - let kindName: string |
48 | | - if (this.kind === ICONS.TABLE) { |
| 39 | + if ( |
| 40 | + this.kind === ICONS.TABLE || |
| 41 | + this.kind === ICONS.DATABASE || |
| 42 | + this.kind === ICONS.CATALOG |
| 43 | + ) { |
49 | 44 | let tableName = label |
50 | 45 | const i = tableName.lastIndexOf('.') |
51 | 46 | if (i > 0) { |
52 | 47 | tableName = label.substring(i + 1) |
53 | 48 | } |
54 | | - kindName = 'table' |
55 | | - } else { |
56 | | - kindName = 'column' |
57 | 49 | } |
58 | 50 |
|
| 51 | + const kindName = (() => { |
| 52 | + switch (this.kind) { |
| 53 | + case ICONS.TABLE: |
| 54 | + return 'table' |
| 55 | + case ICONS.DATABASE: |
| 56 | + return 'schema' |
| 57 | + case ICONS.CATALOG: |
| 58 | + return 'database' |
| 59 | + case ICONS.FUNCTION: |
| 60 | + return 'function' |
| 61 | + case ICONS.ALIAS: |
| 62 | + return 'table' |
| 63 | + case ICONS.COLUMN: |
| 64 | + return 'column' |
| 65 | + default: |
| 66 | + return 'column' |
| 67 | + } |
| 68 | + })() |
| 69 | + |
59 | 70 | const item: CompletionItem = { |
60 | 71 | label: label, |
61 | 72 | detail: `${kindName} ${this.detail}`, |
|
0 commit comments