本文整理汇总了TypeScript中vscode-languageserver-protocol.Disposable类的典型用法代码示例。如果您正苦于以下问题:TypeScript Disposable类的具体用法?TypeScript Disposable怎么用?TypeScript Disposable使用的例子?那么, 这里精选的类代码示例或许可以为您提供帮助。
在下文中一共展示了Disposable类的10个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的TypeScript代码示例。
示例1: watchFile
export function watchFile(filepath: string, onChange: () => void): Disposable {
let callback = debounce(onChange, 100)
try {
let watcher = fs.watch(filepath, {
persistent: true,
recursive: false,
encoding: 'utf8'
}, () => {
callback()
})
return Disposable.create(() => {
watcher.close()
})
} catch (e) {
return Disposable.create(() => {
// noop
})
}
}
示例2: register
public register(selector: DocumentSelector, provider: DefinitionProvider): Disposable {
let item: ProviderItem<DefinitionProvider> = {
id: uuid(),
selector,
provider
}
this.providers.add(item)
return Disposable.create(() => {
this.providers.delete(item)
})
}
示例3: register
public register(selector: DocumentSelector, provider: SelectionRangeProvider): Disposable {
let item = {
id: uuid(),
selector,
provider
}
this.providers.add(item)
return Disposable.create(() => {
this.providers.delete(item)
})
}
示例4: register
public register(selector: DocumentSelector, provider: CodeActionProvider, clientId: string, codeActionKinds?: CodeActionKind[]): Disposable {
let item: ProviderItem<CodeActionProvider> = {
id: uuid(),
selector,
provider,
kinds: codeActionKinds,
clientId
}
this.providers.add(item)
return Disposable.create(() => {
this.providers.delete(item)
})
}
示例5: register
public register(selector: DocumentSelector,
provider: DocumentFormattingEditProvider,
priority = 0): Disposable {
let item: ProviderItem<DocumentFormattingEditProvider> = {
id: uuid(),
selector,
priority,
provider
}
this.providers.add(item)
return Disposable.create(() => {
this.providers.delete(item)
})
}
示例6: register
public register(selector: DocumentSelector, provider: SignatureHelpProvider, triggerCharacters?: string[]): Disposable {
let characters = triggerCharacters.reduce((p, c) => {
return p.concat(c.split(/\s*/g))
}, [] as string[])
let item: ProviderItem<SignatureHelpProvider> = {
id: uuid(),
selector,
provider,
triggerCharacters: characters
}
this.providers.add(item)
return Disposable.create(() => {
this.providers.delete(item)
})
}
示例7: regist
export function regist(sourceMap: Map<string, ISource>): Disposable {
sourceMap.set('buffer', new Buffer())
return Disposable.create(() => {
sourceMap.delete('buffer')
})
}
示例8: regist
export function regist(sourceMap: Map<string, ISource>): Disposable {
sourceMap.set('file', new File())
return Disposable.create(() => {
sourceMap.delete('file')
})
}
示例9: regist
export function regist(sourceMap: Map<string, ISource>): Disposable {
sourceMap.set('around', new Around())
return Disposable.create(() => {
sourceMap.delete('around')
})
}
示例10: dispose
public dispose(): void {
this.disposable.dispose()
}