本文整理汇总了TypeScript中atom.TextBuffer类的典型用法代码示例。如果您正苦于以下问题:TypeScript TextBuffer类的具体用法?TypeScript TextBuffer怎么用?TypeScript TextBuffer使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。
在下文中一共展示了TextBuffer类的8个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于我们的系统推荐出更棒的TypeScript代码示例。
示例1: registerCompletionBuffer
/*
registerCompletionBuffer(buffer)
Every buffer that would be used with autocompletion functions has to
be registered with this function.
buffer: TextBuffer, buffer to be used in autocompletion
Returns: Disposable, which will remove buffer from autocompletion
*/
public registerCompletionBuffer(buffer: TextBuffer) {
if (!this.isActive) { throw new Error('Backend inactive') }
if (this.bufferMap.has(buffer)) {
return new Disposable(() => { /* void */ })
}
this.bufferMap.set(buffer, new BufferInfo(buffer))
const file = buffer.getUri()
buffer.onDidSave(async (_event) => {
const buf: BufferInfo | undefined = this.bufferMap.get(buffer)
if (buf) {
delete buf.completions
}
const contents: string = buffer.getText()
await this.process.backend.setFileContents(file, contents)
await this.process.backend.scanFile({ file, scanProject: false, scanDeps: false })
})
setImmediate(async () => {
this.process.backend.scanFile({ file })
})
return new Disposable(() =>
this.unregisterCompletionBuffer(buffer))
}
开发者ID:mvoidex,项目名称:atom-haskell-hsdev,代码行数:36,代码来源:index.ts
示例2: resolve
const buffer = await new Promise<TextBuffer.ITextBuffer>(resolve => {
const buffer = new Atom.TextBuffer({
filePath,
load: true,
})
buffer.onDidReload(() => {
resolve(buffer)
})
})
开发者ID:GavinJoyce,项目名称:dotfiles,代码行数:10,代码来源:atomts.ts
示例3: getCompletionsForSymbolInModule
/*
getCompletionsForSymbolInModule(buffer,prefix,position,{module})
Used in import hiding/list completions
buffer: TextBuffer, current buffer
prefix: String, completion prefix
position: Point, current cursor position
module: String, module name (optional). If undefined, function
will attempt to infer module name from position and buffer.
Returns: Promise([symbol])
symbol: Object, symbol in given module
name: String, symbol name
typeSignature: String, type signature
symbolType: String, one of ['type', 'class', 'function']
*/
public async getCompletionsForSymbolInModule(
buffer: TextBuffer, prefix: string, position: Point,
opts?: { module: string },
): Promise<CB.ISymbol[]> {
if (!this.isActive) { throw new Error('Backend inactive') }
let moduleName = opts ? opts.module : undefined
if (!moduleName) {
const lineRange = new Range([0, position.row], position)
buffer.backwardsScanInRange(
/^import\s+([\w.]+)/,
lineRange, ({ match }) => moduleName = match[1],
)
}
return [] // TODO: Implement
// tslint:enable: no-null-keyword
// return FZ.filter(symbols, prefix, { key: 'name' })
}
开发者ID:mvoidex,项目名称:atom-haskell-hsdev,代码行数:34,代码来源:index.ts
示例4: getCompletionsForModule
/*
getCompletionsForModule(buffer,prefix,position)
buffer: TextBuffer, current buffer
prefix: String, completion prefix
position: Point, current cursor position
Returns: Promise([module])
module: String, module name
*/
public async getCompletionsForModule(
buffer: TextBuffer, prefix: string, _position: Point,
): Promise<string[]> {
if (!this.isActive) { throw new Error('Backend inactive') }
const modules = await this.process.backend.scopeModules({
query: prefix,
searchType: 'prefix',
file: buffer.getUri(),
})
const parts: number = prefix.split('.').length
const names: string[] = []
for (const m of modules) {
if (m.name.split('.').length == parts) {
names.push(m.name)
}
}
return names
}
开发者ID:mvoidex,项目名称:atom-haskell-hsdev,代码行数:27,代码来源:index.ts
示例5: whoat
public async whoat(
buffer: TextBuffer, crange: Range
) {
const file = buffer.getUri()
const line = crange.start.row + 1
const column = crange.start.column + 1
const symbols: any[] = await this.backend.whoat(file, line, column)
if (symbols.length == 0) {
Util.debug(`No info found for symbol at ${file} ${line} ${column}`)
throw Error(`No info found for symbol at ${file} ${line} ${column}`)
}
else {
const sym = symbols[0]
const what = sym.info.what
const lines = []
switch (what) {
case 'function':
case 'method':
case 'constructor':
lines.push(`${sym.id.name} :: ${sym.info.type ? sym.info.type : '?'}`)
break
case 'data':
case 'type':
case 'class':
case 'newtype':
lines.push(`${what} ${sym.id.name}`)
break
default:
lines.push(`${sym.id.name}`)
}
if (sym.docs) {
lines.push('', `{- ${sym.docs} -}`)
}
if (sym.id.module.location.file && sym.pos) {
lines.push('', `-- Defined in ${sym.id.module.location.file}:${sym.pos.line}:${sym.pos.column}`)
}
return {range: crange, info: lines.join('\n')}
}
}
开发者ID:mvoidex,项目名称:atom-haskell-hsdev,代码行数:41,代码来源:index.ts
示例6: getCompletionsForBuffer
private async getCompletionsForBuffer(
buffer: TextBuffer, symbolTypes?: CB.SymbolType[],
): Promise<CB.ISymbol[]> {
let symbols: CB.ISymbol[] = []
const buf: BufferInfo | undefined = this.bufferMap.get(buffer)
if (buf && buf.completions) {
symbols = buf.completions
}
else {
const comps: any[] = await this.process.backend.complete(
'',
buffer.getUri(),
)
for (const comp of comps) {
let symType: CB.SymbolType = 'function'
switch (comp.info.what) {
case 'function':
case 'method':
case 'selector':
case 'pat-selector':
case 'pat-constructor':
case 'constructor':
symType = 'function'
break
case 'type':
case 'newtype':
case 'data':
case 'type-family':
case 'data-family':
symType = 'type'
break
case 'class':
symType = 'class'
break
default:
break
}
if (symbolTypes && !(symType in symbolTypes)) {
continue
}
symbols.push({
qparent: comp.qualifier,
qname: comp.qualifier ? `${comp.qualifier}.${comp.id.name}` : comp.id.name,
name: comp.id.name,
symbolType: symType,
typeSignature: comp.info.type,
// FIXME: Use import module
module: {
name: comp.id.module.name,
hiding: false,
qualified: false,
alias: null,
importList: null,
}
})
}
if (buf) {
Util.debug(`Caching ${symbols.length} completions for ${buffer.getUri()}`)
buf.completions = symbols
}
}
if (!symbolTypes) {
return symbols
}
const result: CB.ISymbol[] = []
for (const sym of symbols) {
if (sym.symbolType in symbolTypes) {
result.push(sym)
}
}
return result
}
开发者ID:mvoidex,项目名称:atom-haskell-hsdev,代码行数:74,代码来源:index.ts
示例7: lint
public async lint(buffer: TextBuffer) {
const file = buffer.getUri()
const messages = await this.backend.lint([file])
return this.convertMessages(messages)
}
开发者ID:mvoidex,项目名称:atom-haskell-hsdev,代码行数:5,代码来源:index.ts
示例8:
buffer.onDidSave(async (_event) => {
const buf: BufferInfo | undefined = this.bufferMap.get(buffer)
if (buf) {
delete buf.completions
}
const contents: string = buffer.getText()
await this.process.backend.setFileContents(file, contents)
await this.process.backend.scanFile({ file, scanProject: false, scanDeps: false })
})
开发者ID:mvoidex,项目名称:atom-haskell-hsdev,代码行数:9,代码来源:index.ts
注:本文中的atom.TextBuffer类示例整理自Github/MSDocs等源码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。 |
请发表评论