import { Completion } from './Completion' import * as vscode from 'vscode' import { tc } from '../helpers/TsComplier' export class VAttrCompletion extends Completion { public completionArr: vscode.CompletionItem[] = [] public validataType: 'other' | 'comp' | 'tag' | undefined constructor() { super() this.init() } private init() { const ref = this.getCompletionItem('ref', 'ref="$2"') const attr = this.getCompletionItem('attr', 'attr:${1:name}="$2"') const bind = this.getCompletionItem('bind', 'bind') const catchs = this.getCompletionItem('catch', 'catch') const value = this.getCompletionItem('value', 'value="${1:value}"') const method = this.getCompletionItem('method', 'method') const layout = this.getCompletionItem('layout', 'layout') const props = this.getCompletionItem('props', 'props="${1:bindProps}"') this.completionArr.push(ref, attr, bind, catchs, value, method, layout, props) } public validateContext(document: vscode.TextDocument, position: vscode.Position): boolean { const res = tc.validateTagRange(document, position, '@') if (res !== undefined) { this.validataType = res.type return true } return false } protected getCompletionItem(label: string, insertText: string): vscode.CompletionItem { return { label, insertText: new vscode.SnippetString(insertText), kind: vscode.CompletionItemKind.Field, documentation: '', } } }